You need to override OnMeasureItem()
-SM
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have created my own list box with the base class of CListBox. when I use it in the Dialog box it works fine.
but when I try to create dynamic at runtime it gives an error.
here is my code for it
m_LstList= new x_ListBox;
m_LstList->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL |
LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS, rect, m_hWnd, IDC_X_LIST);
am I doing anything wrong?
or there is any extra setting I have to make inside x_ListBox class
class x_ListBox : public CListBox
{
public:
x_ListBox();
virtual ~x_ListBox();
LIST_BOX_TYPE m_ListBoxType;
// my functions for custom draw
protected:
afx_msg void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
DECLARE_MESSAGE_MAP()
};
You need to override OnMeasureItem()
-SM
hi - SM
thanks for your reply. but still not working
I added this line
afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
can't add any item or String to Listbox
Ok, my Mistake.
sorry above code is I Made a mistake
Added these 2 functions from wizard
afx_msg void MeasureItem(LPMEASUREITEMSTRUCT /lpMeasureItemStruct/);
afx_msg int CompareItem(LPCOMPAREITEMSTRUCT /lpCompareItemStruct/);
now it did not give an error.
but control did not show. (display)
yes. I have.
at first, when I click on the dialog box it does not show. but when I move the mouse it comes like this.
do not know what is wrong. I am having difficulty understanding this.
my Code for this
rect = { pf->m_ValueRc.left - 1, pf->m_ValueRc.bottom, pf->m_ValueRc.right + 1, pf->m_ValueRc.bottom + 250 };
m_LstList= new x_ListBox;
m_LstList->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL |
LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS, rect, m_hWnd, IDC_X_LIST);
m_LstList->InitLineWeight();
m_LstList->SetFont(m_hWnd->GetFont());
m_LstList->ShowWindow(SW_SHOW);
thank you for your help.
Yes. you are right. I am trying to make like a Property sheet. I made my own grid UI. and need to pop up when mouse click on a related field
it supposed to be like this.
but it is not taking SetBkMode functions from DrawItem inside xListBox
dcContext.SetBkMode( TRANSPARENT ); // not useing
dcContext.TextOut( TxRc.left, TxRc.top, strColour );
i have use OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) on dialog box Class to repain Text EditBox only but
if (pWnd == m_Prop.m_TxEdit)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(200, 200, 200));
return m_brBkgnd;
}
return hbr;
that image is displayed when I use scroll in Listbox. but when I click on the list box and outside of list box. it like previous image.