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

    Exclamation Cannot subclass listview in combobox

    Hi,
    I am customizing a combobox control, to do that i am subclassing the listview of combobox but it doesn't work! this my code
    Code:
    COMBOBOXINFO *pcbi;
            pcbi->cbSize = sizeof(COMBOBOXINFO);       
            SendMessage(GetDlgItem(hwndDlg, IDC_COMBO1),  0x0164, 0,(WPARAM)pcbi);
            g_oldProc6 = (WNDPROC)SetClassLong(pcbi->hwndList, GWL_WNDPROC, long(WindowProcedure6));
    .
    .
    .
    LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        PAINTSTRUCT lpPaint;
        RECT lpRect;
        HFONT hFont;
        HDC hDC;
        HPEN Pen;
        HBRUSH hBrush,oBrush;
        
        if(message == WM_PAINT)
        {
            GetClientRect(hwnd, &lpRect);
    
            hBrush = CreateSolidBrush(RGB(255,0,255));
            oBrush = CreateSolidBrush(RGB(200,200,200));
            hFont = CreateFont(12, 0, 0, 0, FW_NORMAL, 0, 0, 0, 0, 0, 0, 0, 0, "Verdana");
            SIZE NSize;
    
            hDC = BeginPaint(hwnd, &lpPaint);
            SelectObject(hDC, hFont);
            FillRect(hDC,&lpRect,hBrush);
    
            FrameRect(hDC,&lpRect,oBrush);
            EndPaint(hwnd, &lpPaint);
    
            DeleteObject(hFont);
            DeleteObject(hBrush);
            DeleteObject(oBrush);
    
            return 0L;
        }
        return CallWindowProc(g_oldEditProc6, hwnd, message, wParam, lParam);
    }

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

    Re: Cannot subclass listview in combobox

    Quote Originally Posted by ledaker View Post
    Code:
    COMBOBOXINFO *pcbi;
            pcbi->cbSize = sizeof(COMBOBOXINFO);       
            SendMessage(GetDlgItem(hwndDlg, IDC_COMBO1),  0x0164, 0,(WPARAM)pcbi);
            g_oldProc6 = (WNDPROC)SetClassLong(pcbi->hwndList, GWL_WNDPROC, long(WindowProcedure6));
    .
    .
    .
    LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    Is it a typo?
    Best regards,
    Igor

  3. #3
    Join Date
    Dec 2005
    Location
    algiers, Algeria
    Posts
    132

    Re: Cannot subclass listview in combobox

    Hi,
    yes it's a typo when i wrote the code in the post.the combobox is creating with the following styles (CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP).
    Last edited by ledaker; July 29th, 2012 at 11:45 AM.

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

    Re: Cannot subclass listview in combobox

    Did you debug the calls? I cannot see any error checking there.
    Best regards,
    Igor

  5. #5
    Join Date
    Dec 2005
    Location
    algiers, Algeria
    Posts
    132

    Re: Cannot subclass listview in combobox

    I have changed the function SetClassLong with SetWindowLong, in this case i can subclass:
    ComboBox Edit (g_oldEditProc6 = (WNDPROC)SetWindowLong(pcbi->hwndItem, GWL_WNDPROC, long(WindowProcedureEdit6));).
    ComboxBox itself (g_oldEditProc6 = (WNDPROC)SetWindowLong(pcbi->hwndCombo, GWL_WNDPROC, long(WindowProcedureEdit6));).
    but i cannot subclass ComboBox ListBox (g_oldEditProc6 = (WNDPROC)SetWindowLong(pcbi->hwndList, GWL_WNDPROC, long(WindowProcedureEdit6));).
    I have also noticed in this case that my DialogBox style has changed.
    untitled.JPG

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