Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Toolbar, Timer and BindEvents
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Toolbar, Timer and BindEvents
Miscellaneous
Thread ID:
00791267
Message ID:
00791267
Views:
52
Could someone paste the code below in a PRG and run it in VFP8? When the toolbar is presented to you, resize it so it is vertical, docked, etc. Note the ActivateTimer never fires when the TOP property of ANY button changes.

Can someone see my problem or at least confirm that you can not BINDEVENT the timer event of a timer in a toolbar. This is a workaround to begin with because depending on the various methods of the toolbar did not work [Dock, Undock, Resize, Move].

I would like the picture property of the buttons on a toolbar to change depending on its orientation. I have substituted letters instead of pictures so nothing else is needed but the code below. The desired (expected) result is that when the Top property of any button changes, the ActivateTimer fires, whcih then fires the AfterResize method. TIA!
RELEASE oNav
CLEAR DEBUG
DEBUG
PUBLIC oNav
oNav = CREATEOBJECT('Navigator')
oNav.Visible = .t.
RETURN

DEFINE CLASS Navigator AS Toolbar

   Caption = "Navigate"
   Height = 58
   Left = 0
   Top = 0
   Width = 95
   ControlBox = .F.
   Name = "Navigator"

   ADD OBJECT cmdFirst AS cmdVCR WITH ;
      Top = 11, ;
      Left = 5, ;
      Visible = .T., ;
      ZOrderSet = 0, ;
      Name = "cmdFirst"

   ADD OBJECT cmdPrevious AS cmdVCR WITH ;
      Top = 11, ;
      Left = 26, ;
      Visible = .T., ;
      ZOrderSet = 1, ;
      Name = "cmdPrevious"

   ADD OBJECT cmdNext AS cmdVCR WITH ;
      Top = 11, ;
      Left = 47, ;
      Visible = .T., ;
      ZOrderSet = 2, ;
      Name = "cmdNext"

   ADD OBJECT cmdLast AS cmdVCR WITH ;
      Top = 11, ;
      Left = 68, ;
      Visible = .T., ;
      ZOrderSet = 3, ;
      Name = "cmdLast"

   ADD OBJECT Timer1 AS timer WITH ;
      Enabled = .f., ;
      Name = "Timer1"

   PROCEDURE Init
      LOCAL loButton
      FOR EACH loButton IN THIS.Objects
         IF UPPER(loButton.BaseClass) == [COMMANDBUTTON]
            BINDEVENT(loButton, "Top", THIS, "ActivateTimer", 1)
         ENDIF
      ENDFOR
      lnRetval = BINDEVENT(THIS.Timer1, "Timer", THIS, "AfterResize", 1)
      DEBUGOUT 'Timer BindEvent RetVal: ' + TRANSFORM(lnRetVal)
      THIS.AfterResize()
   ENDPROC
   PROCEDURE AfterResize
      THIS.Timer1.Enabled = .f.
      DEBUGOUT PROGRAM() + [ fired...]
      DEBUGOUT [Last Top: ] + TRANSFORM(THIS.cmdLast.Top)
      LOCAL llDefault
      WITH THIS
         DO CASE
            CASE .cmdFirst.Top = .cmdPrevious.Top
               llDefault = .t.
            CASE .cmdNext.Top = .cmdLast.Top
               llDefault = .t.
            CASE .cmdPrevious.Top = .cmdNext.Top
               llDefault = .t.
         ENDCASE
         IF llDefault
            .SetDefaultPictures()
         ELSE
            .SetVerticalPictures()
         ENDIF
      ENDWITH
   ENDPROC
   PROCEDURE SetDefaultPictures
      WITH THIS
         .cmdFirst.Caption    = [A]
         .cmdPrevious.Caption = [B]
         .cmdNext.Caption     = [C]
         .cmdLast.Caption     = [D]
      ENDWITH
   ENDPROC
   PROCEDURE SetVerticalPictures
      WITH THIS
         .cmdFirst.Caption    = [J]
         .cmdPrevious.Caption = [K]
         .cmdNext.Caption     = [L]
         .cmdLast.Caption     = [M]
      ENDWITH
   ENDPROC
   PROCEDURE ActivateTimer
      WITH THIS.Timer1
         .Interval = 1000
         .Enabled = .T.
      ENDWITH
      DEBUGOUT PROGRAM() + [ fired...]
   ENDPROC
ENDDEFINE
*
*-- EndDefine: navigator
**************************************************

DEFINE CLASS cmdVCR AS CommandButton

   Height = 22
   Width = 22

ENDDEFINE
Mark McCasland
Midlothian, TX USA
Next
Reply
Map
View

Click here to load this message in the networking platform