Sign in to follow this  
Followers 0
wyzzard

[Solved] Input box focus question

6 posts in this topic

#1 ·  Posted (edited)

I'm working on a GUI to get inventory codes to order and I have something that works okay but you have to hit the TAB key to move from box to box. Since all the boxes have to have numbers it would be nice if they could hit the ENTER key on the NUMPAD and it would go to next box as well.

Here's the GUI snippet of what I have so far -

#include <String.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

HotKeySet("{ESC}", "Terminate")

$frmOrder = GUICreate("Items Needed", 460, 450, -1, -1)
GUISetFont(12, 800, 0, "MS Sans Serif")
$butIssue = GUICtrlCreateButton("Issue", 70, 370, 80, 50)
$butXFER = GUICtrlCreateButton("Transfer", 190, 370, 80, 50)
$butCancel = GUICtrlCreateButton("Cancel", 310, 370, 80, 50)
$lblJob = GUICtrlCreateLabel("   Job #", 55, 35, 100, 28)
$lblPSID = GUICtrlCreateLabel("  PSID", 180, 35, 100, 28)
$lblQty = GUICtrlCreateLabel(" Quantity", 305, 35, 100, 28)
$chkRush = GUICtrlCreateCheckbox("", 195, 315, 17, 28)
GUICtrlSetState(-1, $GUI_UNCHECKED)
$lblRush = GUICtrlCreateLabel("RUSH", 215, 318, 75, 28)
GUICtrlSetColor(-1, 0xeb0f0f) ; Red

Local $arrInputBox [5] [4]
Local $arrLineLabel [5]
Global $intActiveSet = 0

For $intSet = 0 To 4
$arrLineLabel [$intSet] =GUICtrlCreateLabel($intSet + 1, 25, 65 + (50 * $intSet), 15, 28)
For $intPart = 0 to 2
$arrInputBox [$intSet] [$intPart] = GUICtrlCreateInput("", 55 + (125 * $intPart), 65 + (50 * $intSet), 100, 28, $ES_NUMBER)
If $intSet > 0 Then
GUICtrlSetState($arrInputBox [$intSet] [$intPart], $GUI_DISABLE)
EndIf
Next
Next

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam)
If _WinAPI_HiWord($wParam) = $EN_CHANGE Then
If $intActiveSet > 0 Then
If (GUICtrlRead($arrInputBox [$intActiveSet] [0]) = "" And GUICtrlRead($arrInputBox [$intActiveSet] [1]) = "" And GUICtrlRead($arrInputBox [$intActiveSet] [2]) = "") And (GUICtrlRead($arrInputBox [$intActiveSet-1] [0]) = "" Or GUICtrlRead($arrInputBox [$intActiveSet] [1]) = "" Or GUICtrlRead($arrInputBox [$intActiveSet] [2]) = "") Then
For $intStep = 0 To 2
GUICtrlSetState($arrInputBox [$intActiveSet] [$intStep],$GUI_DISABLE)
Next
$intActiveSet -= 1
EndIf
EndIf
If (GUICtrlRead($arrInputBox [$intActiveSet] [0]) <> "" And GUICtrlRead($arrInputBox [$intActiveSet] [1]) <> "" And GUICtrlRead($arrInputBox [$intActiveSet] [2]) <> "") Then
If $intActiveSet < 4 Then
$intActiveSet += 1
For $intStep = 0 To 2
GUICtrlSetState($arrInputBox [$intActiveSet] [$intStep],$GUI_ENABLE)
Next
EndIf
EndIf
EndIf
EndFunc ;==>WM_COMMAND

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Terminate()
Case $butCancel
Terminate()
EndSwitch
WEnd

Func Terminate()
Exit 0
EndFunc ;==>Terminate

I found the WM_COMMAND function on the forum here to help me figure out part of what I was doing to prevent the next row of boxes being enabled until the top is filled in but haven't quite figured out how to capture the ENTER key input to make it move the focus to the next control.

Any suggestions?

Edited by wyzzard

Share this post


Link to post
Share on other sites



wyzzard,

how to capture the ENTER key input to make it move the focus to the next control

You should find the answer in this post. Please ask if you have any questions. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

That's exactly what I needed.

Thanks

I've found lots of useful tidbits when I do searches in the forum but I still have trouble actually finding what I really was looking for. Haven't quite figured out what the best search terms to use yet for a given need.

Share this post


Link to post
Share on other sites

One more quick question -

How do I edit the topic heading so I can put [sOLVED] in it? I've seen other topics where this is done but haven't found a way to edit it myself unless I'm missing the obvious.This will let others looking for something similar know that an answer is contained within.

Thanks again for the help

Share this post


Link to post
Share on other sites

wyzzard,

Haven't quite figured out what the best search terms to use yet for a given need

Neither have I - but I do have a good memory and a lot of my own posts to use as a basis for searching. :D

How do I edit the topic heading so I can put [sOLVED] in it?

I take it a "+solved +title +add" search did not work for you? :huh:

Edit the first post of the thread and select the "Use Full Editor" option - then you can edit the title as well. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

I didn't actually search about the [solved] question because I thought I had read somewhere that you couldn't change it until you had some unknown number of posts made... :)

and since the default posting interface did everything I was needing to do I never thought to click on the option :ermm:

probably would help more if I wasn't perusing these forums in the wee hours of the morning here most of the time when I'm not fully awake

Thanks again

Share this post


Link to post
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
Sign in to follow this  
Followers 0