Making a vb.net application blend in with the Windows theme - windows

Previously I used to piddle around with VB6 to develop a couple of personal projects. Following my upgrade to Windows 7, I've decided to piddle about with vb.net Express Edition 2010.
If I wanted my VB6 application to blend in with the visual style of Windows, I would use the code and techniques described here. In short, I would use a Manifest file and a couple of calls within the application and most of the elements would look similar to the XP theme applied. If it was run on 2000, 95 or 98 then it would look like a standard Windows app. All was good.
Now I've moved onto vb.net, I've written a simple "Hello, world" application but I have absolutely no idea on how to make it look like the Windows 7 theme (eg. the font matches the system font and the widgets are styled correctly).
Just changing the font is a hack and will look out of place on machines that are set-up differently or run a different version of Windows where the default font is different.
How do I ensure my application matches the applied Windows theme irrespective of the version of Windows?

A lot of this is automatic if you create a Windows Forms app. They will (mostly) use the standard native Windows controls which draw themselves with the theme colors. But there are exceptions:
the Form item template uses a default Font named Microsoft Sans Serif. You'll have to change it to Segoe UI to match the Vista/Win7 default. This is only necessary for the Form class, all controls you put on it will automatically inherit that font. On an XP machine, the Windows font mapper will notice that the font is missing and automatically fall back to MSS.
the MenuStrip class uses custom rendering to draw the menu items. It tries to match the Windows style when you change the RenderMode property to System but the way it draws doesn't match the Win7 style. Right-click the toolbox, Choose Items and select MainMenu. That's a legacy version that does use Windows to draw menus so it produces the proper theme appearance.
A very similar problem for ToolStrip. It's legacy version is ToolBar. This is a hard one to swallow, it doesn't use a rebar which make the tool bar look flat and ugly.
There are similar problems in WPF but with the added problem that WPF doesn't use any of the standard Windows controls. And gets it wrong in subtle places.

Related

Why does a Lazarus form look 'incorrectly different' on Windows

I create my programs on Ubuntu 12.04 and compile them on Windows (when necessary).
Recently I noticed that my Lazarus projects look different on Ubuntu and Windows. The problem is on Windows XP, 7 and 8. I'm not sure if Vista looks the same.
For example, group boxes containing radio buttons look shrunk in height, thus hiding parts of the components.
Now I have to edit this forms on Windows before compiling for those platforms. What's worse is that when I bring these project back to Ubuntu, the forms looks unnecessarily stretched out (in height).
Is there a solution to this?
Thanks!
It is easily to check if the controls themselves have the same height(just query their left and top properties and dump it in a memo or log for verification)
If that is ok, it is probably the font. Default fonts are subject to themes, and sometimes readability/disability settings.
Consistent cross-platform look is not a trivial task and does not come at no-cost.
Read http://wiki.freepascal.org/Autosize_/_Layout, especially the part that can scale controls on your form depending on the font size that the end user has configured in the Control Panels
Read few chapters from Google: "windows dpi aware applications"

Windows - Force a specific program to use an installed third party windows theme

Is there a way to force a program (Eclipse Kepler in my case) in Windows 7 to use a 3rd party installed theme? I do not want to change the OS theme altogether. All other programs should use the default (Aero in my case) theme. So I am looking for some command line parameter, may be, which can dictate Eclipse to use a specific theme. Is this possible?
Here is an explanation of why I am looking for this solution -
I wanted to completely change the look of Eclipse to a dark theme. I am using 'Oblivion' theme for Eclipse editor and 'Juno Dark' theme for other parts of eclipse. This leaves out certain scrollbars and other areas still inheriting white windows colors. For that I installed third party Windows OS themes. This solves the problem of styling Eclipse to a completely dark look... however I do not wish to change the look of the whole Windows 7, only eclipse.

XP-Styles not working for ListView or ComboBox in Windows XP

I am using a Manifest for XP Styles, so all my controls are using the new look. However if I run my program in Windows XP then my ListView controls are displaying with the old style flat headers. Also the HDS_NOSIZING style is not working for the headers. This seems to imply that XP is using the old Common Controls 5.0 version of the listview instead of 6.0.
I'm very confused about this whole thing. I read that Common Controls 6.00 ships with XP, so why can't I use the latest ListView with XP?
I read on another page that XP-Styles only work in XP for Common Controls 5.0 ListViews but not for 6.0. So if it is indeed using 5.0, then shouldn't it apply the new XP-Styles to listviews anyway?
Is it actually possible to use the Common Controls 6.0 version of some controls and the 5.0 version of others?
Also one other thing. In XP my ComboBox Drop-down lists appear like regular Combo boxes instead of like Buttons as they do in Win7. Is this normal?
Thanks for your help as I find this whole Common Controls 6.0 + XP Styles concept very confusing.
You are hoping to see Windows 7 styles back on Windows XP. That's not going to work. XP will show flat headers, HDS_NOSIZING is only supported in Vista and up. Similarly, combo boxes with the CBS_DROPDOWNLIST only appear as buttons in Vista and up.
In all likelihood, your program is working exactly as it should and is displaying proper XP styles. You can double-check with a debugger. Debug + Windows + Modules and look at the version number of the loaded comctl32.dll

How to avoid theme (lite&dark) efects on windows phone applications?

I developed one Windows Phone 7 application.
After installed the app to my mobile device (in emulator too) I'm experiencing the theme problem.
Means there are two themes in windows phone, LITE and DARK.
When I set my theme to dark and execute my app , it looks OK,
but if I change the theme to LITE everything is reverted.
It means white lables become black, and black background become white.
So I need a solution to my app, so that the user can set any theme, but it doesn't effect the appearrence of application.
Don't hardcode colours, brushes, etc, but instead use {StaticResource ResourceName} and use resources from Theme Resources for Windows Phone
Make sure that every TextBlock and TextBox has a Style associated with it (available values from the same link)
If you have have custom resources (colours, images, etc) that you wish to be theme-aware you are free to use the ThemeResourceDictionary I posted on my blog (and also for this SO question). I promise to commit the code to GitHub one of these days and also create a NuGet package.

How can i change the appearance of Windows 7 menus?

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.

Resources