source: trunk/dll/winlist.c@ 1162

Last change on this file since 1162 was 1162, checked in by John Small, 17 years ago

Ticket 187: Draft 1: Functions only

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1
2/***********************************************************************
3
4 $Id: winlist.c 1162 2008-09-05 21:43:09Z jbs $
5
6 Window List Dialog
7
8 Copyright (c) 1993-97 M. Kimes
9 Copyright (c) 2005, 2006 Steven H.Levine
10
11 23 May 05 SHL Use QWL_USER
12 22 Jul 06 SHL Check more run time errors
13 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
14
15***********************************************************************/
16
17#include <stdlib.h>
18#include <string.h>
19
20#define INCL_DOS
21#define INCL_WIN
22
23#include "fm3dlg.h"
24#include "fm3dll.h"
25#include "winlist.h"
26#include "fortify.h"
27
28#pragma data_seg(DATA1)
29
30static PSZ pszSrcFile = __FILE__;
31
32
33MRESULT EXPENTRY WinListDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
34{
35 SHORT sSelect;
36
37 static HWND Me = (HWND) 0;
38
39 switch (msg) {
40 case WM_INITDLG:
41 if (Me || !mp2) {
42 if (Me)
43 PostMsg(Me, UM_FOCUSME, MPVOID, MPVOID);
44 WinDismissDlg(hwnd, 0);
45 }
46 else {
47
48 HENUM henum;
49 HWND hwndChild;
50 USHORT id;
51 CHAR wtext[CCHMAXPATH + 1];
52
53 Me = hwnd;
54 WinSetWindowULong(hwnd, QWL_USER, *(HWND *) mp2);
55 henum = WinBeginEnumWindows(*(HWND *) mp2);
56 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
57 id = WinQueryWindowUShort(hwndChild, QWS_ID);
58 if (!id)
59 continue;
60 *wtext = ' ';
61 WinQueryWindowText(hwndChild, CCHMAXPATH, wtext + 1);
62 wtext[CCHMAXPATH] = 0;
63 sSelect =
64 (SHORT) WinSendDlgItemMsg(hwnd, WLIST_LISTBOX, LM_INSERTITEM,
65 MPFROM2SHORT(LIT_SORTASCENDING, 0),
66 MPFROMP(wtext));
67 if (sSelect >= 0)
68 WinSendDlgItemMsg(hwnd, WLIST_LISTBOX, LM_SETITEMHANDLE,
69 MPFROM2SHORT(sSelect, 0),
70 MPFROMLONG((ULONG) hwndChild));
71 }
72 WinEndEnumWindows(henum);
73
74 {
75 PSWBLOCK pswb;
76 ULONG ulSize, ulcEntries;
77 register INT i, y;
78
79 /* Get the switch list information */
80 ulcEntries = WinQuerySwitchList(0, NULL, 0);
81 ulSize = sizeof(SWBLOCK) + sizeof(HSWITCH) + (ulcEntries + 4) *
82 (LONG) sizeof(SWENTRY);
83 /* Allocate memory for list */
84 pswb = xmalloc((unsigned)ulSize, pszSrcFile, __LINE__);
85 if (pswb) {
86 /* Put the info in the list */
87 ulcEntries = WinQuerySwitchList(0, pswb, ulSize - sizeof(SWENTRY));
88 /* do the dirty deed */
89 y = 0;
90 for (i = 0; i < pswb->cswentry; i++) {
91 if (pswb->aswentry[i].swctl.uchVisibility == SWL_VISIBLE &&
92 pswb->aswentry[i].swctl.fbJump == SWL_JUMPABLE &&
93 ((pswb->aswentry[i].swctl.idProcess == mypid &&
94 (strnicmp(pswb->aswentry[i].swctl.szSwtitle,
95 "FM/2", 4))) ||
96 !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "AV/2", 4) ||
97 !stricmp(pswb->aswentry[i].swctl.szSwtitle, "File Manager/2")
98 || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "Collector")
99 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VTree", 5)
100 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VDir", 4)
101 || (!strnicmp(pswb->aswentry[i].swctl.szSwtitle, FM2Str, 4)
102 && strnicmp(pswb->aswentry[i].swctl.szSwtitle, "FM/2",
103 4)))) {
104 *wtext = '*';
105 wtext[1] = 0;
106 strcat(wtext, pswb->aswentry[i].swctl.szSwtitle);
107 wtext[CCHMAXPATH] = 0;
108 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
109 WLIST_LISTBOX,
110 LM_INSERTITEM,
111 MPFROM2SHORT
112 (LIT_SORTASCENDING, 0),
113 MPFROMP(wtext));
114 if (sSelect >= 0)
115 WinSendDlgItemMsg(hwnd,
116 WLIST_LISTBOX,
117 LM_SETITEMHANDLE,
118 MPFROM2SHORT(sSelect, 0),
119 MPFROMLONG(pswb->aswentry[i].swctl.hwnd));
120 }
121 y++;
122 }
123 free(pswb);
124 DosPostEventSem(CompactSem);
125 }
126 }
127
128 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
129 WLIST_LISTBOX,
130 LM_QUERYITEMCOUNT, MPVOID, MPVOID);
131 if (sSelect <= 0)
132 WinDismissDlg(hwnd, 0);
133 }
134 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
135 break;
136
137 case UM_FOCUSME:
138 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
139 return 0;
140
141 case UM_SETUP:
142 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
143 return 0;
144
145 case UM_SETUP2:
146 PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
147 return 0;
148
149 case UM_SETUP3:
150 WinSetActiveWindow(HWND_DESKTOP, hwnd);
151 return 0;
152
153 case WM_CONTROL:
154 switch (SHORT1FROMMP(mp1)) {
155 case WLIST_LISTBOX:
156 switch (SHORT2FROMMP(mp1)) {
157 case LN_ENTER:
158 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
159 break;
160 }
161 break;
162 }
163 return 0;
164
165 case WM_COMMAND:
166 switch (SHORT1FROMMP(mp1)) {
167 case WLIST_MINIMIZE:
168 case WLIST_CLOSE:
169 case DID_OK:
170 {
171 HWND hwndActive = (HWND) WinQueryWindowULong(hwnd, QWL_USER);
172
173 hwndActive = WinQueryActiveWindow(hwndActive);
174 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
175 WLIST_LISTBOX,
176 LM_QUERYSELECTION,
177 MPFROM2SHORT(LIT_FIRST, 0),
178 MPVOID);
179 while (sSelect >= 0) {
180
181 HWND HwndC;
182
183 HwndC = (HWND) WinSendDlgItemMsg(hwnd,
184 WLIST_LISTBOX,
185 LM_QUERYITEMHANDLE,
186 MPFROM2SHORT(sSelect, 0), MPVOID);
187 if (HwndC) {
188
189 SWP swp;
190
191 WinQueryWindowPos(HwndC, &swp);
192 if (SHORT1FROMMP(mp1) == DID_OK) {
193 if (!(swp.fl & SWP_MINIMIZE) && (swp.cx == 0 || swp.cy == 0)) {
194 GetNextWindowPos((HWND) WinQueryWindowULong(hwnd, QWL_USER),
195 &swp, NULL, NULL);
196 WinSetWindowPos(HwndC, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
197 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER |
198 SWP_ACTIVATE | SWP_FOCUSACTIVATE);
199 }
200 else
201 WinSetWindowPos(HwndC, HWND_TOP, 0, 0, 0, 0,
202 SWP_RESTORE | SWP_SHOW | SWP_ZORDER |
203 SWP_ACTIVATE | SWP_FOCUSACTIVATE);
204 }
205 else if (SHORT1FROMMP(mp1) == WLIST_MINIMIZE) {
206 WinSetWindowPos(HwndC, HWND_BOTTOM, 0, 0, 0, 0,
207 SWP_MINIMIZE | SWP_DEACTIVATE |
208 SWP_FOCUSDEACTIVATE | SWP_ZORDER);
209 if (hwndActive == HwndC) {
210 WinSetWindowPos(WinWindowFromID(WinQueryWindow(hwndActive,
211 QW_PARENT),
212 TREE_FRAME), HWND_TOP, 0, 0,
213 0, 0,
214 SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE |
215 SWP_FOCUSACTIVATE | SWP_ZORDER);
216 hwndActive = (HWND) 0;
217 }
218 }
219 else if (WinQueryWindowUShort(HwndC, QWS_ID) != TREE_FRAME)
220 PostMsg(HwndC, WM_CLOSE, MPVOID, MPVOID);
221 }
222 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, WLIST_LISTBOX,
223 LM_QUERYSELECTION,
224 MPFROM2SHORT(sSelect, 0),
225 MPVOID);
226 }
227 }
228 WinDismissDlg(hwnd, 0);
229 break;
230
231 case IDM_HELP:
232 if (hwndHelp)
233 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
234 MPFROM2SHORT(HELP_WINLIST, 0), MPFROMSHORT(HM_RESOURCEID));
235 break;
236
237 case DID_CANCEL:
238 WinDismissDlg(hwnd, 0);
239 break;
240 }
241 return 0;
242
243 case WM_DESTROY:
244 if (Me == hwnd)
245 Me = (HWND) 0;
246 else
247 WinSetWindowPos(Me, HWND_TOP, 0, 0, 0, 0,
248 SWP_SHOW | SWP_RESTORE | SWP_ZORDER | SWP_ACTIVATE);
249 break;
250 }
251 return WinDefDlgProc(hwnd, msg, mp1, mp2);
252}
253
254VOID WindowList(HWND hwnd)
255{
256 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, WinListDlgProc, FM3ModHandle,
257 WLIST_FRAME, MPFROMP(&hwnd));
258}
259
260#pragma alloc_text(WINLIST,WindowList,WinListDlgProc)
Note: See TracBrowser for help on using the repository browser.