Print Page | Close Window

SetFocus error

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=14511
Printed Date: 31 January 2025 at 1:08am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: SetFocus error
Posted By: chrisABC
Subject: SetFocus error
Date Posted: 11 June 2009 at 11:02am
I have some vb textboxes on a Frame which is on a Tab control. All this is on a Form in an MDI child using DockingPane.

To move user from one text box to another, I use  textbox(x).SetFocus

This 95% works OK, but sometimes gives error.
I think this error is same as if textbox is not enabled or not visible.

I guess this is a timing error or similar.  Most times the SetFocus is fine. But sometimes I guess the DockingPane is busy doing something and the SetFocus gives error.   (without the DockingPane it always works OK.)


Any ideas to workaround this?


-------------
Chris (Manchester, UK) -- www.abc6.co.uk ---- Using CodeJock ActiveX Suite 13.1.0 with Windows8, VB6 SP6



Replies:
Posted By: chrisABC
Date Posted: 11 June 2009 at 11:43am
Possible workaround

The following sort of thing seems to work OK

Sub AttemptSetFocus(myControl)
     On Error Goto ERR_SF
     For X = 1 to 5
         myControl.SetFocus
         Exit Sub
    
         ERR_SF:
         DoEvents
     Next
End Sub


(Note this is not real code. Just to give the idea).


-------------
Chris (Manchester, UK) -- www.abc6.co.uk ---- Using CodeJock ActiveX Suite 13.1.0 with Windows8, VB6 SP6



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