Window Class和CreateWindow(不断修改中)

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 name
1.USER32.DLLStatic
2.USER32.DLLButton
3.USER32.DLLListbox
4.USER32.DLLCombobox
5.USER32.DLLEdit
6.A.DLLMyClass
7.B.DLLMyClass

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

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值