Discussion:
How to programmatically move the windows TaskBar?
(too old to reply)
James
2008-05-14 22:00:32 UTC
Permalink
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
2008-05-15 02:36:50 UTC
Permalink
Post by James
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;
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
2008-05-15 05:35:30 UTC
Permalink
Hi Kellie,

Many thanks for this, it worked perfectly :-)

Regards,
Jr.
Post by James
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;
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
2008-05-24 07:56:05 UTC
Permalink
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;
}
Post by James
Hi Kellie,
Many thanks for this, it worked perfectly :-)
Regards,
Jr.
Post by James
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;
Hi,
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.
Ze'ev Fainberg
2012-03-07 17:27:20 UTC
Permalink
I succeed to move taskbar by changing registry at HKEY_CURRENT_USER_Software_Microsoft_Windows_CurrentVersion_Explorer_StuckRects2
Post by James
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
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;
}
Post by James
Hi Kellie,
Many thanks for this, it worked perfectly :-)
Regards,
Jr.
Hi,
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.
Post by Kellie Fitton
full
Hi,
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.
Post by James
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?
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;
}
g***@gmail.com
2013-01-22 22:29:11 UTC
Permalink
This post might be inappropriate. Click to display it.
b***@gmail.com
2014-06-05 16:42:00 UTC
Permalink
how would you save this and what program

Loading...