WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_ACTIVATE: { WXWORD state, minimized; WXHWND hwnd; UnpackActivate(wParam, lParam, &state, &minimized, &hwnd); processed = HandleActivate(state, minimized != 0, hwnd); } break; case WM_COMMAND: { WXWORD id, cmd; WXHWND hwnd; UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); (void)HandleCommand(id, cmd, hwnd); // even if the frame didn't process it, there is no need to try it // once again (i.e. call wxFrame::HandleCommand()) - we just did it, // so pretend we processed the message anyhow processed = true; } // always pass this message DefFrameProc(), otherwise MDI menu // commands (and sys commands - more surprisingly!) won't work MSWDefWindowProc(message, wParam, lParam); break; case WM_CREATE: m_clientWindow = OnCreateClient(); // Uses own style for client style if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) ) { wxLogMessage(_("Failed to create MDI parent frame.")); rc = -1; } processed = true; break; case WM_ERASEBKGND: processed = true; // we erase background ourselves rc = true; break; case WM_MENUSELECT: { WXWORD item, flags; WXHMENU hmenu; UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); if ( m_parentFrameActive ) { processed = HandleMenuSelect(item, flags, hmenu); } else if (m_currentChild) { processed = m_currentChild-> HandleMenuSelect(item, flags, hmenu); } } break; case WM_SIZE: // though we don't (usually) resize the MDI client to exactly fit the // client area we need to pass this one to DefFrameProc to allow the children to show break; } if ( !processed ) rc = wxFrame::MSWWindowProc(message, wParam, lParam); return rc; }
/* * MainWindowProc - procedure for main (root) window */ WINEXPORT LRESULT CALLBACK MainWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { RECT rect; vi_rc rc; HANDLE hfileinfo; int cnt, i; char *buff; switch( msg ) { case WM_CREATE: Root = hwnd; GetClientRect( hwnd, &rect ); EditContainer = CreateContainerWindow( &rect ); InitWindows(); DragAcceptFiles( hwnd, TRUE ); timerID = SetTimer( hwnd, TIMER_ID, 60L * 1000L, NULL ); break; case WM_DROPFILES: hfileinfo = (HANDLE) wparam; cnt = DragQueryFile( hfileinfo, (UINT)-1, NULL, 0 ); buff = alloca( FILENAME_MAX + 2 ); /* we add a " at the beginning and at the end so we can handle path- and filenames with spaces */ if( buff != NULL ) { buff[0] = '"'; /* one " at the beginning of the filename */ for( i = 0; i < cnt; i++ ) { if( DragQueryFile( hfileinfo, i, buff + 1, FILENAME_MAX ) == (UINT)-1 ) { break; } strcat( buff, "\"" ); rc = EditFile( buff, FALSE ); if( rc > ERR_NO_ERR ) { Error( GetErrorMsg( rc ) ); } } } DragFinish( hfileinfo ); break; case WM_TIMER: UpdateStatusWindow(); break; case WM_KEYDOWN: if( WindowsKeyPush( wparam, HIWORD( lparam ) ) ) { return( 0 ); } break; case WM_SIZE: DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ); RootState = wparam; if( wparam != SIZE_MINIMIZED ) { ResizeRoot(); GetWindowRect( hwnd, &RootRect ); if( wparam != SIZE_MAXIMIZED ) { RootState = 0; } } return( 0 ); case WM_MOVE: DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ); if( RootState != SIZE_MINIMIZED ) { GetWindowRect( hwnd, &RootRect ); } return( 0 ); case WM_ACTIVATEAPP: if( BAD_ID( CurrentWindow ) ) { break; } SetFocus( Root ); #if 0 if( !wparam ) { InactiveWindow( CurrentWindow ); } else { SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L ); } #endif if( wparam ) { ResetEditWindowCursor( CurrentWindow ); } else { GoodbyeCursor( CurrentWindow ); } break; case WM_MOUSEACTIVATE: SetFocus( hwnd ); return( MA_ACTIVATE ); case WM_SETFOCUS: if( BAD_ID( CurrentWindow ) ) { break; } if( !IsIconic( CurrentWindow ) ) { SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L ); DCUpdate(); SetWindowCursor(); SetWindowCursorForReal(); return( 0 ); } break; case WM_NCLBUTTONDBLCLK: break; case WM_COMMAND: if( LOWORD( wparam ) > 0xF000 ) { break; } else { rc = MenuCommand( LOWORD( wparam ) ); if( rc != MENU_COMMAND_NOT_HANDLED ) { DCUpdateAll(); if( rc > ERR_NO_ERR ) { char *msg; msg = GetErrorMsg( rc ); Error( msg ); } } SetWindowCursor(); } return( 0 ); case WM_INITMENU: if( (HMENU)wparam == GetMenu( hwnd ) ) { HandleInitMenu( (HMENU)wparam ); } else { ResetMenuBits(); } break; case WM_MENUSELECT: HandleMenuSelect( wparam, lparam ); break; case WM_ENDSESSION: if( wparam ) { ExitEditor( 0 ); // will not return } return( 0 ); case WM_QUERYENDSESSION: return( ExitWithPrompt( FALSE, TRUE ) ); case WM_CLOSE: ExitWithPrompt( TRUE, TRUE ); return( 0 ); #ifdef __NT__ case WM_MOUSEWHEEL: { int i, increment; ULONG linesPerNotch; HWND activeWnd; activeWnd = (HWND)SendMessage( EditContainer, WM_MDIGETACTIVE, 0, 0 ); SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &linesPerNotch, 0 ); increment = GET_WHEEL_DELTA_WPARAM( wparam ) / 120; // see WM_MOUSEWHEEL-documentation for information about the "120" if( increment > 0 ) { for( i = 0; i < increment * (int)linesPerNotch; i++ ) { SendMessage( activeWnd, WM_VSCROLL, SB_LINEUP, 0 ); } } else { for( i = 0; i < (-increment) * (int)linesPerNotch; i++ ) { SendMessage( activeWnd, WM_VSCROLL, SB_LINEDOWN, 0 ); } } } return( 0 ); #endif case WM_DESTROY: DestroyToolBar(); DragAcceptFiles( hwnd, FALSE ); EditContainer = 0; if( timerID ) { KillTimer( hwnd, TIMER_ID ); } return( 0 ); } return( DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ) ); } /* MainWindowProc */
MRESULT wxFrame::OS2WindowProc( WXUINT uMessage, WXWPARAM wParam, WXLPARAM lParam ) { MRESULT mRc = 0L; bool bProcessed = false; switch (uMessage) { case WM_CLOSE: // // If we can't close, tell the system that we processed the // message - otherwise it would close us // bProcessed = !Close(); break; case WM_PAINT: bProcessed = HandlePaint(); mRc = (MRESULT)FALSE; break; case WM_ERASEBACKGROUND: // // Returning TRUE to requests PM to paint the window background // in SYSCLR_WINDOW. We capture this here because the PS returned // in Frames is the PS for the whole frame, which we can't really // use at all. If you want to paint a different background, do it // in an OnPaint using a wxPaintDC. // mRc = (MRESULT)(TRUE); break; case WM_COMMAND: { WORD wId; WORD wCmd; WXHWND hWnd; UnpackCommand( (WXWPARAM)wParam ,(WXLPARAM)lParam ,&wId ,&hWnd ,&wCmd ); bProcessed = HandleCommand( wId ,wCmd ,(WXHWND)hWnd ); } break; case WM_MENUSELECT: { WXWORD wItem; WXWORD wFlags; WXHMENU hMenu; UnpackMenuSelect( wParam ,lParam ,&wItem ,&wFlags ,&hMenu ); bProcessed = HandleMenuSelect( wItem ,wFlags ,hMenu ); mRc = (MRESULT)TRUE; } break; case WM_SIZE: { SHORT nScxnew = SHORT1FROMMP(lParam); // New horizontal size. SHORT nScynew = SHORT2FROMMP(lParam); // New vertical size. lParam = MRFROM2SHORT( nScxnew - 20 ,nScynew - 30 ); } bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam); mRc = (MRESULT)FALSE; break; case CM_QUERYDRAGIMAGE: { const wxIcon& vIcon = GetIcon(); HPOINTER hIcon; if (vIcon.Ok()) hIcon = (HPOINTER)::WinSendMsg(GetHWND(), WM_QUERYICON, 0L, 0L); else hIcon = (HPOINTER)m_hDefaultIcon; mRc = (MRESULT)hIcon; bProcessed = mRc != 0; } break; } if (!bProcessed ) mRc = wxWindow::OS2WindowProc( uMessage ,wParam ,lParam ); return (MRESULT)mRc; } // wxFrame::OS2WindowProc
WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_CLOSE: // if we can't close, tell the system that we processed the // message - otherwise it would close us processed = !Close(); break; case WM_SIZE: processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); break; case WM_COMMAND: { WORD id, cmd; WXHWND hwnd; UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, &id, &hwnd, &cmd); HandleCommand(id, cmd, (WXHWND)hwnd); // don't pass WM_COMMAND to the base class whether we processed // it or not because we did generate an event for it (our // HandleCommand() calls the base class version) and we must // not do it again or the handlers which skip the event would // be called twice processed = true; } break; #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) #if wxUSE_MENUS case WM_INITMENUPOPUP: processed = HandleInitMenuPopup((WXHMENU) wParam); break; case WM_MENUSELECT: { WXWORD item, flags; WXHMENU hmenu; UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); processed = HandleMenuSelect(item, flags, hmenu); } break; case WM_EXITMENULOOP: processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam); break; #endif // wxUSE_MENUS case WM_QUERYDRAGICON: { const wxIcon& icon = GetIcon(); HICON hIcon = icon.IsOk() ? GetHiconOf(icon) : (HICON)GetDefaultIcon(); rc = (WXLRESULT)hIcon; processed = rc != 0; } break; #endif // !__WXMICROWIN__ } if ( !processed ) rc = wxFrameBase::MSWWindowProc(message, wParam, lParam); return rc; }
WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_CLOSE: // if we can't close, tell the system that we processed the // message - otherwise it would close us processed = !Close(); break; case WM_SIZE: processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); break; case WM_COMMAND: { WORD id, cmd; WXHWND hwnd; UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, &id, &hwnd, &cmd); processed = HandleCommand(id, cmd, (WXHWND)hwnd); } break; case WM_PAINT: processed = HandlePaint(); break; case WM_INITMENUPOPUP: processed = HandleInitMenuPopup((WXHMENU) wParam); break; #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) case WM_MENUSELECT: { WXWORD item, flags; WXHMENU hmenu; UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); processed = HandleMenuSelect(item, flags, hmenu); } break; case WM_EXITMENULOOP: processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam); break; case WM_QUERYDRAGICON: { const wxIcon& icon = GetIcon(); HICON hIcon = icon.Ok() ? GetHiconOf(icon) : (HICON)GetDefaultIcon(); rc = (long)hIcon; processed = rc != 0; } break; #endif // !__WXMICROWIN__ } if ( !processed ) rc = wxFrameBase::MSWWindowProc(message, wParam, lParam); return rc; }
static pascal SInt32 MenuSelectPatch(Point startPt) // This is our patch on MenuSelect. The basic idea is to // call our clients to let them adjust their menus (and install // sub-menus by calling InsertSystemMenu), call through to // the old trap, call our clients to un-adjust their menus, // and then call HandleMenuSelect to see whether the chosen // menu was one of our system menus. If it was, HandleMenuSelect // calls the client to tell them that their menu was chosen and // returns 0 so that we tell the host application that nothing // happened. // // Note that MenuSelect is called by MenuEvent, so this patch // covers that case as well. { long oldA4; SInt32 result; SubSysMenuHandle tempSubSysMenus; oldA4 = SetUpA4(); // Our patch should only be installed if InitMoreSystemMenus was successful. assert(gRootSysMenus != NULL); // Only do stuff if we're actually up and running. // If gHaveInsertedRootSysMenus is false, it means that // someone is calling MenuSelect before our InsertMenu patch // has run, ie before anyone has inserted any system menus, // ie before the Process Manager has launched. I don't know // whether this ever happens, I'm use being cautious. // Also, if gMenuSelectState is not NULL then we're getting recursion // where we're not expecting it (probably from the kSystemMenuPreSelectAdjust // or kSystemMenuPostSelectAdjust callbacks, but possibly from another // trap patch), so we just call through to the system in that case. // We want debug versions to tell the client that they're recursing // in an unsupport fashion. assert(gMenuSelectState == kMenuSelectStateNil); if ( gHaveInsertedRootSysMenus && gMenuSelectState == kMenuSelectStateNil) { // OK, so we're up and running, so let's do our stuff. // First tell all clients that we're about to do a MenuSelect // (they can adjust their menus and insert sub-menus)... assert(gSubSysMenus == NULL); gMenuSelectState = kMenuSelectStatePre; CallAllClients(kSystemMenuPreSelectAdjust, NULL); // ... then call through to the old trap address... result = CallMenuSelectProc(gMenuSelectOldUPP, startPt); // ... and then tell all clients that we're done... gMenuSelectState = kMenuSelectStatePost; CallAllClients(kSystemMenuPostSelectAdjust, NULL); // Things get tricky here. In order to allow the client // to post modal dialogs from its kSystemMenuActOnChosen callback, // we must be re-entrant at the time we call HandleMenuSelect // (because the ModalDialog routine will call MenuSelect). // But we want to avoid having sub-menus in the menu bar when // we're recursively called because we're going to call the // client's kSystemMenuPreSelectAdjust callback, which will // attempt to re-insert those menus. // // So, we remove our sub-menus now, before calling the // kSystemMenuActOnChosen callback, then we make the callback, // and then we dispose of the memory we used to track the // sub-menus. tempSubSysMenus = gSubSysMenus; gSubSysMenus = NULL; DeleteSubMenus(tempSubSysMenus); gMenuSelectState = kMenuSelectStateNil; // At this point we're prepared to accept recursion. // Call HandleMenuSelect to process the results // from the menu operation and call the appropriate // client if it was one of our menus. result = HandleMenuSelect(result, tempSubSysMenus); // Clean up. If we created any sub-menu info, // dispose of it. if (tempSubSysMenus != NULL) { DisposeHandle( (Handle) tempSubSysMenus); assert(MemError() == noErr); } } else { result = CallMenuSelectProc(gMenuSelectOldUPP, startPt); } assert(gMenuSelectState == kMenuSelectStateNil); (void) SetA4(oldA4); return result; }