The List Control crash my Dialog box... (VC++6, no MFC)

Hello

I made a new project with a working Dialog Box. If I add a List Control on it, then it crash. I also tryed adding a List Control on an older project, and it worked. So, I tryed to copy/paste some code from the old one to the current one, but it still does not work. I also tryed to copy the configuration: no result...

Is there something I forgot to do ?

Comments

  • : Hello
    :
    : I made a new project with a working Dialog Box. If I add a List Control on it, then it crash. I also tryed adding a List Control on an older project, and it worked. So, I tryed to copy/paste some code from the old one to the current one, but it still does not work. I also tryed to copy the configuration: no result...
    :
    : Is there something I forgot to do ?
    :
    [blue]You forgot to post some code how you are adding this mysterious list box... to see the [b]dlg.cpp[/b] will be nice...[/blue]
  • [b][red]This message was edited by Psyko at 2002-11-1 9:15:43[/red][/b][hr]
    It is not a Listbox, it is a List Control. Also knows as List View, if you prefer.

    So, I make a simple Dialog in the ressource editor, there is only one button, and one List Control.

    Here is the code.


    #include
    #include "resource.h"

    LRESULT CALLBACK MainProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
    switch(Msg)
    {
    case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case IDC_CLOSE:
    EndDialog(hWnd,0);
    return TRUE;
    default:
    return FALSE;
    }

    case WM_CLOSE:
    EndDialog(hWnd,0);
    return TRUE;

    default:
    return FALSE;
    }
    }

    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
    DialogBox(hInstance,(LPCTSTR)IDD_MAIN,NULL,(DLGPROC)MainProc);
    return 0;
    }


    If I run my program, it instantly closes. However, if I remove the List Control from the dialog, it does run.






  • Add a call to InitCommonControlsEx at the start of your program.

    : [b][red]This message was edited by Psyko at 2002-11-1 9:15:43[/red][/b][hr]
    : It is not a Listbox, it is a List Control. Also knows as List View, if you prefer.
    :
    : So, I make a simple Dialog in the ressource editor, there is only one button, and one List Control.
    :
    : Here is the code.
    :
    :
    : #include
    : #include "resource.h"
    :
    : LRESULT CALLBACK MainProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    : {
    : switch(Msg)
    : {
    : case WM_COMMAND:
    : switch(LOWORD(wParam))
    : {
    : case IDC_CLOSE:
    : EndDialog(hWnd,0);
    : return TRUE;
    : default:
    : return FALSE;
    : }
    :
    : case WM_CLOSE:
    : EndDialog(hWnd,0);
    : return TRUE;
    :
    : default:
    : return FALSE;
    : }
    : }
    :
    : int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    : {
    : DialogBox(hInstance,(LPCTSTR)IDD_MAIN,NULL,(DLGPROC)MainProc);
    : return 0;
    : }
    :
    :
    : If I run my program, it instantly closes. However, if I remove the List Control from the dialog, it does run.
    :
    :
    :
    :
    :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories