VC中我用了一个网上下载的开源的mapwindow ActiveX控件!
控件是动态创建的,为了相应消息,我将控件子类化了!
代码如下: if(!m_FreeMap.Create("SplWindow",WS_CHILD | WS_VISIBLE | WS_BORDER,r,this,IDC_MYSPLIT,NULL,FALSE,NULL))
{
MessageBox("Create Ctrol Failed");
return;
}
HWND hwnd;
hwnd=m_FreeMap.Detach();
m_FreeMap.SubclassWindow(hwnd);//ʹ¿Ø¼þ×ÓÀ໯
::SendMessage(pMainFrame->m_wndSplitter.GetPane(0,0)->m_hWnd,WM_ADDNODE,0,0);然后我通过classwizard添加了WM_LBUTTONDOWN WM_MOUSEMOVE WM_LBUTTONUP
左键点击的的时候相应WM_LBUTTONDOWN WM_MOUSEMOVE都很正常,只有WM_LBUTTONUP不正常!!!!
左键弹起的时候相应不了,只有双击了才能相应,是怎么回事啊??搞了很久没搞出来!
代码如下!
还有当我吧光标模式设置特定模式就可以,但是在有些模式下确不能正常响应,是用控件提供的函数来设置的!
pRight->m_FreeMap.SetCursorMode(cmZoomIn);//在cmZoomIn模式下就不能正常响应,再cmZoonOut就能!!!!!void CMapFree::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
MessageBox("UP");
int flag;
flag=((CMainFrame*)GetParentFrame())->m_flag;
if(m_PointOld!=point && flag==3)
{
strLayer *pLayer;
_variant_t vResult;
double dwXMin,dwYMin,dwXMax,dwYMax;
pLayer=g_pFirstLayer;
IExtentsPtr pExt;
PixelToProj((double)m_PointOld.x,(double)m_PointOld.y,&dwXMin,&dwYMin);
PixelToProj((double)point.x,(double)point.y,&dwXMax,&dwYMax);
//pExt=GetExtents();
pExt.CreateInstance(__uuidof(Extents));
pExt->SetBounds(dwXMin,dwYMin,0,dwXMax,dwYMax,0);
while(pLayer->next!=NULL)
pLayer=pLayer->next;
(*pLayer->pShpFile)->SelectShapes(pExt,1,INCLUSION,&vResult);
}
CWnd::OnLButtonUp(nFlags, point);
}
控件是动态创建的,为了相应消息,我将控件子类化了!
代码如下: if(!m_FreeMap.Create("SplWindow",WS_CHILD | WS_VISIBLE | WS_BORDER,r,this,IDC_MYSPLIT,NULL,FALSE,NULL))
{
MessageBox("Create Ctrol Failed");
return;
}
HWND hwnd;
hwnd=m_FreeMap.Detach();
m_FreeMap.SubclassWindow(hwnd);//ʹ¿Ø¼þ×ÓÀ໯
::SendMessage(pMainFrame->m_wndSplitter.GetPane(0,0)->m_hWnd,WM_ADDNODE,0,0);然后我通过classwizard添加了WM_LBUTTONDOWN WM_MOUSEMOVE WM_LBUTTONUP
左键点击的的时候相应WM_LBUTTONDOWN WM_MOUSEMOVE都很正常,只有WM_LBUTTONUP不正常!!!!
左键弹起的时候相应不了,只有双击了才能相应,是怎么回事啊??搞了很久没搞出来!
代码如下!
还有当我吧光标模式设置特定模式就可以,但是在有些模式下确不能正常响应,是用控件提供的函数来设置的!
pRight->m_FreeMap.SetCursorMode(cmZoomIn);//在cmZoomIn模式下就不能正常响应,再cmZoonOut就能!!!!!void CMapFree::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
MessageBox("UP");
int flag;
flag=((CMainFrame*)GetParentFrame())->m_flag;
if(m_PointOld!=point && flag==3)
{
strLayer *pLayer;
_variant_t vResult;
double dwXMin,dwYMin,dwXMax,dwYMax;
pLayer=g_pFirstLayer;
IExtentsPtr pExt;
PixelToProj((double)m_PointOld.x,(double)m_PointOld.y,&dwXMin,&dwYMin);
PixelToProj((double)point.x,(double)point.y,&dwXMax,&dwYMax);
//pExt=GetExtents();
pExt.CreateInstance(__uuidof(Extents));
pExt->SetBounds(dwXMin,dwYMin,0,dwXMax,dwYMax,0);
while(pLayer->next!=NULL)
pLayer=pLayer->next;
(*pLayer->pShpFile)->SelectShapes(pExt,1,INCLUSION,&vResult);
}
CWnd::OnLButtonUp(nFlags, point);
}
还有down中的代码是不是特别多,执行时间太长的话,up消息可能没了。
我是用SetWindowLong替换调控件的窗口过程解决的
我的理解是有些消息控件自己处理了,但没发给发出去
When a window is dynamically subclassed, windows messages will route through the CWnd message map and call message handlers in the CWnd class first. Messages that are passed to the base class will be passed to the default message handler in the window.
如果触发WM_BUTTONUP了,应该首先交给CWnd处理才对啊??不知道我理解的是否有偏差!!!!!!
When a window is dynamically subclassed, windows messages will route through the CWnd message map and call message handlers in the CWnd class first. Messages that are passed to the base class will be passed to the default message handler in the window.
如果触发WM_BUTTONUP了,应该首先交给CWnd处理才对啊??不知道我理解的是否有偏差!!!!!!
{
MessageBox("Create Ctrol Failed");
return;
}
HWND hwnd;
hwnd=m_FreeMap.Detach();
m_FreeMap.SubclassWindow(hwnd);自己子类化自己么?是不是应该改成SubclassWindow(hwnd);
是不响应,还是偶尔会响应?
BS_OWNERDRAW