Discussion:
ComCtl.ListViewCtrl doesn't show itself ....
(too old to reply)
R.Wieser
2015-10-07 18:56:09 UTC
Permalink
Hello all,

I'm trying to create a listview control, but although I do not get any
errors I do not see it appear on my screen. :-\


set oTest = CreateObject("COMCTL.ListViewCtrl")
oTest.view = 3 '-- Report mode

Call oTest.ColumnHeaders.Add(,,"Header1", 150)
call oTest.ListItems.add(,,"Foobar")

wscript.echo "It should be there ..."
set oTest=nothing

I *think* I could use a bit of help. :-)

Regards,
Rudy Wieser
GS
2015-10-07 22:28:30 UTC
Permalink
Post by R.Wieser
Hello all,
I'm trying to create a listview control, but although I do not get
any errors I do not see it appear on my screen. :-\
set oTest = CreateObject("COMCTL.ListViewCtrl")
oTest.view = 3 '-- Report mode
Call oTest.ColumnHeaders.Add(,,"Header1", 150)
call oTest.ListItems.add(,,"Foobar")
wscript.echo "It should be there ..."
set oTest=nothing
I *think* I could use a bit of help. :-)
Regards,
Rudy Wieser
Controls exist on forms only, either directly placed on a form OR
placed into a container control on a form. How to do.., I have no clue
in VBS!
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
R.Wieser
2015-10-08 09:18:43 UTC
Permalink
Hello Garry,
Post by GS
Controls exist on forms only, either directly placed on
a form OR placed into a container control on a form.
I did find a reference to a "Controls" CoClass in the typelib, but when
trying to create it it wasn't recognised (a check in the registry showed it
not being present there).
Post by GS
I have no clue in VBS!
And that makes two of us. :-)

Thanks for the reply,
Rudy Wieser.
Post by GS
Post by R.Wieser
Hello all,
I'm trying to create a listview control, but although I do not get
any errors I do not see it appear on my screen. :-\
set oTest = CreateObject("COMCTL.ListViewCtrl")
oTest.view = 3 '-- Report mode
Call oTest.ColumnHeaders.Add(,,"Header1", 150)
call oTest.ListItems.add(,,"Foobar")
wscript.echo "It should be there ..."
set oTest=nothing
I *think* I could use a bit of help. :-)
Regards,
Rudy Wieser
Controls exist on forms only, either directly placed on a form OR
placed into a container control on a form. How to do.., I have no clue
in VBS!
--
Garry
Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2015-10-15 23:31:40 UTC
Permalink
There are at least two problems: First, the control
is licensed. You need a VB/VS license to use it.
Second, as demonstrated by Reventlov's sample,
while it's possible to use it in an HTA or other window
if you have the license, it's still of no real use. What
Reventlov did was clever, but it's no better than
multiple HTML SELECT elements, which are essentially
listboxes. A listview needs to load icons to be useful,
and is typically only used to display the file system.

I've made wrapper DLLs for some controls, like listbox
and RichEdit window, which allows them to be used in
VBS. What mainly makes them useful is that the properties
and methods are wrapped for easy access by VBS.

Personally I've never even used a listview in any
software. It's just too much of a complex hassle. I'm
guessing you're making this control as an experiment
rather than with some specific purpose. You could
probably create a passably useful listview in HTML
as a table with IMG elements in TDs if you really
need that. And it would probably be easier than trying
to tame the VB6 listview control. (I imagine HTML listviews
are probably already being done by some "HTML5"
hotshots.)
R.Wieser
2015-10-16 10:25:34 UTC
Permalink
Mayayana,
Post by Mayayana
A listview needs to load icons to be useful,
I'm often using it in "report" mode, in which I only display text. (alike
the "details" mode in the "file explorer"). Icons can be used there, but
do not need to be.
Post by Mayayana
Personally I've never even used a listview in any
software. It's just too much of a complex hassle.
Granted, It's not the easiest control to work with. Especially as it has
different modi you can use.
Post by Mayayana
I'm guessing you're making this control as an
experiment rather than with some specific purpose.
Well, Its actually for the other side of the equation, the scripting-engine.
I've implemented loading a non-installed control, and now would like to see
if I can create the equivalent of "wscript.ConnectObject()" for it (so I can
accept callbacks to the scripting-engine).

For testing purposes I need a control which generates events. The ListView
was just the last control of a few which all seemed to work, but stayed
invisible. I just assumed I missed/forgot to do something. Only later I
noticed the absense of, among others, positional and size
properties/functions, which made me wonder if they where ment to be directly
accessed at all ...

