DVX_GUI/unused/samples/commdlg.frm

152 lines
3.9 KiB
Text

VERSION DVX 1.00
' commdlg.frm -- Common Dialog Library Demo
'
' Demonstrates every function in the commdlg.bas include file:
' basFileOpen - File Open dialog
' basFileSave - File Save dialog
' basInputBox2 - Text input dialog
' basChoiceDialog - Choice list dialog
' basIntInput - Integer spinner dialog
' basPromptSave - Yes/No/Cancel save prompt
'
' Add commdlg.bas to your project, then click Run.
Begin Form CommDlgDemo
Caption = "Common Dialogs Demo"
Layout = VBox
AutoSize = True
Resizable = False
Centered = True
Begin Label LblTitle
Caption = "Common Dialog Demonstrations"
Weight = 0
End
Begin Line Line1
Weight = 0
End
Begin CommandButton BtnFileOpen
Caption = "File Open..."
Weight = 0
End
Begin CommandButton BtnFileSave
Caption = "File Save..."
Weight = 0
End
Begin CommandButton BtnInputBox
Caption = "Input Box..."
Weight = 0
End
Begin CommandButton BtnChoice
Caption = "Choice Dialog..."
Weight = 0
End
Begin CommandButton BtnIntInput
Caption = "Integer Input..."
Weight = 0
End
Begin CommandButton BtnPromptSave
Caption = "Prompt Save..."
Weight = 0
End
Begin Line Line2
Weight = 0
End
Begin Label LblResult
Caption = "Result will appear here."
Weight = 0
End
End
Load CommDlgDemo
CommDlgDemo.Show
PRINT "Common Dialog Demo started."
SUB BtnFileOpen_Click
DIM path AS STRING
path = basFileOpen("Open a File", "BASIC Files (*.bas;*.frm)|All Files (*.*)")
IF path <> "" THEN
LblResult.Caption = "Opened: " + path
PRINT "File Open: " + path
ELSE
LblResult.Caption = "File Open cancelled."
PRINT "File Open cancelled."
END IF
END SUB
SUB BtnFileSave_Click
DIM path AS STRING
path = basFileSave("Save a File", "Text Files (*.txt)|All Files (*.*)")
IF path <> "" THEN
LblResult.Caption = "Save to: " + path
PRINT "File Save: " + path
ELSE
LblResult.Caption = "File Save cancelled."
PRINT "File Save cancelled."
END IF
END SUB
SUB BtnInputBox_Click
DIM text AS STRING
text = basInputBox2("Text Input", "Enter your name:", "World")
IF text <> "" THEN
LblResult.Caption = "Hello, " + text + "!"
PRINT "Input: " + text
ELSE
LblResult.Caption = "Input Box cancelled."
PRINT "Input Box cancelled."
END IF
END SUB
SUB BtnChoice_Click
DIM idx AS INTEGER
idx = basChoiceDialog("Pick a Color", "Choose your favorite color:", "Red|Orange|Yellow|Green|Blue|Indigo|Violet", 0)
IF idx >= 0 THEN
DIM colors(6) AS STRING
colors(0) = "Red"
colors(1) = "Orange"
colors(2) = "Yellow"
colors(3) = "Green"
colors(4) = "Blue"
colors(5) = "Indigo"
colors(6) = "Violet"
LblResult.Caption = "You chose: " + colors(idx)
PRINT "Choice: " + colors(idx) + " (index" + STR$(idx) + ")"
ELSE
LblResult.Caption = "Choice Dialog cancelled."
PRINT "Choice Dialog cancelled."
END IF
END SUB
SUB BtnIntInput_Click
DIM val AS INTEGER
val = basIntInput("Pick a Number", "Enter a value (1-100):", 50, 1, 100)
LblResult.Caption = "You entered:" + STR$(val)
PRINT "Integer Input:" + STR$(val)
END SUB
SUB BtnPromptSave_Click
DIM result AS INTEGER
result = basPromptSave("Unsaved Changes")
IF result = DVX_SAVE_YES THEN
LblResult.Caption = "You chose: Yes (save)"
PRINT "Prompt Save: Yes"
ELSEIF result = DVX_SAVE_NO THEN
LblResult.Caption = "You chose: No (discard)"
PRINT "Prompt Save: No"
ELSE
LblResult.Caption = "You chose: Cancel"
PRINT "Prompt Save: Cancel"
END IF
END SUB
SUB CommDlgDemo_Load
PRINT "Form loaded. Click any button to try a dialog."
END SUB