Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SetRgn

Posted on 2001-08-09
4
Medium Priority
?
262 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 200 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

705 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