The SetWindowLong function changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory. LONG SetWindowLong(
HWND hWnd, // handle to window
int nIndex, // offset of value to set
LONG dwNewLong // new value
);
GWL_USERDATA:Sets the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window. This value is initially zero.
HWND hWnd, // handle to window
int nIndex, // offset of value to set
LONG dwNewLong // new value
);
GWL_USERDATA:Sets the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window. This value is initially zero.
解决方案 »
- 节点类的疑惑,请大家帮帮忙
- 我如下写,编译不过,应该怎么写?
- 求助:随机从 16 个确定的数中,选取 10 个,他们的平价值的 mod 为 15,谢谢!
- 为什么Win32 Console工程不支持结构体和类的使用?
- iocp完成端口接收数据导致WS2HELP.DLL崩溃,诚心求教
- 我的程序里面连个assert都没有,竟然出现开始运行时出现bug assertion failed
- 如何写CDatabase连接SQRSERVER的连接字符串!急!!!
- 中国高手们黑了它http://zhina444.allhere.com/,为国,为了分,请大家UP,直到它被黑
- ------请大家推荐几本数据库的入门书籍??
- 两个小问题,在线等候!!!
- 怎么把一个字符串中的数字提取出来???? !!!
- 很容易的一个问题。。。 快点
现在Windows位我们提供了userdata这个东西,那么我们可以把名字存在hwnd的userdata里边。这样可以实现一种“数据携带”。
不过如果你要设计一个可以重用的窗口类,那么建议不要使用userdata,因为类的使用者可能使用userdata。比如你是标准button的编写者,那么鉴于其他的编程人员要大量的使用button,那么你不应该实用userdata,因为其它的编程人员也需要存取一些数据。这时候你应该实用附加的窗口字节。
属性包括窗口的样式、扩展样式、窗口函数、窗口的ID值、窗口所在的进程的句柄、和用户自定义的一个USER DATA(也就是WNDCLASS结构里的cbWndExtra,通常为0, 其实没有多大的作用)。
至于改变的是何种属性就由该API的第二个参数nIndex决定,譬如GWL_STYLE就代表要修改的是窗口的样式,具体的样式标致由第三个参数dwNewLong指出。