You can trap runtime binding errors with this line:
s=error() : if s then print s : goto endprog
where endprog is a label located at the end of the script
Here is the working dialog:
#basic
dim as byte dlgtpl(104)=>(1,0,255,255,0,0,0,0,0,0,0,0,0,8,207,16,1,0,10,0,10,0,150,0,100,0,0,0,0,0,73,0,68,0,68,0,95,0,68,0,
76,0,71,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,80,48,0,66,0,51,0,15,0,233,3,0,0,66,0,85,0,84,0,84,0,
79,0,78,0,0,0,73,0,68,0,67,0,95,0,66,0,84,0,78,0,0,0,0,0)
type MSG
; 28 bytes
hwnd as long
message as long
wParam as long
lParam as long
time as long
pt as point
end type
dim kernel32,user32,GDI32 as long
kernel32=LoadLibrary `kernel32.dll`
user32=LoadLibrary `user32.dll`
GDI32=LoadLibrary `GDI32.dll`
bind kernel32
(
GetCommandLine GetCommandLineA ; @0
GetModuleHandle GetModuleHandleA ; @4
ExitProcess ExitProcess ; @4
)
bind user32
(
LoadIcon LoadIconA ; @8
LoadCursor LoadCursorA ; @8
RegisterClass RegisterClassA ; @4
MessageBox MessageBoxA ; @4
CreateWindowEx CreateWindowExA ; @48
ShowWindow ShowWindow ; @8
UpdateWindow UpdateWindow ; @4
GetMessage GetMessageA ; @16
TranslateMessage TranslateMessage ; @4
DispatchMessage DispatchMessageA ; @4
PostQuitMessage PostQuitMessage ; @4
BeginPaint BeginPaint ; @8
EndPaint EndPaint ; @8
GetClientRect GetClientRect ; @8
DrawText DrawTextA ; @20
PostMessage PostMessageA ; @16
DefWindowProc DefWindowProcA ; @16
DialogBoxParam DialogBoxParamA ;@20
DialogBoxIndirectParam DialogBoxIndirectParamA ;@20
EndDialog EndDialog ;@8
)
bind GDI32
(
GetStockObject GetStockObject ; @4
)
s=error() : if s then print s : goto endprog
% WM_DESTROY 2
% WM_CLOSE 16
% WM_SYSCOMMAND = 0x0112
% SC_CLOSE = 0xF060
% WM_COMMAND = 0x0111
% CS_VREDRAW 1
% CS_HREDRAW 2
% IDI_APPLICATION 32512
% IDC_ARROW 32512
% WHITE_BRUSH 0
% MB_ICONERROR 16
declare Function WinMain(byval inst as long ,byval prevInst as long ,byval cmdline as asciiz , byval show as long) as long
declare function WndProc(byval hWnd as long, byval wMsg as long, byval wParam as long, byval lparam as long) as long
'
def SW_NORMAL 1
def SW_SHOWDEFAULT 10
;=====================================
dim byref cmdline as asciiz,inst as long
&cmdline=GetCommandLine
inst=GetModuleHandle 0
'print cmdline `
'` hex inst
WinMain inst,0,cmdline,SW_NORMAL
'
freelibrary kernel32
freelibrary user32
freelibrary gdi32
terminate
Function WinMain(byval inst as long ,byval prevInst as long,byval cmdline as asciiz , byval show as long) as long
Dim RetVal as long
RetVal = DialogBoxIndirectParam(inst,&dlgtpl,0,&WndProc,0)
if RetVal == -1 then
MessageBox 0,`No Resource` ,`Information`,MB_ICONERROR
exit function
end if
function=RetVal
End Function
'==============================================================================
Function WndProc (byval hWnd as long,byval wMsg as long, byval wParam as long,byval lparam as long ) as long callback
select wMsg
case WM_DESTROY
PostQuitMessage 0
'case WM_CLOSE
' EndDialog(hWnd,0)
case WM_SYSCOMMAND
if (wParam AND 0xFFF0) == SC_CLOSE then
EndDialog(hWnd,0)
end if
case WM_COMMAND
end select
End Function
endprog:
Charles