Hiding the caret in a Gui text control.
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Hiding the caret in a Gui text control.
Is there a n easy way to hide and unhide the caret for a Gui text control? I didn't find anything in help. I want to be able to display an edit control on a TV monitor and don't want the caret to be seen. Thanks.
Re: Hiding the caret in a Gui text control.
How about putting the focus on a control that is outside of the visible GUI window like this:
Code: Select all
Gui, Add, Edit, w300 r8
Gui, Add, Edit, x400 vDummy
Gui, Show, w320 h130
GuiControl, Focus, Dummy
return
GuiClose:
ExitApp
Re: Hiding the caret in a Gui text control.
I use a similar method as the one suggested by @boiler, with the exception that you don't have to use a edit control. As far as I can tell (Haven't come across a control you couldn't force focus on) you can use any control as the target of focus. So a invisible text control for example.
*Edit*
Never tried, but it may actually be possible to set focus to the window itself???
*Edit 2
You may be asking something different than what I was thinking. My impression was that you were trying to make the caret vanish between uses. If the intention is to NEVER see a caret then there is no need to show the a edit at all, you can have a hidden edit like boiler said and just have a text control as your display.
*Edit*
Never tried, but it may actually be possible to set focus to the window itself???
*Edit 2
You may be asking something different than what I was thinking. My impression was that you were trying to make the caret vanish between uses. If the intention is to NEVER see a caret then there is no need to show the a edit at all, you can have a hidden edit like boiler said and just have a text control as your display.
Re: Hiding the caret in a Gui text control.
Have tested, can't set the focus to the window (at least not using GuiControl and the guis hwnd).
Ignore edit2, I was right the first time.
Here is a little example that works like a normal edit, but if you click somewhere in the last 10px of the control it will set the focus away from the edit control.
Ignore edit2, I was right the first time.
Here is a little example that works like a normal edit, but if you click somewhere in the last 10px of the control it will set the focus away from the edit control.
Code: Select all
#SingleInstance,Force
Gui, 1:+AlwaysOnTop -Caption hwndGuiHwnd
Gui, 1:Margin, 0, 0
Gui, 1:Add, Text, x190 ym w10 h0 BackgroundTrans hwndTexthwnd gSetFocus
Gui, 1:Add,Edit, xm ym w200 r1 hwndEdit1Hwnd ,
GuiControlGet, pos, 1:Pos, % Edit1Hwnd
GuiControl, 1:MoveDraw, % TextHwnd, % "h" PosH
gosub, SetFocus
Gui, 1:Show, x10 y10 , Gui 1
return
*Esc::ExitApp
SetFocus:
GuiControl, 1:Focus, % Texthwnd
return
-
- Posts: 4333
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Hiding the caret in a Gui text control.
Another way:
Code: Select all
Gui, Add, Edit, w300 h200 hwndhEdit
Gui, Show
Return
$F1:: DllCall(((t := !t) ? "Hide" : "Show") . "Caret", "Ptr", hEdit)
Re: Hiding the caret in a Gui text control.
To hide I‘ve been using:
There’s maybe a DllCall like „UnhideCaret“.
Code: Select all
DllCall("HideCaret","Int", hEdit)
Re: Hiding the caret in a Gui text control.
Thank you.
Code: Select all
Gui, Add, Edit, HwndEditHwnd
DllCall( "HideCaret" , "Ptr" , EditHwnd )
DllCall( "ShowCaret" , "Ptr" , EditHwnd )
;*For later use
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Re: Hiding the caret in a Gui text control.
Thanks for all the replies. I decided to go with hiding the edit control, keeping the focus on the edit control and passing the results to a text control . It worked in my tests.
Who is online
Users browsing this forum: Araphen, Bing [Bot], DataLife, ShatterCoder and 224 guests