I have a toolbar setup, which includes a group of 4 buttons that change the "mode" of the program...
Lets say the keys for the for buttons are "A", "B", "C", & "D"
I have the the Form's KeyPreview Set to True, and in the Form_KeyDown() event, I have code similar to this:
Originally, I had the Value property for Button A set to "Pressed" in the Form Designer...
When I turned it off, It worked fine, except there was no default button pressed, which I see as a program flaw.
So I decided to set it at run time...
I tried this code...
In Each of the following Events:
Form_Load()
Form_Paint()
Form_Activate()
Yet it responded in the same way as if it were set in the designer...
[COLOR=red yellow]Though, after you manually click a button, it works fine, in ANY of the above cases...
Just Not Before You Click A Button...[/color]
So what is causing this?????
I'm running short on ideas here...
Is there something I could be doing to cause this, or is it just a VB Bug?
*Note: I did try setting the Buttons NOT selected to tbrUnpressed...
...But that does not fix the problem either.
Visit My Site
PROGRAMMER:
Red-eyed, mumbling mammal capable of conversing with inanimate objects.
Lets say the keys for the for buttons are "A", "B", "C", & "D"
I have the the Form's KeyPreview Set to True, and in the Form_KeyDown() event, I have code similar to this:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim MyButton As Button
Select Case KeyCode
Case vbKeyF5: Set MyButton = Toolbar1.Buttons("A")
Case vbKeyF6: Set MyButton = Toolbar1.Buttons("B")
Case vbKeyF7: Set MyButton = Toolbar1.Buttons("C")
Case vbKeyF8: Set MyButton = Toolbar1.Buttons("D")
End Select
If Not MyButton Is Nothing Then
Toolbar1_ButtonClick MyButton
MyButton.Value = tbrPressed
TreeView1.SetFocus
End If
End Sub
Originally, I had the Value property for Button A set to "Pressed" in the Form Designer...
When I turned it off, It worked fine, except there was no default button pressed, which I see as a program flaw.
So I decided to set it at run time...
I tried this code...
Code:
Toolbar1.Buttons("A").Value = tbrPressed
Form_Load()
Form_Paint()
Form_Activate()
Yet it responded in the same way as if it were set in the designer...
[COLOR=red yellow]Though, after you manually click a button, it works fine, in ANY of the above cases...
Just Not Before You Click A Button...[/color]
So what is causing this?????
I'm running short on ideas here...
Is there something I could be doing to cause this, or is it just a VB Bug?
*Note: I did try setting the Buttons NOT selected to tbrUnpressed...
Code:
...
With Toolbar1
If .Buttons("A").Key <> MyButton.Key Then .Buttons("A").Value = tbrUnpressed
If .Buttons("B").Key <> MyButton.Key Then .Buttons("B").Value = tbrUnpressed
If .Buttons("C").Key <> MyButton.Key Then .Buttons("C").Value = tbrUnpressed
If .Buttons("D").Key <> MyButton.Key Then .Buttons("D").Value = tbrUnpressed
End With
...
...But that does not fix the problem either.
Visit My Site
PROGRAMMER: