266 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
271 inline _Success_(
return != 0) bool DockAppBar(_In_
wxAppBarState state);
272 inline _Success_(return != 0)
bool UndockAppBar();
273 inline _Success_(return != 0)
bool RegisterAutoHide(_In_
wxAppBarState state);
274 inline _Success_(return != 0)
bool UnregisterAutoHide(_In_
wxAppBarState state);
275 inline _Success_(return != 0)
bool GetDockedRect(_In_
wxAppBarState state, _Out_ LPRECT rect) const;
276 inline _Success_(return != 0)
bool GetAutoHideRect(_In_
wxAppBarState state, _In_
bool bAutoHidden, _Out_ LPRECT rect) const;
297#pragma warning (push)
298#pragma warning (disable:4275)
317 const wxString& title,
320 const wxPoint& pos = wxDefaultPosition,
321 const wxSize& size = wxDefaultSize,
322 long style = wxDEFAULT_FRAME_STYLE,
323 const wxString& name = wxFrameNameStr);
328 bool Create(wxWindow *parent,
330 const wxString& title,
333 const wxPoint& pos = wxDefaultPosition,
334 const wxSize& size = wxDefaultSize,
335 long style = wxDEFAULT_FRAME_STYLE,
336 const wxString& name = wxFrameNameStr);
356 const wxString& title,
359 const wxPoint& pos = wxDefaultPosition,
360 const wxSize& size = wxDefaultSize,
361 long style = wxDEFAULT_DIALOG_STYLE,
362 const wxString& name = wxDialogNameStr);
367 bool Create(wxWindow *parent,
369 const wxString& title,
372 const wxPoint& pos = wxDefaultPosition,
373 const wxSize& size = wxDefaultSize,
374 long style = wxDEFAULT_DIALOG_STYLE,
375 const wxString& name = wxDialogNameStr);
441 return HWND_NOTOPMOST;
461 WXHWND hWndTaskbar = ::FindWindow(_T(
"Shell_TrayWnd"), _T(
""));
474 return HWND_NOTOPMOST;
477 wxFAIL_MSG(wxT(
"unknown application bar state"));
493 APPBARDATA abd = {
sizeof(abd) };
494 return ::SHAppBarMessage(ABM_GETSTATE, &abd);
526 m_taskbarList->Release();
534 wxASSERT_MSG(!m_taskbarList || !m_timerID, wxT(
"application bar is already initialized"));
537 m_sizeFloat.cx = size.x;
538 m_sizeFloat.cy = size.y;
541 m_sizeDocked.cx = size.x;
542 m_sizeDocked.cy = size.y;
546 m_stateDesired = wxAppBarState::UNKNOWN;
553 style |= wxFRAME_TOOL_WINDOW;
556 style &= ~wxFRAME_TOOL_WINDOW;
561 style |= wxFRAME_TOOL_WINDOW;
564 style &= ~wxFRAME_TOOL_WINDOW;
568 wxFAIL_MSG(wxT(
"unknown application bar state"));
572 HRESULT hr = ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList, (LPVOID*)&m_taskbarList);
574 hr = m_taskbarList->HrInit();
576 wxFAIL_MSG(wxString::Format(wxT(
"ITaskbarList::HrInit() failed 0x%x"), hr));
577 m_taskbarList->Release();
578 m_taskbarList = NULL;
581 wxFAIL_MSG(wxString::Format(wxT(
"TaskbarList creation failed 0x%x"), hr));
589 return m_stateDesired != wxAppBarState::UNKNOWN ? m_stateDesired : m_state;
606 m_flags &= ~wxABF_ALWAYSONTOP;
608 if (::IsWindowVisible(m_hWnd)) {
610 wxCHECK(::SetWindowPos(m_hWnd,
wxAppBarGetZWnd(m_state, m_flags), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOSENDCHANGING),
false);
627 bool autoHidePrev = IsAutoHide();
632 m_flags &= ~wxABF_AUTOHIDE;
634 if (autoHidePrev != autoHide &&
wxAppBarIsDocked(m_state) && ::IsWindowVisible(m_hWnd)) {
642 if (!RegisterAutoHide(m_state)) {
649 UnregisterAutoHide(m_state);
671 m_flags &= ~wxABF_ALLOWSIZING;
773 hWnd = wnd->GetHWND();
776 if (hWnd == m_hWnd && !::IsWindowVisible(m_hWnd))
782 wxVERIFY(::GetWindowRect(hWnd, &rect));
783 m_sizeFloat.cx = rect.right - rect.left;
784 m_sizeFloat.cy = rect.bottom - rect.top;
789 GetAutoHideRect(edge,
false, &rectTo);
791 GetDockedRect(edge, &rectTo);
796 wxVERIFY(::GetWindowRect(hWnd, &rectFrom));
797 wxVERIFY(::DrawAnimatedRects(hWnd, IDANI_CAPTION, &rectFrom, &rectTo));
804 if (hWnd != m_hWnd) {
814 RegisterAutoHide(edge);
821 ::SetActiveWindow(m_hWnd);
828 wxASSERT(::IsWindowVisible(m_hWnd));
834 rectTo.left = (::GetSystemMetrics(SM_CXSCREEN) - m_sizeFloat.cx) / 2;
835 rectTo.top = (::GetSystemMetrics(SM_CYSCREEN) - m_sizeFloat.cy) / 2;
836 rectTo.right = rectTo.left + m_sizeFloat.cx;
837 rectTo.bottom = rectTo.top + m_sizeFloat.cy;
841 m_sizeFloat.cx = rect->right - rect->left;
842 m_sizeFloat.cy = rect->bottom - rect->top;
848 wxVERIFY(::GetWindowRect(m_hWnd, &rectFrom));
849 wxVERIFY(::DrawAnimatedRects(m_hWnd, IDANI_CAPTION, &rectFrom, rect));
855 UnregisterAutoHide(m_state);
872 wxASSERT(::IsWindowVisible(m_hWnd));
874 WXHWND hWnd = wnd->GetHWND();
877 wxVERIFY(::GetWindowRect(hWnd, &rectTo));
878 m_sizeFloat.cx = rectTo.right - rectTo.left;
879 m_sizeFloat.cy = rectTo.bottom - rectTo.top;
884 wxVERIFY(::GetWindowRect(m_hWnd, &rectFrom));
885 wxVERIFY(::DrawAnimatedRects(hWnd, IDANI_CAPTION, &rectFrom, &rectTo));
892 wxVERIFY(::SetForegroundWindow(hWnd));
893 ::SetActiveWindow(hWnd);
904 bHidden = GetAutoHidden(),
905 bVisible = ::IsWindowVisible(m_hWnd) ? true :
false;
907 if (!IsAutoHide() || bHidden != show) {
913 GetAutoHideRect(m_state, !bHidden, &rcEnd);
919 if (!::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &bFullDragOn, 0))
923 GetAutoHideRect(m_state, bHidden, &rcStart);
925 if (bFullDragOn && (rcStart.left != rcEnd.left || rcStart.top != rcEnd.top || rcStart.right != rcEnd.right || rcStart.bottom != rcEnd.bottom)) {
926 #pragma warning(push)
927 #pragma warning(disable: 28159)
930 DWORD dwTimeStart = ::GetTickCount();
935 rcDelta.left = rcEnd.left - rcStart.left;
936 rcDelta.top = rcEnd.top - rcStart.top;
937 rcDelta.right = rcEnd.right - rcStart.right;
938 rcDelta.bottom = rcEnd.bottom - rcStart.bottom;
945 rect.right = rcStart.right + ::MulDiv(rcDelta.right, dwTimeElapsed,
wxABT_AUTOHIDETIME);
946 rect.bottom = rcStart.bottom + ::MulDiv(rcDelta.bottom, dwTimeElapsed,
wxABT_AUTOHIDETIME);
949 wxVERIFY(::SetWindowPos(m_hWnd, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE));
958 m_flags &= ~wxABF_AUTOHIDDEN;
963 wxVERIFY(::SetWindowPos(m_hWnd, NULL, rcEnd.left, rcEnd.top, rcEnd.right - rcEnd.left, rcEnd.bottom - rcEnd.top, SWP_NOZORDER | SWP_NOACTIVATE));
979 wxVERIFY(SUCCEEDED(m_taskbarList->DeleteTab(m_hWnd)));
984 wxVERIFY(SUCCEEDED(m_taskbarList->AddTab(m_hWnd)));
991 wxVERIFY(SUCCEEDED(m_taskbarList->DeleteTab(m_hWnd)));
996 wxVERIFY(SUCCEEDED(m_taskbarList->AddTab(m_hWnd)));
1000 wxFAIL_MSG(wxT(
"unknown application bar state"));
1008 if (state != m_stateTaskBar) {
1014 (m_stateTaskBar & ABS_ALWAYSONTOP) != (state & ABS_ALWAYSONTOP)) {
1016 SetAlwaysOnTop((state & ABS_ALWAYSONTOP) ?
true :
false);
1020 (m_stateTaskBar & ABS_AUTOHIDE) != (state & ABS_AUTOHIDE)) {
1022 SetAutoHide((state & ABS_AUTOHIDE) ?
true :
false);
1026 m_stateTaskBar = state;
1039 wxMessageBox(_(
"There is already an auto hidden bar on this edge.\nOnly one auto hidden bar is allowed on each edge.\nAuto-hide feature is now off."), _(
"Warning"), wxOK | wxICON_WARNING,
this);
1049 WXLRESULT lResult = W::MSWWindowProc(message, wParam, lParam);
1052 APPBARDATA abd = {
sizeof(abd), m_hWnd,
WM_AB_NOTIFY,
static_cast<UINT
>(m_state) };
1053 wxCHECK(::SHAppBarMessage(ABM_NEW, &abd),
false);
1060 SetAutoHide((m_stateTaskBar & ABS_AUTOHIDE) ?
true : false);
1065 SetAlwaysOnTop((m_stateTaskBar & ABS_ALWAYSONTOP) ?
true : false);
1072 wxASSERT_MSG(m_timerID == 0, wxT(
"timer still active"));
1075 APPBARDATA abd = {
sizeof(abd), m_hWnd };
1076 wxVERIFY(::SHAppBarMessage(ABM_REMOVE, &abd));
1078 return W::MSWWindowProc(message, wParam, lParam);
1084 OnChangeState(m_state);
1089 RegisterAutoHide(m_state);
1092 DockAppBar(m_state);
1097 return W::MSWWindowProc(message, wParam, lParam);
1100 WXLRESULT lResult = W::MSWWindowProc(message, wParam, lParam);
1105 UnregisterAutoHide(m_state);
1113 case WM_WINDOWPOSCHANGING: {
1116 LPWINDOWPOS lpwndpos = (LPWINDOWPOS)lParam;
1120 GetDockedRect(m_stateDesired, &rect);
1121 lpwndpos->x = rect.left;
1122 lpwndpos->y = rect.top;
1123 lpwndpos->cx = rect.right - rect.left;
1124 lpwndpos->cy = rect.bottom - rect.top;
1125 lpwndpos->flags &= ~(SWP_NOMOVE | SWP_NOSIZE);
1129 return W::MSWWindowProc(message, wParam, lParam);
1132 case WM_WINDOWPOSCHANGED: {
1133 WXLRESULT lResult = W::MSWWindowProc(message, wParam, lParam);
1139 APPBARDATA abd = {
sizeof(abd), m_hWnd };
1140 wxVERIFY(::SHAppBarMessage(ABM_WINDOWPOSCHANGED, &abd));
1146 case WM_ENTERSIZEMOVE:
1147 m_stateDesired = m_state;
1148 return W::MSWWindowProc(message, wParam, lParam);
1150 case WM_EXITSIZEMOVE: {
1151 WXLRESULT lResult = W::MSWWindowProc(message, wParam, lParam);
1158 UnregisterAutoHide(m_state);
1168 RegisterAutoHide(m_stateDesired);
1171 DockAppBar(m_stateDesired);
1176 OnChangeState(m_stateDesired);
1177 m_state = m_stateDesired;
1178 m_stateDesired = wxAppBarState::UNKNOWN;
1184 WXLRESULT lResult = W::MSWWindowProc(message, wParam, lParam);
1187 LPRECT lpRect = (LPRECT)lParam;
1192 DWORD dwPoint = ::GetMessagePos();
1193 wxPoint ptMouse(GET_X_LPARAM(dwPoint), GET_Y_LPARAM(dwPoint));
1195 m_stateDesired = wxAppBarState::UNKNOWN;
1201 RECT rcWorkArea = {};
1202 INT iDist, iDistMin = INT_MAX;
1206 wxVERIFY(::SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0));
1209 if ((m_flags &
wxABF_ALLOWDOCKTOP) && (iDist = ptMouse.y - rcWorkArea.top) < iDistMin) {
1217 if ((m_flags &
wxABF_ALLOWDOCKLEFT) && (iDist = ptMouse.x - rcWorkArea.left) < iDistMin) {
1225 if ((m_flags &
wxABF_ALLOWFLOAT) && (iDist = wxMax(::GetSystemMetrics(SM_CXVSCROLL), ::GetSystemMetrics(SM_CYHSCROLL))) < iDistMin) {
1231 wxASSERT_MSG(m_stateDesired != wxAppBarState::UNKNOWN, wxT(
"undetermined application bar state"));
1238 lpRect->left = ptMouse.x - m_sizeFloat.cx / 2;
1239 lpRect->top = ptMouse.y;
1242 lpRect->right = lpRect->left + m_sizeFloat.cx;
1243 lpRect->bottom = lpRect->top + m_sizeFloat.cy;
1248 GetAutoHideRect(m_stateDesired,
false, lpRect);
1251 GetDockedRect(m_stateDesired, lpRect);
1255 wxFAIL_MSG(wxT(
"unknown application bar state"));
1258 if (m_stateDesired != uStateDesiredPrev) {
1260 OnChangeState(m_stateDesired);
1268 LPRECT lpRect = (LPRECT)lParam;
1272 m_sizeFloat.cx = lpRect->right - lpRect->left;
1273 m_sizeFloat.cy = lpRect->bottom - lpRect->top;
1277 m_sizeDocked.cx = lpRect->right - lpRect->left;
1279 m_sizeDocked.cy = lpRect->bottom - lpRect->top;
1282 wxFAIL_MSG(wxT(
"unknown application bar state"));
1285 return W::MSWWindowProc(message, wParam, lParam);
1288 case WM_GETMINMAXINFO: {
1289 WXLRESULT lResult = W::MSWWindowProc(message, wParam, lParam);
1292 LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
1295 RECT rectClient = {};
1296 wxVERIFY(::GetClientRect(m_hWnd, &rectClient));
1297 if (rectClient.right - rectClient.left && rectClient.bottom - rectClient.top) {
1298 RECT rectWindow = {};
1299 wxVERIFY(::GetWindowRect(m_hWnd, &rectWindow));
1300 lpMMI->ptMinTrackSize.x = m_sizeMin.cx + (rectWindow.right - rectWindow.left) - (rectClient.right - rectClient.left);
1301 lpMMI->ptMinTrackSize.y = m_sizeMin.cy + (rectWindow.bottom - rectWindow.top ) - (rectClient.bottom - rectClient.top );
1307 case WM_NCMOUSEMOVE:
1310 ShowAutoHideAppBar(
true);
1312 return W::MSWWindowProc(message, wParam, lParam);
1314 case WM_NCHITTEST: {
1316 WXLRESULT lResult = W::MSWWindowProc(message, wParam, lParam);
1318 if (HTSIZEFIRST <= lResult && lResult <= HTSIZELAST) {
1319 if (GetAllowSizing()) {
1326 wxPoint point(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
1330 wxVERIFY(::GetClientRect(m_hWnd, &rcClient));
1331 wxVERIFY(::ClientToScreen(m_hWnd, (LPPOINT)&rcClient));
1332 wxVERIFY(::ClientToScreen(m_hWnd, ((LPPOINT)&rcClient) + 1));
1354 WXLRESULT lResult = W::MSWWindowProc(message, wParam, lParam);
1360 APPBARDATA abd = {
sizeof(abd), m_hWnd };
1361 wxVERIFY(::SHAppBarMessage(ABM_ACTIVATE, &abd));
1363 if (LOWORD(wParam) == WA_INACTIVE && IsAutoHide()) {
1365 ShowAutoHideAppBar(
false);
1374 if (!GetAutoHidden() &&
1376 GetActiveWindow() != m_hWnd)
1380 DWORD dwPoint = ::GetMessagePos();
1381 wxPoint pointMouse(GET_X_LPARAM(dwPoint), GET_Y_LPARAM(dwPoint));
1383 wxVERIFY(::GetWindowRect(m_hWnd, &rect));
1384 wxRect rectBounds(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
1387 rectBounds.Inflate(2 * ::GetSystemMetrics(SM_CXDOUBLECLK), 2 * ::GetSystemMetrics(SM_CYDOUBLECLK));
1388 if (!rectBounds.Contains(pointMouse)) {
1390 ShowAutoHideAppBar(
false);
1396 return W::MSWWindowProc(message, wParam, lParam);
1400 case ABN_FULLSCREENAPP:
1404 m_flags &= ~wxABF_FULLSCREENAPPOPEN;
1407 if (::IsWindowVisible(m_hWnd)) {
1409 wxVERIFY(::SetWindowPos(m_hWnd,
wxAppBarGetZWnd(m_state, m_flags), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOSENDCHANGING));
1413 case ABN_POSCHANGED:
1415 DockAppBar(m_state);
1418 case ABN_STATECHANGE:
1423 case ABN_WINDOWARRANGE:
1424 OnWindowsArrange(lParam ?
true : false);
1429 wxFAIL_MSG(wxString::Format(wxT(
"unknown application bar notification 0x%x"), wParam));
1436 return W::MSWWindowProc(message, wParam, lParam);
1445_Use_decl_annotations_
1451 APPBARDATA abd = {
sizeof(abd), m_hWnd, 0,
static_cast<UINT
>(state) };
1452 GetDockedRect(state, &(abd.rc));
1453 wxCHECK(::SHAppBarMessage(ABM_SETPOS, &abd),
false);
1454 wxCHECK(::SetWindowPos(m_hWnd,
wxAppBarGetZWnd(state, m_flags), abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, SWP_NOACTIVATE | SWP_DRAWFRAME | SWP_FRAMECHANGED),
false);
1461_Use_decl_annotations_
1465 APPBARDATA abd = {
sizeof(abd), m_hWnd, 0, ABE_LEFT };
1466 wxASSERT(!abd.rc.left && !abd.rc.top && !abd.rc.right && !abd.rc.bottom);
1467 wxCHECK(::SHAppBarMessage(ABM_SETPOS, &abd),
false);
1474_Use_decl_annotations_
1480 APPBARDATA abd = {
sizeof(abd), m_hWnd, 0,
static_cast<UINT
>(state), {}, (LPARAM)
true };
1481 if (::SHAppBarMessage(ABM_SETAUTOHIDEBAR, &abd)) {
1484 m_flags &= ~wxABF_AUTOHIDDEN;
1487 GetAutoHideRect(state,
false, &(abd.rc));
1488 wxCHECK(::SetWindowPos(m_hWnd,
wxAppBarGetZWnd(state, m_flags), abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, SWP_NOACTIVATE | SWP_DRAWFRAME | SWP_FRAMECHANGED),
false);
1507_Use_decl_annotations_
1513 APPBARDATA abd = {
sizeof(abd), m_hWnd, 0,
static_cast<UINT
>(state), {}, (LPARAM)
false };
1514 wxCHECK(::SHAppBarMessage(ABM_SETAUTOHIDEBAR, &abd),
false);
1515 m_flags &= ~wxABF_AUTOHIDDEN;
1519 ::KillTimer(m_hWnd, m_timerID);
1528_Use_decl_annotations_
1535 APPBARDATA abd = {
sizeof(abd), m_hWnd, 0,
static_cast<UINT
>(state), { 0, 0, ::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN) } };
1536 wxCHECK(::SHAppBarMessage(ABM_QUERYPOS, &abd),
false);
1541 rect->left = abd.rc.left;
1542 rect->top = abd.rc.top;
1543 rect->right = abd.rc.left + m_sizeDocked.cx;
1544 rect->bottom = abd.rc.bottom;
1548 rect->left = abd.rc.left;
1549 rect->top = abd.rc.top;
1550 rect->right = abd.rc.right;
1551 rect->bottom = abd.rc.top + m_sizeDocked.cy;
1555 rect->left = abd.rc.right - m_sizeDocked.cx;
1556 rect->top = abd.rc.top;
1557 rect->right = abd.rc.right;
1558 rect->bottom = abd.rc.bottom;
1562 rect->left = abd.rc.left;
1563 rect->top = abd.rc.bottom - m_sizeDocked.cy;
1564 rect->right = abd.rc.right;
1565 rect->bottom = abd.rc.bottom;
1570 wxFAIL_MSG(wxT(
"unsupported application bar state"));
1579_Use_decl_annotations_
1586 const int iBorder = ::GetSystemMetrics(
wxAppBarIsDockedVert(state) ? SM_CXBORDER : SM_CYBORDER) * 2;
1587 const RECT rcScreen = {
1590 ::GetSystemMetrics(SM_CXSCREEN),
1591 ::GetSystemMetrics(SM_CYSCREEN)
1597 rect->top = rcScreen.top;
1598 rect->bottom = rcScreen.bottom;
1599 rect->right = rcScreen.left + (bAutoHidden ? iBorder : m_sizeDocked.cx);
1600 rect->left = rect->right - m_sizeDocked.cx;
1604 rect->left = rcScreen.left;
1605 rect->right = rcScreen.right;
1606 rect->bottom = rcScreen.top + (bAutoHidden ? iBorder : m_sizeDocked.cy);
1607 rect->top = rect->bottom - m_sizeDocked.cy;
1611 rect->left = rcScreen.right - (bAutoHidden ? iBorder : m_sizeDocked.cx);
1612 rect->top = rcScreen.top;
1613 rect->right = rect->left + m_sizeDocked.cx;
1614 rect->bottom = rcScreen.bottom;
1618 rect->left = rcScreen.left;
1619 rect->top = rcScreen.bottom - (bAutoHidden ? iBorder : m_sizeDocked.cy);
1620 rect->right = rcScreen.right;
1621 rect->bottom = rect->top + m_sizeDocked.cy;
1626 wxFAIL_MSG(wxT(
"unsupported application bar state"));