WINEXPORT LRESULT CALLBACK WMainWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { HMENU menu; #if 0 HWND win; #endif LRESULT ret; Bool pass_to_def; WMenuEditInfo *einfo; WORD wp; MINMAXINFO *minmax; about_info ai; pass_to_def = TRUE; ret = FALSE; einfo = (WMenuEditInfo *)GET_WNDLONGPTR( hWnd, 0 ); WSetCurrentEditInfo( einfo ); switch( message ) { case WM_ACTIVATE: if( GET_WM_ACTIVATE_FACTIVE( wParam, lParam ) && !GET_WM_ACTIVATE_FMINIMIZED( wParam, lParam ) && einfo != NULL && einfo->edit_dlg != (HWND)NULL ) { SetFocus( einfo->edit_dlg ); pass_to_def = FALSE; } break; case WM_INITMENU: if( wParam == (WPARAM)GetMenu( hWnd ) ) { // set the cut and copy menu items ret = SendDlgItemMessage( einfo->edit_dlg, IDM_MENUEDLIST, LB_GETCURSEL, 0, 0 ); if( ret != LB_ERR ) { EnableMenuItem( (HMENU)wParam, IDM_MENU_CUT, MF_ENABLED ); EnableMenuItem( (HMENU)wParam, IDM_MENU_COPY, MF_ENABLED ); } else { EnableMenuItem( (HMENU)wParam, IDM_MENU_CUT, MF_GRAYED ); EnableMenuItem( (HMENU)wParam, IDM_MENU_COPY, MF_GRAYED ); } // set the paste menu item if( OpenClipboard( hWnd ) ) { if( //IsClipboardFormatAvailable( WClipbdFormat ) || IsClipboardFormatAvailable( WItemClipbdFormat ) ) { EnableMenuItem( (HMENU)wParam, IDM_MENU_PASTE, MF_ENABLED ); } else { EnableMenuItem( (HMENU)wParam, IDM_MENU_PASTE, MF_GRAYED ); } CloseClipboard(); } ret = FALSE; } break; case WM_CREATE: einfo = ((CREATESTRUCT *)lParam)->lpCreateParams; SET_WNDLONGPTR( hWnd, 0, (LONG_PTR)einfo ); break; case WM_MENUSELECT: if( einfo != NULL ) { menu = WGetMenuHandle( einfo ); WHandleMenuSelect( einfo->wsb, menu, wParam, lParam ); } break; case WM_GETMINMAXINFO: minmax = (MINMAXINFO *)lParam; minmax->ptMinTrackSize.x = appWidth; minmax->ptMinTrackSize.y = appHeight; break; case WM_MOVE: if( einfo != NULL ) { if( IsZoomed( hWnd ) ) { WSetOption( WOptScreenMax, TRUE ); } else if( !IsIconic( hWnd ) ) { WUpdateScreenPosOpt( hWnd ); WSetOption( WOptScreenMax, FALSE ); } WMovePrevWindow( einfo ); } break; case WM_SETFOCUS: if( einfo != NULL && einfo->preview_window != (HWND)NULL ) { SendMessage( einfo->preview_window, WM_NCACTIVATE, (WPARAM)TRUE, (LPARAM)NULL ); } break; case WM_SHOWWINDOW: if( wParam ) { ShowWindow( einfo->preview_window, SW_SHOWNA ); } else { ShowWindow( einfo->preview_window, SW_HIDE ); } break; case WM_SIZE: if( einfo != NULL ) { if( wParam == SIZE_MAXIMIZED ) { WSetOption( WOptScreenMax, TRUE ); } else if ( wParam != SIZE_MINIMIZED ) { WUpdateScreenPosOpt( hWnd ); WSetOption( WOptScreenMax, FALSE ); } if( einfo->preview_window != (HWND)NULL ) { if( wParam == SIZE_MINIMIZED ) { ShowWindow( einfo->preview_window, SW_HIDE ); } else { ShowWindow( einfo->preview_window, SW_SHOWNA ); } } if( wParam != SIZE_MINIMIZED ) { WResizeWindows( einfo ); } } break; #if 0 case WM_ACTIVATE: if( GET_WM_ACTIVATE_FACTIVE( wParam, lParam ) != WA_INACTIVE ) { win = GET_WM_ACTIVATE_HWND( wParam, lParam ); einfo = (WMenuEditInfo *)GET_WNDLONGPTR( win, 0 ); WSetCurrentEditInfo( einfo ); } else { WSetCurrentEditInfo( NULL ); } break; #endif case WM_COMMAND: wp = LOWORD( wParam ); switch( wp ) { case IDM_MENU_CLEAR: WHandleClear( einfo ); pass_to_def = FALSE; break; case IDM_MENU_UPDATE: SendMessage( einfo->info->parent, MENU_PLEASE_SAVEME, 0, (LPARAM)einfo->hndl ); pass_to_def = FALSE; break; case IDM_MENU_OPEN: pass_to_def = FALSE; if( einfo->info->modified ) { ret = WQuerySave( einfo, FALSE ); if( !ret ) { break; } } ret = SendMessage( einfo->info->parent, MENU_PLEASE_OPENME, 0, (LPARAM)einfo->hndl ); ret = FALSE; break; case IDM_MENU_SAVE: WSaveObject( einfo, FALSE, FALSE ); pass_to_def = FALSE; break; case IDM_MENU_SAVEAS: WSaveObject( einfo, TRUE, FALSE ); pass_to_def = FALSE; break; case IDM_MENU_SAVEINTO: WSaveObject( einfo, TRUE, TRUE ); pass_to_def = FALSE; break; case IDM_MENU_EXIT: /* clean up before we exit */ PostMessage( einfo->win, WM_CLOSE, 0, 0 ); break; case IDM_MENU_PASTE: WPasteMenuItem( einfo ); pass_to_def = FALSE; break; case IDM_MENU_CUT: case IDM_MENU_COPY: WClipMenuItem( einfo, wp == IDM_MENU_CUT ); pass_to_def = FALSE; break; case IDM_MENU_DELETE: WDeleteMenuEntry( einfo ); pass_to_def = FALSE; break; case IDM_MENU_INSERTSUBITEMS: WToggleInsertSubitems( einfo ); break; case IDM_MENU_INSERTBEFORE: if( !einfo->insert_before ) { WToggleInsertBitmap( einfo ); } break; case IDM_MENU_INSERTAFTER: if( einfo->insert_before ) { WToggleInsertBitmap( einfo ); } break; case IDM_MENU_INSERTTOGGLE: WToggleInsertBitmap( einfo ); break; #if 0 case IDM_MENU_NEWITEM: WInsertNewMenuEntry( einfo, FALSE, FALSE ); pass_to_def = FALSE; break; case IDM_MENU_NEWPOPUP: WInsertNewMenuEntry( einfo, TRUE, FALSE ); pass_to_def = FALSE; break; case IDM_MENU_NEWSEPARATOR: WInsertNewMenuEntry( einfo, FALSE, TRUE ); pass_to_def = FALSE; break; #else case IDM_MENU_NEWITEM: WInsertNew( einfo ); pass_to_def = FALSE; break; #endif case IDM_MENU_SYMBOLS: handleSymbols( einfo ); pass_to_def = FALSE; break; case IDM_MENU_LOAD_SYMBOLS: handleLoadSymbols( einfo ); pass_to_def = FALSE; break; case IDM_MENU_SHOWRIBBON: menu = WGetMenuHandle( einfo ); WShowRibbon( einfo, menu ); pass_to_def = FALSE; break; case IDM_MENU_MEM_FLAGS: WSetStatusByID( einfo->wsb, W_CHANGEMENUMEMFLAGS, -1 ); einfo->info->modified |= WChangeMemFlags( einfo->win, &einfo->info->MemFlags, einfo->info->res_name, WGetEditInstance(), WMenuHelpRoutine ); WSetStatusReadyText( einfo->wsb ); pass_to_def = FALSE; break; case IDM_MENU_RENAME: WHandleRename( einfo ); pass_to_def = FALSE; break; case IDM_HELP: WMenuHelpRoutine(); pass_to_def = FALSE; break; case IDM_HELP_SEARCH: WMenuHelpSearchRoutine(); pass_to_def = FALSE; break; case IDM_HELP_ON_HELP: WMenuHelpOnHelpRoutine(); pass_to_def = FALSE; break; case IDM_MENU_ABOUT: ai.owner = hWnd; ai.inst = WGetEditInstance(); ai.name = AllocRCString( W_ABOUT_NAME ); ai.version = AllocRCString( W_ABOUT_VERSION ); ai.first_cr_year = "2002"; ai.title = AllocRCString( W_ABOUT_TITLE ); DoAbout( &ai ); FreeRCString( ai.name ); FreeRCString( ai.version ); FreeRCString( ai.title ); pass_to_def = FALSE; break; } break; case WM_DESTROY: WWinHelp( hWnd, "resmnu.hlp", HELP_QUIT, 0 ); WCleanup( einfo ); break; case WM_CLOSE: ret = TRUE; pass_to_def = WHandleWM_CLOSE( einfo, (Bool)wParam ); wParam = 0; break; } if( pass_to_def ) { ret = DefWindowProc( hWnd, message, wParam, lParam ); } return( ret ); }
WINEXPORT LRESULT CALLBACK WMainWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { HMENU menu; #if 0 HWND win; #endif LRESULT ret; bool pass_to_def; WAccelEditInfo *einfo; WORD wp; MINMAXINFO *minmax; about_info ai; pass_to_def = TRUE; ret = FALSE; einfo = (WAccelEditInfo *)GET_WNDLONGPTR( hWnd, 0 ); WSetCurrentEditInfo( einfo ); if( einfo != NULL && einfo->getting_key ) { if( WGetKeyPressProc( einfo, message, wParam, lParam ) ) { einfo->getting_key = FALSE; DestroyWindow( einfo->key_info.text_win ); ReleaseCapture(); WHandleChange( einfo ); pass_to_def = FALSE; } } switch( message ) { case WM_ACTIVATE: if( GET_WM_ACTIVATE_FACTIVE( wParam, lParam ) && !GET_WM_ACTIVATE_FMINIMIZED( wParam, lParam ) && einfo != NULL && einfo->edit_dlg != (HWND)NULL ) { SetFocus( einfo->edit_dlg ); pass_to_def = FALSE; } break; case WM_INITMENU: if( wParam == (WPARAM)GetMenu( hWnd ) ) { // set the cut and copy menu items if( SendDlgItemMessage( einfo->edit_dlg, IDM_ACCEDLIST, LB_GETCURSEL, 0, 0 ) != LB_ERR ) { EnableMenuItem( (HMENU)wParam, IDM_ACC_CUT, MF_ENABLED ); EnableMenuItem( (HMENU)wParam, IDM_ACC_COPY, MF_ENABLED ); } else { EnableMenuItem( (HMENU)wParam, IDM_ACC_CUT, MF_GRAYED ); EnableMenuItem( (HMENU)wParam, IDM_ACC_COPY, MF_GRAYED ); } // set the paste menu item if( OpenClipboard( hWnd ) ) { if( //IsClipboardFormatAvailable( WClipbdFormat ) || IsClipboardFormatAvailable( WItemClipbdFormat ) ) { EnableMenuItem( (HMENU)wParam, IDM_ACC_PASTE, MF_ENABLED ); } else { EnableMenuItem( (HMENU)wParam, IDM_ACC_PASTE, MF_GRAYED ); } CloseClipboard(); } } break; case WM_CREATE: einfo = ((CREATESTRUCT *)lParam)->lpCreateParams; SET_WNDLONGPTR( hWnd, 0, (LONG_PTR)einfo ); break; case WM_MENUSELECT: if( einfo != NULL ) { menu = WGetMenuHandle( einfo ); WHandleMenuSelect( einfo->wsb, menu, wParam, lParam ); setLastMenuSelect( einfo, wParam, lParam ); } break; case WM_GETMINMAXINFO: minmax = (MINMAXINFO *)lParam; minmax->ptMinTrackSize.x = appWidth; minmax->ptMinTrackSize.y = appHeight; break; case WM_MOVE: if( einfo != NULL ) { if( IsZoomed( hWnd ) ) { WSetOption( WOptScreenMax, TRUE ); } else if( !IsIconic( hWnd ) ) { WUpdateScreenPosOpt( hWnd ); WSetOption( WOptScreenMax, FALSE ); } } break; case WM_SIZE: if( einfo != NULL ) { if( wParam == SIZE_MAXIMIZED ) { WSetOption( WOptScreenMax, TRUE ); } else if( wParam != SIZE_MINIMIZED ) { WUpdateScreenPosOpt( hWnd ); WSetOption( WOptScreenMax, FALSE ); } WResizeWindows( einfo ); } break; #if 0 case WM_ACTIVATE: if( GET_WM_ACTIVATE_FACTIVE( wParam, lParam ) != WA_INACTIVE ) { einfo = (WAccelEditInfo *)GET_WNDLONGPTR( hWnd, 0 ); if( einfo != NULL && einfo->edit_dlg != (HWND)NULL ) { SetFocus( einfo->edit_dlg ); } WSetCurrentEditInfo( einfo ); } else { WSetCurrentEditInfo( NULL ); } break; #endif case WM_COMMAND: wp = LOWORD( wParam ); switch( wp ) { case IDM_ACC_CLEAR: WHandleClear( einfo ); pass_to_def = FALSE; break; case IDM_ACC_UPDATE: SendMessage( einfo->info->parent, ACCEL_PLEASE_SAVEME, 0, (LPARAM)einfo->hndl ); pass_to_def = FALSE; break; case IDM_ACC_OPEN: pass_to_def = FALSE; if( einfo->info->modified ) { ret = WQuerySave( einfo, FALSE ); if( !ret ) { break; } } ret = SendMessage( einfo->info->parent, ACCEL_PLEASE_OPENME, 0, (LPARAM)einfo->hndl ); ret = FALSE; break; case IDM_ACC_SAVE: WSaveObject( einfo, FALSE, FALSE ); pass_to_def = FALSE; break; case IDM_ACC_SAVEAS: WSaveObject( einfo, TRUE, FALSE ); pass_to_def = FALSE; break; case IDM_ACC_SAVEINTO: WSaveObject( einfo, TRUE, TRUE ); pass_to_def = FALSE; break; case IDM_ACC_EXIT: /* clean up before we exit */ PostMessage( einfo->win, WM_CLOSE, 0, 0 ); break; case IDM_ACC_PASTE: WPasteAccelItem( einfo ); pass_to_def = FALSE; break; case IDM_ACC_COPY: case IDM_ACC_CUT: WClipAccelItem( einfo, wp == IDM_ACC_CUT ); pass_to_def = FALSE; break; case IDM_ACC_DELETE: WDeleteAccelEntry( einfo ); pass_to_def = FALSE; break; case IDM_ACC_NEWITEM: WInsertAccelEntry( einfo ); pass_to_def = FALSE; break; case IDM_ACC_KEYVALUE: WSetStatusByID( einfo->wsb, W_GETTINGKEYS, -1 ); WHandleGetKeyValue( einfo, einfo->last_menu_select == IDM_ACC_KEYVALUE ); WSetStatusReadyText( einfo->wsb ); pass_to_def = FALSE; break; case IDM_ACC_SYMBOLS: handleSymbols( einfo ); pass_to_def = FALSE; break; case IDM_ACC_LOAD_SYMBOLS: handleLoadSymbols( einfo ); pass_to_def = FALSE; break; case IDM_ACC_SHOWRIBBON: menu = WGetMenuHandle( einfo ); WShowRibbon( einfo, menu ); pass_to_def = FALSE; break; case IDM_ACC_MEM_FLAGS: WSetStatusByID( einfo->wsb, W_CHANGEACCELMEMFLAGS, -1 ); einfo->info->modified |= WChangeMemFlags( einfo->win, &einfo->info->MemFlags, einfo->info->res_name, WGetEditInstance(), WAccHelpRoutine ); pass_to_def = FALSE; WSetStatusReadyText( einfo->wsb ); break; case IDM_ACC_RENAME: WHandleRename( einfo ); pass_to_def = FALSE; break; case IDM_HELP: WAccHelpRoutine(); pass_to_def = FALSE; break; case IDM_HELP_SEARCH: WAccHelpSearchRoutine(); pass_to_def = FALSE; break; case IDM_HELP_ON_HELP: WAccHelpOnHelpRoutine(); pass_to_def = FALSE; break; case IDM_ACC_ABOUT: ai.owner = hWnd; ai.inst = WGetEditInstance(); ai.name = AllocRCString( W_ABOUT_NAME ); ai.version = AllocRCString( W_ABOUT_VERSION ); ai.first_cr_year = "2002"; ai.title = AllocRCString( W_ABOUT_TITLE ); DoAbout( &ai ); FreeRCString( ai.name ); FreeRCString( ai.version ); FreeRCString( ai.title ); pass_to_def = FALSE; break; } break; case WM_DESTROY: WWinHelp( hWnd, "resacc.hlp", HELP_QUIT, 0 ); WCleanup( einfo ); break; case WM_CLOSE: ret = TRUE; pass_to_def = WHandleWM_CLOSE( einfo, wParam != 0 ); wParam = 0; break; } if( pass_to_def ) { ret = DefWindowProc( hWnd, message, wParam, lParam ); } return( ret ); }
WINEXPORT BOOL CALLBACK WMenuEditProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { WMenuEditInfo *einfo; HWND win; RECT r; POINT p; LRESULT ret; WORD wp, cmd; ret = FALSE; einfo = (WMenuEditInfo *)GET_DLGDATA( hDlg ); switch( message ) { case WM_INITDIALOG: einfo = (WMenuEditInfo *)lParam; einfo->edit_dlg = hDlg; SET_DLGDATA( hDlg, (LONG_PTR)einfo ); WRAddSymbolsToComboBox( einfo->info->symbol_table, hDlg, IDM_MENUEDID, WR_HASHENTRY_ALL ); ret = TRUE; break; case WM_SYSCOLORCHANGE: WCtl3dColorChange(); break; #if 0 #ifdef __NT__ case WM_CTLCOLORBTN: case WM_CTLCOLORDLG: case WM_CTLCOLOREDIT: case WM_CTLCOLORLISTBOX: case WM_CTLCOLORMSGBOX: case WM_CTLCOLORSCROLLBAR: case WM_CTLCOLORSTATIC: #else case WM_CTLCOLOR: #endif return( (LRESULT)WCtl3dCtlColorEx( message, wParam, lParam ) ); #endif case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_RBUTTONUP: MAKE_POINT( p, lParam ); win = GetDlgItem( hDlg, IDM_MENUEDRNAME ); GetWindowRect( win, &r ); MapWindowPoints( HWND_DESKTOP, hDlg, (POINT *)&r, 2 ); if( PtInRect( &r, p ) ) { WHandleRename( einfo ); } ret = TRUE; break; case WM_SETFOCUS: if( einfo != NULL && einfo->preview_window != (HWND)NULL ) { SendMessage( einfo->preview_window, WM_NCACTIVATE, (WPARAM)TRUE, (LPARAM)NULL ); } break; #if 0 case WM_PARENTNOTIFY: cmd = GET_WM_PARENTNOTIFY_EVENT( wParam, lParam ); switch( cmd ) { case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: MAKE_POINT( p, lParam ); win = GetDlgItem( hDlg, IDM_MENUEDLIST ); GetClientRect( win, &r ); MapWindowPoints( win, hDlg, (POINT *)&r, 2 ); if( PtInRect( &r, p ) ) { WHandleSelChange( einfo ); } break; } ret = TRUE; break; #endif case WM_COMMAND: wp = LOWORD( wParam ); cmd = GET_WM_COMMAND_CMD( wParam, lParam ); switch( wp ) { case IDM_MENUEDGRAYED: if( IsDlgButtonChecked( hDlg, wp ) ) { CheckDlgButton( hDlg, IDM_MENUEDINACTIVE, 0 ); } break; case IDM_MENUEDINACTIVE: if( IsDlgButtonChecked( hDlg, wp ) ) { CheckDlgButton( hDlg, IDM_MENUEDGRAYED, 0 ); } break; #if 0 case IDM_MENUEDID: if( cmd == CBN_SELCHANGE ) { einfo->combo_change = TRUE; WHandleSelChange( einfo ); einfo->combo_change = FALSE; } break; #endif case IDM_MENUEDINSERT: WInsertNew( einfo ); break; case IDM_MENUEDCHANGE: WDoHandleSelChange( einfo, TRUE, FALSE ); break; case IDM_MENUEDRESET: WDoHandleSelChange( einfo, FALSE, TRUE ); break; case IDM_MENUEDSHIFTLEFT: WShiftEntry( einfo, TRUE ); break; case IDM_MENUEDSHIFTRIGHT: WShiftEntry( einfo, FALSE ); break; case IDM_MENUEDLIST: if( cmd == LBN_SELCHANGE ) { WHandleSelChange( einfo ); } break; case IDM_MENUEDSETMENU: if( einfo->menu != NULL && einfo->menu->first_entry != NULL ) { WHandleSelChange( einfo ); } else { WInsertNew( einfo ); } break; } break; } return( ret ); }
WINEXPORT BOOL CALLBACK WAcccelEditProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { WAccelEditInfo *einfo; HWND win; RECT r; POINT p; BOOL ret; WORD wp; WORD cmd; ret = FALSE; einfo = (WAccelEditInfo *)GET_DLGDATA( hDlg ); switch( message ) { case WM_INITDIALOG: einfo = (WAccelEditInfo *)lParam; einfo->edit_dlg = hDlg; SET_DLGDATA( hDlg, einfo ); WRAddSymbolsToComboBox( einfo->info->symbol_table, hDlg, IDM_ACCEDCMDID, WR_HASHENTRY_ALL ); ret = TRUE; break; case WM_SYSCOLORCHANGE: WCtl3dColorChange(); break; #if 0 #ifdef __NT__ case WM_CTLCOLORBTN: case WM_CTLCOLORDLG: case WM_CTLCOLOREDIT: case WM_CTLCOLORLISTBOX: case WM_CTLCOLORMSGBOX: case WM_CTLCOLORSCROLLBAR: case WM_CTLCOLORSTATIC: #else case WM_CTLCOLOR: #endif return( WCtl3dCtlColorEx( message, wParam, lParam ) ); #endif case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_RBUTTONUP: MAKE_POINT( p, lParam ); win = GetDlgItem( hDlg, IDM_ACCEDRNAME ); GetClientRect( win, &r ); MapWindowPoints( win, hDlg, (POINT *)&r, 2 ); if( PtInRect( &r, p ) ) { WHandleRename( einfo ); } ret = TRUE; break; #if 0 case WM_PARENTNOTIFY: cmd = GET_WM_PARENTNOTIFY_EVENT( wParam, lParam ); switch( cmd ) { case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: MAKE_POINT( p, lParam ); win = GetDlgItem( hDlg, IDM_ACCEDLIST ); GetWindowRect( win, &r ); MapWindowPoints( HWND_DESKTOP, hDlg, (POINT *)&r, 2 ); if( PtInRect( &r, p ) ) { WHandleSelChange( einfo ); } break; } ret = TRUE; break; #endif case WM_COMMAND: wp = LOWORD( wParam ); cmd = GET_WM_COMMAND_CMD( wParam, lParam ); switch( wp ) { case IDM_ACCEDINSERT: WInsertAccelEntry( einfo ); break; case IDM_ACCEDCHANGE: WHandleChange( einfo ); break; case IDM_ACCEDRESET: WDoHandleSelChange( einfo, FALSE, TRUE ); break; case IDM_ACCEDSETACC: if( einfo->tbl != NULL && einfo->tbl->num != 0 ) { WHandleSelChange( einfo ); } else { WInsertAccelEntry( einfo ); } break; #if 0 case IDM_ACCEDCMDID: if( cmd == CBN_SELCHANGE ) { einfo->combo_change = TRUE; WHandleSelChange( einfo ); einfo->combo_change = FALSE; } break; #endif case IDM_ACCEDLIST: if( cmd == LBN_SELCHANGE ) { WHandleSelChange( einfo ); } break; case IDM_ACCEDVIRT: case IDM_ACCEDASCII: if( cmd == BN_CLICKED ) { WSetVirtKey( hDlg, wp == IDM_ACCEDVIRT ); } break; } break; } return( ret ); }