ReactOS 0.4.15-dev-8434-g155a7c7
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  WINDOWPOSBACKUPDATA
 
struct  EFFECTIVE_INFO
 
struct  MINWNDPOS
 
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
 
#define TIMER_ID_IGNOREPULSERESET   888
 
#define TIMER_IGNOREPULSERESET_TIMEOUT   200
 

Enumerations

enum  { NONE , TILED , CASCADED }
 

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 BackupWindowsPosProc (HWND hwnd, LPARAM lParam)
 
VOID BackupWindowPos ()
 
VOID RestoreWindowPos ()
 
BOOL CanBeMinimized (HWND hwnd)
 
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"
 
enum { ... }  g_Arrangement = NONE
 
CSimpleArray< WINDOWPOSBACKUPDATAg_WindowPosBackup
 
CSimpleArray< MINWNDPOSg_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_IGNOREPULSERESET

#define TIMER_ID_IGNOREPULSERESET   888

Definition at line 2410 of file traywnd.cpp.

◆ TIMER_ID_MOUSETRACK

#define TIMER_ID_MOUSETRACK   2

Definition at line 32 of file traywnd.cpp.

◆ TIMER_IGNOREPULSERESET_TIMEOUT

#define TIMER_IGNOREPULSERESET_TIMEOUT   200

Definition at line 2411 of file traywnd.cpp.

◆ WM_APP_TRAYDESTROY

#define WM_APP_TRAYDESTROY   (WM_APP + 0x100)

Definition at line 29 of file traywnd.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
NONE 
TILED 
CASCADED 

Definition at line 61 of file traywnd.cpp.

@ TILED
Definition: traywnd.cpp:61
@ NONE
Definition: traywnd.cpp:61
@ CASCADED
Definition: traywnd.cpp:61
enum @96 g_Arrangement

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}
static UINT_PTR handle_appbarmessage(DWORD msg, _AppBarData *abd)
Definition: appbar.cpp:133
#define ERR(fmt,...)
Definition: precomp.h:57
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define UnmapViewOfFile
Definition: compat.h:746
#define GetCurrentProcess()
Definition: compat.h:759
#define MapViewOfFile
Definition: compat.h:745
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
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
GLuint64EXT * result
Definition: glext.h:11304
#define PROCESS_DUP_HANDLE
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
ULONG return_map
Definition: appbar.cpp:41
struct _AppBarData abd
Definition: appbar.cpp:49
ULONGLONG result
Definition: appbar.cpp:48
Definition: ftp_var.h:139
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define DUPLICATE_SAME_ACCESS

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}
static struct list appbars
Definition: appbar.cpp:63
LPARAM lParam
Definition: combotst.c:139
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
uint32_t entry
Definition: isohybrid.c:63
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

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

◆ BackupWindowPos()

VOID BackupWindowPos ( )

Definition at line 85 of file traywnd.cpp.

86{
88}
static BOOL CALLBACK BackupWindowsPosProc(HWND hwnd, LPARAM lParam)
Definition: traywnd.cpp:70
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)

Referenced by CTrayWindow::ExecContextMenuCmd().

◆ BackupWindowsPosProc()

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

Definition at line 70 of file traywnd.cpp.

71{
72 WINDOWPOSBACKUPDATA wposdata;
73 HWND hDesk = GetDesktopWindow();
74 if (IsWindowVisible(hwnd) && !IsIconic(hwnd) && (hwnd != hDesk))
75 {
76 wposdata.hwnd = hwnd;
77 wposdata.wplt.length = sizeof(wposdata.wplt);
78 GetWindowPlacement(hwnd, &(wposdata.wplt));
79 g_WindowPosBackup.Add(wposdata);
80 }
81
82 return TRUE;
83}
WINDOWPLACEMENT wplt
Definition: traywnd.cpp:66
CSimpleArray< WINDOWPOSBACKUPDATA > g_WindowPosBackup
Definition: traywnd.cpp:68
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
BOOL WINAPI IsIconic(_In_ HWND)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by BackupWindowPos().

◆ CanBeMinimized()

BOOL CanBeMinimized ( HWND  hwnd)

Definition at line 102 of file traywnd.cpp.

103{
106 {
108 return TRUE;
109
111 if (!(exstyle & WS_EX_TOPMOST))
112 return TRUE;
113 }
114 return FALSE;
115}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWORD
Definition: nt_native.h:44
#define WS_EX_TOPMOST
Definition: pedump.c:647
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define WC_DIALOG
Definition: undocuser.h:11
BOOL WINAPI IsHungAppWindow(HWND hwnd)
Definition: window.c:1847
#define GetWindowLongPtrW
Definition: winuser.h:4829
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define GetClassLongPtrW
Definition: winuser.h:4564
#define GCW_ATOM
Definition: winuser.h:661
#define GWL_EXSTYLE
Definition: winuser.h:851

Referenced by FindEffectiveProc(), and CTrayWindow::MinimizeWindowsProc().

◆ CreateTrayWindow()

HRESULT CreateTrayWindow ( ITrayWindow **  ppTray)

Definition at line 3690 of file traywnd.cpp.