But yes, there is a chance I will, at some time or another, try to wrap some
implementation of the listview into an OCX.

Though currently I'm still struggeling with the basics, like how to describe
certain things in the typelib -- can't seem to get an "[out] long*
Something" accepted by the VBS scripting engine (type-mismatch. most likely
expects/wants a variant). Which is odd to me, as an "[out, retval] *long
Result" works without a problem.

Regards,
Rudy Wieser
Post by Mayayana
There are at least two problems: First, the control
is licensed. You need a VB/VS license to use it.
Second, as demonstrated by Reventlov's sample,
while it's possible to use it in an HTA or other window
if you have the license, it's still of no real use. What
Reventlov did was clever, but it's no better than
multiple HTML SELECT elements, which are essentially
listboxes. A listview needs to load icons to be useful,
and is typically only used to display the file system.
I've made wrapper DLLs for some controls, like listbox
and RichEdit window, which allows them to be used in
VBS. What mainly makes them useful is that the properties
and methods are wrapped for easy access by VBS.
Personally I've never even used a listview in any
software. It's just too much of a complex hassle. I'm
guessing you're making this control as an experiment
rather than with some specific purpose. You could
probably create a passably useful listview in HTML
as a table with IMG elements in TDs if you really
need that. And it would probably be easier than trying
to tame the VB6 listview control. (I imagine HTML listviews
are probably already being done by some "HTML5"
hotshots.)
Mayayana
2015-10-16 14:21:17 UTC
Permalink
| Well, Its actually for the other side of the equation, the
scripting-engine.
| I've implemented loading a non-installed control, and now would like to
see
| if I can create the equivalent of "wscript.ConnectObject()" for it (so I
can
| accept callbacks to the scripting-engine).
|
| For testing purposes I need a control which generates events. The
ListView
| was just the last control of a few which all seemed to work, but stayed
| invisible. I just assumed I missed/forgot to do something.

If it didn't need to be visible then wouldn't a
few arrays or dictionaries serve the same purpose?

It sounds like you've got deep into an intriguing
project. Hopefully you'll be back with a report
if you turn up anything fun. :)

I've used wscript.ConnectObject with ActiveX EXEs,
like a component I made for sending email directly
via an SMTP server. I've found it maddeningly
limited, though. Since the script is a single string of
operations it's very limited in the handling of events.
The only thing one can do is to call a function and
then loop, waiting for an event to "fire". I find something
like an HTA luxurious by comparison. With the GUI there's
room for a facsimile of asynchronous operation.
R.Wieser
2015-10-16 15:22:29 UTC
Permalink
Mayayana,
Post by Mayayana
If it didn't need to be visible then wouldn't a
few arrays or dictionaries serve the same purpose?
I'm sorry, It seems I wasn't too clear in my previous reply. It stayed
invisible, but I needed it to become visible -- to be able to click on it
and generate "events" (something an array or a dictionary object doesn't).
Post by Mayayana
It sounds like you've got deep into an intriguing
project. Hopefully you'll be back with a report
if you turn up anything fun. :)
Well, most of what I do is to learn from it, and by doing so having fun
(yeah, I'm a bit weird, I know :-) ). The end result (if there is one) is
mostly quite mundaine.
Post by Mayayana
Since the script is a single string of operations it's very
limited in the handling of events. The only thing one
can do is to call a function and then loop, waiting for
an event to "fire".
I don't think I quite understand you. Those events are just triggers to
execute functions you can write yourself. How's that more limited than
what a normal windows app message-loop will do for you ?

But than again, I've got *very* little experience with VBS events (and so
long ago that I can't even remember), so I should hold my opinion until I
got something running. :-)

Regards,
Rudy Wieser
Post by Mayayana
| Well, Its actually for the other side of the equation, the
scripting-engine.
| I've implemented loading a non-installed control, and now would like to
see
| if I can create the equivalent of "wscript.ConnectObject()" for it (so I
can
| accept callbacks to the scripting-engine).
|
| For testing purposes I need a control which generates events. The
ListView
| was just the last control of a few which all seemed to work, but stayed
| invisible. I just assumed I missed/forgot to do something.
If it didn't need to be visible then wouldn't a
few arrays or dictionaries serve the same purpose?
It sounds like you've got deep into an intriguing
project. Hopefully you'll be back with a report
if you turn up anything fun. :)
I've used wscript.ConnectObject with ActiveX EXEs,
like a component I made for sending email directly
via an SMTP server. I've found it maddeningly
limited, though. Since the script is a single string of
operations it's very limited in the handling of events.
The only thing one can do is to call a function and
then loop, waiting for an event to "fire". I find something
like an HTA luxurious by comparison. With the GUI there's
room for a facsimile of asynchronous operation.
Mayayana
2015-10-16 16:09:30 UTC
Permalink
| > Since the script is a single string of operations it's very
| > limited in the handling of events. The only thing one
| > can do is to call a function and then loop, waiting for
| > an event to "fire".
|
| I don't think I quite understand you. Those events are just triggers to
| execute functions you can write yourself. How's that more limited than
| what a normal windows app message-loop will do for you ?
|

