Jump to content
  • Advertisement
Sign in to follow this  
michaelbeirne

DirectX and Dialog Windows

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a very frustrating problem with my dialog windows when using them in conjunction with a directx client area. Here is what i have: Master Item List Dialog The "Master Item List" (on the left) Dialog is a child of the DirectX client area window and works fine except for the one problem. if i click on an item from the list or the window itself, the directx client area appears to loose focus (as it should) but the mouse click is still processed by the DirectX window and it and adds an object to the map behind the dialog window. However: Edit Item Dialog When i edit an item in the master item list (which calls up a child dialog of the master item list dialog called "Edit Item"), clicking does not affect the directx client area- which is what i want for both this dialog window AND the master item list dialog window. Both Dialogs have the same properties except for their parenting. I am using direct input for the mouse/keyboard.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by programmer_tom
well, they are both responding to the same msgs. can't u just say "if dlg is open && they click in the dlg, 3d ignore" ?

-programmer_tom


That should be the solution.

Share this post


Link to post
Share on other sites
I considered that, however i get the same problem with the menu at the top too, so i couldnt check if the mouse was in that menu with a box like i could for the dialog windows becuase when they drop down they overlap the directx client area as well.

The dialog windows and the client area are not using the same window proc but are using the same message proc.

the co-operartive level for the direct input device is set to DISCL_FOREGROUND | DISCL_NONEXCLUSIVE (default).

Im less experienced with window programming than directx itself, so any help would be great.

Share this post


Link to post
Share on other sites
I think i have solved this, i am kind of doing what you said programmer_tom. I didnt realise there was a WM_MOUSEMOVE case that says wether the mouse is over a window or not, i was reluctant to do it with a bounding box as i have seen in an example i read. So now all i do is check if that case is true and only allow the user to edit the map if the mouse isnt over the dialog window.

Share this post


Link to post
Share on other sites
You are using IsDialogMessage() in your window loop, aren't you? It should look something like:

while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(IsDialogMessage(hWndDialog, &msg))
continue;

TranslateMessage(&msg);
DispatchMessage(&msg);
}

Share this post


Link to post
Share on other sites

void Application::messageLoop()
{
MSG Msg;
// Enter the message pump
ZeroMemory(&Msg, sizeof(MSG));
while(Msg.message != WM_QUIT)
{
// Handle Windows messages (if any)
if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {

if(IsDialogMessage(dlgHWnd, &Msg))
{
clientAreaFocus = false;
OutputDebugString("IN CLIENT AREA \n");
MessageBeep(2);
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

else
{
clientAreaFocus = true;
OutputDebugString("IN DIALOG \n");
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

} else {
// Do per-frame processing, break on FALSE return value
if(frame() == FALSE)
break;
}
}




Evil Steve - I tried your method and the WM_MOUSEMOVE and both have a similar result. They are not accurate enough for some reaon. as you can see it outputs "IN CLIENT AREA" or "IN DIALOG" depending on if the message is for the client area or the dialog window. However it somehow isnt very accurate. and the initial problem still occurs. (it should only edit the map when clientAreaFocus = false)

Share this post


Link to post
Share on other sites
You shouldn't call TranslateMessage or DispatchMessage if IsDialogMessage returns non-zero.

I don't think this is a DirectX problem if that helps narrow it down at all. DirectX doesn't care about client areas really, Windows will send the messages to where they're supposed to go.

Share this post


Link to post
Share on other sites
Thanks for helping. I changed it as you said:


void Application::messageLoop()
{
MSG Msg;
// Enter the message pump
ZeroMemory(&Msg, sizeof(MSG));
while(Msg.message != WM_QUIT)
{
// Handle Windows messages (if any)
if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {

if(IsDialogMessage(dlgHWnd, &Msg))
{
clientAreaFocus = false;
OutputDebugString("IN DIALOG\n");
continue;
}

else
{
clientAreaFocus = true;
OutputDebugString("IN CLIENT AREA \n");
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

} else {
// Do per-frame processing, break on FALSE return value
if(frame() == FALSE)
break;
}
}
}



but holding the mouse over the dialog box i still get a strange result:

IN DIALOG
IN DIALOG
IN DIALOG
IN DIALOG
IN DIALOG
IN DIALOG
IN DIALOG
IN DIALOG
IN CLIENT AREA
IN DIALOG
IN CLIENT AREA
IN CLIENT AREA
IN CLIENT AREA
IN CLIENT AREA
IN CLIENT AREA
IN DIALOG
IN CLIENT AREA
IN DIALOG
IN DIALOG

and so on.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Instead of continue try return 0; to let windows know you have handled this message(s).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!