Jump to content

Set input control as default in GUI


mtmartis
 Share

Recommended Posts

I would like the default active control to be my input control, it's defaulting to the Connect Button, any suggestions?

#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#include <GuiIPAddress.au3>

Global $Info

$Form1_1 = GUICreate("Connect", 381, 144, -1, -1)

$Img_Header = GUICtrlCreatePic(@ScriptDir & "\Header.bmp", 0, 0, 381, 63, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Label1 = GUICtrlCreateLabel("IP Address :", 8, 80, 88, 20)

GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

$Connect = GUICtrlCreateButton("Connect", 110, 113, 75, 25, 0)

$Cancel = GUICtrlCreateButton("Cancel", 190, 113, 75, 25, 0)

$Clear = GUICtrlCreateButton("Clear IP", 280, 77, 75, 25, 0)

$IPAddress1 = _GUICtrlIpAddress_Create($Form1_1, 110, 80, 155, 21)

_GUICtrlIpAddress_Set($IPAddress1, "")

$IP = _GUICtrlIpAddress_Get($IPAddress1)

Pointer()

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Connect

MsgBox(0,'',$IP)

Case $Cancel

Exit

Case $Clear

_GUICtrlIpAddress_ClearAddress($IPAddress1)

Case $Info

SplashTextOn("Technical Support","Support Info","300","75","-1","-1",6,"Courier New","10","700")

Sleep(4000)

SplashOff()

EndSwitch

WEnd

Func Pointer()

$Info = GUICtrlCreateLabel("í", 360, 120, 20, 20)

GUICtrlSetFont(-1, 16, 800, 0, "Times New Roman")

GUICtrlSetColor(-1, 0x000080)

GUICtrlSetCursor(-1,0)

GUISetState(@SW_SHOW)

EndFunc

Link to comment
Share on other sites

  • Moderators

mtmartis,

Add _WinAPI_SetFocus($IPAddress1) once the control is created. ;)

M23

P.S. When you post code please use Code tags and not quotes. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button. :)

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

ControlFocus is what I would use... I like to use the internal functions where possible.

Melba... The blue button is a pain - I wish it would be like the code button instead. When you edit in place it only gives me a single line input, and I lose all my line breaks. When it does work it puts the text at the top rather than at the caret. Maybe It's just me but I always add them manually now.

Link to comment
Share on other sites

  • Moderators

Mat,

You are right about the blue button - I always put the tags in manually as well. But some people seem unable to grasp the whole "tag" concept. ;)

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

  • Moderators

somdcomputerguy,

GUICtrlSetState will not work here because _GUICtrlIpAddress_Create returns a handle and not a ControlID. ;)

As a general rule, the GUICtrl* commands only work on controls created by the built-in GUICtrlCreate* functions as they require the internal AutoIt ControlIDs as parameters.

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've used this function, GUICtrlSetState, to do that.

Edit: I add the autoit tags manually too, because of that 'one-liner' thing..

IP address is a non standard control (needs include) that means you won't be able to use that function in this case.

Edit: Melba... How are you so fast? You always beat me to the reply button.

Edited by Mat
Link to comment
Share on other sites

I didn't fully read the OP's code, so that's the excuse for my fault this time.. I should've realized that when you two posted (M23 and Mat), there was probably a good reason why that particular function wasn't being used.. Oh well, another lesson learned.. ;)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

mtmartis,

Add _WinAPI_SetFocus($IPAddress1) once the control is created. ;)

M23

P.S. When you post code please use Code tags and not quotes. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button. :)

Tnx Melba, that was exactly what I was looking for!

Sorry about posting code in quotes, that's what I get for posting with a migraine! lol

Link to comment
Share on other sites

I didn't fully read the OP's code, so that's the excuse for my fault this time.. I should've realized that when you two posted (M23 and Mat), there was probably a good reason why that particular function wasn't being used.. Oh well, another lesson learned.. :)

The $IPAddress1 in Melba's snippet gave it away for me... I didn't look at the OP's code either ;)

Link to comment
Share on other sites

  • Moderators

Mat,

I didn't look at the OP's code either

;)

:)

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