' Shows how to add a modeless dialog box to use as a ' debugging window in which to display strings ' The parts between the lines of asterisks are the debug part $DIM ALL $REGISTER NONE $COMPILE EXE $INCLUDE "WIN32API.INC" ' *********************** GLOBAL hDebugDlg AS LONG ' *********************** GLOBAL hDlg AS LONG %ID_TEXT = %WM_USER ' *********************** %ID_DEBUG = %WM_USER + 1 ' *********************** ' ************************************* SUB debug(OPTIONAL BYVAL v1 AS VARIANT, _ OPTIONAL BYVAL v2 AS VARIANT, _ OPTIONAL BYVAL v3 AS VARIANT, _ OPTIONAL BYVAL v4 AS VARIANT, _ OPTIONAL BYVAL v5 AS VARIANT, _ OPTIONAL BYVAL v6 AS VARIANT) LOCAL msg AS STRING LOCAL i AS LONG LOCAL n AS LONG DIM v(6) AS VARIANT v(1) = v1 : v(2) = v2 : v(3) = v3 v(4) = v4 : v(5) = v5 : v(6) = v6 FOR i = 1 TO 6 n = VARIANTVT(v(i)) ' get varient type IF n = 8 THEN ' if dynamic string msg = msg + VARIANT$(v(i)) + ", " ' add it as a string ELSEIF n <> 0 THEN ' not null or empty msg = msg + STR$(VARIANT#(v(i))) + ", " ' convert to string and add END IF NEXT msg = RTRIM$(Msg, ANY ", ") CONTROL SEND hDebugDlg, %ID_Debug, %WM_GETTEXTLENGTH, 0, 0 TO n IF n THEN msg = $CRLF + msg CONTROL SEND hDebugDlg, %ID_Debug, %EM_REPLACESEL, 0, STRPTR(msg) END SUB ' ************************************* ' Callback Declarations DECLARE CALLBACK FUNCTION DlgProc() FUNCTION PBMAIN AS LONG ' ************************************* ' Create dialog box for debugging info DIALOG NEW 0, "Debug Info", 0, 0, 200, 80, 0 TO hDebugDlg CONTROL ADD TEXTBOX, hDebugDlg, %ID_DEBUG, "debug info here", 2, 2, 196, 76, %WS_BORDER OR %WS_VSCROLL OR %WS_HSCROLL OR %ES_MULTILINE OR %ES_NOHIDESEL ' Start up modeless dialog box and continue DIALOG SHOW MODELESS hDebugDlg ' ************************************* ' Create primary dialog box DIALOG NEW 0, "Debug Dialog Demo", 0, 0, 200, 50, %DS_CENTER OR %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg CONTROL ADD LABEL, hDlg, %ID_TEXT, "Mouse coordinates, try left clicking in this window", 5, 5, 195, 45 ' Start up dialog box and run until the user quits DIALOG SHOW MODAL hDlg, CALL DlgProc END FUNCTION CALLBACK FUNCTION DlgProc() SELECT CASE CBMSG CASE %WM_MOUSEMOVE ' display something when mouse is moved just for demo CONTROL SET TEXT hDlg, %ID_TEXT, "Mouse X=" + STR$(HIWRD(CBLPARAM)) + " Y=" + STR$(LOWRD(CBLPARAM)) ' display in main dialog for demo CASE %WM_LBUTTONDOWN ' use mouse button to cause an event to display for the demo debug "X", HIWRD(CBLPARAM), "Y", LOWRD(CBLPARAM) END SELECT END FUNCTION