What I mean is that in a windowed process, like
an HTA, there can be numerous events responded
to without holding up the process.
With VBS, there's no way to wait for events
while doing other things. An event is really just an
asynchronous function, where one has to wait for
the return while looping. This is a simplified version
of how I had to code an emailing component to
allow for asynchronous operation. It works, but
it gets complicated trying to keep the script running,
and not locked, while asynchronous ops are carried
out:

'---------------------------------
Var1 = False
DoIt

Do Until Var1 = True
Loop
WScript.DisconnectObject Ob

Sub DoIt()
Set Ob = WScript.CreateObject("Some.Obj", "Ob_")
'-- do stuff.
Ob.DoSomethingInvolved
While Ob.Busy = True
Wend
End Sub

Sub Ob_Onfinish()
'--do stuff
Var1 = True
End Sub

Sub Ob_Report(data)
RecordReport data
End Sub
'--------------------------------
R.Wieser
2015-10-16 16:35:13 UTC
Permalink
Mayayana,
Post by Mayayana
What I mean is that in a windowed process, like
an HTA, there can be numerous events responded
to without holding up the process.
Are you sure ?

As far as my experiences go if I include, in a standard windows program, a
lengthy operation in any event than the program will stall (become
unresponsive) until that operation is completed. The same goes for VBS
events. Though its quite possible that the overhead of calling and
executing events in VBS (thru the dispatch object) will make the whole a lot
slower.
Post by Mayayana
It works, but it gets complicated trying to keep the
script running, and not locked, while asynchronous
Possibly the events in VBS are a bit more asynchronous than in a standard
windows app. That certainly would complicate things.

... I'm on the treshold to experiencing that myself, so wish me luck. Or
patience. Or wisdom. Or all of it! :-)

Regards,
Rudy Wueser
Post by Mayayana
| > Since the script is a single string of operations it's very
| > limited in the handling of events. The only thing one
| > can do is to call a function and then loop, waiting for
| > an event to "fire".
|
| I don't think I quite understand you. Those events are just triggers to
| execute functions you can write yourself. How's that more limited than
| what a normal windows app message-loop will do for you ?
What I mean is that in a windowed process, like
an HTA, there can be numerous events responded
to without holding up the process.
With VBS, there's no way to wait for events
while doing other things. An event is really just an
asynchronous function, where one has to wait for
the return while looping. This is a simplified version
of how I had to code an emailing component to
allow for asynchronous operation. It works, but
it gets complicated trying to keep the script running,
and not locked, while asynchronous ops are carried
'---------------------------------
Var1 = False
DoIt
Do Until Var1 = True
Loop
WScript.DisconnectObject Ob
Sub DoIt()
Set Ob = WScript.CreateObject("Some.Obj", "Ob_")
'-- do stuff.
Ob.DoSomethingInvolved
While Ob.Busy = True
Wend
End Sub
Sub Ob_Onfinish()
'--do stuff
Var1 = True
End Sub
Sub Ob_Report(data)
RecordReport data
End Sub
'--------------------------------
Mayayana
2015-10-16 16:49:24 UTC
Permalink
| > What I mean is that in a windowed process, like
| > an HTA, there can be numerous events responded
| > to without holding up the process.
|
| Are you sure ?
|
| As far as my experiences go if I include, in a standard windows program, a
| lengthy operation in any event than the program will stall (become
| unresponsive) until that operation is completed. The same goes for VBS
| events.

