Solved

SetRgn

Posted on 2001-08-09
4
252 Views
Last Modified: 2013-12-03
Hi,, I have a Button, i wanna set the SetRectRgn for that button.

How is that done, I DONT wanna make a new Rgn for and then set the Buttons Rgn to the new Rgn. What I wanna do is obtain a pointer to the region already initialized for the button and modify that rgn, with SetRectRgn!!

Why ?, I don't wanna make a new rgn because it takes memory. Modifying an region that's already initialized is that not an option ?

How is it done ?
0
Comment
Question by:win32
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
MichaelS earned 50 total points
ID: 6367312
Strange wish (I mean memory issue) but any way I think in some cases you don't have any other chose, only create a new rgn. For example from beginning, till you set any region to window it has no region at all.

In any cases you can call GetWindowRgn() and if return value is NULLREGION than window has no region, otherwise you can use CombineRgn or what ever.

BUT, even if you use GetWindowRgn take a look at samle from MSDN how to use it:

HRGN hrgn = CreateRectRgn(0,0,0,0);
int regionType = GetWindowRgn(hwnd, hrgn);
if (regionType != ERROR)
{
/* hrgn contains window region */
}
DeleteObject(hrgn); /* finished with region */

So in any cases first of all you have to create a region :(
0
 

Author Comment

by:win32
ID: 6367607
I want to set the Rgn to another Rect, can I do the DeleteObject, the help file sayes that if you've used the SetWindowRgn(rgn, true), rgn can't be deleted because it is used !
0
 
LVL 6

Expert Comment

by:MichaelS
ID: 6367696
>if you've used the SetWindowRgn(rgn, true), rgn can't be deleted because it is used !

yes, it's true, but when you call SetWindowRgn() system deleted automaticly previous region:

from MSDN
In particular, do not delete this region handle. The system deletes the region handle when it no longer needed
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6369131
MichaelS is absolutely right:

You want to define the region of your button. There can be 2 situations:

(1) The button had no region before. In that case you MUST create a new region. It's crystal clear.
(2) The button had a region before. In the moment where you call SetWindowRgn, the old region is automatically destroyed by Windows, so you don't lose any memory or resources.

So you see, Windows does it already as resource/memory friendly as possible. No need to do any pointer tricks.

Regards, Madshi.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question