7
7
#include < stdexcept>
8
8
#include < imgui/backends/imgui_impl_dx9.h>
9
9
#include < imgui/backends/imgui_impl_win32.h>
10
+ #include < random>
10
11
11
12
#include < maniac/common.h>
12
13
@@ -87,6 +88,32 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
87
88
return ::DefWindowProc (hWnd, msg, wParam, lParam);
88
89
}
89
90
91
+ static std::string generate_random_string (int length) {
92
+ std::string random_string;
93
+ std::random_device rd;
94
+ std::mt19937 gen (rd ());
95
+ std::uniform_int_distribution<> distrib (0 , 61 );
96
+
97
+ for (int i = 0 ; i < length; ++i) {
98
+ int random_index = distrib (gen);
99
+ char random_char;
100
+ if (random_index < 10 ) {
101
+ random_char = ' 0' + random_index;
102
+ } else if (random_index < 36 ) {
103
+ random_char = ' A' + (random_index - 10 );
104
+ } else {
105
+ random_char = ' a' + (random_index - 36 );
106
+ }
107
+ random_string += random_char;
108
+ }
109
+
110
+ return random_string;
111
+ }
112
+
113
+ static void randomize_window_title (const HWND window) {
114
+ SetWindowTextA (window, generate_random_string (16 ).c_str ());
115
+ }
116
+
90
117
void window::start (const std::function<void ()> &body) {
91
118
// TODO: Refactor this into something readable
92
119
@@ -98,6 +125,8 @@ void window::start(const std::function<void()> &body) {
98
125
HWND hwnd = ::CreateWindow (wc.lpszClassName , _T (" maniac" ), WS_OVERLAPPEDWINDOW, 100 , 100 , 550 ,
99
126
420 , NULL , NULL , wc.hInstance , NULL );
100
127
128
+ randomize_window_title (hwnd);
129
+
101
130
// Initialize Direct3D
102
131
if (!CreateDeviceD3D (hwnd)) {
103
132
CleanupDeviceD3D ();
0 commit comments