Loading ...
Sorry, an error occurred while loading the content.

RE: [libertybasic] graphicbox on top

Expand Messages
  • Stefan Pendl
    ... There have been two problems: 1) Sleep will disable execution of the calling tread so no display update will occur 2) the switch between show and hide is
    Message 1 of 22 , Aug 13, 2007
    • 0 Attachment
      >
      > Thanks for your patience, Stefan. Perhaps this snip will be
      > a better example of my problem.
      > I want the yellow graphicbox to relocate three times and
      > appear on top of the larger graphicbox.
      > Bill J.
      >

      There have been two problems:
      1) Sleep will disable execution of the calling tread
      so no display update will occur
      2) the switch between show and hide is much to fast
      there is a limited amount of time needed to show the box
      to make it flash

      '---code start (watch for line wraps)
      nomainwin

      WindowWidth=300 : WindowHeight=300

      graphicbox #w1.g3, 30,30,80,30
      graphicbox #w1.g2, 40,40,200,200
      open "flash color" for window as #w1
      #w1 "trapclose [quit]"
      #w1.g3, "backcolor yellow"

      for repeat=1 to 3
      timer 80, [hideMe]
      wait
      [hideMe]
      timer 0
      #w1.g3 "hide"

      timer 1000, [showMe]
      wait
      [showMe]
      timer 0
      #w1.g3 "show"
      next
      WAIT

      [quit]
      close #w1
      end
      '---code end

      ---
      Stefan Pendl
    • Yahoo
      ... Thanks for pointing out my problem with Sleep. I had no idea! I tried Show and Hide at various times, but struck out. You have not only made them work,
      Message 2 of 22 , Aug 13, 2007
      • 0 Attachment
        At 03:56 PM 8/13/07 +0200, you wrote:
        >> Thanks for your patience, Stefan. Perhaps this snip will be
        >> a better example of my problem.
        >> I want the yellow graphicbox to relocate three times and
        >> appear on top of the larger graphicbox.
        >> Bill J.
        >>
        >
        >There have been two problems:
        >1) Sleep will disable execution of the calling tread
        >so no display update will occur
        >2) the switch between show and hide is much to fast
        >there is a limited amount of time needed to show the box
        >to make it flash
        >
        >'---code start (watch for line wraps)
        >nomainwin
        >
        >WindowWidth=300 : WindowHeight=300
        >
        >graphicbox #w1.g3, 30,30,80,30
        >graphicbox #w1.g2, 40,40,200,200
        >open "flash color" for window as #w1
        >#w1 "trapclose [quit]"
        >#w1.g3, "backcolor yellow"
        >
        >for repeat=1 to 3
        >timer 80, [hideMe]
        >wait
        >[hideMe]
        >timer 0
        >#w1.g3 "hide"
        >
        >timer 1000, [showMe]
        >wait
        >[showMe]
        >timer 0 '*** following 2 lines added
        > #w1.g3, "locate 30 ";repeat*50;" 80 30"
        > #w1, "refresh"
        >
        >#w1.g3 "show"
        >next
        >WAIT
        >
        >[quit]
        >close #w1
        >end
        >'---code end
        >=================================

        Thanks for pointing out my problem with "Sleep." I had no idea!

        I tried Show and Hide at various times, but struck out. You have not only
        made them work, but when I relocated .g3 (after [showMe]) they still worked!

        Thanks again, Bill J.
      • Yahoo
        I m trying a simple approach here, but something must be wrong. Why doesn t this snip work? Bill J. start code nomainwin graphicbox #w1.g1, 20,20,100,100
        Message 3 of 22 , Aug 20, 2007
        • 0 Attachment
          I'm trying a "simple" approach here, but something must be wrong.
          Why doesn't this snip work?
          Bill J.

          'start code
          nomainwin
          graphicbox #w1.g1, 20,20,100,100
          graphicbox #w1.g2, 70,70,100,100
          graphicbox #w1.g3, 120,120,100,100
          button #w1.b1, "g1",[g1],UL,240,20
          button #w1.b2, "g2",[g2],UL,240,70
          button #w1.b3, "g3",[g3],UL,240,120

          open "" for window as #w1
          hG1=hwnd(#w1.g1)
          hG2=hwnd(#w1.g2)
          hG3=hwnd(#w1.g3)
          WAIT

          [g1]
          Call ToTop hG1
          WAIT

          [g2]
          Call ToTop hG2
          WAIT

          [g3]
          Call ToTop hG3
          WAIT

          Sub ToTop hwnd
          calldll #user32, "BringWindowToTop",hwnd As Long
          End Sub
          'end code
        • Yahoo
          Never mind (sorry). I found it. I had forgotten to deal with the result in the API call. This works now. Bill J. start code nomainwin graphicbox #w1.g1,
          Message 4 of 22 , Aug 20, 2007
          • 0 Attachment
            Never mind (sorry). I found it.
            I had forgotten to deal with the result in the API call.
            This works now.
            Bill J.

            'start code
            nomainwin
            graphicbox #w1.g1, 20,20,100,100
            graphicbox #w1.g2, 70,70,100,100
            graphicbox #w1.g3, 120,120,100,100
            button #w1.b1, "g1",[g1],UL,240,20
            button #w1.b2, "g2",[g2],UL,240,70
            button #w1.b3, "g3",[g3],UL,240,120

            open "" for window as #w1
            hG1=hwnd(#w1.g1)
            hG2=hwnd(#w1.g2)
            hG3=hwnd(#w1.g3)
            WAIT

            [g1]
            Call ToTop hG1
            WAIT

            [g2]
            Call ToTop hG2
            WAIT

            [g3]
            Call ToTop hG3
            WAIT

            Sub ToTop hwnd
            calldll #user32, "BringWindowToTop",_
            hwnd As Long, Re as boolean
            End Sub
            'end code
          • JanetTerra
            Hi, Bill. You re missing a piece of the BringWindowToTop sub. Try this Sub ToTop handle Calldll #user32, BringWindowToTop , _ handle as Ulong, _ result as
            Message 5 of 22 , Aug 20, 2007
            • 0 Attachment
              Hi, Bill.
              You're missing a piece of the BringWindowToTop sub. Try this

              Sub ToTop handle
              Calldll #user32, "BringWindowToTop", _
              handle as Ulong, _
              result as Boolean
              End Sub

              Nice trick. I've tucked it away in my Code Bank. :)

              Janet

              --- In libertybasic@yahoogroups.com, Yahoo <ib8bbjen5gd@...> wrote:
              >
              > I'm trying a "simple" approach here, but something must be wrong.
              > Why doesn't this snip work?
              > Bill J.
              >
              > 'start code
              > nomainwin
              > graphicbox #w1.g1, 20,20,100,100
              > graphicbox #w1.g2, 70,70,100,100
              > graphicbox #w1.g3, 120,120,100,100
              > button #w1.b1, "g1",[g1],UL,240,20
              > button #w1.b2, "g2",[g2],UL,240,70
              > button #w1.b3, "g3",[g3],UL,240,120
              >
              > open "" for window as #w1
              > hG1=hwnd(#w1.g1)
              > hG2=hwnd(#w1.g2)
              > hG3=hwnd(#w1.g3)
              > WAIT
              >
              > [g1]
              > Call ToTop hG1
              > WAIT
              >
              > [g2]
              > Call ToTop hG2
              > WAIT
              >
              > [g3]
              > Call ToTop hG3
              > WAIT
              >
              > Sub ToTop hwnd
              > calldll #user32, "BringWindowToTop",hwnd As Long
              > End Sub
              > 'end code
              >
            • Yahoo
              At 02:37 AM 8/21/07 -0000, you wrote: Hi, Bill. You re missing a piece of the BringWindowToTop sub. Try this Sub ToTop handle Calldll #user32,
              Message 6 of 22 , Aug 21, 2007
              • 0 Attachment
                At 02:37 AM 8/21/07 -0000, you wrote:

                Hi, Bill.
                You're missing a piece of the BringWindowToTop sub. Try this

                Sub ToTop handle
                Calldll #user32, "BringWindowToTop", _
                handle as Ulong, _
                result as Boolean
                End Sub

                Nice trick. I've tucked it away in my Code Bank. :)
                -----------------------------------------------

                Actually, I stole it from Alyce's "Mastering LB3." (which is why I didn't
                pick up on Ulong).

                Bill J.
              Your message has been successfully submitted and would be delivered to recipients shortly.