Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Tabbed MDI
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Tabbed MDI

 Post Reply Post Reply
Author
Message
kelvincannon View Drop Down
Groupie
Groupie
Avatar

Joined: 12 November 2003
Location: United Kingdom
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote kelvincannon Quote  Post ReplyReply Direct Link To This Post Topic: Tabbed MDI
    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

 

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
kelvincannon View Drop Down
Groupie
Groupie
Avatar

Joined: 12 November 2003
Location: United Kingdom
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote kelvincannon Quote  Post ReplyReply Direct Link To This Post 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

 

Back to Top
Matt1 View Drop Down
Newbie
Newbie


Joined: 06 November 2003
Location: United States
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Matt1 Quote  Post ReplyReply Direct Link To This Post 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?

Back to Top
Matt1 View Drop Down
Newbie
Newbie


Joined: 06 November 2003
Location: United States
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Matt1 Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
kelvincannon View Drop Down
Groupie
Groupie
Avatar

Joined: 12 November 2003
Location: United Kingdom
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote kelvincannon Quote  Post ReplyReply Direct Link To This Post Posted: 13 November 2003 at 7:44am

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

 

Back to Top
ddyer View Drop Down
Groupie
Groupie
Avatar

Joined: 01 December 2003
Location: United States
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote ddyer Quote  Post ReplyReply Direct Link To This Post 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?



Edited by ddyer
Back to Top
ddyer View Drop Down
Groupie
Groupie
Avatar

Joined: 01 December 2003
Location: United States
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote ddyer Quote  Post ReplyReply Direct Link To This Post 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);
}
}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.202 seconds.