include stdafx include CLstViewControl HWND CLstViewControl CreateList

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include "stdafx.h"
#include "CLstViewControl.h"
HWND CLstViewControl::CreateListView (HWND hWnd,HINSTANCE hInstance){
if ( !hWnd )
{
ListViewhWnd = CreateWindowEx (LVS_EX_FULLROWSELECT ,"SysListView32",NULL, WS_CHILD | LVS_REPORT | WS_VISIBLE | WS_BORDER ,0,0,280,200,hWnd,(HMENU)1004,hInstance,NULL);
SendMessage(ListViewhWnd,LVM_SETEXTENDEDLISTVIEWSTYLE,0, LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);
return ListViewhWnd;
}
else
{
ListView_SetExtendedListViewStyle (hWnd, LVS_EX_FLATSB | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
ListViewhWnd = hWnd;
return hWnd;
}
}
int CLstViewControl::InsertColumn (char* Title, int Index, int Width){
LVCOLUMN LvColumn;
memset(&LvColumn,0,sizeof(LvColumn));
LvColumn.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;
LvColumn.pszText=Title;
LvColumn.cx=Width;
SendMessage(ListViewhWnd,LVM_INSERTCOLUMN,Index,(LPARAM)&LvColumn);
return 1;
}
int CLstViewControl::InsertColumn (int Title, int Index, int Width, int AriphmeticSystem )
{
char NewTitle [25];
itoa ( Title, NewTitle, AriphmeticSystem );
strupr ( NewTitle );
int i = (int) strlen ( NewTitle );
memcpy ( NewTitle + (8-i), NewTitle, i );
NewTitle [8] = '\0';
memset ( NewTitle, '0', 8-i);
return InsertColumn ( NewTitle, Index, Width );
}
int CLstViewControl::InsertItem (char* Title, int Index){
LVITEM LvItem;
memset(&LvItem,0,sizeof(LvItem));
LvItem.mask=LVIF_TEXT; // Text Style
LvItem.cchTextMax = 256; // Max size of test
LvItem.iItem=Index; // choose item
LvItem.iSubItem=0; // Put in first coluom
LvItem.pszText=Title; // Text to display (can be from a char variable) (Items)
SendMessage(ListViewhWnd,LVM_INSERTITEM,0,(LPARAM)&LvItem); // Send to the Listview
return 1;
}
int CLstViewControl::InsertItem (int Title, int Index, int AriphmeticSystem )
{
char NewTitle [25];
itoa ( Title, NewTitle, AriphmeticSystem );
strupr ( NewTitle );
int i = (int) strlen ( NewTitle );
memcpy ( NewTitle + (8-i), NewTitle, i );
NewTitle [8] = '\0';
memset ( NewTitle, '0', 8-i);
return InsertItem ( NewTitle, Index );
}
int CLstViewControl::InsertSubItem (char* Title, int Index, int SubIndex){
memset(&LvItem,0,sizeof(LvItem));
int RetVal;
LvItem.mask=LVIF_TEXT; // Text Style
LvItem.cchTextMax = 256; // Max size of test
LvItem.iItem=Index;
LvItem.iSubItem=SubIndex;
LvItem.pszText=Title;
RetVal= (int) SendMessage(ListViewhWnd,LVM_SETITEM,0,(LPARAM)&LvItem);
return 1;
}
int CLstViewControl::InsertSubItem (int Title, int Index, int SubIndex, int AriphmeticSystem )
{
char NewTitle [25];
itoa ( Title, NewTitle, AriphmeticSystem );
strupr ( NewTitle );
int i = (int) strlen ( NewTitle );
memcpy ( NewTitle + (8-i), NewTitle, i );
NewTitle [8] = '\0';
memset ( NewTitle, '0', 8-i);
return InsertSubItem ( NewTitle, Index, SubIndex );
}
int CLstViewControl::GetSelected (){
return (int) SendMessage(ListViewhWnd,LVM_GETNEXTITEM,-1,LVNI_FOCUSED);
}
CLstViewControl::CLstViewControl(){
}
CLstViewControl::~CLstViewControl(){
}
int CLstViewControl::GetNumberOfItems (){
return (int) SendMessage(ListViewhWnd,LVM_GETITEMCOUNT,-1,LVSICF_NOINVALIDATEALL);
}
int CLstViewControl::DeleteAllItems (){
SendMessage(ListViewhWnd,LVM_DELETEALLITEMS,0,0);
return 1;
}
int CLstViewControl::DeleteItem (int Number){
return (int)SendMessage (ListViewhWnd,LVM_DELETEITEM,Number,NULL);
}
int CLstViewControl::SetItemText (int Number,char* Text){
memset(&LvItem,0,sizeof(LvItem));
int RetVal;
LvItem.mask=LVIF_TEXT; // Text Style
LvItem.cchTextMax = 256; // Max size of test
LvItem.iItem=Number;
LvItem.iSubItem=0;
LvItem.pszText=Text;
return RetVal= (int) SendMessage(ListViewhWnd,LVM_SETITEM,0,(LPARAM)&LvItem);
}
char* CLstViewControl::GetItemText (int Number){
ListView_GetItemText (ListViewhWnd,LVM_GETITEMTEXT,0,Txt,50);
return Txt;
}
int CLstViewControl::SetSelected (int Number){
ListView_SetItemState(ListViewhWnd,Number,LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED);
return 1;
}