Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef UNICODE
- #define UNICODE
- #endif
- #include <Windows.h>
- #include <CommCtrl.h>
- #define LoadFilesButtonClicked 1
- #define SortFilesButtonClicked 2
- struct FileData {
- const wchar_t* fileName;
- const FILETIME* fileTime;
- };
- LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- HWND hEdit, hListViewLeft, hListViewRight, hLoadButton, hSortButton;
- void AddColumns(HWND hListView)
- {
- LVCOLUMN lvCol = { };
- lvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
- lvCol.cx = 100;
- lvCol.pszText = (LPWSTR)L"Index";
- ListView_InsertColumn(hListView, 0, &lvCol);
- lvCol.cx = 100;
- lvCol.pszText = (LPWSTR)L"File Name";
- ListView_InsertColumn(hListView, 1, &lvCol);
- lvCol.cx = 300;
- lvCol.pszText = (LPWSTR)L"Last Access Time";
- ListView_InsertColumn(hListView, 2, &lvCol);
- }
- void AddItemToListView(HWND hListView, int index, FileData* fileData)
- {
- LVITEM lvItem;
- lvItem.mask = LVIF_TEXT;
- lvItem.iItem = index;
- lvItem.iSubItem = 0; //Позицию для вставки в колонку
- }
- void LoadFiles(HWND hListView, const wchar_t* directoryPath)
- {
- }
- void SortListView(HWND hListView) {
- }
- int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
- {
- const wchar_t CLASS_NAME[] = L"WINAPI_LAB1";
- WNDCLASS wc = { };
- wc.lpfnWndProc = WindowProc;
- wc.hInstance = hInstance;
- wc.lpszClassName = CLASS_NAME;
- RegisterClass(&wc);
- HWND hwnd = CreateWindowEx(0, CLASS_NAME, L"WINAPI_LAB1", WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
- NULL, NULL, hInstance, NULL
- );
- if (hwnd == NULL)
- {
- return 0;
- }
- ShowWindow(hwnd, nCmdShow);
- hEdit = CreateWindowEx(0, WC_EDIT, L"",
- WS_CHILD | WS_VISIBLE | WS_BORDER,
- 10, 10, 500, 20,
- hwnd, NULL, NULL, NULL);
- ShowWindow(hEdit, TRUE);
- hListViewLeft = CreateWindowEx(0, WC_LISTVIEW, L"",
- WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT,
- 10, 40, 370, 500,
- hwnd, NULL, NULL, NULL);
- ShowWindow(hListViewLeft, TRUE);
- hListViewRight = CreateWindowEx(0, WC_LISTVIEW, L"",
- WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT,
- 390, 40, 370, 500,
- hwnd, NULL, NULL, NULL);
- ShowWindow(hListViewRight, TRUE);
- AddColumns(hListViewLeft);
- AddColumns(hListViewRight);
- hLoadButton = CreateWindowEx(0, WC_BUTTON, L"Load Files",
- WS_CHILD | WS_VISIBLE,
- 530, 10, 80, 25,
- hwnd, (HMENU)LoadFilesButtonClicked, NULL, NULL);
- ShowWindow(hLoadButton, TRUE);
- hSortButton = CreateWindowEx(0, L"BUTTON", L"Sort Files",
- WS_CHILD | WS_VISIBLE,
- 680, 10, 80, 25,
- hwnd, (HMENU)SortFilesButtonClicked, NULL, NULL);
- ShowWindow(hLoadButton, TRUE);
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0) > 0)
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
- LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_CREATE:
- {
- }
- break;
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case LoadFilesButtonClicked:
- {
- wchar_t directoryPath[MAX_PATH];
- GetWindowText(hEdit, directoryPath, MAX_PATH);
- LoadFiles(hListViewLeft, directoryPath);
- }
- break;
- case SortFilesButtonClicked:
- SortListView(hListViewRight);
- break;
- }
- break;
- case WM_CLOSE:
- PostQuitMessage(0);
- break;
- case WM_DESTROY:
- return 0;
- default:
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement