ReactOS 0.4.16-dev-1278-gd809cd0
traywnd.cpp File Reference
#include "precomp.h"
#include <commoncontrols.h>
#include "appbar.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)
 
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

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 20 of file traywnd.cpp.

◆ AUTOHIDE_DELAY_SHOW

#define AUTOHIDE_DELAY_SHOW   50

Definition at line 21 of file traywnd.cpp.

◆ AUTOHIDE_HIDDEN

#define AUTOHIDE_HIDDEN   0

Definition at line 27 of file traywnd.cpp.

◆ AUTOHIDE_HIDING

#define AUTOHIDE_HIDING   3

Definition at line 30 of file traywnd.cpp.

◆ AUTOHIDE_INTERVAL_ANIMATING

#define AUTOHIDE_INTERVAL_ANIMATING   10

Definition at line 22 of file traywnd.cpp.

◆ AUTOHIDE_SHOWING

#define AUTOHIDE_SHOWING   1

Definition at line 28 of file traywnd.cpp.

◆ AUTOHIDE_SHOWN

#define AUTOHIDE_SHOWN   2

Definition at line 29 of file traywnd.cpp.

◆ AUTOHIDE_SPEED_HIDE

#define AUTOHIDE_SPEED_HIDE   1

Definition at line 25 of file traywnd.cpp.

◆ AUTOHIDE_SPEED_SHOW

#define AUTOHIDE_SPEED_SHOW   10

Definition at line 24 of file traywnd.cpp.

◆ IDHK_DESKTOP

#define IDHK_DESKTOP   0x1fe

Definition at line 42 of file traywnd.cpp.

◆ IDHK_EXPLORE

#define IDHK_EXPLORE   0x1f8

Definition at line 36 of file traywnd.cpp.

◆ IDHK_FIND

#define IDHK_FIND   0x1f9

Definition at line 37 of file traywnd.cpp.

◆ IDHK_FIND_COMPUTER

#define IDHK_FIND_COMPUTER   0x1fa

Definition at line 38 of file traywnd.cpp.

◆ IDHK_HELP

#define IDHK_HELP   0x1f7

Definition at line 35 of file traywnd.cpp.

◆ IDHK_MINIMIZE_ALL

#define IDHK_MINIMIZE_ALL   0x1f5

Definition at line 33 of file traywnd.cpp.

◆ IDHK_NEXT_TASK

#define IDHK_NEXT_TASK   0x1fb

Definition at line 39 of file traywnd.cpp.

◆ IDHK_PAGER

#define IDHK_PAGER   0x1ff

Definition at line 43 of file traywnd.cpp.

◆ IDHK_PREV_TASK

#define IDHK_PREV_TASK   0x1fc

Definition at line 40 of file traywnd.cpp.

◆ IDHK_RESTORE_ALL

#define IDHK_RESTORE_ALL   0x1f6

Definition at line 34 of file traywnd.cpp.

◆ IDHK_RUN

#define IDHK_RUN   0x1f4

Definition at line 32 of file traywnd.cpp.

◆ IDHK_SYS_PROPERTIES

#define IDHK_SYS_PROPERTIES   0x1fd

Definition at line 41 of file traywnd.cpp.

◆ MOUSETRACK_INTERVAL

#define MOUSETRACK_INTERVAL   100

Definition at line 19 of file traywnd.cpp.

◆ TIMER_ID_AUTOHIDE

#define TIMER_ID_AUTOHIDE   1

Definition at line 17 of file traywnd.cpp.

◆ TIMER_ID_IGNOREPULSERESET

#define TIMER_ID_IGNOREPULSERESET   888

Definition at line 2395 of file traywnd.cpp.

◆ TIMER_ID_MOUSETRACK

#define TIMER_ID_MOUSETRACK   2

Definition at line 18 of file traywnd.cpp.

◆ TIMER_IGNOREPULSERESET_TIMEOUT

#define TIMER_IGNOREPULSERESET_TIMEOUT   200

Definition at line 2396 of file traywnd.cpp.

◆ WM_APP_TRAYDESTROY

#define WM_APP_TRAYDESTROY   (WM_APP + 0x100)

Definition at line 15 of file traywnd.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
NONE 
TILED 
CASCADED 

Definition at line 45 of file traywnd.cpp.

enum @122 g_Arrangement
@ TILED
Definition: traywnd.cpp:45
@ NONE
Definition: traywnd.cpp:45
@ CASCADED
Definition: traywnd.cpp:45

Function Documentation

◆ BackupWindowPos()

VOID BackupWindowPos ( )

Definition at line 69 of file traywnd.cpp.

70{
72}
#define NULL
Definition: types.h:112
static BOOL CALLBACK BackupWindowsPosProc(HWND hwnd, LPARAM lParam)
Definition: traywnd.cpp:54
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 54 of file traywnd.cpp.

