窗口风格的修改(2) SetClassLong()和SetWindowLong()

来源:互联网 发布:淘宝搜索引擎原理 编辑:程序博客网 时间:2024/05/18 03:53

现在谈谈在窗口创建之后对窗口风格的修改

主要可以用到两个函数:SetClassLong()和SetWindowLong()

看看msdn对SetClassLong()函数的说明:

This function replaces the specified 32-bit (LONG) value at the specified offset into the extra class memory of theWNDCLASS structure for the class to which the specified window belongs.

example:

frame中的OnCreate()函数中://因为现在演示的是在窗口创建之后对窗口风格的修改

SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) & ~WS_MAXIMIZEBOX);
SetClassLong(m_hWnd,GCL_HICON,(LONG)LoadIcon(NULL,IDI_ERROR));

view中://由于view类中 系统没有为其生成OnCreate()函数 所以我们要人为地为其创建一个OnCreate()函数

 SetClassLong(m_hWnd,GCL_HBRBACKGROUND,(LONG)GetStockObject(BLACK_BRUSH));
SetClassLong(m_hWnd,GCL_HCURSOR,(LONG)LoadCursor(NULL,IDC_HELP));  

 

当然 还可以为自己的窗口设计很多有趣的风格 慢慢去享受吧 这里仅介绍最基本的操作 IT之路                     

原创粉丝点击