| View previous topic :: View next topic |
| Author |
Message |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jul 12, 2008 12:07 pm Post subject: [C++]Multi-Column List Box (or an alternative?) |
|
|
How do I add columns, like in a GridBox control, so it'll look like Cheat Engine's Cheat Table, there's "Freeze" column, "Description" column, etc...
Oh, and:
| msdn wrote: | | List boxes with the LBS_MULTICOLUMN style cannot be vertically scrolled. The list box ignores any WM_VSCROLL messages it receives. |
Is this some kind of joke?
Or is there an alternative for multicolumn list box? |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Jul 12, 2008 12:12 pm Post subject: |
|
|
Headers _________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jul 12, 2008 12:15 pm Post subject: |
|
|
Thanks for the quick answer.
But what about scrolling? |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Jul 12, 2008 12:26 pm Post subject: |
|
|
Lol. Just set WM_HSCROLL AND WM_VSCROLL (if you have to). I don't think you have to set LBS_MULTICOLUMN for headers. I think the thing with LBS_MULTICOLUMN was that it would put it in more than one column, but it wouldn't be like headers. So that's why there wasn't WM_VSCROLL. _________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jul 12, 2008 12:51 pm Post subject: |
|
|
Ok, I understand how to add headers, but my ListBox is still one column...:
There's also another item below the header and when I click it, the header goes to the back.
The header isn't above the list box, its right on it. |
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sat Jul 12, 2008 1:42 pm Post subject: |
|
|
Don't tab stops affect multi column behavior? _________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jul 12, 2008 2:01 pm Post subject: |
|
|
I'm not using LBS_MULTICOLUMN.
When I do, the item doesn't doesn't move with the header, how do I add an item for each column?
When I add an item, it belongs to the ListBox, not to the column.
I couldn't find anything on MSDN...  |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat Jul 12, 2008 2:06 pm Post subject: |
|
|
why not add commctrl.h and use the ListView control instead of the ListBox.
from there its all
LVCOLUMN struct
ListView_InsertColumn macro
LVITEM struct
ListView_InsertItem macro
ListView_SetItem macro (for adding to columns other then the first one)
if u want the checkbox's you can use the extended style LVS_EX_CHECKBOXES with ListView_SetExtendedListViewStyle and the item of the first column will have a checkbox. _________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jul 12, 2008 2:35 pm Post subject: |
|
|
Thanks.
Umm, I'm trying to insert an item using "ListView_InsertItem", but its not working:
| Code: | LVITEM i;
i.pszText = "....";
...
...
other parameters I don't know what they're for...
...
...
ListView_InsertItem(h,&i); |
I couldn't find anything on google that explains what are all these parameters for or how to use the ListView control.
By the way:
| Code: | | SendMessage(h, LB_ADDSTRING, 0, (LPARAM)"..."); |
worked fine.
But I couldn't figure out how to add a column this way or another.  |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat Jul 12, 2008 2:42 pm Post subject: |
|
|
heres how u do it for columns.
| Code: | LVCOLUMN LvCol;
memset( &LvCol, 0, sizeof(LVCOLUMN) );
LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
LvCol.cx = 50;
LvCol.pszText =_T("Freeze");
SendMessage( hList, LVM_INSERTCOLUMN, 0, (LPARAM)&LvCol ); |
I used SendMessage, you can also use ListView_InsertColumn macro.
Heres items
| Code: | LVITEM LvItem;
memset( &LvItem, 0, sizeof(LVITEM) );
LvItem.mask = LVIF_TEXT;
LvItem.cchTextMax = 256;
LvItem.iItem = 0;
LvItem.iSubItem = 0;
LvItem.pszText = _T("Item1");
SendMessage( hList, LVM_INSERTITEM, 0, (LPARAM)&LvItem );
LvItem.iSubItem = 1;
LvItem.pszText = _T("SubItem1")
SendMessage( hList, LVM_SETITEM, 0, (LPARAM)&LvItem ); |
_________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jul 12, 2008 2:58 pm Post subject: |
|
|
Edit: Uh, not working?
I think I'm missing some .dll or .lib files.
Do I need to call InitCommonControls(Ex)? |
|
| Back to top |
|
 |
Cx Master Cheater
Reputation: 0
Joined: 27 Jul 2007 Posts: 367
|
Posted: Sat Jul 12, 2008 3:21 pm Post subject: |
|
|
Yes.
| Code: |
#include <windows.h>
#include <commctrl.h>
INITCOMMONCONTROLSEX iccx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_LISTVIEW_CLASSES; // and whatever else...
if (InitCommonControlsEx(&InitCtrlEx))
{
// Create window(s).
|
_________________
armed with this small butterfly net
i will face the world alone
& never be lonely. |
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jul 12, 2008 3:31 pm Post subject: |
|
|
I tried that, it said "unresolved externals" for both InitCommonContorls and InitCommonControlsEx, thats why I said I think I was missing some files.
I just checked, I'm missing commctrl.lib and commctrl.dll. (if those are the ones needed for InitCommonControls) |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat Jul 12, 2008 4:20 pm Post subject: |
|
|
| Code: | | #pragma comment ( lib, "comctl32.lib" ) |
and if you want visual style:
| Code: | #pragma comment ( linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
_________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Jul 12, 2008 5:26 pm Post subject: |
|
|
Thanks, it fixed the error, but I still can't use ListView:
Sending LB_ADDSTRING message works, however this code:
| Code: | LVCOLUMN LvCol;
memset( &LvCol, 0, sizeof(LVCOLUMN) );
LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
LvCol.cx = 50;
LvCol.pszText = L"Item";
SendMessage( h, LVM_INSERTCOLUMN, 0, (LPARAM)&LvCol ); |
Doesn't do anything.
Is it just for me? |
|
| Back to top |
|
 |
|