Solved

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

Posted on 1998-09-16
1
198 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now