Print Page | Close Window

How to return focus to docked window

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Docking Pane
Forum Description: Topics Related to Codejock Docking Pane
URL: http://forum.codejock.com/forum_posts.asp?TID=1336
Printed Date: 17 May 2024 at 4:44am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to return focus to docked window
Posted By: jiri
Subject: How to return focus to docked window
Date 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)
    Form1.Show vbModal
End Sub

Thanks for answer

Jiri




Replies:
Posted By: JSram
Date Posted: 02 November 2004 at 12:06pm
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.


Posted By: jiri
Date Posted: 02 November 2004 at 12:34pm

I try following:

Form1.Show vbModal, Me
But the result is the same as without "Me".

Jiri

 



Posted By: JSram
Date Posted: 02 November 2004 at 12:54pm
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.



Posted By: gallman
Date Posted: 02 November 2004 at 3:15pm

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:
- PutFocus MyForm.hWnd
- PutFocus MyForm.MyControl.hWnd

This comes in handy if you have a specific form and/or control within a pane that needs to get the focus.

Good luck!




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net