Sign in to follow this  
Followers 0
Luigi

What's problem with this GUICtrlCreateUpDown()?

9 posts in this topic

In this script, I can limite the values for $x, it can not be <10 or > 60. Its work fine.

The $y, can't be > 60 or < $x, but here is the problem, it can!

Some one can help-me?

Thanks!

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $x, $y, $UpDownX, $UpDownY, $msg
GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX)
$x = GUICtrlCreateInput(11, 10, 10, 60, 30)
$y = GUICtrlCreateInput(11, 10, 50, 60, 30)
GUICtrlCreateLabel("x",80,10,20,20)
GUICtrlCreateLabel("y",80,50,20,20)
$UpDownX = GUICtrlCreateUpdown($x)
$UpDownY = GUICtrlCreateUpdown($y)
GUISetState()
While 1
  If GUICtrlRead($x) < 10 Then GuiCtrlSetData($x,10)
  If GUICtrlRead($x) > 60 Then GuiCtrlSetData($x,60)
  If GUICtrlRead($y) > 60 Then GuiCtrlSetData($y,60)
  If GUICtrlRead($y) < GUICtrlRead($x) Then GuiCtrlSetData($y,GUICtrlRead($x))
  $msg = GUIGetMsg()
  If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc   ;==>Example

Visit my repository

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

detefon,

Someone needs to read up on GUICtrlSetLimit! :)

Take a look at this: :rip:

#include <guiconstantsex.au3>
#include <windowsconstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()

    Local $x, $y, $UpDownX, $UpDownY, $msg

    GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX)

    $x = GUICtrlCreateInput(11, 10, 10, 60, 30)
    $UpDownX = GUICtrlCreateUpdown($x)
    GUICtrlSetLimit(-1, 60, 10)
    $y = GUICtrlCreateInput(11, 10, 50, 60, 30)
    $UpDownY = GUICtrlCreateUpdown($y)
    GUICtrlSetLimit(-1, 60, 10)
    GUICtrlCreateLabel("x", 80, 10, 20, 20)
    GUICtrlCreateLabel("y", 80, 50, 20, 20)

    GUISetState()

    While 1
        
        ; Set the limit for $y depending on $x
        GUICtrlSetLimit($UpDownY, 60, Number(GUICtrlRead($x)))
        ; And adjust $y if $x in increased
        If Number(GUICtrlRead($y)) < Number(GUICtrlRead($x)) Then
            GUICtrlSetData($y, GUICtrlRead($x))
        EndIf

        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

EndFunc   ;==>Example

Give me a moment and I will produce a sexy one which does not poll the loop. :D

M23

Edit: And here it is: :oops:

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <editconstants.au3>
#include <winapi.au3>

Opt('MustDeclareVars', 1)

Global $x, $y, $UpDownX, $UpDownY

Example()

Func Example()

    Local $msg

    GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX)

    $x = GUICtrlCreateInput(11, 10, 10, 60, 30)
    $UpDownX = GUICtrlCreateUpdown($x)
    GUICtrlSetLimit(-1, 60, 10)
    $y = GUICtrlCreateInput(11, 10, 50, 60, 30)
    $UpDownY = GUICtrlCreateUpdown($y)
    GUICtrlSetLimit(-1, 60, 10)
    GUICtrlCreateLabel("x", 80, 10, 20, 20)
    GUICtrlCreateLabel("y", 80, 50, 20, 20)

    GUISetState()

    GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

EndFunc

Func _WM_COMMAND($hWHnd, $iMsg, $wParam, $lParam)

    If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $x Then

        ; Set the limit for $y depending on $x
        GUICtrlSetLimit($UpDownY, 60, Number(GUICtrlRead($x)))
        If Number(GUICtrlRead($y)) < Number(GUICtrlRead($x)) Then
            GUICtrlSetData($y, GUICtrlRead($x))
        EndIf
    EndIf

EndFunc   ;==>WM_COMMAND
Edited by Melba23

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

Ahhhhh Melba... that is not funny!!!!!!

