Author |
Topic: API Texteditor focus (Read 251 times) |
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
API Texteditor focus
« Thread started on: Jul 11th, 2016, 11:59am » |
|
Richard, if we use this code to create an API based texteditor it fails to regain focus when Alt Tab is used to move between programs. Using Alt Tab we need to click in the window to regain focus. Other programs keep the focus and have a cursor flashing when you return . Is there an easy solution for that?
Code:nomainwin
WindowWidth=640:WindowHeight=480
UpperLeftX=1:UpperLeftY=1
open "Texteditor" for window as #1
print #1, "trapclose [quit]"
hT=CreateTextEdit(hwnd(#1), 1, 1, 630, 432)
wait
[quit]
close #1
end
Function CreateTextEdit(hW, x, y, w, h)
style = _WS_CHILDWINDOW OR _WS_BORDER _
OR _WS_VISIBLE or _ES_MULTILINE or _WS_VSCROLL
hInst=GetWindowLong(hW, _GWL_HINSTANCE)
calldll #user32, "CreateWindowExA",_
0 as long,"EDIT" as ptr,_
"" as ptr, style as long,_
x as long,y as long,w as long,h as long,_
hW as ulong, 0 as long, hInst as ulong,_
0 as long, CreateTextEdit as ulong
end function
Function GetWindowLong(hW, type)
calldll #user32, "GetWindowLongA", _
hW as ulong, type as long,_
GetWindowLong as ulong
End Function
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: API Texteditor focus
« Reply #1 on: Jul 11th, 2016, 1:28pm » |
|
on Jul 11th, 2016, 11:59am, Rod wrote:Other programs keep the focus and have a cursor flashing when you return . Is there an easy solution for that? |
|
I'm afraid I don't know why LBB is exhibiting this behaviour when other programs don't. All I can suggest is a workaround of forcibly setting the focus in a timer:
Code:nomainwin
WindowWidth=640:WindowHeight=480
UpperLeftX=1:UpperLeftY=1
open "Texteditor" for window as #1
print #1, "trapclose [quit]"
hT=CreateTextEdit(hwnd(#1), 1, 1, 630, 432)
timer 100,[setfocus]
wait
[setfocus]
calldll #user32, "SetFocus", hT as ulong, r as long
wait
[quit]
close #1
end
Function CreateTextEdit(hW, x, y, w, h)
style = _WS_CHILDWINDOW OR _WS_BORDER _
OR _WS_VISIBLE or _ES_MULTILINE or _WS_VSCROLL
hInst=GetWindowLong(hW, _GWL_HINSTANCE)
calldll #user32, "CreateWindowExA",_
0 as long,"EDIT" as ptr,_
"" as ptr, style as long,_
x as long,y as long,w as long,h as long,_
hW as ulong, 0 as long, hInst as ulong,_
0 as long, CreateTextEdit as ulong
end function
Function GetWindowLong(hW, type)
calldll #user32, "GetWindowLongA", _
hW as ulong, type as long,_
GetWindowLong as ulong
End Function Richard.
|
|
Logged
|
|
|
|
|