Jump to content

Broken lines surrounding my GUI controls


Info
 Share

Recommended Posts

I don't think autoit actually makes the dotted lines when you select it. There may be a windows option to turn that off, I'm not sure.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

How can I remove these broken lines?

The best way I've seen so far is here.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

martin, I'm not talking only about sliders >_<

Isn't it just more odf the same?

;by aec after suggestion by siao
;http://www.autoitscript.com/forum/index.php?s=&showtopic=53986&view=findpost&p=516869
#include <GuiConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GuiSlider.au3>

$Gui = GUICreate("Subclassed Slider without Focus Border", 300, 200)
$Vertical_Label = GUICtrlCreateLabel("Vertical Slider Read: 0", 20, 15, 200)
$Horizontal_Label = GUICtrlCreateLabel("Horizontal Slider Read: 0", 80, 120, 200)
$Vertical_Slider = GUICtrlCreateSlider(20, 50, 30, 120, BitOr($GUI_SS_DEFAULT_SLIDER, $TBS_VERT))
$Horizontal_Slider = GUICtrlCreateSlider(60, 150, 160, 30)
$Btn = GUICtrlCreateButton("abcdef",100,30,80,80)
; Register callback function and obtain a handle to the new slider WindowProc
$hNewSliderProc = DllCallbackRegister("_NoFocusBorderWindowProc", "int", "hwnd;uint;wparam;lparam")
; Get a pointer to the new WindowProc
$pNewSliderProc = DllCallbackGetPtr($hNewSliderProc)

; Subclass horizontal slider and retrieve a pointer to the original slider WindowProc
$pOriginalSliderProc = _WinSubclass(GUICtrlGetHandle($Horizontal_Slider), $pNewSliderProc)



; Subclass vertical slider
_WinSubclass(GUICtrlGetHandle($Vertical_Slider), $pNewSliderProc)

$hNewSliderProc = DllCallbackRegister("_NoFocusBorderWindowProc", "int", "hwnd;uint;wparam;lparam")
; Get a pointer to the new WindowProc
$pNewSliderProc = DllCallbackGetPtr($hNewSliderProc)


$pOriginalButProc = _WinSubclass(GUICtrlGetHandle($Btn), $pNewSliderProc)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GuiDelete($Gui)
            ; Free
            DllCallBackFree($hNewSliderProc)
            Exit
    EndSwitch
WEnd


Func _NoFocusBorderWindowProc($hWnd, $uiMsg, $wParam, $lParam)
    ;handle setfocus
    If $uiMsg = $WM_SETFOCUS Then Return 0

    if $hWnd = GUICtrlGetHandle($Btn)  Then
     Return _WinAPI_CallWindowProc($pOriginalButProc, $hWnd, $uiMsg, $wParam, $lParam)
    EndIf


        ;other messages are handled with the original slider proc
    Return _WinAPI_CallWindowProc($pOriginalSliderProc, $hWnd, $uiMsg, $wParam, $lParam)
EndFunc

Func _WinSubclass($hWnd, $pNewWindowProc)
    Local $a_res
   ;$GWL_WNDPROC = -4
    $a_res = DllCall("user32.dll", "ptr", "SetWindowLong", "hwnd", $hWnd, "int", -4, "ptr", $pNewWindowProc)

    If @error Then Return SetError(1, 0, 0)
    If $a_res[0] = 0 Then Return SetError(1, 0, 0)
    Return $a_res[0]
EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

Hi all,

I have been playing around with this problem since I came across this topic. While accepting that the subclassing method works (once I worked out what was going on :D !), I wondered if there there was a simpler solution.

Using the code below, I have found that, on my machine at least, I can prevent these annoying focus lines from around sliders - as long as there is a Button in the GUI. For me (in both SciTE and compiled forms) the code works as follows (unwanted controls merely commented out):

Label, Button and Edit created = no focus lines on sliders

Label and Button created = no focus lines on sliders

Label and Edit created = focus lines on sliders

Button and Edit created = no focus lines on sliders

Only Label created = focus lines on sliders

Only Button created = no focus lines on sliders

Only Edit created = focus lines on sliders

