mirror of
https://github.com/izzy2lost/libultraship.git
synced 2026-06-19 01:16:13 -07:00
Set icon for dxgi window (#826)
This is basically copied from SDL. https://github.com/libsdl-org/SDL/blob/52e64f816cd5842a5c1b513d7df6cbfe3daed732/src/video/windows/SDL_windowsevents.c#L2620-L2631 and https://github.com/libsdl-org/SDL/blob/52e64f816cd5842a5c1b513d7df6cbfe3daed732/src/video/windows/SDL_windowsevents.c#L2683-L2684
This commit is contained in:
@@ -499,6 +499,19 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK WIN_ResourceNameCallback(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG_PTR lParam) {
|
||||
WNDCLASSEX* wcex = (WNDCLASSEX*)lParam;
|
||||
|
||||
(void)lpType; /* We already know that the resource type is RT_GROUP_ICON. */
|
||||
|
||||
/* We leave hIconSm as NULL as it will allow Windows to automatically
|
||||
choose the appropriate small icon size to suit the current DPI. */
|
||||
wcex->hIcon = LoadIcon(hModule, lpName);
|
||||
|
||||
/* Do not bother enumerating any more. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void gfx_dxgi_init(const char* game_name, const char* gfx_api_name, bool start_in_fullscreen, uint32_t width,
|
||||
uint32_t height, int32_t posX, int32_t posY) {
|
||||
LARGE_INTEGER qpc_init, qpc_freq;
|
||||
@@ -534,14 +547,17 @@ void gfx_dxgi_init(const char* game_name, const char* gfx_api_name, bool start_i
|
||||
wcex.lpfnWndProc = gfx_dxgi_wnd_proc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = nullptr;
|
||||
wcex.hInstance = GetModuleHandle(nullptr);
|
||||
wcex.hIcon = nullptr;
|
||||
wcex.hIconSm = nullptr;
|
||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||
wcex.lpszMenuName = nullptr;
|
||||
wcex.lpszClassName = WINCLASS_NAME;
|
||||
wcex.hIconSm = nullptr;
|
||||
|
||||
EnumResourceNames(wcex.hInstance, RT_GROUP_ICON, WIN_ResourceNameCallback, (LONG_PTR)&wcex);
|
||||
|
||||
ATOM winclass = RegisterClassExW(&wcex);
|
||||
|
||||
RECT wr = { 0, 0, width, height };
|
||||
|
||||
Reference in New Issue
Block a user