Changeset 6645 for trunk/src/comdlg32/filedlg.c
- Timestamp:
- Sep 5, 2001, 2:14:25 PM (24 years ago)
- File:
-
- 1 edited
-
trunk/src/comdlg32/filedlg.c (modified) (64 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comdlg32/filedlg.c
r6315 r6645 1 /* $Id: filedlg.c,v 1.6 2001-09-05 12:12:00 bird Exp $ */ 1 2 /* 2 3 * COMMDLG - File Dialogs … … 28 29 #define GlobalLock16 GlobalLock 29 30 #define GlobalUnlock16 GlobalUnlock 30 #define GlobalAlloc16 GlobalAlloc31 #define FreeResource16 FreeResource31 #define GlobalAlloc16 GlobalAlloc 32 #define FreeResource16 FreeResource 32 33 #define LoadResource16 LoadResourceA 33 34 #define FindResource16 FindResourceA 34 #define MapSL(a) a35 #define MapSL(a) a 35 36 #define CallWindowProc16 CallWindowProcA 36 37 … … 42 43 43 44 #define BUFFILE 512 44 #define BUFFILEALLOC 512 * sizeof(WCHAR) 45 46 struct FSPRIVATE 45 #define BUFFILEALLOC 512 * sizeof(WCHAR) 46 47 struct FSPRIVATE 47 48 { 48 49 HWND hwnd; /* file dialog window handle */ … … 75 76 #define LFS32A 2 76 77 #define LFS32W 3 77 78 78 79 static const WCHAR FILE_star[] = {'*','.','*', 0}; 79 80 static const WCHAR FILE_bslash[] = {'\\', 0}; … … 111 112 112 113 LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, 113 LPARAM lParam);114 LPARAM lParam); 114 115 LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, 115 LPARAM lParam);116 LPARAM lParam); 116 117 117 118 static LRESULT WINAPI FileOpenDlgProc(HWND hDlg, UINT msg, … … 119 120 120 121 /*********************************************************************** 121 * FileDlg_Init[internal]122 * FileDlg_Init [internal] 122 123 */ 123 124 static BOOL FileDlg_Init(void) … … 125 126 static BOOL initialized = 0; 126 127 CURSORICONINFO *fldrInfo; 127 128 128 129 if (!initialized) { 129 130 #ifdef __WIN32OS2__ 130 if (!hFolder) hFolder = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER), IMAGE_ICON, 16, 16, LR_SHARED);131 if (!hFolder2) hFolder2 = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER2), IMAGE_ICON, 16, 16, LR_SHARED);132 if (!hFloppy) hFloppy = LoadImageA(0, MAKEINTRESOURCEA(OIC_FLOPPY), IMAGE_ICON, 16, 16, LR_SHARED);133 if (!hHDisk) hHDisk = LoadImageA(0, MAKEINTRESOURCEA(OIC_HDISK), IMAGE_ICON, 16, 16, LR_SHARED);134 if (!hCDRom) hCDRom = LoadImageA(0, MAKEINTRESOURCEA(OIC_CDROM), IMAGE_ICON, 16, 16, LR_SHARED);135 if (!hNet) hNet = LoadImageA(0, MAKEINTRESOURCEA(OIC_NETWORK), IMAGE_ICON, 16, 16, LR_SHARED);131 if (!hFolder) hFolder = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER), IMAGE_ICON, 16, 16, LR_SHARED); 132 if (!hFolder2) hFolder2 = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER2), IMAGE_ICON, 16, 16, LR_SHARED); 133 if (!hFloppy) hFloppy = LoadImageA(0, MAKEINTRESOURCEA(OIC_FLOPPY), IMAGE_ICON, 16, 16, LR_SHARED); 134 if (!hHDisk) hHDisk = LoadImageA(0, MAKEINTRESOURCEA(OIC_HDISK), IMAGE_ICON, 16, 16, LR_SHARED); 135 if (!hCDRom) hCDRom = LoadImageA(0, MAKEINTRESOURCEA(OIC_CDROM), IMAGE_ICON, 16, 16, LR_SHARED); 136 if (!hNet) hNet = LoadImageA(0, MAKEINTRESOURCEA(OIC_NETWORK), IMAGE_ICON, 16, 16, LR_SHARED); 136 137 #else 137 138 HINSTANCE inst = GetModuleHandleA( "comdlg32.dll" ); … … 148 149 hNet = LoadImageA( inst, "NETWORK", IMAGE_ICON, 16, 16, LR_SHARED ); 149 150 #endif 150 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 || 151 hHDisk == 0 || hCDRom == 0 || hNet == 0)152 {153 ERR("Error loading icons !\n");154 return FALSE;155 }151 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 || 152 hHDisk == 0 || hCDRom == 0 || hNet == 0) 153 { 154 ERR("Error loading icons !\n"); 155 return FALSE; 156 } 156 157 #ifdef __WIN32OS2__ 157 fldrHeight = 16;158 fldrWidth = 16;158 fldrHeight = 16; 159 fldrWidth = 16; 159 160 #else 160 fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 );161 if (!fldrInfo)162 { 163 ERR("Error measuring icons !\n");164 return FALSE;165 }166 fldrHeight = fldrInfo -> nHeight;167 fldrWidth = fldrInfo -> nWidth;168 GlobalUnlock16( hFolder2 );169 #endif 170 initialized = TRUE;161 fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 ); 162 if (!fldrInfo) 163 { 164 ERR("Error measuring icons !\n"); 165 return FALSE; 166 } 167 fldrHeight = fldrInfo -> nHeight; 168 fldrWidth = fldrInfo -> nWidth; 169 GlobalUnlock16( hFolder2 ); 170 #endif 171 initialized = TRUE; 171 172 } 172 173 return TRUE; … … 188 189 if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE) 189 190 { 190 if (!(lfs->template = LockResource( ofnW->hInstance )))191 {192 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);193 return FALSE;194 }191 if (!(lfs->template = LockResource( ofnW->hInstance ))) 192 { 193 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 194 return FALSE; 195 } 195 196 } 196 197 else if (ofnW->Flags & OFN_ENABLETEMPLATE) 197 198 { 198 HANDLE hResInfo;199 HANDLE hResInfo; 199 200 if (lfs->ofnA) 200 hResInfo = FindResourceA(lfs->ofnA->hInstance,201 lfs->ofnA->lpTemplateName,201 hResInfo = FindResourceA(lfs->ofnA->hInstance, 202 lfs->ofnA->lpTemplateName, 202 203 RT_DIALOGA); 203 204 else 204 hResInfo = FindResourceW(ofnW->hInstance,205 ofnW->lpTemplateName,205 hResInfo = FindResourceW(ofnW->hInstance, 206 ofnW->lpTemplateName, 206 207 RT_DIALOGW); 207 208 if (!hResInfo) 208 {209 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);210 return FALSE;211 }212 if (!(hDlgTmpl = LoadResource(ofnW->hInstance,213 hResInfo)) ||214 !(lfs->template = LockResource(hDlgTmpl)))215 {216 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);217 return FALSE;218 }209 { 210 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 211 return FALSE; 212 } 213 if (!(hDlgTmpl = LoadResource(ofnW->hInstance, 214 hResInfo)) || 215 !(lfs->template = LockResource(hDlgTmpl))) 216 { 217 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 218 return FALSE; 219 } 219 220 } else { /* get it from internal Wine resource */ 220 HANDLE hResInfo;221 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 221 HANDLE hResInfo; 222 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 222 223 lfs->open? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA))) 223 {224 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);225 return FALSE;224 { 225 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 226 return FALSE; 226 227 } 227 228 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) || … … 253 254 else if (ofn16->Flags & OFN_ENABLETEMPLATE) 254 255 { 255 HANDLE16 hResInfo;256 if (!(hResInfo = FindResource16(ofn16->hInstance,257 MapSL(ofn16->lpTemplateName),256 HANDLE16 hResInfo; 257 if (!(hResInfo = FindResource16(ofn16->hInstance, 258 MapSL(ofn16->lpTemplateName), 258 259 RT_DIALOGA))) 259 {260 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);261 return FALSE;262 }263 if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))264 {265 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);266 return FALSE;267 }260 { 261 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 262 return FALSE; 263 } 264 if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo ))) 265 { 266 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 267 return FALSE; 268 } 268 269 lfs->hResource16 = lfs->hDlgTmpl16; 269 270 } 270 271 else 271 272 { /* get resource from (32 bits) own Wine resource; convert it to 16 */ 272 HANDLE hResInfo, hDlgTmpl32;273 HANDLE hResInfo, hDlgTmpl32; 273 274 LPCVOID template32; 274 275 DWORD size; 275 276 276 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 277 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 277 278 lfs->open ? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA))) 278 {279 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);280 return FALSE;281 }282 if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) ||283 !(template32 = LockResource( hDlgTmpl32 )))284 {285 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);286 return FALSE;287 }279 { 280 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 281 return FALSE; 282 } 283 if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) || 284 !(template32 = LockResource( hDlgTmpl32 ))) 285 { 286 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 287 return FALSE; 288 } 288 289 size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo); 289 290 hGlobal16 = GlobalAlloc16(0, size); … … 321 322 cp = strrchrW(temp, '\\'); 322 323 if (cp != NULL) { 323 strcpyW(temp, cp+1);324 strcpyW(temp, cp+1); 324 325 } 325 326 cp = strrchrW(temp, ':'); 326 327 if (cp != NULL) { 327 strcpyW(temp, cp+1);328 strcpyW(temp, cp+1); 328 329 } 329 330 /* FIXME: shouldn't we do something with the result here? ;-) */ … … 366 367 367 368 /*********************************************************************** 368 * FILEDLG_ScanDir [internal]369 * FILEDLG_ScanDir [internal] 369 370 */ 370 371 static BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath) 371 372 { 372 WCHAR buffer[BUFFILE];373 HWND hdlg, hdlgDir;373 WCHAR buffer[BUFFILE]; 374 HWND hdlg, hdlgDir; 374 375 LRESULT lRet = TRUE; 375 376 HCURSOR hCursorWait, oldCursor; … … 387 388 /* list of files */ 388 389 if ((hdlg = GetDlgItem(hWnd, lst1)) != 0) { 389 WCHAR* scptr; /* ptr on semi-colon */390 WCHAR*filter = buffer;391 392 TRACE("Using filter %s\n", debugstr_w(filter));393 SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);394 while (filter) {395 scptr = strchrW(filter, ';');396 if (scptr)*scptr = 0;390 WCHAR* scptr; /* ptr on semi-colon */ 391 WCHAR* filter = buffer; 392 393 TRACE("Using filter %s\n", debugstr_w(filter)); 394 SendMessageW(hdlg, LB_RESETCONTENT, 0, 0); 395 while (filter) { 396 scptr = strchrW(filter, ';'); 397 if (scptr) *scptr = 0; 397 398 while (*filter == ' ') filter++; 398 TRACE("Using file spec %s\n", debugstr_w(filter));399 if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR)400 return FALSE;401 if (scptr) *scptr = ';';402 filter = (scptr) ? (scptr + 1) : 0;403 }399 TRACE("Using file spec %s\n", debugstr_w(filter)); 400 if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR) 401 return FALSE; 402 if (scptr) *scptr = ';'; 403 filter = (scptr) ? (scptr + 1) : 0; 404 } 404 405 } 405 406 … … 416 417 417 418 /*********************************************************************** 418 * FILEDLG_GetFileType[internal]419 * FILEDLG_GetFileType [internal] 419 420 */ 420 421 … … 424 425 i = 0; 425 426 if (cfptr) 426 for ( ;(n = lstrlenW(cfptr)) != 0; i++) 427 for ( ;(n = lstrlenW(cfptr)) != 0; i++) 427 428 { 428 cfptr += n + 1;429 if (i == index)430 return cfptr;431 cfptr += lstrlenW(cfptr) + 1;429 cfptr += n + 1; 430 if (i == index) 431 return cfptr; 432 cfptr += lstrlenW(cfptr) + 1; 432 433 } 433 434 if (fptr) 434 for ( ;(n = lstrlenW(fptr)) != 0; i++) 435 for ( ;(n = lstrlenW(fptr)) != 0; i++) 435 436 { 436 fptr += n + 1;437 if (i == index)438 return fptr;439 fptr += lstrlenW(fptr) + 1;437 fptr += n + 1; 438 if (i == index) 439 return fptr; 440 fptr += lstrlenW(fptr) + 1; 440 441 } 441 442 return (LPWSTR) FILE_star; /* FIXME */ … … 455 456 { 456 457 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) return FALSE; 457 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 458 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 458 459 (LPARAM)str); 459 460 460 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)461 {462 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );463 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));464 }465 if (savedlg)466 SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );467 468 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1,461 if ((lpdis->itemState & ODS_SELECTED) && !savedlg) 462 { 463 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) ); 464 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 465 } 466 if (savedlg) 467 SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) ); 468 469 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1, 469 470 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED, 470 471 &(lpdis->rcItem), str, lstrlenW(str), NULL); 471 472 472 if (lpdis->itemState & ODS_SELECTED)473 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );474 475 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)476 {477 SetBkColor( lpdis->hDC, oldBk );478 SetTextColor( lpdis->hDC, oldText );479 }473 if (lpdis->itemState & ODS_SELECTED) 474 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) ); 475 476 if ((lpdis->itemState & ODS_SELECTED) && !savedlg) 477 { 478 SetBkColor( lpdis->hDC, oldBk ); 479 SetTextColor( lpdis->hDC, oldText ); 480 } 480 481 HeapFree(GetProcessHeap(), 0, str); 481 return TRUE;482 return TRUE; 482 483 } 483 484 … … 486 487 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) 487 488 return FALSE; 488 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 489 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 489 490 (LPARAM)str); 490 491 491 if (lpdis->itemState & ODS_SELECTED)492 {493 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );494 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));495 }496 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,492 if (lpdis->itemState & ODS_SELECTED) 493 { 494 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) ); 495 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 496 } 497 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth, 497 498 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED, 498 499 &(lpdis->rcItem), str, lstrlenW(str), NULL); 499 500 500 if (lpdis->itemState & ODS_SELECTED)501 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );502 503 if (lpdis->itemState & ODS_SELECTED)504 {505 SetBkColor( lpdis->hDC, oldBk );506 SetTextColor( lpdis->hDC, oldText );507 }508 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);501 if (lpdis->itemState & ODS_SELECTED) 502 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) ); 503 504 if (lpdis->itemState & ODS_SELECTED) 505 { 506 SetBkColor( lpdis->hDC, oldBk ); 507 SetTextColor( lpdis->hDC, oldText ); 508 } 509 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder); 509 510 HeapFree(GetProcessHeap(), 0, str); 510 return TRUE;511 return TRUE; 511 512 } 512 513 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2) … … 515 516 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) 516 517 return FALSE; 517 SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, 518 SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, 518 519 (LPARAM)str); 519 520 root[0] += str[2] - 'a'; … … 526 527 default: hIcon = hHDisk; break; 527 528 } 528 if (lpdis->itemState & ODS_SELECTED)529 {530 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );531 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));532 }533 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,529 if (lpdis->itemState & ODS_SELECTED) 530 { 531 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) ); 532 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 533 } 534 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth, 534 535 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED, 535 536 &(lpdis->rcItem), str, lstrlenW(str), NULL); 536 537 537 if (lpdis->itemState & ODS_SELECTED)538 {539 SetBkColor( lpdis->hDC, oldBk );540 SetTextColor( lpdis->hDC, oldText );541 }542 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);538 if (lpdis->itemState & ODS_SELECTED) 539 { 540 SetBkColor( lpdis->hDC, oldBk ); 541 SetTextColor( lpdis->hDC, oldText ); 542 } 543 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon); 543 544 HeapFree(GetProcessHeap(), 0, str); 544 return TRUE;545 return TRUE; 545 546 } 546 547 return FALSE; … … 550 551 * FILEDLG_WMMeasureItem [internal] 551 552 */ 552 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) 553 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) 553 554 { 554 555 LPMEASUREITEMSTRUCT lpmeasure; 555 556 556 557 lpmeasure = (LPMEASUREITEMSTRUCT)lParam; 557 558 lpmeasure->itemHeight = fldrHeight; … … 562 563 */ 563 564 #ifdef __WIN32OS2__ 564 static LONG FILEDLG_WMMeasureItem16(HWND hWnd, WPARAM wParam, LPARAM lParam) 565 static LONG FILEDLG_WMMeasureItem16(HWND hWnd, WPARAM wParam, LPARAM lParam) 565 566 { 566 567 LPMEASUREITEMSTRUCT lpmeasure; 567 568 568 569 lpmeasure = (LPMEASUREITEMSTRUCT)lParam; 569 570 lpmeasure->itemHeight = fldrHeight; … … 571 572 } 572 573 #else 573 static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 574 static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 574 575 { 575 576 LPMEASUREITEMSTRUCT16 lpmeasure; 576 577 577 578 lpmeasure = MapSL(lParam); 578 579 lpmeasure->itemHeight = fldrHeight; … … 608 609 TRACE("lpstrCustomFilter = %p\n", pstr); 609 610 while(*pstr) 610 {611 old_pstr = pstr;611 { 612 old_pstr = pstr; 612 613 i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0, 613 614 (LPARAM)(ofn->lpstrCustomFilter) + n ); 614 615 n += lstrlenW(pstr) + 1; 615 pstr += lstrlenW(pstr) + 1;616 TRACE("add str='%s' "617 "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));616 pstr += lstrlenW(pstr) + 1; 617 TRACE("add str='%s' " 618 "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr)); 618 619 SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr); 619 620 n += lstrlenW(pstr) + 1; 620 pstr += lstrlenW(pstr) + 1;621 }621 pstr += lstrlenW(pstr) + 1; 622 } 622 623 } 623 624 /* read filter information */ 624 625 if (ofn->lpstrFilter) { 625 pstr = (LPWSTR) ofn->lpstrFilter;626 n = 0;627 while(*pstr) {628 old_pstr = pstr;629 i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,630 (LPARAM)(ofn->lpstrFilter + n) );631 n += lstrlenW(pstr) + 1;632 pstr += lstrlenW(pstr) + 1;633 TRACE("add str='%s' "634 "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));635 SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);636 n += lstrlenW(pstr) + 1;637 pstr += lstrlenW(pstr) + 1;638 }626 pstr = (LPWSTR) ofn->lpstrFilter; 627 n = 0; 628 while(*pstr) { 629 old_pstr = pstr; 630 i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0, 631 (LPARAM)(ofn->lpstrFilter + n) ); 632 n += lstrlenW(pstr) + 1; 633 pstr += lstrlenW(pstr) + 1; 634 TRACE("add str='%s' " 635 "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr)); 636 SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr); 637 n += lstrlenW(pstr) + 1; 638 pstr += lstrlenW(pstr) + 1; 639 } 639 640 } 640 641 /* set default filter */ 641 642 if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL) 642 ofn->nFilterIndex = 1;643 SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0); 643 ofn->nFilterIndex = 1; 644 SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0); 644 645 lstrcpynW(tmpstr, FILEDLG_GetFileType(ofn->lpstrCustomFilter, 645 (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);646 TRACE("nFilterIndex = %ld, SetText of edt1 to '%s'\n", 647 ofn->nFilterIndex, debugstr_w(tmpstr));646 (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE); 647 TRACE("nFilterIndex = %ld, SetText of edt1 to '%s'\n", 648 ofn->nFilterIndex, debugstr_w(tmpstr)); 648 649 SetDlgItemTextW( hWnd, edt1, tmpstr ); 649 650 /* get drive list */ … … 651 652 DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE); 652 653 /* read initial directory */ 653 if (ofn->lpstrInitialDir != NULL) 654 if (ofn->lpstrInitialDir != NULL) 654 655 { 655 656 int len; … … 690 691 { 691 692 str[0] = 'a' + i; 692 if(drives & (1 << i)) n++;693 if(drives & (1 << i)) n++; 693 694 694 695 if (toupper(str[0]) == toupper(dir[0])) break; … … 720 721 /*********************************************************************** 721 722 * FILEDLG_UpdateResult [internal] 722 * update the displayed file name (with path) 723 * update the displayed file name (with path) 723 724 */ 724 725 void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr) … … 747 748 if (lfs->ofn16) 748 749 { /* we have to convert to short (8.3) path */ 749 char tmp[1024]; /* MAX_PATHNAME_LEN */750 LPOPENFILENAME16 ofn16 = lfs->ofn16;750 char tmp[1024]; /* MAX_PATHNAME_LEN */ 751 LPOPENFILENAME16 ofn16 = lfs->ofn16; 751 752 char *dest = MapSL(ofn16->lpstrFile); 752 753 if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1, 753 754 tmp, ofnW->nMaxFile, NULL, NULL )) 754 755 tmp[ofnW->nMaxFile-1] = 0; 755 GetShortPathNameA(tmp, dest, ofn16->nMaxFile);756 757 /* the same procedure as every year... */756 GetShortPathNameA(tmp, dest, ofn16->nMaxFile); 757 758 /* the same procedure as every year... */ 758 759 ofn16->nFileOffset = strrchr(dest,'\\') - dest +1; 759 760 ofn16->nFileExtension = 0; … … 779 780 /*********************************************************************** 780 781 * FILEDLG_UpdateFileTitle [internal] 781 * update the displayed file name (without path) 782 * update the displayed file name (without path) 782 783 */ 783 784 void FILEDLG_UpdateFileTitle(LFSPRIVATE lfs) … … 785 786 LONG lRet; 786 787 LPOPENFILENAMEW ofnW = lfs->ofnW; 787 if (ofnW->lpstrFileTitle != NULL) 788 if (ofnW->lpstrFileTitle != NULL) 788 789 { 789 790 lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0); … … 825 826 pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC); 826 827 SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet, 827 (LPARAM)pstr);828 (LPARAM)pstr); 828 829 strcpyW( tmpstr, pstr ); 829 830 HeapFree(GetProcessHeap(), 0, pstr); … … 897 898 pBeginFileName = strrchrW(path, '\\'); 898 899 if (pBeginFileName == NULL) 899 pBeginFileName = strrchrW(path, ':');900 pBeginFileName = strrchrW(path, ':'); 900 901 901 902 if (strchrW(path,'*') != NULL || strchrW(path,'?') != NULL) … … 904 905 if (pBeginFileName != NULL) 905 906 { 906 lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);907 *(pBeginFileName + 1) = 0;908 }909 else910 {911 strcpyW(tmpstr2, path);912 *path = 0;907 lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE); 908 *(pBeginFileName + 1) = 0; 909 } 910 else 911 { 912 strcpyW(tmpstr2, path); 913 *path = 0; 913 914 } 914 915 … … 997 998 lRet = (BOOL)FILEDLG_CallWindowProc(lfs, lfs->fileokstring, 998 999 0, lfs->lParam ); 999 if (lRet) 1000 if (lRet) 1000 1001 { 1001 1002 *ofnW = ofnsav; /* restore old state */ … … 1009 1010 LPWSTR str = (LPWSTR)ofnW->lpstrFile; 1010 1011 LPWSTR ptr = strrchrW(str, '\\'); 1011 str[lstrlenW(str) + 1] = '\0';1012 *ptr = 0;1012 str[lstrlenW(str) + 1] = '\0'; 1013 *ptr = 0; 1013 1014 } 1014 1015 } … … 1035 1036 (LPARAM)pstr); 1036 1037 wsprintfW(diskname, FILE_specc, pstr[2]); 1037 HeapFree(GetProcessHeap(), 0, pstr); 1038 HeapFree(GetProcessHeap(), 0, pstr); 1038 1039 1039 1040 return FILEDLG_Validate( lfs, diskname, cmb2, lRet, TRUE ); … … 1067 1068 */ 1068 1069 static LRESULT FILEDLG_WMCommand(HWND hWnd, LPARAM lParam, UINT notification, 1069 UINT control, LFSPRIVATE lfs ) 1070 UINT control, LFSPRIVATE lfs ) 1070 1071 { 1071 1072 switch (control) … … 1090 1091 1091 1092 case cmb1: /* file type drop list */ 1092 if (notification == CBN_SELCHANGE) 1093 if (notification == CBN_SELCHANGE) 1093 1094 return FILEDLG_FileTypeChange( lfs ); 1094 1095 break; … … 1215 1216 if (ofnA->lpstrTitle) 1216 1217 str = ofnA->lpstrTitle; 1217 else 1218 else 1218 1219 /* Allocates default title (FIXME : get it from resource) */ 1219 1220 str = open ? defaultopen:defaultsave; … … 1272 1273 /************************************************************************ 1273 1274 * FILEDLG_DestroyPrivate [internal] 1274 * destroys the private object 1275 * destroys the private object 1275 1276 */ 1276 1277 void FILEDLG_DestroyPrivate(LFSPRIVATE lfs) … … 1311 1312 /************************************************************************ 1312 1313 * FILEDLG_AllocPrivate [internal] 1313 * allocate a private object to hold 32 bits Unicode 1314 * allocate a private object to hold 32 bits Unicode 1314 1315 * structure that will be used throughtout the calls, while 1315 1316 * keeping available the original structures and a few variables … … 1369 1370 FILEDLG_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open); 1370 1371 } 1371 else 1372 else 1372 1373 ret = NULL; 1373 1374 } … … 1390 1391 * Creates a win31 style dialog box for the user to select a file to open/save. 1391 1392 */ 1392 BOOL WINAPI GetFileName31A( 1393 BOOL WINAPI GetFileName31A( 1393 1394 LPOPENFILENAMEA lpofn, /* addess of structure with data*/ 1394 1395 UINT dlgType /* type dialogue : open/save */ … … 1405 1406 { 1406 1407 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE ); 1407 bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner, 1408 bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner, 1408 1409 (DLGPROC) FileOpenDlgProc, (DWORD) lfs); 1409 1410 FILEDLG_DestroyPrivate(lfs); … … 1420 1421 * Creates a win31 style dialog box for the user to select a file to open/save 1421 1422 */ 1422 BOOL WINAPI GetFileName31W( 1423 BOOL WINAPI GetFileName31W( 1423 1424 LPOPENFILENAMEW lpofn, /* addess of structure with data*/ 1424 1425 UINT dlgType /* type dialogue : open/save */ … … 1435 1436 { 1436 1437 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE ); 1437 bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner, 1438 bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner, 1438 1439 (DLGPROC) FileOpenDlgProc, (DWORD) lfs); 1439 1440 FILEDLG_DestroyPrivate(lfs); … … 1453 1454 LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, 1454 1455 LPARAM lParam) 1455 { 1456 { 1456 1457 LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP); 1457 1458 DRAWITEMSTRUCT dis; 1458 1459 1459 1460 TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam); 1460 1461 if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook) 1461 1462 { 1462 1463 LRESULT lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam); 1463 if (lRet) 1464 if (lRet) 1464 1465 return lRet; /* else continue message processing */ 1465 1466 } … … 1483 1484 switch (HIWORD(lParam)) 1484 1485 { 1485 case CTLCOLOR_BTN:1486 SetTextColor((HDC16)wParam, 0x00000000);1486 case CTLCOLOR_BTN: 1487 SetTextColor((HDC16)wParam, 0x00000000); 1487 1488 return hGRAYBrush; 1488 case CTLCOLOR_STATIC:1489 case CTLCOLOR_STATIC: 1489 1490 SetTextColor((HDC16)wParam, 0x00000000); 1490 1491 return hGRAYBrush; 1491 }1492 } 1492 1493 break; 1493 1494 #endif … … 1510 1511 LRESULT lRet; 1511 1512 lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam); 1512 if (lRet) 1513 if (lRet) 1513 1514 return lRet; /* else continue message processing */ 1514 } 1515 } 1515 1516 switch (wMsg) { 1516 1517 case WM_INITDIALOG: 1517 1518 return FILEDLG_WMInitDialog(hWnd, wParam, lParam); 1518 1519 1519 1520 case WM_MEASUREITEM: 1520 1521 return FILEDLG_WMMeasureItem16(hWnd, wParam, lParam); 1521 1522 1522 1523 case WM_DRAWITEM: 1523 1524 FILEDLG_MapDrawItemStruct(MapSL(lParam), &dis); … … 1527 1528 return FILEDLG_WMCommand(hWnd, lParam, HIWORD(lParam), wParam, lfs); 1528 1529 } 1529 1530 1530 1531 /* 1531 1532 case WM_CTLCOLOR: … … 1541 1542 } 1542 1543 return FALSE; 1543 1544 1544 1545 */ 1545 1546 return FALSE; … … 1549 1550 /*********************************************************************** 1550 1551 * FileOpenDlgProc [internal] 1551 * Used for open and save, in fact. 1552 * Used for open and save, in fact. 1552 1553 */ 1553 1554 static LRESULT WINAPI FileOpenDlgProc(HWND hWnd, UINT wMsg, … … 1561 1562 LRESULT lRet; 1562 1563 lRet = (BOOL)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam); 1563 if (lRet) 1564 if (lRet) 1564 1565 return lRet; /* else continue message processing */ 1565 1566 } … … 1582 1583 switch (HIWORD(lParam)) 1583 1584 { 1584 case CTLCOLOR_BTN:1585 SetTextColor((HDC16)wParam, 0x00000000);1585 case CTLCOLOR_BTN: 1586 SetTextColor((HDC16)wParam, 0x00000000); 1586 1587 return hGRAYBrush; 1587 case CTLCOLOR_STATIC:1588 case CTLCOLOR_STATIC: 1588 1589 SetTextColor((HDC16)wParam, 0x00000000); 1589 1590 return hGRAYBrush; 1590 }1591 } 1591 1592 break; 1592 1593 #endif … … 1595 1596 } 1596 1597 1597 /* ------------------ APIs ---------------------- */ 1598 /* ------------------ APIs ---------------------- */ 1598 1599 #ifndef __WIN32OS2__ 1599 1600 /*********************************************************************** … … 1609 1610 * unknown, there are some FIXME's left. 1610 1611 */ 1611 BOOL16 WINAPI GetOpenFileName16( 1612 SEGPTR ofn /* [in/out] address of structure with data*/1613 )1612 BOOL16 WINAPI GetOpenFileName16( 1613 SEGPTR ofn /* [in/out] address of structure with data*/ 1614 ) 1614 1615 { 1615 1616 HINSTANCE hInst; … … 1626 1627 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE ); 1627 1628 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 6); 1628 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 1629 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 1629 1630 (DLGPROC16) ptr, (DWORD) lfs); 1630 1631 FILEDLG_DestroyPrivate(lfs); … … 1647 1648 * unknown. There are some FIXME's left. 1648 1649 */ 1649 BOOL16 WINAPI GetSaveFileName16( 1650 SEGPTR ofn /* [in/out] addess of structure with data*/1651 )1650 BOOL16 WINAPI GetSaveFileName16( 1651 SEGPTR ofn /* [in/out] addess of structure with data*/ 1652 ) 1652 1653 { 1653 1654 HINSTANCE hInst; … … 1664 1665 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE ); 1665 1666 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 7); 1666 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 1667 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 1667 1668 (DLGPROC16) ptr, (DWORD) lfs); 1668 1669 FILEDLG_DestroyPrivate(lfs); 1669 } 1670 } 1670 1671 1671 1672 TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile)); … … 1685 1686 */ 1686 1687 BOOL WINAPI GetOpenFileNameA( 1687 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */1688 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */ 1688 1689 { 1689 1690 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */ … … 1721 1722 */ 1722 1723 BOOL WINAPI GetOpenFileNameW( 1723 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */1724 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */ 1724 1725 { 1725 1726 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */ … … 1757 1758 */ 1758 1759 BOOL WINAPI GetSaveFileNameA( 1759 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */1760 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */ 1760 1761 { 1761 1762 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */ … … 1775 1776 { 1776 1777 return GetFileDialog95A(ofn, SAVE_DIALOG); 1777 } 1778 } 1778 1779 else 1779 1780 { … … 1793 1794 */ 1794 1795 BOOL WINAPI GetSaveFileNameW( 1795 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */1796 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */ 1796 1797 { 1797 1798 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */ … … 1811 1812 { 1812 1813 return GetFileDialog95W(ofn, SAVE_DIALOG); 1813 } 1814 } 1814 1815 else 1815 1816 {
Note:
See TracChangeset
for help on using the changeset viewer.
