News:

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

Vista Visual Theme Only Skins One Dialog

Started by c_07, August 18, 2007, 09:43:47 PM

Previous topic - Next topic

c_07

Hi,
I would like to apply the Windows Vista/XP visual styles to my dialogs (invoked from an add-in DLL), but so far I have only had partial success: I created a manifest, and added it to my project which created the declaration line in a .rc file:
#define MANIFEST 24
#define RT_RESOURCE 2
RT_RESOURCE MANIFEST  DISCARDABLE "IXModule.xml"

I use RadAsm, and I added the manifest with the "Add resource" option. As you can see above, I changed the RT_RESOURCE from 1 to 2 after browsing a few forums, because the previous way did not work. Now that RT_RESOURCE is defined as 2, the skinning works -- but only on the first dialog! All others, in the same resource section, are NOT skinned. !?

Does anyone have an idea of what may be preventing the visual style from being applied to the other dialogs, and what I can do to correct it?
Thank you!

Tedd

The following is correct..
#define RT_MANIFEST 24
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "myapp.manifest.xml"

'2' would be "ISOLATIONAWARE_MANIFEST_RESOURCE_ID" (whatever that does :lol)

For the dialog resources, define them with DIALOGEX rather than plain 'old' DIALOG; and make sure you InitCommonControls in your app (I usually do it as the first thing in WM_CREATE.)
No snowflake in an avalanche feels responsible.

c_07

Thank you for your reply, Tedd -- but I have repeated all the above steps again as you show, and my problem remains the same. (Except for CREATEPROCESS_MANIFEST_RESOURCE_ID which I kept at 2: declaring it as a "1" as in normal Apps does not work at all in my dialog-from-DLL-case). It seems that the main dialog, and dialogs directly called from the main dialog are skinned correctly, but in any other place in my code, if I display a dialog, it is NOT skinned! ??? - Does not make sense to me. I have tried calling InitCommonControls for each one to no avail. They are all DIALOGEX with nearly the same exStyles. MSDN isn't very helpful here!  :dazzled:

jdoe

c_07,

Are you saying that your dialog is in a DLL and invoked from there. Sorry my english is not very good sometimes and I want to be sure.
If so I can help you I think.


Timbo

Greetings,

Could you provide some source to look at?  Also, InitCommonControls() actually doesn't do anything but force the linker to pull in comctl32.  You should be putting it in the DLL source somewhere, as this is the best way to make sure that comctl32 is loaded before your DLL and application are (due to the way the module loader works).

You might also be facing a threading problem here.  The fact that the dialogs appear skinned on one thread and not another points to this possibility.  Are the dialogs modal?

Regards,

Tim

jdoe

#5

If the dialog is in and invoked from a DLL, I think the problem is that you need an Activation Context to be declared before loading it.
The code below is the one from a shell context menu (.dll) I'm working on and visual style show up as it should on XP and Vista.


In your resource file you need this...



#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID  2
#define RT_MANIFEST  24

ISOLATIONAWARE_MANIFEST_RESOURCE_ID  RT_MANIFEST  "MANIFEST.XML"




Search MSDN for the ACTCTX structure

Before loading the dialog...



.if (dwWinVerMajor == 5) && (dwWinVerMinor >= 1)

    mov l_actctx.cbSize, sizeof ACTCTX

    mov l_actctx.dwFlags, (ACTCTX_FLAG_HMODULE_VALID or ACTCTX_FLAG_RESOURCE_NAME_VALID)

    lea eax, l_szProgPath
    mov l_actctx.lpSource, eax
    invoke GetModuleFileName, hInstance, eax, lengthof l_szProgPath

    mov l_actctx.wProcessorArchitecture, NULL

    mov l_actctx.wLangId, NULL

    mov l_actctx.lpAssemblyDirectory, NULL

    mov l_actctx.lpResourceName, ISOLATIONAWARE_MANIFEST_RESOURCE_ID

    mov l_actctx.lpApplicationName, NULL

    mov eax, hInstance
    mov l_actctx.hModule, eax

    invoke CreateActCtx, addr l_actctx
    mov l_hActCtx, eax
    .if (eax != INVALID_HANDLE_VALUE)
        invoke ActivateActCtx, l_hActCtx, addr l_dwCookie
        .if (eax == FALSE)
            invoke ReleaseActCtx, l_hActCtx
            mov l_hActCtx, INVALID_HANDLE_VALUE
        .endif
    .endif

.endif




When your done with the dialog...



.if (dwWinVerMajor == 5) && (dwWinVerMinor >= 1) && (l_hActCtx != INVALID_HANDLE_VALUE)

    invoke DeactivateActCtx, 0, l_dwCookie
    invoke ReleaseActCtx, l_hActCtx

.endif




Don't forget  "invoke InitCommonControls"


Voilà

:8)



EDIT:  There is an error in the source above about the Windows version for Vista but I'm sure you'll see it.