ReactOS  0.4.15-dev-3456-g4a17d4b
traywnd.cpp
Go to the documentation of this file.
1 /*
2  * ReactOS Explorer
3  *
4  * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
5  * Copyright 2018 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6  *
7  * this library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * this library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "precomp.h"
23 #include <commoncontrols.h>
24 
25 HRESULT TrayWindowCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu);
27 void appbar_notify_all(HMONITOR hMon, UINT uMsg, HWND hwndExclude, LPARAM lParam);
28 
29 #define WM_APP_TRAYDESTROY (WM_APP + 0x100)
30 
31 #define TIMER_ID_AUTOHIDE 1
32 #define TIMER_ID_MOUSETRACK 2
33 #define MOUSETRACK_INTERVAL 100
34 #define AUTOHIDE_DELAY_HIDE 2000
35 #define AUTOHIDE_DELAY_SHOW 50
36 #define AUTOHIDE_INTERVAL_ANIMATING 10
37 
38 #define AUTOHIDE_SPEED_SHOW 10
39 #define AUTOHIDE_SPEED_HIDE 1
40 
41 #define AUTOHIDE_HIDDEN 0
42 #define AUTOHIDE_SHOWING 1
43 #define AUTOHIDE_SHOWN 2
44 #define AUTOHIDE_HIDING 3
45 
46 #define IDHK_RUN 0x1f4
47 #define IDHK_MINIMIZE_ALL 0x1f5
48 #define IDHK_RESTORE_ALL 0x1f6
49 #define IDHK_HELP 0x1f7
50 #define IDHK_EXPLORE 0x1f8
51 #define IDHK_FIND 0x1f9
52 #define IDHK_FIND_COMPUTER 0x1fa
53 #define IDHK_NEXT_TASK 0x1fb
54 #define IDHK_PREV_TASK 0x1fc
55 #define IDHK_SYS_PROPERTIES 0x1fd
56 #define IDHK_DESKTOP 0x1fe
57 #define IDHK_PAGER 0x1ff
58 
59 static const WCHAR szTrayWndClass[] = L"Shell_TrayWnd";
60 
62 {
68 };
69 
70 static BOOL CALLBACK
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 }
109 
110 static BOOL
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));
125  GetWindowTextW(ei.hwndFound, szText, _countof(szText));
126  MessageBoxW(NULL, szText, szClass, 0);
127  }
128  return ei.hwndFound != NULL;
129 }
130 
132 
133 /*
134  * ITrayWindow
135  */
136 
137 const GUID IID_IShellDesktopTray = { 0x213e2df9, 0x9a14, 0x4328, { 0x99, 0xb1, 0x69, 0x61, 0xf9, 0x14, 0x3c, 0xe9 } };
138 
140  : public CWindowImpl<CStartButton>
141 {
145 
146 public:
148  : m_ImageList(NULL),
149  m_Font(NULL)
150  {
151  m_Size.cx = 0;
152  m_Size.cy = 0;
153  }
154 
155  virtual ~CStartButton()
156  {
157  if (m_ImageList != NULL)
159 
160  if (m_Font != NULL)
162  }
163 
165  {
166  return m_Size;
167  }
168 
170  {
171  SIZE Size = { 0, 0 };
172 
173  if (m_ImageList == NULL ||
175  {
177  }
178 
180 
181  /* Save the size of the start button */
182  m_Size = Size;
183  }
184 
186  {
187  /* Get the system fonts, we use the caption font, always bold, though. */
188  NONCLIENTMETRICS ncm = {sizeof(ncm)};
189  if (!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, FALSE))
190  return;
191 
192  if (m_Font)
194 
195  ncm.lfCaptionFont.lfWeight = FW_BOLD;
196  m_Font = CreateFontIndirect(&ncm.lfCaptionFont);
197 
198  SetFont(m_Font, FALSE);
199  }
200 
202  {
203  // HACK & FIXME: CORE-17505
205 
206  SetWindowTheme(m_hWnd, L"Start", NULL);
207 
210  0, 0, 0,
211  IMAGE_BITMAP,
213 
216  UpdateSize();
217  }
218 
219  // Hack:
220  // Use DECLARE_WND_SUPERCLASS instead!
222  {
223  WCHAR szStartCaption[32];
225  IDS_START,
226  szStartCaption,
227  _countof(szStartCaption)))
228  {
229  wcscpy(szStartCaption, L"Start");
230  }
231 
233 
235  0,
236  WC_BUTTON,
237  szStartCaption,
238  dwStyle,
239  0, 0, 0, 0,
240  hwndParent,
243  NULL);
244 
245  if (m_hWnd)
246  Initialize();
247 
248  return m_hWnd;
249  }
250 
252  {
253  if (uMsg == WM_KEYUP && wParam != VK_SPACE)
254  return 0;
255 
257  return 0;
258  }
259 
262  END_MSG_MAP()
263 
264 };
265 
266 class CTrayWindow :
267  public CComCoClass<CTrayWindow>,
268  public CComObjectRootEx<CComMultiThreadModelNoCS>,
269  public CWindowImpl < CTrayWindow, CWindow, CControlWinTraits >,
270  public ITrayWindow,
271  public IShellDesktopTray,
272  public IOleWindow,
273  public IContextMenu
274 {
276 
279 
283 
285 
290 
292 
298 
301 
304 
308 
310 
311 public:
313 
314  union
315  {
317  struct
318  {
319  /* UI Status */
323  };
324  };
325 
326 public:
328  m_StartButton(),
329  m_Theme(NULL),
330  m_Font(NULL),
332  m_Rebar(NULL),
335  m_Position(0),
336  m_Monitor(NULL),
344  Flags(0)
345  {
347  ZeroMemory(&m_TraySize, sizeof(m_TraySize));
350  }
351 
352  virtual ~CTrayWindow()
353  {
354  if (m_ShellServices != NULL)
355  {
358  }
359 
360  if (m_Font != NULL)
361  {
363  m_Font = NULL;
364  }
365 
366  if (m_Theme)
367  {
369  m_Theme = NULL;
370  }
371 
372  PostQuitMessage(0);
373  }
374 
375 
376 
377 
378 
379  /**********************************************************
380  * ##### command handling #####
381  */
382 
384  {
385  WCHAR szCommand[256];
386  WCHAR *pszParameters;
387 
389  id,
390  szCommand,
391  _countof(szCommand)))
392  {
393  return E_FAIL;
394  }
395 
396  pszParameters = wcschr(szCommand, L'>');
397  if (pszParameters)
398  {
399  *pszParameters = 0;
400  pszParameters++;
401  }
402 
403  ShellExecuteW(m_hWnd, NULL, szCommand, pszParameters, NULL, SW_SHOWNORMAL);
404  return S_OK;
405  }
406 
408  {
409  /* Display the ReactOS Shutdown Dialog */
411 
412  /*
413  * If the user presses CTRL+ALT+SHIFT while exiting
414  * the shutdown dialog, exit the shell cleanly.
415  */
416  if ((GetKeyState(VK_CONTROL) & 0x8000) &&
417  (GetKeyState(VK_SHIFT) & 0x8000) &&
418  (GetKeyState(VK_MENU) & 0x8000))
419  {
420  PostMessage(WM_QUIT, 0, 0);
421  }
422  return 0;
423  }
424 
426  {
427  HWND hwnd;
428  RECT posRect;
429 
430  m_StartButton.GetWindowRect(&posRect);
431 
432  hwnd = CreateWindowEx(0,
433  WC_STATIC,
434  NULL,
436  posRect.left,
437  posRect.top,
438  posRect.right - posRect.left,
439  posRect.bottom - posRect.top,
440  NULL,
441  NULL,
442  NULL,
443  NULL);
444 
446 
447  // build the default directory from two environment variables
448  CStringW strDefaultDir, strHomePath;
449  strDefaultDir.GetEnvironmentVariable(L"HOMEDRIVE");
450  strHomePath.GetEnvironmentVariable(L"HOMEPATH");
451  strDefaultDir += strHomePath;
452 
453  RunFileDlg(hwnd, NULL, (LPCWSTR)strDefaultDir, NULL, NULL, RFF_CALCDIRECTORY);
454 
457 
458  return 0;
459  }
460 
462  {
463  CTrayWindow * This = (CTrayWindow*) pParam;
464  return This->RunFileDlgThread();
465  }
466 
468  {
469  HWND hRunDlg;
470  if (m_RunFileDlgOwner)
471  {
473  if (hRunDlg != NULL &&
474  hRunDlg != m_RunFileDlgOwner)
475  {
476  SetForegroundWindow(hRunDlg);
477  return;
478  }
479  }
480 
482  }
483 
485  {
486  HWND hwnd;
487  RECT posRect;
488 
489  m_StartButton.GetWindowRect(&posRect);
490  hwnd = CreateWindowEx(0,
491  WC_STATIC,
492  NULL,
494  posRect.left,
495  posRect.top,
496  posRect.right - posRect.left,
497  posRect.bottom - posRect.top,
498  NULL,
499  NULL,
500  NULL,
501  NULL);
502 
504 
506 
509 
510  return 0;
511  }
512 
514  {
515  CTrayWindow *This = (CTrayWindow*) pParam;
516 
517  return This->TrayPropertiesThread();
518  }
519 
521  {
522  HWND hTrayProp;
523 
525  {
527  if (hTrayProp != NULL &&
528  hTrayProp != m_TrayPropertiesOwner)
529  {
530  SetForegroundWindow(hTrayProp);
531  return NULL;
532  }
533  }
534 
536  return NULL;
537  }
538 
540  {
541  WCHAR szDir[MAX_PATH];
542 
543  if (SHGetSpecialFolderPath(hWndOwner,
544  szDir,
546  FALSE))
547  {
548  ShellExecute(hWndOwner,
549  lpOperation,
550  szDir,
551  NULL,
552  NULL,
553  SW_SHOWNORMAL);
554  }
555  }
556 
558  {
559  ShellExecute(hWndOwner,
560  TEXT("open"),
561  TEXT("taskmgr.exe"),
562  NULL,
563  NULL,
564  SW_SHOWNORMAL);
565  }
566 
568  {
570  {
571  ShowDesktop();
572  }
573  else
574  {
575  RestoreAll();
576  }
577  }
578 
580  {
581  switch (uiCmd)
582  {
585  break;
586 
589  TEXT("open"));
590  break;
591 
594  TEXT("explore"));
595  break;
596 
597  case ID_LOCKTASKBAR:
599  {
601  }
602  break;
603 
606  break;
607 
609  break;
610 
612  ShowDesktop();
613  break;
614 
619  break;
620 
625  break;
626 
631  break;
632 
635  break;
636 
638  //FIXME: Use SHRunControlPanel
639  ShellExecuteW(m_hWnd, NULL, L"timedate.cpl", NULL, NULL, SW_NORMAL);
640  break;
641 
643  RestoreAll();
644  break;
645 
646  default:
647  TRACE("ITrayWindow::ExecContextMenuCmd(%u): Unhandled Command ID!\n", uiCmd);
648  return FALSE;
649  }
650 
651  return TRUE;
652  }
653 
655  {
656  switch (id)
657  {
658  case IDHK_RUN:
660  break;
661  case IDHK_HELP:
663  break;
664  case IDHK_EXPLORE:
665  //FIXME: We don't support this yet:
666  //ShellExecuteW(0, L"explore", NULL, NULL, NULL, 1);
667  ShellExecuteW(0, NULL, L"explorer.exe", L"/e ,", NULL, 1);
668  break;
669  case IDHK_FIND:
671  break;
672  case IDHK_FIND_COMPUTER:
674  break;
675  case IDHK_SYS_PROPERTIES:
676  //FIXME: Use SHRunControlPanel
677  ShellExecuteW(m_hWnd, NULL, L"sysdm.cpl", NULL, NULL, SW_NORMAL);
678  break;
679  case IDHK_NEXT_TASK:
680  break;
681  case IDHK_PREV_TASK:
682  break;
683  case IDHK_MINIMIZE_ALL:
684  MinimizeAll();
685  break;
686  case IDHK_RESTORE_ALL:
687  RestoreAll();
688  break;
689  case IDHK_DESKTOP:
690  ToggleDesktop();
691  break;
692  case IDHK_PAGER:
693  break;
694  }
695 
696  return 0;
697  }
698 
700  {
701  switch (uCommand)
702  {
703  case TRAYCMD_STARTMENU:
704  // TODO:
705  break;
706  case TRAYCMD_RUN_DIALOG:
708  break;
710  LogoffWindowsDialog(m_hWnd); // FIXME: Maybe handle it in a similar way as DoExitWindows?
711  break;
712  case TRAYCMD_CASCADE:
714  break;
715  case TRAYCMD_TILE_H:
717  break;
718  case TRAYCMD_TILE_V:
720  break;
722  ToggleDesktop();
723  break;
725  ShellExecuteW(m_hWnd, NULL, L"timedate.cpl", NULL, NULL, SW_NORMAL);
726  break;
729  break;
731  MinimizeAll();
732  break;
733  case TRAYCMD_RESTORE_ALL:
734  RestoreAll();
735  break;
737  ShowDesktop();
738  break;
741  break;
743  break;
746  {
748  }
749  break;
752  break;
754  // TODO:
755  break;
757  DoExitWindows();
758  break;
760  // TODO:
761  break;
763  // TODO:
764  break;
766  // TODO:
767  break;
768  case IDM_SEARCH:
771  break;
774  break;
775 
776  default:
777  break;
778  }
779 
780  return FALSE;
781  }
782 
783 
785  IN HMENU hMenu,
786  IN POINT *ppt OPTIONAL,
787  IN HWND hwndExclude OPTIONAL,
788  IN BOOL TrackUp,
789  IN BOOL IsContextMenu)
790  {
791  TPMPARAMS tmp, *ptmp = NULL;
792  POINT pt;
793  UINT cmdId;
794  UINT fuFlags;
795 
796  if (hwndExclude != NULL)
797  {
798  /* Get the client rectangle and map it to screen coordinates */
799  if (::GetClientRect(hwndExclude,
800  &tmp.rcExclude) &&
801  ::MapWindowPoints(hwndExclude,
802  NULL,
803  (LPPOINT) &tmp.rcExclude,
804  2) != 0)
805  {
806  ptmp = &tmp;
807  }
808  }
809 
810  if (ppt == NULL)
811  {
812  if (ptmp == NULL &&
813  GetClientRect(&tmp.rcExclude) &&
815  NULL,
816  (LPPOINT) &tmp.rcExclude,
817  2) != 0)
818  {
819  ptmp = &tmp;
820  }
821 
822  if (ptmp != NULL)
823  {
824  /* NOTE: TrackPopupMenuEx will eventually align the track position
825  for us, no need to take care of it here as long as the
826  coordinates are somewhere within the exclusion rectangle */
827  pt.x = ptmp->rcExclude.left;
828  pt.y = ptmp->rcExclude.top;
829  }
830  else
831  pt.x = pt.y = 0;
832  }
833  else
834  pt = *ppt;
835 
836  tmp.cbSize = sizeof(tmp);
837 
838  fuFlags = TPM_RETURNCMD | TPM_VERTICAL;
839  fuFlags |= (TrackUp ? TPM_BOTTOMALIGN : TPM_TOPALIGN);
840  if (IsContextMenu)
841  fuFlags |= TPM_RIGHTBUTTON;
842  else
843  fuFlags |= (TrackUp ? TPM_VERNEGANIMATION : TPM_VERPOSANIMATION);
844 
845  cmdId = TrackPopupMenuEx(hMenu,
846  fuFlags,
847  pt.x,
848  pt.y,
849  m_hWnd,
850  ptmp);
851 
852  return cmdId;
853  }
854 
856  IN IContextMenu * contextMenu,
857  IN POINT *ppt OPTIONAL,
858  IN HWND hwndExclude OPTIONAL,
859  IN BOOL TrackUp,
861  {
862  POINT pt;
864  RECT rc;
865  HRESULT hr;
866  UINT uCommand;
867  HMENU popup = CreatePopupMenu();
868 
869  if (popup == NULL)
870  return E_FAIL;
871 
872  if (ppt)
873  {
874  pt = *ppt;
875  }
876  else
877  {
878  ::GetWindowRect(m_hWnd, &rc);
879  pt.x = rc.left;
880  pt.y = rc.top;
881  }
882 
883  TRACE("Before Query\n");
884  hr = contextMenu->QueryContextMenu(popup, 0, 0, UINT_MAX, CMF_NORMAL);
885  if (FAILED_UNEXPECTEDLY(hr))
886  {
887  TRACE("Query failed\n");
888  DestroyMenu(popup);
889  return hr;
890  }
891 
892  TRACE("Before Tracking\n");
894  if (hwndExclude)
895  {
896  ::GetWindowRect(hwndExclude, &rc);
897  ZeroMemory(&params, sizeof(params));
898  params.cbSize = sizeof(params);
899  params.rcExclude = rc;
900  uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, pt.x, pt.y, m_hWnd, &params);
901  }
902  else
903  {
904  uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, pt.x, pt.y, m_hWnd, NULL);
905  }
906  ::PostMessage(m_hWnd, WM_NULL, 0, 0);
907 
908  if (uCommand != 0)
909  {
910  TRACE("Before InvokeCommand\n");
911  CMINVOKECOMMANDINFO cmi = { 0 };
912  cmi.cbSize = sizeof(cmi);
913  cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
914  cmi.hwnd = m_hWnd;
915  hr = contextMenu->InvokeCommand(&cmi);
916  }
917  else
918  {
919  TRACE("TrackPopupMenu failed. Code=%d, LastError=%d\n", uCommand, GetLastError());
920  hr = S_FALSE;
921  }
922 
923  DestroyMenu(popup);
924  return hr;
925  }
926 
927 
928 
929 
930 
931  /**********************************************************
932  * ##### moving and sizing handling #####
933  */
934 
935  void UpdateFonts()
936  {
937  /* There is nothing to do if themes are enabled */
938  if (m_Theme)
939  return;
940 
942 
943  NONCLIENTMETRICS ncm = {sizeof(ncm)};
944  if (!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, FALSE))
945  {
946  ERR("SPI_GETNONCLIENTMETRICS failed\n");
947  return;
948  }
949 
950  if (m_Font != NULL)
952 
953  ncm.lfCaptionFont.lfWeight = FW_NORMAL;
954  m_Font = CreateFontIndirect(&ncm.lfCaptionFont);
955  if (!m_Font)
956  {
957  ERR("CreateFontIndirect failed\n");
958  return;
959  }
960 
964  }
965 
967  IN OUT RECT *pRect,
968  IN DWORD dwFlags)
969  {
970  MONITORINFO mi;
971  HMONITOR hMon;
972 
973  mi.cbSize = sizeof(mi);
974  hMon = MonitorFromRect(pRect, dwFlags);
975  if (hMon != NULL &&
976  GetMonitorInfo(hMon, &mi))
977  {
978  *pRect = mi.rcMonitor;
979  }
980  else
981  {
982  pRect->left = 0;
983  pRect->top = 0;
984  pRect->right = GetSystemMetrics(SM_CXSCREEN);
985  pRect->bottom = GetSystemMetrics(SM_CYSCREEN);
986 
987  hMon = NULL;
988  }
989 
990  return hMon;
991  }
992 
994  IN const RECT *pRect)
995  {
996  HMONITOR hMon;
997 
998  /* In case the monitor sizes or saved sizes differ a bit (probably
999  not a lot, only so the tray window overlaps into another monitor
1000  now), minimize the risk that we determine a wrong monitor by
1001  using the center point of the tray window if we can't determine
1002  it using the rectangle. */
1003  hMon = MonitorFromRect(pRect, MONITOR_DEFAULTTONULL);
1004  if (hMon == NULL)
1005  {
1006  POINT pt;
1007 
1008  pt.x = pRect->left + ((pRect->right - pRect->left) / 2);
1009  pt.y = pRect->top + ((pRect->bottom - pRect->top) / 2);
1010 
1011  /* be less error-prone, find the nearest monitor */
1012  hMon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
1013  }
1014 
1015  return hMon;
1016  }
1017 
1019  IN HMONITOR hMonitor,
1020  IN OUT RECT *pRect)
1021  {
1022  HMONITOR hMon = NULL;
1023 
1024  if (hMonitor != NULL)
1025  {
1026  MONITORINFO mi;
1027 
1028  mi.cbSize = sizeof(mi);
1029  if (!GetMonitorInfo(hMonitor, &mi))
1030  {
1031  /* Hm, the monitor is gone? Try to find a monitor where it
1032  could be located now */
1033  hMon = GetMonitorFromRect(pRect);
1034  if (hMon == NULL ||
1035  !GetMonitorInfo(hMon, &mi))
1036  {
1037  hMon = NULL;
1038  goto GetPrimaryRect;
1039  }
1040  }
1041 
1042  *pRect = mi.rcMonitor;
1043  }
1044  else
1045  {
1046 GetPrimaryRect:
1047  pRect->left = 0;
1048  pRect->top = 0;
1049  pRect->right = GetSystemMetrics(SM_CXSCREEN);
1050  pRect->bottom = GetSystemMetrics(SM_CYSCREEN);
1051  }
1052 
1053  return hMon;
1054  }
1055 
1057  {
1059  SIZE size;
1060 
1061  if (pos > ABE_BOTTOM)
1062  pos = ABE_BOTTOM;
1063 
1064  HRESULT hr = GetThemePartSize(m_Theme, NULL, iSizerPart[pos], 0, NULL, TS_TRUE, &size);
1065  if (FAILED_UNEXPECTEDLY(hr))
1066  return;
1067 
1068  switch (pos)
1069  {
1070  case ABE_TOP:
1071  rc->bottom -= size.cy;
1072  break;
1073  case ABE_BOTTOM:
1074  rc->top += size.cy;
1075  break;
1076  case ABE_LEFT:
1077  rc->right -= size.cx;
1078  break;
1079  case ABE_RIGHT:
1080  rc->left += size.cx;
1081  break;
1082  }
1083  }
1084 
1086  IN const SIZE *pTraySize,
1087  IN OUT RECT *pRect)
1088  {
1089  switch (Position)
1090  {
1091  case ABE_LEFT:
1092  pRect->right = pRect->left + pTraySize->cx;
1093  break;
1094 
1095  case ABE_TOP:
1096  pRect->bottom = pRect->top + pTraySize->cy;
1097  break;
1098 
1099  case ABE_RIGHT:
1100  pRect->left = pRect->right - pTraySize->cx;
1101  break;
1102 
1103  case ABE_BOTTOM:
1104  default:
1105  pRect->top = pRect->bottom - pTraySize->cy;
1106  break;
1107  }
1108  }
1109 
1111  IN const RECT *pScreen,
1112  IN const SIZE *pTraySize OPTIONAL,
1113  OUT RECT *pRect)
1114  {
1115  if (pTraySize == NULL)
1116  pTraySize = &m_TraySize;
1117 
1118  *pRect = *pScreen;
1119 
1120  if(!m_Theme)
1121  {
1122  /* Move the border outside of the screen */
1123  InflateRect(pRect,
1126  }
1127 
1128  MakeTrayRectWithSize(Position, pTraySize, pRect);
1129  }
1130 
1132  {
1133  return m_Position == ABE_TOP || m_Position == ABE_BOTTOM;
1134  }
1135 
1137  IN DWORD Position,
1138  IN OUT RECT *pRect)
1139  {
1140  RECT rcScreen;
1141  //BOOL Horizontal;
1142  HMONITOR hMon;
1143  SIZE szMax, szWnd;
1144 
1145  //Horizontal = IsPosHorizontal();
1146 
1147  szWnd.cx = pRect->right - pRect->left;
1148  szWnd.cy = pRect->bottom - pRect->top;
1149 
1150  rcScreen = *pRect;
1151  hMon = GetScreenRectFromRect(
1152  &rcScreen,
1153  MONITOR_DEFAULTTONEAREST);
1154 
1155  /* Calculate the maximum size of the tray window and limit the window
1156  size to half of the screen's size. */
1157  szMax.cx = (rcScreen.right - rcScreen.left) / 2;
1158  szMax.cy = (rcScreen.bottom - rcScreen.top) / 2;
1159  if (szWnd.cx > szMax.cx)
1160  szWnd.cx = szMax.cx;
1161  if (szWnd.cy > szMax.cy)
1162  szWnd.cy = szMax.cy;
1163 
1164  /* FIXME - calculate */
1165 
1167  &rcScreen,
1168  &szWnd,
1169  pRect);
1170 
1171  return hMon;
1172  }
1173 
1174 #if 0
1175  VOID
1176  GetMinimumWindowSize(
1177  OUT RECT *pRect)
1178  {
1179  RECT rcMin = {0};
1180 
1181  AdjustWindowRectEx(&rcMin,
1183  GWL_STYLE),
1184  FALSE,
1186  GWL_EXSTYLE));
1187 
1188  *pRect = rcMin;
1189  }
1190 #endif
1191 
1192 
1194  IN POINT pt,
1195  OUT RECT *pRect,
1196  OUT HMONITOR *phMonitor)
1197  {
1198  HMONITOR hMon, hMonNew;
1199  DWORD PosH, PosV, Pos;
1200  SIZE DeltaPt, ScreenOffset;
1201  RECT rcScreen;
1202 
1203  rcScreen.left = 0;
1204  rcScreen.top = 0;
1205 
1206  /* Determine the screen rectangle */
1207  hMon = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL);
1208  if (hMon != NULL)
1209  {
1210  MONITORINFO mi;
1211 
1212  mi.cbSize = sizeof(mi);
1213  if (!GetMonitorInfo(hMon, &mi))
1214  {
1215  hMon = NULL;
1216  goto GetPrimaryScreenRect;
1217  }
1218 
1219  /* make left top corner of the screen zero based to
1220  make calculations easier */
1221  pt.x -= mi.rcMonitor.left;
1222  pt.y -= mi.rcMonitor.top;
1223 
1224  ScreenOffset.cx = mi.rcMonitor.left;
1225  ScreenOffset.cy = mi.rcMonitor.top;
1226  rcScreen.right = mi.rcMonitor.right - mi.rcMonitor.left;
1227  rcScreen.bottom = mi.rcMonitor.bottom - mi.rcMonitor.top;
1228  }
1229  else
1230  {
1231 GetPrimaryScreenRect:
1232  ScreenOffset.cx = 0;
1233  ScreenOffset.cy = 0;
1234  rcScreen.right = GetSystemMetrics(SM_CXSCREEN);
1235  rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN);
1236  }
1237 
1238  /* Calculate the nearest screen border */
1239  if (pt.x < rcScreen.right / 2)
1240  {
1241  DeltaPt.cx = pt.x;
1242  PosH = ABE_LEFT;
1243  }
1244  else
1245  {
1246  DeltaPt.cx = rcScreen.right - pt.x;
1247  PosH = ABE_RIGHT;
1248  }
1249 
1250  if (pt.y < rcScreen.bottom / 2)
1251  {
1252  DeltaPt.cy = pt.y;
1253  PosV = ABE_TOP;
1254  }
1255  else
1256  {
1257  DeltaPt.cy = rcScreen.bottom - pt.y;
1258  PosV = ABE_BOTTOM;
1259  }
1260 
1261  Pos = (DeltaPt.cx * rcScreen.bottom < DeltaPt.cy * rcScreen.right) ? PosH : PosV;
1262 
1263  /* Fix the screen origin to be relative to the primary monitor again */
1264  OffsetRect(&rcScreen,
1265  ScreenOffset.cx,
1266  ScreenOffset.cy);
1267 
1268  RECT rcPos = m_TrayRects[Pos];
1269 
1270  hMonNew = GetMonitorFromRect(&rcPos);
1271  if (hMon != hMonNew)
1272  {
1273  SIZE szTray;
1274 
1275  /* Recalculate the rectangle, we're dragging to another monitor.
1276  We don't need to recalculate the rect on single monitor systems. */
1277  szTray.cx = rcPos.right - rcPos.left;
1278  szTray.cy = rcPos.bottom - rcPos.top;
1279 
1280  GetTrayRectFromScreenRect(Pos, &rcScreen, &szTray, pRect);
1281  hMon = hMonNew;
1282  }
1283  else
1284  {
1285  /* The user is dragging the tray window on the same monitor. We don't need
1286  to recalculate the rectangle */
1287  *pRect = rcPos;
1288  }
1289 
1290  *phMonitor = hMon;
1291 
1292  return Pos;
1293  }
1294 
1296  IN OUT RECT *pRect,
1297  OUT HMONITOR *phMonitor)
1298  {
1299  POINT pt;
1300 
1301  /* Calculate the center of the rectangle. We call
1302  GetDraggingRectFromPt to calculate a valid
1303  dragging rectangle */
1304  pt.x = pRect->left + ((pRect->right - pRect->left) / 2);
1305  pt.y = pRect->top + ((pRect->bottom - pRect->top) / 2);
1306 
1307  return GetDraggingRectFromPt(
1308  pt,
1309  pRect,
1310  phMonitor);
1311  }
1312 
1314  {
1315  RECT rcTray;
1316 
1317  if (IsDragging)
1318  {
1319  rcTray.left = pwp->x;
1320  rcTray.top = pwp->y;
1321  rcTray.right = rcTray.left + pwp->cx;
1322  rcTray.bottom = rcTray.top + pwp->cy;
1323 
1324  if (!EqualRect(&rcTray,
1326  {
1327  /* Recalculate the rectangle, the user dragged the tray
1328  window to another monitor or the window was somehow else
1329  moved or resized */
1331  &rcTray,
1333  //m_TrayRects[DraggingPosition] = rcTray;
1334  }
1335 
1336  //Monitor = CalculateValidSize(DraggingPosition,
1337  // &rcTray);
1338 
1341  IsDragging = FALSE;
1342 
1343  m_TrayRects[m_Position] = rcTray;
1344  goto ChangePos;
1345  }
1346  else if (GetWindowRect(&rcTray))
1347  {
1348  if (InSizeMove)
1349  {
1350  if (!(pwp->flags & SWP_NOMOVE))
1351  {
1352  rcTray.left = pwp->x;
1353  rcTray.top = pwp->y;
1354  }
1355 
1356  if (!(pwp->flags & SWP_NOSIZE))
1357  {
1358  rcTray.right = rcTray.left + pwp->cx;
1359  rcTray.bottom = rcTray.top + pwp->cy;
1360  }
1361 
1363 
1364  if (!(pwp->flags & (SWP_NOMOVE | SWP_NOSIZE)))
1365  {
1366  SIZE szWnd;
1367 
1368  szWnd.cx = pwp->cx;
1369  szWnd.cy = pwp->cy;
1370 
1371  MakeTrayRectWithSize(m_Position, &szWnd, &rcTray);
1372  }
1373 
1374  m_TrayRects[m_Position] = rcTray;
1375  }
1376  else if (m_Position != (DWORD)-1)
1377  {
1378  /* If the user isn't resizing the tray window we need to make sure the
1379  new size or position is valid. this is to prevent changes to the window
1380  without user interaction. */
1381  rcTray = m_TrayRects[m_Position];
1382 
1384  {
1385  rcTray.left += m_AutoHideOffset.cx;
1386  rcTray.right += m_AutoHideOffset.cx;
1387  rcTray.top += m_AutoHideOffset.cy;
1388  rcTray.bottom += m_AutoHideOffset.cy;
1389  }
1390 
1391  }
1392 
1393 ChangePos:
1394  m_TraySize.cx = rcTray.right - rcTray.left;
1395  m_TraySize.cy = rcTray.bottom - rcTray.top;
1396 
1397  pwp->flags &= ~(SWP_NOMOVE | SWP_NOSIZE);
1398  pwp->x = rcTray.left;
1399  pwp->y = rcTray.top;
1400  pwp->cx = m_TraySize.cx;
1401  pwp->cy = m_TraySize.cy;
1402  }
1403  }
1404 
1406  {
1407  RECT rcClip, rcWindow;
1408  HRGN hClipRgn;
1409 
1410  if (GetWindowRect(&rcWindow))
1411  {
1412  /* Disable clipping on systems with only one monitor */
1413  if (GetSystemMetrics(SM_CMONITORS) <= 1)
1414  Clip = FALSE;
1415 
1416  if (Clip)
1417  {
1418  rcClip = rcWindow;
1419 
1420  GetScreenRect(m_Monitor, &rcClip);
1421 
1422  if (!IntersectRect(&rcClip, &rcClip, &rcWindow))
1423  {
1424  rcClip = rcWindow;
1425  }
1426 
1427  OffsetRect(&rcClip,
1428  -rcWindow.left,
1429  -rcWindow.top);
1430 
1431  hClipRgn = CreateRectRgnIndirect(&rcClip);
1432  }
1433  else
1434  hClipRgn = NULL;
1435 
1436  /* Set the clipping region or make sure the window isn't clipped
1437  by disabling it explicitly. */
1438  SetWindowRgn(hClipRgn, TRUE);
1439  }
1440  }
1441 
1443  {
1444 #if !WIN7_DEBUG_MODE
1445  RECT rcTray, rcWorkArea;
1446 
1447  /* If monitor has changed then fix the previous monitors work area */
1449  {
1450  GetScreenRect(m_PreviousMonitor, &rcWorkArea);
1451  SystemParametersInfoW(SPI_SETWORKAREA,
1452  1,
1453  &rcWorkArea,
1454  SPIF_SENDCHANGE);
1455  }
1456 
1457  rcTray = m_TrayRects[m_Position];
1458 
1459  GetScreenRect(m_Monitor, &rcWorkArea);
1461 
1462  /* If AutoHide is false then change the workarea to exclude
1463  the area that the taskbar covers. */
1465  {
1466  switch (m_Position)
1467  {
1468  case ABE_TOP:
1469  rcWorkArea.top = rcTray.bottom;
1470  break;
1471  case ABE_LEFT:
1472  rcWorkArea.left = rcTray.right;
1473  break;
1474  case ABE_RIGHT:
1475  rcWorkArea.right = rcTray.left;
1476  break;
1477  case ABE_BOTTOM:
1478  rcWorkArea.bottom = rcTray.top;
1479  break;
1480  }
1481  }
1482 
1483  /*
1484  * Resize the current monitor work area. Win32k will also send
1485  * a WM_SIZE message to automatically resize the desktop.
1486  */
1487  SystemParametersInfoW(SPI_SETWORKAREA,
1488  1,
1489  &rcWorkArea,
1490  SPIF_SENDCHANGE);
1491 #endif
1492  }
1493 
1495  {
1496  /* Force the rebar bands to resize */
1498  IID_IDeskBand,
1500  0,
1501  NULL,
1502  NULL);
1503 
1504  /* Calculate the size of the taskbar based on the rebar */
1506 
1507  /* Move the tray window */
1508  /* The handler of WM_WINDOWPOSCHANGING will override whatever size
1509  * and position we use here with m_TrayRects */
1510  SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE);
1511  ResizeWorkArea();
1513  }
1514 
1516  {
1517  DWORD Pos;
1518  RECT rcScreen;
1519  SIZE WndSize, EdgeSize, DlgFrameSize;
1520  SIZE StartBtnSize = m_StartButton.GetSize();
1521 
1522  EdgeSize.cx = GetSystemMetrics(SM_CXEDGE);
1523  EdgeSize.cy = GetSystemMetrics(SM_CYEDGE);
1524  DlgFrameSize.cx = GetSystemMetrics(SM_CXDLGFRAME);
1525  DlgFrameSize.cy = GetSystemMetrics(SM_CYDLGFRAME);
1526 
1528  rcScreen = g_TaskbarSettings.sr.Rect;
1529  GetScreenRectFromRect(&rcScreen, MONITOR_DEFAULTTONEAREST);
1530 
1532  {
1533  /* Use the minimum size of the taskbar, we'll use the start
1534  button as a minimum for now. Make sure we calculate the
1535  entire window size, not just the client size. However, we
1536  use a thinner border than a standard thick border, so that
1537  the start button and bands are not stuck to the screen border. */
1538  if(!m_Theme)
1539  {
1540  g_TaskbarSettings.sr.Size.cx = StartBtnSize.cx + (2 * (EdgeSize.cx + DlgFrameSize.cx));
1541  g_TaskbarSettings.sr.Size.cy = StartBtnSize.cy + (2 * (EdgeSize.cy + DlgFrameSize.cy));
1542  }
1543  else
1544  {
1545  g_TaskbarSettings.sr.Size.cx = StartBtnSize.cx - EdgeSize.cx;
1546  g_TaskbarSettings.sr.Size.cy = StartBtnSize.cy - EdgeSize.cy;
1549  }
1550  }
1551  /* Determine a minimum tray window rectangle. The "client" height is
1552  zero here since we cannot determine an optimal minimum width when
1553  loaded as a vertical tray window. We just need to make sure the values
1554  loaded from the registry are at least. The windows explorer behaves
1555  the same way, it allows the user to save a zero width vertical tray
1556  window, but not a zero height horizontal tray window. */
1557  if(!m_Theme)
1558  {
1559  WndSize.cx = 2 * (EdgeSize.cx + DlgFrameSize.cx);
1560  WndSize.cy = StartBtnSize.cy + (2 * (EdgeSize.cy + DlgFrameSize.cy));
1561  }
1562  else
1563  {
1564  WndSize.cx = StartBtnSize.cx;
1565  WndSize.cy = StartBtnSize.cy - EdgeSize.cy;
1566  }
1567 
1568  if (WndSize.cx < g_TaskbarSettings.sr.Size.cx)
1569  WndSize.cx = g_TaskbarSettings.sr.Size.cx;
1570  if (WndSize.cy < g_TaskbarSettings.sr.Size.cy)
1571  WndSize.cy = g_TaskbarSettings.sr.Size.cy;
1572 
1573  /* Save the calculated size */
1574  m_TraySize = WndSize;
1575 
1576  /* Calculate all docking rectangles. We need to do this here so they're
1577  initialized and dragging the tray window to another position gives
1578  usable results */
1579  for (Pos = ABE_LEFT; Pos <= ABE_BOTTOM; Pos++)
1580  {
1582  &rcScreen,
1583  &m_TraySize,
1584  &m_TrayRects[Pos]);
1585  // TRACE("m_TrayRects[%d(%d)]: %d,%d,%d,%d\n", Pos, Position, m_TrayRects[Pos].left, m_TrayRects[Pos].top, m_TrayRects[Pos].right, m_TrayRects[Pos].bottom);
1586  }
1587 
1588  /* Determine which monitor we are on. It shouldn't matter which docked
1589  position rectangle we use */
1591  }
1592 
1594  {
1595  RECT rcClient;
1596  SIZE TraySize, StartSize;
1597  POINT ptTrayNotify = { 0, 0 };
1598  BOOL Horizontal;
1599  HDWP dwp;
1600 
1602  if (prcClient != NULL)
1603  {
1604  rcClient = *prcClient;
1605  }
1606  else
1607  {
1608  if (!GetClientRect(&rcClient))
1609  {
1610  ERR("Could not get client rect lastErr=%d\n", GetLastError());
1611  return;
1612  }
1613  }
1614 
1615  Horizontal = IsPosHorizontal();
1616 
1617  /* We're about to resize/move the start button, the rebar control and
1618  the tray notification control */
1619  dwp = BeginDeferWindowPos(3);
1620  if (dwp == NULL)
1621  {
1622  ERR("BeginDeferWindowPos failed. lastErr=%d\n", GetLastError());
1623  return;
1624  }
1625 
1626  /* Limit the Start button width to the client width, if necessary */
1627  StartSize = m_StartButton.GetSize();
1628  if (StartSize.cx > rcClient.right)
1629  StartSize.cx = rcClient.right;
1630 
1631  HWND hwndTaskToolbar = ::GetWindow(m_TaskSwitch, GW_CHILD);
1632  if (hwndTaskToolbar)
1633  {
1634  DWORD size = SendMessageW(hwndTaskToolbar, TB_GETBUTTONSIZE, 0, 0);
1635 
1636  /* Themed button covers Edge area as well */
1637  StartSize.cy = HIWORD(size) + (m_Theme ? GetSystemMetrics(SM_CYEDGE) : 0);
1638  }
1639 
1640  if (m_StartButton.m_hWnd != NULL)
1641  {
1642  /* Resize and reposition the button */
1643  dwp = m_StartButton.DeferWindowPos(dwp,
1644  NULL,
1645  0,
1646  0,
1647  StartSize.cx,
1648  StartSize.cy,
1650  if (dwp == NULL)
1651  {
1652  ERR("DeferWindowPos for start button failed. lastErr=%d\n", GetLastError());
1653  return;
1654  }
1655  }
1656 
1657  /* Determine the size that the tray notification window needs */
1658  if (Horizontal)
1659  {
1660  TraySize.cx = 0;
1661  TraySize.cy = rcClient.bottom;
1662  }
1663  else
1664  {
1665  TraySize.cx = rcClient.right;
1666  TraySize.cy = 0;
1667  }
1668 
1669  if (m_TrayNotify != NULL &&
1672  (WPARAM)Horizontal,
1673  (LPARAM)&TraySize))
1674  {
1675  /* Move the tray notification window to the desired location */
1676  if (Horizontal)
1677  ptTrayNotify.x = rcClient.right - TraySize.cx;
1678  else
1679  ptTrayNotify.y = rcClient.bottom - TraySize.cy;
1680 
1681  dwp = ::DeferWindowPos(dwp,
1682  m_TrayNotify,
1683  NULL,
1684  ptTrayNotify.x,
1685  ptTrayNotify.y,
1686  TraySize.cx,
1687  TraySize.cy,
1689  if (dwp == NULL)
1690  {
1691  ERR("DeferWindowPos for notification area failed. lastErr=%d\n", GetLastError());
1692  return;
1693  }
1694  }
1695 
1696  /* Resize/Move the rebar control */
1697  if (m_Rebar != NULL)
1698  {
1699  POINT ptRebar = { 0, 0 };
1700  SIZE szRebar;
1701 
1702  SetWindowStyle(m_Rebar, CCS_VERT, Horizontal ? 0 : CCS_VERT);
1703 
1704  if (Horizontal)
1705  {
1706  ptRebar.x = StartSize.cx + GetSystemMetrics(SM_CXSIZEFRAME);
1707  szRebar.cx = ptTrayNotify.x - ptRebar.x;
1708  szRebar.cy = rcClient.bottom;
1709  }
1710  else
1711  {
1712  ptRebar.y = StartSize.cy + GetSystemMetrics(SM_CYSIZEFRAME);
1713  szRebar.cx = rcClient.right;
1714  szRebar.cy = ptTrayNotify.y - ptRebar.y;
1715  }
1716 
1717  dwp = ::DeferWindowPos(dwp,
1718  m_Rebar,
1719  NULL,
1720  ptRebar.x,
1721  ptRebar.y,
1722  szRebar.cx,
1723  szRebar.cy,
1725  }
1726 
1727  if (dwp != NULL)
1728  EndDeferWindowPos(dwp);
1729 
1730  if (m_TaskSwitch != NULL)
1731  {
1732  /* Update the task switch window configuration */
1734  }
1735  }
1736 
1737  void FitToRebar(PRECT pRect)
1738  {
1739  /* Get the rect of the rebar */
1740  RECT rebarRect, taskbarRect, clientRect;
1741  ::GetWindowRect(m_Rebar, &rebarRect);
1742  ::GetWindowRect(m_hWnd, &taskbarRect);
1743  ::GetClientRect(m_hWnd, &clientRect);
1744  OffsetRect(&rebarRect, -taskbarRect.left, -taskbarRect.top);
1745 
1746  /* Calculate the difference of size of the taskbar and the rebar */
1747  SIZE margins;
1748  margins.cx = taskbarRect.right - taskbarRect.left - clientRect.right + clientRect.left;
1749  margins.cy = taskbarRect.bottom - taskbarRect.top - clientRect.bottom + clientRect.top;
1750 
1751  /* Calculate the new size of the rebar and make it resize, then change the new taskbar size */
1752  switch (m_Position)
1753  {
1754  case ABE_TOP:
1755  rebarRect.bottom = rebarRect.top + pRect->bottom - pRect->top - margins.cy;
1757  pRect->bottom = pRect->top + rebarRect.bottom - rebarRect.top + margins.cy;
1758  break;
1759  case ABE_BOTTOM:
1760  rebarRect.top = rebarRect.bottom - (pRect->bottom - pRect->top - margins.cy);
1762  pRect->top = pRect->bottom - (rebarRect.bottom - rebarRect.top + margins.cy);
1763  break;
1764  case ABE_LEFT:
1765  rebarRect.right = rebarRect.left + (pRect->right - pRect->left - margins.cx);
1767  pRect->right = pRect->left + (rebarRect.right - rebarRect.left + margins.cx);
1768  break;
1769  case ABE_RIGHT:
1770  rebarRect.left = rebarRect.right - (pRect->right - pRect->left - margins.cx);
1772  pRect->left = pRect->right - (rebarRect.right - rebarRect.left + margins.cx);
1773  break;
1774  }
1775 
1777  }
1778 
1780  {
1781  if (m_StartMenuPopup != NULL)
1782  {
1783  POINTL pt;
1784  RECTL rcExclude;
1785  DWORD dwFlags = 0;
1786 
1787  if (m_StartButton.GetWindowRect((RECT*) &rcExclude))
1788  {
1789  switch (m_Position)
1790  {
1791  case ABE_BOTTOM:
1792  pt.x = rcExclude.left;
1793  pt.y = rcExclude.top;
1794  dwFlags |= MPPF_TOP;
1795  break;
1796  case ABE_TOP:
1797  pt.x = rcExclude.left;
1798  pt.y = rcExclude.bottom;
1799  dwFlags |= MPPF_BOTTOM;
1800  break;
1801  case ABE_LEFT:
1802  pt.x = rcExclude.right;
1803  pt.y = rcExclude.top;
1804  dwFlags |= MPPF_RIGHT;
1805  break;
1806  case ABE_RIGHT:
1807  pt.x = rcExclude.left;
1808  pt.y = rcExclude.top;
1809  dwFlags |= MPPF_LEFT;
1810  break;
1811  }
1812 
1813  m_StartMenuPopup->Popup(&pt, &rcExclude, dwFlags);
1814 
1815  m_StartButton.SendMessageW(BM_SETSTATE, TRUE, 0);
1816  }
1817  }
1818  }
1819 
1821  {
1822  RECT rcCurrent;
1823  POINT pt;
1824  BOOL over;
1826 
1827  GetCursorPos(&pt);
1828  GetWindowRect(&rcCurrent);
1829  over = PtInRect(&rcCurrent, pt);
1830 
1832  {
1833  over = TRUE;
1834  }
1835 
1836  if (over)
1837  {
1838  if (state == AUTOHIDE_HIDING)
1839  {
1840  TRACE("AutoHide cancelling hide.\n");
1843  }
1844  else if (state == AUTOHIDE_HIDDEN)
1845  {
1846  TRACE("AutoHide starting show.\n");
1849  }
1850  }
1851  else
1852  {
1853  if (state == AUTOHIDE_SHOWING)
1854  {
1855  TRACE("AutoHide cancelling show.\n");
1858  }
1859  else if (state == AUTOHIDE_SHOWN)
1860  {
1861  TRACE("AutoHide starting hide.\n");
1864  }
1865 
1867  }
1868  }
1869 
1871  {
1874 
1875  switch (m_AutoHideState)
1876  {
1877  case AUTOHIDE_HIDING:
1878  switch (m_Position)
1879  {
1880  case ABE_LEFT:
1881  m_AutoHideOffset.cy = 0;
1883  if (m_AutoHideOffset.cx < -w)
1884  m_AutoHideOffset.cx = -w;
1885  break;
1886  case ABE_TOP:
1887  m_AutoHideOffset.cx = 0;
1889  if (m_AutoHideOffset.cy < -h)
1890  m_AutoHideOffset.cy = -h;
1891  break;
1892  case ABE_RIGHT:
1893  m_AutoHideOffset.cy = 0;
1895  if (m_AutoHideOffset.cx > w)
1896  m_AutoHideOffset.cx = w;
1897  break;
1898  case ABE_BOTTOM:
1899  m_AutoHideOffset.cx = 0;
1901  if (m_AutoHideOffset.cy > h)
1902  m_AutoHideOffset.cy = h;
1903  break;
1904  }
1905 
1906  if (m_AutoHideOffset.cx != w && m_AutoHideOffset.cy != h)
1907  {
1909  break;
1910  }
1911 
1912  /* fallthrough */
1913  case AUTOHIDE_HIDDEN:
1914 
1915  switch (m_Position)
1916  {
1917  case ABE_LEFT:
1918  m_AutoHideOffset.cx = -w;
1919  m_AutoHideOffset.cy = 0;
1920  break;
1921  case ABE_TOP:
1922  m_AutoHideOffset.cx = 0;
1923  m_AutoHideOffset.cy = -h;
1924  break;
1925  case ABE_RIGHT:
1926  m_AutoHideOffset.cx = w;
1927  m_AutoHideOffset.cy = 0;
1928  break;
1929  case ABE_BOTTOM:
1930  m_AutoHideOffset.cx = 0;
1931  m_AutoHideOffset.cy = h;
1932  break;
1933  }
1934 
1937  break;
1938 
1939  case AUTOHIDE_SHOWING:
1941  {
1943  }
1945  {
1947  }
1948  else
1949  {
1950  m_AutoHideOffset.cx = 0;
1951  }
1952 
1954  {
1956  }
1958  {
1960  }
1961  else
1962  {
1963  m_AutoHideOffset.cy = 0;
1964  }
1965 
1966  if (m_AutoHideOffset.cx != 0 || m_AutoHideOffset.cy != 0)
1967  {
1969  break;
1970  }
1971 
1972  /* fallthrough */
1973  case AUTOHIDE_SHOWN:
1974 
1977  break;
1978  }
1979 
1980  SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER);
1981  }
1982 
1983 
1984 
1985 
1986 
1987  /**********************************************************
1988  * ##### taskbar drawing #####
1989  */
1990 
1992  {
1993  RECT rect;
1995 
1997 
1998  if (m_Theme)
1999  {
2000  GetClientRect(&rect);
2001  DrawThemeBackground(m_Theme, hdc, iSBkgndPart[m_Position], 0, &rect, 0);
2002  }
2003 
2004  return 0;
2005  }
2006 
2008  {
2009  HDC hdc;
2010  RECT rect;
2012  SIZE size;
2013 
2015 
2016  HRESULT hr = GetThemePartSize(m_Theme, NULL, iSizerPart[m_Position], 0, NULL, TS_TRUE, &size);
2017  if (FAILED_UNEXPECTEDLY(hr))
2018  return 0;
2019 
2020  GetWindowRect(&rect);
2021  OffsetRect(&rect, -rect.left, -rect.top);
2022 
2023  hdc = GetWindowDC();
2024 
2025  switch (m_Position)
2026  {
2027  case ABE_LEFT:
2028  rect.left = rect.right - size.cx;
2029  break;
2030  case ABE_TOP:
2031  rect.top = rect.bottom - size.cy;
2032  break;
2033  case ABE_RIGHT:
2034  rect.right = rect.left + size.cx;
2035  break;
2036  case ABE_BOTTOM:
2037  default:
2038  rect.bottom = rect.top + size.cy;
2039  break;
2040  }
2041 
2042  DrawThemeBackground(m_Theme, hdc, iSizerPart[m_Position], 0, &rect, 0);
2043 
2044  ReleaseDC(hdc);
2045  return 0;
2046  }
2047 
2048 
2049 
2050 
2051 
2052  /*
2053  * ITrayWindow
2054  */
2056  {
2057  RECT rcWnd;
2058 
2059  /* Check if there's already a window created and try to show it.
2060  If it was somehow destroyed just create a new tray window. */
2061  if (m_hWnd != NULL && IsWindow())
2062  {
2063  return S_OK;
2064  }
2065 
2066  DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE;
2068  dwExStyle |= WS_EX_TOPMOST;
2069 
2071  if(!m_Theme)
2072  {
2073  dwStyle |= WS_THICKFRAME | WS_BORDER;
2074  }
2075 
2076  ZeroMemory(&rcWnd, sizeof(rcWnd));
2077  if (m_Position != (DWORD) -1)
2078  rcWnd = m_TrayRects[m_Position];
2079 
2080  if (!Create(NULL, rcWnd, NULL, dwStyle, dwExStyle))
2081  return E_FAIL;
2082 
2083  /* Align all controls on the tray window */
2085 
2086  /* Move the tray window to the right position and resize it if necessary */
2088 
2089  return S_OK;
2090  }
2091 
2093  {
2094  if (m_hWnd != NULL)
2095  {
2098  0,
2099  0);
2100  }
2101 
2102  return S_OK;
2103  }
2104 
2106  {
2107  return m_hWnd;
2108  }
2109 
2111  {
2112  return (m_hWnd == hWnd ||
2113  (m_DesktopWnd != NULL && m_hWnd == m_DesktopWnd));
2114  }
2115 
2117  {
2118  return IsPosHorizontal();
2119  }
2120 
2122  {
2123  BOOL bPrevLock = g_TaskbarSettings.bLock;
2124 
2125  if (g_TaskbarSettings.bLock != bLock)
2126  {
2127  g_TaskbarSettings.bLock = bLock;
2128 
2129  if (m_TrayBandSite != NULL)
2130  {
2131  if (!SUCCEEDED(m_TrayBandSite->Lock(bLock)))
2132  {
2133  /* Reset?? */
2134  g_TaskbarSettings.bLock = bPrevLock;
2135  return bPrevLock;
2136  }
2137  }
2138 
2139  if (m_Theme)
2140  {
2141  /* Update cached tray sizes */
2142  for(DWORD Pos = ABE_LEFT; Pos <= ABE_BOTTOM; Pos++)
2143  {
2144  RECT rcGripper = {0};
2145  AdjustSizerRect(&rcGripper, Pos);
2146 
2148  {
2149  m_TrayRects[Pos].top += rcGripper.top;
2150  m_TrayRects[Pos].left += rcGripper.left;
2151  m_TrayRects[Pos].bottom += rcGripper.bottom;
2152  m_TrayRects[Pos].right += rcGripper.right;
2153  }
2154  else
2155  {
2156  m_TrayRects[Pos].top -= rcGripper.top;
2157  m_TrayRects[Pos].left -= rcGripper.left;
2158  m_TrayRects[Pos].bottom -= rcGripper.bottom;
2159  m_TrayRects[Pos].right -= rcGripper.right;
2160  }
2161  }
2162  }
2164  ResizeWorkArea();
2166  }
2167 
2168  return bPrevLock;
2169  }
2170 
2171 
2172  /*
2173  * IContextMenu
2174  */
2176  UINT indexMenu,
2177  UINT idCmdFirst,
2178  UINT idCmdLast,
2179  UINT uFlags)
2180  {
2181  if (!m_ContextMenu)
2182  {
2184  if (FAILED_UNEXPECTEDLY(hr))
2185  return hr;
2186  }
2187 
2188  return m_ContextMenu->QueryContextMenu(hPopup, indexMenu, idCmdFirst, idCmdLast, uFlags);
2189  }
2190 
2192  {
2193  if (!m_ContextMenu)
2194  return E_INVALIDARG;
2195 
2196  return m_ContextMenu->InvokeCommand(lpici);
2197  }
2198 
2200  UINT uType,
2201  UINT *pwReserved,
2202  LPSTR pszName,
2203  UINT cchMax)
2204  {
2205  if (!m_ContextMenu)
2206  return E_INVALIDARG;
2207 
2208  return m_ContextMenu->GetCommandString(idCmd, uType, pwReserved, pszName, cchMax);
2209  }
2210 
2211  /**********************************************************
2212  * ##### message handling #####
2213  */
2214 
2216  {
2217  HRESULT hRet;
2218 
2219  ((ITrayWindow*)this)->AddRef();
2220 
2221  SetWindowTheme(m_hWnd, L"TaskBar", NULL);
2222 
2223  /* Create the Start button */
2225 
2226  /* Load the saved tray window settings */
2227  RegLoadSettings();
2228 
2229  /* Create and initialize the start menu */
2231  m_StartMenuPopup = CreateStartMenu(this, &m_StartMenuBand, hbmBanner, 0);
2232 
2233  /* Create the task band */
2235  if (FAILED_UNEXPECTEDLY(hRet))
2236  return FALSE;
2237 
2238  /* Create the rebar band site. This actually creates the rebar and the tasks toolbar. */
2240  if (FAILED_UNEXPECTEDLY(hRet))
2241  return FALSE;
2242 
2243  /* Create the tray notification window */
2245  if (FAILED_UNEXPECTEDLY(hRet))
2246  return FALSE;
2247 
2248  /* Get the hwnd of the rebar */
2250  if (FAILED_UNEXPECTEDLY(hRet))
2251  return FALSE;
2252 
2253  /* Get the hwnd of the tasks toolbar */
2255  if (FAILED_UNEXPECTEDLY(hRet))
2256  return FALSE;
2257 
2258  /* Get the hwnd of the tray notification window */
2260  if (FAILED_UNEXPECTEDLY(hRet))
2261  return FALSE;
2262 
2263  SetWindowTheme(m_Rebar, L"TaskBar", NULL);
2264 
2265  UpdateFonts();
2266 
2268 
2270  {
2273  }
2274 
2275  /* Set the initial lock state in the band site */
2277 
2290 
2291  return TRUE;
2292  }
2293 
2295  {
2296  if (m_Theme)
2298 
2299  m_Theme = OpenThemeData(m_hWnd, L"TaskBar");
2300 
2301  if (m_Theme)
2302  {
2304  }
2305  else
2306  {
2308  }
2310 
2311  return TRUE;
2312  }
2313 
2315  {
2316  if (wParam == SPI_SETNONCLIENTMETRICS)
2317  {
2320  UpdateFonts();
2323  }
2324 
2325  return 0;
2326  }
2327 
2329  {
2330  HDC hdc = (HDC) wParam;
2331 
2332  if (!m_Theme)
2333  {
2334  bHandled = FALSE;
2335  return 0;
2336  }
2337 
2338  return EraseBackgroundWithTheme(hdc);
2339  }
2340 
2342  {
2343  /* Load the saved tray window settings */
2344  RegLoadSettings();
2345 
2346  /* Move the tray window to the right position and resize it if necessary */
2348 
2349  return TRUE;
2350  }
2351 
2353  {
2354  COPYDATASTRUCT *pCopyData = reinterpret_cast<COPYDATASTRUCT *>(lParam);
2355  switch (pCopyData->dwData)
2356  {
2357  case TABDMC_APPBAR:
2358  return appbar_message(pCopyData);
2359  case TABDMC_NOTIFY:
2360  case TABDMC_LOADINPROC:
2362  }
2363  return FALSE;
2364  }
2365 
2367  {
2368  if (!m_Theme)
2369  {
2370  bHandled = FALSE;
2371  return 0;
2372  }
2373  else if (g_TaskbarSettings.bLock)
2374  {
2375  return 0;
2376  }
2377 
2378  return DrawSizerWithTheme((HRGN) wParam);
2379  }
2380 
2382  {
2385  }
2386 
2388  {
2389  RECT rcClient;
2390  POINT pt;
2391 
2393  {
2394  /* The user may not be able to resize the tray window.
2395  Pretend like the window is not sizeable when the user
2396  clicks on the border. */
2397  return HTBORDER;
2398  }
2399 
2401  if (GetClientRect(&rcClient) &&
2402  (MapWindowPoints(NULL, (LPPOINT) &rcClient, 2) != 0 || GetLastError() == ERROR_SUCCESS))
2403  {
2404  pt.x = (SHORT) LOWORD(lParam);
2405  pt.y = (SHORT) HIWORD(lParam);
2406 
2407  if (PtInRect(&rcClient, pt))
2408  {
2409  /* The user is trying to drag the tray window */
2410  return HTCAPTION;
2411  }
2412 
2413  /* Depending on the position of the tray window, allow only
2414  changing the border next to the monitor working area */
2415  switch (m_Position)
2416  {
2417  case ABE_TOP:
2418  if (pt.y > rcClient.bottom)
2419  return HTBOTTOM;
2420  break;
2421  case ABE_LEFT:
2422  if (pt.x > rcClient.right)
2423  return HTRIGHT;
2424  break;
2425  case ABE_RIGHT:
2426  if (pt.x < rcClient.left)
2427  return HTLEFT;
2428  break;
2429  case ABE_BOTTOM:
2430  default:
2431  if (pt.y < rcClient.top)
2432  return HTTOP;
2433  break;
2434  }
2435  }
2436  return HTBORDER;
2437  }
2438 
2440  {
2441  POINT ptCursor;
2442  PRECT pRect = (PRECT) lParam;
2443 
2444  /* We need to ensure that an application can not accidently
2445  move the tray window (using SetWindowPos). However, we still
2446  need to be able to move the window in case the user wants to
2447  drag the tray window to another position or in case the user
2448  wants to resize the tray window. */
2449  if (!g_TaskbarSettings.bLock && GetCursorPos(&ptCursor))
2450  {
2451  IsDragging = TRUE;
2453  }
2454  else
2455  {
2456  *pRect = m_TrayRects[m_Position];
2457  }
2458  return TRUE;
2459  }
2460 
2462  {
2463  PRECT pRect = (PRECT) lParam;
2464 
2465  if (!g_TaskbarSettings.bLock)
2466  {
2467  FitToRebar(pRect);
2468  }
2469  else
2470  {
2471  *pRect = m_TrayRects[m_Position];
2472  }
2473  return TRUE;
2474  }
2475 
2477  {
2479  return TRUE;
2480  }
2481 
2483  {
2484  RECT rcClient;
2485  if (wParam == SIZE_RESTORED && lParam == 0)
2486  {
2487  ResizeWorkArea();
2488  /* Clip the tray window on multi monitor systems so the edges can't
2489  overlap into another monitor */
2491 
2492  if (!GetClientRect(&rcClient))
2493  {
2494  return FALSE;
2495  }
2496  }
2497  else
2498  {
2499  rcClient.left = rcClient.top = 0;
2500  rcClient.right = LOWORD(lParam);
2501  rcClient.bottom = HIWORD(lParam);
2502  }
2503 
2504  AlignControls(&rcClient);
2505  return TRUE;
2506  }
2507 
2509  {
2510  InSizeMove = TRUE;
2511  IsDragging = FALSE;
2512  if (!g_TaskbarSettings.bLock)
2513  {
2514  /* Remove the clipping on multi monitor systems while dragging around */
2516  }
2517  return TRUE;
2518  }
2519 
2521  {
2522  InSizeMove = FALSE;
2523  if (!g_TaskbarSettings.bLock)
2524  {
2526 
2527  /* Apply clipping */
2529  }
2530  return TRUE;
2531  }
2532 
2534  {
2535  switch (wParam)
2536  {
2537  case TEXT(' '):
2538  {
2539  /* The user pressed Alt+Space, this usually brings up the system menu of a window.
2540  The tray window needs to handle this specially, since it normally doesn't have
2541  a system menu. */
2542 
2543  static const UINT uidDisableItem [] = {
2544  SC_RESTORE,
2545  SC_MOVE,
2546  SC_SIZE,
2547  SC_MAXIMIZE,
2548  SC_MINIMIZE,
2549  };
2550  HMENU hSysMenu;
2551  UINT i, uId;
2552 
2553  /* temporarily enable the system menu */
2555 
2556  hSysMenu = GetSystemMenu(FALSE);
2557  if (hSysMenu != NULL)
2558  {
2559  /* Disable all items that are not relevant */
2560  for (i = 0; i < _countof(uidDisableItem); i++)
2561  {
2562  EnableMenuItem(hSysMenu,
2563  uidDisableItem[i],
2565  }
2566 
2567  EnableMenuItem(hSysMenu,
2568  SC_CLOSE,
2569  MF_BYCOMMAND |
2571 
2572  /* Display the system menu */
2573  uId = TrackMenu(
2574  hSysMenu,
2575  NULL,
2577  m_Position != ABE_TOP,
2578  FALSE);
2579  if (uId != 0)
2580  {
2581  SendMessage(m_hWnd, WM_SYSCOMMAND, (WPARAM) uId, 0);
2582  }
2583  }
2584 
2585  /* revert the system menu window style */
2587  break;
2588  }
2589 
2590  default:
2591  bHandled = FALSE;
2592  }
2593  return TRUE;
2594  }
2595 
2597  {
2598  /* This handler implements the trick that makes the start button to
2599  get pressed when the user clicked left or below the button */
2600 
2602  WINDOWINFO wi = {sizeof(WINDOWINFO)};
2603  RECT rcStartBtn;
2604 
2605  bHandled = FALSE;
2606 
2607  m_StartButton.GetWindowRect(&rcStartBtn);
2608  GetWindowInfo(m_hWnd, &wi);
2609 
2610  switch (m_Position)
2611  {
2612  case ABE_TOP:
2613  case ABE_LEFT:
2614  {
2615  if (pt.x > rcStartBtn.right || pt.y > rcStartBtn.bottom)
2616  return 0;
2617  break;
2618  }
2619  case ABE_RIGHT:
2620  {
2621  if (pt.x < rcStartBtn.left || pt.y > rcStartBtn.bottom)
2622  return 0;
2623 
2624  if (rcStartBtn.right + (int)wi.cxWindowBorders * 2 + 1 < wi.rcWindow.right &&
2625  pt.x > rcStartBtn.right)
2626  {
2627  return 0;
2628  }
2629  break;
2630  }
2631  case ABE_BOTTOM:
2632  {
2633  if (pt.x > rcStartBtn.right || pt.y < rcStartBtn.top)
2634  {
2635  return 0;
2636  }
2637 
2638  if (rcStartBtn.bottom + (int)wi.cyWindowBorders * 2 + 1 < wi.rcWindow.bottom &&
2639  pt.y > rcStartBtn.bottom)
2640  {
2641  return 0;
2642  }
2643 
2644  break;
2645  }
2646  }
2647 
2648  bHandled = TRUE;
2649  PopupStartMenu();
2650  return 0;
2651  }
2652 
2654  {
2655  /* We want the user to be able to get a context menu even on the nonclient
2656  area (including the sizing border)! */
2657  uMsg = WM_CONTEXTMENU;
2658  wParam = (WPARAM) m_hWnd;
2659 
2660  return OnContextMenu(uMsg, wParam, lParam, bHandled);
2661  }
2662 
2664  {
2665  LRESULT Ret = FALSE;
2666  POINT pt, *ppt = NULL;
2667  HWND hWndExclude = NULL;
2668 
2669  /* Check if the administrator has forbidden access to context menus */
2671  return FALSE;
2672 
2673  pt.x = (SHORT) LOWORD(lParam);
2674  pt.y = (SHORT) HIWORD(lParam);
2675 
2676  if (pt.x != -1 || pt.y != -1)
2677  ppt = &pt;
2678  else
2679  hWndExclude = m_StartButton.m_hWnd;
2680 
2681  if ((HWND) wParam == m_StartButton.m_hWnd)
2682  {
2683  /* Make sure we can't track the context menu if the start
2684  menu is currently being shown */
2686  {
2687  CComPtr<IContextMenu> ctxMenu;
2689  TrackCtxMenu(ctxMenu, ppt, hWndExclude, m_Position == ABE_BOTTOM, this);
2690  }
2691  }
2692  else
2693  {
2694  /* See if the context menu should be handled by the task band site */
2695  if (ppt != NULL && m_TrayBandSite != NULL)
2696  {
2697  HWND hWndAtPt;
2698  POINT ptClient = *ppt;
2699 
2700  /* Convert the coordinates to client-coordinates */
2701  ::MapWindowPoints(NULL, m_hWnd, &ptClient, 1);
2702 
2703  hWndAtPt = ChildWindowFromPoint(ptClient);
2704  if (hWndAtPt != NULL &&
2705  (hWndAtPt == m_Rebar || ::IsChild(m_Rebar, hWndAtPt)))
2706  {
2707  /* Check if the user clicked on the task switch window */
2708  ptClient = *ppt;
2709  ::MapWindowPoints(NULL, m_Rebar, &ptClient, 1);
2710 
2712  if (hWndAtPt == m_TaskSwitch)
2713  goto HandleTrayContextMenu;
2714 
2715  /* Forward the message to the task band site */
2716  m_TrayBandSite->ProcessMessage(m_hWnd, uMsg, wParam, lParam, &Ret);
2717  }
2718  else
2719  goto HandleTrayContextMenu;
2720  }
2721  else
2722  {
2723 HandleTrayContextMenu:
2724  /* Tray the default tray window context menu */
2725  TrackCtxMenu(this, ppt, NULL, FALSE, this);
2726  }
2727  }
2728  return Ret;
2729  }
2730 
2732  {
2733  LRESULT Ret = FALSE;
2734  /* FIXME: We can't check with IsChild whether the hwnd is somewhere inside
2735  the rebar control! But we shouldn't forward messages that the band
2736  site doesn't handle, such as other controls (start button, tray window */
2737 
2738  HRESULT hr = E_FAIL;
2739 
2740  if (m_TrayBandSite)
2741  {
2742  hr = m_TrayBandSite->ProcessMessage(m_hWnd, uMsg, wParam, lParam, &Ret);
2743  if (SUCCEEDED(hr))
2744  return Ret;
2745  }
2746 
2747  if (m_TrayBandSite == NULL || FAILED(hr))
2748  {
2749  const NMHDR *nmh = (const NMHDR *) lParam;
2750 
2751  if (nmh->hwndFrom == m_TrayNotify)
2752  {
2753  switch (nmh->code)
2754  {
2755  case NTNWM_REALIGN:
2756  /* Cause all controls to be aligned */
2758  break;
2759  }
2760  }
2761  }
2762  return Ret;
2763  }
2764 
2766  {
2767  /* Let the clock handle the double click */
2769 
2770  /* We "handle" this message so users can't cause a weird maximize/restore
2771  window animation when double-clicking the tray window! */
2772  return TRUE;
2773  }
2774 
2776  {
2777  DestroyWindow();
2778  return TRUE;
2779  }
2780 
2782  {
2783  HWND hwndStartMenu;
2784  HRESULT hr = IUnknown_GetWindow(m_StartMenuPopup, &hwndStartMenu);
2785  if (FAILED_UNEXPECTEDLY(hr))
2786  return FALSE;
2787 
2788  if (::IsWindowVisible(hwndStartMenu))
2789  {
2790  m_StartMenuPopup->OnSelect(MPOS_CANCELLEVEL);
2791  }
2792  else
2793  {
2794  PopupStartMenu();
2795  }
2796 
2797  return TRUE;
2798  }
2799 
2801  {
2802  /*
2803  * TWM_DOEXITWINDOWS is send by the CDesktopBrowser to us
2804  * to show the shutdown dialog. Also a WM_CLOSE message sent
2805  * by apps should show the dialog.
2806  */
2807  return DoExitWindows();
2808  }
2809 
2811  {
2812  if (wParam == SC_CLOSE)
2813  {
2814  return DoExitWindows();
2815  }
2816 
2817  bHandled = FALSE;
2818  return TRUE;
2819  }
2820 
2822  {
2823  bHandled = TRUE;
2824  return (LRESULT)m_TaskSwitch;
2825  }
2826 
2828  {
2829  return HandleHotKey(wParam);
2830  }
2831 
2833  {
2840  };
2841 
2843  {
2844  WCHAR szClass[32];
2845  GetClassNameW(hwnd, szClass, _countof(szClass));
2846  return wcscmp(szClass, L"#32770") == 0;
2847  }
2848 
2850  {
2852  if (hwnd == info->hwndDesktop || hwnd == info->hTrayWnd ||
2853  hwnd == info->hwndProgman)
2854  {
2855  return TRUE;
2856  }
2857  if (!info->bShowDesktop)
2858  {
2859  if (!::IsWindowEnabled(hwnd) || IsDialog(hwnd))
2860  return TRUE;
2861  HWND hwndOwner = ::GetWindow(hwnd, GW_OWNER);
2862  if (hwndOwner && !::IsWindowEnabled(hwndOwner))
2863  return TRUE;
2864  }
2865  if (::IsWindowVisible(hwnd) && !::IsIconic(hwnd))
2866  {
2868  info->bRet = TRUE;
2869  info->pMinimizedAll->Add(hwnd);
2870  }
2871  return TRUE;
2872  }
2873 
2874  VOID MinimizeAll(BOOL bShowDesktop = FALSE)
2875  {
2877  info.hwndDesktop = GetDesktopWindow();;
2878  info.hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
2879  info.hwndProgman = FindWindowW(L"Progman", NULL);
2880  info.bRet = FALSE;
2881  info.pMinimizedAll = &g_MinimizedAll;
2882  info.bShowDesktop = bShowDesktop;
2884 
2885  // invalid handles should be cleared to avoid mismatch of handles
2886  for (INT i = 0; i < g_MinimizedAll.GetSize(); ++i)
2887  {
2888  if (!::IsWindow(g_MinimizedAll[i]))
2889  g_MinimizedAll[i] = NULL;
2890  }
2891 
2894  }
2895 
2897  {
2898  MinimizeAll(TRUE);
2899  }
2900 
2902  {
2903  for (INT i = g_MinimizedAll.GetSize() - 1; i >= 0; --i)
2904  {
2906  if (::IsWindowVisible(hwnd) && ::IsIconic(hwnd))
2907  {
2909  }
2910  }
2911  g_MinimizedAll.RemoveAll();
2912  }
2913 
2915  {
2916  LRESULT Ret = FALSE;
2917 
2918  if ((HWND) lParam == m_StartButton.m_hWnd)
2919  {
2920  return FALSE;
2921  }
2922 
2923  if (m_TrayBandSite == NULL || FAILED_UNEXPECTEDLY(m_TrayBandSite->ProcessMessage(m_hWnd, uMsg, wParam, lParam, &Ret)))
2924  {
2925  return HandleCommand(LOWORD(wParam));
2926  }
2927  return Ret;
2928  }
2929 
2931  {
2933  {
2935  }
2936 
2937  return TRUE;
2938  }
2939 
2941  {
2942  if (wParam == TIMER_ID_MOUSETRACK)
2943  {
2945  }
2946  else if (wParam == TIMER_ID_AUTOHIDE)
2947  {
2948  ProcessAutoHide();
2949  }
2950 
2951  bHandled = FALSE;
2952  return TRUE;
2953  }
2954 
2956  {
2957  RECT *rc = NULL;
2958  /* Ignore WM_NCCALCSIZE if we are not themed or locked */
2960  {
2961  bHandled = FALSE;
2962  return 0;
2963  }
2964  if(!wParam)
2965  {
2966  rc = (RECT*)wParam;
2967  }
2968  else
2969  {
2971  if(prms->lppos->flags & SWP_NOSENDCHANGING)
2972  {
2973  bHandled = FALSE;
2974  return 0;
2975  }
2976  rc = &prms->rgrc[0];
2977  }
2978 
2980 
2981  return 0;
2982  }
2983 
2985  {
2986  HMENU hMenu = (HMENU)wParam;
2988  {
2992  }
2993  else
2994  {
2998  }
2999  return 0;
3000  }
3001 
3003  {
3004 #if 0
3005  LPNMRBAUTOSIZE as = (LPNMRBAUTOSIZE) nmhdr;
3006 
3007  if (!as->fChanged)
3008  return 0;
3009 
3010  RECT rc;
3011  ::GetWindowRect(m_hWnd, &rc);
3012 
3013  SIZE szWindow = {
3014  rc.right - rc.left,
3015  rc.bottom - rc.top };
3016  SIZE szTarget = {
3017  as->rcTarget.right - as->rcTarget.left,
3018  as->rcTarget.bottom - as->rcTarget.top };
3019  SIZE szActual = {
3020  as->rcActual.right - as->rcActual.left,
3021  as->rcActual.bottom - as->rcActual.top };
3022 
3023  SIZE borders = {
3024  szWindow.cx - szTarget.cx,
3025  szWindow.cy - szTarget.cx,
3026  };
3027 
3028  switch (m_Position)
3029  {
3030  case ABE_LEFT:
3031  szWindow.cx = szActual.cx + borders.cx;
3032  break;
3033  case ABE_TOP:
3034  szWindow.cy = szActual.cy + borders.cy;
3035  break;
3036  case ABE_RIGHT:
3037  szWindow.cx = szActual.cx + borders.cx;
3038  rc.left = rc.right - szWindow.cy;
3039  break;
3040  case ABE_BOTTOM:
3041  szWindow.cy = szActual.cy + borders.cy;
3042  rc.top = rc.bottom - szWindow.cy;
3043  break;
3044  }
3045 
3046  SetWindowPos(NULL, rc.left, rc.top, szWindow.cx, szWindow.cy, SWP_NOACTIVATE | SWP_NOZORDER);
3047 #else
3048  bHandled = FALSE;
3049 #endif
3050  return 0;
3051  }
3052 
3054  {
3055  TaskbarSettings* newSettings = (TaskbarSettings*)lParam;
3056 
3057  /* Propagate the new settings to the children */
3060 
3061  /* Toggle autohide */
3062  if (newSettings->sr.AutoHide != g_TaskbarSettings.sr.AutoHide)
3063  {
3064  g_TaskbarSettings.sr.AutoHide = newSettings->sr.AutoHide;
3067  if (!newSettings->sr.AutoHide)
3068  SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER);
3069  else
3071  }
3072 
3073  /* Toggle lock state */
3074  Lock(newSettings->bLock);
3075 
3076  /* Toggle OnTop state */
3077  if (newSettings->sr.AlwaysOnTop != g_TaskbarSettings.sr.AlwaysOnTop)
3078  {
3080  HWND hWndInsertAfter = newSettings->sr.AlwaysOnTop ? HWND_TOPMOST : HWND_BOTTOM;
3081  SetWindowPos(hWndInsertAfter, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
3082  }
3083 
3085  return 0;
3086  }
3087 
3089 
3092  {
3093  MSG Msg;
3094  LRESULT lRet;
3095 
3096  Msg.hwnd = m_hWnd;
3097  Msg.message = uMsg;
3098  Msg.wParam = wParam;
3099  Msg.lParam = lParam;
3100 
3101  if (m_StartMenuBand->TranslateMenuMessage(&Msg, &lRet) == S_OK)
3102  {
3103  return lRet;
3104  }
3105 
3106  wParam = Msg.wParam;
3107  lParam = Msg.lParam;
3108  }
3109  MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged)
3115  /*MESSAGE_HANDLER(WM_DESTROY, OnDestroy)*/
3122  MESSAGE_HANDLER(WM_DISPLAYCHANGE, OnDisplayChange)
3146  ALT_MSG_MAP(1)
3147  END_MSG_MAP()
3148 
3149  /*****************************************************************************/
3150 
3152  {
3153  MSG Msg;
3154 
3155  /* FIXME: We should keep a reference here... */
3156 
3157  while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
3158  {
3159  if (Msg.message == WM_QUIT)
3160  break;
3161 
3162  if (m_StartMenuBand == NULL ||
3163  m_StartMenuBand->IsMenuMessage(&Msg) != S_OK)
3164  {
3166  DispatchMessage(&Msg);
3167  }
3168  }
3169  }
3170 
3172  {
3173  MSG Msg;
3174  BOOL Ret;
3175 
3176  /* FIXME: We should keep a reference here... */
3177 
3178  while (true)
3179  {
3180  Ret = GetMessage(&Msg, NULL, 0, 0);
3181 
3182  if (!Ret || Ret == -1)
3183  break;
3184 
3185  if (m_StartMenuBand == NULL ||
3186  m_StartMenuBand->IsMenuMessage(&Msg) != S_OK)
3187  {
3189  DispatchMessage(&Msg);
3190  }
3191  }
3192  }
3193 
3194  /*
3195  * IShellDesktopTray
3196  *
3197  * NOTE: this is a very windows-specific COM interface used by SHCreateDesktop()!
3198  * These are the calls I observed, it may be wrong/incomplete/buggy!!!
3199  * The reason we implement it is because we have to use SHCreateDesktop() so
3200  * that the shell provides the desktop window and all the features that come
3201  * with it (especially positioning of desktop icons)
3202  */
3203 
3205  {
3206  /* FIXME: Return ABS_ flags? */
3207  TRACE("IShellDesktopTray::GetState() unimplemented!\n");
3208  return 0;
3209  }
3210 
3212  {
3213  TRACE("IShellDesktopTray::GetTrayWindow(0x%p)\n", phWndTray);
3214  *phWndTray = m_hWnd;
3215  return S_OK;
3216  }
3217 
3219  {
3220  TRACE("IShellDesktopTray::RegisterDesktopWindow(0x%p)\n", hWndDesktop);
3221 
3222  m_DesktopWnd = hWndDesktop;
3223  return S_OK;
3224  }
3225 
3226  virtual HRESULT STDMETHODCALLTYPE Unknown(IN DWORD dwUnknown1, IN DWORD dwUnknown2)
3227  {
3228  TRACE("IShellDesktopTray::Unknown(%u,%u) unimplemented!\n", dwUnknown1, dwUnknown2);
3229  return S_OK;
3230  }
3231 
3233  {
3234  m_StartButton.SendMessageW(BM_SETSTATE, FALSE, 0);
3235  return S_OK;
3236  }
3237 
3239  {
3240  if (!phwnd)
3241  return E_INVALIDARG;
3242  *phwnd = m_hWnd;
3243  return S_OK;
3244  }
3245 
3247  {
3248  return E_NOTIMPL;
3249  }
3250 
3251  void _Init()
3252  {
3253  m_Position = (DWORD) -1;
3254  }
3255 
3257 
3260  /*COM_INTERFACE_ENTRY_IID(IID_ITrayWindow, ITrayWindow)*/
3263  COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu)
3264  END_COM_MAP()
3265 };
3266 
3270  public IContextMenu
3271 {
3276 
3277 public:
3278  HRESULT Initialize(ITrayWindow * pTrayWnd, IN HWND hWndOwner)
3279  {
3280  this->TrayWnd = (CTrayWindow *) pTrayWnd;
3281  this->hWndOwner = hWndOwner;
3282  this->m_idCmdCmFirst = 0;
3283  return S_OK;
3284  }
3285 
3286  virtual HRESULT STDMETHODCALLTYPE
3288  UINT indexMenu,
3289  UINT idCmdFirst,
3290  UINT idCmdLast,
3291  UINT uFlags)
3292  {
3293  HMENU hMenuBase;
3294 
3296 
3297  if (g_MinimizedAll.GetSize() != 0 && !::IsThereAnyEffectiveWindow(TRUE))
3298  {
3299  CStringW strRestoreAll(MAKEINTRESOURCEW(IDS_RESTORE_ALL));
3300  MENUITEMINFOW mii = { sizeof(mii) };
3301  mii.fMask = MIIM_ID | MIIM_TYPE;
3303  mii.fType = MFT_STRING;
3304  mii.dwTypeData = const_cast<LPWSTR>(&strRestoreAll[0]);
3306  }
3307 
3308  if (!hMenuBase)
3309  return HRESULT_FROM_WIN32(GetLastError());
3310 
3311  if (SHRestricted(REST_CLASSICSHELL) != 0)
3312  {
3313  DeleteMenu(hPopup,
3315  MF_BYCOMMAND);
3316  }
3317 
3318  CheckMenuItem(hMenuBase,
3321 
3322  UINT idCmdNext;
3323  idCmdNext = Shell_MergeMenus(hPopup, hMenuBase, indexMenu, idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS | MM_ADDSEPARATOR);
3324  m_idCmdCmFirst = idCmdNext - idCmdFirst;
3325 
3326  ::DestroyMenu(hMenuBase);
3327 
3328  if (TrayWnd->m_TrayBandSite != NULL)
3329  {
3330  if (FAILED(TrayWnd->m_TrayBandSite->AddContextMenus(
3331  hPopup,
3332  indexMenu,
3333  idCmdNext,
3334  idCmdLast,
3335  CMF_NORMAL,
3336  &pcm)))
3337  {
3338  WARN("AddContextMenus failed.\n");
3339  pcm = NULL;
3340  }
3341  }
3342 
3343  return S_OK;
3344  }
3345 
3346  virtual HRESULT STDMETHODCALLTYPE
3348  {
3349  UINT uiCmdId = PtrToUlong(lpici->lpVerb);
3350  if (uiCmdId != 0)
3351  {
3352  if (uiCmdId >= m_idCmdCmFirst)
3353  {
3354  CMINVOKECOMMANDINFO cmici = { 0 };
3355 
3356  if (pcm != NULL)
3357  {
3358  /* Setup and invoke the shell command */
3359  cmici.cbSize = sizeof(cmici);
3360  cmici.hwnd = hWndOwner;
3361  cmici.lpVerb = (LPCSTR) MAKEINTRESOURCEW(uiCmdId - m_idCmdCmFirst);
3362  cmici.nShow = SW_NORMAL;
3363 
3364  pcm->InvokeCommand(&cmici);
3365  }
3366  }
3367  else
3368  {
3369  TrayWnd->ExecContextMenuCmd(uiCmdId);
3370  }
3371  }
3372 
3373  return S_OK;
3374  }
3375 
3376  virtual HRESULT STDMETHODCALLTYPE
3378  UINT uType,
3379  UINT *pwReserved,
3380  LPSTR pszName,
3381  UINT cchMax)
3382  {
3383  return E_NOTIMPL;
3384  }
3385 
3387  {
3388  }
3389 
3391  {
3392  }
3393 
3395  COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu)
3396  END_COM_MAP()
3397 };
3398 
3399 HRESULT TrayWindowCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu)
3400 {
3402  mnu->Initialize(TrayWnd, hWndOwner);
3403  *ppCtxMenu = mnu;
3404  return S_OK;
3405 }
3406 
3407 HRESULT CreateTrayWindow(ITrayWindow ** ppTray)
3408 {
3410  if (Tray == NULL)
3411  return E_OUTOFMEMORY;
3412 
3413  Tray->_Init();
3414  Tray->Open();
3415 
3416  *ppTray = (ITrayWindow *) Tray;
3417 
3418  return S_OK;
3419 }
3420 
3421 HRESULT
3422 Tray_OnStartMenuDismissed(ITrayWindow* Tray)
3423 {
3424  CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3425  return TrayWindow->RaiseStartButton();
3426 }
3427 
3428 VOID TrayProcessMessages(ITrayWindow *Tray)
3429 {
3430  CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3431  TrayWindow->TrayProcessMessages();
3432 }
3433 
3434 VOID TrayMessageLoop(ITrayWindow *Tray)
3435 {
3436  CTrayWindow * TrayWindow = static_cast<CTrayWindow *>(Tray);
3437  TrayWindow->TrayMessageLoop();
3438 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
SIZE GetSize()
Definition: traywnd.cpp:164
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1679
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
CComPtr< IContextMenu > pcm
Definition: traywnd.cpp:3274
#define IDHK_NEXT_TASK
Definition: traywnd.cpp:53
#define IDHK_PREV_TASK
Definition: traywnd.cpp:54
DWORD NewPosSize
Definition: traywnd.cpp:322
#define WM_NULL
Definition: winuser.h:1594
EXTERN_C BOOL WINAPI SHFindComputer(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: stubs.cpp:33
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz)
Definition: draw.c:1777
HMONITOR WINAPI MonitorFromPoint(POINT, DWORD)
#define TPM_VERTICAL
Definition: winuser.h:2362
LRESULT OnGetTaskSwitch(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2821
HMONITOR GetMonitorFromRect(IN const RECT *pRect)
Definition: traywnd.cpp:993
#define WS_DISABLED
Definition: pedump.c:621
#define HTTOP
Definition: winuser.h:2470
#define BS_LEFT
Definition: winuser.h:265
BOOL IsWindowEnabled() const
Definition: atlwin.h:887
#define TRAYCMD_HELP_AND_SUPPORT
Definition: undocshell.h:703
#define WS_THICKFRAME
Definition: pedump.c:630
LRESULT OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2352
#define HTLEFT
Definition: winuser.h:2467
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define BM_SETSTATE
Definition: winuser.h:1910
int MapWindowPoints(HWND hWndTo, LPPOINT lpPoint, UINT nCount) const
Definition: atlwin.h:925
HWND m_RunFileDlgOwner
Definition: traywnd.cpp:303
#define ABE_TOP
Definition: shellapi.h:18
#define IN
Definition: typedefs.h:39
#define SW_NORMAL
Definition: winuser.h:763
#define DispatchMessage
Definition: winuser.h:5745
#define max(a, b)
Definition: svc.c:63
static DWORD WINAPI s_TrayPropertiesThread(IN OUT PVOID pParam)
Definition: traywnd.cpp:513
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define MFT_STRING
Definition: winuser.h:741
HDWP WINAPI BeginDeferWindowPos(_In_ int)
HIMAGELIST m_ImageList
Definition: traywnd.cpp:142
#define RB_SIZETORECT
Definition: commctrl.h:1598
#define PeekMessage
Definition: winuser.h:5810
WORD WINAPI TileWindows(_In_opt_ HWND hwndParent, _In_ UINT wHow, _In_opt_ CONST RECT *lpRect, _In_ UINT cKids, _In_reads_opt_(cKids) const HWND FAR *lpKids)
HWND SetFocus()
Definition: atlwin.h:1133
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CloseHandle
Definition: compat.h:598
LRESULT HandleHotKey(DWORD id)
Definition: traywnd.cpp:654
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define AUTOHIDE_INTERVAL_ANIMATING
Definition: traywnd.cpp:36
#define MF_BYCOMMAND
Definition: winuser.h:202
LRESULT OnEnterSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2508
#define GW_CHILD
Definition: winuser.h:758
#define WC_BUTTON
Definition: commctrl.h:4625
#define SC_RESTORE
Definition: winuser.h:2578
long y
Definition: polytest.cpp:48
HRESULT STDMETHODCALLTYPE InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
Definition: traywnd.cpp:2191
#define ERROR_SUCCESS
Definition: deptool.c:10
UINT WINAPI Shell_MergeMenus(HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags)
Definition: shlmenu.c:857
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define ABN_WINDOWARRANGE
Definition: shellapi.h:72
#define WM_LBUTTONDOWN
Definition: winuser.h:1763
LRESULT OnDisplayChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2341
#define ID_SHELL_CMD_PROPERTIES
Definition: resource.h:185
HRESULT hr
Definition: shlfolder.c:183
#define TWM_DOEXITWINDOWS
Definition: undocshell.h:56
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define IDHK_FIND_COMPUTER
Definition: traywnd.cpp:52
#define SM_CMONITORS
Definition: winuser.h:1034
LRESULT OnThemeChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2294
void FitToRebar(PRECT pRect)
Definition: traywnd.cpp:1737
long x
Definition: polytest.cpp:48
#define IDHK_SYS_PROPERTIES
Definition: traywnd.cpp:55
VOID GetTrayRectFromScreenRect(IN DWORD Position, IN const RECT *pScreen, IN const SIZE *pTraySize OPTIONAL, OUT RECT *pRect)
Definition: traywnd.cpp:1110
DWORD WINAPI TrayPropertiesThread()
Definition: traywnd.cpp:484
HRESULT ShutdownShellServices(HDPA hdpa)
void SetFont(HFONT hFont, BOOL bRedraw=TRUE)
Definition: atlwin.h:1139
#define RBN_AUTOSIZE
Definition: commctrl.h:1631
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
#define WM_INITMENUPOPUP
Definition: winuser.h:1733
HRESULT STDMETHODCALLTYPE GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
Definition: traywnd.cpp:2199
#define AUTOHIDE_SPEED_SHOW
Definition: traywnd.cpp:38
UINT cxWindowBorders
Definition: winuser.h:3752
#define ID_SHELL_CMD_RESTORE_ALL
Definition: resource.h:197
#define ID_SHELL_CMD_UNDO_ACTION
Definition: resource.h:190
BOOL ShowWindowAsync(int nCmdShow)
Definition: atlwin.h:1274
#define WM_HOTKEY
Definition: winuser.h:1866
LRESULT OnMoving(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2439
#define AUTOHIDE_HIDDEN
Definition: traywnd.cpp:41
#define WM_NCCALCSIZE
Definition: winuser.h:1672
HWND Create(HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
Definition: atlwin.h:1666
LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2731
#define TPM_RETURNCMD
Definition: winuser.h:2367
HWND GetLastActivePopup() const
Definition: atlwin.h:630
#define BM_GETSTATE
Definition: winuser.h:1907
LRESULT HandleCommand(UINT uCommand)
Definition: traywnd.cpp:699
static COORD Position
Definition: mouse.c:34
#define ID_SHELL_CMD_OPEN_TASKMGR
Definition: resource.h:189
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
VOID ShowCustomizeNotifyIcons(HINSTANCE hInst, HWND hExplorer)
#define WARN(fmt,...)
Definition: debug.h:112
LRESULT OnNcLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2596
#define SIZE_RESTORED
Definition: winuser.h:2485
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
#define TNWM_GETMINIMUMSIZE
Definition: precomp.h:333
static HDC
Definition: imagelist.c:92
void ProcessAutoHide()
Definition: traywnd.cpp:1870
#define CALLBACK
Definition: compat.h:35
#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd)
Definition: atlwin.h:1935
CComPtr< IContextMenu > m_ContextMenu
Definition: traywnd.cpp:281
BOOL IsWindow() const
Definition: atlwin.h:882
#define ID_SHELL_CMD_SHOW_DESKTOP
Definition: resource.h:191
ush Pos
Definition: deflate.h:92
LRESULT OnNcLButtonDblClick(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2765
HWND hWnd
Definition: settings.c:17
DWORD IsDragging
Definition: traywnd.cpp:321
#define TIMER_ID_AUTOHIDE
Definition: traywnd.cpp:31
#define WM_QUIT
Definition: winuser.h:1610
BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
Definition: atlwin.h:1223
LONG top
Definition: windef.h:307
#define AUTOHIDE_DELAY_SHOW
Definition: traywnd.cpp:35
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
static HRGN hRgn
Definition: mapping.c:33
HFONT m_Font
Definition: traywnd.cpp:284
#define WM_EXITSIZEMOVE
Definition: winuser.h:1811
int DrawSizerWithTheme(IN HRGN hRgn)
Definition: traywnd.cpp:2007
IMenuPopup * CreateStartMenu(IN ITrayWindow *Tray, OUT IMenuBand **ppMenuBand, IN HBITMAP hbmBanner OPTIONAL, IN BOOL bSmallIcons)
Definition: startmnu.cpp:44
virtual HRESULT STDMETHODCALLTYPE GetTrayWindow(OUT HWND *phWndTray)
Definition: traywnd.cpp:3211
UINT cyWindowBorders
Definition: winuser.h:3753
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
LRESULT OnHotkey(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2827
#define ZeroMemory
Definition: winbase.h:1664
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GWL_EXSTYLE
Definition: winuser.h:845
#define SM_CXEDGE
Definition: winuser.h:1002
#define HWND_TOPMOST
Definition: winuser.h:1198
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:612
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
LRESULT OnExitSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2520
VOID RestoreAll()
Definition: traywnd.cpp:2901
#define IDHK_DESKTOP
Definition: traywnd.cpp:56
#define TRAYCMD_TILE_V
Definition: undocshell.h:693
LPWSTR dwTypeData
Definition: winuser.h:3249
static MONITORINFO mi
Definition: win.c:7338
DWORD GetDraggingRectFromPt(IN POINT pt, OUT RECT *pRect, OUT HMONITOR *phMonitor)
Definition: traywnd.cpp:1193
#define IDS_HELP_COMMAND
Definition: resource.h:102
#define ID_SHELL_CMD_CUST_NOTIF
Definition: resource.h:195
#define WM_NCHITTEST
Definition: winuser.h:1673
HMONITOR GetScreenRectFromRect(IN OUT RECT *pRect, IN DWORD dwFlags)
Definition: traywnd.cpp:966
#define TRAYCMD_RESTORE_ALL
Definition: undocshell.h:698
UINT_PTR WPARAM
Definition: windef.h:207
#define VK_TAB
Definition: winuser.h:2179
#define IDHK_MINIMIZE_ALL
Definition: traywnd.cpp:47
#define HTRIGHT
Definition: winuser.h:2469
#define WS_CHILD
Definition: pedump.c:617
#define VK_MENU
Definition: winuser.h:2184
#define AUTOHIDE_DELAY_HIDE
Definition: traywnd.cpp:34
#define TRAYCMD_TOGGLE_DESKTOP
Definition: undocshell.h:694
LONG left
Definition: windef.h:306
CComPtr< ITrayBandSite > m_TrayBandSite
Definition: traywnd.cpp:312
#define SWP_NOZORDER
Definition: winuser.h:1237
UINT uFlags
Definition: api.c:59
DWORD Flags
Definition: traywnd.cpp:316
void _Init()
Definition: traywnd.cpp:3251
DWORD m_Position
Definition: traywnd.cpp:293
static BOOL CALLBACK FindEffectiveProc(HWND hwnd, LPARAM lParam)
Definition: traywnd.cpp:71
char * LPSTR
Definition: xmlstorage.h:182
#define WS_CLIPCHILDREN
Definition: pedump.c:619
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define SW_RESTORE
Definition: winuser.h:773
HMONITOR CalculateValidSize(IN DWORD Position, IN OUT RECT *pRect)
Definition: traywnd.cpp:1136
#define SetWindowStyle(hwnd, val)
Definition: utility.h:153
#define IDS_START
Definition: resource.h:98
LONG right
Definition: windef.h:308
#define IDC_STARTBTN
Definition: resource.h:133
BOOL WINAPI IsIconic(_In_ HWND)
#define ABE_LEFT
Definition: shellapi.h:17
VOID CheckTrayWndPosition()
Definition: traywnd.cpp:1494
RECT rcMonitor
Definition: winuser.h:3765
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1329
#define TWM_GETTASKSWITCH
Definition: precomp.h:130
LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2328
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
#define IDHK_RUN
Definition: traywnd.cpp:46
static BOOL IsThereAnyEffectiveWindow(BOOL bMustBeInMonitor)
Definition: traywnd.cpp:111
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DWORD
Definition: nt_native.h:44
#define ID_SHELL_CMD_CASCADE_WND
Definition: resource.h:194
int32_t INT
Definition: typedefs.h:58
#define SWP_NOSENDCHANGING
Definition: winuser.h:1241
TW_STRUCKRECTS2 sr
Definition: precomp.h:209
LRESULT OnDoExitWindows(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2800
void appbar_notify_all(HMONITOR hMon, UINT uMsg, HWND hwndExclude, LPARAM lParam)
Definition: appbar.cpp:78
& rect
Definition: startmenu.cpp:1413
WPARAM wParam
Definition: combotst.c:138
HWND STDMETHODCALLTYPE DisplayProperties()
Definition: traywnd.cpp:520
HRESULT CStartMenuBtnCtxMenu_CreateInstance(ITrayWindow *TrayWnd, IN HWND hWndOwner, IContextMenu **ppCtxMenu)
LRESULT OnCtlColorBtn(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2381
#define TRAYCMD_SHOW_DESKTOP
Definition: undocshell.h:699
VOID OpenTaskManager(IN HWND hWndOwner)
Definition: traywnd.cpp:557
LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2810
#define WM_SETTINGCHANGE
Definition: winuser.h:1616
#define CCS_VERT
Definition: commctrl.h:2249
HMONITOR m_PreviousMonitor
Definition: traywnd.cpp:295
#define TRAYCMD_SHOW_TASK_MGR
Definition: undocshell.h:700
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
LRESULT OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2476
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
virtual ~CTrayWindow()
Definition: traywnd.cpp:352
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
HWND m_DesktopWnd
Definition: traywnd.cpp:286
DWORD Position
Definition: precomp.h:198
DWORD InSizeMove
Definition: traywnd.cpp:320
UINT code
Definition: winuser.h:3139
#define WM_NCPAINT
Definition: winuser.h:1674
HWND m_Rebar
Definition: traywnd.cpp:287
BOOL STDMETHODCALLTYPE IsSpecialHWND(IN HWND hWnd)
Definition: traywnd.cpp:2110
LRESULT appbar_message(COPYDATASTRUCT *cds)
Definition: appbar.cpp:229
LRESULT EraseBackgroundWithTheme(HDC hdc)
Definition: traywnd.cpp:1991
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
BOOL IsChild(const HWND hWnd) const
Definition: atlwin.h:849
#define TPM_RIGHTBUTTON
Definition: winuser.h:2360
HWND hwndFound
Definition: traywnd.cpp:63
#define SM_CXSCREEN
Definition: winuser.h:953
HWND m_TrayNotify
Definition: traywnd.cpp:289
ULONG_PTR dwData
Definition: winuser.h:2981
#define IDM_TRAYWND
Definition: resource.h:57
HRESULT CTrayNotifyWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv)
Definition: trayntfy.cpp:372
#define L(x)
Definition: ntvdm.h:50
LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2366
#define COLOR_3DFACE
Definition: winuser.h:923
LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:251
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
VOID DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar)
Definition: trayprop.cpp:291
#define WM_CTLCOLORBTN
Definition: winuser.h:1756
VOID MakeTrayRectWithSize(IN DWORD Position, IN const SIZE *pTraySize, IN OUT RECT *pRect)
Definition: traywnd.cpp:1085
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HWND hwndProgman
Definition: traywnd.cpp:65
#define FALSE
Definition: types.h:117
HRESULT Tray_OnStartMenuDismissed(ITrayWindow *Tray)
Definition: traywnd.cpp:3422
static const WCHAR szText[]
Definition: dialog.c:139
HWND Create(HWND hwndParent)
Definition: traywnd.cpp:221
GLenum const GLfloat * params
Definition: glext.h:5645
#define TWM_SETTINGSCHANGED
Definition: precomp.h:132
CSimpleArray< HWND > * pMinimizedAll
Definition: traywnd.cpp:2838
virtual HRESULT STDMETHODCALLTYPE InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
Definition: traywnd.cpp:3347
#define WC_STATIC
Definition: commctrl.h:4682
unsigned int BOOL
Definition: ntddk_ex.h:94
TRACKMOUSEEVENT m_MouseTrackingInfo
Definition: traywnd.cpp:307
#define WM_NCRBUTTONUP
Definition: winuser.h:1683
short SHORT
Definition: pedump.c:59
if SUCCEEDED(hr)
#define MDITILE_HORIZONTAL
Definition: winuser.h:2168
UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse, void(CALLBACK *lpfnTimer)(HWND, UINT, UINT_PTR, DWORD)=NULL)
Definition: atlwin.h:1193
#define TRAYCMD_DATE_AND_TIME
Definition: undocshell.h:695
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
virtual ~CStartButton()
Definition: traywnd.cpp:155
#define CWP_SKIPINVISIBLE
Definition: winuser.h:208
void ProcessMouseTracking()
Definition: traywnd.cpp:1820
#define SM_CYDLGFRAME
Definition: winuser.h:962
BOOL STDMETHODCALLTYPE Lock(IN BOOL bLock)
Definition: traywnd.cpp:2121
#define TPM_TOPALIGN
Definition: winuser.h:2363
#define ShellExecute
Definition: shellapi.h:691
void UpdateFonts()
Definition: traywnd.cpp:935
#define MOUSETRACK_INTERVAL
Definition: traywnd.cpp:33
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:507
#define TABDMC_NOTIFY
Definition: undocshell.h:714
static BOOL CALLBACK MinimizeWindowsProc(HWND hwnd, LPARAM lParam)
Definition: traywnd.cpp:2849
#define CWP_SKIPDISABLED
Definition: winuser.h:209
#define WM_SYSCHAR
Definition: winuser.h:1708
#define SS_LEFT
Definition: pedump.c:692
DWORD AutoHide
Definition: precomp.h:192
HRESULT STDMETHODCALLTYPE Open()
Definition: traywnd.cpp:2055
HRESULT WINAPI SetWindowTheme(_In_ HWND hwnd, _In_ LPCWSTR pszSubAppName, _In_ LPCWSTR pszSubIdList)
Definition: uxthemesupp.c:69
CSimpleArray< HWND > g_MinimizedAll
Definition: traywnd.cpp:131
#define CreateWindowEx
Definition: winuser.h:5735
#define SC_MAXIMIZE
Definition: winuser.h:2568
#define TRANSPARENT
Definition: wingdi.h:950
BOOL KillTimer(UINT_PTR nIDEvent)
Definition: atlwin.h:911
#define S_FALSE
Definition: winerror.h:2357
BOOL WINAPI SHFindFiles(PCIDLIST_ABSOLUTE pidlFolder, PCIDLIST_ABSOLUTE pidlSaveFile)
Definition: shellord.c:2234
BOOL GetWindowRect(LPRECT lpRect) const
Definition: atlwin.h:764
VOID TrayProcessMessages(ITrayWindow *Tray)
Definition: traywnd.cpp:3428
#define VK_SHIFT
Definition: winuser.h:2182
#define WM_SIZING
Definition: winuser.h:1794
#define E_INVALIDARG
Definition: ddrawi.h:101
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
#define TPM_BOTTOMALIGN
Definition: winuser.h:2365
CComPtr< IDeskBand > m_TaskBand
Definition: traywnd.cpp:280
VOID OpenCommonStartMenuDirectory(IN HWND hWndOwner, IN LPCTSTR lpOperation)
Definition: traywnd.cpp:539
#define TRAYCMD_SEARCH_FILES
Definition: undocshell.h:709
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
static HWND hwndParent
Definition: cryptui.c:300
#define SM_CYSIZEFRAME
Definition: winuser.h:989
HWND hwndDesktop
Definition: traywnd.cpp:64
#define ABE_RIGHT
Definition: shellapi.h:19
LONG cx
Definition: windef.h:334
#define TRAYCMD_MINIMIZE_ALL
Definition: undocshell.h:697
HRESULT CreateTrayWindow(ITrayWindow **ppTray)
Definition: traywnd.cpp:3407
LONG_PTR LPARAM
Definition: windef.h:208
#define SM_CYEDGE
Definition: winuser.h:1003
HWND m_TrayPropertiesOwner
Definition: traywnd.cpp:302
RECT m_TrayRects[4]
Definition: traywnd.cpp:299
#define TWM_OPENSTARTMENU
Definition: precomp.h:131
#define IDHK_HELP
Definition: traywnd.cpp:49
#define ID_SHELL_CMD_EXPLORE_ALL_USERS
Definition: resource.h:187
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2033
DWORD WINAPI RunFileDlgThread()
Definition: traywnd.cpp:425
#define TRAYCMD_PRINTERS_AND_FAXES
Definition: undocshell.h:706
PWINDOWPOS lppos
Definition: winuser.h:3579
HRESULT ExecResourceCmd(int id)
Definition: traywnd.cpp:383
UINT flags
Definition: winuser.h:3574
#define TIMER_ID_MOUSETRACK
Definition: traywnd.cpp:32
const char * LPCSTR
Definition: xmlstorage.h:183
RECT rcWindow
Definition: winuser.h:3747
BOOL IsPosHorizontal()
Definition: traywnd.cpp:1131
DWORD AlwaysOnTop
Definition: precomp.h:193
void WINAPI RunFileDlg(HWND hWndOwner, HICON hIcon, LPCWSTR lpstrDirectory, LPCWSTR lpstrTitle, LPCWSTR lpstrDescription, UINT uFlags)
Definition: dialogs.cpp:411
#define IDM_SEARCH
Definition: resource.h:71
#define TRAYCMD_SEARCH_COMPUTERS
Definition: undocshell.h:710
CStartButton m_StartButton
Definition: traywnd.cpp:275
LRESULT OnRebarAutoSize(INT code, LPNMHDR nmhdr, BOOL &bHandled)
Definition: traywnd.cpp:3002
virtual ~CTrayWindowCtxMenu()
Definition: traywnd.cpp:3390
#define PtrToUlong(u)
Definition: config.h:107
#define GetMonitorInfo
Definition: winuser.h:5771
virtual HRESULT RaiseStartButton()
Definition: traywnd.cpp:3232
#define TRAYCMD_CUSTOMIZE_TASKBAR
Definition: undocshell.h:701
#define MIIM_ID
Definition: winuser.h:717
SHORT WINAPI GetKeyState(_In_ int)
#define SM_CXSIZEFRAME
Definition: winuser.h:987
#define MF_CHECKED
Definition: winuser.h:132
UINT m_AutoHideState
Definition: traywnd.cpp:305
#define TB_GETBUTTONSIZE
Definition: commctrl.h:1160
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:542
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
#define WM_COPYDATA
Definition: winuser.h:1651
#define SM_CYSCREEN
Definition: winuser.h:954
LRESULT OnSettingChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2314
virtual ULONG STDMETHODCALLTYPE GetState()
Definition: traywnd.cpp:3204
#define HWND_BOTTOM
Definition: winuser.h:1195
int SetWindowRgn(HRGN hRgn, BOOL bRedraw=FALSE)
Definition: atlwin.h:1229
#define TRACE(s)
Definition: solgame.cpp:4
virtual HRESULT STDMETHODCALLTYPE RegisterDesktopWindow(IN HWND hWndDesktop)
Definition: traywnd.cpp:3218
#define NTNWM_REALIGN
Definition: precomp.h:336
DWORD m_DraggingPosition
Definition: traywnd.cpp:296
GLsizeiptr size
Definition: glext.h:5919
HTHEME m_Theme
Definition: traywnd.cpp:282
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define WS_OVERLAPPED
Definition: pedump.c:615
CComPtr< IMenuBand > m_StartMenuBand
Definition: traywnd.cpp:277
BOOL bMustBeInMonitor
Definition: traywnd.cpp:67
#define SM_CYCAPTION
Definition: winuser.h:957
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2940
#define ASSERT(a)
Definition: mode.c:44
#define MDITILE_SKIPDISABLED
Definition: winuser.h:2167
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)
void WINAPI ExitWindowsDialog(HWND hWndOwner)
Definition: dialogs.cpp:1617
#define MM_ADDSEPARATOR
Definition: shlobj.h:2345
#define WM_SIZE
Definition: winuser.h:1598
HMONITOR m_DraggingMonitor
Definition: traywnd.cpp:297
LONG HRESULT
Definition: typedefs.h:79
#define MDITILE_VERTICAL
Definition: winuser.h:2169
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
#define SM_CXDLGFRAME
Definition: winuser.h:960
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define END_MSG_MAP()
Definition: atlwin.h:1848
HINSTANCE hExplorerInstance
Definition: explorer.cpp:24
#define BST_PUSHED
Definition: winuser.h:201
#define _countof(array)
Definition: sndvol32.h:68
#define WM_TIMER
Definition: winuser.h:1729
#define TRAYCMD_TASKBAR_PROPERTIES
Definition: undocshell.h:696
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1648
#define MF_ENABLED
Definition: winuser.h:128
HDC GetWindowDC()
Definition: atlwin.h:732
VOID ToggleDesktop()
Definition: traywnd.cpp:567
#define WM_CLOSE
Definition: winuser.h:1608
#define HOLLOW_BRUSH
Definition: wingdi.h:899
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnRebarAutoSize) VOID TrayProcessMessages()
Definition: traywnd.cpp:3111
const GUID IID_IShellDesktopTray
Definition: traywnd.cpp:137
#define MAX_PATH
Definition: compat.h:34
#define WINAPI
Definition: msvc.h:6
#define WM_KEYUP
Definition: winuser.h:1703
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
int WINAPI GetSystemMetrics(_In_ int)
virtual HRESULT STDMETHODCALLTYPE GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
Definition: traywnd.cpp:3377
#define HTBOTTOM
Definition: winuser.h:2473
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT CTrayBandSite_CreateInstance(IN ITrayWindow *tray, IN IDeskBand *pTaskBand, OUT ITrayBandSite **pBandSite)
Definition: tbsite.cpp:715
VOID UpdateFont()
Definition: traywnd.cpp:185
DWORD GetDraggingRectFromRect(IN OUT RECT *pRect, OUT HMONITOR *phMonitor)
Definition: traywnd.cpp:1295
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HDPA m_ShellServices
Definition: traywnd.cpp:309
#define SetLastError(x)
Definition: compat.h:611
#define TABDMC_APPBAR
Definition: undocshell.h:713
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
struct tagNMRBAUTOSIZE * LPNMRBAUTOSIZE
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
HFONT m_Font
Definition: traywnd.cpp:144
#define SW_MINIMIZE
Definition: winuser.h:770
VOID RegLoadSettings()
Definition: traywnd.cpp:1515
UINT cchMax
LRESULT DoExitWindows()
Definition: traywnd.cpp:407
struct _test_info info[]
Definition: SetCursorPos.c:19
#define SM_CYBORDER
Definition: winuser.h:959
LRESULT OnSysChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2533
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define BUTTON_IMAGELIST_ALIGN_LEFT
Definition: commctrl.h:4627
LRESULT OnSizing(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2461
BOOL GetEnvironmentVariable(_In_z_ PCXSTR pszVar)
Definition: cstringt.h:610
#define WM_MOVING
Definition: winuser.h:1796
HDC hdc
Definition: main.c:9
HRESULT InitShellServices(HDPA *phdpa)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define MIIM_TYPE
Definition: winuser.h:720
#define LR_LOADTRANSPARENT
Definition: winuser.h:1087
static int state
Definition: maze.c:121
LONG GetWindowLong(int nIndex) const
Definition: atlwin.h:738
#define SM_CXBORDER
Definition: winuser.h:958
#define SWP_FRAMECHANGED
Definition: winuser.h:1230
#define WS_EX_TOPMOST
Definition: pedump.c:647
HWND m_hWnd
Definition: atlwin.h:268
CComPtr< IMenuPopup > m_StartMenuPopup
Definition: traywnd.cpp:278
VOID ApplyClipping(IN BOOL Clip)
Definition: traywnd.cpp:1405
#define CS_DBLCLKS
Definition: winuser.h:646
VOID ChangingWinPos(IN OUT LPWINDOWPOS pwp)
Definition: traywnd.cpp:1313
#define WM_COMMAND
Definition: winuser.h:1727
LRESULT OnOpenStartMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2781
BOOL DestroyWindow()
Definition: atlwin.h:428
UINT TrackMenu(IN HMENU hMenu, IN POINT *ppt OPTIONAL, IN HWND hwndExclude OPTIONAL, IN BOOL TrackUp, IN BOOL IsContextMenu)
Definition: traywnd.cpp:784
Definition: inflate.c:139
HWND hwndFrom
Definition: winuser.h:3137
LRESULT OnInitMenuPopup(INT code, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2984
#define MF_UNCHECKED
Definition: winuser.h:204
#define BST_UNCHECKED
Definition: winuser.h:199
#define BS_VCENTER
Definition: winuser.h:279
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define AUTOHIDE_HIDING
Definition: traywnd.cpp:44
static RECT margins
Definition: print.c:55
#define ID_SHELL_CMD_OPEN_ALL_USERS
Definition: resource.h:186
#define BS_PUSHBUTTON
Definition: pedump.c:651
struct tagWINDOWINFO WINDOWINFO
BOOL IsIconic() const
Definition: atlwin.h:867
#define TRAYCMD_TILE_H
Definition: undocshell.h:692
BOOL WINAPI DestroyMenu(_In_ HMENU)
int ReleaseDC(HDC hDC)
Definition: atlwin.h:1009
#define RBSTR_CHANGERECT
Definition: commctrl.h:1596
LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2663
#define IDHK_EXPLORE
Definition: traywnd.cpp:50
#define ID_SHELL_CMD_TILE_WND_H
Definition: resource.h:193
#define SC_MINIMIZE
Definition: winuser.h:2566
#define SWP_NOSIZE
Definition: winuser.h:1235
#define ERR(fmt,...)
Definition: debug.h:110
#define HTCAPTION
Definition: winuser.h:2456
#define TRAYCMD_RUN_DIALOG
Definition: undocshell.h:689
static DWORD WINAPI s_RunFileDlgThread(IN OUT PVOID pParam)
Definition: traywnd.cpp:461
void DisplayRunFileDlg()
Definition: traywnd.cpp:467
#define GWL_STYLE
Definition: winuser.h:846
#define ABE_BOTTOM
Definition: shellapi.h:20
#define AUTOHIDE_SHOWING
Definition: traywnd.cpp:42
VOID AdjustSizerRect(RECT *rc, DWORD pos)
Definition: traywnd.cpp:1056
#define RFF_CALCDIRECTORY
Definition: run.h:48
HMENU LoadPopupMenu(IN HINSTANCE hInstance, IN LPCWSTR lpMenuName)
Definition: util.cpp:33
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2215
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define UINT_MAX
Definition: limits.h:41
HWND ChildWindowFromPoint(POINT point) const
Definition: atlwin.h:347
#define TSWM_UPDATETASKBARPOS
Definition: precomp.h:347
#define S_OK
Definition: intsafe.h:52
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define AUTOHIDE_SPEED_HIDE
Definition: traywnd.cpp:39
HMENU GetSystemMenu(BOOL bRevert)
Definition: atlwin.h:684
#define TEXT(s)
Definition: k32.h:26
#define WS_BORDER
Definition: pedump.c:625
BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO)
#define FW_BOLD
Definition: wingdi.h:378
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
HRESULT Initialize(ITrayWindow *pTrayWnd, IN HWND hWndOwner)
Definition: traywnd.cpp:3278
BOOL ShowWindow(int nCmdShow)
Definition: atlwin.h:1268
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
VOID MinimizeAll(BOOL bShowDesktop=FALSE)
Definition: traywnd.cpp:2874
BOOL PostMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:979
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
HMONITOR m_Monitor
Definition: traywnd.cpp:294
#define SHGetSpecialFolderPath
Definition: shlobj.h:1456
#define MOD_CONTROL
Definition: imm.h:323
LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2914
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2132
VOID ResizeWorkArea()
Definition: traywnd.cpp:1442
#define TRAYCMD_SWITCH_USER_DIALOG
Definition: undocshell.h:708
DWORD cbSize
Definition: winuser.h:3764
#define IDB_START
Definition: resource.h:75
#define MOD_SHIFT
Definition: imm.h:324
LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2387
#define SC_SIZE
Definition: winuser.h:2564
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:562
#define TRAYCMD_STARTMENU
Definition: undocshell.h:688
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
VOID AlignControls(IN PRECT prcClient OPTIONAL)
Definition: traywnd.cpp:1593
#define E_NOTIMPL
Definition: ddrawi.h:99
#define LR_CREATEDIBSECTION
Definition: winuser.h:1092
VOID ShowDesktop()
Definition: traywnd.cpp:2896
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
WORD WINAPI CascadeWindows(_In_opt_ HWND hwndParent, _In_ UINT wHow, _In_opt_ CONST RECT *lpRect, _In_ UINT cKids, _In_reads_opt_(cKids) const HWND FAR *lpKids)
#define HTBORDER
Definition: winuser.h:2477
#define TRAYCMD_LOCK_DESKTOP
Definition: undocshell.h:707
#define ID_LOCKTASKBAR
Definition: resource.h:188
#define TRAYCMD_LOCK_TASKBAR
Definition: undocshell.h:702
#define WS_POPUP
Definition: pedump.c:616
HWND m_TaskSwitch
Definition: traywnd.cpp:288
#define CreateFontIndirect
Definition: wingdi.h:4444
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1762
#define TABDMC_LOADINPROC
Definition: undocshell.h:715
#define NULL
Definition: types.h:112
#define VK_SPACE
Definition: winuser.h:2199
#define SPIF_SENDCHANGE
Definition: winuser.h:1559
virtual HRESULT STDMETHODCALLTYPE QueryContextMenu(HMENU hPopup, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
Definition: traywnd.cpp:3287
LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2482
#define GW_OWNER
Definition: winuser.h:761
LRESULT OnTaskbarSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:3053
#define IMAGE_BITMAP
Definition: winuser.h:211
#define GetMessage
Definition: winuser.h:5770
#define SWP_SHOWWINDOW
Definition: winuser.h:1238
#define IDHK_FIND
Definition: traywnd.cpp:51
#define WM_APP_TRAYDESTROY
Definition: traywnd.cpp:29
LRESULT OnNcRButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: traywnd.cpp:2653
HRESULT STDMETHODCALLTYPE Close()
Definition: traywnd.cpp:2092
HMONITOR GetScreenRect(IN HMONITOR hMonitor, IN OUT RECT *pRect)
Definition: traywnd.cpp:1018
SIZE m_AutoHideOffset
Definition: traywnd.cpp:306
#define IDB_STARTMENU
Definition: resource.h:44
#define VK_F1
Definition: winuser.h:2235
#define WM_SETFONT
Definition: winuser.h:1637
CComPtr< IUnknown > m_TrayNotifyInstance
Definition: traywnd.cpp:291
#define BEGIN_MSG_MAP(theClass)
Definition: atlwin.h:1829
#define FW_NORMAL
Definition: wingdi.h:373
#define VK_CONTROL
Definition: winuser.h:2183
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
#define TRAYCMD_SHUTDOWN_DIALOG
Definition: undocshell.h:705
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define DECLARE_PROTECT_FINAL_CONSTRUCT()
Definition: atlcom.h:640
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
HIMAGELIST WINAPI ImageList_LoadImageW(HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow, COLORREF clrMask, UINT uType, UINT uFlags)
Definition: imagelist.c:2208
#define MESSAGE_HANDLER(msg, func)
Definition: atlwin.h:1857
#define ALT_MSG_MAP(map)
Definition: atlwin.h:1844
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
BOOL STDMETHODCALLTYPE IsHorizontal()
Definition: traywnd.cpp:2116
#define TRAYCMD_LOGOFF_DIALOG
Definition: undocshell.h:690
#define SC_MOVE
Definition: winuser.h:2565
#define SC_CLOSE
Definition: winuser.h:2572
HRESULT WINAPI GetWindow(HWND *phwnd)
Definition: traywnd.cpp:3238
#define MM_SUBMENUSHAVEIDS
Definition: shlobj.h:2346
#define VK_PAUSE
Definition: winuser.h:2185