ReactOS 0.4.16-dev-125-g798ea90
CStartMenu.cpp File Reference
#include "shellmenu.h"
#include "CMergedFolder.h"
Include dependency graph for CStartMenu.cpp:

Go to the source code of this file.

Classes

class  CShellMenuCallback
 

Macros

#define IDM_RUN   401
 
#define IDM_LOGOFF   402
 
#define IDM_UNDOCKCOMPUTER   410
 
#define IDM_TASKBARANDSTARTMENU   413
 
#define IDM_LASTSTARTMENU_SEPARATOR   450
 
#define IDM_DOCUMENTS   501
 
#define IDM_HELPANDSUPPORT   503
 
#define IDM_PROGRAMS   504
 
#define IDM_CONTROLPANEL   505
 
#define IDM_SHUTDOWN   506
 
#define IDM_FAVORITES   507
 
#define IDM_SETTINGS   508
 
#define IDM_PRINTERSANDFAXES   510
 
#define IDM_SEARCH   520
 
#define IDM_SYNCHRONIZE   553
 
#define IDM_NETWORKCONNECTIONS   557
 
#define IDM_DISCONNECT   5000
 
#define IDM_SECURITY   5001
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (CStartMenu)
 
HRESULT BindToDesktop (LPCITEMIDLIST pidl, IShellFolder **ppsfResult)
 
static HRESULT GetMergedFolder (int folder1, int folder2, IShellFolder **ppsfStartMenu)
 
static HRESULT GetStartMenuFolder (IShellFolder **ppsfStartMenu)
 
static HRESULT GetProgramsFolder (IShellFolder **ppsfStartMenu)
 
HRESULT WINAPI RSHELL_CStartMenu_CreateInstance (REFIID riid, void **ppv)
 

Macro Definition Documentation

◆ IDM_CONTROLPANEL

#define IDM_CONTROLPANEL   505

Definition at line 40 of file CStartMenu.cpp.

◆ IDM_DISCONNECT

#define IDM_DISCONNECT   5000

Definition at line 48 of file CStartMenu.cpp.

◆ IDM_DOCUMENTS

#define IDM_DOCUMENTS   501

Definition at line 37 of file CStartMenu.cpp.

◆ IDM_FAVORITES

#define IDM_FAVORITES   507

Definition at line 42 of file CStartMenu.cpp.

◆ IDM_HELPANDSUPPORT

#define IDM_HELPANDSUPPORT   503

Definition at line 38 of file CStartMenu.cpp.

◆ IDM_LASTSTARTMENU_SEPARATOR

#define IDM_LASTSTARTMENU_SEPARATOR   450

Definition at line 36 of file CStartMenu.cpp.

◆ IDM_LOGOFF

#define IDM_LOGOFF   402

Definition at line 33 of file CStartMenu.cpp.

◆ IDM_NETWORKCONNECTIONS

#define IDM_NETWORKCONNECTIONS   557

Definition at line 47 of file CStartMenu.cpp.

◆ IDM_PRINTERSANDFAXES

#define IDM_PRINTERSANDFAXES   510

Definition at line 44 of file CStartMenu.cpp.

◆ IDM_PROGRAMS

#define IDM_PROGRAMS   504

Definition at line 39 of file CStartMenu.cpp.

◆ IDM_RUN

#define IDM_RUN   401

Definition at line 32 of file CStartMenu.cpp.

◆ IDM_SEARCH

#define IDM_SEARCH   520

Definition at line 45 of file CStartMenu.cpp.

◆ IDM_SECURITY

#define IDM_SECURITY   5001

Definition at line 49 of file CStartMenu.cpp.

◆ IDM_SETTINGS

#define IDM_SETTINGS   508

Definition at line 43 of file CStartMenu.cpp.

◆ IDM_SHUTDOWN

#define IDM_SHUTDOWN   506

Definition at line 41 of file CStartMenu.cpp.

◆ IDM_SYNCHRONIZE

#define IDM_SYNCHRONIZE   553

Definition at line 46 of file CStartMenu.cpp.

◆ IDM_TASKBARANDSTARTMENU

#define IDM_TASKBARANDSTARTMENU   413

Definition at line 35 of file CStartMenu.cpp.

◆ IDM_UNDOCKCOMPUTER

#define IDM_UNDOCKCOMPUTER   410

Definition at line 34 of file CStartMenu.cpp.

Function Documentation

◆ BindToDesktop()

HRESULT BindToDesktop ( LPCITEMIDLIST  pidl,
IShellFolder **  ppsfResult 
)

