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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. document view and dialog

document view and dialog

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
11 Posts 2 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
    saisp
    wrote on last edited by
    #1

    can we use document view in dialog based application. how to do this?

    D 1 Reply Last reply
    0
    • S saisp

      can we use document view in dialog based application. how to do this?

      D Offline
      D Offline
      DevMentor org
      wrote on last edited by
      #2

      just create a doc view app and derive the view from a CFormView class and viola, you got a doc/view dialog based app... you will however have to confine the size of the dialog or do you own resizing of controls and what nots! Why do you want a doc view anyways? I mean there are other ways to separate data and drawing code handling, etc

      Yours Truly, The One and Only! Software Developer Toronto, Ontario Canada

      S 1 Reply Last reply
      0
      • D DevMentor org

        just create a doc view app and derive the view from a CFormView class and viola, you got a doc/view dialog based app... you will however have to confine the size of the dialog or do you own resizing of controls and what nots! Why do you want a doc view anyways? I mean there are other ways to separate data and drawing code handling, etc

        Yours Truly, The One and Only! Software Developer Toronto, Ontario Canada

        S Offline
        S Offline
        saisp
        wrote on last edited by
        #3

        actually i have to show windows explorer style window while clicking a button in mfc dialog application. i dont know how to create a windows explorer style mfc program in dialog. pls help me

        D 1 Reply Last reply
        0
        • S saisp

          actually i have to show windows explorer style window while clicking a button in mfc dialog application. i dont know how to create a windows explorer style mfc program in dialog. pls help me

          D Offline
          D Offline
          DevMentor org
          wrote on last edited by
          #4

          why don't you just create a browser style mfc app using the wizard, and inside the OnInitialUpdate create an instance of your dialog box which can be created as a modeless dialog box so you can pass data and message between your doc/view app and the dialog as focus is moved between the two windows. make sure to make only your dialog box visible and your dov/view app invisible initially. when the user clicks on the boutton in your dialog box, like magic you make your doc/view browser style window visible and set focus to the view... if you want to hide the dialog box you can, otherwise leave it open based on your requirements. that's the quick and dirty way to do what you want :-D GL

          Yours Truly, The One and Only!

          S 1 Reply Last reply
          0
          • D DevMentor org

            why don't you just create a browser style mfc app using the wizard, and inside the OnInitialUpdate create an instance of your dialog box which can be created as a modeless dialog box so you can pass data and message between your doc/view app and the dialog as focus is moved between the two windows. make sure to make only your dialog box visible and your dov/view app invisible initially. when the user clicks on the boutton in your dialog box, like magic you make your doc/view browser style window visible and set focus to the view... if you want to hide the dialog box you can, otherwise leave it open based on your requirements. that's the quick and dirty way to do what you want :-D GL

            Yours Truly, The One and Only!

            S Offline
            S Offline
            saisp
            wrote on last edited by
            #5

            I am not sure of how to do this, since normally all window creation is done via InitInstance. But since I have a dialog based app as the "main window" so to speak, I am not sure how to proceed. Do I need to create a new CWinApp derived class, or what ?I have a dialog, that contains a button. When the user clicks this button, I need to create a new frame window, with a splitter pane splitting the main window into two. The dialog invoking this new window should know if the window is closed.

            D 1 Reply Last reply
            0
            • S saisp

              I am not sure of how to do this, since normally all window creation is done via InitInstance. But since I have a dialog based app as the "main window" so to speak, I am not sure how to proceed. Do I need to create a new CWinApp derived class, or what ?I have a dialog, that contains a button. When the user clicks this button, I need to create a new frame window, with a splitter pane splitting the main window into two. The dialog invoking this new window should know if the window is closed.

              D Offline
              D Offline
              DevMentor org
              wrote on last edited by
              #6

              It going to take some work, but for a splitter window you're going to have to create an instance of the CSplitterWnd, you can pass a window pointer from your dialog box to the splitter window after you create it from the dialog box and use that as a way to communicate events or pass data, or create custom window message and use that between the window to send messages... there are so many ways to do this, find the easiest one that works for you. In your dialog box add a method that will create the new window and initialize it. Save it to a member pointer variable of type CWnd* use type casting were required to get the actual splitter window, or just declare a pointer to the final window you will be working with. Check for this pointer to be null before creating the window, then you will need to use CWnd::GetSafeHwnd API to make sure there is actually a window attached to the window pointer! You don't want to keep creating a window if one already exist, if one exist you simply want to set the focus to it when the User clicks on the dialog button again. Make sure the destroy the window and free the pointer when you're done with it....while t he app is running you can simple show and hide the window to save you from creating and deleting a window and losing data then needs to be persistent. You can start off by looking in the MFC section of this site on splitter windows, also you should create a simple mfc test app with a splitter window and understand how the wizard is generating the view and do the same thing or simply grab the class after tweaking it in the test app and plop it into your dialog app project and create an instance of it yourself. IF you know how to create a modeless dialog box then you have all the know how of creating a simple window my friend, same concept. That's all the help i can give you, I am not going to provide any code, you will just have to do you due diligence with the particulars!:-D

              Yours Truly, The One and Only!

              D S 2 Replies Last reply
              0
              • D DevMentor org

                It going to take some work, but for a splitter window you're going to have to create an instance of the CSplitterWnd, you can pass a window pointer from your dialog box to the splitter window after you create it from the dialog box and use that as a way to communicate events or pass data, or create custom window message and use that between the window to send messages... there are so many ways to do this, find the easiest one that works for you. In your dialog box add a method that will create the new window and initialize it. Save it to a member pointer variable of type CWnd* use type casting were required to get the actual splitter window, or just declare a pointer to the final window you will be working with. Check for this pointer to be null before creating the window, then you will need to use CWnd::GetSafeHwnd API to make sure there is actually a window attached to the window pointer! You don't want to keep creating a window if one already exist, if one exist you simply want to set the focus to it when the User clicks on the dialog button again. Make sure the destroy the window and free the pointer when you're done with it....while t he app is running you can simple show and hide the window to save you from creating and deleting a window and losing data then needs to be persistent. You can start off by looking in the MFC section of this site on splitter windows, also you should create a simple mfc test app with a splitter window and understand how the wizard is generating the view and do the same thing or simply grab the class after tweaking it in the test app and plop it into your dialog app project and create an instance of it yourself. IF you know how to create a modeless dialog box then you have all the know how of creating a simple window my friend, same concept. That's all the help i can give you, I am not going to provide any code, you will just have to do you due diligence with the particulars!:-D

                Yours Truly, The One and Only!

                D Offline
                D Offline
                DevMentor org
                wrote on last edited by
                #7

                FYI: There is a splitter tutorial in the MFC section for beginners that you will find helpful! I would provide you the link but I want to teach you how to be resourceful for yourself and get to know how to use this wonderful site ;P

                Yours Truly, The One and Only!

                1 Reply Last reply
                0
                • D DevMentor org

                  It going to take some work, but for a splitter window you're going to have to create an instance of the CSplitterWnd, you can pass a window pointer from your dialog box to the splitter window after you create it from the dialog box and use that as a way to communicate events or pass data, or create custom window message and use that between the window to send messages... there are so many ways to do this, find the easiest one that works for you. In your dialog box add a method that will create the new window and initialize it. Save it to a member pointer variable of type CWnd* use type casting were required to get the actual splitter window, or just declare a pointer to the final window you will be working with. Check for this pointer to be null before creating the window, then you will need to use CWnd::GetSafeHwnd API to make sure there is actually a window attached to the window pointer! You don't want to keep creating a window if one already exist, if one exist you simply want to set the focus to it when the User clicks on the dialog button again. Make sure the destroy the window and free the pointer when you're done with it....while t he app is running you can simple show and hide the window to save you from creating and deleting a window and losing data then needs to be persistent. You can start off by looking in the MFC section of this site on splitter windows, also you should create a simple mfc test app with a splitter window and understand how the wizard is generating the view and do the same thing or simply grab the class after tweaking it in the test app and plop it into your dialog app project and create an instance of it yourself. IF you know how to create a modeless dialog box then you have all the know how of creating a simple window my friend, same concept. That's all the help i can give you, I am not going to provide any code, you will just have to do you due diligence with the particulars!:-D

                  Yours Truly, The One and Only!

                  S Offline
                  S Offline
                  saisp
                  wrote on last edited by
                  #8

                  i got u. but how to create a window on clicking a button. i worked in dialog application only. i dont know about windows and documents. pls guide me.

                  D 1 Reply Last reply
                  0
                  • S saisp

                    i got u. but how to create a window on clicking a button. i worked in dialog application only. i dont know about windows and documents. pls guide me.

                    D Offline
                    D Offline
                    DevMentor org
                    wrote on last edited by
                    #9

                    did you read the article i told you about? did you build a test app like I told you to and look at the generated source!!! if not do this first here is an idea,

                    // header file your window definition
                    class MyWindow : public CFrameWnd
                    {
                    CWnd* m_pParent;

                    public:
                    MyWindow( CWnd* pParent ) : m_pParent( pParent )
                    {
                    Create( 0, _T("Hello Window!!!") );
                    }
                    };

                    // your dialog source file button click handler
                    void CPopupDlg::OnBnClickedButton1()
                    {
                    if( m_pMyWindow == 0 ) {
                    m_pMyWindow = new MyWindow( this );
                    }

                    if( m_pMyWindow->GetSafeHwnd() != 0 )
                    {
                    m_pMyWindow->ShowWindow( SW_SHOW );
                    m_pMyWindow->UpdateWindow();
                    }
                    }

                    GL

                    Yours Truly, The One and Only!

                    S 1 Reply Last reply
                    0
                    • D DevMentor org

                      did you read the article i told you about? did you build a test app like I told you to and look at the generated source!!! if not do this first here is an idea,

                      // header file your window definition
                      class MyWindow : public CFrameWnd
                      {
                      CWnd* m_pParent;

                      public:
                      MyWindow( CWnd* pParent ) : m_pParent( pParent )
                      {
                      Create( 0, _T("Hello Window!!!") );
                      }
                      };

                      // your dialog source file button click handler
                      void CPopupDlg::OnBnClickedButton1()
                      {
                      if( m_pMyWindow == 0 ) {
                      m_pMyWindow = new MyWindow( this );
                      }

                      if( m_pMyWindow->GetSafeHwnd() != 0 )
                      {
                      m_pMyWindow->ShowWindow( SW_SHOW );
                      m_pMyWindow->UpdateWindow();
                      }
                      }

                      GL

                      Yours Truly, The One and Only!

                      S Offline
                      S Offline
                      saisp
                      wrote on last edited by
                      #10

                      yes i got the window thank you very much. i will try for the explorer style. is there any link for this.

                      D 1 Reply Last reply
                      0
                      • S saisp

                        yes i got the window thank you very much. i will try for the explorer style. is there any link for this.

                        D Offline
                        D Offline
                        DevMentor org
                        wrote on last edited by
                        #11

                        i am glad you got something working :) unfortunately i don't know of any resource you can look at for your explorer style window, you could try a search for it in this site or google it, or like i said create a test mfc app with the app wizard, pick mfc app and then in the wizard window under the "application type" select "window explorer" for project style and then just look at the view class and how it gets created...don't be scared to dig in, roll in the mud and get dirty like a pig!!! :laugh: but here is the link to the splitter window section for you to browse around and find what you're looking for http://www.codeproject.com/splitter/

                        Yours Truly, The One and Only!

                        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