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

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


Callback on CListCtrl

Colin Angus Mackay -- colin.angus.mackay@dial.pipex.com
Tuesday, June 25, 1996


[MFC 4.0 / Win95 & WinNT ]

I have seen that you can get a CListCtrl to receive its data from some 
function and not have it store the information in the list control itself, 
which would be infinitly more useful to my situation than the current 
setup. I have looked through the docs and am now really confused about how 
to go about this.

I have a class CDataPoints which contains the information that I wish to 
see in the list. How do I get the list to access this information? Each 
object of this class is equivalent to one line in the list view. Each 
contains multiple numbers of columns.

What I really want to know is how to I set up the list to call the class 
(or rather functions within the class) to get the information out of it, 
and how do I make sure that each line in the list calls the right object of 
type CDataPoints class and each column to call the right function, or send 
information to a function as to what data is needed?


Thanks in advance for any help you may be able to offer,

Colin.
colin.angus.mackay@dial.pipex.com






Roger Onslow -- Roger_Onslow@compsys.com.au
Saturday, June 29, 1996

Colin wrote
>What I really want to know is how to I set up the list to call the class 
>(or rather functions within the class) to get the information out of it, 
>and how do I make sure that each line in the list calls the right object of 
>type CDataPoints class and each column to call the right function, or send 
>information to a function as to what data is needed?

Quick answer here (I'm rather busy today)
When adding rows to the list, specify that you want callback and then put a 
pointer to the item object for the row in the lParam field (cast to a DWORD).
When handling the Getdispinfo message, you have access to the lParam field for 
that row, can cast it back to a pointer to your data and get the appropriate 
info by calling class members.
Alternatively, store a pointer to the whole object (rather than the individual 
items in it) in you dialog (or a class derived from CListCtrl) and then store 
an index into that object in lParam field.  You can then get at the item in you 
Getdispinfo handle by using the pointer to the whole object and the lParam 
index.

If you need further help, I can mail you more detailed instructions and/or 
sample code.

Hope this helps

           /|\        Roger Onslow
      ____|_|.\       ============
    _/.........\Senior Software Engineer
   /CCC.SSS..A..\
  /CC..SS...A.A..\   Computer
 /.CC...SS..AAA...\       Systems
/\.CC....SSAA.AA../            Australia
\ \.CCCSSS.AA.AA_/
 \ \...........//      Ph: +61 49 577155
  \ \...._____//      Fax: +61 49 675554
   \ \__|_/\_//    RogerO@compsys.com.au
    \/_/  \//






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