Win32 Manifest Causes MessageBox to Not Appear

For testing purposes I've created a simple hello world messagebox in C++ and compiled with MinGW's g++:

hello.cpp:
1
2
3
4
5
6
7
8
#include <windows.h>

int main()
{
    MessageBox(NULL, "Hello World!", "Hi", MB_OK);
    
    return 0;
}


The app works fine, displaying the window.

I then created a manifest file and named it to match the executable.

hello.exe.manifest:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>Simple Dialog</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
	        type="win32"
	        name="Microsoft.Windows.Common-Controls"
	        version="6.0.0.0"
	        processorArchitecture="*"
	        publicKeyToken="6595b64144ccf1df"
	        language="*"
	    />
    </dependentAssembly>
</dependency>
</assembly>


But with the manifest there the window doesn't show up. I hear the beep notification of the messagebox, but nothing visually. I have tested that the manifest works for other apps. Does anyone know why the manifest prevents the window from appearing?
Last edited on
You should call InitCommonControls() or InitCommonControlsEx before doing some GUI stuff.
http://msdn.microsoft.com/en-us/library/bb775695(v=vs.85).aspx
Thank you.

1
2
3
4
5
6
7
8
9
10
#include <windows.h>
#include <Commctrl.h>

int main()
{
    InitCommonControls();
    MessageBox(NULL, "Hello World!", "Hi", MB_OK);
    
    return 0;
}


compile:
g++ hello.cpp -o hello -lcomctrl32

Although, MSDN says that I should use InitCommonControlsEx(), but if I try it the compiler complains that it is not defined:

error: 'InitCommonControlsEx' was not declared in this scope

Does MinGW not come with this function?
Try this..
1. Make all necessary files.

main.cpp
1
2
3
4
5
6
7
8
9
10
#include <windows.h>
#include <Commctrl.h>

int main()
{
    InitCommonControls();
    MessageBox(NULL, "Hello World!", "Hi", MB_OK);
    
    return 0;
}


resource.rc

1                 24                "manifest.xml"


manifest.xml

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>Simple Dialog</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
	        type="win32"
	        name="Microsoft.Windows.Common-Controls"
	        version="6.0.0.0"
	        processorArchitecture="*"
	        publicKeyToken="6595b64144ccf1df"
	        language="*"
	    />
    </dependentAssembly>
</dependency>
</assembly>


2. Compile the with this line.

windres -i resource.rc -J rc -o resource.res -O coff
g++ main.cpp -o main resource.res -lgdi32 -luser32 -lkernel32 -lcomctl32 -mwindows
Topic archived. No new replies allowed.