mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 08:53:02 +00:00
support for owner drawn context menus on the desktop
svn path=/trunk/; revision=13433
This commit is contained in:
parent
a1775e6e4c
commit
7ae66a94b0
2 changed files with 65 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003, 2004 Martin Fuchs
|
* Copyright 2003, 2004, 2005 Martin Fuchs
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -473,6 +473,11 @@ DesktopShellView::DesktopShellView(HWND hwnd, IShellView* pShellView)
|
||||||
: super(hwnd),
|
: super(hwnd),
|
||||||
_pShellView(pShellView)
|
_pShellView(pShellView)
|
||||||
{
|
{
|
||||||
|
_pctxmenu2 = NULL;
|
||||||
|
#ifndef __MINGW32__ // IContextMenu3 missing in MinGW (as of 6.2.2005)
|
||||||
|
_pctxmenu3 = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
_hwndListView = ::GetNextWindow(hwnd, GW_CHILD);
|
_hwndListView = ::GetNextWindow(hwnd, GW_CHILD);
|
||||||
|
|
||||||
SetWindowStyle(_hwndListView, GetWindowStyle(_hwndListView)&~LVS_ALIGNMASK);//|LVS_ALIGNTOP|LVS_AUTOARRANGE);
|
SetWindowStyle(_hwndListView, GetWindowStyle(_hwndListView)&~LVS_ALIGNMASK);//|LVS_ALIGNTOP|LVS_AUTOARRANGE);
|
||||||
|
@ -541,6 +546,36 @@ LRESULT DesktopShellView::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||||
case PM_DISPLAY_VERSION:
|
case PM_DISPLAY_VERSION:
|
||||||
return SendMessage(_hwndListView, nmsg, wparam, lparam);
|
return SendMessage(_hwndListView, nmsg, wparam, lparam);
|
||||||
|
|
||||||
|
#ifndef __MINGW32__ // IContextMenu3 missing in MinGW (as of 6.2.2005)
|
||||||
|
case WM_MENUCHAR: // only supported by IContextMenu3
|
||||||
|
if (_pctxmenu3) {
|
||||||
|
LRESULT lResult = 0;
|
||||||
|
|
||||||
|
_pctxmenu3->HandleMenuMsg2(nmsg, wparam, lparam, &lResult);
|
||||||
|
|
||||||
|
return lResult;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case WM_DRAWITEM:
|
||||||
|
case WM_MEASUREITEM:
|
||||||
|
if (wparam)
|
||||||
|
break; // If wParam != 0 then the message is not menu-related.
|
||||||
|
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case WM_INITMENUPOPUP:
|
||||||
|
#ifndef __MINGW32__ // IContextMenu3 missing in MinGW (as of 6.2.2005)
|
||||||
|
if (_pctxmenu3)
|
||||||
|
_pctxmenu3->HandleMenuMsg(nmsg, wparam, lparam);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if (_pctxmenu2)
|
||||||
|
_pctxmenu2->HandleMenuMsg(nmsg, wparam, lparam);
|
||||||
|
|
||||||
|
return nmsg==WM_INITMENUPOPUP? 0: TRUE; // Inform caller that we handled WM_INITPOPUPMENU by ourself.
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return super::WndProc(nmsg, wparam, lparam);
|
return super::WndProc(nmsg, wparam, lparam);
|
||||||
}
|
}
|
||||||
|
@ -599,11 +634,29 @@ bool DesktopShellView::DoContextMenu(int x, int y)
|
||||||
|
|
||||||
HRESULT DesktopShellView::DoDesktopContextMenu(int x, int y)
|
HRESULT DesktopShellView::DoDesktopContextMenu(int x, int y)
|
||||||
{
|
{
|
||||||
|
IContextMenu* pcm1;
|
||||||
IContextMenu* pcm;
|
IContextMenu* pcm;
|
||||||
|
|
||||||
HRESULT hr = DesktopFolder()->GetUIObjectOf(_hwnd, 0, NULL, IID_IContextMenu, NULL, (LPVOID*)&pcm);
|
HRESULT hr = DesktopFolder()->GetUIObjectOf(_hwnd, 0, NULL, IID_IContextMenu, NULL, (LPVOID*)&pcm1);
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
|
// Get the higher version context menu interfaces.
|
||||||
|
_pctxmenu2 = NULL;
|
||||||
|
#ifndef __MINGW32__ // IContextMenu3 missing in MinGW (as of 6.2.2005)
|
||||||
|
_pctxmenu3 = NULL;
|
||||||
|
|
||||||
|
if (pcm1->QueryInterface(IID_IContextMenu3, (void**)&pcm) == NOERROR)
|
||||||
|
_pctxmenu3 = (LPCONTEXTMENU3)pcm;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if (pcm1->QueryInterface (IID_IContextMenu2, (void**)&pcm) == NOERROR)
|
||||||
|
_pctxmenu2 = (LPCONTEXTMENU2)pcm;
|
||||||
|
|
||||||
|
if (pcm)
|
||||||
|
pcm1->Release();
|
||||||
|
else
|
||||||
|
pcm = pcm1;
|
||||||
|
|
||||||
HMENU hmenu = CreatePopupMenu();
|
HMENU hmenu = CreatePopupMenu();
|
||||||
|
|
||||||
if (hmenu) {
|
if (hmenu) {
|
||||||
|
@ -615,6 +668,11 @@ HRESULT DesktopShellView::DoDesktopContextMenu(int x, int y)
|
||||||
|
|
||||||
UINT idCmd = TrackPopupMenu(hmenu, TPM_LEFTALIGN|TPM_RETURNCMD|TPM_RIGHTBUTTON, x, y, 0, _hwnd, NULL);
|
UINT idCmd = TrackPopupMenu(hmenu, TPM_LEFTALIGN|TPM_RETURNCMD|TPM_RIGHTBUTTON, x, y, 0, _hwnd, NULL);
|
||||||
|
|
||||||
|
_pctxmenu2 = NULL;
|
||||||
|
#ifndef __MINGW32__ // IContextMenu3 missing in MinGW (as of 6.2.2005)
|
||||||
|
_pctxmenu3 = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (idCmd == FCIDM_SHVIEWLAST-1) {
|
if (idCmd == FCIDM_SHVIEWLAST-1) {
|
||||||
explorer_about(_hwnd);
|
explorer_about(_hwnd);
|
||||||
} else if (idCmd) {
|
} else if (idCmd) {
|
||||||
|
|
|
@ -187,4 +187,9 @@ protected:
|
||||||
DesktopDropTarget* _pDropTarget;
|
DesktopDropTarget* _pDropTarget;
|
||||||
HWND _hwndListView;
|
HWND _hwndListView;
|
||||||
int _icon_algo;
|
int _icon_algo;
|
||||||
|
|
||||||
|
IContextMenu2* _pctxmenu2;
|
||||||
|
#ifndef __MINGW32__ // IContextMenu3 missing in MinGW (as of 6.2.2005)
|
||||||
|
IContextMenu3* _pctxmenu3;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue