Obtain Task Bar Docking Setting: Always returns ABE_LEFT

Started by
0 comments, last by gretty 7 years, 11 months ago

I am trying to determine which side the Windows Taskbar (System Tray?) is docked to - so I can position my popup window above/below/left/right of the taskbar. I am using SHAppBarMessage(ABM_QUERYPOS, &barData) to obtain this information but it always returns ABE_LEFT for me when my taskbar is ABE_TOP.

What's going wrong? Maybe I cant use that function to determine it? Maybe my APPBARDATA params are wrong? Its difficult to check whether the function call is successful, see MSDN documentation for return value - not quite sure what the successful value should be.


HWND taskBar = FindWindow(_T("Shell_TrayWnd"), NULL); // taskBar is valid and not null

APPBARDATA barData{};
barData.cbSize = sizeof(APPBARDATA);
barData.hWnd = taskBar;
barData.uCallbackMessage = 0;
//barData.uEdge = ABE_RIGHT;
//barData.rc = RECT{0,0300,300};
barData.lParam = (LPARAM)FALSE;
UINT_PTR res = SHAppBarMessage(ABM_QUERYPOS, &barData);

// barData.uEdge always equals ABE_LEFT

// Unsure how to check res for error: see MSDN documentation - not very helpful
Advertisement

Looks like I was using the wrong flag. The following works:


APPBARDATA barData {0};
barData.cbSize = sizeof(APPBARDATA);
UINT_PTR res = SHAppBarMessage(ABM_GETTASKBARPOS, &barData);

This topic is closed to new replies.

Advertisement