1 | #define OS2EMX_PLAIN_CHAR
|
---|
2 | // this is needed for "os2emx.h"; if this is defined,
|
---|
3 | // emx will define PSZ as _signed_ char, otherwise
|
---|
4 | // as unsigned char
|
---|
5 |
|
---|
6 | #define INCL_DOSPROCESS
|
---|
7 | #define INCL_DOSMISC
|
---|
8 | #define INCL_DOSERRORS
|
---|
9 |
|
---|
10 | #define INCL_WINWINDOWMGR
|
---|
11 | #define INCL_WINFRAMEMGR
|
---|
12 | #define INCL_WINMENUS
|
---|
13 | #define INCL_WINSTDFILE
|
---|
14 |
|
---|
15 | #include <os2.h>
|
---|
16 |
|
---|
17 | #include <stdlib.h>
|
---|
18 | #include <string.h>
|
---|
19 | #include <stdio.h>
|
---|
20 |
|
---|
21 | #include "setup.h" // code generation and debugging options
|
---|
22 |
|
---|
23 | #include "xwpapi.h"
|
---|
24 |
|
---|
25 | #include "helpers\call_file_dlg.c"
|
---|
26 | #include "helpers\winh.h"
|
---|
27 |
|
---|
28 | /*
|
---|
29 | *@@ NewWinFileDlg:
|
---|
30 | * replacement for WinFileDlg. Use similarly.
|
---|
31 | */
|
---|
32 |
|
---|
33 | HWND APIENTRY NewWinFileDlg(HWND hwndOwner,
|
---|
34 | PFILEDLG pfd) // WinFileDlg
|
---|
35 | {
|
---|
36 | HWND hwndReturn = NULLHANDLE;
|
---|
37 | BOOL fCallDefault = TRUE;
|
---|
38 |
|
---|
39 | hwndReturn = ImplCallFileDlg(hwndOwner, pfd, &fCallDefault);
|
---|
40 |
|
---|
41 | if (fCallDefault)
|
---|
42 | // something went wrong:
|
---|
43 | hwndReturn = WinFileDlg(HWND_DESKTOP,
|
---|
44 | hwndOwner,
|
---|
45 | pfd);
|
---|
46 |
|
---|
47 | return (hwndReturn);
|
---|
48 | }
|
---|
49 |
|
---|
50 | /*
|
---|
51 | *@@ ShowFileDlg:
|
---|
52 | *
|
---|
53 | */
|
---|
54 |
|
---|
55 | VOID ShowFileDlg(HWND hwndFrame)
|
---|
56 | {
|
---|
57 | FILEDLG fd;
|
---|
58 |
|
---|
59 | memset(&fd, 0, sizeof(FILEDLG));
|
---|
60 | fd.cbSize = sizeof(FILEDLG);
|
---|
61 | fd.fl = FDS_CENTER | FDS_OPEN_DIALOG;
|
---|
62 |
|
---|
63 | strcpy(fd.szFullFile, "C:\\*");
|
---|
64 |
|
---|
65 | if (NewWinFileDlg(hwndFrame,
|
---|
66 | &fd))
|
---|
67 | {
|
---|
68 | CHAR sz[1000];
|
---|
69 | sprintf(sz, "got: \"%s\"", fd.szFullFile);
|
---|
70 | WinMessageBox(HWND_DESKTOP, hwndFrame,
|
---|
71 | sz,
|
---|
72 | "File:",
|
---|
73 | 0,
|
---|
74 | MB_OK | MB_MOVEABLE);
|
---|
75 | }
|
---|
76 | else
|
---|
77 | WinMessageBox(HWND_DESKTOP, hwndFrame,
|
---|
78 | "file dlg returned FALSE",
|
---|
79 | "File:",
|
---|
80 | 0,
|
---|
81 | MB_OK | MB_MOVEABLE);
|
---|
82 | }
|
---|
83 |
|
---|
84 | /*
|
---|
85 | *@@ main:
|
---|
86 | *
|
---|
87 | */
|
---|
88 |
|
---|
89 | int main(int argc, char *argv[])
|
---|
90 | {
|
---|
91 | HAB hab;
|
---|
92 | HMQ hmq;
|
---|
93 |
|
---|
94 | ULONG flFrame = FCF_TITLEBAR
|
---|
95 | | FCF_SYSMENU
|
---|
96 | | FCF_MINMAX
|
---|
97 | | FCF_SIZEBORDER
|
---|
98 | | FCF_NOBYTEALIGN
|
---|
99 | | FCF_SHELLPOSITION
|
---|
100 | | FCF_TASKLIST;
|
---|
101 |
|
---|
102 | HWND hwndFrame,
|
---|
103 | hwndClient,
|
---|
104 | hwndMenu,
|
---|
105 | hwndSubmenu;
|
---|
106 | QMSG qmsg;
|
---|
107 |
|
---|
108 | hab = WinInitialize(0);
|
---|
109 | hmq = WinCreateMsgQueue(hab, 0);
|
---|
110 |
|
---|
111 | hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
|
---|
112 | WS_VISIBLE,
|
---|
113 | &flFrame,
|
---|
114 | NULL,
|
---|
115 | "Test File Dialog",
|
---|
116 | WS_VISIBLE,
|
---|
117 | 0,
|
---|
118 | 0,
|
---|
119 | &hwndClient);
|
---|
120 |
|
---|
121 | hwndMenu = WinCreateMenu(hwndFrame,
|
---|
122 | NULL);
|
---|
123 |
|
---|
124 | hwndSubmenu = winhInsertSubmenu(hwndMenu,
|
---|
125 | MIT_END,
|
---|
126 | 1,
|
---|
127 | "~File",
|
---|
128 | MIS_TEXT | MIS_SUBMENU,
|
---|
129 | 1000,
|
---|
130 | "~Show dialog",
|
---|
131 | MIS_TEXT,
|
---|
132 | 0);
|
---|
133 |
|
---|
134 | winhInsertMenuItem(hwndSubmenu,
|
---|
135 | MIT_END,
|
---|
136 | SC_CLOSE,
|
---|
137 | "~Close",
|
---|
138 | MIS_SYSCOMMAND | MIS_TEXT,
|
---|
139 | 0);
|
---|
140 |
|
---|
141 | WinSendMsg(hwndFrame, WM_UPDATEFRAME, MPNULL, MPNULL);
|
---|
142 |
|
---|
143 | while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
|
---|
144 | {
|
---|
145 | BOOL fDispatch = TRUE;
|
---|
146 |
|
---|
147 | if (qmsg.hwnd == hwndFrame)
|
---|
148 | {
|
---|
149 | switch (qmsg.msg)
|
---|
150 | {
|
---|
151 | case WM_COMMAND:
|
---|
152 | if (SHORT1FROMMP(qmsg.mp1) == 1000)
|
---|
153 | {
|
---|
154 | ShowFileDlg(hwndFrame);
|
---|
155 | fDispatch = FALSE;
|
---|
156 | }
|
---|
157 | break;
|
---|
158 | }
|
---|
159 | }
|
---|
160 |
|
---|
161 | if (fDispatch)
|
---|
162 | WinDispatchMsg(hab, &qmsg);
|
---|
163 | }
|
---|
164 |
|
---|
165 | WinDestroyMsgQueue(hmq);
|
---|
166 | WinTerminate(hab);
|
---|
167 |
|
---|
168 | return (0);
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|