@@ -2651,15 +2651,14 @@ LRESULT CTreeSettingsDlg::OnBrowse( WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
26512651 CString str;
26522652 m_EditBox.GetWindowText (str);
26532653 str.TrimLeft (); str.TrimRight ();
2654- wchar_t *end;
2655- COLORREF val=wcstol (str,&end,16 )&0xFFFFFF ;
2654+ COLORREF val=RgbToBgr (ParseColor (str));
26562655 static COLORREF customColors[16 ];
26572656 CHOOSECOLOR choose={sizeof (choose),m_hWnd,NULL ,val,customColors};
26582657 choose.Flags =CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
26592658 if (ChooseColor (&choose))
26602659 {
26612660 wchar_t text[100 ];
2662- Sprintf (text,_countof (text),L" %06X" ,choose.rgbResult );
2661+ Sprintf (text,_countof (text),L" %06X" ,BgrToRgb ( choose.rgbResult ) );
26632662 m_EditBox.SetWindowText (text);
26642663 ApplyEditBox ();
26652664 UpdateGroup (m_pEditSetting);
@@ -3048,8 +3047,7 @@ void CTreeSettingsDlg::ApplyEditBox( void )
30483047 }
30493048 else if (pSetting->type ==CSetting::TYPE_COLOR)
30503049 {
3051- wchar_t *end;
3052- int val=wcstol (str,&end,16 )&0xFFFFFF ;
3050+ int val=RgbToBgr (ParseColor (str));
30533051 if (pSetting->value .vt !=VT_I4 || pSetting->value .intVal !=val)
30543052 {
30553053 pSetting->value =CComVariant (val);
@@ -3156,7 +3154,7 @@ void CTreeSettingsDlg::ItemSelected( HTREEITEM hItem, CSetting *pSetting, bool b
31563154 mode=EDIT_COLOR;
31573155 int val=0 ;
31583156 if (valVar.vt ==VT_I4)
3159- val=valVar.intVal ;
3157+ val=BgrToRgb ( valVar.intVal ) ;
31603158 Sprintf (text,_countof (text),L" %06X" ,val);
31613159 }
31623160 }
@@ -3462,7 +3460,7 @@ void CTreeSettingsDlg::UpdateGroup( const CSetting *pModified )
34623460 CString str=LoadStringEx (pSetting->nameID );
34633461 int val=0 ;
34643462 if (valVar.vt ==VT_I4)
3465- val=valVar.intVal ;
3463+ val=BgrToRgb ( valVar.intVal ) ;
34663464 Sprintf (text,_countof (text),L" %s: %06X" ,str,val);
34673465 item.mask |=TVIF_TEXT;
34683466 }
@@ -3616,3 +3614,19 @@ bool CDefaultSettingsPanel::Validate( HWND parent )
36163614 s_Dialog.Validate ();
36173615 return true ;
36183616}
3617+
3618+ DWORD RgbToBgr (DWORD val)
3619+ {
3620+ return ((val & 0xFF ) << 16 ) | (val & 0xFF00 ) | ((val >> 16 ) & 0xFF );
3621+ }
3622+
3623+ DWORD BgrToRgb (DWORD val)
3624+ {
3625+ return RgbToBgr (val);
3626+ }
3627+
3628+ DWORD ParseColor (const wchar_t * str)
3629+ {
3630+ wchar_t * end;
3631+ return wcstoul (str, &end, 16 ) & 0xFFFFFF ;
3632+ }
0 commit comments