msvcr100: Use Context to store critical_section owner.
[wine.git] / programs / winemine / dialog.c
blob47412413381bb032d1c21587d408dfe9a97cac5d
1 /*
2 * WineMine (dialog.c)
4 * Copyright 2000 Joshua Thielen
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.
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.
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
21 #define WIN32_LEAN_AND_MEAN
23 #include <windows.h>
24 #include "main.h"
25 #include "resource.h"
27 INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
29 BOOL IsRet;
30 static BOARD *p_board;
32 switch( uMsg ) {
33 case WM_INITDIALOG:
34 p_board = (BOARD*) lParam;
35 SetDlgItemInt( hDlg, IDC_EDITROWS, p_board->rows, FALSE );
36 SetDlgItemInt( hDlg, IDC_EDITCOLS, p_board->cols, FALSE );
37 SetDlgItemInt( hDlg, IDC_EDITMINES, p_board->mines, FALSE );
38 return TRUE;
40 case WM_COMMAND:
41 switch( LOWORD( wParam ) ) {
42 case IDOK:
43 p_board->rows = GetDlgItemInt( hDlg, IDC_EDITROWS, &IsRet, FALSE );
44 p_board->cols = GetDlgItemInt( hDlg, IDC_EDITCOLS, &IsRet, FALSE );
45 p_board->mines = GetDlgItemInt( hDlg, IDC_EDITMINES, &IsRet, FALSE );
46 CheckLevel( p_board );
47 EndDialog( hDlg, 0 );
48 return TRUE;
50 case IDCANCEL:
51 EndDialog( hDlg, 1 );
52 return TRUE;
54 break;
56 return FALSE;
59 INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
61 static BOARD *p_board;
63 switch( uMsg ) {
64 case WM_INITDIALOG:
65 p_board = (BOARD*) lParam;
66 SetDlgItemTextW( hDlg, IDC_EDITNAME, p_board->best_name[p_board->difficulty] );
67 return TRUE;
69 case WM_COMMAND:
70 switch( LOWORD( wParam ) ) {
71 case IDOK:
72 GetDlgItemTextW( hDlg, IDC_EDITNAME, p_board->best_name[p_board->difficulty],
73 ARRAY_SIZE(p_board->best_name[p_board->difficulty] ));
74 EndDialog( hDlg, 0 );
75 return TRUE;
77 case IDCANCEL:
78 EndDialog( hDlg, 0 );
79 return TRUE;
81 break;
83 return FALSE;
86 INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
88 static BOARD *p_board;
89 unsigned i;
90 int confirm_msgbox_result;
91 WCHAR confirm_title[256], confirm_text[256];
93 switch( uMsg ) {
94 case WM_INITDIALOG:
95 p_board = (BOARD*) lParam;
97 /* set best names */
98 for( i = 0; i < 3; i++ )
99 SetDlgItemTextW( hDlg, (IDC_NAME1) + i, p_board->best_name[i] );
101 /* set best times */
102 for( i = 0; i < 3; i++ )
103 SetDlgItemInt( hDlg, (IDC_TIME1) + i, p_board->best_time[i], FALSE );
104 return TRUE;
106 case WM_COMMAND:
107 switch( LOWORD( wParam ) ) {
108 case IDC_RESET:
109 LoadStringW( NULL, IDC_CONFIRMTITLE, confirm_title, ARRAY_SIZE(confirm_title));
110 LoadStringW( NULL, IDC_CONFIRMTEXT, confirm_text, ARRAY_SIZE(confirm_text));
111 confirm_msgbox_result = MessageBoxW( hDlg, confirm_text, confirm_title, MB_OKCANCEL | MB_DEFBUTTON2 | MB_ICONWARNING );
112 if( confirm_msgbox_result != IDOK )
113 break;
115 /* reset best names and times */
116 ResetResults( p_board );
118 /* save to registry */
119 SaveBoard( p_board );
121 /* update dialog */
122 for( i = 0; i < 3; i++ ) {
123 SetDlgItemTextW( hDlg, (IDC_NAME1) + i, p_board->best_name[i] );
124 SetDlgItemInt( hDlg, (IDC_TIME1) + i, p_board->best_time[i], FALSE );
126 break;
128 case IDOK:
129 case IDCANCEL:
130 EndDialog( hDlg, 0 );
131 return TRUE;
133 break;
135 return FALSE;