Here's an English version (I translated most of the comments)
I often wrote "no comment" when the meaning was very easy to be guessed in less than 2 seconds ^_^
Set display mode 1024,736,32
Sync on
Sync rate 50
set text size 21
randomize timer()
rem there variables are used to get informations about the mouse
rem mm? => mouse move ?
global g_mmx
global g_mmy
global g_clic
global g_lastmove
global g_idle
remstart
Here are the variables for the windows
most of them are in english, so that isn't a problem for you to
understand
the last one, fermable, means "able to be closed" - if it is ONE,
then there won't be the X in the corner)
remend
type t_window
open as boolean
x as word
y as word
width as word
height as word
title as string
reposx as word
reposy as word
move as boolean
gadgets as byte
fermable as boolean
endtype
dim window(32) as t_window
remstart
here are several variables that give informations...
wingadget() is the link that tells the program that the
Nth gadget of the Mth window is the gadget number O
winpos() stock the ordre of the windows.
remend
dim wingadget(32,32)
dim winpos(32) as byte
for t=1 to 32
winpos(t)=t
next t
remstart
And the gadgets ...
+ sorte : king of gadget
1. buttons
2. labels
3. input boxes
4. checkboxes
5. loadingbars
6. trackbars -
7. trackbars |
+ win : number of the window
+ x : position X
+ y : position Y
+ width : no comment
+ height : no comment
+ entier/flottant/chaine/min/max : data
+ tip : help string
remend
type t_gadget
sorte as integer
win as integer
x as integer
y as integer
width as integer
height as integer
entier as integer
flottant as float
chaine as string
min as integer
max as integer
tip as string
endtype
dim gadget(512) as t_gadget
rem very important ;)
InitGadgets()
OpenWindow("Menu", 20, 20, 200, 150, 0, "MENU")
addbutton("Menu", "Menu - open second menu", 5, 5, "Open another menu", "This button opens another window...")
resizewindow("Menu")
rem I'll explain step by step this window...
rem first step : I open it (name, position X, position Y, size X, size Y, closing X, title)
OpenWindow("Menu2", 20, 300, 250, 180, 1, "Menu 2")
rem adding a trackbar : name of the window, name of the trackbar, position (2), height, minimal value, maximal value, current value, tip
addtrackbarv("Menu2", "tbar", 2, 2, 144, 1, 100, 50, "This is only a trackbar :)")
rem a label now... almost the same - look at the parameters of the function (chaine => string => text in the gadget)
addlabel("Menu2", "lbl", 30, 5, 250, "This a label that is displayed on several lines. As you can see, it cuts the text between words.","")
rem an input in which I'll display the value of the trackbar
addinput("Menu2", "tbar value", 30, 80, 50, "This is the value of the trackbar.")
rem this command set the size of the windows so it fit exactly with the gadgets
resizewindow("Menu2")
rem hide the window (by name / hidewindow() works by number)
hidewindow_nom("Menu2")
do
CLS
ink rgb(255,255,255),0
set cursor 0,0
rem updating and displaying
UpdateMouse()
update_windows()
rem and here we have fun :)
if get_button("Menu - open second menu")=1 then showwindow("Menu2")
v = get_trackbar("tbar")
set_input("tbar value", str$(v))
rem easy, isn't it ?
sync
loop
remstart
LIST OF FUNCTIONS
+ addbutton() : add a button
+ addcheckbox() : no comment
+ addinput() : no comment
+ addlabel() : no comment
+ addloadingbar() : no comment
+ addtrackbarh() : no comment
+ addtrackbarv() : no comment
+ get_button() : gives back 1 if the button has been pressed
+ get_checkbox() : gives back 1 if it's checked
+ get_input() : gives back the string in the input box
+ get_trackbar() : gives back the value of the trackbar
+ hidewindow() : hide the window
+ maximizewindow() : I think I used the wrong word - maximise... It just place the window at the first position
+ mouseongadget() : gives 1 if the mouse if on the specified gadget
+ openwindow() : make a new window
+ set_input() : modify the string in an input box
+ set_label() : no comment
+ set_trackbar() : no comment
+ showwindow() : no comment
+ update_mouse() : update the global variables for the mouse
+ update_windows : draw the windows, the gadget, and make them work
+ windowvisible() : gives back 1 if the window can be seen (open and not behind another one)
+ winundermouse() : gives back the number of the window under the mouse
+ initgadgets() : make an INI file that will stock informations about the gadgets
remend
function UpdateMouse()
g_mmx = mousemovex()
g_mmy = mousemovey()
if mouseclick()>0
if g_clic <> mouseclick() and g_clic <> -1
g_clic = mouseclick()
else
g_clic = -1
endif
else
g_clic = 0
endif
if g_mmx <> 0 or g_mmx <> 0 and mouseclick()=0 then g_lastmove = timer()
g_idle = timer() - g_lastmove
endfunction
function update_windows()
rem si on clique sur une fenêtre, elle vient en avant
if g_clic>0 and winundermouse()>0
var = winundermouse()
maximizewindow(var)
endif
for u=0 to 31
t = winpos(32-u)
if window(t).open = 1 and windowvisible(t)=1
rem arrière-plan de la fenêtre
ink rgb(196,196,196),0
box window(t).x, window(t).y, window(t).x + window(t).width, window(t).y + window(t).height
rem barre de titre
rem ink rgb(0,0,255),0
if u=31
ink rgb(255,200,0),0
else
ink rgb(155,155,0),0
endif
box window(t).x, window(t).y-text height("|"), window(t).x+window(t).width, window(t).y
rem écriture du titre
rem ink rgb(255,255,255),0
ink 0,0
while text width(window(t).title)>window(t).width-text width(" X")
window(t).title = left$(window(t).title, len(window(t).title)-1)
endwhile
text window(t).x, window(t).y - text height("|"), " "+window(t).title
rem écriture du bouton FERMER
if window(t).fermable = 1 then text window(t).x+window(t).width-text width("|X"),window(t).y-text height("|"),"|X"
rem dessin d'une bordure
ink 0,0
line window(t).x, window(t).y-text height("|"), window(t).x+window(t).width, window(t).y-text height("|")
line window(t).x+window(t).width, window(t).y-text height("|"), window(t).x+window(t).width, window(t).y+window(t).height
line window(t).x+window(t).width, window(t).y+window(t).height, window(t).x, window(t).y+window(t).height
line window(t).x, window(t).y+window(t).height,window(t).x, window(t).y-text height("|")
rem dessin des gadgets
ink rgb(255,255,255),0
if window(t).gadgets>0
for g=1 to window(t).gadgets
gg = wingadget(t, g)
select gadget(gg).sorte
rem BOUTONS
case 1
ink rgb(128,128,128),0
box window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x + gadget(gg).x + gadget(gg).width, window(t).y + gadget(gg).y + gadget(gg).height
ink rgb(0,0,0),0
text window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, gadget(gg).chaine
line window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y
line window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y+gadget(gg).height
line window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y+gadget(gg).height,window(t).x+gadget(gg).x, window(t).y+gadget(gg).y+gadget(gg).height
line window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x, window(t).y+gadget(gg).y+gadget(gg).height
if mouseongadget(gg)=1 and g_clic=1 and gadget(gg).entier=0
gadget(gg).entier = 1
else
gadget(gg).entier = 0
endif
endcase
REM LABELS
case 2
if text width(gadget(gg).chaine)>gadget(gg).width
var$ = gadget(gg).chaine
var2 = -text height("|")
ink 0,0
repeat
var = 0
repeat
inc var
until text width(left$(var$, var+1))>gadget(gg).width or var >=len(var$)
if text width(left$(var$, var+1))>gadget(gg).width
while var < len(var$) and var > 0.6*gadget(gg).width/text width("_") and mid$(var$, var)<>" "
dec var
endwhile
endif
inc var2, text height("|")
text window(t).x+gadget(gg).x, var2+window(t).y+gadget(gg).y, left$(var$, var)
var$ = right$(var$, len(var$)-var)
until var$=""
else
ink 0,0
text window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, gadget(gg).chaine
endif
endcase
REM INPUT
case 3
ink rgb(150,150,150),0
box window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x + gadget(gg).x + gadget(gg).width, window(t).y + gadget(gg).y + gadget(gg).height
ink 0,0
line window(t).x+gadget(gg).x, window(t).y+gadget(gg).y + gadget(gg).height, window(t).x + gadget(gg).x + gadget(gg).width, window(t).y+gadget(gg).y+gadget(gg).height
var = 0
repeat
inc var
until text width(right$(gadget(gg).chaine, var+1))>gadget(gg).width or var>=len(gadget(gg).chaine)
text window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, right$(gadget(gg).chaine, var)
rem clic dessus
if mouseongadget(gg)=1 and g_clic=1 and gadget(gg).entier=0
gadget(gg).chaine=""
gadget(gg).entier=1
hide mouse
endif
rem modification
if gadget(gg).entier=1
if mouseongadget(gg)=0 or returnkey()=1
gadget(gg).entier = 0
show mouse
endif
if scancode()=14
if len(gadget(gg).chaine)>0
gadget(gg).chaine = left$(gadget(gg).chaine, len(gadget(gg).chaine)-1)
var = 0
repeat
inc var
wait 5
until var = 5 or scancode()<>14
endif
else
if entry$()<>"" and returnkey()=0 and keystate(14)=0
var$ = entry$()
endif
if returnkey()=0 and keystate(14)=0 then gadget(gg).chaine = gadget(gg).chaine + var$
if var$<>""
var$ = ""
endif
if asc(entry$())<>0 then clear entry buffer
endif
endif
endcase
REM CHECKBOX
case 4
line window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+gadget(gg).height, window(t).y+gadget(gg).y
line window(t).x+gadget(gg).x+gadget(gg).height, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+gadget(gg).height, window(t).y+gadget(gg).y+gadget(gg).height
line window(t).x+gadget(gg).x+gadget(gg).height, window(t).y+gadget(gg).y+gadget(gg).height, window(t).x+gadget(gg).x, window(t).y+gadget(gg).y+gadget(gg).height
line window(t).x+gadget(gg).x, window(t).y+gadget(gg).y+gadget(gg).height, window(t).x+gadget(gg).x, window(t).y+gadget(gg).y
text window(t).x+gadget(gg).x+gadget(gg).height+5, window(t).y+gadget(gg).y, gadget(gg).chaine
if g_clic=1 and mouseongadget(gg)=1
if gadget(gg).entier = 0
gadget(gg).entier = 1
else
gadget(gg).entier = 0
endif
endif
if gadget(gg).entier = 1
line window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+gadget(gg).height, window(t).y+gadget(gg).y+gadget(gg).height
line window(t).x+gadget(gg).x+gadget(gg).height, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x, window(t).y+gadget(gg).y+gadget(gg).height
endif
endcase
REM LOADINGBAR
case 5
ink rgb(150,150,150),0
box window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y+gadget(gg).height
ink rgb(96,96,96),0
line window(t).x+gadget(gg).x, window(t).y+gadget(gg).y+gadget(gg).height/2, window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y+gadget(gg).height/2
var1# = (gadget(gg).max-gadget(gg).min)
var2# = (gadget(gg).entier-gadget(gg).min)
var3# = (gadget(gg).width)
var# = var3# / var1# * var2#
box window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+var#, window(t).y+gadget(gg).y+gadget(gg).height
endcase
REM TRACKBAR
case 6
ink rgb(150,150,150),0
box window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y+gadget(gg).height
ink rgb(96,96,96),0
line window(t).x+gadget(gg).x, window(t).y+gadget(gg).y+gadget(gg).height/2, window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y+gadget(gg).height/2
var1# = (gadget(gg).max-gadget(gg).min)
var2# = (gadget(gg).entier-gadget(gg).min)
var3# = (gadget(gg).width-20)
var# = var3# / var1# * var2#
box window(t).x+gadget(gg).x+var#, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+var#+20, window(t).y+gadget(gg).y+gadget(gg).height
rem modif valeurs
if mouseongadget(gg)=1 and g_clic=1
if mousex()<window(t).x+gadget(gg).x+var#
dec gadget(gg).entier
if gadget(gg).entier < gadget(gg).min then gadget(gg).entier = gadget(gg).min
else
if mousex()>window(t).x+gadget(gg).x+var#+20
inc gadget(gg).entier
if gadget(gg).entier > gadget(gg).max then gadget(gg).entier = gadget(gg).max
else
if gadget(gg).flottant = 0
gadget(gg).flottant = 1
else
gadget(gg).flottant = 0
endif
endif
endif
endif
if gadget(gg).flottant=1
if mouseongadget(gg)=0 and mouseclick()=0 then gadget(gg).flottant=0
var1# = (gadget(gg).max-gadget(gg).min)
var3# = (gadget(gg).width-20)
var2# = (mousex()-(window(t).x+gadget(gg).x)-10) / var3# * var1# + gadget(gg).min
gadget(gg).entier = int(var2#)
if gadget(gg).entier < gadget(gg).min then gadget(gg).entier = gadget(gg).min
if gadget(gg).entier > gadget(gg).max then gadget(gg).entier = gadget(gg).max
endif
endcase
case 7
ink rgb(150,150,150),0
box window(t).x+gadget(gg).x, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y+gadget(gg).height
ink rgb(96,96,96),0
line window(t).x+gadget(gg).x+gadget(gg).width/2, window(t).y+gadget(gg).y, window(t).x+gadget(gg).x+gadget(gg).width/2, window(t).y+gadget(gg).y+gadget(gg).height
var1# = (gadget(gg).max-gadget(gg).min)
var2# = (gadget(gg).entier-gadget(gg).min)
var3# = (gadget(gg).height-20)
var# = var3# / var1# * var2#
box window(t).x+gadget(gg).x, window(t).y+gadget(gg).y+var#, window(t).x+gadget(gg).x+gadget(gg).width, window(t).y+gadget(gg).y+var#+20
rem modif valeurs
if mouseongadget(gg)=1 and g_clic=1
if mousey()<window(t).y+gadget(gg).y+var#
dec gadget(gg).entier
if gadget(gg).entier < gadget(gg).min then gadget(gg).entier = gadget(gg).min
else
if mousey()>window(t).y+gadget(gg).y+var#+20
inc gadget(gg).entier
if gadget(gg).entier > gadget(gg).max then gadget(gg).entier = gadget(gg).max
else
if gadget(gg).flottant = 0
gadget(gg).flottant = 1
else
gadget(gg).flottant = 0
endif
endif
endif
endif
if gadget(gg).flottant=1
if mouseongadget(gg)=0 and mouseclick()=0 then gadget(gg).flottant=0
var1# = (gadget(gg).max-gadget(gg).min)
var3# = (gadget(gg).height-20)
var2# = (mousey()-(window(t).y+gadget(gg).y)-10) / var3# * var1# + gadget(gg).min
gadget(gg).entier = int(var2#)
if gadget(gg).entier < gadget(gg).min then gadget(gg).entier = gadget(gg).min
if gadget(gg).entier > gadget(gg).max then gadget(gg).entier = gadget(gg).max
endif
endcase
endselect
next g
for g=1 to window(t).gadgets
gg = wingadget(t, g)
rem écriture du tip
if gadget(gg).tip <> "" and mouseongadget(gg)=1 and g_mmx = 0 and g_mmy = 0 and g_idle > 750
varx = mousex()+10
vary = mousey()+10
set text opaque
ink 0, rgb(196,196,196)
if varx + text width(gadget(gg).tip)>screen width() then varx = screen width()-text width(gadget(gg).tip)
if vary + text height(gadget(gg).tip)>screen height() then vary = screen height()-text height(gadget(gg).tip)
text varx, vary, gadget(gg).tip
set text transparent
endif
next g
endif
rem clic pour déplacer
if g_clic=2 and winundermouse()=t
if mousex()>window(t).x and mousex()<window(t).x+window(t).width
if mousey()>window(t).y-text height("|") and mousey()<window(t).y
if window(t).move = 0
window(t).move=1
window(t).reposx = mousex()-window(t).x
window(t).reposy = mousey()-window(t).y
if window(t).reposx < 3 then window(t).reposx = 3
if window(t).reposy < 3 then window(t).reposy = 3
else
window(t).move=0
endif
endif
endif
endif
if window(t).move=1
window(t).x = mousex()-window(t).reposx
window(t).y = mousey()-window(t).reposy
endif
rem clic pour fermer
if g_clic=1 and winundermouse()=t and window(t).fermable=1
if mousex()>window(t).x + window(t).width - text width("|X") and mousex()<window(t).x + window(t).width
if mousey()>window(t).y-text height("|") and mousey()<window(t).y
window(t).open=0
endif
endif
endif
endif
next u
endfunction
function winundermouse()
res as integer
for u=0 to 31
t = winpos(32-u)
if window(t).open = 1
if mousex()>window(t).x and mousex()<window(t).x+window(t).width
if mousey()>window(t).y-text height("|") and mousey()<window(t).y+window(t).height
res = t
endif
endif
endif
next u
endfunction res
function windowvisible(n)
res as integer
start = 33
repeat
dec start
until winpos(start)=n or start = 0
if start=1 then exitfunction 1
res = 1
for t=start-1 to 1 step -1
m = winpos(t)
if (window(n).x < window(m).x or window(n).x+window(n).width > window(m).x+window(m).width or window(n).y<window(m).y or window(n).y+window(n).height > window(m).y+window(m).height) or window(m).open=0 then res=1 else res=0
if res=0 then exitfunction res
next t
endfunction res
function openwindow(nom as string, x, y, width, height, fermable, title as string)
n = inireadint("fenêtre", nom, "c:\MSWINDOW.ini" )
if n > 0 then erreur("The window '"+nom+"' already exists !")
n = inireadint("données", "fenêtres", "c:\MSWINDOW.ini")+1
iniwritestring("données", "fenêtres", str$(n), "c:\MSWINDOW.ini")
iniwritestring("fenêtre", nom, str$(n), "c:\MSWINDOW.ini")
window(n).open = 1
window(n).x = x
window(n).y = y
window(n).width = width
window(n).height = height
window(n).title = title
window(n).reposx = 0
window(n).reposy = 0
window(n).move = 0
window(n).gadgets = 0
window(n).fermable = fermable
showwindow(nom)
rem maximizewindow(n)
endfunction
function mouseongadget(n)
if winpos(1)=gadget(n).win
t = gadget(n).win
if mousex()>window(t).x+gadget(n).x and mousex()<window(t).x + gadget(n).x + gadget(n).width
if mousey()>window(t).y+gadget(n).y and mousey()<window(t).y + gadget(n).y + gadget(n).height
exitfunction 1
endif
endif
else
exitfunction 0
endif
endfunction 0
function maximizewindow(n)
if winpos(1)<>n
for t=1 to 32
if winpos(t)=n
var2=t
exit
endif
next t
for t=var2 to 2 step -1
winpos(t)=winpos(t-1)
next t
winpos(1)=n
endif
endfunction
function hidewindow(n)
window(n).open = 0
endfunction
function hidewindow_nom(nom as string)
n = inireadint("fenêtre", nom, "c:\MSWINDOW.ini")
if n = 0 then erreur("The window '"+nom+"' doesn't exist.")
window(n).open = 0
endfunction
function showwindow(nom as string)
n = inireadint("fenêtre", nom, "c:\MSWINDOW.ini")
if n = 0 then erreur("The window '"+nom+"' doesn't exist.")
window(n).open = 1
maximizewindow(n)
g_clic = 0
endfunction
function win_maximized(nom as string)
n = inireadint("fenêtre", nom, "c:\MSWINDOW.ini")
if n = 0 then erreur("The window '"+nom+"' doesn't exist.")
if window(n).open = 0 then exitfunction 0
if winpos(1)=n then exitfunction 1
endfunction 0
function get_button(nom as string)
n = inireadint("bouton", nom, "c:\MSWINDOW.ini")
if n=0 then erreur("Le bouton '"+nom+"' n'existe pas !")
res as integer
res = gadget(n).entier
gadget(n).entier = 0
endfunction res
function get_checkbox(nom as string)
n = inireadint("checkbox", nom, "c:\MSWINDOW.ini")
if n=0 then erreur("La checkbox '"+nom+"' n'existe pas !")
res as integer
res = gadget(n).entier
endfunction res
function get_trackbar(nom as string)
n = inireadint("trackbar", nom, "c:\MSWINDOW.ini")
if n=0 then erreur("La trackbar '"+nom+"' n'existe pas !")
res as integer
res = gadget(n).entier
endfunction res
function get_input(nom as string)
n = inireadint("input", nom, "c:\MSWINDOW.ini")
if n=0 then erreur("L'input '"+nom+"' n'existe pas !")
res as string
res = gadget(n).chaine
endfunction res
function set_trackbar(nom as string, value)
n = inireadint("trackbar", nom, "c:\MSWINDOW.ini")
if n=0 then erreur("La trackbar '"+nom+"' n'existe pas !")
gadget(n).entier = value
endfunction
function set_label(nom as string, txt as string)
n = inireadint("label", nom, "c:\MSWINDOW.ini")
if n=0 then erreur("Le label '"+nom+"' n'existe pas !")
gadget(n).chaine = txt
endfunction
function set_input(nom as string, txt as string)
n = inireadint("input", nom, "c:\MSWINDOW.ini")
if n=0 then erreur("L'input '"+nom+"' n'existe pas !")
gadget(n).chaine = txt
endfunction
function AddButton(win as string, nom as string, x, y, chaine as string, tip as string)
rem recherche du numéro du gadget
n = inireadint("bouton", nom, "c:\MSWINDOW.ini")
if n > 0 then erreur("Le bouton '"+nom+"' existe déjà.")
n = inireadint("données", "gadgets", "c:\MSWINDOW.ini")+1
iniwritestring("données", "gadgets", str$(n), "c:\MSWINDOW.ini")
iniwritestring("bouton", nom, str$(n), "c:\MSWINDOW.ini")
rem recherche du numéro de la fenêtre
w = inireadint("fenêtre", win, "c:\MSWINDOW.ini")
if w = 0 then erreur("The window '"+win+"' doesn't exist.")
inc window(w).gadgets
g = window(w).gadgets
wingadget(w, g)=n
gadget(n).sorte = 1
gadget(n).win = w
gadget(n).x = x
gadget(n).y = y
gadget(n).width = text width(chaine)
gadget(n).height = text height(chaine)
gadget(n).entier = 0
gadget(n).flottant = 0.0
gadget(n).chaine = chaine
gadget(n).tip = tip
endfunction
function AddLabel(win as string, nom as string, x, y, width, chaine as string, tip as string)
rem recherche du numéro du gadget
n = inireadint("label", nom, "c:\MSWINDOW.ini")
if n > 0 then erreur("Le label '"+nom+"' existe déjà.")
n = inireadint("données", "gadgets", "c:\MSWINDOW.ini")+1
iniwritestring("données", "gadgets", str$(n), "c:\MSWINDOW.ini")
iniwritestring("label", nom, str$(n), "c:\MSWINDOW.ini")
rem recherche du numéro de la fenêtre
w = inireadint("fenêtre", win, "c:\MSWINDOW.ini")
if w = 0 then erreur("The window '"+win+"' doesn't exist.")
inc window(w).gadgets
g = window(w).gadgets
wingadget(w, g)=n
gadget(n).sorte = 2
gadget(n).win = w
gadget(n).x = x
gadget(n).y = y
gadget(n).width = width
gadget(n).height = text height("|")
gadget(n).entier = 0
gadget(n).flottant = 0.0
gadget(n).chaine = chaine
gadget(n).tip = tip
endfunction
function AddInput(win as string, nom as string, x, y, width, tip as string)
rem recherche du numéro du gadget
n = inireadint("input", nom, "c:\MSWINDOW.ini")
if n > 0 then erreur("L'input '"+nom+"' existe déjà.")
n = inireadint("données", "gadgets", "c:\MSWINDOW.ini")+1
iniwritestring("données", "gadgets", str$(n), "c:\MSWINDOW.ini")
iniwritestring("input", nom, str$(n), "c:\MSWINDOW.ini")
rem recherche du numéro de la fenêtre
w = inireadint("fenêtre", win, "c:\MSWINDOW.ini")
if w = 0 then erreur("The window '"+win+"' doesn't exist.")
inc window(w).gadgets
g = window(w).gadgets
wingadget(w, g)=n
gadget(n).sorte = 3
gadget(n).win = w
gadget(n).x = x
gadget(n).y = y
gadget(n).width = width
gadget(n).height = text height("|")
gadget(n).entier = 0
gadget(n).flottant = 0.0
gadget(n).chaine = ""
gadget(n).tip = tip
endfunction
function AddCheckbox(win as string, nom as string, x, y, valeur, chaine as string, tip as string)
rem recherche du numéro du gadget
n = inireadint("checkbox", nom, "c:\MSWINDOW.ini")
if n > 0 then erreur("La checkbox '"+nom+"' existe déjà.")
n = inireadint("données", "gadgets", "c:\MSWINDOW.ini")+1
iniwritestring("données", "gadgets", str$(n), "c:\MSWINDOW.ini")
iniwritestring("checkbox", nom, str$(n), "c:\MSWINDOW.ini")
rem recherche du numéro de la fenêtre
w = inireadint("fenêtre", win, "c:\MSWINDOW.ini")
if w = 0 then erreur("The window '"+win+"' doesn't exist.")
inc window(w).gadgets
g = window(w).gadgets
wingadget(w, g)=n
gadget(n).sorte = 4
gadget(n).win = w
gadget(n).x = x
gadget(n).y = y
gadget(n).width = text height("|") + text width(chaine)
gadget(n).height = text height("|")
gadget(n).entier = valeur
gadget(n).flottant = 0.0
gadget(n).chaine = chaine
gadget(n).tip = tip
endfunction
function AddLoadingBar(win as string, nom as string, x, y, width, minimum, maximum, valeur, tip as string)
rem recherche du numéro du gadget
n = inireadint("loadingbar", nom, "c:\MSWINDOW.ini")
if n > 0 then erreur("La loadingbar '"+nom+"' existe déjà.")
n = inireadint("données", "gadgets", "c:\MSWINDOW.ini")+1
iniwritestring("données", "gadgets", str$(n), "c:\MSWINDOW.ini")
iniwritestring("loadingbar", nom, str$(n), "c:\MSWINDOW.ini")
rem recherche du numéro de la fenêtre
w = inireadint("fenêtre", win, "c:\MSWINDOW.ini")
if w = 0 then erreur("The window '"+win+"' doesn't exist.")
inc window(w).gadgets
g = window(w).gadgets
wingadget(w, g)=n
gadget(n).sorte = 5
gadget(n).win = w
gadget(n).x = x
gadget(n).y = y
gadget(n).width = width
gadget(n).height = text height("|")
gadget(n).min = minimum
gadget(n).max = maximum
if valeur < minimum then valeur = minimum
if valeur > maximum then valeur = maximum
gadget(n).entier = valeur
gadget(n).flottant = 0.0
gadget(n).chaine = ""
gadget(n).tip = tip
endfunction
function AddTrackBarh(win as string, nom as string, x, y, width, minimum, maximum, valeur, tip as string)
rem recherche du numéro du gadget
n = inireadint("trackbar", nom, "c:\MSWINDOW.ini")
if n > 0 then erreur("La trackbar '"+nom+"' existe déjà.")
n = inireadint("données", "gadgets", "c:\MSWINDOW.ini")+1
iniwritestring("données", "gadgets", str$(n), "c:\MSWINDOW.ini")
iniwritestring("trackbar", nom, str$(n), "c:\MSWINDOW.ini")
rem recherche du numéro de la fenêtre
w = inireadint("fenêtre", win, "c:\MSWINDOW.ini")
if w = 0 then erreur("The window '"+win+"' doesn't exist.")
inc window(w).gadgets
g = window(w).gadgets
wingadget(w, g)=n
gadget(n).sorte = 6
gadget(n).win = w
gadget(n).x = x
gadget(n).y = y
gadget(n).width = width
gadget(n).height = text height("|")
gadget(n).min = minimum
gadget(n).max = maximum
if valeur < minimum then valeur = minimum
if valeur > maximum then valeur = maximum
gadget(n).entier = valeur
gadget(n).flottant = 0.0
gadget(n).chaine = ""
gadget(n).tip = tip
endfunction
function AddTrackBarv(win as string, nom as string, x, y, height, minimum, maximum, valeur, tip as string)
rem recherche du numéro du gadget
n = inireadint("trackbar", nom, "c:\MSWINDOW.ini")
if n > 0 then erreur("La trackbar '"+nom+"' existe déjà.")
n = inireadint("données", "gadgets", "c:\MSWINDOW.ini")+1
iniwritestring("données", "gadgets", str$(n), "c:\MSWINDOW.ini")
iniwritestring("trackbar", nom, str$(n), "c:\MSWINDOW.ini")
rem recherche du numéro de la fenêtre
w = inireadint("fenêtre", win, "c:\MSWINDOW.ini")
if w = 0 then erreur("The window '"+win+"' doesn't exist.")
inc window(w).gadgets
g = window(w).gadgets
wingadget(w, g)=n
gadget(n).sorte = 7
gadget(n).win = w
gadget(n).x = x
gadget(n).y = y
gadget(n).width = text height("|")
gadget(n).height = height
gadget(n).min = minimum
gadget(n).max = maximum
if valeur < minimum then valeur = minimum
if valeur > maximum then valeur = maximum
gadget(n).entier = valeur
gadget(n).flottant = 0.0
gadget(n).chaine = ""
gadget(n).tip = tip
endfunction
function Initgadgets()
if file exist("c:\MSWINDOW.ini") then delete file "c:\MSWINDOW.ini"
open to write 1, "c:\MSWINDOW.ini"
write string 1, "[fenêtre]"
write string 1, "[bouton]"
write string 1, "[checkbox]"
write string 1, "[input]"
write string 1, "[label]"
write string 1, "[loadingbar]"
write string 1, "[trackbar]"
write string 1, "[données]"
write string 1, "gadgets=0"
write string 1, "fenêtres=0"
close file 1
endfunction
function erreur(txt as string)
exit prompt txt, "Erreur"
end
endfunction
function resizewindow(nom as string)
w = inireadint("fenêtre", nom, "c:\MSWINDOW.ini")
if w = 0 then erreur("The window '"+nom+"' doesn't exist.")
sizex = 0
sizey = 0
if window(w).gadgets>0
for g=1 to window(w).gadgets
gg = wingadget(w, g)
if gadget(gg).x + gadget(gg).width > sizex then sizex = gadget(gg).x + gadget(gg).width
if gadget(gg).y + gadget(gg).height > sizey then sizey = gadget(gg).y + gadget(gg).height
next g
endif
inc sizex, 10
inc sizey, 5
window(w).width = sizex
window(w).height = sizey
endfunction
remstart
these functions - found on the DBP forum - write and read data in an INI
file... I lost the name of the one who wrote them when I formated, so if
he wants his name to be here, he just has to contact me ;)
remend
function iniwritesection(sect$, ininame$)
Load dll "kernel32.dll",1
back = Call dll(1,"WritePrivateProfileSectionA", sect$, "", ininame$)
Delete dll 1
endfunction back
function iniwriteString(sect$, key$, wrt$, ininame$)
Load dll "kernel32.dll", 1
back = Call dll(1, "WritePrivateProfileStringA", sect$, key$, wrt$, ininame$)
Delete dll 1
endfunction back
function inireadint(sect$, key$, ininame$)
Load dll "kernel32.dll", 1
back = Call dll(1,"GetPrivateProfileIntA", sect$, key$, 0, ininame$)
Delete dll 1
endfunction back
function inireadstring(sect$, key$, ininame$)
local back$
Load dll "kernel32.dll", 1
lenght = Call dll(1, "GetPrivateProfileStringA", sect$, key$, "default", back$, 254, ininame$)
Delete dll 1
endfunction back$
If you want to move a window, right click on the title bar, move it and right click again
I won't modify the look of my windows, because that would slow doen my program. Between the look and the speed, I choosed the speed.
A few months ago, I wrote a lovely button function, but it was really a "FPS Killer"
I still may modify my windows, but not before long
The sleeper must awaken !