EDIT: NOW updated with 3 more NEW functions!
This function set will let you have complete control over your buttons and will save you alot of time, because they
ARE VERY EFFECTIVE and
EASY TO USE. Give 'em a try.
Just keep in mind that at the moment they are only for DBPro, simply because the functions use a global array, and DBC doesn't support global arrays. If anyone needs a DBC version then just let me know.
ALSO FOR THE DEMO know that it uses a bitmap for the backdrop so make sure you get it before running the demo.
Here's a COMPLETE LIST of all 13 functions:
----------------
BUTTON FUNCTIONS
----------------
-SetupButtonFunctions(TotalButtons,SilentError)
-DeSetupButtonFunctions()
-DefineButtonsToFile(File$,InkF)
-CreateButtonsFromDefinationsFile(File$,CT,DL,SilentError)
-CreateButton(Id,X1,Y1,X2,Y2,CT,DL)
-DeleteButton(Id)
-HighlightButton(Id,HighlightColor,RestoreInkF,RestoreInkB,Delay)
-HighlightAllButtons(Id,HighlightColor,RestoreInkF,RestoreInkB,Delay1,Delay2)
-PrintAllButtonDataToScreen(Top)
-CheckButton(Id)
-CheckAnyButton()
-CheckCursorOverButton(Id)
-CheckCursorOverAnyButton()
---------------
EXTRA FUNCTIONS
---------------
-GetInkForeground()
-GetInkBackground()
-FindFreeMedia(MediaType$,SilentError)
Here's a DETAILED DESCRIPTION and SYNTAX of all the functions:
------------------------------------------
-SetupButtonFunctions(TotalButtons,SilentError)
This function will allow you to use the various button functions that are included
in the ButtonFunctions.dba file. YOU MUST use this function BEFORE YOU CAN USE MOST
of the other functions included in the ButtonFunctions.dba file. First type in the
total amount of buttons that you want to use. Keep in mind that you MUST type in at
least a value of 1 for the total amount of buttons. Then type in a value of 0 or a
value of 1 for the SilentError. The SilentError is used in ALL of the Button Functions,
but not in the Extra Functions that are also included in the ButtonFunctions.dba file.
All of the Button Functions have a sort of built in debuging system in them, so if
you type in something into one of the functions it will give you an error that tells
you what the problem is and will then shutdown the program. If you specify a value of
0 for the SilentError then the debuging system will be active, however if you specify
a value of 1 for the SilentError then the debuging system will be inactive. When the
debuging system is inactive the functions will not notify you of the problem, and will
just do EXACTLY as you say, even if it will cause errors.
SYNTAX
SetupButtonFunctions(interger,interger)
------------------------------------------
-DeSetupButtonFunctions()
This function allows you to 'DeSetup' the ButtonFunctions. You use this function when
you want to specify a NEW amount of total buttons. Keep in mind after you use this
function you will have to use the 'SetupButtonFunctions()' function again in order to
specify the NEW amount of total buttons.
SYNTAX
DeSetupButtonFunctions()
------------------------------------------
-DefineButtonsToFile(File$,InkF)
All you do is first paste whatever you want on the screen like the backdrop for the
buttons, and then use the DefineButtonsToFile() function. It will give you a crosshair
cursor that fills up the whole screen, so you get accurate coordniates instead of
guessing. The cursor's coordinates are displayed at the top of the screen as well as
some other usefull information. You then move the cursor to the Top-Left of the button
and Left-Click and hold. Then move the cursor to the Bottom-Right of the button and
release. The Button data will be stored in a file that you can acces at any time. Also
by doing a Right-Click you can view or edit that data and close out of the data, and
you'll be back in the function. To end the function just hit the ESC key. Now to use
the function started just type in the full name of the file, and then type in what
color value you want the cursor to be
SYNTAX
DefineButtonsToFile(string,interger)
------------------------------------------
-CreateButtonsFromDefinationFile(File$,CT,DL,SilentError)
This function is will allow you to automatically create buttons. You must first use the
DefineButtonsToFile() function to create your button defination file, and then you use
this function. Now this function automatically calls the SetupButtonFunctions() function,
so make sure that you don't have them set up. The first thing you type in is the full
name of the defination file, the type in the ClickType for all the buttons, then type
in the Delay time for all the buttons. Now the only downside to this is you can't specify
the click type or delay time for each button, they have to be the same with this function,
but overall this function saves so much time, that it doesn't even matter. The last thing
you need to type in is the SilentError, which is explained under the SetupButtonFunctions()
function description, because this function calls the SetupButtonFunctions() function
automatically.
SYNTAX
CreateButtonsFromDefinationFile(string,interger,interger,interger)
------------------------------------------
-CreateButton(Id,X1,Y1,X2,Y2,CT,DL)
This function will allow you to create your own custom rectangular button. The first
thing you type in is the button number you want to create, and be sure that button
doesn't already exist. If the button does already exist then you may want to use
the 'DeleteButton()' function first. Next type in the FOUR coordniates of the button
in this order: Left,Top,Right,Bottom. Then you MUST type in the ClickType for the
button: 0 = No Click, 1 = Left Click, 2 = Right Click, 3 = Left+Right Click. Then you
MUST type in the Delay time for the button, which is specified in milliseconds. So,
a value of 0 = 0 seconds, 500 = 1/2 seconds, 1000 = 1 second, and so on.
SYNTAX
CreateButton(interger,interger,interger,interger,interger,interger)
------------------------------------------
-DeleteButton(Id)
This function will allow you to Delete any of the button's that you've previously
created. The only thing you have to type in is the Id of the button you wish to delete.
Just be sure that the specified button already exists. If you want to recreate the
button then you'll need to use the 'CreateButton()' function again.
SYNTAX
DeleteButton(interger)
------------------------------------------
-HighlightButton(Id,HighlightColor,RestoreInkF,RestoreInkB,Delay)
This function will allow you to highlight a SINGLE button that you specify. First type
in the Id of the button you want to highlight, and then type in the FULL COLOR value
that you want the HighlightColor to be. Keep in mind that you can use the Rgb() command
to get the color value that you desire. Also keep in mind that this changes the current
Ink color. Next you MUST type in either a value of 0 or a value of 1 for the RestoreInkF.
A value of 0 meaning that the Ink's forground color will NOT be changed back to it's
original value, and a value of 1 meaning that the Ink's forground color WILL be changed
back to its original value. Next you MUST type in either a value of 0 or a value of 1 for
the RestoreInkB. A value of 0 meaning that the Ink's background color will NOT be changed
back to it's original value, and a value of 1 meaning that the Ink's background color
WILL be changed back to it's original value. BUT, keep in mind that this function will
use the 'GetInkBackground()' function, so *****-IF-***** you specify a value of 1 for
the RestoreInkB, things can slow things down quite a bit. *****-BUT-IF-***** you use a
value of 0 for the RestoreInkB then the 'GetInkBackground()' function will NOT be used
and things *****-WON'T-SLOW-DOWN-*****. The last thing you MUST type in is the Delay,
which is specified in milliseconds, So a value of 0 = 0 seconds, 500 = 1/2 seconds,
1000 = 1 second, and so on. AFTER the button is highlighted the function will wait the
specified amount of time before it exits the function and continues running the program.
SYNTAX
HighlightButton(interger,interger,interger,interger,interger)
------------------------------------------
-HighlightAllButtons(Id,HighlightColor,RestoreInkF,RestoreInkB,Delay1,Delay2)
This function will allow you to highlight a ALL the buttons at ONCE. First type
in the FULL COLOR value that you want the HighlightColor to be. Keep in mind that
you can use the Rgb() command to get the color value that you desire. Also keep in mind
that this changes the current Ink color. Next you MUST type in either a value of 0 or a
value of 1 for the RestoreInkF. A value of 0 meaning that the Ink's forground color will
NOT be changed back to it's original value, and a value of 1 meaning that the Ink's
forground color WILL be changed back to its original value. Next you MUST type in either
a value of 0 or a value of 1 for the RestoreInkB. A value of 0 meaning that the Ink's
background color will NOT be changed back to it's original value, and a value of 1 meaning
that the Ink's background color WILL be changed back to it's original value. BUT, keep
in mind that this function will use the 'GetInkBackground()' function, so *****-IF-*****
you specify a value of 1 for the RestoreInkB, things can slow things down quite a bit.
*****-BUT-IF-***** you use a value of 0 for the RestoreInkB then the 'GetInkBackground()'
function will NOT be used and things *****-WON'T-SLOW-DOWN-*****. The next thing you MUST
type in is the Delay1, which is specified in milliseconds, So a value of 0 = 0 seconds,
500 = 1/2 seconds, 1000 = 1 second, and so on. AFTER EACH button is highlighted the function
will wait the specified amount of time before highlighting the next button. The last thing
you MUST type in is the Delay2, which is also specified in milliseconds. AFTER ALL the buttons
are highlighted the function will wait the specified amount of time before it exits the
function and continues running the program.
SYNTAX
HighlightButton(interger,interger,interger,interger,interger,interger)
------------------------------------------
-PrintAllButtonDataToScreen(Top)
This function will allow you to print the complete data of all your buttons to the screen.
The only thing you need to type in is either a value of 1 or 0 for the Top. A value of 1
will print the data at the top of the screen, and a value of 0 will print the data where
ever the current text cursor is at.
SYNTAX
PrintAllButtonDataToScreen(interger)
------------------------------------------
-Return Varible = CheckButton(Id)
This function will allow you to check the status of a single button. All you need to
is type in the button's Id of the button you want to check. Just make sure that you've
already created the button with the 'CreateButton()' function first. Now remember that
this function returns a interger, so you MUST act on that.
SYNTAX
interger varible = CheckButton(interger)
------------------------------------------
-Return Varible = CheckAnyButton()
This function will allow you to check the status of ANY the buttons at once. But, know
that this function will ONLY Return the Id of the first button it finds that is being
clicked, so if MORE then one button is being clicked at the SAME EXACT time then only
the first button's Id it finds that is being clicked will be returned. This would
only be a problem if you have overlapping buttons, which I can't even think of a reason
why you would have overlapping buttons, so in 99 percent of all casses this function
should work just fine and you shouldn't have any problems with it.
SYNTAX
interger varible = CheckAnyButton()
------------------------------------------
-Return Varible = CheckCursorOverButton(Id)
This function will allow you to check if the Mouse Cursor is over the button specified.
If the mouse cursor is over the button specified then a value of 1 will be returned, and
if the mouse cursor is NOT over the specified button then a value of 0 will be returned.
The only thing you need to type in is the Id of the button you want to check to see if
the mouse cursor is over it. Now remember that this function returns a interger, so you
MUST act on that.
SYNTAX
interger varible = CheckCursorOverButton(interger)
------------------------------------------
-Return Varible = CheckCursorOverAnyButton()
This function will allow you to check if the Mouse Cursor is over ANY of the buttons.
But, know that this function will ONLY Return the Id of the first button it finds that
the mouse cursor is over, so if the mouse cursor is over MORE than one button at the
SAME EXACT time then only the first button's Id it finds that mouse cursor is over will
be returned. This would only be a problem if you have overlapping buttons, which I can't
even think of a reason why you would have overlapping buttons, so in 99 percent of all
casses this function should work just fine and you shouldn't have any problems with it.
Now remember that this function returns a interger, so you MUST act on that.
SYNTAX
interger varible = CheckCursorOverAnyButton()
------------------------------------------
rem *******************************************************
rem THESE FUNCTIONS ARE EXTRA FUNCTIONS...
rem THE BUTTON FUNCTIONS USE THEM TO ACCOMPLISH THEIR TASKS
rem FEEL FREE TO USE THEM AS YOU WILL
rem *******************************************************
------------------------------------------
-Return Varible = GetInkForeground()
This function will allow you to get the Ink's CURRENT FOREGROUND color. The return value
will be in the color's FULL color value. If you wish to get the color's RGB values, then
use the RgbR(), RgbG(), and RgbB() commands.
SYNTAX
interger varible = GetInkForeground()
------------------------------------------
-Return Varible = GetInkBackground()
This function will allow you to get the Ink's CURRENT BACKGROUND color. The return value
will be in the color's FULL color value. If you wish to get the color's RGB values, then
use the RgbR(), RgbG(), and RgbB() commands. HOWEVER, KEEP IN MIND THAT THIS FUNCTION IS
VERY SLOW.
SYNTAX
interger varible = GetInkBackground()
------------------------------------------
-Return Varible = FindFreeMedia(MediaType$,SilentError)
This function is a very useful function that can be used in basically any program. It
allows you to FIND the Id number of availble media. First you MUST type what media type
your looking for, which can be: "Music", "Sound", "Bitmap", "Image", "Object", or "MemBlock".
BE SURE that your SPELLING AND CAPS ARE EXACTLY like the ones shown here. Next you MUST
type in either a value of 0 or a value of 1 for the SilentError. A value of 1 meaning that
the function will NOT notify you of an errors that may occur, and a value of 0 meaning that
the function WILL notify you if any errors occur. IF you type in a value of 1, and the
function can NOT find any availble media of the specified type then it will Return a value
of -1. Now remember that this function returns a interger, so you MUST act on that.
SYNTAX
interger varible = FindFreeMedia(string,interger)
------------------------------------------
Here's all the FUNCTION'S code:
Rem *** Include File: ButtonFunctions.dba ***
Rem Created: 8/14/2005 4:00:54 PM
Rem Included in Project: C:PROGRAM FILESTHE GAME CREATORSDARK BASIC PROFESSIONAL ONLINEProjectsButtonFunctButtonFunct.dbpro
Function SetupButtonFunctions(TotalButtons,SilentError)
If TotalButtons=0
Hide Window
Exit Prompt "Setup Can Not Occur Because You Must Specify A Total Buttons Of AT LEAST 1 Button!","ButtonFunctions - ERROR"
End
EndIf
Global Dim ButtonData(TotalButtons,6)
ButtonData(0)=TotalButtons : ButtonData(0,1)=SilentError
For Num= 1 To ButtonData(0)
ButtonData(Num,0)=-1
Next Num
EndFunction
Function DeSetupButtonFunction()
If Array Index Valid(ButtonData(0))=0 Then ButtonFunctionsNotSetupError()
UnDim ButtonData(0)
EndFunction
Function DefineButtonsToFile(File$,InkF)
SW=Screen Width() : SH=Screen Height() : Hide Mouse
Get Image 2,0,0,SW,SH,1 : Ink InkF,0 : State=0
If File Exist(File$)=1 Then Delete File File$
Open To Write 1,File$ : Write String 1,"Buttons: 0" : Close File 1
Do
Paste Image 2,0,0 : Text 10,10,"XPos: "+Str$(MouseX())+" : "+"YPos: "+Str$(MouseY())
Text 10,30,"Right-Click To View Data" : Text 10,50,"Esc Key To Quit"
Line MouseX(),0,MouseX(),SH : Line 0,MouseY(),SW,MouseY()
If State=1 and MouseClick()=1
Line X1,Y1,X1,MouseY() : Line X1,MouseY(),MouseX(),MouseY()
Line MouseX(),MouseY(),MouseX(),Y1 : Line MouseX(),Y1,X1,Y1
EndIf
If State=0 and MouseClick()=1 Then X1=MouseX() : Y1=MouseY() : State=1
If State=1 and MouseClick()=0 Then X2=MouseX() : Y2=MouseY() : State=2
If State=2
Temp$="Temp.dat"
If File Exist(Temp$)=1 Then Delete File Temp$
Copy File File$,Temp$ : Delete File File$
Open To Write 1,File$ : Open To Read 2,Temp$
Read String 2,Data$ : TotalButtons=Val(Right$(Data$,Len(Data$)-9))
Inc TotalButtons : Write String 1,"Buttons: "+Str$(TotalButtons)
While File End(2)=0
Read String 2,Data$ : Write String 1,Data$
EndWhile
Write String 1,"Button: "+Str$(TotalButtons)
Write String 1,"X1: "+Str$(X1) : Write String 1,"Y1: "+Str$(Y1)
Write String 1,"X2: "+Str$(X2) : Write String 1,"Y2: "+Str$(Y2)
Close File 1 : Close File 2
Delete File Temp$
State=0
EndIf
If MouseClick()=2
Show Mouse : Minimize Window
Execute File File$,"","",1
Hide Mouse : Restore Window
EndIf
Sync
Loop
EndFunction
Function CreateButtonsFromDefinationsFile(File$,CT,DL,SilentError)
Open To Read 1,File$
Read String 1,Data$ : TotalButtons=Val(Right$(Data$,Len(Data$)-9))
SetupButtonFunctions(TotalButtons,SilentError)
Repeat
Read String 1,Data$
If Left$(Data$,8)="Button: "
Id=Val(Right$(Data$,Len(Data$)-8))
Read String 1,Data$ : X1=Val(Right$(Data$,Len(Data$)-4))
Read String 1,Data$ : Y1=Val(Right$(Data$,Len(Data$)-4))
Read String 1,Data$ : X2=Val(Right$(Data$,Len(Data$)-4))
Read String 1,Data$ : Y2=Val(Right$(Data$,Len(Data$)-4))
CreateButton(Id,X1,Y1,X2,Y2,CT,DL)
EndIf
Until File End(1)=1
EndFunction
Function CreateButton(Id,X1,Y1,X2,Y2,CT,DL)
If Array Index Valid(ButtonData(0))=0 Then ButtonFunctionsNotSetupError()
If Id<1 and ButtonData(0,1)=0
Hide Window
Exit Prompt "Button Creation Can Not Occur Because Button Id MUST be Greater than 0!","ButtonFunctions - ERROR"
End
EndIf
If ButtonData(Id,0)=1 and ButtonData(0,1)=0
Hide Window
Exit Prompt "Button #"+Str$(Id)+" Can Not Be Created Because It Already Exists, You Must First Delete It Before Recreating It!","ButtonFunctions - ERROR"
End
EndIf
ButtonData(Id,0)=1
ButtonData(Id,1)=X1 : ButtonData(Id,2)=Y1
ButtonData(Id,3)=X2 : ButtonData(Id,4)=Y2
ButtonData(Id,5)=CT : ButtonData(Id,6)=DL
EndFunction
Function DeleteButton(Id)
If Array Index Valid(ButtonData(0))=0 Then ButtonFunctionsNotSetupError()
If ButtonData(Id,0)=-1 and ButtonData(0,1)=0
Hide Window
Exit Prompt "Button #"+Str$(Id)+" Can Not Be Deleted Because It Doesn't Exist!","ButtonFunctions - Error"
End
EndIf
ButtonData(Id,0)=-1
EndFunction
Function CheckButton(Id)
If Array Index Valid(ButtonData(0))=0 Then ButtonFunctionsNotSetupError()
If ButtonData(Id,0)=-1 and ButtonData(0,1)=0
Hide Window
Exit Prompt "Button #"+Str$(Id)+" Can Not Be Checked Because It Has Not Been Created Yet!","ButtonFunctions - ERROR"
End
EndIf
If MouseX()=>ButtonData(Id,1) and MouseY()=>ButtonData(Id,2)
If MouseX()=<ButtonData(Id,3) and MouseY()=<ButtonData(Id,4)
If MouseClick()=ButtonData(Id,5)
Wait ButtonData(Id,6)
ExitFunction 1
EndIf
EndIf
EndIf
EndFunction 0
Function CheckAnyButton()
If Array Index Valid(ButtonData(0))=0 Then ButtonFunctionsNotSetupError()
For Num= 1 To ButtonData(0)
If CheckButton(Num)=1 Then ExitFunction Num
Next Num
EndFunction 0
Function CheckCursorOverButton(Id)
If Array Index Valid(ButtonData(0))=0 Then ButtonFunctionsNotSetupError()
If MouseX()=>ButtonData(Id,1) and MouseY()=>ButtonData(Id,2)
If MouseX()=<ButtonData(Id,3) and MouseY()=<ButtonData(Id,4)
ExitFunction 1
EndIf
EndIf
EndFunction 0
Function CheckCursorOverAnyButton()
If Array Index Valid(ButtonData(0))=0 Then ButtonFunctionsNotSetupError()
For Num= 1 To ButtonData(0)
If MouseX()=>ButtonData(Num,1) and MouseY()=>ButtonData(Num,2)
If MouseX()=<ButtonData(Num,3) and MouseY()=<ButtonData(Num,4)
ExitFunction Num
EndIf
EndIf
Next Num
EndFunction 0
Function HighlightButton(Id,HighlightColor,RestoreInkF,RestoreInkB,Delay)
If Array Index Valid(ButtonData(0))=0 Then ButtonFunctionsNotSetupError()
If ButtonData(Id,0)=-1 and ButtonData(0,1)=0
Hide Window
Exit Prompt "Button #"+Str$(Id)+" Can Not Be Hightlighted Because It Has Not Been Created Yet!","ButtonFunctions - ERROR"
End
EndIf
If RestoreInkF=1 Then OldInkF=GetInkForeground()
If RestoreInkB=1 Then OldInkB=GetInkBackground()
X1=ButtonData(Id,1) : Y1=ButtonData(Id,2)
X2=ButtonData(Id,3) : Y2=ButtonData(Id,4)
Ink HighlightColor,0
Line X1,Y1,X1,Y2 : Line X1,Y2,X2,Y2
Line X2,Y2,X2,Y1 : Line X2,Y1,X1,Y1
If RestoreInkF=1 and RestoreInkB=1
Ink OldInkF,OldInkB
Else
If RestoreInkF=1 Then Ink OldInkF,0
If RestoreInkB=1 Then Ink Rgb(R,G,B),OldInkB
EndIf
Wait Delay
EndFunction
Function HighlightAllButtons(HighlightColor,RestoreInkF,RestoreInkB,Delay1,Delay2)
If Array Index Valid(ButtonData(0))=0 Then ButtonFunctionsNotSetupError()
If RestoreInkF=1 Then OldInkF=GetInkForeground()
If RestoreInkB=1 Then OldInkB=GetInkBackground()
For Id= 1 To ButtonData(0)
X1=ButtonData(Id,1) : Y1=ButtonData(Id,2)
X2=ButtonData(Id,3) : Y2=ButtonData(Id,4)
Ink HighlightColor,0
Line X1,Y1,X1,Y2 : Line X1,Y2,X2,Y2
Line X2,Y2,X2,Y1 : Line X2,Y1,X1,Y1
Sync
Wait Delay1
Next Id
If RestoreInkF=1 and RestoreInkB=1
Ink OldInkF,OldInkB
Else
If RestoreInkF=1 Then Ink OldInkF,0
If RestoreInkB=1 Then Ink Rgb(R,G,B),OldInkB
EndIf
Wait Delay2
EndFunction
Function PrintAllButtonDataToScreen(Top)
If Top=1 Then Set Cursor 0,0
Print "Total Buttons: "+Str$(ButtonData(0))
Print "SilentError: "+Str$(ButtonData(0,1))
For Id= 1 To ButtonData(0)
X1=ButtonData(Id,1) : X2=ButtonData(Id,2)
X2=ButtonData(Id,3) : Y2=ButtonData(Id,4)
CT=ButtonData(Id,4) : DL=ButtonData(Id,6)
Print "Button "+Str$(Id)+" - "+Str$(X1)+","+Str$(Y1)+","+Str$(X2)+","+Str$(Y2)+","+Str$(CT)+","+Str$(DL)
Next Id
EndFunction
rem *******************************************************
rem THESE FUNCTIONS ARE EXTRA FUNCTIONS...
rem THE BUTTON FUNCTIONS USE THEM TO ACCOMPLISH THEIR TASKS
rem FEEL FREE TO USE THEM AS YOU WILL
rem *******************************************************
rem --------------------START OF EXTRA FUNCTIONS-----------
Function GetInkForeground()
OldPixel=Point(1,1)
Dot 1,1 : Color=Point(1,1)
Ink OldPixel,0 : Dot 1,1
EndFunction Color
Function GetInkBackground()
ImageId=FindFreeMedia("Image",0)
Get Image ImageId,0,0,Screen Width(),Screen Height()
Cls : Color=Point(1,1)
Paste Image ImageId,0,0 : Delete Image ImageId
EndFunction Color
Function FindFreeMedia(MediaType$,SilentError)
Match=0
If MediaType$="Music"
Match=1
For Num= 1 To 32
If Music Exist(Num)=0 Then ExitFunction Num
Next Num
EndIf
If MediaType$="Sound"
Match=1
For Num= 1 To 65535
If Sound Exist(Num)=0 Then ExitFunction Num
Next Num
EndIf
If MediaType$="Bitmap"
Match=1
For Num= 1 To 32
If Bitmap Exist(Num)=0 Then ExitFunction Num
Next Num
EndIf
If MediaType$="Image"
Match=1
For Num= 1 To 65535
If Image Exist(Num)=0 Then ExitFunction Num
Next Num
EndIf
If MediaType$="Object"
Match=1
For Num= 1 To 65535
If Object Exist(Num)=0 Then ExitFunction Num
Next Num
EndIf
If MediaType$="MemBlock"
Match=1
For Num= 1 To 32
If MemBlock Exist(Num)=0 Then ExitFunction Num
Next Num
EndIf
If Match=0 and SilentError=0
Hide Window
Exit Prompt "Your Specified Media Type '"+MediaType$+"' Is INCORRECT, Check It's Spelling and Caps","ButtonFucntions - ERROR"
End
EndIf
If SilentError=0
Hide Window
Exit Prompt "A Free "+MediaType$+" Can NOT Be Found!","ERROR"
End
EndIf
EndFunction -1
Function ButtonFunctionsNotSetupError()
Hide Window
Exit Prompt "YOU MUST FIRST Use The 'SetupButtonFunctions()' Function Before Using Any Of It's Sub-Functions!","ButtonFunctions - ERROR"
End
EndFunction
rem --------------------END OF EXTRA FUNCTIONS-------------
Here's the DEMO code:
Rem Project: ButtonFunctions DEMO
Rem Created: 08/20/2005 4:48:17 PM
Rem ***** Main Source File *****
SetupButtonFunctions(5,1)
CreateButton(1,265,172,362,194,1,0)
CreateButton(2,265,198,362,220,1,0)
CreateButton(3,265,224,362,246,1,0)
CreateButton(4,265,250,362,272,1,0)
CreateButton(5,265,276,362,298,1,0)
Dim Msg$(5)
Msg$(1)="Starting new game...not really"
Msg$(2)="Loading game...not really"
Msg$(3)="There are no options avalible, sorry"
Msg$(4)="Created by: Tim Valentine"
Msg$(5)="Now quiting program..."
Ink Rgb(255,255,255),0 : HighlightColor=Rgb(255,0,0)
Load Image "Menu.bmp",1,1
Do
Paste Image 1,0,0
OverButton=CheckCursorOverAnyButton()
If OverButton>0 Then HighlightButton(OverButton,HighlightColor,1,0,0)
ClickedButton=CheckAnyButton()
If ClickedButton>0 Then Text 10,10,Msg$(ClickedButton) : Wait 1000 : If ClickedButton=5 Then End
If MouseClick()=3 Then HighlightAllButtons(HighlightColor,1,0,1000,1000)
Sync
Loop
Now BE SURE to save the FUNCTIONS as a .dba file called ButtonFunctions, and be sure to KEEP THAT FILE IN SAME DIRECTORY AS THE FILE THAT WILL USE THE FUNCTIONS. Also MAKE SURE THAT YOU USE THE #INCLUDE command to include the ButtonFunctions.dba file with your MAIN SCOURCE file.
I've also included a .zip file with this post that includes the
following in it:
-ButtonFunctions - Descriptions.txt
-ButtonFunctions - List.txt
-Menu.bmp (you need this for the demo to work!)
-ButtonFunctions DEMO.dbpro
-ButtonFunctions DEMO.dba
-ButtonFunctions.dba
-Thread Post.txt
If you just get the .zip file and open it up you can just run the
ButtonFunctions DEMO file in DBPRO and test it out. Now I've
tested all of these functions quite a bit, and I'm pretty sure that
I've fixed all the bugs, but if you do happen to find a bug, then please report it to me as soon as possible. ENJOY!