?
Solved

Region Handles and GetWindowRgn

Posted on 2003-03-16
4
Medium Priority
?
574 Views
Last Modified: 2010-10-05
I recently started exploring the use of regions to skin my program but I am having a terrible experience with them.  My current problem is concerning GetWindowRgn which always returns ERROR no matter what.  I don't quite understand the following quote from MSDN:

"After a successful call to SetWindowRgn, the system owns the region specified by the region handle hRgn. The system does not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do not close this region handle."

and the relationship it might have with my problem.  Does this mean that as soon as you call SetWindowRgn the region handle is no longer valid and cannot be used anywhere else in the program yet not be deleted?

Using a fresh region handle as such:

HRGN hRgn;
GetWindowRgn(hwnd, hRgn);

always returns ERROR even though hwnd has been assigned a region previously in the program successfuly.
Calling GetLastError() gives me a value of 6 (ERROR_INVALID_HANDLE)

What could be the cause of this return value constantly and what are its workarounds?

0
Comment
Question by:georgiek50
[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
  • 2
4 Comments
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8149700
an error will be returned if the window doesn't have a region. did you set one with SetWindowRgn?
0
 
LVL 1

Author Comment

by:georgiek50
ID: 8150881
Yes, I have set a region for the button and I figured out the solution.  MSDN conveniently forgot to mention in their documentation that GetWindowRgn will not work unless the HRGN receiving the copy of the region already has a region of its own eg. CreateRectRgn and assignining it to the new region handle BEFORE you call GetWindowRgn?  This I can not explain, it's backwards logic to me.
0
 
LVL 6

Accepted Solution

by:
PlanetCpp earned 225 total points
ID: 8151521
it needs a null region, one made with 0,0,0,0,
you also can't use combinergn with an empty region handle, you have to create one first also.
0
 
LVL 1

Author Comment

by:georgiek50
ID: 8152107
Yes, I realized that last night, I just don't know why it wasn't mentioned anywhere in MSDN leading to the loss of 15 hours from my day...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Six Sigma Control Plans

752 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