Author: ssawant
Date: Fri Jul 7 14:53:11 2017
New Revision: 75297
URL:
http://svn.reactos.org/svn/reactos?rev=75297&view=rev
Log:
[QCKLNCH]
-Removed CWindowImpl
-Added CWindow
-Used OnWinEvent() instead of subclassing
-Handled WM_COMMAND and WM_NOTIFY as needed
-Now along with buttons chevron menu is also working
CR-122 (
https://code.reactos.org/cru/CR-122#details)
PS: Thank you everyone for spending your time and giving a thorough review. :)
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/resource.h
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] Fri
Jul 7 14:53:11 2017
@@ -7,7 +7,6 @@
*/
#include "precomp.h"
-#include <mshtmcid.h>
#include <commoncontrols.h>
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
@@ -26,7 +25,7 @@
// *** CISFBand ***
CISFBand::CISFBand() :
- m_BandID(0),
+ m_BandID(0),
m_pidl(NULL),
m_textFlag(true),
m_iconFlag(true)
@@ -34,84 +33,10 @@
}
CISFBand::~CISFBand()
-{
+{
}
-// *** CWindowImpl ***
-// Subclassing
-
-LRESULT CISFBand::OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
-{
- 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_hWnd, TB_HITTEST, 0, (LPARAM)&pt);
- bool chk = SendMessage(m_hWnd, TB_GETBUTTON, abs(index), (LPARAM)&tb);
- if(chk)
- SHInvokeDefaultCommand(m_hWnd, m_pISF, (LPITEMIDLIST)tb.dwData);
-
- return 0;
-}
-
-LRESULT CISFBand::OnRButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
-{
- HRESULT hr;
- CComPtr<IContextMenu> picm;
- HMENU fmenu = CreatePopupMenu();
- 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_hWnd, TB_HITTEST, 0, (LPARAM)&pt);
- bool chk = SendMessage(m_hWnd, TB_GETBUTTON, abs(index), (LPARAM)&tb);
- LPITEMIDLIST pidl = (LPITEMIDLIST)tb.dwData;
-
- if (chk)
- {
- ClientToScreen(&pt);
- hr = m_pISF->GetUIObjectOf(m_hWnd, 1, &pidl,
IID_NULL_PPV_ARG(IContextMenu, &picm));
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
-
- hr = picm->QueryContextMenu(fmenu, 0, 1, 0x7FFF, CMF_DEFAULTONLY);
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
-
- int id = TrackPopupMenuEx(fmenu, TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RETURNCMD,
pt.x, pt.y, m_hWnd, 0);
- if (id > 0)
- {
- CMINVOKECOMMANDINFOEX info = { 0 };
- info.cbSize = sizeof(info);
- info.fMask = CMIC_MASK_UNICODE | CMIC_MASK_PTINVOKE;
- if (GetKeyState(VK_CONTROL) < 0)
- {
- info.fMask |= CMIC_MASK_CONTROL_DOWN;
- }
- if (GetKeyState(VK_SHIFT) < 0)
- {
- info.fMask |= CMIC_MASK_SHIFT_DOWN;
- }
- info.hwnd = m_hWnd;
- info.lpVerb = MAKEINTRESOURCEA(id - 1);
- info.lpVerbW = MAKEINTRESOURCEW(id - 0x7FFF);
- info.nShow = SW_SHOWNORMAL;
- info.ptInvoke = pt;
- picm->InvokeCommand((LPCMINVOKECOMMANDINFO)&info);
- }
- }
-
- DestroyMenu(fmenu);
- return 0;
-}
-
-// ToolbarTest
+// Toolbar
HRESULT CISFBand::CreateSimpleToolbar(HWND hWndParent)
{
// Declare and initialize local constants.
@@ -159,9 +84,9 @@
StrRetToBuf(&stret, pidl, sz, _countof(sz));
TBBUTTON tb = { MAKELONG(index, 0), i, TBSTATE_ENABLED, buttonStyles,{ 0 },
(DWORD_PTR)pidl, (INT_PTR)sz };
- SendMessage(m_hWnd, TB_INSERTBUTTONW, 0, (LPARAM)&tb);
- //CoTaskMemFree(pidl);
- }
+ SendMessage(m_hWnd, TB_INSERTBUTTONW, i, (LPARAM)&tb);
+ //CoTaskMemFree(pidl);
+ }
// Resize the toolbar, and then show it.
SendMessage(m_hWnd, TB_AUTOSIZE, 0, 0);
@@ -189,11 +114,7 @@
hr = CreateSimpleToolbar(hwndParent);
if (FAILED_UNEXPECTEDLY(hr))
- return hr;
-
- hr = SubclassWindow(m_hWnd);
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
+ return hr;
return S_OK;
}
@@ -386,20 +307,83 @@
}
STDMETHODIMP CISFBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
LRESULT *theResult)
- {
- /* switch (uMsg)
+ {
+ switch (uMsg)
{
case WM_COMMAND:
{
- MessageBox(L"Button Clicked", L"Test", MB_OKCANCEL |
MB_ICONINFORMATION);
-
+ TBBUTTON tb;
+ bool chk = SendMessage(m_hWnd, TB_GETBUTTON, LOWORD(wParam),
(LPARAM)&tb);
+ if (chk)
+ SHInvokeDefaultCommand(m_hWnd, m_pISF, (LPITEMIDLIST)tb.dwData);
+
+ *theResult = TRUE;
break;
- }
- }
- return DefSubclassProc(hWnd, uMsg, wParam, lParam);*/
-
- UNIMPLEMENTED;
- return E_NOTIMPL;
+ }
+ case WM_NOTIFY:
+ {
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case NM_RCLICK:
+ {
+ HRESULT hr;
+ POINT pt = ((LPNMMOUSE)lParam)->pt;
+ CComPtr<IContextMenu> picm;
+ HMENU fmenu = CreatePopupMenu();
+ TBBUTTON tb;
+
+ bool chk = SendMessage(m_hWnd, TB_GETBUTTON,
((LPNMMOUSE)lParam)->dwItemSpec, (LPARAM)&tb);
+ LPITEMIDLIST pidl = (LPITEMIDLIST)tb.dwData;
+
+ if (chk)
+ {
+ ClientToScreen(&pt);
+ hr = m_pISF->GetUIObjectOf(m_hWnd, 1, &pidl,
IID_NULL_PPV_ARG(IContextMenu, &picm));
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ hr = picm->QueryContextMenu(fmenu, 0, 1, 0x7FFF,
CMF_DEFAULTONLY);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ int id = TrackPopupMenuEx(fmenu, TPM_LEFTALIGN |
TPM_BOTTOMALIGN | TPM_RETURNCMD, pt.x, pt.y, m_hWnd, 0);
+ if (id > 0)
+ {
+ CMINVOKECOMMANDINFOEX info = { 0 };
+ info.cbSize = sizeof(info);
+ info.fMask = CMIC_MASK_UNICODE | CMIC_MASK_PTINVOKE;
+ if (GetKeyState(VK_CONTROL) < 0)
+ {
+ info.fMask |= CMIC_MASK_CONTROL_DOWN;
+ }
+ if (GetKeyState(VK_SHIFT) < 0)
+ {
+ info.fMask |= CMIC_MASK_SHIFT_DOWN;
+ }
+ info.hwnd = m_hWnd;
+ info.lpVerb = MAKEINTRESOURCEA(id - 1);
+ info.lpVerbW = MAKEINTRESOURCEW(id - 0x7FFF);
+ info.nShow = SW_SHOWNORMAL;
+ info.ptInvoke = pt;
+
picm->InvokeCommand((LPCMINVOKECOMMANDINFO)&info);
+ }
+ }
+ DestroyMenu(fmenu);
+
+ *theResult = TRUE;
+ break;
+ }
+ default:
+ *theResult = FALSE;
+ }
+
+ break;
+ }
+ default:
+ *theResult = FALSE;
+ }
+
+ return S_OK;
}
STDMETHODIMP CISFBand::IsWindowOwner(HWND hWnd)
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] Fri
Jul 7 14:53:11 2017
@@ -9,7 +9,7 @@
// COM class for cisfband
class CISFBand :
- public CWindowImpl<CISFBand>,
+ public CWindow,
public CComCoClass<CISFBand>,
public CComObjectRootEx<CComMultiThreadModelNoCS>,
public IObjectWithSite,
@@ -24,9 +24,9 @@
DWORD m_BandID;
CComPtr<IUnknown> m_Site;
- // Toolbar
+ // Toolbar
CComPtr<IShellFolder> m_pISF;
- PCIDLIST_ABSOLUTE m_pidl;
+ PCIDLIST_ABSOLUTE m_pidl;
// Menu
BOOL m_textFlag;
@@ -39,8 +39,6 @@
// Personal Methods
HRESULT CreateSimpleToolbar(HWND hWndParent);
- LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnRButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
// IObjectWithSite
@@ -182,11 +180,7 @@
UINT uFlags
);
-//*****************************************************************************************************
- BEGIN_MSG_MAP(CISFBand)
- MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
- MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp)
- END_MSG_MAP()
+//*****************************************************************************************************
DECLARE_NOT_AGGREGATABLE(CISFBand)
DECLARE_PROTECT_FINAL_CONSTRUCT()
Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/resource.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
==============================================================================
--- branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/resource.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/resource.h [iso-8859-1] Fri
Jul 7 14:53:11 2017
@@ -2,10 +2,10 @@
#define IDR_QCKLNCH 1001
-#define IDM_POPUPMENU 2000
-#define IDM_LARGE_ICONS 1
-#define IDM_SMALL_ICONS 2
-#define IDM_SHOW_TEXT 3
-#define IDM_VIEW_MENU 4
+#define IDM_POPUPMENU 2001
+#define IDM_LARGE_ICONS 101
+#define IDM_SMALL_ICONS 102
+#define IDM_SHOW_TEXT 103
+#define IDM_VIEW_MENU 104
-#define IDS_BROWSEINFO_TITLE 100
+#define IDS_BROWSEINFO_TITLE 201