MFC 窗体样式修改

31 篇文章 2 订阅

窗体创建之后,如何设置窗体的样式呢?

一般情况下使用GetWindowLongW与SetWindowLongW即可实现窗体样式的修改或者使用ModifyStyle。

关于MFC存在GetWindowLongW和GetWindowLongA使用哪一个,可以通过 IsWindowUnicode(this->m_hWnd)获取是使用哪一类型,true则使用GetWindowLongW反之使用GetWindowLongA。

  LONG style = ::GetWindowLongW(this->m_hWnd,GWL_STYLE);//获取原窗体的样式
   style&=~(WS_CAPTION | DS_MODALFRAME|WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE);//更改样式
   ::SetWindowLongW(this->,GWL_STYLE,style);//重新设置窗体样式
ModifyStyle(userForm.m_hWnd,WS_CAPTION | DS_MODALFRAME|WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE,0,0);
//------------------------------------------------------------------------------//
ModifyStyle(WS_CAPTION,0,0); //去除标题栏
ModifyStyle(0,WS_THICKFRAME,0); //添加 WS_THICKFRAME风格
ModifyStyle(0,WS_EX_TOOLWINDOW,0); //设置工具栏窗口风格
ModifyStyleEx(0,WS_EX_ACCEPTFILES,0); //设置Accept files 属性

参数:

hWnd

窗口句柄及间接给出的窗口所属的窗口类

nlndex

指定要获得值的大于等于0的值的偏移量有效值的范围从0到额外窗口内存空间的字节数一4例如,若指定了12位或多于12位的额外类存储空间,则应设为第三个32位整数的索引位8。要获得任意其他值,指定下列值之一:

意义

GWL_EXSTYLE

(-20)

获得扩展窗口风格。

GWL_HINSTANCE

(-6)

获得应用事例的句柄。

GWL_HWNDPARENT

(-8)

如果父窗口存在,获得父窗口句柄

GWL_ID

(-12)

获得窗口标识。

GWL_STYLE

(-16)

获得窗口风格。

GWL_USERDATA

(-21)

获得与窗口有关的32位值。每一个窗口均有一个由创建该窗口的应用程序使用的32位值。

GWL_WNDPROC

(-4)

获得窗口过程的地址,或代表窗口过程的地址的句柄。必须使用CallWindowProc函数调用窗口过程。

 

在hWnd参数标识了一个对话框时也可用下列值:

意义

DWL_DLGPROC

(4)

获得对话框过程的地址,或一个代表对话框过程的地址的句柄。必须使用函数CallWindowProc来调用对话框过程。

DWL_MSGRESULT

(0)

获得在对话框过程中一个消息处理的返回值。

DWL_USER

(8)

获得应用程序私有的额外信息,例如一个句柄或指针

 

 

参考:http://baike.baidu.com/view/1080267.htm

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
MFC开发过程序所需的ModifyStyle(needDelStyle,needAddStyle,SWP_FRAMECHANGED); Sytel: WS_BORDER Creates a window that has a border. WS_CAPTION Creates a window that has a title bar (implies the WS_BORDER style). Cannot be used with the WS_DLGFRAME style. WS_CHILD Creates a child window. Cannot be used with the WS_POPUP style. WS_CHILDWINDOW Same as the WS_CHILD style. WS_CLIPCHILDREN Excludes the area occupied by child windows when you draw within the parent window. Used when you create the parent window. WS_CLIPSIBLINGS Clips child windows relative to each other; that is, when a particular child window receives a paint message, the WS_CLIPSIBLINGS style clips all other overlapped child windows out of the region of the child window to be updated. (If WS_CLIPSIBLINGS is not given and child windows overlap, when you draw within the client area of a child window, it is possible to draw within the client area of a neighboring child window.) For use with the WS_CHILD style only. WS_DISABLED Creates a window that is initially disabled. WS_DLGFRAME Creates a window with a double border but no title. WS_GROUP Specifies the first control of a group of controls in which the user can move from one control to the next with the arrow keys. All controls defined with the WS_GROUP style FALSE after the first control belong to the same group. The next control with the WS_GROUP style starts the next group (that is, one group ends where the next begins). WS_HSCROLL Creates a window that has a horizontal scroll bar. WS_ICONIC Creates a window that is initially minimized. Same as the WS_MINIMIZE style. WS_MAXIMIZE Creates a window of maximum size. WS_MAXIMIZEBOX Creates a window that has a Maximize button. WS_MINIMIZE Creates a window that is initially minimized. For use with the WS_OVERLAPPED style only. WS_MINIMIZEBOX Creates a window that has a Minimize button. WS_OVERLAPPED Creates an overlapped window. An overlapped window usually has a caption a

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值