|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Toolbar DilemaVB6 app with toolbar holding four buttons and no other things like sep.
all set to vbdDefault button. all code handled in the same sub to use the button settings. Private Sub tbFontStyle_ButtonClick(ByVal Button As MSComctlLib.Button) The first button depresses and calls the sub to do its task when clicked. But when I click it again, the sub is again called but the button will not undepress. All other buttons on the same toolbar are configured the same way and all the others work as expected. no compile errors. What am I missing?
Show quote
Hide quote
"Bee" <B**@discussions.microsoft.com> wrote in message Sound like a double click issue. Try using DisableDblClick below. If it news:3F5DAB48-B49C-415B-A6A1-ACE8DDB541D2@microsoft.com... > VB6 app with toolbar holding four buttons and no other things like sep. > all set to vbdDefault button. > all code handled in the same sub to use the button settings. > > Private Sub tbFontStyle_ButtonClick(ByVal Button As MSComctlLib.Button) > > The first button depresses and calls the sub to do its task when clicked. > But when I click it again, the sub is again called but the button will not > undepress. > All other buttons on the same toolbar are configured the same way and all > the others work as expected. > no compile errors. > What am I missing? doesn't work, check out TB_SETSTYLE in MSDN. Private Const GCL_STYLE = (-26) Private Const CS_DBLCLKS = &H8 Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" ( _ ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" ( _ ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Sub DisableDblClick(ByVal hWnd As Long) Dim style As long style = GetClassLong(hWnd, GCL_STYLE) style = style And (Not CS_DBLCLKS) SetClassLong hWnd, GCL_STYLE, style End Sub Hmm ...
this is the leftmost button of the four and the only one that exhibits this phenomenon. No groups or anything else set. I almost makes me think that it is trying to act as an optionbutton, but clicking the other buttons works as expected and leaves the "bad" button pressed. I will look at the form in a text editor and see if there is a problem in the uptop code. What's that called anyway? Show quoteHide quote "Nobody" wrote: > "Bee" <B**@discussions.microsoft.com> wrote in message > news:3F5DAB48-B49C-415B-A6A1-ACE8DDB541D2@microsoft.com... > > VB6 app with toolbar holding four buttons and no other things like sep. > > all set to vbdDefault button. > > all code handled in the same sub to use the button settings. > > > > Private Sub tbFontStyle_ButtonClick(ByVal Button As MSComctlLib.Button) > > > > The first button depresses and calls the sub to do its task when clicked. > > But when I click it again, the sub is again called but the button will not > > undepress. > > All other buttons on the same toolbar are configured the same way and all > > the others work as expected. > > no compile errors. > > What am I missing? > > Sound like a double click issue. Try using DisableDblClick below. If it > doesn't work, check out TB_SETSTYLE in MSDN. > > Private Const GCL_STYLE = (-26) > Private Const CS_DBLCLKS = &H8 > Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" ( _ > ByVal hwnd As Long, ByVal nIndex As Long) As Long > Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" ( _ > ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As > Long > > Public Sub DisableDblClick(ByVal hWnd As Long) > Dim style As long > > style = GetClassLong(hWnd, GCL_STYLE) > style = style And (Not CS_DBLCLKS) > SetClassLong hWnd, GCL_STYLE, style > End Sub > > >
Show quote
Hide quote
"Bee" <B**@discussions.microsoft.com> wrote in message If I understand, you want the pressed button to remainnews:61A6D96A-34B2-4C5E-9DEF-9C9E0D35A533@microsoft.com... > Hmm ... > this is the leftmost button of the four and the only one that exhibits > this > phenomenon. > > No groups or anything else set. > > I almost makes me think that it is trying to act as an optionbutton, but > clicking the other buttons works as expected and leaves the "bad" button > pressed. > > I will look at the form in a text editor and see if there is a problem in > the uptop code. What's that called anyway? > > > "Nobody" wrote: > >> "Bee" <B**@discussions.microsoft.com> wrote in message >> news:3F5DAB48-B49C-415B-A6A1-ACE8DDB541D2@microsoft.com... >> > VB6 app with toolbar holding four buttons and no other things like sep. >> > all set to vbdDefault button. >> > all code handled in the same sub to use the button settings. >> > >> > Private Sub tbFontStyle_ButtonClick(ByVal Button As MSComctlLib.Button) >> > >> > The first button depresses and calls the sub to do its task when >> > clicked. >> > But when I click it again, the sub is again called but the button will >> > not >> > undepress. >> > All other buttons on the same toolbar are configured the same way and >> > all >> > the others work as expected. >> > no compile errors. >> > What am I missing? >> >> Sound like a double click issue. Try using DisableDblClick below. If it >> doesn't work, check out TB_SETSTYLE in MSDN. >> >> Private Const GCL_STYLE = (-26) >> Private Const CS_DBLCLKS = &H8 >> Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" >> ( _ >> ByVal hwnd As Long, ByVal nIndex As Long) As Long >> Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" >> ( _ >> ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As >> Long >> >> Public Sub DisableDblClick(ByVal hWnd As Long) >> Dim style As long >> >> style = GetClassLong(hWnd, GCL_STYLE) >> style = style And (Not CS_DBLCLKS) >> SetClassLong hWnd, GCL_STYLE, style >> End Sub "pressed" & the others "unpressed." Try this code: Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Dim Btn As Button For Each Btn In Toolbar1.Buttons 'unpress all the buttons Btn.Value = tbrUnpressed Next Button.Value = tbrPressed 'press the selected button Toolbar1.Refresh 'doesn't work without this End Sub |
|||||||||||||||||||||||