我是想改变控件的大小,比如说按钮的,我以前是搞.NET的对C++不是很了解刚接触,在.NET中直接ID.Width或ID.Height就可以知道空间的宽和高了,我想知道在C++中怎么获取到,回答真确的追加50。哪位大侠多多帮忙,非常感谢。
GetWindowRect()用这个方法获得了控件的位子,再怎么改变控件的大小呢????或者说SetWindowRgn()这个方法怎么用,里面还想没有改变控件大小的参数,只有HRGN和bRedraw和怎么设置大小啊???
追答你要先创建一个CRgn类,CRgn类是MFC的区域类,可以表示一片特定形状的区域。调用CRgn类的CreateRectRgn(int x1,int y1,int x2,int y2 )或者CreateRectRgnIndirect(LPCRECT lpRect )就可以创建一个代表一个矩形区域的CRgn类,CRgn类重载了HRGN操作,也就是说可以把CRgn类的对象当HRGN用。调用SetWindowRgn后就会把你的控件放置到CRgn所代表的矩形区域。
追问我有先头创建的CRect rc;放进CRgn.CreateRectRgnIndirect(rc);里面,然后直接写SetWindowRgn(rgn,true);页面直接是空白的。
追答不好意思,通过试验,我发现SetWindowRgn和SetWindowPos对于按钮控件是没有用的,我查了下资料,发现如果按钮有BS_OWNERDRAW属性,那么可以重载该按钮的DrawItem函数,在这个函数中可以改变大小,这貌似有点复杂。别怪我才疏学浅啊!!!你要是找到怎么改变的方法,记得写出来,我也想学下!
声明了一个CButton Btn1;的变量 怎么把我要改变的大小的按钮控件ID Btn2,装载到Btn1里面去啊???然后用Btn1.MoveWindow()你是这个意思吗??
追答将btn2的指阵赋给btn1,通过btn1指针操作btn2的控件。你试试这个方法。
追问大虾,你不要直接给我说,你帮我写写代码,我自己写又会偏离方向!!!万分感谢。
追答// m_btn1.MoveWindow(0,0,100,100);
CButton *m_btn2;
m_btn2=&m_btn1;
m_btn2->MoveWindow(0,0,100,100);
你看看这段代码,如果有不懂的再问我。