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);
}

解决方案 »

  1.   

    在cmZoomIn模式下就不能正常响应//是不是这中mode下,把鼠标消息给拦截了,或是部分拦截了。
    还有down中的代码是不是特别多,执行时间太长的话,up消息可能没了。
      

  2.   

    我好像也遇到过这种问题
    我是用SetWindowLong替换调控件的窗口过程解决的
    我的理解是有些消息控件自己处理了,但没发给发出去
      

  3.   

    替换了处理过程的话,还有一些功能实现就很麻烦!!!有没有什么好的解决办法啊,还有DOWN 里面的代码不长!
      

  4.   

    我用了SubClassWindow我查了下MSDN
     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处理才对啊??不知道我理解的是否有偏差!!!!!!
      

  5.   

    我用了SubClassWindow我查了下MSDN 
    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处理才对啊??不知道我理解的是否有偏差!!!!!! 
      

  6.   

    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);自己子类化自己么?是不是应该改成SubclassWindow(hwnd);
      

  7.   

    试试在WM_LBUTTONDOWN消息中调用SetCapture,在WM_LBUTTONUP中ReleaseCapture。
      

  8.   

    估计是你代码某个地方有问题, 不明白为什么要用SubclassWindow自已,
      

  9.   

    在cmZoomIn模式下就不能正常响应??
    是不响应,还是偶尔会响应?
      

  10.   

    判断如果被capture, 就在DrawItem中自绘吧, 最好先设置button的style
    BS_OWNERDRAW