/* * CurrentWndProc - handle messages for the current color selection window */ WPI_MRESULT CALLBACK CurrentWndProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { switch ( msg ) { case WM_CREATE: SetCurrentNumColors( 16 ); break; case WM_PAINT: paintCurrent( hwnd ); break; case WM_DESTROY: if( lButton.bitmap != NULL ) { _wpi_deletebitmap( lButton.bitmap ); } if( rButton.bitmap != NULL ) { _wpi_deletebitmap( rButton.bitmap ); } break; default: return( DefWindowProc( hwnd, msg, wparam, lparam ) ); } return 0; } /* CurrentWndProc */
/* * SetNumColors - set the number of colors in the image and repaint the window */ void SetNumColors( int number_of_colors ) { HMENU hmenu; HWND frame; if( numberOfColors == number_of_colors ) { return; } SetCurrentNumColors( number_of_colors ); numberOfColors = number_of_colors; initPaletteBoxes( FALSE ); _wpi_invalidaterect( hColorsWnd, NULL, FALSE ); if( numberOfColors == 2 ) { if( HMainWindow != NULL ) { frame = _wpi_getframe( HMainWindow ); hmenu = GetMenu( frame ); if( _wpi_isitemenabled( hmenu, IMGED_RCOLOR ) ) { prevRestoreState = TRUE; } else { prevRestoreState = FALSE; } _wpi_enablemenuitem( hmenu, IMGED_SCOLOR, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_LCOLOR, FALSE, FALSE ); } } else { if( HMainWindow != NULL ) { frame = _wpi_getframe( HMainWindow ); hmenu = GetMenu( frame ); _wpi_enablemenuitem( hmenu, IMGED_SCOLOR, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, prevRestoreState, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_LCOLOR, TRUE, FALSE ); } } } /* SetNumColors */