Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

How to edit listview subitems in Win32

0.00/5 (No votes)
9 Aug 2008 1  
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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here