一个简单的问题。 如何给一个窗口发送Ctrol+O(字母欧)的消息。谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以自定义消息,Ctrl+O 作为参数,或者在窗口用钩子 你要用系统热键:RegisterHotKey 给你一段关于热键的代码看看吧:#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);} BOOL RegisterHotKey( HWND hWnd, // 接收此消息的窗口句柄 int id, // hot key 的ID UINT fsModifiers, // 你要设这个MOD_CONTROL UINT vk // 你要设VK_O); 定义accelerator key,把它和一个WM_COMMAND消息结合起来 界面 如何对EditBox控件初始化时即显示光标并且让光标显示在字符的后面,高手帮忙呀 求书!MXX,SEE,SEE2的书 活见鬼问题,不相干的东西相干了-_-! 簡單的,純C++的問題 请问怎么写华为C&C08机的读小磁带的程序? 一个简单问题 在OnMouseMove()中怎样检测到按下Mouse按下左键? 键盘消息(投票有分) odbc开发数据库问题 ftp客户端下载边写边读的问题,我的这个办法,为什么不行呢? ★★★★★★〔专题开发版〕欢迎你!★★★★★★
RegisterHotKey
#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);
}
HWND hWnd, // 接收此消息的窗口句柄
int id, // hot key 的ID
UINT fsModifiers, // 你要设这个MOD_CONTROL
UINT vk // 你要设VK_O
);