Click here to Skip to main content
14,739,729 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi people,

I'm trying to fix a problem with a dialog based app:

Somebody decided to show a dialog with a turning hourglass while the main dialog is initializing:

BOOL CMainDlg::OnInitDialog() {
	CDialog::OnInitDialog();
	
	<Launch thread to open hourglass dialog and control animation>
	<Do all initialization stuff>
	<Abruptly kill the thread with no remorse>
}


The problem is that when this hourglass dialog gets closed it seems to take away the taskbar icon with it. The taskbar icon dissapears, gets hidden or whatever and the user has to alt-tab to bring it to front (plus figuring out the window is there and not launching the app over and over).

I've managed to solve this to some point with that little change:

BOOL CMainDlg::OnInitDialog() {
	CDialog::OnInitDialog();
	
	<Launch thread to open hourglass dialog and control animation>
	<Do all initialization stuff>
}

...

void CMainDlg::OnShowWindow(BOOL bShow, UINT nStatus) {
	<Kindly ask the thread to stop>
}


But I still have the same problem if the user brings another window to front while the hourglass dialog is running. The taskbar icon gets lost again.

I've tried to bring the main dialog to front when it's done (with no luck). I've also tried to open de hourglass dialog somewhere else. And a bazillion useless workarounds.

Anybody faced this problem and can put me in the path?

Thanks in advance!
Posted

1 solution

Have you tried, for testing purposes, doing the initialisation after on Init Dialog, e.g. on a button press or a timer tick. I suspect the problem is to do with it being in onInitDialog.

If it works in thuis scienario , you could consider disabling the dialog in OnInitDialog, then doing your initialisation on a separate custom message which you can post from oninitdialog, then when your intialisation is done reenable the dialog
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900