ReactOS 0.4.17-dev-243-g1369312
traywnd.cpp File Reference
#include "precomp.h"
#include <commoncontrols.h>
#include <cfgmgr32.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
 

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

◆ AUTOHIDE_DELAY_SHOW

#define AUTOHIDE_DELAY_SHOW   50

Definition at line 22 of file traywnd.cpp.

◆ AUTOHIDE_HIDDEN

#define AUTOHIDE_HIDDEN   0

Definition at line 28 of file traywnd.cpp.

◆ AUTOHIDE_HIDING

#define AUTOHIDE_HIDING   3

Definition at line 31 of file traywnd.cpp.

◆ AUTOHIDE_INTERVAL_ANIMATING

#define AUTOHIDE_INTERVAL_ANIMATING   10

Definition at line 23 of file traywnd.cpp.

◆ AUTOHIDE_SHOWING

#define AUTOHIDE_SHOWING   1

Definition at line 29 of file traywnd.cpp.

◆ AUTOHIDE_SHOWN

#define AUTOHIDE_SHOWN   2

Definition at line 30 of file traywnd.cpp.

◆ AUTOHIDE_SPEED_HIDE

#define AUTOHIDE_SPEED_HIDE   1

Definition at line 26 of file traywnd.cpp.

◆ AUTOHIDE_SPEED_SHOW

#define AUTOHIDE_SPEED_SHOW   10

Definition at line 25 of file traywnd.cpp.

◆ IDHK_DESKTOP

#define IDHK_DESKTOP   0x1fe

Definition at line 43 of file traywnd.cpp.

◆ IDHK_EXPLORE

#define IDHK_EXPLORE   0x1f8

Definition at line 37 of file traywnd.cpp.

◆ IDHK_FIND

#define IDHK_FIND   0x1f9

Definition at line 38 of file traywnd.cpp.

◆ IDHK_FIND_COMPUTER

#define IDHK_FIND_COMPUTER   0x1fa

Definition at line 39 of file traywnd.cpp.

◆ IDHK_HELP

#define IDHK_HELP   0x1f7

Definition at line 36 of file traywnd.cpp.

◆ IDHK_MINIMIZE_ALL

#define IDHK_MINIMIZE_ALL   0x1f5

Definition at line 34 of file traywnd.cpp.

◆ IDHK_NEXT_TASK

#define IDHK_NEXT_TASK   0x1fb

Definition at line 40 of file traywnd.cpp.

◆ IDHK_PAGER

#define IDHK_PAGER   0x1ff

Definition at line 44 of file traywnd.cpp.

◆ IDHK_PREV_TASK

#define IDHK_PREV_TASK   0x1fc

Definition at line 41 of file traywnd.cpp.

◆ IDHK_RESTORE_ALL

#define IDHK_RESTORE_ALL   0x1f6

Definition at line 35 of file traywnd.cpp.

◆ IDHK_RUN

#define IDHK_RUN   0x1f4

Definition at line 33 of file traywnd.cpp.

◆ IDHK_SYS_PROPERTIES

#define IDHK_SYS_PROPERTIES   0x1fd

Definition at line 42 of file traywnd.cpp.

◆ MOUSETRACK_INTERVAL

#define MOUSETRACK_INTERVAL   100

Definition at line 20 of file traywnd.cpp.

◆ TIMER_ID_AUTOHIDE

#define TIMER_ID_AUTOHIDE   1

Definition at line 18 of file traywnd.cpp.

◆ TIMER_ID_MOUSETRACK

#define TIMER_ID_MOUSETRACK   2

Definition at line 19 of file traywnd.cpp.

◆ WM_APP_TRAYDESTROY

#define WM_APP_TRAYDESTROY   (WM_APP + 0x100)

Definition at line 16 of file traywnd.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
NONE 
TILED 
CASCADED 

Definition at line 46 of file traywnd.cpp.

enum @116 g_Arrangement
@ TILED
Definition: traywnd.cpp:46
@ NONE
Definition: traywnd.cpp:46
@ CASCADED
Definition: traywnd.cpp:46

Function Documentation

◆ BackupWindowPos()

VOID BackupWindowPos ( )

Definition at line 70 of file traywnd.cpp.

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

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

88{
91 {
93 return TRUE;
94
96 if (!(exstyle & WS_EX_TOPMOST))
97 return TRUE;
98 }
99 return FALSE;
100}
#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:4983
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define GetClassLongPtrW
Definition: winuser.h:4718
#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 3760 of file traywnd.cpp.

3761{
3763 if (Tray == NULL)
3764 return E_OUTOFMEMORY;
3765
3766 Tray->_Init();
3767 Tray->Open();
3768
3769 *ppTray = (ITrayWindow *) Tray;
3770
3771 return S_OK;
3772}
#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 112 of file traywnd.cpp.

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

153{
155 ei.hwndFound = NULL;
157 ei.hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
158 ei.hwndProgman = FindWindowW(L"Progman", NULL);
159 ei.bMustBeInMonitor = bMustBeInMonitor;
160
162 return ei.hwndFound != NULL;
163}
#define L(x)
Definition: resources.c:13
LONG_PTR LPARAM
Definition: minwindef.h:175
static BOOL CALLBACK FindEffectiveProc(HWND hwnd, LPARAM lParam)
Definition: traywnd.cpp:112
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)

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

◆ RestoreWindowPos()

VOID RestoreWindowPos ( )

Definition at line 75 of file traywnd.cpp.

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

3776{
3777 CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3778 return TrayWindow->RaiseStartButton();
3779}
virtual HRESULT RaiseStartButton()
Definition: traywnd.cpp:3542

Referenced by CStartMenuSite::SetSubMenu().

◆ TrayMessageLoop()

VOID TrayMessageLoop ( ITrayWindow *  Tray)

Definition at line 3787 of file traywnd.cpp.

3788{
3789 CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3790 TrayWindow->TrayMessageLoop();
3791}
VOID TrayMessageLoop()
Definition: traywnd.cpp:3477

◆ TrayProcessMessages()

VOID TrayProcessMessages ( ITrayWindow *  Tray)

Definition at line 3781 of file traywnd.cpp.

3782{
3783 CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3784 TrayWindow->TrayProcessMessages();
3785}
VOID TrayProcessMessages()
Definition: traywnd.cpp:3457

◆ TrayWindowCtxMenuCreator()

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

Definition at line 3752 of file traywnd.cpp.

3753{
3755 mnu->Initialize(TrayWnd, hWndOwner);
3756 *ppCtxMenu = mnu;
3757 return S_OK;
3758}
HRESULT Initialize(ITrayWindow *pTrayWnd, IN HWND hWndOwner)
Definition: traywnd.cpp:3630

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