ReactOS  0.4.15-dev-1201-gb2cf5a4
traywnd.cpp File Reference
#include "precomp.h"
#include <commoncontrols.h>
Include dependency graph for traywnd.cpp:

Go to the source code of this file.

Classes

struct  EFFECTIVE_INFO
 
class  CStartButton
 
class  CTrayWindow
 
struct  CTrayWindow::MINIMIZE_INFO
 
class  CTrayWindowCtxMenu
 

Macros

#define WM_APP_TRAYDESTROY   (WM_APP + 0x100)
 
#define TIMER_ID_AUTOHIDE   1
 
#define TIMER_ID_MOUSETRACK   2
 
#define MOUSETRACK_INTERVAL   100
 
#define AUTOHIDE_DELAY_HIDE   2000
 
#define AUTOHIDE_DELAY_SHOW   50
 
#define AUTOHIDE_INTERVAL_ANIMATING   10
 
#define AUTOHIDE_SPEED_SHOW   10
 
#define AUTOHIDE_SPEED_HIDE   1
 
#define AUTOHIDE_HIDDEN   0
 
#define AUTOHIDE_SHOWING   1
 
#define AUTOHIDE_SHOWN   2
 
#define AUTOHIDE_HIDING   3
 
#define IDHK_RUN   0x1f4
 
#define IDHK_MINIMIZE_ALL   0x1f5
 
#define IDHK_RESTORE_ALL   0x1f6
 
#define IDHK_HELP   0x1f7
 
#define IDHK_EXPLORE   0x1f8
 
#define IDHK_FIND   0x1f9
 
#define IDHK_FIND_COMPUTER   0x1fa
 
#define IDHK_NEXT_TASK   0x1fb
 
#define IDHK_PREV_TASK   0x1fc
 
#define IDHK_SYS_PROPERTIES   0x1fd
 
#define IDHK_DESKTOP   0x1fe
 
#define IDHK_PAGER   0x1ff
 

Functions

HRESULT TrayWindowCtxMenuCreator (ITrayWindow *TrayWnd, IN HWND hWndOwner, IContextMenu **ppCtxMenu)
 
LRESULT appbar_message (COPYDATASTRUCT *cds)
 
void appbar_notify_all (HMONITOR hMon, UINT uMsg, HWND hwndExclude, LPARAM lParam)
 
static BOOL CALLBACK FindEffectiveProc (HWND hwnd, LPARAM lParam)
 
static BOOL IsThereAnyEffectiveWindow (BOOL bMustBeInMonitor)
 
HRESULT CreateTrayWindow (ITrayWindow **ppTray)
 
HRESULT Tray_OnStartMenuDismissed (ITrayWindow *Tray)
 
VOID TrayProcessMessages (ITrayWindow *Tray)
 
VOID TrayMessageLoop (ITrayWindow *Tray)
 

Variables

static const WCHAR szTrayWndClass [] = L"Shell_TrayWnd"
 
CSimpleArray< HWNDg_MinimizedAll
 
const GUID IID_IShellDesktopTray = { 0x213e2df9, 0x9a14, 0x4328, { 0x99, 0xb1, 0x69, 0x61, 0xf9, 0x14, 0x3c, 0xe9 } }
 

Macro Definition Documentation

◆ AUTOHIDE_DELAY_HIDE

#define AUTOHIDE_DELAY_HIDE   2000

Definition at line 34 of file traywnd.cpp.

◆ AUTOHIDE_DELAY_SHOW

#define AUTOHIDE_DELAY_SHOW   50

Definition at line 35 of file traywnd.cpp.

◆ AUTOHIDE_HIDDEN

#define AUTOHIDE_HIDDEN   0

Definition at line 41 of file traywnd.cpp.

◆ AUTOHIDE_HIDING

#define AUTOHIDE_HIDING   3

Definition at line 44 of file traywnd.cpp.

◆ AUTOHIDE_INTERVAL_ANIMATING

#define AUTOHIDE_INTERVAL_ANIMATING   10

Definition at line 36 of file traywnd.cpp.

◆ AUTOHIDE_SHOWING

#define AUTOHIDE_SHOWING   1

Definition at line 42 of file traywnd.cpp.

