Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a menu function?
#9
(12-14-2025, 08:16 PM)bplus Wrote: I will try something from primitive Sound command a one-liner with no need for assets.

Update:
Code: (Select All)
While _KeyDown(27) = 0
    'test click
    Sound 2000, .015
    _Delay .8
Wend

   I kinda like it,  thank you,    Actually doing Programmatic sounds is always kind of a chore for me,   I often just resort to PCM samples !    But this is what I have so far for my Button Library.   

Not bad I think for just an hour or so of work in it !     I have some other chores but when I come back to this I'm going to add Buttons with Images too !.

Code: (Select All)

Type BUTTONTYPE
    Height As Integer
    Width As Integer
    X As Integer
    Y As Integer
    Image As Long
    PushImage As Long
    OldImage As Long
    CREATED As Integer
    ONSCREEN As Integer
End Type

Dim B(0 To 2) As BUTTONTYPE

Screen _NewImage(800, 600, 256)


MAKEBUTTON_LABELBTN 16, B(0), 8, "BUTTON 0"
MAKEBUTTON_LABELBTN 16, B(1), 8, "BUTTON 1"
MAKEBUTTON_LABELBTN 16, B(2), 8, "BUTTON 2"

BUTTONPUT_XY B(0), 220, 60
BUTTONPUT_XY B(1), 220, 120
BUTTONPUT_XY B(2), 220, 190

Dim J As Integer
Do
    For J = 0 To 2
        PUSH_BUTTON B(J)
    Next

    _Limit 30
Loop Until InKey$ = Chr$(27)

End

Sub PUSH_BUTTON (BTarget As BUTTONTYPE)
    _PutImage (BTarget.X, BTarget.Y), BTarget.PushImage
    Sound 2000, .015
    _Delay .5
    _PutImage (BTarget.X, BTarget.Y), BTarget.Image
End Sub

Sub BUTTONPUT_XY (BTarget As BUTTONTYPE, X As Integer, Y As Integer)
    BTarget.X = X
    BTarget.Y = Y
    _PutImage (X, Y), BTarget.Image
    BTarget.ONSCREEN = _TRUE
End Sub

Sub MAKEBUTTON_LABELBTN (bFont As Long, NEWBUTTON As BUTTONTYPE, BorderWidth As Integer, Label As String)
    Dim CImage As Long
    Dim SaveHandle As Long
    Dim SavePMode As Integer
    Dim C As Integer
    Dim X As Integer
    Dim I As Integer
    Dim TWidth As Integer
    Dim THeight As Integer

    SaveHandle = _Font

    _Font bFont
    NEWBUTTON.Height = _FontHeight(bFont) + 8 + (BorderWidth * 2)
    NEWBUTTON.Width = _PrintWidth(Label) + 12 + (BorderWidth * 2)
    _Font SaveHandle
    SaveHandle = _Dest

    NEWBUTTON.Image = _NewImage(NEWBUTTON.Width, NEWBUTTON.Height, 256)

    NEWBUTTON.OldImage = _NewImage(NEWBUTTON.Width, NEWBUTTON.Height, 256)

    C = 0
    For I = 16 To 31
        _PaletteColor I, _RGB32(C, C, C, 255), NEWBUTTON.Image
        C = C + 16
    Next

    _Dest NEWBUTTON.Image
    TWidth = NEWBUTTON.Width
    THeight = NEWBUTTON.Height
    X = 0
    Y = 0
    I = 1
    If BorderWidth > 0 Then
        C = &H11
        Do
            Line (X, Y)-(X + (TWidth - 1), Y + (THeight - 1)), C, BF
            C = C + 1
            I = I + 1
            TWidth = TWidth - 2
            THeight = THeight - 2
            X = X + 1
            Y = Y + 1
        Loop Until I = BorderWidth
    Else
        C = &H15
        Line (X, Y)-(X + (TWidth - 1), Y + (THeight - 1)), C, BF
    End If
    NEWBUTTON.PushImage = _CopyImage(NEWBUTTON.Image)

    _Font bFont, NEWBUTTON.Image
    _PrintMode _KeepBackground , NEWBUTTON.Image
    Color 0
    _PrintString (0 + BorderWidth + 8, 0 + BorderWidth + 6), Label, NEWBUTTON.Image

    _Dest NEWBUTTON.PushImage
    _PrintMode _KeepBackground
    Color 15
    _PrintString (0 + BorderWidth + 8, 0 + BorderWidth + 6), Label, NEWBUTTON.PushImage
    _Dest NEWBUTTON.Image
    Color 15
    _PrintString (0 + BorderWidth + 6, 0 + BorderWidth + 4), Label, NEWBUTTON.Image
    _Dest SaveHandle
End Sub

Reply


Messages In This Thread
Is there a menu function? - by Mad Axeman - 12-14-2025, 05:03 PM
RE: Is there a menu function? - by bplus - 12-14-2025, 06:36 PM
RE: Is there a menu function? - by ahenry3068 - 12-14-2025, 07:00 PM
RE: Is there a menu function? - by bplus - 12-14-2025, 07:28 PM
RE: Is there a menu function? - by ahenry3068 - 12-14-2025, 07:54 PM
RE: Is there a menu function? - by bplus - 12-14-2025, 07:59 PM
RE: Is there a menu function? - by ahenry3068 - 12-14-2025, 08:13 PM
RE: Is there a menu function? - by ahenry3068 - 12-15-2025, 02:54 AM
RE: Is there a menu function? - by bplus - 12-14-2025, 08:16 PM
RE: Is there a menu function? - by ahenry3068 - 12-14-2025, 08:42 PM
RE: Is there a menu function? - by Mad Axeman - 12-14-2025, 11:16 PM
RE: Is there a menu function? - by Petr - 12-15-2025, 07:53 AM
RE: Is there a menu function? - by Mad Axeman - 12-15-2025, 09:05 AM
RE: Is there a menu function? - by Petr - 12-15-2025, 11:02 AM
RE: Is there a menu function? - by Mad Axeman - 12-15-2025, 11:13 AM
RE: Is there a menu function? - by bplus - 12-16-2025, 01:58 AM
RE: Is there a menu function? - by Pete - 12-16-2025, 10:28 PM
RE: Is there a menu function? - by SMcNeill - 12-17-2025, 04:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Star Suggestion for new REPLACE$() function zaadstra 3 262 01-26-2026, 05:11 PM
Last Post: grymmjack
  Universal Menu Concept Pete 3 388 01-05-2026, 07:31 PM
Last Post: Pete
  Trying to create a simple menu CMR 8 1,240 06-18-2025, 06:59 PM
Last Post: CookieOscar
  Another way to use Hardware Images and Transparency (alpha channel) for a PopUp Menu TempodiBasic 1 521 03-30-2025, 05:10 PM
Last Post: Pete
  Using the Screen function PhilOfPerth 19 3,099 04-16-2024, 05:23 PM
Last Post: bobalooie

Forum Jump:


Users browsing this thread: 1 Guest(s)