有一個操作,就是不停地從goldwave里剪一小節音頻,然后保存為另一個音頻檔案。這個操作類似的重復很多,而且又在兩個軟體之間不停來回,因此就有了用Delphi解決這個問題的想法。在網上查了很久,總的結果有兩個。第一個是https://blog.csdn.net/xieyunc/article/details/17360983。
改成如下代碼后,
var
vh: HWND;
begin
ShellExecute(Self.Handle,'open',Pchar('C:\Windows\System32\notepad.exe'),'1',nil,SW_SHOWNORMAL);
vh := windows.FindWindow( nil, 'Form1');
ShowMessage(IntToStr(vh));
if vh<>0 then
begin
Windows.SetParent(pnlApp.Handle, Self.pnlApp.Handle);
Windows.MoveWindow(pnlApp.Handle, 0, 0,Self.pnlApp.Width,Self.pnlApp.Height,True);
end else
ShowMessage('xx程式未運行!');
程式倒是呼叫出來了,但沒有在panel里,而是在外部。請問是什么原因?
uj5u.com熱心網友回復:
第二種是:https://blog.csdn.net/xtfnpgy/article/details/39900331運行后直接出錯。

請大俠指點,不勝感激。
uj5u.com熱心網友回復:
第一種方法:vh := Winapi.Windows.FindWindow(nil, 'Form8'); 這里,不應該是你自己的表單名應該是需要被嵌入的程式的表單名。
如下圖片的Form8是被嵌入的另外的程式。

notepad.exe,記事本的標題,好像不是表單上顯示的,總是找不到。
uj5u.com熱心網友回復:
用計算器再做了測驗,發現可以改變計算器表單大小(與 Panel1 一樣大),但不能嵌入。ShellExecute(Self.Handle,'open',Pchar('C:\Windows\System32\calc.exe'),'',nil,SW_SHOWNORMAL);
sleep(1000);
vh := Winapi.Windows.FindWindow(nil, '計算器');
uj5u.com熱心網友回復:
var vh: HWND;
begin
ShellExecute(Self.Handle,'open',Pchar('C:\Windows\System32\notepad.exe'),'',nil,SW_SHOWNORMAL);
sleep(1000); // 延遲一下,等待記事三打開。
vh := Winapi.Windows.FindWindow(nil, '無標題 - 記事本');
if vh<>0 then
begin
Winapi.Windows.SetParent(vh, Self.Panel1.Handle);
Winapi.Windows.MoveWindow(vh, 0, 0,Self.Panel1.Width,Self.Panel1.Height,False);
end
else
ShowMessage('xx程式未運行!');
效果如下:

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/189545.html
標籤:VCL組件開發及應用
上一篇:類的“繼承”、“派生”