◆ AUTOHIDE_SHOWN

#define AUTOHIDE_SHOWN   2

Definition at line 43 of file traywnd.cpp.

◆ AUTOHIDE_SPEED_HIDE

#define AUTOHIDE_SPEED_HIDE   1

Definition at line 39 of file traywnd.cpp.

◆ AUTOHIDE_SPEED_SHOW

#define AUTOHIDE_SPEED_SHOW   10

Definition at line 38 of file traywnd.cpp.

◆ IDHK_DESKTOP

#define IDHK_DESKTOP   0x1fe

Definition at line 56 of file traywnd.cpp.

◆ IDHK_EXPLORE

#define IDHK_EXPLORE   0x1f8

Definition at line 50 of file traywnd.cpp.

◆ IDHK_FIND

#define IDHK_FIND   0x1f9

Definition at line 51 of file traywnd.cpp.

◆ IDHK_FIND_COMPUTER

#define IDHK_FIND_COMPUTER   0x1fa

Definition at line 52 of file traywnd.cpp.

◆ IDHK_HELP

#define IDHK_HELP   0x1f7

Definition at line 49 of file traywnd.cpp.

◆ IDHK_MINIMIZE_ALL

#define IDHK_MINIMIZE_ALL   0x1f5

Definition at line 47 of file traywnd.cpp.

◆ IDHK_NEXT_TASK

#define IDHK_NEXT_TASK   0x1fb

Definition at line 53 of file traywnd.cpp.

◆ IDHK_PAGER

#define IDHK_PAGER   0x1ff

Definition at line 57 of file traywnd.cpp.

◆ IDHK_PREV_TASK

#define IDHK_PREV_TASK   0x1fc

Definition at line 54 of file traywnd.cpp.

◆ IDHK_RESTORE_ALL

#define IDHK_RESTORE_ALL   0x1f6

Definition at line 48 of file traywnd.cpp.

◆ IDHK_RUN

#define IDHK_RUN   0x1f4

Definition at line 46 of file traywnd.cpp.

◆ IDHK_SYS_PROPERTIES

#define IDHK_SYS_PROPERTIES   0x1fd

Definition at line 55 of file traywnd.cpp.

◆ MOUSETRACK_INTERVAL

#define MOUSETRACK_INTERVAL   100

Definition at line 33 of file traywnd.cpp.

◆ TIMER_ID_AUTOHIDE

#define TIMER_ID_AUTOHIDE   1

Definition at line 31 of file traywnd.cpp.

◆ TIMER_ID_MOUSETRACK

#define TIMER_ID_MOUSETRACK   2

Definition at line 32 of file traywnd.cpp.

◆ WM_APP_TRAYDESTROY

#define WM_APP_TRAYDESTROY   (WM_APP + 0x100)

Definition at line 29 of file traywnd.cpp.

Function Documentation

◆ appbar_message()

LRESULT appbar_message ( COPYDATASTRUCT cds)

Definition at line 229 of file appbar.cpp.

