![delphi實現(xiàn)延時自動關(guān)閉對話框_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/4/c0f41e84-ca8f-4bba-baa9-63cd553f7634/c0f41e84-ca8f-4bba-baa9-63cd553f76341.gif)
![delphi實現(xiàn)延時自動關(guān)閉對話框_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/4/c0f41e84-ca8f-4bba-baa9-63cd553f7634/c0f41e84-ca8f-4bba-baa9-63cd553f76342.gif)
![delphi實現(xiàn)延時自動關(guān)閉對話框_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/4/c0f41e84-ca8f-4bba-baa9-63cd553f7634/c0f41e84-ca8f-4bba-baa9-63cd553f76343.gif)
![delphi實現(xiàn)延時自動關(guān)閉對話框_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/4/c0f41e84-ca8f-4bba-baa9-63cd553f7634/c0f41e84-ca8f-4bba-baa9-63cd553f76344.gif)
![delphi實現(xiàn)延時自動關(guān)閉對話框_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/4/c0f41e84-ca8f-4bba-baa9-63cd553f7634/c0f41e84-ca8f-4bba-baa9-63cd553f76345.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、delphi實現(xiàn)延時自動關(guān)閉對話框*一種自動關(guān)閉對話框的簡單方法使用方法:打開對話框前調(diào)用SetDlgAutoClose參數(shù)1:設(shè)定多長時間后關(guān)閉參數(shù)2:是否在對話框標(biāo)題欄進行倒計時提示取消自動關(guān)閉調(diào)用ResetDlgAutoCloseunit*TimerDlg;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,ExtCtrls;/如果指定的時間沒有操作對話框,則自動關(guān)閉procedureResetDlgAutoClose;procedureSetDlgAutoClose(nTime:
2、Integer;ADoHint:Boolean=False);implementation*如果對話框被打開,貝U在指定時間后關(guān)閉,并在標(biāo)題欄進行提示varnWndCount:Integer=0;SavWnds,SavWnds2:arrayofTHandle;hDlgWnd:THandle=0;hTimerk:Integer=0;nTimerTick:Integer=0;nLastTrk:Integer=0;nDoHint:Integer=0;nCapCt:Integer=0;nSavCapt:String=''fTimer1:TTimer=nil;functionMyEnum
3、Proc(hWnd:THandle;lParam:Integer):Boolean;stdcall;varn:Integer;beginResult:=True;iflParam=0thenbeginifnotIsWindowEnabled(hWnd)thenExit;ifnotIsWindowVisible(hWnd)thenExit;end;n:=(nWndCount+10)div10*10;SetLength(SavWnds,n);SavWndsnWndCount:=hWnd;Inc(nWndCount);end;procedureMyTimerProc(hWnd:THandle;uMs
4、g:Integer;idEvent:Integer;dwTime:Integer);vari,t:Integer;functionFindInArray(ar:arrayofTHandle;hd:THandle):Boolean;vart:Integer;beginResult:=False;fort:=Low(ar)toHigh(ar)dobeginResult:=art=hd;ifResultthenBreak;end;end;beginif(hDlgWnd=0)and(SavWnds=nil)and(SavWnds2nil)thenbeginnWndCount:=0;EnumThread
5、Windows(GetCurrentThreadId,MyEnumProc,0);SetLength(SavWnds,nWndCount);fori:=Low(SavWnds)toHigh(SavWnds)dobeginifnotFindInArray(SavWnds2,SavWndsi)thenbeginifSavWndsi=GetActiveWindowthenbeginhDlgWnd:=SavWndsi;end;end;end;ifhDlgWnd=0thenResetDlgAutoClose;nLastTrk:=GetTickCount;SetLength(nSavCapt,500);t
6、:=GetWindowText(hDlgWnd,PChar(nSavCapt),500);SetLength(nSavCapt,t);nCapCt:=0;endelseif(hDlgWnd0)thenifnotIsWindow(hDlgWnd)ornotIsWindowVisible(hDlgWnd)ornotIsWindowEnabled(hDlgWnd)thenbeginResetDlgAutoClose;Exit;end;t:=GetTickCount;t:=(nTimerTick-(t-nLastTrk)-1);ift0)thenbegint:=(t+1000)div1000;ifnC
7、apCttthenbeginSetWindowText(hDlgWnd,PChar(Format('(%d)%2s%s',t,'',nSavCapt);nCapCt:=t;end;end;end;end;procedureTimerFunc(Sender:TObject);MyTimerProc(0,0,0,0);end;procedureSetDlgAutoClose(nTime:Integer;ADoHint:Boolean=False);varFakeEvt:TNotifyEvent;Ptrs:array1.2ofPointerabsoluteFakeEv
8、t;beginResetDlgAutoClose;nWndCount:=0;EnumThreadWindows(GetCurrentThreadId,MyEnumProc,1);SetLength(SavWnds,nWndCount);SavWnds2:=SavWnds;SavWnds:=nil;ifnotAssigned(fTimer1)thenbeginfTimer1:=TTimer.Create(Application);Ptrs2:=nil;Ptrs1:=TimerFunc;fTimer1.OnTimer:=FakeEvt;fTimer1.Interval:=100;fTimer1.E
9、nabled:=True;end;nLastTrk:=GetTickCount;nDoHint:=Ord(ADoHint);nTimerTick:=nTime;end;procedureResetDlgAutoClose;beginifhDlgWnd0thenbeginSetWindowText(hDlgWnd,PChar(nSavCapt);end;ifAssigned(fTimer1)thenFreeAndNil(fTimer1);nWndCount:=0;hDlgWnd:=0;SavWnds:=nil;SavWnds2:=nil;nTimerTick:=0;end;end.測試proce
10、dureTForm1.Button1Click(Sender:TObject);beginSetDlgAutoClose(15*1000,True);ShowMessage('Thismessageboxwillcloseautomatically,+#13#10+'afterfifteenseconds.');end;procedureTForm1.Button3Click(Sender:TObject);beginSetDlgAutoClose(8000,Sender=Button3);MessageBox(Handle,PChar('這是一個測試?yán)?#39;+#13#10+'此消息框?qū)⒃?秒鐘后自動關(guān)閉'+#13#10+'只需要在調(diào)用消息框和對話框之前調(diào)用一個函數(shù)+#13#10+'就可以方便的實現(xiàn)這種效果'),'定時自動關(guān)閉的消息框',MB_ICONINFORMATIONorMB_OKCANCEL);end;procedureTForm1.Button2Click(Sender:TObject);vardlg:TDlgTest;beginSetD
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030年中國皮帶轉(zhuǎn)送線數(shù)據(jù)監(jiān)測研究報告
- 2025至2030年中國外罩?jǐn)?shù)據(jù)監(jiān)測研究報告
- 2025年中國高速輪轉(zhuǎn)膠印紙市場調(diào)查研究報告
- 商業(yè)綜合體商戶支持與服務(wù)體系建設(shè)考核試卷
- 墨水在食品包裝印刷中的安全性考核試卷
- 樂器維修與調(diào)律考核試卷
- 技術(shù)服務(wù)綠色能源技術(shù)創(chuàng)新考核試卷
- 2025-2030年發(fā)光服裝定制行業(yè)跨境出海戰(zhàn)略研究報告
- 2025-2030年變形概念車設(shè)計與展示行業(yè)跨境出海戰(zhàn)略研究報告
- 2025-2030年可折疊畫紙支架企業(yè)制定與實施新質(zhì)生產(chǎn)力戰(zhàn)略研究報告
- 2024-2025學(xué)年人教版生物八年級上冊期末綜合測試卷
- FZ/T 54007-2019錦綸6彈力絲
- DB11-T 291-2022日光溫室建造規(guī)范
- 2021-2022學(xué)年山東省淄博市高二(下)期末英語試卷(附答案詳解)
- 北師大版高中數(shù)學(xué)選修4-6初等數(shù)論初步全套課件
- 外貿(mào)業(yè)務(wù)員面試試卷
- 紀(jì)檢知識答題測試題及答案
- 創(chuàng)傷急救-止血、包扎課件
- 大數(shù)據(jù)背景下網(wǎng)絡(luò)輿情成因及治理
- 道教系統(tǒng)諸神仙位寶誥全譜
- 中國經(jīng)濟轉(zhuǎn)型導(dǎo)論-政府與市場的關(guān)系課件
評論
0/150
提交評論