m_button.Create("Text",WS_VISIBLE|WS_CHILD|BS_AUTORADIOBUTTON,Rect,OnOK,IDOK);
请问其中的  Rect 如何定义?
怎么赋值?
谢了

解决方案 »

  1.   

    RECT Structure
    The RECT data structure has the following form:typedef struct tagRECT {
       LONG left;
       LONG top;
       LONG right;
       LONG bottom;
    } RECT;The RECT structure defines the coordinates of the upper-left and lower-right corners of a rectangle.MembersleftSpecifies the x-coordinate of the upper-left corner of a rectangle.topSpecifies the y-coordinate of the upper-left corner of a rectangle.rightSpecifies the x-coordinate of the lower-right corner of a rectangle.bottomSpecifies the y-coordinate of the lower-right corner of a rectangle.See Also   CRectCRect
    The CRect class is similar to a Windows RECT structure. CRect also includes member functions to manipulate CRect objects and Windows RECT structures. A CRect object can be passed as a function parameter wherever a RECT structure, LPCRECT, or LPRECT can be passed.Note   This class is derived from the tagRECT structure. (The name tagRECT is a less-commonly-used name for the RECT structure.) This means that the data members (left, top, right, and bottom) of the RECT structure are accessible data members of CRect.A CRect contains member variables that define the top-left and bottom-right points of a rectangle.
    CRect  rcButton;rcButton.top = 0;
    rcButton.left = 0 ;
    rcButton.right = 100;
    rcButton.buttom = 100
      

  2.   

    楼上说的对,但CRect不同于CSize,它代表的是某个位置上的rectangle,所以top和left是这个rectangle的位置,对于一个button来说,放在左上角显然不合适。
      

  3.   

    应该这样:
      CRect rect;
      CWnd* pWnd=GetDlgItem(IDC_BUTTON1);
      pWnd->GetWindowRect(&rect);
      ScreenToClient(&rect); 
      m_button.Create("Text",WS_VISIBLE|WS_CHILD|BS_AUTORADIOBUTTON,rect,OnOK,IDOK);