Print Page | Close Window

Tabbed MDI

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=226
Printed Date: 23 December 2024 at 4:00am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Tabbed MDI
Posted By: kelvincannon
Subject: Tabbed MDI
Date Posted: 12 November 2003 at 8:16am

I have written a Tabbed MDI program with a PreCreateWindow function as follows:

BOOL CDigitizeFrame::PreCreateWindow(CREATESTRUCT& cs)
{
  cs.x=cs.y=0;
  cs.cx=cs.cy=32767;
  cs.style |= WS_BORDER;
  cs.style &= ~WS_THICKFRAME;
  cs.style &= ~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX);
  return CMDIChildWnd::PreCreateWindow(cs);
}

The problem is that when I tab to the next window it is drawn as a restored window and not a maximized windows. Does anyone know how to prevent this from happening.

Thanks

Kelvin

 




Replies:
Posted By: Oleg
Date Posted: 12 November 2003 at 8:31am

You remove WS_MAXIMIZEBOX flag and it cant be maximized.

Try to remove  this line

 cs.style &= ~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX);



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: kelvincannon
Date Posted: 12 November 2003 at 9:08am

I can not do that because I need the windows to remain maximized and not let the user changed them.

Thanks

Kelvin

 



Posted By: Matt1
Date Posted: 12 November 2003 at 12:28pm

This is an MFC issue.

I also would benefit from MDI windows that are force to stay maximized.  I've tried forcing this in OnSize() but it's hackish and makes the Min/Max/Close buttons do strange things.

Does anybody know how to solve this problem gracefully?



Posted By: Matt1
Date Posted: 12 November 2003 at 1:01pm

Kelvin,

Try using this code in your child frame's OnSize() function:

void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
     CMDIChildWnd::OnSize(nType, cx, cy);

      // ADD ->
     if(nType == SIZE_MINIMIZED || nType == SIZE_RESTORED) {
          WINDOWPLACEMENT sWndPos;
          sWndPos.length = sizeof(WINDOWPLACEMENT);
          sWndPos.flags = 0;
          sWndPos.showCmd = SW_SHOWMAXIMIZED;
          SetWindowPlacement(&sWndPos);
     }
     //<- ADD
}

This actually seems to work well with ToolkitPro when combined with a child window that doesn't have Min/Max box styles like yours.  For straight MFC this does not work so well because the Min/Max boxes sometimes show up for some reason.

Also, you might want to remove the FWS_ADDTOTITLE style too because the above code interferes with that process.

If you end up finding a better solution, please post it here.



Posted By: Oleg
Date Posted: 13 November 2003 at 12:58am

If you use ToolkitPro you can add  

CXTPCommandBar* pMenuBar = pCommandBars->SetMenu("Menu Bar", IDR_MAINFRAME);
pMenuBar->SetFlags(xtpFlagHideMinimizeBox | xtpFlagHideMaximizeBox);

this hide minimize and maximize buttons in the menu bar.



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: kelvincannon
Date Posted: 13 November 2003 at 7:44am

Thanks oleg that worked ok only you must place it after "LoadCommandBars(_T("Bar State"));"

 



Posted By: ddyer
Date Posted: 01 December 2003 at 12:02pm

I used the OnSize tip and and it worked great.  It even removed that annoying "flash" when tabbing between the  windows caused by rendering the "normal size" window frame then erasing it and rendering the maximized frame.

BUT... create three frames, then click on the middle tab (frame #2 on forefront).   Now resize the window.  As you resize, the XTP MDI manager goes nuts making frames #2 and #3 alternately the forefront window.

 

You can easily replicate this by adding the OnSize bit to the GUI_VisualStudio7 demo, then when running it select File->New->File three times and resize the application:

void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
     CMDIChildWnd::OnSize(nType, cx, cy);

      // ADD ->
     if(nType == SIZE_MINIMIZED || nType == SIZE_RESTORED) {
          WINDOWPLACEMENT sWndPos;
          sWndPos.length = sizeof(WINDOWPLACEMENT);
          sWndPos.flags = 0;
          sWndPos.showCmd = SW_SHOWMAXIMIZED;
          SetWindowPlacement(&sWndPos);
     }
     //<- ADD
}

 

 

Is this an XTP bug?



Posted By: ddyer
Date Posted: 08 December 2003 at 12:01pm

A fix for the above problem is to place the OnSize code above into ShowWindow.  You still get that annoying redraw flash whenver you click on a tab, but it works:

Any thoughts on how to prevent the redraw flashing?

void CChildFrame::OnShowWindow(BOOL bShow, UINT nStatus)
{
CMDIChildWnd::OnShowWindow(bShow, nStatus);

if (bShow) {
WINDOWPLACEMENT sWndPos;
sWndPos.length = sizeof(WINDOWPLACEMENT);
sWndPos.flags = 0;
sWndPos.showCmd = SW_SHOWMAXIMIZED;
SetWindowPlacement(&sWndPos);
}
}




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net