Bay Six Software Forum Index Bay Six Software
Beyond the Basics
 
 FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[DEMO BETA] Dialog with a menu

 
Post new topic   Reply to topic    Bay Six Software Forum Index -> WMLiberty DLL -> WMLiberty Demos & Tutorials
View previous topic :: View next topic  
Author Message
Brent
Site Admin


Joined: 01 Jul 2005
Posts: 797

PostPosted: Sep 11th, 2006, 6:39am    Post subject: [DEMO BETA] Dialog with a menu Reply with quote

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
Back to top
View user's profile Send private message Send e-mail
BASICwebmaster
Guest





PostPosted: Sep 12th, 2006, 9:10pm    Post subject: Re: [DEMO BETA] Dialog with a menu Reply with quote

Works for me. WinXP with SP2, LB v4.03, WMLiberty v1.03
Back to top
Brent
Site Admin


Joined: 01 Jul 2005
Posts: 797

PostPosted: Sep 13th, 2006, 1:57am    Post subject: Re: [DEMO BETA] Dialog with a menu Reply with quote

Thanks a lot, Bill!

I'll get this filled out and formalized in a few days.

_________________
Brent
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Bay Six Software Forum Index -> WMLiberty DLL -> WMLiberty Demos & Tutorials All times are GMT
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Lo-Fi Version
Powered by phpBB © 2001, 2005 phpBB Group