Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Docking Pane
  New Posts New Posts RSS Feed - Set focus to control inside docking pane
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Set focus to control inside docking pane

 Post Reply Post Reply
Author
Message
tobi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 September 2004
Location: Germany
Status: Offline
Points: 451
Post Options Post Options   Thanks (0) Thanks(0)   Quote tobi Quote  Post ReplyReply Direct Link To This Post Topic: Set focus to control inside docking pane
    Posted: 10 September 2009 at 12:46pm
I have a VB6 SDI app with one docking pane !
At application startup I want to set the focus to the textbox inside the pane, but at the end of FORM_LOAD I receive error !

I think at this moment the docking pane isn't yet ready ?

Does anyone have idea when and where I can set focus to the textbox inside the pane?



Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 10 September 2009 at 4:16pm
I don't think that this is a DockingPane limitation. You can never call SetFocus methods inside the Form_Load event because the control must be visible otherwise an error will be raised (you can try this on a regular VB6 form). You can set the focus inside the Form_Activate event though (because the form is visible at this point). If you only want this to happen once, you can use a Static variable...something like:


Private Sub Form_Activate()
   Static s_Activated As Boolean

   If Not s_Activated Then
      s_Activated = True

      Me.Text1.SetFocus
   End If
End Sub


Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
chrisABC View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 June 2008
Status: Offline
Points: 258
Post Options Post Options   Thanks (0) Thanks(0)   Quote chrisABC Quote  Post ReplyReply Direct Link To This Post Posted: 05 November 2009 at 12:52pm
I used to get this error seemingly at random on different PCs. The problem is when the control (eg TextBox) you want to set Focus to is not visible when you try to set focus -- this gives error.  In my apps, I think timing caused the problem to only happen sometimes (eg maybe sometimes the control is visible, sometimes it is not quite ready).

I solved this by adding a Timer to each form that needs this.  Set the Timer to give a delay of 200 mSec or so, and in the Form_Activate (or other) event, set a module level variable to indicate which control is to get Focus. 
The Form is displayed, and then the Timer fires and sets Focus to that control. (And then set the Timer off).

This can be more useful. If you have several Forms (or Panes) on screen, you can remember which control in each one had focus and set focus to it again when user returns to that form.
Chris (Manchester, UK) -- www.abc6.co.uk ---- Using CodeJock ActiveX Suite 13.1.0 with Windows8, VB6 SP6
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.