/* * saveBitmapFile - gets the bitmap data and saves it in fname. */ static bool saveBitmapFile( img_node *node ) { BITMAPARRAYFILEHEADER2 new_file; BITMAPINFO2 *bmi; long clrtable_size; RGB2 *colours; FILE *fp; char text[ HINT_TEXT_LEN ]; char filename[ _MAX_FNAME ]; bool ok; ok = false; bmi = GetXorBitmapInfo(node); if( bmi != NULL ) { clrtable_size = sizeof( RGB2 ) * ( 1 << ( node->bitcount ) ); new_file.usType = BFT_BITMAPARRAY; new_file.cbSize = sizeof( BITMAPARRAYFILEHEADER2 ); new_file.offNext = 0; new_file.cxDisplay = 0; new_file.cyDisplay = 0; new_file.bfh2.usType = BFT_BMAP; new_file.bfh2.cbSize = sizeof( BITMAPFILEHEADER2 ); new_file.bfh2.xHotspot = 0; new_file.bfh2.yHotspot = 0; new_file.bfh2.offBits = new_file.cbSize + clrtable_size; memcpy( &(new_file.bfh2.bmp2), bmi, sizeof( BITMAPINFOHEADER2 ) ); colours = (void *)&(bmi->argbColor[0]); fp = fopen( node->fname, "wb" ); if( fp != NULL ) { if( fseek( fp, 0L, SEEK_SET ) == 0 ) { if( fwrite( &new_file, sizeof( BITMAPARRAYFILEHEADER2 ), 1, fp ) == 1 ) { if( fwrite( colours, clrtable_size, 1, fp ) == 1 ) { if( writeDataInPieces( bmi, fp, node ) ) { ok = true; } else { MessageBox( HMainWindow, "Error writing file!", "Error", MB_OK | MB_ICONEXCLAMATION ); SetHintText( "Error saving file" ); } } } } fclose( fp ); } FreeDIBitmapInfo( bmi ); if( ok ) { AllowRestoreOption( node ); SetIsSaved( node->hwnd, TRUE ); GetFnameFromPath( node->fname, filename ); sprintf( text, "Bitmap saved to '%s'", filename ); SetHintText( text ); } } return( ok ); } /* saveBitmapFile */
/* * PrintHintText */ void PrintHintText( char *msg, char *fname ) { char *text; if( msg != NULL ) { if( fname != NULL ) { text = (char *)MemAlloc( strlen(msg) + strlen( fname ) + 1 ); if( text != NULL ) { sprintf( text, msg, fname ); SetHintText( text ); MemFree( text ); } } else { SetHintText( msg ); } } } /* PrintHintText */
/* * SaveColourPalette - saves the current colour palette. */ bool SaveColourPalette( void ) { a_pal_file pal_file; FILE *fp; char fname[ _MAX_PATH ]; char filename[ _MAX_FNAME + _MAX_EXT ]; char text[ HINT_TEXT_LEN ]; bool ok; if( !getSavePalName( fname ) ) { if( CommDlgExtendedError() != 0 ) { sprintf( text, "Error saving '%s'", fname ); SetHintText( text ); return( false ); } else { return( true ); } } checkForPalExt( fname ); if( !GetPaletteFile( &pal_file ) ) { sprintf( text, "Current palette not 16 colours!", fname ); SetHintText( text ); return( true ); // Just return ... no error } ok = false; sprintf( text, "Error saving '%s'", fname ); fp = fopen( fname, "wb" ); if( fp != NULL ) { if( fseek( fp, 0L, SEEK_SET ) == 0 ) { if( fwrite( &pal_file, sizeof( a_pal_file ), 1, fp ) == 1 ) { ok = true; } } fclose( fp ); } if( ok ) { GetFnameFromPath( fname, filename ); sprintf( text, "Palette saved to '%s'", filename ); } SetHintText( text ); return( ok ); } /* SaveColourPalette */
void WriteIconLoadedText( char *filename, int num ) { char *text; char msg[ _MAX_PATH ]; text = IEAllocRCString( WIE_ICONOPENEDTEXT ); if( text ) { sprintf( msg, text, filename, num ); SetHintText( msg ); IEFreeRCString( text ); } }
//----------------------------------------------------------------------------- // Purpose: Localize, display, and animate the hud element //----------------------------------------------------------------------------- void CHudSideHintPanel::LocalizeAndDisplay( const char *pszHudTxtMsg, const char *szRawString ) { static wchar_t szBuf[128]; static wchar_t *pszBuf; // init buffers & pointers szBuf[0] = 0; pszBuf = szBuf; // try to localize if ( pszHudTxtMsg ) { pszBuf = g_pVGuiLocalize->Find( pszHudTxtMsg ); } else { pszBuf = g_pVGuiLocalize->Find( szRawString ); } if ( !pszBuf ) { // use plain ASCII string g_pVGuiLocalize->ConvertANSIToUnicode( szRawString, szBuf, sizeof(szBuf) ); pszBuf = szBuf; } // make it visible if ( SetHintText( pszBuf ) ) { SetVisible( true ); g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SideHintShow" ); C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); if ( pLocalPlayer ) { pLocalPlayer->EmitSound( "Hud.Hint" ); if ( pLocalPlayer->Hints() ) { pLocalPlayer->Hints()->PlayedAHint(); } } } else { g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SideHintHide" ); } }
/* * WriteSetSizeText */ void WriteSetSizeText( DWORD msg, int x, int y ) { char *text; char *msg_text; text = IEAllocRCString( msg ); if( text != NULL ) { msg_text = (char *)MemAlloc( strlen( text ) + 20 + 1 ); if( msg_text != NULL ) { sprintf( msg_text, text, x, y ); SetHintText( msg_text ); MemFree( msg_text ); } IEFreeRCString( text ); } } /* WriteSetSizeText */
/* * IEPrintAmtText */ void IEPrintAmtText( DWORD message, int amt ) { char *text; char *msg; text = IEAllocRCString( message ); if( text != NULL ) { msg = (char *)MemAlloc( strlen( text ) + 10 + 1 ); if( msg != NULL ) { sprintf( msg, text, amt ); SetHintText( msg ); MemFree( msg ); } IEFreeRCString( text ); } } /* IEPrintAmtText */
void CHudLessonPanel::Reset() { SetHintText( NULL ); g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "LessonHide" ); m_bLastLabelUpdateHack = true; }
/* * ImgEdFrameProc - handle messages for the image editor application */ WPI_MRESULT CALLBACK ImgEdFrameProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { static BOOL window_destroyed = FALSE; static HMENU hmenu; ctl_id cmdid; img_node *node; WPI_RECT rcmain; #ifndef __OS2_PM__ about_info ai; #endif WPI_RECTDIM left, top; if( !window_destroyed ) { enableMainItems( hmenu ); } switch( msg ) { case UM_EXIT: _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L ); /* fall through */ case UM_EXIT_NO_SAVE: if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) { break; } #ifndef __OS2_PM__ _wpi_destroywindow( _wpi_getframe( hwnd ) ); #else _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 ); #endif break; case UM_SAVE_ALL: SaveAllImages(); break; case WM_CREATE: hmenu = _wpi_getmenu( _wpi_getframe( hwnd ) ); #ifndef __OS2_PM__ createClientWindow( hwnd ); #endif if( !InitStatusLine( hwnd ) ) { return( -1 ); } InitFunctionBar( hwnd ); InitIconInfo(); InitializeCursors(); /* * Set values from profile information ... */ if( ImgedConfigInfo.brush_size <= 5 && ImgedConfigInfo.brush_size >= 2 ) { checkBrushItem( hmenu, IMGED_2x2 - 2 + ImgedConfigInfo.brush_size ); } if( ImgedConfigInfo.grid_on ) { CheckGridItem( hmenu ); } if( ImgedConfigInfo.square_grid ) { CheckSquareGrid( hmenu ); } if( ImgedConfigInfo.show_state & SET_SHOW_VIEW ) { CheckViewItem( hmenu ); } _wpi_enablemenuitem( hmenu, IMGED_CRESET, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE ); #ifndef __OS2_PM__ // not necessary for PM InitMenus( hmenu ); #endif SetHintText( IEAppTitle ); return( 0 ); #ifdef __NT__ case WM_DROPFILES: OpenImage( (HANDLE)wparam ); break; #endif case WM_MOVE: _wpi_getwindowrect( hwnd, &rcmain ); if( !ImgedConfigInfo.ismaximized ) { ImgedConfigInfo.last_xpos = ImgedConfigInfo.x_pos; ImgedConfigInfo.last_ypos = ImgedConfigInfo.y_pos; _wpi_getrectvalues( rcmain, &left, &top, NULL, NULL ); ImgedConfigInfo.x_pos = (short)left; ImgedConfigInfo.y_pos = (short)top; } return( 0 ); case WM_SIZE: ResizeFunctionBar( lparam ); ResizeStatusBar( lparam ); #ifndef __OS2_PM__ if( ClientWindow != NULL ) { setClientSize( hwnd ); } #else resizeClientArea( lparam ); #endif if( !_imgwpi_issizeminimized( wparam ) && !_imgwpi_issizemaximized( wparam ) ) { _wpi_getwindowrect( hwnd, &rcmain ); ImgedConfigInfo.width = (short)_wpi_getwidthrect( rcmain ); ImgedConfigInfo.height = (short)_wpi_getheightrect( rcmain ); ImgedConfigInfo.ismaximized = FALSE; } else { ImgedConfigInfo.x_pos = ImgedConfigInfo.last_xpos; ImgedConfigInfo.y_pos = ImgedConfigInfo.last_ypos; ImgedConfigInfo.ismaximized = _imgwpi_issizemaximized( wparam ); } return( FALSE ); case WM_MENUSELECT: #ifndef __OS2_PM__ if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SEPARATOR ) { break; } if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SYSMENU ) { PrintHintTextByID( WIE_SYSMENUOPERATIONS, NULL ); break; } #endif ShowHintText( LOWORD( wparam ) ); break; case WM_COMMAND: cmdid = LOWORD( wparam ); if( !IEIsMenuIDValid( hmenu, cmdid ) ) { break; } switch( cmdid ) { case IMGED_NEW: if( !ImgedIsDDE ) { if( !NewImage( UNDEF_IMG, NULL ) ) { PrintHintTextByID( WIE_NEIMAGENOTCREATED, NULL ); } } break; case IMGED_CLOSE: node = GetCurrentNode(); if( node != NULL ) { _wpi_sendmessage( node->hwnd, WM_CLOSE, 0, 0L ); } break; case IMGED_CLOSEALL: CloseAllImages(); break; case IMGED_HELP: IEHelpRoutine(); break; case IMGED_HELP_SEARCH: IEHelpSearchRoutine(); break; case IMGED_HELP_ON_HELP: IEHelpOnHelpRoutine(); break; case IMGED_ABOUT: #ifndef __OS2_PM__ ai.owner = hwnd; ai.inst = Instance; ai.name = IEAllocRCString( WIE_ABOUTTEXT ); ai.version = IEAllocRCString( WIE_ABOUTVERSION ); ai.title = IEAllocRCString( WIE_ABOUTTITLE ); DoAbout( &ai ); if( ai.name != NULL ) { IEFreeRCString( ai.name ); } if( ai.version != NULL ) { IEFreeRCString( ai.version ); } if( ai.title != NULL ) { IEFreeRCString( ai.title ); } #endif break; #ifndef __OS2_PM__ case IMGED_DDE_UPDATE_PRJ: IEUpdateDDEEditSession(); break; #endif case IMGED_SAVE_AS: SaveFile( SB_SAVE_AS ); break; case IMGED_SAVE: SaveFile( SB_SAVE ); break; case IMGED_OPEN: if( !ImgedIsDDE ) { OpenImage( NULL ); } break; case IMGED_CLEAR: ClearImage(); break; case IMGED_NEWIMG: AddNewIcon(); break; case IMGED_SELIMG: SelectIconImg(); break; case IMGED_DELIMG: DeleteIconImg(); break; case IMGED_UNDO: UndoOp(); break; case IMGED_REDO: RedoOp(); break; case IMGED_REST: RestoreImage(); break; case IMGED_SNAP: #ifndef __OS2_PM__ SnapPicture(); #endif break; case IMGED_RIGHT: case IMGED_LEFT: case IMGED_UP: case IMGED_DOWN: ShiftImage( cmdid ); break; case IMGED_FLIPHORZ: case IMGED_FLIPVERT: FlipImage( cmdid ); break; case IMGED_ROTATECC: case IMGED_ROTATECL: RotateImage( cmdid ); break; case IMGED_PASTE: PlaceAndPaste(); break; case IMGED_COPY: IECopyImage(); break; case IMGED_CUT: CutImage(); break; case IMGED_COLOR: CheckPaletteItem( hmenu ); break; case IMGED_VIEW: CheckViewItem( hmenu ); break; case IMGED_TOOLBAR: CheckToolbarItem( hmenu ); break; case IMGED_SQUARE: CheckSquareGrid( hmenu ); break; case IMGED_SIZE: ChangeImageSize(); break; case IMGED_GRID: CheckGridItem( hmenu ); break; case IMGED_MAXIMIZE: MaximizeCurrentChild(); break; case IMGED_SETTINGS: SelectOptions(); break; case IMGED_2x2: case IMGED_3x3: case IMGED_4x4: case IMGED_5x5: checkBrushItem( hmenu, cmdid ); break; case IMGED_CEDIT: #ifndef __OS2_PM__ EditColors(); #endif break; case IMGED_CRESET: #ifndef __OS2_PM__ RestoreColors(); #endif break; case IMGED_CSCREEN: ChooseBkColor(); break; case IMGED_SCOLOR: #ifndef __OS2_PM__ SaveColorPalette(); #endif break; case IMGED_LCOLOR: #ifndef __OS2_PM__ if( LoadColorPalette() ) { _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, TRUE, FALSE ); } #endif break; case IMGED_RCOLOR: RestoreColorPalette(); break; case IMGED_FREEHAND: case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_FILL: case IMGED_BRUSH: case IMGED_CLIP: case IMGED_HOTSPOT: SetToolType( cmdid ); PushToolButton( cmdid ); break; case IMGED_ARRANGE: #ifndef __OS2_PM__ SendMessage( ClientWindow, WM_MDIICONARRANGE, 0, 0L ); #endif break; case IMGED_TILE: #ifndef __OS2_PM__ SendMessage( ClientWindow, WM_MDITILE, MDITILE_VERTICAL, 0L ); #endif break; case IMGED_CASCADE: #ifndef __OS2_PM__ SendMessage( ClientWindow, WM_MDICASCADE, MDITILE_SKIPDISABLED, 0L ); #endif break; case IMGED_EXIT: _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L ); if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) { break; } #ifndef __OS2_PM__ _wpi_destroywindow( _wpi_getframe( hwnd ) ); #else _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 ); #endif break; default: #if 1 return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) ); #else return( 0 ); #endif } return( 0 ); #ifndef __OS2_PM__ case WM_COMPACTING: RelieveUndos(); return 0; #endif case WM_QUERYENDSESSION: if( _wpi_isiconic( _wpi_getframe( hwnd ) ) ) { if( ImgedConfigInfo.ismaximized ) { _wpi_maximizewindow( _wpi_getframe( hwnd ) ); } else { _wpi_showwindow( _wpi_getframe( hwnd ), SW_SHOWNORMAL ); } } _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L ); if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) { return( 0 ); } return( (WPI_MRESULT)1 ); case WM_CLOSE: // wParam is non-zero if the DDE connection died if( !wparam && !ImgEdEnableMenuInput ) { // this prevents the user from closing the editor during // DDE initialization return( 0 ); } _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L ); #ifdef __OS2_PM__ return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); #else if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) { return( 0 ); } window_destroyed = TRUE; _wpi_destroywindow( _wpi_getframe( hwnd ) ); return( 0 ); #endif case WM_DESTROY: #ifndef __OS2_PM__ WWinHelp( HMainWindow, "resimg.hlp", HELP_QUIT, 0 ); #endif FiniStatusLine(); CleanupClipboard(); CleanupCursors(); CloseToolBar(); CloseFunctionBar(); _wpi_deletefont( SmallFont ); _wpi_postquitmessage( 0 ); return( 0 ); default: break; } return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) ); } /* ImgEdFrameProc */
void TMessageBar::ClearHintText() { SetHintText(0); }
/* * imgEditInit - initialization */ static BOOL imgEditInit( HAB hab ) { ULONG flags; BOOL maximized; HWND frame; char clientclass[] = { "IMGEDClientClass" }; HWND hwnd; WPI_RECT rect; HMENU hmenu; // Change this to use the querycaps routine ColourPlanes = 1; BitsPerPixel = 4; Instance.hab = hab; Instance.mod_handle = NULL; /* * set up window class */ if (!WinRegisterClass( hab, className, (PFNWP)ImgEdFrameProc, CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, clientclass, (PFNWP)ClientProc, CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, PaletteClass, (PFNWP)ColourPalWinProc, CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, CURRENT_CLASS, (PFNWP)CurrentWndProc, CS_SIZEREDRAW | CS_SYNCPAINT, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, AVAIL_CLASS, (PFNWP)ColoursWndProc, CS_SIZEREDRAW | CS_SYNCPAINT, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, SCREEN_CLASS, (PFNWP)ScreenWndProc, CS_SIZEREDRAW, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, DrawAreaClassB, (PFNWP)DrawAreaWinProc, CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, DrawAreaClassI, (PFNWP)DrawAreaWinProc, CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, DrawAreaClassC, (PFNWP)DrawAreaWinProc, CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, ViewWinClass, (PFNWP)ViewWindowProc, CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN, 0 )) { return( FALSE ); } LoadImgedConfig(); maximized = ImgedConfigInfo.ismaximized; InitPalette(); /* * now make the main window */ flags = FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX | FCF_SYSMENU | FCF_TASKLIST | FCF_ICON | FCF_MENU; frame = WinCreateStdWindow( HWND_DESKTOP, 0L, &flags, className, ImgEdName, 0L, (HMODULE)0, IMGED_MAIN, &HMainWindow); WinSetWindowPos(frame, HWND_TOP, ImgedConfigInfo.x_pos, ImgedConfigInfo.y_pos, ImgedConfigInfo.width, ImgedConfigInfo.height, SWP_MOVE | SWP_SHOW | SWP_SIZE); _wpi_getclientrect( HMainWindow, &rect ); flags = 0L; /* * N.B. - NOTE that ClientWindow is actually a FRAME WINDOW!!!!! The * name is a bit misleading and it is unlike HMainWindow which * is a client window. */ ClientWindow = WinCreateStdWindow( HMainWindow, 0L, &flags, clientclass, "", 0L, (HMODULE)0, 0, &hwnd); WinSetWindowPos(ClientWindow, HWND_TOP, 0, STATUS_WIDTH, _wpi_getwidthrect( rect ), _wpi_getheightrect(rect) -STATUS_WIDTH -FUNCTIONBAR_WIDTH -1, SWP_MOVE | SWP_SHOW | SWP_SIZE); CreateColourPal(); InitFunctionBar( HMainWindow ); InitTools( _wpi_getframe(HMainWindow) ); hmenu = _wpi_getmenu( frame ); if (ImgedConfigInfo.grid_on) { CheckGridItem(hmenu); } SetHintText("Open Watcom Image Editor."); WinSetFocus( HWND_DESKTOP, _wpi_getframe(HMainWindow) ); return( TRUE ); } /* imgEditInit */
/* * SpyWindowProc - handle messages for the spy appl. */ LRESULT CALLBACK SpyWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { int check; HWND selwin; HWND hinthwnd; WORD cmdid = 0; RECT area; BOOL pausestate; BOOL spyallstate; about_info ai; HMENU mh; switch ( msg ) { case WM_CREATE: GetClientRect( hwnd, &area ); mh = GetMenu( hwnd ); area.top = area.bottom - statusHite; StatusHdl = HintWndCreate( hwnd, &area, Instance, NULL ); statusHite = SizeHintBar( StatusHdl ); SetHintText( StatusHdl, (MenuItemHint *)menuHints, sizeof( menuHints ) / sizeof( MenuItemHint ) ); if( SpyMainWndInfo.show_hints ) { CheckMenuItem( mh, SPY_SHOW_HELP, MF_CHECKED | MF_BYCOMMAND ); } else { hinthwnd = GetHintHwnd( StatusHdl ); ShowWindow( hinthwnd, SW_HIDE ); } CreateSpyBox( hwnd ); SET_WNDINFO( hwnd, (LONG_PTR)SpyListBox ); CreateSpyTool( hwnd ); ShowSpyTool( SpyMainWndInfo.show_toolbar ); if( SpyMainWndInfo.show_toolbar ) { CheckMenuItem( mh, SPY_SHOW_TOOLBAR, MF_CHECKED | MF_BYCOMMAND ); } LogInit( hwnd, Instance, SpyLogTitle ); CheckMenuItem( SpyMenu, SPY_AUTO_SCROLL, MF_CHECKED ); EnableMenuItem( SpyMenu, SPY_ADD_WINDOW, MF_GRAYED ); EnableMenuItem( SpyMenu, SPY_STOP, MF_GRAYED ); EnableMenuItem( SpyMenu, SPY_OFFON, MF_GRAYED ); if( SpyMainWndInfo.on_top ) { CheckMenuItem( mh, SPY_TOP, MF_CHECKED | MF_BYCOMMAND ); SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); } break; case WM_TIMER: // See comment on setUpForPick KillTimer( hwnd, wparam ); switch( wparam ) { case SPY_ADD_WINDOW: selwin = DoPickDialog( wparam ); if( selwin != NULL ) { setMultipleWindows( hwnd ); AddSelectedWindow( selwin ); } break; case SPY_PEEK_WINDOW: DoPickDialog( wparam ); break; case SPY_WINDOW: selwin = DoPickDialog( cmdid ); if( selwin != NULL ) { ClearSelectedWindows(); setSingleWindow( hwnd, selwin ); enableSpy(); AddSelectedWindow( selwin ); } break; } break; #ifdef __NT__ case WM_COPYDATA: HandleMessage( (LPMSG)((COPYDATASTRUCT *)lparam)->lpData ); break; #endif case WM_MENUSELECT: hinthwnd = GetHintHwnd( StatusHdl ); HintMenuSelect( StatusHdl, hwnd, wparam, lparam ); break; case WM_COMMAND: cmdid = LOWORD( wparam ); switch( cmdid ) { case SPY_SHOW_HELP: SpyMainWndInfo.show_hints = !SpyMainWndInfo.show_hints; mh = GetMenu( hwnd ); hinthwnd = GetHintHwnd( StatusHdl ); if( SpyMainWndInfo.show_hints ) { CheckMenuItem( mh, SPY_SHOW_HELP, MF_CHECKED | MF_BYCOMMAND ); showHintBar( hwnd ); } else { CheckMenuItem( mh, SPY_SHOW_HELP, MF_UNCHECKED | MF_BYCOMMAND ); ShowWindow( hinthwnd, SW_HIDE ); } GetClientRect( hwnd, &area ); ResizeSpyBox( area.right - area.left, area.bottom - area.top ); break; case SPY_SHOW_TOOLBAR: SpyMainWndInfo.show_toolbar = !SpyMainWndInfo.show_toolbar; mh = GetMenu( hwnd ); if( SpyMainWndInfo.show_toolbar ) { CheckMenuItem( mh, SPY_SHOW_TOOLBAR, MF_CHECKED | MF_BYCOMMAND ); } else { CheckMenuItem( mh, SPY_SHOW_TOOLBAR, MF_UNCHECKED | MF_BYCOMMAND ); } ShowSpyTool( SpyMainWndInfo.show_toolbar ); GetClientRect( hwnd, &area ); ResizeSpyBox( area.right - area.left, area.bottom - area.top ); break; case SPY_TOP: SpyMainWndInfo.on_top = !SpyMainWndInfo.on_top; mh = GetMenu( hwnd ); if( SpyMainWndInfo.on_top ) { CheckMenuItem( mh, SPY_TOP, MF_CHECKED | MF_BYCOMMAND ); SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); } else { CheckMenuItem( mh, SPY_TOP, MF_UNCHECKED | MF_BYCOMMAND ); SetWindowPos( hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); } break; case SPY_MARK: pausestate = SpyMessagesPaused; SpyMessagesPaused = FALSE; /* make sure marks are * always added */ ProcessMark( hwnd, Instance, markCallback ); SpyMessagesPaused = pausestate; break; case SPY_SET_FONT: if( ChooseMonoFont( hwnd ) ) { statusHite = SizeHintBar( StatusHdl ); ResetSpyListBox(); showHintBar( hwnd ); } break; case SPY_SAVE_AS: SaveListBox( SLB_SAVE_AS, SaveExtra, "", SpyName, hwnd, SpyListBox ); break; case SPY_SAVE: SaveListBox( SLB_SAVE_TMP, SaveExtra, ".\\wspy.txt", SpyName, hwnd, SpyListBox ); break; case SPY_LOG: if( LogToggle() ) { CheckMenuItem( SpyMenu, SPY_LOG, MF_BYCOMMAND | MF_CHECKED ); } else { CheckMenuItem( SpyMenu, SPY_LOG, MF_BYCOMMAND | MF_UNCHECKED ); CheckMenuItem( SpyMenu, SPY_PAUSE_LOG, MF_BYCOMMAND | MF_UNCHECKED ); } break; case SPY_CONFIG_LOG: LogConfigure(); break; case SPY_EXIT: ClearFilter(); DestroyWindow( hwnd ); break; case SPY_LIST_BOX: switch( GET_WM_COMMAND_CMD( wparam, lparam ) ) { case LBN_ERRSPACE: ClearSpyBox(); break; case LBN_DBLCLK: DoMessageSelDialog( hwnd ); break; } break; case SPY_SHOW_SELECTED_WINDOWS: spyallstate = spyAll; DoShowSelectedDialog( hwnd, &spyallstate ); if( spyallstate ) { doSpyAll( hwnd, spyallstate ); if( spyAll ) { SetSpyState( ON ); } break; } if( WindowCount == 0 ) { SetWindowText( hwnd, SpyName ); disableSpy(); break; } if( WindowCount == 1 ) { setSingleWindow( hwnd, WindowList[0] ); } else { setMultipleWindows( hwnd ); } if( SpyState == NEITHER ) { enableSpy(); } break; case SPY_HELP_CONTENTS: if( !WHtmlHelp( hwnd, "spy.chm", HELP_CONTENTS, 0 ) ) { WWinHelp( hwnd, "spy.hlp", HELP_CONTENTS, 0 ); } break; case SPY_HELP_SRCH: if( !WHtmlHelp( hwnd, "spy.chm", HELP_PARTIALKEY, (HELP_DATA)"" ) ) { WWinHelp( hwnd, "spy.hlp", HELP_PARTIALKEY, (HELP_DATA)"" ); } break; case SPY_HELP_ON_HELP: WWinHelp( hwnd, "winhelp.hlp", HELP_HELPONHELP, 0 ); break; case SPY_ABOUT: ai.owner = hwnd; ai.inst = Instance; ai.name = AllocRCString( STR_ABOUT_NAME ); ai.version = AllocRCString( STR_ABOUT_VERSION ); ai.first_cr_year = "1993"; ai.title = AllocRCString( STR_ABOUT_TITLE ); DoAbout( &ai ); FreeRCString( ai.name ); FreeRCString( ai.version ); FreeRCString( ai.title ); break; case SPY_AUTO_SCROLL: if( SpyMessagesAutoScroll ) { SpyMessagesAutoScroll = FALSE; CheckMenuItem( SpyMenu, SPY_AUTO_SCROLL, MF_UNCHECKED ); } else { SpyMessagesAutoScroll = TRUE; CheckMenuItem( SpyMenu, SPY_AUTO_SCROLL, MF_CHECKED ); } break; case SPY_PAUSE_LOG: if( SpyLogPauseToggle() ) { CheckMenuItem( SpyMenu, SPY_PAUSE_LOG, MF_BYCOMMAND | MF_CHECKED ); } else { CheckMenuItem( SpyMenu, SPY_PAUSE_LOG, MF_BYCOMMAND | MF_UNCHECKED ); } break; case SPY_PAUSE_MESSAGES: SpyMessagePauseToggle(); break; case SPY_CLEAR_MESSAGES: ClearSpyBox(); ClearMessageCount(); break; case SPY_MESSAGES_ASCFG: if( AutoSaveConfig ) { check = MF_UNCHECKED; AutoSaveConfig = FALSE; } else { AutoSaveConfig = TRUE; check = MF_CHECKED; } CheckMenuItem( SpyMenu, SPY_MESSAGES_ASCFG, check ); break; case SPY_MESSAGES_SAVE: DoSaveSpyConfig(); break; case SPY_MESSAGES_LOAD: DoLoadSpyConfig(); break; case SPY_MESSAGES_WATCH: case SPY_MESSAGES_STOP: DoMessageDialog( hwnd, cmdid ); break; case SPY_OFFON: if( SpyState != NEITHER ) { SetSpyState( !SpyState ); } break; case SPY_STOP: disableSpy(); ClearSelectedWindows(); SetWindowText( hwnd, SpyName ); break; case SPY_ANOTHER_WINDOW: if( SpyState == NEITHER || spyAll ) { SendMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( SPY_WINDOW, 0, 0 ) ); } else { SendMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( SPY_ADD_WINDOW, 0, 0 ) ); } break; case SPY_PEEK_WINDOW: case SPY_ADD_WINDOW: case SPY_WINDOW: setUpForPick( hwnd, cmdid ); break; case SPY_ALL_WINDOWS: doSpyAll( hwnd, !spyAll ); if( spyAll ) { SetSpyState( ON ); } break; } break; #ifdef __NT__ case WM_NOTIFY: if( ((NMHDR *)lparam)->code == NM_DBLCLK && ((NMHDR *)lparam)->idFrom == SPY_LIST_BOX ) { DoMessageSelDialog( hwnd ); } break; #endif case WM_CLOSE: PostMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( SPY_EXIT, 0, 0 ) ); break; case WM_ENDSESSION: if( wparam ) { SpyFini(); } break; case WM_DESTROY: HintWndDestroy( StatusHdl ); HintFini(); StatusWndFini(); DestroyMonoFonts(); DestroySpyTool(); WWinHelp( hwnd, "spy.hlp", HELP_QUIT, 0 ); PostQuitMessage( 0 ); break; case WM_MOVE: GetWindowRect( hwnd, &area ); if( !SpyMainWndInfo.minimized ) { SpyMainWndInfo.last_xpos = SpyMainWndInfo.xpos; SpyMainWndInfo.last_ypos = SpyMainWndInfo.ypos; SpyMainWndInfo.xpos = area.left; SpyMainWndInfo.ypos = area.top; } break; case WM_SIZE: if( wparam != SIZE_MAXIMIZED && wparam != SIZE_MINIMIZED ) { GetWindowRect( hwnd, &area ); SpyMainWndInfo.xsize = area.right - area.left; SpyMainWndInfo.ysize = area.bottom - area.top; } else { SpyMainWndInfo.xpos = SpyMainWndInfo.last_xpos; SpyMainWndInfo.ypos = SpyMainWndInfo.last_ypos; } SpyMainWndInfo.minimized = ( wparam == SIZE_MINIMIZED ); GetClientRect( hwnd, &area ); area.top = area.bottom - statusHite; hinthwnd = GetHintHwnd( StatusHdl ); MoveWindow( hinthwnd, area.left, area.top, area.right - area.left, statusHite, TRUE ); ResizeSpyBox( LOWORD( lparam ), HIWORD( lparam ) ); ResizeSpyTool( LOWORD( lparam ), HIWORD( lparam ) ); showHintBar( hwnd ); return( DefWindowProc( hwnd, msg, wparam, lparam ) ); break; #if defined( __NT__ ) case WM_ERASEBKGND: { static RECT r; GetClientRect( hwnd, &r ); FillRect( (HDC)wparam, &r, (HBRUSH)(COLOR_BTNFACE + 1) ); return 1; } #endif default: return( DefWindowProc( hwnd, msg, wparam, lparam ) ); } return( 0 ); } /* SpyWindowProc */
/* * saveImageFile - saves a cursor or icon file */ static bool saveImageFile( img_node *node ) { BITMAPARRAYFILEHEADER2 new_file; BITMAPFILEHEADER2 *and_part; BITMAPFILEHEADER2 *xor_part; BITMAPINFO2 *andbmi; BITMAPINFO2 *xorbmi; long clrtable_size; long and_size; ULONG nextoff; RGB2 *colours; FILE *fp; char text[ HINT_TEXT_LEN ]; char filename[ _MAX_FNAME ]; img_node *new_image; bool ok; ok = false; fp = fopen( node->fname, "wb" ); if( fp != NULL ) { if( fseek( fp, 0L, SEEK_SET ) == 0 ) { ok = true; nextoff = 0; for( new_image = node; new_image != NULL; new_image = new_image->nexticon ) { new_file.usType = BFT_BITMAPARRAY; new_file.cbSize = sizeof( BITMAPARRAYFILEHEADER2 ); new_file.offNext = nextoff; new_file.cxDisplay = 0; new_file.cyDisplay = 0; and_part = fillFileHeader( new_image ); memcpy( &(new_file.bfh2), and_part, sizeof( BITMAPFILEHEADER2 ) ); /* * First the info for the AND mask */ andbmi = GetAndBitmapInfo( new_image ); if( andbmi == NULL ) { ok = false; } else { clrtable_size = sizeof( RGB2 ) * ( 1 << new_image->bitcount ); and_size = sizeof( RGB2 ) * 2; new_file.bfh2.offBits = new_file.offNext + new_file.cbSize + and_size + clrtable_size + sizeof( BITMAPFILEHEADER2 ); memcpy( &(new_file.bfh2.bmp2), andbmi, sizeof( BITMAPINFOHEADER2 ) ); colours = (void *)&(andbmi->argbColor[0]); if( fwrite( &new_file, sizeof( BITMAPARRAYFILEHEADER2 ), 1, fp ) != 1 ) { ok = false; } else if( fwrite( colours, and_size, 1, fp ) != 1 ) { ok = false; } FreeDIBitmapInfo( andbmi ); } MemFree( and_part ); if( ok ) { /* * Now we write the XOR part */ xor_part = fillFileHeader( new_image ); xorbmi = GetXorBitmapInfo( new_image ); if( xorbmi == NULL ) { ok = false; } else { xor_part->offBits = new_file.bfh2.offBits + BITS_TO_BYTES( new_image->width, 2 * new_image->height ); memcpy( &(xor_part->bmp2), xorbmi, sizeof( BITMAPINFOHEADER2 ) ); colours = (void *)&(xorbmi->argbColor[0]); if( fwrite( xor_part, sizeof( BITMAPFILEHEADER2 ), 1, fp ) != 1 ) { ok = false; } else if( fwrite( colours, clrtable_size, 1, fp ) != 1 ) { ok = false; } FreeDIBitmapInfo( xorbmi ); } MemFree( xor_part ); nextoff = nextoff + sizeof( BITMAPARRAYFILEHEADER2 ) + and_size + sizeof( BITMAPFILEHEADER2 ) + clrtable_size; } if( !rc ) { break; } } } fclose( fp ); } if( ok ) { /* * Now we write the bits for all the images in the file. */ if( !writeImageBits( fp, node ) ) { return( false ); } AllowRestoreOption( node ); SetIsSaved( node->hwnd, TRUE ); GetFnameFromPath( node->fname, filename ); if( node->imgtype == ICON_IMG ) { sprintf( text, "Icon saved to '%s'", filename ); } else { sprintf( text, "Pointer saved to '%s'", filename ); } SetHintText( text ); } return( ok ); } /* saveImageFile */