请问GetWindowLong()函数用来做什么?什么情况下采用?
谢谢!

解决方案 »

  1.   

    获得一个窗口的信息,比如类型,句柄等
    具体参考MSDN
      

  2.   

    The GetWindowLong function retrieves information about the specified window. The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory of a window. LONG GetWindowLong(
      HWND hWnd,  // handle of window
      int nIndex  // offset of value to retrieve
    );这是MSDN上说得
      

  3.   

    LONG GetWindowLong( 
    HWND hWnd, 
    int nIndex
    ); This function retrieves information about the specified window. GetWindowLong also retrieves the 32-bit (long) value at the specified offset into the extra window memory of a window
    它是用来获取指定窗口的信息的函数
    其中第一个参数为你想获得信息的窗口句柄
    第二个参数为你想获得窗口信息的内容,有如下几种情况
    GWL_EXSTYLE 获取窗口的扩展风格
    GWL_STYLE 获取窗口的一般风格 
    GWL_WNDPROC 获得窗口函数的地址,或者表示窗口函数地址的句柄。你可以通过CallWindowProc来调用此窗口函数 
    GWL_ID 暂时不支持. 
    GWL_USERDATA 暂时不支持. 一般用得多的是前两个
    比如你现在想得到窗口的风格然后对其风格进行改变,就可以使用这个函数,具体用法如下:
      

  4.   

    LONG lStyle=GetWindowLong(m_pListctrl->GetSafeHwnd(),GWL_STYLE);//获得窗口类型
    lStyle&=~LVS_TYPEMASK; //清除显示方式位
    lStyle|=WS_VISIBLE|LVS_REPORT; //修改窗口风格
    SetWindowLong(m_pListctrl->GetSafeHwnd(),GWL_STYLE,lStyle);//设置窗口风格
      

  5.   

    GetWindowLong/SetWindowLong
    取得/修改hwnd对应的窗口的窗口类结构中的某些字段的值,比如说改变窗口函数、改变窗口风格(SetWindowPos之类函数对窗口作用一下才能看出)