Exercise exported desktop services
Check the complete dialog, clipboard, media and report sample before and after Windows or Linux export.
This sample exercises system integration, so Check on Mac is only the first gate. Inspect every resource and handler below. On Windows, test native dialogs, codec-dependent audio/video and report printing. On Linux L1, audio/video and four CommonDialog operations are unavailable: their refusal is an expected boundary, not successful playback. Reports.Print opens a temporary PDF viewer instead of a native print dialog. Keep the app open while inspecting that temporary document. Do not run clipboard-changing actions until you have preserved anything important in the clipboard.
Step 1Prepare a safe practice project#
Extract the archive into a new writable folder, separate from your own application. Open WindowsServicesTest.mcbproj in McBasic™. Keep every declared source, layout, resource and migration file together.
To reconstruct it yourself, create a DesktopApp project and add the files declared below. In the complete project, follow these steps as a guided rebuild: replace each named source file once and Check after all its procedures are present.
Exact project configuration
{
"schemaVersion": 1,
"projectId": "ab3e7724-fb71-4b4e-a5b1-5a9efe266bf3",
"name": "WindowsServicesTest",
"kind": "DesktopApp",
"ai": {
"storeChatsInProject": false
},
"language": {
"dialect": "McBasic1",
"requireExplicit": true,
"compare": "Binary",
"defaultArrayBase": 0
},
"application": {
"bundleIdentifier": "com.mcbasic.samples.windowsservicestest",
"version": "0.1.0",
"buildNumber": "1",
"appearance": "macOS",
"startupFormId": "form-main",
"shutdownMode": "OnStartupFormClosed"
},
"forms": [
{
"id": "form-main",
"typeName": "frmMain",
"layout": "Forms/frmMain.form.json",
"code": "Forms/frmMain.bas"
},
{
"id": "form-second",
"typeName": "frmSecond",
"layout": "Forms/frmSecond.form.json",
"code": "Forms/frmSecond.bas"
},
{
"id": "form-nobox",
"typeName": "frmNoBox",
"layout": "Forms/frmNoBox.form.json",
"code": "Forms/frmNoBox.bas"
}
],
"modules": [],
"classes": [],
"tests": [],
"references": [],
"resources": [
{
"name": "Tone",
"path": "Resources/tone.wav"
},
{
"name": "HelloReport",
"path": "Resources/Reports/Hello.report.json"
},
{
"name": "DemoVideo",
"path": "Resources/demo.mp4"
}
],
"targets": [
"osx-arm64"
],
"capabilities": []
}Step 2Build the Form and set its properties#
frmMain
Select the Form first and set its properties. Add containers before their children. These are initial Designer values, not statements to paste into a procedure.
| Form property | Value |
|---|---|
Caption | "Windows Services Test" |
Width | 1110 |
Height | 560 |
MinWidth | 600 |
MinHeight | 480 |
| Type | Name | Parent |
|---|---|---|
| Label | lblStatus | Form |
| CommandButton | cmdMsgOk | Form |
| CommandButton | cmdMsgYnc | Form |
| CommandButton | cmdMsgCrit | Form |
| CommandButton | cmdMsgExcl | Form |
| CommandButton | cmdMsgInfo | Form |
| CommandButton | cmdInput | Form |
| CommandButton | cmdOpen | Form |
| CommandButton | cmdSave | Form |
| CommandButton | cmdFolder | Form |
| CommandButton | cmdColor | Form |
| CommandButton | cmdFont | Form |
| CommandButton | cmdPrinter | Form |
| CommandButton | cmdPageSetup | Form |
| CommandButton | cmdClip | Form |
| CommandButton | cmdUrl | Form |
| CommandButton | cmdPlay | Form |
| CommandButton | cmdPause | Form |
| CommandButton | cmdStop | Form |
| CommandButton | cmdSeek | Form |
| CommandButton | cmdVol | Form |
| CommandButton | cmdSecond | Form |
| CommandButton | cmdError | Form |
| CommandButton | cmdNoBox | Form |
| CommandButton | cmdReport | Form |
| Panel | pnlColor | Form |
| Label | lblFontSample | Form |
| AudioPlayer | audTone | Form |
| Label | lblNotes | Form |
| VideoPlayer | vidDemo | Form |
| CommandButton | cmdVidPlay | Form |
| CommandButton | cmdVidPause | Form |
| CommandButton | cmdVidStop | Form |
| CommandButton | cmdVidPos | Form |
| CommandButton | cmdVidVol | Form |
| CommandButton | cmdVidLoop | Form |
| CommandButton | cmdVidStretch | Form |
| Label | lblVideoNotes | Form |
| CommonDialog | dlgCommon | Component tray |
| MenuItem | mnuFile | Component tray |
| MenuItem | mnuFileOpen | Component tray |
| MenuItem | mnuFileSave | Component tray |
| MenuItem | mnuFileSep1 | Component tray |
| MenuItem | mnuFileExit | Component tray |
| MenuItem | mnuEdit | Component tray |
| MenuItem | mnuEditCopy | Component tray |
| MenuItem | mnuEditPaste | Component tray |
lblStatus · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 14 |
Width | 680 |
Height | 44 |
Caption | "Choose a service. The result appears here." |
ForeColor | "#263238" |
| Anchor edges | Left, Top, Right |
cmdMsgOk · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 70 |
Width | 164 |
Height | 36 |
Caption | "MsgBox OK only" |
TabIndex | 0 |
| Anchor edges | Left, Top |
cmdMsgYnc · exact Inspector values
| Property | Value |
|---|---|
Left | 192 |
Top | 70 |
Width | 164 |
Height | 36 |
Caption | "MsgBox Yes/No/Cancel" |
TabIndex | 1 |
| Anchor edges | Left, Top |
cmdMsgCrit · exact Inspector values
| Property | Value |
|---|---|
Left | 364 |
Top | 70 |
Width | 164 |
Height | 36 |
Caption | "MsgBox Critical" |
TabIndex | 2 |
| Anchor edges | Left, Top |
cmdMsgExcl · exact Inspector values
| Property | Value |
|---|---|
Left | 536 |
Top | 70 |
Width | 164 |
Height | 36 |
Caption | "MsgBox Exclamation" |
TabIndex | 3 |
| Anchor edges | Left, Top |
cmdMsgInfo · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 114 |
Width | 164 |
Height | 36 |
Caption | "MsgBox Information" |
TabIndex | 4 |
| Anchor edges | Left, Top |
cmdInput · exact Inspector values
| Property | Value |
|---|---|
Left | 192 |
Top | 114 |
Width | 164 |
Height | 36 |
Caption | "InputBox" |
TabIndex | 5 |
| Anchor edges | Left, Top |
cmdOpen · exact Inspector values
| Property | Value |
|---|---|
Left | 364 |
Top | 114 |
Width | 164 |
Height | 36 |
Caption | "ShowOpen" |
TabIndex | 6 |
| Anchor edges | Left, Top |
cmdSave · exact Inspector values
| Property | Value |
|---|---|
Left | 536 |
Top | 114 |
Width | 164 |
Height | 36 |
Caption | "ShowSave" |
TabIndex | 7 |
| Anchor edges | Left, Top |
cmdFolder · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 158 |
Width | 164 |
Height | 36 |
Caption | "ShowFolder" |
TabIndex | 8 |
| Anchor edges | Left, Top |
cmdColor · exact Inspector values
| Property | Value |
|---|---|
Left | 192 |
Top | 158 |
Width | 164 |
Height | 36 |
Caption | "ShowColor" |
TabIndex | 9 |
| Anchor edges | Left, Top |
cmdFont · exact Inspector values
| Property | Value |
|---|---|
Left | 364 |
Top | 158 |
Width | 164 |
Height | 36 |
Caption | "ShowFont" |
TabIndex | 10 |
| Anchor edges | Left, Top |
cmdPrinter · exact Inspector values
| Property | Value |
|---|---|
Left | 536 |
Top | 158 |
Width | 164 |
Height | 36 |
Caption | "ShowPrinter" |
TabIndex | 11 |
| Anchor edges | Left, Top |
cmdPageSetup · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 202 |
Width | 164 |
Height | 36 |
Caption | "ShowPageSetup" |
TabIndex | 12 |
| Anchor edges | Left, Top |
cmdClip · exact Inspector values
| Property | Value |
|---|---|
Left | 192 |
Top | 202 |
Width | 164 |
Height | 36 |
Caption | "Clipboard round trip" |
TabIndex | 13 |
| Anchor edges | Left, Top |
cmdUrl · exact Inspector values
| Property | Value |
|---|---|
Left | 364 |
Top | 202 |
Width | 164 |
Height | 36 |
Caption | "Open mcbasic.com" |
TabIndex | 14 |
| Anchor edges | Left, Top |
cmdPlay · exact Inspector values
| Property | Value |
|---|---|
Left | 536 |
Top | 202 |
Width | 164 |
Height | 36 |
Caption | "Play" |
TabIndex | 15 |
| Anchor edges | Left, Top |
cmdPause · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 246 |
Width | 164 |
Height | 36 |
Caption | "Pause" |
TabIndex | 16 |
| Anchor edges | Left, Top |
cmdStop · exact Inspector values
| Property | Value |
|---|---|
Left | 192 |
Top | 246 |
Width | 164 |
Height | 36 |
Caption | "Stop" |
TabIndex | 17 |
| Anchor edges | Left, Top |
cmdSeek · exact Inspector values
| Property | Value |
|---|---|
Left | 364 |
Top | 246 |
Width | 164 |
Height | 36 |
Caption | "Position 0.5 + Play" |
TabIndex | 18 |
| Anchor edges | Left, Top |
cmdVol · exact Inspector values
| Property | Value |
|---|---|
Left | 536 |
Top | 246 |
Width | 164 |
Height | 36 |
Caption | "Volume 0.5" |
TabIndex | 19 |
| Anchor edges | Left, Top |
cmdSecond · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 290 |
Width | 164 |
Height | 36 |
Caption | "Open second form" |
TabIndex | 20 |
| Anchor edges | Left, Top |
cmdError · exact Inspector values
| Property | Value |
|---|---|
Left | 192 |
Top | 290 |
Width | 164 |
Height | 36 |
Caption | "Raise error 5" |
TabIndex | 21 |
| Anchor edges | Left, Top |
cmdNoBox · exact Inspector values
| Property | Value |
|---|---|
Left | 364 |
Top | 290 |
Width | 164 |
Height | 36 |
Caption | "Open form without box" |
TabIndex | 22 |
| Anchor edges | Left, Top |
cmdReport · exact Inspector values
| Property | Value |
|---|---|
Left | 536 |
Top | 290 |
Width | 164 |
Height | 36 |
Caption | "Print report" |
TabIndex | 23 |
| Anchor edges | Left, Top |
pnlColor · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 344 |
Width | 120 |
Height | 44 |
BackColor | "#EEEEEE" |
| Anchor edges | Left, Top |
lblFontSample · exact Inspector values
| Property | Value |
|---|---|
Left | 152 |
Top | 344 |
Width | 548 |
Height | 44 |
Caption | "Sample text for ShowFont" |
| Anchor edges | Left, Top |
audTone · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 400 |
Width | 680 |
Height | 60 |
Source | "Tone" |
AutoPlay | False |
Loop | False |
Volume | 0.8 |
| Anchor edges | Left, Top, Right |
lblNotes · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 468 |
Width | 680 |
Height | 76 |
Caption | "Also check: Alt+F opens File and Alt+E opens Edit (underlined letters); Help > About WindowsServicesTest; the second form has About in its system menu (Alt+Space) and a disabled Minimize button; the form without box has a Help > About menu bar. MDI keys: publish the MdiForms sample." |
ForeColor | "#455A64" |
| Anchor edges | Left, Top, Right |
vidDemo · exact Inspector values
| Property | Value |
|---|---|
Left | 720 |
Top | 70 |
Width | 370 |
Height | 250 |
Source | "DemoVideo" |
AutoPlay | False |
Loop | False |
Volume | 0.8 |
ControlsVisible | True |
Stretch | "Uniform" |
| Anchor edges | Left, Top |
cmdVidPlay · exact Inspector values
| Property | Value |
|---|---|
Left | 720 |
Top | 334 |
Width | 180 |
Height | 36 |
Caption | "Video Play" |
TabIndex | 24 |
| Anchor edges | Left, Top |
cmdVidPause · exact Inspector values
| Property | Value |
|---|---|
Left | 910 |
Top | 334 |
Width | 180 |
Height | 36 |
Caption | "Video Pause" |
TabIndex | 25 |
| Anchor edges | Left, Top |
cmdVidStop · exact Inspector values
| Property | Value |
|---|---|
Left | 720 |
Top | 378 |
Width | 180 |
Height | 36 |
Caption | "Video Stop" |
TabIndex | 26 |
| Anchor edges | Left, Top |
cmdVidPos · exact Inspector values
| Property | Value |
|---|---|
Left | 910 |
Top | 378 |
Width | 180 |
Height | 36 |
Caption | "Video Position 0.5" |
TabIndex | 27 |
| Anchor edges | Left, Top |
cmdVidVol · exact Inspector values
| Property | Value |
|---|---|
Left | 720 |
Top | 422 |
Width | 180 |
Height | 36 |
Caption | "Video Volume 0.3" |
TabIndex | 28 |
| Anchor edges | Left, Top |
cmdVidLoop · exact Inspector values
| Property | Value |
|---|---|
Left | 910 |
Top | 422 |
Width | 180 |
Height | 36 |
Caption | "Video Loop on/off" |
TabIndex | 29 |
| Anchor edges | Left, Top |
cmdVidStretch · exact Inspector values
| Property | Value |
|---|---|
Left | 720 |
Top | 466 |
Width | 180 |
Height | 36 |
Caption | "Video Stretch next" |
TabIndex | 30 |
| Anchor edges | Left, Top |
lblVideoNotes · exact Inspector values
| Property | Value |
|---|---|
Left | 910 |
Top | 466 |
Width | 180 |
Height | 80 |
Caption | "Video check: the clip shows in the black area with the Play bar below it; Stretch cycles Uniform, Fill, UniformToFill; Loop repeats it. The clip has no sound track." |
ForeColor | "#455A64" |
| Anchor edges | Left, Top |
dlgCommon · exact Inspector values
| Property | Value |
|---|---|
Title | "Windows Services Test" |
Filter | "Text files|*.txt;*.md" |
FileName | "notes.txt" |
Color | "#1565C0" |
Font | "System|13|Regular|Normal" |
PrinterName | "" |
PaperName | "" |
PageOrientation | "Portrait" |
PageWidth | 612 |
PageHeight | 792 |
mnuFile · exact Inspector values
| Property | Value |
|---|---|
Caption | "&File" |
Parent | "" |
Order | 0 |
mnuFileOpen · exact Inspector values
| Property | Value |
|---|---|
Caption | "&Open…" |
Parent | "mnu-file" |
Order | 0 |
Shortcut | "Ctrl+O" |
mnuFileSave · exact Inspector values
| Property | Value |
|---|---|
Caption | "&Save…" |
Parent | "mnu-file" |
Order | 1 |
Shortcut | "Ctrl+S" |
mnuFileSep1 · exact Inspector values
| Property | Value |
|---|---|
Caption | "-" |
Parent | "mnu-file" |
Order | 2 |
mnuFileExit · exact Inspector values
| Property | Value |
|---|---|
Caption | "E&xit" |
Parent | "mnu-file" |
Order | 3 |
mnuEdit · exact Inspector values
| Property | Value |
|---|---|
Caption | "&Edit" |
Parent | "" |
Order | 1 |
mnuEditCopy · exact Inspector values
| Property | Value |
|---|---|
Caption | "&Copy" |
Parent | "mnu-edit" |
Order | 0 |
Shortcut | "Ctrl+C" |
mnuEditPaste · exact Inspector values
| Property | Value |
|---|---|
Caption | "&Paste" |
Parent | "mnu-edit" |
Order | 1 |
Shortcut | "Ctrl+V" |
frmSecond
Select the Form first and set its properties. Add containers before their children. These are initial Designer values, not statements to paste into a procedure.
| Form property | Value |
|---|---|
Caption | "Second form" |
Width | 360 |
Height | 200 |
MinButton | False |
| Type | Name | Parent |
|---|---|---|
| Label | lblInfo | Form |
| CommandButton | cmdClose | Form |
lblInfo · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 20 |
Width | 320 |
Height | 80 |
Caption | "Opened modelessly. Minimize is disabled (MinButton = False). Alt+Space, or the icon at the left of the title bar, opens the system menu with About WindowsServicesTest." |
cmdClose · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 120 |
Width | 120 |
Height | 36 |
Caption | "Close" |
frmNoBox
Select the Form first and set its properties. Add containers before their children. These are initial Designer values, not statements to paste into a procedure.
| Form property | Value |
|---|---|
Caption | "Form without control box" |
Width | 380 |
Height | 200 |
ControlBox | False |
| Type | Name | Parent |
|---|---|---|
| Label | lblInfo | Form |
| CommandButton | cmdClose | Form |
lblInfo · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 20 |
Width | 340 |
Height | 80 |
Caption | "ControlBox = False: no system menu and no Close button. On Windows the form shows a menu bar with only Help > About WindowsServicesTest, so the About stays reachable." |
cmdClose · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 120 |
Width | 120 |
Height | 36 |
Caption | "Close" |
Step 3Connect the events explicitly#
frmMain
| Object | Event | Procedure | Parameters |
|---|---|---|---|
cmdMsgOk | Click | cmdMsgOk_Click | Click() |
cmdMsgYnc | Click | cmdMsgYnc_Click | Click() |
cmdMsgCrit | Click | cmdMsgCrit_Click | Click() |
cmdMsgExcl | Click | cmdMsgExcl_Click | Click() |
cmdMsgInfo | Click | cmdMsgInfo_Click | Click() |
cmdInput | Click | cmdInput_Click | Click() |
cmdOpen | Click | cmdOpen_Click | Click() |
cmdSave | Click | cmdSave_Click | Click() |
cmdFolder | Click | cmdFolder_Click | Click() |
cmdColor | Click | cmdColor_Click | Click() |
cmdFont | Click | cmdFont_Click | Click() |
cmdPrinter | Click | cmdPrinter_Click | Click() |
cmdPageSetup | Click | cmdPageSetup_Click | Click() |
cmdClip | Click | cmdClip_Click | Click() |
cmdUrl | Click | cmdUrl_Click | Click() |
cmdPlay | Click | cmdPlay_Click | Click() |
cmdPause | Click | cmdPause_Click | Click() |
cmdStop | Click | cmdStop_Click | Click() |
cmdSeek | Click | cmdSeek_Click | Click() |
cmdVol | Click | cmdVol_Click | Click() |
cmdSecond | Click | cmdSecond_Click | Click() |
cmdError | Click | cmdError_Click | Click() |
cmdNoBox | Click | cmdNoBox_Click | Click() |
cmdReport | Click | cmdReport_Click | Click() |
audTone | Failed | audTone_Failed | Failed() |
audTone | Completed | audTone_Completed | Completed() |
vidDemo | Loaded | vidDemo_Loaded | Loaded() |
vidDemo | Completed | vidDemo_Completed | Completed() |
vidDemo | Failed | vidDemo_Failed | Failed() |
vidDemo | StateChanged | vidDemo_StateChanged | StateChanged() |
cmdVidPlay | Click | cmdVidPlay_Click | Click() |
cmdVidPause | Click | cmdVidPause_Click | Click() |
cmdVidStop | Click | cmdVidStop_Click | Click() |
cmdVidPos | Click | cmdVidPos_Click | Click() |
cmdVidVol | Click | cmdVidVol_Click | Click() |
cmdVidLoop | Click | cmdVidLoop_Click | Click() |
cmdVidStretch | Click | cmdVidStretch_Click | Click() |
mnuFileOpen | Click | mnuFileOpen_Click | Click() |
mnuFileSave | Click | mnuFileSave_Click | Click() |
mnuFileExit | Click | mnuFileExit_Click | Click() |
mnuEditCopy | Click | mnuEditCopy_Click | Click() |
mnuEditPaste | Click | mnuEditPaste_Click | Click() |
| Form | Load | Form_Load | () |
frmSecond
| Object | Event | Procedure | Parameters |
|---|---|---|---|
cmdClose | Click | cmdClose_Click | Click() |
frmNoBox
| Object | Event | Procedure | Parameters |
|---|---|---|---|
cmdClose | Click | cmdClose_Click | Click() |
Step 4Enter the complete behavior#
Open the named source file. Enter declarations first, then every procedure. Expand a procedure for its full body, or copy the complete file. Helpers are required: do not stop after entering the first Click handler.
Forms/frmMain.bas
Enter these declarations at file scope, before the procedures.
Option Explicit
' frmMain: tries every platform service on one form (dialogs, clipboard, URL, audio, video, menus, a second form, a run-time error).
' Each action writes its result to lblStatus, so no MsgBox is needed to read it (the MsgBox buttons show the value they return).
' Shows a short ready message when the form loads.Private Sub Form_Load()
Initialize state before enabling dependent actions. Keep the shared declarations and startup dependencies with this procedure.
Private Sub Form_Load()
lblStatus.Caption = "Ready. Audio state: " + audTone.State
End SubPrivate Sub ShowMsgResult(ByVal Style As String, ByVal Result As Long)
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub ShowMsgResult(ByVal Style As String, ByVal Result As Long)
lblStatus.Caption = Style + " returned " + CStr(Result)
End SubPrivate Sub ShowDialogResult(ByVal Value As String)
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub ShowDialogResult(ByVal Value As String)
If dlgCommon.Cancelled Then
lblStatus.Caption = dlgCommon.LastAction + " cancelled"
Else
lblStatus.Caption = dlgCommon.LastAction + ": " + Value
End If
End SubPrivate Sub cmdMsgOk_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdMsgOk_Click()
ShowMsgResult "OK only", MsgBox("This is a message with an OK button.", vbOKOnly, "Windows Services Test")
End SubPrivate Sub cmdMsgYnc_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdMsgYnc_Click()
ShowMsgResult "Yes/No/Cancel", MsgBox("Do you want to continue?", vbYesNoCancel + vbQuestion + vbDefaultButton2, "Question")
End SubPrivate Sub cmdMsgCrit_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdMsgCrit_Click()
ShowMsgResult "Critical", MsgBox("Something went wrong.", vbOKOnly + vbCritical, "Critical")
End SubPrivate Sub cmdMsgExcl_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdMsgExcl_Click()
ShowMsgResult "Exclamation", MsgBox("Take care.", vbOKOnly + vbExclamation, "Exclamation")
End SubPrivate Sub cmdMsgInfo_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdMsgInfo_Click()
ShowMsgResult "Information", MsgBox("For your information.", vbOKOnly + vbInformation, "Information")
End SubPrivate Sub cmdInput_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdInput_Click()
Dim Answer As String
Answer = InputBox("What is your name?", "InputBox", "Ada")
lblStatus.Caption = "InputBox returned [" + Answer + "]"
End SubPrivate Sub cmdOpen_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdOpen_Click()
dlgCommon.ShowOpen
ShowDialogResult dlgCommon.FileName
End SubPrivate Sub cmdSave_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdSave_Click()
dlgCommon.ShowSave
ShowDialogResult dlgCommon.FileName
End SubPrivate Sub cmdFolder_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdFolder_Click()
dlgCommon.ShowFolder
ShowDialogResult dlgCommon.FileName
End SubPrivate Sub cmdColor_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdColor_Click()
dlgCommon.ShowColor
If Not dlgCommon.Cancelled Then pnlColor.BackColor = dlgCommon.Color
ShowDialogResult dlgCommon.Color
End SubPrivate Sub cmdFont_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdFont_Click()
dlgCommon.ShowFont
If Not dlgCommon.Cancelled Then lblFontSample.Font = dlgCommon.Font
ShowDialogResult dlgCommon.Font
End SubPrivate Sub cmdPrinter_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdPrinter_Click()
dlgCommon.ShowPrinter
ShowDialogResult dlgCommon.PrinterName + " / " + dlgCommon.PaperName
End SubPrivate Sub cmdPageSetup_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdPageSetup_Click()
dlgCommon.ShowPageSetup
ShowDialogResult dlgCommon.PageOrientation + " " + CStr(dlgCommon.PageWidth) + " x " + CStr(dlgCommon.PageHeight)
End SubPrivate Sub cmdClip_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdClip_Click()
Dim Back As String
Clipboard.SetText "McBasic clipboard test"
Back = Clipboard.GetText()
lblStatus.Caption = "Clipboard has text: " + CStr(Clipboard.HasText()) + ", read back [" + Back + "]"
Clipboard.Clear
lblStatus.Caption = lblStatus.Caption + "; after Clear has text: " + CStr(Clipboard.HasText())
End SubPrivate Sub cmdUrl_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdUrl_Click()
Platform.OpenUrl "https://www.mcbasic.com"
lblStatus.Caption = "Asked the system to open https://www.mcbasic.com"
End SubPrivate Sub cmdPlay_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdPlay_Click()
audTone.Play
lblStatus.Caption = "Audio state: " + audTone.State
End SubPrivate Sub cmdPause_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdPause_Click()
audTone.Pause
lblStatus.Caption = "Audio state: " + audTone.State
End SubPrivate Sub cmdStop_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdStop_Click()
audTone.Stop
lblStatus.Caption = "Audio state: " + audTone.State
End SubPrivate Sub cmdSeek_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdSeek_Click()
audTone.Position = 0.5
audTone.Play
lblStatus.Caption = "Position set to 0.5 before Play; state: " + audTone.State
End SubPrivate Sub cmdVol_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdVol_Click()
audTone.Volume = 0.5
lblStatus.Caption = "Volume is " + CStr(audTone.Volume)
End SubPrivate Sub audTone_Failed()
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub audTone_Failed()
lblStatus.Caption = "Audio failed: " + audTone.Error
End SubPrivate Sub audTone_Completed()
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub audTone_Completed()
lblStatus.Caption = "Audio completed"
End SubPrivate Sub ShowVideo(ByVal Action As String)
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub ShowVideo(ByVal Action As String)
lblStatus.Caption = Action + "; video state: " + vidDemo.State + ", position " + CStr(vidDemo.Position) + " of " + CStr(vidDemo.Duration) + " s"
End SubPrivate Sub cmdVidPlay_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdVidPlay_Click()
vidDemo.Play
ShowVideo "Video Play"
End SubPrivate Sub cmdVidPause_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdVidPause_Click()
vidDemo.Pause
ShowVideo "Video Pause"
End SubPrivate Sub cmdVidStop_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdVidStop_Click()
vidDemo.Stop
ShowVideo "Video Stop"
End SubPrivate Sub cmdVidPos_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdVidPos_Click()
vidDemo.Position = 0.5
vidDemo.Play
ShowVideo "Video Position 0.5 + Play"
End SubPrivate Sub cmdVidVol_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdVidVol_Click()
vidDemo.Volume = 0.3
lblStatus.Caption = "Video volume is " + CStr(vidDemo.Volume)
End SubPrivate Sub cmdVidLoop_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdVidLoop_Click()
vidDemo.Loop = Not vidDemo.Loop
lblStatus.Caption = "Video Loop is " + CStr(vidDemo.Loop)
End SubPrivate Sub cmdVidStretch_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdVidStretch_Click()
If vidDemo.Stretch = "Uniform" Then
vidDemo.Stretch = "Fill"
ElseIf vidDemo.Stretch = "Fill" Then
vidDemo.Stretch = "UniformToFill"
Else
vidDemo.Stretch = "Uniform"
End If
lblStatus.Caption = "Video Stretch is " + vidDemo.Stretch
End SubPrivate Sub vidDemo_Loaded()
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub vidDemo_Loaded()
lblStatus.Caption = "Video loaded (" + CStr(vidDemo.Duration) + " s)"
End SubPrivate Sub vidDemo_Completed()
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub vidDemo_Completed()
lblStatus.Caption = "Video completed"
End SubPrivate Sub vidDemo_Failed()
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub vidDemo_Failed()
lblStatus.Caption = "Video failed: " + vidDemo.Error
End SubPrivate Sub vidDemo_StateChanged()
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub vidDemo_StateChanged()
lblStatus.Caption = "Video state: " + vidDemo.State
End SubPrivate Sub cmdSecond_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdSecond_Click()
Dim f As frmSecond
Set f = New frmSecond
f.Show
lblStatus.Caption = "Second form opened (modeless)"
End SubPrivate Sub cmdNoBox_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdNoBox_Click()
Dim f As frmNoBox
Set f = New frmNoBox
f.Show
lblStatus.Caption = "Form without control box opened"
End SubPrivate Sub cmdReport_Click()
Follow the success, failure and cleanup paths together. Do not omit a guard or Finally block when entering this procedure.
Private Sub cmdReport_Click()
Try
If Reports.Print(App.ResourcePath & "/Resources/Reports/Hello.report.json") Then
lblStatus.Caption = "Report sent to the printer"
Else
lblStatus.Caption = "Report printing cancelled"
End If
Catch failure As McException
lblStatus.Caption = "Report failed " & CStr(failure.Number) & ": " & failure.Message
End Try
End SubPrivate Sub cmdError_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdError_Click()
Err.Raise 5, "WindowsServicesTest", "This error was raised on purpose."
End SubPrivate Sub mnuFileOpen_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub mnuFileOpen_Click()
lblStatus.Caption = "Menu: File > Open"
End SubPrivate Sub mnuFileSave_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub mnuFileSave_Click()
lblStatus.Caption = "Menu: File > Save"
End SubPrivate Sub mnuFileExit_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub mnuFileExit_Click()
lblStatus.Caption = "Menu: File > Exit"
Unload Me
End SubPrivate Sub mnuEditCopy_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub mnuEditCopy_Click()
lblStatus.Caption = "Menu: Edit > Copy"
End SubPrivate Sub mnuEditPaste_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub mnuEditPaste_Click()
lblStatus.Caption = "Menu: Edit > Paste"
End SubCopy the complete Forms/frmMain.bas file
Replace the file once; do not append duplicate procedures.
Option Explicit
' frmMain: tries every platform service on one form (dialogs, clipboard, URL, audio, video, menus, a second form, a run-time error).
' Each action writes its result to lblStatus, so no MsgBox is needed to read it (the MsgBox buttons show the value they return).
' Shows a short ready message when the form loads.
Private Sub Form_Load()
lblStatus.Caption = "Ready. Audio state: " + audTone.State
End Sub
' Reports the value a MsgBox returned (1 OK, 2 Cancel, 6 Yes, 7 No).
Private Sub ShowMsgResult(ByVal Style As String, ByVal Result As Long)
lblStatus.Caption = Style + " returned " + CStr(Result)
End Sub
' Reports a CommonDialog result, or that the person cancelled.
Private Sub ShowDialogResult(ByVal Value As String)
If dlgCommon.Cancelled Then
lblStatus.Caption = dlgCommon.LastAction + " cancelled"
Else
lblStatus.Caption = dlgCommon.LastAction + ": " + Value
End If
End Sub
' MsgBox with the OK button only.
Private Sub cmdMsgOk_Click()
ShowMsgResult "OK only", MsgBox("This is a message with an OK button.", vbOKOnly, "Windows Services Test")
End Sub
' MsgBox with Yes, No and Cancel, a question icon and the second button (No) as default.
Private Sub cmdMsgYnc_Click()
ShowMsgResult "Yes/No/Cancel", MsgBox("Do you want to continue?", vbYesNoCancel + vbQuestion + vbDefaultButton2, "Question")
End Sub
' MsgBox with the critical (error) icon.
Private Sub cmdMsgCrit_Click()
ShowMsgResult "Critical", MsgBox("Something went wrong.", vbOKOnly + vbCritical, "Critical")
End Sub
' MsgBox with the exclamation (warning) icon.
Private Sub cmdMsgExcl_Click()
ShowMsgResult "Exclamation", MsgBox("Take care.", vbOKOnly + vbExclamation, "Exclamation")
End Sub
' MsgBox with the information icon.
Private Sub cmdMsgInfo_Click()
ShowMsgResult "Information", MsgBox("For your information.", vbOKOnly + vbInformation, "Information")
End Sub
' InputBox with a default value; Cancel returns an empty string.
Private Sub cmdInput_Click()
Dim Answer As String
Answer = InputBox("What is your name?", "InputBox", "Ada")
lblStatus.Caption = "InputBox returned [" + Answer + "]"
End Sub
' Open dialog limited by the filter set on the component.
Private Sub cmdOpen_Click()
dlgCommon.ShowOpen
ShowDialogResult dlgCommon.FileName
End Sub
' Save dialog.
Private Sub cmdSave_Click()
dlgCommon.ShowSave
ShowDialogResult dlgCommon.FileName
End Sub
' Folder dialog.
Private Sub cmdFolder_Click()
dlgCommon.ShowFolder
ShowDialogResult dlgCommon.FileName
End Sub
' Color dialog; paints the sample panel with the chosen color.
Private Sub cmdColor_Click()
dlgCommon.ShowColor
If Not dlgCommon.Cancelled Then pnlColor.BackColor = dlgCommon.Color
ShowDialogResult dlgCommon.Color
End Sub
' Font dialog; applies the chosen font to the sample label.
Private Sub cmdFont_Click()
dlgCommon.ShowFont
If Not dlgCommon.Cancelled Then lblFontSample.Font = dlgCommon.Font
ShowDialogResult dlgCommon.Font
End Sub
' Print dialog; shows the printer and paper it returned.
Private Sub cmdPrinter_Click()
dlgCommon.ShowPrinter
ShowDialogResult dlgCommon.PrinterName + " / " + dlgCommon.PaperName
End Sub
' Page setup dialog; shows orientation and page size.
Private Sub cmdPageSetup_Click()
dlgCommon.ShowPageSetup
ShowDialogResult dlgCommon.PageOrientation + " " + CStr(dlgCommon.PageWidth) + " x " + CStr(dlgCommon.PageHeight)
End Sub
' Clipboard round trip: set, test, read, clear, test again.
Private Sub cmdClip_Click()
Dim Back As String
Clipboard.SetText "McBasic clipboard test"
Back = Clipboard.GetText()
lblStatus.Caption = "Clipboard has text: " + CStr(Clipboard.HasText()) + ", read back [" + Back + "]"
Clipboard.Clear
lblStatus.Caption = lblStatus.Caption + "; after Clear has text: " + CStr(Clipboard.HasText())
End Sub
' Opens the McBasic web site in the default browser.
Private Sub cmdUrl_Click()
Platform.OpenUrl "https://www.mcbasic.com"
lblStatus.Caption = "Asked the system to open https://www.mcbasic.com"
End Sub
' Starts the audio from the beginning.
Private Sub cmdPlay_Click()
audTone.Play
lblStatus.Caption = "Audio state: " + audTone.State
End Sub
' Pauses the audio.
Private Sub cmdPause_Click()
audTone.Pause
lblStatus.Caption = "Audio state: " + audTone.State
End Sub
' Stops the audio.
Private Sub cmdStop_Click()
audTone.Stop
lblStatus.Caption = "Audio state: " + audTone.State
End Sub
' Sets Position to 0.5 seconds before Play (must not fail), then plays.
Private Sub cmdSeek_Click()
audTone.Position = 0.5
audTone.Play
lblStatus.Caption = "Position set to 0.5 before Play; state: " + audTone.State
End Sub
' Sets the player volume to half.
Private Sub cmdVol_Click()
audTone.Volume = 0.5
lblStatus.Caption = "Volume is " + CStr(audTone.Volume)
End Sub
' Reports an audio error text.
Private Sub audTone_Failed()
lblStatus.Caption = "Audio failed: " + audTone.Error
End Sub
' Reports that playback reached the end.
Private Sub audTone_Completed()
lblStatus.Caption = "Audio completed"
End Sub
' Shows the video state, with the position while it plays.
Private Sub ShowVideo(ByVal Action As String)
lblStatus.Caption = Action + "; video state: " + vidDemo.State + ", position " + CStr(vidDemo.Position) + " of " + CStr(vidDemo.Duration) + " s"
End Sub
' Plays the one-second demo clip (a resumed pause continues where it stopped).
Private Sub cmdVidPlay_Click()
vidDemo.Play
ShowVideo "Video Play"
End Sub
' Pauses the clip.
Private Sub cmdVidPause_Click()
vidDemo.Pause
ShowVideo "Video Pause"
End Sub
' Stops the clip and rewinds it.
Private Sub cmdVidStop_Click()
vidDemo.Stop
ShowVideo "Video Stop"
End Sub
' Moves to half a second (the clip is one second long), then plays from there.
Private Sub cmdVidPos_Click()
vidDemo.Position = 0.5
vidDemo.Play
ShowVideo "Video Position 0.5 + Play"
End Sub
' Sets the video volume to 0.3 (the demo clip has no sound track, so this only proves the call works).
Private Sub cmdVidVol_Click()
vidDemo.Volume = 0.3
lblStatus.Caption = "Video volume is " + CStr(vidDemo.Volume)
End Sub
' Turns Loop on or off; with Loop on the clip restarts at the end until Pause or Stop.
Private Sub cmdVidLoop_Click()
vidDemo.Loop = Not vidDemo.Loop
lblStatus.Caption = "Video Loop is " + CStr(vidDemo.Loop)
End Sub
' Cycles Stretch: Uniform, Fill, UniformToFill, then Uniform again.
Private Sub cmdVidStretch_Click()
If vidDemo.Stretch = "Uniform" Then
vidDemo.Stretch = "Fill"
ElseIf vidDemo.Stretch = "Fill" Then
vidDemo.Stretch = "UniformToFill"
Else
vidDemo.Stretch = "Uniform"
End If
lblStatus.Caption = "Video Stretch is " + vidDemo.Stretch
End Sub
' Reports that the clip is ready, with its length.
Private Sub vidDemo_Loaded()
lblStatus.Caption = "Video loaded (" + CStr(vidDemo.Duration) + " s)"
End Sub
' Reports that the clip reached the end (never with Loop on).
Private Sub vidDemo_Completed()
lblStatus.Caption = "Video completed"
End Sub
' Reports why the clip cannot play.
Private Sub vidDemo_Failed()
lblStatus.Caption = "Video failed: " + vidDemo.Error
End Sub
' Shows each state change (Loaded, Playing, Paused, Stopped, Completed).
Private Sub vidDemo_StateChanged()
lblStatus.Caption = "Video state: " + vidDemo.State
End Sub
' Opens the second form modelessly, so this form stays usable.
Private Sub cmdSecond_Click()
Dim f As frmSecond
Set f = New frmSecond
f.Show
lblStatus.Caption = "Second form opened (modeless)"
End Sub
' Opens a form with ControlBox = False and no menus: on Windows it gets a Help > About menu bar.
Private Sub cmdNoBox_Click()
Dim f As frmNoBox
Set f = New frmNoBox
f.Show
lblStatus.Caption = "Form without control box opened"
End Sub
' Prints a one-page report through the system print dialog (the Windows Print dialog on Windows).
' Cancel returns False; a printer error stops the call with error 5 and the reason, shown in the label.
Private Sub cmdReport_Click()
Try
If Reports.Print(App.ResourcePath & "/Resources/Reports/Hello.report.json") Then
lblStatus.Caption = "Report sent to the printer"
Else
lblStatus.Caption = "Report printing cancelled"
End If
Catch failure As McException
lblStatus.Caption = "Report failed " & CStr(failure.Number) & ": " & failure.Message
End Try
End Sub
' Raises run-time error 5 on purpose to show the error dialog.
Private Sub cmdError_Click()
Err.Raise 5, "WindowsServicesTest", "This error was raised on purpose."
End Sub
' File > Open (Ctrl+O).
Private Sub mnuFileOpen_Click()
lblStatus.Caption = "Menu: File > Open"
End Sub
' File > Save (Ctrl+S).
Private Sub mnuFileSave_Click()
lblStatus.Caption = "Menu: File > Save"
End Sub
' File > Exit closes the window.
Private Sub mnuFileExit_Click()
lblStatus.Caption = "Menu: File > Exit"
Unload Me
End Sub
' Edit > Copy (Ctrl+C).
Private Sub mnuEditCopy_Click()
lblStatus.Caption = "Menu: Edit > Copy"
End Sub
' Edit > Paste (Ctrl+V).
Private Sub mnuEditPaste_Click()
lblStatus.Caption = "Menu: Edit > Paste"
End SubForms/frmSecond.bas
Enter these declarations at file scope, before the procedures.
Option Explicit
' frmSecond: a small form that frmMain opens modelessly.
' Closes this form; the main form stays open.Private Sub cmdClose_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdClose_Click()
Unload Me
End SubCopy the complete Forms/frmSecond.bas file
Replace the file once; do not append duplicate procedures.
Option Explicit
' frmSecond: a small form that frmMain opens modelessly.
' Closes this form; the main form stays open.
Private Sub cmdClose_Click()
Unload Me
End SubForms/frmNoBox.bas
Enter these declarations at file scope, before the procedures.
Option Explicit
' frmNoBox: a form with ControlBox = False and no menus. Windows gives it no system menu, so McBasic adds a menu bar
' with only Help > About; this form proves the About stays reachable.
' Closes this form (it has no Close button of its own); the main form stays open.Private Sub cmdClose_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdClose_Click()
Unload Me
End SubCopy the complete Forms/frmNoBox.bas file
Replace the file once; do not append duplicate procedures.
Option Explicit
' frmNoBox: a form with ControlBox = False and no menus. Windows gives it no system menu, so McBasic adds a menu bar
' with only Help > About; this form proves the About stays reachable.
' Closes this form (it has no Close button of its own); the main form stays open.
Private Sub cmdClose_Click()
Unload Me
End SubStep 5Keep resources and storage reproducible#
Keep the following files at their declared relative paths. Apply migrations before the first query. Media and report resources must travel with the build.
| File | Purpose |
|---|---|
Resources/tone.wav | Bundled asset / license |
Resources/Reports/Hello.report.json | Structured resource |
Resources/demo.mp4 | Bundled asset / license |
Resources/Reports/Hello.report.json
{
"schemaVersion": 1,
"title": "WindowsServicesTest report",
"page": {
"size": "A4",
"orientation": "Portrait",
"margin": 42
},
"paragraphs": [
"A one-page report for the Windows test: Reports.Print shows the Windows Print dialog and prints this page on the chosen printer."
],
"columns": [
{
"header": "Service",
"weight": 2,
"alignment": "Left"
},
{
"header": "Result",
"weight": 1,
"alignment": "Right"
}
],
"rows": [
["MsgBox", "1"],
["Clipboard", "2"],
["Audio", "3"]
],
"totalColumn": 1
}Step 6Check, run and test the result#
Save all files and run Check. Resolve diagnostics before Run. Developer CLI users can work from the extracted folder:
mcbasic check WindowsServicesTest.mcbproj
mcbasic run WindowsServicesTest.mcbprojAcceptance checklist
- Save and Check, then run the sample on the Mac as a baseline.
- Publish for the destination architecture and transfer the artifact to a machine you control.
- Try file and folder dialogs, including Cancel; confirm cancellation does not report a saved file.
- Set and read a disposable clipboard value. Open only the sample URL you intend to visit.
- Windows: test supplied media, stop/pause and close; try a report and Cancel printing.
- Linux: confirm unavailable operations are handled, normal controls remain usable, and report handoff opens the default viewer.
- Record OS/architecture and each observed result. A successful export alone is not an acceptance pass.
Step 7Make one change and repeat the tests#
Use Platform.IsLinux to hide unsupported actions, while retaining runtime error handling for failures on every platform.
Save a working Git checkpoint first. Change one behavior, Check again and repeat the acceptance checklist. Compare with the downloaded solution if a regression appears.
20f4bfed6b · Build manifestSources & maintenance
Original web explanation, reviewed against these repository sources. API tables and example files follow the implementation.
docs/manual/33-publishing-for-windows.mddocs/manual/34-publishing-for-linux.mdsrc/McBasic.Build/PublishTargets.cssrc/McBasic.Build/PlatformAvailabilityCheck.cssrc/McBasic.Runtime/McPlatformAvailability.cssamples/WindowsServicesTest.mcbproj/Forms/frmMain.bassamples/WindowsServicesTest.mcbproj/Forms/frmMain.form.json