MCPcopy Create free account
hub / github.com/NetHack/NetHack / mswin_init_main_window

Function mswin_init_main_window

win/win32/mhmain.c:46–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44// returns strdup() created pointer - callee assumes the ownership
45
46HWND
47mswin_init_main_window(void)
48{
49 static int run_once = 0;
50 HWND ret;
51 WINDOWPLACEMENT wp;
52
53 /* register window class */
54 if (!run_once) {
55 LoadString(GetNHApp()->hApp, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
56 register_main_window_class();
57 run_once = 1;
58 }
59
60 /* create the main window */
61 ret =
62 CreateWindow(szMainWindowClass, /* registered class name */
63 szTitle, /* window name */
64 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, /* window style */
65 CW_USEDEFAULT, /* horizontal position of window */
66 CW_USEDEFAULT, /* vertical position of window */
67 CW_USEDEFAULT, /* window width */
68 CW_USEDEFAULT, /* window height */
69 NULL, /* handle to parent or owner window */
70 NULL, /* menu handle or child identifier */
71 GetNHApp()->hApp, /* handle to application instance */
72 NULL /* window-creation data */
73 );
74
75 if (!ret)
76 panic("Cannot create main window");
77
78 if (GetNHApp()->regMainMinX != CW_USEDEFAULT) {
79 wp.length = sizeof(wp);
80 wp.showCmd = GetNHApp()->regMainShowState;
81
82 wp.ptMinPosition.x = GetNHApp()->regMainMinX;
83 wp.ptMinPosition.y = GetNHApp()->regMainMinY;
84
85 wp.ptMaxPosition.x = GetNHApp()->regMainMaxX;
86 wp.ptMaxPosition.y = GetNHApp()->regMainMaxY;
87
88 wp.rcNormalPosition.left = GetNHApp()->regMainLeft;
89 wp.rcNormalPosition.top = GetNHApp()->regMainTop;
90 wp.rcNormalPosition.right = GetNHApp()->regMainRight;
91 wp.rcNormalPosition.bottom = GetNHApp()->regMainBottom;
92 SetWindowPlacement(ret, &wp);
93 } else
94 ShowWindow(ret, SW_SHOWDEFAULT);
95
96 UpdateWindow(ret);
97 return ret;
98}
99
100void
101register_main_window_class(void)

Callers 1

mswin_init_nhwindowsFunction · 0.70

Calls 3

GetNHAppFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected