Post by tsh73 on Nov 4, 2021 12:31:20 GMT -5
with SetCursorPos
'tsh73 Nov 2021
'playing with moving popup window
' by moving mouse cursor
'Just click a mouse anywhere, and it will move popup along a circle
'ROYGBIV
'Richard Of York Gave Battle In Vain.
'Read Out Your Good Book In Verse
'Red Orange Yellow Green Blue Indigo Violet
names$="Red Orange Yellow Green Blue Indigo Violet"
mnemonic1$="Richard Of York Gave Battle In Vain"
mnemonic2$="Read Out Your Good Book In Verse"
'sampled from a picture, because 255 etc are too harsh
data R, "226 0 17"
data O, "255 94 60"
data Y, "252 247 82"
data G, "0 188 56"
data B, "0 157 245"
data I, "8 7 124"
data V, "50 9 148"
nomainwin
Struct tagPoint, x As long, _
y As long
ra.name=1: ra.mnemonic1=2: ra.mnemonic2=3: ra.letter=4: ra.color=5
dim rainbow$(7,5)
qq$=chr$(34)
for i = 1 to 7
read a$, b$
rainbow$(i,ra.name)=word$(names$, i)
rainbow$(i,ra.letter)=a$
rainbow$(i,ra.color)=b$
rainbow$(i,ra.mnemonic1)=word$(mnemonic1$, i)
rainbow$(i,ra.mnemonic2)=word$(mnemonic2$, i)
print i;" ";
'for j = 1 to 5: print rainbow$(i,j),:next
for j = 1 to 3: print qq$;rainbow$(i,j);qq$;",[popClk],",:next
'1 Red Richard Read
'-> 1 "Red", [popClk],"Richard", [popClk],"Read", [popClk],
print
next
open "Roy G. Biv" for graphics_nsb_nf as #gr
#gr "down; trapclose [quit]"
#gr "home; posxy cx cy"
pi = acs(-1)
R=100
r=30
i=1
#gr "font Times_new_roman 16"
txt$="Please do some clicking"
'txtW=200
#gr "stringwidth? txt$ txtW"
#gr "place ";cx-txtW/2;" ";cy
#gr "\";txt$
#gr "color white"
#gr "font Times_new_roman 24"
#gr, "when leftButtonDown [popupMenu]"
wait
[popupMenu]
if i=1 then #gr "cls"
if i <= 7 then
a=(i-1)*2*pi/7
x=cx+R*cos(a)
y=cx+R*sin(a)
'do LB-specific trick with positioning popup window
tagPoint.x.struct=x
tagPoint.y.struct=y
res = ClientToScreen(Hwnd(#gr))
res = SetCursorPos(tagPoint.x.struct, tagPoint.y.struct)
end if
select case i
case 1: popupmenu "Red",[popClk],|, "Richard",[popClk], "Read",[popClk]
case 2: popupmenu "Orange",[popClk],|, "Of",[popClk], "Out",[popClk]
case 3: popupmenu "Yellow",[popClk],|, "York",[popClk], "Your",[popClk]
case 4: popupmenu "Green",[popClk],|, "Gave",[popClk], "Good",[popClk]
case 5: popupmenu "Blue",[popClk],|, "Battle",[popClk], "Book",[popClk]
case 6: popupmenu "Indigo",[popClk],|, "In",[popClk], "In",[popClk]
case 7: popupmenu "Violet",[popClk],|, "Vain",[popClk], "Verse",[popClk]
case else: notice "It's over now"
end select
wait
[popClk]
'process i-th click (1..7)
#gr "backcolor ";rainbow$(i,ra.color)
#gr "place ";x;" ";y
#gr "circlefilled ";r
#gr "place ";x-0.4*r;" ";y+0.4*r
#gr "\";rainbow$(i,ra.letter)
#gr "flush"
i=i+1
wait
[quit]
close #gr
end
Function ClientToScreen (hWnd)
CallDLL #user32, "ClientToScreen", hWnd As ulong, _
tagPoint As struct, _
ClientToScreen As long
End Function
Function SetCursorPos ( intX, intY )
CallDLL #user32, "SetCursorPos", intX As long, _
intY As long, _
SetCursorPos As long
End Function