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

請問 HInstance 與 TApplication.Handle 有何不同?

答題得分者是:Justmade
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-04-01 15:57:31 IP:202.39.xxx.xxx 未訂閱
TApplication.Handle: Provides access to the window handle of the main form (window) of the application. HInstance: HInstance contains the instance handle of the application or library as provided by the Windows environment. 看 help 這兩句, 前者是指 window hanle, 後者是指 instance handle 可不可以解釋一下, 兩者是什麼不同呢? --- Have you ever wondered what it would be like?
Justmade
版主


發表:94
回覆:1934
積分:2030
註冊:2003-03-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-04-01 17:03:12 IP:218.16.xxx.xxx 未訂閱
Application.Handle 其實是 Main Form 的 window handle,是指向 MainForm 這個窗體的。在同一個 Application 裡可以有許多 Form 各有各的 Window Handle,每個 Form 又可以有許多的視覺化元件,各有各的 Window Handle,而一些元件也可再包含其化的視覺化元件,又再有各的 Window Handle,如些類推。 一個 Window Handle 最主要就是用來處理在這個視覺化物件發生的事件和變動,所以很多和 window 有關的 API 都需要 Window Handle。 而 HInstance 是整個程式是次執行的 handle,主要用處是記憶管理,資源運用等等。每個程式有自己的一個 Instance Handle 以資識別,而DLL在執行時亦有自己的 HInstance Win32 Developer Guild 對 HInstance 有較詳細的解說 : Every window class requires an instance handle to identify the application or DLL that registered the class. As a multitasking system, Windows lets several applications or DLLs run at the same time, so it requires instance handles to keep track of all of them. Windows assigns a handle to each copy of a running application or DLL. Multiple instances of the same application or DLL all use the same code segment, but each has its own data segment. Windows uses an instance handle to identify the data segment that corresponds to a particular instance of an application or DLL. Windows passes an instance handle to an application or DLL when the application starts. The application or DLL assigns this instance handle to the class by copying it to the hInstance member of the WNDCLASSEX structure. 其實一個程式除了 Instance Handle 和 Window Handle 外,還有 Process Handle 和 Thread Handle 等等,在不同的 Window API 需要不同的 Handle。 其中小弟亦不很分得精 Instance Handle 和 Process Handle 的分別,只知道 Instance 是和 Window Class 有直接關係而 Process 關於那程式的執行空間的,希望各前輩高手們能夠指教。
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-04-01 17:22:17 IP:202.39.xxx.xxx 未訂閱
大概懂一點了, 謝啦! Justmade 前輩! ---
系統時間:2024-05-14 2:45:08
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!