Post by GWS on Apr 23, 2018 0:27:04 GMT -5
Hi,
Many years ago I wrote this bit of LB code to display a desktop clock, which can be dragged around using the LeftButton of the mouse.
Problem is, I didn't put many comments in it, and now I can't understand how it works.
I've a feeling I must have had a bit of help back then.
For instance, the MoveIt subroutine has 3 parameters and is called from 'leftButtonMove MoveIt'. This doesn't seem to set the MoveIt parameters w.g$, X, Y .. so I don't see how it works.
Here's the program ..
So embarrassing when you can't understand your own code .. that'll teach me to put more comments in my programs.
I'm at a loss to understand it now .. a bit of enlightenment would be good
Best wishes,
Graham
Many years ago I wrote this bit of LB code to display a desktop clock, which can be dragged around using the LeftButton of the mouse.
Problem is, I didn't put many comments in it, and now I can't understand how it works.
I've a feeling I must have had a bit of help back then.
For instance, the MoveIt subroutine has 3 parameters and is called from 'leftButtonMove MoveIt'. This doesn't seem to set the MoveIt parameters w.g$, X, Y .. so I don't see how it works.
Here's the program ..
nomainwin
WindowWidth = 74: WindowHeight = 18
UpperLeftX = (DisplayWidth - 74)/2
UpperLeftY = 5
ForegroundColor$ = "cyan"
button #w.exit, "", [quit], UL, 62,2,12,16
GraphicBox #w.g, 0, 0, WindowWidth, WindowHeight
stylebits #w, 0, _WS_BORDER,_WS_EX_TOPMOST,0
open "" for window_popup as #w
#w, "trapclose [quit]"
'update the time every second ..
timer 1000, [TimerEvent]
#w.g "setfocus;when leftButtonMove MoveIt"
#w.g "down; fill 35 35 35"
#w.g "backColor 35 35 35"
#w.g "font arial bold 9"
hMain = hwnd(#w)
calldll #user32, "MoveWindow",_
hMain as ulong, _ 'window handle
UpperLeftX as long,_ 'x location of window
UpperLeftY as long,_ 'y location of window
WindowWidth as long,_ 'desired width of window
WindowHeight as long,_ 'desired height of window
1 as boolean,_ 'repaint flag,0=false,1=true
ret as long 'nonzero=success
call TimeSet
wait
[quit]
close #w
end
[TimerEvent]
call TimeSet
wait
Sub MoveIt w.g$, X, Y
' routine to move the window by sending a message
' to make it think it has a caption which the mouse can drag.
w$ = Word$(w.g$, 1, ".")
CallDLL #user32, "ReleaseCapture", r as void
hWnd = HWnd(#w$)
CallDLL #user32, "SendMessageA", hWnd as ULong, _
_WM_NCLBUTTONDOWN as ULong, _HTCAPTION as Long, 0 as Long, result as Long
End Sub
Sub TimeSet
' Update the time ..
#w.g "place 6 12"
#w.g "\"+time$()
End Sub
So embarrassing when you can't understand your own code .. that'll teach me to put more comments in my programs.
I'm at a loss to understand it now .. a bit of enlightenment would be good
Best wishes,
Graham