{"record":{"id":"f7fc4d9716a90a33","repo":"wailsapp/wails","slug":"icontype-is-invalid","errorCode":null,"errorMessage":"IconType is invalid","messagePattern":"IconType is invalid","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/internal/frontend/desktop/windows/winc/form.go","lineNumber":222,"sourceCode":"\tif !fm.isFullscreen {\n\t\treturn\n\t}\n\tw32.SetWindowLong(fm.hwnd, w32.GWL_STYLE, fm.previousWindowStyle)\n\tw32.SetWindowLong(fm.hwnd, w32.GWL_EXSTYLE, fm.previousWindowExStyle)\n\tw32.SetWindowPlacement(fm.hwnd, &fm.previousWindowPlacement)\n\tfm.isFullscreen = false\n\tw32.SetWindowPos(fm.hwnd, 0, 0, 0, 0, 0,\n\t\tw32.SWP_NOMOVE|w32.SWP_NOSIZE|w32.SWP_NOZORDER|w32.SWP_NOOWNERZORDER|w32.SWP_FRAMECHANGED)\n}\n\nfunc (fm *Form) IsFullScreen() bool {\n\treturn fm.isFullscreen\n}\n\n// IconType: 1 - ICON_BIG; 0 - ICON_SMALL\nfunc (fm *Form) SetIcon(iconType int, icon *Icon) {\n\tif iconType > 1 {\n\t\tpanic(\"IconType is invalid\")\n\t}\n\tw32.SendMessage(fm.hwnd, w32.WM_SETICON, uintptr(iconType), uintptr(icon.Handle()))\n}\n\nfunc (fm *Form) EnableMaxButton(b bool) {\n\tSetStyle(fm.hwnd, b, w32.WS_MAXIMIZEBOX)\n}\n\nfunc (fm *Form) EnableMinButton(b bool) {\n\tSetStyle(fm.hwnd, b, w32.WS_MINIMIZEBOX)\n}\n\nfunc (fm *Form) EnableSizable(b bool) {\n\tSetStyle(fm.hwnd, b, w32.WS_THICKFRAME)\n}\n\nfunc (fm *Form) EnableDragMove(_ bool) {\n\t//fm.isDragMove = b","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v2/internal/frontend/desktop/windows/winc/form.go#L204-L240","documentation":"Form.SetIcon maps iconType to WM_SETICON's wParam, which accepts only 0 (ICON_SMALL) or 1 (ICON_BIG); any value above 1 panics with 'IconType is invalid'. This is pure input validation before the SendMessage — nothing Windows-related can fail here. The panic is always a caller bug: passing an icon index, size, or enum from another API.","triggerScenarios":"Calling form.SetIcon(2, ico) or higher; passing an icon dimension like 32/256 as iconType; confusing this API with per-DPI icon setting (WM_SETICON has no DPI variants).","commonSituations":"Wrapping SetIcon in a loop over icon sizes; porting code from frameworks where icon 'type' enums have more members.","solutions":["Use only the two documented constants: w32.ICON_BIG (1) for the alt-tab/taskbar icon and w32.ICON_SMALL (0) for the title-bar icon","Set both: SetIcon(w32.ICON_BIG, icoBig) and SetIcon(w32.ICON_SMALL, icoSmall) — for other sizes register icons in the window class or via the exe resource","If multiple resolutions are needed, embed them as a single multi-size .ico resource instead of extra SetIcon calls"],"exampleFix":"// before\nform.SetIcon(32, icon) // 32 > 1 -> panic\n\n// after\nform.SetIcon(w32.ICON_BIG, icon)\nform.SetIcon(w32.ICON_SMALL, icon)","handlingStrategy":"type-guard","validationCode":"func validIconType(t int) bool { return t == 0 || t == 1 } // ICON_SMALL / ICON_BIG","typeGuard":"func iconTypeValid(t int) bool { return t == int(w32.ICON_SMALL) || t == int(w32.ICON_BIG) }","tryCatchPattern":null,"preventionTips":["Always use w32.ICON_BIG / w32.ICON_SMALL constants, never literals","Set both icons right after form creation"],"tags":["windows","win32-api","icon","winc","panic","invalid-argument"],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}