|
-
October 19th, 2004, 07:54 AM
#1
Modal Dialog loosing focus
I have got a SDI application. On selecting a menu option, a modal dialog is shown using dlg.DoModal().
In the InitDialog, 6 comboboxes (5 visible and 1 invisible) are populated with values read from files. But as soon as the dialog is painted on the screen, it looses focus. (The title bar appears gray instead of blue). On clicking on the dialog, focus returns.
I want u to suggest probable reasons of this kind of behaviour. Could it be bcoz of the invisible combo.
Moreover, OnPaint has not been overridden, neither has been PreCreateWindow.
Sarve Bhavantu Sukheenah,
Sarve Santu Niramayah,
Sarve Bhadrani Pashyantu,
Ma Kashchit dukh bhag bhavet.
-
October 19th, 2004, 07:58 AM
#2
Re: Modal Dialog loosing focus
Try in the resource editor to change the tab order of the dialog controls and make it first one visible.
Hokutata Yakubotu
-
October 19th, 2004, 07:59 AM
#3
Re: Modal Dialog loosing focus
Is your dialog style set to child by any chance?
Also are you performing any lengthy operation in a while loop?
Last edited by JohnCz; October 19th, 2004 at 08:01 AM.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
October 19th, 2004, 08:09 AM
#4
Re: Modal Dialog loosing focus
I have tried setting the tab order. Tab order 1 is a visible control. My dialog style is Popup.
The operations I perform to populate the combo cant be categorized as lengthy. 10 values for each of 6 combos read either from memory or from local disk.
Sarve Bhavantu Sukheenah,
Sarve Santu Niramayah,
Sarve Bhadrani Pashyantu,
Ma Kashchit dukh bhag bhavet.
-
October 19th, 2004, 08:19 AM
#5
Re: Modal Dialog loosing focus
Return Value of OnInitDialog
Specifies whether the application has set the input focus to one of the controls in the dialog box. If OnInitDialog returns nonzero, Windows sets the input focus to the first control in the dialog box. The application can return 0 only if it has explicitly set the input focus to one of the controls in the dialog box.
Have a look at OnInitDialog function description in MSDN.
http://msdn.microsoft.com/library/de...initdialog.asp
-
October 19th, 2004, 08:30 AM
#6
Re: Modal Dialog loosing focus
OnInitDialog is returning non-zero. The dialog has focus for abt a fraction of second and I can notice that the focus was actually on the first control before the focus goes away.
Sarve Bhavantu Sukheenah,
Sarve Santu Niramayah,
Sarve Bhadrani Pashyantu,
Ma Kashchit dukh bhag bhavet.
-
October 19th, 2004, 08:34 AM
#7
Re: Modal Dialog loosing focus
Better post your sample source.. Not clear what you are doing in OnInitDialog
-
October 19th, 2004, 11:14 AM
#8
Re: Modal Dialog loosing focus
What kind of comboboxes are those ? Are they CComboBox / or some other class ?
Did you try stripping out the initialization of those comboboxes and see if that made a difference ?
-
October 19th, 2004, 11:25 PM
#9
Re: Modal Dialog loosing focus
Hi Gurus.
Actualy there was a timer active, the handler of which performed SetWindowPos on the mainframe. That was forcing the focus away from the dialog. Now the dialog works fine.
Sarve Bhavantu Sukheenah,
Sarve Santu Niramayah,
Sarve Bhadrani Pashyantu,
Ma Kashchit dukh bhag bhavet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|