当前位置:首页 » 多媒体相关

我翻译的关于窗口类的一点知识 分享吧


窗口类  
  这篇文章描述了各种类型的窗口类,他们在系统中的位置以及属于窗口类的用来定义窗口默认行为的各种元素。  
  窗口类是一系列窗口属性的集合。系统把窗口类当作生成窗口的模板。每一个窗口都是窗口类的成员。所有的窗口类是和进程相关的。  
  概述:  
  1. 关于窗口类  
  每一个窗口对应一个窗口过程,而该窗口过程是被所有使用这个窗口类的窗口所共享的。每一个进程在要创建窗口之前,必须要先注册改窗口所属的窗口类。注册窗口类就是将窗口过程,窗口风格以及其他窗口属性用一个类名相关连起来。当进程在createwindow,   createwindowex中使用窗口类名时,所创建的窗口属性就和窗口类中的各属性相联系了。  
  窗口类的类型有3种:系统的,应用程序全局的,应用程序局部的。  
  系统的窗口类是系统创建的。因此你的进程不能销毁它们。win95,win98和winme中的系统窗口类是在系统启动时就建立的。2000,nt,xp是在进程第一次调用gdi或者user中的函数时建立的。每一个应用程序都拥有一份系统窗口类的拷贝。系统中总可以在我们的进程中使用的窗口类有:  
  class description  
  button the   class   for   a   button.  
  combobox the   class   for   a   combo   box.  
  edit the   class   for   an   edit   control.  
  listbox the   class   for   a   list   box.  
  mdiclient the   class   for   an   mdi   client   window.  
  scrollbar the   class   for   a   scroll   bar.  
  static the   class   for   a   static   control.  
  以下是只用系统能使用的系统窗口类:  
  class description  
  combolbox the   class   for   the   list   box   contained   in   a   combo   box.  
  ddemlevent windows   nt/windows   2000/windows   xp:   the   class   for   dynamic   data   exchange   management   library   (ddeml)   events.  
  message windows   2000/windows   xp:   the   class   for   a   message-only   window.  
  #32768 the   class   for   a   menu.  
  #32769 the   class   for   the   desktop   window.  
  #32770 the   class   for   a   dialog   box.  
  #32771 the   class   for   the   task   switch   window.  
  #32772 windows   nt/windows   2000/windows   xp:   the   class   for   icon   titles.  
  应用程序全局窗口类是由可执行程序或者动态链接库所建立的。它可以被进程中的其他模块所共享。比如,你的dll通过调用registerclassex注册了一个应用程序全局窗口类的自定义的控件。那么凡是将这个dll映射到自己进程空间的进程都可以创建这个窗口制定的控件。为了能创建这样一个窗口类系统就在注册表中把该dll的名字添加到appinit_dlls中:  
  hkey_local_machine\software\microsoft\windows   nt\currentversion\windows。当然,用unregisterclass就可以卸掉这样的窗口类。  
  应用程序局部窗口类是在模块局部使用的。当一个模块关闭的时候,该窗口类也就被注销了。当让也可以使用unregisterclass来释放她所占有的空间。  
  系统是如何定位窗口类的呢?  
  系统为上述三中窗口类维护一个结构列表。当使用createwindow,createwindowex时,系统使用下列步骤来定位窗口类:  
  a. 在当前模块空间内搜索应用程序局部窗口类列表;  
  b. 搜索应用程序全局窗口类列表;  
  c. 搜索系统窗口类列表;  
  应用程序可以创建和高一级重名的窗口类,但决不会改写高一级的窗口类信息。具有局部隐藏的性质。  
  注册窗口类  
                                  窗口类定义了诸如风格,图标,光标,菜单以及窗口过程等属性.注册窗口类的第一步是要填充一个wndclassex的结构.然后,把这个结构通过registerclassex进行注册。在注册应用程序全局窗口类的时候,要在wndclassex的style成员中添加cs_globalclass属性。局部窗口类就不用添加这一属性。  
      注册窗口类的可执行模块或动态链接库是该窗口类的所有者。这一信息系统是从wndclass的hinstance成员中得出的。  
      95/98/me   当窗口类的所有者被关闭或卸载时,窗口类就被销毁了。因而,在窗口类所有者进程被销毁之前,就应该销毁所有使用该窗口类的窗口。  
      nt/2000/xp;当dll被卸载时,窗口类不会被销毁。因此,当系统调用窗口的窗口函数时,就会发生违规访问,因为窗口过程已经不再内存中了。所以,在dll卸下之前,要销毁所有的窗口,并调用unregisterclass。  
  窗口类的元素  
  窗口类的各个元素定义了使用该窗口类的窗口的行为和风格。初测窗口类的应用程序要在wndclassex结构中填充各成员,然后使用registerclassex函数来注册。getclassinfoex和getclasslong函数能够返回该窗口的窗口类的信息。setclasslong函数可以改变已经注册的全局和局部窗口类的属性。  
  element purpose  
  class   name distinguishes   the   class   from   other   registered   classes.  
  window   procedure   address pointer   to   the   function   that   processes   all   messages   sent   to   windows   in   the   class   and   defines   the   behavior   of   the   window.  
  instance   handle identifies   the   application   or   .dll   that   registered   the   class.  
  class   cursor defines   the   mouse   cursor   that   the   system   displays   for   a   window   of   the   class.  
  class   icons defines   the   large   icon   and   the   small   icon   (windows   95/98/me,   windows   nt   4.0   and   later).  
  class   background   brush defines   the   color   and   pattern   that   fill   the   client   area   when   the   window   is   opened   or   painted.  
  class   menu specifies   the   default   menu   for   windows   that   do   not   explicitly   define   a   menu.  
  class   styles defines   how   to   update   the   window   after   moving   or   resizing   it,   how   to   process   double-clicks   of   the   mouse,   how   to   allocate   space   for   the   device   context,   and   other   aspects   of   the   window.  
  extra   class   memory specifies   the   amount   of   extra   memory,   in   bytes,   that   the   system   should   reserve   for   the   class.   all   windows   in   the   class   share   the   extra   memory   and   can   use   it   for   any   application-defined   purpose.   the   system   initializes   this   memory   to   zero.  
  extra   window   memory specifies   the   amount   of   extra   memory,   in   bytes,   that   the   system   should   reserve   for   each   window   belonging   to   the   class.   the   extra   memory   can   be   used   for   any   application-defined   purpose.   the   system   initializes   this   memory   to   zero.  
  extra   class   memory:在系统内部,为每一窗口类维护一个wndclassex结构。在应用程序注册窗口类的时候,系统就在wndclassex结构的后面又添加了一定数量的字节空间(extra   class   memory)。这个空间是使用该窗口类的所用窗口所共享的。这部分空间是从系统的局部堆中分配的。当申请的这个空间超过40字节时,registerclassex就会失败。否则,就必须在应用程序自己的堆中分配相应的空间,并把指针交给extra   class   memory。setclassword和setclasslong函数可以向extra   class   memory中拷贝值。  
  extral   window   memory:在系统内部,为每一个窗口都维护一个窗口结构。在注册后,系统就会在该结构的后面又添加一定字节的存储空间(extra   window   memory)。同样是从系统的局部堆中分配的。这些数据是和指定窗口相关的。setwindowlong。  
  2.(尚未译完) 使用窗口类  
  函数:  
  结构:  
   
 

.

推荐阅读

  • 联想英文名正式更改为Lenovo 4月1日起生效 [详细内容]
  • 7月12日下午全北京ADSL瘫痪 断网原因尚不明 [详细内容]
  • 有关小P的电话薄备份的方法 [详细内容]
  • 手机维修大起底 中外厂商没有一家让你爽 [详细内容]
  • Intel携手电信 64位处理器联合ADSL大促 [详细内容]
  • M760相关问题的答案 [详细内容]
  • 波导考虑在印度建厂 有望成为软件开发中心 [详细内容]
  • 网友回答:

    讨论区

    Login