CButton DrawItem problem
-
I've create my own CButton derived class with the BS_OWNERDRAW style. Somehow the button's DrawItem method is not called, and the button is not displayed. When I remove the BS_OWNERDRAW style the button is draw. I'm not getting this, am I'm missing something? This should be simple.
-
I've create my own CButton derived class with the BS_OWNERDRAW style. Somehow the button's DrawItem method is not called, and the button is not displayed. When I remove the BS_OWNERDRAW style the button is draw. I'm not getting this, am I'm missing something? This should be simple.
-
Did you consider the correct declaration of the function, that means did you declare it as virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct ) ?
I did. And I probalby also found the cause of the problem. I copied the code to a simple dialog and it works there. In my current project there are a lot of OnCommand function (I did not write the code) and someting probably goes wrong there.
-
I did. And I probalby also found the cause of the problem. I copied the code to a simple dialog and it works there. In my current project there are a lot of OnCommand function (I did not write the code) and someting probably goes wrong there.
I like to autosize the owner draw button depending upon the text that it load dynamically based on localization strings. so some strings are large than others. Keeping this I override DrawItem in the inherited class from CButton. The sample code is below void CMyGraphicButton::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct) { CString cs; CString cslong; ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON); LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData; if (!lpszText || lpszText == (LPCTSTR)-1) { GetWindowText (cs); } else cs = lpszText; // now i m trying to resize , so let try to increase the size of button unconditioally // I get //lpDrawItemStruct>rcItem.left =0 //lpDrawItemStruct>rcItem.right =75 //lpDrawItemStruct>rcItem.top = 0 //lpDrawItemStruct>rcItem.bottom = 25 //As my button is on extreme right side of dialog so i tried to extend/increase the size of // button of the left side as follows lpDrawItemStruct>rcItem.left -= 25 ; // but the above causes the text to be moved on right side insead of resize/increase the //button size. other code here... Any idea or help is appriciated. Thanks Anil
[AKS]