source: golgotha/src/i4/video/win32/display_dialog.cc

Last change on this file was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 3.0 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include <windows.h>
10#include "video/display_dialog.hh"
11#include "video/win32/resource.h"
12#include "main/win_main.hh"
13
14static int i4_choices_t_picks;
15
16BOOL FAR PASCAL displayDlgProc(HWND hDlg,DWORD dwMessage,DWORD wParam,DWORD lParam)
17{
18  int         result, ctrlMsg, i;
19  static int  busy;
20
21
22  switch(dwMessage)
23  {
24    case WM_INITDIALOG:
25    {
26      char **picks=(char **)lParam;
27      int t_picks=0; 
28      while (picks[t_picks]) t_picks++;
29      i4_choices_t_picks=t_picks;
30      busy=0;
31
32
33      for(i=0; picks[i]; i++)
34      {
35        CreateWindowEx(WS_EX_NOPARENTNOTIFY,
36                       "BUTTON",
37                       picks[i],
38                       (WS_CHILD|BS_AUTORADIOBUTTON|WS_VISIBLE|((i==0)? WS_GROUP|WS_TABSTOP : 0)),
39                       20,      // horizontal position of window
40                       10+(i*16),       // vertical position of window
41                       300,     // window width
42                       12,      // window height
43                       hDlg,    // handle to parent or owner window
44                       (HMENU)(i+69),   // child-window identifier
45                       i4_win32_instance, // handle to application instance
46                       (LPVOID)NULL); // pointer to window-creation data
47      }
48
49
50      SetFocus( GetDlgItem(hDlg, 69) );
51      CheckDlgButton(hDlg, 69, 1);  //check the first one as a default
52
53      //return 0 here indicating we have set the focus for the dialog box
54      //and it doesn't need to help us
55      return 0;
56    }
57
58    case WM_SETCURSOR:
59      if(busy)
60      {
61        SetCursor(LoadCursor(NULL, IDC_WAIT));
62        return TRUE;
63      }
64      break;
65     
66    case WM_COMMAND:
67      ctrlMsg=HIWORD(wParam);
68      switch(LOWORD(wParam))
69      {
70        case IDOK:
71          if(busy > 0) break;
72          else if(ctrlMsg==STN_CLICKED)
73          {
74            for(i=0; i<i4_choices_t_picks; i++)
75              if(IsDlgButtonChecked(hDlg, (i+69))==1) break;
76
77            if (i==i4_choices_t_picks) i=-1;
78
79            EndDialog(hDlg, i);
80          }
81          break;
82           
83        case IDCANCEL:
84          if(!busy && ctrlMsg==STN_CLICKED)
85            EndDialog( hDlg, -1 );
86          break;
87      }
88  }
89  return 0;
90}
91
92
93int i4_system_choose_option(char **choices)
94{
95  return DialogBoxParam(i4_win32_instance,
96                        MAKEINTRESOURCE(101),
97                        NULL,
98                        (DLGPROC)displayDlgProc,
99                        (long)choices );
100}
Note: See TracBrowser for help on using the repository browser.