BaKuBaKu说得有一点道理,不过我查过相关资料,资料上说:
一个.EXE文件中的所有控件可以自动获得application.handle 而 .Dll和.Ocx却不能
自动得到 Application.handle,通俗一点就是 .Exe文件的每个控件可以自动为其设置
Parent属性,而.Ocx文件在实现却不能,原因是它不知道到底是那个程序在调用它,为此
程序员必须手动为.Ocx的相关控件设置 Handle 或 parent属性,
可是怎么设定?????
下面是Delphi帮助中对Application.handle 和 Dll类型的说明:
Provides access to the window handle of the main form (window) of the application.
property Handle: HWND;
Description
Use Handle when calling Windows API functions that require a parent window handle. For example, a DLL that displays its own top-level pop-up windows needs a parent window to display its windows in the application. Using the Handle property makes such windows part of the application, so that they are minimized, restored, enabled and disabled with the application.
Note: When writing a DLL that uses VCL forms, assign the window handle of the host EXE抯 main window to the DLL抯 Application.Handle property. This makes the DLL抯 form part of the host application. Never assign to the Handle property in an EXE.