| Previous | Next |
| ERROR_STACK_OVERFLOW | ERROR_CAN_NOT_COMPLETE |
ERROR_INVALID_MESSAGE
the window cannot act on the sent message.
ERROR_INVALID_MESSAGE means that a window or GUI subsystem component rejected a message that is not valid in its current context.
Where the result appears
- SendMessage, PostMessage, dialog, menu, clipboard, or window-management operations.
- cross-thread or cross-process GUI automation.
- messages sent before window initialization or after teardown.
- custom controls receiving a message with incompatible parameters or state.
Typical causes
- the target window class does not support the message.
- the message is valid only during a specific modal, menu, clipboard, or lifecycle state.
- wParam or lParam does not match the documented contract.
- the HWND is stale, belongs to another desktop/session, or changed ownership.
What to collect
- message number, symbolic name, HWND, class name, process, and thread.
- wParam/lParam values and ownership of any pointed-to memory.
- window creation/destruction timeline and current UI state.
- whether the call crosses process, integrity, desktop, or session boundaries.
Handling and recovery
Check the message contract and the target window lifecycle rather than converting the result into a generic UI failure. Prefer documented control APIs or accessibility/UI Automation interfaces for cross-process work. Never pass process-local pointers in a message whose receiver runs in another process unless the API explicitly marshals them.
Common misinterpretation
The code does not imply that the window handle is always invalid. A real window may reject a message that is unsupported or illegal at that moment.
References
Looking for a different code? Search another status or error code.