全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:4462
推到 Plurk!
推到 Facebook!

如何能讓ShowMessage 不要跳出來...

答題得分者是:pceyes
yching
一般會員


發表:6
回覆:22
積分:10
註冊:2007-03-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-12-05 09:42:35 IP:220.130.xxx.xxx 訂閱
如何能讓ShowMessage 不要跳出來...
我的問題有些矛盾.... 不過我需要這麼做.... 或者有其它方式可以達到我的目的....

話說....
因為Delphi 未提供File Copy的Function...
所以前人就不知從哪弄來了個 FileCopy 的元件...
我們就直接Install 到Delphi裡應用...
不過當執行FileCopy失敗時.. 會跳出ShowMessage ....
然後我的系統就卡在那裡.... 一定要點掉Message....
系統才會繼續執行Timer... 醬... 給我很不方便.... 一"一
那系統我都是設Timer 讓他自己跑的...
還要三不五時去關心它... 就失去我設Timer 的意義了.... >"<

如果是回頭去修改FileCopy 的pas file...
但有時用FileCopy 是需要知道執行失敗的原因...
需要ShowMessage 看訊息... 所以也不能醬做內.... >"<
((( 惱...@@ )))
pceyes
尊榮會員


發表:70
回覆:657
積分:1140
註冊:2003-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-12-05 10:23:31 IP:122.118.xxx.xxx 訂閱

===================引 用 yching 文 章===================
如何能讓ShowMessage 不要跳出來...
我的問題有些矛盾.... 不過我需要這麼做.... 或者有其它方式可以達到我的目的....
對呀
話說....
因為Delphi 未提供File Copy的Function...
所以前人就不知從哪弄來了個 FileCopy 的元件...
不用那元件可不可以,自己寫一個,然後攔錯,寫出error log
我們就直接Install 到Delphi裡應用...
不過當執行FileCopy失敗時.. 會跳出ShowMessage ....
然後我的系統就卡在那裡.... 一定要點掉Message....
系統才會繼續執行Timer... 醬... 給我很不方便.... 一"一
那系統我都是設Timer 讓他自己跑的...
還要三不五時去關心它... 就失去我設Timer 的意義了.... >"<
對呀,你再寫一個代理人程式(機器人),看到showmessage時就按"Ok",這也是個辦法,懶人懶方法。
如果是回頭去修改FileCopy 的pas file...
對呀,反正多學也不錯,它是否有你用的價值,除了copyfile及欄錯,很好奇,它還有何作用呢?
但有時用FileCopy 是需要知道執行失敗的原因...
需要ShowMessage 看訊息... 所以也不能醬做內.... >"<
((( 惱...@@ )))
對呀,怪怪,不一定非用showmessage不可的,用listbox存錯誤訊息也可以呀,不顯示,直接寫logfile 到檔案也可以呀!
------
努力會更接近成功
yching
一般會員


發表:6
回覆:22
積分:10
註冊:2007-03-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-12-05 11:07:01 IP:220.130.xxx.xxx 訂閱
感謝您的指引... ^^

===================引 用 pceyes 文 章===================

略.....

那系統我都是設Timer 讓他自己跑的...
還要三不五時去關心它... 就失去我設Timer 的意義了.... >"<
對呀,你再寫一個代理人程式(機器人),看到showmessage時就按"Ok",這也是個辦法,懶人懶方法。
>> 請問大大哪裡找的到 代理人程式(機器人) 範例可以參考呢?我沒寫過... @///@

略.....
pceyes
尊榮會員


發表:70
回覆:657
積分:1140
註冊:2003-03-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-12-05 14:26:08 IP:122.118.xxx.xxx 訂閱
站上找來改的,幫你加上註解。
[code delphi]
....
type
PRec = ^TRec;
TRec = record
Wnd:THandle;
Cls:String; // Type
Txt:String; // Caption
end;
...
procedure TForm1.Timer1Timer(Sender: TObject);
var
Found:Boolean;

// for close WinMessageBox
function EnumFunc(wnd:HWND;lp:LPARAM):Boolean;stdcall;
var
p1,p2:Array[0..100]of Char;
pr :PRec;
begin
New(pr);
GetWindowText(wnd,p1,100); // 按鈕名稱
GetClassName (wnd,p2,100); // 按鈕Class Name
pr^.Wnd:=Wnd;
pr^.Txt:=StrPas(p1);
pr^.Cls:=StrPas(p2);
if (pos('Button',pr^.Cls)>0) and (pr^.Txt='是(Y)') then // pr^.Cls 可能是TButton
begin
SetForegroundWindow(wNd); // 抬起視窗
SendMessage(Wnd, BM_CLICK, 0, 0); // 按下按鈕
end;
EnumChildWindows(wnd,@EnumFunc,Integer(nil));
Result:=true;
end;
begin

// for close WinMessageBox
if (sWinMessageTitleStr <>'') and (sWinMessageButtonStr<>'') then begin
Found:=False;
while not Found do
begin
application.ProcessMessages;
pwnd:=findwindow(nil, pchar(sWinMessageTitleStr) ); // 找你視窗的抬頭
if pwnd<>0 then
begin
EnumFunc(pwnd,integer(nil));
sleep(3000);
break;
Found:=True;
end; // if
end; // while
end;

end;
[/code]
------
努力會更接近成功
編輯記錄
pceyes 重新編輯於 2008-12-05 15:06:08, 註解 無‧
yching
一般會員


發表:6
回覆:22
積分:10
註冊:2007-03-23

發送簡訊給我
#5 引用回覆 回覆 發表時間:2008-12-05 16:25:10 IP:220.130.xxx.xxx 訂閱

