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. Maximising CMDIChildWnd

Maximising CMDIChildWnd

Scheduled Pinned Locked Moved C / C++ / MFC
csharpquestion
5 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.
  • J Offline
    J Offline
    Jawache
    wrote on last edited by
    #1

    I'm trying to create an MDI app, I want any child windows to be automatically Maximised at all times. I've overidden the Create function and removed the style WS_SYSMENU and added the style WS_MAXIMIZE. (see bellow) The window wtill doesn't display maximised though? What am I missing? Cheers

    BOOL CSegmentationFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CMDIFrameWnd* pParentWnd, CCreateContext* pContext)
    {
    // Remove the System Menu from the Frame
    dwStyle ^= WS_SYSMENU ;

    // Create a Maximised Window
    dwStyle |= WS\_MAXIMIZE ;
    return CMDIChildWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, pContext);
    

    }

    Asim Hussain e: asim@jawache.net w: www.jawache.net

    J 1 Reply Last reply
    0
    • J Jawache

      I'm trying to create an MDI app, I want any child windows to be automatically Maximised at all times. I've overidden the Create function and removed the style WS_SYSMENU and added the style WS_MAXIMIZE. (see bellow) The window wtill doesn't display maximised though? What am I missing? Cheers

      BOOL CSegmentationFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CMDIFrameWnd* pParentWnd, CCreateContext* pContext)
      {
      // Remove the System Menu from the Frame
      dwStyle ^= WS_SYSMENU ;

      // Create a Maximised Window
      dwStyle |= WS\_MAXIMIZE ;
      return CMDIChildWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, pContext);
      

      }

      Asim Hussain e: asim@jawache.net w: www.jawache.net

      J Offline
      J Offline
      Joseph Dempsey
      wrote on last edited by
      #2

      try moving your functionality into PreCreateWindow.

      virtual BOOL CSegmentationFrame::PreCreateWindow( CREATESTRUCT& cs )
      {
      cs.style ^= WS_SYSMENU;
      cs.sytle |= WS_MAXIMIZE;
      return CFrameWnd::PreCreateWindow( cs );
      }

      That may help you out. Is kinda hard to tell w/o seeing more of your source. The style could be getting overriden somewhere else. Joseph Dempsey joseph_r_dempsey@yahoo.com "Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning." --anonymous

      J 1 Reply Last reply
      0
      • J Joseph Dempsey

        try moving your functionality into PreCreateWindow.

        virtual BOOL CSegmentationFrame::PreCreateWindow( CREATESTRUCT& cs )
        {
        cs.style ^= WS_SYSMENU;
        cs.sytle |= WS_MAXIMIZE;
        return CFrameWnd::PreCreateWindow( cs );
        }

        That may help you out. Is kinda hard to tell w/o seeing more of your source. The style could be getting overriden somewhere else. Joseph Dempsey joseph_r_dempsey@yahoo.com "Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning." --anonymous

        J Offline
        J Offline
        Jawache
        wrote on last edited by
        #3

        Cheers, but that doesn't work either. The only other code I have in the class is the OnCreateClient function. Its displaying a splitter window as bellow:

        BOOL CSegmentationFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
        {
        //calculate client size
        CRect cr;
        GetClientRect( &cr);
        // Window Styles
        DWORD dwStyle = WS_BORDER | WS_CHILD | WS_VISIBLE;

        // Main splitter wnd, two rows 1 columns
        if ( !m\_mainSplitterWnd.CreateStatic( this, 2, 1 ) ) 
        { 
        	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); 
        	return FALSE; 
        }
        
        // Top splitter win, 2 rows 4 columns (To hold the slice views)
        if ( !m\_topSplitterWnd.CreateStatic( &m\_mainSplitterWnd, 2, 4, dwStyle ,m\_mainSplitterWnd.IdFromRowCol(0,0) ) )
        { 
        	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); 
        	return FALSE; 
        }
        
        // Bottom Splitter window, 1 row 2 columns ( to hold the form and histogram view )
        if ( !m\_botSplitterWnd.CreateStatic( &m\_mainSplitterWnd, 1, 2, dwStyle ,m\_mainSplitterWnd.IdFromRowCol(1,0) ) ) 
        { 
        	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); 
        	return FALSE; 
        }
        // Top Slice Views
        for (int row = 0; row < 2; row ++)
        {
        	for (int col = 0; col < 4; col ++)
        	{
        		if ( !m\_topSplitterWnd.CreateView( row, col, RUNTIME\_CLASS(CSliceView), CSize(cr.Width()/4, cr.Height()/3), pContext ) ) 
        		{ 
        			MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR );
        			return FALSE; 
        		}
        
        	}
        }
        // Bottom Slice Views
        if ( !m\_botSplitterWnd.CreateView( 0, 0, RUNTIME\_CLASS(CSegmentationForm), CSize(cr.Width()/2, cr.Height()/3), pContext ) ) 
        { 
        	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR );
        	return FALSE; 
        }
        
        if ( !m\_botSplitterWnd.CreateView( 0, 1, RUNTIME\_CLASS(CHistogramView), CSize(cr.Width()/2, cr.Height()/3), pContext ) ) 
        { 
        	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR );
        	return FALSE; 
        }
        
        return true; //CMDIChildWnd::OnCreateClient(lpcs, pContext);
        

        Asim Hussain e: asim@jawache.net w: www.jawache.net

        J 1 Reply Last reply
        0
        • J Jawache

          Cheers, but that doesn't work either. The only other code I have in the class is the OnCreateClient function. Its displaying a splitter window as bellow:

          BOOL CSegmentationFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
          {
          //calculate client size
          CRect cr;
          GetClientRect( &cr);
          // Window Styles
          DWORD dwStyle = WS_BORDER | WS_CHILD | WS_VISIBLE;

          // Main splitter wnd, two rows 1 columns
          if ( !m\_mainSplitterWnd.CreateStatic( this, 2, 1 ) ) 
          { 
          	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); 
          	return FALSE; 
          }
          
          // Top splitter win, 2 rows 4 columns (To hold the slice views)
          if ( !m\_topSplitterWnd.CreateStatic( &m\_mainSplitterWnd, 2, 4, dwStyle ,m\_mainSplitterWnd.IdFromRowCol(0,0) ) )
          { 
          	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); 
          	return FALSE; 
          }
          
          // Bottom Splitter window, 1 row 2 columns ( to hold the form and histogram view )
          if ( !m\_botSplitterWnd.CreateStatic( &m\_mainSplitterWnd, 1, 2, dwStyle ,m\_mainSplitterWnd.IdFromRowCol(1,0) ) ) 
          { 
          	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); 
          	return FALSE; 
          }
          // Top Slice Views
          for (int row = 0; row < 2; row ++)
          {
          	for (int col = 0; col < 4; col ++)
          	{
          		if ( !m\_topSplitterWnd.CreateView( row, col, RUNTIME\_CLASS(CSliceView), CSize(cr.Width()/4, cr.Height()/3), pContext ) ) 
          		{ 
          			MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR );
          			return FALSE; 
          		}
          
          	}
          }
          // Bottom Slice Views
          if ( !m\_botSplitterWnd.CreateView( 0, 0, RUNTIME\_CLASS(CSegmentationForm), CSize(cr.Width()/2, cr.Height()/3), pContext ) ) 
          { 
          	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR );
          	return FALSE; 
          }
          
          if ( !m\_botSplitterWnd.CreateView( 0, 1, RUNTIME\_CLASS(CHistogramView), CSize(cr.Width()/2, cr.Height()/3), pContext ) ) 
          { 
          	MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR );
          	return FALSE; 
          }
          
          return true; //CMDIChildWnd::OnCreateClient(lpcs, pContext);
          

          Asim Hussain e: asim@jawache.net w: www.jawache.net

          J Offline
          J Offline
          Jawache
          wrote on last edited by
          #4

          It works now if i just use cs.style = WS_CHILD | WS_VISIBLE | WS_MAXIMIZE; in PreCreateWidow. Cheers Asim Hussain e: asim@jawache.net w: www.jawache.net

          B 1 Reply Last reply
          0
          • J Jawache

            It works now if i just use cs.style = WS_CHILD | WS_VISIBLE | WS_MAXIMIZE; in PreCreateWidow. Cheers Asim Hussain e: asim@jawache.net w: www.jawache.net

            B Offline
            B Offline
            basementman
            wrote on last edited by
            #5

            another solution which works well is the following: void CChildFrame::ActivateFrame(int nCmdShow) { // TODO: Modify this function to change how the frame is activated. nCmdShow = SW_SHOWMAXIMIZED; CMDIChildWnd::ActivateFrame(nCmdShow); }

            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