ModifyStyle()调用不起作用

在使用WTL的CListBox子类化过程中遇到问题,尝试使用ModifyStyle(0, LBS_OWNERDRAWFIXED)修改样式无效。原因是某些风格如LBS_HASSTRINGS | LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE只能在控件创建时设定,后续动态修改不会生效。解决方法包括动态创建控件或在创建ListBox时直接指定所需风格。参考Code Project的解释,对于需要动态切换的风格,可能需要新建并替换控件,或者使用两个覆盖的ListBox来实现。" 114955216,10538668,使用Java生成Outlook日程:多事件.ICS文件示例,"['Java开发', '日历同步', 'Outlook集成', '数据格式', '赛事管理']
摘要由CSDN通过智能技术生成

现象:在使用WTL做CListBox子类化时,使用 ModifyStyle(0, LBS_OWNERDRAWFIXED)不起作用;

原因:并不是所有的风格都可以动态利用ModifyStyle/ModifyStyleEx()函数增加和去除,有些风格比如 LBS_HASSTRINGS | LBS_OWNERDRAWFIXED| LBS_OWNERDRAWVARIABLE 就只能在创建窗口的时候指定(其后再增加是无效的),也就是说你只能创建的之前指定。

解决:自己动态创建控件,或在待子类化的ListBox控件中指定属性(如LBS_HASSTRINGS | LBS_OWNERDRAWFIXED| LBS_OWNERDRAWVARIABLE )

 

附:

1) code   project中的解释

It   is   not   possible   to   change   these   styles   at   runtime   even   though   ModifyStyle()   may   give   the   impression   it   does.   If   you   want   turn   the   Sort   style   on   and   off   for   example   it   is   best   to   construct   the   List   box   by   calling   new   and   Create   then   deleting   it   and   creating   a   new   one   when   the  

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、付费专栏及课程。

余额充值