Thanks to visit codestin.com
Credit goes to www.codeproject.com

65.9K
CodeProject is changing. Read more.
Home

How to edit listview subitems in Win32

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.68/5 (7 votes)

Aug 9, 2008

CPOL
viewsIcon

52076

downloadIcon

962

Shows how to edit listview subitem text without using MFC.

Introduction

This is the first article I submit to CodeProject so I want the more experienced members to help me. I don't known English very well, but I'll try my best.

This article tries to explain how to allow listview controls to edit its subitems like in spreadsheet controls. The code is written using the Win32 Native API as a counterpart of existing code written in MFC. Please tell me what you think and what I can do to improve it. Thanks in advance.

Using the code

In order to use the code, you must use two files: "StrViewWnd.cpp" and "StrViewWnd.h". These two files are fully commented to explain what each line of code does.

1. Creating the control

case WM_CREATE:
{
    // Here create the listview
    CreateStringView(hWnd,ID_LIST);
    ...
}
break;

2. Processing control notifications

case WM_NOTIFY:
{
    LPNMHDR lpnmHdr = (LPNMHDR)lParam;

    switch(lpnmHdr->idFrom)
    {
        // catch its notify events
        case ID_LIST: // ID_LIST is the listview id
            return OnStrViewNotify(wParam,lParam);
    }
}
break;

3. Reverting changes

case WM_DESTROY:
        // call Revert() to restore original listview window procedure
        Revert();
        PostQuitMessage(0);
        break;

Ending

Well, that's all. I hope you enjoy it. Please send me your opinions, suggestions, etc.