KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

From help: "The Controls collection cannot be enumerate

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
gchet
KiXforms Dabbler
KiXforms Dabbler


Joined: 08 Aug 2005
Posts: 9

PostPosted: Sun Dec 11, 2005 9:19 am    Post subject: From help: "The Controls collection cannot be enumerate Reply with quote

Shawn, you will make?

Without this feature it is necessary to use rough methods for the reverse engineering in my KFDTool :(
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sun Dec 11, 2005 4:39 pm    Post subject: Reply with quote

Do you want just the FOR-EACH-IN-NEXT support ? or do you need all the properties and methods of the collection (like COUNT and ITEM) ?
Back to top
View user's profile Send private message
gchet
KiXforms Dabbler
KiXforms Dabbler


Joined: 08 Aug 2005
Posts: 9

PostPosted: Sun Dec 11, 2005 5:18 pm    Post subject: Reply with quote

It makes no difference to me. As you will make, so it will be :)
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sun Dec 11, 2005 5:24 pm    Post subject: Reply with quote

ok, im working on it now... will be able to do this when done ...

1) Enumerate the Controls collection ...

Code:

For Each $Control In $Form.Controls

 ?"Name=" $Control.Name

Next


2) Step throught he collection like this:

Code:

For $i = 0 To $Form.Controls.Count - 1

 ?"Name=" $Form.Controls($i).Name

Next


Is that good enough to give you what your looking for ?

-Shawn


Last edited by Shawn on Sun Dec 11, 2005 6:00 pm; edited 1 time in total
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Sun Dec 11, 2005 5:27 pm    Post subject: Reply with quote

I think all collections should be alike.
thus, make it full blooded collection (arraylist for .net version)

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
gchet
KiXforms Dabbler
KiXforms Dabbler


Joined: 08 Aug 2005
Posts: 9

PostPosted: Sun Dec 11, 2005 8:27 pm    Post subject: Reply with quote

Shawn wrote:

...
1) Enumerate the Controls collection ...
...
2) Step throught he collection like this:
...
Is that good enough to give you what your looking for ?
-Shawn


1) & 2) - OK !

And this in all containers controls ?
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Sun Dec 11, 2005 8:32 pm    Post subject: Reply with quote

yes, is this now the all version?
is there going to be a children collection?

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sun Dec 11, 2005 9:03 pm    Post subject: Reply with quote

lol, thats the last thing I'm trying to decide ...

1) Will the Controls collection enumerate ALL children in the container ? Including the children of the childen (like Jooels says - ALL controls) ?

2) Will the Controls collection only enumerate the "direct" children of the container ... not including the grand-children (for example, the checkboxes inside a GroupBox, inside a Form).

.Net enumerates just the direct decendants, vb and vba enumerate all the children - there are upsides and down-sides to both ideas.

Any thoughts ?

-Shawn


Last edited by Shawn on Sun Dec 11, 2005 9:11 pm; edited 1 time in total
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sun Dec 11, 2005 9:09 pm    Post subject: Reply with quote

Jooel and I chatted about this earlier, he was trying to convince me to enumerate only the Direct decendants ... I argued that enumerating all would be more "powerfull" ... but after some thought, thinking that just enumerating direct children would be the best. And I get the impression (correct me if im wrong) that this would serve your purpose better too (just a gut feeling).

btw - all containers will support this.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Dec 13, 2005 3:18 pm    Post subject: Reply with quote

ok gchet,

There is a new Development Build available ... check it out ... the CHM has been updated with all the details ... heres a test script ... it basically creates a bunch of buttons on a form, then "lines them up" automatically using the Controls collection ...

Code:

Break On

$System = CreateObject("Kixtart.System")

$Form = $System.Form()

$Button1 = $Form.Controls.Button()
$Button1.Text = $Button1.Name
$Button1.Name = "Button1"

$Button2 = $Form.Controls.Button()
$Button2.Text = $Button2.Name
$Button2.Name = "Button2"

$Button3 = $Form.Controls.Button()
$Button3.Text = "Button3"
$Button3.Name = "Button3"

$Button4 = $Form.Controls.Button()
$Button4.Text = "Button4"
$Button4.Name = "Button4"

