Solved

SetRgn

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now