Link to home
Start Free TrialLog in
Avatar of sasinair
sasinair

asked on

Taskbar size

Hi all,

How can I trap the windows taskbar size changes programmatically??

thanks
sasinair

Avatar of stsanz
stsanz

Intercept the WM_SETTINGCHANGE message.

This message is sent when a system setting has changed, and among these settings, is the size of the desktop working area (SPI_SETWORKAREA parameter of SystemParametersInfo API).

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/wm_settingchange.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp
ASKER CERTIFIED SOLUTION
Avatar of BorlandMan
BorlandMan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sasinair

ASKER

Thanks a lot. It helped me.

I have one more doubt...

How can we find the desktop changed rectangle area? That means only the rectangle that changed in the desktop.


Thanks in advance
sasinair

// example
RECT rct;
long lResult = SystemParametersInfo(SPI_GETWORKAREA, NULL, &rct, 0)

this gives you the work area in a rectangle.

fResult = (BOOL) SHAppBarMessage(ABM_GETTASKBARPOS, pabd);

where pabd is a pointer to a struct like this
typedef struct _AppBarData {
    DWORD  cbSize;
    HWND   hWnd;
    UINT   uCallbackMessage;
    UINT   uEdge;
    RECT   rc;
    LPARAM lParam;
} APPBARDATA, *PAPPBARDATA;

use rc to get the bounding rectangle of the taskbar (that's screen coordinates)

then you can do some math between the work area rect and taskbar Rect

but I would think that if the taskbar has changed, the Work area rect tells you where the Taskbar is not.
So you could resize your app to fit that area.

hope that helps,
J