From 16ddc047d9e1ead356eb1cabc68a01330252703e Mon Sep 17 00:00:00 2001 From: Shriraj Sawant Date: Thu, 8 Jun 2017 15:18:21 +0000 Subject: [PATCH] [QCKLNCH] -Created a sample button to test toolbar area. -Added qcklnch.dll entry in syssetup.inf file for registration. svn path=/branches/GSoC_2017/shellext/; revision=74961 --- .../dll/shellext/qcklnch/CQuickLaunchBand.cpp | 161 ++++++++++++++---- .../dll/shellext/qcklnch/CQuickLaunchBand.h | 8 +- reactos/dll/shellext/qcklnch/precomp.h | 14 +- reactos/dll/shellext/qcklnch/qcklnch.cpp | 7 +- reactos/dll/shellext/qcklnch/rgs/qcklnch.rgs | 2 +- reactos/media/inf/syssetup.inf | 1 + 6 files changed, 148 insertions(+), 45 deletions(-) diff --git a/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp b/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp index fc092ca6763..ac5c188a492 100644 --- a/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp +++ b/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp @@ -13,7 +13,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(qcklnch); // {260CB95D-4544-44F6-A079-575BAA60B72F} static const GUID CLSID_QuickLaunchBand = { 0x260cb95d, 0x4544, 0x44f6, { 0xa0, 0x79, 0x57, 0x5b, 0xaa, 0x60, 0xb7, 0x2f } }; -//RegComCat function +//Componenet Category Registration HRESULT RegisterComCat() { ICatRegister *pcr; @@ -26,6 +26,18 @@ HRESULT RegisterComCat() } return hr; } +HRESULT UnregisterComCat() +{ + ICatRegister *pcr; + HRESULT hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr); + if (SUCCEEDED(hr)) + { + CATID catid = CATID_DeskBand; + hr = pcr->UnRegisterClassImplCategories(CLSID_QuickLaunchBand, 1, &catid); + pcr->Release(); + } + return hr; +} //CQuickLaunchBand @@ -42,7 +54,9 @@ HRESULT RegisterComCat() //IObjectWithSite HRESULT STDMETHODCALLTYPE CQuickLaunchBand::SetSite(IUnknown *pUnkSite) { - /*HRESULT hRet; + MessageBox(0, L"CQuickLaunchBand::SetSite called!", L"Testing", MB_OK | MB_ICONINFORMATION); + + HRESULT hRet; HWND hwndSite; TRACE("CQuickLaunchBand::SetSite(0x%p)\n", pUnkSite); @@ -53,19 +67,10 @@ HRESULT RegisterComCat() TRACE("Querying site window failed: 0x%x\n", hRet); return hRet; } - - TRACE("CreateTaskSwitchWnd(Parent: 0x%p)\n", hwndSite); - - HWND hwndTaskSwitch = CreateTaskSwitchWnd(hwndSite, m_Tray); - if (!hwndTaskSwitch) - { - ERR("CreateTaskSwitchWnd failed"); - return E_FAIL; - } - - m_Site = pUnkSite; - m_hWnd = hwndTaskSwitch;*/ - + m_Site = pUnkSite; + + m_hWnd = CreateWindowEx(0, L"BUTTON", L"Quick Launch >>", WS_CHILD, CW_USEDEFAULT, CW_USEDEFAULT, 50, 50, hwndSite, 0, m_hInstance, 0); + return S_OK; } @@ -73,14 +78,16 @@ HRESULT RegisterComCat() IN REFIID riid, OUT VOID **ppvSite) { + //MessageBox(0, L"GetSite called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); TRACE("CQuickLaunchBand::GetSite(0x%p,0x%p)\n", riid, ppvSite); - /* if (m_Site != NULL) + if (m_Site != NULL) { return m_Site->QueryInterface(riid, ppvSite); } - *ppvSite = NULL;*/ + *ppvSite = NULL; + return E_FAIL; } @@ -88,11 +95,14 @@ HRESULT RegisterComCat() //IDeskBand HRESULT STDMETHODCALLTYPE CQuickLaunchBand::GetWindow(OUT HWND *phwnd) { - /*if (!m_hWnd) + //MessageBox(0, L"GetWindow called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); + + if (!m_hWnd) return E_FAIL; if (!phwnd) return E_INVALIDARG; - *phwnd = m_hWnd;*/ + *phwnd = m_hWnd; + return S_OK; } @@ -100,20 +110,36 @@ HRESULT RegisterComCat() IN BOOL fEnterMode) { /* FIXME: Implement */ + + //MessageBox(0, L"ContextSensitiveHelp called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::ShowDW( IN BOOL bShow) { + //MessageBox(0, L"ShowDW called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); /* We don't do anything... */ + if (m_hWnd) + { + ShowWindow(m_hWnd, bShow ? SW_SHOW : SW_HIDE); + } + return S_OK; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::CloseDW( IN DWORD dwReserved) { + //MessageBox(0, L"CloseDW called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); /* We don't do anything... */ + if (m_hWnd) + { + ShowWindow(m_hWnd, SW_HIDE); + DestroyWindow(m_hWnd); + m_hWnd = NULL; + } + return S_OK; } @@ -123,6 +149,8 @@ HRESULT RegisterComCat() BOOL fReserved) { /* No need to implement this method */ + + //MessageBox(0, L"ResizeBorderDW called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } @@ -131,7 +159,58 @@ HRESULT RegisterComCat() IN DWORD dwViewMode, IN OUT DESKBANDINFO *pdbi) { - TRACE("CQuickLaunchBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID, dwViewMode, pdbi, m_hWnd); + //MessageBox(0, L"GetBandInfo called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); + TRACE("CTaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID, dwViewMode, pdbi, m_hWnd); + + if (m_hWnd != NULL) + { + /* The task band never has a title */ + pdbi->dwMask &= ~DBIM_TITLE; + + /* NOTE: We don't return DBIMF_UNDELETEABLE here, the band site will + handle us differently and add this flag for us. The reason for + this is future changes that might allow it to be deletable. + We want the band site to be in charge of this decision rather + the band itself! */ + /* FIXME: What about DBIMF_NOGRIPPER and DBIMF_ALWAYSGRIPPER */ + pdbi->dwModeFlags = DBIMF_VARIABLEHEIGHT; + + if (dwViewMode & DBIF_VIEWMODE_VERTICAL) + { + pdbi->ptIntegral.y = 1; + pdbi->ptMinSize.y = 1; + /* FIXME: Get the button metrics from the task bar object!!! */ + pdbi->ptMinSize.x = (3 * GetSystemMetrics(SM_CXEDGE) / 2) + /* FIXME: Might be wrong if only one column! */ + GetSystemMetrics(SM_CXSIZE) + (2 * GetSystemMetrics(SM_CXEDGE)); /* FIXME: Min button size, query!!! */ + } + else + { + /* When the band is horizontal its minimum height is the height of the start button */ + RECT rcButton; + GetWindowRect(m_hWndStartButton, &rcButton); + pdbi->ptMinSize.y = rcButton.bottom - rcButton.top; + pdbi->ptIntegral.y = pdbi->ptMinSize.y + (3 * GetSystemMetrics(SM_CYEDGE) / 2); /* FIXME: Query metrics */ + /* We're not going to allow task bands where not even the minimum button size fits into the band */ + pdbi->ptMinSize.x = pdbi->ptIntegral.y; + } + + /* Ignored: pdbi->ptMaxSize.x */ + pdbi->ptMaxSize.y = -1; + + /* FIXME: We should query the height from the task bar object!!! */ + pdbi->ptActual.y = GetSystemMetrics(SM_CYSIZE) + (2 * GetSystemMetrics(SM_CYEDGE)); + + /* Save the band ID for future use in case we need to check whether a given band + is the task band */ + m_BandID = dwBandID; + + TRACE("H: %d, Min: %d,%d, Integral.y: %d Actual: %d,%d\n", (dwViewMode & DBIF_VIEWMODE_VERTICAL) == 0, + pdbi->ptMinSize.x, pdbi->ptMinSize.y, pdbi->ptIntegral.y, + pdbi->ptActual.x, pdbi->ptActual.y); + + return S_OK; + } + return E_FAIL; } @@ -141,6 +220,8 @@ HRESULT RegisterComCat() IN IUnknown *punkClient) { TRACE("IDeskBar::SetClient(0x%p)\n", punkClient); + + //MessageBox(0, L"SetClient called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } @@ -148,16 +229,19 @@ HRESULT RegisterComCat() OUT IUnknown **ppunkClient) { TRACE("IDeskBar::GetClient(0x%p)\n", ppunkClient); + + //MessageBox(0, L"GetClient called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::OnPosRectChangeDB( IN RECT *prc) { - /*TRACE("IDeskBar::OnPosRectChangeDB(0x%p=(%d,%d,%d,%d))\n", prc, prc->left, prc->top, prc->right, prc->bottom); + TRACE("IDeskBar::OnPosRectChangeDB(0x%p=(%d,%d,%d,%d))\n", prc, prc->left, prc->top, prc->right, prc->bottom); if (prc->bottom - prc->top == 0) - return S_OK;*/ + return S_OK; + //MessageBox(0, L"OnPosRectChangeDB called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_FALSE; } @@ -166,15 +250,19 @@ HRESULT RegisterComCat() HRESULT STDMETHODCALLTYPE CQuickLaunchBand::GetClassID( OUT CLSID *pClassID) { + //MessageBox(0, L"GetClassID called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); TRACE("CQuickLaunchBand::GetClassID(0x%p)\n", pClassID); - /* We're going to return the (internal!) CLSID of the task band interface */ + /* We're going to return the (internal!) CLSID of the quick launch band */ *pClassID = CLSID_QuickLaunchBand; + return S_OK; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::IsDirty() { /* The object hasn't changed since the last save! */ + + //MessageBox(0, L"IsDirty called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_FALSE; } @@ -183,6 +271,8 @@ HRESULT RegisterComCat() { TRACE("CQuickLaunchBand::Load called\n"); /* Nothing to do */ + + //MessageBox(0, L"Load called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_OK; } @@ -191,6 +281,8 @@ HRESULT RegisterComCat() IN BOOL fClearDirty) { /* Nothing to do */ + + //MessageBox(0, L"Save called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_OK; } @@ -200,6 +292,8 @@ HRESULT RegisterComCat() TRACE("CQuickLaunchBand::GetSizeMax called\n"); /* We don't need any space for the task band */ //pcbSize->QuadPart = 0; + + //MessageBox(0, L"GetSizeMax called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_OK; } @@ -214,30 +308,36 @@ HRESULT RegisterComCat() OUT LRESULT *plrResult) { TRACE("CQuickLaunchBand: IWinEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p)\n", hWnd, uMsg, wParam, lParam, plrResult); + + //MessageBox(0, L"ProcessMessage called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::ContainsWindow( IN HWND hWnd) { - /*if (hWnd == m_hWnd || + //MessageBox(0, L"ContainsWindow called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); + + if (hWnd == m_hWnd || IsChild(m_hWnd, hWnd)) { TRACE("CQuickLaunchBand::ContainsWindow(0x%p) returns S_OK\n", hWnd); return S_OK; - }*/ + } return S_FALSE; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult) - { - UNIMPLEMENTED; + { + //MessageBox(0, L"OnWinEvent called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); + UNIMPLEMENTED; return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::IsWindowOwner(HWND hWnd) { + //MessageBox(0, L"IsWindowOwner called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return (hWnd == m_hWnd) ? S_OK : S_FALSE; } @@ -245,13 +345,14 @@ HRESULT RegisterComCat() // *** IOleCommandTarget methods *** HRESULT STDMETHODCALLTYPE CQuickLaunchBand::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText) { + //MessageBox(0, L"QueryStatus called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); UNIMPLEMENTED; return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) { - /*if (IsEqualIID(*pguidCmdGroup, IID_IBandSite)) + if (IsEqualIID(*pguidCmdGroup, IID_IBandSite)) { return S_OK; } @@ -259,9 +360,11 @@ HRESULT RegisterComCat() if (IsEqualIID(*pguidCmdGroup, IID_IDeskBand)) { return S_OK; - }*/ + } + //MessageBox(0, L"Exec called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); UNIMPLEMENTED; + return E_NOTIMPL; } diff --git a/reactos/dll/shellext/qcklnch/CQuickLaunchBand.h b/reactos/dll/shellext/qcklnch/CQuickLaunchBand.h index bd6dfab50e6..cb478e1a15a 100644 --- a/reactos/dll/shellext/qcklnch/CQuickLaunchBand.h +++ b/reactos/dll/shellext/qcklnch/CQuickLaunchBand.h @@ -9,8 +9,11 @@ extern const GUID CLSID_QuickLaunchBand; +//Component category registration HRESULT RegisterComCat(); +HRESULT UnregisterComCat(); +//COM class for quick launch class CQuickLaunchBand : public CComCoClass, public CComObjectRootEx, @@ -21,13 +24,16 @@ class CQuickLaunchBand : public IWinEventHandler, public IOleCommandTarget { + CComPtr m_Site; + HINSTANCE m_hInstance; HWND m_hWnd; + HWND m_hWndStartButton; DWORD m_BandID; public: CQuickLaunchBand(); - virtual ~CQuickLaunchBand(); + virtual ~CQuickLaunchBand(); //IObjectWithSite diff --git a/reactos/dll/shellext/qcklnch/precomp.h b/reactos/dll/shellext/qcklnch/precomp.h index 12dd2046621..24438f91fc3 100644 --- a/reactos/dll/shellext/qcklnch/precomp.h +++ b/reactos/dll/shellext/qcklnch/precomp.h @@ -38,16 +38,4 @@ #undef DbgPrint -#include "CQuickLaunchBand.h" - -/*extern HINSTANCE g_hInstance; - -#define ID_ICON_VOLUME (WM_APP + 0x4CB) - -// {845B0FB2-66E0-416B-8F91-314E23F7C12D} -DEFINE_GUID(CLSID_NtObjectFolder, - 0x845b0fb2, 0x66e0, 0x416b, 0x8f, 0x91, 0x31, 0x4e, 0x23, 0xf7, 0xc1, 0x2d); - -//#include "ntobjfolder.h" -//#include "regfolder.h" -*/ +#include "CQuickLaunchBand.h" \ No newline at end of file diff --git a/reactos/dll/shellext/qcklnch/qcklnch.cpp b/reactos/dll/shellext/qcklnch/qcklnch.cpp index 10ad906ac1a..d693f962a71 100644 --- a/reactos/dll/shellext/qcklnch/qcklnch.cpp +++ b/reactos/dll/shellext/qcklnch/qcklnch.cpp @@ -56,7 +56,12 @@ DllRegisterServer(void) STDAPI DllUnregisterServer(void) { - return g_Module.DllUnregisterServer(FALSE); + HRESULT hr = g_Module.DllUnregisterServer(FALSE); + + if (FAILED(hr)) + return hr; + else + return UnregisterComCat(); } STDAPI diff --git a/reactos/dll/shellext/qcklnch/rgs/qcklnch.rgs b/reactos/dll/shellext/qcklnch/rgs/qcklnch.rgs index d125c899cce..f4e4a3657f7 100644 --- a/reactos/dll/shellext/qcklnch/rgs/qcklnch.rgs +++ b/reactos/dll/shellext/qcklnch/rgs/qcklnch.rgs @@ -2,7 +2,7 @@ HKCR { NoRemove CLSID { - ForceRemove {260CB95D-4544-44F6-A079-575BAA60B72F} = s 'QuickLaunchBand' + ForceRemove {260CB95D-4544-44F6-A079-575BAA60B72F} = s 'Quick Launch' { InprocServer32 = s '%MODULE%' { diff --git a/reactos/media/inf/syssetup.inf b/reactos/media/inf/syssetup.inf index bb435cde2e2..1fe4d93733d 100644 --- a/reactos/media/inf/syssetup.inf +++ b/reactos/media/inf/syssetup.inf @@ -85,6 +85,7 @@ AddReg=Classes 11,,olepro32.dll,1 11,,propsys.dll,1 11,,pstorec.dll,1 +11,,qcklnch.dll,1 11,,qedit.dll,1 11,,qmgr.dll,1 11,,qmgrprxy.dll,1