tags:

views:

116

answers:

2

How can I obtain the Window Rect of a CDialog which is based on a dialog template. The dialog is not and can not be visible

+1  A: 

It might be tricky with CDialog, because if you dont show the CDialog, the window handle is not created and you cant call GetClientRect.

Might i suggest calling CreateDialogIndirect instead to create the dialog, then you can get the client rect. You dont need to show the dialog. I think as long as the window handle is created, the GetClientRect should work. I am not an expert though and its been many years since i have written MFC code.

Andrew Keith
A: 

Well...

In Windows API-land, you could load the resource yourself (FindResourceEx, LoadResource), understand the binary structure of the dialog template resource (some clues at http://blogs.msdn.com/oldnewthing/archive/2004/06/22/162360.aspx), convert the size of the dialog in the dialog template from dialog units to pixels (check out http://msdn.microsoft.com/en-us/library/ms645475(VS.85).aspx).

I'd be curious why you'd want to do this, though.

Ron Pihlgren