summaryrefslogtreecommitdiff
path: root/redo/sizing_windows.c
blob: 0b1620b984680b51c92cda04d53fbacc3d073297 (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
/* 17 july 2014 */

#include "winapi_windows.h"

HDC getDC(HWND hwnd)
{
	HDC dc;

	dc = GetDC(hwnd);
	if (dc == NULL)
		xpanic("error getting DC for preferred size calculations", GetLastError());
/* TODO */
	/* TODO save for restoring later */
/*
	if (SelectObject(dc, controlFont) == NULL)
		xpanic("error loading control font into device context for preferred size calculation", GetLastError());
*/
	return dc;
}

void releaseDC(HWND hwnd, HDC dc)
{
	if (ReleaseDC(hwnd, dc) == 0)
		xpanic("error releasing DC for preferred size calculations", GetLastError());
}

void getTextMetricsW(HDC dc, TEXTMETRICW *tm)
{
	if (GetTextMetricsW(dc, tm) == 0)
		xpanic("error getting text metrics for preferred size calculations", GetLastError());
}

void moveWindow(HWND hwnd, int x, int y, int width, int height)
{
	if (MoveWindow(hwnd, x, y, width, height, TRUE) == 0)
		xpanic("error setting window/control rect", GetLastError());
}