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.
Many thanks for this, it worked perfectly :-)
Regards,
Jr.
"Kellie Fitton" <KELLIE...@yahoo.com> wrote in message
news:ea65678c-562d-4924...@q24g2000prf.googlegroups.com...
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...