CreateWindow
lpClassName[in] Pointer to a null-terminated string or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero. If lpClassName is a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, provided that the module that registers the class is also the module that creates the window. The class name can also be any of the predefined system class names. For a list of system class names, see the Res section.

解决方案 »

  1.   

    lpClassName指向一个以null结束的字符串,或一个类的原子(?),创建于先前调用的RegisterClass或RegisterClassEx函数.如果lpClassName是原子,则原子在lpClassName的低字节处,高字节为0.如果lpClassName为字符串,则它为某个窗口类的名字.这个类名,可以是由RegisterClass或RegisterClassEx注册的,它既是类名也是窗口的名字.类名也可以是系统预定义的类名之一.要看系统预定义的类的名字列表,请看re段.
      

  2.   

    也就是说,你调用createWindow时,必须传入一个已经注册过的类,你可以直接传入类名,也可以传入代表这个类名的原子值,原子值和类名是对应的,并且是唯一的。
      

  3.   

    provided that the module that registers the class is also the module that creates the window.这句没译吧?!
      

  4.   

    provided that the module that registers the class is also the module that creates the window.假若注册类的模块也是创建窗口的模块,...
      

  5.   

    An atom table is a system-defined table that stores strings and corresponding identifiers. An application places a string in an atom table and receives a 16-bit integer, called an atom, that can be used to access the string. A string that has been placed in an atom table is called an atom name.
      

  6.   

    记得 VC 中有字符串常量表,是指这张表吗?为什么“原子在lpClassName的低字节处,高字节为0”
      

  7.   

    An atom table 是windows系统内置的表。//为什么“原子在lpClassName的低字节处,高字节为0”
    1、atom是16位的整数;
    2、不是低字节、高字节,而是低字和高字。只有高字为0,才能和字符串指针区分开。
      

  8.   

    第一,你在createwindow时传入的参数,系统如何知道是string还是atom,这需要区别。
    第二,lpClassName是一个指针,指针是32位的,而atom是16位的。综上,为了区别字符串和atom,所以M$的开发人员规定,如果你传入的指针高位为0,那说明它实际是一个atom,而不是一个指向一串以0结尾的字符。实际在使用资源时,这种约定在大量的使用。当然,由于某些原因,普通的字符串指针的高位是不会为0的。具体原因就留给楼下的高手来回答吧,嘿嘿
      

  9.   

    谢谢大家,贴加 30 分 ,再问:
    能不能举个用 atom 的例子 ?
      

  10.   

    The most typical use for atoms is in Dynamic Data Exchange (DDE) applications. In the DDE protocol, applications use global atoms to identify the applications exchanging data, the nature of the data being exchanged, and the actual data items being exchanged. 查MSDN,有很多示例程序。
      

  11.   

    能不能举个用 atom 的例子 ?
    ===========================
    没怎么用过。
    msdn里函数一堆,
    AddAtom
    DeleteAtom
    FindAtom
    GlobalAddAtom
    .
    .
    .
      

  12.   

    唉!我就是在MSDN 上找不到和CreateWindow 相关的例子,才来问的
      

  13.   

    ATOM rc;
    WNDCLASSEX wcex;wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc = (WNDPROC)WndProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 16;
    wcex.hInstance = hInstance;
    wcex.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_WINLOGO);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName = (LPCSTR)IDC_TEST;
    wcex.lpszClassName = szWindowClass;
    wcex.hIconSm = LoadIcon(NULL, (LPCTSTR)IDI_WINLOGO);rc=RegisterClassEx(&wcex);if(rc)
    {
    hFrame=CreateWindowEx(0, (LPCTSTR)rc, szWindowName, 1<<31, 0, 1<<31, 0, 
    (HWND)NULL, (HMENU)NULL, hInstance, 0L);
    ...
    }
      

  14.   

    (LPCTSTR)rc 放在第二个参数? 为什么? MSDN 上的那句话是在第一个参数中写的
      

  15.   

    CreateWindowEx比CreateWindow多了一个参数。