/********************************************************************* * * FUNCTION NAME: ShowFrameControls * * DESCRIPTION: * * * INPUT PARAMETERS: * None. * * OUTPUT PARAMETERS: * None. * *********************************************************************/ VOID ShowFrameControls (VOID) { RECTL rclTitlebar, rclMenu; /* Increase the height of the frame now and titlebar are back */ WinQueryWindowRect (hwndMenu, &rclMenu); WinQueryWindowRect (hwndTitlebar, &rclTitlebar); gsFrameHeight += (SHORT)((rclTitlebar.yTop - rclMenu.yBottom) + (rclMenu.yTop - rclMenu.yBottom)); WinSetWindowPos (hwndDefFrame, HWND_TOP, 0, 0, gsFrameWidth, gsFrameHeight, SWP_SIZE); /* Make the parent of the windows the frame to reenable them */ WinSetParent (hwndTitlebar, hwndDefFrame, FALSE); WinSetParent (hwndSysmenu, hwndDefFrame, FALSE); WinSetParent (hwndMinmax, hwndDefFrame, FALSE); WinSetParent (hwndMenu, hwndDefFrame, FALSE); WinSendMsg (hwndDefFrame, WM_UPDATEFRAME, MPFROMLONG(FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX | FCF_MENU), MPVOID); WinInvalidateRect (hwndDefFrame, NULL, TRUE); }
/****************************************************************\ * *-------------------------------------------------------------- * * Name:ClkHideFrameControls * * Purpose:Hide the title bar and associted controls * * * * Usage: * * Method: * - * * - * - * * - * - * * Returns: * * \****************************************************************/ VOID ClkHideFrameControls ( HWND hwndFrame ) { WinSetParent ( hwndTitleBar , HWND_OBJECT , FALSE ) ; WinSetParent ( hwndSysMenu , HWND_OBJECT , FALSE ) ; WinSetParent ( hwndMinMax , HWND_OBJECT , FALSE ) ; WinSetParent ( hwndMenu , HWND_OBJECT , FALSE ) ; WinSendMsg ( hwndFrame , WM_UPDATEFRAME , MPFROMLONG( FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX | FCF_MENU ) , MPVOID) ; cp.fControlsHidden = TRUE ; }
/**************************************************************************** * ShowFrameControls * * - Shows frame controls by assigning ownership to frame window and * * updating the frame window. * * - No I/O. * ****************************************************************************/ VOID ShowFrameControls (VOID) { WinSetParent(hwndTitleBar, hwndFrame, FALSE); WinSetParent(hwndSysMenu, hwndFrame, FALSE); WinSetParent(hwndMenu, hwndFrame, FALSE); WinSetParent(hwndMinMax, hwndFrame, FALSE); WinSendMsg(hwndFrame, WM_UPDATEFRAME, (MPARAM) (FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX | FCF_MENU), NULL); /* Make sure the frame window gets repainted */ WinInvalidateRect( hwndFrame , NULL , TRUE ) ; }
VOID ClkShowFrameControls ( HWND hwndFrame ) { WinSetParent ( hwndTitleBar , hwndFrame , FALSE ) ; WinSetParent ( hwndSysMenu , hwndFrame , FALSE ) ; WinSetParent ( hwndMinMax , hwndFrame , FALSE ) ; WinSetParent ( hwndMenu , hwndFrame , FALSE ) ; WinSendMsg ( hwndFrame , WM_UPDATEFRAME , MPFROMLONG( FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX | FCF_MENU ) , MPVOID) ; WinInvalidateRect ( hwndFrame , NULL , TRUE ) ; cp.fControlsHidden = FALSE ; }
/**************************************************************************** * HideFrameControls * * - Hides frame controls by assigning ownership to (invisible) object * * window and updating the frame window. * * - No I/O. * ****************************************************************************/ VOID HideFrameControls (VOID) { /* I don't believe the following line is required. Appearantly it was * * required for correct operation in early versions of OS/2 v1.2 */ /* WinSetFocus(HWND_DESKTOP, hwndFrame); */ WinSetParent(hwndTitleBar, hwndObject, FALSE); WinSetParent(hwndSysMenu, hwndObject, FALSE); WinSetParent(hwndMenu, hwndObject, FALSE); WinSetParent(hwndMinMax, hwndObject, FALSE); WinSendMsg(hwndFrame, WM_UPDATEFRAME, (MPARAM) (FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX | FCF_MENU), NULL); }
//---------------------------------- // Init Dialog //---------------------------------- BOOL ProjWin::EvInitDialog(HWND hWndFocus) { BOOL RetValue = TDialog::EvInitDialog(hWndFocus); WinSetParent(HWindow, HWND_DESKTOP,0); //Must Be Here too ReloadFile(); return(RetValue); }
/************************************************************************** * * Name : InitMainWindow() * * Description: Creates the application window and puts it into * its initial state. * * Concepts : Called once by the Init() routine * - create main application window * - detach scrollbars from window * - subclass frame window procedure * * API's : WinCreateStdWindow * WinWindowFromID * WinSetParent * WinSendMsg * WinRegisterClass * WinSubclassWindow * * Parameters : [none] * * Return : TRUE - window successfully created * FALSE - window creation failed * *************************************************************************/ BOOL InitMainWindow(VOID) { ULONG ctlData = FCF_STANDARD | FCF_VERTSCROLL | FCF_HORZSCROLL; /* * Create a window with standard controls. */ vhwndFrame = WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE, (PULONG)&ctlData, (PSZ)szAppName, (PSZ)NULL, WS_VISIBLE, (HMODULE)NULL, IDR_MAIN, (PHWND)&vhwndClient); if (!vhwndFrame) return FALSE; /* * for the time being detach the scrollbars from the main * window - but remember their handles for later */ vhwndVScroll = WinWindowFromID(vhwndFrame, FID_VERTSCROLL); vhwndHScroll = WinWindowFromID(vhwndFrame, FID_HORZSCROLL); WinSetParent(vhwndVScroll, HWND_OBJECT, FALSE); WinSetParent(vhwndHScroll, HWND_OBJECT, FALSE); WinSendMsg(vhwndFrame, WM_UPDATEFRAME, MPFROMLONG(FCF_VERTSCROLL | FCF_HORZSCROLL), (MPARAM)NULL); /* save menubar handle */ vhwndMenu = WinWindowFromID(vhwndFrame, FID_MENU); /* * the frame window procedure is subclassed, so that frame-sizing * restrictions can be implemented. */ if (!WinRegisterClass(vhab, "SUBFRAME", (PFNWP)FrameWndProc, 0L, 0)) return FALSE; vpfnwpFrame = WinSubclassWindow(vhwndFrame, (PFNWP)FrameWndProc); return TRUE; } /* End of InitMainWindow() */
void XToolBar::Attach(void) { frame->frameWin->AddFrameControl(this); WinSetParent(winhandle, frame->frame, TRUE); WinSetOwner(winhandle, frame->frame); LONG x = borderSize, y = borderSize; XRect rect; int width = 0, height = 0; if (style & TB_RIGHT || style & TB_LEFT) { for (int i = 0; i < clients; i++) { clientArray[i]->clientWin->GetSize(&rect); if (clientArray[i]->group) x = borderSize; if (x + clientArray[i]->xOffset + rect.GetWidth() > width) width = x + clientArray[i]->xOffset + rect.GetWidth() + borderSize; x += clientArray[i]->xOffset + rect.GetWidth(); } cx = width; } else { int yy = 0; for (int i = 0; i < clients; i++) { char className[10]; WinQueryClassName(clientArray[i]->clientWin->GetHandle(), 10, (PCH) className); className[0] = ' '; if (atol(className) == 2) { if (yy < borderSize * 2 + 25) yy = borderSize * 2 + 25; } else { clientArray[i]->clientWin->GetSize(&rect); if (yy < rect.GetHeight() + borderSize * 2 + clientArray[i]->yOffset) yy = rect.GetHeight() + borderSize * 2 + clientArray[i]->yOffset; } } cy = yy; } cutWindow = NULL; XRect rect2; frame->GetSize(&rect2); rect2.SetHeight(rect2.GetHeight() - 1); frame->SetSize(&rect2); }
/************************************************************************** * * FUNCTION NAME: HideFrameControls * * DESCRIPTION: * * * INPUT PARAMETERS: * None. * * OUTPUT PARAMETERS: * None. * **************************************************************************/ VOID HideFrameControls (VOID) { RECTL rclTitlebar, rclMenu; /* Make the parent of the frames HWND_OBJECT to effectively remove them */ WinSetParent (hwndTitlebar, HWND_OBJECT, FALSE); WinSetParent (hwndSysmenu, HWND_OBJECT, FALSE); WinSetParent (hwndMinmax, HWND_OBJECT, FALSE); WinSetParent (hwndMenu, HWND_OBJECT, FALSE); WinSendMsg (hwndDefFrame, WM_UPDATEFRAME, MPFROMLONG(FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX | FCF_MENU), MPVOID); /* Reduce the height of the frame once menu and titlebar are gone */ WinQueryWindowRect (hwndMenu, &rclMenu); WinQueryWindowRect (hwndTitlebar, &rclTitlebar); gsFrameHeight -= (SHORT)((rclTitlebar.yTop - rclMenu.yBottom) + (rclMenu.yTop - rclMenu.yBottom)); WinSetWindowPos (hwndDefFrame, HWND_TOP, 0, 0, gsFrameWidth, gsFrameHeight, SWP_SIZE); }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) { static HWND hwndMenuPopup ; HPS hps ; POINTL ptlMouse ; switch (msg) { case WM_CREATE: hwndMenuPopup = WinLoadMenu (hwnd, NULL, ID_POPUP) ; WinSetWindowPos (hwndMenuPopup, NULL, 0, 0, 0, 0, SWP_SIZE) ; WinSetParent (hwndMenuPopup, HWND_DESKTOP, FALSE) ; return 0 ; case WM_BUTTON2UP: WinQueryPointerPos (HWND_DESKTOP, &ptlMouse) ; ptlMouse.y += WinQuerySysValue (HWND_DESKTOP, SV_CYMENU) ; WinSetWindowPos (hwndMenuPopup, NULL, (SHORT) ptlMouse.x, (SHORT) ptlMouse.y, 0, 0, SWP_MOVE) ; WinSendMsg (hwndMenuPopup, MM_SELECTITEM, MPFROM2SHORT (IDM_POPUP, FALSE), MPFROMSHORT (FALSE)) ; WinSetCapture (HWND_DESKTOP, hwndMenuPopup) ; return 0 ; case WM_COMMAND: switch (COMMANDMSG(&msg)->cmd) { case IDM_ABOUT: WinDlgBox (HWND_DESKTOP, hwnd, AboutDlgProc, NULL, IDD_ABOUT, NULL) ; return 0 ; } break ; case WM_PAINT: hps = WinBeginPaint (hwnd, NULL, NULL) ; GpiErase (hps) ; WinEndPaint (hps) ; return 0 ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
nsresult os2FrameWindow::HideWindowChrome(bool aShouldHide) { // Putting a maximized window into fullscreen mode causes multiple // problems if it's later minimized & then restored. To avoid them, // restore maximized windows before putting them in fullscreen mode. if (WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MAXIMIZED) { WinSetWindowPos(mFrameWnd, 0, 0, 0, 0, 0, SWP_RESTORE | SWP_NOREDRAW); } HWND hParent; if (aShouldHide) { hParent = HWND_OBJECT; mChromeHidden = true; } else { hParent = mFrameWnd; mChromeHidden = false; } // Hide or show the frame controls. WinSetParent(mTitleBar, hParent, FALSE); WinSetParent(mSysMenu, hParent, FALSE); WinSetParent(mMinMax, hParent, FALSE); // Modify the frame style, then advise it of the changes. if (aShouldHide) { mSavedStyle = WinQueryWindowULong(mFrameWnd, QWL_STYLE); WinSetWindowULong(mFrameWnd, QWL_STYLE, mSavedStyle & ~FS_SIZEBORDER); WinSendMsg(mFrameWnd, WM_UPDATEFRAME, 0, 0); } else { WinSetWindowULong(mFrameWnd, QWL_STYLE, mSavedStyle); WinSendMsg(mFrameWnd, WM_UPDATEFRAME, MPFROMLONG(FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX), 0); } return NS_OK; }
ToolBarParent :: ToolBarParent(const XResource * r, const XRect& rec, XToolBar * t):XFrameWindow(r, "", FRM_TITLEBAR | FRM_BORDER | FRM_SYSMENU | WIN_VISIBLE, rec) { t->cutWindow = this; init = TRUE; toolBar = t; WinSetParent(t->GetHandle(), frameWin->GetHandle(), TRUE); WinSetOwner(frame, t->frame->frame); SetClient(t); /****************************** ULONG Frame_style = WinQueryWindowULong( frame, QWL_STYLE ); Frame_style = ( Frame_style & ~FS_BORDER ) | FS_SIZEBORDER; WinSetWindowULong( frame, QWL_STYLE, Frame_style ); WinSendMsg( frame, WM_UPDATEFRAME, MPFROMP( FCF_BORDER ), 0 ); ********************************/ Activate(); SetText(t->title); init = FALSE; }
OWindow& OWindow::setParent(const HWND handle) { parent = handle; WinSetParent(hwnd, parent, TRUE); return(*this); }
MRESULT os2FrameWindow::ProcessFrameMessage(ULONG msg, MPARAM mp1, MPARAM mp2) { MRESULT mresult = 0; bool isDone = false; switch (msg) { case WM_WINDOWPOSCHANGED: { PSWP pSwp = (PSWP)mp1; // Don't save the new position or size of a minimized // window, or else it won't be restored correctly. if (pSwp->fl & SWP_MOVE && !(pSwp->fl & SWP_MINIMIZE)) { POINTL ptl = { pSwp->x, pSwp->y + pSwp->cy }; ptl.y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - ptl.y; mFrameBounds.x = ptl.x; mFrameBounds.y = ptl.y; mOwner->DispatchMoveEvent(ptl.x, ptl.y); } // Save the frame's bounds, then call the default wndproc // so the client can handle its WM_WINDOWPOSCHANGED msg now. if (pSwp->fl & SWP_SIZE && !(pSwp->fl & SWP_MINIMIZE)) { mFrameBounds.width = pSwp->cx; mFrameBounds.height = pSwp->cy; mresult = (*mPrevFrameProc)(mFrameWnd, msg, mp1, mp2); isDone = true; } if (pSwp->fl & (SWP_MAXIMIZE | SWP_MINIMIZE | SWP_RESTORE)) { if (mOwner->mWidgetListener) { nsSizeMode mode; if (pSwp->fl & SWP_MAXIMIZE) { mode = nsSizeMode_Maximized; } else if (pSwp->fl & SWP_MINIMIZE) { mode = nsSizeMode_Minimized; } else { mode = nsSizeMode_Normal; } mOwner->mWidgetListener->SizeModeChanged(mode); } } break; } // A frame window in kiosk/fullscreen mode must have its frame // controls reattached before it's minimized & detached after it's // restored. If this doesn't happen at the correct times, clicking // on the icon won't restore it, the sysmenu will have the wrong // items, and/or the minmax button will have the wrong buttons. case WM_ADJUSTWINDOWPOS: if (mChromeHidden && ((PSWP)mp1)->fl & SWP_MINIMIZE) { WinSetParent(mTitleBar, mFrameWnd, TRUE); WinSetParent(mSysMenu, mFrameWnd, TRUE); WinSetParent(mMinMax, mFrameWnd, TRUE); } break; case WM_ADJUSTFRAMEPOS: if (mChromeHidden && ((PSWP)mp1)->fl & SWP_RESTORE) { WinSetParent(mTitleBar, HWND_OBJECT, TRUE); WinSetParent(mSysMenu, HWND_OBJECT, TRUE); WinSetParent(mMinMax, HWND_OBJECT, TRUE); } break; case WM_DESTROY: DEBUGFOCUS(frame WM_DESTROY); WinSubclassWindow(mFrameWnd, mPrevFrameProc); WinSetWindowPtr(mFrameWnd, QWL_USER, 0); break; case WM_INITMENU: // If we are in fullscreen/kiosk mode, disable maximize menu item. if (mChromeHidden && SHORT1FROMMP(mp1) == SC_SYSMENU && WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) { MENUITEM menuitem; WinSendMsg(WinWindowFromID(mFrameWnd, FID_SYSMENU), MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, FALSE), MPARAM(&menuitem)); mresult = (*mPrevFrameProc)(mFrameWnd, msg, mp1, mp2); WinEnableMenuItem(menuitem.hwndSubMenu, SC_MAXIMIZE, FALSE); isDone = true; } break; case WM_SYSCOMMAND: // If we are in fullscreen/kiosk mode, don't honor maximize requests. if (mChromeHidden && SHORT1FROMMP(mp1) == SC_MAXIMIZE && WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) { isDone = true; } break; // When the frame is activated, set a flag to be acted on after // PM has finished changing focus. When deactivated, dispatch // the event immediately because it doesn't affect the focus. case WM_ACTIVATE: DEBUGFOCUS(WM_ACTIVATE); if (mp1) { mNeedActivation = true; } else { mNeedActivation = false; DEBUGFOCUS(NS_DEACTIVATE); mOwner->DispatchActivationEvent(false); // Prevent the frame from automatically focusing any window // when it's reactivated. Let moz set the focus to avoid // having non-widget children of plugins focused in error. WinSetWindowULong(mFrameWnd, QWL_HWNDFOCUSSAVE, 0); } break; } if (!isDone) { mresult = (*mPrevFrameProc)(mFrameWnd, msg, mp1, mp2); } return mresult; }
// Process messages from the frame MRESULT nsFrameWindow::FrameMessage( ULONG msg, MPARAM mp1, MPARAM mp2) { MRESULT mresult = 0; BOOL bDone = FALSE; switch (msg) { case WM_WINDOWPOSCHANGED: { PSWP pSwp = (PSWP) mp1; // Note that client windows never get 'move' messages (well, they won't here anyway) if( pSwp->fl & SWP_MOVE && !(pSwp->fl & SWP_MINIMIZE)) { // These commented-out `-1's cancel each other out. POINTL ptl = { pSwp->x, pSwp->y + pSwp->cy /* - 1 */ }; ptl.y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - ptl.y /* - 1*/ ; mBounds.x = ptl.x; mBounds.y = ptl.y; OnMove( ptl.x, ptl.y); } // When the frame is sized, do stuff to recalculate client size. if( pSwp->fl & SWP_SIZE && !(pSwp->fl & SWP_MINIMIZE)) { mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2); bDone = TRUE; mBounds.width = pSwp->cx; mBounds.height = pSwp->cy; UpdateClientSize(); DispatchResizeEvent( mSizeClient.width, mSizeClient.height); } if (pSwp->fl & (SWP_MAXIMIZE | SWP_MINIMIZE | SWP_RESTORE)) { nsSizeModeEvent event(PR_TRUE, NS_SIZEMODE, this); if (pSwp->fl & SWP_MAXIMIZE) event.mSizeMode = nsSizeMode_Maximized; else if (pSwp->fl & SWP_MINIMIZE) event.mSizeMode = nsSizeMode_Minimized; else event.mSizeMode = nsSizeMode_Normal; InitEvent(event); DispatchWindowEvent(&event); } break; } // a frame window in kiosk/fullscreen mode must have its frame // controls reattached before it's minimized & detached after it's // restored; if this doesn't happen at the correct times, clicking // on the icon won't restore it, the sysmenu will have the wrong // items, and/or the minmax button will have the wrong buttons case WM_ADJUSTWINDOWPOS: { if (mChromeHidden && ((PSWP)mp1)->fl & SWP_MINIMIZE) { HWND hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndMinMax"); if (hwndTemp) WinSetParent(hwndTemp, mFrameWnd, TRUE); hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndTitleBar"); if (hwndTemp) WinSetParent(hwndTemp, mFrameWnd, TRUE); hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndSysMenu"); if (hwndTemp) WinSetParent(hwndTemp, mFrameWnd, TRUE); } break; } case WM_ADJUSTFRAMEPOS: { if (mChromeHidden && ((PSWP)mp1)->fl & SWP_RESTORE) { HWND hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndSysMenu"); if (hwndTemp) WinSetParent(hwndTemp, HWND_OBJECT, TRUE); hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndTitleBar"); if (hwndTemp) WinSetParent(hwndTemp, HWND_OBJECT, TRUE); hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndMinMax"); if (hwndTemp) WinSetParent(hwndTemp, HWND_OBJECT, TRUE); } break; } case WM_DESTROY: DEBUGFOCUS(frame WM_DESTROY); WinSubclassWindow( mFrameWnd, fnwpDefFrame); WinSetWindowPtr( mFrameWnd, QWL_USER, 0); WinRemoveProperty(mFrameWnd, "hwndTitleBar"); WinRemoveProperty(mFrameWnd, "hwndSysMenu"); WinRemoveProperty(mFrameWnd, "hwndMinMax"); WinRemoveProperty(mFrameWnd, "ulStyle"); break; case WM_INITMENU: /* If we are in fullscreen/kiosk mode, disable maximize menu item */ if (mChromeHidden) { if (WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) { if (SHORT1FROMMP(mp1) == SC_SYSMENU) { MENUITEM menuitem; WinSendMsg(WinWindowFromID(mFrameWnd, FID_SYSMENU), MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, FALSE), MPARAM(&menuitem)); mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2); WinEnableMenuItem(menuitem.hwndSubMenu, SC_MAXIMIZE, FALSE); bDone = TRUE; } } } break; case WM_SYSCOMMAND: /* If we are in fullscreen/kiosk mode, don't honor maximize requests */ if (mChromeHidden) { if (WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) { if ((SHORT1FROMMP(mp1) == SC_MAXIMIZE)) { bDone = TRUE; } } } break; // When the frame is activated, set a flag to be acted on after // PM has finished changing focus. When deactivated, dispatch // the event immediately because it doesn't affect the focus. case WM_ACTIVATE: DEBUGFOCUS(WM_ACTIVATE); if (mp1) { mNeedActivation = PR_TRUE; } else { mNeedActivation = PR_FALSE; DEBUGFOCUS(NS_DEACTIVATE); DispatchFocus(NS_DEACTIVATE); // Prevent the frame from automatically focusing any window // when it's reactivated. Let moz set the focus to avoid // having non-widget children of plugins focused in error. WinSetWindowULong(mFrameWnd, QWL_HWNDFOCUSSAVE, 0); } break; } if( !bDone) mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2); return mresult; }