Jump to content

Is there a UDF for touchscreen-enabled large inputbox ?


Myicq
 Share

Recommended Posts

I am developing a few apps that will run on a touch screen.

Part of this will be asking operator for values. I do not want to use a regular inputbox(), and at the same time, I would like to have different options for input.. sometimes I need number-only, other times a date etc.

This leads me to two questions

  • Does such project (or similar) exist ? I don't want to re-invent the wheel, and I could not directly find it by search.
  • In general, is there an example that shows "open child window and get return value on close"

I am not asking for someone to do this for me, I can program this myself. And if the project does not exist, I may create my own little UDF for similar.

I created a 10 min. mockup.

Cheers.

post-59882-0-62591700-1360318749_thumb.p

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
Share on other sites

Part of this will be asking operator for values. I do not want to use a regular inputbox(), and at the same time, I would like to have different options for input.. sometimes I need number-only, other times a date etc.

I have created a simple example which only accepts number characters. (with sign and dot)

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)

#region GUI
Global $GUI, $tbMyInput

$GUI = GUICreate("MyGUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetFont(17)

$tbMyInput = GUICtrlCreateInput("", 20, 20, 360, 30, $ES_AUTOHSCROLL)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW, $GUI)
#endregion

While 1
Sleep(1000)
WEnd

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $iIDFrom, $iCode

    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word

Switch $iIDFrom
Case $tbMyInput
            Switch $iCode
                Case $EN_CHANGE
GUICtrlSetData($tbMyInput, StringRegExpReplace(GUICtrlRead($tbMyInput), "[^0-9\.\-]", ""))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _Exit()
Exit
EndFunc

Br, FireFox.

Link to comment
Share on other sites

Firefox

I have created a simple example which only accepts number characters. (with sign and dot)

Thanks for this, your code works.. can you point me in direction of having a 2nd child window pop up and return value to main window ?

This is the part I struggle with.

My idea was to have a keyboard for touch, no physical kdb. present.

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
Share on other sites

having a 2nd child window pop up and return value to main window ?

I don't understand what you mean.

Maybe this?

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)

#region GUI
Global $GUI, $lMyLabel

$GUI_Main = GUICreate("MyGUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetFont(17)

$lMyLabel = GUICtrlCreateLabel("", 20, 20, 360, 30)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW, $GUI_Main)
#endregion GUI

#region ChildGUI
Global $GUI_Child, $tbMyInput

$GUI_Child = GUICreate("MyGUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetFont(17)

$tbMyInput = GUICtrlCreateInput("", 20, 20, 360, 30, $ES_AUTOHSCROLL)

GUISetState(@SW_SHOW, $GUI_Child)
#endregion

While 1
Sleep(1000)
WEnd

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
Local $iIDFrom, $iCode

$iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
$iCode = BitShift($iwParam, 16) ; Hi Word

Switch $iIDFrom
Case $tbMyInput
Switch $iCode
Case $EN_CHANGE
Local $sInputData = StringRegExpReplace(GUICtrlRead($tbMyInput), "[^0-9\.\-]", "")

GUICtrlSetData($tbMyInput, $sInputData)
GUICtrlSetData($lMyLabel, $sInputData)
EndSwitch
EndSwitch

Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _Exit()
Exit
EndFunc   ;==>_Exit

Br, FireFox.

Link to comment
Share on other sites

Firefox,

coming back to this one..

In a very primitive way, something like this:

#include <WindowsConstants.au3>

$Gui = GUICreate('My program', 450, 250, 300, 300)
$MsgBox = GUICtrlCreateButton("Button", 20, 20, 90, 30)
$txt = GUICtrlCreateLabel("", 20, 90, 400, 40)
GUICtrlSetFont(-1, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $MsgBox
            $r = _MsgBox()
            GUICtrlSetData($txt, $r)
        Case -3
            Exit
    EndSwitch
WEnd

Func _MsgBox()

    $Gui1 = GUICreate('Message', 300, 300, 300, 300, $WS_CAPTION + $WS_SYSMENU + $WS_POPUP, -1, $Gui)
    GUICtrlCreateLabel('Return a value', 20, 10, 180, 23)
    $returnval = GUICtrlCreateButton('click me', 220, 40, 80, 22)
    $inputbox = GUICtrlCreateInput("", 10, 80, 220, 22)
    GUICtrlSetData(-1, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC)
    GUISetState(@SW_SHOW, $Gui1)
    While 1
        Switch GUIGetMsg()
            Case $returnval
                $myval = GUICtrlRead($inputbox)
                GUISetState(@SW_ENABLE, $Gui)
                GUIDelete($Gui1)
                return ($myval)
                ;ExitLoop
            Case -3
                GUISetState(@SW_ENABLE, $Gui)
                GUIDelete($Gui1)
                return ("")
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_MsgBox

Only, the child form should be modal (should be no problem).

Child form should have different looks depending on need, see my mockup in first post.

This is the kind of functionality I would imagine would already exist as UDF. If not, I have a hole to fill :)

I am just a hobby programmer, and nothing great to publish right now.

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