Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Creating a SDI window from a dialog (MFC)

Creating a SDI window from a dialog (MFC)

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++tutorialquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sascha billian
    wrote on last edited by
    #1

    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 with CSingleDocTemplate* 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

    M L 2 Replies Last reply
    0
    • S 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 with CSingleDocTemplate* 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

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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")

      S 1 Reply Last reply
      0
      • M Mark Salsbery

        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")

        S Offline
        S Offline
        sascha billian
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • S sascha billian

          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

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          :) 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")

          1 Reply Last reply
          0
          • S 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 with CSingleDocTemplate* 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

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            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

            S 1 Reply Last reply
            0
            • L 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

              S Offline
              S Offline
              sascha billian
              wrote on last edited by
              #6

              correct. any clues? thanks Sascha

              L 1 Reply Last reply
              0
              • S sascha billian

                correct. any clues? thanks Sascha

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                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

                S 1 Reply Last reply
                0
                • L 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

                  S Offline
                  S Offline
                  sascha billian
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups