Article ID: 128110
Article Last Modified on 7/11/2005
LRESULT CALLBACK NewComboProc(
HWND hWnd,
UINT uMessage,
WPARAM uParam,
LPARAM lParam)
{
HDC myDC;
HPEN hPen, hOldPen;
HBRUSH hBrush;
HBRUSH hOldBrush;
COLORREF myColor=RGB(255,255,255); //It can be any color. Here
//the area is painted white.
HWND hEdit, hList;
RECT comboRect, editRect, listRect;
char *wndClassName="Edit";
if (uMessage == WM_PAINT)
{
CallWindowProc(lpfnOldComboProc, hWnd, uMessage, uParam,
lParam);
myDC = GetDC(hWnd);
hBrush = CreateSolidBrush(myColor);
hPen = CreatePen (PS_SOLID, 1, myColor);
hOldBrush = SelectObject(myDC, hBrush) ;
hOldPen = SelectObject(myDC, hPen);
//This code obtains the handle to the edit control of the
//combobox.
hEdit = GetWindow(hWnd, GW_CHILD);
GetClassName (hEdit, wndClassName, 10);
if (!lstrcmp (wndClassName, "Edit"))
hList=GetWindow(hEdit, GW_HWNDNEXT);
else
{
hList=hEdit;
hEdit=GetWindow(hList, GW_HWNDNEXT);
}
//The dimensions of the Edit Control, ListBox control and
//the Combobox are calculated and then used
//as the base dimensions for the Rectangle() routine.
GetClientRect (hWnd, &comboRect);
GetClientRect (hEdit, &editRect);
GetClientRect (hList, &listRect);
Rectangle (myDC,
comboRect.left,
editRect.bottom,
comboRect.right-listRect.right,
comboRect.bottom);
//Also paint the gap, if any exists, between the bottom
//of the listbox and the bottom of the ComboBox rectangle.
Rectangle (myDC,
comboRect.right-listRect.right,
editRect.bottom +
listRect.bottom,
comboRect.right,
comboRect.bottom);
DeleteObject(SelectObject(myDC, hOldBrush)) ;
DeleteObject(SelectObject(myDC, hOldPen)) ;
ReleaseDC(hWnd, myDC);
return TRUE;
}
return CallWindowProc(lpfnOldComboProc, hWnd, uMessage, uParam,
lParam);
}
Additional query words: win16sdk
Keywords: kbcombobox kbctrl kbprb KB128110