大家好,为什么我在程序里用上面二个函数,都能得到矩形框的大小啊?我想知道两者的区别?我是VC新手。

解决方案 »

  1.   

    GetWindowRect(m_rSettingsRect),实际上在CRect内部先走了operator LPRECT() throw();
    ATLTYPES_INLINE CRect::operator LPRECT() throw()
    { return this; }
    CRect转化成为了LPRECT类型。
      

  2.   

    CRect
    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.
      

  3.   

    GetWindowRect实际上形参就是LPRECT,我觉得已经很详细了,你自己可以断点跟一下。两者的区别。实际上是微软封装的CRect对象作为参数传进去的时候的特殊处理。