void nsFrameWindow::UpdateClientSize() { RECTL rcl = { 0, 0, mBounds.width, mBounds.height }; WinCalcFrameRect( mFrameWnd, &rcl, TRUE); // provided == frame rect mSizeClient.width = rcl.xRight - rcl.xLeft; mSizeClient.height = rcl.yTop - rcl.yBottom; mSizeBorder.width = (mBounds.width - mSizeClient.width) / 2; mSizeBorder.height = (mBounds.height - mSizeClient.height) / 2; }
nsresult nsFrameWindow::GetClientBounds( nsIntRect &aRect) { RECTL rcl = { 0, 0, mBounds.width, mBounds.height }; WinCalcFrameRect( mFrameWnd, &rcl, TRUE); // provided == frame rect aRect.x = rcl.xLeft; aRect.y = mBounds.height - rcl.yTop; aRect.width = mSizeClient.width; aRect.height = mSizeClient.height; return NS_OK; }
// Set the notebook and top-level dialog sizes based on the page sizes void SetNotebookSize(PNBHDR pNotebookHdr) { int i; RECTL rcl; SWP swp; HWND hwndNB = pNotebookHdr->hwndNB; LONG cx, cy, px, py; (void) memset(&rcl, 0, sizeof(RECTL)); // Get the size of a notebook page by finding the dimensions of the largest // dialog. for (i = 0; i < pNotebookHdr->nPages; i++) { // Get the height and width of the dialog. Also fill in the id of the // item that is to get focus when the dialog is brought up. if (pNotebookHdr->PageArray[i].idDlg) { GetDialogDimensions(pNotebookHdr->PageArray[i].idDlg, &cx, &cy, &(pNotebookHdr->PageArray[i].idFocus)); if (cx > rcl.xRight) rcl.xRight = cx; if (cy > rcl.yTop) rcl.yTop = cy; } } // Adjust the notebook so it is big enough for the pages WinMapDlgPoints(HWND_DESKTOP, (PPOINTL) &rcl, 2, TRUE); WinSendMsg(hwndNB, BKM_CALCPAGERECT, MPFROMP(&rcl), MPFROMLONG(FALSE)); WinSetWindowPos(hwndNB, NULLHANDLE, 0, 0, rcl.xRight-rcl.xLeft, rcl.yTop-rcl.yBottom, SWP_SIZE); // Calculate the size required for the dialog window WinQueryWindowPos(hwndNB, &swp); rcl.xLeft = 0; rcl.yBottom = 0; rcl.xRight = swp.x + swp.cx; rcl.yTop = swp.y + swp.cy; WinCalcFrameRect(pNotebookHdr->hwndNBDlg, &rcl, FALSE ); // Find the centered position and size, and adjust the dialog window so // it is centered, and big enough for the notebook cx = rcl.xRight - rcl.xLeft; cy = rcl.yTop - rcl.yBottom; px = (WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN) - cx) / 2; py = (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - cy) / 2; WinSetWindowPos(pNotebookHdr->hwndNBDlg, NULLHANDLE, px, py, cx, cy, SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ACTIVATE); }
MRESULT EXPENTRY wndFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { HWND hwndClient = WinQueryWindow( hwnd, QW_BOTTOM ); PGROPDATA pGrop = (PGROPDATA)WinQueryWindowULong( hwndClient, 0 ); switch( msg ) { case WM_ADJUSTFRAMEPOS: if ( !pGrop->fInternalResize && !pGrop->pVideoSys->fFreeWinSize && ( (pGrop->stUserMode.ulFlags & GROP_MODEFL_RESIZABLE) == 0 ) && ( (((PSWP)mp1)->fl & (SWP_SIZE | SWP_MINIMIZE)) == SWP_SIZE ) ) { RECTL rectl; rectl.xLeft = 0; rectl.yBottom = 0; rectl.xRight = pGrop->stUserMode.ulWidth; rectl.yTop = pGrop->stUserMode.ulHeight; WinCalcFrameRect( hwnd, &rectl, FALSE ); ((PSWP)mp1)->cx = rectl.xRight - rectl.xLeft; ((PSWP)mp1)->cy = rectl.yTop - rectl.yBottom; } break; case WM_MINMAXFRAME: if ( (((PSWP)mp1)->fl & SWP_MINIMIZE) != 0 ) // To avoid call GROPCALLBACK.fnSize() on window minimization... pGrop->lSkipWinResize++; if ( ( (((PSWP)mp1)->fl & SWP_MAXIMIZE) != 0 ) && !pGrop->fInternalResize && !pGrop->pVideoSys->fFreeWinSize && ( (pGrop->stUserMode.ulFlags & GROP_MODEFL_RESIZABLE) == 0 ) ) ((PSWP)mp1)->fl &= ~(SWP_MAXIMIZE | SWP_MOVE); break; } return pGrop->fnOldFrameWinProc( hwnd, msg, mp1, mp2 ); }
static BOOL _setFullscreen(PGROPDATA pGrop, ULONG ulModeIdx) { PVIDEOMODE pMode = &pGrop->stModes.pList[ulModeIdx]; RECTL rectl; LONG lX, lY, lW, lH; // Move _client_ window to up-left corner of screen, set client window size // equals mode size. rectl.xLeft = 0; rectl.yBottom = 0; rectl.xRight = pMode->ulWidth; rectl.yTop = pMode->ulHeight; WinCalcFrameRect( pGrop->hwndFrame, &rectl, FALSE ); lX = rectl.xLeft; lY = pGrop->ulDTHeight - pMode->ulHeight + rectl.yBottom; lW = rectl.xRight - rectl.xLeft; lH = rectl.yTop - rectl.yBottom; pGrop->fInternalResize = TRUE; WinSetWindowPos( pGrop->hwndFrame, HWND_TOP, lX, lY, lW, lH, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE ); pGrop->fInternalResize = FALSE; _captureMouse( pGrop, TRUE ); #ifdef GROP_NO_MOUSE_IN_FULLSCREEN WinSetPointer( pGrop->hwndDT, NULLHANDLE ); #endif WinPostMsg( pGrop->hwnd, WM_VRNENABLED, 0, 0 ); WinSetVisibleRegionNotify( pGrop->hwnd, FALSE ); if ( !pGrop->pVideoSys->fnSetMode( pGrop->pVSData, pMode, TRUE, pGrop->hwndDT, pGrop->hdcDT ) ) return FALSE; return TRUE; }
static MRESULT EXPENTRY MyFrameWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { vout_display_t *vd = WinQueryWindowPtr( hwnd, 0 ); vout_display_sys_t *sys = vd->sys; switch( msg ) { case WM_QUERYTRACKINFO : { PTRACKINFO pti = ( PTRACKINFO )mp2; RECTL rcl; sys->p_old_frame( hwnd, msg, mp1, mp2 ); pti->rclBoundary.xLeft = 0; pti->rclBoundary.yBottom = 0; pti->rclBoundary.xRight = sys->i_screen_width; pti->rclBoundary.yTop = sys->i_screen_height; WinCalcFrameRect( hwnd, &pti->rclBoundary, FALSE ); pti->ptlMaxTrackSize.x = pti->rclBoundary.xRight - pti->rclBoundary.xLeft; pti->ptlMaxTrackSize.y = pti->rclBoundary.yTop - pti->rclBoundary.yBottom; rcl.xLeft = 0; rcl.yBottom = 0; rcl.xRight = sys->kvas.szlSrcSize.cx + 1; rcl.yTop = sys->kvas.szlSrcSize.cy + 1; WinCalcFrameRect( hwnd, &rcl, FALSE ); pti->ptlMinTrackSize.x = rcl.xRight - rcl.xLeft; pti->ptlMinTrackSize.y = rcl.yTop - rcl.yBottom; return MRFROMLONG( TRUE ); } case WM_ADJUSTWINDOWPOS : { PSWP pswp = ( PSWP )mp1; RECTL rcl; if( pswp->fl & SWP_SIZE ) { rcl.xLeft = pswp->x; rcl.yBottom = pswp->y; rcl.xRight = rcl.xLeft + pswp->cx; rcl.yTop = rcl.yBottom + pswp->cy; WinCalcFrameRect( hwnd, &rcl, TRUE ); if( rcl.xRight - rcl.xLeft <= sys->kvas.szlSrcSize.cx ) rcl.xRight = rcl.xLeft + ( sys->kvas.szlSrcSize.cx + 1 ); if( rcl.yTop - rcl.yBottom <= sys->kvas.szlSrcSize.cy ) rcl.yTop = rcl.yBottom + ( sys->kvas.szlSrcSize.cy + 1 ); if( rcl.xRight - rcl.xLeft > sys->i_screen_width ) { rcl.xLeft = 0; rcl.xRight = sys->i_screen_width; } if( rcl.yTop - rcl.yBottom > sys->i_screen_height ) { rcl.yBottom = 0; rcl.yTop = sys->i_screen_height; } WinCalcFrameRect( hwnd, &rcl, FALSE ); if( pswp->x != rcl.xLeft || pswp->y != rcl.yBottom ) pswp->fl |= SWP_MOVE; pswp->x = rcl.xLeft; pswp->y = rcl.yBottom; pswp->cx = rcl.xRight - rcl.xLeft; pswp->cy = rcl.yTop - rcl.yBottom; } break; } } return sys->p_old_frame( hwnd, msg, mp1, mp2 ); }
/***************************************************************************** * OpenDisplay: open and initialize KVA device ***************************************************************************** * Open and initialize display according to preferences specified in the vout * thread fields. *****************************************************************************/ static int OpenDisplay( vout_display_t *vd, video_format_t *fmt ) { vout_display_sys_t * sys = vd->sys; const vlc_fourcc_t *fallback; bool b_hw_accel = 0; FOURCC i_kva_fourcc; int i_chroma_shift; char sz_title[ 256 ]; RECTL rcl; int w, h; msg_Dbg( vd, "render chroma = %4.4s", ( const char * )&fmt->i_chroma ); for( int pass = 0; pass < 2 && !b_hw_accel; pass++ ) { fallback = ( pass == 0 ) ? vlc_fourcc_GetYUVFallback( fmt->i_chroma ) : vlc_fourcc_GetRGBFallback( fmt->i_chroma ); for( int i = 0; fallback[ i ]; i++ ) { switch( fallback[ i ]) { case VLC_CODEC_YV12: b_hw_accel = sys->kvac.ulInputFormatFlags & KVAF_YV12; i_kva_fourcc = FOURCC_YV12; i_chroma_shift = 1; break; case VLC_CODEC_YUYV: b_hw_accel = sys->kvac.ulInputFormatFlags & KVAF_YUY2; i_kva_fourcc = FOURCC_Y422; i_chroma_shift = 0; break; case VLC_CODEC_YV9: b_hw_accel = sys->kvac.ulInputFormatFlags & KVAF_YVU9; i_kva_fourcc = FOURCC_YVU9; i_chroma_shift = 2; break; case VLC_CODEC_RGB32: b_hw_accel = sys->kvac.ulInputFormatFlags & KVAF_BGR32; i_kva_fourcc = FOURCC_BGR4; i_chroma_shift = 0; break; case VLC_CODEC_RGB24: b_hw_accel = sys->kvac.ulInputFormatFlags & KVAF_BGR24; i_kva_fourcc = FOURCC_BGR3; i_chroma_shift = 0; break; case VLC_CODEC_RGB16: b_hw_accel = sys->kvac.ulInputFormatFlags & KVAF_BGR16; i_kva_fourcc = FOURCC_R565; i_chroma_shift = 0; break; case VLC_CODEC_RGB15: b_hw_accel = sys->kvac.ulInputFormatFlags & KVAF_BGR15; i_kva_fourcc = FOURCC_R555; i_chroma_shift = 0; break; } if( b_hw_accel ) { fmt->i_chroma = fallback[ i ]; break; } } } if( !b_hw_accel ) { msg_Err( vd, "Ooops. There is no fourcc supported by KVA at all."); return VLC_EGENERIC; } /* Set the RGB masks */ fmt->i_rmask = sys->kvac.ulRMask; fmt->i_gmask = sys->kvac.ulGMask; fmt->i_bmask = sys->kvac.ulBMask; msg_Dbg( vd, "output chroma = %4.4s", ( const char * )&fmt->i_chroma ); msg_Dbg( vd, "KVA chroma = %4.4s", ( const char * )&i_kva_fourcc ); w = vd->source.i_width; h = vd->source.i_height; sys->kvas.ulLength = sizeof( KVASETUP ); sys->kvas.szlSrcSize.cx = w; sys->kvas.szlSrcSize.cy = h; sys->kvas.rclSrcRect.xLeft = 0; sys->kvas.rclSrcRect.yTop = 0; sys->kvas.rclSrcRect.xRight = w; sys->kvas.rclSrcRect.yBottom = h; sys->kvas.ulRatio = KVAR_FORCEANY; sys->kvas.ulAspectWidth = w; sys->kvas.ulAspectHeight = h; sys->kvas.fccSrcColor = i_kva_fourcc; sys->kvas.fDither = TRUE; if( kvaSetup( &sys->kvas )) { msg_Err( vd, "cannot set up KVA"); return VLC_EGENERIC; } /* Create the associated picture */ picture_resource_t *rsc = &sys->resource; rsc->p_sys = malloc( sizeof( *rsc->p_sys )); if( !rsc->p_sys ) return VLC_EGENERIC; rsc->p_sys->i_chroma_shift = i_chroma_shift; for( int i = 0; i < PICTURE_PLANE_MAX; i++ ) { rsc->p[ i ].p_pixels = NULL; rsc->p[ i ].i_pitch = 0; rsc->p[ i ].i_lines = 0; } picture_t *picture = picture_NewFromResource( fmt, rsc ); if( !picture ) goto exit_picture; /* Wrap it into a picture pool */ picture_pool_configuration_t pool_cfg; memset( &pool_cfg, 0, sizeof( pool_cfg )); pool_cfg.picture_count = 1; pool_cfg.picture = &picture; pool_cfg.lock = KVALock; pool_cfg.unlock = KVAUnlock; sys->pool = picture_pool_NewExtended( &pool_cfg ); if( !sys->pool ) { picture_Release( picture ); goto exit_picture; } if (vd->cfg->display.title) snprintf( sz_title, sizeof( sz_title ), "%s", vd->cfg->display.title ); else snprintf( sz_title, sizeof( sz_title ), "%s (%4.4s to %4.4s - %s mode KVA output)", VOUT_TITLE, ( char * )&vd->fmt.i_chroma, ( char * )&sys->kvas.fccSrcColor, psz_video_mode[ sys->kvac.ulMode - 1 ]); WinSetWindowText( sys->frame, sz_title ); sys->i_screen_width = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); sys->i_screen_height = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); if( sys->parent_window ) WinQueryWindowRect( sys->parent, &sys->client_rect ); else { sys->client_rect.xLeft = ( sys->i_screen_width - w ) / 2; sys->client_rect.yBottom = ( sys->i_screen_height - h ) / 2 ; sys->client_rect.xRight = sys->client_rect.xLeft + w; sys->client_rect.yTop = sys->client_rect.yBottom + h; } rcl = sys->client_rect; WinCalcFrameRect( sys->frame, &rcl, FALSE); WinSetWindowPos( sys->frame, HWND_TOP, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW | SWP_ACTIVATE ); return VLC_SUCCESS; exit_picture: free( rsc->p_sys ); return VLC_EGENERIC; }
HWND os2FrameWindow::CreateFrameWindow(nsWindow* aParent, HWND aParentWnd, const nsIntRect& aRect, nsWindowType aWindowType, nsBorderStyle aBorderStyle) { // Create a frame window with a MozillaWindowClass window as its client. HWND hClient; uint32_t fcfFlags = GetFCFlags(aWindowType, aBorderStyle); mFrameWnd = WinCreateStdWindow(HWND_DESKTOP, 0, (ULONG*)&fcfFlags, kWindowClassName, "Title", WS_CLIPCHILDREN, NULLHANDLE, 0, &hClient); if (!mFrameWnd) { return 0; } // Hide from the Window List until shown. SetWindowListVisibility(false); // This prevents a modal dialog from being covered by its disabled parent. if (aParentWnd != HWND_DESKTOP) { WinSetOwner(mFrameWnd, aParentWnd); } // Get the frame control HWNDs for use by fullscreen mode. mTitleBar = WinWindowFromID(mFrameWnd, FID_TITLEBAR); mSysMenu = WinWindowFromID(mFrameWnd, FID_SYSMENU); mMinMax = WinWindowFromID(mFrameWnd, FID_MINMAX); // Calc the size of a frame needed to contain a client area of the // specified width & height. Without this, eWindowType_dialog windows // will be truncated (toplevel windows will still display correctly). RECTL rcl = {0, 0, aRect.width, aRect.height}; WinCalcFrameRect(mFrameWnd, &rcl, FALSE); mFrameBounds = nsIntRect(aRect.x, aRect.y, rcl.xRight-rcl.xLeft, rcl.yTop-rcl.yBottom); // Move & resize the frame. int32_t pmY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - mFrameBounds.y - mFrameBounds.height; WinSetWindowPos(mFrameWnd, 0, mFrameBounds.x, pmY, mFrameBounds.width, mFrameBounds.height, SWP_SIZE | SWP_MOVE); // Store the client's bounds. For windows with resizable borders, // the width includes the width of the frame controls (minmax, etc.). SWP swp; WinQueryWindowPos(hClient, &swp); mOwner->SetBounds(nsIntRect(swp.x, mFrameBounds.height - swp.y - swp.cy, swp.cx, swp.cy)); // Subclass the frame. mPrevFrameProc = WinSubclassWindow(mFrameWnd, fnwpFrame); WinSetWindowPtr(mFrameWnd, QWL_USER, this); DEBUGFOCUS(Create os2FrameWindow); return hClient; }
int winmain() { HAB hab = NULLHANDLE; HMQ hmq = NULLHANDLE; QMSG qmsg; HWND hwndFrame = NULLHANDLE; HWND hwndClient = NULLHANDLE; ULONG ctlData = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_TASKLIST | FCF_MENU | FCF_ACCELTABLE | FCF_NOBYTEALIGN | FCF_ICON; RECTL rectl; do { if ((hab = WinInitialize(0)) == NULLHANDLE) break; if ((hmq = WinCreateMsgQueue(hab,0)) == NULLHANDLE) break; if (!WinRegisterClass(hab, APPCLASS, ClientWndProc, CS_SIZEREDRAW, 4)) break; // Register the HanMLE and HanInputAutomata window class if (!RegisterHanAutomataClass(hab)) break; if (!RegisterHanMLEControl(hab)) break; if (!RegisterHanStaticTextControl(hab)) break; if (!RegisterHanEntryFieldControl(hab)) break; if (!RegisterStatbarControl(hab)) break; if (!RegisterToolbarControl(hab)) break; if ((hwndFrame = WinCreateStdWindow( HWND_DESKTOP, 0, &ctlData, APPCLASS, APPTITLE, 0, NULLHANDLE, ID_APP, &hwndClient )) == NULLHANDLE ) { printf("errorcode: %x\n",WinGetLastError(hab)); break; } //printf("Frame: %x\nClient: %x\n",hwndFrame,hwndClient); rectl.xLeft = 0; rectl.yBottom = 0; rectl.xRight = xSize; rectl.yTop = ySize; WinSendMsg(hwndClient,HEWM_CALCRECT,(MPARAM)&rectl,0); WinCalcFrameRect(hwndFrame,&rectl,FALSE); WinSetWindowPos(hwndFrame,NULLHANDLE, xLeft,yBottom, rectl.xRight-rectl.xLeft,rectl.yTop-rectl.yBottom, SWP_MOVE|SWP_SIZE|SWP_SHOW); WinSetFocus(HWND_DESKTOP,hwndFrame); houtInit(hab,maxLineSize); if (use_externalengfont) houtSetEngFont(external_engfontbuf); if (use_externalhanfont) houtSetHanFont(external_hanfontbuf); if (use_externalspecfont) houtSetSpecFont(external_specfontbuf); if (use_externalhanjafont) houtSetHanjaFont(external_hanjafontbuf); while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) { WinDispatchMsg(hab, &qmsg); } houtClose(); } while (FALSE); if (hmq != NULLHANDLE) WinDestroyMsgQueue(hmq); if (hab != NULLHANDLE) WinTerminate(hab); return 0; }
static VOID arrangeItems(HWND hwnd, PSWP pswp) { SWP aswp[23]; RECTL r = {0, 0, pswp->cx, pswp->cy}; WinCalcFrameRect(hwnd, &r, TRUE); initItemsSwp(hwnd, aswp); aswp[RI_DTGRP3].x = r.xLeft + 2; aswp[RI_DTGRP3].y = r.yBottom + 2; aswp[RI_DTGRP3].cx = (r.xRight - aswp[RI_DTGRP3].x) / 2 - 1; aswp[RI_DTGRP3].cy = (r.yTop - aswp[RI_DTGRP3].y) / 2 - 5; aswp[RI_DTBTN9].x = aswp[RI_DTGRP3].x + 6; aswp[RI_DTBTN9].y = aswp[RI_DTGRP3].y + 6; aswp[RI_DTBTN9].cx = aswp[RI_DTGRP3].cx / 2 - 15; aswp[RI_DTBTN9].cy = (aswp[RI_DTGRP3].cy - 40) / 5; aswp[RI_DTBTN10].x = aswp[RI_DTBTN9].x + aswp[RI_DTBTN9].cx + 3; aswp[RI_DTBTN10].y = aswp[RI_DTBTN9].y; aswp[RI_DTBTN10].cx = aswp[RI_DTBTN9].cx; aswp[RI_DTBTN10].cy = aswp[RI_DTBTN9].cy; aswp[RI_DTBTN7].x = aswp[RI_DTBTN9].x; aswp[RI_DTBTN7].y = aswp[RI_DTBTN9].y + aswp[RI_DTBTN9].cy + 4; aswp[RI_DTBTN7].cx = aswp[RI_DTBTN9].cx; aswp[RI_DTBTN7].cy = aswp[RI_DTBTN9].cy; aswp[RI_DTBTN8].x = aswp[RI_DTBTN10].x; aswp[RI_DTBTN8].y = aswp[RI_DTBTN7].y; aswp[RI_DTBTN8].cx = aswp[RI_DTBTN9].cx; aswp[RI_DTBTN8].cy = aswp[RI_DTBTN9].cy; aswp[RI_DTBTN5].x = aswp[RI_DTBTN9].x; aswp[RI_DTBTN5].y = aswp[RI_DTBTN7].y + aswp[RI_DTBTN7].cy + 4; aswp[RI_DTBTN5].cx = aswp[RI_DTBTN9].cx; aswp[RI_DTBTN5].cy = aswp[RI_DTBTN9].cy; aswp[RI_DTBTN6].x = aswp[RI_DTBTN10].x; aswp[RI_DTBTN6].y = aswp[RI_DTBTN5].y; aswp[RI_DTBTN6].cx = aswp[RI_DTBTN9].cx; aswp[RI_DTBTN6].cy = aswp[RI_DTBTN9].cy; aswp[RI_DTBTN3].x = aswp[RI_DTBTN9].x; aswp[RI_DTBTN3].y = aswp[RI_DTBTN5].y + aswp[RI_DTBTN5].cy + 4; aswp[RI_DTBTN3].cx = aswp[RI_DTBTN9].cx; aswp[RI_DTBTN3].cy = aswp[RI_DTBTN9].cy; aswp[RI_DTBTN4].x = aswp[RI_DTBTN10].x; aswp[RI_DTBTN4].y = aswp[RI_DTBTN3].y; aswp[RI_DTBTN4].cx = aswp[RI_DTBTN9].cx; aswp[RI_DTBTN4].cy = aswp[RI_DTBTN9].cy; aswp[RI_DTBTN1].x = aswp[RI_DTBTN9].x; aswp[RI_DTBTN1].y = aswp[RI_DTBTN3].y + aswp[RI_DTBTN3].cy + 4; aswp[RI_DTBTN1].cx = aswp[RI_DTBTN9].cx; aswp[RI_DTBTN1].cy = aswp[RI_DTBTN9].cy; aswp[RI_DTBTN2].x = aswp[RI_DTBTN10].x; aswp[RI_DTBTN2].y = aswp[RI_DTBTN1].y; aswp[RI_DTBTN2].cx = aswp[RI_DTBTN9].cx; aswp[RI_DTBTN2].cy = aswp[RI_DTBTN9].cy; aswp[RI_DTGRP4].x = aswp[RI_DTGRP3].x + aswp[RI_DTGRP3].cx + 3; aswp[RI_DTGRP4].y = aswp[RI_DTGRP3].y; aswp[RI_DTGRP4].cx = aswp[RI_DTGRP3].cx; aswp[RI_DTGRP4].cy = aswp[RI_DTGRP3].cy; aswp[RI_DTLBOX].x = aswp[RI_DTGRP4].x + 6; aswp[RI_DTLBOX].y = aswp[RI_DTGRP4].y + 6; aswp[RI_DTLBOX].cx = aswp[RI_DTGRP4].cx - 12; aswp[RI_DTLBOX].cy = aswp[RI_DTGRP4].cy - 28; aswp[RI_DTGRP1].x = aswp[RI_DTGRP3].x; aswp[RI_DTGRP1].y = aswp[RI_DTGRP3].y + aswp[RI_DTGRP3].cy + 10; aswp[RI_DTGRP1].cx = aswp[RI_DTGRP3].cx; aswp[RI_DTGRP1].cy = aswp[RI_DTGRP3].cy; aswp[RI_DTMLE].x = aswp[RI_DTGRP1].x + 6; aswp[RI_DTMLE].y = aswp[RI_DTGRP1].y + 6; aswp[RI_DTMLE].cx = aswp[RI_DTGRP1].cx - 12; aswp[RI_DTMLE].cy = aswp[RI_DTGRP1].cy - 28; aswp[RI_DTDTGRP2].x = aswp[RI_DTGRP4].x; aswp[RI_DTDTGRP2].y = aswp[RI_DTGRP1].y; aswp[RI_DTDTGRP2].cx = aswp[RI_DTGRP3].cx; aswp[RI_DTDTGRP2].cy = aswp[RI_DTGRP3].cy; aswp[RI_DTRDBTN7].x = aswp[RI_DTDTGRP2].x + 8; aswp[RI_DTRDBTN7].y = aswp[RI_DTDTGRP2].y + 8; aswp[RI_DTRDBTN7].cx = aswp[RI_DTDTGRP2].cx - 12; aswp[RI_DTRDBTN7].cy = (aswp[RI_DTDTGRP2].cy - 24) / 7; aswp[RI_DTRDBTN6].x = aswp[RI_DTRDBTN7].x; aswp[RI_DTRDBTN6].y = aswp[RI_DTRDBTN7].y + aswp[RI_DTRDBTN7].cy; aswp[RI_DTRDBTN6].cx = aswp[RI_DTRDBTN7].cx; aswp[RI_DTRDBTN6].cy = aswp[RI_DTRDBTN7].cy; aswp[RI_DTRDBTN5].x = aswp[RI_DTRDBTN7].x; aswp[RI_DTRDBTN5].y = aswp[RI_DTRDBTN6].y + aswp[RI_DTRDBTN6].cy; aswp[RI_DTRDBTN5].cx = aswp[RI_DTRDBTN7].cx; aswp[RI_DTRDBTN5].cy = aswp[RI_DTRDBTN7].cy; aswp[RI_DTRDBTN4].x = aswp[RI_DTRDBTN7].x; aswp[RI_DTRDBTN4].y = aswp[RI_DTRDBTN5].y + aswp[RI_DTRDBTN5].cy; aswp[RI_DTRDBTN4].cx = aswp[RI_DTRDBTN7].cx; aswp[RI_DTRDBTN4].cy = aswp[RI_DTRDBTN7].cy; aswp[RI_DTRDBTN3].x = aswp[RI_DTRDBTN7].x; aswp[RI_DTRDBTN3].y = aswp[RI_DTRDBTN4].y + aswp[RI_DTRDBTN4].cy; aswp[RI_DTRDBTN3].cx = aswp[RI_DTRDBTN7].cx; aswp[RI_DTRDBTN3].cy = aswp[RI_DTRDBTN7].cy; aswp[RI_DTRDBTN2].x = aswp[RI_DTRDBTN7].x; aswp[RI_DTRDBTN2].y = aswp[RI_DTRDBTN3].y + aswp[RI_DTRDBTN3].cy; aswp[RI_DTRDBTN2].cx = aswp[RI_DTRDBTN7].cx; aswp[RI_DTRDBTN2].cy = aswp[RI_DTRDBTN7].cy; aswp[RI_DTRDBTN1].x = aswp[RI_DTRDBTN7].x; aswp[RI_DTRDBTN1].y = aswp[RI_DTRDBTN2].y + aswp[RI_DTRDBTN2].cy; aswp[RI_DTRDBTN1].cx = aswp[RI_DTRDBTN7].cx; aswp[RI_DTRDBTN1].cy = aswp[RI_DTRDBTN7].cy; WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), aswp, 23); }
MRESULT EXPENTRY fnwpClient(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2) { RECTL rcl; USHORT Command; ULONG *pulPtr; switch(msg) { case WM_CREATE: stCell.cy = 12; stCell.cx = 8; hdcPs = WinOpenWindowDC(hwnd); /****************************************************************/ /* Set the size and position of the frame window by making the */ /* client area width and height integral numbers of AVIO cell */ /* units. Calculate the frame window values necessary to */ /* achieve this. */ /****************************************************************/ rcl.yBottom = 0L; rcl.xLeft = 0L; rcl.yTop = 20 * stCell.cy; rcl.xRight = 40 * stCell.cx; WinCalcFrameRect(WinQueryWindow(hwnd,QW_PARENT),&rcl,FALSE); WinSetWindowPos(WinQueryWindow(hwnd,QW_PARENT), 0, 7 * stCell.cx, 2 * stCell.cy, (SHORT)(rcl.xRight - rcl.xLeft), (SHORT)(rcl.yTop - rcl.yBottom), SWP_MOVE | SWP_SIZE); WinPostMsg(hwnd,UM_INIT,0L,0L); break; case WM_ACTIVATE: if(LOUSHORT(LONGFROMMP(mp1))) WinSetFocus(HWND_DESKTOP,hwnd); break; case UM_INIT: if (szPortName[0] != 0) WinSetWindowText(hwndFrame,szPortName); else MenuItemEnable(hwndFrame,IDM_PROCESS,FALSE); WinShowWindow(hwndFrame,TRUE); WinQueryWindowRect(hwndClient,&rcl); ulWindowWidth = rcl.xRight; ulWindowHeight = rcl.yTop; ClearScreen(); break; case WM_PAINT: Paint(); break; case WM_SIZE: WndSize(hwnd,mp2); ClearScreen(); return WinDefWindowProc(hwnd,msg,mp1,mp2); case WM_COMMAND: switch (SHORT1FROMMP(mp1)) { case IDM_SELECT: if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)fnwpSelectPortDlg, (USHORT)NULL, PS_DLG, NULL)) WinSetWindowText(hwndFrame,szPortDesc); break; case IDM_RECOVER_USER_INI: RecoverProfile(HINI_USERPROFILE); break; case IDM_RECOVER_SYS_INI: RecoverProfile(HINI_SYSTEMPROFILE); break; case IDM_EXIT: WinPostMsg(hwnd,WM_QUIT,0L,0L); break; case IDM_SETUP: SetupPort(); break; case IDM_REMOVE: RemovePort(); break; case IDM_INSTALL: InstallPort(); break; case IDM_INIT: InitializePort(); break; case IDM_TERM: TerminatePort(); // TerminatePort(szPortName); break; case IDM_QUERY: ulItemCount = QueryPort(achBuffer,4096); break; default: return WinDefWindowProc(hwnd,msg,mp1,mp2); } break; case WM_CLOSE: WinPostMsg(hwnd,WM_QUIT,0L,0L); /* Cause termination */ break; default: return WinDefWindowProc(hwnd,msg,mp1,mp2); } return(FALSE); }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static CHAR *szButtonLabel[] = { "Smaller", "Larger" } ; static HWND hwndFrame, hwndButton[2] ; static INT cxClient, cyClient, cxChar, cyChar ; FONTMETRICS fm ; HPS hps ; INT id ; RECTL rcl ; switch (msg) { case WM_CREATE : hwndFrame = WinQueryWindow (hwnd, QW_PARENT) ; hps = WinGetPS (hwnd) ; GpiQueryFontMetrics (hps, sizeof fm, &fm) ; cxChar = fm.lAveCharWidth ; cyChar = fm.lMaxBaselineExt ; WinReleasePS (hps) ; for (id = 0 ; id < 2 ; id++) hwndButton[id] = WinCreateWindow ( hwnd, // Parent WC_BUTTON, // Class szButtonLabel[id], // Text WS_VISIBLE | // Style BS_PUSHBUTTON, 0, 0, // Position 12 * cxChar, // Width 2 * cyChar, // Height hwnd, // Owner HWND_BOTTOM, // Placement id, // ID NULL, // Ctrl Data NULL) ; // Pres Params return 0 ; case WM_SIZE : cxClient = SHORT1FROMMP (mp2) ; cyClient = SHORT2FROMMP (mp2) ; for (id = 0 ; id < 2 ; id++) WinSetWindowPos (hwndButton[id], NULLHANDLE, cxClient / 2 + (14 * id - 13) * cxChar, (cyClient - 2 * cyChar) / 2, 0, 0, SWP_MOVE) ; return 0 ; case WM_COMMAND: WinQueryWindowRect (hwnd, &rcl) ; WinMapWindowPoints (hwnd, HWND_DESKTOP, (PPOINTL) &rcl, 2) ; switch (COMMANDMSG(&msg)->cmd) // Child ID { case 0: // "Smaller" rcl.xLeft += cxClient / 20 ; rcl.xRight -= cxClient / 20 ; rcl.yBottom += cyClient / 20 ; rcl.yTop -= cyClient / 20 ; break ; case 1: // "Larger" rcl.xLeft -= cxClient / 20 ; rcl.xRight += cxClient / 20 ; rcl.yBottom -= cyClient / 20 ; rcl.yTop += cyClient / 20 ; break ; } WinCalcFrameRect (hwndFrame, &rcl, FALSE) ; WinSetWindowPos (hwndFrame, NULLHANDLE, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_MOVE | SWP_SIZE) ; return 0 ; case WM_ERASEBACKGROUND: return MRFROMSHORT (1) ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
MRESULT EXPENTRY ClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static HWND hwndFrame, hwndButton[10]; static INT cxClient, cyClient, cyChar; static LONG ButtonWidth, ButtonHeight; static CLR buttonColour; CHAR szBuffer[32]; FONTMETRICS fm; HAB hab; HPS hps; INT id; RECTL rcl; switch(msg) { case WM_CREATE: hab = WinQueryAnchorBlock(hwnd); hwndFrame = WinQueryWindow(hwnd, QW_PARENT); hps = WinGetPS(hwnd); GpiQueryFontMetrics(hps, sizeof(fm),&fm); cyChar = fm.lMaxBaselineExt; WinReleasePS(hps); buttonColour.Index = 0x00CCCCCC; // Buttons should be big enough to hold the pointer, with a 4 pixel border ButtonWidth = WinQuerySysValue(HWND_DESKTOP, SV_CXPOINTER) + 4; ButtonHeight = WinQuerySysValue(HWND_DESKTOP, SV_CYPOINTER) + 4; hwndButton[0] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "100", WS_VISIBLE | GBT_NORIGHTLINE | GBT_GRAPHIC, 0, 0, ButtonWidth, ButtonHeight, hwnd, HWND_BOTTOM, 0, NULL, NULL); hwndButton[1] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "101", WS_VISIBLE | GBT_NOLEFTLINE | GBT_GRAPHIC, 0, 0, ButtonWidth, ButtonHeight, hwnd, HWND_BOTTOM, 1, NULL, NULL); // This is the status bar hwndButton[2] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "Status Bar", WS_VISIBLE | GBT_NOPUSH, 0, 0, 0, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 2, NULL, NULL); sprintf(szBuffer, "Red: %d Green: %d Blue: %d", buttonColour.rgb.red, buttonColour.rgb.green, buttonColour.rgb.blue); WinSetWindowText(hwndButton[2], szBuffer); // Buttons to change the colour of the about button hwndButton[3] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "<", WS_VISIBLE | GBT_NORIGHTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 3, NULL, NULL); hwndButton[4] = WinCreateWindow(hwnd, SHADEDBTNCLASS, ">", WS_VISIBLE | GBT_NOLEFTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 4, NULL, NULL); hwndButton[5] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "<", WS_VISIBLE | GBT_NORIGHTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 5, NULL, NULL); hwndButton[6] = WinCreateWindow(hwnd, SHADEDBTNCLASS, ">", WS_VISIBLE | GBT_NOLEFTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 6, NULL, NULL); hwndButton[7] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "<", WS_VISIBLE | GBT_NORIGHTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 7, NULL, NULL); hwndButton[8] = WinCreateWindow(hwnd, SHADEDBTNCLASS, ">", WS_VISIBLE | GBT_NOLEFTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 8, NULL, NULL); // info about this program hwndButton[9] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "About", WS_VISIBLE | GBT_RIGHTROUND | GBT_LEFTROUND, 0, 0, 2 * ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 9, NULL, NULL); // change the colour of the buttons WinSendMsg(hwndButton[3], GBM_SETCOLOR, MPFROMLONG(0x00FFCCCC), NULL); WinSendMsg(hwndButton[4], GBM_SETCOLOR, MPFROMLONG(0x00FFCCCC), NULL); WinSendMsg(hwndButton[5], GBM_SETCOLOR, MPFROMLONG(0x00CCFFCC), NULL); WinSendMsg(hwndButton[6], GBM_SETCOLOR, MPFROMLONG(0x00CCFFCC), NULL); WinSendMsg(hwndButton[7], GBM_SETCOLOR, MPFROMLONG(0x00CCCCFF), NULL); WinSendMsg(hwndButton[8], GBM_SETCOLOR, MPFROMLONG(0x00CCCCFF), NULL); WinSendMsg(hwndButton[9], GBM_SETCOLOR, MPFROMLONG(buttonColour.Index), NULL); return 0; case WM_SIZE: hps = WinGetPS(hwnd); GpiQueryFontMetrics(hps, sizeof(fm),&fm); cyChar = fm.lMaxBaselineExt; WinReleasePS(hps); cxClient = SHORT1FROMMP(mp2); cyClient = SHORT2FROMMP(mp2); // Center the buttons for(id = 0; id < 2; id++) WinSetWindowPos(hwndButton[id], NULLHANDLE, (cxClient >> 1) + ButtonWidth * (id - 1), (cyClient - ButtonHeight) >> 1, 0, 0, SWP_MOVE); for(id = 3; id < 9; id++) WinSetWindowPos(hwndButton[id], NULLHANDLE, (cxClient >> 1) + ButtonWidth * (-(id % 2)), ((cyClient + ButtonHeight) >> 1) + (3 - (id-1) / 2) * cyChar * 5 / 4, 0, 0, SWP_MOVE); WinSetWindowPos(hwndButton[9], NULLHANDLE, (cxClient >> 1) - ButtonWidth, ((cyClient - ButtonHeight) >> 1) - cyChar * 15 / 8, 0, 0, SWP_MOVE); // make the status bar span the width of the window WinSetWindowPos(hwndButton[2], NULLHANDLE, 0, 0, cxClient, cyChar * 5 / 4, SWP_SIZE); // Enable "Smaller" button if window is large enough for the buttons if (!WinIsWindowEnabled(hwndButton[0]) && ((9 * cxClient / 10) >= (2 * ButtonWidth)) && ((9 * cyClient / 10) >= (ButtonHeight + cyChar * 15 / 2))) WinEnableWindow(hwndButton[0], TRUE); // Disable "Smaller" button if window is too small for the buttons if (WinIsWindowEnabled(hwndButton[0]) && (((9 * cxClient / 10) < (2 * ButtonWidth)) || ((9 * cyClient / 10) < (ButtonHeight + cyChar * 15 / 2)))) WinEnableWindow(hwndButton[0], FALSE); return 0; case WM_COMMAND: WinQueryWindowRect(hwnd, &rcl); WinMapWindowPoints(hwnd, HWND_DESKTOP, (PPOINTL) &rcl, 2); switch(COMMANDMSG(&msg)->cmd) { case 0: // "Smaller" rcl.xLeft += cxClient / 20; rcl.xRight -= cxClient / 20; rcl.yBottom += cyClient / 20; rcl.yTop -= cyClient / 20; break; case 1: // "Larger" rcl.xLeft -= cxClient / 20; rcl.xRight += cxClient / 20; rcl.yBottom -= cyClient / 20; rcl.yTop += cyClient / 20; break; case 3: // change red buttonColour.rgb.red--; if (buttonColour.rgb.red == 0) WinEnableWindow(hwndButton[3], FALSE); if (!WinIsWindowEnabled(hwndButton[4])) WinEnableWindow(hwndButton[4], TRUE); break; case 4: buttonColour.rgb.red++; if (buttonColour.rgb.red == 255) WinEnableWindow(hwndButton[4], FALSE); if (!WinIsWindowEnabled(hwndButton[3])) WinEnableWindow(hwndButton[3], TRUE); break; case 5: // change green buttonColour.rgb.green--; if (buttonColour.rgb.green == 0) WinEnableWindow(hwndButton[5], FALSE); if (!WinIsWindowEnabled(hwndButton[6])) WinEnableWindow(hwndButton[6], TRUE); break; case 6: buttonColour.rgb.green++; if (buttonColour.rgb.green == 255) WinEnableWindow(hwndButton[6], FALSE); if (!WinIsWindowEnabled(hwndButton[5])) WinEnableWindow(hwndButton[5], TRUE); break; case 7:// change blue buttonColour.rgb.blue--; if (buttonColour.rgb.blue == 0) WinEnableWindow(hwndButton[7], FALSE); if (!WinIsWindowEnabled(hwndButton[8])) WinEnableWindow(hwndButton[8], TRUE); break; case 8: buttonColour.rgb.blue++; if (buttonColour.rgb.blue == 255) WinEnableWindow(hwndButton[8], FALSE); if (!WinIsWindowEnabled(hwndButton[7])) WinEnableWindow(hwndButton[7], TRUE); break; case 9: WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, NULLHANDLE, IDD_ABOUT, NULL); return 0; } sprintf(szBuffer, "Red: %d Green: %d Blue: %d", buttonColour.rgb.red, buttonColour.rgb.green, buttonColour.rgb.blue); WinSetWindowText(hwndButton[2], szBuffer); WinCalcFrameRect(hwndFrame, &rcl, FALSE); WinSetWindowPos(hwndFrame, NULLHANDLE, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_MOVE | SWP_SIZE); WinPostMsg(hwndButton[9], GBM_SETCOLOR, MPFROMLONG(buttonColour.Index), NULL); return 0; case WM_ERASEBACKGROUND: WinFillRect((HPS)LONGFROMMP(mp1), PVOIDFROMMP(mp2), CLR_PALEGRAY); return 0; } return WinDefWindowProc(hwnd, msg, mp1, mp2); }
static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { vout_display_t * vd = WinQueryWindowPtr( hwnd, 0 ); MRESULT result = ( MRESULT )TRUE; if ( !vd ) return WinDefWindowProc( hwnd, msg, mp1, mp2 ); vout_display_sys_t * sys = vd->sys; RECTL rcl; SWP swp; if ( sys->is_mouse_hidden && ((msg >= WM_MOUSEFIRST && msg <= WM_MOUSELAST) || (msg >= WM_EXTMOUSEFIRST && msg <= WM_EXTMOUSELAST) || msg == WM_MOUSELEAVE)) { WinShowPointer(HWND_DESKTOP, TRUE); sys->is_mouse_hidden = false; } switch( msg ) { /* the user wants to close the window */ case WM_CLOSE: vout_display_SendEventClose(vd); result = 0; break; case WM_MOUSEMOVE : { SHORT i_mouse_x = SHORT1FROMMP( mp1 ); SHORT i_mouse_y = SHORT2FROMMP( mp1 ); RECTL movie_rect; int i_movie_width, i_movie_height; int i_src_width, i_src_height; /* Get a current movie area */ kvaAdjustDstRect( &sys->kvas.rclSrcRect, &movie_rect ); i_movie_width = movie_rect.xRight - movie_rect.xLeft; i_movie_height = movie_rect.yTop - movie_rect.yBottom; i_src_width = sys->kvas.rclSrcRect.xRight - sys->kvas.rclSrcRect.xLeft; i_src_height = sys->kvas.rclSrcRect.yBottom - sys->kvas.rclSrcRect.yTop; int x = ( i_mouse_x - movie_rect.xLeft ) * i_src_width / i_movie_width + sys->kvas.rclSrcRect.xLeft; int y = ( i_mouse_y - movie_rect.yBottom ) * i_src_height / i_movie_height; /* Invert Y coordinate and add y offset */ y = ( i_src_height - y ) + sys->kvas.rclSrcRect.yTop;; vout_display_SendEventMouseMoved(vd, x, y); result = WinDefWindowProc( hwnd, msg, mp1,mp2 ); break; } case WM_BUTTON1DOWN : MousePressed( vd, hwnd, MOUSE_BUTTON_LEFT ); break; case WM_BUTTON2DOWN : MousePressed( vd, hwnd, MOUSE_BUTTON_RIGHT ); break; case WM_BUTTON3DOWN : MousePressed( vd, hwnd, MOUSE_BUTTON_CENTER ); break; case WM_BUTTON1UP : MouseReleased( vd, MOUSE_BUTTON_LEFT ); break; case WM_BUTTON2UP : MouseReleased( vd, MOUSE_BUTTON_RIGHT ); break; case WM_BUTTON3UP : MouseReleased( vd, MOUSE_BUTTON_CENTER ); break; case WM_BUTTON1DBLCLK : vout_display_SendEventMouseDoubleClick(vd); break; case WM_TRANSLATEACCEL : /* We have no accelerator table at all */ result = ( MRESULT )FALSE; break; case WM_CHAR : { USHORT i_flags = SHORT1FROMMP( mp1 ); USHORT i_ch = SHORT1FROMMP( mp2 ); USHORT i_vk = SHORT2FROMMP( mp2 ); int i_key = 0; /* If embedded window, let the parent process keys */ if( sys->parent_window ) { WinPostMsg( sys->parent, msg, mp1, mp2 ); break; } if( !( i_flags & KC_KEYUP )) { if( i_flags & KC_VIRTUALKEY ) /* convert the key if possible */ i_key = ConvertKey( i_vk ); else if(( i_flags & KC_CHAR ) && !HIBYTE( i_ch )) i_key = tolower( i_ch ); if( i_key ) { if( i_flags & KC_SHIFT ) i_key |= KEY_MODIFIER_SHIFT; if( i_flags & KC_CTRL ) i_key |= KEY_MODIFIER_CTRL; if( i_flags & KC_ALT ) i_key |= KEY_MODIFIER_ALT; vout_display_SendEventKey(vd, i_key); } } break; } /* Process Manage() call */ case WM_VLC_MANAGE : break; /* Fullscreen change */ case WM_VLC_FULLSCREEN_CHANGE : if( LONGFROMMP( mp1 )) { WinQueryWindowPos( sys->frame, &swp ); sys->client_rect.xLeft = swp.x; sys->client_rect.yBottom = swp.y; sys->client_rect.xRight = sys->client_rect.xLeft + swp.cx; sys->client_rect.yTop = sys->client_rect.yBottom + swp.cy; WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE ); rcl.xLeft = 0; rcl.yBottom = 0; rcl.xRight = sys->i_screen_width; rcl.yTop = sys->i_screen_height; } else rcl = sys->client_rect; WinCalcFrameRect( sys->frame, &rcl, FALSE ); WinSetWindowPos( sys->frame, HWND_TOP, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW | SWP_ACTIVATE ); break; /* Size change */ case WM_VLC_SIZE_CHANGE : rcl.xLeft = 0; rcl.yBottom = 0; rcl.xRight = LONGFROMMP( mp1 ); rcl.yTop = LONGFROMMP( mp2 ); WinCalcFrameRect( sys->frame, &rcl, FALSE ); WinSetWindowPos( sys->frame, NULLHANDLE, 0, 0, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_SIZE ); WinQueryWindowPos( sys->frame, &swp ); sys->client_rect.xLeft = swp.x; sys->client_rect.yBottom = swp.y; sys->client_rect.xRight = sys->client_rect.xLeft + swp.cx; sys->client_rect.yTop = sys->client_rect.yBottom + swp.cy; WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE ); break; default : return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } /* If embedded window, we need to change our window size according to a * parent window size */ if( sys->parent_window ) { WinQueryWindowRect( sys->parent, &rcl ); if( rcl.xLeft != sys->parent_rect.xLeft || rcl.yBottom != sys->parent_rect.yBottom || rcl.xRight != sys->parent_rect.xRight || rcl.yTop != sys->parent_rect.yTop) { sys->parent_rect = rcl; WinCalcFrameRect( sys->frame, &rcl, FALSE ); WinSetWindowPos( sys->frame, NULLHANDLE, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_SIZE | SWP_MOVE ); } } return result; }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static INT aiPuzzle[NUMROWS][NUMCOLS], iBlankRow, iBlankCol, cxSquare, cySquare ; CHAR szNum[10] ; HPS hps ; HWND hwndFrame ; INT iRow, iCol, iMouseRow, iMouseCol, i ; POINTL ptl ; RECTL rcl, rclInvalid, rclIntersect ; SIZEL sizl ; switch (msg) { case WM_CREATE: // Calculate square size in pixels hps = WinGetPS (hwnd) ; sizl.cx = sizl.cy = 0 ; GpiSetPS (hps, &sizl, PU_LOENGLISH) ; ptl.x = SQUARESIZE ; ptl.y = SQUARESIZE ; GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptl) ; WinReleasePS (hps) ; cxSquare = ptl.x ; cySquare = ptl.y ; // Calculate client window size and position rcl.xLeft = (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) - NUMCOLS * cxSquare) / 2 ; rcl.yBottom = (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) - NUMROWS * cySquare) / 2 ; rcl.xRight = rcl.xLeft + NUMCOLS * cxSquare ; rcl.yTop = rcl.yBottom + NUMROWS * cySquare ; // Set frame window position and size hwndFrame = WinQueryWindow (hwnd, QW_PARENT) ; WinCalcFrameRect (hwndFrame, &rcl, FALSE) ; WinSetWindowPos (hwndFrame, NULLHANDLE, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_MOVE | SWP_SIZE | SWP_ACTIVATE) ; // Initialize the aiPuzzle array WinSendMsg (hwnd, WM_COMMAND, MPFROMSHORT (IDM_NORMAL), NULL) ; return 0 ; case WM_PAINT: hps = WinBeginPaint (hwnd, NULLHANDLE, &rclInvalid) ; // Draw the squares for (iRow = NUMROWS - 1 ; iRow >= 0 ; iRow--) for (iCol = 0 ; iCol < NUMCOLS ; iCol++) { rcl.xLeft = cxSquare * iCol ; rcl.yBottom = cySquare * iRow ; rcl.xRight = rcl.xLeft + cxSquare ; rcl.yTop = rcl.yBottom + cySquare ; if (!WinIntersectRect (0, &rclIntersect, &rcl, &rclInvalid)) continue ; if (iRow == iBlankRow && iCol == iBlankCol) WinFillRect (hps, &rcl, CLR_BLACK) ; else { WinDrawBorder (hps, &rcl, 5, 5, CLR_PALEGRAY, CLR_DARKGRAY, DB_STANDARD | DB_INTERIOR) ; WinDrawBorder (hps, &rcl, 2, 2, CLR_BLACK, 0L, DB_STANDARD) ; sprintf (szNum, "%d", aiPuzzle[iRow][iCol]) ; WinDrawText (hps, -1, szNum, &rcl, CLR_WHITE, CLR_DARKGRAY, DT_CENTER | DT_VCENTER) ; } } WinEndPaint (hps) ; return 0 ; case WM_BUTTON1DOWN: iMouseCol = MOUSEMSG(&msg)->x / cxSquare ; iMouseRow = MOUSEMSG(&msg)->y / cySquare ; // Check if mouse was in valid area if ( iMouseRow < 0 || iMouseCol < 0 || iMouseRow >= NUMROWS || iMouseCol >= NUMCOLS || (iMouseRow != iBlankRow && iMouseCol != iBlankCol) || (iMouseRow == iBlankRow && iMouseCol == iBlankCol)) break ; // Move a row right or left if (iMouseRow == iBlankRow) { if (iMouseCol < iBlankCol) for (iCol = iBlankCol ; iCol > iMouseCol ; iCol--) aiPuzzle[iBlankRow][iCol] = aiPuzzle[iBlankRow][iCol - 1] ; else for (iCol = iBlankCol ; iCol < iMouseCol ; iCol++) aiPuzzle[iBlankRow][iCol] = aiPuzzle[iBlankRow][iCol + 1] ; } // Move a column up or down else { if (iMouseRow < iBlankRow) for (iRow = iBlankRow ; iRow > iMouseRow ; iRow--) aiPuzzle[iRow][iBlankCol] = aiPuzzle[iRow - 1][iBlankCol] ; else for (iRow = iBlankRow ; iRow < iMouseRow ; iRow++) aiPuzzle[iRow][iBlankCol] = aiPuzzle[iRow + 1][iBlankCol] ; } // Calculate invalid rectangle rcl.xLeft = cxSquare * min (iMouseCol, iBlankCol) ; rcl.yBottom = cySquare * min (iMouseRow, iBlankRow) ; rcl.xRight = cxSquare * (max (iMouseCol, iBlankCol) + 1) ; rcl.yTop = cySquare * (max (iMouseRow, iBlankRow) + 1) ; // Set new array and blank values iBlankRow = iMouseRow ; iBlankCol = iMouseCol ; aiPuzzle[iBlankRow][iBlankCol] = 0 ; // Invalidate rectangle WinInvalidateRect (hwnd, &rcl, FALSE) ; break ; case WM_CHAR: if (!(CHARMSG(&msg)->fs & KC_VIRTUALKEY) || CHARMSG(&msg)->fs & KC_KEYUP) return 0 ; // Mimic a WM_BUTTON1DOWN message iMouseCol = iBlankCol ; iMouseRow = iBlankRow ; switch (CHARMSG(&msg)->vkey) { case VK_LEFT: iMouseCol++ ; break ; case VK_RIGHT: iMouseCol-- ; break ; case VK_UP: iMouseRow-- ; break ; case VK_DOWN: iMouseRow++ ; break ; default: return 0 ; } WinSendMsg (hwnd, WM_BUTTON1DOWN, MPFROM2SHORT (iMouseCol * cxSquare, iMouseRow * cySquare), NULL) ; return 0 ; case WM_COMMAND: switch (COMMANDMSG(&msg)->cmd) { // Initialize aiPuzzle array case IDM_NORMAL: case IDM_INVERT: for (iRow = 0 ; iRow < NUMROWS ; iRow++) for (iCol = 0 ; iCol < NUMCOLS ; iCol++) aiPuzzle[iRow][iCol] = iCol + 1 + NUMCOLS * (NUMROWS - iRow - 1) ; if (COMMANDMSG(&msg)->cmd == IDM_INVERT) { aiPuzzle[0][NUMCOLS-2] = NUMCOLS * NUMROWS - 2 ; aiPuzzle[0][NUMCOLS-3] = NUMCOLS * NUMROWS - 1 ; } aiPuzzle[iBlankRow = 0][iBlankCol = NUMCOLS - 1] = 0 ; WinInvalidateRect (hwnd, NULL, FALSE) ; return 0 ; // Randomly scramble the squares case IDM_SCRAMBLE: WinSetPointer (HWND_DESKTOP, WinQuerySysPointer ( HWND_DESKTOP, SPTR_WAIT, FALSE)) ; srand ((int) WinGetCurrentTime (0)) ; for (i = 0 ; i < SCRAMBLEREP ; i++) { WinSendMsg (hwnd, WM_BUTTON1DOWN, MPFROM2SHORT (rand() % NUMCOLS * cxSquare, iBlankRow * cySquare), NULL) ; WinUpdateWindow (hwnd) ; WinSendMsg (hwnd, WM_BUTTON1DOWN, MPFROM2SHORT (iBlankCol * cxSquare, rand() % NUMROWS * cySquare), NULL) ; WinUpdateWindow (hwnd) ; } WinSetPointer (HWND_DESKTOP, WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE)); return 0 ; } break ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
/* ARGSUSED5 */ /* Only Win32 uses gameMode parameter. */ GLUTwindow * __glutCreateWindow(GLUTwindow * parent, int x, int y, int width, int height, int gameMode) { GLUTwindow *window; XSetWindowAttributes wa; unsigned long attribMask; int winnum; int i; #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig) GLXFBConfigSGIX fbc; #else void *fbc; #endif #if defined(__OS2PM__) { extern HAB hab; /* PM anchor block handle */ CLASSINFO classinfo; if(!WinQueryClassInfo(hab,"GLUT", &classinfo) ) __glutOpenOS2Connection(NULL); } #elif defined(_WIN32) WNDCLASS wc; int style; if (!GetClassInfo(GetModuleHandle(NULL), "GLUT", &wc)) { __glutOpenWin32Connection(NULL); } #else if (!__glutDisplay) { __glutOpenXConnection(NULL); } #endif #ifndef __OS2PM__ if (__glutGameModeWindow) { __glutFatalError("cannot create windows in game mode."); } #endif winnum = getUnusedWindowSlot(); window = (GLUTwindow *) malloc(sizeof(GLUTwindow)); if (!window) { __glutFatalError("out of memory."); } window->num = winnum; #if defined(__OS2PM__) /* Add this new window to the window list. */ __glutWindowList[winnum] = window; window->shownState = -1; #endif #if !defined(_WIN32) && !defined(__OS2PM__) window->vis = __glutDetermineWindowVisual(&window->treatAsSingle, &window->visAlloced, (void**) &fbc); if (!window->vis) { __glutFatalError( "visual with necessary capabilities not found."); } __glutSetupColormap(window->vis, &window->colormap, &window->cmap); #endif window->eventMask = StructureNotifyMask | ExposureMask; attribMask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask; wa.background_pixmap = None; wa.border_pixel = 0; wa.colormap = window->cmap; wa.event_mask = window->eventMask; if (parent) { if (parent->eventMask & GLUT_HACK_STOP_PROPAGATE_MASK) wa.event_mask |= GLUT_HACK_STOP_PROPAGATE_MASK; attribMask |= CWDontPropagate; wa.do_not_propagate_mask = parent->eventMask & GLUT_DONT_PROPAGATE_FILTER_MASK; } else { wa.do_not_propagate_mask = 0; } /* Stash width and height before Win32's __glutAdjustCoords possibly overwrites the values. */ window->width = width; window->height = height; window->forceReshape = True; window->ignoreKeyRepeat = False; #if defined(__OS2PM__) { ULONG flStyle=0; int ii; ERRORID erridErrorCode;/* last error id code */ extern HAB hab; /* PM anchor block handle */ if (parent) { flStyle = WS_CLIPCHILDREN|WS_VISIBLE; } else { if (gameMode) { /* Game mode window should be a WS_POPUP window to ensure that the taskbar is hidden by it. A standard WS_OVERLAPPEDWINDOW does not hide the task bar. */ flStyle = FCF_STANDARD | WS_MAXIMIZED; } else { /* A standard toplevel window with borders and such. */ flStyle = FCF_STANDARD | WS_CLIPCHILDREN; // flStyle = WS_OVERLAPPEDWINDOW; } } { HWND hwnd; /* Window */ ULONG ListBoxId; /* Window id */ /* (supplied by application) */ HWND hwndClient; /* handle to the client */ HWND hwndFrame; /* handle to the frame */ PFNWP GenericWndProc; FRAMECDATA fcd; RECTL rect; /* Boundary rectangle */ /************************************************/ // flCreate = (FCF_STANDARD) & ~FCF_TASKLIST; /**********************************/ if (parent) { window->frame = NULL; hwnd = WinCreateWindow(parent->win, /* Parent window */ "GLUTCHILD", /* Class name */ "", /* Window text */ flStyle, /* Window style */ x, y, /* Position (x,y) */ width, height, /* Size (width,height) */ parent->win, /* Owner window */ HWND_TOP, /* Sibling window */ 0, /* Window id */ NULL, /* Control data */ NULL); /* Pres parameters */ erridErrorCode = WinGetLastError(hab); window->win = hwnd; window->hdc = WinOpenWindowDC(window->win); window->hpsBuffer = hpsCurrent; rect.xLeft = x; rect.xRight = x+width; rect.yBottom = y; rect.yTop = y + height; /***** else parent *****************************/ } else { hwnd = WinCreateStdWindow(HWND_DESKTOP, 0, /* WS_VISIBLE frame-window style */ &flStyle, /* window style */ "GLUT", /* class name */ "GLUT",/* window title */ 0L, /* default client style */ NULLHANDLE, /* resource in executable file */ ID_WINDOW, /* resource id */ &hwndClient); /* receives client window handle */ erridErrorCode = WinGetLastError(hab); window->win = hwndClient; window->frame = hwnd; window->hdc = WinOpenWindowDC(window->win); window->hpsBuffer = hpsCurrent; /* converts a client window's boundaries into an equivalent frame rectangle */ rect.xLeft = x; rect.xRight = x+width; rect.yBottom = y; rect.yTop = y + height; /* calculate equivalent frame boundary from boundary data */ WinCalcFrameRect(window->frame, &rect, FALSE); } /***** endof if(parent) *****************************/ /* Must set the XHDC for fake glXChooseVisual & fake glXCreateContext & fake XAllocColorCells. */ XHDC = window->hdc; XHWND = window->win; window->vis = __glutDetermineWindowVisual(&window->treatAsSingle, &window->visAlloced, &fbc); if (!window->vis) { __glutFatalError( "pixel format with necessary capabilities not found."); } { int rc; rc = wglChoosePixelFormat(window->hdc, window->vis), // evglSetPixelFormat(2); /* int iPixelFormat 1 - doublebuffer/2 - single buffer ??*/ wglSetPixelFormat(window->hdc,rc,window->vis); } __glutSetupColormap(window->vis, &window->colormap, &window->cmap); window->ctx = glXCreateContext(window->hpsBuffer, window->vis, None, __glutTryDirect); WinSetWindowPos(hwnd, HWND_TOP,rect.xLeft,rect.yBottom, rect.xRight-rect.xLeft, rect.yTop-rect.yBottom, SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW|SWP_ZORDER); /* flags*/ /* Make sure subwindows get a windowStatus callback. */ if (parent) WinPostMsg(parent->win, WM_ACTIVATE, 0, 0); } } #elif defined(_WIN32) __glutAdjustCoords(parent ? parent->win : NULL, &x, &y, &width, &height); if (parent) { style = WS_CHILD; } else { if (gameMode) { /* Game mode window should be a WS_POPUP window to ensure that the taskbar is hidden by it. A standard WS_OVERLAPPEDWINDOW does not hide the task bar. */ style = WS_POPUP | WS_MAXIMIZE; } else { /* A standard toplevel window with borders and such. */ style = WS_OVERLAPPEDWINDOW; } } window->win = CreateWindow("GLUT", "GLUT", WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style, x, y, width, height, parent ? parent->win : __glutRoot, NULL, GetModuleHandle(NULL), 0); window->hdc = GetDC(window->win); /* Must set the XHDC for fake glXChooseVisual & fake glXCreateContext & fake XAllocColorCells. */ XHDC = window->hdc; window->vis = __glutDetermineWindowVisual(&window->treatAsSingle, &window->visAlloced, &fbc); if (!window->vis) { __glutFatalError( "pixel format with necessary capabilities not found."); } if (!SetPixelFormat(window->hdc, ChoosePixelFormat(window->hdc, window->vis), window->vis)) { __glutFatalError("SetPixelFormat failed during window create."); } __glutSetupColormap(window->vis, &window->colormap, &window->cmap); /* Make sure subwindows get a windowStatus callback. */ if (parent) { PostMessage(parent->win, WM_ACTIVATE, 0, 0); } window->renderDc = window->hdc; #else window->win = XCreateWindow(__glutDisplay, parent == NULL ? __glutRoot : parent->win, x, y, width, height, 0, window->vis->depth, InputOutput, window->vis->visual, attribMask, &wa); #endif window->renderWin = window->win; #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig) if (fbc) { window->ctx = __glut_glXCreateContextWithConfigSGIX(__glutDisplay, fbc, GLX_RGBA_TYPE_SGIX, None, __glutTryDirect); } else #endif #if defined(__OS2PM__) // window->ctx = glXCreateContext(window->hpsBuffer, window->vis, // None, __glutTryDirect); #else window->ctx = glXCreateContext(__glutDisplay, window->vis, None, __glutTryDirect); #endif if (!window->ctx) { __glutFatalError( "failed to create OpenGL rendering context."); } window->renderCtx = window->ctx; #if !defined(_WIN32) && !defined(__OS2PM__) window->isDirect = glXIsDirect(__glutDisplay, window->ctx); if (__glutForceDirect) { if (!window->isDirect) __glutFatalError("direct rendering not possible."); } #endif window->parent = parent; if (parent) { window->siblings = parent->children; parent->children = window; } else { window->siblings = NULL; } window->overlay = NULL; window->children = NULL; window->display = __glutDefaultDisplay; window->reshape = __glutDefaultReshape; window->mouse = NULL; window->motion = NULL; window->passive = NULL; window->entry = NULL; window->keyboard = NULL; window->keyboardUp = NULL; window->windowStatus = NULL; window->visibility = NULL; window->special = NULL; window->specialUp = NULL; window->buttonBox = NULL; window->dials = NULL; window->spaceMotion = NULL; window->spaceRotate = NULL; window->spaceButton = NULL; window->tabletMotion = NULL; window->tabletButton = NULL; #ifdef _WIN32 window->joystick = NULL; window->joyPollInterval = 0; #endif #if defined(__OS2PM__) window->wm_command = NULL; #endif window->tabletPos[0] = -1; window->tabletPos[1] = -1; #if defined(__OS2PM__) if(window->shownState == -1) window->shownState = 0; window->visState = window->shownState; #else window->shownState = 0; window->visState = -1; /* not VisibilityUnobscured, VisibilityPartiallyObscured, or VisibilityFullyObscured */ #endif window->entryState = -1; /* not EnterNotify or LeaveNotify */ window->desiredConfMask = 0; window->buttonUses = 0; window->cursor = GLUT_CURSOR_INHERIT; /* Setup window to be mapped when glutMainLoop starts. */ window->workMask = GLUT_MAP_WORK; #ifdef _WIN32 if (gameMode) { /* When mapping a game mode window, just show the window. We have already created the game mode window with a maximize flag at creation time. Doing a ShowWindow(window->win, SW_SHOWNORMAL) would be wrong for a game mode window since it would unmaximize the window. */ window->desiredMapState = GameModeState; } else { window->desiredMapState = NormalState; } #else window->desiredMapState = NormalState; #endif window->prevWorkWin = __glutWindowWorkList; __glutWindowWorkList = window; /* Initially, no menus attached. */ for (i = 0; i < GLUT_MAX_MENUS; i++) { window->menu[i] = 0; } /* Add this new window to the window list. */ __glutWindowList[winnum] = window; /* Make the new window the current window. */ __glutSetWindow(window); __glutDetermineMesaSwapHackSupport(); if (window->treatAsSingle) { /* We do this because either the window really is single buffered (in which case this is redundant, but harmless, because this is the initial single-buffered context state); or we are treating a double buffered window as a single-buffered window because the system does not appear to export any suitable single- buffered visuals (in which the following are necessary). */ glDrawBuffer(GL_FRONT); glReadBuffer(GL_FRONT); } return window; }
static BOOL _setMode(PGROPDATA pGrop, ULONG ulModeIdx, BOOL fFullscreen) { PVIDEOMODE pMode = &pGrop->stModes.pList[ulModeIdx]; // fFirstTime - Mode was not selected, mode will be set first time. BOOL fFirstTime = pGrop->ulModeIdx == ~0; RECTL rectl; LONG lX, lY, lW, lH; BOOL fSuccess = TRUE; if ( fFirstTime ) { pGrop->swpOld.x = pGrop->ulDTWidth / 2; pGrop->swpOld.y = pGrop->ulDTHeight / 2; } fFullscreen &= ( pGrop->stUserMode.ulWidth <= pMode->ulWidth ) && ( pGrop->stUserMode.ulHeight <= pMode->ulHeight ); if ( fFullscreen ) { if ( pGrop->fActive || fFirstTime ) { // Is the fullscreen and not on the descktop now - change fulscreen mode. if ( !pGrop->fFullscreen && !fFirstTime ) // Save windows position before switching to full-screen mode. WinQueryWindowPos( pGrop->hwndFrame, &pGrop->swpOld ); // Do not change FS mode if it is the same as the current one. fSuccess = ( pGrop->fFullscreen && ( pGrop->ulModeIdx == ulModeIdx ) ) || _setFullscreen( pGrop, ulModeIdx ); } // else: FS mode but on the desktop now, change mode later in _wmActive(). pGrop->ulModeIdx = ulModeIdx; pGrop->fFullscreen = TRUE; } else //if ( pGrop->fFullscreen || ( pGrop->ulModeIdx != ulModeIdx ) ) { // Change window if mode is not same as the current one. if ( pGrop->fFullscreen ) { debug( "Return to the desktop..." ); _setDesktop( pGrop ); } debug( "Calc new window size..." ); rectl.xLeft = 0; rectl.yBottom = 0; rectl.xRight = pGrop->stUserMode.ulWidth; rectl.yTop = pGrop->stUserMode.ulHeight; WinCalcFrameRect( pGrop->hwndFrame, &rectl, FALSE ); lW = rectl.xRight - rectl.xLeft; lH = rectl.yTop - rectl.yBottom; if ( !pGrop->fFullscreen && !fFirstTime ) { // Positioning relative to the current location. debug( "Query current window position..." ); WinQueryWindowPos( pGrop->hwndFrame, &pGrop->swpOld ); } else debug( "Window's location will be relative to the location before FS." ); lX = pGrop->swpOld.x + (pGrop->swpOld.cx / 2) - (lW / 2); lY = pGrop->swpOld.y + (pGrop->swpOld.cy / 2) - (lH / 2); if ( lW > pGrop->ulDTWidth ) lX = (pGrop->ulDTWidth / 2) - ( lW / 2); else if ( (lX + lW) > pGrop->ulDTWidth ) lX = pGrop->ulDTWidth - lW; else if ( lX < 0 ) lX = 0; if ( lY < 0 ) lY = 0; if ( (lY + lH) > pGrop->ulDTHeight ) lY = pGrop->ulDTHeight - lH; pGrop->ulModeIdx = ulModeIdx; pGrop->fFullscreen = FALSE; debug( "Set window position..." ); pGrop->fInternalResize = TRUE; WinSetWindowPos( pGrop->hwndFrame, HWND_TOP, lX, lY, lW, lH, fFirstTime ? SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE : SWP_MOVE | SWP_SIZE | SWP_SHOW ); pGrop->fInternalResize = FALSE; debug( "Call _captureMouse(,%s)...", pGrop->fCapture ? "TRUE" : "FALSE" ); _captureMouse( pGrop, pGrop->fCapture ); } debug( "Call _calcViewRect(,FALSE)..." ); _calcViewRect( pGrop, FALSE ); debug( "Call pVideoSys->fnUpdate()..." ); pGrop->pVideoSys->fnUpdate( pGrop->pVSData, pGrop, 0, NULL ); return fSuccess; }