Placing toolbar into Windows taskbar (ala language bar) - windows

I'm currently in the process of writing a Windows MFC app to quickly search our corporate DMS. The idea is to have a button placed at the right hand edge of the windows taskbar much like the language bar, that when clicked, would popup the search interface.
I can't seem to find much regarding how placing items in the taskbar like this is performed, can anyone point me to some useful resources or examples?
I'd prefer native API resources (that is, not .NET) if possible.
Thanks!

Such toolbar is named a Deskband.
Here's an example: http://www.codeproject.com/KB/shell/dotnetbandobjects.aspx

You could look at the StExBar. It implements an explorer toolbar which can also be added to the taskbar. Doesn't use MFC though, just plain win32.

Related

MFC: Address Bar control like Windows Explorer

In my MFC app, I'm attempting to make a window that resembles the Windows 7 Open File dialog, but it browses a virtual/fake file system. It doesn't need to be pixel-perfect, but I'd like parity with the native OS dialog where possible.
Probably the most challenging part is the address bar the runs along the top of an Open dialog. The address bar control is also atop all Windows Explorer windows. It shows the folder names that make up your path. It shows and hides buttons when moused over (including an attractive fade animation), changes the active directory when names are clicked, and shows submenus when the triangles between names are clicked. This doesn't seem to correspond to any MFC control (or group of controls). Spy++ shows it as an "AddressDisplay Control" but I can't find much documentation beyond that.
Is there a way to access a control like this, or to mimic it, in MFC? Also, I am not browsing the real file system, so I have to be able to tell the control what to display--I can't just point it at C:\ and let the system do the rest.
Here's a picture of the control in question.
Unfortunately, I think this is one of those controls that Microsoft has decided not to expose to developers through the Feature Pack. The Feature Pack was developed from the BCG control library. And, that library contains the control you want. However, it's not free. The only other alternative is to code it yourself.

How can I add custom menu item to window system menu under X?

I would like to add my custom command, to a window system menu (the one usually on the left top on titlebar, usually containing Minimize, Maximize and so on), and respond to it in my application.
In ms windows one can do
HMENU hMenu = GetSystemMenu(hwnd, false);
AppendMenu(hMenu, MF_STRING, ...)
Is something like this possible under X11? If not a general method maybe a solution for some specific window manager?
Ok, after your last edit, what I understand is that you want to add your custom menu to the menu that's on the window decoration, which is controlled by the Window Manager.
I don't think that's possible, although I'm not sure. I believe you should read the ICCCM and the EWMH to find if this is possible or not:
http://en.wikipedia.org/wiki/Inter-Client_Communication_Conventions_Manual
http://en.wikipedia.org/wiki/Extended_Window_Manager_Hints
Or you can send an email to wm-spec-list asking:
http://mail.gnome.org/mailman/listinfo/wm-spec-list
Also, adding an option there makes it quite hidden, doesn't it? I guess most people don't ever click that menu... I don't even think that menu exists on all the possible Window Managers. You should really try to put your menu inside your application's Window instead of the Window Manager's decoration. Some environments don't even have Window Managers: what would your users do in this case?
Note that some applications (like the Chromium browser) don't use the Window Manager decorations: they implement their own decoration, they implement their own close/maximize/minimize buttons. This way, they have complete control over all the decoration buttons and menus, but their decoration doesn't have the same "look and feel" of the rest of the desktop. You could think about doing this, but I wouldn't encourage that... You should probably put your menu somewhere else (where it's not that hidden...).
You mean you want to add your app to the system menu?
I believe most modern desktop environments implement the XDG Menu Standard:
http://standards.freedesktop.org/menu-spec/menu-spec-latest.html
You'll have to learn other standards too probably:
http://standards.freedesktop.org/
They're all somehow short, so they won't consume more than some hours to read and learn.

MS Word is an MDI or SDI

