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. InitDialog in splitter

InitDialog in splitter

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsgame-devhelptutorialquestion
11 Posts 4 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.
  • U User 12249262

    With MFCm I am trying to create an OpenGL control on a split form the uses the splitter class to create the panes. My problem is I don't know where to put the OnInitDialog() function or how to wire it up. I have a main form CMainFrame and 2 child forms CFormRight and CFormLeft but don't see any place for the OnInitDialog function. The OnCreateClient function in MainForm calls m_splitter.CreateView but not OnInitDialog. Any Suggestions? John C

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    What does OnInitDialog have to do with this, where is the dialog in the above application?

    1 Reply Last reply
    0
    • U User 12249262

      With MFCm I am trying to create an OpenGL control on a split form the uses the splitter class to create the panes. My problem is I don't know where to put the OnInitDialog() function or how to wire it up. I have a main form CMainFrame and 2 child forms CFormRight and CFormLeft but don't see any place for the OnInitDialog function. The OnCreateClient function in MainForm calls m_splitter.CreateView but not OnInitDialog. Any Suggestions? John C

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #3

      You seem to need the OnInitialUpdate overrides for your left and right CView derived classes.

      U 1 Reply Last reply
      0
      • V Victor Nijegorodov

        You seem to need the OnInitialUpdate overrides for your left and right CView derived classes.

        U Offline
        U Offline
        User 12249262
        wrote on last edited by
        #4

        Victor, Thanks so much but I still don't know what to do. my CForm right and CFormLeft (where I want to put the OpenGL window) inherit from CFormView. Where do put the over ride? I have CMainForm : public CFrameWnd, and COpenGL: public CWnd. The OnCreateClient() function in CmainForm creates the splitter

        BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
        {
        // TODO: Add your specialized code here and/or call the base class

        // create splitter window
        if (!m\_wndSplitter.CreateStatic(this, 1, 2)){
        	return FALSE;
        }
        
        if (!m\_wndSplitter.CreateView(0, 0, RUNTIME\_CLASS(CFormLeft), CSize(300, 100), pContext) ||
        	!m\_wndSplitter.CreateView(0, 1, RUNTIME\_CLASS(CFormRight), CSize(100, 100), pContext))
        {
        	m\_wndSplitter.DestroyWindow();
        	return FALSE;
        }
        

        Thanks. John

        L 1 Reply Last reply
        0
        • U User 12249262

          Victor, Thanks so much but I still don't know what to do. my CForm right and CFormLeft (where I want to put the OpenGL window) inherit from CFormView. Where do put the over ride? I have CMainForm : public CFrameWnd, and COpenGL: public CWnd. The OnCreateClient() function in CmainForm creates the splitter

          BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
          {
          // TODO: Add your specialized code here and/or call the base class

          // create splitter window
          if (!m\_wndSplitter.CreateStatic(this, 1, 2)){
          	return FALSE;
          }
          
          if (!m\_wndSplitter.CreateView(0, 0, RUNTIME\_CLASS(CFormLeft), CSize(300, 100), pContext) ||
          	!m\_wndSplitter.CreateView(0, 1, RUNTIME\_CLASS(CFormRight), CSize(100, 100), pContext))
          {
          	m\_wndSplitter.DestroyWindow();
          	return FALSE;
          }
          

          Thanks. John

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          See my previous response. Where is the dialog?

          U 1 Reply Last reply
          0
          • L Lost User

            See my previous response. Where is the dialog?

            U Offline
            U Offline
            User 12249262
            wrote on last edited by
            #6

            Richard, The function that I am trying to get to execute is COpenGLControl::oglInitialize() which was called in OnInitDialog in the example template I am following. the oglInitialize function, listed below should setup the OpenGL context. But my case is somewhat different as you can see from my most recent post and I don't know where to place the call to oglInitalize()

            void COpenGLControl::oglInitialize()
            {
            // Initial Setup:
            //
            static PIXELFORMATDESCRIPTOR pfd =
            {
            sizeof(PIXELFORMATDESCRIPTOR),
            1,
            PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
            PFD_TYPE_RGBA,
            32, // bit depth
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            16, // z-buffer depth
            0, 0, 0, 0, 0, 0, 0,
            };

            // Get device context only once.
            hdc = GetDC()->m\_hDC;
            
            // Pixel format.
            m\_nPixelFormat = ChoosePixelFormat(hdc, &pfd);
            SetPixelFormat(hdc, m\_nPixelFormat, &pfd);
            
            // Create the OpenGL Rendering Context.
            hrc = wglCreateContext(hdc);
            wglMakeCurrent(hdc, hrc);
            
            // Basic Setup:
            //
            // Set color to use when clearing the background.
            glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            glClearDepth(1.0f);
            
            // Turn on backface culling
            glFrontFace(GL\_CCW);
            glCullFace(GL\_BACK);
            
            // Turn on depth testing
            glEnable(GL\_DEPTH\_TEST);
            glDepthFunc(GL\_LEQUAL);
            
            // Send draw request
            OnDraw(NULL);
            

            }

            In that example template I have three classes CMFCOpenGLDlg : public CDialogEx COpenGLControl : public CWnd and CMFCOpenGLApp : public CWinApp in this example the CMFCOpenGLDlg::OnInitDialog() function calls COpenGLControl::oglCreate() and COpenGLControl::OnCreate() calls COpenGLControl::oglInitialize() but I just don't see how to wire this up in my splitt form example where the panes are created from the splitter class. Thanks, John ... // Create OpenGL Control window m_oglWindow.oglCreate(rect, this);

            L D 2 Replies Last reply
            0
            • U User 12249262

              Richard, The function that I am trying to get to execute is COpenGLControl::oglInitialize() which was called in OnInitDialog in the example template I am following. the oglInitialize function, listed below should setup the OpenGL context. But my case is somewhat different as you can see from my most recent post and I don't know where to place the call to oglInitalize()

              void COpenGLControl::oglInitialize()
              {
              // Initial Setup:
              //
              static PIXELFORMATDESCRIPTOR pfd =
              {
              sizeof(PIXELFORMATDESCRIPTOR),
              1,
              PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
              PFD_TYPE_RGBA,
              32, // bit depth
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              16, // z-buffer depth
              0, 0, 0, 0, 0, 0, 0,
              };

              // Get device context only once.
              hdc = GetDC()->m\_hDC;
              
              // Pixel format.
              m\_nPixelFormat = ChoosePixelFormat(hdc, &pfd);
              SetPixelFormat(hdc, m\_nPixelFormat, &pfd);
              
              // Create the OpenGL Rendering Context.
              hrc = wglCreateContext(hdc);
              wglMakeCurrent(hdc, hrc);
              
              // Basic Setup:
              //
              // Set color to use when clearing the background.
              glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
              glClearDepth(1.0f);
              
              // Turn on backface culling
              glFrontFace(GL\_CCW);
              glCullFace(GL\_BACK);
              
              // Turn on depth testing
              glEnable(GL\_DEPTH\_TEST);
              glDepthFunc(GL\_LEQUAL);
              
              // Send draw request
              OnDraw(NULL);
              

              }

              In that example template I have three classes CMFCOpenGLDlg : public CDialogEx COpenGLControl : public CWnd and CMFCOpenGLApp : public CWinApp in this example the CMFCOpenGLDlg::OnInitDialog() function calls COpenGLControl::oglCreate() and COpenGLControl::OnCreate() calls COpenGLControl::oglInitialize() but I just don't see how to wire this up in my splitt form example where the panes are created from the splitter class. Thanks, John ... // Create OpenGL Control window m_oglWindow.oglCreate(rect, this);

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              OK, but you are not calling this from a dialog, but from a CView, so you probably need to call the initializer from the CView::OnInitialUpdate[^] function.

              U 1 Reply Last reply
              0
              • U User 12249262

                Richard, The function that I am trying to get to execute is COpenGLControl::oglInitialize() which was called in OnInitDialog in the example template I am following. the oglInitialize function, listed below should setup the OpenGL context. But my case is somewhat different as you can see from my most recent post and I don't know where to place the call to oglInitalize()

                void COpenGLControl::oglInitialize()
                {
                // Initial Setup:
                //
                static PIXELFORMATDESCRIPTOR pfd =
                {
                sizeof(PIXELFORMATDESCRIPTOR),
                1,
                PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
                PFD_TYPE_RGBA,
                32, // bit depth
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                16, // z-buffer depth
                0, 0, 0, 0, 0, 0, 0,
                };

                // Get device context only once.
                hdc = GetDC()->m\_hDC;
                
                // Pixel format.
                m\_nPixelFormat = ChoosePixelFormat(hdc, &pfd);
                SetPixelFormat(hdc, m\_nPixelFormat, &pfd);
                
                // Create the OpenGL Rendering Context.
                hrc = wglCreateContext(hdc);
                wglMakeCurrent(hdc, hrc);
                
                // Basic Setup:
                //
                // Set color to use when clearing the background.
                glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
                glClearDepth(1.0f);
                
                // Turn on backface culling
                glFrontFace(GL\_CCW);
                glCullFace(GL\_BACK);
                
                // Turn on depth testing
                glEnable(GL\_DEPTH\_TEST);
                glDepthFunc(GL\_LEQUAL);
                
                // Send draw request
                OnDraw(NULL);
                

                }

                In that example template I have three classes CMFCOpenGLDlg : public CDialogEx COpenGLControl : public CWnd and CMFCOpenGLApp : public CWinApp in this example the CMFCOpenGLDlg::OnInitDialog() function calls COpenGLControl::oglCreate() and COpenGLControl::OnCreate() calls COpenGLControl::oglInitialize() but I just don't see how to wire this up in my splitt form example where the panes are created from the splitter class. Thanks, John ... // Create OpenGL Control window m_oglWindow.oglCreate(rect, this);

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #8

                Member 12282738 wrote:

                ...I don't know where to place the call to oglInitalize()

                See here.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                1 Reply Last reply
                0
                • L Lost User

                  OK, but you are not calling this from a dialog, but from a CView, so you probably need to call the initializer from the CView::OnInitialUpdate[^] function.

                  U Offline
                  U Offline
                  User 12249262
                  wrote on last edited by
                  #9

                  Richard, Thanks for bearing with me. I looked in MDN and found this comment about OnInitialUpdate

                  Called by the framework after the view is first attached to the document, but before the view is initially displayed.

                  So I assume that OnInitalUpdate is called automaticaly and I don't need to do anything to invoke it but where would I put the override code in CFormRight : public CFormView or COpenGLControl : public CWnd ? Thanks again, John

                  D V 2 Replies Last reply
                  0
                  • U User 12249262

                    Richard, Thanks for bearing with me. I looked in MDN and found this comment about OnInitialUpdate

                    Called by the framework after the view is first attached to the document, but before the view is initially displayed.

                    So I assume that OnInitalUpdate is called automaticaly and I don't need to do anything to invoke it but where would I put the override code in CFormRight : public CFormView or COpenGLControl : public CWnd ? Thanks again, John

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #10

                    Member 12282738 wrote:

                    CFormRight

                    Yes.

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                    1 Reply Last reply
                    0
                    • U User 12249262

                      Richard, Thanks for bearing with me. I looked in MDN and found this comment about OnInitialUpdate

                      Called by the framework after the view is first attached to the document, but before the view is initially displayed.

                      So I assume that OnInitalUpdate is called automaticaly and I don't need to do anything to invoke it but where would I put the override code in CFormRight : public CFormView or COpenGLControl : public CWnd ? Thanks again, John

                      V Offline
                      V Offline
                      Victor Nijegorodov
                      wrote on last edited by
                      #11

                      Member 12282738 wrote:

                      So I assume that OnInitalUpdate is called automaticaly and I don't need to do anything to invoke it but where would I put the override code in CFormRight : public CFormView or COpenGLControl : public CWnd ?

                      Yes, it is called automatically. Note that if you do not override the OnInitalUpdate in your derived class then the base class implementation will be called. And note, that OnInitalUpdate is a method of a CView, not a CDialog. So - override it in CFormRight class.

                      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