source: trunk/dll/winlist.c@ 689

Last change on this file since 689 was 551, checked in by Gregg Young, 19 years ago

Indentation cleanup

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