跪求!~请问如何将其它程序嵌入自己程序的窗体中~如能实现最加500!例如程序启动后,在个GroupBox控件中显示一个外部程序,最好能改变外部程序的尺寸(如去掉标题栏),当移动自己程序的窗体时,外部程序跟着移动好像听说可以用findwindow找到窗口handle后,windows.setparent为自己的窗口,movewindows到自己的窗口不懂!!!!!跪求大家赐教啊,也可把简单实例源码发给我: [email protected] 或 [email protected]~如能实现追加500!
~如能实现追加500!
~如能实现追加500!
解决方案 »
- 请教UrlDownloadToFile支持进度条
- ^^^^^^^^^转行,散分庆祝!^^^^^^^^^
- 编译提示ADODB版本不对
- 有没有QUICKREPORT的高手帮忙解决一下动态报表的问题啊?
- ToolBar的按钮能不能竖直排列?
- 心情好,放分200^o^
- 如何向DLL传递参数?
- 我在form中动态生成了一个listbox控件,如何让它显示出来?
- 求助:我希望 图片从 image1 的左下角,移动到 左上角,这样的程序要怎么写?谢谢!
- 如何让自己编写的程序运行时进程名不出现在Ctrl+Alt+del的对话框中?
- "inno setup+快捷方式+起始位置"问题?
- 使用GMFBridge可以平滑的连接播放2个视频文件,但怎么连接2个内存中的视频文件呢?
(外部程序不必加入资源文件)跪求大家赐教啊,也可把简单实例源码发给我: [email protected] 或 [email protected]~如能实现追加500!
~如能实现追加500!
var
h: HWND;
begin
h := WIndows.FindWindow(nil, '计算器');
Windows.SetParent(h, Self.Panel1.Handle);
Windows.MoveWindow(h, 0, 0, 200, 200, true);
end;这样即可,你开个计算器,再执行~~~
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
PProcessWindow = ^TProcessWindow;
TProcessWindow = record
TargetProcessID: Cardinal;
FoundWindow: hWnd;
end;
TForm1 = class(TForm)
Button1: TButton;
OpenD: TOpenDialog;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
hWin: HWND = 0;
implementation{$R *.dfm}function EnumWindowsProc(Wnd: hWnd; ProcWndInfo: PProcessWindow): BOOL; stdcall;
var
WndProcessID: Cardinal;
begin
GetWindowThreadProcessId(Wnd, @WndProcessID);
if WndProcessID = ProcWndInfo^.TargetProcessID then begin
ProcWndInfo^.FoundWindow := Wnd;
Result := False; // This tells EnumWindows to stop enumerating since we've already found a window.
end else Result := True; // Keep searching
end;function GetProcessWindow(TargetProcessID: Cardinal): hWnd;
var
ProcWndInfo: TProcessWindow;
begin
ProcWndInfo.TargetProcessID := TargetProcessID;
ProcWndInfo.FoundWindow := 0;
EnumWindows(@EnumWindowsProc, Integer(@ProcWndInfo));
Result := ProcWndInfo.FoundWindow;
end;function RunAppInPanel(const AppName: string; PanelHandle: HWND): boolean;
var
si: STARTUPINFO;
pi: TProcessInformation;
begin
FillChar(si, SizeOf(si), 0);
si.cb := SizeOf(si);
si.wShowWindow := SW_SHOW;
result := CreateProcess(nil, PChar(AppName), nil,
nil, true, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, si, pi); if not result then exit; WaitForInputIdle(pi.hProcess, 10000); // let process start! hWin := GetProcessWindow(pi.dwProcessID);
if hWin > 0 then begin
Windows.SetParent(hWin, PanelHandle);
SetWindowPos(hWin, 0, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOZORDER);
result := true;
end; // we don't need the handles so we close them
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
end;
procedure Delay(msecs:integer);var
FirstTickCount:longint;beginFirstTickCount:=GetTickCount;
repeat
Application.ProcessMessages;
until ((GetTickCount-FirstTickCount) >= Longint(msecs));end;
procedure TForm1.Button1Click(Sender: TObject);
begin
delay(4000);
if OpenD.Execute then begin
if hWin > 0 then PostMessage(hWin, WM_CLOSE, 0, 0); // close any app currently opened
if not RunAppInPanel(OpenD.FileName, Panel1.Handle) then ShowMessage('App not found');
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if hWin > 0 then
PostMessage(hWin, WM_CLOSE, 0, 0);
end;end.
两位的代码都能实现!初步满足我的想法!to : mikespook(懒猫开始新生活)
简洁的三行便实现了外部程序的嵌入,强(我菜:-))!
有点不足就是不能动态获取外部程序的类名:
即WIndows.FindWindow(nil, '计算器')中的'nil'.
最加得分~200to : guolvguolv(guolvguolv)
感谢你发来的代码包!
由于程序能在运行后,嵌入随便选择的外部程序,证明实现了以上说所的功能.
最加得分~300我重新发贴,请两位尽快来拿分,以免被删!(刷新一下或查找我的贴)拿分处:
mikespook(懒猫开始新生活):
http://community.csdn.net/Expert/TopicView.asp?id=3469964
http://community.csdn.net/Expert/TopicView.asp?id=3469969
guolvguolv(guolvguolv):
http://community.csdn.net/Expert/TopicView.asp?id=3469974
http://community.csdn.net/Expert/TopicView.asp?id=3469978
http://community.csdn.net/Expert/TopicView.asp?id=3469982不好意思,本来想每人加500的,100一个贴的话我绝对被封IP了.以后再提问的时候请两位再来捧个场,绝对高分奉上!