ReactOS  0.4.15-dev-1171-gab82533
TaskBar Struct Reference

Taskbar window. More...

#include <taskbar.h>

Inheritance diagram for TaskBar:
Collaboration diagram for TaskBar:

Public Types

typedef Window super
 
- Public Types inherited from Window
typedef map< HWND, Window * > WindowMap
 
typedef Window *(* CREATORFUNC) (HWND)
 
typedef Window *(* CREATORFUNC_INFO) (HWND, const void *)
 

Public Member Functions

 TaskBar (HWND hwnd)
 
 ~TaskBar ()
 
- Public Member Functions inherited from Window
 Window (HWND hwnd)
 
virtual ~Window ()
 
LRESULT SendParent (UINT nmsg, WPARAM wparam=0, LPARAM lparam=0)
 
LRESULT PostParent (UINT nmsg, WPARAM wparam=0, LPARAM lparam=0)
 
 Window (INT cx, INT cy, BOOL fAutoHide=FALSE)
 
virtual ~Window ()
 
virtual LRESULT CALLBACK WindowProcDx (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void DoAction ()
 

Static Public Member Functions

static HWND Create (HWND hwndParent)
 
- Static Public Member Functions inherited from Window
static HWND Create (CREATORFUNC creator, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0)
 
static HWND Create (CREATORFUNC_INFO creator, const void *info, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0)
 
static Windowcreate_mdi_child (const ChildWndInfo &info, const MDICREATESTRUCT &mcs, CREATORFUNC_INFO creator)
 
static LRESULT CALLBACK WindowWndProc (HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
 
static INT_PTR CALLBACK DialogProc (HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
 
static Windowget_window (HWND hwnd)
 get window controller from window handle More...
 
template<typename CLASS >
static CLASS * get_window (HWND hwnd)
 
static void register_pretranslate (HWND hwnd)
 
static void unregister_pretranslate (HWND hwnd)
 
static BOOL pretranslate_msg (LPMSG pmsg)
 
static void register_dialog (HWND hwnd)
 
static void unregister_dialog (HWND hwnd)
 
static BOOL dispatch_dialog_msg (LPMSG pmsg)
 
static int MessageLoop ()
 
static void CancelModes ()
 
static BOOL DoRegisterClass (HINSTANCE hInstance)
 
static HWND DoCreateMainWnd (HINSTANCE hInstance, LPCTSTR pszText, INT cx, INT cy, DWORD style=WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN, DWORD exstyle=WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW|WS_EX_TOPMOST, BOOL fAutoHide=FALSE)
 
static INT DoMainLoop ()
 
static WindowGetAppbarData (HWND hwnd)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static DWORD WINAPI ActionThreadFunc (LPVOID args)
 

Protected Member Functions

LRESULT Init (LPCREATESTRUCT pcs)
 
LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
 
int Command (int id, int code)
 
int Notify (int id, NMHDR *pnmh)
 
void ActivateApp (TaskBarMap::iterator it, bool can_minimize=true, bool can_restore=true)
 
void ShowAppSystemMenu (TaskBarMap::iterator it)
 
void Refresh ()
 
void ResizeButtons ()
 
- Protected Member Functions inherited from Window
void OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
 
void OnPaint (HWND hwnd)
 
void OnRButtonDown (HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
 
void OnKey (HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
 
void OnAppBarCallback (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL AppBar_Register (HWND hwnd)
 
BOOL AppBar_UnRegister (HWND hwnd)
 
BOOL AppBar_SetAutoHide (HWND hwnd, BOOL fHide)
 
BOOL AppBar_AutoHide (HWND hwnd)
 
BOOL AppBar_NoAutoHide (HWND hwnd)
 
BOOL AppBar_SetSide (HWND hwnd, UINT uSide)
 
void AppBar_SetAlwaysOnTop (HWND hwnd, BOOL fOnTop)
 
void AppBar_Hide (HWND hwnd)
 
void AppBar_UnHide (HWND hwnd)
 
void AppBar_SetAutoHideTimer (HWND hwnd)
 
void AppBar_SetAutoUnhideTimer (HWND hwnd)
 
void AppBar_Size (HWND hwnd)
 
void AppBar_QueryPos (HWND hwnd, LPRECT lprc)
 
void AppBar_QuerySetPos (UINT uEdge, LPRECT lprc, PAPPBARDATA pabd, BOOL fMove)
 
void AppBar_PosChanged (PAPPBARDATA pabd)
 
BOOL OnCreate (HWND hwnd, LPCREATESTRUCT lpCreateStruct)
 
void OnActivate (HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
 
void OnWindowPosChanged (HWND hwnd, const LPWINDOWPOS lpwpos)
 
void OnSize (HWND hwnd, UINT state, int cx, int cy)
 
void OnMove (HWND hwnd, int x, int y)
 
void OnNCDestroy (HWND hwnd)
 
void OnTimer (HWND hwnd, UINT id)
 
UINT OnNCHitTest (HWND hwnd, int x, int y)
 
void OnLButtonDown (HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
 
void OnMouseMove (HWND hwnd, int x, int y, UINT keyFlags)
 
void OnLButtonUp (HWND hwnd, int x, int y, UINT keyFlags)
 
void GetWorkArea (LPRECT prc) const
 

Static Protected Member Functions

static BOOL CALLBACK EnumWndProc (HWND hwnd, LPARAM lparam)
 
- Static Protected Member Functions inherited from Window
static Windowcreate_controller (HWND hwnd)
 create controller for a new window More...
 
static StaticWindowDataGetStaticWindowData ()
 
static LRESULT CALLBACK MDICBTHookProc (int code, WPARAM wparam, LPARAM lparam)
 
static LRESULT CALLBACK PropSheetCBTHookProc (int code, WPARAM wparam, LPARAM lparam)
 

Protected Attributes

WindowHandle _htoolbar
 
TaskBarMap _map
 
int _next_id
 
WindowHandle _last_foreground_wnd
 
int _last_btn_width
 
MINIMIZEDMETRICS _mmMetrics_org
 
const UINT WM_SHELLHOOK
 
- Protected Attributes inherited from Window
HWND m_hwnd
 
BOOL m_fAutoHide
 
BOOL m_fOnTop
 
BOOL m_fHiding
 
UINT m_uSide
 
LONG m_cxWidth
 
LONG m_cyHeight
 
LONG m_cxSave
 
LONG m_cySave
 
BOOL m_fAppBarRegd
 
BOOL m_fMoving
 
BOOL m_bDragged
 
POINT m_ptDragOn
 
RECT m_rcAppBar
 
RECT m_rcDrag
 

Additional Inherited Members

- Public Attributes inherited from Window
IAccessible IAccessible_iface
 
IOleWindow IOleWindow_iface
 
IEnumVARIANT IEnumVARIANT_iface
 
LONG ref
 
- Static Protected Attributes inherited from Window
static WindowMap s_wnd_map
 
static const voids_new_info = NULL
 
static CREATORFUNC s_window_creator = NULL
 
static HHOOK s_hcbtHook = 0
 
static WindowSet s_pretranslate_windows
 
static WindowSet s_dialogs
 

Detailed Description

Taskbar window.

Definition at line 73 of file taskbar.h.

Member Typedef Documentation

◆ super

Definition at line 75 of file taskbar.h.

Constructor & Destructor Documentation

◆ TaskBar()

TaskBar::TaskBar ( HWND  hwnd)

Definition at line 70 of file taskbar.cpp.

71  : super(hwnd),
73 {
74  _last_btn_width = 0;
75 
77 
78  SystemParametersInfo(SPI_GETMINIMIZEDMETRICS, sizeof(_mmMetrics_org), &_mmMetrics_org, 0);
79 
80  // configure the window manager to hide windows when they are minimized
81  // This is neccessary to enable shell hook messages.
82  if (!(_mmMetrics_org.iArrange & ARW_HIDE)) {
83  MINIMIZEDMETRICS _mmMetrics_new = _mmMetrics_org;
84 
85  _mmMetrics_new.iArrange |= ARW_HIDE;
86 
87  SystemParametersInfo(SPI_SETMINIMIZEDMETRICS, sizeof(_mmMetrics_new), &_mmMetrics_new, 0);
88  }
89 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
struct tagMINIMIZEDMETRICS MINIMIZEDMETRICS
Window super
Definition: taskbar.h:75
#define SystemParametersInfo
Definition: winuser.h:5833
const UINT WM_SHELLHOOK
Definition: taskbar.h:90
MINIMIZEDMETRICS _mmMetrics_org
Definition: taskbar.h:88
#define WINMSG_SHELLHOOK
Definition: window.h:988
int _last_btn_width
Definition: taskbar.h:87
#define RegisterWindowMessage
Definition: winuser.h:5815
#define ARW_HIDE
Definition: winuser.h:1066

◆ ~TaskBar()

TaskBar::~TaskBar ( )

Definition at line 91 of file taskbar.cpp.

92 {
93 // if (g_RegisterShellHook)
94 // (*g_RegisterShellHook)(_hwnd, RSH_UNREGISTER);
95 
97  (*g_DeregisterShellHookWindow)(_hwnd);
98  else
99  KillTimer(_hwnd, 0);
100 
101  if (g_SetTaskmanWindow)
102  (*g_SetTaskmanWindow)(0);
103 
104  SystemParametersInfo(SPI_GETMINIMIZEDMETRICS, sizeof(_mmMetrics_org), &_mmMetrics_org, 0);
105 }
#define SystemParametersInfo
Definition: winuser.h:5833
MINIMIZEDMETRICS _mmMetrics_org
Definition: taskbar.h:88
DynamicFct< BOOL(WINAPI *)(HWND hwnd)> g_DeregisterShellHookWindow(TEXT("user32"), "DeregisterShellHookWindow")
Definition: taskbar.cpp:37
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
DynamicFct< BOOL(WINAPI *)(HWND hwnd)> g_SetTaskmanWindow(TEXT("user32"), "SetTaskmanWindow")
Definition: taskbar.cpp:35

Member Function Documentation

◆ ActivateApp()

void TaskBar::ActivateApp ( TaskBarMap::iterator  it,
bool  can_minimize = true,
bool  can_restore = true 
)
protected

Definition at line 280 of file taskbar.cpp.

281 {
282  HWND hwnd = it->first;
283 
284  bool minimize_it = can_minimize && !IsIconic(hwnd) &&
286 
287  // switch to selected application window
288  if (can_restore && !minimize_it)
289  if (IsIconic(hwnd))
291 
292  // In case minimize_it is true, we _have_ to switch to the app before
293  // posting SW_MINIMIZE to be compatible with some applications (e.g. "Sleipnir")
295 
296  if (minimize_it) {
299  } else
301 
302  Refresh();
303 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SC_RESTORE
Definition: winuser.h:2573
BOOL WINAPI IsIconic(_In_ HWND)
void Refresh()
Definition: taskbar.cpp:488
#define PostMessage
Definition: winuser.h:5807
#define SC_MINIMIZE
Definition: winuser.h:2561
WindowHandle _last_foreground_wnd
Definition: taskbar.h:86
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define WM_SYSCOMMAND
Definition: winuser.h:1723

Referenced by Command(), Notify(), and ShowAppSystemMenu().

◆ Command()

int TaskBar::Command ( int  id,
int  code 
)
protectedvirtual

Reimplemented from Window.

Definition at line 231 of file taskbar.cpp.

232 {
233  TaskBarMap::iterator found = _map.find_id(id);
234 
235  if (found != _map.end()) {
236  ActivateApp(found);
237  return 0;
238  }
239 
240  return super::Command(id, code);
241 }
iterator find_id(int id)
Definition: taskbar.cpp:561
TaskBarMap _map
Definition: taskbar.h:84
void ActivateApp(TaskBarMap::iterator it, bool can_minimize=true, bool can_restore=true)
Definition: taskbar.cpp:280
Definition: inflate.c:139
virtual int Command(int id, int code)
Definition: window.cpp:285
_Rep_type::iterator iterator
Definition: _map.h:85
iterator end()
Definition: _map.h:165

◆ Create()

HWND TaskBar::Create ( HWND  hwndParent)
static

Definition at line 107 of file taskbar.cpp.

108 {
109  ClientRect clnt(hwndParent);
110 
111  int taskbar_pos = 80; // This start position will be adjusted in DesktopBar::Resize().
112 
116  taskbar_pos, 0, clnt.right-taskbar_pos-(NOTIFYAREA_WIDTH_DEF+1), clnt.bottom, hwndParent);
117 }
#define WINDOW_CREATOR(WND_CLASS)
Definition: window.h:202
#define WS_CHILD
Definition: pedump.c:617
#define CCS_NODIVIDER
Definition: commctrl.h:2244
#define CLASSNAME_TASKBAR
Definition: taskbar.h:32
Taskbar window.
Definition: taskbar.h:73
static HWND hwndParent
Definition: cryptui.c:300
#define CCS_TOP
Definition: commctrl.h:2238
static HWND Create(CREATORFUNC creator, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0)
Definition: window.cpp:87
#define TITLE_TASKBAR
Definition: taskbar.h:33
window class with gray background color
Definition: window.h:248
#define CCS_NORESIZE
Definition: commctrl.h:2241
#define NOTIFYAREA_WIDTH_DEF
Definition: traynotify.h:34
#define WS_VISIBLE
Definition: pedump.c:620

Referenced by DesktopBar::Init().

◆ EnumWndProc()

BOOL CALLBACK TaskBar::EnumWndProc ( HWND  hwnd,
LPARAM  lparam 
)
staticprotected

Definition at line 374 of file taskbar.cpp.

375 {
376  TaskBar* pThis = (TaskBar*)lparam;
377 
379  DWORD ex_style = GetWindowExStyle(hwnd);
380 
381  if ((style&WS_VISIBLE) && !(ex_style&WS_EX_TOOLWINDOW) &&
384 
386  title[0] = '\0';
387 
388  TaskBarMap::iterator found = pThis->_map.find(hwnd);
389  int last_id = 0;
390 
391  if (found != pThis->_map.end()) {
392  last_id = found->second._id;
393 
394  if (!last_id)
395  found->second._id = pThis->_next_id++;
396  } else {
397  HBITMAP hbmp;
399  BOOL delete_icon = FALSE;
400 
401  if (!hIcon) {
403  delete_icon = TRUE;
404  }
405 
406  if (hIcon) {
408  if (delete_icon)
409  DestroyIcon(hIcon); // some icons can be freed, some not - so ignore any error return of DestroyIcon()
410  } else
411  hbmp = 0;
412 
413  TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
414  int bmp_idx = SendMessage(pThis->_htoolbar, TB_ADDBITMAP, 1, (LPARAM)&ab);
415 
417 
418  entry._id = pThis->_next_id++;
419  entry._hbmp = hbmp;
420  entry._bmp_idx = bmp_idx;
421  entry._title = title;
422 
423  pThis->_map[hwnd] = entry;
424  found = pThis->_map.find(hwnd);
425  }
426 
427  TBBUTTON btn = {-2/*I_IMAGENONE*/, 0, TBSTATE_ENABLED/*|TBSTATE_ELLIPSES*/, BTNS_BUTTON, {0, 0}, 0, 0};
428  TaskBarEntry& entry = found->second;
429 
430  ++entry._used;
431  btn.idCommand = entry._id;
432 
433  HWND foreground = GetForegroundWindow();
434  HWND foreground_owner = GetWindow(foreground, GW_OWNER);
435 
436  if (hwnd==foreground || hwnd==foreground_owner) {
438  pThis->_last_foreground_wnd = hwnd;
439  }
440 
441  if (!last_id) {
442  // create new toolbar buttons for new windows
443  if (title[0])
444  btn.iString = (INT_PTR)title;
445 
446  btn.iBitmap = entry._bmp_idx;
447  entry._btn_idx = SendMessage(pThis->_htoolbar, TB_BUTTONCOUNT, 0, 0);
448 
449  SendMessage(pThis->_htoolbar, TB_INSERTBUTTON, entry._btn_idx, (LPARAM)&btn);
450 
451  pThis->ResizeButtons();
452  } else {
453  // refresh attributes of existing buttons
454  if (btn.fsState != entry._fsState)
455  SendMessage(pThis->_htoolbar, TB_SETSTATE, entry._id, MAKELONG(btn.fsState,0));
456 
457  if (entry._title != title) {
459 
460  info.cbSize = sizeof(TBBUTTONINFO);
461  info.dwMask = TBIF_TEXT;
462  info.pszText = title;
463 
465 
466  entry._title = title;
467  }
468  }
469 
470  entry._fsState = btn.fsState;
471 
472 #ifdef __REACTOS__ // now handled by activating the ARW_HIDE flag with SystemParametersInfo(SPI_SETMINIMIZEDMETRICS)
473  // move minimized windows out of sight
474  if (IsIconic(hwnd)) {
475  RECT rect;
476 
478 
479  if (rect.bottom > 0)
480  SetWindowPos(hwnd, 0, -32000, -32000, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
481  }
482 #endif
483  }
484 
485  return TRUE;
486 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HICON
Definition: imagelist.c:84
#define TB_BUTTONCOUNT
Definition: commctrl.h:1106
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define TRUE
Definition: types.h:120
#define TB_SETSTATE
Definition: commctrl.h:1050
TaskBarMap _map
Definition: taskbar.h:84
#define IDI_APPLICATION
Definition: winuser.h:699
#define SWP_NOZORDER
Definition: winuser.h:1232
int32_t INT_PTR
Definition: typedefs.h:64
#define TB_INSERTBUTTON
Definition: commctrl.h:1266
BOOL WINAPI IsIconic(_In_ HWND)
WindowHandle _htoolbar
Definition: taskbar.h:83
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
& rect
Definition: startmenu.cpp:1413
#define TB_SETBUTTONINFO
Definition: commctrl.h:1259
#define GetWindowText
Definition: winuser.h:5773
#define GetWindowStyle(hwnd)
Definition: windowsx.h:290
struct _test_info info[]
Definition: SetCursorPos.c:19
#define BTNS_BUTTON
Definition: commctrl.h:994
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
Taskbar window.
Definition: taskbar.h:73
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define BUFFER_LEN
Definition: utility.h:97
LONG_PTR LPARAM
Definition: windef.h:208
void ResizeButtons()
Definition: taskbar.cpp:570
UCHAR ab[sizeof("Hello World!") -1]
Definition: fdi.c:106
INT_PTR iString
Definition: commctrl.h:955
int iBitmap
Definition: commctrl.h:945
HBITMAP hbmp
char TCHAR
Definition: xmlstorage.h:189
#define TBSTATE_PRESSED
Definition: commctrl.h:969
int _next_id
Definition: taskbar.h:85
#define SWP_NOACTIVATE
Definition: winuser.h:1227
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TB_ADDBITMAP
Definition: commctrl.h:1052
internal task bar button management entry
Definition: taskbar.h:50
_STLP_TEMPLATE_FOR_CONT_EXT iterator find(const _KT &__x)
Definition: _map.h:210
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
int idCommand
Definition: commctrl.h:946
#define COLOR_BTNFACE
Definition: winuser.h:918
uint32_t entry
Definition: isohybrid.c:63
#define SWP_NOSIZE
Definition: winuser.h:1230
WindowHandle _last_foreground_wnd
Definition: taskbar.h:86
HWND WINAPI GetParent(_In_ HWND)
#define TBSTATE_CHECKED
Definition: commctrl.h:968
HICON hIcon
Definition: msconfig.c:44
#define TBIF_TEXT
Definition: commctrl.h:1216
HICON get_window_icon_small(HWND hwnd)
retrieve icon from window
Definition: taskbar.cpp:323
#define GW_OWNER
Definition: winuser.h:761
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define SendMessage
Definition: winuser.h:5818
#define TBSTATE_ENABLED
Definition: commctrl.h:970
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
static HBITMAP
Definition: button.c:44
#define LoadIcon
Definition: winuser.h:5788
HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd)
create a bitmap from an icon
Definition: explorer.cpp:332
BYTE fsState
Definition: commctrl.h:947
#define GetWindowExStyle(hwnd)
Definition: windowsx.h:285
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620
HBRUSH WINAPI GetSysColorBrush(_In_ int)
static char title[]
Definition: ps.c:92
_Rep_type::iterator iterator
Definition: _map.h:85
#define TBBUTTONINFO
Definition: commctrl.h:1250
iterator end()
Definition: _map.h:165

Referenced by Refresh().

◆ Init()

LRESULT TaskBar::Init ( LPCREATESTRUCT  pcs)
protectedvirtual

Reimplemented from Window.

Definition at line 119 of file taskbar.cpp.

120 {
121  if (super::Init(pcs))
122  return 1;
123 
124  /* FIXME: There's an internal padding for non-flat toolbar. Get rid of it somehow. */
125  _htoolbar = CreateToolbarEx(_hwnd,
128  IDW_TASKTOOLBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON));
129 
131  //SendMessage(_htoolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
132  //SendMessage(_htoolbar, TB_SETDRAWTEXTFLAGS, DT_CENTER|DT_VCENTER, DT_CENTER|DT_VCENTER);
133  //SetWindowFont(_htoolbar, GetStockFont(ANSI_VAR_FONT), FALSE);
134  //SendMessage(_htoolbar, TB_SETPADDING, 0, MAKELPARAM(8,8));
135 
136  // set metrics for the Taskbar toolbar to enable button spacing
138 
139  metrics.cbSize = sizeof(TBMETRICS);
141  metrics.cxBarPad = 0;
142  metrics.cyBarPad = 0;
143  metrics.cxButtonSpacing = 3;
144  metrics.cyButtonSpacing = 3;
145 
147 
149 
150  // register the taskbar window as task manager window to make the following call to RegisterShellHookWindow working
151  if (g_SetTaskmanWindow)
152  (*g_SetTaskmanWindow)(_hwnd);
153 
155  LOG(TEXT("Using shell hooks for notification of shell events."));
156 
157  (*g_RegisterShellHookWindow)(_hwnd);
158  } else {
159  LOG(TEXT("Shell hooks not available."));
160 
161  SetTimer(_hwnd, 0, 200, NULL);
162  }
163 
164 /* Alternatively we could use the RegisterShellHook() function in SHELL32, but this is not yet implemented in the WINE code.
165  if (g_RegisterShellHook) {
166  (*g_RegisterShellHook)(0, RSH_REGISTER);
167 
168  if ((HIWORD(GetVersion())>>14) == W_VER_NT)
169  (*g_RegisterShellHook)(_hwnd, RSH_REGISTER_TASKMAN);
170  else
171  (*g_RegisterShellHook)(_hwnd, RSH_REGISTER);
172  }
173 */
174  Refresh();
175 
176  return 0;
177 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
virtual LRESULT Init(LPCREATESTRUCT pcs)
Definition: window.cpp:241
#define WS_CHILD
Definition: pedump.c:617
#define WS_CLIPCHILDREN
Definition: pedump.c:619
HWND WINAPI CreateToolbarEx(HWND hwnd, DWORD style, UINT wID, INT nBitmaps, HINSTANCE hBMInst, UINT_PTR wBMID, LPCTBBUTTON lpButtons, INT iNumButtons, INT dxButton, INT dyButton, INT dxBitmap, INT dyBitmap, UINT uStructSize)
Definition: commctrl.c:929
WindowHandle _htoolbar
Definition: taskbar.h:83
void Refresh()
Definition: taskbar.cpp:488
#define CCS_NODIVIDER
Definition: commctrl.h:2244
#define TBMF_BUTTONSPACING
Definition: commctrl.h:1285
DynamicFct< BOOL(WINAPI *)(HWND hwnd)> g_RegisterShellHookWindow(TEXT("user32"), "RegisterShellHookWindow")
Definition: taskbar.cpp:36
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define IDC_FIRST_APP
Definition: taskbar.h:35
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define CCS_TOP
Definition: commctrl.h:2238
#define TASKBUTTONWIDTH_MAX
Definition: taskbar.h:40
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
int _next_id
Definition: taskbar.h:85
#define TB_SETMETRICS
Definition: commctrl.h:1299
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:985
#define IDW_TASKTOOLBAR
Definition: taskbar.h:43
#define TB_SETBUTTONWIDTH
Definition: commctrl.h:1157
#define LOG(txt)
Definition: utility.h:102
#define TEXT(s)
Definition: k32.h:26
#define TBMF_BARPAD
Definition: commctrl.h:1284
DynamicFct< BOOL(WINAPI *)(HWND hwnd)> g_SetTaskmanWindow(TEXT("user32"), "SetTaskmanWindow")
Definition: taskbar.cpp:35
#define SendMessage
Definition: winuser.h:5818
#define TBSTYLE_WRAPABLE
Definition: commctrl.h:986
#define WS_VISIBLE
Definition: pedump.c:620
#define TBSTYLE_LIST
Definition: commctrl.h:989

◆ Notify()

int TaskBar::Notify ( int  id,
NMHDR pnmh 
)
protectedvirtual

Reimplemented from Window.

Definition at line 243 of file taskbar.cpp.

244 {
245  if (pnmh->hwndFrom == _htoolbar)
246  switch(pnmh->code) {
247  case NM_RCLICK: {
248  TBBUTTONINFO btninfo;
252 
253  btninfo.cbSize = sizeof(TBBUTTONINFO);
254  btninfo.dwMask = TBIF_BYINDEX|TBIF_COMMAND;
255 
257 
258  if (idx>=0 &&
259  SendMessage(_htoolbar, TB_GETBUTTONINFO, idx, (LPARAM)&btninfo)!=-1 &&
260  (it=_map.find_id(btninfo.idCommand))!=_map.end()) {
261  //TaskBarEntry& entry = it->second;
262 
263  ActivateApp(it, false, false); // don't restore minimized windows on right button click
264 
265  static DynamicFct<DWORD(STDAPICALLTYPE*)(RESTRICTIONS)> pSHRestricted(TEXT("SHELL32"), "SHRestricted");
266 
267  if (pSHRestricted && !(*pSHRestricted)(REST_NOTRAYCONTEXTMENU))
268  ShowAppSystemMenu(it);
269  }
270  break;}
271 
272  default:
273  return super::Notify(id, pnmh);
274  }
275 
276  return 0;
277 }
#define TBIF_COMMAND
Definition: commctrl.h:1220
#define TB_HITTEST
Definition: commctrl.h:1264
#define TB_GETBUTTONINFO
Definition: commctrl.h:1258
#define pt(x, y)
Definition: drawing.c:79
#define TBIF_BYINDEX
Definition: commctrl.h:1222
iterator find_id(int id)
Definition: taskbar.cpp:561
TaskBarMap _map
Definition: taskbar.h:84
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
WindowHandle _htoolbar
Definition: taskbar.h:83
#define DWORD
Definition: nt_native.h:44
RESTRICTIONS
Definition: shlobj.h:1546
UINT code
Definition: winuser.h:3134
unsigned int idx
Definition: utils.c:41
LONG_PTR LPARAM
Definition: windef.h:208
virtual int Notify(int id, NMHDR *pnmh)
Definition: window.cpp:290
void ActivateApp(TaskBarMap::iterator it, bool can_minimize=true, bool can_restore=true)
Definition: taskbar.cpp:280
void ShowAppSystemMenu(TaskBarMap::iterator it)
Definition: taskbar.cpp:305
#define STDAPICALLTYPE
Definition: guid.c:3
HWND hwndFrom
Definition: winuser.h:3132
#define TEXT(s)
Definition: k32.h:26
#define NM_RCLICK
Definition: commctrl.h:133
#define SendMessage
Definition: winuser.h:5818
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
_Rep_type::iterator iterator
Definition: _map.h:85
#define TBBUTTONINFO
Definition: commctrl.h:1250
iterator end()
Definition: _map.h:165

◆ Refresh()

void TaskBar::Refresh ( )
protected

Definition at line 488 of file taskbar.cpp.

489 {
490  for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it)
491  it->second._used = 0;
492 
494  //EnumDesktopWindows(GetThreadDesktop(GetCurrentThreadId()), EnumWndProc, (LPARAM)_htoolbar);
495 
496  set<int> btn_idx_to_delete;
497  set<HBITMAP> hbmp_to_delete;
498 
499  for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it) {
500  TaskBarEntry& entry = it->second;
501 
502  if (!entry._used && entry._id) {
503  // store button indexes to remove
504  btn_idx_to_delete.insert(entry._btn_idx);
505  hbmp_to_delete.insert(entry._hbmp);
506  entry._id = 0;
507  }
508  }
509 
510  if (!btn_idx_to_delete.empty()) {
511  // remove buttons from right to left
512  for(set<int>::reverse_iterator it=btn_idx_to_delete.rbegin(); it!=btn_idx_to_delete.rend(); ++it) {
513  int idx = *it;
514 
516  MessageBoxW(NULL, L"failed to delete button", NULL, MB_OK);
517 
518 
519  for(TaskBarMap::iterator it2=_map.begin(); it2!=_map.end(); ++it2) {
520  TaskBarEntry& entry = it2->second;
521 
522  // adjust button indexes
523  if (entry._btn_idx > idx) {
524  --entry._btn_idx;
525 #if 0
526  --entry._bmp_idx;
527 
529 
530  info.cbSize = sizeof(TBBUTTONINFO);
531  info.dwMask = TBIF_IMAGE;
532  info.iImage = entry._bmp_idx;
533 
535  MessageBoxW(NULL, L"failed to set button info", NULL, MB_OK);
536 #endif
537  }
538  }
539 
540  }
541 
542  for(set<HBITMAP>::iterator it=hbmp_to_delete.begin(); it!=hbmp_to_delete.end(); ++it) {
543  HBITMAP hbmp = *it;
544 #if 0
545  TBREPLACEBITMAP tbrepl = {0, (UINT_PTR)hbmp, 0, 0};
547 #endif
549 
550  for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it)
551  if (it->second._hbmp == hbmp) {
552  _map.erase(it);
553  break;
554  }
555  }
556 
557  ResizeButtons();
558  }
559 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
TaskBarMap _map
Definition: taskbar.h:84
WindowHandle _htoolbar
Definition: taskbar.h:83
#define TB_SETBUTTONINFO
Definition: commctrl.h:1259
#define TBIF_IMAGE
Definition: commctrl.h:1215
struct _test_info info[]
Definition: SetCursorPos.c:19
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
void ResizeButtons()
Definition: taskbar.cpp:570
pair< iterator, bool > insert(const value_type &__x)
Definition: _set.h:168
HBITMAP hbmp
void erase(iterator __pos)
Definition: _map.h:203
reverse_iterator rend()
Definition: _set.h:156
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
_Rep_type::iterator iterator
Definition: _set.h:73
bool empty() const
Definition: _set.h:159
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
internal task bar button management entry
Definition: taskbar.h:50
static const WCHAR L[]
Definition: oid.c:1250
_Rep_type::reverse_iterator reverse_iterator
Definition: _set.h:75
uint32_t entry
Definition: isohybrid.c:63
iterator begin()
Definition: _set.h:151
static BOOL CALLBACK EnumWndProc(HWND hwnd, LPARAM lparam)
Definition: taskbar.cpp:374
#define TB_REPLACEBITMAP
Definition: commctrl.h:1144
reverse_iterator rbegin()
Definition: _set.h:155
#define MB_OK
Definition: winuser.h:784
#define SendMessage
Definition: winuser.h:5818
iterator end()
Definition: _set.h:152
static HBITMAP
Definition: button.c:44
iterator begin()
Definition: _map.h:163
Definition: _set.h:46
_Rep_type::iterator iterator
Definition: _map.h:85
#define TBBUTTONINFO
Definition: commctrl.h:1250
#define TB_DELETEBUTTON
Definition: commctrl.h:1104
iterator end()
Definition: _map.h:165

Referenced by ActivateApp(), Init(), and WndProc().

◆ ResizeButtons()

void TaskBar::ResizeButtons ( )
protected

Definition at line 570 of file taskbar.cpp.

571 {
572  int btns = _map.size();
573 
574  if (btns > 0) {
575  int bar_width = ClientRect(_hwnd).right;
576  int btn_width = (bar_width / btns) - 3;
577 
578  if (btn_width < TASKBUTTONWIDTH_MIN)
579  btn_width = TASKBUTTONWIDTH_MIN;
580  else if (btn_width > TASKBUTTONWIDTH_MAX)
581  btn_width = TASKBUTTONWIDTH_MAX;
582 
583  if (btn_width != _last_btn_width) {
584  _last_btn_width = btn_width;
585 
586  SendMessage(_htoolbar, TB_SETBUTTONWIDTH, 0, MAKELONG(btn_width,btn_width));
588  }
589  }
590 }
TaskBarMap _map
Definition: taskbar.h:84
WindowHandle _htoolbar
Definition: taskbar.h:83
size_type size() const
Definition: _map.h:172
#define TB_AUTOSIZE
Definition: commctrl.h:1133
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define TASKBUTTONWIDTH_MAX
Definition: taskbar.h:40
int _last_btn_width
Definition: taskbar.h:87
#define TB_SETBUTTONWIDTH
Definition: commctrl.h:1157
#define TASKBUTTONWIDTH_MIN
Definition: taskbar.h:39
#define SendMessage
Definition: winuser.h:5818

Referenced by EnumWndProc(), Refresh(), and WndProc().

◆ ShowAppSystemMenu()

void TaskBar::ShowAppSystemMenu ( TaskBarMap::iterator  it)
protected

Definition at line 305 of file taskbar.cpp.

306 {
307  HMENU hmenu = GetSystemMenu(it->first, FALSE);
308 
309  if (hmenu) {
310  POINT pt;
311 
312  GetCursorPos(&pt);
314 
315  if (cmd) {
316  ActivateApp(it, false, false); // reactivate window after the context menu has closed
317  PostMessage(it->first, WM_SYSCOMMAND, cmd, 0);
318  }
319  }
320 }
static HMENU hmenu
Definition: win.c:66
Definition: ftp_var.h:139
#define pt(x, y)
Definition: drawing.c:79
#define TPM_RETURNCMD
Definition: winuser.h:2362
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define TPM_RIGHTBUTTON
Definition: winuser.h:2355
#define FALSE
Definition: types.h:117
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
#define PostMessage
Definition: winuser.h:5807
void ActivateApp(TaskBarMap::iterator it, bool can_minimize=true, bool can_restore=true)
Definition: taskbar.cpp:280
#define TPM_LEFTBUTTON
Definition: winuser.h:2354
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WM_SYSCOMMAND
Definition: winuser.h:1723
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)

Referenced by Notify().

◆ WndProc()

LRESULT TaskBar::WndProc ( UINT  nmsg,
WPARAM  wparam,
LPARAM  lparam 
)
protectedvirtual

Reimplemented from Window.

Definition at line 179 of file taskbar.cpp.

180 {
181  switch(nmsg) {
182  case WM_SIZE:
183  SendMessage(_htoolbar, WM_SIZE, 0, 0);
184  ResizeButtons();
185  break;
186 
187  case WM_TIMER:
188  Refresh();
189  return 0;
190 
191  case WM_CONTEXTMENU: {
192  Point pt(lparam);
194 
196  break; // avoid displaying context menu for application button _and_ desktop bar at the same time
197 
198  goto def;}
199 
200  case PM_GET_LAST_ACTIVE:
202 
203  case WM_SYSCOLORCHANGE:
205  break;
206 
207  default: def:
208  if (nmsg == WM_SHELLHOOK) {
209  switch(wparam) {
212  case HSHELL_WINDOWACTIVATED:
213  case HSHELL_REDRAW:
214 #ifdef HSHELL_FLASH
215  case HSHELL_FLASH:
216 #endif
217 #ifdef HSHELL_RUDEAPPACTIVATED
219 #endif
220  Refresh();
221  break;
222  }
223  } else {
224  return super::WndProc(nmsg, wparam, lparam);
225  }
226  }
227 
228  return 0;
229 }
#define TB_HITTEST
Definition: commctrl.h:1264
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1608
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define pt(x, y)
Definition: drawing.c:79
#define HSHELL_FLASH
Definition: winuser.h:1262
#define HSHELL_WINDOWCREATED
Definition: winuser.h:1240
HANDLE HWND
Definition: compat.h:19
const UINT WM_SHELLHOOK
Definition: taskbar.h:90
WindowHandle _htoolbar
Definition: taskbar.h:83
void Refresh()
Definition: taskbar.cpp:488
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
LONG_PTR LPARAM
Definition: windef.h:208
void ResizeButtons()
Definition: taskbar.cpp:570
#define WM_SIZE
Definition: winuser.h:1593
#define WM_TIMER
Definition: winuser.h:1724
virtual LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
Definition: window.cpp:280
#define PM_GET_LAST_ACTIVE
Definition: taskbar.h:46
#define HSHELL_WINDOWDESTROYED
Definition: winuser.h:1241
WindowHandle _last_foreground_wnd
Definition: taskbar.h:86
#define HSHELL_RUDEAPPACTIVATED
Definition: winuser.h:1263
#define SendMessage
Definition: winuser.h:5818
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
LONG_PTR LRESULT
Definition: windef.h:209
static UINT WPARAM wparam
Definition: combo.c:716

Member Data Documentation

◆ _htoolbar

WindowHandle TaskBar::_htoolbar
protected

Definition at line 83 of file taskbar.h.

Referenced by EnumWndProc(), Init(), Notify(), Refresh(), ResizeButtons(), and WndProc().

◆ _last_btn_width

int TaskBar::_last_btn_width
protected

Definition at line 87 of file taskbar.h.

Referenced by ResizeButtons(), and TaskBar().

◆ _last_foreground_wnd

WindowHandle TaskBar::_last_foreground_wnd
protected

Definition at line 86 of file taskbar.h.

Referenced by ActivateApp(), EnumWndProc(), and WndProc().

◆ _map

TaskBarMap TaskBar::_map
protected

Definition at line 84 of file taskbar.h.

Referenced by Command(), EnumWndProc(), Notify(), Refresh(), and ResizeButtons().

◆ _mmMetrics_org

MINIMIZEDMETRICS TaskBar::_mmMetrics_org
protected

Definition at line 88 of file taskbar.h.

Referenced by TaskBar(), and ~TaskBar().

◆ _next_id

int TaskBar::_next_id
protected

Definition at line 85 of file taskbar.h.

Referenced by EnumWndProc(), and Init().

◆ WM_SHELLHOOK

const UINT TaskBar::WM_SHELLHOOK
protected

Definition at line 90 of file taskbar.h.

Referenced by WndProc().


The documentation for this struct was generated from the following files: