NEWBIE: how to iniate dialog after application window is shown?
-
I'm using MSVC++6, and I have a normal Doc/view application. I have an item in the File menu, which iniates a dialog. How can I initiate the dialog automatically when the application is started, _after_ the application window is fully visible? I have placed a call to the function in more places than I want to think about, and I always get the dialog _before_ the application window is drawn. I'm just so tired of that, so tired... ;P
-
I'm using MSVC++6, and I have a normal Doc/view application. I have an item in the File menu, which iniates a dialog. How can I initiate the dialog automatically when the application is started, _after_ the application window is fully visible? I have placed a call to the function in more places than I want to think about, and I always get the dialog _before_ the application window is drawn. I'm just so tired of that, so tired... ;P
Try to add the dialog call in the
InitInstance()
function of your application before you return the function.BOOL CTestApp::InitInstance()
{
...
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
...
CMyDialog dlg;
dlg.DoModal();return TRUE;
}Daniel ;) --------------------------- Never change a running system!
-
Try to add the dialog call in the
InitInstance()
function of your application before you return the function.BOOL CTestApp::InitInstance()
{
...
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
...
CMyDialog dlg;
dlg.DoModal();return TRUE;
}Daniel ;) --------------------------- Never change a running system!
The function is in CView derived class. How could I get a pointer there so I won't have to rewrite the code in InitInstance? (Explanation: The OnFileSelectserver() function is in CView derived class, and it has calls to CDocument derived class. Now it would need to be called from CWinApp based class.)
-
The function is in CView derived class. How could I get a pointer there so I won't have to rewrite the code in InitInstance? (Explanation: The OnFileSelectserver() function is in CView derived class, and it has calls to CDocument derived class. Now it would need to be called from CWinApp based class.)
What kind of pointer do you have in CView derived class? I thought you want do display a dialog after showing the application ... is that right? Daniel ;) --------------------------- Never change a running system!
-
The function is in CView derived class. How could I get a pointer there so I won't have to rewrite the code in InitInstance? (Explanation: The OnFileSelectserver() function is in CView derived class, and it has calls to CDocument derived class. Now it would need to be called from CWinApp based class.)
If you want to fire you dialog right after the application starts, that is before a document has been opened, you will have to do it as was posted. But if you want your dialog to open after a document had been loaded and its view had been created, you could use your views
OnInitialUpdate()
message handler. A pointer to the active (SDI-)view can be obtained usingCFrameWnd::GetActiveView()
. (For MDI, there is a possibility shown in that MSDN entry). -- "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert Kaminski -
What kind of pointer do you have in CView derived class? I thought you want do display a dialog after showing the application ... is that right? Daniel ;) --------------------------- Never change a running system!
Yes, I want to show a dialog *after* showing the application window. All solutions I have tried will show the dialog before painting the application window. Err.. I am not sure what you mean with "what kind of pointer do you have in CView derived class". The only flaw in my application (that I know of ;) ) is that the dialog should be iniated automatically instead of having to iniate it from menu. The menu item is handled in CView derived class (CMyView), in OnFileSelectserver() function. That function has calls to CDocument derived class (CMyDocument). So I need to be able to call CMyView::OnFileSelectserver() from inside CWinApp based class (CMyApp), in InitInstance(). How to do that? Putting the CMyView::OnFileSelectserver() in CMyView::OnInitialUpdate() causes the dialog to be shown first, then a pause as the program gathers data and only after that the application is shown. Doing that skips the progress bar and gives the impression that nothing is happening. That's the problem. First application window, THEN dialog.
-
Yes, I want to show a dialog *after* showing the application window. All solutions I have tried will show the dialog before painting the application window. Err.. I am not sure what you mean with "what kind of pointer do you have in CView derived class". The only flaw in my application (that I know of ;) ) is that the dialog should be iniated automatically instead of having to iniate it from menu. The menu item is handled in CView derived class (CMyView), in OnFileSelectserver() function. That function has calls to CDocument derived class (CMyDocument). So I need to be able to call CMyView::OnFileSelectserver() from inside CWinApp based class (CMyApp), in InitInstance(). How to do that? Putting the CMyView::OnFileSelectserver() in CMyView::OnInitialUpdate() causes the dialog to be shown first, then a pause as the program gathers data and only after that the application is shown. Doing that skips the progress bar and gives the impression that nothing is happening. That's the problem. First application window, THEN dialog.
Add the following code lines in your
InitInstance
function of your application:...
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
**CYourView* pView = (CYourView*) ((CFrameWnd*) m_pMainWnd)->GetActiveView();pView->SendMessage(WM_COMMAND, ID_for_your_OnFileSelectserver_menu_item, 0);**
return TRUE;Insert the right ID for the ID_for_your_OnFileSelectserver_menu_item in the
SendMessage
function. I hope this helps you! :-D Daniel ;) --------------------------- Never change a running system! -
Add the following code lines in your
InitInstance
function of your application:...
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
**CYourView* pView = (CYourView*) ((CFrameWnd*) m_pMainWnd)->GetActiveView();pView->SendMessage(WM_COMMAND, ID_for_your_OnFileSelectserver_menu_item, 0);**
return TRUE;Insert the right ID for the ID_for_your_OnFileSelectserver_menu_item in the
SendMessage
function. I hope this helps you! :-D Daniel ;) --------------------------- Never change a running system! -
Add the following code lines in your
InitInstance
function of your application:...
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
**CYourView* pView = (CYourView*) ((CFrameWnd*) m_pMainWnd)->GetActiveView();pView->SendMessage(WM_COMMAND, ID_for_your_OnFileSelectserver_menu_item, 0);**
return TRUE;Insert the right ID for the ID_for_your_OnFileSelectserver_menu_item in the
SendMessage
function. I hope this helps you! :-D Daniel ;) --------------------------- Never change a running system! -
Fine! :) ;) Nice greets from Tyrol / Austria, Daniel. Daniel ;) --------------------------- Never change a running system!