線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:3203
推到 Plurk!
推到 Facebook!

如何能呼叫同一視窗的ie,不要另開視窗

答題得分者是:shinjie
shinhrn
中階會員


發表:54
回覆:165
積分:83
註冊:2002-06-05

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-11-16 14:26:26 IP:220.134.xxx.xxx 未訂閱
ShellExecute(0, PChar('open'), PChar(URLstr), nil, nil, SW_NORMAL) 用以上方式呼叫每次均會開一新視窗,是否可以設定不要開出新視窗??? 謝謝..
shinjie
資深會員


發表:12
回覆:275
積分:287
註冊:2003-03-19

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-11-16 15:00:01 IP:220.134.xxx.xxx 未訂閱
請參考 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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-11-17 09:44:56 IP:220.134.xxx.xxx 未訂閱
謝謝...如果不指定瀏覽器用ie可以嗎??(我的意思是不確定流覽器的程式是拿一支) 而不知是不是我機器的問題,Button1Click後 關掉ie,再按Button2Click 或CLOSE 時均要等待許久??? 發表人 - shinhrn 於 2005/11/17 10:42:19
shinjie
資深會員


發表:12
回覆:275
積分:287
註冊:2003-03-19

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-11-17 11:17:24 IP:203.73.xxx.xxx 未訂閱
>而不知是不是我機器的問題,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
========================================= 程式有問題並不可怕,最怕是不知問題出在那 不知問題在那不可怕,更怕是不知如何問問題 寫程式要從最簡單的開始
------
我將在茫茫人海中尋訪我唯一之靈魂伴侶。
得之;我幸。不得;我命。
系統時間:2024-05-15 1:18:00
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!