m_nFsToolBarHeight = 0;
m_bFsIsMaximized = FALSE;
m_bFsIsShowing = FALSE;
+
+ //
+ // Initialize SWP's
+ //
+ memset(&m_vSwp, 0, sizeof(SWP));
+ memset(&m_vSwpClient, 0, sizeof(SWP));
+ memset(&m_vSwpTitleBar, 0, sizeof(SWP));
+ memset(&m_vSwpMenuBar, 0, sizeof(SWP));
+ memset(&m_vSwpHScroll, 0, sizeof(SWP));
+ memset(&m_vSwpVScroll, 0, sizeof(SWP));
+ memset(&m_vSwpStatusBar, 0, sizeof(SWP));
+ memset(&m_vSwpToolBar, 0, sizeof(SWP));
} // end of wxFrame::Init
bool wxFrame::Create(
if (wxTheApp->GetExitOnFrameDelete())
{
- ::WinPostMsg(GetHwnd(), WM_QUIT, 0, 0);
+ ::WinPostMsg(m_hFrame, WM_QUIT, 0, 0);
}
}
wxModelessWindows.DeleteObject(this);
// top-left thus the += instead of the -=
//
RECTL vRect;
- HWND hWndClient;
//
// PM has no GetClientRect that inherantly knows about the client window
// We have to explicitly go fetch it!
//
- hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
- ::WinQueryWindowRect(hWndClient, &vRect);
+ ::WinQueryWindowRect(GetHwnd(), &vRect);
#if wxUSE_STATUSBAR
if ( GetStatusBar() )
)
{
HWND hWnd = GetHwnd();
- HWND hWndClient;
RECTL vRect;
RECTL vRect2;
- hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
- ::WinQueryWindowRect(hWndClient, &vRect);
+ ::WinQueryWindowRect(GetHwnd(), &vRect);
- ::WinQueryWindowRect(hWnd, &vRect2);
+ ::WinQueryWindowRect(m_hFrame, &vRect2);
//
// Find the difference between the entire window (title bar and all)
vPointl.x = vRect2.xLeft;
vPoint.y = vRect2.yTop;
- ::WinSetWindowPos( hWnd
+ ::WinSetWindowPos( m_hFrame
,HWND_TOP
,vPointl.x
,vPointl.y
{
RECTL vRect;
- ::WinQueryWindowRect(GetHwnd(), &vRect);
+ ::WinQueryWindowRect(m_hFrame, &vRect);
*pWidth = vRect.xRight - vRect.xLeft;
*pHeight = vRect.yTop - vRect.yBottom;
} // end of wxFrame::DoGetSize
RECTL vRect;
POINTL vPoint;
- ::WinQueryWindowRect(GetHwnd(), &vRect);
+ ::WinQueryWindowRect(m_hFrame, &vRect);
vPoint.x = vRect.xLeft;
//
int bShowCmd
)
{
- HWND hClient;
+ HWND hClient = NULLHANDLE;
+ SWP vSwp;
//
- // Send anything to initialize the frame
+ // Reset the window position
//
- ::WinSendMsg( GetHwnd()
- ,WM_UPDATEFRAME
- ,(MPARAM)FCF_MENU
- ,(MPARAM)0
- );
- hClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
+ WinQueryWindowPos(m_hFrame, &vSwp);
+ WinSetWindowPos( GetHwnd()
+ ,HWND_TOP
+ ,vSwp.x
+ ,vSwp.y
+ ,vSwp.cx
+ ,vSwp.cy
+ ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE
+ );
+ ::WinShowWindow(m_hFrame, (BOOL)bShowCmd);
::WinShowWindow(GetHwnd(), (BOOL)bShowCmd);
- ::WinShowWindow(hClient, (BOOL)bShowCmd);
} // end of wxFrame::DoShowWindow
bool wxFrame::Show(
{
wxActivateEvent vEvent(wxEVT_ACTIVATE, TRUE, m_windowId);
- ::WinQueryWindowPos(GetHwnd(), &vSwp);
+ ::WinQueryWindowPos(m_hFrame, &vSwp);
m_bIconized = vSwp.fl & SWP_MINIMIZE;
- ::WinSetWindowPos( (HWND) GetHWND()
- ,HWND_TOP
- ,vSwp.x
- ,vSwp.y
- ,vSwp.cx
- ,vSwp.cy
- ,SWP_ZORDER | SWP_ACTIVATE | SWP_SHOW | SWP_MOVE
- );
+ ::WinEnableWindow(m_hFrame, TRUE);
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent);
}
,vSwp.cy
,SWP_ZORDER | SWP_ACTIVATE | SWP_SHOW | SWP_MOVE
);
+ ::WinEnableWindow(hWndParent, TRUE);
}
}
return TRUE;
SWP vSwp;
bool bIconic;
- ::WinQueryWindowPos(GetHwnd(), &vSwp);
+ ::WinQueryWindowPos(m_hFrame, &vSwp);
return (vSwp.fl & SWP_MAXIMIZE);
} // end of wxFrame::IsMaximized
if ((m_icon.GetHICON()) != NULLHANDLE)
{
- ::WinSendMsg( GetHwnd()
+ ::WinSendMsg( m_hFrame
,WM_SETICON
,(MPARAM)((HPOINTER)m_icon.GetHICON())
,NULL
);
- ::WinSendMsg( GetHwnd()
+ ::WinSendMsg( m_hFrame
,WM_UPDATEFRAME
,(MPARAM)FCF_ICON
,(MPARAM)0
)
{
wxStatusBar* pStatusBar = NULL;
+ SWP vSwp;
+ ERRORID vError;
+ wxString sError;
+ HWND hWnd;
pStatusBar = wxFrameBase::OnCreateStatusBar( nNumber
,lulStyle
,vId
,rName
);
+ //
+ // The default parent set for the Statusbar is m_hWnd which, of course,
+ // is the handle to the client window of the frame. We don't want that,
+ // so we have to set the parent to actually be the Frame.
+ //
+ hWnd = pStatusBar->GetHWND();
+ if (!::WinSetParent(hWnd, m_hFrame, FALSE))
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError("Error setting parent for statusbar. Error: %s\n", sError);
+ return NULL;
+ }
+
+ //
+ // Also we need to reset it positioning to enable the SHOW attribute
+ //
+ if (!::WinQueryWindowPos((HWND)pStatusBar->GetHWND(), &vSwp))
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError("Error querying frame for statusbar position. Error: %s\n", sError);
+ return NULL;
+ }
+ if (!::WinSetWindowPos( (HWND)pStatusBar->GetHWND()
+ ,HWND_TOP
+ ,vSwp.cx
+ ,vSwp.cy
+ ,vSwp.x
+ ,vSwp.y
+ ,SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER
+ ))
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError("Error setting statusbar position. Error: %s\n", sError);
+ return NULL;
+ }
return pStatusBar;
} // end of wxFrame::OnCreateStatusBar
void wxFrame::PositionStatusBar()
{
+ SWP vSwp;
+ ERRORID vError;
+ wxString sError;
+
//
// Native status bar positions itself
//
HWND hWndClient;
RECTL vRect;
- hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
- ::WinQueryWindowRect(hWndClient, &vRect);
+ ::WinQueryWindowRect(GetHwnd(), &vRect);
nWidth = vRect.xRight - vRect.xLeft;
nHeight = vRect.yTop - vRect.yBottom;
,nWidth
,nStatbarHeight
);
+ if (!::WinQueryWindowPos(m_frameStatusBar->GetHWND(), &vSwp))
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError("Error setting parent for submenu. Error: %s\n", sError);
+ return;
+ }
+ if (!::WinSetWindowPos( m_frameStatusBar->GetHWND()
+ ,HWND_TOP
+ ,nStatbarWidth
+ ,nStatbarHeight
+ ,vSwp.x
+ ,vSwp.y
+ ,SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER
+ ))
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError("Error setting parent for submenu. Error: %s\n", sError);
+ return;
+ }
}
} // end of wxFrame::PositionStatusBar
#endif // wxUSE_STATUSBAR
wxMenuBar* pMenuBar
)
{
+ ERRORID vError;
+ wxString sError;
+ HWND hClient = NULLHANDLE;
+ HWND hFrame = NULLHANDLE;
+ HWND hTitlebar = NULLHANDLE;
+ HWND hHScroll = NULLHANDLE;
+ HWND hVScroll = NULLHANDLE;
+ HWND hMenuBar = NULLHANDLE;
+ SWP vSwp;
+ SWP vSwpTitlebar;
+ SWP vSwpVScroll;
+ SWP vSwpHScroll;
+ SWP vSwpMenu;
+
if (!pMenuBar)
{
DetachMenuBar();
return;
}
+ //
+ // Set the parent and owner of the menubar to be the frame
+ //
+ if (!::WinSetParent(m_hMenu, m_hFrame, FALSE))
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError("Error setting parent for submenu. Error: %s\n", sError);
+ }
+
+ if (!::WinSetOwner(m_hMenu, m_hFrame))
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError("Error setting parent for submenu. Error: %s\n", sError);
+ }
InternalSetMenuBar();
m_frameMenuBar = pMenuBar;
pMenuBar->Attach(this);
+
+ //
+ // Now resize the client to fit the new frame
+ //
+ WinQueryWindowPos(m_hFrame, &vSwp);
+ hTitlebar = WinWindowFromID(m_hFrame, FID_TITLEBAR);
+ WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
+ hHScroll = WinWindowFromID(m_hFrame, FID_HORZSCROLL);
+ WinQueryWindowPos(hHScroll, &vSwpHScroll);
+ hVScroll = WinWindowFromID(m_hFrame, FID_VERTSCROLL);
+ WinQueryWindowPos(hVScroll, &vSwpVScroll);
+ hMenuBar = WinWindowFromID(m_hFrame, FID_MENU);
+ WinQueryWindowPos(hMenuBar, &vSwpMenu);
+ WinSetWindowPos( GetHwnd()
+ ,HWND_TOP
+ ,SV_CXSIZEBORDER/2
+ ,(SV_CYSIZEBORDER/2) + vSwpHScroll.cy/2
+ ,vSwp.cx - ((SV_CXSIZEBORDER + 1) + vSwpVScroll.cx)
+ ,vSwp.cy - ((SV_CYSIZEBORDER + 1) + vSwpTitlebar.cy + vSwpMenu.cy + vSwpHScroll.cy/2)
+ ,SWP_SIZE | SWP_MOVE
+ );
} // end of wxFrame::SetMenuBar
void wxFrame::InternalSetMenuBar()
{
- WinSendMsg((HWND)GetHwnd(), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
+ WinSendMsg((HWND)m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
} // end of wxFrame::InternalSetMenuBar
//
FRAMECDATA vFrameCtlData;
HWND hParent = NULLHANDLE;
HWND hClient = NULLHANDLE;
+ HWND hFrame = NULLHANDLE;
HWND hTitlebar = NULLHANDLE;
HWND hHScroll = NULLHANDLE;
HWND hVScroll = NULLHANDLE;
- SWP vSwp;
- SWP vSwpTitlebar;
- SWP vSwpVScroll;
- SWP vSwpHScroll;
+ SWP vSwp[10];
+ RECTL vRect[10];
+ USHORT uCtlCount;
m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON);
- memset(&vSwp, '\0', sizeof(SWP));
- memset(&vSwpTitlebar, '\0', sizeof(SWP));
- memset(&vSwpVScroll, '\0', sizeof(SWP));
- memset(&vSwpHScroll, '\0', sizeof(SWP));
+
if (pParent)
hParent = GetWinHwnd(pParent);
else
if (ulStyle == wxDEFAULT_FRAME_STYLE)
ulCreateFlags = FCF_SIZEBORDER | FCF_TITLEBAR | FCF_SYSMENU |
- FCF_MINMAX | FCF_VERTSCROLL | FCF_HORZSCROLL | FCF_TASKLIST;
+ FCF_MINMAX | FCF_TASKLIST;
else
{
if ((ulStyle & wxCAPTION) == wxCAPTION)
else
ulCreateFlags = FCF_NOMOVEWITHOWNER;
+ if ((ulStyle & wxVSCROLL) == wxVSCROLL)
+ ulCreateFlags |= FCF_VERTSCROLL;
+ if ((ulStyle & wxHSCROLL) == wxHSCROLL)
+ ulCreateFlags |= FCF_HORZSCROLL;
if (ulStyle & wxMINIMIZE_BOX)
ulCreateFlags |= FCF_MINBUTTON;
if (ulStyle & wxMAXIMIZE_BOX)
//
// Create the frame window
//
- if (!wxWindow::OS2Create( hParent
- ,WC_FRAME
- ,zTitle
- ,ulStyleFlags
- ,(long)nX
- ,(long)nY
- ,(long)nWidth
- ,(long)nHeight
- ,NULLHANDLE
- ,HWND_TOP
- ,(long)nId
- ,(void*)&vFrameCtlData
- ,NULL
- ))
+ if ((m_hFrame = ::WinCreateWindow( hParent // Frame is parent
+ ,WC_FRAME // standard frame class
+ ,(PSZ)zTitle // Window title
+ ,0 // No styles
+ ,0, 0, 0, 0 // Window position
+ ,NULLHANDLE // Owner
+ ,HWND_TOP // Sibling
+ ,(ULONG)nId // ID
+ ,(PVOID)&vFrameCtlData // Creation data
+ ,NULL // Window Pres Params
+ )) == 0L)
{
return FALSE;
}
- //
- // Create the client window. We must call the API from here rather than
- // the static base class create because we need a separate handle
- //
- if ((hClient = ::WinCreateWindow( GetHwnd() // Frame is parent
- ,zWclass // Custom client class
- ,NULL // Window title
- ,0 // No styles
- ,0, 0, 0, 0 // Window position
- ,NULLHANDLE // Owner
- ,HWND_TOP // Sibling
- ,FID_CLIENT // standard client ID
- ,NULL // Creation data
- ,NULL // Window Pres Params
- )) == 0L)
+ if (!wxWindow::OS2Create( m_hFrame
+ ,wxFrameClassName
+ ,NULL
+ ,0L
+ ,0L
+ ,0L
+ ,0L
+ ,0L
+ ,NULLHANDLE
+ ,HWND_TOP
+ ,(unsigned long)FID_CLIENT
+ ,NULL
+ ,NULL
+ ))
{
return FALSE;
}
- //
- // Send anything to initialize the frame
- //
- ::WinSendMsg( GetHwnd()
- ,WM_UPDATEFRAME
- ,(MPARAM)FCF_TASKLIST
- ,(MPARAM)0
- );
//
// Now size everything. If adding a menu the client will need to be resized.
//
- if (!::WinSetWindowPos( GetHwnd()
+ if (!::WinSetWindowPos( m_hFrame
,HWND_TOP
,nX
,nY
,nWidth
,nHeight
- ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE
+ ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_ZORDER
))
return FALSE;
- WinQueryWindowPos(GetHwnd(), &vSwp);
-
- if (ulCreateFlags & FCF_TITLEBAR)
- {
- hTitlebar = WinWindowFromID(GetHwnd(), FID_TITLEBAR);
- WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
- }
- if (ulCreateFlags & FCF_HORZSCROLL)
- {
- hHScroll = WinWindowFromID(GetHwnd(), FID_HORZSCROLL);
- WinQueryWindowPos(hHScroll, &vSwpHScroll);
- }
- if (ulCreateFlags & FCF_VERTSCROLL)
+ uCtlCount = SHORT1FROMMP(::WinSendMsg(m_hFrame, WM_FORMATFRAME, (MPARAM)vSwp, (MPARAM)vRect));
+ for (int i = 0; i < uCtlCount; i++)
{
- hVScroll = WinWindowFromID(GetHwnd(), FID_VERTSCROLL);
- WinQueryWindowPos(hVScroll, &vSwpVScroll);
+ if (vSwp[i].hwnd == m_hFrame)
+ memcpy(&m_vSwp, &vSwp[i], sizeof(SWP));
+ else if (vSwp[i].hwnd == m_hVScroll)
+ memcpy(&m_vSwpVScroll, &vSwp[i], sizeof(SWP));
+ else if (vSwp[i].hwnd == m_hHScroll)
+ memcpy(&m_vSwpVScroll, &vSwp[i], sizeof(SWP));
+ else if (vSwp[i].hwnd == m_hTitleBar)
+ memcpy(&m_vSwpTitleBar, &vSwp[i], sizeof(SWP));
}
- if (!::WinSetWindowPos( hClient
- ,HWND_TOP
- ,SV_CXSIZEBORDER
- ,(SV_CYSIZEBORDER - 1) + vSwpHScroll.cy
- ,vSwp.cx - ((SV_CXSIZEBORDER * 2) + vSwpVScroll.cx)
- ,vSwp.cy - ((SV_CYSIZEBORDER * 2) + 1 + vSwpTitlebar.cy + vSwpHScroll.cy)
- ,SWP_SIZE | SWP_MOVE
- ))
- return FALSE;
- WinQueryWindowPos(hClient, &vSwp);
+
+ //
+ // Now set the size of the client
+ //
+ WinSetWindowPos( hClient
+ ,HWND_TOP
+ ,SV_CXSIZEBORDER/2
+ ,(SV_CYSIZEBORDER/2) + m_vSwpHScroll.cy/2
+ ,m_vSwp.cx - ((SV_CXSIZEBORDER + 1) + m_vSwpVScroll.cx)
+ ,m_vSwp.cy - ((SV_CYSIZEBORDER + 1) + m_vSwpTitleBar.cy + m_vSwpHScroll.cy/2)
+ ,SWP_SIZE | SWP_MOVE
+ );
+
+ //
+ // Set the client window's background, otherwise it is transparent!
+ //
return TRUE;
} // end of wxFrame::OS2Create
HWND hWndClient;
RECTL vRect;
- hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
- ::WinQueryWindowRect(hWndClient, &vRect);
+ ::WinQueryWindowRect(GetHwnd(), &vRect);
#if wxUSE_STATUSBAR
if (GetStatusBar())
WXMSG* pMsg
)
{
- if (wxWindow::OS2TranslateMessage(pMsg))
- return TRUE;
//
// try the menu bar accels
//
return FALSE;
const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable();
- return rAcceleratorTable.Translate(this, pMsg);
+ return rAcceleratorTable.Translate(m_hFrame, pMsg);
} // end of wxFrame::OS2TranslateMessage
// ---------------------------------------------------------------------------
{
RECTL vRect;
- if (::WinQueryUpdateRect(GetHwnd(), &vRect))
+ if (::WinQueryUpdateRect(m_hFrame, &vRect))
{
if (m_bIconized)
{
HPOINTER hIcon;
if (m_icon.Ok())
- hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L);
+ hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L);
else
hIcon = (HPOINTER)m_hDefaultIcon;
// is being processed
//
RECTL vRect2;
- HPS hPs = ::WinBeginPaint(GetHwnd(), NULLHANDLE, &vRect2);
+ HPS hPs = ::WinBeginPaint(m_hFrame, NULLHANDLE, &vRect2);
//
// Erase background before painting or we get white background
HWND hWndClient;
RECTL vRect3;
- hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
- ::WinQueryWindowRect(hWndClient, &vRect3);
+ ::WinQueryWindowRect(GetHwnd(), &vRect3);
static const int nIconWidth = 32;
static const int nIconHeight = 32;
}
else
{
+ HPS hPS;
+ RECTL vRect;
+
+ hPS = WinBeginPaint(GetHwnd(), 0L, &vRect);
+ WinFillRect(hPS, &vRect, SYSCLR_WINDOW);
+ WinEndPaint(hPS);
+
return wxWindow::HandlePaint();
}
}
bProcessed = HandlePaint();
break;
+ case WM_ERASEBACKGROUND:
+ //
+ // Return TRUE to request PM to paint the window background
+ // in SYSCLR_WINDOW.
+ //
+ bProcessed = TRUE;
+ mRc = (MRESULT)(TRUE);
+ break;
+
case CM_QUERYDRAGIMAGE:
{
HPOINTER hIcon;
if (m_icon.Ok())
- hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L);
+ hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L);
else
hIcon = (HPOINTER)m_hDefaultIcon;
mRc = (MRESULT)hIcon;