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

Using Bmpbuttons and mouse events

Expand Messages
  • Ben Scott
    I have recently made a program that involved secondary borders, like a groupbox but it cannot work with a groupbox. What I have done is made a bmpbutton (of a
    Message 1 of 6 , Apr 30, 2004
    • 0 Attachment
      I have recently made a program that involved secondary borders, like
      a groupbox but it cannot work with a groupbox. What I have done is
      made a bmpbutton (of a single white dot) that is then transformed and
      moved using the 'locate' command. The borders are clickable, but
      they are only two pixels thick, and they are led to a wait command.

      Now this works all well, but I have a question:

      How can I make a sliding bar, that will move when I click on it and
      drag it, but It only goes so far left and right. I did try to use a
      sprite, and that worked very well, but I need to use a 'window'
      window, and I guess I could use several graphics boxes, but I am only
      allowed one that contains sprites at a time.
    • JanetTerra
      ... a ... only ... Do you need to use a sprite (or sprites) for the sliding bar? Could something like this work? GraphicBox #sb.g, 25, 150, 150, 100 Open
      Message 2 of 6 , Apr 30, 2004
      • 0 Attachment
        --- In libertybasic@yahoogroups.com, "Ben Scott" <kaboomer16@h...>
        wrote:

        >
        > How can I make a sliding bar, that will move when I click on it and
        > drag it, but It only goes so far left and right. I did try to use
        a
        > sprite, and that worked very well, but I need to use a 'window'
        > window, and I guess I could use several graphics boxes, but I am
        only
        > allowed one that contains sprites at a time.

        Do you need to use a sprite (or sprites) for the sliding bar? Could
        something like this work?


        GraphicBox #sb.g, 25, 150, 150, 100
        Open "Sliding Bar" for Window as #sb
        #sb.g, "Trapclose [endProgram]"
        #sb.g, "when leftButtonMove [slideBar]"
        #sb.g, "setfocus"
        #sb.g, "Down"
        #sb.g, "Fill Darkcyan"
        #sb.g, "Color Darkgray"
        #sb.g "BackColor Darkgray"
        #sb.g, "Place 15 15"
        #sb.g, "Boxfilled 100 25"
        #sb.g, "Flush"
        Wait

        [slideBar]
        #sb.g, "Delsegment ";segmentID
        x1 = 15
        y1 = 15
        x2 = Max(MouseX,15)
        x2 = Min(x2, 100)
        y2 = 25
        #sb.g, "Color Darkgray"
        #sb.g, "BackColor Darkgray"
        #sb.g, "Place 15 15"
        #sb.g, "Boxfilled 100 25"
        #sb.g, "BackColor DarkBlue"
        #sb.g, "Place ";x1;" ";y1
        #sb.g, "Boxfilled ";x2;" ";y2
        #sb.g, "Segment segmentID"
        #sb.g, "Flush"
        Wait

        [endProgram]
        Popupmenu "E&xit",[yesQuit],|,"&Cancel",[mainAwaitInput]
        [yesQuit]
        Close #sb
        End

        I've not done a lot with multiple graphic boxes, but I think you
        could use one graphicbox for your sprite and another for turtle
        graphics. Be careful with your setfocus commands.
        Janet
      • Ben Scott
        ... Yes this would work very well for exactly what I need, but there is a problem, I want many of them (I think 16) some shown and some hiding at different
        Message 3 of 6 , May 1, 2004
        • 0 Attachment
          > I've not done a lot with multiple graphic boxes, but I think you
          > could use one graphicbox for your sprite and another for turtle
          > graphics. Be careful with your setfocus commands.
          > Janet

          Yes this would work very well for exactly what I need, but there is a
          problem, I want many of them (I think 16) some shown and some hiding
          at different times, and I need to use a window window...

          So if you can see my porblem

          Thank you for your help

          Ben Scott
        • JanetTerra
          ... a ... hiding ... Ben, If you use a graphicbox within a regular window, then you could place as many sliders as you want. You d just need to obtain the
          Message 4 of 6 , May 1, 2004
          • 0 Attachment
            --- In libertybasic@yahoogroups.com, "Ben Scott" <kaboomer16@h...>
            wrote:

            > Yes this would work very well for exactly what I need, but there is
            a
            > problem, I want many of them (I think 16) some shown and some
            hiding
            > at different times, and I need to use a window window...
            >
            > So if you can see my porblem
            >
            > Thank you for your help
            >
            > Ben Scott

            Ben, If you use a graphicbox within a regular window, then you could
            place as many sliders as you want. You'd just need to obtain the
            MouseX and MouseY variables and, using those variables, determine
            which slider the user is manipulating, then use the same routine.
            That routine could either be a sub Slider slideNumber, x, y or a
            subroutine [slider]. But, are you saying you can't use even a
            graphicbox within a regular window? (Because you could use one
            graphicbox for each slider and size the graphicbox to be the exact
            size of the slider.) And you still want the user to adjust several
            sliders? There is a way to capture the mouse events in a regular
            window. Search either the LB Forum and/or the newsletters. Or, do
            you just need to display the slider but the adjustment is actually
            controlled by the program and not the user? Please clarify: (1) Can
            one or more graphicboxes within a regular window be used and (2) Will
            the user be adjusting the slider?
            Janet
            If you need the display on a regular window with user control, I'm
            thinking along the lines of kc)monkeyman's idea of disabled bmp
            buttons and Alyce's newsletter article (NL#105) re: changing bmp's on
            a bmp button and then perhaps using side arrow keys to adjust lesser -
            greater. Just a thought
          • John Davidson
            ... Hey Ben, Sounds like you want a trackbar control. Microsoft Win32 Programmer s Reference says A trackbar is a window that contains a slider and optional
            Message 5 of 6 , May 1, 2004
            • 0 Attachment
              > How can I make a sliding bar, that will move when I click on it and
              > drag it, but It only goes so far left and right. I did try to use

              Hey Ben,
              Sounds like you want a trackbar control.
              Microsoft Win32 Programmer's Reference says "A trackbar is a window
              that contains a slider and optional tick marks. When the user moves
              the slider, using either the mouse or the direction keys, the
              trackbar sends notification messages to indicate the change."

              This, and other common controls, are covered in the Microsoft Win32
              Programmer's Reference.
              If you are new to LB, or programming, this reference is can be pretty
              scary.

              After many long hours of research I've found an easy way to create a
              trackbar, copy it from Liberty BASIC 4 Companion or Mastering LB 3!

              Now for a little off topic bloviating:

              Alyce asked my one time how I remember code references. Fact is, I
              can't, but I can remember the Liberty Five Step Plan.

              1 LB's very own helpfile

              2 Liberty BASIC 4 Companion or Mastering LB 3.
              Required reading for those who are serious about their programming,
              it is also very handy for lazy programmers, like myself!

              3 LB Newsletters.
              An unbelievable of information by some of the very best programmers
              around.

              4 Users Groups
              I always do a search before asking for help because it seems that
              someone has provided the solution long before I even have a problem.
              Don't forget to check the files section.

              5 Liberty BASIC Programmer's web sites.
              These sites all have applications written in LB and most keep
              snippets of code right out in plain view.

              The code found at these sites can be from the very basic to stuff so
              advanced it makes my head hurt thinking about it.

              I'm not sure why someone would put in so much effort producing and
              maintaining a web site but I sure do appreciate it.
              Without these sites most of my apps would be about four lines long!


              HTH
              John Davidson
              e-me: johnshomeport@...
              home: http://www.geocities.com/johnshomeport/
              Did ya Libby yet? http://libby.lbdownloads.com/
            • JanetTerra
              ... wrote: and I need to use a window window... ... Well, can you live with arrow buttons rather than mouse dragging? Maybe someone will even come up with an
              Message 6 of 6 , May 1, 2004
              • 0 Attachment
                --- In libertybasic@yahoogroups.com, "Ben Scott" <kaboomer16@h...>
                wrote:
                and I need to use a window window...
                >
                > So if you can see my porblem
                >
                > Thank you for your help
                >
                > Ben Scott

                Well, can you live with arrow buttons rather than mouse dragging?
                Maybe someone will even come up with an API/DLL that will allow the
                button to read a continuous depressed key rather than having to
                reclick each time. You'll need to run this from your main LB
                directory (or change the path to the bmp directory). The disable
                function won't work in LB3. If you don't have LB4, rem out that one
                line.


                Nomainwin
                GoSub [createSliderBitMaps]
                BmpButton #w.btn0, "bmp\blank2.bmp", [doNothing], UL, 40, 40
                BmpButton #w.btn1, "bmp\leftbttn.bmp", [decreaseSomething], UL,
                20, 40
                BmpButton #w.btn1, "bmp\rghtbttn.bmp", [increaseSomething], UL,
                240, 40

                Open "SliderDemo" for Window as #w
                #w, "Trapclose [endDemo]"
                ' #w.btn0, "Disable"
                sliderAmount =10
                #w.btn0 "bitmap ";slider$(sliderAmount)
                #w.btn0, "locate 40 40 200 20"
                #w, "Refresh"

                [doNothing]
                Wait

                [decreaseSomething]
                sliderAmount = Max(0,sliderAmount-1)
                #w.btn0 "bitmap ";slider$(sliderAmount)
                #w.btn0, "locate 40 40 200 20"
                #w, "Refresh"
                Wait

                [increaseSomething]
                sliderAmount = Min(20,sliderAmount+1)
                #w.btn0, "bitmap ";slider$(sliderAmount)
                #w.btn0, "locate 40 40 200 20"
                #w, "Refresh"
                Wait

                [createSliderBitMaps]
                Open "CreateSliders" for graphics_nsb as #gw
                Dim slider$(20)
                #gw, "Down"
                #gw, "Fill LightGray"
                #gw, "Color DarkCyan"
                #gw, "Backcolor DarkBlue"
                For i = 0 to 20
                slider$(i) = "Slider"
                If i < 10 Then
                slider$(i) = slider$(i);"0"
                End If
                slider$(i) = slider$(i);Str$(i)
                Next i
                ct = 0
                For i = 40 to 240 step 10
                #gw, "Place 40 40"
                #gw, "box 240 60"
                #gw, "boxfilled ";i;" ";60
                slider$ = slider$(ct)
                #gw, "Getbmp ";slider$;" 40 40 200 20"
                ct = ct + 1
                Next i
                #gw, "cls"
                Close #gw
                Return

                [endDemo]
                Popupmenu "E&xit",[quit],|,"&Cancel",[cancel]
                [cancel]
                Wait
                [quit]
                For i = 0 to 20
                Unloadbmp slider$(i)
                Next i
                Close #w
                End
              Your message has been successfully submitted and would be delivered to recipients shortly.