- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
function WindowProc(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM ): LRESULT; stdcall;
type
Item = record
szItemNr: array[0..8] of char;
szItem: array[0..32] of char;
szItemDescription: array[0..32] of char;
end;
var
ListColumn: LV_COLUMN;
ListItem: LV_ITEM;
begin
// In case of Msg ...
case Msg of
WM_CREATE: // Create?
begin
// Create list
ListView := CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, '', WS_VISIBLE Or WS_CHILD Or LVS_REPORT Or LVS_SHOWSELALWAYS,
10, 10, 524, 300, Wnd, 0, hInstance, nil);
ListView_SetExtendedListViewStyle(ListView, LVS_EX_FULLROWSELECT Or LVS_EX_GRIDLINES);
// Filling list columns
with ListColumn do begin
mask := LVCF_FMT Or LVCF_WIDTH Or LVCF_TEXT Or LVCF_SUBITEM;
fmt := LVCFMT_LEFT;
iSubItem := 0;
cx := 200;
pszText := 'File name';
ListView_InsertColumn(ListView, 0, ListColumn);
iSubItem := 1;
cx := 250;
pszText := 'Folder path';
ListView_InsertColumn(ListView, 1, ListColumn);
iSubItem := 2;
cx := 70;
pszText := 'File size';
ListView_InsertColumn(ListView, 2, ListColumn);
end;
with ListItem do begin
mask := LVIF_TEXT;
iItem := 1;
iSubItem := 1;
pszText := PChar('test');
cchTextMax := SizeOf(PChar('test')) + 1;
end;
ListView_InsertItem(ListView, ListItem);
ListView_SetItemText(ListView, 1, 1, PChar('Hello world!'));
// Create static text, progress bar and buttons
StaticText := CreateWindowEx(0, 'Static', '', WS_CHILD Or WS_VISIBLE Or SS_CENTER,
10, 310, 524, 16, Wnd, ID_StaticText, hInstance, 0);
ProgressBar := CreateWindowEx(0, PROGRESS_CLASS, nil, WS_CHILD Or WS_VISIBLE Or PBS_SMOOTH,
9, 326, 525, 17, Wnd, ID_ProgressBar, hInstance, nil);
Button_Start := CreateWindowEx(WS_EX_STATICEDGE, 'Button', 'Start', BS_DEFPUSHBUTTON Or WS_VISIBLE Or WS_CHILD,
150, 350, 70, 25, Wnd, ID_Button_Start, hInstance, nil );
Button_Pause := CreateWindowEx(WS_EX_STATICEDGE, 'Button', 'Pause', WS_VISIBLE Or WS_CHILD Or WS_DISABLED,
230, 350, 70, 25, Wnd, ID_Button_Pause, hInstance, nil );
Button_Stop := CreateWindowEx(WS_EX_STATICEDGE, 'Button', 'Stop', WS_VISIBLE Or WS_CHILD Or WS_DISABLED,
310, 350, 70, 25, Wnd, ID_Button_Stop, hInstance, nil );
end;
WM_DESTROY: // Closing?
begin
PostQuitMessage(0);
Result := 0;
Exit; // Bye.
end;
WM_COMMAND: // Any command?
case LoWord(wParam) of
// ....................................
end;
end;
Пристрелите меня кто-нибудь. Или объясните, как работает этот волшебный listview %)