• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

How to switch the Autohide Taskbar?

I am writing a screen saver, and would like to detect an autohide taskbar to turn it off (to non-autohide). I found the function SHAppBarMessage with ABM_AUTOHIDEBAR, which takes a APPBARDATRA structure. I try to call it, but I do not get anything back. (return either null or zero). What should I put in the hwnd of the APPBARDATA structure to pass to the function (or do I have to initialize it, if yes with what?)
When I use ABM_GETSTATE, I guess I need the hwnd of the task bar, how else can I get the handle of the taskbar?
0
hshliang
Asked:
hshliang
  • 3
  • 2
1 Solution
 
hshliangAuthor Commented:
Edited text of question.
0
 
mjswartCommented:
Here's a part answer for finding the handle of the taskbar:
HWND hwnd = ::FindWindow("Shell_TrayWnd", NULL);

Shell_TrayWnd is the class name of the bar.
0
 
hshliangAuthor Commented:
Thank you, I got a window handle, but when I try to turn off the autohide by SHAppBarMessage(ABM_SETAUTODIEBAR, pabd) with param of pabd's hWnd = the handle and lParam = FALSE, I was not able to change the task bar to non autohide, what's the problem?
I check it before and after the ABM_SETAUTOHDIEBAR call by ABM_GETSTATE, it return '3' before or after.
0
 
mjswartCommented:
I've tried this out and for your purposes (screensaver) it should do what you want:

      HWND hwnd = ::FindWindow("Shell_TrayWnd", NULL);
      WINDOWPLACEMENT wp;
      ::GetWindowPlacement(hwnd, &wp);
      wp.showCmd = SW_HIDE;
      ::SetWindowPlacement(hwnd, &wp);
      Sleep(10000); // Do what you want to do
      wp.showCmd = SW_RESTORE;
      ::SetWindowPlacement(hwnd, &wp);

This way the tray bar is hid, plus you're not messing with the user's preferences.

Good luck
0
 
hshliangAuthor Commented:
dear mjswart,
Thank you for you suggestion. I am so stuck with the SHAppBarMessage, I was trying all the commands without any effect. Is SHAppBarMessage not able to change the TaskBar?
I use your suggestion of ShowWindow, it serve the prupose, viz, make the taskbar invisible. I got what I want although I still do not know why taskbar is not changed by SHAppBarMessage.
thank you any way, you got the credits!
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now