2014-07-17 21:33:03 -05:00
|
|
|
/* 17 july 2014 */
|
|
|
|
|
|
|
|
#include "winapi_windows.h"
|
|
|
|
|
2014-07-17 23:22:21 -05:00
|
|
|
HINSTANCE hInstance;
|
2014-07-17 21:33:03 -05:00
|
|
|
int nCmdShow;
|
|
|
|
|
|
|
|
HICON hDefaultIcon;
|
|
|
|
HCURSOR hArrowCursor;
|
|
|
|
|
2014-07-18 10:20:18 -05:00
|
|
|
HFONT controlFont;
|
|
|
|
HFONT titleFont;
|
|
|
|
HFONT smallTitleFont;
|
|
|
|
HFONT menubarFont;
|
|
|
|
HFONT statusbarFont;
|
|
|
|
|
2014-08-05 15:30:12 -05:00
|
|
|
HBRUSH hollowBrush;
|
|
|
|
|
2014-07-17 21:33:03 -05:00
|
|
|
DWORD initWindows(char **errmsg)
|
|
|
|
{
|
|
|
|
STARTUPINFOW si;
|
2014-07-18 10:20:18 -05:00
|
|
|
NONCLIENTMETRICSW ncm;
|
2014-07-17 21:33:03 -05:00
|
|
|
|
|
|
|
/* WinMain() parameters */
|
|
|
|
hInstance = GetModuleHandleW(NULL);
|
|
|
|
if (hInstance == NULL) {
|
|
|
|
*errmsg = "error getting hInstance";
|
|
|
|
return GetLastError();
|
|
|
|
}
|
|
|
|
nCmdShow = SW_SHOWDEFAULT;
|
|
|
|
GetStartupInfoW(&si);
|
|
|
|
if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0)
|
|
|
|
nCmdShow = si.wShowWindow;
|
|
|
|
|
|
|
|
/* icons and cursors */
|
|
|
|
hDefaultIcon = LoadIconW(NULL, IDI_APPLICATION);
|
|
|
|
if (hDefaultIcon == NULL) {
|
|
|
|
*errmsg = "error loading default icon";
|
|
|
|
return GetLastError();
|
|
|
|
}
|
2014-07-17 23:22:21 -05:00
|
|
|
hArrowCursor = LoadCursorW(NULL, IDC_ARROW);
|
2014-07-17 21:33:03 -05:00
|
|
|
if (hArrowCursor == NULL) {
|
|
|
|
*errmsg = "error loading arrow (default) cursor";
|
|
|
|
return GetLastError();
|
|
|
|
}
|
|
|
|
|
2014-07-18 10:20:18 -05:00
|
|
|
/* standard fonts */
|
|
|
|
#define GETFONT(l, f, n) l = CreateFontIndirectW(&ncm.f); \
|
|
|
|
if (l == NULL) { \
|
|
|
|
*errmsg = "error loading " n " font"; \
|
|
|
|
return GetLastError(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
ZeroMemory(&ncm, sizeof (NONCLIENTMETRICSW));
|
|
|
|
ncm.cbSize = sizeof (NONCLIENTMETRICSW);
|
|
|
|
if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof (NONCLIENTMETRICSW), &ncm, sizeof (NONCLIENTMETRICSW)) == 0) {
|
|
|
|
*errmsg = "error getting non-client metrics parameters";
|
|
|
|
return GetLastError();
|
|
|
|
}
|
|
|
|
GETFONT(controlFont, lfMessageFont, "control");
|
|
|
|
GETFONT(titleFont, lfCaptionFont, "titlebar");
|
|
|
|
GETFONT(smallTitleFont, lfSmCaptionFont, "small title bar");
|
|
|
|
GETFONT(menubarFont, lfMenuFont, "menu bar");
|
|
|
|
GETFONT(statusbarFont, lfStatusFont, "status bar");
|
|
|
|
|
2014-08-05 15:30:12 -05:00
|
|
|
hollowBrush = GetStockObject(HOLLOW_BRUSH);
|
|
|
|
if (hollowBrush == NULL) {
|
|
|
|
*errmsg = "error getting hollow brush";
|
|
|
|
return GetLastError();
|
|
|
|
}
|
|
|
|
|
2014-07-17 21:33:03 -05:00
|
|
|
return 0;
|
|
|
|
}
|