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 141 142
|
#include "BsolListView.h"
//Globale Variables:
WNDPROC lvOriginWndProc_g;
// Old globale variable already defined in other file
extern BsolEventHandler * lvEventHandler_g;
extern const int maxMsgNum_g;
namespace BsolControls {
BsolListView::BsolListView (BsolClass * class_p) {
this->LvClass.BsolSetClass (class_p->ctrlName, class_p->ctrlId, class_p->ctrlText,
class_p->X, class_p->Y, class_p->width, class_p->hight,
class_p->ctrlLTR, class_p->ctrlStyle, class_p->rowNum,
class_p->extra1, class_p->extra2, class_p->extra3);
this->LvWnd = NULL;
this->LvNumCol = class_p->extra1;
}
HWND BsolListView::BsolLvCreate (BsolWindow * prntWnd_p) {
DWORD style_v, styleEx_v;
int X_v, Y_v, W_v, H_v, ctrlId_v;
X_v = this->LvClass.X;
Y_v = this->LvClass.Y;
W_v = this->LvClass.width;
H_v = this->LvClass.hight;
ctrlId_v = this->LvClass.ctrlId;
styleEx_v = LVS_EX_FULLROWSELECT;
style_v = WS_CHILD | //WS_SIZEBOX | //WS_SYSMENU |
// WS_BORDER | WS_CAPTION |
LVS_OWNERDATA | LVS_EDITLABELS | LVS_REPORT;// | LVS_EX_GRIDLINES;
this->LvWnd = CreateWindowEx(styleEx_v, WC_LISTVIEW, TEXT("List Of Values"),
style_v, X_v, Y_v, W_v, H_v,
prntWnd_p->BsolGetWndHandle(),
(HMENU)ctrlId_v, prntWnd_p->BsolGetInstance(), NULL);
lvOriginWndProc_g = (WNDPROC)BsolMSDN_SetWindowLong (this->LvWnd, GWL_WNDPROC,
(long)BsolListViewProcedure,
TEXT("BsolListView:SetWindowLong"));
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_STANDARD_CLASSES | ICC_COOL_CLASSES | ICC_LISTVIEW_CLASSES;
// Initialize ListView Columns
this->BsolLvInitColumns();
// Initialize ListView Items
this->BsolLvInitItems();
ShowWindow (this->LvWnd, SW_SHOW);
return this->LvWnd;
}
// Initialize Columns of List View
long BsolListView::BsolLvInitColumns () {
WCHAR szText[256]; // Temporary buffer.
int iCol;
// Initialize the LVCOLUMN structure.
// The mask specifies that the format, width, text,
// and subitem members of the structure are valid.
this->LvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
// Add the columns.
for (iCol = 0; iCol < this->LvNumCol; iCol++) {
this->LvColumn.iSubItem = iCol;
this->LvColumn.pszText = szText;
this->LvColumn.cx = 100; // Width of column in pixels.
if ( iCol < 2 )
this->LvColumn.fmt = LVCFMT_LEFT; // Left-aligned column.
else
this->LvColumn.fmt = LVCFMT_RIGHT; // Right-aligned column.
// Load the names of the column headings from the string resources.
LoadString(NULL, //eArgs_p->ehIns,
2650 + iCol,
szText,
sizeof(szText)/sizeof(szText[0]));
// Insert the columns into the list view.
if (ListView_InsertColumn(this->LvWnd, iCol, &this->LvColumn) == -1)
return FALSE;
}
return 1;
}
// Inserting Items into List View
long BsolListView::BsolLvInitItems () {
int index = -1;
// Initialize LVITEM members that are common to all items.
this->LvItem.pszText = 0;// LPSTR_TEXTCALLBACK; // Sends an LVN_GETDISPINFO message.
this->LvItem.mask = LVIF_TEXT | LVIF_IMAGE |LVIF_STATE;
this->LvItem.stateMask = 0;
this->LvItem.iSubItem = 0;
this->LvItem.state = 0;
// Initialize LVITEM members that are different for each item.
for (int i = 0; i < 2; i++) {
this->LvItem.iItem = i;
this->LvItem.iImage = i;
// Insert items into the list.
index = ListView_InsertItem(this->LvWnd, &this->LvItem);
if (index == -1)
return FALSE;
}
return index;
}
. . .
long BsolListView::BsolListViewProcedure (HWND hWnd_p, UINT msg_p, WPARAM wParam_p, LPARAM lParam_p) {
char * msgStr_v;
BsolEventHandler::BsolEventArgs eArgs_v;
msgStr_v = BsolPrintWindowMessages (msg_p, "---------- BsolListView");
for (int i = 0; i < maxMsgNum_g; i++) {
if (lvEventHandler_g->eHandler[i].mCode == msg_p) {
eArgs_v.ehWnd = hWnd_p;
eArgs_v.eMsg = msg_p;
eArgs_v.ewParam = wParam_p;
eArgs_v.elParam = lParam_p;
lvEventHandler_g->eHandler[i].functionPtr(&eArgs_v);
break;
}
}
return CallWindowProc (lvOriginWndProc_g, hWnd_p, msg_p, wParam_p, lParam_p);
}
}
|