具体是这样的,我的程序是基于对话框的,然后再对话框上添加了一个PICTURE控件。再然后就是在这个控件上画图,画完图后弹出动态创建的STATIC提示信息。然后响应鼠标单击事件。问题:响应完单击事件后,怎么让文本提示信息消失?
dialog、picture

解决方案 »

  1.   

    static控件showwindow(sw_hide)不行么
      

  2.   

    CStatic m_wndStatic
    你在鼠标单击消息处理函数中销毁窗口?if(IsWindow(m_wndStatic.m_hWnd))
    DestroyWindow(m_wndStatic.m_hWnd);
      

  3.   

    CToolTipCtrl Class
    Encapsulates the functionality of a "tool tip control," a small pop-up window that displays a single line of text describing the purpose of a tool in an application.可以使用这个!
      

  4.   

    不行啊  例如我在LBUTTONUP中创建控件,然后再鼠标点击后,释放内存的同时让其消失,但是在响应函数中不能调用SHOWWINDOW函数   不知道是不是我用的不对啊
      

  5.   

    这个估计不行吧  我的绘图是在自定义的类中(CStatic)
      

  6.   


    你的CStatic是自定义的?即使是自定义的,那也应该是派生于CWnd类吧??
      

  7.   

    自定义的,那也应该是派生于CWnd类
      

  8.   

    是的,那应该怎么调用SHOWWINDOW隐藏创建的控件呢?
    if( p_MyBut[0])
     {
     p_MyBut->ShowWindow(SW_HIDE);
        delete p_MyBut[0];
    m_IsDel=TRUE;
    m_IsCls=FALSE;;

     }
    这样调用时出现错误:
    error C2227: left of '->ShowWindow' must point to class/struct/union
      

  9.   


    把你的那个自定义类的声明 和 p_MyBut的声明代码贴出来
      

  10.   

    类声明
    class CMyStatic : public CStatic
    声明
    CStatic* p_MyBut[3];
    创建
    CStatic *p_MyBut = new CStatic();
    p_MyBut->Create( m_Caption, WS_CHILD | WS_VISIBLE | SS_NOTIFY | nStyle, rect, this, nID );
      

  11.   


    #ifndef DELETE_PTRA
    #define DELETE_PTRA(p) if(p){delete[] p;p=NULL;}
    #endifif( p_MyBut[0] && IsWindow(p_MyBut[0]->m_hWnd))
     {
        p_MyBut[0]->ShowWindow(SW_HIDE);
        DestroyWindow(p_MyBut[0].m_hWnd);
        //delete p_MyBut[0];
        //p_MyBut[0]=NULL;
        DELETE_PTRA(p_MyBut[0]);
        m_IsDel=TRUE;
        m_IsCls=FALSE;;
     }
      

  12.   

    声明
    CStatic* p_MyBut[3];
    创建
    CStatic *p_MyBut = new CStatic();
    --------------------------------------------你这是什么意思??
      

  13.   

    给我要动态创建的STATIC控件分配内存
      

  14.   

    DestroyWindow(p_MyBut[0].m_hWnd);
    报错:D:\SCAN\2302\MyStatic.cpp(149) : error C2228: left of '.m_hWnd' must have class/struct/union type
    D:\SCAN\2302\MyStatic.cpp(149) : error C2660: 'DestroyWindow' : function does not take 1 parameters
      

  15.   

    声明
    CStatic* p_MyBut[3];
    创建
    CStatic *p_MyBut = new CStatic();
    --------------------------------------你不是声明了p_MyBut[3]嘛,干嘛还要CStatic *p_MyBut = new CStatic();????
    你直接p_MyBut[0] = new CStatic(); 不就行了!!! 你这逻辑乱的...........
      

  16.   

    DestroyWindow(p_MyBut[0].m_hWnd); 改成
    DestroyWindow(p_MyBut[0]->m_hWnd);
      

  17.   

    还是报错:
    error C2660: 'DestroyWindow' : function does not take 1 parameters
      

  18.   

    在响应函数中使用:
    ::DestroyWindow(GetDlgItem(IDC_STATICXXX)->GetSafeHwnd());
      

  19.   

    void CMyStatic::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default m_startRect = TRUE;   //鼠标左键单击,设置可以开始绘制矩形框 
    m_startPoint = point; //记录开始点 
    m_OldPoint = point;   //设置老点也为开始点 CStatic::OnLButtonDown(nFlags, point);
    }void CMyStatic::OnLButtonUp(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default m_startRect = FALSE; //重置绘制矩形框标志 
    m_IsDel=FALSE;
    CClientDC dc(this); 
    // m_IsDel=FALSE;
    // dc.SetROP2(R2_NOT); 
    // dc.SelectStockObject(NULL_BRUSH); 
    // dc.Rectangle(CRect(m_startPoint,m_OldPoint));
    if(TRUE==m_IsMove)
    {
    p_MyBut[0] = NewMyStatic( IDC_STATIC2, CRect(point.x,point.y,point.x+80,point.y+35), BS_DEFPUSHBUTTON );
    m_IsMove=FALSE;
    }
    // delete p_MyBut[0];
    }void CMyStatic::OnMouseMove(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    if(TRUE==m_IsDel)
    {
    CClientDC dc(this);   //获取设备句柄 

    dc.SetROP2(R2_NOT);    
    dc.SelectStockObject(NULL_BRUSH); //不使用画刷 
    if (TRUE == m_startRect)   //根据是否有单击判断是否可以画矩形 

       dc.Rectangle(CRect(m_startPoint,m_OldPoint)); 
       dc.Rectangle(CRect(m_startPoint,point)); 
       m_OldPoint = point; 
       m_IsMove=TRUE;
       m_IsCls=TRUE; //消隐最后的一个矩形(其原理跟拖动时矩形框绘制原理相同)
      //  
    }
    //
    }
    CStatic::OnMouseMove(nFlags, point);
    }CStatic* CMyStatic::NewMyStatic(int nID,CRect rect,int nStyle)
    {
    CString m_Caption;
    m_Caption.LoadString( nID ); //取按钮标题
    // CStatic *p_MyBut = new CStatic();
    p_MyBut[0] = new CStatic();
    p_MyBut[0]->Create( m_Caption, WS_CHILD | WS_VISIBLE | SS_NOTIFY | nStyle, rect, this, nID );
    return p_MyBut[0];}
    void CMyStatic::OnMybut1()
    {
     MessageBox( "CLICKED!" );
     CClientDC dc(this);  dc.SetROP2(R2_NOT); 
    dc.SelectStockObject(NULL_BRUSH); 
    dc.Rectangle(CRect(m_startPoint,m_OldPoint));
     if( p_MyBut[0])
     {
     p_MyBut[0]->ShowWindow(SW_HIDE);
     ::DestroyWindow(GetDlgItem(IDC_STATIC2)->GetSafeHwnd());
        delete p_MyBut[0];
    m_IsDel=TRUE;
    m_IsCls=FALSE;;

     }
    //p_MyBut[0]->DestroyWindow();//ShowWindow(SW_HIDE);
    }void CMyStatic::OnLButtonDblClk(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    //p_MyBut[0] = NewMyStatic( IDC_STATIC2, CRect(point.x,point.y,point.x+80,point.y+35), BS_DEFPUSHBUTTON );
    CStatic::OnLButtonDblClk(nFlags, point);
    }void CMyStatic::OnRButtonDown(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    if(TRUE==m_IsCls)
    {

    m_IsCls=FALSE;
    if( p_MyBut[0])
    {
    CClientDC dc(this);
    dc.SetROP2(R2_NOT); 
    dc.SelectStockObject(NULL_BRUSH); 
    dc.Rectangle(CRect(m_startPoint,m_OldPoint));
    // ::DestroyWindow(GetDlgItem(IDC_STATIC2)->GetSafeHwnd());
    delete p_MyBut[0];
    m_IsDel=TRUE;
     }
    }
    CStatic::OnRButtonDown(nFlags, point);
    }
      

  20.   

    CStatic* CMyStatic::NewMyStatic(int nID,CRect rect,int nStyle)
    {
    CString m_Caption;
    m_Caption.LoadString( nID ); //取按钮标题
    // CStatic *p_MyBut = new CStatic();
    p_MyBut[0] = new CStatic();
    p_MyBut[0]->Create( m_Caption, WS_CHILD | WS_VISIBLE | SS_NOTIFY | nStyle, rect, this, nID );
    return p_MyBut[0];
    }
    ----------------------------
    p_MyBut[0]应该是你的类成员变量吧,如果是,改成:CMyStatic::NewMyStatic(int nID,CRect rect,int nStyle)
    {
         CString m_Caption;
         m_Caption.LoadString( nID ); //取按钮标题
          // CStatic *p_MyBut = new CStatic();
         if(p_MyBut[0] = new CStatic())
         {
              p_MyBut[0]->Create( m_Caption, WS_CHILD | WS_VISIBLE | SS_NOTIFY | nStyle, rect, this, nID );
         }
    }
    void CMyStatic::OnMybut1() 函数中:
     ::DestroyWindow(GetDlgItem(IDC_STATIC2)->GetSafeHwnd());
    你这扯哪儿去了??
    批一下22楼的,你这纯属误人子弟!!
    这一句改回去
      

  21.   

    笔误
    void CMyStatic::NewMyStatic(int nID,CRect rect,int nStyle) 
      

  22.   

    p_MyBut->ShowWindow(SW_HIDE);
    (p_MyBut[0])->ShowWindow(SW_HIDE);
      

  23.   

    区别大了 !
    p_MyBut 是指针数组。
    p_MyBut[0] 是第一个元素,他才是指向 static 的 指针!
      

  24.   

    这个我知道  我的程序里边也是p_MyBut[0] 我是说加括号  呵呵 
      

  25.   

    // 既然是 派生 类, 那么 使用 每个 实例 的 click
    // 根本不要 p_MyBut ,如果要 区分 那个 实例 使用 GetDlgCtrlID() 
    void CMyStatic::OnClick()
    {
     MessageBox( "CLICKED!" );
    // CClientDC dc(this); //dc.SetROP2(R2_NOT); 
    //dc.SelectStockObject(NULL_BRUSH); 
    //dc.Rectangle(CRect(m_startPoint,m_OldPoint));
    // if( p_MyBut[0])
    // {
    // p_MyBut[0]->ShowWindow(SW_HIDE);
       this->DestroyWindow();
    //    delete p_MyBut[0];
    m_IsDel=TRUE;
    m_IsCls=FALSE;; }