I have a confusion that MSWord is a MDI or SDI application. Looking at the Application, I do believe that it is a SDI application but there are people who strongly "believe" that its an example of MDI. After using the Taskmanager in windows, the Applications tab list all all the instances of the Documents currently opened. However there is only one process in the Processes tab.
Since all the documents have same process, it make me feel its an MDI. But at the same time, the Applications tab lists all the documents opened make methink its an SDI. What do you people think about this? Please give your valuable and detailed answers.
If you uncheck Show all documents in the taskbar in Options, Word is a classical MDI application (even Word 2010).
If you leave it checked, it's an SDI application with multiple root windows.
According to Microsoft, it is an MDI application: http://msdn.microsoft.com/en-us/library/aa263481(v=vs.60).aspx
Depending on your settings and version, it could be MDI or SDI. It is MDI in older versions and if you use the "Show all documents in taskbar" option; otherwise, it is SDI.
Honestly, I didn't realize this part myself, until I tested:
After using the Taskmanager in windows, the Applications tab list all all the instances of the Documents currently opened. However there is only one process in the Processes tab.
Thank you and +1 on the post. On exploring further, I found something that might shed light further. I am using 2007, but I guess it would apply for 2010 as well. I clicked on the Control Menu (the small menu that pops up when you click on the Icon on the top left corner - used to be called Control Menu, before Microsoft decided to redraw its interface). You would find a "Word Options" button. Click on it, in the dialog that pops up after that, go to "Advanced" tab. Scroll down to the "Display" section. Locate the "Show all windows in the Taskbar" check box, I guess it will be checked. Uncheck it. You would see that there are no multiple windows (corresponding to each document) anymore. Also, in Task Manager, you will see only one instance even in the Applications Tab.
With this, I strongly believe Word is still an MDI. Oh by the way, if you want to see every document opened after you change these "Advanced" options, you might want to go to View menu and and chose "View side by side" option.
I came across some more info regarding this from Chris Ryan which I am sharing here:
It depends on what you mean by MDI.
MS-Word does have multiple documents and an interface but it does not fit the classic definition of an MDI application because it does not use an MDICLIENT window class to manage the child frames.
For an example of an MDICLIENT, see:
ftp://ftp.charlespetzold.com/ProgWin5/Chap19/MDIDemo/MDIDemo.c .
ftp://ftp.charlespetzold.com/ProgWin5/Chap19/MDIDemo/Release/MDIDemo.exe
Even the older versions of Word and Excel that had the child windows inside the main frame, were technically not MDI. They looked like it but they did not use MDICLIENT. MS used a proprietary windowing library called Software Dialog Manager. SDM was used so a common application code base could be used on multiple platforms: Windows, OS/2, & Mac. All they had to do was recompile for that platform and link a platform specific SDM library.
This link talks a little about SDM but does not mention MDICLIENT
http://msdn.microsoft.com/en-us/library/windows/desktop/dd317997(v=vs.85).aspx

How come some controls don't have a windows handle?

I want to get the window handle of some controls to do some stuff with it (requiring a handle). The controls are in a different application.
Strangely enough; I found out that many controls don't have a windows handle, like the buttons in the toolbar (?) in Windows Explorer. Just try to get a handle to the Folder/Search/(etc) buttons. It just gives me 0.
So.. first question: how come that some controls have no windows handle? Aren't all controls windows, in their hearts? (Just talking about standard controls, like I would expect them in Windows Explorer, nothing customdrawn on a pane or the like.)
Which brings me to my second question: how to work with them (like using EnableWindow) if you cannot get their handle?
Many thanks for any inputs!
EDIT (ADDITIONAL INFORMATION):
Windows Explorer is just an example. I have the problem frequently - and in a different application (the one I am really interested in, a proprietary one). I have "physical" controls (since I can get an AutomationElement of those controls), but they have no windows handle. Also, I am trying to send a message (SendMessage) to get the button state, trying to find out whether it is pushed or not (it is a standard button that seems to exhibit that behaviour only through that message - at least as far as I have seen. Also, the pushed state can last a lot longer on that button than you would expect on a standard button, though the Windows Explorer buttons show a similar behaviour, acting like button-style checkboxes, though they are (push)buttons). SendMessage requires a window handle.
Does a ToolBar in some way change the behaviour of its child elements? Taking away their window handle or something similar? (Using parent handle/control id for identification??) But then how to use functions on those controls that require a windows handle?
If they don't have a handle, they're not real controls, they're just drawn to look like controls.
But of course, the toolbar buttons in Windows Explorer do have window handles, they're part of a toolbar. Use the toolbar manipulation functions to interact with them, not EnableWindow.
Or, better yet, use the documented APIs for things like search. Reverse-engineering Windows Explorer has never ended well for anyone, least of all the poor Windows Shell team, saddled with years of backwards-compatibility hacks for certain developers who thought that APIs are for everyone else. Whatever you do manage to get to work is very likely to break on the next version of Windows.
The controls you are talking about are using the ToolbarWindow32 class. If you want to interact with them then you'll need to use the toolbar control APIs/message. For example for enabling buttons you'd want to use TB_ENABLEBUTTON.
You can implement the controls yourself using GDI, OpenGL or DirectX. Try Window Detective on Mozilla Firefox and you will see that there is only one window. Controls in dialog boxes are not windows known to Windows.

