'==============================================================================
' DDT / SDK interop sample
' Creates a dialog and a button, then calls SendMessageA with the button HWND.
' No message loop; create, inspect, destroy.
'==============================================================================
#COMPILE EXE
#DIM ALL

%WM_GETTEXTLENGTH = &H000E

DECLARE FUNCTION SendMessageA LIB "user32.dll" ALIAS "SendMessageA" (BYVAL hWnd AS QUAD, BYVAL Msg AS LONG, BYVAL wParam AS QUAD, BYVAL lParam AS QUAD) AS QUAD

FUNCTION PBMAIN() AS LONG
    LOCAL hDlg  AS DWORD
    LOCAL hCtrl AS DWORD
    LOCAL r     AS QUAD

    DIALOG NEW 0, "SDK Interop", 10, 10, 300, 200 TO hDlg
    PRINT "HWND=" + STR$(hDlg)

    CONTROL ADD BUTTON, hDlg, 100, "Click", 10, 10, 80, 24 TO hCtrl
    PRINT "CTRL=" + STR$(hCtrl)

    ' Use the control HWND directly with the SDK.
    r = SendMessageA(hCtrl, %WM_GETTEXTLENGTH, 0, 0)
    PRINT "TEXTLEN=" + STR$(r)

    DIALOG END hDlg
    FUNCTION = 0
END FUNCTION
