|
-
July 28th, 2012, 07:52 PM
#1
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);
}
-
July 29th, 2012, 10:47 AM
#2
Re: Cannot subclass listview in combobox
 Originally Posted by ledaker
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
-
July 29th, 2012, 11:34 AM
#3
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.
-
July 29th, 2012, 11:48 AM
#4
Re: Cannot subclass listview in combobox
Did you debug the calls? I cannot see any error checking there.
Best regards,
Igor
-
July 29th, 2012, 12:08 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|