Post by rwg on Sept 17, 2019 20:07:09 GMT -5
hi - i'm having trouble making a graphics window the active window without having to click on it.
i want clicking on the graphics window (left click, right click etc) to send the program to different branches,
instead of using them to activate the graphics screen. ok - i could click twice, but this is messy.
the following code shows the problem.
it's quite possible i'm doing something wrong.
i've tried "setfocus" with no success
regards rwg
'get mainwindow number
calldll #user32,"GetActiveWindow",_
mainwinhandle as short
'place mainwindow to left top, 400x400 pixels
calldll #user32,"MoveWindow", _
mainwinhandle as word, _
0 as short, _
0 as short, _
400 as short, _
400 as short, _
1 as word, _
result as void
'create a graphics window
WindowWidth=300
WindowHeight=300
UpperLeftX=600
UpperLeftY=1
open "Test Window" for graphics as #test
[repeat]
cls
#test "cls"
'print hello on graphic window at 50,50
#test "place 50 50"
#test "\ hello"
'set the mainwindow as the active window
gosub [main]
input "junk = ";a$
'set the graphics window as the active window
gosub [graph]
'print hello2 on graphic window at 50,80
#test "place 50 80"
#test "\ hello2"
'i have to click on the graphics window to make it active
'even though i made it active via subroutine [graph]
#test "when characterInput [gotit]"
wait
[gotit]
gosub [main]
goto [repeat]
[main]
calldll #user32, "SetActiveWindow",_
mainwinhandle as ulong,_
ret as ulong
return
[graph]
'get the graphics window number
h1=hwnd(#test)
calldll #user32, "SetActiveWindow",_
h1 as ulong,_
ret as ulong
'#test "setfocus"
return