Jump to content

Prevent focus on combo


Champak
 Share

Recommended Posts

How can I prevent focus on a combo box when a specific gui window in my app is activated? Is there something I can put in the creation of the control or GUI? I only want it to have focus when I actually click on it.

Edited by Champak
Link to comment
Share on other sites

  • Moderators

Champak,

Set the focus to another control just before displaying the GUI: :)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData($cCombo, "1|2|3")

$cButton = GUICtrlCreateButton("Focus", 10, 100, 80, 30)
; Give focus to the button
GUICtrlSetState($cButton, $GUI_FOCUS)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
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'm unable to test any suggestions right now so I'm just asking questions so I can sort this out when I get home.

michaelslamet, if I do that, won't I be unable to use the combo when I actually go to click and use it?

Melba23, that's fin on initial creation of the GUI, but when I go to another app or window and then come back won't the combo box have focus upon activation of the window?

---I'm trying to avoid putting any unnecessary/extra things in the main loop, but if that's the route I have to go, I guess I already know what I have to do.

Thanks

Link to comment
Share on other sites

  • Moderators

Champak,

Normally the control that had focus will regain it when the GUI is reactivated - certainly that is the case when I activate/reactivate the GUI created by that script. :)

You could always test for reactivation and reset the focus to whatever you wanted. That would require some code to detect the reactivation which is not that difficult to write. ;)

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...