Thread: Weird error with WC_LISTVIEW

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    52

    Question Weird error with WC_LISTVIEW

    Hi guys,

    I'm new to programming in windows so I thought I'd write a simple program to start me off.

    I have this code:

    Code:
    HWND hList;
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
        /* snip */
    
        hList = CreateWindowEx(
            LVS_EX_FULLWORSELECT | WS_EX_CLIENTEDGE, WC_LISTVIEW, TEXT(""),
            WS_VISIBLE | WS_CHILD | LVS_REPORT,
            150, 10, 550, 300,
            hwnd, (HMENU)ID_LISTVIEW, hInstance, NULL);
    
            if(!hList)
              exitError();
    
            /* snip */
    That code works fine on Windows XP (I'm sure it works on most other windows platforms too). hInstance is externally declared and it is the instance of the main window used with RegisterClass().

    Now, when I plug in a network cable and run the program, I get error 1400 Invalid Window Handle, but only when I have WC_LISTVIEW there, if I make it TEXT("BUTTON") or something else it is displayed.

    I don't understand what is going on, it's all weird. I don't have any network code at all, just CreateWindow() 's and that's it. I have some MySQL backend code in there, but I've taken it out for the time being to see if it was that causing it.

    Any help would be greatly appreciated

    Daniel
    - Daniel Wallace

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Are you calling InitCommonControls() (Ex) and specifing the ICC_LISTVIEW_CLASSES for listviews?

    You don't need it for buttons but do for the more complex controls.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    No I'm not calling it, I tried putting it in, but I kept getting an unresolved symbol for _InitCommonControls(), even though I've included commctrl.h which is weird (in my opinion)
    - Daniel Wallace

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    Oh my god, I just checked my libraries I was linking with and forgot to include comctrl32.lib, I'm stupid.

    Sorry about that guys. Can't tell I'm new to this :P
    - Daniel Wallace

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    shouldnt LVS_EX_FULLWORSELECT be LVS_EX_FULLROWSELECT? just wondering how it compiled.. heh, musta been a typo

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    Heh, yeah, it was a typo, I'm full of those :P I prefer to re-type most things because that way, if there is a typo, you normally see it, not in this case though, heh
    - Daniel Wallace

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird things with my linked list of queue
    By -EquinoX- in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 11:23 PM
  2. weird
    By kiz in forum C Programming
    Replies: 8
    Last Post: 09-24-2007, 01:16 AM
  3. Weird Characters With GetDlgItemText
    By execute in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2006, 04:53 PM
  4. weird error
    By gandalf_bar in forum Linux Programming
    Replies: 2
    Last Post: 07-17-2005, 07:32 AM
  5. Getting weird characters in Strings
    By steve8820 in forum C Programming
    Replies: 3
    Last Post: 09-18-2001, 02:49 AM