diff --git a/internal/glfwwin/api_windows.go b/internal/glfwwin/api_windows.go index d62fb3123..db9d9c93e 100644 --- a/internal/glfwwin/api_windows.go +++ b/internal/glfwwin/api_windows.go @@ -1457,6 +1457,10 @@ func _LoadImageW(hInst _HINSTANCE, name uintptr, typ uint32, cx int32, cy int32, return windows.Handle(r), nil } +func _LoadImageW_Available() bool { + return procLoadImageW.Find() == nil +} + func _MapVirtualKeyW(uCode uint32, uMapType uint32) uint32 { r, _, _ := procMapVirtualKeyW.Call(uintptr(uCode), uintptr(uMapType)) return uint32(r) @@ -1683,6 +1687,10 @@ func _SetProcessDpiAwarenessContext(value _DPI_AWARENESS_CONTEXT) error { return nil } +func _SetProcessDpiAwarenessContext_Available() bool { + return procSetProcessDpiAwarenessContext.Find() == nil +} + func _SetPropW(hWnd windows.HWND, str string, hData windows.Handle) error { var lpString *uint16 if str != "" { diff --git a/internal/glfwwin/win32init_windows.go b/internal/glfwwin/win32init_windows.go index 20b627ba5..78d5e9d17 100644 --- a/internal/glfwwin/win32init_windows.go +++ b/internal/glfwwin/win32init_windows.go @@ -254,8 +254,10 @@ func platformInit() error { createKeyTables() if isWindows10CreatorsUpdateOrGreaterWin32() { - if err := _SetProcessDpiAwarenessContext(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) { - return err + if _SetProcessDpiAwarenessContext_Available() { + if err := _SetProcessDpiAwarenessContext(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) { + return err + } } } else if _IsWindows8Point1OrGreater() { if err := _SetProcessDpiAwareness(_PROCESS_PER_MONITOR_DPI_AWARE); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) { diff --git a/internal/glfwwin/win32window_windows.go b/internal/glfwwin/win32window_windows.go index 7fdb89064..d5d1f77e2 100644 --- a/internal/glfwwin/win32window_windows.go +++ b/internal/glfwwin/win32window_windows.go @@ -1355,11 +1355,13 @@ func registerWindowClassWin32() error { // In the original GLFW implementation, an embedded resource GLFW_ICON is used if possible. // See https://www.glfw.org/docs/3.3/group__window.html - icon, err := _LoadImageW(0, _IDI_APPLICATION, _IMAGE_ICON, 0, 0, _LR_DEFAULTSIZE|_LR_SHARED) - if err != nil { - return err + if _LoadImageW_Available() { + icon, err := _LoadImageW(0, _IDI_APPLICATION, _IMAGE_ICON, 0, 0, _LR_DEFAULTSIZE|_LR_SHARED) + if err != nil { + return err + } + wc.hIcon = _HICON(icon) } - wc.hIcon = _HICON(icon) if _, err := _RegisterClassExW(&wc); err != nil { return err @@ -2138,6 +2140,10 @@ func (c *Cursor) platformCreateCursor(image *Image, xhot, yhot int) error { } func (c *Cursor) platformCreateStandardCursor(shape StandardCursor) error { + if !_LoadImageW_Available() { + return nil + } + var id int switch shape { case ArrowCursor: