Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access dialog items between ctor and DoModal

Status
Not open for further replies.

Sen7inel

IS-IT--Management
Feb 14, 2001
90
FI
I want to create a resource-based dialog, and before displaying it with DoModal, get a pointer to a dialog item. If I do..

CDialog d(ID_RS);
blabla = ..d.GetDlgItem(ID_RS2);
d.DoModal();

.. the program crashes at GetDlgItem. It seems the the resource isn't actually loaded until DoModal.. How can I initialize the dialog completely before displaying it modally?
 
It is true - before you call DoModal the ressources are not loaded. You can do any changes (e.g. SetText) with variables.
 
A dialog resource is just a template. It describes how big to make the dialog, what window styles to apply, the number and types of controls in the dialog, and their attributes. The dialog and its control windows are not actually created until DoModal is called.

A good way to initialize the dialog is to override the OnInitDialog method and do the initialization there. This is called just once, right after the dialog and its control windows are created, but just before they are actually displayed on the screen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top