Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Sep 11th, 2006, 6:39am Post subject: [DEMO BETA] Dialog with a menu |
|
|
Code: | ' WORK IN PROGRESS - DO NOT REPOST
Open "WMLiberty" For DLL As #wmlib
StyleBits #wnd, 0, _WS_VISIBLE, 0, 0
Menu #wnd, _
"&File", _
"&Open...", wnd.mnuFileOpen, _
|, _
"E&xit", wnd.mnuFileExit
Open "Hidden Menu Processor" For Window As #wnd
hWnd = HWnd(#wnd)
CallDLL #user32, "GetMenu", _
hWnd As ULong, _
hMenu As ULong
WindowWidth = 320
WindowHeight = 75
StyleBits #dlg, _DS_CENTER, 0, 0, 0
StaticText #dlg.stcFile, "Selected file:", 6, 4, 100, 16
TextBox #dlg.txtFile, 6, 20, 300, 20
Open "Dialog with a Menu" For Dialog As #dlg
#dlg "TrapClose Quit"
hDlg = HWnd(#dlg)
Call GetClientSize hDlg, 0, cyInit
CallDLL #user32, "SetMenu", _
hDlg As ULong, _
hMenu As ULong, _
ret As Long
Call GetClientSize hDlg, 0, cyNew
cyMenu = cyInit - cyNew
Call GetWindowSize hDlg, cxDlg, cyDlg
Call SetWindowPos hDlg, 0, 0, 0, cxDlg, cyDlg + cyMenu, _
_SWP_NOZORDER Or _SWP_NOMOVE
Callback lpfn, _
dlg.OnCommand( ULong, ULong, ULong, ULong ), Long
CallDLL #wmlib, "SetWMHandler", _
hDlg As ULong, _
_WM_COMMAND As Long, _
lpfn As ULong, _
1 As Long, _
ret As Long
Call DoEvents
Sub DoEvents
[DoEvents]
Scan
CallDLL #kernel32, "Sleep", 50 As Long, r As Void
GoTo [DoEvents]
End Sub
Sub wnd.mnuFileOpen
FileDialog "", "*.*", file$
If file$ = "" Then Exit Sub
#dlg.txtFile file$
#dlg.txtFile "!SetFocus"
ret = SendMessageLong(HWnd(#dlg.txtFile), _EM_SETSEL, 0, -1)
End Sub
Sub wnd.mnuFileExit
Call Quit "#dlg"
End Sub
Sub Quit h$
Close #dlg
Close #wnd
Close #wmlib
End
End Sub
Function dlg.OnCommand( hDlg, uMsg, wParam, lParam )
If wParam <= 65535 then
ret = SendMessageLong(HWnd(#wnd), uMsg, wParam, lParam )
dlg.OnCommand = 1
End If
End Function
Function SendMessageLong( hWnd, uMsg, wParam, lParam )
CallDLL #user32, "SendMessageA", _
hWnd As ULong, _
uMsg As ULong, _
wParam As ULong, _
lParam As ULong, _
SendMessageLong As Long
End Function
Sub GetClientSize hWnd, ByRef retWidth, ByRef retHeight
Struct ClientRect, _
left As Long, _
top As Long, _
right As Long, _
bottom As Long
CallDLL #user32, "GetClientRect", _
hWnd As ULong, _
ClientRect As Struct, _
ret As Long
retWidth = ClientRect.right.struct
retHeight = ClientRect.bottom.struct
End Sub
Sub GetWindowSize hWnd, ByRef retWidth, ByRef retHeight
Struct WindowRect, _
left As Long, _
top As Long, _
right As Long, _
bottom As Long
CallDLL #user32, "GetWindowRect", _
hWnd As ULong, _
WindowRect As Struct, _
ret As Long
retWidth = WindowRect.right.struct - WindowRect.left.struct + 1
retHeight = WindowRect.bottom.struct - WindowRect.top.struct + 1
End Sub
Sub SetWindowPos hWnd, hWndAfter, X, Y, Width, Height, Flags
CallDLL #user32, "SetWindowPos", _
hWnd As ULong, _
hWndAfter As ULong, _
X As Long, _
Y As Long, _
Width As Long, _
Height As Long, _
Flags As ULong, _
ret As Long
End Sub |
_________________ Brent |
|