Sign in to follow this  
gp343

How to programmatically move the windows TaskBar?

Recommended Posts

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 <stdio.h> #include <windows.h> #include <shellapi.h> 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; }

Share this post


Link to post
Share on other sites
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 "".

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this