-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows.c
101 lines (87 loc) · 2.4 KB
/
windows.c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <stdio.h>
#include <windows.h>
#include <tchar.h>
#include "windows.h"
void append_menu_with_tag(HMENU hMenu, char *title, UINT tag) {
AppendMenu(hMenu, MF_STRING | MF_POPUP, tag, title);
}
void append_menu_with_sub(HMENU hMenu, char *title, HMENU sub) {
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT) sub, title);
}
void append_menu(HMENU hMenu, char *title) {
AppendMenu(hMenu, MF_STRING | MF_POPUP, 0, title);
}
void message_box(char *title, char *message) {
MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK);
}
void paint_text(HDC hdc, HWND hwnd, PAINTSTRUCT ps, char *str, int x, int y) {
HFONT hFont, oldFont;
hFont = CreateFont(
15,
0,
0,
0,
FW_NORMAL,
0,
0,
0,
HANGEUL_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH,
_T("Arial")
);
oldFont = (HFONT)SelectObject(hdc, hFont);
TextOut(hdc, x, y, _T(str), _tcslen(_T(str)));
SelectObject(hdc, oldFont);
DeleteObject(hFont);
}
HWND create_textbox(HWND hwnd) {
return CreateWindowEx(
WS_EX_CLIENTEDGE, // dwExStyle
"EDIT",
"",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
0,
0,
100,
100,
hwnd,
(HMENU)101,
GetModuleHandle(NULL),
NULL
);
}
HWND create_general_window(HINSTANCE hInstance, char *className, char *windowTitle) {
return CreateWindow(
_T(className), //lpClassName
_T(windowTitle), //lpWindowName
WS_OVERLAPPEDWINDOW, //dsStyle
CW_USEDEFAULT, //x
CW_USEDEFAULT, //y
CW_USEDEFAULT, //nWidth
CW_USEDEFAULT, //nHeight
NULL, //hMenu
NULL, //hMenu
hInstance, //hInstance
NULL //lpParam
);
}
void set_console_cursor_position(int x, int y) {
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void set_console_color(int color) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
}
int get_screen_width() {
int width = GetSystemMetrics(SM_CXSCREEN);
return width;
}
int get_screen_height() {
int width = GetSystemMetrics(SM_CYSCREEN);
return width;
}