summaryrefslogtreecommitdiff
path: root/plugins/ChangeKeyboardLayout/src/options.cpp
blob: 39c678a9f322608184294794cfc5b1e706b6d855 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
#include "options.h"


INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
	static BOOL MainDialogLock = FALSE;
	LPTSTR ptszGenLay, ptszMemLay, ptszFormLay, ptszShortNameLay;
	LPSTR pszNameLay;
	BYTE i;

	switch (uiMessage)
	{
	case WM_INITDIALOG:
		{			
			MainDialogLock = TRUE;
			TranslateDialogDefault(hWnd);
			
			//Ãîðÿ÷èå êëàâèøè
			// Çàïðåùàåì ââîäèòü â êîíòðîëû âñå, êðîìå îáû÷íûõ êíîïîê
			SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT, HKM_SETRULES, 0xFF, 0);
			SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT2, HKM_SETRULES, 0xFF, 0);
			SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_SETRULES, 0xFF, 0);
			
			//Îòîáðàæàåì óïðàâëÿþùèå êëàâèøè
			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_SHIFT, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000100), 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_CTRL, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000200), 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_ALT, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000400), 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_WIN, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000800), 0);

			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_SHIFT, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000100), 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_CTRL, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000200), 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_ALT, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000400), 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_WIN, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000800), 0);

			SendDlgItemMessage(hWnd, IDC_CHECK_CASE_SHIFT, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000100), 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_CASE_CTRL, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000200), 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_CASE_ALT, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000400), 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_CASE_WIN, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000800), 0);

			//Ïîêàçûâàåì ñèìâîë èç õîòêåÿ
			SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT, HKM_SETHOTKEY, moOptions.dwHotkey_Layout&0x000000FF, 0);
			SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT2, HKM_SETHOTKEY, moOptions.dwHotkey_Layout2&0x000000FF, 0);
			SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_SETHOTKEY, moOptions.dwHotkey_Case&0x000000FF, 0);
			
			//Îñòàëüíûå îïöèè
			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE, BM_SETCHECK, moOptions.CurrentWordLayout, 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE2, BM_SETCHECK, moOptions.CurrentWordLayout2, 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_CASE_MODE, BM_SETCHECK, moOptions.CurrentWordCase, 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_TWOWAY, BM_SETCHECK, moOptions.TwoWay, 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_SYSTEMLAYOUT, BM_SETCHECK, moOptions.ChangeSystemLayout, 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_CLIPBOARD, BM_SETCHECK, moOptions.CopyToClipboard, 0);
			SendDlgItemMessage(hWnd, IDC_CHECK_POPUP, BM_SETCHECK, moOptions.ShowPopup, 0);

			//Ñìåíà ñîñòîÿíèÿ CapsLock
			switch(moOptions.bCaseOperations)
			{
			case 1:
				SendDlgItemMessage(hWnd, IDC_RADIO_OFFCAPS, BM_SETCHECK, 1, 0);
				break;
			case 2:
			    SendDlgItemMessage(hWnd, IDC_RADIO_IGNORECAPS, BM_SETCHECK, 1, 0);
				break;
			default:
				SendDlgItemMessage(hWnd, IDC_RADIO_INVERTCAPS, BM_SETCHECK, 1, 0);
			    break;
			}

			// Îòîáðàæàåì ïðèìåð êîíôèã.ñòðîêè
			ptszMemLay = ptszLayStrings[0];
			SendDlgItemMessage(hWnd, IDC_EDIT_EXAMPLE, WM_SETTEXT, 0, (LPARAM)ptszMemLay);
			ptszShortNameLay = GetShortNameOfLayout(hklLayouts[0]);
			SendDlgItemMessage(hWnd, IDC_STATIC_EXAMPLE, WM_SETTEXT, 0, (LPARAM)ptszShortNameLay);
			mir_free(ptszShortNameLay);

			// Çàïîëíÿåì êîìáîáîêñ ñ òåêóùèìè ðàñêëàäêàìè
			for(i = 0; i < bLayNum; i++) 
			{
				ptszShortNameLay = GetShortNameOfLayout(hklLayouts[i]);				
				SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_ADDSTRING, 0, (LPARAM)ptszShortNameLay);
				mir_free(ptszShortNameLay);
			}
			//Îòîáðàæàåì ïåðâóþ ðàñêëàäêó â ñïèñêå
			SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_SETCURSEL, 0, 0);
			ptszMemLay = ptszLayStrings[0];
			SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_SETTEXT, 0, (LPARAM)ptszMemLay);
			
			if (bLayNum != 2) EnableWindow(GetDlgItem(hWnd, IDC_CHECK_TWOWAY), FALSE);		
			MainDialogLock = FALSE;
			return TRUE;
		}
	case WM_COMMAND:
		{
			switch (LOWORD(wParam))
			{
			case IDC_HOTKEY_LAYOUT:
			case IDC_HOTKEY_LAYOUT2:
			case IDC_HOTKEY_CASE:			
				
				{
					if ((HIWORD(wParam) == EN_CHANGE))
						SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
					break;
				}
			case IDC_CHECK_DETECT:
			case IDC_CHECK_LAYOUT_MODE:
			case IDC_CHECK_LAYOUT_MODE2:
			case IDC_CHECK_CASE_MODE:
			case IDC_CHECK_TWOWAY:
			case IDC_CHECK_SYSTEMLAYOUT:
			case IDC_CHECK_POPUP:
			case IDC_CHECK_CLIPBOARD:
			case IDC_CHECK_LAYOUT_SHIFT:
			case IDC_CHECK_LAYOUT_ALT:
			case IDC_CHECK_LAYOUT_CTRL:
			case IDC_CHECK_LAYOUT_WIN:
			case IDC_CHECK_LAYOUT2_SHIFT:
			case IDC_CHECK_LAYOUT2_ALT:
			case IDC_CHECK_LAYOUT2_CTRL:
			case IDC_CHECK_LAYOUT2_WIN:
			case IDC_CHECK_CASE_SHIFT:
			case IDC_CHECK_CASE_ALT:
			case IDC_CHECK_CASE_CTRL:
			case IDC_CHECK_CASE_WIN:
			case IDC_RADIO_IGNORECAPS:
			case IDC_RADIO_INVERTCAPS:
			case IDC_RADIO_OFFCAPS:

				{
					if ((HIWORD(wParam) == BN_CLICKED))
						SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
					break;
				}
			case IDC_COMBO_LANG:
				{
					if ((HIWORD(wParam) == CBN_SELCHANGE))
					{
						MainDialogLock = TRUE;
						ptszMemLay = ptszLayStrings[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)];
						SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_SETTEXT, 0, (LPARAM)ptszMemLay);
						MainDialogLock = FALSE;
					}
					break;
				}
			case IDC_EDIT_SET:
				{
					if ((HIWORD(wParam) == EN_CHANGE) && (!MainDialogLock))
						SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
					break;
				}

			case IDC_BUTTON_DEFAULT:
				{
					if ((HIWORD(wParam) == BN_CLICKED ))
					{
						ptszGenLay = GenerateLayoutString(hklLayouts[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)]);
						SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_SETTEXT, 0, (LPARAM)ptszGenLay);
						mir_free(ptszGenLay);
						SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
					}
					break;
				}

 			}
			break;	
		}
	case WM_NOTIFY:
		{
			switch(((LPNMHDR)lParam)->idFrom)
			{
			case 0:
				{
					switch (((LPNMHDR)lParam)->code)
					{
					case PSN_APPLY:
						{
							// Ïðî÷èòàåì õîòêåè
							moOptions.dwHotkey_Layout = SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT, HKM_GETHOTKEY, 0, 0);
							moOptions.dwHotkey_Layout2 = SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT2, HKM_GETHOTKEY, 0, 0);
							moOptions.dwHotkey_Case = SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_GETHOTKEY, 0, 0);							

							//Äîïèøåì ê ñèìâîëàì óïðàâëÿþùèå êëàâèøè
							if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_SHIFT, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Layout |= 0x00000100;
							if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_CTRL, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Layout |= 0x00000200;
							if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_ALT, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Layout |= 0x00000400;
							if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_WIN, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Layout |= 0x00000800;
							
							if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_SHIFT, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Layout2 |= 0x00000100;
							if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_CTRL, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Layout2 |= 0x00000200;
							if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_ALT, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Layout2 |= 0x00000400;
							if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_WIN, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Layout2 |= 0x00000800;

							if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_SHIFT, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Case |= 0x00000100;
							if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_CTRL, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Case |= 0x00000200;
							if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_ALT, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Case |= 0x00000400;
							if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_WIN, BM_GETCHECK, 0, 0)) 
								moOptions.dwHotkey_Case |= 0x00000800;

							
							//Ïðî÷èå îïöèè
							moOptions.CurrentWordLayout = SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE, BM_GETCHECK, 0, 0);
							moOptions.CurrentWordLayout2 = SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE2, BM_GETCHECK, 0, 0);
							moOptions.CurrentWordCase = SendDlgItemMessage(hWnd, IDC_CHECK_CASE_MODE, BM_GETCHECK, 0, 0);
							moOptions.TwoWay = SendDlgItemMessage(hWnd, IDC_CHECK_TWOWAY, BM_GETCHECK, 0, 0);
							moOptions.ChangeSystemLayout = SendDlgItemMessage(hWnd, IDC_CHECK_SYSTEMLAYOUT, BM_GETCHECK, 0, 0);
							moOptions.CopyToClipboard = SendDlgItemMessage(hWnd, IDC_CHECK_CLIPBOARD, BM_GETCHECK, 0, 0);
							moOptions.ShowPopup = SendDlgItemMessage(hWnd, IDC_CHECK_POPUP, BM_GETCHECK, 0, 0);

							// CapsLock
							if (SendDlgItemMessage(hWnd, IDC_RADIO_OFFCAPS, BM_GETCHECK, 0, 0) == BST_CHECKED)
								moOptions.bCaseOperations = 1;
							else if (SendDlgItemMessage(hWnd, IDC_RADIO_IGNORECAPS, BM_GETCHECK, 0, 0) == BST_CHECKED)
								moOptions.bCaseOperations = 2;
							else moOptions.bCaseOperations = 0;								

							WriteMainOptions();

							ptszFormLay = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
							SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_GETTEXT, (WPARAM) MaxTextSize, (LPARAM)ptszFormLay);
							i = SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0);
							ptszMemLay = ptszLayStrings[i];
							if(_tcscmp(ptszMemLay, ptszFormLay) != 0)
							{
								_tcscpy(ptszMemLay, ptszFormLay);
								ptszGenLay = GenerateLayoutString(hklLayouts[i]);
								pszNameLay = GetNameOfLayout(hklLayouts[i]);

								if(_tcscmp(ptszMemLay, ptszGenLay) != 0)
									DBWriteContactSettingTString(NULL, ModuleName, pszNameLay, ptszMemLay);
								else
									DBDeleteContactSetting(NULL, ModuleName, pszNameLay);
								
								mir_free(pszNameLay);
								mir_free(ptszGenLay);
							}
							mir_free(ptszFormLay);							
							
							ptszMemLay = ptszLayStrings[0];
							SendDlgItemMessage(hWnd, IDC_EDIT_EXAMPLE, WM_SETTEXT, 0, (LPARAM)ptszMemLay);
							
							UnhookWindowsHookEx(kbHook_All);
							kbHook_All = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)Keyboard_Hook, NULL, GetCurrentThreadId());

							break;
						}
					}
					break;
				}
			}
			break;
		}

	case WM_DESTROY:
		{			
			break;
		}

	}
	return FALSE;
}


INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
	POPUPDATAT_V2 pdtData;
	static BOOL PopupDialogLock = FALSE;
	LPTSTR ptszPopupPreviewText;
	DWORD dwTimeOut;

	switch (uiMessage)
	{
	case WM_INITDIALOG:
	{
			PopupDialogLock = TRUE;
			TranslateDialogDefault(hWnd);
			poOptionsTemp = poOptions;

			//Öâåòà
			SendDlgItemMessage(hWnd, IDC_CUSTOM_BACK, CPM_SETCOLOUR, 0, poOptionsTemp.crBackColour);
			SendDlgItemMessage(hWnd, IDC_CUSTOM_TEXT, CPM_SETCOLOUR, 0, poOptionsTemp.crTextColour);
			CheckDlgButton(hWnd, IDC_RADIO_COLOURS_POPUP, poOptionsTemp.bColourType == PPC_POPUP);
			CheckDlgButton(hWnd, IDC_RADIO_COLOURS_WINDOWS, poOptionsTemp.bColourType == PPC_WINDOWS);
			CheckDlgButton(hWnd, IDC_RADIO_COLOURS_CUSTOM, poOptionsTemp.bColourType == PPC_CUSTOM);
			EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_BACK), poOptionsTemp.bColourType == PPC_CUSTOM);
			EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_TEXT), poOptionsTemp.bColourType == PPC_CUSTOM);
			
			// Òàéìàóò
			CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_POPUP, poOptionsTemp.bTimeoutType == PPT_POPUP);
			CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_PERMANENT, poOptionsTemp.bTimeoutType == PPT_PERMANENT);
			CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_CUSTOM, poOptionsTemp.bTimeoutType == PPT_CUSTOM);			
			SetDlgItemInt(hWnd, IDC_EDIT_TIMEOUT, poOptionsTemp.bTimeout, FALSE);
			EnableWindow(GetDlgItem(hWnd, IDC_EDIT_TIMEOUT), poOptionsTemp.bTimeoutType == PPT_CUSTOM);
			
			// Êëèê ëåâîé
			CheckDlgButton(hWnd, IDC_RADIO_LEFT_CLIPBOARD, poOptionsTemp.bLeftClick == 0);
			CheckDlgButton(hWnd, IDC_RADIO_LEFT_DISMISS, poOptionsTemp.bLeftClick == 1);
			// Êëèê ïðàâîé
			CheckDlgButton(hWnd, IDC_RADIO_RIGHT_CLIPBOARD, poOptionsTemp.bRightClick == 0);
			CheckDlgButton(hWnd, IDC_RADIO_RIGHT_DISMISS, poOptionsTemp.bRightClick == 1);
			PopupDialogLock = FALSE;
			return TRUE;
	}	
	
	case WM_COMMAND:
	{
		switch (LOWORD(wParam))
		{
			case IDC_RADIO_COLOURS_POPUP:	
			case IDC_RADIO_COLOURS_WINDOWS:
			case IDC_RADIO_COLOURS_CUSTOM:
				{
					if ((HIWORD(wParam) == BN_CLICKED))
					{
						if (IsDlgButtonChecked(hWnd, IDC_RADIO_COLOURS_POPUP))
							poOptionsTemp.bColourType = PPC_POPUP;
						else if (IsDlgButtonChecked(hWnd, IDC_RADIO_COLOURS_WINDOWS))
							poOptionsTemp.bColourType = PPC_WINDOWS;
						else if (IsDlgButtonChecked(hWnd, IDC_RADIO_COLOURS_CUSTOM))
							poOptionsTemp.bColourType = PPC_CUSTOM;

						EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_BACK), poOptionsTemp.bColourType == PPC_CUSTOM);
						EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_TEXT), poOptionsTemp.bColourType == PPC_CUSTOM);
						SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
					}
				}

		
			case IDC_RADIO_TIMEOUT_POPUP:
			case IDC_RADIO_TIMEOUT_PERMANENT:
			case IDC_RADIO_TIMEOUT_CUSTOM:
				{
					if ((HIWORD(wParam) == BN_CLICKED))
					{
						if (IsDlgButtonChecked(hWnd, IDC_RADIO_TIMEOUT_POPUP))
							poOptionsTemp.bTimeoutType = PPT_POPUP;
						else if (IsDlgButtonChecked(hWnd, IDC_RADIO_TIMEOUT_PERMANENT))
							poOptionsTemp.bTimeoutType = PPT_PERMANENT;
						if (IsDlgButtonChecked(hWnd, IDC_RADIO_TIMEOUT_CUSTOM))
							poOptionsTemp.bTimeoutType = PPT_CUSTOM;

						EnableWindow(GetDlgItem(hWnd, IDC_EDIT_TIMEOUT), poOptionsTemp.bTimeoutType == PPT_CUSTOM);
						SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
					}
					break;
				}	
				
			case IDC_RADIO_LEFT_CLIPBOARD:
			case IDC_RADIO_LEFT_DISMISS:
				{
					if ((HIWORD(wParam) == BN_CLICKED))
					{
						if (IsDlgButtonChecked(hWnd, IDC_RADIO_LEFT_CLIPBOARD))
							poOptionsTemp.bLeftClick = 0;
						else if (IsDlgButtonChecked(hWnd, IDC_RADIO_LEFT_DISMISS))
							poOptionsTemp.bLeftClick = 1;
						SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
					}
					break;
				}	
			
			case IDC_RADIO_RIGHT_CLIPBOARD:
			case IDC_RADIO_RIGHT_DISMISS:
				{
					if ((HIWORD(wParam) == BN_CLICKED))
					{
						if (IsDlgButtonChecked(hWnd, IDC_RADIO_RIGHT_CLIPBOARD))
							poOptionsTemp.bRightClick = 0;
						else if (IsDlgButtonChecked(hWnd, IDC_RADIO_RIGHT_DISMISS))
							poOptionsTemp.bRightClick = 1;
						SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
					}
					break;
				}	
				
			case IDC_CUSTOM_BACK:
			case IDC_CUSTOM_TEXT:
				{
					if (HIWORD(wParam) == CBN_SELCHANGE)
					{
						poOptionsTemp.crBackColour = SendDlgItemMessage(hWnd, IDC_CUSTOM_BACK, CPM_GETCOLOUR, 0, 0);
						poOptionsTemp.crTextColour = SendDlgItemMessage(hWnd, IDC_CUSTOM_TEXT, CPM_GETCOLOUR, 0, 0);
						SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);							
					}
					break;
				}
			case IDC_EDIT_TIMEOUT:
				{
					if (HIWORD(wParam) == EN_CHANGE)
					{
						dwTimeOut = GetDlgItemInt(hWnd, IDC_EDIT_TIMEOUT, NULL, FALSE);
						if (dwTimeOut>255)
							poOptionsTemp.bTimeout = 255;
						else 
							poOptionsTemp.bTimeout = dwTimeOut;

						if (!PopupDialogLock)
							SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
					}
					break;
				}

			case IDC_BUTTON_PREVIEW:
				{
					if ((HIWORD(wParam) == BN_CLICKED ))
					{
						ptszPopupPreviewText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
						
						pdtData.cbSize = sizeof(POPUPDATAT_V2);
						ZeroMemory(&pdtData, sizeof(pdtData));
						_tcsncpy(pdtData.lptzContactName, TranslateT(ModuleName), MAX_CONTACTNAME);
						_tcsncpy(pdtData.lptzText, _T("Ghbdtn? rfr ltkf&"), MAX_SECONDLINE);
		
						switch(poOptionsTemp.bColourType)
						{
							case PPC_POPUP:
								pdtData.colorBack = pdtData.colorText = 0;
								break;
							case PPC_WINDOWS:
								pdtData.colorBack = GetSysColor(COLOR_BTNFACE);
								pdtData.colorText = GetSysColor(COLOR_WINDOWTEXT);
								break;
							case PPC_CUSTOM:
								pdtData.colorBack = poOptionsTemp.crBackColour;
								pdtData.colorText = poOptionsTemp.crTextColour;
								break;
							default:
								break;
						}						
						switch(poOptionsTemp.bTimeoutType)
						{
						case PPT_POPUP:
							pdtData.iSeconds = 0;
							break;
						case PPT_PERMANENT:
							pdtData.iSeconds = -1;
							break;
						case PPC_CUSTOM:
							pdtData.iSeconds = poOptionsTemp.bTimeout;
							break;
						}
						_tcscpy(ptszPopupPreviewText, pdtData.lptzText);
						pdtData.PluginData = ptszPopupPreviewText;
						pdtData.lchIcon = hPopupIcon;
						poOptions.paActions[0].lchIcon = hCopyIcon;
						pdtData.lpActions = poOptions.paActions;
						pdtData.actionCount = 1;
						pdtData.PluginWindowProc = (WNDPROC)CKLPopupDlgProc;
						
						if (CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pdtData, APF_NEWDATA)<0)
							mir_free(ptszPopupPreviewText);
					}
					break;
				}

			default: 
				break;
	}
	break;
}
	
	case WM_NOTIFY:
	{		
		switch(((LPNMHDR)lParam)->idFrom)
		{
			case 0:
			{
				switch (((LPNMHDR)lParam)->code)
				{
					case PSN_APPLY:
					{
						poOptions = poOptionsTemp;
						WritePopupOptions();
						break;
					}
				}
				break;
			}
		}
		break;
	}

	case WM_DESTROY:
	{			
		break;
	}

	}
	return FALSE;
}