Click here to Skip to main content
15,887,135 members
Articles / Desktop Programming / Win32

How to edit listview subitems in Win32

Rate me:
Please Sign up or sign in to vote.
1.68/5 (11 votes)
9 Aug 2008CPOL 51.4K   951   20   6
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

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

2. Processing control notifications

C++
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

C++
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Cuba Cuba
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionFIX THE GOD DAMN LINKS PLEASE Pin
edwardking7-Feb-18 4:40
edwardking7-Feb-18 4:40 
QuestionLinks are broken! Pin
_carra_13-Sep-13 9:24
_carra_13-Sep-13 9:24 
GeneralJust perfect! Big thanks! :-) Pin
jur200225-Nov-09 10:46
jur200225-Nov-09 10:46 
QuestionIn a dialog? Pin
lamerjack2-Mar-09 7:08
lamerjack2-Mar-09 7:08 
AnswerRe: In a dialog? Pin
koloko27-Oct-09 10:51
koloko27-Oct-09 10:51 
GeneralThanks! Pin
priling22216-Dec-08 1:35
priling22216-Dec-08 1:35 

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.