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