我想要一个Activex里面动态的创建多个个数的Activex控件(同一个控件多次创建),
现在是这样实现的:
typedef struct  _HFRAME_INFO
{
CAxWindow   axNestedControl;
DWORD       dwHFrameEvt;
        CHFrameEventSink    *pEvent;
IHFramePtr m_spBrowser;
_HFRAME_INFO()
{
m_spBrowser = NULL;
dwHFrameEvt = 0;  
pEvent = NULL; 
}
}HFRAME_INFO;
Creatnew(int R, int C)//根据行列得到每个控件的显示位置和大小。
{
        RECT  rc; 
        GetClientRect(&rc);  
if(R == 0 || C == 0)
return S_FALSE;
  int m_nXGap = rc.right/C;
  int m_nYGap = rc.bottom/R;
for(int c = 0; c < C; c++ )
   for(int r = 0; r< R; r++)//依次创建多个控件(同一个控件多次创建)
   {
   RECT src;
   src.left = c * m_nXGap;
   src.right = (c + 1) * m_nXGap;
   src.top = r * m_nYGap;
   src.bottom = (r + 1) * m_nYGap;
           HFRAME_INFO  m_hframeinfo;
           if(m_hframeinfo.axNestedControl.IsWindow())  
                   m_hframeinfo.axNestedControl.DestroyWindow();
                   m_hframeinfo.axNestedControl.Create(m_hWnd, rc, 0, WS_CHILD | WS_VISIBLE);
               m_hframeinfo.axNestedControl.CreateControlEx(bstrbrowser, NULL, NULL,
                   reinterpret_cast  <IUnknown **>(&m_hframeinfo.m_spBrowser));
           m_hframeinfo.axNestedControl.QueryControl(__uuidof(IHFrame),
                   (void   **)  &m_hframeinfo.m_spBrowser);     }
}
按照上面的方法创建是可以显示多个控件了,但是当我点击任何一个控件都只响应连接点事件,耍外面的Activex的  OnMouseMove,OnLButtonDown, OnRButtonDown, OnMouseHover, OnLButtonDbclk, 都没有响应就退出了,请问怎么样创建这些里面的控件外面的控件才能响应上面的消息呢?
谢谢!

解决方案 »

  1.   

    To find out when the user clicks the button, add a handler for the WM_LBUTTONDOWN message.To add a handler for the WM_LBUTTONDOWN message
    In Class View, right-click the CPolyCtl class and click Properties on the shortcut menu.In the Properties window, click the Messages icon and then click WM_LBUTTONDOWN from the list on the left.From the drop-down list that appears, click <Add> OnLButtonDown. The OnLButtonDown handler declaration will be added to PolyCtl.h, and the handler implementation will be added to PolyCtl.cpp.Next, modify the handler.To modify the OnLButtonDown method
    Change the code which comprises the OnLButtonDown method in PolyCtl.cpp (deleting any code placed by the wizard) so that it looks like this: LRESULT CPolyCtl::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
       HRGN hRgn;
       WORD xPos = LOWORD(lParam);  // horizontal position of cursor
       WORD yPos = HIWORD(lParam);  // vertical position of cursor   CalcPoints(m_rcPos);   // Create a region from our list of points
       hRgn = CreatePolygonRgn(&m_arrPoint[0], m_nSides, WINDING);   // If the clicked point is in our polygon then fire the ClickIn
       //  event otherwise we fire the ClickOut event
       if (PtInRegion(hRgn, xPos, yPos))
          Fire_ClickIn(xPos, yPos);
       else
          Fire_ClickOut(xPos, yPos);   // Delete the region that we created
       DeleteObject(hRgn);
       return 0;
    }
     This code makes use of the points calculated in the OnDraw function to create a region that detects the user's mouse clicks with the call to PtInRegion.The uMsg parameter is the ID of the Windows message being handled. This allows you to have one function that handles a range of messages. The wParam and the lParam parameters are the standard values for the message being handled. The parameter bHandled allows you to specify whether the function handled the message or not. By default, the value is set to TRUE to indicate that the function handled the message, but you can set it to FALSE. This will cause ATL to continue looking for another message handler function to send the message to.
      

  2.   

    我是在ATL里,怎么添加class view类啊?
      

  3.   

    是一组控件,还是一个项目中有多个activex控件
      

  4.   

    是一个控件里面多次动态创建一个已经写好的Activex控件
      

  5.   

    看样子,CSDN上几乎没有高手了。