===================引 用 pceyes 文 章===================
站上找來改的,幫你加上註解。
[code delphi]

.....
if (sWinMessageTitleStr <>'') and (sWinMessageButtonStr<>'') then begin
....
end;
[/code]

這個有問題.... @@!?
[Error] Temp1.pas(592): Undeclared identifier: 'sWinMessageTitleStr'
[Error] Temp1.pas(592): Undeclared identifier: 'sWinMessageButtonStr'

歹勢...
我比較沒有慧根.... 看不出是少了什麼宣告.... @@a

P.D.
版主


發表:603
回覆:4038
積分:3874
註冊:2006-10-31

發送簡訊給我
#6 引用回覆 回覆 發表時間:2008-12-05 18:36:04 IP:61.67.xxx.xxx 未訂閱
見紅字
===================引 用 yching 文 章===================
如何能讓ShowMessage 不要跳出來...
我的問題有些矛盾.... 不過我需要這麼做.... 或者有其它方式可以達到我的目的....

話說....
因為Delphi 未提供File Copy的Function...
所以前人就不知從哪弄來了個 FileCopy 的元件...
Delphi怎麼會沒有提供, 就是 CopyFile(pChar(sourcfilename), pChar(Targetfilename), False)
若失敗則傳回 非0值(一般是-1)
不過無法知道失敗原因

yching
一般會員


發表:6
回覆:22
積分:10
註冊:2007-03-23

發送簡訊給我
#7 引用回覆 回覆 發表時間:2008-12-05 19:04:01 IP:220.130.xxx.xxx 訂閱

===================引 用 P.D. 文 章===================
見紅字
===================引 用 yching 文 章===================
如何能讓ShowMessage 不要跳出來...
我的問題有些矛盾.... 不過我需要這麼做.... 或者有其它方式可以達到我的目的....

話說....
因為Delphi 未提供File Copy的Function...
所以前人就不知從哪弄來了個 FileCopy 的元件...
Delphi怎麼會沒有提供, 就是 CopyFile(pChar(sourcfilename), pChar(Targetfilename), False)
若失敗則傳回 非0值(一般是-1)
不過無法知道失敗原因

大人.... 真的沒這個Function溜....
我用的是Delphi 7..... Help 裡也找不到!

pceyes
尊榮會員


發表:70
回覆:657
積分:1140
註冊:2003-03-13

發送簡訊給我
#8 引用回覆 回覆 發表時間:2008-12-05 19:32:54 IP:220.141.xxx.xxx 訂閱
sWinMessageTitleStr := 'Massagebox的抬頭'; // 它要抓取SHOWMESSAGE的FORM.CAPTION
sWinMessageButtonStr := '確定(Y)'; // 要按下的按鈕,比如 '確定' OR 'OK'

===================引 用 yching 文 章===================

===================引 用 pceyes 文 章===================
站上找來改的,幫你加上註解。
[code delphi]

.....

if (sWinMessageTitleStr <>'') and (sWinMessageButtonStr<>'') then begin
....
end;[/code]

這個有問題.... @@!?
[Error] Temp1.pas(592): Undeclared identifier: 'sWinMessageTitleStr'
[Error] Temp1.pas(592): Undeclared identifier: 'sWinMessageButtonStr'

歹勢...
我比較沒有慧根.... 看不出是少了什麼宣告.... @@a

------
努力會更接近成功
pceyes
尊榮會員


發表:70
回覆:657
積分:1140
註冊:2003-03-13

發送簡訊給我
#9 引用回覆 回覆 發表時間:2008-12-05 19:38:02 IP:220.141.xxx.xxx 訂閱
C:\Program Files\Common Files\Borland Shared\MSHelp
內容如下:
The CopyFile function copies an existing file to a new file.

BOOL CopyFile(

LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);


Parameters

lpExistingFileName

Points to a null-terminated string that specifies the name of an existing file.

lpNewFileName

Points to a null-terminated string that specifies the name of the new file.

bFailIfExists

Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Security attributes for the existing file are not copied to the new file.
File attributes (FILE_ATTRIBUTE_*) for the existing file are copied to the new file. For example, if an existing file has the FILE_ATTRIBUTE_READONLY file attribute, a copy created through a call to CopyFile will also have the FILE_ATTRIBUTE_READONLY file attribute. For further information on file attributes, see CreateFile.

See Also

CreateFile, MoveFile

===================引 用 yching 文 章===================

===================引 用 P.D. 文 章===================
見紅字
===================引 用 yching 文 章===================
如何能讓ShowMessage 不要跳出來...
我的問題有些矛盾.... 不過我需要這麼做.... 或者有其它方式可以達到我的目的....

話說....
因為Delphi 未提供File Copy的Function...
所以前人就不知從哪弄來了個 FileCopy 的元件...
Delphi怎麼會沒有提供, 就是 CopyFile(pChar(sourcfilename), pChar(Targetfilename), False)
若失敗則傳回 非0值(一般是-1)
不過無法知道失敗原因

大人.... 真的沒這個Function溜....
我用的是Delphi 7..... Help 裡也找不到!
------
努力會更接近成功
yching
一般會員


發表:6
回覆:22
積分:10
註冊:2007-03-23

發送簡訊給我
#10 引用回覆 回覆 發表時間:2008-12-08 12:03:42 IP:220.130.xxx.xxx 訂閱
還真的有欸.... 真怪... @@a
我的Delphi 7 按F1 真的找不到.... 不過在這個路徑下真的有....

我先拿來試看看....... ^^
感激您!!


===================引 用 pceyes 文 章===================
C:\Program Files\Common Files\Borland Shared\MSHelp
略....

系統時間:2024-03-29 13:59:22
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!