void wxTextCtrl::WriteText( const wxString& rsValue ) { if (m_bIsMLE) ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM((PCHAR)rsValue.c_str()), MPARAM(0)); else ::WinSetWindowText(GetHwnd(), (PSZ)rsValue.c_str()); AdjustSpaceLimit(); } // end of wxTextCtrl::WriteText
void wxMenuBar::SetMenuLabel( size_t nPos , const wxString& rLabel ) { SHORT nId; MENUITEM vItem; wxCHECK_RET(nPos < GetMenuCount(), wxT("invalid menu index")); m_titles[nPos] = rLabel; if (!IsAttached()) { return; } nId = SHORT1FROMMR(::WinSendMsg((HWND)m_hMenu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(nPos), (MPARAM)0)); if (nId == MIT_ERROR) { wxLogLastError(wxT("LogLastError")); return; } if(!::WinSendMsg( (HWND)m_hMenu ,MM_QUERYITEM ,MPFROM2SHORT(nId, TRUE) ,MPARAM(&vItem) )) { wxLogLastError(wxT("QueryItem")); } nId = vItem.id; if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT, MPFROMSHORT(nId), (MPARAM)rLabel.wx_str())); { wxLogLastError(wxT("ModifyMenu")); } Refresh(); } // end of wxMenuBar::SetMenuLabel
void wxSpinButton::SetValue( int nValue ) { ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE, MPFROMLONG(nValue), MPARAM(0)); } // end of wxSpinButton::SetValue
MRESULT Window::wndProc( HWND hWnd, ULONG iMessage, MPARAM mParam1, MPARAM mParam2) { switch( iMessage ) { case WM_COMMAND : { // A menu selection if( SHORT1FROMMP( mParam2 ) == CMDSRC_MENU ) { processMenuEnd = TRUE; performMenuEvent( (int)mParam1 ); } break; } case WM_INITMENU : { processMenuEnd = TRUE; break; } case WM_MENUSELECT : { if( SHORT2FROMMP( mParam1 ) ) processMenuEnd = FALSE; break; } case WM_MENUEND : { if( processMenuEnd ) performMenuEvent( MENU_CLOSE ); break; } case WM_PAINT : { // Do not paint if subclassed window if( oldWndProc != NULL ) break; CURSORINFO cursorinfo; BOOL rc = WinQueryCursorInfo(HWND_DESKTOP, &cursorinfo); if( rc ) WinShowCursor( hWnd, 0 ); RECTL rcl; HPS hps = WinBeginPaint( hWnd, NULLHANDLE, &rcl ); Rect rect( rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom ); Graphics *graph = new Graphics( hps ); paint( &rect, graph ); delete graph; WinEndPaint( hps ); if( rc ) WinShowCursor( hWnd, 1 ); return MPARAM(0); } case WM_ERASEBACKGROUND : return (MPARAM)FALSE; } BOOL returned = TRUE; MRESULT retVal = stdWndProc( hWnd, iMessage, mParam1, mParam2, &returned ); if( !returned ) { if( oldWndProc == NULL ) return WinDefWindowProc( hWnd, iMessage, mParam1, mParam2 ); else return oldWndProc( hWnd, iMessage, mParam1, mParam2 ); } else return retVal; }
MRESULT Window::stdWndProc( HWND hWnd, ULONG iMessage, MPARAM mParam1, MPARAM mParam2, BOOL *returned ) { switch( iMessage ) { // case WM_FOCUSCHANGE : case WM_SETSELECTION : case WM_ACTIVATE : { if( type != Window::LISTBOX && type != Window::COMBOLISTBOX ) { focus( (BOOL)mParam1 );//SHORT1FROMMP( mParam2 ) ); } break; } case WM_SETFOCUS : { if( type != Window::LISTBOX && type != Window::COMBOLISTBOX ) focusSet( (BOOL)mParam2 ); break; } case WM_BUTTON1DOWN : { if( type == SCROLLBAR ) setFocus(); HWND hwnd = WinQueryFocus( HWND_DESKTOP ); if( mouseListener.getSize() != 0 ) { mouseButtonDown = TRUE; WinSetCapture( HWND_DESKTOP, hWnd ); WinStartTimer( Application::hab, hWndClient, 1, 50 ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::DOWN ); } if( hwnd != WinQueryFocus( HWND_DESKTOP ) ) return (MRESULT)TRUE; break; } case WM_BUTTON1UP : { if( type == LISTBOX || type == COMBOLISTBOX ) { performFocusEvent( (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) ); } else if( mouseListener.getSize() != 0 ) { mouseButtonDown = FALSE; WinStopTimer( Application::hab, hWndClient, 1 ); WinSetCapture( HWND_DESKTOP, NULLHANDLE ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::RELEASE ); // return (MPARAM)TRUE; } break; } case WM_BUTTON2DOWN : { if( mouseListener.getSize() != 0 ) { WinSetCapture( HWND_DESKTOP, hWnd ); WinStartTimer( Application::hab, hWndClient, 1, 50 ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::DOWN ); } break; } case WM_BUTTON2UP : { if( mouseListener.getSize() != 0 ) { WinStopTimer( Application::hab, hWndClient, 1 ); WinSetCapture( HWND_DESKTOP, NULLHANDLE ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::RELEASE ); } break; } case WM_BUTTON1CLICK : { if( mouseListener.getSize() != 0 ) { // Check if triple click int newTick = WinGetCurrentTime( Application::hab ); if( newTick - lastTick <= WinQuerySysValue( HWND_DESKTOP, SV_DBLCLKTIME ) ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::TRIPLECLICK ); } else { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::CLICK ); } } break; } case WM_BUTTON2CLICK : { if( mouseListener.getSize() != 0 ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::CLICK ); } break; } case WM_BUTTON1DBLCLK : { if( mouseListener.getSize() != 0 ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::DOUBLECLICK ); } lastTick = WinGetCurrentTime( Application::hab ); break; } case WM_BUTTON2DBLCLK : { if( mouseListener.getSize() != 0 ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::DOUBLECLICK ); } break; } case WM_MOUSEMOVE : { if( currentPointer != NULLHANDLE ) WinSetPointer( HWND_DESKTOP, currentPointer ); if( mouseListener.getSize() != 0 ) { Point pos( (SHORT)SHORT1FROMMP(mParam1), (SHORT)SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, 0, AMouseEvent::MOVE ); } if( currentPointer != NULLHANDLE ) return (MPARAM)TRUE; break; } case WM_TIMER : { if( mouseButtonDown ) { POINTL ptl; WinQueryPointerPos( HWND_DESKTOP, &ptl ); WinMapWindowPoints( HWND_DESKTOP, hWnd, &ptl, 1 ); if( ptl.y < 0 || ptl.y > height ) { Point pos( ptl.x, ptl.y ); performMouseEvent( &pos, 0, AMouseEvent::MOVE ); } } break; } case WM_SIZE : { int oldWidth = width, oldHeight = height; SWP swp; WinQueryWindowPos( hWndFrame, &swp ); width = swp.cx; height = swp.cy; size( oldWidth, oldHeight ); break; } case WM_HSCROLL : { int pos = SHORT1FROMMP( mParam2 ), id = SHORT1FROMMP( mParam1 ); switch( SHORT2FROMMP( mParam2 ) ) { case SB_PAGERIGHT : { performScrollbarEvent( id, Scrollbar::PAGERIGHT, pos ); break; } case SB_PAGELEFT : { performScrollbarEvent( id, Scrollbar::PAGELEFT, pos ); break; } case SB_LINERIGHT : { performScrollbarEvent( id, Scrollbar::LINERIGHT, pos ); break; } case SB_LINELEFT : { performScrollbarEvent( id, Scrollbar::LINELEFT, pos ); break; } case SB_SLIDERTRACK : { performScrollbarEvent( id, Scrollbar::HORZTRACK, pos ); break; } case SB_SLIDERPOSITION : { performScrollbarEvent( id, Scrollbar::HORZRELEASED, pos ); break; } } break; } case WM_SYSCOMMAND : { // Check if the parent is a dialog, then chain the WM_SYSCOMMAND if( parent->getType() == DIALOG ) WinSendMsg( ((Window *)parent)->getHWND(), WM_SYSCOMMAND, mParam1, mParam2 ); break; } case WM_VSCROLL : { int id = SHORT1FROMMP( mParam1 ); Scrollbar *scrollbar = (Scrollbar *)getControl( id ); int pos; if( scrollbar ) pos = scrollbar->convertScrollPosToReal( SHORT1FROMMP( mParam2 ) ); else pos = SHORT1FROMMP( mParam2 ); switch( SHORT2FROMMP( mParam2 ) ) { case SB_PAGEDOWN : { performScrollbarEvent( id, Scrollbar::PAGEDOWN, pos ); break; } case SB_PAGEUP : { performScrollbarEvent( id, Scrollbar::PAGEUP, pos ); break; } case SB_LINEDOWN : { performScrollbarEvent( id, Scrollbar::LINEDOWN, pos ); break; } case SB_LINEUP : { performScrollbarEvent( id, Scrollbar::LINEUP, pos ); break; } case SB_SLIDERTRACK : { performScrollbarEvent( id, Scrollbar::VERTTRACK, pos ); break; } case SB_SLIDERPOSITION : { performScrollbarEvent( id, Scrollbar::VERTRELEASED, pos ); break; } } break; } case WM_MOVE : { SWP swp; WinQueryWindowPos( hWndFrame, &swp ); x = swp.x; y = swp.y; move(); break; } case WM_CLOSE : { if( close() ) break; else return (MPARAM)FALSE; } case WM_COMMAND : { if( SHORT1FROMMP( mParam2 ) == CMDSRC_PUSHBUTTON ) { Window *control = (Window *)getControl( SHORT1FROMMP(mParam1)); if( control != NULL ) { if( control->type == PUSHBUTTON ) { control->performButtonEvent( control, control->id ); return FALSE; } } else return FALSE; // In case ESC would close the dialog } break; } case WM_CHAR : { if( type == LISTBOX ) { performFocusEvent( (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) ); } if( (SHORT1FROMMP( mParam1 ) & KC_KEYUP) || (SHORT1FROMMP( mParam1 ) & KC_DEADKEY) || (SHORT1FROMMP( mParam1 ) & KC_INVALIDCOMP) ) break; /* if( SHORT1FROMMP( mParam1 ) & KC_COMPOSITE ) mParam1 = MPFROM2SHORT( SHORT1FROMMP( mParam1 ) & ~KC_VIRTUALKEY, SHORT2FROMMP( mParam1 ) );*/ int modifiers = 0; if( SHORT1FROMMP( mParam1 ) & KC_SHIFT ) modifiers |= KeyDef::SHIFT; if( SHORT1FROMMP( mParam1 ) & KC_ALT ) modifiers |= KeyDef::kALT; if( SHORT1FROMMP( mParam1 ) & KC_CTRL) modifiers |= KeyDef::CTRL; if( SHORT1FROMMP( mParam1 ) & KC_VIRTUALKEY ) { int key = 0, vKey = SHORT2FROMMP( mParam2 ); // Maybe NumLock is on if( SHORT1FROMMP(mParam1) & KC_CHAR && !(vKey == VK_ENTER || vKey == VK_NEWLINE || vKey == VK_TAB || vKey == VK_BACKSPACE )) key = SHORT1FROMMP( mParam2 ); else if( vKey == VK_UP ) key = KeyDef::UP; else if( vKey == VK_DOWN ) key = KeyDef::DOWN; else if( vKey == VK_LEFT ) key = KeyDef::LEFT; else if( vKey == VK_RIGHT ) key = KeyDef::RIGHT; else if( vKey == VK_PAGEUP ) key = KeyDef::PAGEUP; else if( vKey == VK_PAGEDOWN ) key = KeyDef::PAGEDOWN; else if( vKey == VK_INSERT ) key = KeyDef::INSERT; else if( vKey == VK_DELETE ) key = KeyDef::kDELETE; else if( vKey == VK_HOME ) key = KeyDef::HOME; else if( vKey == VK_END ) key = KeyDef::END; else if( vKey == VK_ESC ) key = KeyDef::ESCAPE; else if( vKey == VK_F1 ) key = KeyDef::F1; else if( vKey == VK_F2 ) key = KeyDef::F2; else if( vKey == VK_F3 ) key = KeyDef::F3; else if( vKey == VK_F4 ) key = KeyDef::F4; else if( vKey == VK_F5 ) key = KeyDef::F5; else if( vKey == VK_F6 ) key = KeyDef::F6; else if( vKey == VK_F7 ) key = KeyDef::F7; else if( vKey == VK_F8 ) key = KeyDef::F8; else if( vKey == VK_F9 ) key = KeyDef::F9; else if( vKey == VK_F10 ) key = KeyDef::F10; else if( vKey == VK_F11 ) key = KeyDef::F11; else if( vKey == VK_F12 ) key = KeyDef::F12; else if( vKey == VK_ENTER ) key = KeyDef::ENTER; else if( vKey == VK_NEWLINE ) key = KeyDef::RETURN; else if( vKey == VK_BACKSPACE ) key = KeyDef::BACKSPACE; else if( vKey == VK_TAB ) key = KeyDef::TAB; else if( vKey == VK_BACKTAB ) { key = KeyDef::TAB; modifiers |= KeyDef::SHIFT; } else if( vKey == VK_SPACE ) key = KeyDef::SPACE; if( parent->getType() == DIALOG ) ((Dialog *)parent)->focusHotkey( key ); if( key != 0 ) if( performKeyEvent( this, modifiers, key ) ) return MPARAM(TRUE); // Do not pass up and down key to dialog if this is a combobox (would // move focus) /* if( getFilterDialogArrows() && (vKey == VK_UP || vKey == VK_DOWN) ) return (MPARAM)TRUE;*/ } else { int key = SHORT1FROMMP( mParam2 ); if( performKeyEvent( this, modifiers, key ) ) return MPARAM(TRUE); } break; } case WM_CONTROL : { Window *control = (Window *)getControl( SHORT1FROMMP(mParam1)); if( control != NULL ) { if( control->type == Window::LISTBOX || control->type == Window::COMBOLISTBOX ) { switch( SHORT2FROMMP(mParam1) ) { case LN_KILLFOCUS : control->focus( FALSE ); break; case LN_SETFOCUS : control->focus( TRUE );break; case LN_ENTER : control->performSelectionEvent( (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) ); break; } } else if( control->type == Window::SCROLLBAR ) { switch( SHORT2FROMMP(mParam1) ) { case SLN_KILLFOCUS : control->focus( FALSE ); break; case SLN_SETFOCUS : control->setFocus(); break; } } else if( control->type == Window::RADIOBUTTON || control->type == Window::CHECKBOX ) { switch( SHORT2FROMMP( mParam1) ) { case BN_CLICKED : case BN_DBLCLICKED : control->performButtonEvent( control, control->id ); break; } } } break; } case DM_DRAGOVER: { PDRAGINFO pDInfo; PDRAGITEM pDItem; if( !acceptDropFiles ) return MRFROM2SHORT(DOR_NODROPOP, 0); pDInfo = (PDRAGINFO)mParam1; DrgAccessDraginfo(pDInfo); pDItem = DrgQueryDragitemPtr(pDInfo, 0); USHORT usOp = 0, usDrop = DOR_NEVERDROP; /* Inspect each item to see if it is acceptable */ ULONG ulItems = DrgQueryDragitemCount (pDInfo); for (INT i = 0; i < ulItems; i++) { pDItem = DrgQueryDragitemPtr(pDInfo, i); /* The item is acceptable only if it is copyable and the */ /* operation is a copy, or it is moveable and the operation */ /* is a move, and it can render <DRM_OS2FILE, NULL> */ if (pDItem->fsSupportedOps & DO_COPYABLE) { usOp = DO_COPY; /* Only check files, all types */ if (DrgVerifyRMF(pDItem, "DRM_OS2FILE", 0)) usDrop = DOR_DROP; else { usDrop = DOR_NEVERDROP; break; } } else { /* Must be a file but not droppable in type op */ usDrop = DOR_NODROPOP; usOp = 0; break; } } /* end for all items dragged */ DrgFreeDraginfo(pDInfo); return MRFROM2SHORT(usDrop, usOp); } case DM_DROP: { PDRAGINFO pDInfo; PDRAGITEM pDItem; pDInfo = (PDRAGINFO)mParam1; DrgAccessDraginfo(pDInfo); pDItem = DrgQueryDragitemPtr(pDInfo, 0); ULONG ulItems = DrgQueryDragitemCount (pDInfo); ULONG p; char **files; files = (char **)malloc( sizeof( char * ) * ulItems ); for (INT i=0; i < ulItems; i++) { CHAR DragSrcPath[CCHMAXPATH], DragSrcName[CCHMAXPATH]; pDItem = DrgQueryDragitemPtr(pDInfo, i); DrgQueryStrName(pDItem->hstrContainerName, sizeof(DragSrcPath), (PSZ)DragSrcPath); if (!(PSZ)DragSrcPath) break; if (DragSrcPath[(strlen(DragSrcPath)-1)] != '\\') strcat((PSZ)DragSrcPath, "\\"); /* Use the dragitem source name, it's the real name */ DrgQueryStrName(pDItem->hstrSourceName, sizeof(DragSrcName), (PSZ)DragSrcName); if (!((PSZ)DragSrcName)) break; strcat((PSZ)DragSrcPath, (PSZ)DragSrcName); FILESTATUS3 fsFile; DosError(FERR_DISABLEHARDERR); APIRET rc = DosQueryPathInfo(DragSrcPath, FIL_STANDARD, &fsFile, sizeof(FILESTATUS3)); DosError(FERR_ENABLEHARDERR); if (!rc && !(fsFile.attrFile & FILE_DIRECTORY)) { files[i] = (char *)malloc( strlen(DragSrcPath) + 1 ); strcpy( files[i], DragSrcPath ); DrgSendTransferMsg(pDItem->hwndItem, DM_ENDCONVERSATION, MPFROMLONG(pDItem->ulItemID), MPFROMLONG(DMFL_TARGETSUCCESSFUL)); } else { DosBeep(100,10); // EditorDisplay[BufNum]->DisplayMessage( pszDropNoFile ); } } filesDropped( files, ulItems ); for( i = 0; i < ulItems; i++ ) free( (void *)files[i] ); free( (void *)files ); DrgFreeDraginfo(pDInfo); break; } case WM_USER + 1 : { return (MPARAM)execFromMainThread( (int)mParam1, (void *)mParam2 ); } case WM_USER + 2 : { setFocus(); break; } } *returned = FALSE; return (MRESULT)NULL; }
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; }
MRESULT EXPENTRY SETTINGS :: Page1Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static PSETTINGS pset = NULL; switch (msg) { case WM_INITDLG: { #ifdef _DOLOGDEBUG_ LogDebug( "Page1Procedure: start WM_INITDLG" ); #endif ULONG ul; pset = PSETTINGS (mp2); for( int i = 0; i < BMF_INVALID; i++ ) { if( pset->ifi[ i ].available ) { ul = WinInsertLboxItem( WinWindowFromID( hwnd, WID_LB_FILEFORMAT ), LIT_END, pset->ifi[ i ].label ); WinSendMsg( WinWindowFromID( hwnd, WID_LB_FILEFORMAT ), LM_SETITEMHANDLE, MPFROMLONG(ul), MPFROMP( i ) ); } } #ifdef _DOLOGDEBUG_ LogDebug( "Page1Procedure: end WM_INITDLG" ); #endif return MRESULT (FALSE); } case WM_COMMAND: if( SHORT1FROMMP( mp1 ) == DID_CANCEL ) WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 ); return MRESULT( FALSE ); case UM_SETTINGS2DIALOG: { #ifdef _DOLOGDEBUG_ LogDebug( "Page1Procedure: start UM_SETTINGS2DIALOG" ); #endif // set num save dir name WinSendDlgItemMsg (hwnd, WID_E_NUMSAVEDIR, EM_SETTEXTLIMIT, MPARAM (_MAX_PATH-1), (MPARAM)0); WinSetDlgItemText (hwnd, WID_E_NUMSAVEDIR, pset->QueryNumSaveDir ()); WinSendDlgItemMsg (hwnd, WID_E_NUMSAVEDIR, EM_SETSEL, MPFROM2SHORT (0, _MAX_PATH), (MPARAM)0); // set force file name WinSendDlgItemMsg (hwnd, WID_E_FORCESAVEFILE, EM_SETTEXTLIMIT, MPARAM (_MAX_PATH-1), (MPARAM)0); WinSetDlgItemText (hwnd, WID_E_FORCESAVEFILE, pset->QueryForceSaveFile ()); WinSendDlgItemMsg (hwnd, WID_E_FORCESAVEFILE, EM_SETSEL, MPFROM2SHORT (0, _MAX_PATH), (MPARAM)0); /* switch (pset->QueryFileFormat ()) { case BMF_20: WinSendDlgItemMsg (hwnd, WID_RB_BMF20, BM_CLICK, MPFROMSHORT(TRUE), 0); break; case BMF_12: WinSendDlgItemMsg (hwnd, WID_RB_BMF12, BM_CLICK, MPFROMSHORT(TRUE), 0); break; default: WinSendDlgItemMsg (hwnd, WID_RB_BMF16, BM_CLICK, MPFROMSHORT(TRUE), 0); break; } */ // Select the appropriate entry in the fileformat-listbox. HWND hwndLB = WinWindowFromID( hwnd, WID_LB_FILEFORMAT ); ULONG c, i; c = WinQueryLboxCount( hwndLB ); for( i = 0; i < c; i++ ) { ULONG type = ULONG( WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT, LM_QUERYITEMHANDLE, MPFROMLONG(i), NULL ) ); if( type == ULONG( pset->QueryFileFormat() ) ) break; } if( i < c ) WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT, LM_SELECTITEM, MPFROMSHORT(i), MPFROMSHORT(TRUE) ); else WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT, LM_SELECTITEM, MPFROMSHORT(0), MPFROMSHORT(TRUE) ); // Select appropriate radiobutton for save style. switch (pset->QueryFileSaveStyle ()) { case FSS_NUMFILES: WinSendDlgItemMsg (hwnd, WID_RB_FSSNUMFILES, BM_CLICK, MPFROMSHORT(TRUE), 0); AdjustSaveTypeButtons (FALSE); break; case FSS_FORCEFILE: WinSendDlgItemMsg (hwnd, WID_RB_FSSFORCEFILE, BM_CLICK, MPFROMSHORT(TRUE), 0); AdjustSaveTypeButtons (TRUE); break; default: WinSendDlgItemMsg (hwnd, WID_RB_FSSPROMPT, BM_CLICK, MPFROMSHORT(TRUE), 0); AdjustSaveTypeButtons (FALSE); break; } #ifdef _DOLOGDEBUG_ LogDebug( "Page1Procedure: end UM_SETTINGS2DIALOG" ); #endif return MRESULT (FALSE); } case UM_ADJUST: { #ifdef _DOLOGDEBUG_ LogDebug( "Page1Procedure: start UM_ADJUST" ); #endif // get file save style if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_FSSNUMFILES), BM_QUERYCHECK, 0,0)) pset->SetFileSaveStyle (FSS_NUMFILES); else if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_FSSFORCEFILE), BM_QUERYCHECK, 0,0)) pset->SetFileSaveStyle (FSS_FORCEFILE); else pset->SetFileSaveStyle (FSS_PROMPT); #ifdef _DOLOGDEBUG_ LogDebug( "Page1Procedure: checkpoint 1" ); #endif // Get file format. ULONG ul = USHORT( WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT, LM_QUERYSELECTION, MPFROMLONG( LIT_FIRST ), 0L ) ); ul = ULONG( WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT, LM_QUERYITEMHANDLE, MPFROMLONG( ul ), NULL ) ); pset->SetFileFormat( SHORT( ul ) ); /* if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_BMF12), BM_QUERYCHECK, 0,0)) pset->SetFileFormat (BMF_12); else if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_BMF20), BM_QUERYCHECK, 0,0)) pset->SetFileFormat (BMF_20); else pset->SetFileFormat (BMF_16); */ #ifdef _DOLOGDEBUG_ LogDebug( "Page1Procedure: checkpoint 2" ); #endif // num save dir file name CHAR psz[_MAX_PATH]; WinQueryDlgItemText (hwnd, WID_E_NUMSAVEDIR, _MAX_PATH, psz); pset->SetNumSaveDir (psz); // force file name WinQueryDlgItemText (hwnd, WID_E_FORCESAVEFILE, _MAX_PATH, psz); pset->SetForceSaveFile (psz); AdjustSaveTypeButtons (BOOL (pset->QueryFileSaveStyle () == FSS_FORCEFILE)); #ifdef _DOLOGDEBUG_ LogDebug( "Page1Procedure: end UM_ADJUST" ); #endif } break; case WM_CONTROL: switch (SHORT1FROMMP (mp1)) { case WID_RB_FSSFORCEFILE: AdjustSaveTypeButtons (TRUE); break; case WID_RB_FSSPROMPT: case WID_RB_FSSNUMFILES: AdjustSaveTypeButtons (FALSE); break; } return MRESULT (FALSE); } return WinDefDlgProc (hwnd, msg, mp1, mp2); }
// 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; }