This topic is now archived and is closed to further replies.


Idle in a Dialog Box? [MFC]

Recommended Posts

For my current project I need to create a loading dialog. Thing is I need to create a dialog that will display.. then have a function called... then quit.. I find out how to do this.. Anyone have any ideas?

Share this post

Link to post
Share on other sites
You just create a dialog resource, wap ctrl-w make a new dialog class, and include the header file in your main app. Add the function you want to the new dialog class.

The trick is you need to creat a "modeless" dialog, and instead of calling .DoModal you just call .Show(SW_SHOW) and then the main program will launch. Once that happens you whack the dialog.

Magmai Kai Holmlor
- Not For Rent

Share this post

Link to post
Share on other sites
Did you create your dialog before calling Show()? if IsWindow fails, it oftn means the object either was never created or has gone out of scope.

Actually, backing up to your first post, you want to create a "Loading..." dialog box, no? You want it to quit after the function returns, right? Perhaps the dialog is being destroyed before the function ends (depends on how you call the function - inside the dialog?), and your reference to the dialog object after that is to an invalid object. Try this:
class CLoadingDlg : public CDialog()
void CallFuction( void * ); // uses function pointer to call actual function

void LoadData( void );
CLoadingDlg dlg;
dlg.Show(SW_SHOW); // inherit CDialog functionality

dlg.CallFuntion( LoadData );
dlg.Show(SW_HIDE); // SW_? can't remember

// now either allow dlg to go out of scope or explicitly call destructor

Hope it helps.

Edited by - Oluseyi on July 24, 2001 2:34:36 PM

Share this post

Link to post
Share on other sites