Author Topic: Classic vs. Modern Control Styles  (Read 12426 times)

squares

  • Guest
Classic vs. Modern Control Styles
« on: June 30, 2012, 06:50:40 PM »
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

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Classic vs. Modern Control Styles
« Reply #1 on: June 30, 2012, 08:01:39 PM »
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
Code: [Select]
        dd InitCommonControlsExthis 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

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Classic vs. Modern Control Styles
« Reply #2 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.

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

squares

  • Guest
Re: Classic vs. Modern Control Styles
« Reply #3 on: June 30, 2012, 09:26:30 PM »
Quote
the 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.

Quote
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
That's bizarre, I guess it's something to do with the way windows checks for the initialisation call.

Quote
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
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

  • Guest
Re: Classic vs. Modern Control Styles
« Reply #4 on: June 30, 2012, 10:40:45 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

  • Guest
Re: Classic vs. Modern Control Styles
« Reply #5 on: June 30, 2012, 10:57:12 PM »
the 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

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Classic vs. Modern Control Styles
« Reply #6 on: July 01, 2012, 01:14:45 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 6660
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Classic vs. Modern Control Styles
« Reply #7 on: July 01, 2012, 01:44:42 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

tenkey

  • Regular Member
  • *
  • Posts: 19
Re: Classic vs. Modern Control Styles
« Reply #8 on: July 01, 2012, 02:41:19 AM »
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

  • Guest
Re: Classic vs. Modern Control Styles
« Reply #9 on: July 01, 2012, 08:19:16 AM »
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

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Classic vs. Modern Control Styles
« Reply #10 on: July 01, 2012, 09:42:10 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 6660
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Classic vs. Modern Control Styles
« Reply #11 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Classic vs. Modern Control Styles
« Reply #12 on: July 01, 2012, 08:54:19 PM »
no window, here
i suspect it is as Michael says - Class Does Not Exist

i add the following
Code: [Select]
        .data

        dd InitCommonControls
and it works with XP theme

RuiLoureiro

  • Member
  • ****
  • Posts: 819
Re: Classic vs. Modern Control Styles
« Reply #13 on: July 01, 2012, 09:34:21 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

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Classic vs. Modern Control Styles
« Reply #14 on: July 01, 2012, 09:34:45 PM »
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.