summaryrefslogtreecommitdiff
path: root/new/initparent_windows.c
blob: 9f115c16df947014c4cf1921d84d1465e307f225 (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
// 10 april 2015
#include "uipriv_windows.h"

// for maximum safety, all controls that don't have a parent are made children of this, the "initial parent"
// it behaves like other containers due to bugs described in container_windows.c, but is never seen and cannot be interacted with by end users
// despite being called the initial parent, it is used whenever a control has no parent, even if it loses its parent at some later point during the execution of the program

#define uiInitialParentClass L"uiInitialParentClass"

HWND initialParent;

static LRESULT CALLBACK initialParentWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	LRESULT lResult;

	if (sharedWndProc(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
		return lResult;
	return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}

const char *initInitialParent(HICON hDefaultIcon, HCURSOR hDefaultCursor)
{
	WNDCLASSW wc;

	ZeroMemory(&wc, sizeof (WNDCLASSW));
	wc.lpszClassName = uiInitialParentClass;
	wc.lpfnWndProc = initialParentWndProc;
	wc.hInstance = hInstance;
	wc.hIcon = hDefaultIcon;
	wc.hCursor = hDefaultCursor;
	wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
	if (RegisterClassW(&wc) == 0)
		return "registering initial parent window class";

	initialParent = CreateWindowExW(0,
		uiInitialParentClass, L"",
		WS_OVERLAPPEDWINDOW,
		0, 0,
		100, 100,
		NULL, NULL, hInstance, NULL);
	if (initialParent == NULL)
		return "creating initial parent window";

	// TODO disable?
	return NULL;
}