Creating a SDI window from a dialog (MFC)
-
Hi there! We've got a real big problem, allthough it seems to be not really difficult: Our main application is a dialog which definitely MUST remain a dialog. My colleague wants to create a SDI window from this dialog by clicking on a specific button. Still no problem. The problem ist, that the window seems not to get the windows messages: Usually if you create a method to handle a mouseclick on a button in the toolbar, you can also create a function
OnUpdateClickXXX(CCmdUI* pCmdUI)
for example you could gray a specific button, if ButtonXXX is being clicked on. But OnUpdateClickXXX is never called! For me it seems, that the WM_PAINT message is being processed just by the dialog. the SDI window is created withCSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSDI_LeerDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CSDI_LeerView)); AfxGetApp()->AddDocTemplate(pDocTemplate); //because i am in the dialog, i have to call AfxGetApp() to register the doctemplate with the application
when you click on a button in the dialog. All OnClickBlah, OnUpdateBlah... methods are inserted by the class wizard, and the AFX_MESSAGE_MAP has the correct ON_COMMAND, ON_UPDATE_COMMAND...entries Could you give us some hints, where we could look for that problem? Sure, the problem is caused by the dialog "standing" between the application and the doc/view. Thank you all, and i hope you can help us with our problem. Sascha Billian Sascha Billian -
Hi there! We've got a real big problem, allthough it seems to be not really difficult: Our main application is a dialog which definitely MUST remain a dialog. My colleague wants to create a SDI window from this dialog by clicking on a specific button. Still no problem. The problem ist, that the window seems not to get the windows messages: Usually if you create a method to handle a mouseclick on a button in the toolbar, you can also create a function
OnUpdateClickXXX(CCmdUI* pCmdUI)
for example you could gray a specific button, if ButtonXXX is being clicked on. But OnUpdateClickXXX is never called! For me it seems, that the WM_PAINT message is being processed just by the dialog. the SDI window is created withCSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSDI_LeerDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CSDI_LeerView)); AfxGetApp()->AddDocTemplate(pDocTemplate); //because i am in the dialog, i have to call AfxGetApp() to register the doctemplate with the application
when you click on a button in the dialog. All OnClickBlah, OnUpdateBlah... methods are inserted by the class wizard, and the AFX_MESSAGE_MAP has the correct ON_COMMAND, ON_UPDATE_COMMAND...entries Could you give us some hints, where we could look for that problem? Sure, the problem is caused by the dialog "standing" between the application and the doc/view. Thank you all, and i hope you can help us with our problem. Sascha Billian Sascha BillianHuh? Does the "SDI window" ever show? You haven't shown any code that creates a window. Mark
"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")
-
Huh? Does the "SDI window" ever show? You haven't shown any code that creates a window. Mark
"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")
Yes, the window appears. I haven't the code here, because i'm at home, but the window shows as it should. but there's one thing i forgot to tell you. The problem problem occured, when we tried to gray out a button in the toolbar by clicking on another toolbar button. It didn't gray out. BUT: in the menu bar, if i try the same with the menu items which are linked with the buttons (same id), one item is grayed out when clicking the other: this is the code which is used to create the doc/view and show the window:
CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSDI_LeerDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CSDI_LeerView)); AddDocTemplate(pDocTemplate); CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if (!ProcessShellCommand(cmdInfo)) return FALSE; m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); ...
thanks! Sascha -
Yes, the window appears. I haven't the code here, because i'm at home, but the window shows as it should. but there's one thing i forgot to tell you. The problem problem occured, when we tried to gray out a button in the toolbar by clicking on another toolbar button. It didn't gray out. BUT: in the menu bar, if i try the same with the menu items which are linked with the buttons (same id), one item is grayed out when clicking the other: this is the code which is used to create the doc/view and show the window:
CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSDI_LeerDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CSDI_LeerView)); AddDocTemplate(pDocTemplate); CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if (!ProcessShellCommand(cmdInfo)) return FALSE; m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); ...
thanks! Sascha:) I'm lost. Is the probem with disalng a button or with window creation? Mark
"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")
-
Hi there! We've got a real big problem, allthough it seems to be not really difficult: Our main application is a dialog which definitely MUST remain a dialog. My colleague wants to create a SDI window from this dialog by clicking on a specific button. Still no problem. The problem ist, that the window seems not to get the windows messages: Usually if you create a method to handle a mouseclick on a button in the toolbar, you can also create a function
OnUpdateClickXXX(CCmdUI* pCmdUI)
for example you could gray a specific button, if ButtonXXX is being clicked on. But OnUpdateClickXXX is never called! For me it seems, that the WM_PAINT message is being processed just by the dialog. the SDI window is created withCSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSDI_LeerDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CSDI_LeerView)); AfxGetApp()->AddDocTemplate(pDocTemplate); //because i am in the dialog, i have to call AfxGetApp() to register the doctemplate with the application
when you click on a button in the dialog. All OnClickBlah, OnUpdateBlah... methods are inserted by the class wizard, and the AFX_MESSAGE_MAP has the correct ON_COMMAND, ON_UPDATE_COMMAND...entries Could you give us some hints, where we could look for that problem? Sure, the problem is caused by the dialog "standing" between the application and the doc/view. Thank you all, and i hope you can help us with our problem. Sascha Billian Sascha Billiansascha.billian wrote:
Sure, the problem is caused by the dialog "standing" between the application and the doc/view.
And you "know" this because you developed the document/frame/view classes in a normal SDI application where it all works as expected but when you share the source code files into your dialog based application it behaves differently... correct?
led mike
-
sascha.billian wrote:
Sure, the problem is caused by the dialog "standing" between the application and the doc/view.
And you "know" this because you developed the document/frame/view classes in a normal SDI application where it all works as expected but when you share the source code files into your dialog based application it behaves differently... correct?
led mike
correct. any clues? thanks Sascha
-
correct. any clues? thanks Sascha
sascha.billian wrote:
any clues?
My guess would be that the command routing is not initialized. Put Spy++ on your dialog and then envoke an action in your frame window and see if it shows up in the dialog messages. If it does you might be able to override OnCmdMsg in the dialog and forward the message to the frame window.
led mike
-
sascha.billian wrote:
any clues?
My guess would be that the command routing is not initialized. Put Spy++ on your dialog and then envoke an action in your frame window and see if it shows up in the dialog messages. If it does you might be able to override OnCmdMsg in the dialog and forward the message to the frame window.
led mike
Hi Mike, That sounds like a good idea. As soon as my colleague is at the office we'll try that. Thanks so far. Sascha