diff options
author | John Ankarström <john@ankarstrom.se> | 2022-02-15 16:56:31 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-02-15 16:56:31 +0100 |
commit | c605ea0545ac22dc328c83d78011e3d18346eb63 (patch) | |
tree | b809214638566a8dc0621095c4be3fd721577b0c | |
parent | 2e5ea298da89df79fc057ad46253e5a9d860e7e3 (diff) | |
download | EpisodeBrowser-c605ea0545ac22dc328c83d78011e3d18346eb63.tar.gz |
Show data list view.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | c/datalistview.c | 20 | ||||
-rw-r--r-- | c/defs.h | 2 | ||||
-rw-r--r-- | c/episodelistview.c | 1 | ||||
-rw-r--r-- | c/listview.c | 2 | ||||
-rw-r--r-- | c/main.c | 33 | ||||
-rw-r--r-- | c/resource.h | 1 |
7 files changed, 48 insertions, 13 deletions
@@ -28,7 +28,7 @@ endif all: episode_browser.exe -episode_browser.exe: $(INPUTS) $(PROJECT_ROOT)Makefile +episode_browser.exe: $(INPUTS) $(PROJECT_ROOT)c/defs.h $(PROJECT_ROOT)Makefile swipl-ld -v $(CFLAGS) $(LDFLAGS) -goal true -o $@ $(INPUTS) $(EXTRA_CMDS) diff --git a/c/datalistview.c b/c/datalistview.c index 43cfeb6..873befc 100644 --- a/c/datalistview.c +++ b/c/datalistview.c @@ -6,10 +6,28 @@ HWND gDlv_hWnd; -void +HWND DlvCreate(HWND hWnd) { + HWND hListView; + LVCOLUMN lvc; + gDlv_hWnd = hWnd; + hListView = LvCreate(hWnd, (HMENU)IDC_DATALISTVIEW); + + lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM; + + lvc.iSubItem = 0; + lvc.pszText = TEXT("Key"); + lvc.cx = 42; + ListView_InsertColumn(hListView, 0, &lvc); + + lvc.iSubItem = 1; + lvc.pszText = TEXT("Value"); + lvc.cx = 500; + ListView_InsertColumn(hListView, 1, &lvc); + + return hListView; } /* Show episode data. */ @@ -21,7 +21,7 @@ void ElvUpdate(void); void ElvUpdateName(NMLISTVIEW *); /* datalistview.c */ -void DlvCreate(HWND); +HWND DlvCreate(HWND); void DlvShowEpisode(int); #endif diff --git a/c/episodelistview.c b/c/episodelistview.c index 64644fc..ab54f81 100644 --- a/c/episodelistview.c +++ b/c/episodelistview.c @@ -15,7 +15,6 @@ int g_SelectedItem = -1; /* Remembered after refresh. */ HWND ElvCreate(HWND hWnd) { - HMODULE hModule; HWND hListView; LVCOLUMN lvc; diff --git a/c/listview.c b/c/listview.c index e38429b..66bcc29 100644 --- a/c/listview.c +++ b/c/listview.c @@ -18,7 +18,7 @@ LvCreate(HWND hWnd, HMENU hMenu) HWND hListView; hListView = CreateWindowEx( - 0, + WS_EX_CLIENTEDGE, WC_LISTVIEW, TEXT(""), WS_CHILD|WS_VISIBLE|WS_VSCROLL|LVS_REPORT, @@ -12,8 +12,8 @@ HFONT g_GUIFontBold; static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM); -static void SetupFonts(); static int Attach(void); +static void SetupFonts(); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -114,6 +114,7 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; case WM_CREATE: ElvCreate(hWnd); + DlvCreate(hWnd); break; case WM_SIZE: UpdateLayout(hWnd); @@ -205,7 +206,7 @@ SetupFonts() void UpdateLayout(HWND hWnd) { - HWND hListView; + HWND hElv, hDlv; int cxColumn; RECT rc; static int cxVScroll = 0; @@ -215,14 +216,30 @@ UpdateLayout(HWND hWnd) cxVScroll = GetSystemMetrics(SM_CXVSCROLL); GetClientRect(hWnd, &rc); - hListView = GetDlgItem(hWnd, IDC_EPISODELISTVIEW); - MoveWindow(hListView, 0, 0, + +#define EDGE 4 + + /* Resize data list view. */ + + hDlv = GetDlgItem(hWnd, IDC_DATALISTVIEW); + MoveWindow(hDlv, 0, rc.bottom-100, rc.right, rc.bottom, TRUE); - cxColumn = ListView_GetColumnWidth(hListView, 0); - ListView_SetColumnWidth(hListView, 1, - rc.right-cxColumn-cxVScroll); + cxColumn = ListView_GetColumnWidth(hDlv, 0); + ListView_SetColumnWidth(hDlv, 1, + rc.right-cxColumn-cxVScroll-EDGE); + + /* Resize episode list view. */ + + hElv = GetDlgItem(hWnd, IDC_EPISODELISTVIEW); + MoveWindow(hElv, 0, 0, + rc.right, rc.bottom-100+1, + TRUE); + + cxColumn = ListView_GetColumnWidth(hElv, 0); + ListView_SetColumnWidth(hElv, 1, + rc.right-cxColumn-cxVScroll-EDGE); - ListView_EnsureVisible(hListView, g_SelectedItem, TRUE); + ListView_EnsureVisible(hElv, g_SelectedItem, TRUE); } diff --git a/c/resource.h b/c/resource.h index 6cab078..16af73e 100644 --- a/c/resource.h +++ b/c/resource.h @@ -5,6 +5,7 @@ #define IDD_ABOUT 201 #define IDC_ABOUTTEXT 301 #define IDC_EPISODELISTVIEW 302 +#define IDC_DATALISTVIEW 303 #define ID_FILE_EXIT 4001 #define ID_FILE_REFRESH 4002 #define ID_FILE_ABOUT 4011 |