how to remove the blue border when "Edit" is on focus?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wo52616111
Posts: 47
Joined: 21 Aug 2014, 04:46

how to remove the blue border when "Edit" is on focus?

Post by wo52616111 » 29 May 2016, 02:18

Code: Select all

Gui, new, HwndGuiHwnd , newgui
Gui, Color, red, green
Gui, Show, Center w300 h200, ahk_id%GuiHwnd%
Gui, Add, Edit, x20 y20 w150 h50 -Multi -Border
Image

Code: Select all

Gui, Add, Edit, x20 y20 w150 h50 -Multi -Border -E0x200
;E0x200 = WS_EX_CLIENTEDGE ( Extended style) 
-E0x200 can remove the blue border, but it remove white border and padding either, I need them.

User avatar
jballi
Posts: 727
Joined: 29 Sep 2013, 17:34

Re: how to remove the blue border when "Edit" is on focus?

Post by jballi » 29 May 2016, 17:45

I played around with it a bit but couldn't come up with anything off the bat. Removing the WS_EX_CLIENTEDGE style may be your best bet. You can put back the white border by drawing a white border around the control. Someone posted an easy way to do this but I couldn't find the link. Maybe someone else can help me out here. The padding is also an issue that could be resolved by drawing a green border (as in your example) inside of the white border. Some of the padding would be automatically restored if the Edit control was multi-line. Also if multiline, you could use EM_SETRECT to set/reset the formatting rectangle.

Sorry, I wish I could be more helpful. Good luck!

timelizards
Posts: 20
Joined: 11 Sep 2015, 21:00

Re: how to remove the blue border when "Edit" is on focus?

Post by timelizards » 29 May 2016, 23:01

If you dont find a solution, i would suggest looking into HTML gui's. Specifically, the shell.explorer method that supports css3.

https://autohotkey.com/boards/viewtopic.php?t=4588

I couldnt come up with many reasons to invest time into learning ahk ( or windows ) gui formats and styles. As an amateur programmer, i found the html / css syntax much easier to pick up and manipulate. There are lots of css templates out there that might already meet your needs. Oh, and the border thing would be a non issue (so many options for borders). I recently needed a very specific border for a field on one of my applications and made my own CSS class (i know, this is nothing special, but it was my first). I dont even recall how it works anymore but whenever i need it i just call up the class.

http://www.w3schools.com/ is a great reference and helped me get off the ground quickly when i needed to start putting guis on things.

wo52616111
Posts: 47
Joined: 21 Aug 2014, 04:46

Re: how to remove the blue border when "Edit" is on focus?

Post by wo52616111 » 30 May 2016, 01:53

Thank you, jballi and timelizards !
timelizards you gave me a big help. I was just a front-end developer, I like HTML/CSS. HTML gui is wonderful, I will try it.

timelizards
Posts: 20
Joined: 11 Sep 2015, 21:00

Re: how to remove the blue border when "Edit" is on focus?

Post by timelizards » 30 May 2016, 02:17

here is some code i stripped from something ive been working on (which was mainly found on the forums). the HwndhAtlAxWin thing and the meta tag in the html document i dont think were in the orignal link i posted but i found them on the forums as well. i believe they were necessary to support the most recent css features. i left a bit in there about resizing in case you went looking for that eventually, you could probably search the forums for more on it if needed; the label is probably unchanged from wherever i found it.

meta tag in html doc

Code: Select all

<meta http-equiv="X-UA-Compatible" content="IE=edge">
ahk code - navigates to document and connects to elements

Code: Select all

guiW := 800
guiH := 600

Gui, New, +Resize +HwndMyGuiHwnd
Gui Add, ActiveX, x0 y0 w%guiW% h%guiH% vWB HwndhAtlAxWin, Shell.Explorer  ; The final parameter is the name of the ActiveX component.

WB.silent := true ;Surpress JS Error boxes

WB.Navigate("file://" . filename)

while WB.readystate != 4 or WB.busy
	sleep 10

btn1 := wb.document.getElementById("btn1")
btn2 := wb.document.getElementById("btn2")
btn3 := wb.document.getElementById("btn3")
btn4 := wb.document.getElementById("btn4")

ComObjConnect(btn1, "btn1_") ;connect button events
ComObjConnect(btn2, "btn2_")
ComObjConnect(btn3, "btn3_")
ComObjConnect(btn4, "btn4_")

Gui Show, w%guiW% h%guiH%

return

GuiSize:
    
    if ErrorLevel = 1  ; The window has been minimized.  No action needed.
        return
    
    ; Otherwise, the window has been resized or maximized. Resize the Edit control to match.
    NewWidth := A_GuiWidth
    NewHeight := A_GuiHeight
    
    GuiControl, Move, WB, W%NewWidth% H%NewHeight%
    
return

GuiClose:
ExitApp
return

btn1_OnClick() {
	global wb
    
  	;do stuffs
}


lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: how to remove the blue border when "Edit" is on focus?

Post by lexikos » 30 May 2016, 03:53

This gives just a thin white border around the Edit control, but no padding around the text:

Code: Select all

Gui, new, HwndGuiHwnd , newgui
Gui, Color, red, green
Gui, Show, Center w300 h200, ahk_id%GuiHwnd%
Gui, Add, Text, x19 y19 w152 h52 +9
Gui, Add, Edit, x20 y20 w150 h50 -Multi -Border -E0x200
This adds "padding" using an extra Edit control for the green background:

Code: Select all

Gui, new, HwndGuiHwnd , newgui
Gui, Color, red, green
Gui, Show, Center w300 h200, ahk_id%GuiHwnd%
Gui, Add, Text, x19 y19 w152 h52 +9
Gui, Add, Edit, x20 y20 w150 h50 -Multi -Border -E0x200 -Tabstop
Gui, Add, Edit, x22 y22 w146 h46 -Multi -Border -E0x200
There may be other styles listed in the help file (under "styles for GUI command") that can help.

Edit: Also, if you don't mind the classic "sunken" border style, you can just add -Theme to the Edit control's options.

wo52616111
Posts: 47
Joined: 21 Aug 2014, 04:46

Re: how to remove the blue border when "Edit" is on focus?

Post by wo52616111 » 30 May 2016, 22:47

thank you timelizards and lexikos, great help really.

Post Reply

Return to “Ask for Help (v1)”