-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_window.h
More file actions
59 lines (50 loc) · 1.65 KB
/
create_window.h
File metadata and controls
59 lines (50 loc) · 1.65 KB
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
#pragma once
#include <fmod.hpp>
#include <thread>
#include "file.h"
#include "fullscreen.h"
#include "func.h"
#include "music.h"
#include "time_show.h"
#include "video.h"
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
int ShowMeTheWindow()
{
WNDCLASS windowClass = { 0 };
windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hInstance = NULL;
windowClass.lpfnWndProc = WndProc;
windowClass.lpszClassName = L"Window in Console";
windowClass.style = CS_HREDRAW | CS_VREDRAW;
HWND windowHandle;
HWND windowHandle = CreateWindow(L"Window in Console", NULL, WS_POPUP, 0, 0, 300, 300, NULL, NULL, NULL, NULL);
HWND hConsole = GetConsoleWindow();
SetParent(windowHandle, hConsole); //a will be the new parent b
DWORD style = GetWindowLong(windowHandle, GWL_STYLE); //get the b style
style &= ~(WS_POPUP | WS_CAPTION); //reset the "caption" and "popup" bits
style |= WS_CHILD; //set the "child" bit
SetWindowLong(windowHandle, GWL_STYLE, style); //set the new style of b
RECT rc; //temporary rectangle
GetClientRect(hConsole, &rc); //the "inside border" rectangle for a
MoveWindow(windowHandle, 0, 0, 400, 300, true); //place b at (x,y,w,h) in a
UpdateWindow(hConsole);
return 0;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
switch (message)
{
case WM_CHAR: //this is just for a program exit besides window's borders/task bar
if (wparam == VK_ESCAPE)
{
DestroyWindow(hwnd);
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wparam, lparam);
}
return 0;
}