1 #include "FirstUiBuilder.h"
8 static HBRUSH gFillColorBrush
= 0;
9 static HBRUSH gEdgeColorBrush
= 0;
11 static UIColor gCurrentEdgeColor
;
12 static UIColor gCurrentFillColor
;
14 extern bool gDrawHighlightRect
;
15 extern UIColor gHighlightOutlineColor
;
16 extern UIColor gHighlightFillColor
;
18 static void LoadData( HWND hwndDlg
)
20 if( gDrawHighlightRect
)
21 CheckDlgButton( hwndDlg
, IDC_DRAWHIGHLIGHT
, BST_CHECKED
);
23 CheckDlgButton( hwndDlg
, IDC_DRAWHIGHLIGHT
, BST_UNCHECKED
);
25 SendDlgItemMessage( hwndDlg
, IDC_EDGEOPACITY_SLIDER
, TBM_SETRANGE
, FALSE
, MAKELONG( 0, 255 ) );
26 SendDlgItemMessage( hwndDlg
, IDC_EDGEOPACITY_SLIDER
, TBM_SETPOS
, TRUE
, gHighlightOutlineColor
.a
);
28 SendDlgItemMessage( hwndDlg
, IDC_FILLOPACITY_SLIDER
, TBM_SETRANGE
, FALSE
, MAKELONG( 0, 255 ) );
29 SendDlgItemMessage( hwndDlg
, IDC_FILLOPACITY_SLIDER
, TBM_SETPOS
, TRUE
, gHighlightFillColor
.a
);
31 gCurrentEdgeColor
= gHighlightOutlineColor
;
32 gCurrentFillColor
= gHighlightFillColor
;
35 static void SaveData( HWND hwndDlg
)
37 gHighlightOutlineColor
= gCurrentEdgeColor
;
38 gHighlightOutlineColor
.a
= (unsigned char)SendDlgItemMessage( hwndDlg
, IDC_EDGEOPACITY_SLIDER
, TBM_GETPOS
, 0, 0 );
39 gHighlightFillColor
= gCurrentFillColor
;
40 gHighlightFillColor
.a
= (unsigned char)SendDlgItemMessage( hwndDlg
, IDC_FILLOPACITY_SLIDER
, TBM_GETPOS
, 0, 0 );
41 gDrawHighlightRect
= IsDlgButtonChecked( hwndDlg
, IDC_DRAWHIGHLIGHT
) != 0;
44 static void ChangeEdgeColor( HWND hwndDlg
)
46 CHOOSECOLOR cc
= {sizeof(cc
)};
49 ZeroMemory( sc
, sizeof( sc
) );
51 cc
.hwndOwner
= hwndDlg
;
52 cc
.rgbResult
= RGB( gCurrentEdgeColor
.r
, gCurrentEdgeColor
.g
, gCurrentEdgeColor
.b
);
53 cc
.Flags
= CC_RGBINIT
;
56 if( ChooseColor( &cc
) )
58 gCurrentEdgeColor
.r
= GetRValue( cc
.rgbResult
);
59 gCurrentEdgeColor
.g
= GetGValue( cc
.rgbResult
);
60 gCurrentEdgeColor
.b
= GetBValue( cc
.rgbResult
);
64 static void ChangeFillColor( HWND hwndDlg
)
66 CHOOSECOLOR cc
= {sizeof(cc
)};
69 ZeroMemory( sc
, sizeof( sc
) );
71 cc
.hwndOwner
= hwndDlg
;
72 cc
.rgbResult
= RGB( gCurrentFillColor
.r
, gCurrentFillColor
.g
, gCurrentFillColor
.b
);
73 cc
.Flags
= CC_RGBINIT
;
76 if( ChooseColor( &cc
) )
78 gCurrentFillColor
.r
= GetRValue( cc
.rgbResult
);
79 gCurrentFillColor
.g
= GetGValue( cc
.rgbResult
);
80 gCurrentFillColor
.b
= GetBValue( cc
.rgbResult
);
84 static void Cleanup( void )
88 DeleteObject( gFillColorBrush
);
94 DeleteObject( gEdgeColorBrush
);
99 BOOL CALLBACK
HighlightSettingsDlgProc( HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
108 // Equivalent to pressing cancel
109 EndDialog( hwndDlg
, 0 );
114 if( LOWORD( wParam
) == IDOK
)
117 EndDialog( hwndDlg
, 0 );
120 else if( LOWORD( wParam
) == IDCANCEL
)
122 EndDialog( hwndDlg
, 0 );
125 else if( LOWORD( wParam
) == IDC_CHANGE_EDGECOLOR
)
127 ChangeEdgeColor( hwndDlg
);
128 InvalidateRect( GetDlgItem( hwndDlg
, IDC_EDGECOLOR
), 0, TRUE
);
130 else if( LOWORD( wParam
) == IDC_CHANGE_FILLCOLOR
)
132 ChangeFillColor( hwndDlg
);
133 InvalidateRect( GetDlgItem( hwndDlg
, IDC_FILLCOLOR
), 0, TRUE
);
137 case WM_CTLCOLORSTATIC
:
138 if( (HWND
)lParam
== GetDlgItem( hwndDlg
, IDC_EDGECOLOR
) )
140 COLORREF col
= RGB( gCurrentEdgeColor
.r
, gCurrentEdgeColor
.g
, gCurrentEdgeColor
.b
);
142 if( gEdgeColorBrush
)
143 DeleteObject( gEdgeColorBrush
);
145 gEdgeColorBrush
= CreateSolidBrush( col
);
146 SetTextColor( (HDC
)wParam
, col
);
147 SetBkColor( (HDC
)wParam
, col
);
149 return (BOOL
)gEdgeColorBrush
;
151 else if( (HWND
)lParam
== GetDlgItem( hwndDlg
, IDC_FILLCOLOR
) )
153 COLORREF col
= RGB( gCurrentFillColor
.r
, gCurrentFillColor
.g
, gCurrentFillColor
.b
);
155 if( gFillColorBrush
)
156 DeleteObject( gFillColorBrush
);
158 gFillColorBrush
= CreateSolidBrush( col
);
159 SetTextColor( (HDC
)wParam
, col
);
160 SetBkColor( (HDC
)wParam
, col
);
162 return (BOOL
)gFillColorBrush
;