Window Class和CreateWindow(不断修改中)

来源:互联网 发布:软件商务怎么谈 编辑:程序博客网 时间:2024/06/05 08:58

1.窗口类WNDCLASS和窗口实例CreateWindow

1.1 这两者怎么联系起来的?

使用WNDCLASS的最后一个成员lpszClassName和CreateWindow第一个参数classname联系起来,正如MSDN所说:

  1. Search the list of application local classes for a class with the specified name whose instance handle matches the module's instance handle. (Several modules can use the same name to register local classes in the same process.)
  2. If the name is not in the application local class list, search the list of application global classes.
  3. If the name is not in the application global class list, search the list of system classes.

1.2 窗口类的作用范围?全局,进程还是线程?

由style成员决定,如果wndClass.style = CS_GLOBALCLASS,则表示这个窗口类是全局的。如果希望在其他进程中使用:

load拥有这个窗口类的dll或者可执行性文件

CreateWindow(类名,.......,dll的句柄,......)

1.3 CreateWindow为什么需要hInstance参数

由 1.2 可知,当程序加载了多个dll的时候,是有可能出现类名冲突的,例如


 HINSTANCEClass name1.USER32.DLLStatic2.USER32.DLLButton3.USER32.DLLListbox4.USER32.DLLCombobox5.USER32.DLLEdit6.A.DLLMyClass7.B.DLLMyClass

A.dll和B.dll都注册了为MyClass的窗口类,因此,需要hInstance区别不同的dll来唯一指定窗口类。

博文http://blogs.msdn.com/b/oldnewthing/archive/2005/04/18/409205.aspx有详细解答


0 0
原创粉丝点击