Jump to content

Rectangle wrong size


Recommended Posts

Hi, this are a logic problem, i am creating a square 50x50 and when i point the AIM with AutoIt Window Info with magnify the "color" of the square start at 10 and end in 59

59-10 = 49 not 50, why it nots end in 50?

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

$Form1 = GUICreate("Form1", 800, 600,-1,-1)
GUICtrlCreateLabel("",10,10,50,50)
GUICtrlSetBkColor(-1,0x0000FF)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Edited by GordonFreeman
Link to comment
Share on other sites

My AutoIt Window Info tool returns

Quote

>>>> Window <<<<
Title:    Form1
Class:    AutoIt v3 GUI
Position:    558, 207
Size:    806, 629
Style:    0x94CA0000
ExStyle:    0x00000100
Handle:    0x000000000086062C

>>>> Control <<<<
Class:    Static
Instance:    1
ClassnameNN:    Static1
Name:    
Advanced (Class):    [CLASS:Static; INSTANCE:1]
ID:    3
Text:    
Position:    10, 10
Size:    50, 50
ControlClick Coords:    23, 30
Style:    0x50020100
ExStyle:    0x00000000
Handle:    0x00000000003B03CA

>>>> Mouse <<<<
Position:    594, 273
Cursor ID:    0
Color:    0x0000FF

And storing the id of the label in $lblRect gives me the same as the info tool

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $lblRect
            Local $size = ControlGetPos($Form1, "", $lblRect)
            ConsoleWrite($size[0] & ", " & $size[1] & " | " & $size[2] & ", " & $size[3] & @LF)
    EndSwitch
WEnd

 

Edited by InunoTaishou
Link to comment
Share on other sites

  • Moderators

GordonFreeman,

Quote

 i am creating a square 50x50 and [...] the square start at 10 and end in 59

59-10 = 49 not 50

Oh yes it is. That simple subtraction gives you the difference between the 2 numbers - but if you look carefully there are indeed 50 pixels:

10  ]              30  ]              50  ]
11  ]              31  ]              51  ]
12  ]              32  ]              52  ]
13  ]              33  ]              53  ]
14  ]              34  ]              54  ]
15  ]              35  ]              55  ]
16  ]              36  ]              56  ]
17  ]              37  ]              57  ]
18  ]              38  ]              58  ]
19  ] - first 10   39  ] - third 10   59  ] - fifth 10
20  )              40  )
21  )              41  )
22  )              42  )
23  )              43  )
24  )              44  )              And 5 x 10 = 50
25  )              45  )
26  )              46  )
27  )              47  )
28  )              48  )
29  ) - second 10  49  ) - fourth 10

The subtraction ignores the "10" pixel.

M23

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

Open spoiler to see 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

 

Link to comment
Share on other sites

On 15/03/2016 at 7:50 AM, Melba23 said:

GordonFreeman,

Oh yes it is. That simple subtraction gives you the difference between the 2 numbers - but if you look carefully there are indeed 50 pixels:

10  ]              30  ]              50  ]
11  ]              31  ]              51  ]
12  ]              32  ]              52  ]
13  ]              33  ]              53  ]
14  ]              34  ]              54  ]
15  ]              35  ]              55  ]
16  ]              36  ]              56  ]
17  ]              37  ]              57  ]
18  ]              38  ]              58  ]
19  ] - first 10   39  ] - third 10   59  ] - fifth 10
20  )              40  )
21  )              41  )
22  )              42  )
23  )              43  )
24  )              44  )              And 5 x 10 = 50
25  )              45  )
26  )              46  )
27  )              47  )
28  )              48  )
29  ) - second 10  49  ) - fourth 10

The subtraction ignores the "10" pixel.

M23

Thankss. I think because coords start at 0 but this no have relation.

Then if i create a square with [100,100,5,5] then 100,100 (1) / 101,100 (2) / 102,100 (3) / 103,100 (4) / 104,100 (5).

:) big thanks

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