/* * ReplacePaletteEntry - replace the current entry with the given RGB value */ void ReplacePaletteEntry( COLORREF newcolor ) { COLORREF cur_color; COLORREF nearestcolor; COLORREF screencolor; COLORREF rightcolor; wie_clrtype lefttype; wie_clrtype righttype; int index; int rightindex; WPI_PRES pres; if( currentPalIndex != COLOR_16 && currentPalIndex != COLOR_256 ) { return; } cur_color = GetSelectedColor( LMOUSEBUTTON, NULL, &lefttype ); if( lefttype == NORMAL_CLR ) { index = getColorIndex( cur_color ); rightcolor = GetSelectedColor( RMOUSEBUTTON, NULL, &righttype ); rightindex = getColorIndex( rightcolor ); palette[currentPalIndex][index].rgbRed = GetRValue( newcolor ); palette[currentPalIndex][index].rgbGreen = GetGValue( newcolor ); palette[currentPalIndex][index].rgbBlue = GetBValue( newcolor ); palette[currentPalIndex][index].rgbReserved = 0; ShowNewColor( index, newcolor, TRUE ); pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); SetColor( LMOUSEBUTTON, newcolor, _wpi_getnearestcolor( pres, newcolor ), NORMAL_CLR ); if( index == rightindex ) { SetColor( RMOUSEBUTTON, newcolor, _wpi_getnearestcolor( pres, newcolor ), NORMAL_CLR ); } _wpi_releasepres( HWND_DESKTOP, pres ); } else if( lefttype == SCREEN_CLR ) { pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); nearestcolor = _wpi_getnearestcolor( pres, newcolor ); _wpi_releasepres( HWND_DESKTOP, pres ); SetScreenClr( nearestcolor ); } else { pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); nearestcolor = _wpi_getnearestcolor( pres, newcolor ); _wpi_releasepres( HWND_DESKTOP, pres ); screencolor = GetInverseColor( nearestcolor ); SetScreenClr( screencolor ); } } /* ReplacePaletteEntry */
/* * ChooseBkColor - choose the color to represent the background */ void ChooseBkColor( void ) { WPI_DLGPROC dlgproc; WPI_DLGRESULT button_type; screenColor.color = GetViewBkColor(); dlgproc = _wpi_makedlgprocinstance( SelColorDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, SELBKCOLOR, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == IDCANCEL ) { return; } SetViewBkColor( screenColor.color ); SetScreenClr( screenColor.color ); PrintHintTextByID( WIE_NEWBKCOLORSELECTED, NULL ); } /* ChooseBkColor */