Enabling Visual Styles without using Manifest File

I'm writing an application which injects a DLL into a certain game, and my DLL then creates my application's user interface in the game's main thread (causing the game itself to execute my window's message loop between frames). This works, but the game doesn't enable Visual Styles, causing the user interface to look like it would on an older OS such as XP. It doesn't do this if I don't create the user interface from the game's main thread, but that's not possible with this app because it calls non-thread-safe functions in the game (i.e. it can only be done from the main thread).

Normally, I'd just add a linker directive to my DLL's UI's header file to enable Visual Styles, but it's being ignored, I assume because the process's EXE doesn't have Visual Styles enabled.

Is there any way to enable Visual Styles other than enabling them in the manifest file or using a linker directive (which actually just adds to the manifest file)? I've tried both of those, and neither of them work. Thanks.

Here's an article on Visual Styles: http://msdn.microsoft.com/en-us/library/windows/desktop/bb773175(v=vs.85).aspx
Use activation context APIs if you don't want to use a manifest, altough in your case maybe patching the game EXE file could be the only way:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <windows.h>

ULONG_PTR EnableVisualStyles(VOID)
{
    TCHAR dir[MAX_PATH];
    ULONG_PTR ulpActivationCookie = FALSE;
    ACTCTX actCtx =
    {
        sizeof(actCtx),
        ACTCTX_FLAG_RESOURCE_NAME_VALID
            | ACTCTX_FLAG_SET_PROCESS_DEFAULT
            | ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID,
        TEXT("shell32.dll"), 0, 0, dir, (LPCTSTR)124
    };
    UINT cch = GetSystemDirectory(dir, sizeof(dir) / sizeof(*dir));
    if (cch >= sizeof(dir) / sizeof(*dir)) { return FALSE; /*shouldn't happen*/ }
    dir[cch] = TEXT('\0');
    ActivateActCtx(CreateActCtx(&actCtx), &ulpActivationCookie);
    return ulpActivationCookie;
}
Topic archived. No new replies allowed.