如题,谢谢!
解决方案 »
- 如何分别提取字符串中的所有数字、汉字首字母、字符? ?
- delphi能给access数据库创建新表吗?
- 有一动态SQl的问题,请教大家!
- delphi中 ACTION 方法,怎么用,什么时用适合。有经验的指点一下,谢了。
- 请高手指教:怎样将一个SQL Server的数据库作在安装程序中?
- 关于调用EXCEL
- D6 + ADO + ORACLE9i 不能增加新纪录
- type里面的 Button1: TButton;代表什么意思?他和TForm4 = class(TForm)是一个意思吗?
- 支持断点续传----新手不可不看-高手更要看
- 插件啊!!!为何极少人懂??
- 如何在视频窗口绘制截图框
- 画画的问题,如下,画出来总是有点问题。。。 停下来想了半天,输了半天数字也好象还是显示的有问题
var
Hand: integer;
begin
Hand:=FindWindow('notepad',nil);
if Hand=0 then
begin
ShellExecute(self.Panel1.Handle ,'','c:\windows\notepad.exe',nil,nil,sw_show);
Sleep(100);
Hand:=FindWindow('notepad',nil);
end;
Windows.SetParent(Hand, self.Panel1.Handle);
调用notepad时,可以在panel上显示,但是换成其他的外部程序就不行,这是怎么回事啊?
这句查找窗体的句柄是针对记事本这个程序的。notepad是记事本的类名,后一个参数是窗体的标题。你可以用SPY++这个工具来查看其它外部程序的类名和标题。
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Button10: TButton;
Panel1: TPanel;
procedure Button10Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
h:HWND;
implementation
uses clipbrd;
{$R *.DFM}//把计算器作为自己程序的子窗口
procedure TForm1.Button10Click(Sender: TObject);
begin
WinExec('calc.exe',SW_SHOW);
h := FindWindow('SciCalc',nil);
Windows.SetParent(h,Panel1.Handle);
//SetWindowLong (h, GWL_STYLE, GetWindowLong (h, GWL_STYLE) AND NOT WS_CAPTION);
SetWindowPos(h,HWND_BOTTOM,-2,-22,600,200,0); //设定位置
//EnableWindow(h,false);
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
PostMessage(h, WM_CLOSE, 0, 0);
end;end.