Page 1 of 1 1
Topic Options
#88297 - 2002-09-26 02:54 PM KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Chris - hope you don't mind but I'm hijacking your KiXomatic code (read stealing) for use in the first forms ListView script. This application really lends itself to this kind of presentation ...

Anyways .. that EnumClasses thingy you wrote ... have you posted that to the UDF forum ... is there already one like it there. Just as an FYI and in terms of experimentation - I modified your function to get make it more generic (passing the class filter as a parm) plus, returning an array of class strings plus - passing a reference to an optional progress bar (instead of hard coding it) ... just thought I would open-up a dialog because I really like your KiXomatic script ...

Usage (Forms 2.1):

code:
For Each $Class In WmiEnumClasses("WIN32_",$Progress)
$Item = $ClassList.Items.Add($Class)
Next

Script:

code:
Function WmiEnumClasses(Optional $Filter, Optional $Progress)

If Not $Filter
$Filter = "WIN32_"
Endif

Dim $WMI,$Class,$Qualifier,$IsQ
Dim $Bounds,$Count,$Increment

Dim $Array[400]

$Count = 0
$Increment = 100
$Bounds = UBound($Array)

$WMI = GetObject("winmgmts:\\.\root\cimv2")

If $Progress
$Progress.Min = 0
$Progress.Max = 0
$Progress.Value = 0
For Each $Class in $WMI.SubclassesOf()
$Progress.Max = $Progress.Max + 1
Next
EndIf

For Each $Class in $WMI.SubclassesOf()
$Progress.Value = $Progress.Value + 1
$IsQ = 0
If Instr($Class.Path_.Class,$Filter);
For Each $Qualifier in $objClass.Qualifiers_
If Instr($Qualifier.Name, "ASSOCIATION")
$IsQ = 1
Endif
Next
If $IsQ = 0
$Array[$count] = $Class.Path_.Class
$Count = $Count + 1
If $Count > $Bounds
$Bounds = $Bounds + $Increment
ReDim Preserve $Array[$Bounds]
EndIf
EndIf
EndIf
Next
If $Count
ReDim Preserve $Array[$Count-1]
EndIf
If $Progress
$Progress.Value = 0
EndIf
$WmiEnumClasses = $Array
$WMI = 0
EndFunction



[ 26. September 2002, 15:23: Message edited by: Shawn ]

Top
#88298 - 2002-09-26 03:25 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ps. With the olde ListBox object - can simply say this now:

code:
$ClassList.List = WmiEnumClasses("WIN32_",$Progress)



[ 26. September 2002, 15:26: Message edited by: Shawn ]

Top
#88299 - 2002-09-26 05:19 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Its OK with me. I already hijacked it from the 'Script Guys' at M$.
Top
#88300 - 2002-09-26 05:57 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Here's kinda where I'm heading with this ... hope it works (if you try it) because I'm running 2.1 here - hope I'm not using any of the new methods or properties ... should work under 2.0

Couple of things ... Its got an embedded progress bar in the status bar (kinda like IE) and its got a realtime clock in the status bar ... other than that ... just lists the WMI classes right now.

code:
Break On

$TITLE = "WmiList"
$WIDTH = 400
$HEIGHT = 300
$MARGIN = 4

$Form = CreateObject("Kixtart.Form")
$Form.ClientWidth = $WIDTH
$Form.ClientHeight = $HEIGHT
$Form.FontSize = 10
$Form.Caption = $TITLE

$Status = $Form.Label()
$Status.Left = $MARGIN
$Status.Top = $Form.ClientHeight - 25
$Status.Width = 0.4 * $Form.ClientWidth
$Status.Height = 20
$Status.BorderStyle = 5
$Status.Text = "Ready..."

$Progress = $Form.ProgressBar()
$Progress.Left = $Status.Right + $MARGIN
$Progress.Top = $Form.ClientHeight - 25
$Progress.Width = 0.4 * $Form.ClientWidth
$Progress.Height = 20
$Progress.BorderStyle = 5
$Progress.ForeColor = 0,200,0 ; Green

$Clock = $Form.Label()
$Clock.Left = $Progress.Right + $MARGIN
$Clock.Top = $Form.ClientHeight - 25
$Clock.Width = $Form.ClientWidth-$Progress.Right-$MARGIN*2
$Clock.Height = 20
$Clock.BorderStyle = 5
$Clock.Text = "Ready..."

$Timer = $Form.Timer(1000)
$Timer.OnTimer = "OnTimer()"

Function OnTimer()
$Clock.Text = @TIME
EndFunction

$List = $Form.ListBox
$List.Sorted = 1
$List.Top = 5
$List.Left = 5
$List.Right = $Form.ClientWidth - $MARGIN
$List.Bottom = $Status.Top - $MARGIN

$Form.Center
$Form.Show

$Form.MousePointer = 11
$Form.Enabled = 0
$Status.Text = "Loading classes..."
$List.List = WmiEnumClasses("WIN32_",$Progress)
$Status.Text = "Ready"
$Form.Enabled = 1
$Form.MousePointer = 0

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

Exit 1

Function WmiEnumClasses(Optional $Filter, Optional $Progress)

If Not $Filer
$Filter = "WIN32_"
Endif

Dim $WMI,$Class,$Qualifier,$IsQ
Dim $Bounds,$Count,$Increment

Dim $Array[400]

$Count = 0
$Increment = 100
$Bounds = UBound($Array)

$WMI = GetObject("winmgmts:\\.\root\cimv2")

If $Progress
$Progress.Min = 0
$Progress.Max = 0
$Progress.Value = 0
For Each $Class in $WMI.SubclassesOf()
$Progress.Max = $Progress.Max + 1
Next
EndIf

For Each $Class in $WMI.SubclassesOf()
$Progress.Value = $Progress.Value + 1
$IsQ = 0
If Instr($Class.Path_.Class,$Filter);
For Each $Qualifier in $objClass.Qualifiers_
If Instr($Qualifier.Name, "ASSOCIATION")
$IsQ = 1
Endif
Next
If $IsQ = 0
$Array[$count] = $Class.Path_.Class
$Count = $Count + 1
If $Count > $Bounds
$Bounds = $Bounds + $Increment
ReDim Preserve $Array[$Bounds]
EndIf
EndIf
EndIf
Next
If $Count
ReDim Preserve $Array[$Count-1]
EndIf
If $Progress
$Progress.Value = 0
EndIf
$WmiEnumClasses = $Array
$WMI = 0
EndFunction


Top
#88301 - 2002-09-26 06:00 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
oh yeah - and its resizable through code - just change the $WIDTH and $HEIGHT variables ... dynamic resizability is in the cards ... certainly not in the next big release - but im laying down the framework now.

[ 26. September 2002, 18:01: Message edited by: Shawn ]

Top
#88302 - 2002-09-26 06:18 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
That's sweet. I like that status bar thingy.

I think I see where you're going. You creating a WMI Explorer?

Top
#88303 - 2002-09-26 06:27 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Just noticed that your WMIEnumClasses() is not filtering out the Association classes. Compare to KiXomatic's listing.
Top
#88304 - 2002-09-26 06:30 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
yap - the 2.1 version has the listbox pushed over to the left a little - next to that is a ListView grid that behaves like the property sheet from VB or VBA ... know what I mean ? Column one is called "Property" and column two is called "Value". The intent is to enumerate the selected classes properties into the property sheet view. A WMI browser yeah ... after that ... ahhh ... i don't know what [Wink]
Top
#88305 - 2002-09-26 06:37 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I added a...

$List.Width = 0.33 * $Width

to make the listbox dynamic too. [Wink]

Top
#88306 - 2002-09-26 06:46 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
crap - a 2.1 feature did slip through ... i thought I had redid all those RIGHT properties ... in 2.1, setting the RIGHT property has been "defined" - by that I mean nailed down once and for all. I had a tough time with that because setting the RIGHT property can have two meanings:

1) The object MOVES to the position designated as RIGHT ... example - if you had a BUTTON that was 50x50 at the left of the form - then you set its RIGHT property to somewhere around the right edge of the form ... the button would MOVE to that location - not be RESIZED to that location.

2) The object RESIZES to the position designated as RIGHT - ie - the button would RESIZE to be a big honking button that strecthes from the RIGHT of the form - to the LEFT of the FORM - a big guy.

In my own mind - This behavior of the RIGHT and BOTTOM properties I call "STICKY" settings ... the LEFT and TOP edge stick and the RIGHT and BOTTOM edge move - and the whole control resizes with it ... kinda like dragging an object by the lower bottom corner to be BIGGER.

STICKY RIGHT and STICKY BOTTOM - lol

ps.

Thats one of the benefits of plaing with Kixtart Forms ... you get to observe all these weird behaviors and coin your own phrases. rofl

[ 26. September 2002, 18:49: Message edited by: Shawn ]

Top
#88307 - 2002-09-26 06:50 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Found the bug in WMIEnumClasses()
code:
For Each $Qualifier in $objClass.Qualifiers_

Should be...
code:
For Each $Qualifier in $Class.Qualifiers_


Top
#88308 - 2002-09-26 06:52 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I don't know if STICKY BOTTOM will catch on. Unless you throw yer unnerware gainst the wall. ewww. lol.
Top
#88309 - 2002-09-26 06:52 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ps. this STICKY stuff is the "framework" bit I eluded to earlier re: Dynamic Resizing.

Shawn "Sticky Bottoms" Tassie

[ 26. September 2002, 18:53: Message edited by: Shawn ]

Top
#88310 - 2002-09-26 06:59 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Hey, since I have your attention. Is there a way to get an object to Center-On another object?

Example, in KiXomatic if I move the PForm or the main Form then the PForm is no longer centered on the main.

Maybe something like

$PForm.CenterOn ($Form)

Top
#88311 - 2002-09-26 07:05 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Yeah - a form or control will center on its parent - so in your ChooseClass function - do a $PForm.Center just before your $PForm.Show.
Top
#88312 - 2002-09-26 07:34 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
My $PForm isn't a child of $Form, but rather it's own separate form (object). So center centers it on the desktop. How should I have created the $PForm?

[ 26. September 2002, 19:35: Message edited by: Chris S. ]

Top
#88313 - 2002-09-26 07:52 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hmmm thats weird - it seems to work for me - if I put that $PForm.Center in ChooseClass - then move the Form around the desktop - then choose a class from the ComboBox - the proggy bar always comes-up centered on the main form ... hmmm ...
Top
#88314 - 2002-09-26 07:55 PM Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
My bad, I was centering the $PBar instead of the $PForm. Doh!
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.656 seconds in which 0.451 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org