Solved

Create vs DoModal for CDialog w/ controls created on the fly

Posted on 1997-06-05
1
916 Views
Last Modified: 2013-11-20
I have a situation where I create a window with a number of buttons on it. The number and label of these buttons are unknown at dialog creation time. What I do now is Create() the dialog window and call ShowWindow() once everthing has been created. On cancel and okay the dialog window is destroyed (I tried using hide if okay was clicked and the program crashed. I'm ignoring htis point right now because I haven't gone back through and tried it again no that the program is stable. Point is I did try the hide/show method). This functions just fine, however, I'm not sure what this is doing to memory. What I'm wondering is if there is a way to create a window with DoModal and create child controls before the dialog is shown.

THanks

ps. I'm using MFC DevStudio Visual C++ version 5.0
0
Comment
Question by:winkle
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1301990
Yes. Derive your own dialog class from CDialog and override OnInitDialog or OnCreate to create the controls. There is another method that is complicated. You can create the dialog template in memory to do so. Please see the Win32 SDK documentation for detailed information and sample code: Win32 SDK/Win32 Programmer's Reference/Overviews/Window Management/Dialog Boxes.

But, in your case, it is easier and simpler to create a window instead of a dialog box.

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 61
Process filename extension 3 184
Use of condition with 'serial' in ansible 2 58
x-bar in Google Sheets 2 52
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

786 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