[KSPROXY]
[reactos.git] / reactos / dll / cpl / desk / effappdlg.c
1 /* $Id: effappdlg.c 24836 2007-02-12 03:12:56Z tkreuzer $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS Display Control Panel
5 * FILE: dll/cpl/desk/effappdlg.c
6 * PURPOSE: Effects appearance dialog
7 *
8 * PROGRAMMER: Jan Roeloffzen (jroeloffzen[at]hotmail[dot]com)
9 *
10 */
11
12 #include "desk.h"
13 #include "appearance.h"
14
15 /* Update all the controls with the current values for the selected screen element */
16 static VOID
17 UpdateControls(HWND hwndDlg, GLOBALS *g)
18 {
19 WPARAM state;
20 state = SendDlgItemMessage(hwndDlg, IDC_EFFAPPEARANCE_ANIMATION, BM_GETCHECK, 0, 0);
21 g->ThemeAdv.Effects.bMenuAnimation = (state == BST_CHECKED) ? TRUE : FALSE;
22 EnableWindow(GetDlgItem(hwndDlg, IDC_EFFAPPEARANCE_ANIMATIONTYPE), g->ThemeAdv.Effects.bMenuAnimation);
23
24 //A boolean as an index for a 2-value list:
25 SendDlgItemMessage(hwndDlg, IDC_EFFAPPEARANCE_ANIMATIONTYPE, CB_SETCURSEL, (WPARAM)g->ThemeAdv.Effects.bMenuFade, 0);
26
27 state = SendDlgItemMessage(hwndDlg, IDC_EFFAPPEARANCE_KEYBOARDCUES, BM_GETCHECK, 0, 0);
28 g->ThemeAdv.Effects.bKeyboardCues = (state == BST_CHECKED) ? TRUE : FALSE;
29 state = SendDlgItemMessage(hwndDlg, IDC_EFFAPPEARANCE_DRAGFULLWINDOWS, BM_GETCHECK, 0, 0);
30 g->ThemeAdv.Effects.bDragFullWindows = (state == BST_CHECKED) ? TRUE : FALSE;
31
32 }
33
34
35 static VOID
36 SaveCurrentValues(HWND hwndDlg, GLOBALS *g)
37 {
38 }
39
40 static VOID
41 AddToCombo(HWND hwndDlg, INT From, INT To, INT Combo)
42 {
43 INT iElement, iListIndex, i=0;
44 TCHAR tstrText[80];
45
46 for (iElement = From; iElement<=To; iElement++)
47 {
48 LoadString(hApplet, iElement, (LPTSTR)tstrText, 80);
49 iListIndex = SendDlgItemMessage(hwndDlg, Combo, CB_ADDSTRING, 0, (LPARAM)tstrText);
50 SendDlgItemMessage(hwndDlg, Combo, CB_SETITEMDATA, (WPARAM)iListIndex, (LPARAM)i++ );
51 }
52 }
53
54 /* Initialize the effects appearance dialog */
55 static VOID
56 EffAppearanceDlg_Init(HWND hwndDlg, GLOBALS *g)
57 {
58 WPARAM state;
59
60 /* Copy the current theme values */
61 g->ThemeAdv = g->Theme;
62
63 AddToCombo(hwndDlg, IDS_SLIDEEFFECT, IDS_FADEEFFECT, IDC_EFFAPPEARANCE_ANIMATIONTYPE);
64
65 state = g->ThemeAdv.Effects.bMenuAnimation ? BST_CHECKED : BST_UNCHECKED;
66 SendDlgItemMessage(hwndDlg, IDC_EFFAPPEARANCE_ANIMATION, BM_SETCHECK, state, 0);
67
68 state = g->ThemeAdv.Effects.bKeyboardCues ? BST_CHECKED : BST_UNCHECKED;
69 SendDlgItemMessage(hwndDlg, IDC_EFFAPPEARANCE_KEYBOARDCUES, BM_SETCHECK, state, 0);
70
71 state = g->ThemeAdv.Effects.bDragFullWindows ? BST_CHECKED : BST_UNCHECKED;
72 SendDlgItemMessage(hwndDlg, IDC_EFFAPPEARANCE_DRAGFULLWINDOWS, BM_SETCHECK, state, 0);
73
74 /* Update the controls */
75 UpdateControls(hwndDlg, g);
76 }
77
78
79 static VOID
80 EffAppearanceDlg_CleanUp(HWND hwndDlg, GLOBALS* g)
81 {
82 }
83
84 INT_PTR CALLBACK
85 EffAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
86 {
87 GLOBALS* g;
88
89 g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
90
91 switch (uMsg)
92 {
93 case WM_INITDIALOG:
94 g = (GLOBALS*)lParam;
95 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
96 EffAppearanceDlg_Init(hwndDlg, g);
97 break;
98
99 case WM_DESTROY:
100 EffAppearanceDlg_CleanUp(hwndDlg, g);
101 break;
102
103 case WM_COMMAND:
104 switch(LOWORD(wParam))
105 {
106 case IDOK:
107 SaveCurrentValues(hwndDlg, g);
108 EndDialog(hwndDlg, 0);
109 break;
110
111 case IDCANCEL:
112 g->ThemeAdv = g->Theme;
113 EndDialog(hwndDlg, 0);
114 break;
115
116 case IDC_EFFAPPEARANCE_ANIMATION:
117 case IDC_EFFAPPEARANCE_KEYBOARDCUES:
118 case IDC_EFFAPPEARANCE_DRAGFULLWINDOWS:
119 if (HIWORD(wParam) == BN_CLICKED)
120 {
121 UpdateControls(hwndDlg, g);
122 }
123 break;
124
125 case IDC_EFFAPPEARANCE_ANIMATIONTYPE:
126 if (HIWORD(wParam) == CBN_SELCHANGE)
127 {
128 SaveCurrentValues(hwndDlg, g);
129 g->ThemeAdv.Effects.bMenuFade = SendDlgItemMessage(hwndDlg, IDC_EFFAPPEARANCE_ANIMATIONTYPE, CB_GETCURSEL, 0, 0);
130 UpdateControls(hwndDlg, g);
131 }
132 break;
133
134 default:
135 return FALSE;
136 }
137 break;
138
139 default:
140 return FALSE;
141 }
142
143 return TRUE;
144 }