Changeset 3243 for trunk/src/comdlg32/filedlg95.c
- Timestamp:
- Mar 26, 2000, 6:34:57 PM (26 years ago)
- File:
-
- 1 edited
-
trunk/src/comdlg32/filedlg95.c (modified) (68 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comdlg32/filedlg95.c
r3216 r3243 1 /* $Id: filedlg95.c,v 1.4 2000-03-26 16:31:41 cbratschi Exp $*/ 1 2 /* 2 3 * COMMDLG - File Open Dialogs Win95 look and feel 3 4 * 5 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch) 6 * Project Odin Software License can be found in LICENSE.TXT 7 * 8 * Corel WINE 20000324 level 4 9 */ 5 10 #ifdef __WIN32OS2__ … … 48 53 CHAR* szDisplayName; 49 54 INT iIcon; 55 INT iSelIcon; 50 56 HIMAGELIST ilItemImage; 51 57 … … 173 179 HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode); 174 180 HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 181 BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPSTR lpstrFileList, UINT nFileCount, UINT sizeUsed); 182 static BOOL BrowseSelectedFolder(HWND hwnd); 175 183 176 184 /*********************************************************************** … … 207 215 lRes = DialogBoxIndirectParamA(COMMDLG_hInstance32, 208 216 (LPDLGTEMPLATEA) template, 209 fodInfos->ofnInfos .hwndOwner,217 fodInfos->ofnInfos->hwndOwner, 210 218 (DLGPROC) FileOpenDlgProc95, 211 219 (LPARAM) fodInfos); … … 229 237 BOOL WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType) 230 238 { 231 232 239 BOOL ret; 233 240 FileOpenDlgInfos *fodInfos; 241 HINSTANCE hInstance; 242 LPCSTR lpstrFilter = NULL; 243 LPSTR lpstrCustomFilter = NULL; 244 LPCSTR lpstrInitialDir = NULL; 245 DWORD dwFlags = 0; 234 246 235 247 /* Initialise FileOpenDlgInfos structure*/ 236 248 fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos)); 237 memset(&fodInfos->ofnInfos,'\0',sizeof(*ofn)); fodInfos->ofnInfos.lStructSize = sizeof(*ofn); 238 fodInfos->ofnInfos.hwndOwner = ofn->hwndOwner; 239 fodInfos->ofnInfos.hInstance = MapHModuleLS(ofn->hInstance); 249 250 /* Pass in the original ofn */ 251 fodInfos->ofnInfos = ofn; 252 253 /* Save original hInstance value */ 254 hInstance = ofn->hInstance; 255 fodInfos->ofnInfos->hInstance = MapHModuleLS(ofn->hInstance); 256 240 257 if (ofn->lpstrFilter) 241 258 { 242 259 LPSTR s,x; 260 lpstrFilter = ofn->lpstrFilter; 243 261 244 262 /* filter is a list... title\0ext\0......\0\0 */ … … 249 267 x = (LPSTR)MemAlloc(s-ofn->lpstrFilter); 250 268 memcpy(x,ofn->lpstrFilter,s-ofn->lpstrFilter); 251 fodInfos->ofnInfos .lpstrFilter = (LPSTR)x;269 fodInfos->ofnInfos->lpstrFilter = (LPSTR)x; 252 270 } 253 271 if (ofn->lpstrCustomFilter) 254 272 { 255 273 LPSTR s,x; 274 lpstrCustomFilter = ofn->lpstrCustomFilter; 256 275 257 276 /* filter is a list... title\0ext\0......\0\0 */ … … 262 281 x = MemAlloc(s-ofn->lpstrCustomFilter); 263 282 memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter); 264 fodInfos->ofnInfos.lpstrCustomFilter = (LPSTR)x; 265 } 266 fodInfos->ofnInfos.nMaxCustFilter = ofn->nMaxCustFilter; 267 fodInfos->ofnInfos.nFilterIndex = ofn->nFilterIndex; 268 if (ofn->nMaxFile) 269 { 270 fodInfos->ofnInfos.lpstrFile = (LPSTR)MemAlloc(ofn->nMaxFile); 271 strcpy((LPSTR)fodInfos->ofnInfos.lpstrFile,ofn->lpstrFile); 272 } 273 fodInfos->ofnInfos.nMaxFile = ofn->nMaxFile; 274 fodInfos->ofnInfos.nMaxFileTitle = ofn->nMaxFileTitle; 275 if (fodInfos->ofnInfos.nMaxFileTitle) 276 fodInfos->ofnInfos.lpstrFileTitle = (LPSTR)MemAlloc(ofn->nMaxFileTitle); 277 if (ofn->lpstrInitialDir) 278 { 279 fodInfos->ofnInfos.lpstrInitialDir = (LPSTR)MemAlloc(strlen(ofn->lpstrInitialDir)+1); 280 strcpy((LPSTR)fodInfos->ofnInfos.lpstrInitialDir,ofn->lpstrInitialDir); 281 } 282 283 if (ofn->lpstrTitle) 284 { 285 fodInfos->ofnInfos.lpstrTitle = (LPSTR)MemAlloc(strlen(ofn->lpstrTitle)+1); 286 strcpy((LPSTR)fodInfos->ofnInfos.lpstrTitle,ofn->lpstrTitle); 287 } 288 289 fodInfos->ofnInfos.Flags = ofn->Flags|OFN_WINE; 290 fodInfos->ofnInfos.nFileOffset = ofn->nFileOffset; 291 fodInfos->ofnInfos.nFileExtension = ofn->nFileExtension; 292 if (ofn->lpstrDefExt) 293 { 294 fodInfos->ofnInfos.lpstrDefExt = MemAlloc(strlen(ofn->lpstrDefExt)+1); 295 strcpy((LPSTR)fodInfos->ofnInfos.lpstrDefExt,ofn->lpstrDefExt); 296 } 297 fodInfos->ofnInfos.lCustData = ofn->lCustData; 298 fodInfos->ofnInfos.lpfnHook = (LPOFNHOOKPROC)ofn->lpfnHook; 299 300 if (HIWORD(ofn->lpTemplateName)) 301 { 302 fodInfos->ofnInfos.lpTemplateName = MemAlloc(strlen(ofn->lpTemplateName)+1); 303 strcpy ((LPSTR)fodInfos->ofnInfos.lpTemplateName, ofn->lpTemplateName); 304 } 305 else 306 { 307 /* resource id */ 308 fodInfos->ofnInfos.lpTemplateName = ofn->lpTemplateName; 309 } 283 fodInfos->ofnInfos->lpstrCustomFilter = (LPSTR)x; 284 } 285 286 dwFlags = ofn->Flags; 287 fodInfos->ofnInfos->Flags = ofn->Flags|OFN_WINE; 310 288 311 289 /* Replace the NULL lpstrInitialDir by the current folder */ 312 if(!ofn->lpstrInitialDir) 313 { 314 fodInfos->ofnInfos.lpstrInitialDir = MemAlloc(MAX_PATH); 315 GetCurrentDirectoryA(MAX_PATH,(LPSTR)fodInfos->ofnInfos.lpstrInitialDir); 290 lpstrInitialDir = ofn->lpstrInitialDir; 291 if(!lpstrInitialDir) 292 { 293 fodInfos->ofnInfos->lpstrInitialDir = MemAlloc(MAX_PATH); 294 GetCurrentDirectoryA(MAX_PATH,(LPSTR)fodInfos->ofnInfos->lpstrInitialDir); 316 295 } 317 296 … … 333 312 } 334 313 335 ofn->nFileOffset = fodInfos->ofnInfos.nFileOffset; 336 ofn->nFileExtension = fodInfos->ofnInfos.nFileExtension; 337 338 /* 339 Transfer the combo index in the OPENFILENAME structure; 340 No support for custom filters, so nFilterIndex must be one-based. 341 */ 342 ofn->nFilterIndex = fodInfos->ofnInfos.nFilterIndex; 343 344 if (fodInfos->ofnInfos.lpstrFilter) 345 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrFilter)); 346 if (HIWORD(fodInfos->ofnInfos.lpTemplateName)) 347 MemFree((LPVOID)(fodInfos->ofnInfos.lpTemplateName)); 348 if (fodInfos->ofnInfos.lpstrDefExt) 349 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrDefExt)); 350 if (fodInfos->ofnInfos.lpstrTitle) 351 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrTitle)); 352 if (fodInfos->ofnInfos.lpstrInitialDir) 353 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrInitialDir)); 354 if (fodInfos->ofnInfos.lpstrCustomFilter) 355 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrCustomFilter)); 356 357 if (fodInfos->ofnInfos.lpstrFile) 358 { 359 /* 360 * We have to clear the buffer before we copy the filename since we don't 361 * support selecting multiple files. We have to make sure that the caller won't 362 * attempt to read past the first filename. 363 */ 364 memset(ofn->lpstrFile, '\0', ofn->nMaxFile); 365 strcpy(ofn->lpstrFile,fodInfos->ofnInfos.lpstrFile); 366 MemFree((LPVOID)fodInfos->ofnInfos.lpstrFile); 367 } 368 if (fodInfos->ofnInfos.lpstrFileTitle) 369 { 370 if (ofn->lpstrFileTitle) 371 strcpy(ofn->lpstrFileTitle, 372 fodInfos->ofnInfos.lpstrFileTitle); 373 MemFree((LPVOID)fodInfos->ofnInfos.lpstrFileTitle); 314 if (lpstrInitialDir) 315 { 316 MemFree((LPVOID)(fodInfos->ofnInfos->lpstrInitialDir)); 317 fodInfos->ofnInfos->lpstrInitialDir = lpstrInitialDir; 374 318 } 375 319 if (lpstrFilter) 320 { 321 MemFree((LPVOID)(fodInfos->ofnInfos->lpstrFilter)); 322 fodInfos->ofnInfos->lpstrFilter = lpstrFilter; 323 } 324 if (lpstrCustomFilter) 325 { 326 MemFree((LPVOID)(fodInfos->ofnInfos->lpstrCustomFilter)); 327 fodInfos->ofnInfos->lpstrCustomFilter = lpstrCustomFilter; 328 } 329 330 ofn->Flags = dwFlags; 331 ofn->hInstance = hInstance; 376 332 MemFree((LPVOID)(fodInfos)); 377 333 return ret; … … 391 347 BOOL ret; 392 348 FileOpenDlgInfos *fodInfos; 349 HINSTANCE hInstance; 350 LPCSTR lpstrFilter = NULL; 351 LPSTR lpstrCustomFilter = NULL; 352 DWORD dwFlags; 393 353 394 354 /* Initialise FileOpenDlgInfos structure*/ 395 355 fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos)); 396 memset(&fodInfos->ofnInfos,'\0',sizeof(*ofn)); 397 fodInfos->ofnInfos.lStructSize = sizeof(*ofn); 398 fodInfos->ofnInfos.hwndOwner = ofn->hwndOwner; 399 fodInfos->ofnInfos.hInstance = MapHModuleLS(ofn->hInstance); 356 357 /* Pass in the original ofn */ 358 fodInfos->ofnInfos = (LPOPENFILENAMEA)ofn; 359 360 /* Save hInstance */ 361 hInstance = fodInfos->ofnInfos->hInstance; 362 fodInfos->ofnInfos->hInstance = MapHModuleLS(ofn->hInstance); 363 364 /* Save lpstrFilter */ 400 365 if (ofn->lpstrFilter) 401 366 { … … 403 368 LPSTR x,y; 404 369 int n; 370 371 lpstrFilter = fodInfos->ofnInfos->lpstrFilter; 405 372 406 373 /* filter is a list... title\0ext\0......\0\0 */ … … 419 386 } 420 387 *x=0; 421 fodInfos->ofnInfos.lpstrFilter = (LPSTR)y; 422 } 423 if (ofn->lpstrCustomFilter) { 388 fodInfos->ofnInfos->lpstrFilter = (LPSTR)y; 389 } 390 /* Save lpstrCustomFilter */ 391 if (ofn->lpstrCustomFilter) 392 { 424 393 LPWSTR s; 425 394 LPSTR x,y; 426 395 int n; 427 396 397 lpstrCustomFilter = fodInfos->ofnInfos->lpstrCustomFilter; 428 398 /* filter is a list... title\0ext\0......\0\0 */ 429 399 s = (LPWSTR)ofn->lpstrCustomFilter; … … 440 410 } 441 411 *x=0; 442 fodInfos->ofnInfos.lpstrCustomFilter = (LPSTR)y; 443 } 444 fodInfos->ofnInfos.nMaxCustFilter = ofn->nMaxCustFilter; 445 fodInfos->ofnInfos.nFilterIndex = ofn->nFilterIndex; 446 if (ofn->nMaxFile) 447 fodInfos->ofnInfos.lpstrFile = (LPSTR)MemAlloc(ofn->nMaxFile); 448 fodInfos->ofnInfos.nMaxFile = ofn->nMaxFile; 449 fodInfos->ofnInfos.nMaxFileTitle = ofn->nMaxFileTitle; 450 if (ofn->nMaxFileTitle) 451 fodInfos->ofnInfos.lpstrFileTitle = (LPSTR)MemAlloc(ofn->nMaxFileTitle); 452 if (ofn->lpstrInitialDir) 453 { 454 fodInfos->ofnInfos.lpstrInitialDir = (LPSTR)MemAlloc(lstrlenW(ofn->lpstrInitialDir)+1); 455 lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpstrInitialDir,ofn->lpstrInitialDir); 456 } 457 if (ofn->lpstrTitle) 458 { 459 fodInfos->ofnInfos.lpstrTitle = (LPSTR)MemAlloc(lstrlenW(ofn->lpstrTitle)+1); 460 lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpstrTitle,ofn->lpstrTitle); 461 } 462 fodInfos->ofnInfos.Flags = ofn->Flags|OFN_WINE|OFN_UNICODE; 463 fodInfos->ofnInfos.nFileOffset = ofn->nFileOffset; 464 fodInfos->ofnInfos.nFileExtension = ofn->nFileExtension; 465 if (ofn->lpstrDefExt) 466 { 467 fodInfos->ofnInfos.lpstrDefExt = (LPSTR)MemAlloc(lstrlenW(ofn->lpstrDefExt)+1); 468 lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpstrDefExt,ofn->lpstrDefExt); 469 } 470 fodInfos->ofnInfos.lCustData = ofn->lCustData; 471 fodInfos->ofnInfos.lpfnHook = (LPOFNHOOKPROC)ofn->lpfnHook; 472 473 if (HIWORD(ofn->lpTemplateName)) 474 { 475 fodInfos->ofnInfos.lpTemplateName = (LPSTR)MemAlloc(lstrlenW(ofn->lpTemplateName)+1); 476 lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpTemplateName,ofn->lpTemplateName); 477 } 478 else 479 { 480 /* resource id */ 481 fodInfos->ofnInfos.lpTemplateName = (LPSTR)ofn->lpTemplateName; 482 } 412 fodInfos->ofnInfos->lpstrCustomFilter = (LPSTR)y; 413 } 414 415 /* Save Flags */ 416 dwFlags = fodInfos->ofnInfos->Flags; 417 fodInfos->ofnInfos->Flags = ofn->Flags|OFN_WINE|OFN_UNICODE; 418 483 419 /* Initialise the dialog property */ 484 420 fodInfos->DlgInfos.dwDlgProp = 0; … … 498 434 499 435 /* Cleaning */ 500 ofn->nFileOffset = fodInfos->ofnInfos.nFileOffset; 501 ofn->nFileExtension = fodInfos->ofnInfos.nFileExtension; 502 503 /* 504 Transfer the combo index in the OPENFILENAME structure; 505 No support for custom filters, so nFilterIndex must be one-based. 506 */ 507 ofn->nFilterIndex = fodInfos->ofnInfos.nFilterIndex; 508 509 if (fodInfos->ofnInfos.lpstrFilter) 510 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrFilter)); 511 if (HIWORD(fodInfos->ofnInfos.lpTemplateName)) 512 MemFree((LPVOID)(fodInfos->ofnInfos.lpTemplateName)); 513 if (fodInfos->ofnInfos.lpstrDefExt) 514 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrDefExt)); 515 if (fodInfos->ofnInfos.lpstrTitle) 516 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrTitle)); 517 if (fodInfos->ofnInfos.lpstrInitialDir) 518 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrInitialDir)); 519 if (fodInfos->ofnInfos.lpstrCustomFilter) 520 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrCustomFilter)); 521 522 if (fodInfos->ofnInfos.lpstrFile) 523 { 524 /* 525 * We have to clear the buffer before we copy the filename since we don't 526 * support selecting multiple files. We have to make sure that the caller won't 527 * attempt to read past the first filename. 528 */ 529 memset(ofn->lpstrFile, '\0', ofn->nMaxFile * sizeof(WCHAR) ); 530 lstrcpyAtoW(ofn->lpstrFile,(fodInfos->ofnInfos.lpstrFile)); 531 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrFile)); 532 } 533 534 if (fodInfos->ofnInfos.lpstrFileTitle) { 535 if (ofn->lpstrFileTitle) 536 lstrcpyAtoW(ofn->lpstrFileTitle, 537 (fodInfos->ofnInfos.lpstrFileTitle)); 538 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrFileTitle)); 539 } 436 /* Restore Flags */ 437 fodInfos->ofnInfos->Flags = dwFlags; 438 439 /* Restore lpstrFilter */ 440 if (fodInfos->ofnInfos->lpstrFilter) 441 { 442 MemFree((LPVOID)(fodInfos->ofnInfos->lpstrFilter)); 443 fodInfos->ofnInfos->lpstrFilter = lpstrFilter; 444 } 445 if (fodInfos->ofnInfos->lpstrCustomFilter) 446 { 447 MemFree((LPVOID)(fodInfos->ofnInfos->lpstrCustomFilter)); 448 fodInfos->ofnInfos->lpstrCustomFilter = lpstrCustomFilter; 449 } 450 451 /* Restore hInstance */ 452 fodInfos->ofnInfos->hInstance = hInstance; 540 453 MemFree((LPVOID)(fodInfos)); 541 454 return ret; 542 543 455 } 544 456 … … 688 600 lParam = (LPARAM) &fodInfos->ofnInfos; 689 601 ArrangeCtrlPositions(hwnd,GetParent(hwnd)); 690 if(fodInfos && (fodInfos->ofnInfos .Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos.lpfnHook)691 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos .lpfnHook,hwnd,uMsg,wParam,lParam);602 if(fodInfos && (fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook) 603 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam); 692 604 return 0; 693 605 } 694 606 } 695 if(fodInfos && (fodInfos->ofnInfos .Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos.lpfnHook )696 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos .lpfnHook,hwnd,uMsg,wParam,lParam);607 if(fodInfos && (fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook ) 608 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam); 697 609 return DefWindowProcA(hwnd,uMsg,wParam,lParam); 698 610 } … … 704 616 HANDLE hDlgTmpl = 0; 705 617 HWND hChildDlg = 0; 706 if (fodInfos->ofnInfos .Flags & OFN_ENABLETEMPLATE || fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATEHANDLE)618 if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATE || fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE) 707 619 { 708 if (fodInfos->ofnInfos .Flags & OFN_ENABLETEMPLATEHANDLE)620 if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE) 709 621 { 710 if( !(template = LockResource( fodInfos->ofnInfos .hInstance)))622 if( !(template = LockResource( fodInfos->ofnInfos->hInstance))) 711 623 { 712 624 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); … … 717 629 else 718 630 { 719 if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos .hInstance),720 (fodInfos->ofnInfos .lpTemplateName), RT_DIALOGA)))631 if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos->hInstance), 632 (fodInfos->ofnInfos->lpTemplateName), RT_DIALOGA))) 721 633 { 722 634 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 723 635 return (HWND)NULL; 724 636 } 725 if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos .hInstance),637 if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos->hInstance), 726 638 hRes )) || 727 639 !(template = LockResource( hDlgTmpl ))) … … 732 644 } 733 645 734 hChildDlg= CreateDialogIndirectParamA(fodInfos->ofnInfos .hInstance,template,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);646 hChildDlg= CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,template,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos); 735 647 if(hChildDlg) 736 648 { … … 739 651 } 740 652 } 741 else if(fodInfos->ofnInfos .Flags & OFN_ENABLEHOOK && fodInfos->ofnInfos.lpfnHook)653 else if(fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK && fodInfos->ofnInfos->lpfnHook) 742 654 { 743 655 RECT rectHwnd; … … 752 664 tmplate.cy = rectHwnd.bottom-rectHwnd.top; 753 665 754 return CreateDialogIndirectParamA(fodInfos->ofnInfos .hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);666 return CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos); 755 667 } 756 668 return (HWND)NULL; … … 774 686 ofnNotify.hdr.idFrom=0; 775 687 ofnNotify.hdr.code = uCode; 776 ofnNotify.lpOFN = &fodInfos->ofnInfos;688 ofnNotify.lpOFN = fodInfos->ofnInfos; 777 689 return SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify); 778 690 } … … 788 700 { 789 701 LPSTR lpstrFileSpec; 790 int reqSize; 791 char lpstrPath[MAX_PATH]; 702 char lpstrCurrentDir[MAX_PATH]=""; 792 703 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); 793 704 if(!fodInfos) 794 return -1;705 return TRUE; 795 706 switch(uMsg) 796 707 { 797 708 case CDM_GETFILEPATH: 709 { 710 char lpstrPathSpec[MAX_PATH]=""; 711 GetDlgItemTextA(hwnd,IDC_FILENAME,(LPSTR)lParam, (int)wParam); 712 lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA((LPSTR)lParam); 713 strcpy(lpstrPathSpec,(LPSTR)lParam); 714 COMDLG32_PathRemoveFileSpecA(lpstrPathSpec); 715 if(!lpstrPathSpec[0]) 716 COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent, 717 lpstrPathSpec); 718 strcat(lpstrPathSpec,"\\"); 719 strcat(lpstrPathSpec,(LPSTR)lParam); 720 strcpy((LPSTR)lParam,(LPSTR)lpstrPathSpec); 721 } 722 return TRUE; 723 case CDM_GETFOLDERPATH: 724 if(lParam) 798 725 { 799 GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath)); 800 lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA(lpstrPath); 801 if (lpstrFileSpec==lpstrPath) { 802 char lpstrCurrentDir[MAX_PATH]; 803 /* Prepend the current path */ 804 COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir); 805 if ((LPSTR)lParam!=NULL) 806 wsnprintfA((LPSTR)lParam,(int)wParam,"%s\\%s",lpstrCurrentDir,lpstrPath); 807 reqSize=strlen(lpstrCurrentDir)+1+strlen(lpstrPath)+1; 808 } else { 809 lstrcpynA((LPSTR)lParam,(LPSTR)lpstrPath,(int)wParam); 810 reqSize=strlen(lpstrPath); 726 if(fodInfos) 727 { 728 COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent, 729 lpstrCurrentDir); 730 strncpy((LPSTR)lParam,lpstrCurrentDir,(int)wParam); 811 731 } 732 else 733 *((LPSTR)lParam)=0; 812 734 } 813 /* return the required buffer size */ 814 return reqSize; 815 case CDM_GETFOLDERPATH: 816 COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath); 817 if ((LPSTR)lParam!=NULL) 818 lstrcpynA((LPSTR)lParam,lpstrPath,(int)wParam); 819 return strlen(lpstrPath); 735 return TRUE; 820 736 case CDM_GETSPEC: 821 reqSize=GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath)); 822 lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA(lpstrPath); 823 if ((LPSTR)lParam!=NULL) 824 lstrcpynA((LPSTR)lParam, lpstrFileSpec, (int)wParam); 825 return strlen(lpstrFileSpec); 737 if(lParam) 738 { 739 GetDlgItemTextA(hwnd,IDC_FILENAME,(LPSTR)lParam, (int)wParam); 740 lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA((LPSTR)lParam); 741 if(lpstrFileSpec) 742 strcpy((LPSTR)lParam, lpstrFileSpec); 743 else 744 *((LPSTR)lParam)=0; 745 } 746 return TRUE; 747 case CDM_SETCONTROLTEXT: 748 if ( 0 != lParam ) 749 SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam ); 750 return TRUE; 826 751 case CDM_HIDECONTROL: 827 case CDM_SETCONTROLTEXT:828 752 case CDM_SETDEFEXT: 829 753 FIXME("CDM_HIDECONTROL,CDM_SETCONTROLTEXT,CDM_SETDEFEXT not implemented\n"); 830 754 return TRUE; 831 755 } 832 return -1;756 return TRUE; 833 757 } 834 758 … … 869 793 870 794 case WM_DESTROY: 871 RemovePropA(hwnd, FileOpenDlgInfosStr); 795 FILEDLG95_Clean(hwnd); 796 RemovePropA(hwnd, FileOpenDlgInfosStr); 797 return FALSE; 798 799 case WM_NOTIFY: 800 { 801 LPNMHDR lpnmh = (LPNMHDR)lParam; 802 UINT stringId = -1; 803 804 /* set up the button tooltips strings */ 805 if(TTN_GETDISPINFOA == lpnmh->code ) 806 { 807 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam; 808 switch(lpnmh->idFrom ) 809 { 810 /* Up folder button */ 811 case FCIDM_TB_UPFOLDER: 812 stringId = IDS_UPFOLDER; 813 break; 814 /* New folder button */ 815 case FCIDM_TB_NEWFOLDER: 816 stringId = IDS_NEWFOLDER; 817 break; 818 /* List option button */ 819 case FCIDM_TB_SMALLICON: 820 stringId = IDS_LISTVIEW; 821 break; 822 /* Details option button */ 823 case FCIDM_TB_REPORTVIEW: 824 stringId = IDS_REPORTVIEW; 825 break; 826 } 827 lpdi->hinst = COMMDLG_hInstance32; 828 lpdi->lpszText = (LPSTR) stringId; 829 } 830 return FALSE; 831 } 872 832 873 833 default : … … 887 847 LPITEMIDLIST pidlItemId; 888 848 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam; 849 DWORD count; 889 850 890 851 TRACE("\n"); … … 894 855 InitCommonControls(); 895 856 #endif 896 857 //MessageBox(hwnd,"WM_INITDIALOG",NULL,MB_OK); 858 dprintf(("CB: FILEDLG95_SHELL_Init")); 859 count = GetTickCount(); 897 860 /* Initialise shell objects */ 898 861 FILEDLG95_SHELL_Init(hwnd); 899 862 dprintf(("CB: FILEDLG95_InitUI %d ms",GetTickCount()-count)); 863 count = GetTickCount(); 900 864 /* Initialise dialog UI */ 901 865 FILEDLG95_InitUI(hwnd); 902 866 dprintf(("CB: FILEDLG95_LOOKIN_Init %d",GetTickCount()-count)); 867 count = GetTickCount(); 903 868 /* Initialize the Look In combo box*/ 904 869 FILEDLG95_LOOKIN_Init(fodInfos->DlgInfos.hwndLookInCB); 905 870 dprintf(("CB: FILEDLG95_FILETYPE_Init %d",GetTickCount()-count)); 871 count = GetTickCount(); 906 872 /* Initialize the filter combo box */ 907 873 FILEDLG95_FILETYPE_Init(hwnd); 908 874 dprintf(("CB: FILEDLG95_FILETYPE_Init done %d",GetTickCount()-count)); 875 count = GetTickCount(); 909 876 /* Get the initial directory pidl */ 910 877 911 if(!(pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder,fodInfos->ofnInfos .lpstrInitialDir)))878 if(!(pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder,fodInfos->ofnInfos->lpstrInitialDir))) 912 879 { 913 880 char path[MAX_PATH]; … … 918 885 919 886 } 920 887 dprintf(("CB: IShellBrowser_BrowseObject %d",GetTickCount()-count)); 888 count = GetTickCount(); 921 889 /* Browse to the initial directory */ 922 890 IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,pidlItemId,SBSP_RELATIVE); 923 891 dprintf(("CB: done WM_INITDIALOG %d",GetTickCount()-count)); 924 892 /* Free pidlItem memory */ 925 893 COMDLG32_SHFree(pidlItemId); … … 958 926 /* Cancel button */ 959 927 case IDCANCEL: 960 FILEDLG95_Clean(hwnd);961 928 EndDialog(hwnd, FALSE); 962 929 break; … … 1064 1031 1065 1032 /* Set the window text with the text specified in the OPENFILENAME structure */ 1066 if(fodInfos->ofnInfos .lpstrTitle)1067 { 1068 SetWindowTextA(hwnd,fodInfos->ofnInfos .lpstrTitle);1033 if(fodInfos->ofnInfos->lpstrTitle) 1034 { 1035 SetWindowTextA(hwnd,fodInfos->ofnInfos->lpstrTitle); 1069 1036 } 1070 1037 else if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) … … 1074 1041 1075 1042 /* Initialise the file name edit control */ 1076 if(fodInfos->ofnInfos.lpstrFile) 1077 { 1078 SetDlgItemTextA(hwnd,IDC_FILENAME,fodInfos->ofnInfos.lpstrFile); 1079 } 1043 if(fodInfos->ofnInfos->lpstrFile) 1044 { 1045 /** 1046 * When passed a fully qualified filename, windows removes 1047 * the path component, before showing it in the control 1048 */ 1049 LPSTR lpstrFileName = NULL; 1050 1051 lpstrFileName = (LPSTR)COMDLG32_PathFindFilenameA(fodInfos->ofnInfos->lpstrFile); 1052 if(NULL != lpstrFileName) 1053 SetDlgItemTextA(hwnd,IDC_FILENAME,lpstrFileName); 1054 else 1055 SetDlgItemTextA(hwnd,IDC_FILENAME,""); 1056 } 1057 1080 1058 /* Must the open as read only check box be checked ?*/ 1081 if(fodInfos->ofnInfos .Flags & OFN_READONLY)1059 if(fodInfos->ofnInfos->Flags & OFN_READONLY) 1082 1060 { 1083 1061 SendDlgItemMessageA(hwnd,IDC_OPENREADONLY,BM_SETCHECK,(WPARAM)TRUE,0); 1084 1062 } 1085 1063 /* Must the open as read only check box be hid ?*/ 1086 if(fodInfos->ofnInfos .Flags & OFN_HIDEREADONLY)1064 if(fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) 1087 1065 { 1088 1066 ShowWindow(GetDlgItem(hwnd,IDC_OPENREADONLY),SW_HIDE); 1067 } 1068 /* Must the help button be hid ?*/ 1069 if (!(fodInfos->ofnInfos->Flags & OFN_SHOWHELP)) 1070 { 1071 ShowWindow(GetDlgItem(hwnd, pshHelp), SW_HIDE); 1072 } 1073 /* Resize the height, if open as read only checkbox ad help button 1074 are hidden */ 1075 if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) && 1076 (!(fodInfos->ofnInfos->Flags & OFN_SHOWHELP)) ) 1077 { 1078 RECT rectDlg, rectHelp, rectCancel; 1079 GetWindowRect(hwnd, &rectDlg); 1080 GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp); 1081 GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel); 1082 /* subtract the height of the help button plus the space between 1083 the help button and the cancel button to the height of the dialog */ 1084 SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left, 1085 (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom), 1086 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER); 1089 1087 } 1090 1088 /* change Open to Save */ … … 1092 1090 { 1093 1091 SetDlgItemTextA(hwnd,IDOK,"Save"); 1092 SetDlgItemTextA(hwnd,IDC_LOOKINSTATIC,"Save &in"); 1094 1093 } 1095 1094 return 0; … … 1097 1096 1098 1097 /*********************************************************************** 1098 * FILEDLG95_OnOpenMultipleFiles 1099 * 1100 * Handles the opening of multiple files. 1101 * 1102 */ 1103 BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPSTR lpstrFileList, UINT nFileCount, UINT sizeUsed) 1104 { 1105 CHAR lpstrPathSpec[MAX_PATH] = ""; 1106 CHAR lpstrTempFileList[MAX_PATH] = ""; 1107 LPSTR lpstrFile; 1108 UINT sizePath; 1109 UINT nCount; 1110 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); 1111 1112 TRACE("\n"); 1113 1114 lpstrFile = fodInfos->ofnInfos->lpstrFile; 1115 1116 COMDLG32_SHGetPathFromIDListA( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec ); 1117 sizePath = lstrlenA( lpstrPathSpec ); 1118 1119 memset( lpstrFile, 0x0, fodInfos->ofnInfos->nMaxFile * sizeof(CHAR) ); 1120 1121 if ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST || 1122 !(fodInfos->ofnInfos->Flags & OFN_EXPLORER )) 1123 { 1124 LPSTR lpstrTemp = lpstrFileList; 1125 1126 for ( nCount = 0; nCount < nFileCount; nCount++ ) 1127 { 1128 WIN32_FIND_DATAA findData; 1129 CHAR lpstrFindFile[MAX_PATH]; 1130 1131 memset( lpstrFindFile, 0x0, MAX_PATH * sizeof(CHAR) ); 1132 1133 lstrcpyA( lpstrFindFile, lpstrPathSpec ); 1134 lstrcatA( lpstrFindFile, "\\" ); 1135 lstrcatA( lpstrFindFile, lpstrTemp ); 1136 1137 if ( FindFirstFileA( lpstrFindFile, &findData ) == INVALID_HANDLE_VALUE ) 1138 { 1139 CHAR lpstrNotFound[100]; 1140 CHAR lpstrMsg[100]; 1141 CHAR tmp[400]; 1142 1143 LoadStringA(COMMDLG_hInstance32, IDS_FILENOTFOUND, lpstrNotFound, 100); 1144 LoadStringA(COMMDLG_hInstance32, IDS_VERIFYFILE, lpstrMsg, 100); 1145 1146 strcpy(tmp, lpstrFindFile); 1147 strcat(tmp, "\n"); 1148 strcat(tmp, lpstrNotFound); 1149 strcat(tmp, "\n"); 1150 strcat(tmp, lpstrMsg); 1151 1152 MessageBoxA(hwnd, 1153 tmp, 1154 fodInfos->ofnInfos->lpstrTitle, 1155 MB_OK | MB_ICONEXCLAMATION); 1156 return FALSE; 1157 } 1158 1159 if (!(fodInfos->ofnInfos->Flags & OFN_EXPLORER )) 1160 { 1161 lstrcatA( lpstrTempFileList, findData.cAlternateFileName); 1162 if ( nCount + 1 < nFileCount) 1163 lstrcatA( lpstrTempFileList, " "); 1164 } 1165 lpstrTemp += strlen(lpstrFileList) + 1; 1166 } 1167 } 1168 1169 if ( fodInfos->ofnInfos->Flags & OFN_EXPLORER ) 1170 { 1171 lstrcpyA( lpstrFile, lpstrPathSpec); 1172 memcpy( lpstrFile + sizePath + 1, lpstrFileList, sizeof(CHAR) * sizeUsed ); 1173 } 1174 else 1175 { 1176 memcpy( lpstrFile, lpstrTempFileList, sizeof(CHAR) * strlen(lpstrTempFileList)); 1177 } 1178 1179 fodInfos->ofnInfos->nFileOffset = sizePath + 1; 1180 fodInfos->ofnInfos->nFileExtension = 0; 1181 1182 /* clean and exit */ 1183 return EndDialog(hwnd,TRUE); 1184 } 1185 1186 /*********************************************************************** 1099 1187 * FILEDLG95_OnOpen 1100 1188 * … … 1105 1193 BOOL FILEDLG95_OnOpen(HWND hwnd) 1106 1194 { 1107 char lpstrSpecifiedByUser[MAX_PATH]; 1195 CHAR lpstrSpecifiedByUser[MAX_PATH] = ""; 1196 CHAR lpstrFileList[MAX_PATH] = ""; 1197 LPSTR lpstrFile; 1198 UINT nStrCharCount = 0; 1199 UINT nFileCount = 0; 1200 UINT nFileIndex = 0; 1201 UINT sizeUsed = 0; 1202 UINT nStrLen = 0; 1203 1108 1204 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); 1109 LPITEMIDLIST pidlSelection;1110 1111 lpstrSpecifiedByUser[0]='\0';1112 1205 1113 1206 TRACE("\n"); 1114 1115 /* Check if there is a selected item in the listview */ 1116 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_USEVIEW) 1117 { 1118 pidlSelection = GetSelectedPidl(fodInfos->Shell.FOIShellView); 1119 GetName(fodInfos->Shell.FOIShellFolder,pidlSelection,SHGDN_NORMAL,lpstrSpecifiedByUser); 1120 COMDLG32_SHFree((LPVOID)pidlSelection); 1121 } 1122 else 1123 /* Get the text from the filename edit */ 1124 GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrSpecifiedByUser,MAX_PATH); 1125 1126 if(strlen(lpstrSpecifiedByUser)) 1207 //CB: optimize this function! 1208 /* If a folder is selected browse folder */ 1209 if (BrowseSelectedFolder(hwnd)) 1210 return FALSE; 1211 1212 lpstrFile = fodInfos->ofnInfos->lpstrFile; 1213 1214 GetDlgItemTextA(hwnd, IDC_FILENAME, lpstrSpecifiedByUser, MAX_PATH); 1215 nStrLen = strlen(lpstrSpecifiedByUser); 1216 1217 while ( nStrCharCount <= nStrLen ) 1218 { 1219 if ( lpstrSpecifiedByUser[nStrCharCount]=='"' ) 1220 { 1221 nStrCharCount++; 1222 1223 while ((lpstrSpecifiedByUser[nStrCharCount]!='"') && 1224 (nStrCharCount <= nStrLen)) 1225 { 1226 lpstrFileList[nFileIndex++] = lpstrSpecifiedByUser[nStrCharCount]; 1227 nStrCharCount++; 1228 sizeUsed++; 1229 } 1230 lpstrFileList[nFileIndex++] = '\0'; 1231 sizeUsed++; 1232 nFileCount++; 1233 } 1234 nStrCharCount++; 1235 } 1236 1237 if(nFileCount > 0) 1238 return FILEDLG95_OnOpenMultipleFiles(hwnd, lpstrFileList, nFileCount, sizeUsed); 1239 1240 if (nStrLen) 1127 1241 { 1128 1242 LPSHELLFOLDER psfDesktop; … … 1130 1244 LPSTR lpstrFileSpec; 1131 1245 LPSTR lpstrTemp; 1132 char lpstrPathSpec[MAX_PATH]; 1133 char lpstrCurrentDir[MAX_PATH]; 1134 char lpstrPathAndFile[MAX_PATH]; 1135 1136 lpstrPathSpec[0] = '\0'; 1137 lpstrCurrentDir[0] = '\0'; 1138 lpstrPathAndFile[0] = '\0'; 1246 char lpstrPathSpec[MAX_PATH] = ""; 1247 char lpstrCurrentDir[MAX_PATH] = ""; 1248 char lpstrPathAndFile[MAX_PATH] = ""; 1139 1249 1140 1250 /* Separate the file spec from the path spec … … 1143 1253 C:\TEXT1\TEXT2 C:\TEXT1 TEXT2 1144 1254 */ 1255 if (nFileCount == 0) 1256 { 1145 1257 lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA(lpstrSpecifiedByUser); 1146 1258 strcpy(lpstrPathSpec,lpstrSpecifiedByUser); 1147 1259 COMDLG32_PathRemoveFileSpecA(lpstrPathSpec); 1260 } 1148 1261 1149 1262 /* Get the index of the selected item in the filetype combo box */ 1150 fodInfos->ofnInfos .nFilterIndex = (DWORD) CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);1263 fodInfos->ofnInfos->nFilterIndex = (DWORD) CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); 1151 1264 /* nFilterIndex is 1 based while combo GetCurSel return zero based index */ 1152 fodInfos->ofnInfos .nFilterIndex++;1265 fodInfos->ofnInfos->nFilterIndex++; 1153 1266 1154 1267 /* Get the current directory name */ … … 1164 1277 case '\\': 1165 1278 { 1166 int lenPathSpec=strlen(lpstrPathSpec); 1167 INT iCopy = (lenPathSpec!=0?2:3); 1168 memmove(lpstrPathSpec+iCopy,lpstrPathSpec,lenPathSpec); 1169 strncpy(lpstrPathSpec,lpstrCurrentDir,iCopy); 1279 INT iCopy = 2; 1280 char lpstrTmp[MAX_PATH] = ""; 1281 if(!strlen(lpstrPathSpec)) 1282 iCopy = 3; 1283 strncpy(lpstrTmp,lpstrCurrentDir,iCopy); 1284 strcat(lpstrTmp,lpstrPathSpec); 1285 strcpy(lpstrPathSpec,lpstrTmp); 1170 1286 } 1171 1287 break; … … 1174 1290 { 1175 1291 INT iSize; 1176 char lpstrTmp2[MAX_PATH] ;1292 char lpstrTmp2[MAX_PATH] = ""; 1177 1293 LPSTR lpstrTmp = strrchr(lpstrCurrentDir,'\\'); 1178 1179 1294 iSize = lpstrTmp - lpstrCurrentDir; 1180 1295 strncpy(lpstrTmp2,lpstrCurrentDir,iSize + 1); 1181 1296 if(strlen(lpstrSpecifiedByUser) <= 3) 1182 *lpstrFileSpec='\0';1297 strcpy(lpstrFileSpec,""); 1183 1298 if(strcmp(lpstrPathSpec,"..")) 1184 1299 strcat(lpstrTmp2,&lpstrPathSpec[3]); … … 1188 1303 default: 1189 1304 { 1190 char lpstrTmp[MAX_PATH]; 1191 1305 char lpstrTmp[MAX_PATH] = ""; 1192 1306 if(strcmp(&lpstrCurrentDir[strlen(lpstrCurrentDir)-1],"\\")) 1193 1307 strcat(lpstrCurrentDir,"\\"); … … 1216 1330 { 1217 1331 /* Path does not exist */ 1218 if(fodInfos->ofnInfos .Flags & OFN_PATHMUSTEXIST)1332 if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST) 1219 1333 { 1220 1334 MessageBoxA(hwnd, 1221 1335 "Path does not exist", 1222 fodInfos->ofnInfos .lpstrTitle,1336 fodInfos->ofnInfos->lpstrTitle, 1223 1337 MB_OK | MB_ICONEXCLAMATION); 1224 1338 return FALSE; … … 1273 1387 } 1274 1388 1389 { 1390 HANDLE hFile; 1391 WIN32_FIND_DATAA stffile; 1275 1392 /* browse if the user specified a directory */ 1393 hFile = FindFirstFileA(lpstrFileSpec, &stffile); 1394 if ( hFile != INVALID_HANDLE_VALUE ) 1395 { 1396 FindClose (hFile); 1397 if (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 1276 1398 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1277 1399 lpstrFileSpec); 1400 else 1401 { 1402 // if there is an extention, then get the Pidl otherwise 1403 // we are going to need to add the extention 1404 if(strrchr(lpstrFileSpec,'.')) 1405 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1406 lpstrFileSpec); 1407 else 1408 browsePidl=NULL; 1409 } 1410 } 1411 else 1412 browsePidl=NULL; 1413 } 1414 1278 1415 if (!browsePidl) /* not a directory check the specified file exists */ 1279 1416 { 1417 int i; 1280 1418 int iExt; 1281 1419 char lpstrFileSpecTemp[MAX_PATH] = ""; … … 1285 1423 iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); 1286 1424 lpOrg = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, iExt); 1425 if (lpOrg == (LPSTR)-1) 1426 lpOrg = NULL; // we get -1 if the filetype LB is empty 1427 1287 1428 lpstrExt = lpOrg; 1288 1429 1289 1430 /* 1290 add user specified extentions to the file one by one and 1291 check if the file exists 1431 Simply take the first one of the list as default. 1432 Otherwise the user must specify which extention they want. 1433 Also, make sure we don't have a .*, in this case simply 1434 forget about the extention 1292 1435 */ 1293 while(lpOrg)1294 {1295 int i;1296 1436 lpstrExt = strchr(lpOrg, ';'); 1297 1437 if (lpstrExt) … … 1309 1449 if (strchr(lpBuf, '.')) 1310 1450 strcat(lpstrFileSpecTemp, (strchr(lpBuf, '.')) + 1); 1311 } else {1312 if (strchr(lpBuf, '.'))1313 strcat(lpstrFileSpecTemp, strchr(lpBuf, '.'));1314 1451 } 1452 else 1453 strcat(lpstrFileSpecTemp, strchr(lpBuf, '.')); 1315 1454 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1316 1455 lpstrFileSpecTemp); 1317 1456 MemFree((void *)lpBuf); 1318 1457 if (browsePidl) 1319 {1320 1458 strcpy(lpstrFileSpec,lpstrFileSpecTemp); 1321 break;1322 }1323 1459 if (lpstrExt) 1324 1460 lpOrg = lpstrExt+1; 1325 1461 else 1326 1462 lpOrg = NULL; 1327 }1328 1463 } 1329 1464 … … 1346 1481 SBSP_RELATIVE))) 1347 1482 { 1348 if(fodInfos->ofnInfos .Flags & OFN_PATHMUSTEXIST)1483 if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST) 1349 1484 { 1350 1485 MessageBoxA(hwnd, 1351 1486 "Path does not exist", 1352 fodInfos->ofnInfos .lpstrTitle,1487 fodInfos->ofnInfos->lpstrTitle, 1353 1488 MB_OK | MB_ICONEXCLAMATION); 1354 1489 COMDLG32_SHFree(browsePidl); … … 1362 1497 /* The file does exist, so ask the user if we should overwrite it */ 1363 1498 if((fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && 1364 (fodInfos->ofnInfos .Flags & OFN_OVERWRITEPROMPT))1499 (fodInfos->ofnInfos->Flags & OFN_OVERWRITEPROMPT)) 1365 1500 { 1366 1501 strcpy(lpstrFileExist, lpstrFileSpec); … … 1369 1504 nMsgBoxRet = MessageBoxA(hwnd, 1370 1505 lpstrFileExist, 1371 fodInfos->ofnInfos .lpstrTitle,1506 fodInfos->ofnInfos->lpstrTitle, 1372 1507 MB_YESNO | MB_ICONEXCLAMATION); 1373 1508 if (nMsgBoxRet == IDNO) … … 1385 1520 /* The selected file does not exist */ 1386 1521 /* Tell the user the selected does not exist */ 1387 if(fodInfos->ofnInfos .Flags & OFN_FILEMUSTEXIST)1522 if(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) 1388 1523 { 1389 1524 char lpstrNotFound[100]; … … 1400 1535 100); 1401 1536 1402 strcpy(tmp,fodInfos->ofnInfos .lpstrFile);1537 strcpy(tmp,fodInfos->ofnInfos->lpstrFile); 1403 1538 strcat(tmp,"\n"); 1404 1539 strcat(tmp,lpstrNotFound); … … 1408 1543 MessageBoxA(hwnd, 1409 1544 tmp, 1410 fodInfos->ofnInfos .lpstrTitle,1545 fodInfos->ofnInfos->lpstrTitle, 1411 1546 MB_OK | MB_ICONEXCLAMATION); 1412 1547 return FALSE; 1413 1548 } 1414 1549 /* Ask the user if he wants to create the file*/ 1415 if(fodInfos->ofnInfos .Flags & OFN_CREATEPROMPT)1550 if(fodInfos->ofnInfos->Flags & OFN_CREATEPROMPT) 1416 1551 { 1417 1552 char tmp[100]; … … 1419 1554 LoadStringA(COMMDLG_hInstance32,IDS_CREATEFILE,tmp,100); 1420 1555 1421 if(IDYES == MessageBoxA(hwnd,tmp,fodInfos->ofnInfos .lpstrTitle,1556 if(IDYES == MessageBoxA(hwnd,tmp,fodInfos->ofnInfos->lpstrTitle, 1422 1557 MB_YESNO | MB_ICONQUESTION)) 1423 1558 { 1424 1559 /* Create the file, clean and exit */ 1425 FILEDLG95_Clean(hwnd);1426 1560 return EndDialog(hwnd,TRUE); 1427 1561 } … … 1429 1563 } 1430 1564 } 1565 /* check the write access to the current directory before opening the selected file */ 1566 if((fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && (fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)) 1567 { 1568 HANDLE hfile; 1569 char testFile[MAX_PATH]; 1570 1571 strcpy(testFile,lpstrPathSpec); 1572 strcat(testFile,"_tes_13.579"); 1573 1574 hfile = CreateFileA(testFile,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0); 1575 1576 switch(GetLastError()) 1577 { 1578 case ERROR_ACCESS_DENIED: 1579 case ERROR_WRITE_PROTECT: 1580 case ERROR_PATH_NOT_FOUND: 1581 case ERROR_FILE_NOT_FOUND: 1582 { 1583 char strAccessDenied[MAX_PATH + 100]; 1584 strcpy(strAccessDenied,lpstrPathSpec); 1585 strcat(strAccessDenied,lpstrFileSpec); 1586 strcat(strAccessDenied,"\nWrite access denied for this file !"); 1587 MessageBoxA(hwnd,strAccessDenied,fodInfos->ofnInfos->lpstrTitle,MB_OK | MB_ICONEXCLAMATION); 1588 return FALSE; 1589 } 1590 } 1591 1592 if (hfile != INVALID_HANDLE_VALUE) 1593 { 1594 CloseHandle(hfile); 1595 DeleteFileA(testFile); 1596 } 1597 1598 } 1431 1599 1432 1600 /* Open the selected file */ … … 1457 1625 } 1458 1626 1459 if(!strcmp(&lpstrExt[1],"*") && fodInfos->ofnInfos.lpstrDefExt) 1460 { 1461 lpstrExt = MemAlloc(strlen(fodInfos->ofnInfos.lpstrDefExt)+2); 1462 strcat(lpstrExt,"."); 1463 strcat(lpstrExt,(LPSTR) fodInfos->ofnInfos.lpstrDefExt); 1627 if(strcmp(lpstrExt,".*") != 0) 1628 { 1629 /* OPEN DIALOG: Let's see if the file exists with the current extention, 1630 if not return the file without the extention. 1631 SAVE DIALOG: Concatenate the extention to the file. 1632 */ 1633 1634 if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)) 1635 { 1636 LPSTR lpstrFindFile; 1637 WIN32_FIND_DATAA fd; 1638 1639 lpstrFindFile = MemAlloc(strlen(lpstrPathAndFile)+strlen(lpstrExt)); 1640 strcpy(lpstrFindFile, lpstrPathAndFile); 1641 strcat(lpstrFindFile, lpstrExt); 1642 if(FindFirstFileA(lpstrFindFile, &fd) != INVALID_HANDLE_VALUE) 1643 strcat(lpstrPathAndFile,lpstrExt); 1644 MemFree(lpstrFindFile); 1645 } 1646 else 1647 strcat(lpstrPathAndFile,lpstrExt); 1464 1648 } 1465 strcat(lpstrPathAndFile,lpstrExt);1649 MemFree( lpstrExt ); 1466 1650 } 1467 1651 } 1468 1652 /* Check that size size of the file does not exceed buffer size */ 1469 if(strlen(lpstrPathAndFile) > fodInfos->ofnInfos .nMaxFile)1653 if(strlen(lpstrPathAndFile) > fodInfos->ofnInfos->nMaxFile) 1470 1654 { 1471 1655 /* set error FNERR_BUFFERTOSMALL */ 1472 FILEDLG95_Clean(hwnd);1473 1656 return EndDialog(hwnd,FALSE); 1474 1657 } 1475 strcpy(fodInfos->ofnInfos.lpstrFile,lpstrPathAndFile); 1658 strcpy(fodInfos->ofnInfos->lpstrFile,lpstrPathAndFile); 1659 fodInfos->ofnInfos->lpstrFile[strlen(lpstrPathAndFile)] = '\0'; 1660 fodInfos->ofnInfos->lpstrFile[strlen(lpstrPathAndFile)+1] = '\0'; 1476 1661 1477 1662 /* Set the lpstrFileTitle of the OPENFILENAME structure */ 1478 if(fodInfos->ofnInfos .lpstrFileTitle)1479 strncpy(fodInfos->ofnInfos .lpstrFileTitle,1663 if(fodInfos->ofnInfos->lpstrFileTitle) 1664 strncpy(fodInfos->ofnInfos->lpstrFileTitle, 1480 1665 lpstrFileSpec, 1481 fodInfos->ofnInfos .nMaxFileTitle);1666 fodInfos->ofnInfos->nMaxFileTitle); 1482 1667 1483 1668 /* Check if the file is to be opened as read only */ … … 1485 1670 IDC_OPENREADONLY, 1486 1671 BM_GETSTATE,0,0)) 1487 SetFileAttributesA(fodInfos->ofnInfos .lpstrFile,1672 SetFileAttributesA(fodInfos->ofnInfos->lpstrFile, 1488 1673 FILE_ATTRIBUTE_READONLY); 1489 1674 1490 1675 /* nFileExtension and nFileOffset of OPENFILENAME structure */ 1491 lpstrTemp = strrchr(fodInfos->ofnInfos .lpstrFile,'\\');1492 fodInfos->ofnInfos .nFileOffset = lpstrTemp - fodInfos->ofnInfos.lpstrFile + 1;1493 lpstrTemp = strrchr(fodInfos->ofnInfos .lpstrFile,'.');1494 fodInfos->ofnInfos .nFileExtension = lpstrTemp - fodInfos->ofnInfos.lpstrFile + 1;1676 lpstrTemp = strrchr(fodInfos->ofnInfos->lpstrFile,'\\'); 1677 fodInfos->ofnInfos->nFileOffset = lpstrTemp - fodInfos->ofnInfos->lpstrFile + 1; 1678 lpstrTemp = strrchr(fodInfos->ofnInfos->lpstrFile,'.'); 1679 fodInfos->ofnInfos->nFileExtension = lpstrTemp - fodInfos->ofnInfos->lpstrFile + 1; 1495 1680 1496 1681 1497 1682 /* clean and exit */ 1498 FILEDLG95_Clean(hwnd);1499 1683 return EndDialog(hwnd,TRUE); 1500 1684 } … … 1527 1711 fodInfos->ShellInfos.hwndOwner = hwnd; 1528 1712 1529 fodInfos->ShellInfos.folderSettings.fFlags = FWF_AUTOARRANGE | FWF_ALIGNLEFT; 1713 fodInfos->ShellInfos.folderSettings.fFlags = 0; 1714 /* Disable multi-select if flag not set */ 1715 if (!(fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT)) 1716 { 1717 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL; 1718 } 1719 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_AUTOARRANGE | FWF_ALIGNLEFT; 1530 1720 fodInfos->ShellInfos.folderSettings.ViewMode = FVM_LIST; 1531 1721 … … 1654 1844 char lpstrText[128+MAX_PATH]; 1655 1845 char lpstrTempText[128]; 1656 char lpstrCaption[ 256];1846 char lpstrCaption[32]; 1657 1847 1658 1848 /* Cannot Create folder because of permissions */ … … 1695 1885 TRACE("\n"); 1696 1886 1697 if(fodInfos->ofnInfos .lpstrFilter)1887 if(fodInfos->ofnInfos->lpstrFilter) 1698 1888 { 1699 1889 int iStrIndex = 0; … … 1712 1902 1713 1903 /* Get the title */ 1714 lpstrTmp = (&((LPBYTE)fodInfos->ofnInfos .lpstrFilter)[iStrIndex]);1904 lpstrTmp = (&((LPBYTE)fodInfos->ofnInfos->lpstrFilter)[iStrIndex]); 1715 1905 if(!strlen(lpstrTmp)) 1716 1906 break; 1717 1907 iStrIndex += strlen(lpstrTmp) +1; 1718 1908 /* Get the extension */ 1719 lpstrExtTmp = (&((LPBYTE)fodInfos->ofnInfos .lpstrFilter)[iStrIndex]);1909 lpstrExtTmp = (&((LPBYTE)fodInfos->ofnInfos->lpstrFilter)[iStrIndex]); 1720 1910 if(!lpstrExtTmp) 1721 1911 break; … … 1738 1928 1739 1929 /* set default filter index */ 1740 if(fodInfos->ofnInfos .nFilterIndex == 0 && fodInfos->ofnInfos.lpstrCustomFilter == NULL)1741 fodInfos->ofnInfos .nFilterIndex = 1;1930 if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->ofnInfos->lpstrCustomFilter == NULL) 1931 fodInfos->ofnInfos->nFilterIndex = 1; 1742 1932 /* First, check to make sure our index isn't out of bounds. */ 1743 if ( fodInfos->ofnInfos .nFilterIndex > iPos )1744 fodInfos->ofnInfos .nFilterIndex = iPos;1933 if ( fodInfos->ofnInfos->nFilterIndex > iPos ) 1934 fodInfos->ofnInfos->nFilterIndex = iPos; 1745 1935 1746 1936 1747 1937 /* Get the current index selection. */ 1748 1938 CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, 1749 fodInfos->ofnInfos .nFilterIndex-1);1939 fodInfos->ofnInfos->nFilterIndex-1); 1750 1940 1751 1941 /* Get the corresponding text string from the combo box. */ 1752 1942 lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, 1753 fodInfos->ofnInfos.nFilterIndex-1); 1943 fodInfos->ofnInfos->nFilterIndex-1); 1944 1945 if ((INT)lpstrFilter == -1) 1946 lpstrFilter = NULL; // we get -1 if the control is empty 1754 1947 1755 1948 if(lpstrFilter) … … 1774 1967 switch(wNotifyCode) 1775 1968 { 1776 case CBN_ CLOSEUP:1969 case CBN_SELENDOK: 1777 1970 { 1778 1971 LPSTR lpstrFilter; … … 1780 1973 /* Get the current item of the filetype combo box */ 1781 1974 int iItem = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); 1975 1976 /* set the current filter index - indexed from 1 */ 1977 fodInfos->ofnInfos->nFilterIndex = iItem + 1; 1782 1978 1783 1979 /* Set the current filter with the current selection */ … … 1870 2066 CBSetItemHeight(hwndCombo,0,GetSystemMetrics(SM_CYSMICON)); 1871 2067 2068 #ifndef SHELL_NO_DESKTOP 1872 2069 /* Initialise data of Desktop folder */ 1873 2070 COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidlTmp); 1874 2071 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND); 1875 2072 COMDLG32_SHFree(pidlTmp); 2073 #endif 1876 2074 1877 2075 COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DRIVES,&pidlDrives); … … 1934 2132 int iIndentation; 1935 2133 LPSFOLDER tmpFolder; 2134 INT iIcon; 1936 2135 1937 2136 LookInInfos *liInfos = (LookInInfos *)GetPropA(pDIStruct->hwndItem,LookInInfosStr); … … 1942 2141 return 0; 1943 2142 1944 if( !(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(pDIStruct->hwndItem,2143 if((LPSFOLDER)CB_ERR == (tmpFolder = (LPSFOLDER) CBGetItemDataPtr(pDIStruct->hwndItem, 1945 2144 pDIStruct->itemID))) 1946 2145 return 0; … … 1957 2156 &sfi, 1958 2157 sizeof (SHFILEINFOA), 1959 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ OPENICON | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME);2158 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME); 1960 2159 len = strlen(sfi.szDisplayName)+1; 1961 2160 tmpFolder->szDisplayName = MemAlloc(len); … … 1963 2162 tmpFolder->iIcon = sfi.iIcon; 1964 2163 } 2164 2165 if((pDIStruct->itemID == liInfos->uSelectedItem) || (pDIStruct->itemState & ODS_COMBOBOXEDIT)) 2166 { 2167 if (!tmpFolder->iSelIcon) 2168 { 2169 SHFILEINFOA sfi2; 2170 2171 COMDLG32_SHGetFileInfoA((LPCSTR)tmpFolder->pidlItem,0,&sfi2,sizeof(SHFILEINFOA), 2172 SHGFI_PIDL | SHGFI_SMALLICON | 2173 SHGFI_OPENICON | SHGFI_SYSICONINDEX); 2174 tmpFolder->iSelIcon = sfi2.iIcon; 2175 } 2176 iIcon = tmpFolder->iSelIcon; 2177 } else iIcon = tmpFolder->iIcon; 2178 1965 2179 1966 2180 /* Is this item selected ?*/ … … 2001 2215 /* Draw the icon from the image list */ 2002 2216 COMDLG32_ImageList_Draw(tmpFolder->ilItemImage, 2003 tmpFolder->iIcon,2217 iIcon, 2004 2218 pDIStruct->hDC, 2005 2219 rectIcon.left, … … 2029 2243 switch(wNotifyCode) 2030 2244 { 2031 case CBN_ CLOSEUP:2245 case CBN_SELENDOK: 2032 2246 { 2033 2247 LPSFOLDER tmpFolder; … … 2064 2278 LPITEMIDLIST pidlNext; 2065 2279 SHFILEINFOA sfi; 2066 SFOLDER *tmpFolder = MemAlloc(sizeof(SFOLDER));2280 SFOLDER *tmpFolder; 2067 2281 LookInInfos *liInfos; 2068 2282 2069 2283 TRACE("\n"); 2284 2285 if(!pidl) 2286 return -1; 2070 2287 2071 2288 if(!(liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr))) 2072 2289 return -1; 2073 2290 2291 tmpFolder = MemAlloc(sizeof(SFOLDER)); 2074 2292 tmpFolder->m_iIndent = 0; 2075 2293 tmpFolder->szDisplayName = NULL; 2076 2077 if(!pidl)2078 return -1;2079 2294 2080 2295 /* Calculate the indentation of the item in the lookin*/ … … 2094 2309 &sfi, 2095 2310 sizeof(sfi), 2096 SHGFI_ ATTRIBUTES);2311 SHGFI_PIDL | SHGFI_ATTRIBUTES); 2097 2312 2098 2313 if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM)) … … 2115 2330 } 2116 2331 2332 MemFree(tmpFolder); 2117 2333 return -1; 2118 2119 2334 } 2120 2335 … … 2433 2648 } 2434 2649 } 2650 2651 /*********************************************************************** 2652 * BrowseSelectedFolder 2653 * 2654 */ 2655 static BOOL BrowseSelectedFolder(HWND hwnd) 2656 { 2657 BOOL bBrowseSelFolder = FALSE; 2658 2659 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); 2660 2661 if (GetNumSelected(fodInfos->Shell.FOIShellView) == 1) 2662 { 2663 LPITEMIDLIST pidlSelection; 2664 ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; 2665 2666 /* get the file selected */ 2667 EnumSelectedPidls( fodInfos->Shell.FOIShellView, 0, &pidlSelection ); 2668 IShellFolder_GetAttributesOf( fodInfos->Shell.FOIShellFolder, 1, &pidlSelection, &uAttr ); 2669 if ( uAttr & SFGAO_FOLDER ) 2670 { 2671 if ( FAILED( IShellBrowser_BrowseObject( fodInfos->Shell.FOIShellBrowser, 2672 pidlSelection, SBSP_RELATIVE ) ) ) 2673 { 2674 MessageBoxA( hwnd, "Path does not exist", fodInfos->ofnInfos->lpstrTitle, 2675 MB_OK | MB_ICONEXCLAMATION ); 2676 } 2677 2678 bBrowseSelFolder = TRUE; 2679 } 2680 COMDLG32_SHFree( pidlSelection ); 2681 } 2682 2683 return bBrowseSelFolder; 2684 } 2685
Note:
See TracChangeset
for help on using the changeset viewer.