Mac style menus on Windows, system wide

I'm a Mac user and a Windows user (and once upon a time I used to be an Amiga user). I much prefer the menu-bar-at-the-top-of-the-screen approach that Mac (and Amiga) take (/took), and I'd like to write something for Windows that can provide this functionality (and work with existing applications).
I know this is a little ambitious, especially as it's just an itch-to-scratch type of a project and, thanks to a growing family, I have virtually zero free time. I looked in to this a few years a go and concluded that it was very difficult, but that was before StackOverflow ;)
I presume that I would need to do something like this to achieve the desired outcome:
Create application that will be the custom menu bar that sits on top of all other windows. The custom menus would have to provide all functionality to replace the standard Win32 in-window menus. That's OK, it's just an application that behaves like a menu bar.
It would continuously enumerate windows to find windows that are being created/destroyed. It would enumerate the child windows collection to find the menu bar.
It would build a menu that represents the menu options in the window.
It would hide the menu bar in the window and move all direct child windows up by a corresponding pixel amount. It would shorten the window height too.
It would capture all messages that an application sends to its menu, to adjust the custom menu accordingly.
It would constantly poll for the currently active window, so it can switch menus when necessary.
When a menu hit occurs, it would post a message to the window using the hwnd of the real menu child control.
That's it! Easy, eh? No, probably not.
I would really appreciate any advice from Win32 gurus about where to start, ideas, pitfalls, thoughts on if it's even possible. I'm not a Win32 C++ programmer by day, but I've done a bit in my time and I don't mind digging my way through the MSDN platform SDK docs...
(I also have another idea, to create a taskbar for each screen in a multi-monitor setup and show the active windows for the desktop -- but I think I can do that in managed code and save myself a lot of work).
The real difference between the Mac menu accross the top, and the Windows approach, is not just in the menu :- Its how the menu is used to crack open MDI apps.
In windows, MDI applications - like dev studio and office - have all their document windows hosted inside an application frame window. On the Mac, there are no per-application frame windows, all document windows share the desktop with all other document windows from other applications.
Lacking the ability to do a deep rework of traditional MDI apps to get their document windows out and onto the desktop, an attempt, however noble, to get a desktop menu, seems doomed to be a novelty with no real use or utility.
I am, all things considered, rather depressed by the current state of window managers on both Mac and Windows (and Linux): Things like tabbed paged in browsers are really acts of desperation by application developers who have not been given such things as part of the standard window manager - which is where I believe tabs really belong. Why should notepad++ have a set of tabs, and chrome, and firefox, and internet explorer (yes, I have been known to run all 4), along with dev studios docking view, various paint programs.
Its just a mess of different interpretations of what a modern multi document interface should look like.
The menu bar on a typical window is part of the non-client area of the window. It's drawn when the WndProc gets a WM_NCPAINT message and passes it on to DefWindowProc, which is part of User32.dll - the core window manager code.
Other things that are drawn in the same message? The caption, the window borders, the min/max/close boxes. These are all drawn while processing a single message. So in order to hide the menu for an application, you will have to take over handling of this message, which means changing the behavior of user32.dll. Hiding the menu is going to mean that you become responsible for drawing all of the non-client area.
And the appearance of all of these elements - The caption, the borders, etc. changes with every major version of Windows. So you have to chase that as well.
That's just one of about a dozen insurmountable problems with this idea. Even Microsoft probably couldn't pull this off and they have access to the source code of user32.dll!
It would be a far less difficult job to echo the menu for each application at the top of the screen, and even that is a nearly impossible job. When the menu pops there is lots of interaction with the application during which the menu can be (and often is) changed. It is very common for applications to change the state of menu items just before they are drawn. So you will have to replicate not only the appearance of the menus, but their entire message flow interaction with the application.
What you are trying to do is about a dozen impossible jobs all at once, If you try it, you will probably learn a lot, but you will never get it to work.

Resources