I look at BCX-basic as a modernized qbasic. This simple code creates a Windows GUI program that plays a midi instrumental music file. To keep it simple, the file it looks for is "TheRose.mid" file. If you don't have this file, you have the option of editing the code, or simply to rename a midi file you have and stick it in the working folder.
Play a midi music file (BCX basic)
' uses the mci-library to play a midi file (.mid)
' the mci-libary winmm.lib is in PellesC\lib\win
' needs BCX basic, download the free package from:
' http://www.rjpcomputing.com/programming/bcx/devsuite.html
$LIBRARY <winmm.lib>
' this generates WinMain() and sets the Classname
GUI "MIDI3"
CONST ID_Button1 = 101
DIM Form1 AS HWND
DIM Butt1 AS CONTROL
DIM MciCommand$
' required to create the form and it's components
SUB FORMLOAD
Form1 = BCX_FORM("Play a Midi ...",30,20,140,40 )
Butt1 = BCX_BUTTON("Play",Form1,ID_Button1,10,10,30,12)
DECLARE FUNCTION MCI_Execute LIB "winmm.dll" ALIAS "mciExecute" (A$)
Show(Form1)
END SUB
' code between BEGIN EVENTS/END EVENTS takes care of the event messages
BEGIN EVENTS
SELECT CASE CBMSG
CASE WM_CREATE
EXIT FUNCTION
CASE WM_COMMAND
IF CBCTL = ID_Button1 THEN
'
' this plays TheRose.mid or change to whatever you have ...
'
MciCommand$ = "play TheRose.mid"
MCI_Execute (MciCommand$)
EXIT FUNCTION
END IF
' clean up and exit properly
CASE WM_CLOSE
mciSendString ("close all",0,0,0)
DestroyWindow (Form1)
EXIT FUNCTION
END SELECT
END EVENTS
billzilla 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.