Jump to content
Sign in to follow this  
Jdub

Problem with input box

Recommended Posts

Jdub

A stupid issue this I expect. When I run this script how do I get the cursor to return to the input box after the calculate button or clear button is pressed? When I run this the focus seems elsewhere and even clicking in the input box only works if you click at a particular point. What am I doing wrong?

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode 
$mainwindow = GUICreate("Window1", 310, 295)

$displaytext1 = ("")
GUICtrlSetFont (-1,11)
$monthly = GUICtrlCreateInput("",110,40,90,30, $ES_RIGHT)
GUICtrlSetFont (-1,14)
$CalcButton  = GUICtrlCreateButton("Calculate", 10, 80, 80, 20, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent($CalcButton, "CalcButton")
$ExitButton = GUICtrlCreateButton("Exit", 190, 80, 80, 20)
GUICtrlSetOnEvent($ExitButton, "ExitButton")
$ClearButton = GUICtrlCreateButton("Clear", 100, 80, 80, 20)
GUICtrlSetOnEvent($ClearButton, "ClearButton")
GuiCtrlCreateTab(5, 125, 300, 160)

GUISetState(@SW_SHOW)


While 1
  Sleep(1000)  ; Idle around
WEnd


Func CalcButton()
    $msg = GUIGetMsg()
    $text = GUICtrlRead($monthly)
    $displaytext1 = ("£" & $text & " entered... ")

    $result1 = GUICtrlCreateLabel($displaytext1, 10, 130, 280)
    GUICtrlSetFont (-1,10)
    GUICtrlSetColor(-1,0x2e8b57)    ; Sea Green
    GUICtrlSetBkColor(-1,0xFFFFFF)

    GUISetState(@SW_SHOW)

EndFunc

Func CLOSEClicked()
  Exit
EndFunc

Func ClearButton()
    $msg = GUIGetMsg()
    $text = ""
    $displaytext1 = ""

    $result1 = GUICtrlCreateLabel($displaytext1, 10, 130, 280)
    GUICtrlSetFont (-1,10)
    GUICtrlSetColor(-1,0x2e8b57)    ; Sea Green
    GUICtrlSetBkColor(-1,0xFFFFFF)

    GUISetState(@SW_SHOW)

EndFunc

Func ExitButton()
  Exit
EndFunc

Share this post


Link to post
Share on other sites
RodT

At the end of your CalcButton and ClearButton functions, add "GUICtrlSetState($monthly, $GUI_FOCUS)".

Also, just before that, in ClearButton, you may want to add "GUICtrlSetData($monthly, "")". That will clear the control.

Share this post


Link to post
Share on other sites
z0mgItsJohn

Whats The Problem Can You Give More Detail? And What Is This Program Supposed To Do? If You Would Like So Better Help Add Me On Msn xD [Maxell225@Hotmail.Com]


Latest Projects :- New & Improved TCP Chat

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  

×