Definition at line 490 of file CStartMenu.cpp.

491{
492 HRESULT hr;
493 CComPtr<IShellFolder> psfDesktop;
494
495 *ppsfResult = NULL;
496
497 hr = SHGetDesktopFolder(&psfDesktop);
498 if (FAILED(hr))
499 return hr;
500
501 hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, ppsfResult));
502
503 return hr;
504}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
#define NULL
Definition: types.h:112
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)

Referenced by GetMergedFolder().

◆ GetMergedFolder()

static HRESULT GetMergedFolder ( int  folder1,
int  folder2,
IShellFolder **  ppsfStartMenu 
)
static

Definition at line 506 of file CStartMenu.cpp.

507{
508 HRESULT hr;
509 LPITEMIDLIST pidlUserStartMenu;
510 LPITEMIDLIST pidlCommonStartMenu;
511 CComPtr<IShellFolder> psfUserStartMenu;
512 CComPtr<IShellFolder> psfCommonStartMenu;
513 CComPtr<IAugmentedShellFolder> pasf;
514
515 *ppsfStartMenu = NULL;
516
517 hr = SHGetSpecialFolderLocation(NULL, folder1, &pidlUserStartMenu);
518 if (FAILED(hr))
519 {
520 WARN("Failed to get the USER start menu folder. Trying to run with just the COMMON one.\n");
521
522 hr = SHGetSpecialFolderLocation(NULL, folder2, &pidlCommonStartMenu);
524 return hr;
525
526 TRACE("COMMON start menu obtained.\n");
527 hr = BindToDesktop(pidlCommonStartMenu, ppsfStartMenu);
528 ILFree(pidlCommonStartMenu);
529 return hr;
530 }
531#if MERGE_FOLDERS
532 hr = SHGetSpecialFolderLocation(NULL, folder2, &pidlCommonStartMenu);
534#else
535 else
536#endif
537 {
538 WARN("Failed to get the COMMON start menu folder. Will use only the USER contents.\n");
539 hr = BindToDesktop(pidlUserStartMenu, ppsfStartMenu);
540 ILFree(pidlUserStartMenu);
541 return hr;
542 }
543
544 TRACE("Both COMMON and USER statr menu folders obtained, merging them...\n");
545
546 hr = BindToDesktop(pidlUserStartMenu, &psfUserStartMenu);
548 return hr;
549
550 hr = BindToDesktop(pidlCommonStartMenu, &psfCommonStartMenu);
552 return hr;
553
554 hr = CMergedFolder_CreateInstance(IID_PPV_ARG(IAugmentedShellFolder, &pasf));
556 {
557 *ppsfStartMenu = psfUserStartMenu.Detach();
558 ILFree(pidlCommonStartMenu);
559 ILFree(pidlUserStartMenu);
560 return hr;
561 }
562
563 hr = pasf->AddNameSpace(NULL, psfUserStartMenu, pidlUserStartMenu, 0xFF00);
565 return hr;
566
567 hr = pasf->AddNameSpace(NULL, psfCommonStartMenu, pidlCommonStartMenu, 0);
569 return hr;
570
571 hr = pasf->QueryInterface(IID_PPV_ARG(IShellFolder, ppsfStartMenu));
572 pasf.Release();
573
574 ILFree(pidlCommonStartMenu);
575 ILFree(pidlUserStartMenu);
576
577 return hr;
578}
HRESULT BindToDesktop(LPCITEMIDLIST pidl, IShellFolder **ppsfResult)
Definition: CStartMenu.cpp:490
#define WARN(fmt,...)
Definition: precomp.h:61
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3257
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:946
#define CMergedFolder_CreateInstance
Definition: shellmenu.h:93
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by GetProgramsFolder(), and GetStartMenuFolder().

◆ GetProgramsFolder()

static HRESULT GetProgramsFolder ( IShellFolder **  ppsfStartMenu)
static

Definition at line 585 of file CStartMenu.cpp.

586{
588}
static HRESULT GetMergedFolder(int folder1, int folder2, IShellFolder **ppsfStartMenu)
Definition: CStartMenu.cpp:506
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2195
#define CSIDL_PROGRAMS
Definition: shlobj.h:2175

Referenced by RSHELL_CStartMenu_CreateInstance().

◆ GetStartMenuFolder()

static HRESULT GetStartMenuFolder ( IShellFolder **  ppsfStartMenu)
static

Definition at line 580 of file CStartMenu.cpp.

581{
583}
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2194
#define CSIDL_STARTMENU
Definition: shlobj.h:2184

Referenced by RSHELL_CStartMenu_CreateInstance().

◆ RSHELL_CStartMenu_CreateInstance()

HRESULT WINAPI RSHELL_CStartMenu_CreateInstance ( REFIID  riid,
void **  ppv 
)

Definition at line 592 of file CStartMenu.cpp.

593{
594 CComPtr<IShellMenu> pShellMenu;
595 CComPtr<IBandSite> pBandSite;
596 CComPtr<IDeskBar> pDeskBar;
597
598 HRESULT hr;
599 IShellFolder * psf;
600
601 LPITEMIDLIST pidlProgramsAbsolute;
602 LPITEMIDLIST pidlPrograms;
603 CComPtr<IShellFolder> psfPrograms;
604
607 return hr;
608
611 return hr;
612
615 return hr;
616
617 CComObject<CShellMenuCallback> *pCallback;
618 hr = CComObject<CShellMenuCallback>::CreateInstance(&pCallback);
620 return hr;
621
622 pCallback->AddRef(); // CreateInstance returns object with 0 ref count */
623 pCallback->Initialize(pShellMenu, pBandSite, pDeskBar);
624
625 hr = pShellMenu->Initialize(pCallback, (UINT) -1, 0, SMINIT_TOPLEVEL | SMINIT_VERTICAL);
627 return hr;
628
629 hr = GetStartMenuFolder(&psf);
631 return hr;
632
633 /* psf is a merged folder, so now we want to get the pidl of the programs item from the merged folder */
634 {
635 hr = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidlProgramsAbsolute);
637 {
638 WARN("USER Programs folder not found\n");
639 hr = SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_PROGRAMS, &pidlProgramsAbsolute);
641 return hr;
642 }
643
644 LPCITEMIDLIST pcidlPrograms;
645 CComPtr<IShellFolder> psfParent;
646 STRRET str;
647 TCHAR szDisplayName[MAX_PATH];
648
649 hr = SHBindToParent(pidlProgramsAbsolute, IID_PPV_ARG(IShellFolder, &psfParent), &pcidlPrograms);
651 return hr;
652
653 hr = psfParent->GetDisplayNameOf(pcidlPrograms, SHGDN_FORPARSING | SHGDN_INFOLDER, &str);
655 return hr;
656
657 StrRetToBuf(&str, pcidlPrograms, szDisplayName, _countof(szDisplayName));
658 ILFree(pidlProgramsAbsolute);
659
660 /* We got the display name from the fs folder and we parse it with the merged folder here */
661 hr = psf->ParseDisplayName(NULL, NULL, szDisplayName, NULL, &pidlPrograms, NULL);
663 return hr;
664 }
665
666 hr = GetProgramsFolder(&psfPrograms);
668 return hr;
669
670 hr = pCallback->_SetProgramsFolder(psfPrograms, pidlPrograms);
672 return hr;
673
674 hr = pShellMenu->SetShellFolder(psf, NULL, NULL, SMSET_TOP);
676 return hr;
677
678 hr = pDeskBar->SetClient(pBandSite);
680 return hr;
681
682 hr = pBandSite->AddBand(pShellMenu);
684 return hr;
685
686 return pDeskBar->QueryInterface(riid, ppv);
687}
static HRESULT GetProgramsFolder(IShellFolder **ppsfStartMenu)
Definition: CStartMenu.cpp:585
static HRESULT GetStartMenuFolder(IShellFolder **ppsfStartMenu)
Definition: CStartMenu.cpp:580
#define MAX_PATH
Definition: compat.h:34
FxPnpStateCallbackInfo * pCallback
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT ParseDisplayName([in] HWND hwndOwner, [in] LPBC pbcReserved, [in, string] LPOLESTR lpszDisplayName, [out] ULONG *pchEaten, [out] PIDLIST_RELATIVE *ppidl, [in, out, unique] ULONG *pdwAttributes)
unsigned int UINT
Definition: ndis.h:50
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1356
const WCHAR * str
#define CMenuSite_CreateInstance
Definition: shellmenu.h:87
#define CMenuDeskBar_CreateInstance
Definition: shellmenu.h:75
#define CMenuBand_CreateInstance
Definition: shellmenu.h:81
#define StrRetToBuf
Definition: shlwapi.h:1769
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define _countof(array)
Definition: sndvol32.h:70
char TCHAR
Definition: xmlstorage.h:189

Referenced by CRShellClassFactory::CreateInstance(), and CStartMenuDummy::_CreatorClass::CreateInstance().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( CStartMenu  )