In Vista and Windows 7 almost any time the system uses a standard Listview (ie: Explorer Windows) it's accompanied by a little split button that shows a slider when the split is clicked that allows you to switch between the different views available for that listview (Tile, Details, List, etc.) as well as sliding smoothly between icon sizes (from 32x32 is to 256x256) using the top half of the slider.
This is a cool little bit of functionality, so I was wondering: Is that control available to developers, and if so what is it called and where is it documented? (Win32/C++ preferred)
Turns out in Windows 7, the explorer window is no longer a standard listview (though it does an extremely good job of looking like one). Open Spy++, point it at an explorer window list pane, and you'll see a classname of "DirectUIHWND" instead of the old "SysListView32".
The actual slider itself is indeed a real ComCtl32 slider; so you could perhaps roll your own; but as far as I know there's no way to reuse the existing explorer pane's functionality.
Related
I'm trying to implement simple metro style window using WinAPI (basicly like Visual Studio 2012 style) to run on Windows 7 and Windows 8, I know it a hard work and at begin, I have those problems:
1. Create a squared window
I can achieve this by create a borderless window (mean no border, no titlebar, only client area) but by this way, I can't resize this window and titlebar was lost of course. Are these any ways to create a squared corner window and still keep titlebar (including close, max, min, ... buttons)?
2. Owner draw close, maximize, minimize buttons
I can owner draw whole titlebar by catching WM_NCPAINT event but this way I see these buttons (close, maximize, minimize) go to the hell. How can I show these button in my way (I mean draw it by my ideas)?
3. Create shadow
You can see that if Visual Studio 2012's window do not maximized, it show a shadow, it look great and I want apply that effect to my simple window. How can I do that?
You need to write your own code that draws basic window elements, and handle mouse events by hand to make them interactive. (hooking WM_NCHITTEST may help for interactivity)
To make a shadow, make your window layered, then set a background image with an alpha-transparent shadow.
In addition to what SLaks said, which will work but is a lot of effort and will take time, you may want to consider whether you can use a framework in developing your program. If you can, then you may be able to use a framework toolkit to implement the "window chrome" leaving you free to work on the the important part of your application: the logic.
If you can use MFC, then I would recommend CodeJock's Toolkit Pro 2013; I am not affiliated with them in any way, but have used their product in the past and it's quite good.
I'm sure that there are other toolkits, some of which might target different frameworks, but I have no experience with them and no basis to recommend them.
I need to get the width of the icon area of a context menu using the Windows API (>= Windows XP if this matters). What I mean by icon area you can see in this question, there is an image. It is a space reserved for icons on the left side of the menu.
I scanned through the wealth of information you can get via SystemParametersInfo and GetSystemMetrics, but found nothing. But there has to be some default value, right? How could I get it?
A native win32 menu does not really support icons so you can't really call it the icon area. In a basic menu the size of that area is SM_CXMENUCHECK wide (Plus SM_CXEDGE for padding probably) For Vista+ you might be able to find some better metrics with the MENU_POPUP* constants and GetThemeInt. AFAIK the exact layout and border constants required to replicate classic Win95+ menus are not documented.
Since you are talking about icons I assume you want to add icons to your menu so your width should probably be max(yourIconWidth,GetSystemMetrics(SM_CXMENUCHECK)) + padding. This old MSJ article is probably the best menu owner draw tutorial out there, and codeproject has its own menu article section with several different owner draw implementations. (MS Office and Visual Studio use custom stuff as well)
As a final note, since you said XP+ you should be able to use HBMMENU_CALLBACK and only worry about the icon and not the rest of the menu drawing...
My Win32 Application displays Menus as shown when running on Win 7:
This is the Default for the themes Windows 7 as well as Windows 7 Aqua.
Please note that the selected menu entry is only slightly different from the other entries. I think it is much too less highlighted and therefore i am looking for a way to give the selected entry a different color. But unfortunately all possibilities to modify menu colors disappeared in Windows 7. The settings made in the window color dialog are non effective for menus.
But amazingly Microsoft's own applications look different. I.e. Paint has different color and appearance of menus:
This has good contrast and is much better than the default for a Win32 application.
Also Visual Studio 2010 looks different:
I know that VS 2010 is build on WPF. I don't know if and how the ribbon, used in paint influences the menu appearance. My menus are set up dynamically using SetMenu();
My Question: Is there any way to change the appearance of my applications menu using a API or maybe a manifest or resource?
Or is there a way to modify the color of the selected menu entry in Windows 7 through settings?
You can make your own user drawn menus. For an example, take a look at this CodeProject.com article: http://www.codeproject.com/KB/menus/newmenuxpstyle.aspx
Also, VS 2010 is not entirely built on WPF - only the code editor.
Through experience I have found that the native windows forms/components don’t like to be changed. I know using Delphi or Visual Studio you are given native windows components to populate a form or window with and then you attach code on events that these components may do (onClick for example).
However, how do all of these programs like Word or google’s Chrome browser alter the standard windows’ window? I thought it was somehow protected?
Chrome seems to have tabs actually on the window’s frame?
I know you can also get toolkits like Swing and QT that have their own controls/components to populate a form. How do these work? (How does the operating system/computer know what a non-native button should act like? For example; Chrome's back and forward buttons, they're not native components?).
I can understand how OpenGL/DirectX window would work because you’re telling the computer exactly what to draw with polygons/quads.
I hope this question is clear!
Windows does not protect GUI elements. Windows and controls can be subclassed to handle various drawing operations in a custom way. For example, windows may override and reimplement the handling of the WM_NCPAINT message to draw a custom titlebar and frame:
http://msdn.microsoft.com/en-us/library/dd145212(VS.85).aspx
Some Windows controls have an "owner-draw" mode. If you use this, you get to draw the control (or at least vital parts of the control), while Windows takes care of responding to user input in the standard way.
Swing ant QT draw their own widgets at a low level using basic primitives, but they also have theme engines which can mimic the native controls.
Qt moved to native controls a while back. As for how swing does it, it gets a basic window from the OS. Then much like Opengl\Directx it does all of the drawing with in that window. As for where to position things that is what the layout managers do. Each manager has a layout style horizontal, vertical, grid, components it has to draw and a section of window it is expected to fill. From there it does some pretty easy math to allocate its space to its controls.
There's no magic: non native controls are simply drawn on a blank window. Or, instead of being drawn they may be represented as one of several bitmaps based on state (ie: a button may be represented as a .png for the normal state, another .png for the pressed state, etc)
I have a VB6 program which uses comctrl32.ocx to display a progress bar. I've also had programs using mscomctl.ocx. However, it is displaying it using the ugly, old-style blue boxes progress bar instead of using the new-style progressbar (which presumably varies depending on the OS). Other programs which reference that same ocx file display the new-style progressbar (unless I run them VB6, in which case they still use the ugly one). All of the properties of the control are the same. Any suggestions on what I'm doing wrong?
Most likely, your application doesn't have a manifest and therefore uses the old pre-Windows XP style common controls. vbAccelerator has a great article on how to add one