Post by tsh73 on Dec 12, 2022 8:14:46 GMT
JB cannot read current window position to store for a next time.
But we can occupy fullscreen and drag things there
After that report coordinates we select
(btw if I move window too far, on opening JB or Windows moves it back so it is fully on-screen)
But we can occupy fullscreen and drag things there
After that report coordinates we select
(btw if I move window too far, on opening JB or Windows moves it back so it is fully on-screen)
'window placer
'tsh73 Dec 2022
nomainwin
notice "Window placer demo"+chr$(13)+"Now we ask user where to place window"
call windowPlacer x, y
'x=200
'y=100
notice "Window placer demo"+chr$(13)+"Got the coords ";x;" ";y;chr$(13);"(Hint: you can save it to a file and use on next start)"
confirm "Placing ordinary window (yes) "+chr$(13)+"or modal_dialog (no) ?"; answer$
if answer$ = "no" then useAux=1
if useAux then 'positioning modal dialog by using of helper window
UpperLeftX =x
UpperLeftY =y
WindowWidth =1 'actually pretty invisble
WindowHeight=1
open "Auxiliary window" for window_popup as #auxiliary
'now, modal dialog counts coords from Auxiliary window
UpperLeftX =1
UpperLeftY =1
WindowWidth =400
WindowHeight=300
STATICTEXT #main, "This is MODAL dialog. And it closes on ESC!", 20, 20, 350, 50
open "Dialog placed at ";x;" ";y for dialog_modal as #main
else
UpperLeftX =x
UpperLeftY =y
WindowWidth =400
WindowHeight=300
'normal window
STATICTEXT #main, "Normal boring window", 20, 20, 350, 50
open "Window placed at ";x;" ";y for window as #main
'dialog window - no problem, jst works
' I forgot. There is no problem with placing DILAOG windows - but only DIALOG_MODAL. Don't think I need that.
'STATICTEXT #main, "I'm pretty sure it is dialog. It is closes on ESC!", 20, 20, 350, 50
'open "Dialog placed at ";x;" ";y for dialog as #main
end if
#main "trapclose [quit]"
wait
[quit]
close #main
if useAux then close #auxiliary
end
sub windowPlacer byRef x, byRef y
UpperLeftX =1
UpperLeftY =1
WindowWidth =DisplayWidth
WindowHeight=DisplayHeight
graphicbox #windowPlacer.g, 0, 0, DisplayWidth, DisplayHeight
open "test" for window_popup as #windowPlacer
#windowPlacer "trapclose [quit]"
#windowPlacer.g "down; home; posxy x y"
#windowPlacer.g "when leftButtonMove [move]"
gosub [draw]
wait
[move]
#windowPlacer.g "color white" 'that's lazy clear
gosub [draw]
x= MouseX: y= MouseY
#windowPlacer.g "color black"
gosub [draw]
wait
[draw]
#windowPlacer.g "place ";x;" ";y
#windowPlacer.g "\\ Drag this rectangle where you want"
#windowPlacer.g "\ close with Alt-F4 then done"
#windowPlacer.g "place ";x;" ";y
#windowPlacer.g "box ";x+250;" ";y+50
return
[quit]
close #windowPlacer
if x<1 then x=1 'JB does not allows 0 or negative window pos
if y<1 then y=1
'notice "Got the coords ";x;" ";y
end sub