CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005
    Location
    algiers, Algeria
    Posts
    132

    Cannot create listview control

    Hi all,
    i wouldlike to create a listview control but the createwindow function return null

    Code:
    hWndListView = CreateWindow(WC_LISTVIEW,WC_LISTVIEW,WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |LVS_REPORT | LVS_AUTOARRANGE | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_SINGLESEL, 0,0,300,300,hwnd,NULL,h, NULL);
                 if (hWndListView == NULL)
                            MessageBox(hwnd,"Oooops","",MB_OK);
    I am coding with Dev-C++.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Cannot create listview control

    Quote Originally Posted by ledaker View Post
    Hi all,
    i wouldlike to create a listview control but the createwindow function return null

    Code:
    hWndListView = CreateWindow(WC_LISTVIEW,WC_LISTVIEW,WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |LVS_REPORT | LVS_AUTOARRANGE | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_SINGLESEL, 0,0,300,300,hwnd,NULL,h, NULL);
                 if (hWndListView == NULL)
                            (hwnd,"Oooops","",MB_OK);
    I am coding with Dev-C++.
    Well, your MessageBox doesn't make any sense.
    From MSDN (CreateWindow Function):
    If the function fails, the return value is NULL. To get extended error information, call GetLastError.
    Victor Nijegorodov

  3. #3
    Join Date
    Jan 2011
    Posts
    8

    Thumbs up Re: Cannot create listview control

    While I am new to vc++ myself, I have created a listview control.

    try to see if your input handle to hwnd is valid.

    make sure h your instance handle is valid.

    I would remove some of the styles and see what you get.

    here is some code I used in my program
    hTemp = CreateWindow(WC_LISTVIEW, L"List", WS_CHILD | WS_VISIBLE | LVS_REPORT , 45 + 35, 148 + 122, 240, 110, hDlg, (HMENU)Direct_List_ID, hInst, NULL);

    //note: Direct_List_ID is useful if you plan on making reference to the control later in receiving notification messages.

    if all else is lost refer to the source for listviews
    http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx
    Last edited by JPatchSPSU; August 7th, 2011 at 11:51 AM. Reason: spelling

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Cannot create listview control

    Appropriate InitCommonControlsEx call is required prior to create common controls.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured