给小弟个好的方法。。最好给出代码。vc平台的。。谢谢

解决方案 »

  1.   

    在父窗口的PreTranslateMessage里面做区域判断
      

  2.   

    我以前写的CShockwaveFlash m_flash;
    ...
    BOOL CFlashpanelDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if((WM_RBUTTONDOWN == pMsg->message) || (WM_RBUTTONDBLCLK == pMsg->message))
    {
    //防止右键产生广告信息
    DWORD dwPos = GetMessagePos();
    CPoint point(LOWORD(dwPos),HIWORD(dwPos));

    CRect rect;
    m_flash.GetWindowRect(&rect);

    int m = point.x;
    int n = point.y;

    int x = rect.left;
    int y = rect.right;

    int a = rect.top;
    int b = rect.bottom;

    if(x<=m && y>=m && a<=n && b>=n)
    {
    return TRUE;
    }
    } return CDialog::PreTranslateMessage(pMsg);
    }
      

  3.   

    重载PreTranslateMessage
    在此函数中添加if((pMsg->message == WM_RBUTTONDOWN) || (pMsg->message == WM_RBUTTONDBLCLK))
    {
    return TRUE;
    }
      

  4.   

    谢谢各位的帮助。不过我的事在win32平台中使用atl作容器来显示flash的。在这种情况下。又怎么做呢????
    我的代码如下:
    #import   "C:\WINDOWS\system32\macromed\flash\flash.ocx"     
    #include   <atlbase.h>   
        CComModule   _Module;   
    #include   <atlwin.h>   
    #pragma   comment(lib,"atl") 
    int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
    {
      UNREFERENCED_PARAMETER(hPrevInstance);
      UNREFERENCED_PARAMETER(nCmdShow);
      MSG messages;
      hIns=hInstance;
      HANDLE hMutex = NULL;
      hMutex = CreateMutex(NULL, false, TEXT("emergeDesktop"));
      if (GetLastError() == ERROR_ALREADY_EXISTS)
        {
          CloseHandle(hMutex);
          return 0;
        } /*初始化桌面窗口*/
    POINT p;
       p.x = GetSystemMetrics(SM_CXSCREEN);
       p.y = GetSystemMetrics(SM_CYSCREEN);
       ScreenRect.bottom=p.y;
       ScreenRect.right=p.x;
       ScreenRect.left=0;
       ScreenRect.top=0;
       ScrWorkSpace.bottom= p.y ;
       ScrWorkSpace.top=0;
       ScrWorkSpace.left=0;
       ScrWorkSpace.right= p.x;
       desktopCom.CreateDesktop(hInstance,DesktopProc,p,&ScrWorkSpace,true,true);//创建一个窗口
      while (GetMessage (&messages, NULL, 0, 0))
        {
          TranslateMessage(&messages);
          DispatchMessage(&messages);
        }
      if (hMutex)
        CloseHandle(hMutex);
      return (int)messages.wParam;
    }/*---------------------------------------------------------
    *桌面的消息处理函数
    *----------------------------------------------------------*/
    LRESULT CALLBACK DesktopProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
    {
    PAINTSTRUCT psPaint;
    HDC hDC;
    POINT pPoint;
    WINDOWPOS *wpPos;
    _bstr_t bstr;
    switch (uMsg)
    {
    case WM_CREATE:
    m_container.Create(   hWnd,  ScrWorkSpace,   LPCTSTR("ShockwaveFlash.ShockwaveFlash.1"),   WS_CHILD|WS_VISIBLE);
    m_container.QueryControl(   __uuidof(IShockwaveFlash),   reinterpret_cast<void**>(&shwaveflash)   );
    bstr=_bstr_t("D:\\123.swf"); 
    if(shwaveflash==NULL)
    {
    PostQuitMessage(0);
    }
        shwaveflash->put_Movie(bstr);    
    shwaveflash->put_AlignMode(5);
    shwaveflash->put_ScaleMode(3);
    shwaveflash->put_Menu(false);
    shwaveflash->Play();
    /*设置桌面背景*/
    SetDesktopBack();
    break;
      

  5.   

    [code]
    class CFlashControlWnd:public CWindowImpl<CFlashControlWnd>
    {
    BEGIN_MSG_MAP(CFlashWnd)
    if (uMsg==WM_RBUTTONDOWN)
    {
    return 1;
    }
    else if (uMsg==WM_KEYDOWN || uMsg==WM_SYSKEYDOWN || uMsg==WM_KEYUP || uMsg==WM_SYSKEYUP)
    {
    HRESULT hr = pObj->TranslateAccelerator((LPMSG)m_pCurrentMsg);
    if (hr==S_OK)
    {
    return 1;
    }
    }
    else if (uMsg == WM_CHAR)
    {
    return GetAsyncKeyState(VK_CONTROL)||GetAsyncKeyState(VK_LCONTROL) || GetAsyncKeyState(VK_RCONTROL);
    }
    END_MSG_MAP()
    public:
    CComPtr<IOleInPlaceActiveObject> pObj;
    };
    class CFlashWnd : 
    public CWindowImpl<CFlashWnd,CAxWindow>,
    public IDispEventImpl<1,CFlashWnd,&__uuidof(_IShockwaveFlashEvents),&__uuidof(ShockwaveFlash)>
    {
         CFlashControlWnd m_ControlWnd;
    }
    LRESULT CFlashWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam)
    {

    LRESULT ret=DefWindowProc();
    HRESULT hr = CreateControlEx(L"{D27CDB6E-AE6D-11CF-96B8-444553540000}",0,0,0,__uuidof(_IShockwaveFlashEvents),
    (IUnknown*)static_cast<IDispEventImpl<1,CFlashWnd,&__uuidof(_IShockwaveFlashEvents),&__uuidof(ShockwaveFlash)>*>(this)
    );

    if (FAILED(hr))
    {
    MessageBox("Flash插件未安装");
    return -1;
    }
    hr = QueryControl(__uuidof(IShockwaveFlash),(void**)&m_pFlash);
    if (FAILED(hr))
    {
    MessageBox("Flash插件未安装");
    return -1;
    }
    CComPtr<IOleWindow> pWindow;
    QueryControl(&pWindow);
    if (pWindow)
    {
    HWND hWnd;
    if (SUCCEEDED(pWindow->GetWindow(&hWnd)))
    {
    m_ControlWnd.SubclassWindow(hWnd);
    QueryControl(&m_ControlWnd.pObj);
    }
    }
    return 0;
    }
    [/code]
      

  6.   


    class CFlashControlWnd:public CWindowImpl<CFlashControlWnd>
    {
    BEGIN_MSG_MAP(CFlashWnd)
    if (uMsg==WM_RBUTTONDOWN)
    {
    return 1;
    }
    else if (uMsg==WM_KEYDOWN || uMsg==WM_SYSKEYDOWN || uMsg==WM_KEYUP || uMsg==WM_SYSKEYUP)
    {
    HRESULT hr = pObj->TranslateAccelerator((LPMSG)m_pCurrentMsg);
    if (hr==S_OK)
    {
    return 1;
    }
    }
    else if (uMsg == WM_CHAR)
    {
    return GetAsyncKeyState(VK_CONTROL)||GetAsyncKeyState(VK_LCONTROL) || GetAsyncKeyState(VK_RCONTROL);
    }
    END_MSG_MAP()
    public:
    CComPtr<IOleInPlaceActiveObject> pObj;
    };
    class CFlashWnd : 
    public CWindowImpl<CFlashWnd,CAxWindow>,
    public IDispEventImpl<1,CFlashWnd,&__uuidof(_IShockwaveFlashEvents),&__uuidof(ShockwaveFlash)>
    {
    CFlashControlWnd m_ControlWnd;
    }
    LRESULT CFlashWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam)
    {

    LRESULT ret=DefWindowProc();
    HRESULT hr = CreateControlEx(L"{D27CDB6E-AE6D-11CF-96B8-444553540000}",0,0,0,__uuidof(_IShockwaveFlashEvents),
    (IUnknown*)static_cast<IDispEventImpl<1,CFlashWnd,&__uuidof(_IShockwaveFlashEvents),&__uuidof(ShockwaveFlash)>*>(this)
    );

    if (FAILED(hr))
    {
    MessageBox("Flash插件未安装");
    return -1;
    }
    hr = QueryControl(__uuidof(IShockwaveFlash),(void**)&m_pFlash);
    if (FAILED(hr))
    {
    MessageBox("Flash插件未安装");
    return -1;
    }
    CComPtr<IOleWindow> pWindow;
    QueryControl(&pWindow);
    if (pWindow)
    {
    HWND hWnd;
    if (SUCCEEDED(pWindow->GetWindow(&hWnd)))
    {
    m_ControlWnd.SubclassWindow(hWnd);
    QueryControl(&m_ControlWnd.pObj);
    }
    }

    return 0;
    }
      

  7.   

    为什么我的flash无法响应键盘消息,但能响应鼠标?