Click here to Skip to main content
15,895,537 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalhelp! ADO - how to determine if a field is PK/FK Pin
devvvy25-Nov-02 23:22
devvvy25-Nov-02 23:22 
Generalany ADO/C++ solution? Pin
devvvy26-Nov-02 7:58
devvvy26-Nov-02 7:58 
GeneralCreate a font from the resource file Pin
Hernan Breinbauer25-Nov-02 16:16
Hernan Breinbauer25-Nov-02 16:16 
GeneralRe: Create a font from the resource file Pin
Scott H. Settlemier26-Nov-02 8:10
Scott H. Settlemier26-Nov-02 8:10 
Questionhow do you kill a dialog? Pin
trustno125-Nov-02 14:53
trustno125-Nov-02 14:53 
AnswerRe: how do you kill a dialog? Pin
Chris Losinger25-Nov-02 15:01
professionalChris Losinger25-Nov-02 15:01 
GeneralRe: how do you kill a dialog? Pin
trustno125-Nov-02 21:03
trustno125-Nov-02 21:03 
GeneralListview images in LVS_REPORT mode Pin
trimtrom25-Nov-02 13:37
trimtrom25-Nov-02 13:37 
Hello,

I am trying to construct a CListView in the LVS_REPORT mode, but I still want an icon at the beginning of each line entry. Is this possible? I can create the listview, and list all the data, but I cannot seem to make the icons appear.

I have written the following code:

Construction of the listview:

int CLPSListView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
lpCreateStruct->style |= LVS_REPORT;
if (CListView::OnCreate(lpCreateStruct) == -1)
return -1;

// Give the document a pointer to this view
GetDocument()->m_pListView = this;
return 0;
}

In another function where I initialise the data, I create the CImageList, and also the CListCtrlEx, which is a helper class for listviews I found in the MFC Help:

CListCtrlEx& ctlList = (CListCtrlEx&) GetListCtrl();
m_ctlImage.Create(16,16,ILC_COLOR,0,3);
HICON PTIcon = theApp.LoadIcon(IDB_CLOSED);
ASSERT(PTIcon);
m_ctlImage.Add(PTIcon);
PTIcon = theApp.LoadIcon(IDB_OPEN);
m_ctlImage.Add(PTIcon);
ctlList.SetImageList(&m_ctlImage);

I create the columns, no problem, and then use the CListCtrlEx method Additem:

var = rs.GetFieldValue("Readfld");
ctlList.AddItem(nItem,0,CCrack::strVARIANT(var),0);

The last zero refers to the imagelist index.

For completeness I attach the AddItem code in CListCtrlEx:-

BOOL CListCtrlEx::AddItem(int nItem,int nSubItem,LPCTSTR strItem,int nImageIndex)
{
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = nItem;
lvItem.iSubItem = nSubItem;
lvItem.pszText = (LPTSTR) strItem;
if(nImageIndex != -1){
lvItem.mask |= LVIF_IMAGE;
lvItem.iImage |= LVIF_IMAGE;
}
if(nSubItem == 0)
return InsertItem(&lvItem);
return SetItem(&lvItem);
}

I would be very grateful to anyone who can suggest how to make the icon appear at the beginning of the line in this Report mode.

Thanks,

Paul Trimming

GeneralRe: Listview images in LVS_REPORT mode Pin
Roman Fadeyev25-Nov-02 18:24
Roman Fadeyev25-Nov-02 18:24 
GeneralRe: Listview images in LVS_REPORT mode Pin
trimtrom26-Nov-02 9:27
trimtrom26-Nov-02 9:27 
GeneralPhone Bill Pin
Autunmsky25-Nov-02 13:28
Autunmsky25-Nov-02 13:28 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 14:46
protectorChristian Graus25-Nov-02 14:46 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 14:59
Autunmsky25-Nov-02 14:59 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 15:06
protectorChristian Graus25-Nov-02 15:06 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 15:31
Autunmsky25-Nov-02 15:31 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 15:39
protectorChristian Graus25-Nov-02 15:39 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 15:48
Autunmsky25-Nov-02 15:48 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 15:57
protectorChristian Graus25-Nov-02 15:57 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 16:09
Autunmsky25-Nov-02 16:09 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 16:15
protectorChristian Graus25-Nov-02 16:15 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 16:27
Autunmsky25-Nov-02 16:27 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 16:34
Autunmsky25-Nov-02 16:34 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 16:40
protectorChristian Graus25-Nov-02 16:40 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 16:44
Autunmsky25-Nov-02 16:44 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 16:48
protectorChristian Graus25-Nov-02 16:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.