Jump to content
Sign in to follow this  
martin

GuiCtrlSetResizing possible bug

Recommended Posts

martin

GuiCtrlSetResizing should set how a control is resized when the parent window is resized. It appears not to override the globally set resizing method for graphic controls.

Here is an example which looks to me like a bug.

#include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 Opt("GuiREsizeMode", $GUI_DOCKALL)

 $gui = GUICreate("graphic resizing",-1,-1,-1,-1,BitOr($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX))

 $btn = GUICtrlCreateButton("button",30,50,80,22)
 GUICtrlSetResizing(-1, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKWIDTH, $GUI_DOCKLEFT, $GUI_DOCKBOTTOM))
 
 $g1 = GUICtrlCreateGraphic(50,120,100,100)
 GUICtrlSetBkColor(-1,0xffffff)
 GUICtrlSetResizing(-1, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKWIDTH, $GUI_DOCKLEFT, $GUI_DOCKBOTTOM))
 
GUISetState()
 
 while GUIGetMsg() <> -3
 WEnd

Can someone confirm?

I am using production version 3.3.0.0

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Authenticity

It seems like there is a collision or conflict between the "GuiResizeMode" option and the GUICtrlSetResizing function. If you drop the Opt call and use GUICtrlSetResizing(-1, $GUI_DOCKALL) on both, then it seems to function correctly.

Share this post


Link to post
Share on other sites
Quual

At first I thought it was because you used bitor for joining the $gui_dock vars, I have always just added them, Took me a minute to realize in this case they produce same result. lol

If BitOr($GUI_DOCKHEIGHT, $GUI_DOCKWIDTH, $GUI_DOCKLEFT, $GUI_DOCKBOTTOM) = $GUI_DOCKHEIGHT + $GUI_DOCKWIDTH + $GUI_DOCKLEFT + $GUI_DOCKBOTTOM Then MsgBox(0,'','Yep they be equal')

And yes I experienced same results as both of you.

Share this post


Link to post
Share on other sites
martin

At first I thought it was because you used bitor for joining the $gui_dock vars, I have always just added them, Took me a minute to realize in this case they produce same result. lol

If BitOr($GUI_DOCKHEIGHT, $GUI_DOCKWIDTH, $GUI_DOCKLEFT, $GUI_DOCKBOTTOM) = $GUI_DOCKHEIGHT + $GUI_DOCKWIDTH + $GUI_DOCKLEFT + $GUI_DOCKBOTTOM Then MsgBox(0,'','Yep they be equal')

And yes I experienced same results as both of you.

Thank you Authenticity and Quual, I have reported it as a bug (ticket #931)

@Quual

You need to change the way you deal with values which give styles or characteristics. It is true that adding often gives the same result as oring but you should never add values even though you will see many people doing that and even in the help file.

This is an example of where it makes no difference

BitOr($GUI_DOCKRIGHT,$GUI_DOCKHEIGHT,$GUI_DOCKTOP,$GUI_DOCKWIDTH)

It makes no difference because each value is a different multiple of 2.

Here is an example where it does make a difference

BitOr($GUI_DOCKMENUBAR,$GUI_DOCKTOP)

which seems logical because you want a menu bar at the top but it does not give the same effect as

BitAnd($GUI_DOCKMENUBAR,$GUI_DOCKTOP)

There are many Gui window styles which are combinations of other styles and if you add them together instead of oring them you can get unexpected results which can even make you script crash.

After all, 2 OR 2 OR 2 = 2, but 2 AND 2 ANd 2 = 6

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Quual

Thank you Authenticity and Quual, I have reported it as a bug (ticket #931)

@Quual

You need to change the way you deal with values which give styles or characteristics. It is true that adding often gives the same result as oring but you should never add values even though you will see many people doing that and even in the help file.

There are many Gui window styles which are combinations of other styles and if you add them together instead of oring them you can get unexpected results which can even make you script crash.

Ah I see your point, just adding them works fine, unless you run into a case where you add a value to another that already contains that value. as in your example

$GUI_DOCKMENUBAR = $GUI_DOCKTOP + $GUI_DOCKHEIGHT so adding another $GUI_DOCKTOP into it would cause a problem. where bitor avoids the issue.

I do always bitor styles, and I never ran into a issue with docking because I never use Docksize, Dockmenubar, Dockstatebar, Dockall or Dockborders

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.