summaryrefslogtreecommitdiff
path: root/plugins/HistoryStats/src/dlgoption_subbase.cpp
blob: 2ac33f6b225541f2f70a0d838a21ce538800895d (plain)
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
#include "stdafx.h"
#include "dlgoption.h"

#include "main.h"

/*
 * DlgOption::SubBase
 */

INT_PTR CALLBACK DlgOption::SubBase::staticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	SubBase* pDlg = reinterpret_cast<SubBase*>(GetWindowLongPtr(hDlg, DWLP_USER));

	switch (msg) {
	case WM_INITDIALOG:
		pDlg = reinterpret_cast<SubBase*>(lParam);
		SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(pDlg));
		pDlg->m_hWnd = hDlg;
		pDlg->onWMInitDialog();
		pDlg->loadSettings();
		return TRUE;

	case WM_DESTROY:
		pDlg->onWMDestroy();
		delete pDlg;
		SetWindowLongPtr(hDlg, DWLP_USER, 0);
		return TRUE;
	}

	return pDlg ? pDlg->handleMsg(msg, wParam, lParam) : FALSE;
}

DlgOption::SubBase::SubBase() :
	m_pParent(nullptr), m_hWnd(nullptr)
{
}

DlgOption::SubBase::~SubBase()
{
}

void DlgOption::SubBase::createWindow(DlgOption* pParent, WORD nDlgResource, const RECT& rect)
{
	m_pParent = pParent;

	CreateDialogParam(
		g_hInst,
		MAKEINTRESOURCE(nDlgResource),
		m_pParent->getHWnd(),
		staticDlgProc,
		reinterpret_cast<LPARAM>(this));

	MoveWindow(
		m_hWnd,
		rect.left,
		rect.top,
		rect.right - rect.left,
		rect.bottom - rect.top, TRUE);
}

void DlgOption::SubBase::destroyWindow()
{
	if (m_hWnd) {
		DestroyWindow(m_hWnd);

		// exit NOW since we destroyed ourselves
		return;
	}
}

void DlgOption::SubBase::moveWindow(const RECT& rWnd)
{
	utils::moveWindow(m_hWnd, rWnd);
}