modeless dialog focus problem

modeless dialog focus problem

Post by andre » Sat, 12 Mar 2005 00:38:51


Hi there,

I'm having a problem with setting the focus on a modeless dialog properly.

This is my situation...

I have a main dialog app and this creates a modeless dialog when I double
click an item in a tree control; I then use SetFocus to bring that window to
the top. Ok, this works great so far. Now if I click back on the main
window and double click the same item then I look for the modeless dialog
that I created (I store pointers to the dialogs that I've created) and call
SetFocus on the dialog again, but this time it flashes to the front and then
my main dialog window regains the focus with the modeless dialog losing the
focus. What's the reason for this? I've even tried using
SetForegroundWindow instead of SetFocus... same thing.

Thanks in advance,
Andrew
 
 
 

modeless dialog focus problem

Post by AliR » Sat, 12 Mar 2005 01:00:06

I think this is happening because after you handle the double click message
the tree control still gets a WM_LBUTTONUP message, and the focus gets
changed back to the main dialog.

do this
m_ChildDialog.PostMessage(WM_SETFOCUS);

AliR.



to
call
then
the

 
 
 

modeless dialog focus problem

Post by andre » Sat, 12 Mar 2005 01:08:41

Beautiful... works like a charm!

Thanks