wailsapp/wails · error

SetTextColor failed

Error message

SetTextColor failed

What it means

Error "SetTextColor failed" thrown in wailsapp/wails.

Source

Thrown at v3/pkg/w32/gdi32.go:416

	return ret != 0
}

func SetStretchBltMode(hdc HDC, iStretchMode int) int {
	ret, _, _ := procSetStretchBltMode.Call(
		uintptr(hdc),
		uintptr(iStretchMode))

	return int(ret)
}

func SetTextColor(hdc HDC, crColor COLORREF) COLORREF {
	ret, _, _ := procSetTextColor.Call(
		uintptr(hdc),
		uintptr(crColor))

	if ret == CLR_INVALID {
		panic("SetTextColor failed")
	}

	return COLORREF(ret)
}

func SetBkColor(hdc HDC, crColor COLORREF) COLORREF {
	ret, _, _ := procSetBkColor.Call(
		uintptr(hdc),
		uintptr(crColor))

	if ret == CLR_INVALID {
		panic("SetBkColor failed")
	}

	return COLORREF(ret)
}

func StartDoc(hdc HDC, lpdi *DOCINFO) int {

View on GitHub (pinned to 0e754b1b40)

Solutions

  1. Pass a valid HDC that supports text output; SetTextColor fails on invalid or deleted device contexts.
  2. Ensure the COLORREF value is a valid RGB value; passing CLR_INVALID or an out-of-range constant is treated as an error indicator.

When it happens

Trigger: Occurs when SetTextColor returns CLR_INVALID, typically due to an invalid device context handle.

Common situations: See trigger scenarios.


AI-assisted analysis of wailsapp/wails@0e754b1b40 (2026-08-15). Data as JSON: /api/errors/f6ae263289cffe52. Report an issue: GitHub.