Yes. It may not be fundamentally different.
It can only do one operation at a time. But in
an HTA, for example, I can code 20 events and
don't have to be concerned about timing or
order. That's all handled by the HTA process.
With VBS I have to keep the script going.
It either works or quits. So it's a case of hacking
one's own stall loops to keep the script
alive while waiting for events to happen. And
if the event goes wrong somehow then the script
is stuck in a loop. I found it a mind-bender trying
to plan the stall loops in a way that would work.
R.Wieser
2015-10-16 23:00:40 UTC
Permalink
Mayayana,
Post by Mayayana
With VBS I have to keep the script going.
It either works or quits. So it's a case of hacking
one's own stall loops to keep the script
alive while waiting for events to happen.
Yup, true. But a question: do events still run when you display a modal
message-box (sorry, can't currently test it myself) ? If not than that
main loop of yours cannot be helped. If however they do than you could
include a bit of sleep into it, freeing more time for the events to run
(while still be able to programmatically terminate the loop).
Post by Mayayana
And if the event goes wrong somehow then the script
is stuck in a loop.
Hmmm ... The first things that come to my mind are either an "on error", or
a "watchdog timer" setup in the main loop.

But as I said, I've got too little experience with it, and should probably
keep my mouth shut. :-)

Regards,
Rudy Wieser
Post by Mayayana
| > What I mean is that in a windowed process, like
| > an HTA, there can be numerous events responded
| > to without holding up the process.
|
| Are you sure ?
|
| As far as my experiences go if I include, in a standard windows program, a
| lengthy operation in any event than the program will stall (become
| unresponsive) until that operation is completed. The same goes for VBS
| events.
Yes. It may not be fundamentally different.
It can only do one operation at a time. But in
an HTA, for example, I can code 20 events and
don't have to be concerned about timing or
order. That's all handled by the HTA process.
With VBS I have to keep the script going.
It either works or quits. So it's a case of hacking
one's own stall loops to keep the script
alive while waiting for events to happen. And
if the event goes wrong somehow then the script
is stuck in a loop. I found it a mind-bender trying
to plan the stall loops in a way that would work.
Reventlov
2015-10-15 21:43:29 UTC
Permalink
Post by GS
Controls exist on forms only, either directly placed on a form OR
placed into a container control on a form. How to do.., I have no clue
in VBS!
You can create an HTA application, which is a html page with the extension changed to HTA.
It is a window that can contain text boxes, drop down menus, buttons, etc. And vbs code to
manage all of it.
I think there isn't a native html code for a listview and I don't know how to put the
object in the html code.

I've found this code in
http://www.tech-archive.net/Archive/Scripting/microsoft.public.scripting.vbscript/2005-12/msg00275.html
and here some theory
http://www.codeproject.com/Articles/33660/GUI-in-JScript-and-VBScript-using-Windows-Common-C

<html>
<head>
<hta:application id = "TestListView"
/>
<title>TestListView</title>
<meta http-equiv = "content-script-type" content = "text/vbscript"/>
<script language = "VBScript"
type = "text/vbscript"
'<![CDATA[

''= on load body: fill ListView
' ============================================================================

Sub onloadBody()
' MsgBox "onloadBody()"

Dim oLV : Set oLV = document.getElementById( "lvListView" )
If oLV Is Nothing Then
MsgBox "oLV Is Nothing"
Else
Const cnRows = 30
Const cnCols = 3
Dim nRow, nCol, oLI

With oLV
.View = 3
.Width = 300
.Height = 400

.ColumnHeaders.Clear
For nCol = 1 To cnCols
.ColumnHeaders.Add , , "Col " & nCol, 100
Next

.ListItems.Clear
For nRow = 1 To cnRows
Set oLI = .ListItems.Add
oLI.Text = "R" & nRow & "C1"
For nCol = 2 To cnCols
oLI.ListSubItems.Add.Text = "R" & nRow & "C" & nCol
Next
Next
End With
End If
End Sub

''= refreshes the HTA page, which includes re-running any Windows_Onload code
' ============================================================================

Sub reloadHTA()
location.reload( True )
End Sub

']]>
</script>
</head>

<body onload = "onloadBody()">
<form>
<table border = "1">
<tr>
<td>
<OBJECT id = "lvListView"
classid = "clsid:BDD1F04B-858B-11D1-B16A-00C0F0283628"
</OBJECT>
</td>
</tr>
</table>
<hr />
<input type = "BUTTON" value = "reload" onclick = "reloadHTA()">
</form>
</body>
</html>
--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
Evertjan.
2015-10-15 21:54:21 UTC
Permalink
Post by GS
Controls exist on forms only, either directly placed on a form OR
placed into a container control on a form. How to do.., I have no clue
in VBS!
"controll" is VB [or perhaps VBA] slang,
on its defined surroundings.

VBS is a scripting language, also needs a platform but the language in sensu
strictior is free from it.

If the VBS-platform is wscript, some form of "controll" is imaginable.

When the platform is a server, the "controll" on the server is nonsense, a
server often has no screen, it could be on the client in a html page,
in the form of a <form> or run by clientside code most often in Javascript.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Loading...