-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettingsDialog.c
42 lines (39 loc) · 1.09 KB
/
settingsDialog.c
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
#include "stdafx.h"
#include "settingsDialog.h"
#include "resource.h"
#include "Commctrl.h"
BOOL CALLBACK DialogProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void ChangeValue(HINSTANCE hInst, HWND hWnd, int* current)
{
DialogBoxParam(hInst, (LPCWSTR)IDD_PREFERENCES, hWnd, DialogProc, (LPARAM)current);
}
INT* editingValue;
INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_INITDIALOG:
editingValue = (INT*)lParam;
SendDlgItemMessage(hDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(100, 0));
SendDlgItemMessage(hDlg, IDC_SPIN1, UDM_SETPOS, 0, *editingValue);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
{
DWORD res = SendDlgItemMessage(hDlg, IDC_SPIN1, UDM_GETPOS, 0, *editingValue);
if(HIWORD(res)) return FALSE;
*editingValue = res;
EndDialog(hDlg, TRUE);
return TRUE;
}
case IDCANCEL:
EndDialog(hDlg, FALSE);
return TRUE;
}
break;
case WM_CLOSE:
EndDialog(hDlg, FALSE);
return TRUE;
}
return FALSE;
}