News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

XP "look"

Started by Retsim_X, April 19, 2005, 02:42:30 AM

Previous topic - Next topic

QvasiModo

To use XP themes, just copy & paste the manifest file contents, and rename to whatever your app is called, but with the ".manifest" extension appended. If you want to use just the executable instead, add the file as a resource with ID 1 and type 24. That's it. :)

Once you've done all that, you can forget about that manifest thing. Unless you're writing a custom control (and that is when things gets messy).

IMHO things were made quite simple for a reason: updating any app to work with XP themes just involves addin a single file to your program. No extra code, no XP detecting, nothing.

Another thing: I've found that manifest files should not have tab characters (ASCII 09), or Windows will refuse to load your app.

pbrennick

QvasiModo

So you are saying I do not need:


; how to enable XP-themed controls
include    ComCtl32.inc
includelib ComCtl32.lib

invoke InitCommonControls


in the .asm file or:


XP 24 DISCARDABLE "YourApp.exe.manifest"


in the .rc file?  And what about:


Here's where things get funky: renaming the executable seems to invalidate the XP theme.
Also renaming or deleting the .manifest file invalidates the XP theme. Furthermore,
the v6.x.x.x Common Controls library is NOT redistributable, so this is an XP-only hack. Lastly,
and most absurdly, only create a .manifest file for XP apps using an XP theme... the .manifest
file just being  present  might mess up a non-XP-themed app! For example, if you create a
.manifest file for an existing (non-XP theme) application which doesn't use ComCtl32 and
InitCommonControls, the application may refuse to run! Try commenting out those lines of the
sample included. The result simply exits.


This is definitely getting confusing to me.  MSDN agrees with Mark and not you:

Quote
To create a manifest and enable your application to use visual styles.

Link to ComCtl32.lib and call InitCommonControls.
Add a file called YourApp.exe.manifest to your source tree that has the XML manifest format.

In a later paragraph it says:

Quote
Add the manifest to your application's resource file as follows:
MANIFEST_RESOURCE_ID RT_MANIFEST "YourApp.manifest"

//Winuser.rh includes the following defines:
//#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1

Did you look at MSDN?

Paul

Mark Jones

Aaaha, QvasiModo has a point, thank you. Changing the .rc file contents to:


1 24 "YourApp.exe.manifest"  ; needed for XP theme


will yield an executable that is no longer dependant on the .manifest file. Interestingly, RT_MANIFEST will not work in place of 24 in that line, even though RT_MANIFEST is set to 24 in windows.inc? No error is generated.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

pbrennick

Mark (and QvasModo),
I will test this and tell you what I get.  I can test it on XP and then move it to my ME testbox without the manifest and see what happens.

I wonder why MSDN just does not say this.  It appears to say something like this at the start of the thread and then it goes into the usual hoopla  :lol

If this works, as QvasiModo says - problem solved!!

Paul

pbrennick

Hi Retsim x86,
Sorry we took control of this thread but you struck a chord that needed to be dealt with.  I am sure you are learning some fastinating stuff in answer to your question.

Paul

pbrennick

Mark and QvasiModo,
It works just fine, since yuz guyz did such a terrific job on this, I am going to create my own topic and ask a similar question.

Paul

farrier

My code used in JACTS to check that users COMCTL32.DLL is at least 4.70--needed for datetimepicker functionality

lib_name    db  "\comctl32.dll", 0           ;library for DateTimePicker
dgv         db  "DllGetVersion", 0           ;function to check version of DLL


lib_handle  HWND    ?                        ;Handle to check for dll version
d_buffer    BYTE    MAX_PATH + 1 dup (?)     ;allows us to read MAX filename size and 0
align 4
dvi         DLLVERSIONINFO  <>               ;Structure for Dll Version Info


    invoke  GetSystemDirectory, addr d_buffer, sizeof d_buffer
    invoke  lstrcat, addr d_buffer, addr lib_name
    invoke  LoadLibrary, addr d_buffer
                                        ;Load comctl32.dll to see if we have at least version 4.70
    mov     lib_handle, eax             ;save handle
    invoke  GetProcAddress, lib_handle, addr dgv
                                        ;get address of DllGetVersion within comctl32.dll
    mov     proc_add, eax
    invoke  RtlZeroMemory, addr dvi, sizeof DLLVERSIONINFO
                                        ;set DLLVERSIONINFO Stru to zeroes
    mov     dvi.cbSize, sizeof DLLVERSIONINFO
    push    OFFSET dvi                  ;push structure address for DLLGetVersion
    call    proc_add                    ;call COMCTL32.DLL's DllGetVersion routine
    cmp     dvi.dwMajorVersion, 4       ;major version should be at least 4
    ja      ok
    jb      not_ok
@@: cmp     dvi.dwMinorVersion, 70      ;minor version should be at least 70
    jae     ok
not_ok:
ok:



hth

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

sluggy

