Link to home
Start Free TrialLog in
Avatar of Anbuselvan
Anbuselvan

asked on

ListView_InsertItem - Failed

Dear Experts,

I am trying to insert a new item into a ListView control.

The following code failes...

LVITEM stLVI;
char   szBuf[6];
memset(szBuf, '\0', sizeof(szBuf));
strcpy(szBuf,"Hello");
stLVI.pszText = szBuf;
stLVI.cchTextMax = sizeof(szBuf);
stLVI.iItem = 0;
stLVI.iSubItem = 0;
stLVI.mask = LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT;
stLVI.iImage = 2;
stLVI.lParam = 0;
ListView_InsertItem(listViewWindow,&stLVI);

Any suggestion?

Thanks in advance.

Regards
Anbuselvan
SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Anbuselvan
Anbuselvan

ASKER

Hi roshmon,

  Thanks for your immediate suggestion.

  But, I have already three columns in my report style listview.

  The given is working fine in my dialog based application with listview control.

  But, I am doing one hook application. I need to hook one theird party application and
  clear the list items and add a new item into that.

  Here, I am facing the problem that I have mentioned.

  Any suggestion?

Thanks in advance.

Regards,
Anbuselvan
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi roshmon,

The given links are very useful. Thanks.

Actually my code is working fine.

But, what I notised is wrong.

The given value is inserted successfully in the list control. But, it is not visibled. So, that I couldn't realised.

I can get the list count = 1.

But, I couldn't see the values in the list control.

Any possible reason?

Thanks.

Regards,
Anbu
Probably string that you are giving becoming out of scope.
I'm checking on that....
Rosh :)
Hi,

Have you  created the resource using the resource editor?
If so in the general page of the properties of the control there is an checkbox called visible.
Make sure that is ticked.
Even if you are creating the control dynamically then also during create you have to specify the VISIBLE style.

Regards,
ArchMD