Populating a VB listview using API 
Author Message
 Populating a VB listview using API

Big problem is with PostMessage, which in the case of LVM_INSERTITEM
will create a big mess. It just copies the message to the que and
returns immediately. If the control can't keep up with your loop
(which most likely it can't) you max out the que and start dropping
messages. Also because it returns immediately, by the time the control
acts on the message, your loop may have already run several more
iterations, and the contents of LVITEM will have been changed. Worse,
if messages are still be qued up when the function ends, LVITEM will
be out of scope and the address passed with the message will be
pointing to who knows what. Use SendMessage instead. <g>

ListItems collection. Can't tell from your code snip if you're aware
of this one, but it will bite if it hasn't already. The VB ocx
wrapper's ListItems collection is totally unaware of any additions or
deletions made via the API. That means that once you've made a change
with the API, ListItems will be useless because it's out of sync with
the "real" contents. Any use of ListItems therafter can (and
eventually will) cause an error, so you'll have to continue to use API
methods exclusively to access the control contents.

I'm not sure what the LV's behavior is if LVM_SETITEMCOUNT is lower
than needed. I suppose it reverts to "as needed" allocation, but
unless you're sure, it's a tweak I'd save until the rest is working.

Minor point, but your LVITEM declare has a member named cchTextMask
which should really be cchTextMax. (Might save you some possible
confusion in the future<g>).

On Wed, 29 Sep 1999 12:56:51 -0400, "Todd Behr"

Quote:

>Hello,

>I am trying (unsuccessfully) to populate a listview using API and not VB's
>methods. In using WM_SETREDRAW, it seems useless once the VB listitem
>method's add or remove is used.  So I am going the API route to stop flicker
>and allow the user to work while the listview continues to load (this will
>eventually be run in its own thread).

>Attached is a text file of the raw sample code I have written so far
>including the API calls, type declarations, and the subroutine.  When I get
>through the first iteration of the loop, the PostMessage API returns a 1.
>Any iteration after that, the PostMessage API causes VB to crash.

>Does anyone have any advice??? - Thanks

-Tom
(remove gibberish for e-mail repl)


Mon, 18 Mar 2002 03:00:00 GMT  
 Populating a VB listview using API
Tom,

From the way you said it, this does not even seem like the way to go - I
really do not want to use the API any further than populating the control.

Thank you for your help.



Mon, 18 Mar 2002 03:00:00 GMT  
 Populating a VB listview using API
Before you decide, you may want to check these two sites. Both have
some examples of working around VB LV limitations with the API.

http://www.mvps.org/btmtz/
http://vbaccelerator.com/

On Thu, 30 Sep 1999 08:29:28 -0400, "Todd Behr"

Quote:

>Tom,

>From the way you said it, this does not even seem like the way to go - I
>really do not want to use the API any further than populating the control.

>Thank you for your help.

-Tom
(remove gibberish for e-mail repl)


Mon, 18 Mar 2002 03:00:00 GMT  
 Populating a VB listview using API
On Thu, 30 Sep 1999 08:29:28 -0400, "Todd Behr"

Quote:

>Tom,

>From the way you said it, this does not even seem like the way to go - I
>really do not want to use the API any further than populating the control.

>Thank you for your help.

Can you please quote next time?

--
Never underestimate the power of stupid people on large groups.



Fri, 29 Mar 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. retreive text from listview item using API calls?

2. retreive text from listview item using API calls?

3. retreive text from listview item using API

4. retreive text from listview item using API calls.

5. retreive text from listview item using API

6. Listview find item using API

7. adding listitems to a listview using api

8. trying to populate treeview control in activex using vb script

9. API - Cabinet - how to pack and extract using api in VB

10. Email Software in VB using APIs, ie., without using MAPI object

11. populate listview error

12. code example to dynamically populate listview control

 

 
Powered by phpBB® Forum Software