利用 keybd_event函数可实现,如下面的代码用以实现在一个公共菜单中模拟Ctrl_F按钮以调用DBGridEH的查找对话框功能:
这是在一个ActionList中的某一Action的OnExecute事件代码。

procedure TDM.act_LocateExecute(Sender: TObject); 
var
  myPopupMenu:TPopupMenu; 
  MyDBGridEH:TDBGridEh; 
begin
  //ShowMessage(TMenuItem(TAction(Sender).ActionComponent).GetParentComponent.Name); 
  if (TAction(Sender).ActionComponent).GetParentComponent is TPopupMenu then
    myPopupMenu := (TAction(Sender).ActionComponent).GetParentComponent as TPopupMenu 
  else
    Exit; 
 
  //ShowMessage(MyPopupMenu.PopupComponent.Name); 
  if (MyPopupMenu.PopupComponent is TDBGridEh) then
  begin
    MyDBGridEH := TDBGridEh(MyPopupMenu.PopupComponent); 
    MyDBGridEH.SetFocus; 
    keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), 0, 0);       //按下Ctrl键 
    keybd_event(ord('F'), MapVirtualKey(ord('F'), 0), 0, 0);                    //按下F键 
    keybd_event(ord('F'), MapVirtualKey(ord('F'), 0), KEYEVENTF_KEYUP, 0);    //放开F键 
    keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), KEYEVENTF_KEYUP, 0); //放开Ctrl键 
  end; 
end;

最新文章

  1. [转]asp.net c# 网上搜集面试题目(附答案)
  2. JavaScript的DOM操作-重点部分-第一部分
  3. MySQL之aborted connections和aborted clients
  4. Android:requestWindowFeature应用程序窗体显示状态操作
  5. 武汉科技大学ACM :1002: 零起点学算法38——求阶乘和
  6. s14 第5天 时间模块 随机模块 String模块 shutil模块(文件操作) 文件压缩(zipfile和tarfile)shelve模块 XML模块 ConfigParser配置文件操作模块 hashlib散列模块 Subprocess模块(调用shell) logging模块 正则表达式模块 r字符串和转译
  7. handler消息机制
  8. 勤拂拭软件 java web 开发教程(1) - 开发环境搭建
  9. Linux 使用 top 命令查看系统的运行情况
  10. Java核心技术卷一基础知识-第10章-部署应用程序和applet-读书笔记
  11. Linux如何统计进程的CPU利用率[转]
  12. 解决MAMP启动mysql服务 但是Navicat连接不上
  13. hibernate的native sql查询
  14. JDK1.7+eclipse 4.4(luna)+pydev4.4.5构建django开发环境
  15. SpringBoot + Spring MVC国际化使用示例
  16. SQL转换全角和半角函数
  17. 文件流的处理 C C++
  18. Web标准及网站的可用性、可访问性
  19. picks loves segment tree I
  20. start-stop-daemon

热门文章

  1. stm32 boot0 boot1的启动方式
  2. Grunt-jsdoc生成JS API文档
  3. javascript瀑布流效果
  4. Arduino入门笔记(4):用蜂鸣器演奏音乐并配有LED闪烁
  5. Arduino入门笔记(3):单LED闪烁
  6. 20155223 Exp8 WEB基础实践
  7. 洛咕3312 [SDOI2014]数表
  8. VS Code使用Git管理代码
  9. Egret(白鹭引擎)——“TypeError: Cannot read property 'asCom' of null”
  10. CSS快速入门-前端布局2(唯品会1)