[KERNEL32]
[reactos.git] / base / applications / games / winmine / dialog.c
1 /*
2 * WineMine (dialog.c)
3 *
4 * Copyright 2000 Joshua Thielen
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #define WIN32_NO_STATUS
22 #include <stdarg.h>
23 #include <windef.h>
24
25 #include "main.h"
26 #include "resource.h"
27
28 INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
29 {
30 BOOL IsRet;
31 static BOARD *p_board;
32
33 switch( uMsg ) {
34 case WM_INITDIALOG:
35 p_board = (BOARD*) lParam;
36 SetDlgItemInt( hDlg, IDC_EDITROWS, p_board->rows, FALSE );
37 SetDlgItemInt( hDlg, IDC_EDITCOLS, p_board->cols, FALSE );
38 SetDlgItemInt( hDlg, IDC_EDITMINES, p_board->mines, FALSE );
39 return TRUE;
40
41 case WM_COMMAND:
42 switch( LOWORD( wParam ) ) {
43 case IDOK:
44 p_board->rows = GetDlgItemInt( hDlg, IDC_EDITROWS, &IsRet, FALSE );
45 p_board->cols = GetDlgItemInt( hDlg, IDC_EDITCOLS, &IsRet, FALSE );
46 p_board->mines = GetDlgItemInt( hDlg, IDC_EDITMINES, &IsRet, FALSE );
47 CheckLevel( p_board );
48 EndDialog( hDlg, 0 );
49 return TRUE;
50
51 case IDCANCEL:
52 EndDialog( hDlg, 1 );
53 return TRUE;
54 }
55 break;
56 }
57 return FALSE;
58 }
59
60 INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
61 {
62 static BOARD *p_board;
63
64 switch( uMsg ) {
65 case WM_INITDIALOG:
66 p_board = (BOARD*) lParam;
67 SetDlgItemText( hDlg, IDC_EDITNAME,
68 p_board->best_name[p_board->difficulty] );
69 return TRUE;
70
71 case WM_COMMAND:
72 switch( LOWORD( wParam ) ) {
73 case IDOK:
74 GetDlgItemText( hDlg, IDC_EDITNAME,
75 p_board->best_name[p_board->difficulty],
76 sizeof( p_board->best_name[p_board->difficulty] ) );
77 EndDialog( hDlg, 0 );
78 return TRUE;
79
80 case IDCANCEL:
81 EndDialog( hDlg, 0 );
82 return TRUE;
83 }
84 break;
85 }
86 return FALSE;
87 }
88
89 INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
90 {
91 static BOARD *p_board;
92 unsigned i;
93
94 switch( uMsg ) {
95 case WM_INITDIALOG:
96 p_board = (BOARD*) lParam;
97
98 /* set best names */
99 for( i = 0; i < 3; i++ )
100 SetDlgItemText( hDlg, (IDC_NAME1) + i, p_board->best_name[i] );
101
102 /* set best times */
103 for( i = 0; i < 3; i++ )
104 SetDlgItemInt( hDlg, (IDC_TIME1) + i, p_board->best_time[i], FALSE );
105 return TRUE;
106
107 case WM_COMMAND:
108 switch( LOWORD( wParam ) ) {
109 case IDOK:
110 case IDCANCEL:
111 EndDialog( hDlg, 0 );
112 return TRUE;
113 }
114 break;
115 }
116 return FALSE;
117 }