source: trunk/dll/winlist.c@ 1570

Last change on this file since 1570 was 1400, checked in by Gregg Young, 16 years ago

Remainder of changes to rename commafmt.h/c (Ticket 28, 82); Additional strings moved to PCSZs in init.c (Ticket 6); Added WriteDetailsSwitches used it and LoadDetailsSwitches to consolidate inline code (Ticket 343, 344)

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