| 1 |
|
|---|
| 2 | /***********************************************************************
|
|---|
| 3 |
|
|---|
| 4 | $Id: chklist.c 347 2006-07-26 05:43:28Z root $
|
|---|
| 5 |
|
|---|
| 6 | Utility windows and mouse positioning
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
|---|
| 9 | Copyright (c) 2005, 2006 Steven H.Levine
|
|---|
| 10 |
|
|---|
| 11 | 10 Jan 05 SHL Allow DND_TARGET to hold CCHMAXPATH
|
|---|
| 12 | 14 Jul 06 SHL Use Runtime_Error
|
|---|
| 13 |
|
|---|
| 14 | ***********************************************************************/
|
|---|
| 15 |
|
|---|
| 16 | #define INCL_DOS
|
|---|
| 17 | #define INCL_WIN
|
|---|
| 18 | #define INCL_GPI
|
|---|
| 19 | #include <os2.h>
|
|---|
| 20 |
|
|---|
| 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 | #include "fm3str.h"
|
|---|
| 29 |
|
|---|
| 30 | #pragma data_seg(DATA1)
|
|---|
| 31 |
|
|---|
| 32 | static PSZ pszSrcFile = __FILE__;
|
|---|
| 33 |
|
|---|
| 34 | #pragma alloc_text(CHECKLIST,CheckListProc)
|
|---|
| 35 | #pragma alloc_text(DNDLIST,DropListProc)
|
|---|
| 36 | #pragma alloc_text(MISC7,PosOverOkay,CenterOverWindow,PopupMenu)
|
|---|
| 37 |
|
|---|
| 38 | VOID CenterOverWindow (HWND hwnd)
|
|---|
| 39 | {
|
|---|
| 40 | SWP swp;
|
|---|
| 41 | POINTL ptl;
|
|---|
| 42 |
|
|---|
| 43 | if(!fDontMoveMouse) {
|
|---|
| 44 | if(WinQueryWindowPos(hwnd,&swp)) {
|
|---|
| 45 | ptl.x = swp.x + (swp.cx / 2);
|
|---|
| 46 | ptl.y = swp.y + (swp.cy / 2);
|
|---|
| 47 | WinMapWindowPoints(WinQueryWindow(hwnd,QW_PARENT),HWND_DESKTOP,&ptl,1L);
|
|---|
| 48 | WinSetPointerPos(HWND_DESKTOP,ptl.x,ptl.y);
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | BOOL PopupMenu (HWND hwndParent,HWND hwndOwner,HWND hwndMenu)
|
|---|
| 55 | {
|
|---|
| 56 | POINTL ptl;
|
|---|
| 57 | BOOL rc;
|
|---|
| 58 |
|
|---|
| 59 | if(!WinQueryPointerPos(HWND_DESKTOP,&ptl))
|
|---|
| 60 | ptl.x = ptl.y = 32;
|
|---|
| 61 | WinMapWindowPoints(HWND_DESKTOP,hwndParent,&ptl,1L);
|
|---|
| 62 | rc = WinPopupMenu(hwndParent,hwndOwner,hwndMenu,
|
|---|
| 63 | ptl.x,ptl.y,0,
|
|---|
| 64 | PU_HCONSTRAIN | PU_VCONSTRAIN |
|
|---|
| 65 | PU_KEYBOARD | PU_MOUSEBUTTON1);
|
|---|
| 66 | if(rc)
|
|---|
| 67 | CenterOverWindow(hwndMenu);
|
|---|
| 68 | return rc;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | VOID PosOverOkay (HWND hwnd)
|
|---|
| 73 | {
|
|---|
| 74 | SWP swp;
|
|---|
| 75 | POINTL ptl;
|
|---|
| 76 |
|
|---|
| 77 | if(!fDontMoveMouse) {
|
|---|
| 78 | if(WinQueryWindowPos(WinWindowFromID(hwnd,DID_OK),&swp)) {
|
|---|
| 79 | ptl.x = swp.x + (swp.cx / 2);
|
|---|
| 80 | ptl.y = swp.y + (swp.cy / 2);
|
|---|
| 81 | WinMapWindowPoints(hwnd,HWND_DESKTOP,&ptl,1L);
|
|---|
| 82 | WinSetPointerPos(HWND_DESKTOP,ptl.x,ptl.y);
|
|---|
| 83 | }
|
|---|
| 84 | }
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 | MRESULT EXPENTRY CheckListProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
|
|---|
| 89 | {
|
|---|
| 90 | CHECKLIST *cl;
|
|---|
| 91 |
|
|---|
| 92 | switch(msg) {
|
|---|
| 93 | case WM_INITDLG:
|
|---|
| 94 | if(mp2) {
|
|---|
| 95 |
|
|---|
| 96 | SHORT x;
|
|---|
| 97 |
|
|---|
| 98 | WinSetWindowPtr(hwnd,0,(PVOID)mp2);
|
|---|
| 99 | cl = (CHECKLIST *)mp2;
|
|---|
| 100 | if(!cl->list || !cl->list[0]) {
|
|---|
| 101 | WinDismissDlg(hwnd,0);
|
|---|
| 102 | break;
|
|---|
| 103 | }
|
|---|
| 104 | WinSetDlgItemText(hwnd,CHECK_PROMPT,cl->prompt);
|
|---|
| 105 | for(x = 0;cl->list[x];x++) {
|
|---|
| 106 | WinSendDlgItemMsg(hwnd,CHECK_LISTBOX,LM_INSERTITEM,
|
|---|
| 107 | MPFROM2SHORT(LIT_END,0),
|
|---|
| 108 | MPFROMP(cl->list[x]));
|
|---|
| 109 | WinSendDlgItemMsg(hwnd,CHECK_LISTBOX,LM_SELECTITEM,
|
|---|
| 110 | MPFROM2SHORT(x,0),MPFROMSHORT(TRUE));
|
|---|
| 111 | }
|
|---|
| 112 | PosOverOkay(hwnd);
|
|---|
| 113 | WinEnableWindow(WinWindowFromID(hwnd,CHECK_INFO),
|
|---|
| 114 | ((cl->flags & CHECK_FILES) != 0));
|
|---|
| 115 | WinShowWindow(WinWindowFromID(hwnd,CHECK_INFO),
|
|---|
| 116 | ((cl->flags & CHECK_FILES) != 0));
|
|---|
| 117 | {
|
|---|
| 118 | HBITMAP hbm,hbmd,hbmdd;
|
|---|
| 119 | HPS hps;
|
|---|
| 120 |
|
|---|
| 121 | hps = WinGetPS(WinWindowFromID(hwnd,CHECK_BITMAP));
|
|---|
| 122 | hbm = GpiLoadBitmap(hps,0,cl->cmd,28,28);
|
|---|
| 123 | if(hbm) {
|
|---|
| 124 | hbmd = (HBITMAP)WinSendDlgItemMsg(hwnd,CHECK_BITMAP,SM_QUERYHANDLE,
|
|---|
| 125 | MPVOID,MPVOID);
|
|---|
| 126 | hbmdd = (HBITMAP)WinSendDlgItemMsg(hwnd,CHECK_BITMAP,SM_SETHANDLE,
|
|---|
| 127 | MPFROMLONG(hbm),MPVOID);
|
|---|
| 128 | if(hbmdd && hbmd && hbmd != hbmdd)
|
|---|
| 129 | GpiDeleteBitmap(hbmd);
|
|---|
| 130 | }
|
|---|
| 131 | if(hps)
|
|---|
| 132 | WinReleasePS(hps);
|
|---|
| 133 | WinSetWindowPos(WinWindowFromID(hwnd,CHECK_BITMAP),HWND_TOP,
|
|---|
| 134 | 0,0,28,28,SWP_SIZE);
|
|---|
| 135 | }
|
|---|
| 136 | }
|
|---|
| 137 | else
|
|---|
| 138 | WinDismissDlg(hwnd,0);
|
|---|
| 139 | break;
|
|---|
| 140 |
|
|---|
| 141 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 142 | PostMsg(hwnd,UM_SETDIR,MPVOID,MPVOID);
|
|---|
| 143 | break;
|
|---|
| 144 |
|
|---|
| 145 | case UM_SETDIR:
|
|---|
| 146 | PaintRecessedWindow(WinWindowFromID(hwnd,CHECK_HELP),(HPS)0,FALSE,TRUE);
|
|---|
| 147 | return 0;
|
|---|
| 148 |
|
|---|
| 149 | case WM_CONTROL:
|
|---|
| 150 | switch(SHORT1FROMMP(mp1)) {
|
|---|
| 151 | case CHECK_LISTBOX:
|
|---|
| 152 | switch(SHORT2FROMMP(mp1)) {
|
|---|
| 153 | case LN_ENTER:
|
|---|
| 154 | {
|
|---|
| 155 | SHORT x;
|
|---|
| 156 | CHAR szBuffer[CCHMAXPATH];
|
|---|
| 157 |
|
|---|
| 158 | x = (SHORT)WinSendDlgItemMsg(hwnd,CHECK_LISTBOX,
|
|---|
| 159 | LM_QUERYSELECTION,
|
|---|
| 160 | MPFROMSHORT(LIT_FIRST),MPVOID);
|
|---|
| 161 | if(x >= 0) {
|
|---|
| 162 | *szBuffer = 0;
|
|---|
| 163 | WinSendDlgItemMsg(hwnd,CHECK_LISTBOX,LM_QUERYITEMTEXT,
|
|---|
| 164 | MPFROM2SHORT(x,CCHMAXPATH),
|
|---|
| 165 | MPFROMP(szBuffer));
|
|---|
| 166 | if(*szBuffer)
|
|---|
| 167 | QuickView(hwnd,szBuffer);
|
|---|
| 168 | }
|
|---|
| 169 | }
|
|---|
| 170 | break;
|
|---|
| 171 | }
|
|---|
| 172 | break;
|
|---|
| 173 | }
|
|---|
| 174 | return 0;
|
|---|
| 175 |
|
|---|
| 176 | case WM_COMMAND:
|
|---|
| 177 | switch(SHORT1FROMMP(mp1)) {
|
|---|
| 178 | case CHECK_INFO:
|
|---|
| 179 | cl = INSTDATA(hwnd);
|
|---|
| 180 | if(cl)
|
|---|
| 181 | WinDlgBox(HWND_DESKTOP,hwnd,FileInfoProc,FM3ModHandle,
|
|---|
| 182 | FLE_FRAME,(PVOID)cl->list);
|
|---|
| 183 | break;
|
|---|
| 184 |
|
|---|
| 185 | case IDM_HELP:
|
|---|
| 186 | if(hwndHelp)
|
|---|
| 187 | WinSendMsg(hwndHelp,HM_DISPLAY_HELP,
|
|---|
| 188 | MPFROM2SHORT(HELP_CHECKLIST,0),
|
|---|
| 189 | MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 190 | break;
|
|---|
| 191 |
|
|---|
| 192 | case DID_OK:
|
|---|
| 193 | cl = INSTDATA(hwnd);
|
|---|
| 194 | if(cl) {
|
|---|
| 195 |
|
|---|
| 196 | CHAR szBuffer[CCHMAXPATH + 1];
|
|---|
| 197 | INT numfiles = 0,numalloc = 0,error;
|
|---|
| 198 | SHORT x;
|
|---|
| 199 |
|
|---|
| 200 | FreeList(cl->list);
|
|---|
| 201 | cl->list = NULL;
|
|---|
| 202 | x = (SHORT)WinSendDlgItemMsg(hwnd,CHECK_LISTBOX,LM_QUERYSELECTION,
|
|---|
| 203 | MPFROMSHORT(LIT_FIRST),MPVOID);
|
|---|
| 204 | if(x >= 0) {
|
|---|
| 205 | do {
|
|---|
| 206 | *szBuffer = 0;
|
|---|
| 207 | WinSendDlgItemMsg(hwnd,CHECK_LISTBOX,LM_QUERYITEMTEXT,
|
|---|
| 208 | MPFROM2SHORT(x,CCHMAXPATH),
|
|---|
| 209 | MPFROMP(szBuffer));
|
|---|
| 210 | if(*szBuffer) {
|
|---|
| 211 | error = AddToList(szBuffer,&cl->list,&numfiles,&numalloc);
|
|---|
| 212 | if(error) {
|
|---|
| 213 | Runtime_Error(pszSrcFile, __LINE__, "AddToList");
|
|---|
| 214 | break;
|
|---|
| 215 | }
|
|---|
| 216 | }
|
|---|
| 217 | x = (SHORT)WinSendDlgItemMsg(hwnd,CHECK_LISTBOX,
|
|---|
| 218 | LM_QUERYSELECTION,
|
|---|
| 219 | MPFROMSHORT(x),MPVOID);
|
|---|
| 220 | } while(x >= 0);
|
|---|
| 221 | }
|
|---|
| 222 | WinDismissDlg(hwnd,1);
|
|---|
| 223 | }
|
|---|
| 224 | else
|
|---|
| 225 | WinDismissDlg(hwnd,0);
|
|---|
| 226 | break;
|
|---|
| 227 |
|
|---|
| 228 | case DID_CANCEL:
|
|---|
| 229 | WinDismissDlg(hwnd,0);
|
|---|
| 230 | break;
|
|---|
| 231 | }
|
|---|
| 232 | return 0;
|
|---|
| 233 | }
|
|---|
| 234 | return WinDefDlgProc(hwnd,msg,mp1,mp2);
|
|---|
| 235 | }
|
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 | MRESULT EXPENTRY DropListProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
|
|---|
| 239 | {
|
|---|
| 240 | CHECKLIST *cl;
|
|---|
| 241 | static BOOL Shadow = FALSE,Wild = FALSE;
|
|---|
| 242 |
|
|---|
| 243 | switch(msg) {
|
|---|
| 244 | case WM_INITDLG:
|
|---|
| 245 | if(mp2) {
|
|---|
| 246 |
|
|---|
| 247 | SHORT x;
|
|---|
| 248 |
|
|---|
| 249 | WinSetWindowPtr(hwnd,0,(PVOID)mp2);
|
|---|
| 250 | cl = (CHECKLIST *)mp2;
|
|---|
| 251 | if(!cl->list || !cl->list[0]) {
|
|---|
| 252 | WinDismissDlg(hwnd,0);
|
|---|
| 253 | break;
|
|---|
| 254 | }
|
|---|
| 255 | if(IsRoot(cl->list[0])) {
|
|---|
| 256 | WinDismissDlg(hwnd,DND_COMPARE);
|
|---|
| 257 | break;
|
|---|
| 258 | }
|
|---|
| 259 | WinSendDlgItemMsg(hwnd,DND_LISTBOX,LM_DELETEALL,MPVOID,MPVOID);
|
|---|
| 260 | for(x = 0;cl->list[x];x++) {
|
|---|
| 261 | WinSendDlgItemMsg(hwnd,DND_LISTBOX,LM_INSERTITEM,
|
|---|
| 262 | MPFROM2SHORT(LIT_END,0),
|
|---|
| 263 | MPFROMP(cl->list[x]));
|
|---|
| 264 | WinSendDlgItemMsg(hwnd,DND_LISTBOX,LM_SELECTITEM,
|
|---|
| 265 | MPFROM2SHORT(x,0),MPFROMSHORT(TRUE));
|
|---|
| 266 | }
|
|---|
| 267 | WinSendDlgItemMsg(hwnd,DND_TARGET,EM_SETTEXTLIMIT, (MPARAM)CCHMAXPATH,(MPARAM)0);
|
|---|
| 268 | PostMsg(hwnd,UM_UNDO,MPVOID,MPVOID);
|
|---|
| 269 | }
|
|---|
| 270 | else
|
|---|
| 271 | WinDismissDlg(hwnd,0);
|
|---|
| 272 | break;
|
|---|
| 273 |
|
|---|
| 274 | case UM_UNDO:
|
|---|
| 275 | cl = INSTDATA(hwnd);
|
|---|
| 276 | if(cl) {
|
|---|
| 277 |
|
|---|
| 278 | CHAR *p;
|
|---|
| 279 |
|
|---|
| 280 | WinSetDlgItemText(hwnd,DND_TARGET,cl->prompt);
|
|---|
| 281 | WinEnableWindow(WinWindowFromID(hwnd,DND_LAUNCH),
|
|---|
| 282 | (IsExecutable(cl->prompt)));
|
|---|
| 283 | WinEnableWindow(WinWindowFromID(hwnd,DND_COPY),TRUE);
|
|---|
| 284 | WinEnableWindow(WinWindowFromID(hwnd,DND_MOVE),TRUE);
|
|---|
| 285 | WinEnableWindow(WinWindowFromID(hwnd,DND_RENAME),TRUE);
|
|---|
| 286 | WinEnableWindow(WinWindowFromID(hwnd,DND_OBJECT),TRUE);
|
|---|
| 287 | WinEnableWindow(WinWindowFromID(hwnd,DND_SHADOW),TRUE);
|
|---|
| 288 | WinEnableWindow(WinWindowFromID(hwnd,DND_EXTRACT),TRUE);
|
|---|
| 289 | WinEnableWindow(WinWindowFromID(hwnd,DND_SETICON),FALSE);
|
|---|
| 290 | p = strrchr(cl->list[0],'.');
|
|---|
| 291 | if(p) {
|
|---|
| 292 | p++;
|
|---|
| 293 | if(!stricmp(p,"ICO") || !stricmp(p,"PTR"))
|
|---|
| 294 | WinEnableWindow(WinWindowFromID(hwnd,DND_SETICON),TRUE);
|
|---|
| 295 | }
|
|---|
| 296 | if(IsFile(cl->prompt)) {
|
|---|
| 297 | WinEnableWindow(WinWindowFromID(hwnd,DND_OBJECT),FALSE);
|
|---|
| 298 | WinEnableWindow(WinWindowFromID(hwnd,DND_SHADOW),FALSE);
|
|---|
| 299 | WinEnableWindow(WinWindowFromID(hwnd,DND_EXTRACT),FALSE);
|
|---|
| 300 | WinEnableWindow(WinWindowFromID(hwnd,DND_RENAME),FALSE);
|
|---|
| 301 | }
|
|---|
| 302 | else {
|
|---|
| 303 |
|
|---|
| 304 | ARC_TYPE *info;
|
|---|
| 305 |
|
|---|
| 306 | info = find_type(cl->list[0],NULL);
|
|---|
| 307 | if(!info)
|
|---|
| 308 | WinEnableWindow(WinWindowFromID(hwnd,DND_EXTRACT),FALSE);
|
|---|
| 309 | }
|
|---|
| 310 | if(Shadow)
|
|---|
| 311 | WinCheckButton(hwnd,DND_SHADOW,TRUE);
|
|---|
| 312 | if(Wild)
|
|---|
| 313 | WinCheckButton(hwnd,DND_RENAME,TRUE);
|
|---|
| 314 | PostMsg(hwnd,UM_SETUP,MPVOID,MPVOID);
|
|---|
| 315 | if(cl->prompt && isalpha(*cl->prompt) &&
|
|---|
| 316 | (driveflags[toupper(*cl->prompt) - 'A'] & DRIVE_NOTWRITEABLE)) {
|
|---|
| 317 | WinEnableWindow(WinWindowFromID(hwnd,DND_COPY),FALSE);
|
|---|
| 318 | WinEnableWindow(WinWindowFromID(hwnd,DND_MOVE),FALSE);
|
|---|
| 319 | WinEnableWindow(WinWindowFromID(hwnd,DND_RENAME),FALSE);
|
|---|
| 320 | WinEnableWindow(WinWindowFromID(hwnd,DND_OBJECT),FALSE);
|
|---|
| 321 | WinEnableWindow(WinWindowFromID(hwnd,DND_SHADOW),FALSE);
|
|---|
| 322 | WinEnableWindow(WinWindowFromID(hwnd,DND_EXTRACT),FALSE);
|
|---|
| 323 | }
|
|---|
| 324 | if(cl->prompt && IsFile(cl->prompt) == 1) {
|
|---|
| 325 |
|
|---|
| 326 | ARC_TYPE *info;
|
|---|
| 327 |
|
|---|
| 328 | info = find_type(cl->prompt,NULL);
|
|---|
| 329 | if(!info) {
|
|---|
| 330 | WinEnableWindow(WinWindowFromID(hwnd,DND_COPY),FALSE);
|
|---|
| 331 | WinEnableWindow(WinWindowFromID(hwnd,DND_MOVE),FALSE);
|
|---|
| 332 | WinEnableWindow(WinWindowFromID(hwnd,DND_RENAME),FALSE);
|
|---|
| 333 | WinEnableWindow(WinWindowFromID(hwnd,DND_OBJECT),FALSE);
|
|---|
| 334 | WinEnableWindow(WinWindowFromID(hwnd,DND_SHADOW),FALSE);
|
|---|
| 335 | WinEnableWindow(WinWindowFromID(hwnd,DND_EXTRACT),FALSE);
|
|---|
| 336 | }
|
|---|
| 337 | }
|
|---|
| 338 | }
|
|---|
| 339 | break;
|
|---|
| 340 |
|
|---|
| 341 | case UM_SETUP:
|
|---|
| 342 | cl = WinQueryWindowPtr(hwnd,0);
|
|---|
| 343 | if(cl) {
|
|---|
| 344 | if(cl->flags == DO_MOVE)
|
|---|
| 345 | WinSetFocus(HWND_DESKTOP,WinWindowFromID(hwnd,DND_MOVE));
|
|---|
| 346 | else if(cl->flags == DO_LINK)
|
|---|
| 347 | WinSetFocus(HWND_DESKTOP,WinWindowFromID(hwnd,DND_COMPARE));
|
|---|
| 348 | else
|
|---|
| 349 | WinSetFocus(HWND_DESKTOP,WinWindowFromID(hwnd,DND_COPY));
|
|---|
| 350 | }
|
|---|
| 351 | return 0;
|
|---|
| 352 |
|
|---|
| 353 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 354 | PostMsg(hwnd,UM_SETDIR,MPVOID,MPVOID);
|
|---|
| 355 | break;
|
|---|
| 356 |
|
|---|
| 357 | case UM_SETDIR:
|
|---|
| 358 | PaintRecessedWindow(WinWindowFromID(hwnd,DND_HELP),(HPS)0,FALSE,TRUE);
|
|---|
| 359 | return 0;
|
|---|
| 360 |
|
|---|
| 361 | case WM_CONTROL:
|
|---|
| 362 | switch(SHORT1FROMMP(mp1)) {
|
|---|
| 363 | case DND_LISTBOX:
|
|---|
| 364 | switch(SHORT2FROMMP(mp1)) {
|
|---|
| 365 | case LN_SETFOCUS:
|
|---|
| 366 | WinSetDlgItemText(hwnd,DND_HELP,
|
|---|
| 367 | GetPString(IDS_DNDLISTBOXHELPTEXT));
|
|---|
| 368 | break;
|
|---|
| 369 | case LN_KILLFOCUS:
|
|---|
| 370 | WinSetDlgItemText(hwnd,DND_HELP,
|
|---|
| 371 | GetPString(IDS_DNDHELPTEXT));
|
|---|
| 372 | break;
|
|---|
| 373 | case LN_ENTER:
|
|---|
| 374 | {
|
|---|
| 375 | SHORT x;
|
|---|
| 376 | CHAR szBuffer[CCHMAXPATH];
|
|---|
| 377 |
|
|---|
| 378 | x = (SHORT)WinSendDlgItemMsg(hwnd,DND_LISTBOX,LM_QUERYSELECTION,
|
|---|
| 379 | MPFROMSHORT(LIT_FIRST),MPVOID);
|
|---|
| 380 | if(x >= 0) {
|
|---|
| 381 | *szBuffer = 0;
|
|---|
| 382 | WinSendDlgItemMsg(hwnd,DND_LISTBOX,LM_QUERYITEMTEXT,
|
|---|
| 383 | MPFROM2SHORT(x,CCHMAXPATH),
|
|---|
| 384 | MPFROMP(szBuffer));
|
|---|
| 385 | if(*szBuffer)
|
|---|
| 386 | QuickView(hwnd,szBuffer);
|
|---|
| 387 | }
|
|---|
| 388 | }
|
|---|
| 389 | break;
|
|---|
| 390 | }
|
|---|
| 391 | break;
|
|---|
| 392 | case DND_TARGET:
|
|---|
| 393 | switch(SHORT2FROMMP(mp1)) {
|
|---|
| 394 | case EN_SETFOCUS:
|
|---|
| 395 | WinSetDlgItemText(hwnd,DND_HELP,
|
|---|
| 396 | GetPString(IDS_DNDTARGETHELPTEXT));
|
|---|
| 397 | break;
|
|---|
| 398 | case EN_KILLFOCUS:
|
|---|
| 399 | WinSetDlgItemText(hwnd,DND_HELP,
|
|---|
| 400 | GetPString(IDS_DNDHELPTEXT));
|
|---|
| 401 | break;
|
|---|
| 402 | }
|
|---|
| 403 | break;
|
|---|
| 404 | }
|
|---|
| 405 | return 0;
|
|---|
| 406 |
|
|---|
| 407 | case WM_COMMAND:
|
|---|
| 408 | switch(SHORT1FROMMP(mp1)) {
|
|---|
| 409 | case IDM_HELP:
|
|---|
| 410 | if(hwndHelp)
|
|---|
| 411 | WinSendMsg(hwndHelp,HM_DISPLAY_HELP,
|
|---|
| 412 | MPFROM2SHORT(HELP_DNDDLG,0),
|
|---|
| 413 | MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 414 | break;
|
|---|
| 415 |
|
|---|
| 416 | case DND_INFO:
|
|---|
| 417 | cl = INSTDATA(hwnd);
|
|---|
| 418 | if(cl)
|
|---|
| 419 | WinDlgBox(HWND_DESKTOP,hwnd,FileInfoProc,FM3ModHandle,
|
|---|
| 420 | FLE_FRAME,(PVOID)cl->list);
|
|---|
| 421 | break;
|
|---|
| 422 |
|
|---|
| 423 | case DND_CHANGETARGET:
|
|---|
| 424 | cl = INSTDATA(hwnd);
|
|---|
| 425 | if(cl) {
|
|---|
| 426 | if(cl->prompt && *cl->prompt) {
|
|---|
| 427 | if(!IsFile(cl->prompt)) {
|
|---|
| 428 |
|
|---|
| 429 | CHAR newpath[CCHMAXPATH];
|
|---|
| 430 |
|
|---|
| 431 | strcpy(newpath,cl->prompt);
|
|---|
| 432 | if(WinDlgBox(HWND_DESKTOP,hwnd,WalkAllDlgProc,
|
|---|
| 433 | FM3ModHandle,WALK_FRAME,
|
|---|
| 434 | MPFROMP(newpath)) && *newpath) {
|
|---|
| 435 | strcpy(cl->prompt,newpath);
|
|---|
| 436 | PostMsg(hwnd,UM_UNDO,MPVOID,MPVOID);
|
|---|
| 437 | }
|
|---|
| 438 | }
|
|---|
| 439 | else {
|
|---|
| 440 |
|
|---|
| 441 | FILEDLG fdlg;
|
|---|
| 442 | FILESTATUS3 fs3;
|
|---|
| 443 | CHAR drive[3],*pdrive = drive,
|
|---|
| 444 | filename[CCHMAXPATH],*p;
|
|---|
| 445 |
|
|---|
| 446 | memset(&fdlg,0,sizeof(FILEDLG));
|
|---|
| 447 | fdlg.cbSize = (ULONG)sizeof(FILEDLG);
|
|---|
| 448 | fdlg.fl = FDS_HELPBUTTON | FDS_CENTER |
|
|---|
| 449 | FDS_OPEN_DIALOG | FDS_CUSTOM;
|
|---|
| 450 | fdlg.pszTitle = GetPString(IDS_NEWTARGETTEXT);
|
|---|
| 451 | fdlg.pszOKButton = GetPString(IDS_CHANGETEXT);
|
|---|
| 452 | *drive = *cl->prompt;
|
|---|
| 453 | drive[1] = ':';
|
|---|
| 454 | drive[2] = 0;
|
|---|
| 455 | fdlg.pszIDrive = pdrive;
|
|---|
| 456 | strcpy(fdlg.szFullFile,cl->prompt);
|
|---|
| 457 | p = strrchr(fdlg.szFullFile,'\\');
|
|---|
| 458 | if(p)
|
|---|
| 459 | *p = 0;
|
|---|
| 460 | strcat(fdlg.szFullFile,"\\*");
|
|---|
| 461 |
|
|---|
| 462 | fdlg.pfnDlgProc = (PFNWP)CustomFileDlg;
|
|---|
| 463 | fdlg.hMod = FM3ModHandle;
|
|---|
| 464 | fdlg.usDlgId = FDLG_FRAME;
|
|---|
| 465 |
|
|---|
| 466 | if(WinFileDlg(HWND_DESKTOP,
|
|---|
| 467 | hwnd,
|
|---|
| 468 | &fdlg)) {
|
|---|
| 469 | if(fdlg.lReturn != DID_CANCEL &&
|
|---|
| 470 | !fdlg.lSRC) {
|
|---|
| 471 | if(!DosQueryPathInfo(fdlg.szFullFile,
|
|---|
| 472 | FIL_QUERYFULLNAME,
|
|---|
| 473 | filename,
|
|---|
| 474 | sizeof(filename))) {
|
|---|
| 475 | if(!DosQueryPathInfo(filename,
|
|---|
| 476 | FIL_STANDARD,
|
|---|
| 477 | &fs3,
|
|---|
| 478 | sizeof(fs3))) {
|
|---|
| 479 | p = filename;
|
|---|
| 480 | while(*p) {
|
|---|
| 481 | if(*p == '/')
|
|---|
| 482 | *p = '\\';
|
|---|
| 483 | p++;
|
|---|
| 484 | }
|
|---|
| 485 | strcpy(cl->prompt,filename);
|
|---|
| 486 | PostMsg(hwnd,
|
|---|
| 487 | UM_UNDO,
|
|---|
| 488 | MPVOID,
|
|---|
| 489 | MPVOID);
|
|---|
| 490 | }
|
|---|
| 491 | // else saymsg(MB_ENTER,hwnd,DEBUG_STRING,"DosQueryPathInfo FIL_STANDARD failed");
|
|---|
| 492 | }
|
|---|
| 493 | // else saymsg(MB_ENTER,hwnd,DEBUG_STRING,"DosQueryPathInfo FIL_QUERYFULLNAME failed");
|
|---|
| 494 | }
|
|---|
| 495 | // else saymsg(MB_ENTER,hwnd,DEBUG_STRING,"lReturn = %lu lSRC = %lu",fdlg.lReturn,fdlg.lSRC);
|
|---|
| 496 | }
|
|---|
| 497 | // else saymsg(MB_ENTER,hwnd,DEBUG_STRING,"WinFileDlg failed");
|
|---|
| 498 | }
|
|---|
| 499 | }
|
|---|
| 500 | }
|
|---|
| 501 | break;
|
|---|
| 502 |
|
|---|
| 503 | case DND_TARGETINFO:
|
|---|
| 504 | cl = INSTDATA(hwnd);
|
|---|
| 505 | if(cl) {
|
|---|
| 506 |
|
|---|
| 507 | CHAR *list[2];
|
|---|
| 508 |
|
|---|
| 509 | list[0] = cl->prompt;
|
|---|
| 510 | list[1] = NULL;
|
|---|
| 511 | WinDlgBox(HWND_DESKTOP,hwnd,FileInfoProc,FM3ModHandle,
|
|---|
| 512 | FLE_FRAME,(PVOID)&list);
|
|---|
| 513 | }
|
|---|
| 514 | break;
|
|---|
| 515 |
|
|---|
| 516 | case DND_EXTRACT:
|
|---|
| 517 | case DND_LAUNCH:
|
|---|
| 518 | case DND_COPY:
|
|---|
| 519 | case DND_MOVE:
|
|---|
| 520 | case DND_OBJECT:
|
|---|
| 521 | case DND_COMPARE:
|
|---|
| 522 | case DND_SETICON:
|
|---|
| 523 | case DND_APPEND:
|
|---|
| 524 | cl = INSTDATA(hwnd);
|
|---|
| 525 | if(cl) {
|
|---|
| 526 |
|
|---|
| 527 | SHORT x;
|
|---|
| 528 | CHAR szBuffer[CCHMAXPATH + 1];
|
|---|
| 529 | INT numfiles = 0,numalloc = 0,error;
|
|---|
| 530 | USHORT cmd;
|
|---|
| 531 |
|
|---|
| 532 | FreeList(cl->list);
|
|---|
| 533 | cl->list = NULL;
|
|---|
| 534 | x = (SHORT)WinSendDlgItemMsg(hwnd,DND_LISTBOX,LM_QUERYSELECTION,
|
|---|
| 535 | MPFROMSHORT(LIT_FIRST),MPVOID);
|
|---|
| 536 | if(x >= 0) {
|
|---|
| 537 | do {
|
|---|
| 538 | *szBuffer = 0;
|
|---|
| 539 | WinSendDlgItemMsg(hwnd,DND_LISTBOX,LM_QUERYITEMTEXT,
|
|---|
| 540 | MPFROM2SHORT(x,CCHMAXPATH),
|
|---|
| 541 | MPFROMP(szBuffer));
|
|---|
| 542 | if(*szBuffer) {
|
|---|
| 543 | error = AddToList(szBuffer,&cl->list,&numfiles,&numalloc);
|
|---|
| 544 | if (error) {
|
|---|
| 545 | Runtime_Error(pszSrcFile, __LINE__, "AddToList");
|
|---|
| 546 | break;
|
|---|
| 547 | }
|
|---|
| 548 | }
|
|---|
| 549 | x = (SHORT)WinSendDlgItemMsg(hwnd,DND_LISTBOX,
|
|---|
| 550 | LM_QUERYSELECTION,
|
|---|
| 551 | MPFROMSHORT(x),MPVOID);
|
|---|
| 552 | } while(x >= 0);
|
|---|
| 553 | }
|
|---|
| 554 | cmd = SHORT1FROMMP(mp1);
|
|---|
| 555 | switch(cmd) {
|
|---|
| 556 | case DND_COPY:
|
|---|
| 557 | if(WinQueryButtonCheckstate(hwnd,DND_RENAME)) {
|
|---|
| 558 | Wild = TRUE;
|
|---|
| 559 | cmd = DND_WILDCOPY;
|
|---|
| 560 | }
|
|---|
| 561 | else
|
|---|
| 562 | Wild = FALSE;
|
|---|
| 563 | break;
|
|---|
| 564 | case DND_MOVE:
|
|---|
| 565 | if(WinQueryButtonCheckstate(hwnd,DND_RENAME)) {
|
|---|
| 566 | Wild = TRUE;
|
|---|
| 567 | cmd = DND_WILDMOVE;
|
|---|
| 568 | }
|
|---|
| 569 | else
|
|---|
| 570 | Wild = FALSE;
|
|---|
| 571 | break;
|
|---|
| 572 | case DND_OBJECT:
|
|---|
| 573 | if(WinQueryButtonCheckstate(hwnd,DND_SHADOW)) {
|
|---|
| 574 | Shadow = TRUE;
|
|---|
| 575 | cmd = DND_SHADOW;
|
|---|
| 576 | }
|
|---|
| 577 | else
|
|---|
| 578 | Shadow = FALSE;
|
|---|
| 579 | break;
|
|---|
| 580 | }
|
|---|
| 581 | WinDismissDlg(hwnd,cmd);
|
|---|
| 582 | }
|
|---|
| 583 | else
|
|---|
| 584 | WinDismissDlg(hwnd,0);
|
|---|
| 585 | break;
|
|---|
| 586 |
|
|---|
| 587 | case DID_CANCEL:
|
|---|
| 588 | WinDismissDlg(hwnd,0);
|
|---|
| 589 | break;
|
|---|
| 590 | }
|
|---|
| 591 | return 0;
|
|---|
| 592 | }
|
|---|
| 593 | return WinDefDlgProc(hwnd,msg,mp1,mp2);
|
|---|
| 594 | }
|
|---|
| 595 |
|
|---|