Hello, I have an application made in C NOT C++ in which when painting or creating a LISTBOX control it gives the error Exception code: 0xc000041d in the CreateWindow statement in WINDOWS 11 24H2

Villarreal, Jesus 0 Reputation points
2025-01-13T20:32:01.1366667+00:00

Hello, I have an application made in C NOT C++ in which when painting or creating a LISTBOX control it gives the error Exception code: 0xc000041d in the CreateWindow statement in WINDOWS 11 24H2 Has anyone else had this happen to them and how did they correct it? Does continuing to use this language in this Windows 11 24H2 operating system have any expired support? ...

Why does my application work in Windows 23H2?

ejem

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {

 


WNDCLASS wc = {0};

wc.lpfnWndProc = WndProc;

wc.hInstance = hInstance;

wc.hCursor = LoadCursor(NULL, IDC_ARROW);

wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 8);

wc.lpszClassName = "MiClaseVentana";

RegisterClass(&wc);



HWND hwnd = CreateWindow("MiClaseVentana", "Ejemplo de ListBox",

                          WS_OVERLAPPEDWINDOW | WS_VISIBLE,

                          CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,

                          NULL, NULL, hInstance, NULL);



// Bucle 

MSG msg;

while (GetMessage(&msg, NULL, 0, 0)) 

{

    TranslateMessage(&msg);

    DispatchMessage(&msg);

}

return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {


switch (msg) {

    case WM_CREATE: {

        // Crear el ListBox

        HWND hwndListBox = CreateWindow("LISTBOX", NULL,

                                         WS_CHILD | WS_VISIBLE | LBS_NOTIFY,

                                         10, 10, 200, 150,

                                         hwnd, (HMENU)ID_LISTBOX,

                                         ((LPCREATESTRUCT)lParam)->hInstance, NULL);



        break;

    }

    case WM_COMMAND: {

        if (LOWORD(wParam) == ID_LISTBOX

			&& HIWORD(wParam) == LBN_SELCHANGE) {


            

			HWND hwndListBox = (HWND)lParam;

            int index = SendMessage(hwndListBox, LB_GETCURSEL, 0, 0);

            char buffer[256];

            SendMessage(hwndListBox, LB_GETTEXT, index, (LPARAM)buffer);


           

        }

        break;

    }

    case WM_DESTROY:

        PostQuitMessage(0);

        break;

    default:

        return DefWindowProc(hwnd, msg, wParam, lParam);

}

return 0;
}

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,829 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,455 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.