I thinking is problem is mega hard dificults (for me was) and you solved it in one reply! 8(

One day I have a unsolved topic with more a hundred replys... but, not today!

Thanks Melba! ^^


Visit my repository

Share this post


Link to post
Share on other sites

detefon,

Make sure you look at the second script I posted as well. :D

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

#5 ·  Posted (edited)

Hum....

For example...

If I write a main GUI, with many buttons and each button open a child GUI...

Like this...

The main GUI have:

*add user;

*add computer;

*add phone;

and more... more... more...

For each button, is opened a child GUI... And for each child GUI I have a logic's validation...

If I correct, You write above a way to validate each funcion (child GUI) out the main GUI...

Each validation's process run out the main process, and run only when the have a current secondary GUI...

It's work?

This is great for me, I am here to solve one problem, and gain another solution!

I am happy! Irrrrrrrrrrrrrrrrrrrrrrrrrruuuuuuu! ^^

Edited by detefon

Visit my repository

Share this post


Link to post
Share on other sites

detefon,

It's work?

Perhaps. It should work if you use the same variables to store the ControlIDs of the Inputs and UpDowns in each child AND you only have one child open at a time. :D

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

Melba! Everything is work fine!

But for a new UpDown does not work...

I have create a new control, Port, with limts (1024, 65535), and it show crazy values...

The limt1s value is very high to GUICtrlSetLimit or is not this?

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <editconstants.au3>
#include <winapi.au3>
Opt('MustDeclareVars', 1)
Global $x, $y, $port, $UpDownX, $UpDownY, $UpDownPort
Example()
Func Example()
    Local $msg
    GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX)
    $x = GUICtrlCreateInput(11, 10, 10, 60, 30)
    $UpDownX = GUICtrlCreateUpdown($x)
    GUICtrlSetLimit(-1, 60, 10)
    $y = GUICtrlCreateInput(11, 10, 50, 60, 30)
    $UpDownY = GUICtrlCreateUpdown($y)
    GUICtrlSetLimit(-1, 60, 10)
    GUICtrlCreateLabel("x", 80, 10, 20, 20)
GUICtrlCreateLabel("y", 80, 50, 20, 20)
GUICtrlCreateLabel("Port", 80, 90, 90, 20)
$port = GUICtrlCreateInput(1200, 10, 90, 60, 30)
$UpDownPort = GUICtrlCreateUpdown($port)
GUICtrlSetLimit(-1, 65535, 1024)
    GUISetState()
    GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc
Func _WM_COMMAND($hWHnd, $iMsg, $wParam, $lParam)
    If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $x Then
        ; Set the limit for $y depending on $x
        GUICtrlSetLimit($UpDownY, 60, Number(GUICtrlRead($x)))
        If Number(GUICtrlRead($y)) < Number(GUICtrlRead($x)) Then
            GUICtrlSetData($y, GUICtrlRead($x))
        EndIf
    EndIf
EndFunc   ;==>WM_COMMAND

Visit my repository

Share this post


Link to post
Share on other sites

detefon,

It looks as if the UpDown top limit is (surprise, surprise) 32767 - it is the signed integer limit. :D

You might have to make your own "UpDown" controls. Here is a rough idea of how to do it: :oops:

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <editconstants.au3>
#include <winapi.au3>
#include <StaticConstants.au3>
#include <Misc.au3>

;Opt('MustDeclareVars', 1)
Global $x, $y, $port, $UpDownX, $UpDownY, $UpDownPort
Example()
Func Example()
    Local $msg
    GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX)
    $x = GUICtrlCreateInput(11, 10, 10, 60, 30)
    $UpDownX = GUICtrlCreateUpdown($x)
    GUICtrlSetLimit(-1, 60, 10)
    $y = GUICtrlCreateInput(11, 10, 50, 60, 30)
    $UpDownY = GUICtrlCreateUpdown($y)
    GUICtrlSetLimit(-1, 60, 10)
    GUICtrlCreateLabel("x", 80, 10, 20, 20)
    GUICtrlCreateLabel("y", 80, 50, 20, 20)
    GUICtrlCreateLabel("Port", 80, 90, 90, 20)
    $port = GUICtrlCreateInput(65000, 10, 90, 40, 30)
    GUICtrlCreateLabel("", 50,  90, 20, 15, $SS_BLACKFRAME)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("", 50,  105, 20, 15, $SS_BLACKFRAME)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $portup = GUICtrlCreateLabel("U", 51,  91, 18, 13, $SS_CENTER)
    $portdn = GUICtrlCreateLabel("D", 51, 106, 18, 13, $SS_CENTER)
    GUISetState()
    GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
    While 1
        Switch  GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $portup
                While _IsPressed("01")
                    GUICtrlSetData($port, GUICtrlRead($port) + 1)
                    If Number(GUICtrlRead($port)) > 65535 Then
                        GUICtrlSetData($port, 65535)
                    EndIf
                    Sleep(50)
                WEnd
            Case $portdn
                While _IsPressed("01")
                    GUICtrlSetData($port, GUICtrlRead($port) - 1)
                    If Number(GUICtrlRead($port)) < 1024 Then
                        GUICtrlSetData($port, 1024)
                    EndIf
                    Sleep(50)
                WEnd
        EndSwitch
    WEnd
EndFunc   ;==>Example
Func _WM_COMMAND($hWHnd, $iMsg, $wParam, $lParam)
    If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $x Then
        ; Set the limit for $y depending on $x
        GUICtrlSetLimit($UpDownY, 60, Number(GUICtrlRead($x)))
        If Number(GUICtrlRead($y)) < Number(GUICtrlRead($x)) Then
            GUICtrlSetData($y, GUICtrlRead($x))
        EndIf
    EndIf
EndFunc   ;==>_WM_COMMAND

I know you will ask if you have any questions.... :rip:

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

Thank you Melba! You help me! ^^


Visit my repository

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