Skip to content

Commit

Permalink
[EXPLORER] getting toolbar in cpp manner
Browse files Browse the repository at this point in the history
  • Loading branch information
Getequ committed Mar 8, 2018
1 parent 5f7aa85 commit c5dd667
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 23 deletions.
17 changes: 9 additions & 8 deletions base/shell/explorer/notifyiconscust.cpp
Expand Up @@ -207,13 +207,14 @@ INT_PTR CALLBACK CustomizeNotifyIconsProc(HWND hwnd, UINT Message, WPARAM wParam
return TRUE;
}

VOID SetNotifyIcons(HWND hDialog, HWND hTrayNotify)
VOID SetNotifyIcons(HWND hDialog, IUnknown *TrayNotify)
{
HWND hListView = GetDlgItem(hDialog, IDC_NOTIFICATION_LIST);
HWND hSysPager = FindWindowEx(hTrayNotify, NULL, L"SysPager", NULL);
HWND hToolbar = FindWindowEx(hSysPager, NULL, L"ToolbarWindow32", NULL);
CToolbar<InternalIconData>* toolbar = CTrayNotifyWnd_GetTrayToolbar(TrayNotify);

HIMAGELIST tbImageList = (HIMAGELIST)SendMessage(hToolbar, TB_GETIMAGELIST, 0, 0);
if (toolbar == NULL) return;

HIMAGELIST tbImageList = (HIMAGELIST)toolbar->GetImageList();
HIMAGELIST lvImageList = ImageList_Duplicate(tbImageList);
ListView_SetImageList(hListView, lvImageList, LVSIL_SMALL);

Expand All @@ -228,10 +229,10 @@ VOID SetNotifyIcons(HWND hDialog, HWND hTrayNotify)
LVITEM lvItem;
TBBUTTON tbtn;

DWORD nButtons = (DWORD)SendMessage(hToolbar, TB_BUTTONCOUNT, 0, 0);
DWORD nButtons = toolbar->GetButtonCount();
for (UINT i = 0; i != nButtons; i++)
{
if (SendMessage(hToolbar, TB_GETBUTTON, (WPARAM)i, (LPARAM)&tbtn))
if (toolbar->GetButton(i, &tbtn))
{
ZeroMemory(&lvItem, sizeof(lvItem));
lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_GROUPID | LVIF_PARAM;
Expand All @@ -253,11 +254,11 @@ VOID SetNotifyIcons(HWND hDialog, HWND hTrayNotify)
}
}

VOID ShowCustomizeNotifyIcons(HINSTANCE hInst, HWND hExplorer, HWND hTrayNotify)
VOID ShowCustomizeNotifyIcons(HINSTANCE hInst, HWND hExplorer, IUnknown *TrayNotify)
{
HWND hDlg = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_NOTIFICATIONS_CUSTOMIZE), hExplorer, CustomizeNotifyIconsProc);

SetNotifyIcons(hDlg, hTrayNotify);
SetNotifyIcons(hDlg, TrayNotify);

ShowWindow(hDlg, SW_SHOW);
}
12 changes: 10 additions & 2 deletions base/shell/explorer/precomp.h
Expand Up @@ -242,7 +242,7 @@ ProcessStartupItems(VOID);
*/

VOID
DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar, IN HWND hTrayNotify);
DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar, IN IUnknown *Tray);

/*
* desktop.cpp
Expand All @@ -258,7 +258,7 @@ DesktopDestroyShellWindow(IN HANDLE hDesktop);
* notifyiconscust.cpp
*/
VOID
ShowCustomizeNotifyIcons(HINSTANCE, HWND, HWND);
ShowCustomizeNotifyIcons(HINSTANCE, HWND, IUnknown*);

/*
* taskband.cpp
Expand Down Expand Up @@ -344,10 +344,18 @@ HRESULT CTrayClockWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv);

#define NTNWM_REALIGN (0x1)

struct InternalIconData : NOTIFYICONDATA
{
// Must keep a separate copy since the original is unioned with uTimeout.
UINT uVersionCopy;
};

HRESULT CTrayNotifyWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv);
CToolbar<InternalIconData>* CTrayNotifyWnd_GetTrayToolbar(IUnknown *pTray);

/* SysPagerWnd */
HRESULT CSysPagerWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv);
CToolbar<InternalIconData>* CSysPagerWnd_GetTrayToolbar(IUnknown *pPager);