No other controls created = focus lines on sliders

#include <GuiConstants.au3>
#include <GuiSlider.au3>

$Gui = GUICreate("Slider Focus Border Demo", 300, 200)

$hLabel = GUICtrlCreateLabel("I cannot take focus",    160,  30, 100, 20)
$hButton = GUICtrlCreateButton("But I can!",           160,  70,  80, 30)
$hEdit = GUICtrlCreateEdit("But I can too and I fail!", 60, 120, 200, 20)

$hVertical_Slider = GUICtrlCreateSlider(  10,  10,  30, 120, BitOr($GUI_SS_DEFAULT_SLIDER, $TBS_VERT))
$hHorizontal_Slider = GUICtrlCreateSlider(60, 150, 180,  30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Would someone else be kind enough to try the code and see if they get the same results?

And perhaps someone could even explain why this happens? :D I initially guessed it was because the Button could take focus (hence the text on the Label and Button) but I thought I ought to experiment a bit further and try another "focusable" control. I was very surprised when the Edit control did not act in the same manner as the Button.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi all,

I have been playing around with this problem since I came across this topic. While accepting that the subclassing method works (once I worked out what was going on :D !), I wondered if there there was a simpler solution.

Using the code below, I have found that, on my machine at least, I can prevent these annoying focus lines from around sliders - as long as there is a Button in the GUI. For me (in both SciTE and compiled forms) the code works as follows (unwanted controls merely commented out):

Label, Button and Edit created = no focus lines on sliders

Label and Button created = no focus lines on sliders

Label and Edit created = focus lines on sliders

Button and Edit created = no focus lines on sliders

Only Label created = focus lines on sliders

Only Button created = no focus lines on sliders

Only Edit created = focus lines on sliders

No other controls created = focus lines on sliders

#include <GuiConstants.au3>
#include <GuiSlider.au3>

$Gui = GUICreate("Slider Focus Border Demo", 300, 200)

$hLabel = GUICtrlCreateLabel("I cannot take focus",    160,  30, 100, 20)
$hButton = GUICtrlCreateButton("But I can!",           160,  70,  80, 30)
$hEdit = GUICtrlCreateEdit("But I can too and I fail!", 60, 120, 200, 20)

$hVertical_Slider = GUICtrlCreateSlider(  10,  10,  30, 120, BitOr($GUI_SS_DEFAULT_SLIDER, $TBS_VERT))
$hHorizontal_Slider = GUICtrlCreateSlider(60, 150, 180,  30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Would someone else be kind enough to try the code and see if they get the same results?

And perhaps someone could even explain why this happens? :D I initially guessed it was because the Button could take focus (hence the text on the Label and Button) but I thought I ought to experiment a bit further and try another "focusable" control. I was very surprised when the Edit control did not act in the same manner as the Button.

M23

With your example I get focus lines on the button and the sliders. The lines around sliders can be covered up with little blank labels but the subclassing method is the only way I know how to prevent the broken lines on a button. (Known since I tried it for the post above.)

@Yashied. What does compiling do? I tried and it made no difference for me.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

martin,

Thanks for trying. How interesting that you get the focus lines regardless of the controls present :D . I wonder if it is a function of the OS? I am running Vista with 'Windows Vista Basic' as the colour scheme. I get the same results with 3.3.0.0 and 3.3.1.1 so I doubt it is the Autoit version.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

a lil somethin i threw together

#include "guiconstants.au3"
$gui = guicreate("test")
$b = GUICtrlCreateButton("button",100,100,100,50)
$b2 = GUICtrlCreateButton("button2",200,200,100,50)
$dummy = guictrlcreatelabel("",0,0)
GUISetState()
ControlFocus($gui,"",$dummy)
while 1
    $m = GUIGetMsg()
    Switch $m
        Case $gui_event_close
            Exit
        Case $b
            MsgBox(0,"","",0,$gui)
            ControlFocus($gui,"",$dummy)
        case $b2
            ControlFocus($gui,"",$dummy)
    EndSwitch
WEnd
Link to comment
Share on other sites

  • Moderators

suirad,

A nice idea which works well for things like buttons, but try this version with sliders:

#include "guiconstants.au3"
$gui = guicreate("test")
$s1 = GUICtrlCreateSlider(100,100,100,50)
$s2 = GUICtrlCreateSlider(200,200,100,50)
$dummy = guictrlcreatelabel("",0,0)
GUISetState()
ControlFocus($gui,"",$dummy)
while 1
    $m = GUIGetMsg()
    Switch $m
        Case $gui_event_close
            Exit
        Case $s1
            ControlFocus($gui,"",$dummy)
        case $s2
            ControlFocus($gui,"",$dummy)
    EndSwitch
WEnd

I get the focus lines while the mouse is moving the sliders. Sliders seem to be the worst affected because the focus lines appear in a "blank" area around the control.

If the label is replaced with a button, I get no focus lines (as I would expect from my earlier tests) - is it the same for you? What OS and AutoIt version do you use? Grateful for any feedback.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Label, Button and Edit created = no focus lines on sliders

Label and Button created = no focus lines on sliders

Label and Edit created = focus lines on sliders

Button and Edit created = no focus lines on sliders

Only Label created = focus lines on sliders

Only Button created = no focus lines on sliders

Only Edit created = focus lines on sliders

No other controls created = focus lines on sliders

I got exactly the same results as you on all of the following:

Win XP SP3 using the default XP theme.

Vista SP2 using the default Aero theme.

Win 7 using the default Aero theme.

Link to comment
Share on other sites

  • Moderators

bolthead,

Thanks for taking the time to try it out. I think we might need to get a Dev interested here :D .

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

No problem, it was a welcome break from what I was doing.

I see that even a hidden button in the form prevents the slider focus lines.

#include <GuiConstants.au3>
#include <GuiSlider.au3>

$Gui = GUICreate("Slider Focus Border Demo", 300, 200)

;$hLabel = GUICtrlCreateLabel("I cannot take focus",    160,  30, 100, 20)
GUICtrlCreateButton("", 0, 0)
GUICtrlSetState(-1, $GUI_HIDE)
;$hButton = GUICtrlCreateButton("But I can!",           160,  70,  80, 20)
;$hEdit = GUICtrlCreateEdit("But I can too and I fail!", 60, 100, 200, 20, 0)

$hVertical_Slider = GUICtrlCreateSlider(  10,  10,  30, 120, BitOr($GUI_SS_DEFAULT_SLIDER, $TBS_VERT))
$hHorizontal_Slider = GUICtrlCreateSlider(60, 150, 180,  30)


GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

@Info can you post the script you used to create the GUI in your pictures? I’m interested to see what styles you are using.

Link to comment
Share on other sites

  • Moderators

bolthead,

Yes, I found the same thing - it is what I have been using in the past to prevent the focus lines.

However, further experimentation has thrown up another twist. As long as you only use the mouse put focus onto a control, the focus lines do not appear - but once you have used the TAB key to change the focus, the blasted things show up on all controls from then on until you restart the script. Even though the TAB does not actually move the focus to the sliders, the lines turn up when you use the mouse to select them later. :D

Seems like martin's subclassing method is the only way to go - that really does remove the focus lines regardless of how the focus is changed. It seems a pity that there is not an easier way to do it! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I use a method that seems to work for me when I don't want focus to jump to an input box on a GUI with no buttons. It may also work here.

Create a blank label at the bottom left corner (or any place really) and set the focus to that.

$Lbl_Blank = GUICtrlCreateLabel("", $Gw-15, $Gh-15, 15, 15)

GUICtrlSetState($Lbl_Blank, $GUI_FOCUS)
GUISetState()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • Moderators

GEOSoft,

Thanks for that suggestion. It is basically what bolthead and I were doing with our hidden buttons and it works well as long as you only use the mouse - but it does not prevent the lines returning around the sliders once the dreaded TAB button is used. I have spent the last hour or so "happily" incorporating martin's Subclassing code into my script and after a bit of tweaking it now behaves as I want - no focus lines ever on my sliders.

It looks as if the hobbyist coders are beaten on this one - no simple solution! Unless anyone else knows different...... Where is Valuater when you need him? He comes up with some very good workarounds :D .

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...