0X00000598

0x598: Invalid LB Message in Single-Select Listbox

Windows Errors Advanced 👁 1 views 📅 May 29, 2026

This error fires when you send a wrong message to a single-selection list box like you're trying to set a selection using a multi-selection command. It's a programming bug, not a system failure.

When This Error Shows Up

You're building or debugging a Win32 desktop app—maybe an old MFC dialog or a raw Win32 control. The app does something with a list box: populates it, selects an item, or removes one. Then you get hit with ERROR_INVALID_LB_MESSAGE (0x00000598) in your debug output or as a return value from SendMessage. This happens most often when you're calling LB_SETSEL or LB_SETCOUNT on a list box that was created with LBS_MULTIPLESEL style missing.

Root Cause

What's actually happening here is a mismatch between the message you're sending and the list box's selection style. Windows list boxes come in two flavors: single-selection (default) and multi-selection (with LBS_MULTIPLESEL or LBS_EXTENDEDSEL). Single-selection boxes use messages like LB_SETCURSEL to pick one item. Multi-selection boxes use LB_SETSEL to toggle items on or off. The error code 0x598 literally means "invalid message for single-selection list box."

The reason you get 0x598 is that LB_SETSEL, LB_SETCOUNT, LB_GETSELCOUNT, and LB_GETSELITEMS are all multi-selection commands. If your list box wasn't born with LBS_MULTIPLESEL or LBS_EXTENDEDSEL, the control rejects these calls. The same goes for sending LB_SETCURSEL to a multi-select box—that's also an invalid message, but you'd get a different error code.

How to Fix It

The fix depends on whether you want a single-selection or multi-selection list box. Here's the checklist:

  1. Check your list box style. Open the resource file (.rc) or dialog template. For a single-selection list box, you should see LISTBOX with no LBS_MULTIPLESEL or LBS_EXTENDEDSEL. If it's multi-selection, you'll see one of those flags. Make sure the style matches your intent.
  2. Inspect the code that sends messages. Search for LB_SETSEL, LB_SETCOUNT, LB_GETSELCOUNT, LB_GETSELITEMS. These should only appear if your list box is multi-selection. If you see them and your control is single-selection, change the message. For single-selection, use LB_SETCURSEL to select an item and LB_GETCURSEL to read the selection.
  3. If you need multi-selection, fix the style. Add LBS_MULTIPLESEL to the list box style in the resource file or at creation time. For example: CreateWindow(L"LISTBOX", ..., WS_CHILD | WS_VISIBLE | LBS_MULTIPLESEL | WS_VSCROLL, ...); Then LB_SETSEL will work.
  4. Check for copy-paste errors. I've seen code where someone copied a multi-selection handler and forgot to change the message. If you have two list boxes—one single, one multi—make sure each handler sends the correct message.
  5. Rare case: owner-drawn list boxes. If your list box has LBS_OWNERDRAWFIXED or LBS_OWNERDRAWVARIABLE, this doesn't change the selection model. Owner-drawn is about rendering, not selection. The style flags for selection are still what matter.

Still Broken?

If you've confirmed the style and the message match and you still get 0x598, verify the list box handle isn't stale. Sometimes you get a handle from GetDlgItem or a global variable, but the control was destroyed and recreated (common with property sheets or tab controls). The stale handle points to a different window that still rejects the message. Also, run a quick test with Spy++ (part of Visual Studio) to see what messages the list box actually receives. That'll confirm if your code is the culprit or if something else is sending the bad message.

Was this solution helpful?