我是通过下面的代码来动态创建 CSTATIC 窗体的,但是 DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 却始终没有被调用,请问问题出在什么地方?void MyCell::CreateMyCell(CWnd* parent,CRect rect)
{
this->Create(
_T("STATIC"), 
_T("Header Cell"), 
WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
rect,
parent, 
1
);
}

解决方案 »

  1.   

    MSDN:The WM_DRAWITEM message is sent to the parent window of an owner-drawn button, combo box, list box, or menu when a visual aspect of the button, combo box, list box, or menu has changed.
      

  2.   

    我在它的父窗口调试,也没有调用它的 DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct),还有创建STATIC窗口时,我加了 SS_OWNERDRAM this->Create(
    _T("STATIC"), 
    _T("Header Cell"), 
    WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | SS_OWNERDRAW,
    rect,
    parent, 
    1
    );
      

  3.   

    静态文本是不是不能用DRAWITEM消息?
      

  4.   

    SS_OWNERDRAW   Specifies that the owner of the static control is responsible for drawing the control. The owner window receives a WM_DRAWITEM message whenever the control needs to be drawn. 根据MSDN 对于 SS_OWNERDRAW 的解释, STATIC 应该是自己负责 DrawItem 而不是其父窗口
      

  5.   

    不用这么复杂,直接响应OnPaint就可以了
      

  6.   

    对不起,搞错了,我以为你是派生一个CMyStatic.如果是就可以在CMyStatic中响应Paint\
      

  7.   

    你的DrawItem是在哪里实现的?
      

  8.   

    http://topic.csdn.net/t/20030917/20/2271499.html
    http://blog.chinaunix.net/u/19962/showart_136117.html
      

  9.   

    为什么很多人推荐用ONDRAW 来重画,而不用ONPAINT? 我现在用ONPAINT来重画的,但当改变窗口大小时会出现闪烁,通过ONDRAW来画,就可以避免闪烁吗?