uses crt,graph,mouse,gui;
Var tab: integer;
i : char;
bok,bcancel : bobject;
nameb : ttextbox;
Dropdownmenu1 : ddmobject;
Begin
initvga;
display_desktop;
showmouse; {display the mouse on screen}
Tab:=1; {this set the curent button select by the keyboard}
dropdownmenu1.tbutton[1]:='check'; {name of first button on drop down menu}
dropdownmenu1.tbutton[2]:='Close'; {name of second button on drop down menu}
{to add more button cange variable eg tbutton[x]:='???'; where X in the button
number for top to bottom. NOT CHANG THE VARIABLE IN THE INIT PROCEDURE TO ADD
MORE BUTTONS. EG Dropdownmenu1.init(1,1,100,20,Y,'file',green);
Where Y is the number of buttons}
{NOTE YOU MUST SET THE BUTTON NAME FIST THEN RUN THE INIT CODE}
Dropdownmenu1.init(1,1,100,30,2,'file',green); {first 4 vars are cordnts of
the first button. Note the other buttons are calcuated artomaticly
the next var is the number of button on the menu and the last var is the
colour}
nameb.init(20,100,120,120,3); {First 4 variables are the cordints last one is
tab possision in the tab order}
bok.init(150,50,250,100,1,'Ok',green,1);
bcancel.init(300,50,400,100,2,'Close',green,1); {the first 4 vars are the buttons coridnts on the screen x,y,x1,y1}
{
x,y------------x1,y
: :
: :
: :
x,y1-----------x1,y1
then next one is the tab order then the next one is the button name. the next one is button color and the last one between
0 and 1 0 is normal button 1 is butten with curved edges}
Repeat
I := Chr(255); {this set the key back to nill do not change unless you realy know what you are doing}
If Keypressed Then
I := Readkey; {this just gets the key wtich are pressed on the keyboard this is very importet as it is needed for
the tab fuctions and textboxes will not work without it. it also do not wait for a key pressed so it is idle for games
also}
If I=Chr(9) Then Inc(Tab); {if the tab button is pressed then move the tab to the next one}
If I=Chr(15) Then {if the tab and shift button is pressed the move the tab back one}
Tab:=Tab-1;
if tab<=0 then tab := 2;
if tab>3 then tab:=1; {these set the limit to the tabs the buttons and textboxes, items that you what to be able to tab between
so if you have more than 2 change the value 2 to how many items you have}
DropDownMenu1.Run(i); {all this neads is the input for the keyboard}
if dropdownmenu1.obutton[1].clicked then {if the 1st button is pressed in menu}
begin
dropdownmenu1.close; {this closes the menu}
if nameb.textstring='test' then {if the data entered in the text box = test}
error_box(100,100,300,300,'Data entered correct','','',True)
Else error_box(100,100,300,300,'Data entered InCorrect','Please Re-Enter','',True);
{this is just the same code a below}
End;
nameb.run(tab,i);
bok.run(tab,i);
bcancel.run(tab,i);
{this will run all the code for the button everything. the first vale the cureent tab selected
and the last one is the imput for the keyboard what order you what the button to be in
the tab form. what i meen is when you press the tab putton on the keyboard it will sitch between them. and the variable tab
is the current button seleted}
if bok.clicked then {check to see if the buton is pressed}
if nameb.textstring='test' then {if the data entered in the text box = test}
error_box(100,100,300,300,'Data entered correct','','',True)
Else error_box(100,100,300,300,'Data entered InCorrect','Please Re-Enter','',True);
{first 4 variables are the coridnts to display on screen
the next 3 are the error message to display on screen
the last one is if you want the internal speker to bleep
set it to true to bleep and false to swith it off}
if dropdownmenu1.obutton[2].clicked then bcancel.clicked:=true;
{if the 2 button on menu pressed then force the cancel button to be true
this is the last line of code so that the bcancel can not be swicted back
to false when ruing the bcancel.run proceder}
Until bcancel.clicked;{note you can have bok.pressed or bok.clicked i got a bit confuesd when i programed this i a carnt
remember which is which. one will be when you presses the button and then let go, and the other will be one that works
as soon as you press it.}
End.