Let the ActiveX control design status lock in the container in the container, you can use the following macro, the macro is a window-free ActiveX control, compiled successfully under VC . Net (ATL7.0).
#ifndef __control_no_window_with_icon __ # define __control_no_window_with_icon__
#include
/ * This macro implements a windowless control when the design mode shows a small icon under the design window, the window size is fixed icon size
This macro inherits the four functions of the control setObjectRects Some containers must specify this function to specify the window size GetExtent container to the control query window size onDRAW to draw icons
Parameters: ID nCx icon classControl control class name iconID icon (control window) width nCY icon (control window) height * / # define CONTROL_NO_WINDOW_WITH_ICON (classControl, iconID, nCx, nCy) / public: / STDMETHOD (SetObjectRects) (LPCRECT prcPos, LPCRect prcClip) / {/ csize size (prcpos-> right - prcpos-> left, prcpos-> bottom - prcpos-> top); / / if (size.cx! = Ncx || size.cy! = Ncy) / {/ m_spInPlaceSite-> OnPosRectChange (CRect (prcPos-> left, prcPos-> top, prcPos-> left nCx, prcPos-> top nCy)); / return S_OK; /} / / IOleInPlaceObjectWindowlessImpl
* (RECT *) di.prcBounds; / FillRect (di.hdcDraw, & rc, hBrush); / DeleteObject (hBrush); / SetBkMode (di.hdcDraw, TRANSPARENT); hIcon / HICON = LoadIcon (_AtlBaseModule.GetResourceInstance (), MAKEINTRESOURCE (iCONID)); / Drawicon (Di.hdcdraw, rc.left, rc.top, hic); / deleteObject (hic); / / RETURN S_OK; /} #ENDIF / / __CON_NO_WINDOW_WITH_ICON__