views:

437

answers:

4

I'm buisy on a DirectX10 game engine and i'm having a problem which has nothing to do with DirectX :P The problem is that in the DLL which contains the engine sometimes a DialogBox is called, just like you would do in normal win32. With the only difference that instead of the HINSTANCE i use the HMODULE which i get when loading the DLL.

Everything seems to be working fine, if i step through my code with F10 (Visual C++ 2008) i can even see it going through my DlgMessageProc function and do everything it should do. The only weird thing is that no dialog is shown and that all of a sudden it jumps out of the message loop and just continues with the rest of the code???

Weirly engough I have the same problem when calling MessageBox from inside my DLL, I get no errors, everything seems to be working fine but no window is shown, nor is the code halted (as normal with messageboxes)

The funny thing is that I have some code from a book which uses the same basic architecture as me and if i compile that everything shows just fine??

So my question, is there any hidden option, pragama comment or other thing i should look at if i want to be able to show MessageBoxes and Dialogs from my Dll?

A: 

In the visual studio resource editor's property page for the dialog resource there should be an option in which you can specify - "No Fail Create: True".

Usually dialogs fail to create because a common control cannot be created - usually because InitCommonControlsEx has not been called. Setting the No Fail Create flag lets you see dialog and determine which controls are missing.


Other things to check:

  • Is there a message in the debug window about a first chance exception? Perhaps its 'jumping out' because of an exception that is being caught and silently handled by Win32. Turn on debugging of first chance win32 exceptions in the Dev Studio exceptions dialog to track that down.

    Even this wouldn't explain how a MessageBox call would fail to create a message box.

  • The only times Ive seen MessageBox fail to work were when:

    1. Resource leaks had made the process run out of available user32 handles - have you checked your apps handle counts using task manager?
    2. the system was in the process of being shut down. Have you called PostQuitMessage and then tried to create a dialog/MessageBox?
Chris Becke
No, sorry it doesn't work. BTW, i did call InitCommonControlls and adjusted my manifest so I get XP/VISTA style buttons, could that influence anything? Another mysterie is why i have the same problem with MessageBoxes? Those should be completely handled by Windows. I have the feeling that i need to link something extra or set a commandline option but i have absolutely no idea.I'll try and see if i can rebuild my solution without the adjusted manifest, but i don't think it will do much.
Rik Nauta
I restarted my system and ran the solution but nothing happend. Then I added a messagebox to a static library which is also called and found out the problem is even worse. I have this static library which has to functions, create device and release device, and if i put a message box there nothing happens either. If i put a message box in the main of the exe file which links to the .lib there is a normal message box. So there is nothing wrong with my system!!!!! Nor did i find any errors, or warnings in my debug output window
Rik Nauta
A: 

No as i thought, chaning the manifest doesn't help at all. I also created a separate project where i just test the dialog and its proc function and there everything works perfect (links to a .exe instead of dll)

Rik Nauta
A: 

I catched all the messages which are being sent to my dialog, and there are some which i can't find defined. The weird part is that indeed a WM_ACTIVATE message gets send but both the lParam and the wParam are 0. The wParam should be the window handle??? i have no idea what is going on. Here is the complete list: (PLEASE HELP ME :(

WM_SETFONT = 0x30
WM_INITDIALOG = 0x110
WM_WINDOWPOSCHANGING = 0x46
WM_NCACTIVATE = 0x86
WM_ACTIVATE = 0x06
UNKNWON MESSAGE = 0x127
UNKNOWN MESSAGE = 0x31F
UNKOWN MESSAGE = 0x90
WM_DESTROY = 0x02
WM_NCDESTROY = 0x82
Rik Nauta
A: 

Ok, update:

I found out that is has something to do with the manifest. I completely deleted all the #pragma's concerning that, and all the InitCommonControls calls and did a complete rebuild of the solution. Then i loaded the dll in my testing solution and fired it up. What happened then is that is see the Dialog verry briefly, about 0,5 second before my app storms on and starts up. I still don't understand why it doesn't stop when it opens the dialog or MessageBox. I am not manually multithreading or anything like that Any more suggestions?

Rik Nauta