我想要一个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, 都没有响应就退出了,请问怎么样创建这些里面的控件外面的控件才能响应上面的消息呢?
谢谢!
现在是这样实现的:
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, 都没有响应就退出了,请问怎么样创建这些里面的控件外面的控件才能响应上面的消息呢?
谢谢!
解决方案 »
- 一个vc++消息处理函数死循环的疑惑
- 请问,XMLHTTPRequest 在VC2008 SP1里面的头文件是什么啊
- 一个困扰我许久的多线程问题。
- WIN32服务问题
- FormView SDI如何实现控件的大小和位置随窗口的改变而改变?!
- 如何写一个COM
- 用CDATABASE的OPEN()函数来动态连接数据库,我是用SQL SERVER的,但是,现在要该用ACCESS的,那个连接字符串是怎么写的?小弟不知道格
- 如何替换win98的shell,改成启动后直接运行我的程序
- 关于build和rebuild的判决标准是什么啊?
- 问个很弱的问题
- VC6开发activex,如何将枚举暴露出来? enum box{pencil=1,pen=2}; 让外面能使用这个枚举
- 求工控程序源码
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.