Quote from: Mark Jones on May 06, 2005, 06:17:48 AMFurthermore, the v6.x.x.x Common Controls library is NOT redistributable, ....
This is only marginally correct. The dll by itself is not redistributable, however MS release the COMCTL32 merge module which you can include in your installs. MS don't allow you to ship the dll only as you would be missing all its dependancies and registry entries.

Quote from: Mark Jones on May 06, 2005, 06:17:48 AM..... so this is an XP-only hack.
Correct, because only XP onwards has the theming subsystem.




pbrennick

Sluggy,
I read what MSDN said about the DLL not being redistributable but I sure missed any talk about a freely released library or is it only 'technically' free as long as you purchase one of their developmental software packs.  If the last is so, then it ain't free.  Where can I find this library?

Paul

sluggy

Paul,
we (the company i work for) actually use Wise and InstallShield, and get a whole lot of merge modules with those products. But having said that, the modules are released by MS and just distributed through those companies. I would check out the Windows Installer SDK which is part of the platform SDK, the modules should also be either in there or available from there (ie by link in the documentation).

Mark Jones

Sluggy and Paul, is a "merge module" something I (a hobbyist code warrior) could redistribute with my apps? And would this really allow other versions of MS Windows to display the XP-style buttons and curved window edges? Or just prevent those apps from crashing. :toothy

Also thanks Farrier, that code is very helpful. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

sluggy

#26
Quote from: Mark Jones on May 07, 2005, 02:01:04 PMSluggy and Paul, is a "merge module" something I (a hobbyist code warrior) could redistribute with my apps?
Yes. A merge module (file with an .msm extension) is a component that gets included when you compile an msi/exe install using the proper Windows installer technology. MM's are no good by themselves, so you if you distribute your app in a WinRAR/Zip package then there is no point including the MM as you can't use it. However, if you pick up the Windows Installer SDK and start building proper installs then you can include the merge module. And you will get a bunch of other features like proper uninstalling, inclusion in the add/remove programs applet, feature advertising (install upon demand), and application repair. If you learn this stuff then you actually move from being just a hobbyist to having some commercial skills :U


Quote from: Mark Jones on May 07, 2005, 02:01:04 PMAnd would this really allow other versions of MS Windows to display the XP-style buttons and curved window edges?
No, only XP onwards has the themeing system. In prior versions of Windows the manifest file will be ignored, the problem that you would strike is if you linked to a version of comctl that was too high (in the past MS have broken binary compatability in this area, meaning that a later version is not always compatable with an earlier version.)

QvasiModo

Quote from: pbrennick on May 06, 2005, 10:59:01 PM
QvasiModo

So you are saying I do not need:


; how to enable XP-themed controls
include    ComCtl32.inc
includelib ComCtl32.lib

invoke InitCommonControls


in the .asm file

My bad, I forgot to mention that your app has to link to comctl.dll, since that library is the one that actually implements the themes support. Sorry! :(

Quoteor:

XP 24 DISCARDABLE "YourApp.exe.manifest"


in the .rc file?

That's right, having the file is enough, if the filename is correct. The resource script is the alternative if you don't want an extra file.

QuoteAnd what about:


Here's where things get funky: renaming the executable seems to invalidate the XP theme.
Also renaming or deleting the .manifest file invalidates the XP theme. Furthermore,
the v6.x.x.x Common Controls library is NOT redistributable, so this is an XP-only hack. Lastly,
and most absurdly, only create a .manifest file for XP apps using an XP theme... the .manifest
file just being  present  might mess up a non-XP-themed app! For example, if you create a
.manifest file for an existing (non-XP theme) application which doesn't use ComCtl32 and
InitCommonControls, the application may refuse to run! Try commenting out those lines of the
sample included. The result simply exits.


This is definitely getting confusing to me.  MSDN agrees with Mark and not you:

Quote
To create a manifest and enable your application to use visual styles.

Link to ComCtl32.lib and call InitCommonControls.
Add a file called YourApp.exe.manifest to your source tree that has the XML manifest format.

In a later paragraph it says:

Quote
Add the manifest to your application's resource file as follows:
MANIFEST_RESOURCE_ID RT_MANIFEST "YourApp.manifest"

//Winuser.rh includes the following defines:
//#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1

Did you look at MSDN?

Yes, I did. And you too... but you were reading about two different techniques! ;)

pbrennick

QvasiModo,
Thank you.  I have already discovered you are correct in this.  I even posted that.  Did you miss this?

Quote
Insert Quote
Mark and QvasiModo,
It works just fine, since yuz guyz did such a terrific job on this, I am going to create my own topic and ask a similar question.

Anway,
Thank you again for solving my problem.  Your solution is very simple and downwards compatable which is something I really needed!

I have been so busy in the last 2 days that I have not started my topic on a similar problem as of yet.  I will do so ASAP.

Paul

QvasiModo

Quote from: pbrennick on May 08, 2005, 01:48:26 PM
QvasiModo,
Thank you.  I have already discovered you are correct in this.  I even posted that.  Did you miss this?

Yep, I just browsed the topic... :red