1、使用MFC ActiveX控件向导创建控件,在“控件设置”这一步,附加功能选“运行时不可见”;
2、在C***Ctl类的OnDraw里写入下面的代码。
//限制控件窗口大小
if (rcBounds.Height()!=25 || rcBounds.Width()!=25)
SetControlSize(25,25);
CBitmap bitmap;
BITMAP bmp;
CPictureHolder picHolder;
CRect rcSrcBounds;
// Load bitmap
bitmap.LoadBitmap(IDB_NOINTERFACE);
bitmap.GetObject(sizeof(BITMAP), &bmp);
rcSrcBounds.right = bmp.bmWidth;
rcSrcBounds.bottom = bmp.bmHeight;
// Create picture and render
picHolder.CreateFromBitmap((HBITMAP)bitmap.m_hObject, NULL, FALSE);
picHolder.Render(pdc, rcBounds, rcSrcBounds);