{"record":{"id":"fadf93a297157544","repo":"wailsapp/wails","slug":"create-compatible-dc-failed","errorCode":null,"errorMessage":"Create compatible DC failed","messagePattern":"Create compatible DC failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/pkg/w32/gdi32.go","lineNumber":159,"sourceCode":"\t\tuintptr(hemfSrc),\n\t\tuintptr(unsafe.Pointer(lpszFile)))\n\n\treturn HENHMETAFILE(ret)\n}\n\nfunc CreateBrushIndirect(lplb *LOGBRUSH) HBRUSH {\n\tret, _, _ := procCreateBrushIndirect.Call(\n\t\tuintptr(unsafe.Pointer(lplb)))\n\n\treturn HBRUSH(ret)\n}\n\nfunc CreateCompatibleDC(hdc HDC) HDC {\n\tret, _, _ := procCreateCompatibleDC.Call(\n\t\tuintptr(hdc))\n\n\tif ret == 0 {\n\t\tpanic(\"Create compatible DC failed\")\n\t}\n\n\treturn HDC(ret)\n}\n\nfunc CreateDC(lpszDriver, lpszDevice, lpszOutput *uint16, lpInitData *DEVMODE) HDC {\n\tret, _, _ := procCreateDC.Call(\n\t\tuintptr(unsafe.Pointer(lpszDriver)),\n\t\tuintptr(unsafe.Pointer(lpszDevice)),\n\t\tuintptr(unsafe.Pointer(lpszOutput)),\n\t\tuintptr(unsafe.Pointer(lpInitData)))\n\n\treturn HDC(ret)\n}\n\nfunc CreateDIBSection(hdc HDC, pbmi *BITMAPINFO, iUsage uint, ppvBits *unsafe.Pointer, hSection HANDLE, dwOffset uint) HBITMAP {\n\tret, _, _ := procCreateDIBSection.Call(\n\t\tuintptr(hdc),","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v3/pkg/w32/gdi32.go#L141-L177","documentation":"Error \"Create compatible DC failed\" thrown in wailsapp/wails.","triggerScenarios":"Occurs when CreateCompatibleDC returns NULL, typically due to an invalid source DC handle or system GDI object exhaustion.","commonSituations":"See trigger scenarios.","solutions":["Pass a valid source HDC to CreateCompatibleDC; passing 0 creates a DC compatible with the screen, but a garbage or already-deleted HDC causes failure.","Check for GDI resource exhaustion: too many un-deleted DCs or bitmaps can make CreateCompatibleDC fail; ensure every created DC is released with DeleteDC."],"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-15T17:31:12.345Z"}