diff --git a/reactos/dll/shellext/qcklnch/CISFBand.cpp b/reactos/dll/shellext/qcklnch/CISFBand.cpp index d7ec0161152..828603b7f99 100644 --- a/reactos/dll/shellext/qcklnch/CISFBand.cpp +++ b/reactos/dll/shellext/qcklnch/CISFBand.cpp @@ -14,86 +14,106 @@ WINE_DEFAULT_DEBUG_CHANNEL(qcklnch); -//Toolbar +//Misc Methods: +//Subclassing Button -HWND CreateSimpleToolbar(HWND hWndParent, HINSTANCE hInst) +LRESULT CALLBACK MyWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) +{ + switch (uMsg) + { + case WM_COMMAND: + { + MessageBox(0, L"Button Clicked!!", L"Testing", MB_OK | MB_ICONINFORMATION); + } + } + return DefSubclassProc(hWnd, uMsg, wParam, lParam); +} + +//***************************************************************************************** +//CISFBand + +CISFBand::CISFBand() : m_hWnd(NULL), m_BandID(0) {} + +CISFBand::~CISFBand() {} + +//ToolbarTest + +HWND CISFBand::CreateSimpleToolbar(HWND hWndParent, HINSTANCE hInst) { //This ought to be global.. (currently testing) //HIMAGELIST g_hImageList = NULL; - // Declare and initialize local constants. + // Declare and initialize local constants. const int ImageListID = 0; - const int numButtons = 3; const int bitmapSize = 16; const DWORD buttonStyles = BTNS_AUTOSIZE; // Create the toolbar. HWND hWndToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, - WS_CHILD | TBSTYLE_WRAPABLE | TBSTYLE_FLAT | CCS_NORESIZE, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, + WS_CHILD | TBSTYLE_WRAPABLE | TBSTYLE_LIST | CCS_NORESIZE, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hWndParent, NULL, hInst, NULL); - if (hWndToolbar == NULL) return NULL; // Create the image list. - /* g_hImageList = ImageList_Create(bitmapSize, bitmapSize, // Dimensions of individual bitmaps. - ILC_COLOR16 | ILC_MASK, // Ensures transparent background. - numButtons, 0); + /* g_hImageList = ImageList_Create(bitmapSize, bitmapSize, // Dimensions of individual bitmaps. + ILC_COLOR16 | ILC_MASK, // Ensures transparent background. + numButtons, 0); // Set the image list. SendMessage(hWndToolbar, TB_SETIMAGELIST, - (WPARAM)ImageListID, - (LPARAM)g_hImageList); + (WPARAM)ImageListID, + (LPARAM)g_hImageList); // Load the button images. SendMessage(hWndToolbar, TB_LOADIMAGES, - (WPARAM)IDB_STD_SMALL_COLOR, - (LPARAM)HINST_COMMCTRL);*/ + (WPARAM)IDB_STD_SMALL_COLOR, + (LPARAM)HINST_COMMCTRL);*/ // Initialize button info. - // IDM_NEW, IDM_OPEN, and IDM_SAVE are application-defined command constants. - - TBBUTTON tbButtons[numButtons] = - { - { MAKELONG(STD_FILENEW, ImageListID), IDM_NEW, TBSTATE_ENABLED, buttonStyles,{ 0 }, 0, (INT_PTR)L"New" }, - { MAKELONG(STD_FILEOPEN, ImageListID), IDM_OPEN, TBSTATE_ENABLED, buttonStyles,{ 0 }, 0, (INT_PTR)L"Open" }, - { MAKELONG(STD_FILESAVE, ImageListID), IDM_SAVE, 0, buttonStyles,{ 0 }, 0, (INT_PTR)L"Save" } - }; - + // IDM_NEW, IDM_OPEN, and IDM_SAVE are application-defined command constants. + /*{ + { MAKELONG(STD_FILENEW, ImageListID), IDM_NEW, TBSTATE_ENABLED, buttonStyles,{ 0 }, 0, (INT_PTR)L"New" }, + { MAKELONG(STD_FILEOPEN, ImageListID), IDM_OPEN, TBSTATE_ENABLED, buttonStyles,{ 0 }, 0, (INT_PTR)L"Open" }, + { MAKELONG(STD_FILESAVE, ImageListID), IDM_SAVE, 0, buttonStyles,{ 0 }, 0, (INT_PTR)L"Save" } + };*/ // Add buttons. - SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); - SendMessage(hWndToolbar, TB_ADDBUTTONS, (WPARAM)numButtons, (LPARAM)&tbButtons); + /*SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); + SendMessage(hWndToolbar, TB_ADDBUTTONS, (WPARAM)nb, (LPARAM)&tbButtons);*/ - //SendMessage(hWndToolbar, TB_INSERTBUTTON, /*(WPARAM)numButtons*/ 0, (LPARAM)&tbButtons[0]); + //Enumerate objects + CComPtr pedl; + HRESULT hr = m_pISF->EnumObjects(0, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pedl); + LPITEMIDLIST pidl = NULL; + STRRET stret; + //LPWSTR pstr = NULL; + + if (SUCCEEDED(hr)) + { + for (int i=0; pedl->Next(MAX_PATH, &pidl, 0) != S_FALSE; i++) + { + WCHAR sz[MAX_PATH]; + m_pISF->GetDisplayNameOf(pidl, SHGDN_NORMAL, &stret); + //StrRetToStr(&stret, pidl, &pstr); + StrRetToBuf(&stret, pidl, sz, sizeof(sz)); + //MessageBox(0, sz, L"Namespace Object Found!", MB_OK | MB_ICONINFORMATION); + + TBBUTTON tb = { MAKELONG(I_IMAGENONE, ImageListID), i, TBSTATE_ENABLED, buttonStyles,{ 0 }, 0, (INT_PTR)sz }; + SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); + SendMessage(hWndToolbar, TB_INSERTBUTTONW, 0, (LPARAM)&tb); + } + } // Resize the toolbar, and then show it. SendMessage(hWndToolbar, TB_AUTOSIZE, 0, 0); ShowWindow(hWndToolbar, TRUE); + CoTaskMemFree((void*)pidl); + //CoTaskMemFree((void*)pstr); return hWndToolbar; } -//Subclassing Button - - LRESULT CALLBACK MyWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) - { - switch (uMsg) - { - case WM_COMMAND: - { - MessageBox(0, L"Button Clicked!!", L"Testing", MB_OK | MB_ICONINFORMATION); - } - } - return DefSubclassProc(hWnd, uMsg, wParam, lParam); - } - -//CISFBand - - CISFBand::CISFBand() : m_hWnd(NULL), m_BandID(0) {} - - CISFBand::~CISFBand() {} - /*****************************************************************************/ //IObjectWithSite @@ -118,6 +138,7 @@ HWND CreateSimpleToolbar(HWND hWndParent, HINSTANCE hInst) //SetWindowSubclass(hwndParent, MyWndProc, 0, 0); //when button is clicked, parent receives WM_COMMAND, and thus subclassed to show a test message box m_hWnd = CreateSimpleToolbar(hwndParent, m_hInstance); + SetWindowSubclass(hwndParent, MyWndProc, 0, 0); return S_OK; } @@ -257,7 +278,7 @@ HWND CreateSimpleToolbar(HWND hWndParent, HINSTANCE hInst) pdbi->ptActual = actualSize; } if (pdbi->dwMask & DBIM_TITLE) - wcscpy(pdbi->wszTitle, L""); + wcscpy(pdbi->wszTitle, L"Quick Launch"); if (pdbi->dwMask & DBIM_MODEFLAGS) { pdbi->dwModeFlags = DBIMF_NORMAL | DBIMF_VARIABLEHEIGHT; @@ -427,11 +448,38 @@ HWND CreateSimpleToolbar(HWND hWndParent, HINSTANCE hInst) UNIMPLEMENTED; return E_NOTIMPL; - } + } + +//IShellFolderBand + HRESULT STDMETHODCALLTYPE CISFBand::GetBandInfoSFB(PBANDINFOSFB pbi) + { + return E_NOTIMPL; + } + + HRESULT STDMETHODCALLTYPE CISFBand::InitializeSFB(IShellFolder *psf, PCIDLIST_ABSOLUTE pidl) + { + if (pidl != NULL) + { + psf->BindToObject(pidl, 0, IID_IShellFolder, (void**)&m_pISF); + m_pidl = pidl; + } + else + { + m_pISF = psf; + m_pidl = pidl; + } + + return S_OK; + } + + HRESULT STDMETHODCALLTYPE CISFBand::SetBandInfoSFB( PBANDINFOSFB pbi) + { + return E_NOTIMPL; + } //C Constructor extern "C" - HRESULT WINAPI CIFSBand_CreateInstance(REFIID riid, void** ppv) + HRESULT WINAPI CISFBand_CreateInstance(REFIID riid, void** ppv) { return ShellObjectCreator(riid, ppv); } diff --git a/reactos/dll/shellext/qcklnch/CISFBand.h b/reactos/dll/shellext/qcklnch/CISFBand.h index cf6f4654fb0..32e528de242 100644 --- a/reactos/dll/shellext/qcklnch/CISFBand.h +++ b/reactos/dll/shellext/qcklnch/CISFBand.h @@ -16,11 +16,13 @@ class CISFBand : public IDeskBar, public IPersistStream, public IWinEventHandler, - public IOleCommandTarget + public IOleCommandTarget, + public IShellFolderBand { HINSTANCE m_hInstance; CComPtr m_Site; CComPtr m_pISF; + PCIDLIST_ABSOLUTE m_pidl; HWND m_hWnd; HWND m_hWndStartButton; DWORD m_BandID; @@ -30,6 +32,9 @@ public: CISFBand(); virtual ~CISFBand(); +//Personal Methods + HWND CreateSimpleToolbar(HWND hWndParent, HINSTANCE hInst); + //IObjectWithSite virtual HRESULT STDMETHODCALLTYPE GetSite( @@ -149,6 +154,20 @@ public: /*[in, out]*/ OLECMDTEXT *pCmdText ); +//IShellFolderBand + virtual HRESULT STDMETHODCALLTYPE GetBandInfoSFB( + PBANDINFOSFB pbi + ); + + virtual HRESULT STDMETHODCALLTYPE InitializeSFB( + IShellFolder *psf, + PCIDLIST_ABSOLUTE pidl + ); + + virtual HRESULT STDMETHODCALLTYPE SetBandInfoSFB( + PBANDINFOSFB pbi + ); + //***************************************************************************************************** DECLARE_NOT_AGGREGATABLE(CISFBand) @@ -162,9 +181,10 @@ public: COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream) COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler) COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget) + COM_INTERFACE_ENTRY_IID(IID_IShellFolderBand, IShellFolderBand) END_COM_MAP() }; //C Constructor extern "C" -HRESULT WINAPI CIFSBand_CreateInstance(REFIID riid, void** ppv); \ No newline at end of file +HRESULT WINAPI CISFBand_CreateInstance(REFIID riid, void** ppv); \ No newline at end of file