$Button5 = $Form.Controls.Button()
$Button5.Text = "Button5"
$Button5.Name = "Button5"

$Top = 0
For Each $Control In $Form.Controls
 $Control.Top = $Top
 $Top = $Control.Bottom + 5
Next

$Form.Center
$Form.Show

While $Form.Visible
 $=Execute($Form.DoEvents)
Loop

Exit 0


Here is a function that recurses through the Controls collection for a "parent" control (like a form), and displays all the embedded controls ...

Code:

Function EnumControls($parent)

 For Each $control In $parent
  ? $parent.Name + "." $control.Name
  If $control.Controls.Count
   EnumControls($control)
  Endif
 Next

EndFunction


Please advise if anything further is required.

-Shawn
Back to top
View user's profile Send private message
gchet
KiXforms Dabbler
KiXforms Dabbler


Joined: 08 Aug 2005
Posts: 9

PostPosted: Wed Dec 14, 2005 9:24 pm    Post subject: Reply with quote

Shawn wrote:
ok gchet,
There is a new Development Build available ... check it out ... the CHM has been updated with all the details ...
...
Please advise if anything further is required.
-Shawn


Fine !
Thanks for fast reaction !

I for a long time wished you to ask about this.
I shall borrow in completions under the new version Kixforms.

If you will not pay attention on my English, I can throw some more wishes/remarks.

It would be quite good to add meta-functions for work with any objects, namely:
- Check of existence of property by name at object;
- There can be a collection of properties of object ?
- Cloning of object.

And still: at some properties of objects it is impossible to receive type by VarType, for example "Default", "Cancel".
The full list of properties I can send, if you will correct it.

I shall try to recollect, there were at me still any remarks when started KFDTool to write.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Dec 15, 2005 12:19 am    Post subject: Reply with quote

Wonderfull, I like getting requests for features ... but un-fortunately a couple of the ones your suggesting are not possible:


1) Check of existence of property by name at object.

The way Kixforms is designed, that would be impossible I'm afraid.

2) There can be a collection of properties of object ?

For the same reasons, that would be impossible as well. If you want to understand the reasons why its impossible, I can get into the details if you want.

3) Cloning of object.

That is possible - let me think about more.

4) And still: at some properties of objects it is impossible to receive type by VarType, for example "Default", "Cancel". The full list of properties I can send, if you will correct it.

Not sure I follow what your saying there - need some more information of code examples on that one. The code examples could be "pretend-code" if you want ...

Looking forward to your response.

-Shawn
Back to top
View user's profile Send private message
gchet
KiXforms Dabbler
KiXforms Dabbler


Joined: 08 Aug 2005
Posts: 9

PostPosted: Thu Dec 15, 2005 6:30 am    Post subject: Reply with quote

Shawn wrote:

[...]
For the same reasons, that would be impossible as well. If you want to understand the reasons why its impossible, I can get into the details if you want.

I trust :)
Shawn wrote:

Not sure I follow what your saying there - need some more information of code examples on that one. The code examples could be "pretend-code" if you want ...

Code:

Break on

$system = CreateObject("kixtart.system")
$f = $System.Form()
$b = $f.Controls.Button()
? "VarType(f.Enabled)="+VarType($f.Enabled)
? "VarType(b.Top)="+VarType($b.Top)
? "VarType(b.Enabled)="+VarType($b.Enabled)
? "VarType(b.Default)="+VarType($b.Default)
? "VarType(b.Cancel)="+VarType($b.Cancel)

Shawn wrote:

3) Cloning of object.
That is possible - let me think about more.

Now for copying (cloning) of object I use
Code:

function CopyObj($obj, $proplist)
  $CopyObj = $System.Object()
  dim $p
  for each $p in $proplist
    $ = SetObjProp($CopyObj, $p, GetObjProp($obj, $p))
  next
endfunction

If there was function CopyObject ($obj) or CloneObject ($obj), without use of the list of properties, it would be easier...
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Dec 15, 2005 9:04 am    Post subject: Reply with quote

wonder if shawn is making it happen in one implementation for all objects.
placing the clone method to all objects one by one is little bigger project.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group