Skip to main content
GameDev.net gamedev.net
🔒 Locked

How to programmatically move the windows TaskBar?

Started by gp343 May 14, 2008 at 4:16 PM 2 replies 2.7k views
Original Post
gp343
gp343
Hi There, Is it possible to programmatically move the Windows Tas I've been attempting to write a simple C program that is capable of moving the TaskBar in Windows. So far, I've stumple upon the ShellAPI function "SHAppBarMessage". I've attempted to use it, but nothing is happening to my taskbar at all. Please see below for my full code. Can someone please help? Regards, Jr #include #include #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { HWND hWnd = FindWindow("Shell_TrayWnd", NULL); APPBARDATA abd; ZeroMemory(&abd, sizeof(abd)); abd.cbSize = sizeof(APPBARDATA); SHAppBarMessage(ABM_GETTASKBARPOS, &abd); abd.rc.top = 300; abd.uEdge = ABE_RIGHT; SHAppBarMessage(ABM_SETPOS, &abd); MessageBox(NULL, "Done!", "Taskbar Refresh", MB_OK); return 0; }
deadstar
deadstar
Looking at the struct for APPBARDATA, you need to obtain a handle to the app bar window.

typedef struct _AppBarData {    DWORD cbSize;    HWND hWnd;    UINT uCallbackMessage;    UINT uEdge;    RECT rc;    LPARAM lParam;} APPBARDATA, *PAPPBARDATA;


There are functions to obtain a window handle from another application. FindWindow() might be what you need:

HWND FindWindow(          LPCTSTR lpClassName,    LPCTSTR lpWindowName);


EDIT: The lpClassName for the taskbar in Windows XP is "Shell_traywnd". Call that function with lpWindowName as "".
"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2   A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk
Colin Jeanne
Colin Jeanne
The SHAppBarMessage() function doesnt actually move the window. It only requests that movement take place and suggests a place for the moved appbar to go so that the system can coordinate with the other appbars. To move the window you need to use SetWindowPos().

By the way, why do you want to move the taskbar? This seems like a very not nice thing to do (not to mention completely dependent on a specific version of Windows).
gp343
gp343
My primary reason for moving the taskbar is that I normally have to use remote login into my workstation. The problem is that Citrix resize most of the applications that are opened on my workstation. When I do go into work the next day and login, most of my applications cannot maximize correctly again and I have to completely restart windows to fix this. This is a known problem that occurs with all of my co-workers. Nevertheless, I discovered that If I move my taskbar to another location and then move it back, it fixes this problem without my having to restart my workstation.

Thanks,
Jr

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.