及其它窗体(dialog)中某控件的位置,宽高。

解决方案 »

  1.   

    CRect winrect;
    GetWindowRect(&winrect);
    int winwidth = winrect.right-winrect.left; // 窗体宽
    int winhiegh = winrect.bottom-winrect.top; // 窗体高只要得到某控件的CWnd 对象或指针,其操作与上相同;至于位置,可通过ClientToScreenT和ScreenToClient转换。
      

  2.   

    CRect ClientRect;
    CRect WindowRect;
    CRect ToolbarRect; &this->GetWindowRect(&WindowRect);
    &this->GetWindowRect(&ClientRect);
    &this->CalcWindowRect(&WindowRect,CWnd::adjustBorder);
    m_wndToolBar.GetWindowRect(&ToolbarRect);
    //Height = WindowRect.Height()
      

  3.   

    我想在基于dialog的程序中开辟一块区域用于画图,不知道这块区域用什么控件比较好?
      

  4.   

    在Onpaint()和OnReDraw()中使用CDC dc的成员函数直接画就可以了,没有必要专门定一块区域吧。
      

  5.   

    同lingfeng8888(棱枫)。楼主意思可能是先检查一下该区域有无有控件,有的话先移动一下腾出空间。
      

  6.   

    CRect rect;
    GetWindowRect(rect);
    rect.Height();高度
      

  7.   

    其实任何一种控件只要是直接或间接从CWindow类继承来的类都可以在其中绘图和写字下面给你举个例子:    
    //m_edit1是与一个文本框控件相关联的变量
    CBrush *brush;
    brush=new CBrush;
    brush->CreateSolidBrush(0xff0000);  
    CDC *pDC=this->m_edit1.GetDC();
    pDC->SelectObject(brush);
             pDC->Ellipse(20,20,100,50);
    pDC->DeleteDC(); 
             delete brush;
    //输出结果在文本框里面绘制一个蓝色的椭圆
      

  8.   

    //m_edit1是与一个文本框控件相关联的变量
    HICON icon1;
             icon1=LoadIcon(AfxGetApp()->m_hInstrance,(LPCTSTR)IDI_ICON1);
             
             CBrush *brush;
             CPoint oldPoint;
    brush=new CBrush;
    brush->CreateSolidBrush(0xff0000);  

             CDC *pDC=this->m_edit1.GetDC();
    pDC->SelectObject(brush);
             
             pDC->DrawIcon(icon1);  //绘制图标
             
             pDC->Ellipse(20,20,100,50);绘制椭圆
             
             pDC->MoveToEx(100,100,oldPoint);
             pDC->LineTo(200,200); //从100到200的一条直线

             pDC->DeleteDC(); 
             delete brush;
             
    如果你要想捕获鼠标事件你必须要使用GetWindowLong(),SetWindowLong()两个函数将编辑子类化,然后才能对该编辑框进行正常的鼠标捕获操作。多看看书,学习VC编程最好还是从Win32编程开始写了两次了给点分吧,兄弟