| 307 | } |
| 308 | |
| 309 | BOOL CALLBACK |
| 310 | PlayerSelectorDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
| 311 | { |
| 312 | struct plsel_data *data; |
| 313 | RECT main_rt, dlg_rt; |
| 314 | SIZE dlg_sz; |
| 315 | |
| 316 | switch (message) { |
| 317 | case WM_INITDIALOG: |
| 318 | data = (struct plsel_data *) lParam; |
| 319 | SetWindowLong(hWnd, GWL_USERDATA, lParam); |
| 320 | |
| 321 | /* center dialog in the main window */ |
| 322 | GetWindowRect(GetNHApp()->hMainWnd, &main_rt); |
| 323 | GetWindowRect(hWnd, &dlg_rt); |
| 324 | dlg_sz.cx = dlg_rt.right - dlg_rt.left; |
| 325 | dlg_sz.cy = dlg_rt.bottom - dlg_rt.top; |
| 326 | |
| 327 | dlg_rt.left = (main_rt.left + main_rt.right - dlg_sz.cx) / 2; |
| 328 | dlg_rt.right = dlg_rt.left + dlg_sz.cx; |
| 329 | dlg_rt.top = (main_rt.top + main_rt.bottom - dlg_sz.cy) / 2; |
| 330 | dlg_rt.bottom = dlg_rt.top + dlg_sz.cy; |
| 331 | MoveWindow(hWnd, (main_rt.left + main_rt.right - dlg_sz.cx) / 2, |
| 332 | (main_rt.top + main_rt.bottom - dlg_sz.cy) / 2, dlg_sz.cx, |
| 333 | dlg_sz.cy, TRUE); |
| 334 | |
| 335 | /* init dialog */ |
| 336 | plselInitDialog(hWnd); |
| 337 | |
| 338 | #if defined(WIN_CE_SMARTPHONE) |
| 339 | NHSPhoneDialogSetup(hWnd, IDC_SPHONE_DIALOGBAR, FALSE, FALSE); |
| 340 | #endif |
| 341 | /* set focus on the role checkbox (random) field */ |
| 342 | SetFocus(GetDlgItem(hWnd, IDC_PLSEL_ROLE_RANDOM)); |
| 343 | |
| 344 | /* tell windows we set the focus */ |
| 345 | return FALSE; |
| 346 | break; |
| 347 | |
| 348 | case WM_COMMAND: |
| 349 | data = (struct plsel_data *) GetWindowLong(hWnd, GWL_USERDATA); |
| 350 | switch (LOWORD(wParam)) { |
| 351 | /* OK button was clicked */ |
| 352 | case IDOK: |
| 353 | if (plselFinalSelection(hWnd, data->selection)) { |
| 354 | EndDialog(hWnd, wParam); |
| 355 | } else { |
| 356 | MessageBox( |
| 357 | hWnd, TEXT("Cannot match this role. Try something else."), |
| 358 | TEXT("STOP"), MB_OK); |
| 359 | } |
| 360 | return TRUE; |
| 361 | |
| 362 | /* CANCEL button was clicked */ |
| 363 | case IDCANCEL: |
| 364 | *data->selection = -1; |
| 365 | EndDialog(hWnd, wParam); |
| 366 | return TRUE; |
nothing calls this directly
no test coverage detected