Archived

This topic is now archived and is closed to further replies.

A Table Control?

This topic is 4945 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''ve made a Search and Replace program in C++, that searches multiple directories and multiple files to search and replace, but what I would like to do, is create like a scrollable table that displays what the filename, and the number of times it had a replace done in it..much like a list box, but with 2 columns instead of one. I have no idea to go about this at all. I was wondering maybe you could embed an excel table or something in it? what are the common ways of doing what i''m doing? btw I''m using the Win32 API only. thanks kag

Share this post


Link to post
Share on other sites
I would utilize a list box with multiple column headings like this:

//By Bengi

case WM_INITDIALOG:
{
int i;
char Temp[255];

SetFocus(hWnd);
hList=GetDlgItem(hWnd,IDC_LIST); // get the ID of the ListView

SendMessage(hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS_EX_FULLROWSELECT); // Set style


// Here we put the info on the Coulom headers

// this is not data, only name of each header we like

memset(&LvCol,0,sizeof(LvCol)); // Reset Coluom

LvCol.mask=LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM; // Type of mask

LvCol.cx=0x28; // width between each coloum

LvCol.pszText="Item"; // First Header

LvCol.cx=0x42;

// Inserting Columns as much as we want

SendMessage(hList,LVM_INSERTCOLUMN,0,(LPARAM)&LvCol); // Insert/Show the coloum

LvCol.pszText="Sub Item1"; // Next coloum

SendMessage(hList,LVM_INSERTCOLUMN,1,(LPARAM)&LvCol); // ...

LvCol.pszText="Sub Item2"; //

SendMessage(hList,LVM_INSERTCOLUMN,2,(LPARAM)&LvCol); //

LvCol.pszText="Sub Item3"; //

SendMessage(hList,LVM_INSERTCOLUMN,3,(LPARAM)&LvCol); //

LvCol.pszText="Sub Item4"; //

SendMessage(hList,LVM_INSERTCOLUMN,4,(LPARAM)&LvCol); //

LvCol.pszText="Sub Item5"; //

SendMessage(hList,LVM_INSERTCOLUMN,5,(LPARAM)&LvCol); // ...same as above


memset(&LvItem,0,sizeof(LvItem)); // Reset Item Struct


// Setting properties Of Items:


LvItem.mask=LVIF_TEXT; // Text Style

LvItem.cchTextMax = 256; // Max size of test


LvItem.iItem=0; // choose item

LvItem.iSubItem=0; // Put in first coluom

LvItem.pszText="Item 0"; // Text to display (can be from a char variable) (Items)


SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&LvItem); // Send to the Listview


for(i=1;i<=5;i++) // Add SubItems in a loop

{
LvItem.iSubItem=i;
sprintf(Temp,"SubItem %d",i);
LvItem.pszText=Temp;
SendMessage(hList,LVM_SETITEM,0,(LPARAM)&LvItem); // Enter text to SubItems

}

// lets add a new Item:

LvItem.iItem=1; // choose item

LvItem.iSubItem=0; // Put in first coluom

LvItem.pszText="Item 1"; // Text to display (can be from a char variable) (Items)

SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&LvItem); // Send to the Listview


for(i=1;i<=5;i++) // Add SubItems in a loop

{
LvItem.iSubItem=i;
sprintf(Temp,"SubItem %d",i);
LvItem.pszText=Temp;
SendMessage(hList,LVM_SETITEM,0,(LPARAM)&LvItem); // Enter etxt to SubItems

}


return TRUE; // Always True

}
break;

You can define as many columns as you want this way.

I can e-mail you the source code show casing this if you want.

For information regarding how to obtain the filename and/or instances that it has been replaced - just allocate an array to hold the names and a counter for each instance found. Take that information and place it into your list box.

Hope that helps.

Share this post


Link to post
Share on other sites