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
|
#ifndef WINDOW_H
#define WINDOW_H
#include <windows.h>
#include "data.h"
#include "datalistview.h"
#include "drag.h"
#include "episodelistview.h"
#include "res.h"
#include "win32.h"
struct Window
{
HWND hWnd;
HWND hWndFocus = nullptr;
HWND hWndStatus = nullptr;
const HMENU hMenuPopup = []()
{
HMENU hm;
if (!(hm = LoadMenuW(nullptr, MAKEINTRESOURCE(IDR_POPUPMENU))))
throw Err(WINDOWS, L"Context menu could not be loaded: %s");
if (!GetSubMenu(hm, 0))
throw Err(WINDOWS, L"Submenu could not be retrieved: %s");
return hm;
}();
/* File views. */
FileView<CfgA> fvCfg = FileView<CfgA>::Initialized(L"cfg.dat", 1);
CfgA& cfg = fvCfg.At(0);
FileView<ElvDataA> fvElv{L"elvdata.dat", cfg.cEp+128u};
FileView<DlvDataA> fvDlv{L"dlvdata.dat", cfg.cEp+128u};
/* Layout handlers. */
DlvDragger dragDlv = DlvDragger(*this);
/* Child window objects. */
DataListView dlv = DataListView(*this);
EpisodeListView elv = EpisodeListView(*this);
inline Window(HWND hWnd) : hWnd(hWnd) {}
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
/* Given main window's width and height, set appropriate
* positions and sizes for child windows. */
void UpdateLayout(int w = 0, int h = 0);
/* Process main menu commands. */
void HandleMainMenu(HWND, WORD);
/* Display text in status bar. */
void Status(const wchar_t* msg, unsigned short i = 0) noexcept;
/* Try to style application according to current Windows theme. */
void UpdateTheme();
};
#endif
|