如何能呼叫同一視窗的ie,不要另開視窗 |
答題得分者是:shinjie
|
shinhrn
中階會員 發表:54 回覆:165 積分:83 註冊:2002-06-05 發送簡訊給我 |
|
shinjie
資深會員 發表:12 回覆:275 積分:287 註冊:2003-03-19 發送簡訊給我 |
請參考
http://delphi.ktop.com.tw/topic.php?topic_Id=38858
範例如下:
var Form1: TForm1; hnd:HWND; procedure TForm1.Button1Click(Sender: TObject); var ExitCode: cardinal; ExecInfo: TShellExecuteInfo; begin ZeroMemory(@ExecInfo,SizeOf(ExecInfo)); with ExecInfo do begin cbSize := SizeOf(ExecInfo); fMask := SEE_MASK_NOCLOSEPROCESS; lpVerb := 'open'; lpFile := 'C:\Program Files\Internet Explorer\IEXPLORE.EXE'; lpParameters := 'http://tw.yahoo.com/'; Wnd := self.Handle; nShow := SW_SHOWNORMAL; end; ShellExecuteEx(@ExecInfo); hnd:=ExecInfo.Wnd; //取得HWND GetExitCodeProcess(ExecInfo.hProcess,ExitCode); while ExitCode=STILL_ACTIVE do begin GetExitCodeProcess(ExecInfo.hProcess,ExitCode); sleep(10); Application.ProcessMessages; end; end; procedure TForm1.Button2Click(Sender: TObject); begin ShellExecute(hnd, PChar('open'), PChar('http://www.google.com.tw/'), nil, nil, SW_NORMAL); //指定視窗的handle end;========================================= 程式有問題並不可怕,最怕是不知問題出在那 不知問題在那不可怕,更怕是不知如何問問題 寫程式要從最簡單的開始
------
我將在茫茫人海中尋訪我唯一之靈魂伴侶。 得之;我幸。不得;我命。 |
shinhrn
中階會員 發表:54 回覆:165 積分:83 註冊:2002-06-05 發送簡訊給我 |
|
shinjie
資深會員 發表:12 回覆:275 積分:287 註冊:2003-03-19 發送簡訊給我 |
>而不知是不是我機器的問題,Button1Click後 關掉ie,再按Button2Click 或CLOSE 時均要等待許久??? 我的電腦並不會。 不指定瀏覽器的話,就要查視窗的標題名稱了,可以參考
http://delphi.ktop.com.tw/topic.php?topic_id=18901
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST); while hCurrentWindow <> 0 do begin if (GetWindowText(hCurrentWindow, @szText, 255) > 0) and IsWindowVisible(hCurrentWindow) then begin if (Pos('標題名稱',sText)>0) then begin hnd := hCurrentWindow; end; end; hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT); end; ShellExecute(hnd, PChar('open'), PChar('http://www.google.com.tw/'), nil, nil, SW_NORMAL); //指定視窗的handle========================================= 程式有問題並不可怕,最怕是不知問題出在那 不知問題在那不可怕,更怕是不知如何問問題 寫程式要從最簡單的開始
------
我將在茫茫人海中尋訪我唯一之靈魂伴侶。 得之;我幸。不得;我命。 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |