Author: ssawant
Date: Sun Jun 25 20:20:27 2017
New Revision: 75198
URL:
http://svn.reactos.org/svn/reactos?rev=75198&view=rev
Log:
[QCKLNCH]
-Added CWindowImpl for proper subclassing.
-Now buttons are alive \0/.
-Code Cleanup.
Modified:
branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CISFBand.cpp
branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CISFBand.h
branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp
Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CISFBand.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
==============================================================================
--- branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CISFBand.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CISFBand.cpp [iso-8859-1] Sun
Jun 25 20:20:27 2017
@@ -15,38 +15,41 @@
WINE_DEFAULT_DEBUG_CHANNEL(qcklnch);
-//Misc Methods:
-//Subclassing Button
-
-LRESULT CALLBACK MyWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR
uIdSubclass, DWORD_PTR dwRefData)
+//*****************************************************************************************
+// *** CISFBand ***
+
+CISFBand::CISFBand() : m_hWndTb(NULL), m_BandID(0), m_pidl(NULL) {}
+
+CISFBand::~CISFBand() {}
+
+// *** CWindowImpl ***
+//Subclassing
+
+LRESULT CISFBand::OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
- switch (uMsg)
- {
- case WM_COMMAND:
- {
- MessageBox(0, L"Button Clicked!!", L"Testing", MB_OK |
MB_ICONINFORMATION);
- }
- }
- return DefSubclassProc(hWnd, uMsg, wParam, lParam);
+ TBBUTTON tb;
+ POINT pt;
+ DWORD pos = GetMessagePos();
+ pt.x = GET_X_LPARAM(pos);
+ pt.y = GET_Y_LPARAM(pos);
+ ScreenToClient(&pt);
+
+ int index = SendMessage(m_hWndTb, TB_HITTEST, 0, (LPARAM)&pt);
+ bool chk = SendMessage(m_hWndTb, TB_GETBUTTON, abs(index), (LPARAM)&tb);
+ if(chk) SHInvokeDefaultCommand(m_hWndTb, m_pISF, (LPITEMIDLIST)tb.dwData);
+
+ return 0;
}
-//*****************************************************************************************
-//CISFBand
-
-CISFBand::CISFBand() : m_hWnd(NULL), m_BandID(0) {}
-
-CISFBand::~CISFBand() {}
-
//ToolbarTest
-
HWND CISFBand::CreateSimpleToolbar(HWND hWndParent, HINSTANCE hInst)
{
// Declare and initialize local constants.
const DWORD buttonStyles = BTNS_AUTOSIZE;
// Create the toolbar.
- HWND hWndToolbar = CreateWindowEx(0 , TOOLBARCLASSNAME, NULL,
- WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_LIST | CCS_NORESIZE,
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0,
+ HWND hWndToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
+ WS_CHILD | TBSTYLE_FLAT | TBSTYLE_LIST | CCS_NORESIZE, CW_USEDEFAULT,
CW_USEDEFAULT, 0, 0,
hWndParent, NULL, hInst, NULL);
if (hWndToolbar == NULL)
return NULL;
@@ -54,8 +57,7 @@
// Set the image list.
HIMAGELIST* piml;
HRESULT hr1 = SHGetImageList(SHIL_SMALL, IID_IImageList, (void**)&piml);
- SendMessage(hWndToolbar, TB_SETIMAGELIST, 0, (LPARAM)piml);
- //SendMessage(hWndToolbar, TB_LOADIMAGES, (WPARAM)IDB_STD_SMALL_COLOR,
(LPARAM)HINST_COMMCTRL);
+ SendMessage(hWndToolbar, TB_SETIMAGELIST, 0, (LPARAM)piml);
//Enumerate objects
CComPtr<IEnumIDList> pedl;
@@ -66,16 +68,14 @@
if (SUCCEEDED(hr1) && SUCCEEDED(hr2))
{
ULONG count = 0;
- for (int i=0; pedl->Next(MAX_PATH, &pidl, &count) != S_FALSE; i++)
+ for (int i=0; pedl->Next(MAX_PATH, &pidl, 0) != S_FALSE; i++, count++)
{
WCHAR sz[MAX_PATH];
int index = SHMapPIDLToSystemImageListIndex(m_pISF, pidl, NULL);
m_pISF->GetDisplayNameOf(pidl, SHGDN_NORMAL, &stret);
- StrRetToBuf(&stret, pidl, sz, sizeof(sz));
- //MessageBox(0, sz, L"Namespace Object Found!", MB_OK |
MB_ICONINFORMATION);
-
- TBBUTTON tb = { MAKELONG(index, 0), i, TBSTATE_ENABLED, buttonStyles,{ 0 },
0, (INT_PTR)sz };
- //SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON),
0);
+ StrRetToBuf(&stret, pidl, sz, sizeof(sz));
+
+ TBBUTTON tb = { MAKELONG(index, 0), i, TBSTATE_ENABLED, buttonStyles,{ 0 },
(DWORD_PTR)pidl, (INT_PTR)sz };
SendMessage(hWndToolbar, TB_INSERTBUTTONW, 0, (LPARAM)&tb);
}
}
@@ -83,7 +83,7 @@
// Resize the toolbar, and then show it.
SendMessage(hWndToolbar, TB_AUTOSIZE, 0, 0);
- ShowWindow(hWndToolbar, TRUE);
+ ::ShowWindow(hWndToolbar, TRUE);
CoTaskMemFree((void*)pidl);
return hWndToolbar;
@@ -91,11 +91,9 @@
/*****************************************************************************/
-//IObjectWithSite
+// *** IObjectWithSite ***
HRESULT STDMETHODCALLTYPE CISFBand::SetSite(IUnknown *pUnkSite)
{
- //MessageBox(0, L"CISFBand::SetSite called!", L"Testing",
MB_OK | MB_ICONINFORMATION);
-
HRESULT hRet;
HWND hwndParent;
@@ -108,12 +106,9 @@
return hRet;
}
m_Site = pUnkSite;
-
- //m_hWnd = CreateWindowEx(0, L"BUTTON", L">>",
WS_CHILD, CW_USEDEFAULT, CW_USEDEFAULT, 50, 50, hwndParent, 0, m_hInstance, 0);
- //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);
+ m_hWndTb = CreateSimpleToolbar(hwndParent, m_hInstance);
+ SubclassWindow(m_hWndTb);
return S_OK;
}
@@ -121,8 +116,7 @@
HRESULT STDMETHODCALLTYPE CISFBand::GetSite(
IN REFIID riid,
OUT VOID **ppvSite)
- {
- //MessageBox(0, L"GetSite called!", L"Test Caption", MB_OK |
MB_ICONINFORMATION);
+ {
TRACE("CISFBand::GetSite(0x%p,0x%p)\n", riid, ppvSite);
HRESULT hr;
@@ -137,16 +131,14 @@
}
/*****************************************************************************/
-//IDeskBand
+// *** IDeskBand ***
HRESULT STDMETHODCALLTYPE CISFBand::GetWindow(OUT HWND *phwnd)
{
- //MessageBox(0, L"GetWindow called!", L"Test Caption", MB_OK
| MB_ICONINFORMATION);
-
- if (!m_hWnd)
+ if (!m_hWndTb)
return E_FAIL;
if (!phwnd)
return E_INVALIDARG;
- *phwnd = m_hWnd;
+ *phwnd = m_hWndTb;
return S_OK;
}
@@ -154,21 +146,16 @@
HRESULT STDMETHODCALLTYPE CISFBand::ContextSensitiveHelp(
IN BOOL fEnterMode)
{
- /* FIXME: Implement */
-
- //MessageBox(0, L"ContextSensitiveHelp called!", L"Test
Caption", MB_OK | MB_ICONINFORMATION);
-
+ /* FIXME: Implement */
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CISFBand::ShowDW(
IN BOOL bShow)
- {
- //MessageBox(0, L"ShowDW called!", L"Test Caption", MB_OK |
MB_ICONINFORMATION);
-
- if (m_hWnd)
- {
- ShowWindow(m_hWnd, bShow ? SW_SHOW : SW_HIDE);
+ {
+ if (m_hWndTb)
+ {
+ ::ShowWindow(m_hWndTb, bShow ? SW_SHOW : SW_HIDE);
}
return S_OK;
@@ -176,14 +163,12 @@
HRESULT STDMETHODCALLTYPE CISFBand::CloseDW(
IN DWORD dwReserved)
- {
- //MessageBox(0, L"CloseDW called!", L"Test Caption", MB_OK |
MB_ICONINFORMATION);
-
- if (m_hWnd)
- {
- ShowWindow(m_hWnd, SW_HIDE);
- DestroyWindow(m_hWnd);
- m_hWnd = NULL;
+ {
+ if (m_hWndTb)
+ {
+ ::ShowWindow(m_hWndTb, SW_HIDE);
+ ::DestroyWindow(m_hWndTb);
+ m_hWndTb = NULL;
}
return S_OK;
@@ -196,8 +181,6 @@
{
/* No need to implement this method */
- //MessageBox(0, L"ResizeBorderDW called!", L"Test Caption",
MB_OK | MB_ICONINFORMATION);
-
return E_NOTIMPL;
}
@@ -205,12 +188,10 @@
IN DWORD dwBandID,
IN DWORD dwViewMode,
IN OUT DESKBANDINFO *pdbi)
- {
- //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);
+ {
+ TRACE("CTaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID,
dwViewMode, pdbi, m_hWndTb);
- if (m_hWnd && pdbi)
+ if (m_hWndTb && pdbi)
{
m_BandID = dwBandID;
@@ -220,19 +201,19 @@
POINTL maxSize;
POINTL itemSize;
- ::GetWindowRect(m_hWnd, &actualRect);
+ ::GetWindowRect(m_hWndTb, &actualRect);
actualSize.x = actualRect.right - actualRect.left;
actualSize.y = actualRect.bottom - actualRect.top;
// Obtain the ideal size, to be used as min and max
- SendMessageW(m_hWnd, TB_AUTOSIZE, 0, 0);
- SendMessageW(m_hWnd, TB_GETMAXSIZE, 0,
reinterpret_cast<LPARAM>(&maxSize));
+ SendMessageW(m_hWndTb, TB_AUTOSIZE, 0, 0);
+ SendMessageW(m_hWndTb, TB_GETMAXSIZE, 0,
reinterpret_cast<LPARAM>(&maxSize));
idealSize = maxSize;
- SendMessageW(m_hWnd, TB_GETIDEALSIZE, FALSE,
reinterpret_cast<LPARAM>(&idealSize));
+ SendMessageW(m_hWndTb, TB_GETIDEALSIZE, FALSE,
reinterpret_cast<LPARAM>(&idealSize));
// Obtain the button size, to be used as the integral size
- DWORD size = SendMessageW(m_hWnd, TB_GETBUTTONSIZE, 0, 0);
+ DWORD size = SendMessageW(m_hWndTb, TB_GETBUTTONSIZE, 0, 0);
itemSize.x = GET_X_LPARAM(size);
itemSize.y = GET_Y_LPARAM(size);
@@ -267,14 +248,12 @@
}
/*****************************************************************************/
- //IDeskBar
+ // *** IDeskBar ***
HRESULT STDMETHODCALLTYPE CISFBand::SetClient(
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;
}
@@ -283,8 +262,6 @@
{
TRACE("IDeskBar::GetClient(0x%p)\n", ppunkClient);
- //MessageBox(0, L"GetClient called!", L"Test Caption", MB_OK
| MB_ICONINFORMATION);
-
return E_NOTIMPL;
}
@@ -293,18 +270,14 @@
{
TRACE("IDeskBar::OnPosRectChangeDB(0x%p=(%d,%d,%d,%d))\n", prc,
prc->left, prc->top, prc->right, prc->bottom);
- //MessageBox(0, L"OnPosRectChangeDB called!", L"Test
Caption", MB_OK | MB_ICONINFORMATION);
-
- return S_OK;
- }
-
-/*****************************************************************************/
-//IPersistStream
+ return S_OK;
+ }
+
+/*****************************************************************************/
+// *** IPersistStream ***
HRESULT STDMETHODCALLTYPE CISFBand::GetClassID(
OUT CLSID *pClassID)
- {
- //MessageBox(0, L"GetClassID called!", L"Test Caption", MB_OK
| MB_ICONINFORMATION);
-
+ {
TRACE("CISFBand::GetClassID(0x%p)\n", pClassID);
/* We're going to return the (internal!) CLSID of the quick launch band */
*pClassID = CLSID_QuickLaunchBand;
@@ -316,8 +289,6 @@
{
/* The object hasn't changed since the last save! */
- //MessageBox(0, L"IsDirty called!", L"Test Caption", MB_OK |
MB_ICONINFORMATION);
-
return S_FALSE;
}
@@ -327,8 +298,6 @@
TRACE("CISFBand::Load called\n");
/* Nothing to do */
- //MessageBox(0, L"Load called!", L"Test Caption", MB_OK |
MB_ICONINFORMATION);
-
return S_OK;
}
@@ -338,25 +307,19 @@
{
/* Nothing to do */
- //MessageBox(0, L"Save called!", L"Test Caption", MB_OK |
MB_ICONINFORMATION);
-
return S_OK;
}
HRESULT STDMETHODCALLTYPE CISFBand::GetSizeMax(
OUT ULARGE_INTEGER *pcbSize)
{
- TRACE("CISFBand::GetSizeMax called\n");
- //pcbSize->QuadPart = 0;
-
- //MessageBox(0, L"GetSizeMax called!", L"Test Caption", MB_OK
| MB_ICONINFORMATION);
-
- return S_OK;
- }
-
-
-/*****************************************************************************/
-//IWinEventHandler
+ TRACE("CISFBand::GetSizeMax called\n");
+
+ return S_OK;
+ }
+
+/*****************************************************************************/
+// *** IWinEventHandler ***
HRESULT STDMETHODCALLTYPE CISFBand::ProcessMessage(
IN HWND hWnd,
IN UINT uMsg,
@@ -366,17 +329,14 @@
{
TRACE("CISFBand: 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 CISFBand::ContainsWindow(
IN HWND hWnd)
- {
- //MessageBox(0, L"ContainsWindow called!", L"Test Caption",
MB_OK | MB_ICONINFORMATION);
-
- if (hWnd == m_hWnd ||
- IsChild(m_hWnd, hWnd))
+ {
+ if (hWnd == m_hWndTb ||
+ ::IsChild(m_hWndTb, hWnd))
{
TRACE("CISFBand::ContainsWindow(0x%p) returns S_OK\n", hWnd);
return S_OK;
@@ -386,55 +346,28 @@
}
HRESULT STDMETHODCALLTYPE CISFBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, LRESULT *theResult)
- {
- //MessageBox(0, L"OnWinEvent called!", L"Test Caption", MB_OK
| MB_ICONINFORMATION);
+ {
UNIMPLEMENTED;
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CISFBand::IsWindowOwner(HWND hWnd)
- {
- //MessageBox(0, L"IsWindowOwner called!", L"Test Caption",
MB_OK | MB_ICONINFORMATION);
- return (hWnd == m_hWnd) ? S_OK : S_FALSE;
- }
-
+ {
+ return (hWnd == m_hWndTb) ? S_OK : S_FALSE;
+ }
+
/*****************************************************************************/
// *** IOleCommandTarget methods ***
HRESULT STDMETHODCALLTYPE CISFBand::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 CISFBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdID,
DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
- {
- /* if (*pguidCmdGroup == CGID_IDeskBand)
- {
- switch (m_BandID)
- {
- case DBID_BANDINFOCHANGED:
- case DBID_MAXIMIZEBAND:
- {
- pvaIn = (VARIANT*)m_BandID;
- return S_OK;
- }
- case DBID_SHOWONLY:
- {
- pvaIn = (VARIANT*)VT_UNKNOWN;
- return S_OK;
- }
- case DBID_PUSHCHEVRON:
- {
- nCmdexecopt = m_BandID;
- pvaIn = (VARIANT*)VT_I4;
- return S_OK;
- }
- default: return S_OK;
- }
- }*/
+ {
if (IsEqualIID(*pguidCmdGroup, IID_IBandSite))
{
return S_OK;
@@ -443,15 +376,15 @@
if (IsEqualIID(*pguidCmdGroup, IID_IDeskBand))
{
return S_OK;
- }
+ }
- //MessageBox(0, L"Exec called!", L"Test Caption", MB_OK |
MB_ICONINFORMATION);
UNIMPLEMENTED;
return E_NOTIMPL;
}
-//IShellFolderBand
+/*****************************************************************************/
+// *** IShellFolderBand ***
HRESULT STDMETHODCALLTYPE CISFBand::GetBandInfoSFB(PBANDINFOSFB pbi)
{
return E_NOTIMPL;
@@ -481,6 +414,7 @@
return E_NOTIMPL;
}
+/*****************************************************************************/
//C Constructor
extern "C"
HRESULT WINAPI CISFBand_CreateInstance(REFIID riid, void** ppv)
Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CISFBand.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
==============================================================================
--- branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CISFBand.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CISFBand.h [iso-8859-1] Sun
Jun 25 20:20:27 2017
@@ -9,8 +9,9 @@
//COM class for cisfband
class CISFBand :
+ public CWindowImpl<CISFBand>,
public CComCoClass<CISFBand>,
- public CComObjectRootEx<CComMultiThreadModelNoCS>,
+ public CComObjectRootEx<CComMultiThreadModelNoCS>,
public IObjectWithSite,
public IDeskBand,
public IDeskBar,
@@ -21,9 +22,9 @@
{
HINSTANCE m_hInstance;
CComPtr<IUnknown> m_Site;
- CComPtr<IShellFolder> m_pISF;
+ CComPtr<IShellFolder> m_pISF;
PCIDLIST_ABSOLUTE m_pidl;
- HWND m_hWnd;
+ HWND m_hWndTb;
DWORD m_BandID;
public:
@@ -33,7 +34,8 @@
//Personal Methods
HWND CreateSimpleToolbar(HWND hWndParent, HINSTANCE hInst);
-
+ LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
//IObjectWithSite
virtual HRESULT STDMETHODCALLTYPE GetSite(
@@ -166,9 +168,12 @@
virtual HRESULT STDMETHODCALLTYPE SetBandInfoSFB(
PBANDINFOSFB pbi
);
+
+//*****************************************************************************************************
+ BEGIN_MSG_MAP(CStartButton)
+ MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
+ END_MSG_MAP()
-//*****************************************************************************************************
-
DECLARE_NOT_AGGREGATABLE(CISFBand)
DECLARE_PROTECT_FINAL_CONSTRUCT()
Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
==============================================================================
---
branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp [iso-8859-1]
(original)
+++
branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp [iso-8859-1]
Sun Jun 25 20:20:27 2017
@@ -72,32 +72,23 @@
HRESULT CQuickLaunchBand::FinalConstruct()
{
- //MessageBox(0, L"CQuickLaunchBand::FinalConstruct Begin!",
L"Testing", MB_OK | MB_ICONINFORMATION);
-
HRESULT hr = CISFBand_CreateInstance(IID_IUnknown, (void**) &m_punkISFB);
if (SUCCEEDED(hr))
- {
- //MessageBox(0, L"CreateInstance success!", L"Testing",
MB_OK | MB_ICONINFORMATION);
-
+ {
CComPtr<IShellFolderBand> pISFB;
hr = m_punkISFB->QueryInterface(IID_IShellFolderBand, (void**)
&pISFB);
if (SUCCEEDED(hr))
{
- //MessageBox(0, L"IID_ISFBand query success!",
L"Testing", MB_OK | MB_ICONINFORMATION);
-
CComPtr<IShellFolder> pISF;
hr = SHGetDesktopFolder(&pISF);
if (SUCCEEDED(hr))
- {
- //MessageBox(0, L"pisf success!", L"Testing",
MB_OK | MB_ICONINFORMATION);
+ {
LPITEMIDLIST pidl = PidlBrowse(m_hWndBro, CSIDL_DESKTOP);
if (pidl == NULL) return E_FAIL;
pISFB->InitializeSFB(pISF, pidl);
}
}
- }
-
- // MessageBox(0, L"CQuickLaunchBand::FinalConstruct End!",
L"Testing", MB_OK | MB_ICONINFORMATION);
+ }
return hr;
}