Easy question 
Author Message
 Easy question

How to not display focus at startup when the form contains the array of
check boxes covering the whole form?
Claire


Sat, 28 Jul 2012 04:21:14 GMT  
 Easy question


Quote:
> How to not display focus at startup when the form contains the array of
> check boxes covering the whole form?

Focus HAS to go somewhere and it has to go to a control that is visible.
If you don't want the user to see a focus rectangle, you can add a 1x1 pixel
Picturebox with no borders (so it matches the form background) and set its
TabStop to 0 in the IDE.  A Picturebox does not show a focus rectangle.

That will hide the focus on startup, but when the user goes tabbing through
the checkboxes, there will be a time when the focus seems to disappear
(when it gets back to the Picturebox).  To avoid that, you can hide the
Picturebox (set Visible to False) in the GotFocus event of your Check
boxes.  That way, when the user selects a checkbox, or starts tabbing
through the check boxes, the Picture box is hidden which takes it out
of the tab sequence.

HTH
LFS



Sat, 28 Jul 2012 05:31:44 GMT  
 Easy question
How about an enabled, visible but hidden control? (a PictureBox, Textbox,
any control that can receive the focus will do).
Set its TabIndex to 0. and Left to -20000.
If you set Visible to false the Checkbox with the lowest TabIndex
will get the focus, but Visible = True and with Left = -20000 out of sight
it will get the focus.

Helmut.



Quote:
> How to not display focus at startup when the form contains the array of
> check boxes covering the whole form?
> Claire



Sat, 28 Jul 2012 05:53:46 GMT  
 Easy question
I tried that before and it does not work for me.
Claire


Quote:
> How about an enabled, visible but hidden control? (a PictureBox, Textbox,
> any control that can receive the focus will do).
> Set its TabIndex to 0. and Left to -20000.
> If you set Visible to false the Checkbox with the lowest TabIndex
> will get the focus, but Visible = True and with Left = -20000 out of sight
> it will get the focus.

> Helmut.



>> How to not display focus at startup when the form contains the array of
>> check boxes covering the whole form?
>> Claire



Sat, 28 Jul 2012 11:30:29 GMT  
 Easy question
On Mon, 8 Feb 2010 22:53:46 +0100, "Helmut Meukel"

Quote:

>How about an enabled, visible but hidden control? (a PictureBox, Textbox,
>any control that can receive the focus will do).
>Set its TabIndex to 0. and Left to -20000.
>If you set Visible to false the Checkbox with the lowest TabIndex
>will get the focus, but Visible = True and with Left = -20000 out of sight
>it will get the focus.

>Helmut.



>> How to not display focus at startup when the form contains the array of
>> check boxes covering the whole form?
>> Claire

I just tried a slight modification of this: Place 5x Check1 in a
control array on the form, plus 1x Text1 with its Left property set to
-200 and with a TabIndex of 0. Result: None of the checkboxes gets
focus.

In the Text1.GotFocus event I set its TabStop = False, so that tabbing
now only goes to the checkboxes with no gaps. No focus is shown until
the tab key is pressed for the first time.

MM



Sat, 28 Jul 2012 17:01:12 GMT  
 Easy question
Hmmm,

before I wrote my first post, I created a small test app - nothing fancy,
just 1 form with an array of 3 checkboxes and 1 textbox. No code at all.
Then I changed - in design mode - 2 Properties of the textbox:
Text1.TabOrder = 0  'was 3
Text1.Left = -20000
Now the textbox was not visible any more, but Text1.Visible was still True
When I run the app from the IDE or I compile the exe and run the compiled
exe
I get the form without the focus visible. Then I can tab through the
controls.
As Larry mentioned, the fourth tab keystroke sets the tab back to the
"invisible"
Textbox.

So it works on my system.
I used Win2000, latest SP + VB6, SP6.

After reading your answer I testet the small exe on a Windows7 system and it
worked fine.
So I started VB6 on that Win7 system, loaded the projekt, run it in the IDE:
worked fine.
Then I compiled it on the Win7 system and run the new exe: worked fine.

I can't understand why it didn't work for you.

Helmut.

I opened the form file in notepad and pasted it at the end of this answer,
have a look at it.



Quote:
>I tried that before and it does not work for me.
> Claire



>> How about an enabled, visible but hidden control? (a PictureBox, Textbox,
>> any control that can receive the focus will do).
>> Set its TabIndex to 0. and Left to -20000.
>> If you set Visible to false the Checkbox with the lowest TabIndex
>> will get the focus, but Visible = True and with Left = -20000 out of
>> sight
>> it will get the focus.

>> Helmut.



>>> How to not display focus at startup when the form contains the array of
>>> check boxes covering the whole form?
>>> Claire

VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   2484
   ClientLeft      =   48
   ClientTop       =   348
   ClientWidth     =   3756
   LinkTopic       =   "Form1"
   ScaleHeight     =   2484
   ScaleWidth      =   3756
   StartUpPosition =   3  'Windows Default
   Begin VB.CheckBox Check1
      Caption         =   "Check1"
      Height          =   372
      Index           =   2
      Left            =   120
      TabIndex        =   3
      Top             =   1080
      Width           =   1212
   End
   Begin VB.CheckBox Check1
      Caption         =   "Check1"
      Height          =   372
      Index           =   1
      Left            =   120
      TabIndex        =   2
      Top             =   600
      Width           =   1212
   End
   Begin VB.CheckBox Check1
      Caption         =   "Check1"
      Height          =   372
      Index           =   0
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   1212
   End
   Begin VB.TextBox Text1
      Height          =   288
      Left            =   -20000
      TabIndex        =   0
      Text            =   "Text1"
      Top             =   2040
      Width           =   1092
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Sat, 28 Jul 2012 17:05:04 GMT  
 Easy question

Quote:
> Then I compiled it on the Win7 system and run the new exe: worked fine.
> [Addressed to Claire] I can't understand why it didn't work for you

Reading through your initial post my guess is that Claire "skip read" it and
failed to notice the second half of your sentence:

    "If you set [Picbox] Visible to false the Checkbox with the
     lowest TabIndex will get the focus, but Visible = True and
     with Left = -20000 out of sight it will get the focus".

Mike



Sat, 28 Jul 2012 21:25:08 GMT  
 Easy question

Quote:

> does not work for me.

No way to troubleshoot that.  Thanks for playing!

--
.NET: It's About Trust!
http://vfred.mvps.org



Sun, 29 Jul 2012 01:50:34 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. EASY EASY EASY question

2. help easy easy question

3. easy question

4. bitmaps, easy question

5. Public functions, easy question

6. Easy question

7. I'm sure that this is an easy question

8. easy question

9. help new to VBA, easy question

10. quick and easy question....please help!

11. How does A2K handle ASP - Many Easy Questions

12. easy question

 

 
Powered by phpBB® Forum Software