Changeset 4511 for trunk/src/comdlg32/filedlgbrowser.c
- Timestamp:
 - Oct 21, 2000, 8:42:42 PM (25 years ago)
 - File:
 - 
      
- 1 edited
 
- 
          
  trunk/src/comdlg32/filedlgbrowser.c (modified) (32 diffs)
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
trunk/src/comdlg32/filedlgbrowser.c
r3256 r4511 1 /* $Id: filedlgbrowser.c,v 1.5 2000-03-28 15:26:48 cbratschi Exp $ */2 1 /* 3 2 * Implementation of IShellBrowser for the File Open common dialog 3 * 4 4 * 5 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)6 * Project Odin Software License can be found in LICENSE.TXT7 *8 * Corel WINE 20000324 level9 5 */ 10 6 … … 22 18 #include "unknwn.h" 23 19 #include "filedlgbrowser.h" 20 #include "windef.h" 21 #include "wingdi.h" 24 22 #include "winuser.h" 23 #include "wine/winestring.h" 25 24 #include "heap.h" 25 #include "shlguid.h" 26 26 #include "wine/obj_dataobject.h" 27 27 #include "debugtools.h" 28 28 #include "cdlg.h" 29 #include "wine/undocshell.h" 30 31 DEFAULT_DEBUG_CHANNEL(commdlg) 32 33 #define SETDefFormatEtc(fe,cf,med) \ 34 { \ 35 (fe).cfFormat = cf;\ 36 (fe).dwAspect = DVASPECT_CONTENT; \ 37 (fe).ptd =NULL;\ 38 (fe).tymed = med;\ 39 (fe).lindex = -1;\ 40 }; 41 29 30 DEFAULT_DEBUG_CHANNEL(commdlg); 42 31 43 32 /************************************************************************** … … 96 85 * External Prototypes 97 86 */ 98 extern const char *FileOpenDlgInfosStr; 87 extern const char *FileOpenDlgInfosStr; 99 88 100 89 extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName); … … 121 110 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr); 122 111 123 sb=(IShellBrowserImpl*) SHAlloc(sizeof(IShellBrowserImpl));112 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl)); 124 113 125 114 /* Initialisation of the member variables */ … … 131 120 sb->lpVtbl2 = &IShellBrowserImpl_ICommDlgBrowser_Vtbl; 132 121 133 COMDLG32_SHGetSpecialFolderLocation(hwndOwner, 134 CSIDL_DESKTOP, 122 COMDLG32_SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP, 135 123 &fodInfos->ShellInfos.pidlAbsCurrent); 136 124 … … 155 143 */ 156 144 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface, 157 REFIID riid, 145 REFIID riid, 158 146 LPVOID *ppvObj) 159 147 { … … 165 153 166 154 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/ 167 { *ppvObj = This; 155 { *ppvObj = This; 168 156 } 169 157 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/ … … 207 195 TRACE("(%p)\n", This); 208 196 209 if (!--(This->ref)) 210 { 211 COMDLG32_SHFree(This);197 if (!--(This->ref)) 198 { 199 HeapFree(GetProcessHeap(),0, This); 212 200 return 0; 213 201 } … … 227 215 * 228 216 * Note : We will never be window less in the File Open dialog 229 * 230 */ 231 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface, 217 * 218 */ 219 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface, 232 220 HWND * phwnd) 233 221 { … … 241 229 *phwnd = This->hwndOwner; 242 230 243 return (*phwnd) ? S_OK : E_UNEXPECTED; 231 return (*phwnd) ? S_OK : E_UNEXPECTED; 244 232 245 233 } … … 268 256 * See Windows documentation on IShellBrowser::BrowseObject for more details 269 257 * 270 * This function will override user specified flags and will always 271 * use SBSP_DEFBROWSER and SBSP_DEFMODE. 272 */ 273 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface, 274 LPCITEMIDLIST pidl, 258 * This function will override user specified flags and will always 259 * use SBSP_DEFBROWSER and SBSP_DEFMODE. 260 */ 261 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface, 262 LPCITEMIDLIST pidl, 275 263 UINT wFlags) 276 264 { … … 280 268 FileOpenDlgInfos *fodInfos; 281 269 LPITEMIDLIST pidlTmp; 282 283 ICOM_THIS(IShellBrowserImpl, iface); 284 285 TRACE("(%p)\n", This); 270 HWND hwndView; 271 HWND hDlgWnd; 272 BOOL bViewHasFocus; 273 274 ICOM_THIS(IShellBrowserImpl, iface); 275 276 TRACE("(%p)(%p,0x%08x)\n", This, pidl, wFlags); 286 277 287 278 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); … … 290 281 if(wFlags & SBSP_RELATIVE) 291 282 { 292 283 293 284 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */ 294 hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder, 295 pidl, 296 NULL, 297 &IID_IShellFolder, 298 (LPVOID *)&psfTmp); 299 if(FAILED(hRes)) 285 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder, 286 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp))) 300 287 { 301 return hRes; 288 ERR("bind to object failed\n"); 289 return hRes; 302 290 } 303 291 /* create an absolute pidl */ 304 292 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent, 305 293 (LPITEMIDLIST)pidl); 306 307 294 } 308 295 else if(wFlags & SBSP_PARENT) 309 296 { 310 297 /* Browse the parent folder (ignores the pidl) */ 311 312 298 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent); 313 299 psfTmp = GetShellFolderFromPidl(pidlTmp); 314 300 315 301 } 316 else 302 else /* SBSP_ABSOLUTE is 0x0000 */ 317 303 { 318 304 /* An absolute pidl (relative from the desktop) */ … … 320 306 psfTmp = GetShellFolderFromPidl(pidlTmp); 321 307 } 322 323 324 /* Retrieve the IShellFolder interface of the pidl specified folder */ 325 if(!psfTmp) 326 return E_FAIL; 327 328 /* If the pidl to browse to is equal to the actual pidl ... 308 309 if(!psfTmp) return E_FAIL; 310 311 /* If the pidl to browse to is equal to the actual pidl ... 329 312 do nothing and pretend you did it*/ 330 313 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent)) 331 314 { 332 315 IShellFolder_Release(psfTmp); 333 COMDLG32_SHFree(pidlTmp);316 COMDLG32_SHFree(pidlTmp); 334 317 return NOERROR; 335 318 } 336 #ifdef SHELL_NO_DESKTOP 337 338 if(pidlTmp->mkid.cb == 0x00) 339 { 340 IShellFolder_Release(psfTmp); 341 COMDLG32_SHFree(pidlTmp); 342 return NOERROR; 343 } 344 #endif 345 346 /* Release the current fodInfos->Shell.FOIShellFolder and update its value */ 347 IShellFolder_Release(fodInfos->Shell.FOIShellFolder); 319 320 /* Release the current DataObject */ 321 if (fodInfos->Shell.FOIDataObject) 322 { 323 IDataObject_Release(fodInfos->Shell.FOIDataObject); 324 fodInfos->Shell.FOIDataObject = NULL; 325 } 326 327 /* Create the associated view */ 328 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner, 329 &IID_IShellView, (LPVOID *)&psvTmp))) return hRes; 330 331 /* Check if listview has focus */ 332 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus()); 333 334 /* Get the foldersettings from the old view */ 335 if(fodInfos->Shell.FOIShellView) 336 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings); 337 338 /* Release the old fodInfos->Shell.FOIShellView and update its value. 339 We have to update this early since ShellView_CreateViewWindow of native 340 shell32 calls OnStateChange and needs the correct view here.*/ 341 if(fodInfos->Shell.FOIShellView) 342 { 343 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView); 344 IShellView_Release(fodInfos->Shell.FOIShellView); 345 } 346 fodInfos->Shell.FOIShellView = psvTmp; 347 348 /* Release old FOIShellFolder and update its value */ 349 if (fodInfos->Shell.FOIShellFolder) 350 IShellFolder_Release(fodInfos->Shell.FOIShellFolder); 348 351 fodInfos->Shell.FOIShellFolder = psfTmp; 349 352 350 /* Create the associated view */ 351 if(SUCCEEDED(hRes = IShellFolder_CreateViewObject(psfTmp, 352 fodInfos->ShellInfos.hwndOwner, 353 &IID_IShellView, 354 (LPVOID *)&psvTmp))) 355 { 356 HWND hwndView; 357 HWND hDlgWnd; 358 BOOL bViewHasFocus; 359 360 /* Check if listview has focus */ 361 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus()); 362 363 /* Get the foldersettings from the old view */ 364 if(fodInfos->Shell.FOIShellView) 365 { 366 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, 367 &fodInfos->ShellInfos.folderSettings); 368 } 369 370 /* Create the window */ 371 if(SUCCEEDED(hRes = IShellView_CreateViewWindow(psvTmp, 372 NULL, 373 &fodInfos->ShellInfos.folderSettings, 374 fodInfos->Shell.FOIShellBrowser, 375 &fodInfos->ShellInfos.rectView, 376 &hwndView))) 377 { 378 /* Fit the created view in the appropriate RECT */ 379 MoveWindow(hwndView, 380 fodInfos->ShellInfos.rectView.left, 381 fodInfos->ShellInfos.rectView.top, 382 fodInfos->ShellInfos.rectView.right-fodInfos->ShellInfos.rectView.left, 383 fodInfos->ShellInfos.rectView.bottom-fodInfos->ShellInfos.rectView.top, 384 FALSE); 385 386 /* Select the new folder in the Look In combo box of the Open file dialog */ 387 388 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,pidlTmp); 389 390 /* Release old pidlAbsCurrent memory and update its value */ 391 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent); 392 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp; 393 394 /* Release the current fodInfos->Shell.FOIShellView and update its value */ 395 if(fodInfos->Shell.FOIShellView) 396 { 397 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView); 398 IShellView_Release(fodInfos->Shell.FOIShellView); 399 } 400 #if 0 401 ShowWindow(fodInfos->ShellInfos.hwndView,SW_HIDE); 402 #endif 403 fodInfos->Shell.FOIShellView = psvTmp; 404 405 fodInfos->ShellInfos.hwndView = hwndView; 406 407 /* changes the tab order of the ListView to reflect the window's File Dialog */ 408 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN); 409 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE); 410 411 /* Since we destroyed the old view if it had focus set focus 412 to the newly created view */ 413 if (bViewHasFocus) 414 SetFocus(fodInfos->ShellInfos.hwndView); 415 416 return NOERROR; 417 } 418 } 419 353 /* Release old pidlAbsCurrent and update its value */ 354 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent); 355 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp; 356 357 /* Create the window */ 358 TRACE("create view window\n"); 359 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL, 360 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser, 361 &fodInfos->ShellInfos.rectView, &hwndView))) return hRes; 362 363 fodInfos->ShellInfos.hwndView = hwndView; 364 365 /* Select the new folder in the Look In combo box of the Open file dialog */ 420 366 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent); 421 return hRes; 367 368 /* changes the tab order of the ListView to reflect the window's File Dialog */ 369 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN); 370 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE); 371 372 /* Since we destroyed the old view if it had focus set focus to the newly created view */ 373 if (bViewHasFocus) 374 SetFocus(fodInfos->ShellInfos.hwndView); 375 376 return hRes; 422 377 } 423 378 … … 425 380 * IShellBrowserImpl_EnableModelessSB 426 381 */ 427 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface, 382 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface, 428 383 BOOL fEnable) 429 384 430 385 { 431 386 ICOM_THIS(IShellBrowserImpl, iface); … … 440 395 * IShellBrowserImpl_GetControlWindow 441 396 */ 442 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface, 443 UINT id, 397 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface, 398 UINT id, 444 399 HWND *lphwnd) 445 400 446 401 { 447 402 ICOM_THIS(IShellBrowserImpl, iface); … … 456 411 */ 457 412 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface, 458 DWORD grfMode, 413 DWORD grfMode, 459 414 LPSTREAM *ppStrm) 460 461 { 462 ICOM_THIS(IShellBrowserImpl, iface); 463 464 TRACE("(%p)\n", This); 465 466 /* Feature not implemented */ 467 return E_NOTIMPL; 468 } 415 416 { 417 ICOM_THIS(IShellBrowserImpl, iface); 418 419 TRACE("(%p)\n", This); 420 421 /* Feature not implemented */ 422 return E_NOTIMPL; 423 } 469 424 /************************************************************************** 470 425 * IShellBrowserImpl_InsertMenusSB … … 473 428 HMENU hmenuShared, 474 429 LPOLEMENUGROUPWIDTHS lpMenuWidths) 475 430 476 431 { 477 432 ICOM_THIS(IShellBrowserImpl, iface); … … 487 442 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface, 488 443 IShellView *ppshv) 489 490 { 491 ICOM_THIS(IShellBrowserImpl, iface); 492 493 TRACE("(%p)\n", This); 494 495 /* Feature not implemented */ 496 return E_NOTIMPL; 497 } 444 445 { 446 ICOM_THIS(IShellBrowserImpl, iface); 447 448 TRACE("(%p)\n", This); 449 450 /* Feature not implemented */ 451 return E_NOTIMPL; 452 } 498 453 /************************************************************************** 499 454 * IShellBrowserImpl_QueryActiveShellView … … 501 456 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface, 502 457 IShellView **ppshv) 503 458 504 459 { 505 460 ICOM_THIS(IShellBrowserImpl, iface); … … 517 472 IShellView_AddRef(fodInfos->Shell.FOIShellView); 518 473 return NOERROR; 519 } 474 } 520 475 /************************************************************************** 521 476 * IShellBrowserImpl_RemoveMenusSB … … 523 478 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface, 524 479 HMENU hmenuShared) 525 526 { 527 ICOM_THIS(IShellBrowserImpl, iface); 528 529 TRACE("(%p)\n", This); 530 531 /* Feature not implemented */ 532 return E_NOTIMPL; 533 } 480 481 { 482 ICOM_THIS(IShellBrowserImpl, iface); 483 484 TRACE("(%p)\n", This); 485 486 /* Feature not implemented */ 487 return E_NOTIMPL; 488 } 534 489 /************************************************************************** 535 490 * IShellBrowserImpl_SendControlMsg 536 491 */ 537 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface, 538 UINT id, 539 UINT uMsg, 540 WPARAM wParam, 492 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface, 493 UINT id, 494 UINT uMsg, 495 WPARAM wParam, 541 496 LPARAM lParam, 542 497 LRESULT *pret) 543 498 544 499 { 545 500 ICOM_THIS(IShellBrowserImpl, iface); 546 501 LRESULT lres; 547 502 548 503 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret); 549 504 … … 552 507 case FCW_TOOLBAR: 553 508 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam); 554 break;509 break; 555 510 default: 556 511 FIXME("ctrl id: %x\n", id); … … 564 519 */ 565 520 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface, 566 HMENU hmenuShared, 521 HMENU hmenuShared, 567 522 HOLEMENU holemenuReserved, 568 523 HWND hwndActiveObject) 569 570 { 571 ICOM_THIS(IShellBrowserImpl, iface); 572 573 TRACE("(%p)\n", This); 574 575 /* Feature not implemented */ 576 return E_NOTIMPL; 577 } 524 525 { 526 ICOM_THIS(IShellBrowserImpl, iface); 527 528 TRACE("(%p)\n", This); 529 530 /* Feature not implemented */ 531 return E_NOTIMPL; 532 } 578 533 /************************************************************************** 579 534 * IShellBrowserImpl_SetStatusTextSB … … 581 536 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface, 582 537 LPCOLESTR lpszStatusText) 583 584 { 585 ICOM_THIS(IShellBrowserImpl, iface); 586 587 TRACE("(%p)\n", This); 588 589 /* Feature not implemented */ 590 return E_NOTIMPL; 591 } 538 539 { 540 ICOM_THIS(IShellBrowserImpl, iface); 541 542 TRACE("(%p)\n", This); 543 544 /* Feature not implemented */ 545 return E_NOTIMPL; 546 } 592 547 /************************************************************************** 593 548 * IShellBrowserImpl_SetToolbarItems 594 549 */ 595 550 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface, 596 LPTBBUTTON lpButtons, 597 UINT nButtons, 551 LPTBBUTTON lpButtons, 552 UINT nButtons, 598 553 UINT uFlags) 599 600 { 601 ICOM_THIS(IShellBrowserImpl, iface); 602 603 TRACE("(%p)\n", This); 604 605 /* Feature not implemented */ 606 return E_NOTIMPL; 607 } 554 555 { 556 ICOM_THIS(IShellBrowserImpl, iface); 557 558 TRACE("(%p)\n", This); 559 560 /* Feature not implemented */ 561 return E_NOTIMPL; 562 } 608 563 /************************************************************************** 609 564 * IShellBrowserImpl_TranslateAcceleratorSB 610 565 */ 611 566 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface, 612 LPMSG lpmsg, 567 LPMSG lpmsg, 613 568 WORD wID) 614 569 615 570 { 616 571 ICOM_THIS(IShellBrowserImpl, iface); … … 630 585 */ 631 586 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(ICommDlgBrowser *iface, 632 REFIID riid, 587 REFIID riid, 633 588 LPVOID *ppvObj) 634 589 { … … 678 633 TRACE("(%p)\n", This); 679 634 680 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 681 635 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 636 682 637 /* If the selected object is not a folder, send a IDOK command to parent window */ 683 pidl = GetSelectedPidl(ppshv); 684 if (pidl) 638 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1))) 685 639 { 686 640 HRESULT hRes; … … 688 642 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; 689 643 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr); 690 if (ulAttr) 691 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE); 692 /* Tell the dialog that the user selected a file */ 644 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) ) 645 { 646 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE); 647 } 693 648 else 694 { 695 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L); 696 } 649 { 650 /* Tell the dialog that the user selected a file */ 651 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L); 652 } 697 653 698 654 /* Free memory used by pidl */ … … 715 671 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface); 716 672 717 TRACE("(%p )\n", This);673 TRACE("(%p shv=%p)\n", This, ppshv); 718 674 719 675 switch (uChange) … … 721 677 case CDBOSC_SETFOCUS: 722 678 /* FIXME: Reset the default button. 723 This should be taken care of by defdlg. If control724 other than button receives focus the default button725 should be restored. */679 This should be taken care of by defdlg. If control 680 other than button receives focus the default button 681 should be restored. */ 726 682 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0); 683 727 684 break; 728 case CDBOSC_KILLFOCUS: 729 {730 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);731 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)732 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");685 case CDBOSC_KILLFOCUS: 686 { 687 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 688 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) 689 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save"); 733 690 } 734 691 break; … … 736 693 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv); 737 694 case CDBOSC_RENAME: 695 /* nothing to do */ 738 696 break; 739 697 } 740 698 741 return NOERROR; 699 return NOERROR; 700 } 701 702 /* copied from shell32 to avoid linking to it */ 703 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl) 704 { 705 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl); 706 707 switch (src->uType) 708 { 709 case STRRET_WSTR: 710 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len); 711 COMDLG32_SHFree(src->u.pOleStr); 712 break; 713 714 case STRRET_CSTRA: 715 lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len); 716 break; 717 718 case STRRET_OFFSETA: 719 if (pidl) 720 { 721 lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len); 722 } 723 break; 724 725 default: 726 FIXME("unknown type!\n"); 727 if (len) 728 { *(LPSTR)dest = '\0'; 729 } 730 return(FALSE); 731 } 732 return S_OK; 742 733 } 743 734 /************************************************************************** 744 735 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject 745 736 */ 746 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, 737 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, 747 738 IShellView * ppshv, 748 739 LPCITEMIDLIST pidl) … … 756 747 757 748 TRACE("(%p)\n", This); 758 //CB: slow!!! 749 759 750 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 760 751 761 752 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK; 762 753 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr); 763 754 764 755 if( (ulAttr & SFGAO_HIDDEN) /* hidden */ 765 756 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */ 766 757 return S_FALSE; 758 767 759 /* always include directorys and links */ 768 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK)) 760 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK)) 769 761 return S_OK; 762 770 763 /* Check if there is a mask to apply if not */ 771 if(!fodInfos->ShellInfos.lpstrCurrentFilter || 772 !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter)) 764 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter)) 773 765 return S_OK; 774 766 775 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_ FORPARSING, &str)))776 { 777 if (SUCCEEDED( StrRetToBufW(&str, pidl,szPathW, MAX_PATH)))767 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str))) 768 { 769 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl))) 778 770 { 779 if (COMDLG32_PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))780 return S_OK;771 if (COMDLG32_PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter)) 772 return S_OK; 781 773 } 782 774 } 783 775 return S_FALSE; 776 784 777 } 785 778 786 779 /************************************************************************** 787 780 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange 788 */ 781 */ 789 782 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv) 790 783 { 791 ULONG uAttr;792 784 FileOpenDlgInfos *fodInfos; 793 UINT nFiles = 0; /* Intial to zero */794 UINT nCurrLength;795 UINT nFileToOpen;796 UINT nAllLength = 2; /* Include intial '"' and final NULL */797 UINT nSize = MAX_PATH;798 UINT nFileSelected = 0;799 LPITEMIDLIST pidlSelection;800 LPSTR lpstrTemp = NULL;801 LPSTR lpstrAllFile = NULL;802 char lpstrCurrFile[MAX_PATH];803 785 804 786 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface); 805 787 806 788 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 807 TRACE("(%p)\n", This); 808 809 /* Locate memory and Get selected item counter */ 810 if((lpstrAllFile = (LPSTR)SHAlloc(nSize * sizeof(char))) != NULL) 811 { 812 ZeroMemory(lpstrAllFile, nSize * sizeof(char)); 813 *lpstrAllFile = '\"'; 814 lpstrTemp = lpstrAllFile + 1; 815 nFileSelected = GetNumSelected(fodInfos->Shell.FOIShellView); /* Get all selected counter */ 816 } 817 818 /* Count all selected files we have */ 819 for(nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++) 820 { /* get the file selected */ 821 pidlSelection = NULL; 822 uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; 823 ZeroMemory(lpstrCurrFile, MAX_PATH * sizeof(char)); 824 EnumSelectedPidls(fodInfos->Shell.FOIShellView, nFileToOpen, &pidlSelection); 825 826 /* get the file name and attrib of the selected files*/ 827 GetName(fodInfos->Shell.FOIShellFolder, pidlSelection, SHGDN_NORMAL, lpstrCurrFile); 828 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidlSelection, &uAttr); 829 COMDLG32_SHFree((LPVOID) pidlSelection); 830 831 if(!uAttr) 832 { /* Get the new file name */ 833 nCurrLength = lstrlenA(lpstrCurrFile); 834 if(nAllLength + nCurrLength + 3 > nSize) 835 { /* increase the memory and transfer string to new location */ 836 nSize += MAX_PATH; 837 if((lpstrTemp = (LPSTR)SHAlloc(nSize * sizeof(char))) != NULL) 838 { /* Transfer old file names */ 839 ZeroMemory(lpstrTemp, nSize * sizeof(char)); 840 lstrcpyA(lpstrTemp, lpstrAllFile); 841 SHFree(lpstrAllFile); 842 lpstrAllFile = lpstrTemp; 843 lpstrTemp = lpstrAllFile + nAllLength - 1; 844 } 845 else 846 { /* if failure, stop the loop to get filename */ 847 nFileSelected = 0; 848 } 849 } 850 851 if(lpstrTemp != NULL) 852 { /* Add the new file name */ 853 nFiles++; 854 lstrcpyA(lpstrTemp, lpstrCurrFile); 855 *(lpstrTemp + nCurrLength) = '\"'; 856 *(lpstrTemp + nCurrLength + 1) = ' '; 857 *(lpstrTemp + nCurrLength + 2) = '\"'; 858 nAllLength += nCurrLength + 3; 859 lpstrTemp = lpstrAllFile + nAllLength - 1; 860 } 861 } 862 } 863 864 if(lpstrAllFile) 865 { 866 if(nFiles > 1) 867 { 868 *(lpstrTemp - 2) = '\0'; 869 SetWindowTextA(fodInfos->DlgInfos.hwndFileName, lpstrAllFile); 870 } 871 else 872 { 873 *(lpstrTemp - 3) = '\0'; 874 SetWindowTextA(fodInfos->DlgInfos.hwndFileName, lpstrAllFile + 1); 875 } 876 877 fodInfos->DlgInfos.dwDlgProp |= FODPROP_USEVIEW; 878 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE); 879 SHFree( lpstrAllFile ); 880 } 881 else 882 { 883 SetWindowTextA(fodInfos->DlgInfos.hwndFileName, ""); 884 } 885 886 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) 887 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner, IDOK, "&Save"); 888 else 889 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner, IDOK, "&Open"); 890 891 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW; 892 893 return nFileSelected ? S_OK : E_FAIL; 894 } 895 896 /*********************************************************************** 897 * GetSelectedPidl 898 * 899 * Return the pidl of the first selected item in the view 900 */ 901 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv) 902 { 903 904 IDataObject *doSelected; 905 LPITEMIDLIST pidlSelected = NULL; 906 907 TRACE("sv=%p\n", ppshv); 908 909 /* Get an IDataObject from the view */ 910 if(SUCCEEDED(IShellView_GetItemObject(ppshv, 911 SVGIO_SELECTION, 912 &IID_IDataObject, 913 (LPVOID *)&doSelected))) 914 { 915 STGMEDIUM medium; 916 FORMATETC formatetc; 917 918 /* Set the FORMATETC structure*/ 919 SETDefFormatEtc(formatetc, 920 RegisterClipboardFormatA(CFSTR_SHELLIDLIST), 921 TYMED_HGLOBAL); 922 923 /* Get the pidl from IDataObject */ 924 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium))) 925 { 926 LPIDA cida = GlobalLock(medium.u.hGlobal); 927 TRACE("cida=%p\n", cida); 928 pidlSelected = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[1]])); 929 930 if(medium.pUnkForRelease) 931 IUnknown_Release(medium.pUnkForRelease); 932 else 933 { 934 GlobalUnlock(medium.u.hGlobal); 935 GlobalFree(medium.u.hGlobal); 936 } 937 } 938 IDataObject_Release(doSelected); 939 return pidlSelected; 940 } 941 942 return NULL; 943 } 944 945 /*********************************************************************** 946 * EnumSelectedPidls 947 * 948 * Return the pidl(s) of the selected item(s) in the view. 949 * 950 */ 951 BOOL EnumSelectedPidls( IShellView *ppshv, /*[in]*/ 952 UINT nPidlIndex, /*[in]*/ 953 LPITEMIDLIST *pidlSelected /*[out]*/ ) 954 { 955 956 IDataObject *doSelected; 957 BOOL retVal = TRUE; 958 959 /* Get an IDataObject from the view */ 960 if(SUCCEEDED(IShellView_GetItemObject(ppshv, 961 SVGIO_SELECTION, 962 &IID_IDataObject, 963 (LPVOID *)&doSelected))) 964 { 965 STGMEDIUM medium; 966 FORMATETC formatetc; 967 968 /* Set the FORMATETC structure*/ 969 SETDefFormatEtc(formatetc, 970 RegisterClipboardFormatA(CFSTR_SHELLIDLIST), 971 TYMED_HGLOBAL); 972 973 /* Get the pidls from IDataObject */ 974 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium))) 975 { 976 LPIDA cida = GlobalLock(medium.u.hGlobal); 977 if(nPidlIndex < cida->cidl) 978 { 979 *pidlSelected = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex + 1]])); 980 } 981 else 982 { 983 retVal = FALSE; 984 } 985 986 if(medium.pUnkForRelease) 987 { 988 IUnknown_Release(medium.pUnkForRelease); 989 } 990 else 991 { 992 GlobalUnlock(medium.u.hGlobal); 993 GlobalFree(medium.u.hGlobal); 994 } 995 } 996 IDataObject_Release(doSelected); 997 return retVal; 998 } 999 return FALSE; 1000 } 1001 1002 /*********************************************************************** 1003 * GetNumSelected 1004 * 1005 * Return the number of selected items in the view. 1006 * 1007 */ 1008 UINT GetNumSelected( IShellView *ppshv ) 1009 { 1010 IDataObject *doSelected; 1011 UINT retVal = 0; 1012 1013 /* Get an IDataObject from the view */ 1014 if(SUCCEEDED(IShellView_GetItemObject(ppshv, 1015 SVGIO_SELECTION, 1016 &IID_IDataObject, 1017 (LPVOID *)&doSelected))) 1018 { 1019 STGMEDIUM medium; 1020 FORMATETC formatetc; 1021 1022 /* Set the FORMATETC structure*/ 1023 SETDefFormatEtc(formatetc, 1024 RegisterClipboardFormatA(CFSTR_SHELLIDLIST), 1025 TYMED_HGLOBAL); 1026 1027 /* Get the pidls from IDataObject */ 1028 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium))) 1029 { 1030 LPIDA cida = GlobalLock(medium.u.hGlobal); 1031 retVal = cida->cidl; 1032 1033 if(medium.pUnkForRelease) 1034 IUnknown_Release(medium.pUnkForRelease); 1035 else 1036 { 1037 GlobalUnlock(medium.u.hGlobal); 1038 GlobalFree(medium.u.hGlobal); 1039 } 1040 } 1041 IDataObject_Release(doSelected); 1042 return retVal; 1043 } 1044 1045 return 0; 1046 } 1047 1048 1049 789 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView); 790 791 /* release old selections */ 792 if (fodInfos->Shell.FOIDataObject) 793 IDataObject_Release(fodInfos->Shell.FOIDataObject); 794 795 /* get a new DataObject from the ShellView */ 796 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION, 797 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject))) 798 return E_FAIL; 799 800 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner); 801 802 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE); 803 return S_OK; 804 } 805  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  