Jump to content

GUICtrlCreateUpdown & $GUI_DOCKRIGHT misbehaved


Recommended Posts

GUICtrlCreateUpdown & $GUI_DOCKRIGHT dont play along with GUICtrlSetState( CtrlCreateUpdown ,  $GUI_HIDE ).
Here is an example to shows it's misbehaviour:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=G:\au3s\SMS_lite\TestUpdownHidei.kxf
Global $idGui = GUICreate("GUI_DOCKRIGHT oops", 389, 180, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
Global $idLabel = GUICtrlCreateLabel("try OnTop and resize, the UpDown does not behave as expacted, play around, you'll see", 16, 52, 356, 100)
GUICtrlSetFont(-1, 26, 400, 0, "Lucida Console")
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
Global $idCk_KeepOnTop = GUICtrlCreateCheckbox("OnTop", 280, 12, 97, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE))
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
Global $idSetTrans = GUICtrlCreateInput("0", 200, 12, 69, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
Global $StatusBar1 = _GUICtrlStatusBar_Create($idGui)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $idSetTransUpdown = GUICtrlCreateUpdown($idSetTrans)
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlSetLimit($idSetTransUpdown, 9)
GUICtrlSetState($idSetTrans, $GUI_HIDE)
GUICtrlSetState($idSetTransUpdown, $GUI_HIDE)
GUICtrlSetState($idLabel, $GUI_FOCUS)

GUISetState(@SW_SHOW)


; this is to better show what I mean
WinMove($idGui,"",50,50,389+100,180)
_GUICtrlStatusBar_Resize($StatusBar1)
; this is to better show what I mean


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit 0

        Case $GUI_EVENT_RESIZED
            _GUICtrlStatusBar_Resize($StatusBar1)

        Case $idSetTransUpdown
            GUICtrlSetState($idLabel, $GUI_FOCUS)

        Case $idSetTrans
            GUICtrlSetState($idLabel, $GUI_FOCUS)
            If Int(GUICtrlRead($idSetTrans)) Then
                WinSetTrans($idGui, "", 255 - (Int(GUICtrlRead($idSetTrans)) * 25))
            Else
                WinSetTrans($idGui, "", 255)
            EndIf

        Case $idCk_KeepOnTop
            GUICtrlSetState($idLabel, $GUI_FOCUS)
            If GUICtrlRead($idCk_KeepOnTop) = 1 Then
                GUICtrlSetState($idSetTransUpdown, $GUI_SHOW)
                GUICtrlSetState($idSetTrans, $GUI_SHOW)
                WinSetOnTop($idGui, "", 1)
                WinSetTrans($idGui, "", 255 - (Int(GUICtrlRead($idSetTrans)) * 20))
            Else
                WinSetOnTop($idGui, "", 0)
                WinSetTrans($idGui, "", 255)
                GUICtrlSetState($idSetTrans, $GUI_HIDE)
                GUICtrlSetState($idSetTransUpdown, $GUI_HIDE)
            EndIf

    EndSwitch
WEnd

I believe not to be doing anything wrong, therefore I posted here.

If there is a workaround for this, please let me know.

And if you can open a ticket for it better, I've never done it before. I took the plunge and open a ticket for it

Thanks.

Edited by argumentum
tweak the code to better show what I would like you to observe
Link to post
Share on other sites

if I do something like:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=G:\au3s\SMS_lite\TestUpdownHidei.kxf
Global $idGui = GUICreate("GUI_DOCKRIGHT oops", 389, 180, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
Global $idLabel = GUICtrlCreateLabel("try OnTop and resize, the UpDown does not behave as expacted, play around, you'll see", 16, 52, 356, 100)
GUICtrlSetFont(-1, 26, 400, 0, "Lucida Console")
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
Global $idCk_KeepOnTop = GUICtrlCreateCheckbox("OnTop", 280, 12, 97, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE))
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
Global $idSetTrans = GUICtrlCreateInput("0", 200, 12, 69, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")
GUICtrlSetResizing($idSetTrans, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
Global $StatusBar1 = _GUICtrlStatusBar_Create($idGui)
GUISetState(@SW_HIDE)
#EndRegion ### END Koda GUI section ###

Global $idSetTransUpdown = GUICtrlCreateUpdown($idSetTrans)
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlSetLimit($idSetTransUpdown, 9)
GUICtrlSetState($idSetTrans, $GUI_HIDE)
GUICtrlSetState($idSetTransUpdown, $GUI_HIDE)
GUICtrlSetState($idLabel, $GUI_FOCUS)

GUISetState(@SW_SHOW)


; this is to better show what I mean
WinMove($idGui,"",50,50,389+100,180)
_GUICtrlStatusBar_Resize($StatusBar1)
; this is to better show what I mean

Local $i = 1
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit 0

        Case $GUI_EVENT_RESIZED
            _GUICtrlStatusBar_Resize($StatusBar1)

        Case $idSetTransUpdown
            GUICtrlSetState($idLabel, $GUI_FOCUS)

        Case $idSetTrans
            GUICtrlSetState($idLabel, $GUI_FOCUS)
            If Int(GUICtrlRead($idSetTrans)) Then
                WinSetTrans($idGui, "", 255 - (Int(GUICtrlRead($idSetTrans)) * 25))
            Else
                WinSetTrans($idGui, "", 255)
            EndIf

        Case $idCk_KeepOnTop
            GUICtrlSetState($idLabel, $GUI_FOCUS)
            If GUICtrlRead($idCk_KeepOnTop) = 1 Then
                GUICtrlSetState($idSetTrans, $GUI_SHOW)
                GUICtrlSetState($idSetTransUpdown, $GUI_SHOW)

                f_TriggerGuiResize($idGui) ; ---- dirty fix

                WinSetOnTop($idGui, "", 1)
                WinSetTrans($idGui, "", 255 - (Int(GUICtrlRead($idSetTrans)) * 20))
            Else
                WinSetOnTop($idGui, "", 0)
                WinSetTrans($idGui, "", 255)
                GUICtrlSetState($idSetTrans, $GUI_HIDE)
                GUICtrlSetState($idSetTransUpdown, $GUI_HIDE)
            EndIf
    EndSwitch
WEnd

Func f_TriggerGuiResize($idGui)
    Local $a = WinGetPos( $idGui )
    If UBound($a) = 4 Then
        WinMove($idGui,"",$a[0],$a[1],$a[2],$a[3]+1)
        WinMove($idGui,"",$a[0],$a[1],$a[2],$a[3])
    EndIf
EndFunc

f_TriggerGuiResize($idGui) triggers the $GUI_EVENT_RESIZED. Is there a DLL call to fake it, as if it actually resized ?. That would fix my problem for now until a new version comes out. 

Edited by argumentum
clarify
Link to post
Share on other sites

My grandmother has asked if you cannot place two hidden labels below the input and up-down controls, and use these labels to position the controls:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=G:\au3s\SMS_lite\TestUpdownHidei.kxf
Global $idGui = GUICreate("GUI_DOCKRIGHT oops", 389, 180, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
Global $idLabel = GUICtrlCreateLabel("try OnTop and resize, the UpDown does not behave as expacted, play around, you'll see", 16, 52, 356, 100)
GUICtrlSetFont(-1, 26, 400, 0, "Lucida Console")
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
Global $idCk_KeepOnTop = GUICtrlCreateCheckbox("OnTop", 280, 12, 97, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE))
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
Global $idSetTrans = GUICtrlCreateInput("0", 200, 12, 69, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
Global $StatusBar1 = _GUICtrlStatusBar_Create($idGui)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $idSetTransUpdown = GUICtrlCreateUpdown($idSetTrans)
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlSetLimit($idSetTransUpdown, 9)
GUICtrlSetState($idSetTrans, $GUI_HIDE)
GUICtrlSetState($idSetTransUpdown, $GUI_HIDE)
GUICtrlSetState($idLabel, $GUI_FOCUS)

$idSetTransLabel1 = GUICtrlCreateLabel( "", 200, 12, 69, 24 )
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlSetState(-1, $GUI_HIDE)

$a = ControlGetPos( $idGui, "", $idSetTransUpdown )
$idSetTransLabel2 = GUICtrlCreateLabel( "", $a[0], $a[1], $a[2], $a[3] )
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlSetState(-1, $GUI_HIDE)

GUISetState(@SW_SHOW)


; this is to better show what I mean
WinMove($idGui,"",50,50,389+100,180)
_GUICtrlStatusBar_Resize($StatusBar1)
; this is to better show what I mean


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit 0

        Case $GUI_EVENT_RESIZED
            _GUICtrlStatusBar_Resize($StatusBar1)

        Case $idSetTransUpdown
            GUICtrlSetState($idLabel, $GUI_FOCUS)

        Case $idSetTrans
            GUICtrlSetState($idLabel, $GUI_FOCUS)
            If Int(GUICtrlRead($idSetTrans)) Then
                WinSetTrans($idGui, "", 255 - (Int(GUICtrlRead($idSetTrans)) * 25))
            Else
                WinSetTrans($idGui, "", 255)
            EndIf

        Case $idCk_KeepOnTop
            GUICtrlSetState($idLabel, $GUI_FOCUS)
            If GUICtrlRead($idCk_KeepOnTop) = 1 Then
                $a = ControlGetPos( $idGui, "", $idSetTransLabel2 )
                GUICtrlSetPos( $idSetTransUpdown, $a[0], $a[1], $a[2], $a[3] )
                GUICtrlSetState($idSetTransUpdown, $GUI_SHOW)
                $a = ControlGetPos( $idGui, "", $idSetTransLabel1 )
                GUICtrlSetPos( $idSetTrans, $a[0], $a[1], $a[2], $a[3] )
                GUICtrlSetState($idSetTrans, $GUI_SHOW)
                WinSetOnTop($idGui, "", 1)
                WinSetTrans($idGui, "", 255 - (Int(GUICtrlRead($idSetTrans)) * 20))
            Else
                WinSetOnTop($idGui, "", 0)
                WinSetTrans($idGui, "", 255)
                GUICtrlSetState($idSetTrans, $GUI_HIDE)
                GUICtrlSetState($idSetTransUpdown, $GUI_HIDE)
            EndIf

    EndSwitch
WEnd

It's also my grandmother's opinion that the 3215-bug, could well be one of the bugs that are never solved (and it's not a big deal since there are so easy workarounds).

Link to post
Share on other sites
7 hours ago, LarsJ said:

My grandmother has asked if you cannot place two hidden labels below the input and up-down controls, and use these labels to position the controls:

Thanks for the answer. In that same route, I decided, might as well delete the controls and recreate 'em when needed. Again, thanks, this workaround did not come to my mind, at all.

Link to post
Share on other sites

Try it this way:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=G:\au3s\SMS_lite\TestUpdownHidei.kxf
Global $idGui = GUICreate("GUI_DOCKRIGHT oops", 389, 180, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
Global $idLabel = GUICtrlCreateLabel("try OnTop and resize, the UpDown does not behave as expacted, play around, you'll see", 16, 52, 356, 100)
GUICtrlSetFont(-1, 26, 400, 0, "Lucida Console")
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
Global $idCk_KeepOnTop = GUICtrlCreateCheckbox("OnTop", 280, 12, 97, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE))
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
Global $idSetTrans = GUICtrlCreateInput("0", 200, 12, 69, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
Global $StatusBar1 = _GUICtrlStatusBar_Create($idGui)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $idSetTransUpdown = GUICtrlCreateUpdown($idSetTrans)
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlSetLimit($idSetTransUpdown, 9)
GUICtrlSetState($idSetTrans, $GUI_HIDE)
GUICtrlSetState($idSetTransUpdown, $GUI_HIDE)
GUICtrlSetState($idLabel, $GUI_FOCUS)

GUISetState(@SW_SHOW)


; this is to better show what I mean
WinMove($idGui, "", 50, 50, 389 + 100, 180)
_GUICtrlStatusBar_Resize($StatusBar1)
; this is to better show what I mean

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit 0

        Case $GUI_EVENT_RESIZED
            _GUICtrlStatusBar_Resize($StatusBar1)
            _MoveIdTrans()
        Case $idSetTransUpdown
            GUICtrlSetState($idLabel, $GUI_FOCUS)

        Case $idSetTrans
            GUICtrlSetState($idLabel, $GUI_FOCUS)
            If Int(GUICtrlRead($idSetTrans)) Then
                WinSetTrans($idGui, "", 255 - (Int(GUICtrlRead($idSetTrans)) * 25))
            Else
                WinSetTrans($idGui, "", 255)
            EndIf

        Case $idCk_KeepOnTop
            GUICtrlSetState($idLabel, $GUI_FOCUS)
            If GUICtrlRead($idCk_KeepOnTop) = 1 Then
                _MoveIdTrans()
                GUICtrlSetState($idSetTransUpdown, $GUI_SHOW)
                GUICtrlSetState($idSetTrans, $GUI_SHOW)
                WinSetOnTop($idGui, "", 1)
                WinSetTrans($idGui, "", 255 - (Int(GUICtrlRead($idSetTrans)) * 20))
            Else
                WinSetOnTop($idGui, "", 0)
                WinSetTrans($idGui, "", 255)
                GUICtrlSetState($idSetTrans, $GUI_HIDE)
                GUICtrlSetState($idSetTransUpdown, $GUI_HIDE)
            EndIf

    EndSwitch
WEnd

Func _MoveIdTrans()
    Local $aButton = ControlGetPos($idGui, '', $idCk_KeepOnTop)
    Local $aTrans = ControlGetPos($idGui, '', $idSetTrans)
    ControlMove($idGui, '', $idSetTrans, $aButton[0] - 80, $aButton[1])
    ControlMove($idGui, '', $idSetTransUpdown, $aButton[0] - 80+$aTrans[2] , $aButton[1])
EndFunc   ;==>_MoveIdTrans

 

Link to post
Share on other sites
  • 4 years later...

To all interested:
The issue reported by @argumentum is fixed by @jpm

https://www.autoitscript.com/trac/autoit/ticket/3215

The only one thing you should to do is to wait patiently for the fix to be approved and released in one of the next beta or final versions.

Please don't ask when it will be, I will answer right away   ..... when the right person has enough free time for it.

 

Signature beginning:
Please remember: "AutoIt".....  Wondering who uses AutoIt and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-03-17

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...