4 * Copyright 2000 Joshua Thielen <jt85296@ltu.edu>
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 Street, Fifth Floor, Boston, MA 02110-1301 USA
27 INT_PTR CALLBACK
CustomDlgProc( HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
34 pBoard
= (BOARD
*) lParam
;
35 SetDlgItemInt( hDlg
, IDC_EDITROWS
, pBoard
->uRows
, FALSE
);
36 SetDlgItemInt( hDlg
, IDC_EDITCOLS
, pBoard
->uCols
, FALSE
);
37 SetDlgItemInt( hDlg
, IDC_EDITMINES
, pBoard
->uMines
, FALSE
);
41 switch( LOWORD( wParam
) )
44 pBoard
->uRows
= GetDlgItemInt( hDlg
, IDC_EDITROWS
, NULL
, FALSE
);
45 pBoard
->uCols
= GetDlgItemInt( hDlg
, IDC_EDITCOLS
, NULL
, FALSE
);
46 pBoard
->uMines
= GetDlgItemInt( hDlg
, IDC_EDITMINES
, NULL
, FALSE
);
50 EndDialog( hDlg
, LOWORD(wParam
) );
59 INT_PTR CALLBACK
CongratsDlgProc( HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
66 pBoard
= (BOARD
*) lParam
;
67 SetDlgItemText( hDlg
, IDC_EDITNAME
, pBoard
->szBestName
[pBoard
->Difficulty
] );
71 switch( LOWORD(wParam
) )
74 GetDlgItemText( hDlg
, IDC_EDITNAME
,
75 pBoard
->szBestName
[pBoard
->Difficulty
],
76 sizeof( pBoard
->szBestName
[pBoard
->Difficulty
] ) );
89 INT_PTR CALLBACK
TimesDlgProc( HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
103 pBoard
= (BOARD
*) lParam
;
106 for( i
= 0; i
< 3; i
++ )
107 SetDlgItemText( hDlg
, (IDC_NAME1
) + i
, pBoard
->szBestName
[i
] );
110 LoadString( pBoard
->hInst
, IDS_SECONDS
, szSeconds
, sizeof(szSeconds
) / sizeof(TCHAR
) );
112 for( i
= 0; i
< 3; i
++ )
114 wsprintf(szTimes
, TEXT("%d %s"), pBoard
->uBestTime
[i
], szSeconds
);
115 SetDlgItemText( hDlg
, (IDC_TIME1
) + i
, szTimes
);
121 switch( LOWORD( wParam
) )
125 EndDialog( hDlg
, 0 );
129 if( RegCreateKeyEx( HKEY_CURRENT_USER
, szWineMineRegKey
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
132 LoadString( pBoard
->hInst
, IDS_NOBODY
, szNobody
, sizeof(szNobody
) / sizeof(TCHAR
) );
133 LoadString( pBoard
->hInst
, IDS_SECONDS
, szSeconds
, sizeof(szSeconds
) / sizeof(TCHAR
) );
135 for (i
= 0; i
< 3; i
++)
137 pBoard
->uBestTime
[i
] = 999;
138 _tcscpy(pBoard
->szBestName
[i
], szNobody
);
139 wsprintf(szTimes
, TEXT("%d %s"), pBoard
->uBestTime
[i
], szSeconds
);
141 SetDlgItemText( hDlg
, (IDC_NAME1
) + i
, pBoard
->szBestName
[i
] );
142 SetDlgItemText( hDlg
, (IDC_TIME1
) + i
, szTimes
);
145 /* Write the changes to the registry
146 As we write to the same registry key as MS WinMine does, we have to start at 1 for the registry keys */
147 for( i
= 0; i
< 3; i
++ )
149 wsprintf( szKeyName
, TEXT("Name%u"), i
+ 1 );
150 _tcsncpy( szData
, pBoard
->szBestName
[i
], sizeof(szData
) / sizeof(TCHAR
) );
151 RegSetValueEx( hKey
, szKeyName
, 0, REG_SZ
, (LPBYTE
)szData
, (_tcslen(szData
) + 1) * sizeof(TCHAR
) );
154 for( i
= 0; i
< 3; i
++ )
156 wsprintf( szKeyName
, TEXT("Time%u"), i
+ 1 );
157 RegSetValueEx( hKey
, szKeyName
, 0, REG_DWORD
, (LPBYTE
)&pBoard
->uBestTime
[i
], sizeof(DWORD
) );