55{
56 WINDOWPOSBACKUPDATA wposdata;
57 HWND hDesk = GetDesktopWindow();
58 if (IsWindowVisible(hwnd) && !IsIconic(hwnd) && (hwnd != hDesk))
59 {
60 wposdata.hwnd = hwnd;
61 wposdata.wplt.length = sizeof(wposdata.wplt);
62 GetWindowPlacement(hwnd, &(wposdata.wplt));
63 g_WindowPosBackup.Add(wposdata);
64 }
65
66 return TRUE;
67}
#define TRUE
Definition: types.h:120
WINDOWPLACEMENT wplt
Definition: traywnd.cpp:50
CSimpleArray< WINDOWPOSBACKUPDATA > g_WindowPosBackup
Definition: traywnd.cpp:52
_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 86 of file traywnd.cpp.

87{
90 {
92 return TRUE;
93
95 if (!(exstyle & WS_EX_TOPMOST))
96 return TRUE;
97 }
98 return FALSE;
99}
#define FALSE
Definition: types.h:117
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:13
BOOL WINAPI IsHungAppWindow(HWND hwnd)
Definition: window.c:1845
#define GetWindowLongPtrW
Definition: winuser.h:4905
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define GetClassLongPtrW
Definition: winuser.h:4640
#define GCW_ATOM
Definition: winuser.h:669
#define GWL_EXSTYLE
Definition: winuser.h:862

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

◆ CreateTrayWindow()

HRESULT CreateTrayWindow ( ITrayWindow **  ppTray)

Definition at line 3765 of file traywnd.cpp.

3766{
3768 if (Tray == NULL)
3769 return E_OUTOFMEMORY;
3770
3771 Tray->_Init();
3772 Tray->Open();
3773
3774 *ppTray = (ITrayWindow *) Tray;
3775
3776 return S_OK;
3777}
#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 111 of file traywnd.cpp.

112{
114
115 if (!CanBeMinimized(hwnd))
116 return TRUE; // continue
117
118 if (pei->hTrayWnd == hwnd || pei->hwndDesktop == hwnd ||
119 pei->hwndProgman == hwnd)
120 {
121 return TRUE; // continue
122 }
123
124 if (pei->bMustBeInMonitor)
125 {
126 // is the window in the nearest monitor?
127 HMONITOR hMon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
128 if (hMon)
129 {
131 ZeroMemory(&info, sizeof(info));
132 info.cbSize = sizeof(info);
133 if (GetMonitorInfoW(hMon, &info))
134 {
135 RECT rcWindow, rcMonitor, rcIntersect;
136 rcMonitor = info.rcMonitor;
137
138 GetWindowRect(hwnd, &rcWindow);
139
140 if (!IntersectRect(&rcIntersect, &rcMonitor, &rcWindow))
141 return TRUE; // continue
142 }
143 }
144 }
145
146 pei->hwndFound = hwnd;
147 return FALSE; // stop if found
148}
LPARAM lParam
Definition: combotst.c:139
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
HWND hwndDesktop
Definition: traywnd.cpp:104
HWND hwndProgman
Definition: traywnd.cpp:105
BOOL bMustBeInMonitor
Definition: traywnd.cpp:107
BOOL CanBeMinimized(HWND hwnd)
Definition: traywnd.cpp:86
#define ZeroMemory
Definition: winbase.h:1753
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 151 of file traywnd.cpp.

152{
154 ei.hwndFound = NULL;
156 ei.hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
157 ei.hwndProgman = FindWindowW(L"Progman", NULL);
158 ei.bMustBeInMonitor = bMustBeInMonitor;
159
161 return ei.hwndFound != NULL;
162}
#define L(x)
Definition: ntvdm.h:50
static BOOL CALLBACK FindEffectiveProc(HWND hwnd, LPARAM lParam)
Definition: traywnd.cpp:111
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 74 of file traywnd.cpp.

75{
77
78 for (INT i = g_WindowPosBackup.GetSize() - 1; i >= 0; --i)
79 {
81 }
82
83 g_WindowPosBackup.RemoveAll();
84}
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 3780 of file traywnd.cpp.

3781{
3782 CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3783 return TrayWindow->RaiseStartButton();
3784}
virtual HRESULT RaiseStartButton()
Definition: traywnd.cpp:3547

Referenced by CStartMenuSite::SetSubMenu().

◆ TrayMessageLoop()

VOID TrayMessageLoop ( ITrayWindow *  Tray)

Definition at line 3792 of file traywnd.cpp.

3793{
3794 CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3795 TrayWindow->TrayMessageLoop();
3796}
VOID TrayMessageLoop()
Definition: traywnd.cpp:3482

◆ TrayProcessMessages()

VOID TrayProcessMessages ( ITrayWindow *  Tray)

Definition at line 3786 of file traywnd.cpp.

3787{
3788 CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3789 TrayWindow->TrayProcessMessages();
3790}
VOID TrayProcessMessages()
Definition: traywnd.cpp:3462

◆ TrayWindowCtxMenuCreator()

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

Definition at line 3757 of file traywnd.cpp.

3758{
3760 mnu->Initialize(TrayWnd, hWndOwner);
3761 *ppCtxMenu = mnu;
3762 return S_OK;
3763}
HRESULT Initialize(ITrayWindow *pTrayWnd, IN HWND hWndOwner)
Definition: traywnd.cpp:3635

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 176 of file traywnd.cpp.