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

Retsim_X

hey guys,

how do you get the xp look in your applications?

like the edit boxes that have that thin blue border and buttons with round couners????

also is there any good xp api help files.

and does anyone know where i can get the XP api library's?

thanx.

wizzra

you should usually learn to search the site first,
but, ah well,
u need to 'Manifest' your resource (it is done by using an XML declaration)
either by using a 3d party file that must be shifted with ur exe, or internally compiled with ur resource

see here: http://www.mctainsh.com/Csharp/XpControlsInCS.aspx

thomasantony

Quote from: wizzra on April 19, 2005, 06:09:57 AM
you should usually learn to search the site first,
but, ah well,
u need to 'Manifest' your resource (it is done by using an XML declaration)
either by using a 3d party file that must be shifted with ur exe, or internally compiled with ur resource

see here: http://www.mctainsh.com/Csharp/XpControlsInCS.aspx
Hey,
I have never heard of that stuff before and I call myself a hardcore win32asm programmer. The only MANIFEST files I knew so far were those used by Java executable JAR files in which they define the executable class name. Nice info

Thomas :U
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

Mark Jones

That is a nifty trick... but isn't it for .NET code?
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Retsim_X

so does that mean that the RadASM ide has manifests in its dialog editor??

still need help with xp api libs and help file

Nilrem

The link gives me a time out. 8-(

wizzra

Quote from: Mark Jones on April 19, 2005, 02:38:55 PM
That is a nifty trick... but isn't it for .NET code?

it is supported by XP and above OS.

Mark Jones

Aaah, that text above is in fact compatible with MASM32, but not without a slew of gotchas. Here's the lowdown:


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

invoke InitCommonControls

; put this in the .rc file, updating YourApp with real executable name
XP 24 DISCARDABLE "YourApp.exe.manifest"

; create this file: YourApp.exe.manifest using real executable name
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
    xmlns="urn:schemas-microsoft-com:asm.v1"
    manifestVersion="1.0">
    <assemblyIdentity
        version="1.0.0.0"
        processorArchitecture="X86"
        name="Company.Product.Application"
       type="Win32"
    />
<description>Your application description here.
    </description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>
</assembly>


More info at MSDN. For me it still works if I omit the resource file data, (and the executable shrinks by 1kb as the .manifest file is not included in the compiled code) but I don't think this has any influence on its operation. The project is attached.

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.

Suddenly, .manifest files have become rather important. I remember the days when those came in shareware archives to outline the package contents, like a directory listing. Since they were rather redundant, I bet more than a few file-deletion utilities mark those as junk by default.  :dazzled: :naughty:

What a confusing bunch of hooey-gooey! ::)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

sluggy

I haven't done a lot of messing with manifest files, but here are a couple of pointers for things i have experienced while putting together installs and bug fixing applications:

- having a correct manifest file but *no* call to InitCommonControls will usually cause your app to fail with a fairly random error message, the message you get will not give you a clue of what the real problem is. Delete the manifest file and the app will run perfectly.

- having a corrupt manifest file can cause your app to crash. To check if the file is ok and doesn't contain any non printable chars that corrupt it, just try and open it in IE, if IE complains or can't render it properly then the file needs to be fixed.

- it doesn't matter what you put in the data sections of your manifest file (i.e. your correct app name doesn't have to be in the name attribute of the assemblyIdentity node), as long as the file itself is named correctly it is still valid for your exe.

- if you *do* call InitCommonControls but have no manifest file, your app will still work, it just won't be XP themed. The manifest file simply specifies the minimum version of the common controls to load.


Mark Jones

Oh yeah, attaching the file would help. :lol

[attachment deleted by admin]
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Rifleman

Hi Mark,
I tried your ideas on my Editor and they worked like a charm.  However, I think it is too soon to write XP specific code (too many other versions of Windows still being used) and to write code to detect XP is too much bother and also will always bump heads with win2k using the 'NT' test or the 5.00 test at this point.

Paul

Mark Jones

Hi Paul, perhaps one way to identifiy WinXP is from the fact that only ComCtl32 v6.x.x.x is included with XP. Can you poll that file for its version? Version-checking sounds tricky. Is there no universal macro made for it yet? :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

pbrennick

Hi Mark,
Back using pbrennick for a bit, we will see what happens.  Anyway, don't talk about that in this thread.

Your proposal to poll Comctrl32.dll for version info should work as a good test.  Are you certain that the v6.x.x.x Common Controls library is not used by win2k?  I have no way of testing this.  If it is truly an XP only hybrid then this is an excellent test method.  Wish I had win2k, though!

Paul

MichaelW

Windows 2000 Pro SP4, comctl32.dll, 5.81.4916.400

eschew obfuscation

sluggy

Quote from: Mark Jones on May 06, 2005, 05:23:33 PMperhaps one way to identifiy WinXP is from the fact that only ComCtl32 v6.x.x.x is included with XP.
That is incorrect. I have a fully patched XP system, with dev tools on it, and my version of comctl32 is 5.82.2900.2180.
If checking versions, you should only trust the versions of dlls that YOU have control over, you can never trust the versioning of third party dlls, as that third party can do anything they like with the version and that can break the logic in your code.