$OPTION ICON "midi.ico"
$TYPECHECK ON
$INCLUDE "Rapidq.inc"
$INCLUDE "Object\QMidi.inc"
$RESOURCE PLAYBMP AS "play.bmp"
$RESOURCE STOPBMP AS "Stop.bmp"
$RESOURCE PAUSEBMP AS "Pause.bmp"
$RESOURCE SCREENBMP AS "midiscreen.bmp"
DECLARE SUB Play
DECLARE SUB Stop
DECLARE SUB Pause
DECLARE SUB OPEN
DECLARE SUB CLOSE
DECLARE SUB Quitter
DECLARE SUB TrackBarChange
DECLARE SUB PostimerOnTimer(Position AS LONG)
DIM OpenDialog AS QOPENDIALOG
OpenDialog.Filter="Fichier midi|*.mid"
OpenDialog.CAPTION= "Selectionner une séquence"
DIM midi AS QMidi
midi.OnChange=PostimerOnTimer
midi.TIMER.interval=200
CREATE Form AS QFORM
CAPTION="Midi"
Width=288
Height=140
Center
BorderStyle=bsSingle
DelBorderIcons 2
OnClose=Quitter
CREATE MENU AS QMAINMENU
CREATE FileMenu AS QMENUITEM
CAPTION="&Fichier"
CREATE Item1 AS QMENUITEM
CAPTION="&Ouvrir"
OnClick=OPEN
END CREATE
CREATE Item2 AS QMENUITEM
CAPTION="&Fermer"
OnClick=CLOSE
END CREATE
CREATE Item3 AS QMENUITEM
CAPTION="-"
END CREATE
CREATE Item4 AS QMENUITEM
CAPTION="&Quitter"
OnClick=Quitter
END CREATE
END CREATE
END CREATE
CREATE Panel1 AS QPANEL
Left=0
Top=0
Width=281
Height=100
BevelOuter=bvNone
CREATE image AS QIMAGE
width=301
height=160
BmpHandle=SCREENBMP
END CREATE
CREATE BtPlay AS QCOOLBTN
BMPHandle=PLAYBMP
Left=8
Top=26
Width=28
Height=28
Flat=true
Hint="Play"
ShowHint=true
GroupIndex=1
Enabled=false
OnClick=Play
END CREATE
CREATE BtStop AS QCOOLBTN
BMPHandle=STOPBMP
Left=46
Top=26
Width=28
Height=28
Down=true
Flat=true
Enabled=false
Hint="Stop"
ShowHint=true
GroupIndex=1
OnClick=Stop
END CREATE
CREATE BtPause AS QCOOLBTN
BMPHandle=PAUSEBMP
Left=84
Top=26
Width=28
Height=28
Flat=true
GroupIndex=1
Enabled=false
Hint="Pause"
ShowHint=true
OnClick=Pause
END CREATE
CREATE TrackBar1 AS QTRACKBAR
TickMarks=tmBoth
TickStyle=tsNone
Left=2
Top=66
LineSize=0
Width=272
Height=21
Hint="Position"
ShowHint=true
Enabled=false
OnChange=TrackBarChange
END CREATE
END CREATE
END CREATE
Form.SHOWMODAL
SUB OPEN
IF OpenDialog.EXECUTE THEN
midi.CLOSE
IF midi.OPEN(OpenDialog.FileName) THEN
TrackBar1.Max=midi.lenght
TrackBar1.Position=0
btPlay.Enabled=true
btStop.Enabled=true
btPause.Enabled=true
trackbar1.Enabled=true
ELSE
SHOWMESSAGE midi.ERROR
END IF
END IF
END SUB
SUB CLOSE
midi.CLOSE
btPlay.Enabled=false
btStop.Enabled=false
btPause.Enabled=false
trackbar1.Enabled=false
END SUB
SUB Play
IF midi.FileOpen=false THEN BtStop.Down=True
midi.play
END SUB
SUB Stop
midi.stop
TrackBar1.Position=0
END SUB
SUB Pause
IF midi.FileOpen=false THEN BtStop.Down=True
midi.pause
END SUB
SUB TrackBarChange
midi.currentFrame=TrackBar1.Position
END SUB
SUB PostimerOnTimer(Position AS LONG)
TrackBar1.Position=Position
IF midi.state=MD_STOP THEN
midi.stop
TrackBar1.Position=0
BtStop.Down=True
END IF
END SUB
SUB Quitter
midi.CLOSE
form.CLOSE
END SUB
|