GetWindowLong API作用

GetWindowLong 函数检索有关指定窗口的信息。 该函数还将指定偏移量处的 32 位(长)值检索到额外的窗口内存中。

LONG GetWindowLong(  HWND hWnd,  // 窗口句柄
  int nIndex  // 填特定的参数以获取改句柄的不同信息;

下面是第二个参数可以填的一些特定值

ValueAction
GWL_EXSTYLERetrieves the extended window styles. For more information, see CreateWindowEx.
GWL_STYLERetrieves the window styles.
GWL_WNDPROCRetrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure.
GWL_HINSTANCERetrieves a handle to the application instance.
GWL_HWNDPARENTRetrieves a handle to the parent window, if any.
GWL_IDRetrieves the identifier of the window.
GWL_USERDATARetrieves 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.

如果窗体是Dialog的话,还可以多添几个,主要是后三个是Dialog专用的。

DWL_DLGPROCRetrieves the address of the dialog box procedure, or a handle representing the address of the dialog box procedure. You must use the CallWindowProc function to call the dialog box procedure.
DWL_MSGRESULTRetrieves the return value of a message processed in the dialog box procedure.
DWL_USERRetrieves extra information private to the application, such as handles or pointers.

常用的就是GWL_STYLE,他会返回改窗体的风格,对于不知道风格来加风格非常有用。

例子:比如我想给一个static窗口类添加一个可以显示图片的风格,却又不想改变他原有的风格,这就十分必要需要GetWindowLong这个函数了

LONG nStyle = GetWindowLong(hWndBMP, GWL_STYLE);
		GetWindowLong SetWindowLong很重要
		GetWindowLOng  就是获取原有的窗口风格
		然后不改变原有风格的条件下还能加载
		SetWindowLong(hWndBMP, GWL_STYLE,nStyle|SS_BITMAP);

当然,这里用到了SetWindowLong,要和GetWindowLOng对应起来使用.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值