怎样改变使用ATL创建的控件的大小(或设置初始化大小)
我使用ATL创建的控件,请问怎样改变控件的大小或者初始大小?
在使用MFC创建的ActiveX控件中,可以使用SetInitialSize(cx,cy)来设置控件的初始大小,请问在ATL中对应的方法是什么?
[解决办法]
Just like you do when using MFC. You override the SetExtent method of the IOleObject interface. Here 's some code that forces a control size of 1000x1000 HIMETRIC units.
// NoteCtl.h : Declaration of the CNoteCtl
...
class ATL_NO_VTABLE CNoteCtl :
...
STDMETHOD(SetExtent)(DWORD dwDrawAspect, SIZEL *psizel)
{
ATLTRACE(_T( "SetExtent sizing control to 1000x1000\n "));
psizel-> cx = psizel-> cy = 1000;
return IOleObjectImpl <CNoteCtl> ::SetExtent(dwDrawAspect, psizel);
}
...
};