News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Classic vs. Modern Control Styles

Started by squares, June 30, 2012, 06:50:40 PM

Previous topic - Next topic

squares

Is anyone able to tell me what the basic difference is between programs which have classic-looking controls and programs which have modern looking control styles?

I thought it might have been the use of a manifest file as I'd found these supplied with applications using modern controls, but then I found an almost identical manifest file with a program using classic controls... so no help there.


dedndave

the manifest file is only part of the equation
to get the "UxTheme" style controls, it is probably also necessary to call InitCommonControlsEx
InitCommon controls may work, rather than InitCommonControlsEx
- and - there was some discussion that the function need not be called, only referenced
for example, you might be able to place the function name in the data area
        dd InitCommonControlsEx
this may also work

i prefer to call it   :P

the UxTheme looks nicer, but comes at a cost
for some controls, it can be more difficult to subclass the control to get certain features
for example, it is hard to change the background color of a button without owner-drawing it

MichaelW

Under Windows XP I have not been able to get that exact behavior. With InitCommonControls or InitCommonControlsEx I get the newer button style, but without either of them the call to CreateWindowEx fails with a "Class does not exist" error.

Well Microsoft, here's another nice mess you've gotten us into.

squares

Quotethe manifest file is only part of the equation
That's wild! Thank you very much dedndave, that explains everything.
Is there also some kind of way to achieve the same effect without using manifest or resource files?
I realise that large projects are more difficult to maintain without these files.

Quotethere was some discussion that the function need not be called, only referenced
for example, you might be able to place the function name in the data area
That's bizarre, I guess it's something to do with the way windows checks for the initialisation call.

Quotethe UxTheme looks nicer, but comes at a cost
for some controls, it can be more difficult to subclass the control to get certain features
for example, it is hard to change the background color of a button without owner-drawing it
Right, I won't run into that issue any time soon, but thanks for the warning!

Thank you very much for all of your assistance!

The bare minimum msgbox code that I was mucking around with is attached if it's of any interest to anyone.

squares

Quote from: MichaelW on June 30, 2012, 08:37:05 PM
Under Windows XP I have not been able to get that exact behavior. With InitCommonControls or InitCommonControlsEx I get the newer button style, but without either of them the call to CreateWindowEx fails with a "Class does not exist" error.
That's weird, I'll have to cross that bridge at some stage, thanks for the heads up MichaelW

squares

Quote from: dedndave on June 30, 2012, 08:01:39 PMthe manifest file is only part of the equation
I just deleted the line invoke InitCommonControls and references to comctl32.inc & comctl32.lib and it still produces a UxTheme'd message box.
So it seems to only require a manifest file included as a resource.

dedndave

you will find that the behaviour is very OS-dependant
i guess you are using windows 7

i use a version of XP
if the manifest file appears without the InitCommonControls, the program will not run at all   :P

best thing you can do is to have someone test it under all OS's you intend to support   :t

hutch--

Its this simple with the SP3 XP I use, I can take an old program, Win2000 era, make an external manifest file for it and it displays the later controls. There is in fact good reason to include a manifest file as it does not matter on Win2000 but works on later versions to modernise the interface. Many more cynical than I would suggest that Microsoft used this technique to render older programs obsolete in terms of appearance but in most instances you can just add an external manifest.

tenkey

I have not checked this in a while.

When Win95 came out, you could switch between 3.1 style and Win95 style by setting the linker subsystem to 3.1 or 4.0.

squares

Thank you dedndave & hutch!

I do use Windows 7, although I just set up XP Mode (which is distributed with SP3 installed) to test this and now I see that you guys have already explained exactly what I found:

InitCommonControls call & manifest file    msgbox displayed with uxtheme
InitCommonControls call only    msgbox displayed without uxtheme
manifest file only    msgbox does not display at all
neither InitCommonControls call nor manifest file    msgbox displays without uxtheme


Enabling Visual Styles: http://msdn.microsoft.com/en-us/library/windows/desktop/bb773175%28v=vs.85%29.aspx
Application Manifests: http://msdn.microsoft.com/en-us/library/windows/desktop/aa374191%28v=vs.85%29.aspx

dedndave

i did a little more reading...

i learned something that i wondered about, before
that is - how do these UxTheme-enabled programs work under win 2000 ???
thing is - under win 2000, manifests are not supported
so - the OS does not recognize that there is a dependancy - and the EXE runs without it

hutch--

Here is a message box with a manifest, works on my XP and Win7 64 bit displaying the later interface.

dedndave

no window, here
i suspect it is as Michael says - Class Does Not Exist

i add the following
        .data

        dd InitCommonControls

and it works with XP theme

RuiLoureiro

Quote from: hutch-- on July 01, 2012, 03:30:40 PM
Here is a message box with a manifest, works on my XP and Win7 64 bit displaying the later interface.
we cannot see any message box it closes
              It works if we add what Dave post
        .data
        dd InitCommonControls

MichaelW

This has not worked the way I expected under XP. In my button in an app window example, if I include the manifest then I must do the InitCommonControls bit, or I get no button. If I forgo the manifest and the InitCommonControls then I get an old-style button. And the same for the msgbox example, except instead of no button I get no MessageBox dialog. It looks like if you include the manifest, then the old-style classes don't get registered. I guess Microsoft is done with them.

Come to think of it, with Windows 8 they appear to be done with a bunch of things that I've never even looked at :biggrin:
Well Microsoft, here's another nice mess you've gotten us into.