15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CListCtrl problems

Benjamin B. Brouse -- brouse@innernet.net
Saturday, August 17, 1996

Enviroment: VC++4.1, WIN95

My problem exists with the CListCtrl class. I would like to know if there
is anyway to override the size and range of the scrollbar associated with
the list control.  I am filling a list box with data by means of an ODBC
driver.  (this isn't a problem).   However, the odbc calls begin to take
forever.  Therefore, i am intercepting the the WM_VSCROLL messages and
filling and deleting the listbox as needed.  This provides drastic speed
increases.  Now if I could only utilize something like the SetScrollRange
fcn.  Any help would be appreciated.

-------------------------------
Benjamin B. Brouse 
Sytel, Inc.
brouse@innernet.net
-------------------------------



Tim Hagemann -- Tim@way2.net
Tuesday, August 20, 1996

Benjamin,

I think you try to display the contents of a database in a list control. =
This is generally not a good idea, because you have to enumerate the =
whole database to get your control filled. Even when you fill the =
control in a second thread, allowing the user to select the already =
loaded entries, this is bad coding style (personal opinion).
You should use a so called "virtual list box", which does load the =
entries when it needs them. I think for Win16 MS provided such a listbox =
on the MSDN (but I heard that this implementation is errorneous..)

HTH,

Tim Hagemann
ifa informationssysteme

The original mail was :

From	: Benjamin B. Brouse
Sent	: 1996/08/20 02:48
To	: mfc-l@netcom.com
CC	:=20
Subject	: CListCtrl problems

Enviroment: VC++4.1, WIN95

My problem exists with the CListCtrl class. I would like to know if =
there
is anyway to override the size and range of the scrollbar associated =
with
the list control.  I am filling a list box with data by means of an ODBC
driver.  (this isn't a problem).   However, the odbc calls begin to take
forever.  Therefore, i am intercepting the the WM_VSCROLL messages and
filling and deleting the listbox as needed.  This provides drastic speed
increases.  Now if I could only utilize something like the =
SetScrollRange
fcn.  Any help would be appreciated.

-------------------------------
Benjamin B. Brouse=20
Sytel, Inc.
brouse@innernet.net
-------------------------------



Roger Onslow -- Roger_Onslow@compsys.com.au
Tuesday, August 27, 1996

>Benjamin,
>
>I think you try to display the contents of a database in a list control.
>This is generally not a good idea, because you have to
>enumerate the whole database to get your control filled.
>Even when you fill the control in a second thread, allowing the user
>to select the already loaded entries, this is bad coding style (personal 
opinion).
>You should use a so called "virtual list box", which does load the
>entries when it needs them. I think for Win16 MS provided such a
>listbox on the MSDN (but I heard that this implementation is errorneous..)
>
>HTH,
>
>Tim Hagemann
>ifa informationssysteme
>
>The original mail was :
>
>From : Benjamin B. Brouse
>Sent : 1996/08/20 02:48
>To : mfc-l@netcom.com
>CC : 
>Subject : CListCtrl problems
>
>Enviroment: VC++4.1, WIN95
>
>My problem exists with the CListCtrl class. I would like to know if there
>is anyway to override the size and range of the scrollbar associated with
>the list control.  I am filling a list box with data by means of an ODBC
>driver.  (this isn't a problem).   However, the odbc calls begin to take
>forever.  Therefore, i am intercepting the the WM_VSCROLL messages and
>filling and deleting the listbox as needed.  This provides drastic speed
>increases.  Now if I could only utilize something like the SetScrollRange
>fcn.  Any help would be appreciated.
>
>-------------------------------
>Benjamin B. Brouse 
>Sytel, Inc.
>brouse@innernet.net
>-------------------------------

How about using CListCtrl and using the call back method for items.  That way 
you only need to know the *number* of values required, and the list control 
will only ask your database class for the items it requires (via the 
callback).  Look at help on CListControl for info on using callbacks for list 
control items (you supply a specaial value instead of string for items, and 
handle a getdispinfo message for each line required for display by the list 
control).

Roger



Stuart Downing -- stuartd@izzy.net
Thursday, August 29, 1996

We used the callback technique in our program, and it did help to
improve performance.  However, I have a couple caveats and a
suggestion...

1)  Make sure you call CListCtrl::SetItemCount to the number of records
before you initialize the list elements.  This allows the control to
allocate memory for its data structures once up front

2)  When we profiled our program, we discovered that for a large number
of items in the list (>2000) it still took significant time to
initialize the list because you have to insert each item the list.
There is no way to initialize a batch of identical (callback) list
items.  This is a linear cost (that we didn't discover any way around),
so if you have a lot of items you might want to consider...

3)  Use Objective Grid's CGXGridWnd class.  It has a SetRowCount member
that lets you set the count with one call.  It also supports callbacks,
and we were able to get it to look and behave pretty much like a
CListCtrl.

------------------------ Stuart Downing Creative Solutions, Inc.
stuartd@izzy.net



---------- From:  Roger Onslow/Newcastle/Computer Systems
Australia/AU[SMTP:Roger_Onslow@compsys.com.au] Sent:  Tuesday, August
27, 1996 6:20 AM To:  Tim Hagemann; brouse; mfc-l Subject:  RE:
CListCtrl problems

>Benjamin, > >I think you try to display the contents of a database in
a list control.  >This is generally not a good idea, because you have
to >enumerate the whole database to get your control filled.  >Even
when you fill the control in a second thread, allowing the user >to
select the already loaded entries, this is bad coding style (personal
opinion).  >You should use a so called "virtual list box", which does
load the >entries when it needs them. I think for Win16 MS provided
such a >listbox on the MSDN (but I heard that this implementation is
errorneous..) > >HTH, > >Tim Hagemann >ifa informationssysteme > >The
original mail was :  > >From : Benjamin B. Brouse >Sent : 1996/08/20
02:48 >To : mfc-l@netcom.com >CC :  >Subject : CListCtrl problems >
>Enviroment: VC++4.1, WIN95 > >My problem exists with the CListCtrl
class. I would like to know if there >is anyway to override the size
and range of the scrollbar associated with >the list control.  I am
filling a list box with data by means of an ODBC >driver.  (this isn't
a problem).   However, the odbc calls begin to take >forever.
Therefore, i am intercepting the the WM_VSCROLL messages and >filling
and deleting the listbox as needed.  This provides drastic speed
>increases.  Now if I could only utilize something like the
SetScrollRange >fcn.  Any help would be appreciated.  >
>------------------------------- >Benjamin B. Brouse >Sytel, Inc.
>brouse@innernet.net >-------------------------------

How about using CListCtrl and using the call back method for items.
That way you only need to know the *number* of values required, and the
list control will only ask your database class for the items it
requires (via the callback).  Look at help on CListControl for info on
using callbacks for list control items (you supply a specaial value
instead of string for items, and handle a getdispinfo message for each
line required for display by the list control).

Roger




Gene Sewell -- genes@fast.net
Wednesday, September 04, 1996

Sorry not to have responded sooner....

You might do what I have done, and implement a virtual list box.  A virtual
list box only has as many strings as is seen on the screen, but acts like a
window into the entire database.  For example, I can allow the user to
scroll through a 60k record database instantly.

I've posted the concepts and code for this to this forum a couple of times
to this forum, but would be happy to send you the same.
>
>My problem exists with the CListCtrl class. I would like to know if there
>is anyway to override the size and range of the scrollbar associated with
>the list control.  I am filling a list box with data by means of an ODBC
>driver.  (this isn't a problem).   However, the odbc calls begin to take
>forever.  Therefore, i am intercepting the the WM_VSCROLL messages and
>filling and deleting the listbox as needed.  This provides drastic speed
>increases.  Now if I could only utilize something like the SetScrollRange
>fcn.  Any help would be appreciated.
>
>-------------------------------
>Benjamin B. Brouse 
>Sytel, Inc.
>brouse@innernet.net
>-------------------------------
>
----
"You know quite well, deep within you, that there is only a single magic, a
single power, a single salvation...and that is called loving.  Well, then, love
your suffering.  Do not resist it, do not flee from it.  It is your aversion
that hurts, nothing else."
                                        --Hermann Hesse





| Вернуться в корень Архива |