I wrote this a long time ago ... someone might find a practical use for this technique.
Anyway, compile this as a console app, not a GUI app then run it.
It compiles and runs with Mingw, Clang, MSVC, LccWin32, and Pelles
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
' I don't know how useful this is but it does demonstrate how it
' is possible to startup in CONSOLE mode and conditionally switch
' GUI mode. Released to the public domain by Kevin Diggins.
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
' Please compile this as a CONSOLE app, to see the full benefit.
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
SUB main() ' main MUST be spelled using lower case
LOCAL Tmp$
INPUT "Do you wanna do the gui? ", Tmp$
IF UCASE$(MID$(Tmp$,1,1)) = "Y" THEN
WinMain(0,0,0,0) ' Yes ... Call WINMAIN() from main() ... crazy, huh?
ELSE
END
END IF
END SUB
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
GUI "BCX GUI-Console"
SUB FormLoad
CONST ID_Button1 = 101
GLOBAL Form1 AS HWND
GLOBAL Button1 AS HWND
Form1 = BCX_FORM("Con_Gui", 0, 0, 165, 120)
Button1 = BCX_BUTTON ("Print message to Console Window", Form1, ID_Button1, 10, 42, 140, 14)
CENTER (Form1)
SHOW (Form1)
END SUB
BEGIN EVENTS
SELECT CASE Msg
' *****************
CASE WM_COMMAND
' *****************
IF CBCTL = ID_Button1 THEN
PRINT "This is supposed to print to our console"
END IF
' *****************
CASE WM_CLOSE
' *****************
LOCAL id
id = MessageBox( _
hWnd, _
"Are you sure?", _
"Quit Program!", _
MB_YESNO OR MB_ICONQUESTION )
IF id = IDYES THEN DestroyWindow (hWnd)
EXIT FUNCTION
' *****************
CASE WM_DESTROY
' *****************
PostQuitMessage(0)
EXIT FUNCTION
END SELECT
END EVENTS