How to return focus to docked window |
Post Reply |
Author | |
jiri
Newbie Joined: 31 October 2003 Location: Czech Republic Status: Offline Points: 38 |
Post Options
Thanks(0)
Posted: 28 October 2004 at 4:46am |
I have SDI app with docking pane. I have following problem: I show modal window from any docked window. When I close modal window, focus is in main form. It is easy to reproduce this behaviour putting following code to the frmPane in SDISample. Form1 is empty new form Private Sub txtContent_KeyUp(KeyCode As Integer, Shift As Integer) Thanks for answer Jiri |
|
JSram
Groupie Joined: 22 October 2004 Status: Offline Points: 42 |
Post Options
Thanks(0)
|
Ok I haven't got that far yet, but sure will... just wonder, what happen if you code
Private Sub txtContent_KeyUp(KeyCode As Integer, Shift As Integer) Form1.Show vbModal, Me End Sub any differance? Not sure but maybe you have to code wise pin the pane or make sure it's pinned as if it closes it probably can't regain focus. Just an idea. |
|
jiri
Newbie Joined: 31 October 2003 Location: Czech Republic Status: Offline Points: 38 |
Post Options
Thanks(0)
|
I try following: Form1.Show vbModal, Me Jiri
|
|
JSram
Groupie Joined: 22 October 2004 Status: Offline Points: 42 |
Post Options
Thanks(0)
|
Ok sorry,
it was just an idea. I assume it would be the same if you used the calling form name as referense instead of Me as well? I'm not really "there" yet, trying to rebuild my app using the codejock controls. Maybe it's not a good idea to load a form from a pane, I don't know. have you tried to simply pop up a msgbox and see if that show the same pattern? An other idea I come to think of, instead of is to load the form in a bit other way. In the form you want to show, make a Public Function/Sub ShowMe() Me.Show Modal End Function/Sub Private Sub txtContent_KeyUp(KeyCode As Integer, Shift As Integer) Call Form1.ShowMe Me.SetFocus End Sub I use this technique often to show a modal, for other reasons like returning a variable/object value from a form. Maybe you don't even need the Me.SetFocus as it normally would return to the calling instans automaticly. |
|
gallman
Newbie Joined: 06 September 2004 Status: Offline Points: 18 |
Post Options
Thanks(0)
|
Hi Jiri, Along the same lines as JSram's solution, you can use the Win32 API route to force a window into focus. See below for an example: Public Declare Function PutFocus Lib "user32" Alias "SetFocus" (ByVal hWnd As Long) As Long Then just call the function from anywhere you need to force focus. For example: This comes in handy if you have a specific form and/or control within a pane that needs to get the focus. Good luck! |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |