• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

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?
0
RodneyYeo
Asked:
RodneyYeo
  • 4
  • 3
  • 2
  • +2
1 Solution
 
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
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
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
 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now