在书中P281和P282中有一段代码如下:
  case   WM_CREATE   :   
                      for (x = 0 ; x < DIVISIONS ; x++)   
                                for (y = 0 ; y < DIVISIONS ; y++)   
                                      hwndChild[x][y] = CreateWindow (szChildClass, NULL,   
                                          WS_CHILDWINDOW | WS_VISIBLE, 0,   0,   0,   0,   
                                          hwnd, (HMENU) (y << 8 | x),   
                                         (HINSTANCE) GetWindowLong(hwnd,GWL_HINSTANCE),   
                                                              NULL)   ;   
                      return   0   ;      请问其中的y << 8 | x是个什么作用,我只了解意思是左移8位按位或x,但是具体起到了什么作用呢?
还有idFocus=x&0xFF   ,idFocus=y>>8  又起到了什么作用?
   Getwindowlong(hwnd,0)中的0好像没什么作用啊,相当什么东西都没有获得啊!在之后的
   Setwindowlong(hwnd,0,1Getwindowlong(hwnd,0))中,又起到了什么作用呢?
       

解决方案 »

  1.   

    y << 8 |  就是左移8位按位或x,它的作用是指定此窗口的ID号,每一个控件都有它所对应的ID号。
    LONG GetWindowLong( 
    HWND hWnd, 
    int nIndex); Getwindowlong的第二个参数: 
      nIndex 
    Specifies the zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus four; for example, if you specified 12 or more bytes of extra memory, a value of 8 would be an index to the third 32-bit integer. 
      

  2.   

    (y << 8 | x) 就是把x,y合并为一个16位ID