CWnd::GetWindowRgn()

I've tried using the above method but i can't seems to get the value for HRGN and the return value is always ERROR(that is 0). Any clue?
RodneyYeoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

Yes, I am also facing the same problem. So I will be interested in the answer. But What I am thinking to do is,

Use CWnd::GetClientRect() then using that rectangle
CRgn::CreateRectRgn()

So that I will have the Rgn in CRgn object.

Thanks,
0
MichaelSCommented:
Try to use SetWindowRgn and after that GetWindowRgn.
0
RodneyYeoAuthor Commented:
But what's the point of having that method under window? if in the end, I still have to do what VinExpert has suggested. Anyway, thanks for your suggestion MichaelS.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

MichaelSCommented:
In this way we can test your code. For sure will be more easy to see it directly here.
0
RodneyYeoAuthor Commented:
Actually I'm thinking about the reason Microsoft have for putting that method in. Look kinda silly setting and getting the value back again. I'm very sure there must be a specific purpose for this method :)
0
MichaelSCommented:
Didn't catch your last comment, sorry.
0
ZoppoCommented:
Hi RodneyYeo,

I think it's a kind of a feature, by default a window has no region set, so the whole window will be drawn. If one's setting a window region for that window, only the parts of the window inside the region will be drawn. If you set the window's region to NULL again, the whole window will be drawn again. I think it's the best way to implement such a feature instead of having a region for each window by default which needs to be updated each time the window's size changes.

Regions are windows resources, so why waste them without any affect?

ZOPPO

ZOPPO
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZoppoCommented:
sorry, wanted to post it as a comment and with only one signature, sorry...
0
chensuCommented:
You have to create a region and pass the HRGN of that region to CWnd::GetWindowRgn. You can't pass an invalid HRGN to it.
0
RodneyYeoAuthor Commented:
Thanks for your information. I got the picture.
0
RodneyYeoAuthor Commented:
and thanks for all those who have help in one way or another :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.