$ filename "dlg_one1.exe"
'uses rtl32
uses rtl64
'% review
uses winutil
uses dialogs
namespace
# autodim off
% DS_MODALFRAME=128
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#define IDR_MYMENU 101
#define IDD_ABOUT 102
#define ID_FILE_EXIT 40001
#define ID_HELP_ABOUT 40002
declare sub initMenu(sys hWnd)
MainWindow 240, 120,WS_OVERLAPPEDWINDOW
function DialogProc(sys hDlg, Message, wParam, lParam) as bool callback
select case Message
case WM_INITDIALOG
return true
case WM_COMMAND
select case loword(wParam)
case IDOK
EndDialog( hDlg, null)
MessageBox(null, "Dialog exited with IDOK.", "Notice",
MB_OK or MB_ICONINFORMATION)
case IDCANCEL
EndDialog( hDlg, null )
MessageBox(null, "Dialog exited with IDCANCEL.", "Notice",
MB_OK or MB_ICONINFORMATION)
end select
case WM_CLOSE
EndDialog( hDlg, null )
end select
return 0
end function
function WndProc(sys hwnd, Message, wParam, lParam) as sys callback
select Message
case WM_CREATE
initMenu(hwnd)
SetWindowText (hWnd, "The title of my window")
case WM_COMMAND
select loword(wParam)
case ID_HELP_ABOUT
sys lpdt
dyn::init(lpdt) '1024
dyn::Dialog( 4, 0, 0, 239, 66, "My About Box", lpdt,
DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU or DS_SETFONT,
8, "MS Sans Serif" )
dyn::DEFPUSHBUTTON "OK", IDOK, 174, 18, 50, 14, 0, WS_EX_LEFT
dyn::PUSHBUTTON "Cancel", IDCANCEL, 174, 35, 50, 14, 0, WS_EX_LEFT
dyn::GROUPBOX "About this program...", IDC_STATIC, 7, 7, 225, 52, 0, WS_EX_LEFT
dyn::CTEXT "An example program showing how to use" cr "Dialog Boxes" cr+cr "by theForger", IDC_STATIC, 16, 18, 144, 33, SS_CENTER, WS_EX_LEFT
dyn::CreateModalDialog( hWnd, @DialogProc, 0, lpdt )
case ID_FILE_EXIT
SendMessage(hWnd, WM_CLOSE,0,0)
end select
case WM_CLOSE
DestroyWindow(hwnd)
case WM_DESTROY
PostQuitMessage(0)
case else
return DefWindowProc(hwnd, Message, wParam, lParam)
end select
return 0
end function
==================================
sub initMenu(sys hWnd)
sys hMenu
dyn::MENU(hMenu)
dyn::POPUP "&File"
dyn::BEGIN
dyn::MENUITEM "E&xit", ID_FILE_EXIT
dyn::ENDMenu
dyn::POPUP "&Help"
dyn::BEGIN
dyn::MENUITEM "&About...", ID_HELP_ABOUT
dyn::ENDMenu
if SetMenu( hWnd, hMenu ) = 0 then
mbox "SetMenu hMenu failed!"
end if
end sub