响应事件操作? 如果说程序A是非当前状态(当前的焦点在程序B上)。现在我按Ctrl键,让程序A响应,并执行相关的操作。 现在请问以上应该怎样实现?代码应该怎样写? 谢谢! 急。~! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 首先用键盘钩子,钩住键盘,当按下了Ctrl时执行Application.BringToFront;就行了。 从B发送自定义消息到AA收到什么消息就做什么事 也可在A,B程序间建立通讯连接,当B程序Ctrl按下后,B程序发送相关字符给A程序,A收到后再执行相应的动作. 程序B:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons;type TForm1 = class(TForm) procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormShortCut(var Msg: TWMKey; var Handled: Boolean);begin if Msg.CharCode = VK_CONTROL then SendMessage(FindWindow(nil,'Form2'), WM_APP+1, 0,0);end;end.程序A:unit Unit2;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) private { Private declarations } public procedure WndProc(var Msg: TMessage); override; { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.WndProc(var Msg: TMessage);begin with Msg do begin if Msg = WM_APP + 1 then Form1.Caption := 'gggggg'; end; inherited;end;end. 当在程序B上按CTRL键时程序A的标题变为:ggggg 在这里我想告诉大家的是:B程序是Windows里面的任何一个程序,是未知的,它并不是我编的。 pcomm.dll接收数据有问题 各位大下,推荐一下比较好的日期控件吧 求Web Services一份!! 用Delphi创建一个dbf表格,为什么字段里中文显示是乱码? QS Parliament 求NMUDP传输文件的例子 求Delphi5的序列号,安上就给分 论坛文章的滚动 在多层结构系统中,应用服务器才用NT服务性的好呢还是才用一般的好呢? combobox选择完后触发什么事件呀? 100分:主-从报表如何做? 请问定做一套工资管理系统(单机)要多少钱?
Application.BringToFront;
就行了。
A收到什么消息就做什么事
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;type
TForm1 = class(TForm)
procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
if Msg.CharCode = VK_CONTROL then
SendMessage(FindWindow(nil,'Form2'), WM_APP+1, 0,0);
end;
end.程序A:
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
private
{ Private declarations }
public
procedure WndProc(var Msg: TMessage); override;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.WndProc(var Msg: TMessage);
begin
with Msg do
begin
if Msg = WM_APP + 1 then
Form1.Caption := 'gggggg';
end;
inherited;
end;end.