Solved

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

Posted on 1998-09-16
1
216 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:nielsew
1 Comment
 
LVL 2

Accepted Solution

by:
jstolan earned 100 total points
ID: 1322181
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 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