现象:在使用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