ColorPickerDialogClass.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // ColorPickerDialogClass.cpp : implementation file
  19. //
  20. #include "StdAfx.H"
  21. #include "ColorPickerDialogClass.H"
  22. #include "ColorBar.H"
  23. #include "ColorPicker.H"
  24. #include "WWCtrl.H"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. extern HINSTANCE _hinstance;
  31. /////////////////////////////////////////////////////////////////////////////
  32. //
  33. // Local constants
  34. //
  35. /////////////////////////////////////////////////////////////////////////////
  36. const DWORD UPDATE_COLOR_BARS = 0x00000001;
  37. const DWORD UPDATE_WHITENESS = 0x00000002;
  38. const DWORD UPDATE_HUE_PICKER = 0x00000004;
  39. class MyManageStateClass
  40. {
  41. public:
  42. MyManageStateClass (void)
  43. {
  44. m_hResHandle = ::AfxGetResourceHandle ();
  45. ::AfxSetResourceHandle (_hinstance);
  46. }
  47. ~MyManageStateClass (void) { ::AfxSetResourceHandle (m_hResHandle); }
  48. private:
  49. HINSTANCE m_hResHandle;
  50. };
  51. #define MY_MANAGE_STATE() MyManageStateClass _xmystate;
  52. extern "C"
  53. {
  54. HWND
  55. Create_Color_Picker_Form (HWND parent, int red, int green, int blue)
  56. {
  57. MY_MANAGE_STATE ()
  58. CWnd *parent_wnd = CWnd::FromHandle (parent);
  59. ColorPickerDialogClass *dialog = new ColorPickerDialogClass (red, green, blue, parent_wnd, IDD_COLOR_FORM);
  60. dialog->Create_Form (parent_wnd);
  61. HINSTANCE old_handle = ::AfxGetResourceHandle ();
  62. ::AfxSetResourceHandle (_hinstance);
  63. return dialog->m_hWnd;
  64. }
  65. }
  66. extern "C"
  67. {
  68. BOOL
  69. Get_Form_Color (HWND form_wnd, int *red, int *green, int *blue)
  70. {
  71. MY_MANAGE_STATE ()
  72. BOOL retval = FALSE;
  73. ColorPickerDialogClass *dialog = (ColorPickerDialogClass *)::GetProp (form_wnd, "COLORPICKERDLGCLASS");
  74. if (dialog != NULL) {
  75. (*red) = dialog->Get_Red ();
  76. (*green) = dialog->Get_Green ();
  77. (*blue) = dialog->Get_Blue ();
  78. retval = TRUE;
  79. }
  80. return retval;
  81. }
  82. }
  83. extern "C"
  84. {
  85. BOOL
  86. Set_Form_Color (HWND form_wnd, int red, int green, int blue)
  87. {
  88. MY_MANAGE_STATE ()
  89. BOOL retval = FALSE;
  90. ColorPickerDialogClass *dialog = (ColorPickerDialogClass *)::GetProp (form_wnd, "COLORPICKERDLGCLASS");
  91. if (dialog != NULL) {
  92. dialog->Set_Color (red, green, blue);
  93. retval = TRUE;
  94. }
  95. return retval;
  96. }
  97. }
  98. extern "C"
  99. {
  100. BOOL
  101. Set_Form_Original_Color (HWND form_wnd, int red, int green, int blue)
  102. {
  103. MY_MANAGE_STATE ()
  104. BOOL retval = FALSE;
  105. ColorPickerDialogClass *dialog = (ColorPickerDialogClass *)::GetProp (form_wnd, "COLORPICKERDLGCLASS");
  106. if (dialog != NULL) {
  107. dialog->Set_Original_Color (red, green, blue);
  108. retval = TRUE;
  109. }
  110. return retval;
  111. }
  112. }
  113. extern "C"
  114. {
  115. BOOL
  116. Show_Color_Picker (int *red, int *green, int *blue)
  117. {
  118. MY_MANAGE_STATE ()
  119. BOOL retval = FALSE;
  120. ColorPickerDialogClass dialog (*red, *green, *blue);
  121. if (dialog.DoModal () == IDOK) {
  122. (*red) = dialog.Get_Red ();
  123. (*green) = dialog.Get_Green ();
  124. (*blue) = dialog.Get_Blue ();
  125. retval = TRUE;
  126. }
  127. return retval;
  128. }
  129. }
  130. extern "C"
  131. {
  132. BOOL
  133. Set_Update_Callback (HWND form_wnd, WWCTRL_COLORCALLBACK callback, void *arg)
  134. {
  135. MY_MANAGE_STATE()
  136. BOOL retval = FALSE;
  137. ColorPickerDialogClass *dialog = (ColorPickerDialogClass *)::GetProp (form_wnd, "COLORPICKERDLGCLASS");
  138. if (dialog != NULL) {
  139. dialog->Set_Update_Callback(callback, arg);
  140. retval = TRUE;
  141. }
  142. return retval;
  143. }
  144. }
  145. /////////////////////////////////////////////////////////////////////////////
  146. //
  147. // ColorPickerDialogClass
  148. //
  149. /////////////////////////////////////////////////////////////////////////////
  150. ColorPickerDialogClass::ColorPickerDialogClass
  151. (
  152. int red,
  153. int green,
  154. int blue,
  155. CWnd *pParent,
  156. UINT res_id
  157. )
  158. : m_OrigRed ((float)red),
  159. m_OrigGreen ((float)green),
  160. m_OrigBlue ((float)blue),
  161. m_CurrentRed ((float)red),
  162. m_CurrentGreen ((float)green),
  163. m_CurrentBlue ((float)blue),
  164. m_CurrentColorBar (NULL),
  165. m_OrigColorBar (NULL),
  166. m_RedColorBar (NULL),
  167. m_GreenColorBar (NULL),
  168. m_BlueColorBar (NULL),
  169. m_WhitenessColorBar (NULL),
  170. m_HuePicker (NULL),
  171. m_bDeleteOnClose (false),
  172. m_UpdateCallback(NULL),
  173. CDialog(res_id, pParent)
  174. {
  175. //{{AFX_DATA_INIT(ColorPickerDialogClass)
  176. // NOTE: the ClassWizard will add member initialization here
  177. //}}AFX_DATA_INIT
  178. return ;
  179. }
  180. /////////////////////////////////////////////////////////////////////////////
  181. //
  182. // Create_Form
  183. //
  184. /////////////////////////////////////////////////////////////////////////////
  185. void
  186. ColorPickerDialogClass::Create_Form (CWnd *parent)
  187. {
  188. Create (IDD_COLOR_FORM, parent);
  189. SetProp (m_hWnd, "COLORPICKERDLGCLASS", (HANDLE)this);
  190. m_bDeleteOnClose = true;
  191. return ;
  192. }
  193. /////////////////////////////////////////////////////////////////////////////
  194. //
  195. // DoDataExchange
  196. //
  197. /////////////////////////////////////////////////////////////////////////////
  198. void
  199. ColorPickerDialogClass::DoDataExchange (CDataExchange *pDX)
  200. {
  201. CDialog::DoDataExchange(pDX);
  202. //{{AFX_DATA_MAP(ColorPickerDialogClass)
  203. DDX_Control(pDX, IDC_BLUE_SPIN, m_BlueSpin);
  204. DDX_Control(pDX, IDC_GREEN_SPIN, m_GreenSpin);
  205. DDX_Control(pDX, IDC_RED_SPIN, m_RedSpin);
  206. //}}AFX_DATA_MAP
  207. return ;
  208. }
  209. BEGIN_MESSAGE_MAP(ColorPickerDialogClass, CDialog)
  210. //{{AFX_MSG_MAP(ColorPickerDialogClass)
  211. ON_BN_CLICKED(IDC_RESET, OnReset)
  212. //}}AFX_MSG_MAP
  213. END_MESSAGE_MAP()
  214. /////////////////////////////////////////////////////////////////////////////
  215. //
  216. // OnInitDialog
  217. //
  218. /////////////////////////////////////////////////////////////////////////////
  219. BOOL
  220. ColorPickerDialogClass::OnInitDialog (void)
  221. {
  222. CDialog::OnInitDialog ();
  223. //
  224. // Setup the spin controls
  225. //
  226. m_BlueSpin.SetRange (0, 255);
  227. m_GreenSpin.SetRange (0, 255);
  228. m_RedSpin.SetRange (0, 255);
  229. m_BlueSpin.SetPos ((int)m_CurrentBlue);
  230. m_GreenSpin.SetPos ((int)m_CurrentGreen);
  231. m_RedSpin.SetPos ((int)m_CurrentRed);
  232. //
  233. // Get control of all the color bars on the dialog
  234. //
  235. m_CurrentColorBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_CURRENT_COLOR_BAR));
  236. m_OrigColorBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_ORIG_COLOR_BAR));
  237. m_RedColorBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_RED_BAR));
  238. m_GreenColorBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_GREEN_BAR));
  239. m_BlueColorBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_BLUE_BAR));
  240. m_WhitenessColorBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_WHITENESS_BAR));
  241. m_HuePicker = ColorPickerClass::Get_Color_Picker (::GetDlgItem (m_hWnd, IDC_HUE_PICKER));
  242. // Setup the original color bar
  243. m_OrigColorBar->Modify_Point (0, 0, m_OrigRed, m_OrigGreen, m_OrigBlue);
  244. m_HuePicker->Select_Color ((int)m_OrigRed, (int)m_OrigGreen, (int)m_OrigBlue);
  245. //m_WhitenessColorBar->Modify_Point (0, 0, m_OrigRed, m_OrigGreen, m_OrigBlue);
  246. m_RedColorBar->Set_Range (0, 255);
  247. m_GreenColorBar->Set_Range (0, 255);
  248. m_BlueColorBar->Set_Range (0, 255);
  249. m_WhitenessColorBar->Set_Range (0, 255);
  250. m_WhitenessColorBar->Insert_Point (1, 255, 255, 255, 255);
  251. //
  252. // Setup the red/green/blue color bars
  253. //
  254. //m_RedColorBar->Insert_Point (1, 1, 255, 0, 0);
  255. //m_GreenColorBar->Insert_Point (1, 1, 0, 255, 0);
  256. //m_BlueColorBar->Insert_Point (1, 1, 0, 0, 255);
  257. //
  258. // Update the remaining color bars to reflect the initial color
  259. //
  260. Update_Red_Bar ();
  261. Update_Green_Bar ();
  262. Update_Blue_Bar ();
  263. Update_Current_Color_Bar ();
  264. Update_Whiteness_Bar ();
  265. return TRUE;
  266. }
  267. /////////////////////////////////////////////////////////////////////////////
  268. //
  269. // Update_Red_Bar
  270. //
  271. /////////////////////////////////////////////////////////////////////////////
  272. void
  273. ColorPickerDialogClass::Update_Red_Bar (void)
  274. {
  275. m_RedColorBar->Set_Selection_Pos (m_CurrentRed);
  276. m_RedColorBar->Modify_Point (0, 0, 0, (float)m_CurrentGreen, (float)m_CurrentBlue);
  277. m_RedColorBar->Modify_Point (1, 255, 255, (float)m_CurrentGreen, (float)m_CurrentBlue);
  278. return ;
  279. }
  280. /////////////////////////////////////////////////////////////////////////////
  281. //
  282. // Update_Green_Bar
  283. //
  284. /////////////////////////////////////////////////////////////////////////////
  285. void
  286. ColorPickerDialogClass::Update_Green_Bar (void)
  287. {
  288. m_GreenColorBar->Set_Selection_Pos (m_CurrentGreen);
  289. m_GreenColorBar->Modify_Point (0, 0, m_CurrentRed, 0, m_CurrentBlue);
  290. m_GreenColorBar->Modify_Point (1, 255, m_CurrentRed, 255, m_CurrentBlue);
  291. return ;
  292. }
  293. /////////////////////////////////////////////////////////////////////////////
  294. //
  295. // Update_Blue_Bar
  296. //
  297. /////////////////////////////////////////////////////////////////////////////
  298. void
  299. ColorPickerDialogClass::Update_Blue_Bar (void)
  300. {
  301. m_BlueColorBar->Set_Selection_Pos (m_CurrentBlue);
  302. m_BlueColorBar->Modify_Point (0, 0, m_CurrentRed, m_CurrentGreen, 0);
  303. m_BlueColorBar->Modify_Point (1, 255, m_CurrentRed, m_CurrentGreen, 255);
  304. return ;
  305. }
  306. /////////////////////////////////////////////////////////////////////////////
  307. //
  308. // Update_Current_Color_Bar
  309. //
  310. /////////////////////////////////////////////////////////////////////////////
  311. void
  312. ColorPickerDialogClass::Update_Current_Color_Bar (void)
  313. {
  314. m_CurrentColorBar->Modify_Point (0, 0, m_CurrentRed, m_CurrentGreen, m_CurrentBlue);
  315. return ;
  316. }
  317. /////////////////////////////////////////////////////////////////////////////
  318. //
  319. // Update_Whiteness_Bar
  320. //
  321. /////////////////////////////////////////////////////////////////////////////
  322. void
  323. ColorPickerDialogClass::Update_Whiteness_Bar (void)
  324. {
  325. int red = 0;
  326. int green = 0;
  327. int blue = 0;
  328. m_HuePicker->Get_Current_Color (&red, &green, &blue);
  329. //
  330. // Given the current color, determine the 'whiteness' and update
  331. //
  332. float whiteness = min (m_CurrentRed, m_CurrentGreen);
  333. whiteness = min (whiteness, m_CurrentBlue);
  334. float percent = whiteness / 255;
  335. m_WhitenessColorBar->Set_Selection_Pos (whiteness);
  336. m_WhitenessColorBar->Modify_Point (0, 0, (float)red, (float)green, (float)blue);
  337. // Can we extrapolate the starting color from the whiteness factor?
  338. /*if (percent == 1) {
  339. m_WhitenessColorBar->Modify_Point (0, 0, 0, 0, 0);
  340. } else {
  341. //
  342. // Extrapolate the starting color
  343. //
  344. float start_red = (m_CurrentRed - whiteness) / (1 - percent);
  345. float start_green = (m_CurrentGreen - whiteness) / (1 - percent);
  346. float start_blue = (m_CurrentBlue - whiteness) / (1 - percent);
  347. m_WhitenessColorBar->Modify_Point (0, 0, start_red, start_green, start_blue);
  348. }*/
  349. return ;
  350. }
  351. /////////////////////////////////////////////////////////////////////////////
  352. //
  353. // OnNotify
  354. //
  355. /////////////////////////////////////////////////////////////////////////////
  356. BOOL
  357. ColorPickerDialogClass::OnNotify
  358. (
  359. WPARAM wParam,
  360. LPARAM lParam,
  361. LRESULT *pResult
  362. )
  363. {
  364. CBR_NMHDR *color_bar_hdr = (CBR_NMHDR *)lParam;
  365. switch (color_bar_hdr->hdr.idFrom)
  366. {
  367. case IDC_RED_BAR:
  368. {
  369. if (color_bar_hdr->hdr.code == CBRN_SEL_CHANGED) {
  370. float red = color_bar_hdr->red;
  371. float green = m_CurrentGreen;
  372. float blue = m_CurrentBlue;
  373. Update_Color (red, green, blue);
  374. }
  375. }
  376. break;
  377. case IDC_GREEN_BAR:
  378. {
  379. if (color_bar_hdr->hdr.code == CBRN_SEL_CHANGED) {
  380. float red = m_CurrentRed;
  381. float green = color_bar_hdr->green;
  382. float blue = m_CurrentBlue;
  383. Update_Color (red, green, blue);
  384. }
  385. }
  386. break;
  387. case IDC_BLUE_BAR:
  388. {
  389. if (color_bar_hdr->hdr.code == CBRN_SEL_CHANGED) {
  390. float red = m_CurrentRed;
  391. float green = m_CurrentGreen;
  392. float blue = color_bar_hdr->blue;
  393. Update_Color (red, green, blue);
  394. }
  395. }
  396. break;
  397. case IDC_WHITENESS_BAR:
  398. {
  399. if (color_bar_hdr->hdr.code == CBRN_SEL_CHANGED) {
  400. float red = color_bar_hdr->red;
  401. float green = color_bar_hdr->green;
  402. float blue = color_bar_hdr->blue;
  403. Update_Color (red, green, blue, UPDATE_COLOR_BARS);
  404. }
  405. }
  406. break;
  407. case IDC_HUE_PICKER:
  408. {
  409. CP_NMHDR *picker_hdr = (CP_NMHDR *)lParam;
  410. if (picker_hdr->hdr.code == CPN_COLORCHANGE) {
  411. float red = picker_hdr->red;
  412. float green = picker_hdr->green;
  413. float blue = picker_hdr->blue;
  414. float whiteness = m_WhitenessColorBar->Get_Selection_Pos () / 255;
  415. red = red + ((255 - red) * whiteness);
  416. green = green + ((255 - green) * whiteness);
  417. blue = blue + ((255 - blue) * whiteness);
  418. Update_Color (red, green, blue, UPDATE_COLOR_BARS | UPDATE_WHITENESS);
  419. }
  420. }
  421. break;
  422. case IDC_RED_SPIN:
  423. case IDC_GREEN_SPIN:
  424. case IDC_BLUE_SPIN:
  425. {
  426. if (color_bar_hdr->hdr.code == UDN_DELTAPOS) {
  427. float red = (float)m_RedSpin.GetPos ();
  428. float green = (float)m_GreenSpin.GetPos ();
  429. float blue = (float)m_BlueSpin.GetPos ();
  430. Update_Color (red, green, blue, UPDATE_COLOR_BARS | UPDATE_WHITENESS | UPDATE_HUE_PICKER);
  431. }
  432. }
  433. break;
  434. }
  435. return CDialog::OnNotify (wParam, lParam, pResult);
  436. }
  437. /////////////////////////////////////////////////////////////////////////////
  438. //
  439. // Update_Color
  440. //
  441. /////////////////////////////////////////////////////////////////////////////
  442. void
  443. ColorPickerDialogClass::Update_Color
  444. (
  445. float red,
  446. float green,
  447. float blue,
  448. DWORD flags
  449. )
  450. {
  451. /*bool update_red = m_CurrentRed != red;
  452. bool update_green = m_CurrentGreen != green;
  453. bool update_blue = m_CurrentBlue != blue;*/
  454. m_CurrentRed = red;
  455. m_CurrentGreen = green;
  456. m_CurrentBlue = blue;
  457. int int_blue = (int)blue;
  458. int int_green = (int)green;
  459. int int_red = (int)red;
  460. if (int_blue != m_BlueSpin.GetPos ()) {
  461. m_BlueSpin.SetPos (int_blue);
  462. }
  463. if (int_green != m_GreenSpin.GetPos ()) {
  464. m_GreenSpin.SetPos (int_green);
  465. }
  466. if (int_red != m_RedSpin.GetPos ()) {
  467. m_RedSpin.SetPos (int_red);
  468. }
  469. // Hack to get the edit controls to update in a timely fashion
  470. ::UpdateWindow (::GetDlgItem (m_hWnd, IDC_RED_EDIT));
  471. ::UpdateWindow (::GetDlgItem (m_hWnd, IDC_GREEN_EDIT));
  472. ::UpdateWindow (::GetDlgItem (m_hWnd, IDC_BLUE_EDIT));
  473. //
  474. // Update the red, green and blue color bars
  475. //
  476. if (flags & UPDATE_COLOR_BARS) {
  477. Update_Red_Bar ();
  478. Update_Green_Bar ();
  479. Update_Blue_Bar ();
  480. }
  481. //
  482. // Update the hue picker
  483. //
  484. if (flags & UPDATE_HUE_PICKER) {
  485. m_HuePicker->Select_Color ((int)red, (int)green, (int)blue);
  486. }
  487. //
  488. // Update the whiteness color bar
  489. //
  490. if (flags & UPDATE_WHITENESS) {
  491. Update_Whiteness_Bar ();
  492. }
  493. Update_Current_Color_Bar ();
  494. // If a callback is registered, call it.
  495. if (m_UpdateCallback)
  496. m_UpdateCallback((int)red, (int)green, (int)blue, m_CallArg);
  497. return ;
  498. }
  499. /////////////////////////////////////////////////////////////////////////////
  500. //
  501. // Set_Original_Color
  502. //
  503. /////////////////////////////////////////////////////////////////////////////
  504. void ColorPickerDialogClass::Set_Original_Color (int r, int g, int b)
  505. {
  506. m_OrigRed = (float)r;
  507. m_OrigGreen = (float)g;
  508. m_OrigBlue = (float)b;
  509. m_OrigColorBar->Modify_Point (0, 0, m_OrigRed, m_OrigGreen, m_OrigBlue);
  510. }
  511. /////////////////////////////////////////////////////////////////////////////
  512. //
  513. // OnReset
  514. //
  515. /////////////////////////////////////////////////////////////////////////////
  516. void
  517. ColorPickerDialogClass::OnReset (void)
  518. {
  519. Update_Color (m_OrigRed,
  520. m_OrigGreen,
  521. m_OrigBlue,
  522. UPDATE_COLOR_BARS| UPDATE_WHITENESS | UPDATE_HUE_PICKER);
  523. return ;
  524. }
  525. LRESULT ColorPickerDialogClass::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  526. {
  527. return CDialog::WindowProc(message, wParam, lParam);
  528. }
  529. /////////////////////////////////////////////////////////////////////////////
  530. //
  531. // OnCommand
  532. //
  533. /////////////////////////////////////////////////////////////////////////////
  534. BOOL
  535. ColorPickerDialogClass::OnCommand
  536. (
  537. WPARAM wParam,
  538. LPARAM lParam
  539. )
  540. {
  541. switch (LOWORD (wParam))
  542. {
  543. case IDC_RED_EDIT:
  544. case IDC_GREEN_EDIT:
  545. case IDC_BLUE_EDIT:
  546. {
  547. if (HIWORD (wParam) == EN_KILLFOCUS) {
  548. float red = (float)GetDlgItemInt (IDC_RED_EDIT);
  549. float green = (float)GetDlgItemInt (IDC_GREEN_EDIT);
  550. float blue = (float)GetDlgItemInt (IDC_BLUE_EDIT);
  551. Update_Color (red, green, blue, UPDATE_COLOR_BARS| UPDATE_WHITENESS | UPDATE_HUE_PICKER);
  552. }
  553. }
  554. break;
  555. }
  556. return CDialog::OnCommand(wParam, lParam);
  557. }
  558. /////////////////////////////////////////////////////////////////////////////
  559. //
  560. // PostNcDestroy
  561. //
  562. /////////////////////////////////////////////////////////////////////////////
  563. void
  564. ColorPickerDialogClass::PostNcDestroy (void)
  565. {
  566. CDialog::PostNcDestroy();
  567. if (m_bDeleteOnClose) {
  568. delete this;
  569. }
  570. return ;
  571. }