Jump to content

What (save) assumptions can be made about Control IDs?


Mirko
 Share

Recommended Posts

What (save) assumptions can be made about Control IDs?

I know, that a Control ID is a positive, unique number

with the same value as reported by the Window Info Tool.

However, one thing I saw in the docs was like this:

GUIStartGroup()

$radio_1 = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)

$radio_2 = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)

$radio_3 = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)

While 1

$msg = GUIGetMsg()

Select

Case $msg >= $radio_1 AND $msg <= $radio_3

$radioval1 = $msg - $radio_1

EndSelect

Wend

Is it save to assume, that subsequently created controls have subsequent and

gap-less IDs? Or is it due to the usage of GUIStartGroup() that it is possible

to "range-check" controls as shown in the Case statement and savely do arithmetics

with the IDs?

What happends if GUICtrlDelete() is called on such a control and a new

control is created? Does the new control gets the first unused ID?

Actually, I thought that the IDs where allocated by Windows and if this

is true, then I actually doubt that it is save to make such assumptions

about them, or am I wrong?

Thanks for any infos about this.

Link to comment
Share on other sites

Control IDs are only unique within the particular GUI they reside in. Subsequently-created controls will always have subsequent control IDs with no gaps, assuming GUICtrlDelete hasn't been used. I have a very large program that relies on this behavior for several crucial functions, and I've been using it for over a year with no problems.

So if you have a giant array of 100 input boxes, feel free to do this:

For $i = $input1 To $input100
    GUICtrlSetData($i,"Whatever")
Next

Assuming inputs 2 through 99 were all created in order between numbers 1 and 100. $i-$input1+1 will give you the current iteration of the above loop.

As for GUICtrlDelete, I have no idea, since I've never used it. Try testing it with the window info tool.

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