如何给一个窗口发送Ctrol+O(字母欧)的消息。
谢谢。

解决方案 »

  1.   

    可以自定义消息,Ctrl+O 作为参数,或者在窗口用钩子
      

  2.   

    你要用系统热键:
    RegisterHotKey
      

  3.   

    给你一段关于热键的代码看看吧:
    #include "stdafx.h"•••//////////////////
    // Standard dialog has edit control and static icon
    //
    class CMyDialog : public CDialog {
    public:
       CMyDialog(CWnd* pParent = NULL);     // standard constructor   •••protected:
       UINT m_nIDHotKey;                    // hot key identifier   virtual BOOL OnInitDialog();
       afx_msg LRESULT OnHotKey(WPARAM wp, LPARAM lp);
       afx_msg void OnHideDialog();
       afx_msg void OnDestroy();
       DECLARE_MESSAGE_MAP()
    };//////////////////
    // Generic app object
    //
    class CMyApp : public CWinApp {
    public:
       CMyApp();
       virtual BOOL InitInstance();
       DECLARE_MESSAGE_MAP()
    } theApp;BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
    END_MESSAGE_MAP()CMyApp::CMyApp()
    {
    }BOOL CMyApp::InitInstance()
    {
       CMyDialog dlg;
       m_pMainWnd = &dlg;
       dlg.DoModal();
       return FALSE;
    }////////////////////////////////////////////////////////////////
    // Dialog classCMyDialog::CMyDialog(CWnd* pParent /*=NULL*/)
       : CDialog(IDD_MYDIALOG, pParent)
    {
       m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    }BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
       ON_COMMAND(IDC_HIDE_DIALOG, OnHideDialog)
       ON_MESSAGE(WM_HOTKEY, OnHotKey)
       ON_WM_DESTROY()
    END_MESSAGE_MAP()//////////////////
    // Dialog just created: initialize it
    //
    BOOL CMyDialog::OnInitDialog()
    {   •••   // Register "Windows-A" as my hot key (Windows key + A)
       m_nIDHotKey = GlobalAddAtom("FileType2App");
       TRACE("m_nIDHotKey = %d\n", m_nIDHotKey);
       RegisterHotKey(m_hWnd, m_nIDHotKey, MOD_WIN, 'A');   return FALSE;  // return TRUE  unless you set the focus to a control
    }//////////////////
    // Dialog destroyed: unregister hot key
    //
    void CMyDialog::OnDestroy()
    {
       UnregisterHotKey(m_hWnd, m_nIDHotKey);
    }//////////////////
    // User pressed hot key: show myself if not already.
    //
    LRESULT CMyDialog::OnHotKey(WPARAM wp, LPARAM lp)
    {
       TRACE(_T("CMyDialog::OnHotKey\n"));
       if (wp==m_nIDHotKey && !IsWindowVisible()) {
          ShowWindow(SW_SHOWNORMAL);
       }
       return 0;
    }//////////////////
    // User pressed Hide button: hide myself
    //
    void CMyDialog::OnHideDialog()
    {
       ShowWindow(SW_HIDE);
    }
      

  4.   

    BOOL RegisterHotKey(
      HWND hWnd,         // 接收此消息的窗口句柄
      int id,            // hot key 的ID
      UINT fsModifiers,  // 你要设这个MOD_CONTROL
      UINT vk            // 你要设VK_O
    );
      

  5.   

    定义accelerator key,把它和一个WM_COMMAND消息结合起来