BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) { // OnCommand responds to menu and and toolbar input UNREFERENCED_PARAMETER(lParam); switch(LOWORD(wParam)) { case IDM_FILE_EXIT: OnFileExit(); return TRUE; case IDM_MODERN: ChooseColor(IDM_MODERN); return TRUE; case IDM_BLUE: ChooseColor(IDM_BLUE); return TRUE; case IDM_GREY: ChooseColor(IDM_GREY); return TRUE; case IDM_OLIVE: ChooseColor(IDM_OLIVE); return TRUE; case IDM_OCHRE: ChooseColor(IDM_OCHRE); return TRUE; case IDM_MAUVE: ChooseColor(IDM_MAUVE); return TRUE; case IDM_PINK: ChooseColor(IDM_PINK); return TRUE; case IDM_GOLD: ChooseColor(IDM_GOLD); return TRUE; case IDM_BLACK: ChooseColor(IDM_BLACK); return TRUE; case IDM_USE_THEMES: OnUseThemes(); return TRUE; case IDM_BAND_COLORS: OnBandColors(); return TRUE; case IDM_FLAT_STYLE: OnFlatStyle(); return TRUE; case IDM_LEFT_BANDS: OnLeftBands(); return TRUE; case IDM_LOCK_MENUBAR: OnLockMenuBar(); return TRUE; case IDM_ROUND_BORDERS: OnRoundBorders(); return TRUE; case IDM_SHORT_BANDS: OnShortBands(); return TRUE; case IDM_USE_LINES: OnUseLines(); return TRUE; case IDM_VIEW_ARROWS: OnViewArrows(); return TRUE; case IDM_VIEW_CARDS: OnViewCards(); return TRUE; case IDW_VIEW_STATUSBAR: OnViewStatusBar(); return TRUE; case IDW_VIEW_TOOLBAR: OnViewToolBar(); return TRUE; case IDM_HELP_ABOUT: OnHelp(); return TRUE; } return FALSE; }
void MYMENU_FormatBGColor() { CHOOSECOLOR cc; static COLORREF acrCustClr[16];// array of custom colors static DWORD rgbCurrent;// initial color selection ZeroMemory(&cc, sizeof(cc)); cc.lStructSize = sizeof(cc); cc.hwndOwner = hwnd; cc.lpCustColors = (LPDWORD) acrCustClr; cc.rgbResult = rgbCurrent; cc.Flags = CC_FULLOPEN | CC_RGBINIT; if ( ChooseColor(&cc) ) { int row, col; CellInfo* info = iterate_selection( table, &row, &col ); while ( info != NULL ) { // history history_append( row, col ); free_redo_history(); info->style.bg_rgb = cc.rgbResult; info = iterate_selection( table, &row, &col ); } update_table_view(); } }
bool ColorDlg(HWND hwnd, DWORD &dwColor ) { CHOOSECOLOR cc; // common dialog box structure static COLORREF acrCustClr[16]; // array of custom colors HBRUSH hbrush; // brush handle //static DWORD rgbCurrent; // initial color selection bool rslt = false; // Initialize CHOOSECOLOR ZeroMemory(&cc, sizeof(cc)); cc.lStructSize = sizeof(cc); cc.hwndOwner = hwnd; cc.lpCustColors = (LPDWORD)acrCustClr; cc.rgbResult = dwColor; cc.Flags = CC_FULLOPEN | CC_RGBINIT ; if (ChooseColor(&cc) == TRUE) { dwColor = cc.rgbResult; rslt = true; } return rslt; }
void CButton::Draw() { float bz = GetBufferedZ(); CGUISpriteInstance *sprite, *sprite_over, *sprite_pressed, *sprite_disabled; int cell_id; // Statically initialise some strings, so we don't have to do // lots of allocation every time this function is called static CStr strSprite("sprite"); static CStr strSpriteOver("sprite_over"); static CStr strSpritePressed("sprite_pressed"); static CStr strSpriteDisabled("sprite_disabled"); static CStr strCellId("cell_id"); GUI<CGUISpriteInstance>::GetSettingPointer(this, strSprite, sprite); GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpriteOver, sprite_over); GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpritePressed, sprite_pressed); GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpriteDisabled, sprite_disabled); GUI<int>::GetSetting(this, strCellId, cell_id); DrawButton(m_CachedActualSize, bz, *sprite, *sprite_over, *sprite_pressed, *sprite_disabled, cell_id); CColor color = ChooseColor(); IGUITextOwner::Draw(0, color, m_TextPos, bz+0.1f); }
CDDB::CDDB( // build a CDDB object from a DIB in a resource file HINSTANCE hInstance, // instance conatining DIB resource LPCSTR lpResource1, // DIB resource identifier for 1 bit/pixel DIB LPCSTR lpResource4, // DIB resource identifier for 4 bit/pixel DIB LPCSTR lpResource8, // DIB resource identifier for 8 bit/pixel DIB LPCSTR lpResource24, // DIB resource identifier for 24 bit/pixel DIB LPCSTR wResourceType, // type of resource, usually RT_BITMAP HDC hDC, // device context to use for call to CreateDIBitmap() BOOL fUseDIBPalette) // flag indicating if DIB bitmap should be used for conversion { Release(TRUE); /* // Get the best resource choice based on the color depth of the device context. */ LPSTR lpResource; if ((lpResource = (LPSTR)ChooseColor(hDC, lpResource1, lpResource4, lpResource8, lpResource24)) != NULL) { ConstructDDBFromResource( // build a CDDB object from a DIB in a resource file hInstance, // instance conatining DIB resource lpResource, // DIB resource identifier wResourceType, // type of resource, usually RT_BITMAP hDC, // device context to use for call to CreateDIBitmap() fUseDIBPalette); // flag indicating if DIB bitmap should be used for conversion } }
bool mxChooseColor (mxWindow *parent, int *r, int *g, int *b) { CHOOSECOLOR cc; static COLORREF custColors[16]; BYTE rr = *r; BYTE gg = *g; BYTE bb = *b; memset (&cc, 0, sizeof (CHOOSECOLOR)); cc.lStructSize = sizeof (CHOOSECOLOR); cc.hwndOwner = parent ? (HWND) parent->getHandle ():NULL; cc.rgbResult = RGB (rr, gg, bb); cc.lpCustColors = custColors; cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT; if (ChooseColor (&cc)) { *r = (int) GetRValue (cc.rgbResult); *g = (int) GetGValue (cc.rgbResult); *b = (int) GetBValue (cc.rgbResult); return true; } return false; }
/*------------------------------------------------------------------------ Procedure: CallChangeColor ID:1 Purpose: Calls the standard color dialog of windows, starting with the given color reference. The result is the same as the input if the user cancels, or another color if the user validates another one. Input: The starting color Output: The color the user has choosen. Errors: None ------------------------------------------------------------------------*/ static COLORREF CallChangeColor(COLORREF InitialColor) { CHOOSECOLOR CC; COLORREF CustColors[16]; int r, g, b, i; memset(&CC, 0, sizeof(CHOOSECOLOR)); r = g = b = 0; for (i = 0; i < 16; i++) { CustColors[i] = RGB(r, g, b); if (r < 255) r += 127; else if (g < 255) g += 127; else if (b < 255) g += 127; } CC.lStructSize = sizeof(CHOOSECOLOR); CC.hwndOwner = hwndMain; CC.hInstance = hInst; CC.rgbResult = InitialColor; CC.lpCustColors = CustColors; CC.Flags = CC_RGBINIT; if (!ChooseColor(&CC)) return (InitialColor); return (CC.rgbResult); }
void JXStyleMenu::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == this && message.Is(JXMenu::kNeedsUpdate)) { UpdateMenu(); } else if (sender == this && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast(const JXMenu::ItemSelected*, &message); assert( selection != NULL ); const JIndex i = selection->GetIndex(); if (i == kCustomColorCmd) { assert( itsChooseCustomColorFlag ); ChooseColor(); } else { if (i >= kFirstColorCmd) { itsColorIndex = IndexToColor(i); } HandleMenuItem(i); } } else if (sender == itsChooseColorDialog &&
void TypeEd_EditBox::OnTextColorChanged(const MGUI::MouseEvent * e) { Float4 color = mEditBox->GetTextColor(); color.a = 1; static COLORREF crCustColors[6]; CHOOSECOLOR cc; cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = App::Instance()->_hWnd(); cc.hInstance = NULL; cc.rgbResult = RGB(color.r * 255, color.g * 255, color.b * 255); cc.lpCustColors = crCustColors; cc.Flags = CC_RGBINIT|CC_FULLOPEN; cc.lCustData = 0; cc.lpfnHook = NULL; cc.lpTemplateName = NULL; if (ChooseColor(&cc)) { color.r = GetRValue(cc.rgbResult) / 255.0f; color.g = GetGValue(cc.rgbResult) / 255.0f; color.b = GetBValue(cc.rgbResult) / 255.0f; mEditBox->SetTextColor(color); mWidget_TextColor->SetColor(color); } }
LRESULT CEditColorDlg::OnLButtonUp( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled ) { RECT rcColorWnd = { 0 }; CWindow ColorWnd = GetDlgItem( IDC_COLOR ); ColorWnd.GetWindowRect( &rcColorWnd ); DWORD dwPos = GetMessagePos(); POINT pt = { LOWORD( dwPos ), HIWORD( dwPos ) }; if( !PtInRect( &rcColorWnd, pt ) ) return( 0 ); CHOOSECOLOR cc; cc.lStructSize = sizeof( CHOOSECOLOR ); cc.hwndOwner = m_hWnd; cc.hInstance = NULL; cc.rgbResult = m_uColor; cc.lpCustColors = g_CustomColors; cc.Flags = CC_RGBINIT | CC_FULLOPEN; cc.lCustData = 0; cc.lpfnHook = NULL; cc.lpTemplateName = NULL; if( ChooseColor( &cc ) ) { m_uColor = cc.rgbResult; ShowColorInfo(); } return( 0 ); }
void CTransCtrl::SetTextColor( ) { TestDesktop( ); DWORD dwCustClrs [16]; for ( int i = 0; i < 16; i++ ) dwCustClrs [i] = _WHITE; m_textcolor = ReadRGBSetting( "res_x86", "textcolor", "255,255,255"); CHOOSECOLOR color; ZeroMemory( &color, sizeof( CHOOSECOLOR ) ); color.lStructSize = sizeof( CHOOSECOLOR ); color.Flags = CC_RGBINIT|CC_ENABLEHOOK; color.rgbResult = m_textcolor; color.hwndOwner = GetMyWindowHandle( ); color.lpCustColors = ( LPDWORD )dwCustClrs; color.lCustData = 0L; color.lpfnHook = CCHookProc; if( ChooseColor( &color ) ) { m_textcolor = color.rgbResult; WriteRGBSetting( "res_x86", "textcolor", m_textcolor ); SendMessage( __GetDesktopListView( ), LVM_SETTEXTCOLOR, 57, m_textcolor ); InvalidateRect( __GetDesktopListView( ), NULL, false ); UpdateWindow( __GetDesktopListView( ) ); SetTransparent(); } }
static VOID OnColorButton(HWND hwndDlg, PDATA pData) { /* Load custom colors from Registry */ HKEY hKey = NULL; LONG res = ERROR_SUCCESS; CHOOSECOLOR cc; res = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); /* Now the key is either created or opened existing, if res == ERROR_SUCCESS */ if (res == ERROR_SUCCESS) { /* Key opened */ DWORD dwType = REG_BINARY; DWORD cbData = sizeof(pData->custom_colors); res = RegQueryValueEx(hKey, TEXT("CustomColors"), NULL, &dwType, (LPBYTE)pData->custom_colors, &cbData); RegCloseKey(hKey); hKey = NULL; } /* Launch ChooseColor() dialog */ cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hwndDlg; cc.hInstance = NULL; cc.rgbResult = g_GlobalData.desktop_color; cc.lpCustColors = pData->custom_colors; cc.Flags = CC_ANYCOLOR | /* Causes the dialog box to display all available colors in the set of basic colors. */ CC_FULLOPEN | /* opens dialog in full size */ CC_RGBINIT ; /* init chosen color by rgbResult value */ cc.lCustData = 0; cc.lpfnHook = NULL; cc.lpTemplateName = NULL; if (ChooseColor(&cc)) { /* Save selected color to var */ g_GlobalData.desktop_color = cc.rgbResult; pData->bClrBackgroundChanged = TRUE; /* Apply button will be activated */ PropSheet_Changed(GetParent(hwndDlg), hwndDlg); /* Window will be updated :) */ InvalidateRect(GetDlgItem(hwndDlg, IDC_BACKGROUND_PREVIEW), NULL, TRUE); /* Save custom colors to reg. To this moment key must be created already. See above */ res = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0, KEY_WRITE, &hKey); if (res == ERROR_SUCCESS) { /* Key opened */ RegSetValueEx(hKey, TEXT("CustomColors"), 0, REG_BINARY, (const BYTE *)pData->custom_colors, sizeof(pData->custom_colors)); RegCloseKey(hKey); hKey = NULL; } } }
/* ============= DoColor ============= */ qboolean DoColor(int iIndex) { CHOOSECOLOR cc; static COLORREF custom[16]; cc.lStructSize = sizeof(cc); cc.hwndOwner = g_qeglobals.d_hwndMain; cc.hInstance = g_qeglobals.d_hInstance; cc.rgbResult = (int)(g_qeglobals.d_savedinfo.colors[iIndex][0]*255) + (((int)(g_qeglobals.d_savedinfo.colors[iIndex][1]*255))<<8) + (((int)(g_qeglobals.d_savedinfo.colors[iIndex][2]*255))<<16); cc.lpCustColors = custom; cc.Flags = CC_FULLOPEN|CC_RGBINIT; //cc.lCustData; //cc.lpfnHook; //cc.lpTemplateName if (!ChooseColor(&cc)) return false; g_qeglobals.d_savedinfo.colors[iIndex][0] = (cc.rgbResult&255)/255.0; g_qeglobals.d_savedinfo.colors[iIndex][1] = ((cc.rgbResult>>8)&255)/255.0; g_qeglobals.d_savedinfo.colors[iIndex][2] = ((cc.rgbResult>>16)&255)/255.0; /* ** scale colors so that at least one component is at 1.0F ** if this is meant to select an entity color */ if ( iIndex == COLOR_ENTITY ) { float largest = 0.0F; if ( g_qeglobals.d_savedinfo.colors[iIndex][0] > largest ) largest = g_qeglobals.d_savedinfo.colors[iIndex][0]; if ( g_qeglobals.d_savedinfo.colors[iIndex][1] > largest ) largest = g_qeglobals.d_savedinfo.colors[iIndex][1]; if ( g_qeglobals.d_savedinfo.colors[iIndex][2] > largest ) largest = g_qeglobals.d_savedinfo.colors[iIndex][2]; if ( largest == 0.0F ) { g_qeglobals.d_savedinfo.colors[iIndex][0] = 1.0F; g_qeglobals.d_savedinfo.colors[iIndex][1] = 1.0F; g_qeglobals.d_savedinfo.colors[iIndex][2] = 1.0F; } else { float scaler = 1.0F / largest; g_qeglobals.d_savedinfo.colors[iIndex][0] *= scaler; g_qeglobals.d_savedinfo.colors[iIndex][1] *= scaler; g_qeglobals.d_savedinfo.colors[iIndex][2] *= scaler; } } Sys_UpdateWindows (W_ALL); return true; }
bool IGraphicsWin::PromptForColor(IColor* pColor, char* prompt) { if (!mPlugWnd) { return false; } if (!mCustomColorStorage) { mCustomColorStorage = (COLORREF*) calloc(16, sizeof(COLORREF)); } CHOOSECOLOR cc; memset(&cc, 0, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = mPlugWnd; cc.rgbResult = RGB(pColor->R, pColor->G, pColor->B); cc.lpCustColors = mCustomColorStorage; cc.lCustData = (LPARAM) prompt; cc.lpfnHook = CCHookProc; cc.Flags = CC_RGBINIT | CC_ANYCOLOR | CC_FULLOPEN | CC_SOLIDCOLOR | CC_ENABLEHOOK; if (ChooseColor(&cc)) { pColor->R = GetRValue(cc.rgbResult); pColor->G = GetGValue(cc.rgbResult); pColor->B = GetBValue(cc.rgbResult); return true; } return false; }
BOOL CALLBACK ColorProc(HWND hWnd, UINT msg, WPARAM wP, LPARAM lP) { static bool chng; static CHOOSECOLOR chc; static COLORREF clold[Ncl]; DRAWITEMSTRUCT *di; HBRUSH br; int cmd; RECT rc; switch(msg){ case WM_INITDIALOG: setDlgTexts(hWnd, 23); memcpy(clold, colors, sizeof(clold)); chng=false; return TRUE; case WM_DRAWITEM: di = (DRAWITEMSTRUCT*)lP; DrawFrameControl(di->hDC, &di->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH|(di->itemState&ODS_SELECTED ? DFCS_PUSHED : 0)); CopyRect(&rc, &di->rcItem); InflateRect(&rc, -3, -3); br= CreateSolidBrush(colors[di->CtlID-100]); FillRect(di->hDC, &rc, br); DeleteObject(br); break; case WM_COMMAND: cmd=LOWORD(wP); switch(cmd){ default: //color square chc.lStructSize= sizeof(CHOOSECOLOR); chc.hwndOwner= hWnd; chc.hInstance= 0; chc.rgbResult= colors[cmd-100]; chc.lpCustColors= custom; chc.Flags= CC_RGBINIT|CC_FULLOPEN; if(ChooseColor(&chc)){ colors[cmd-100]=chc.rgbResult; InvalidateRect(GetDlgItem(hWnd, cmd), 0, TRUE); colorChanged(); chng=true; } break; case IDCANCEL: if(chng){ memcpy(colors, clold, sizeof(clold)); colorChanged(); } //! case IDOK: EndDialog(hWnd, cmd); } break; } return FALSE; }
/* Select a color using a color picker */ static BOOL GetColor(HWND hwndDlg, GLOBALS* g, INT nButton) { CHOOSECOLOR cc; COLORREF crCustom[16] = { 0 }; COLORREF crColor; INT ID = 0; INT ColorIndex = 0; /* Get the color index from the element index and button number */ switch (nButton) { case 0: ColorIndex = g_Assignment[g->CurrentElement].Color1; ID = IDC_ADVAPPEARANCE_COLOR1_B; break; case 1: ColorIndex = g_Assignment[g->CurrentElement].Color2; ID = IDC_ADVAPPEARANCE_COLOR2_B; break; case 2: ColorIndex = g_Assignment[g->CurrentElement].FontColor; ID = IDC_ADVAPPEARANCE_FONTCOLOR_B; break; } crColor = g->ThemeAdv.crColor[ColorIndex]; /* Prepare cc structure */ cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hwndDlg; cc.hInstance = NULL; cc.rgbResult = crColor; cc.lpCustColors = crCustom; cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT; cc.lCustData = 0; cc.lpfnHook = NULL; cc.lpTemplateName = NULL; /* Create the colorpicker */ if (ChooseColor(&cc)) { g->ThemeAdv.crColor[ColorIndex] = cc.rgbResult; if (crColor != cc.rgbResult) { UpdateButtonColor(hwndDlg, g, ID, nButton, ColorIndex); SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv); return TRUE; } } return FALSE; }
void CMainFrame::OnBandColors() { if (IsReBarSupported()) { m_UseBandColors = !m_UseBandColors; ChooseColor(m_nColor); GetReBar()->RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN); RecalcLayout(); } }
static int winColorDlgPopup(Ihandle* ih, int x, int y) { InativeHandle* parent = iupDialogGetNativeParent(ih); CHOOSECOLOR choosecolor; unsigned char r, g, b; COLORREF lpCustColors[16]; char* value; iupAttribSetInt(ih, "_IUPDLG_X", x); /* used in iupDialogUpdatePosition */ iupAttribSetInt(ih, "_IUPDLG_Y", y); /* if NOT set will NOT be Modal */ /* anyway it will be modal only relative to its parent */ if (!parent) parent = GetActiveWindow(); iupStrToRGB(iupAttribGet(ih, "VALUE"), &r, &g, &b); ZeroMemory(lpCustColors, 16*sizeof(COLORREF)); value = iupAttribGetStr(ih, "COLORTABLE"); if (value) winColorDlgStringToColors(value, lpCustColors); ZeroMemory(&choosecolor, sizeof(CHOOSECOLOR)); choosecolor.lStructSize = sizeof(CHOOSECOLOR); choosecolor.hwndOwner = parent; choosecolor.rgbResult = RGB(r, g, b); choosecolor.lpCustColors = lpCustColors; choosecolor.lCustData = (LPARAM)ih; choosecolor.Flags = CC_RGBINIT|CC_FULLOPEN; if (IupGetCallback(ih, "HELP_CB")) choosecolor.Flags |= CC_SHOWHELP; choosecolor.Flags |= CC_ENABLEHOOK; choosecolor.lpfnHook = (LPCCHOOKPROC)winColorDlgHookProc; if (!ChooseColor(&choosecolor)) { iupAttribSet(ih, "VALUE", NULL); iupAttribSet(ih, "COLORTABLE", NULL); iupAttribSet(ih, "STATUS", NULL); return IUP_NOERROR; } iupAttribSetStrf(ih, "VALUE", "%d %d %d", GetRValue(choosecolor.rgbResult), GetGValue(choosecolor.rgbResult), GetBValue(choosecolor.rgbResult)); iupAttribSet(ih, "COLORTABLE", winColorDlgColorsToString(lpCustColors)); iupAttribSet(ih, "STATUS", "1"); return IUP_NOERROR; }
LRESULT CPaletteWindow::OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (GET_X_LPARAM(lParam) >= 31) if (ChooseColor(&choosecolor)) { paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14, choosecolor.rgbResult); paletteModel.SetBgColor(choosecolor.rgbResult); } return 0; }
void Dialog_showColorPicker(unsigned int* color) { CHOOSECOLOR cc; ZeroMemory(&cc, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.lpCustColors = (LPDWORD)custColors; cc.rgbResult = *color & 0x00ffffff; cc.Flags = CC_FULLOPEN | CC_RGBINIT; cc.hwndOwner = s_window; if (ChooseColor(&cc)) *color = cc.rgbResult | 0xff000000; }
/* ================ GEOptionsDlg_GeneralProc Dialog procedure for the general options tab ================ */ static INT_PTR CALLBACK GEOptionsDlg_GeneralProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: ColorButton_SetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR), RGB(gApp.GetOptions().GetSelectionColor()[0]*255, gApp.GetOptions().GetSelectionColor()[1]*255, gApp.GetOptions().GetSelectionColor()[2]*255)); CheckDlgButton(hwnd, IDC_GUIED_IGNOREDESKTOP, gApp.GetOptions().GetIgnoreDesktopSelect()?BST_CHECKED:BST_UNCHECKED); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_GUIED_SELECTIONCOLOR: { CHOOSECOLOR col; ZeroMemory(&col, sizeof(col)); col.lStructSize = sizeof(col); col.lpCustColors = gApp.GetOptions().GetCustomColors(); col.hwndOwner = hwnd; col.hInstance = NULL; col.Flags = CC_RGBINIT; col.rgbResult = ColorButton_GetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR)); if (ChooseColor(&col)) { ColorButton_SetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR), col.rgbResult); } break; } } break; case WM_DRAWITEM: ColorButton_DrawItem(GetDlgItem(hwnd, wParam), (LPDRAWITEMSTRUCT)lParam); return TRUE; case WM_NOTIFY: switch (((NMHDR FAR *) lParam)->code) { case PSN_APPLY: gApp.GetOptions().SetLastOptionsPage(PropSheet_HwndToIndex(GetParent(hwnd), PropSheet_GetCurrentPageHwnd(GetParent(hwnd)))); gApp.GetOptions().SetSelectionColor(ColorButton_GetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR))); gApp.GetOptions().SetIgnoreDesktopSelect(IsDlgButtonChecked(hwnd, IDC_GUIED_IGNOREDESKTOP) != 0); break; } break; } return FALSE; }
INT_PTR CWipeProp::OnReceiveMsg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static COLORREF acrCustomClr[16]; switch (msg) { case WM_DRAWITEM: // Paint the color swatch if (wParam == IDC_SMPTE_COLOR) { HBRUSH solidBrush = CreateSolidBrush(m_dwBorderColor); DRAWITEMSTRUCT *pDraw = (DRAWITEMSTRUCT*)lParam; FillRect(pDraw->hDC, &pDraw->rcItem, solidBrush); FrameRect(pDraw->hDC, &pDraw->rcItem, (HBRUSH)GetStockObject(BLACK_BRUSH)); DeleteObject(solidBrush); return TRUE; } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SMPTE_PICK_COLOR: { // Show the Choose Color dialog to pick a new color swatch CHOOSECOLOR cc; ZeroMemory(&cc, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = m_hDlg; cc.lpCustColors = (LPDWORD)acrCustomClr; cc.Flags = CC_RGBINIT; cc.rgbResult = m_dwBorderColor; if (ChooseColor(&cc)) { m_dwBorderColor = cc.rgbResult; InvalidateRect(GetDlgItem(hDlg, IDC_SMPTE_COLOR), 0, FALSE); } } return TRUE; } // inner switch break; } // default return FALSE; }
BOOL choose_color(LPCHOOSECOLOR lpcs, HWND hwnd) { CHOOSECOLOR dcs; static COLORREF custcolors[16]; lpcs->lStructSize = sizeof(dcs); lpcs->hwndOwner = hwnd; lpcs->hInstance = 0; lpcs->rgbResult=config_color; lpcs->lpCustColors = custcolors; lpcs->Flags = CC_RGBINIT|CC_FULLOPEN; return ChooseColor(lpcs); }
bool ColorDialog::Show(HWND hWnd,ColorFlags flags){ CHOOSECOLOR cc; ZeroMemory(&cc, sizeof(cc)); cc.lStructSize = sizeof(cc); cc.hwndOwner = hWnd; cc.lpCustColors = CustomColor; cc.rgbResult = Color; cc.Flags = CC_ANYCOLOR|CC_RGBINIT|flags; if (!ChooseColor(&cc)) return false; Color = cc.rgbResult; return true; }
COLORREF GetColor(HWND parent, COLORREF cur){ COLORREF custCols[16] = { 0 }; CHOOSECOLOR cc; ZeroMemory(&cc, sizeof cc); cc.lStructSize = sizeof cc; cc.Flags = CC_FULLOPEN | CC_RGBINIT; cc.hwndOwner = parent; cc.lpCustColors = custCols; cc.rgbResult = cur; if (ChooseColor(&cc)) cur = cc.rgbResult; return cur; }
uint32 ColorFrame::onMessage(uint32 message, uint32 wParam, uint32 lParam) { static COLORREF custColors[16] = { 0x000000, 0x800000, 0x008000, 0x808000, 0x000080, 0x800080, 0x008080, 0xC0C0C0, 0x808080, 0xFF0000, 0x00FF00, 0xFFFF00, 0x0000FF, 0xFF00FF, 0x00FFFF, 0xFFFFFF, }; switch (message) { case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); } break; case WM_ERASEBKGND: { HDC hDC = (HDC) wParam; RECT rc; GetClientRect(hWnd, &rc); SetBkColor(hDC, color); ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL); } return TRUE; case WM_LBUTTONDOWN: SetCapture(hWnd); break; case WM_LBUTTONUP: if (GetCapture() == hWnd) { ReleaseCapture(); CHOOSECOLOR cc; memset(&cc, 0, sizeof cc); cc.lStructSize = sizeof cc; cc.hwndOwner = GetParent(hWnd); cc.rgbResult = color; cc.Flags = CC_FULLOPEN | CC_RGBINIT; cc.lpCustColors = custColors; if (ChooseColor(&cc)) { setColor(cc.rgbResult); notify(WM_COMMAND, MAKELONG(id(), BN_CLICKED), (uint32) hWnd); } } break; default: return M_UNHANDLED; } return 0; }
void ChoosingColor(HWND hWnd, COLORREF &col) { CHOOSECOLOR cc; COLORREF arrCol[16] = { 0 }; ZeroMemory(&cc, sizeof(cc)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hWnd; cc.lpCustColors = arrCol; cc.rgbResult = col; cc.Flags = CC_RGBINIT; if (ChooseColor(&cc)) { col = cc.rgbResult; } }
COLORREF GetColor(HWND hwnd) { CHOOSECOLOR chooseColor; static COLORREF crCustClr[16]; ZeroMemory(&chooseColor, sizeof(chooseColor)); chooseColor.lStructSize = sizeof(chooseColor); chooseColor.hwndOwner = hwnd; chooseColor.lpCustColors = (LPDWORD) crCustClr; chooseColor.rgbResult = RGB(0, 0, 0); chooseColor.Flags = CC_FULLOPEN | CC_RGBINIT; if (ChooseColor(&chooseColor)) return chooseColor.rgbResult; return NULL; }
void OnScreenDisplayWnd::SelectBgColor() { CHOOSECOLOR cc; static COLORREF acrCustClr[16]; ZeroMemory(&cc, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = vdWindow; cc.rgbResult = m_bgColor; cc.lpCustColors = acrCustClr; cc.Flags = CC_RGBINIT | CC_ANYCOLOR | CC_FULLOPEN; if (ChooseColor(&cc)) SetBgColor(cc.rgbResult); }
void ColorOptionView::onEvent(const std::string &event, W32EventSender&) { static std::string OPTION_PREFIX = "Color"; static std::string COLOR_GROUP_NAME = "ColorDialog"; if (event == W32PushButton::RELEASED_EVENT) { CHOOSECOLOR chooser; COLORREF refs[16]; for (int i = 0; i < 16; ++i) { std::string optionName = OPTION_PREFIX; ZLStringUtil::appendNumber(optionName, i); ZLColor color = ZLColorOption( ZLCategoryKey::LOOK_AND_FEEL, COLOR_GROUP_NAME, optionName, ZLColor(0, 0, 0) ).value(); refs[i] = RGB(color.Red, color.Green, color.Blue); } chooser.lStructSize = sizeof(chooser); chooser.hwndOwner = GetActiveWindow(); chooser.hInstance = 0; ZLColor currentColor = myStandardColorComboBox->selectedColor(); chooser.rgbResult = RGB(currentColor.Red, currentColor.Green, currentColor.Blue); chooser.lpCustColors = refs; chooser.Flags = CC_RGBINIT | CC_FULLOPEN | CC_SOLIDCOLOR; //chooser.lCustData = 0; //chooser.lpfnHook = 0; //chooser.lpTemplateName = 0; bool code = ChooseColor(&chooser) == TRUE; for (int i = 0; i < 16; ++i) { std::string optionName = OPTION_PREFIX; ZLStringUtil::appendNumber(optionName, i); ZLColor color(GetRValue(refs[i]), GetGValue(refs[i]), GetBValue(refs[i])); ZLColorOption( ZLCategoryKey::LOOK_AND_FEEL, COLOR_GROUP_NAME, optionName, ZLColor(0, 0, 0) ).setValue(color); } if (code) { ZLColor color(GetRValue(chooser.rgbResult), GetGValue(chooser.rgbResult), GetBValue(chooser.rgbResult)); myStandardColorComboBox->setSelectedColor(color); } } }