Date: | May 6, 2005 / year-entry #114 |
Tags: | code |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20050506-32/?p=35693 |
Comments: | 14 |
Summary: | Occasionally, people want to query properties of the taskbar. I don't quite understand why; you should just get on with your life and let the taskbar get on with its life. After all, there might not even be a taskbar, as we discussed last time. But if you really want to know (perhaps you're collecting... |
Occasionally, people want to query properties of the taskbar. I don't quite understand why; you should just get on with your life and let the taskbar get on with its life. After all, there might not even be a taskbar, as we discussed last time. But if you really want to know (perhaps you're collecting usability data), here's how: #include <stdio.h> #include <windows.h> #include <shellapi.h> int __cdecl main(int argc, const char* argv[]) { APPBARDATA abd = { sizeof(abd) }; UINT uState = (UINT)SHAppBarMessage(ABM_GETSTATE, &abd); printf("Taskbar on top? %s\n", (uState & ABS_ALWAYSONTOP) ? "yes" : "no"); printf("Taskbar autohide? %s\n", (uState & ABS_AUTOHIDE) ? "yes" : "no"); return 0; }
This little program uses
the
Since you're using the
You can also use
the And to stave off follow-up questions: These are the only two properties of the taskbar that are programmable. Exposing a programmable interface for something as highly visible as the taskbar is a very sensitive issue, because once you grant programmatic access to something, there is a very strong temptation for programs to start abusing it. |
Comments (14)
Comments are closed. |
One of the most common requests that I’ve seen was how to set the user’s display to a particular resolution. With some of them, I had a hard time convincing them how user hostile that was.
I wrote a Python script that toggles auto-hide, which I have on a keyboard shortcut (no, I do not want auto-hide on all the time, but I do want to be able to toggle it quickly), and which uses this interface.
The most common reason that I’ve seen for wanting to know about the taskbar is to display notices in the lower right corner, usually after an automatic update or in response to clicking a tray icon. I’ve seen a lot of programs that don’t work correctly unless the user has this set up with the taskbar at the bottom and never hidden. I personally have my taskbar set up 3 rows high with auto-hide on and always on top, and I often get weird results. In fact, I can almost never see the tooltips for the tray icons.
Explorer is responsible for the wrong tooltip placement/z-order, not the app
I admit I have tried to screw around with the taskbar before, not in a distributed application but as an attempt to add some features. However I quickly found that I could not change anything i wanted to anyway (which is good in a way). Sadly I still have no nice way to reorder programs in my taskbar if i ever want to.
Explorer is the app I’m talking about in this case.
Well, you can have custom ‘notification’ dealys, like MSN Messenger, or Zone Alarm or something. These apps need to know where the tray icons are on the screen to ensure that the notifications are placed properly.
Admitedly, you should be using the Shell ones wherever possible, but if you want to provide custom UI on them (like the ‘Block’ / ‘Allow’ buttons on Zone Alarm) then you have to write your own.
Betty: see TaskArrange for simple app to rearrange task bar buttons.
http://users.forthnet.gr/pat/efotinis/programs/index.html
http://www.codeproject.com/tools/tbarsort.asp
This utility allows you to change the order of items on your taskbar, by dragging them into position in a list.
It looks like SHAppBarMessage() didn’t make it into the WinCE pared-down API, so I guess "whacking registry keys" is still the de facto correct way to change Taskbar settings in CE.
(Keep in mind not all CE devices are Pocket PC. Our device is an industrial controller, so we don’t particularly care what a user’s shell settings are. In fact, we may eventually replace the shell entirely.)
Dean, you don’t need to know where your icon is. If what you mean is the popup menu that is shown, with a delay, after a user click then Windows has a way of finding where the mouse pounter was at the time of the last message – GetMessagePos. That’s what those programs use.
My taskbar is 2 rows high and never hidden. I don’t know if this is an app error or a Windows internal error, but when I’m running Microsoft SQL Server 2000 (Query Analyzer), and I’m looking at a query execution plan, and I hover over a part of it to get the details, there’s a tooltip with a long explanation (about 15 lines long) of what that "node" in the execution plan represents.
Maybe because I have system fonts set to Custom/105%, and/or because the taskbar is 2 rows high, the bottom line of the multi-line description in Query Analyzer’s tooltip is usually hidden underneath my taskbar. Sometimes I can see the top third of the text on the last line, and sometimes none of it… Kinda hard to read, though.
Jerry: I’m talking about custom notifications, which aren’t in response to user commands. Like with Zone Alarm when a new program tries to make a connection out, it pops up a notification next to its icon in the task bar saying "Program XYZ is trying to connect to a.b.c.d". It’s not a default Shell notification because they have extra UI on there which lets you allow it, block it, etc.
RePost:
http://www.yeyan.cn/Programming/PropertiesTaskbar.aspx