Archived

This topic is now archived and is closed to further replies.

00702000744

Directx + GUI == WHAT THE???!!!

Recommended Posts

00702000744    122
Hi: I am trying to create a modeless dialog in my directx program. But when the dialog is supposed to be showed after the call ShowWindow(..), only two buttons on the dialog appear. It is weir and I figured maybe this is a problem caused by conflict between GUI and Directx? Here is my code creating the dialog box: m_hDialog = CreateDialog(m_hInst, MAKEINTRESOURCE(IDD_MODIFY_DIALOG), m_hWnd, (DLGPROC)DialogProc); ShowWindow(m_hDialog , SW_SHOW); Any help will be appreciated!!!

Share this post


Link to post
Share on other sites
I''m not sure why, but when I make MessageBox() calls in fullscreen mode, they only show up half the time, and the other half of the time they seem to remain "Behind" the game, but still accept keyboard input.

This post has been totally useless!

Share this post


Link to post
Share on other sites
wah_on_2    122
I also meet this problem before. You need set the window style to CLIPCHILDREN

e.g hWnd = CreateWindowEx(WS_EX_APPWINDOW, "Game", "Testing", WS_BORDER | CLIPCHILDREN, ......);

and then use the DiretDrawClipper to show the GDI window component.

e.g
void FlipGDI()
{
m_lpPrimary->SetClipper(m_ddClipper);
m_lpPrimary->Blt(.............);
}

Share this post


Link to post
Share on other sites
a person    118
thats interesting. when i use d3d8 in window (even a fullscreen window) i have no problems with displaying comm dialogs (ie things like fileopen, file svae as, etc). i dont do anything special. in fact the only thing special i did was place the main game loop in a seperate thread so displaying a dialog would not lock my rendering up.

also you may want to have the dialog not be a child of your main window (this may be causing the problems). i dont, but it will still work as expected. not sure if this would be useful for custom dialogs, but worth a shot.

using a seperate thread is NOT the answer. it was working fine before i moved it over. are you doing anything special in wm_paint or wm_nccpaint? you should not be blitting to the screen at all. present() handles that for you.

also make sure your not doing anything funky in your call to present(). in most cases its should be Present(NULL, NULL, NULL, NULL).

Share this post


Link to post
Share on other sites
mutex    1111
DirectX 8 does not have a clipper object.

Abort_Retry_Fail, what is happening is that flipping surfaces is causing the main GDI surface to be hidden. Normally when you initialize DirectX, there is the initial front buffer, and one or more back buffers. That first front buffer is the buffer used by Windows GDI to draw stuff, even if it is hidden. Hence, half of the time that GDI buffer is in the back, and the message box cannot be seen. DirectX 8 does not have a FlipToGDISurface function that previous versions have, so I''m not sure how you would remedy that, besides keeping track of where the GDI buffer is in the buffer chain.

a person, I''m not sure if common dialogs will still work if you flip because of the GDI buffer thing. You can get around the problem by blitting from back to front, instead of flipping. I suspect that is what you did there.

00702000744, try messing around with your dialog box styles. You said this was in a normal window. Windows will clip dialogs in a normal window. Try adding the clip siblings and clip children styles to your dialog box like wah_on_2 suggested.

And now for the main purpose of my post, getting Windows GUI to work in full screen D3D 8 Because of the lack of a clipper interface and FlipToGDISurface in D3D 8, I resorted to a hack that involves DIB sections and WM_PRINT. You can read about it here.

Share this post


Link to post
Share on other sites
00702000744    122
Hi:

First of all, I want to say thanks for all the helps from you!!

I have done all you have suggested me to do,BUT...(sigh)the dialog just didn''t show up!!

This is the worst truoble i have ever got into!

Share this post


Link to post
Share on other sites
hello2k1    122
First of all, does "MessageBox(m_hWnd, "test", "test", 0);" (copy that into your app) work?

If it does, then did you set a message pump up for your dialog?

Share this post


Link to post
Share on other sites
00702000744    122
MessageBox does show up properly and I did set a message pump for my dialog! Here is how i did it:

// Translate and dispatch the message
if(!m_hDialog || !IsDialogMessage(m_hDialog,&msg))
{
// is not a dialog message
if( 0 == TranslateAccelerator( m_hWnd, hAccel, &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
//and i have a DialogProc() function that handles the dialog messages specifically

Share this post


Link to post
Share on other sites
siaspete    208
There''s a doc on MSDN here...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/dlgboxes_0kag.asp
Hopefully there''ll be something there that helps.

If not, then it may be the case that you''re either not handling your WM_INITDIALOG message correctly or that the controls that aren''t showing up need to be initialised using InitCommonControls or similar.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites
00702000744    122
Oh, I got my problem fixed already, just need to change the return value to false when the message is not handled manully.

Thanks for all your help!!!

Share this post


Link to post
Share on other sites
00702000744    122
Oh, god, I soon ran into another GUI problem. Now, my dialogbox shows up fine, I added some controls like labels, textboxes to it, everything is just all right! But, once I added a slider(TrackBar) to my dialog, the CreateDialog() function will return a value of NULL. Does anyone have any ideas of how that happened?

Thanks for any help here!!

Share this post


Link to post
Share on other sites
Oluseyi    2103
quote:
Original post by 00702000744
But, once I added a slider(TrackBar) to my dialog, the CreateDialog() function will return a value of NULL. Does anyone have any ideas of how that happened?

Did you initialize common controls?

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ ]
[ MS RTFM [MSDN] | SGI STL Docs | Boost ]
[ Google! | Asking Smart Questions | Jargon File ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
00702000744    122
Could you please explain what do you exactly mean by initializing common controls?? I did not do anything to my Labels and TextBoxes, but they showed up automatically.

Share this post


Link to post
Share on other sites
Oluseyi    2103
Common controls are additional UI elements introduced with Internet Explorer. You introduce them into your application as follows:

INITCOMMONCONTROLSEX iccx;
iccx.dwSize = sizeof( INITCOMMONCONTROLSEX );
// initialize toolbar, status bar, trackbar, ToolTip, and ReBar control classes
iccx.dwICC = ICC_BAR_CLASSES|ICC_COOL_CLASSES;
if( ! InitCommonControlsEx( &iccx ) )
return -1;

See MSDN (link in sig) for more info.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ ]
[ MS RTFM [MSDN] | SGI STL Docs | Boost ]
[ Google! | Asking Smart Questions | Jargon File ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites