List box tab stops error 0x0000059A fix
This error fires when Windows tries to send tab-stop data to a list box that wasn't created with the LBS_USETABSTOPS style. Fix requires rebuilding the control with the right flag.
When this error actually shows up
You're building an old-school Win32 app — maybe porting a VB6 dialog, or working on a legacy MFC tool in Visual Studio 2019/2022. Your list box displays columns of data, so you call LB_SETTABSTOPS to align them. Instead of nicely spaced columns, you get a message box with error 0x0000059A — ERROR_LB_WITHOUT_TABSTOPS. The dialog won't even open, just crashes out.
What's actually happening here is that the list box control was created without the LBS_USETABSTOPS window style. Windows doesn't try to be smart about it — it simply refuses to set tab stops on a control that wasn't designed for them. The error code maps to ERROR_LB_WITHOUT_TABSTOPS in winerror.h, and the root cause is almost always the resource script or the CreateWindow call.
Root cause: missing style flag
A standard list box in Windows (the LISTBOX class) supports tab stops only when you explicitly opt in. The flag is LBS_USETABSTOPS (0x0080). Without it, Windows treats any LB_SETTABSTOPS message as invalid and returns this error. The design rationale is performance: tab stop processing adds a tiny overhead, so for simple single-column lists, you skip it. But if you need tab-aligned columns, you must set this style at creation time. You can't add it later with SetWindowLong — that won't reinitialize the internal tab-stop array.
The fix: add LBS_USETABSTOPS to your list box
Step 1 — Find where the list box is defined
Look in your .rc file (resource script) or in the CreateWindow / CreateWindowEx call. In MFC, it's usually in the dialog's DoDataExchange or the .rc file.
Step 2 — Add the missing style
If you're using a resource script dialog definition, edit the LISTBOX line:
CONTROL "", IDC_MYLISTBOX, "LISTBOX", WS_TABSTOP | WS_VSCROLL | LBS_USETABSTOPS | LBS_NOTIFY, 10, 10, 200, 150
If you're calling CreateWindow directly, add the style to the dwStyle parameter:
HWND hList = CreateWindow("LISTBOX", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_USETABSTOPS, 10, 10, 200, 150, hParent, (HMENU)IDC_MYLISTBOX, hInst, NULL);
In MFC, if you're overriding PreCreateWindow, add the style there:
BOOL CMyListBox::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= LBS_USETABSTOPS;
return CListBox::PreCreateWindow(cs);
}
Step 3 — Rebuild and test
Clean rebuild your project. The dialog should now open without the error. Then call LB_SETTABSTOPS with an array of dialog units (not pixels — that's a separate gotcha).
What to check if it still fails
If the error persists, three things:
- Resource compiler version — Very old resource compilers (pre-Visual Studio 2005) sometimes strip unknown styles silently. Check your
.rcfile's first line — if it says#include "winres.h"and your SDK is ancient, upgrade to at least Windows SDK 7.0. - Dynamic creation vs dialog resource — If the list box is created in a dialog template but you also create one dynamically in code, make sure both paths set the style. The error only fires on the one that gets the
LB_SETTABSTOPSmessage. - Wrong control class — I've seen people accidentally use the
COMBOBOXorLISTVIEWclass and then sendLB_SETTABSTOPS. That'll return the same error because those controls don't support list-box messages. Verify the control class is literally"LISTBOX".
The reason step 3 works is that Windows checks the class type before processing the message. If the class isn't LISTBOX, it returns the same error code — but the root cause is different. Always double-check the control's actual class name.
Was this solution helpful?