VB6: Problems with pressed / unpressed Toolbar buttons 
Author Message
 VB6: Problems with pressed / unpressed Toolbar buttons

Hey everyone,
I'm having a problem with an application I'm writing with VB6 (SP5), and I'm
hoping someone here can help me out.

I'm using RichText boxes because I need fonts in Bold/Italics/Underlines,
etc.  I'm using a Toolbar for those buttons, much like a toolbar in
Microsoft Word.

Here's my dilemma:
When someone clicks on one of the buttons (Bold, for example) I want the
button to appear "pressed."  When they click on it again, I want the button
to appear "unpressed".

I figured that the code would be something like this (forgive me, I don't
have the code in front of me, so I'm just guessing what I did):

With Toolbar1.buttons(1)
   debug.print .value
   if .value = tbsPressed then   'or whatever the constant is...
      .value = tbsUnpressed
      ' blah blah blah...
  else
      .value = tbsPressed
      ' blah blah blah...
  end if
end with

Well, it seems about 50% functional.  When the program starts, the button is
Unpressed.  When I click on the button, it appears that it is now pressed.
However, according to the debug information, the Value of the button is
always returned as Unpressed, even when it is pressed.   Thus, my code
doesn't work, and I can't do what I want.

What is it that I'm doing wrong?  Is there an easier way to do the
Bold/Italic/Underline menu?

Thanks for any help.
--

Mike K. MCSE on Windows 2000
MS-MVP (Windows XP)
Associate Expert - Windows XP
http://www.*-*-*.com/



Wed, 28 Apr 2004 01:27:31 GMT  
 VB6: Problems with pressed / unpressed Toolbar buttons


Fri, 19 Jun 1992 00:00:00 GMT  
 VB6: Problems with pressed / unpressed Toolbar buttons
Do you have the Style set to "1-tbrCheck" for those buttons you want to use
as toggles?
If not, that's the problem.

--
Ken Halter
MS-MVP-VB
http://www.vbsight.com
Please respond only to the newsgroups so all can benefit.
Besides.. I check my email only once a week :-)


Quote:
> Hey everyone,
> I'm having a problem with an application I'm writing with VB6 (SP5), and
I'm
> hoping someone here can help me out.

> I'm using RichText boxes because I need fonts in Bold/Italics/Underlines,
> etc.  I'm using a Toolbar for those buttons, much like a toolbar in
> Microsoft Word.

> Here's my dilemma:
> When someone clicks on one of the buttons (Bold, for example) I want the
> button to appear "pressed."  When they click on it again, I want the
button
> to appear "unpressed".

> I figured that the code would be something like this (forgive me, I don't
> have the code in front of me, so I'm just guessing what I did):

> With Toolbar1.buttons(1)
>    debug.print .value
>    if .value = tbsPressed then   'or whatever the constant is...
>       .value = tbsUnpressed
>       ' blah blah blah...
>   else
>       .value = tbsPressed
>       ' blah blah blah...
>   end if
> end with

> Well, it seems about 50% functional.  When the program starts, the button
is
> Unpressed.  When I click on the button, it appears that it is now pressed.
> However, according to the debug information, the Value of the button is
> always returned as Unpressed, even when it is pressed.   Thus, my code
> doesn't work, and I can't do what I want.

> What is it that I'm doing wrong?  Is there an easier way to do the
> Bold/Italic/Underline menu?

> Thanks for any help.
> --

> Mike K. MCSE on Windows 2000
> MS-MVP (Windows XP)
> Associate Expert - Windows XP
> http://www.microsoft.com/WindowsXP/ExpertZone



Wed, 28 Apr 2004 01:45:22 GMT  
 VB6: Problems with pressed / unpressed Toolbar buttons
I should've also mentioned... If, when starting a new project, you select
the VB Application Wizard template, choose MDI, Next (accept defaults), then
click the Finish button, the code to handle Bold/Italic/Etc can be found in
"frmMain"s "tbToolBar_ButtonClick" event.

--
Ken Halter
MS-MVP-VB
http://www.vbsight.com
Please respond only to the newsgroups so all can benefit.
Besides.. I check my email only once a week :-)


Quote:
> Do you have the Style set to "1-tbrCheck" for those buttons you want to
use
> as toggles?
> If not, that's the problem.

> --
> Ken Halter
> MS-MVP-VB
> http://www.vbsight.com
> Please respond only to the newsgroups so all can benefit.
> Besides.. I check my email only once a week :-)



> > Hey everyone,
> > I'm having a problem with an application I'm writing with VB6 (SP5), and
> I'm
> > hoping someone here can help me out.

> > I'm using RichText boxes because I need fonts in

Bold/Italics/Underlines,

- Show quoted text -

Quote:
> > etc.  I'm using a Toolbar for those buttons, much like a toolbar in
> > Microsoft Word.

> > Here's my dilemma:
> > When someone clicks on one of the buttons (Bold, for example) I want the
> > button to appear "pressed."  When they click on it again, I want the
> button
> > to appear "unpressed".

