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
|
#define _WIN32_IE 0x0300
#include <windows.h>
#include <commctrl.h>
#include "resources.h"
#define IDM_CODE_SAMPLES 1
HINSTANCE hInst;
HWND CreateListView(HWND hwnd)
{
INITCOMMONCONTROLSEX icex;
icex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&icex);
HWND hWndListView = CreateWindowW(WC_LISTVIEWW, L"", WS_CHILD | LVS_REPORT,
5, 5, 150, 450, hwnd, (HMENU)IDM_CODE_SAMPLES, hInst, NULL);
return(hWndListView);
}
BOOL InitListViewColumns(HWND hWndListView)
{
WCHAR szText[256];
LVCOLUMN lvc;
int iCol;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
for(iCol = 0; iCol < C_COLUMNS; iCol++)
{
lvc.iSubItem = iCol;
lvc.pszText = szText;
lvc.cx = 100;
if(iCol < 2)
lvc.fmt = LVCFMT_LEFT;
else
lvc.fmt = LVCFMT_RIGHT;
LoadString(hInst, IDC_FIRSTCOLUMN, +iCol, sizeof(szText)/sizeof(szText[0]));
if(ListView_InsertColumn(hWndListView, iCol, &lvc) == -1);
return FALSE;
}
return TRUE;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProcW(hwnd, msg, wp, lp);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int nCmdShow)
{
HWND hwnd;
WNDCLASSW wc = {0};
wc.hbrBackground = (HBRUSH)COLOR_WINDOW + 1;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInst;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = L"myWindowClass";
if(!RegisterClassW(&wc))
return -1;
hwnd = CreateWindowW(L"myWindowClass", L"List View", WS_OVERLAPPEDWINDOW,
350, 120, 700, 500, NULL, NULL, NULL, NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
MSG msg = {0};
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
| |