{"record":{"id":"b39367d1c720f111","repo":"wailsapp/wails","slug":"selectobject-failed","errorCode":null,"errorMessage":"SelectObject failed","messagePattern":"SelectObject failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/pkg/w32/gdi32.go","lineNumber":374,"sourceCode":"\n\treturn ret != 0\n}\n\nfunc ResetDC(hdc HDC, lpInitData *DEVMODE) HDC {\n\tret, _, _ := procResetDC.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(unsafe.Pointer(lpInitData)))\n\n\treturn HDC(ret)\n}\n\nfunc SelectObject(hdc HDC, hgdiobj HGDIOBJ) HGDIOBJ {\n\tret, _, _ := procSelectObject.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(hgdiobj))\n\n\tif ret == 0 {\n\t\tpanic(\"SelectObject failed\")\n\t}\n\n\treturn HGDIOBJ(ret)\n}\n\nfunc SetBkMode(hdc HDC, iBkMode int) int {\n\tret, _, _ := procSetBkMode.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(iBkMode))\n\n\tif ret == 0 {\n\t\tpanic(\"SetBkMode failed\")\n\t}\n\n\treturn int(ret)\n}\n\nfunc SetBrushOrgEx(hdc HDC, nXOrg, nYOrg int, lppt *POINT) bool {","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v3/pkg/w32/gdi32.go#L356-L392","documentation":"Error \"SelectObject failed\" thrown in wailsapp/wails.","triggerScenarios":"Occurs when SelectObject returns NULL or HGDI_ERROR, e.g. selecting a deleted GDI object, a bitmap into incompatible DCs simultaneously, or an invalid DC handle.","commonSituations":"See trigger scenarios.","solutions":["Ensure the HGDIOBJ being selected is valid and not already deleted; selecting a deleted brush, pen, or bitmap makes SelectObject fail.","Do not select a bitmap into more than one DC at a time; deselect it from the previous DC first.","Do not select a stock object that is still selected into another DC in an incompatible way; restore the original object returned by the first SelectObject call before deleting objects."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}