Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to programmatically move the windows TaskBar?

655 views
Skip to first unread message

James

unread,
May 14, 2008, 6:00:32 PM5/14/08
to
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 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;
}


Kellie Fitton

unread,
May 14, 2008, 10:36:50 PM5/14/08
to


Hi,

You can use the following APIs to size/position Windows taskbar:

SHAppBarMessage(ABM_GETTASKBARPOS, &pData);

hTaskbar = FindWindow(L"Shell_TrayWnd", NULL);

GetWindowRect(hTaskbar, &RECT);

SetWindowPos(hTaskbar, NULL, X, Y, CX, CY,
SWP_NOSENDCHANGING);
ShowWindow(hTaskbar, SW_SHOW);

UpdateWindow(hTaskbar);

GetDesktopWindow();

RedrawWindow(hDesktopWindow, NULL, NULL,
RDW_FRAME|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);

SystemParametersInfo(SPI_SETWORKAREA, 0, NULL, SPIF_SENDCHANGE);

http://msdn2.microsoft.com/en-us/library/ms647647.aspx

http://msdn2.microsoft.com/en-us/library/ms633499.aspx

http://msdn2.microsoft.com/en-us/library/ms633519.aspx

http://msdn2.microsoft.com/en-us/library/ms633545.aspx

http://msdn2.microsoft.com/en-us/library/ms633548.aspx

http://msdn2.microsoft.com/en-us/library/ms534874.aspx

http://msdn2.microsoft.com/en-us/library/ms633504.aspx

http://msdn2.microsoft.com/en-us/library/ms534900.aspx

http://msdn2.microsoft.com/en-us/library/ms724947.aspx

Kellie.

James

unread,
May 15, 2008, 1:35:30 AM5/15/08
to
Hi Kellie,

Many thanks for this, it worked perfectly :-)

Regards,
Jr.

"Kellie Fitton" <KELLIE...@yahoo.com> wrote in message
news:ea65678c-562d-4924...@q24g2000prf.googlegroups.com...

James

unread,
May 24, 2008, 3:56:05 AM5/24/08
to
Hi there again,

The below code is working, however, the problem is that the Taskbar is only
repositioned temporarily - a few seconds and then it is return back to the
bottom of the screen.

Can somebody please help as I want it to be permanently repositioned the
taskbar at the top of the screen?


#include <stdio.h>
#include <windows.h>
#include <shellapi.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nShowCmd)
{

RECT rect;
RECT deskTopRect;
HWND hDesktopWindow;
char* strMessage = "Your Taskbar is now refreshed.";


HWND hWnd = FindWindow("Shell_TrayWnd", NULL);
APPBARDATA abd;

ZeroMemory(&abd, sizeof(APPBARDATA));
abd.cbSize = sizeof(APPBARDATA);

SHAppBarMessage(ABM_GETTASKBARPOS, &abd);
GetWindowRect(hWnd, &rect);
SetWindowPos(hWnd, NULL, rect.left, 0, rect.right, rect.bottom-rect.top,
SWP_NOSENDCHANGING);

ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
GetWindowRect(hWnd, &rect);

hDesktopWindow = GetDesktopWindow();

GetWindowRect(hDesktopWindow, &deskTopRect);
deskTopRect.top = rect.bottom;


RedrawWindow(hDesktopWindow, NULL, NULL,
RDW_FRAME|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);

SystemParametersInfo(SPI_SETWORKAREA, 0, (LPVOID)&deskTopRect,
SPIF_SENDCHANGE);

//SystemParametersInfo(SPI_SETWORKAREA, 0, NULL, SPIF_SENDCHANGE);
UpdateWindow(hDesktopWindow);

MessageBox(NULL, strMessage, "Taskbar Refresh", MB_OK);
return 0;
}

"James" <arl...@hotmail.com> wrote in message
news:OjS8$1ktIH...@TK2MSFTNGP04.phx.gbl...

Ze'ev Fainberg

unread,
Mar 7, 2012, 12:27:20 PM3/7/12
to
I succeed to move taskbar by changing registry at HKEY_CURRENT_USER_Software_Microsoft_Windows_CurrentVersion_Explorer_StuckRects2

> On Wednesday, May 14, 2008 6:00 PM James wrote:

> 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 help?
>
>
> Regards,
> Jr
>
>
>
>>> On Saturday, May 17, 2008 1:55 AM Kellie Fitton wrote:

>>> On May 14, 3:00=A0pm, "James" <arl...@hotmail.com> wrote:
>>>
>>> full
>>>
>>>
>>> Hi,
>>>
>>> You can use the following APIs to size/position Windows taskbar:
>>>
>>> SHAppBarMessage(ABM_GETTASKBARPOS, &pData);
>>>
>>> hTaskbar =3D FindWindow(L"Shell_TrayWnd", NULL);
>>>
>>> GetWindowRect(hTaskbar, &RECT);
>>>
>>> SetWindowPos(hTaskbar, NULL, X, Y, CX, CY,
>>> SWP_NOSENDCHANGING);
>>> ShowWindow(hTaskbar, SW_SHOW);
>>>
>>> UpdateWindow(hTaskbar);
>>>
>>> GetDesktopWindow();
>>>
>>> RedrawWindow(hDesktopWindow, NULL, NULL,
>>> RDW_FRAME|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
>>>
>>> SystemParametersInfo(SPI_SETWORKAREA, 0, NULL, SPIF_SENDCHANGE);
>>>
>>> http://msdn2.microsoft.com/en-us/library/ms647647.aspx
>>>
>>> http://msdn2.microsoft.com/en-us/library/ms633499.aspx
>>>
>>> http://msdn2.microsoft.com/en-us/library/ms633519.aspx
>>>
>>> http://msdn2.microsoft.com/en-us/library/ms633545.aspx
>>>
>>> http://msdn2.microsoft.com/en-us/library/ms633548.aspx
>>>
>>> http://msdn2.microsoft.com/en-us/library/ms534874.aspx
>>>
>>> http://msdn2.microsoft.com/en-us/library/ms633504.aspx
>>>
>>> http://msdn2.microsoft.com/en-us/library/ms534900.aspx
>>>
>>> http://msdn2.microsoft.com/en-us/library/ms724947.aspx
>>>
>>> Kellie.


>>>> On Saturday, May 24, 2008 3:56 AM James wrote:

>>>> Hi there again,
>>>>
>>>> The below code is working, however, the problem is that the Taskbar is only
>>>> repositioned temporarily - a few seconds and then it is return back to the
>>>> bottom of the screen.
>>>>
>>>> Can somebody please help as I want it to be permanently repositioned the
>>>> taskbar at the top of the screen?
>>>>
>>>>
>>>>

gep...@gmail.com

unread,
Jan 22, 2013, 5:29:11 PM1/22/13
to synta...@yahoo.co.uk
Hello,

Do you have any information about the values that you wrote into this key in order to control the taskbar position?

Thanks

Gary

beneve...@gmail.com

unread,
Jun 5, 2014, 12:42:00 PM6/5/14
to
how would you save this and what program
0 new messages