230 {
231  struct appbar_cmd cmd;
233  HANDLE return_hproc;
235  LPVOID return_view;
236  struct appbar_response* response;
237 
238  if (cds->cbData != sizeof(struct appbar_cmd))
239  return TRUE;
240 
241  RtlCopyMemory(&cmd, cds->lpData, cds->cbData);
242 
243  result = handle_appbarmessage(cmd.dwMsg, &cmd.abd);
244 
245  return_hproc = OpenProcess(PROCESS_DUP_HANDLE, FALSE, cmd.return_process);
246  if (return_hproc == NULL)
247  {
248  ERR("couldn't open calling process\n");
249  return TRUE;
250  }
251 
252  if (!DuplicateHandle(return_hproc, UlongToHandle(cmd.return_map), GetCurrentProcess(), &return_map, 0, FALSE, DUPLICATE_SAME_ACCESS))
253  {
254  ERR("couldn't duplicate handle\n");
255  CloseHandle(return_hproc);
256  return TRUE;
257  }
258  CloseHandle(return_hproc);
259 
260  return_view = MapViewOfFile(return_map, FILE_MAP_WRITE, 0, 0, sizeof(struct appbar_response));
261 
262  if (return_view)
263  {
264  response = (struct appbar_response*)return_view;
265  response->result = result;
266  response->abd = cmd.abd;
267 
268  UnmapViewOfFile(return_view);
269  }
270  else
271  {
272  ERR("couldn't map view of file\n");
273  }
274 
275  CloseHandle(return_map);
276  return TRUE;
277 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define CloseHandle
Definition: compat.h:598
#define MapViewOfFile
Definition: compat.h:604
Definition: ftp_var.h:139
#define TRUE
Definition: types.h:120
#define DUPLICATE_SAME_ACCESS
#define FALSE
Definition: types.h:117
#define PROCESS_DUP_HANDLE
smooth NULL
Definition: ftsmooth.c:416
struct _AppBarData abd
Definition: appbar.cpp:49
static UINT_PTR handle_appbarmessage(DWORD msg, _AppBarData *abd)
Definition: appbar.cpp:133
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define FILE_MAP_WRITE
Definition: winbase.h:154
ULONG return_map
Definition: appbar.cpp:41
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
ULONGLONG result
Definition: appbar.cpp:48
#define GetCurrentProcess()
Definition: compat.h:618
#define ERR(fmt,...)
Definition: debug.h:110
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
#define UnmapViewOfFile
Definition: compat.h:605
GLuint64EXT * result
Definition: glext.h:11304
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149

Referenced by CTrayWindow::OnCopyData().

◆ appbar_notify_all()

void appbar_notify_all ( HMONITOR  hMon,
UINT  uMsg,
HWND  hwndExclude,
LPARAM  lParam 
)

Definition at line 78 of file appbar.cpp.

79 {
80  struct appbar_data* data;
81 
83  {
84  if (data->hwnd == hwndExclude)
85  continue;
86 
87  if (hMon && hMon != MonitorFromWindow(data->hwnd, MONITOR_DEFAULTTONULL))
88  continue;
89 
90  SendMessageW(data->hwnd, data->callback_msg, uMsg, lParam);
91  }
92 }
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
uint32_t entry
Definition: isohybrid.c:63
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
static struct list appbars
Definition: appbar.cpp:63
LPARAM lParam
Definition: combotst.c:139

Referenced by CTrayWindow::ExecContextMenuCmd(), and send_poschanged().

◆ CreateTrayWindow()

HRESULT CreateTrayWindow ( ITrayWindow **  ppTray)

Definition at line 3404 of file traywnd.cpp.

3405 {
3407  if (Tray == NULL)
3408  return E_OUTOFMEMORY;
3409 
3410  Tray->_Init();
3411  Tray->Open();
3412 
3413  *ppTray = (ITrayWindow *) Tray;
3414 
3415  return S_OK;
3416 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define S_OK
Definition: intsafe.h:51

Referenced by StartWithDesktop().

◆ FindEffectiveProc()

static BOOL CALLBACK FindEffectiveProc ( HWND  hwnd,
LPARAM  lParam 
)
static

Definition at line 71 of file traywnd.cpp.

72 {
74 
76  return TRUE; // continue
77 
78  if (pei->hTrayWnd == hwnd || pei->hwndDesktop == hwnd ||
79  pei->hwndProgman == hwnd)
80  {
81  return TRUE; // continue
82  }
83 
84  if (pei->bMustBeInMonitor)
85  {
86  // is the window in the nearest monitor?
87  HMONITOR hMon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
88  if (hMon)
89  {
91  ZeroMemory(&info, sizeof(info));
92  info.cbSize = sizeof(info);
93  if (GetMonitorInfoW(hMon, &info))
94  {
95  RECT rcWindow, rcMonitor, rcIntersect;
96  rcMonitor = info.rcMonitor;
97 
98  GetWindowRect(hwnd, &rcWindow);
99 
100  if (!IntersectRect(&rcIntersect, &rcMonitor, &rcWindow))
101  return TRUE; // continue
102  }
103  }
104  }
105 
106  pei->hwndFound = hwnd;
107  return FALSE; // stop if found
108 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI IsIconic(_In_ HWND)
struct _test_info info[]
Definition: SetCursorPos.c:19
HWND hwndFound
Definition: traywnd.cpp:63
HWND hwndProgman
Definition: traywnd.cpp:65
#define FALSE
Definition: types.h:117
HWND hwndDesktop
Definition: traywnd.cpp:64
BOOL bMustBeInMonitor
Definition: traywnd.cpp:67
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
LPARAM lParam
Definition: combotst.c:139

Referenced by IsThereAnyEffectiveWindow().

◆ IsThereAnyEffectiveWindow()

static BOOL IsThereAnyEffectiveWindow ( BOOL  bMustBeInMonitor)
static

Definition at line 111 of file traywnd.cpp.

112 {
113  EFFECTIVE_INFO ei;
114  ei.hwndFound = NULL;
116  ei.hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
117  ei.hwndProgman = FindWindowW(L"Progman", NULL);
118  ei.bMustBeInMonitor = bMustBeInMonitor;
119 
121  if (ei.hwndFound && FALSE)
122  {
123  WCHAR szClass[64], szText[64];
124  GetClassNameW(ei.hwndFound, szClass, _countof(szClass));
126  MessageBoxW(NULL, szText, szClass, 0);
127  }
128  return ei.hwndFound != NULL;
129 }
static BOOL CALLBACK FindEffectiveProc(HWND hwnd, LPARAM lParam)
Definition: traywnd.cpp:71
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
HWND hwndFound
Definition: traywnd.cpp:63
HWND hwndProgman
Definition: traywnd.cpp:65
#define FALSE
Definition: types.h:117
static const WCHAR szText[]
Definition: dialog.c:139
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
HWND hwndDesktop
Definition: traywnd.cpp:64
LONG_PTR LPARAM
Definition: windef.h:208
BOOL bMustBeInMonitor
Definition: traywnd.cpp:67
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)
#define _countof(array)
Definition: sndvol32.h:68
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412

Referenced by CTrayWindow::OnInitMenuPopup(), CTrayWindowCtxMenu::QueryContextMenu(), and CTrayWindow::ToggleDesktop().

◆ Tray_OnStartMenuDismissed()

HRESULT Tray_OnStartMenuDismissed ( ITrayWindow *  Tray)

Definition at line 3419 of file traywnd.cpp.

3420 {
3421  CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3422  return TrayWindow->RaiseStartButton();
3423 }
virtual HRESULT RaiseStartButton()
Definition: traywnd.cpp:3229

Referenced by CStartMenuSite::SetSubMenu().

◆ TrayMessageLoop()

VOID TrayMessageLoop ( ITrayWindow *  Tray)

Definition at line 3431 of file traywnd.cpp.

3432 {
3433  CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3434  TrayWindow->TrayMessageLoop();
3435 }
VOID TrayMessageLoop()
Definition: traywnd.cpp:3168

◆ TrayProcessMessages()

VOID TrayProcessMessages ( ITrayWindow *  Tray)

Definition at line 3425 of file traywnd.cpp.

3426 {
3427  CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3428  TrayWindow->TrayProcessMessages();
3429 }

◆ TrayWindowCtxMenuCreator()

HRESULT TrayWindowCtxMenuCreator ( ITrayWindow *  TrayWnd,
IN HWND  hWndOwner,
IContextMenu **  ppCtxMenu 
)

Definition at line 3396 of file traywnd.cpp.

3397 {
3399  mnu->Initialize(TrayWnd, hWndOwner);
3400  *ppCtxMenu = mnu;
3401  return S_OK;
3402 }
#define S_OK
Definition: intsafe.h:51
HRESULT Initialize(ITrayWindow *pTrayWnd, IN HWND hWndOwner)
Definition: traywnd.cpp:3275

Referenced by CTrayWindow::QueryContextMenu().

Variable Documentation

◆ g_MinimizedAll

◆ IID_IShellDesktopTray

const GUID IID_IShellDesktopTray = { 0x213e2df9, 0x9a14, 0x4328, { 0x99, 0xb1, 0x69, 0x61, 0xf9, 0x14, 0x3c, 0xe9 } }

Definition at line 137 of file traywnd.cpp.

◆ szTrayWndClass

const WCHAR szTrayWndClass[] = L"Shell_TrayWnd"
static

Definition at line 59 of file traywnd.cpp.