Solved

SetRgn

Posted on 2001-08-09
4
246 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
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is UAC Virtualization in the Process (TASK) Manager? 4 2,848
Problem to packaging 1 98
Problem to open text file 11 128
Need a simple RegEx to search for two words 27 42
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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