emy
New Member
Hello
Posts: 45
|
Post by emy on Jan 25, 2021 8:44:10 GMT -5
Hello all of You, I would like to make a program window with a graphicbox and when the mouse pointer goes into this graphicbox the mouse ponter change in a cross wide H & V (like AutoCad) When the mouse goes out of the graphicbox ia an arrow again. What ever is inside the graphic box the mouse should work. I did try different way, but no success. It works partially which is not correct. I am thinking that API DLL are probably necessary How I can do that, some one can help me ? Here is what I have done. WideCursor.zip (1.45 KB)
|
|
|
Post by Rod on Jan 25, 2021 9:41:34 GMT -5
Well it seems to function pretty well. The problem is that it stops moving when the cursor is over one of the other controls you have programmed? If so I am not sure about a solution. There is a great article on LBPE about custom cursors. However I am not sure one as wide and high is possible. In any event even a real cursor will display the same problem, once it hits another control it will change behaviour. Wait to see what other folks say. If you look at freeform.bas that ships with Liberty you will see that it places images of controls not real controls. That way the design graphicbox can show the cursor over the display and snap to grid and other such tricks can move the image of the control.
|
|
|
Post by tsh73 on Jan 25, 2021 15:13:34 GMT -5
I am not expert in API calls but I found this thread libertybasiccom.proboards.com/thread/842/mousemove-when-stoppedand last code has a function returning mouse position, seems everywhere So I put it into your program and it kinda works. May be someone could make it neater. '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° ' WideCursor.bas '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° SlideMin = 1 SlideMax = 100 MouseOffset = 1 SLimitMin = 0 SLimitMax = 445 - MouseOffset SliderLen = 445 - MouseOffset Middle = 220 'Start Position cursor (middle) slip = int(445/(SlideMax-SlideMin)) if slip < 1 then slip = 1 LoadBmp "slideH", "CursorH.bmp" 'H LoadBmp "slideV", "CursorV.bmp" 'V '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° nomainwin WindowWidth = 510 : WindowHeight = 600 UpperLeftX = 400 : UpperLeftY = 220 '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Button #w.bt1, "Exit",[quit],UL, 415, 10, 60, 30 Button #w.bt2, "Test",[Test],UL, 360, 400, 60, 30 '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Graphicbox #w.Graphicbox2, 190, 210, 120, 120 Graphicbox #w.Graphicbox1, 30, 50, 445, 445 '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Statictext #w.St1, " ", 3, 270, 20, 20 Statictext #w.St2, " ", 244, 30, 40, 20 Statictext #w.St3, " ", 210, 520, 120, 20 '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° textbox #w.tx1, 80, 120, 55, 20 stylebits #w.tx1, 0, _WS_BORDER, 0, 0 'This works 'stylebits #w.tx1, 0, _ES_READONLY, 0, 0 'This doesn't work with graphic '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Open "Wide full cross cursor H & V in a Graphic Area" For Window As #w #w, "trapclose [quit]" '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Mouse Attributions #w.Graphicbox1, "when leftButtonMove [Cursor]" #w.Graphicbox1, "when mouseMove [Cursor]" #w.Graphicbox1, "when leftButtonDown [Value]" '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Horizontal #w.Graphicbox1, "addsprite slideH slideH"; #w.Graphicbox1, "spritevisible slideH on" '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Vertical #w.Graphicbox1, "addsprite slideV slideV"; #w.Graphicbox1, "spritevisible slideV on" '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° #w.Graphicbox1, "flush" MouseY = Middle +5 : MouseX = Middle #w.St1, using("###",mouseMoveH(MouseY,SlideMax,SlideMin,SLimitMax,SLimitMin,SliderLen)) #w.St2, using("###",mouseMoveV(MouseX,SlideMax,SlideMin,SLimitMax,SLimitMin,SliderLen)) #w.St3, " X = " + str$(MouseX) + " - " + " Y = " + str$(MouseY) '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° #w.Graphicbox2, "down;fill cyan" #w.Graphicbox2, "color black;backcolor cyan" #w.Graphicbox2, "place 40 60;\Hello" '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° #w.tx1, " Value"
'for GetCursorPos global x global y struct point, x as long, y as long
timer 100, [tick] wait
[tick] dummy$= CursorPos$(hwnd(#w.Graphicbox1)) MouseX=x MouseY=y goto [Cursor] wait '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° [Test] wait '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° [quit] unloadbmp "slideH" unloadbmp "slideV" Close #w End
'°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° [Value] #w.tx1, using("###",MouseX) + " - " + using("###",MouseY) wait '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° [Cursor] #w.St1, using("###",mouseMoveH(MouseY,SlideMax,SlideMin,SLimitMax,SLimitMin,SliderLen)) #w.St2, using("###",mouseMoveV(MouseX,SlideMax,SlideMin,SLimitMax,SLimitMin,SliderLen)) #w.St3, " X = " + str$(MouseX) + " - " + " Y = " + str$(MouseY) wait '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Function mouseMoveH(MouseY,SlideMax,SlideMin,SLimitMax,SLimitMin,SliderLen) If MouseY <= SLimitMin Then MouseY = SLimitMin If MouseY >= SLimitMax Then MouseY = SLimitMax #w.Graphicbox1, "spritexy slideH 0 ";MouseY #w.Graphicbox1, "drawsprites" TempVar = Int((MouseY/SliderLen)*(SlideMax-SlideMin)+SlideMin) mouseMoveH = 101 - TempVar End Function '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Function mouseMoveV(MouseX,SlideMax,SlideMin,SLimitMax,SLimitMin,SliderLen) If MouseX <= SLimitMin Then MouseX=SLimitMin If MouseX >= SLimitMax Then MouseX=SLimitMax #w.Graphicbox1, "spritexy slideV ";MouseX;" 0" #w.Graphicbox1, "drawsprites" TempVar = Int((MouseX/SliderLen)*(SlideMax-SlideMin)+SlideMin) mouseMoveV = TempVar End Function '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° '-------------------------------------------------------------- function CursorPos$(handle) Calldll #user32, "GetCursorPos",_ point as struct,_ result as long Calldll #user32, "ScreenToClient",_ handle As Ulong,_ point As struct,_ result as long x = point.x.struct y = point.y.struct ' CursorPos$=x; ",";y end function
|
|
emy
New Member
Hello
Posts: 45
|
Post by emy on Jan 26, 2021 3:32:08 GMT -5
Thanks Rod for Your answer I will read article on LBPE Regards.
|
|
emy
New Member
Hello
Posts: 45
|
Post by emy on Jan 26, 2021 4:56:22 GMT -5
Thank You tsh73 for Your message. I did run with modifications, cursor move behind control. A bit slower behind the control, good step. What about fonctions "rule";_R2_xxxxxxxxxx, I don't know about, could they help the wide cursor ? Regards.
|
|
|
Post by tsh73 on Jan 26, 2021 6:04:57 GMT -5
Mouse event of graphicbox doesn't fire behind controls So when behind controls, timer event happens. I set timer to 100 ms - if you make it smaller likely get better responce
"rule" stuff works only on graphicbox It will not draw over controls - or I have no idea how
Do you really need cursor to be visible over buttons etc? (it depends on what you actually going to do, which I have no idea)
|
|
|
Post by Rod on Jan 26, 2021 9:46:49 GMT -5
This is the XOR drawing but it is still flawed. While controls do function on top of graphicboxes we are told to avoid this. Statictext for example will not work, and as you can see there is a Z order which prevents line drawing from being seen.
What is the ultimate aim of the project?
nomainwin WindowWidth = 510 : WindowHeight = 600 UpperLeftX = 400 : UpperLeftY = 220 '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Button #w.bt1, "Exit",[quit],UL, 415, 10, 60, 30 Button #w.bt2, "Test",[Test],UL, 360, 400, 60, 30 '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Graphicbox #w.Graphicbox2, 190, 210, 120, 120 Graphicbox #w.Graphicbox1, 30, 50, 445, 445 '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Statictext #w.St1, " ", 3, 270, 20, 20 Statictext #w.St2, " ", 244, 30, 40, 20 Statictext #w.St3, " ", 210, 520, 120, 20 '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° textbox #w.tx1, 80, 120, 55, 20 stylebits #w.tx1, 0, _WS_BORDER, 0, 0 'This works 'stylebits #w.tx1, 0, _ES_READONLY, 0, 0 'This doesn't work with graphic '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Open "Wide full cross cursor H & V in a Graphic Area" For Window As #w #w, "trapclose [quit]" #w.Graphicbox1 "down ; color black"
#w.Graphicbox2 "down;fill cyan" #w.Graphicbox2 "color black;backcolor cyan" #w.Graphicbox2 "place 40 60;\Hello" '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° #w.tx1, " Value"
'for GetCursorPos global x global y global hgb struct point, x as long, y as long hgb=hwnd(#w.Graphicbox1) cursor crosshair timer 56, [tick] wait
[tick] Calldll #user32, "GetCursorPos",_ point as struct,_ result as long Calldll #user32, "ScreenToClient",_ hgb As Ulong,_ point As struct,_ result as long x = point.x.struct y = point.y.struct #w.Graphicbox1 "rule XOR" #w.Graphicbox1 "line 0 ";oy;" 500 ";oy #w.Graphicbox1 "line ";ox;" 0 ";ox;" 500"
#w.Graphicbox1 "line 0 ";y;" 500 ";y #w.Graphicbox1 "line ";x;" 0 ";x;" 500" #w.Graphicbox1 "rule OVER" ox=x oy=y #w.tx1, using("###",x) + " - " + using("###",y) wait '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
[quit] timer 0 close #w End
|
|
emy
New Member
Hello
Posts: 45
|
Post by emy on Jan 27, 2021 7:45:25 GMT -5
Hi, the idea was to make a large window display with data, without hight lighted row or column. Cursor will be used as mouse pointer and a kind of line rule as well. Remain a challenge. Can be useful also for different applications. May be one day this kind of cursor will be available on the Window library ?
|
|
|
Post by tsh73 on Jan 27, 2021 10:14:46 GMT -5
|
|
emy
New Member
Hello
Posts: 45
|
Post by emy on Jan 28, 2021 7:28:06 GMT -5
Yes, it helps with H & V separation lines, interesting. Thanks tsh73
|
|
|
Post by Walt Decker on Jan 29, 2021 10:55:51 GMT -5
Anyone thought of user32.dll functions SetCapture()/ReleaseCapture() in the mouse move event?
Could add rightButtonDown event to release capture and allow input in text boxes or clicking buttons.
I did not see the above rules in LB4x PRO Help. Nor have I been able to get the "_R2_" types to work. Have the _R2_ group been changed?
|
|
|
Post by Rod on Jan 29, 2021 11:58:42 GMT -5
In the graphics section of the help file
So two rulenames are known to Liberty OVER and XOR the remainder need used in the second form with the leading underscore but outside the command string, the second format shown above.
Not sure if setCapture() can help given the Z order problem still remains. The drawing will be behind the control.
|
|