3#include <SplashScreen.h>
13#define _CRT_SECURE_NO_WARNINGS
19HBITMAP hBitmap = NULL;
22HANDLE splashWindowThread;
26static char splashMessage[256];
27static int splashMessageLength;
32LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
38 DeleteObject(hBitmap);
50 hBitmap = (HBITMAP)LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(SPLASH1));
55 hBitmap = (HBITMAP)LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(SPLASH2));
66 hdc = BeginPaint(hwnd, &ps);
67 hdcMem = CreateCompatibleDC(hdc);
68 oldBitmap = SelectObject(hdcMem, hBitmap);
69 GetObject(hBitmap,
sizeof(bitmap), &bitmap);
70 BitBlt(hdc, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY);
71 SelectObject(hdcMem, oldBitmap);
86 DeleteObject(hBitmap);
91 return DefWindowProc(hwnd, message, wParam, lParam);
97void SetSplashMessage(std::string message)
99 strcpy_s(splashMessage, message.c_str());
100 splashMessageLength = message.size();
103void ShowSplashScreen()
105 std::cout <<
"Hsadgbshdy\n";
109void HideSplashScreen()
114DWORD WINAPI SetUpSplashWindow(LPVOID par)
119 std::string classname =
"SplashWindowClass";
121 wc.cbSize =
sizeof(WNDCLASSEX);
123 wc.lpfnWndProc = WndProc;
126 wc.hInstance = hInstance;
127 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
128 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
129 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
130 wc.lpszMenuName = NULL;
131 wc.lpszClassName = (LPCWSTR)classname.c_str();
132 wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
134 if (!RegisterClassEx(&wc))
141 hwnd = CreateWindowEx(
143 (LPCWSTR)classname.c_str(),
144 L
"The title of my window",
145 ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU),
146 GetSystemMetrics(SM_CXSCREEN) / 2 - 300,
147 GetSystemMetrics(SM_CYSCREEN) / 2 - 225,
150 NULL, NULL, hInstance, NULL);
159 ShowScrollBar(hwnd, SB_BOTH, FALSE);
160 ShowWindow(hwnd, TRUE);
165 while (GetMessage(&Msg, NULL, 0, 0) && isRunning)
167 TranslateMessage(&Msg);
168 DispatchMessage(&Msg);
174void Init(HINSTANCE hIn)
179 memset(splashMessage, 0, 256);
180 memcpy(splashMessage, (
char *)
"Loading...\0", 11);
181 splashMessageLength = 10;
182 splashWindowThread = CreateThread(NULL, 0, SetUpSplashWindow, (
void *)0, 0, 0);
187 DestroyWindow(splashWindow);
188 CloseWindow(splashWindow);
189 CloseHandle(splashWindowThread);