3691{
3693 if (Tray == NULL)
3694 return E_OUTOFMEMORY;
3695
3696 Tray->_Init();
3697 Tray->Open();
3698
3699 *ppTray = (ITrayWindow *) Tray;
3700
3701 return S_OK;
3702}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_OK
Definition: intsafe.h:52

Referenced by StartWithDesktop().

◆ FindEffectiveProc()

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

Definition at line 127 of file traywnd.cpp.

128{
130
131 if (!CanBeMinimized(hwnd))
132 return TRUE; // continue
133
134 if (pei->hTrayWnd == hwnd || pei->hwndDesktop == hwnd ||
135 pei->hwndProgman == hwnd)
136 {
137 return TRUE; // continue
138 }
139
140 if (pei->bMustBeInMonitor)
141 {
142 // is the window in the nearest monitor?
143 HMONITOR hMon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
144 if (hMon)
145 {
147 ZeroMemory(&info, sizeof(info));
148 info.cbSize = sizeof(info);
149 if (GetMonitorInfoW(hMon, &info))
150 {
151 RECT rcWindow, rcMonitor, rcIntersect;
152 rcMonitor = info.rcMonitor;
153
154 GetWindowRect(hwnd, &rcWindow);
155
156 if (!IntersectRect(&rcIntersect, &rcMonitor, &rcWindow))
157 return TRUE; // continue
158 }
159 }
160 }
161
162 pei->hwndFound = hwnd;
163 return FALSE; // stop if found
164}
HWND hwndDesktop
Definition: traywnd.cpp:120
HWND hwndProgman
Definition: traywnd.cpp:121
BOOL bMustBeInMonitor
Definition: traywnd.cpp:123
BOOL CanBeMinimized(HWND hwnd)
Definition: traywnd.cpp:102
#define ZeroMemory
Definition: winbase.h:1712
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)

Referenced by IsThereAnyEffectiveWindow().

◆ IsThereAnyEffectiveWindow()

static BOOL IsThereAnyEffectiveWindow ( BOOL  bMustBeInMonitor)
static

Definition at line 167 of file traywnd.cpp.

168{
170 ei.hwndFound = NULL;
172 ei.hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
173 ei.hwndProgman = FindWindowW(L"Progman", NULL);
174 ei.bMustBeInMonitor = bMustBeInMonitor;
175
177 return ei.hwndFound != NULL;
178}
#define L(x)
Definition: ntvdm.h:50
static BOOL CALLBACK FindEffectiveProc(HWND hwnd, LPARAM lParam)
Definition: traywnd.cpp:127
LONG_PTR LPARAM
Definition: windef.h:208
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)

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

◆ RestoreWindowPos()

VOID RestoreWindowPos ( )

Definition at line 90 of file traywnd.cpp.

91{
93
94 for (INT i = g_WindowPosBackup.GetSize() - 1; i >= 0; --i)
95 {
97 }
98
99 g_WindowPosBackup.RemoveAll();
100}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI SetWindowPlacement(_In_ HWND hWnd, _In_ const WINDOWPLACEMENT *)

Referenced by CTrayWindow::ExecContextMenuCmd().

◆ Tray_OnStartMenuDismissed()

HRESULT Tray_OnStartMenuDismissed ( ITrayWindow *  Tray)

Definition at line 3705 of file traywnd.cpp.

3706{
3707 CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3708 return TrayWindow->RaiseStartButton();
3709}
virtual HRESULT RaiseStartButton()
Definition: traywnd.cpp:3515

Referenced by CStartMenuSite::SetSubMenu().

◆ TrayMessageLoop()

VOID TrayMessageLoop ( ITrayWindow *  Tray)

Definition at line 3717 of file traywnd.cpp.

3718{
3719 CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3720 TrayWindow->TrayMessageLoop();
3721}
VOID TrayMessageLoop()
Definition: traywnd.cpp:3454

◆ TrayProcessMessages()

VOID TrayProcessMessages ( ITrayWindow *  Tray)

Definition at line 3711 of file traywnd.cpp.

3712{
3713 CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3714 TrayWindow->TrayProcessMessages();
3715}
VOID TrayProcessMessages()
Definition: traywnd.cpp:3434

◆ TrayWindowCtxMenuCreator()

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

Definition at line 3682 of file traywnd.cpp.

3683{
3685 mnu->Initialize(TrayWnd, hWndOwner);
3686 *ppCtxMenu = mnu;
3687 return S_OK;
3688}
HRESULT Initialize(ITrayWindow *pTrayWnd, IN HWND hWndOwner)
Definition: traywnd.cpp:3561

Referenced by CTrayWindow::QueryContextMenu().

Variable Documentation

◆ 

◆ g_MinimizedAll

◆ g_WindowPosBackup

CSimpleArray<WINDOWPOSBACKUPDATA> g_WindowPosBackup

◆ IID_IShellDesktopTray

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

Definition at line 192 of file traywnd.cpp.

◆ szTrayWndClass

const WCHAR szTrayWndClass[] = L"Shell_TrayWnd"
static

Definition at line 59 of file traywnd.cpp.