如何固定一个activex控件的初始大小?
Q:
我做了一个控件(用MFC),做好之后,我想只要把它加入一个对话框它就自动设成固定大小,我试了多种方法都不行,我重载了precreatewindow,还有colecontrol::setinitialsize,都没有任何效果,控件只要一加入对话框的资源栏就自动成初始大小(100,50),可是如果在activex control test container中就没有问题。
A:
a1:(未验证)
return ideal RECT in IOleObjectImpl::GetExtent。
a2:(已通过验证)
First, we need to set the initial size of the control to its static size using the COleControl::SetInitialSize method. This should be done in your control 's constructor like this:
// CFAQCtrl::CFAQCtrl - Constructor
CFAQCtrl::CFAQCtrl()
{
InitializeIIDs(&IID_DFAQ, &IID_DFAQEvents);
SetInitialSize( 28, 28 );
}
override OnSetExtent and return FALSE, which tells the container that the control cannot be re-sized
BOOL CFAQCtrl::OnSetExtent( LPSIZEL lpSizeL )
{
return FALSE;
}