> > I figured that the code would be something like this (forgive me, I
don't
> > have the code in front of me, so I'm just guessing what I did):

> > With Toolbar1.buttons(1)
> >    debug.print .value
> >    if .value = tbsPressed then   'or whatever the constant is...
> >       .value = tbsUnpressed
> >       ' blah blah blah...
> >   else
> >       .value = tbsPressed
> >       ' blah blah blah...
> >   end if
> > end with

> > Well, it seems about 50% functional.  When the program starts, the
button
> is
> > Unpressed.  When I click on the button, it appears that it is now
pressed.
> > However, according to the debug information, the Value of the button is
> > always returned as Unpressed, even when it is pressed.   Thus, my code
> > doesn't work, and I can't do what I want.

> > What is it that I'm doing wrong?  Is there an easier way to do the
> > Bold/Italic/Underline menu?

> > Thanks for any help.
> > --

> > Mike K. MCSE on Windows 2000
> > MS-MVP (Windows XP)
> > Associate Expert - Windows XP
> > http://www.microsoft.com/WindowsXP/ExpertZone



Wed, 28 Apr 2004 01:54:04 GMT  
 VB6: Problems with pressed / unpressed Toolbar buttons
Excellent!   Thank you very much, Ken.
I appreciate your help!
--

Mike K. MCSE on Windows 2000
MS-MVP (Windows XP)
Associate Expert - Windows XP
http://www.microsoft.com/WindowsXP/ExpertZone


Quote:
> I should've also mentioned... If, when starting a new project, you select
> the VB Application Wizard template, choose MDI, Next (accept defaults),
then
> click the Finish button, the code to handle Bold/Italic/Etc can be found
in
> "frmMain"s "tbToolBar_ButtonClick" event.

> --
> Ken Halter
> MS-MVP-VB
> http://www.vbsight.com
> Please respond only to the newsgroups so all can benefit.
> Besides.. I check my email only once a week :-)



> > Do you have the Style set to "1-tbrCheck" for those buttons you want to
> use
> > as toggles?
> > If not, that's the problem.

> > --
> > Ken Halter
> > MS-MVP-VB
> > http://www.vbsight.com
> > Please respond only to the newsgroups so all can benefit.
> > Besides.. I check my email only once a week :-)



> > > Hey everyone,
> > > I'm having a problem with an application I'm writing with VB6 (SP5),
and
> > I'm
> > > hoping someone here can help me out.

> > > I'm using RichText boxes because I need fonts in
> Bold/Italics/Underlines,
> > > etc.  I'm using a Toolbar for those buttons, much like a toolbar in
> > > Microsoft Word.

> > > Here's my dilemma:
> > > When someone clicks on one of the buttons (Bold, for example) I want
the
> > > button to appear "pressed."  When they click on it again, I want the
> > button
> > > to appear "unpressed".

> > > I figured that the code would be something like this (forgive me, I
> don't
> > > have the code in front of me, so I'm just guessing what I did):

> > > With Toolbar1.buttons(1)
> > >    debug.print .value
> > >    if .value = tbsPressed then   'or whatever the constant is...
> > >       .value = tbsUnpressed
> > >       ' blah blah blah...
> > >   else
> > >       .value = tbsPressed
> > >       ' blah blah blah...
> > >   end if
> > > end with

> > > Well, it seems about 50% functional.  When the program starts, the
> button
> > is
> > > Unpressed.  When I click on the button, it appears that it is now
> pressed.
> > > However, according to the debug information, the Value of the button
is
> > > always returned as Unpressed, even when it is pressed.   Thus, my code
> > > doesn't work, and I can't do what I want.

> > > What is it that I'm doing wrong?  Is there an easier way to do the
> > > Bold/Italic/Underline menu?

> > > Thanks for any help.
> > > --

> > > Mike K. MCSE on Windows 2000
> > > MS-MVP (Windows XP)
> > > Associate Expert - Windows XP
> > > http://www.microsoft.com/WindowsXP/ExpertZone



Wed, 28 Apr 2004 02:55:53 GMT  
 VB6: Problems with pressed / unpressed Toolbar buttons


Fri, 19 Jun 1992 00:00:00 GMT  
 VB6: Problems with pressed / unpressed Toolbar buttons

Quote:

> When someone clicks on one of the buttons (Bold, for example) I want the
> button to appear "pressed."  When they click on it again, I want the button
> to appear "unpressed".

Oh, by the way ...

Just in case anyone doesn't know this,
if you want similar functionality from a regular
command button, it's really easy, but not obvious.

Set the Style property of a CheckBox (yes, a CheckBox!)
to "1 - Graphical" and there you have it.

        Bob
--
Seems to me we went through the whole copy-protection thing decades ago,
and smart folks realized it can only hurt the customer.



Wed, 28 Apr 2004 05:32:02 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Retrieving index of pressed toolbar button

2. Find out if button is pressed on a Word toolbar

3. Simultaneously pressing a key and mouse-clicking a button on a toolbar

4. programmatically pressing toolbar buttons

5. Pressing button menu on a toolbar

6. TBN_DROPDOWN notification menu shows but button stays unpressed

7. Without Pressing Keyboard I need to Press Enter In VB6 Code

8. Help: Detect Right-Click of specific Toolbar Button (VB6)

9. VB6: Toolbar with flat Office 97 style buttons?

10. VB6 Toolbar with button style dropdown

11. BUG: Toolbar-Buttons wrong pictures - toolbar.zip (1/1)

12. BUG: Toolbar-Buttons wrong pictures - toolbar.zip (0/1)

 

 
Powered by phpBB® Forum Software