 |
Bay Six Software Beyond the Basics
|
View previous topic :: View next topic |
Author |
Message |
Tasp Guest
|
Posted: Jan 18th, 2008, 8:36pm Post subject: Using WMLiberty With Buttons |
|
|
I read on the LB forums that WML can be used to check the states of buttons??
i.e. clicked and released
If so can someone post an example, as I can find anything over there. |
|
Back to top |
|
 |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 793
|
Posted: Jan 19th, 2008, 2:46am Post subject: Re: Using WMLiberty With Buttons |
|
|
Hi Tasp,
How are you creating the buttons? There's already a demo on this site to trap simple clicks for API-created buttons.
http://www.b6sw.com/forum/content.php?mode=snips2&p=747 _________________ Brent |
|
Back to top |
|
 |
Guest
|
Posted: Jan 19th, 2008, 11:20am Post subject: Re: Using WMLiberty With Buttons |
|
|
This is what I have done so far, I'm just waiting for the code to tell me when the button has been pressed and then when it's released.
Code: |
nomainwin
WindowWidth = 200
WindowHeight = 250
stylebits #1, 0, _WS_MAXIMIZEBOX or _WS_MINIMIZEBOX, 0, 0
fontname$ = "Wingdings 3" + chr$(0)
height = 60
GOSUB [create]
'q, p, t
'f, g, h, i
button #1.b, "f",[left],UL,10,70,60,60 'left
button #1.c, "g",[right],ul,120,70,60,60 'right
button #1.d, "h",[up],ul,65,10,60,60 'up
button #1.e, "i",[down],ul,65,130,60,60 'down
button #1.f, "P",[zoomin],ul,15,145,40,40 'zoomin
button #1.g, "Q",[zoomout],ul,135,145,40,40 'zoomout
MENU #1, "Menu", "Connect", [branchLabel], "text2", [branchLabel2]
open "Cam Ctrl V1.0" for window as #1
print #1, "trapclose [quit]"
hButton=hwnd(#1.b)
gosub [button]
hButton=hwnd(#1.c)
gosub [button]
hButton=hwnd(#1.d)
gosub [button]
hButton=hwnd(#1.e)
gosub [button]
height = 40
GOSUB [create]
hButton=hwnd(#1.f)
gosub [button]
hButton=hwnd(#1.g)
gosub [button]
WAIT
[left]
Value$ = "LEFT"
CALL Send Value$
WAIT
[right]
Value$ = "LEFT"
CALL Send Value$
WAIT
[up]
Value$ = "LEFT"
CALL Send Value$
WAIT
[down]
Value$ = "LEFT"
CALL Send Value$
WAIT
[zoomin]
Value$ = "LEFT"
CALL Send Value$
WAIT
[zoomout]
Value$ = "LEFT"
CALL Send Value$
WAIT
SUB Send Value$
END SUB
[button]
calldll #user32, "SendMessageA", _
hButton as ulong, _
_WM_SETFONT as long,_
hFont as ulong, _
1 as long,_
result as long
return
[create]
Calldll #gdi32, "CreateFontA", height as long,_
0 as long, 0 as long, 0 as long,_
0 as long, 0 as long, 0 as long, _
0 as long, _SYMBOL_CHARSET as long,_
0 as long,0 as long, 0 as long, 0 as long, _
fontname$ as PTR, hFont as ulong
return
[quit]
calldll #gdi32, "DeleteObject", hFont as ulong, r as long
close #1:END
|
|
|
Back to top |
|
 |
Guest
|
Posted: Jan 19th, 2008, 1:03pm Post subject: Re: Using WMLiberty With Buttons |
|
|
I have made this code using your telnet.mesock demo
But when I close the program after connectioning it crashes LB,
any ideas?
Code: |
nomainwin
WindowWidth = 200
WindowHeight = 250
stylebits #1, 0, _WS_MAXIMIZEBOX or _WS_MINIMIZEBOX, 0, 0
fontname$ = "Wingdings 3" + chr$(0)
fontname2$ = "Wingdings" + chr$(0)
address$ = "localhost"
let port = 23
height = 60
GOSUB [create]
'GOSUB [create2]
'q, p, t
'f, g, h, i
button #1.b, "f",[left],UL,10,70,60,60 'left
button #1.c, "g",[right],ul,120,70,60,60 'right
button #1.d, "h",[up],ul,65,10,60,60 'up
button #1.e, "i",[down],ul,65,130,60,60 'down
button #1.f, "P",[zoomin],ul,15,145,40,40 'zoomin
button #1.g, "Q",[zoomout],ul,135,145,40,40 'zoomout
button #1.h, "n",[stop],ul,75,80,40,40
MENU #1, "Menu", "Connect", [connect], "text2", [branchLabel2]
open "Cam Ctrl V1.0" for window as #1
open "mesock32.dll" for dll as #me
print #1, "trapclose [quit]"
hButton=hwnd(#1.b)
gosub [button]
hButton=hwnd(#1.c)
gosub [button]
hButton=hwnd(#1.d)
gosub [button]
hButton=hwnd(#1.e)
gosub [button]
height = 40
GOSUB [create]
hButton=hwnd(#1.f)
gosub [button]
hButton=hwnd(#1.g)
gosub [button]
height = 20
GOSUB [create2]
hButton=hwnd(#1.h)
gosub [button]
[loop]
scan
CallDLL #kernel32, "Sleep", _
10 As Long, _
rc As Void
scan
goto [loop]
WAIT
[left]
Value$ = "LEFT"
GOTO [send]
WAIT
[right]
Value$ = "RIGHT"
GOTO [send]
WAIT
[up]
Value$ = "UP"
GOTO [send]
WAIT
[down]
Value$ = "DOWN"
GOTO [send]
WAIT
[zoomin]
Value$ = "ZOOMIN"
GOTO [send]
WAIT
[zoomout]
Value$ = "ZOOMOUT"
GOTO [send]
WAIT
[stop]
Value$ = "STOP"
GOTO [send]
wait
[connect]
'if connect = 1 then
'func = TCPClose(handle)
'let connect = 0
'end if
sn$ = "Finkton"
Prompt "Ip Address Of Server:";address$
let handle = TCPOpen(address$,port)
let connect = 1
goto [loop]
SUB Send Value$
END SUB
[send]
if connect = 1 then
text$ = Value$
if text$ <> "" then
let text$ = trim$(text$)
let text$ = sn$;": ";text$
let func = TCPSend(handle,text$)
end if
end if
goto [loop]
wait
[button]
calldll #user32, "SendMessageA", _
hButton as ulong, _
_WM_SETFONT as long,_
hFont as ulong, _
1 as long,_
result as long
return
[create]
Calldll #gdi32, "CreateFontA", height as long,_
0 as long, 0 as long, 0 as long,_
0 as long, 0 as long, 0 as long, _
0 as long, _SYMBOL_CHARSET as long,_
0 as long,0 as long, 0 as long, 0 as long, _
fontname$ as PTR, hFont as ulong
return
[create2]
Calldll #gdi32, "CreateFontA", height as long,_
0 as long, 0 as long, 0 as long,_
0 as long, 0 as long, 0 as long, _
0 as long, _SYMBOL_CHARSET as long,_
0 as long,0 as long, 0 as long, 0 as long, _
fontname2$ as PTR, hFont as ulong
return
[quit]
if connect = 1 then let func = TCPClose(handle)
calldll #gdi32, "DeleteObject", hFont as ulong, r as long
close #me
close #1
END
wait
''''Function TCPOpen()''''''''''
Function TCPOpen(address$,Port)
Timeout=1000
calldll #me, "Open", address$ As ptr,_
Port As ULong,_
Timeout As ULong, re As ULong
TCPOpen=re
if re = 0 then NOTICE "Connection To Server Failed!"
End Function
''''Function TCPReceive$()''''''''''
Function TCPReceive$(handle)
buffer=4096
all=0
calldll #me, "ReceiveA" ,handle As ULong,_
buffer As ULong,_
all As ULong, re As Ulong
if re<>0 then TCPReceive$ = winstring(re)
End Function
''''Function TCPPrint()''''''''''
Function TCPSend(handle,text$)
calldll #me, "PrintA", handle As ULong,_
text$ As ptr,re As ULong
TCPPrint=re
End Function
''''Function TCPClose()''''''''''
Function TCPClose(handle)
calldll #me, "CloseA",handle As ULong,_
TCPClose As ULong
End Function
|
|
|
Back to top |
|
 |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 793
|
Posted: Jan 19th, 2008, 6:14pm Post subject: Re: Using WMLiberty With Buttons |
|
|
Guest (Tasp) wrote: | This is what I have done so far, I'm just waiting for the code to tell me when the button has been pressed and then when it's released. |
I posted a reply to your question on this same subject on the LB Conforums, but to keep help anyone reading this first, I'll repost it here.
Brent Thorn wrote: | Here's a partial solution:
Code: | Open "WMLiberty" For DLL As #wmlib
Button #demo.btn, "Hold me", [click], UL, 10, 10, 75, 25
Open "Button Down Demo" For Dialog As #demo
#demo "TrapClose [quit]"
hwnd = HWnd(#demo.btn)
Callback lpfnCB, OnLButtonDown( ULong, ULong, ULong, ULong ), Long
CallDLL #wmlib, "SetWMHandler", _
hwnd As ULong, _
_WM_LBUTTONDOWN As ULong, _
lpfnCB As ULong, _
-1 As Long, _
ret As Long
[wait]
Scan
CallDLL #kernel32, "Sleep", 100 As Long, ret As Void
GoTo [wait]
[quit]
Close #demo
Close #wmlib
End
[click]
#demo.btn "Hold me"
GoTo [wait]
Function OnLButtonDown( hwnd, umsg, wparam, lparam )
#demo.btn "Let me go!"
End Function |
I say partial because it doesn't take into account the possibility of the user pressing the button with his space bar. According to the docs (SDK), the proper way to trap state changes is to create an owner-drawn button. However, that's quite complicated. If anyone is interested and I get some time, I'll probably post a demo using OD on my site in a few days. |
_________________ Brent |
|
Back to top |
|
 |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 793
|
Posted: Jan 19th, 2008, 6:25pm Post subject: Re: Using WMLiberty With Buttons |
|
|
Guest (Tasp) wrote: | I have made this code using your telnet.mesock demo
But when I close the program after connectioning it crashes LB,
any ideas? |
Sorry, I don't think I be of much help. I've never used mesock, but I've heard that it gives people problems on occasion.
Besides, it's hard to read your code. If you invest the time to format it and give things better (more descriptive) names, errors might pop out at you (or others) much more easily. _________________ Brent |
|
Back to top |
|
 |
|
|
|
|
|
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
|
|
|