If you look at the thumbnail images in Windows Explorer you'll notice that they have a drop shadow, is this effect associated with the ListView control or does Windows Explorer does some extra coding to accomplish this effect?
Edit:
So it turned out that Windows uses another control. So my question now is how can I add a drop shadow to the "normal" ListView.
For a standard list view, you may want to use a technique called custom draw (https://msdn.microsoft.com/en-us/library/windows/desktop/ff919569(v=vs.85).aspx).
Basically, you ask your list view not to draw its items, but instead send you some window messages for you to draw them yourself. This is a very flexible but also troublesome technique, because you need to handle many things (like whether an item is selected/disabled, font, color etc.)
The drop shadow you see in Windows Explorer is not publicly available for you to use. So you will have to custom-draw the items (NM_CUSTOMDRAW) by yourself.
Not sure if such effect is available in GDI/GDI+, but Direct2D does have one: https://learn.microsoft.com/en-us/windows/win32/direct2d/drop-shadow
Related
Visual Studio's windows have a close button (as well as other frame controls) that blend into the caption color and appear like so:
I was wondering if there's an accepted way of drawing controls like that. Do controls like these use DrawFrameControl or DrawThemeBackground, or do they use another approach altogether?
Thank you for any information.
There are two approaches for creating custom buttons using Win32 API:
1. Draw the control yourself. This is very complicated and requires a lot of knowledge about Win32 controls. Here are some links to get you started:
https://learn.microsoft.com/en-us/windows/win32/controls/user-controls-intro
https://www.codeproject.com/Articles/646482/Custom-Controls-in-Win-API-Control-Customization
Owner-drawn button, WM_CTLCOLORBTN and WM_DRAWITEM (clearing an HDC)
2. Modify an existing control using SubclassWindow. This is much easier, but in most cases very limited.
For example you can use a static control and handle mouse activity for it. You can also use multiple controls and show and move them as needed.
There is no set way of doing this since it's custom logic. But here are some links:
https://learn.microsoft.com/en-us/windows/win32/controls/window-controls
https://learn.microsoft.com/en-us/windows/win32/inputdev/mouse-input
https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-mousemove
I want to add checkboxes to my CListCtrl-derived class, that has LVS_OWNERDRAWFIXED-style for drawing them in any subitems. I can draw them simple inside DrawItem member function, but it look a little bit bad. How can I retreive the images of checkboxes, which are used for this control, if the LVS_EX_CHECKBOXES-style is set? It is important, because in each Windows version those checkboxes have its own unique look.
Is it possible?
You call OpenThemeData() to get the current theme's handle and then GetThemeBitmap() to get the images for the checkboxes.
Also have a look at the other GetThemeXXXX() functions to get the correct background
color, text color, font etc.
I also recommend you to play around with ThemeExplorer, it should give you
a great overview how visual styles work. The best thing is, the tools actually uses
OpenThemeData() & co. to render a preview of the controls, so check out its source code (main.cpp, Line 142+) as well!
I am trying to place some overlay text over a wxPanel.
I have several panels with completely different Content but I want to place this overlay text over all of these panels in the top right Corner of the panel.
I am restricted to wxWidgets 2.8.12..
Do you see any way to achieve this behaviour?
Edit:
Here a bit more detailed Version of what I am trying to do:
I have a Layout that consists of e.g. 5 containers and each container can contain a module. A module can be either wxPanels that contain Plain text or Input controls or for example a OpenGL canvas or an Image or something else.
Because I have much content and it does not fit on a single page I want to make the modules inside a Container exchangeable. It would be also nice if the user is able to perform this action only by using its keyboard. E.g. if he presses the key "3" the content of the third container has to be switched.
To handle these shortcuts isn't a problem. However I need to signalize to the user the identifier / hotkey of the containers.
I could do this by placing a additional headline above each container, but I want to waste as little space as possible on the gui.
I also could draw directly to the modules content, but I would have to do this for every module and every module is designed in a different way (images, multi column, opengl, ...) and maybe even by different persons.
So I am looking for a simple solution to indicate the number of these containers that does not consume that much space.
Thanks for your help
You can use a wxWindowDC to draw anywhere on the window, even on child windows. However anything you draw will be painted over whenever the windows or controls repaint themselves. You can draw your overlay in an UpdateUI event handler to minimize this. I have used this approach with success on Windows with wxWidgets 2.8.12. Not sure if it works with OpenGL though.
Main aim is wanting to draw Tab's within the draw area of the Toolbar of the Applicaiton for a NoteBook or Tab's to use the above space instead of being bellow the toolbar.
The frame work we're using is WxWidgets, C++/C. I have looked around but have not been able to find a solution or if anyone has done a similar approach with drawing tab's actually inside the toolbar itself.
I read some Microsoft MSDN articles and they recommend against controls drawing over controls.
I did some test's today, and think I've come up with a solution. My solution is to draw the window like normal, but have the NoteBook on the right in a child window that is dynamically resized and repositioned so that it's tab's are overlay on-top of the toolbar to make the most effective use of the area. I would have to deal with on focus and lose focus window messages, but this is the most elegant way I can think about achieving the task.
Any Idea's you can recommend or problem's I may face with following this approach.
I would be concerned about using overlapping widgets like this. Although it may not look quite the same visually I would suggest looking at wxToolBook which puts tabs in a toolbar and would solve your problem, you could use the GetToolBar method to insert your own toolbar items.
If that wasn't close enough visually to what you are looking to achieve I would suggest deriving a new control from wxBookCtrlBase and then creating a tab control with custom drawn tabs which you could add to the toolbar using wxToolBar::AddControl.
I'm trying to find a simple way to change the colour of the text and background in listview and treeview controls in WTL or plain Win32 code.
I really don't want to have to implement full owner drawing for these controls, simply change the colours used.
I want to make sure that the images are still drawn with proper transparency.
Any suggestions?
Have a look at the following macros:
ListView_SetBkColor
ListView_SetTextColor
TreeView_SetBkColor
TreeView_SetTextColor
There are also appropriate methods of the CListViewCtrl and CTreeViewCtrl wrapper classes:
GetBkColor
SetBkColor
You may also want to take a look at WTL's CCustomDraw::OnItemPrePaint (that's if you need to control the drawing of individual items)
A good article that describes this process is here
It's been a while since I've use the win32 API directly, but I believe that if you handle the WM_ERASEBACKGROUND message for your control, you can use FillRect() in your handler to paint the background using whatever color you like.