OnDrawItem / OnPaint problem...
-
Hi, I've been able to create an activeX control and to change its background color and font using OnDrawItem. Now my problem is that everytime I put this activeX in a composite control and then use this composite control as an ActiveX over the Internet, I can see everything being drawn and disappear... First I just implemented the OnPaint function in the composite control with just 'return 0' in it -> my activeX control shows up, the onSize function works great, but of course, if I switch from a window to another one, the activeX control disappears and is not refreshed... Here is some code: From the activeX: BEGIN_MSG_MAP(CSRAxControl) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem) CHAIN_MSG_MAP(CComControl) ALT_MSG_MAP(1) END_MSG_MAP() From the composite control: LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { _axViewControl.SetFocus(); return 0; } LRESULT CIdefixView::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled){ HRESULT hresult=0; CLSID clsid; CWindow hwndParent = NULL; hwndParent = GetParent(); CComPtr myIDispatchView; CComBSTR progID = OLESTR("Ctrls.SRAxControl"); hresult = CLSIDFromProgID(progID, &clsid) ; if (SUCCEEDED(hresult)){ hresult = CoCreateInstance(clsid, 0, CLSCTX_ALL, IID_IDispatch, (void**)&myIDispatchView); if(SUCCEEDED(hresult)) { _axViewControl.Attach(GetDlgItem(IDC_VIEW)); _axViewControl.ModifyStyle( NULL, WS_CLIPSIBLINGS, SWP_SHOWWINDOW ); hresult=_axViewControl.AttachControl(myIDispatchView, NULL); _pViewControl = myIDispatchView; RECT rc; hwndParent.GetClientRect(&rc); _axViewControl.MoveWindow( 0, 0, rc.right - rc.left, 26, TRUE ); } } return S_OK; } Please Help !! Thanks, Catherine.