Change ListBox border color... how?

This is a discussion on Change ListBox border color... how? within the Windows Programming forums, part of the Platform Specific Boards category; I'm making a ownerdraw ListBox: Code: hListBox = CreateWindowEx(NULL, "LISTBOX", NULL, LBS_HASSTRINGS|LBS_OWNERDRAWFIXED|LBS_NOINTEGRALHEIGHT|LBS_NOTIFY|WS_CHILD|WS_VISIBLE|WS_BORDER, 5, 5, 150, 150, hWndParent, (HMENU)1201, g_hInst, NULL); ...

  1. #1
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308

    Red face Change ListBox border color... how?

    I'm making a ownerdraw ListBox:
    Code:
    hListBox = CreateWindowEx(NULL, "LISTBOX", NULL, LBS_HASSTRINGS|LBS_OWNERDRAWFIXED|LBS_NOINTEGRALHEIGHT|LBS_NOTIFY|WS_CHILD|WS_VISIBLE|WS_BORDER, 5, 5, 150, 150, hWndParent, (HMENU)1201, g_hInst, NULL);
    I'm attempting to change to color of the border in WM_CREATE
    Code:
    RECT r;
    			GetWindowRect(hListBox, &r);
    			HDC hdc = GetDC(hListBox);
    			FrameRect(hdc, &r, GetSysColorBrush(COLOR_INFOBK));
    			ReleaseDC(hListBox, hdc);
    Any ideas...?
    I try this on my WM_DRAWITEM but no luck

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    GetWindowRect returns the window dimensions in screen coordinates, not client coordinates as you seem to require - use GetClientRect for that. In any event, your window doesn't have any extended style 'edges' - it's all client area. You also don't need to use GetDC - the lParam passed to your WM_DRAWITEM handler should be cast to a DRAWITEMSTRUCT pointer and its hDC member variable used instead.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    Thanks... will test

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reference parameters and calculating change
    By Cstudent2121 in forum C Programming
    Replies: 6
    Last Post: 11-04-2005, 02:19 PM
  2. Button and edit control border
    By maxorator in forum Windows Programming
    Replies: 4
    Last Post: 11-04-2005, 01:31 PM
  3. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 07:55 AM
  4. program wont run, always aborts
    By stormfront in forum C Programming
    Replies: 31
    Last Post: 10-31-2005, 04:55 PM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21