This is like toggleTaskbarAutohide, except that it toggles the always on top state instead of the autohide state.

I've tested it only on Windows XP.

[download]

The code (windows.h must be included):

	APPBARDATA abd;
	//both ABM_GETSTATE and ABM_SETSTATE require .cbSize to be set
	abd.cbSize = sizeof(APPBARDATA);
	//get state
	abd.lParam = (UINT) SHAppBarMessage(ABM_GETSTATE, &abd);
	//toggle always on top state
	abd.lParam ^= ABS_ALWAYSONTOP;
	//ABM_SETSTATE requires .hWnd to be set
	abd.hWnd = FindWindow(_T("Shell_TrayWnd"), NULL);
	//set state
	SHAppBarMessage(ABM_SETSTATE, &abd);