Click here to Skip to main content
15,920,217 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionadd column into control CListCtrl Pin
durban26-Apr-09 1:16
durban26-Apr-09 1:16 
AnswerRe: add column into control CListCtrl Pin
_AnsHUMAN_ 6-Apr-09 1:33
_AnsHUMAN_ 6-Apr-09 1:33 
GeneralRe: add column into control CListCtrl Pin
Iain Clarke, Warrior Programmer6-Apr-09 1:47
Iain Clarke, Warrior Programmer6-Apr-09 1:47 
GeneralRe: add column into control CListCtrl Pin
_AnsHUMAN_ 6-Apr-09 1:52
_AnsHUMAN_ 6-Apr-09 1:52 
GeneralRe: add column into control CListCtrl Pin
Iain Clarke, Warrior Programmer6-Apr-09 2:07
Iain Clarke, Warrior Programmer6-Apr-09 2:07 
GeneralRe: add column into control CListCtrl Pin
Rajesh R Subramanian6-Apr-09 3:41
professionalRajesh R Subramanian6-Apr-09 3:41 
JokeRe: add column into control CListCtrl Pin
Cedric Moonen6-Apr-09 3:48
Cedric Moonen6-Apr-09 3:48 
AnswerRe: add column into control CListCtrl Pin
Iain Clarke, Warrior Programmer6-Apr-09 1:39
Iain Clarke, Warrior Programmer6-Apr-09 1:39 
I can make a few incorrect lines too - but what didn't work with them?

Maybe you can't add column 6 without having added columns 1,2,3,4 and 5...

When I struggle with something new to me in MFC, I go back to fundamentals - HWND's and messages...

Here is a page from the REAL documentation - the Platform SDK.
Adding List-View Columns
Columns are used when a list-view control is in report view to display the items and subitems. The following example adds columns to a list-view control. The column headings are defined in the application's header file as string resources, which are numbered consecutively starting with IDS_FIRSTCOLUMN. The number of columns is defined in the header file as C_COLUMNS.

// InitListViewColumns - adds columns to a list-view control. 
// Returns TRUE if successful, or FALSE otherwise. 
// hWndListView - handle to the list-view control. 
BOOL InitListViewColumns(HWND hWndListView) 
{ 
    char szText[256];     // temporary buffer 
    LVCOLUMN lvc; 
    int iCol; 
 
    // Initialize the LVCOLUMN structure.
    // The mask specifies that the format, width, text, and subitem
    // members of the structure are valid. 
    lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; 
     
    // Add the columns. 
    for (iCol = 0; iCol < C_COLUMNS; iCol++) 
	{ 
        lvc.iSubItem = iCol;
        lvc.pszText = szText;	
        lvc.cx = 100;           // width of column in pixels
        if ( iCol < 2 )
          {
          lvc.fmt = LVCFMT_LEFT;  // left-aligned column
          }
        else
          { 
          lvc.fmt = LVCFMT_RIGHT;  // right-aligned column
          }  
        LoadString(hInst, IDS_FIRSTCOLUMN + iCol, 
                szText, sizeof(szText));
        if (ListView_InsertColumn(hWndListView, iCol, &lvc) == -1) 
            return FALSE; 
    } 
    return TRUE; 
}


You can adapt this for your purposes if you wish - I certainly wouldn't stay with the code as is, but it might start you on the right road.

Iain.

In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!

QuestionDividing property shett into two parts Pin
irshad13856-Apr-09 0:48
irshad13856-Apr-09 0:48 
AnswerRe: Dividing property shett into two parts Pin
Iain Clarke, Warrior Programmer6-Apr-09 1:53
Iain Clarke, Warrior Programmer6-Apr-09 1:53 
QuestionPostNCDestroy Problem Pin
S p k 5216-Apr-09 0:33
S p k 5216-Apr-09 0:33 
AnswerRe: PostNCDestroy Problem Pin
Iain Clarke, Warrior Programmer6-Apr-09 1:30
Iain Clarke, Warrior Programmer6-Apr-09 1:30 
QuestionRe: PostNCDestroy Problem Pin
David Crow6-Apr-09 3:18
David Crow6-Apr-09 3:18 
AnswerRe: PostNCDestroy Problem Pin
S p k 5216-Apr-09 18:10
S p k 5216-Apr-09 18:10 
Questionsource code for distributed mutual exclusion Pin
shriyangika5-Apr-09 23:45
shriyangika5-Apr-09 23:45 
QuestionRe: source code for distributed mutual exclusion Pin
CPallini5-Apr-09 23:58
mveCPallini5-Apr-09 23:58 
QuestionMFC Visual Studio Project Never Gets Updated Pin
phydthekid5-Apr-09 23:30
phydthekid5-Apr-09 23:30 
AnswerRe: MFC Visual Studio Project Never Gets Updated Pin
kakan6-Apr-09 1:17
professionalkakan6-Apr-09 1:17 
QuestionRe: MFC Visual Studio Project Never Gets Updated Pin
phydthekid6-Apr-09 2:46
phydthekid6-Apr-09 2:46 
AnswerRe: MFC Visual Studio Project Never Gets Updated Pin
kakan6-Apr-09 3:11
professionalkakan6-Apr-09 3:11 
AnswerRe: MFC Visual Studio Project Never Gets Updated Pin
phydthekid7-Apr-09 23:24
phydthekid7-Apr-09 23:24 
GeneralRe: MFC Visual Studio Project Never Gets Updated Pin
kakan8-Apr-09 1:45
professionalkakan8-Apr-09 1:45 
QuestionHow to get the total time of the wav file. Pin
Deepu Antony5-Apr-09 23:01
Deepu Antony5-Apr-09 23:01 
AnswerRe: How to get the total time of the wav file. Pin
David Crow6-Apr-09 3:25
David Crow6-Apr-09 3:25 
GeneralRe: How to get the total time of the wav file. Pin
Deepu Antony6-Apr-09 3:40
Deepu Antony6-Apr-09 3:40 

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.