/*
* taskswnd.c
Expand Down
24 changes: 18 additions & 6 deletions base/shell/explorer/syspager.cpp
Expand Up @@ -21,12 +21,6 @@

#include "precomp.h"

struct InternalIconData : NOTIFYICONDATA
{
// Must keep a separate copy since the original is unioned with uTimeout.
UINT uVersionCopy;
};

struct IconWatcherData
{
HANDLE hProcess;
Expand Down Expand Up @@ -208,6 +202,7 @@ class CSysPagerWnd :
LRESULT OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSettingChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnGetMinimumSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
CNotifyToolbar* GetToolbar();

public:

Expand Down Expand Up @@ -1463,7 +1458,24 @@ HRESULT CSysPagerWnd::Initialize(IN HWND hWndParent)
return S_OK;
}

CNotifyToolbar* CSysPagerWnd::GetToolbar()
{
return &Toolbar;
}

HRESULT CSysPagerWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv)
{
return ShellObjectCreatorInit<CSysPagerWnd>(hwndParent, riid, ppv);
}

CToolbar<InternalIconData>* CSysPagerWnd_GetTrayToolbar(IUnknown *pPager)
{
CSysPagerWnd *pager = static_cast<CSysPagerWnd*>(pPager);

if (pager != NULL)
{
return pager->GetToolbar();
}

return NULL;
}
17 changes: 17 additions & 0 deletions base/shell/explorer/trayntfy.cpp
Expand Up @@ -330,6 +330,11 @@ class CTrayNotifyWnd :
return E_NOTIMPL;
}

IUnknown* GetPager()
{
return m_pager;
}

DECLARE_NOT_AGGREGATABLE(CTrayNotifyWnd)

DECLARE_PROTECT_FINAL_CONSTRUCT()
Expand Down Expand Up @@ -369,3 +374,15 @@ HRESULT CTrayNotifyWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv)
{
return ShellObjectCreatorInit<CTrayNotifyWnd>(hwndParent, riid, ppv);
}

CToolbar<InternalIconData>* CTrayNotifyWnd_GetTrayToolbar(IUnknown* pTray)
{
CTrayNotifyWnd *tray = static_cast<CTrayNotifyWnd*>(pTray);

if (tray != NULL)
{
return CSysPagerWnd_GetTrayToolbar(tray->GetPager());
}

return NULL;
}
10 changes: 5 additions & 5 deletions base/shell/explorer/trayprop.cpp
Expand Up @@ -50,7 +50,7 @@ class CTaskBarSettingsPage : public CPropertyPageImpl<CTaskBarSettingsPage>
HBITMAP m_hbmpTaskbar;
HBITMAP m_hbmpTray;
HWND m_hwndTaskbar;
HWND m_TrayNotify;
IUnknown *m_TrayNotify;

void UpdateDialog()
{
Expand Down Expand Up @@ -124,11 +124,11 @@ class CTaskBarSettingsPage : public CPropertyPageImpl<CTaskBarSettingsPage>
CHAIN_MSG_MAP(CPropertyPageImpl<CTaskBarSettingsPage>)
END_MSG_MAP()

CTaskBarSettingsPage(HWND hwnd, HWND hTrayNotify):
CTaskBarSettingsPage(HWND hwnd, IUnknown *Tray):
m_hbmpTaskbar(NULL),
m_hbmpTray(NULL),
m_hwndTaskbar(hwnd),
m_TrayNotify(hTrayNotify)
m_TrayNotify(Tray)
{
}

Expand Down Expand Up @@ -248,11 +248,11 @@ class CStartMenuSettingsPage : public CPropertyPageImpl<CStartMenuSettingsPage>
};

VOID
DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar, IN HWND hTrayNotify)
DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar, IN IUnknown *Tray)
{
PROPSHEETHEADER psh;
HPROPSHEETPAGE hpsp[2];
CTaskBarSettingsPage tbSettingsPage(hwndTaskbar, hTrayNotify);
CTaskBarSettingsPage tbSettingsPage(hwndTaskbar, Tray);
CStartMenuSettingsPage smSettingsPage;
CStringW caption;

Expand Down
4 changes: 2 additions & 2 deletions base/shell/explorer/traywnd.cpp
Expand Up @@ -405,7 +405,7 @@ class CTrayWindow :

m_TrayPropertiesOwner = hwnd;

DisplayTrayProperties(hwnd, m_hWnd, m_TrayNotify);
DisplayTrayProperties(hwnd, m_hWnd, m_TrayNotifyInstance);

m_TrayPropertiesOwner = NULL;
::DestroyWindow(hwnd);
Expand Down Expand Up @@ -515,7 +515,7 @@ class CTrayWindow :
break;

case ID_SHELL_CMD_CUST_NOTIF:
ShowCustomizeNotifyIcons(hExplorerInstance, m_hWnd, m_TrayNotify);
ShowCustomizeNotifyIcons(hExplorerInstance, m_hWnd, m_TrayNotifyInstance);
break;

case ID_SHELL_CMD_ADJUST_DAT:
Expand Down
5 changes: 5 additions & 0 deletions sdk/include/reactos/rosctrls.h
Expand Up @@ -400,6 +400,11 @@ class CToolbar :
return SendMessageW(TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(himl));
}

HIMAGELIST GetImageList()
{
return (HIMAGELIST)SendMessageW(TB_GETIMAGELIST, 0, 0);
}

public: // Other methods
INT HitTest(PPOINT ppt)
{
Expand Down

0 comments on commit c5dd667

Please sign in to comment.