https://ciang.top/ https://ciang.top/
首页
  • 首页
  • python
  • 工具经验
  • 教程
  • c++
  • mysql
  • 登录
搜索历史 清空
写文章

登录

账号密码登录
扫码登录
扫码登录
请使用手机扫码登录
注册登录即表示同意用户协议和隐私政策
编程
java c/c++ mysql python excel html/css/js 工具经验
思路/心得
传奇私服-V8M2引擎学习笔记
教程
翻译
游戏
推荐 最新
Accelerators and WTL Dialogs
benojan 2024-3-9

Accelerators and WTL Dialogs

Author: Rory Buchanan Date: 2006 Introduction I searched and searched the CodeProject but never found an example on using accelerators and WTL dialogs. I have used accelerators in MFC dialogs extensively, but couldn't figure out how to add this functionality to WTL dialogs. Like a lot of things, it is very easy to do once you have figured it out. Well, here goes.... Using the code Declare a handle to the accelerator, and add the CMessageFilter if it has not been done already. #pragma once class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>, public CMessageFilter, public CIdleHandler { private: HACCEL m_haccelerator; //....... }; Then in your OnInitDialog, assign the m_haccelerator variable to the accelerator resource, which in this example is IDR_MAINFRAME. LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { // ....... //Bind keys... m_haccelerator = AtlLoadAccelerators(IDR_MAINFRAME); // register object for message filtering and idle updates CMessageLoop* pLoop = _Module.GetMessageLoop(); ATLASSERT(pLoop != NULL); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this); //............... return TRUE; } Then we need to overload the PreTranslateMessage function... BOOL CMainDlg::PreTranslateMessage(MSG* pMsg) { if(m_haccelerator != NULL) { if(::TranslateAccelerator(m_hWnd, m_haccelerator, pMsg)) return TRUE; } return CWindow::IsDialogMessage(pMsg); } Also, in you constructor, initialize the handle to the accelerator. CMainDlg::CMainDlg() { //.................. m_haccelerator = NULL; //.................. } If the dialog wasn't made to be modeless, it needs to be for the PreTranslateMessage to work. This is easily done by... int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { _Module.Init(NULL, hInstance); CMessageLoop myMessageLoop; _Module.AddMessageLoop(&myMessageLoop); CMainDlg dlgMain; dlgMain.Create(NULL); dlgMain.ShowWindow(nCmdShow); int retValue = myMessageLoop.Run(); _Module.RemoveMessageLoop(); _Module.Term(); return retValue; } And make sure you include atlmisc.h.

777 27 0
WTLAcceleratorsModeless

搜索

搜索历史 清空

最新评论

标签

  • 重写
  • 继承
  • 虚函数
  • springboot
  • java
  • drf
  • 私服
  • 脚本
  • Windows窗口程序
  • cmake
  • dll
  • Modeless
  • Accelerators
  • WTL
  • ListCtrl
  • MFC
  • regex
  • 正则表达式
  • 虚拟环境
  • venv
  • radio
  • html
  • vim
  • nodejs
  • Linux
  • 宝塔面板
  • bt
  • chatGPT
  • AI
  • turtle
  • python
  • 我的世界
  • api
  • bukkit
  • 字符串操作
  • docker
  • 本地架设
  • 游戏
  • 编程
  • CodeCombat
  • 教程
  • 插件开发
  • Minecraft
  • GBK
  • Unicode
  • UTF-8
  • 字符集
  • 转换
  • 编码
  • boost

链接

  • 標準吳語字典
  • 台州方言維基
  • 溫嶺吳語微辭典
关于 友链 rss
Powered by benojan

备案号: