How can I find the size of a dialog before it is displayed?

From the .rc file I have the following:

IDD_DIALOG4 DIALOG DISCARDABLE  0, 0, 186, 95

How can I get access to the numbers 186 and 95 before the
dialog gets displayed?

Here is what I would like to do:

m_myDlg = new MyDlg;
m_myDlg->Create(IDD_DIALOG4, this);

SomeHowGetMyDlgSize(  )  //get the number 186  95
.
.
.

Thanks,
-Eric
nielsewAsked:
Who is Participating?
 
jstolanConnect With a Mentor Commented:
The steps are as follows

1.  Use FindResourceEx to get a handle to the dialog resource

2.  Use LoadResource to load the resultant location into memory

3.  Use LockResource to get a pointer to the resource

The pointer will point to a dialog template structure as defined below.  Control items will follow but you don't care about them.  The cx and xy parameters are the ones you want.

typedef struct {    
DWORD style;    
DWORD dwExtendedStyle;
WORD  cdit;    
short x;    
short y;    
short cx;    
short cy;
} DLGTEMPLATE;

4.  It is not necessary to unlock or free this memory (at least according to the docs).  Careful, if you specifed the extended dialog box format the structure will be different from that described above.  Note that you can get this information at anytime, you don't even need to create the dialog box.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.