LB Booster
« API Texteditor focus »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:46am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: API Texteditor focus  (Read 250 times)
Rod
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 110
xx 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

 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls