About how to set the clistctrl extension Style
-------------------------------------- Comparison between setextendedstyle and modifystyleex
For those who have just started learning, when they need to set the extended style of listctrl, they often want to use modifystyleex to set it. The Code is as follows:
ModifyStyleEx(0,LVS_EX_GRIDLINES)
This is not correct. The correct setting should be:
SetExtendedStyle(LVS_EX_GRIDLINES)
So what is the difference between modifystyleex and setextendedstyle?
In fact, modifystyleex only sets the gwl_exstyle attribute of the form, that is, it only sets the general extended attribute of the form. Such attributes use ws_ex _ as the prefix, for example, ws_ex_clientedge,
In the listctrl control, its extended style value is not stored in the gwl_exstyle attribute value of the form, but is implemented by sending the lvm_setextendlistviewstyle message to the listctrl control. Therefore, it cannot be set through modifystyleex.
Compared with modifystyle, this API can set the style of a common form, such as ws_child and ws_visible. Or. set the general style of the control. For listctrl, there are lvs_report, lvs_ownerdrawfixed, and so on. This is why we can set ws_child when creating the child control, the reason why ws_visible is combined to pass the create function of the control:
m_list.Create(WS_CHILD|WS_VISIBLE|LVS_REPORT,CRect(0,0,100,100),this,0);
However, you cannot do this for the extended style:
m_list.CreateEx(WS_EX_CLIENTEDGE|LVS_EX_GRIDLINES,"LISTCTRL","",WS_CHILD|WS_VISIBLE,CRect(0,0,100,100),this,0);
Why does Microsoft not store the extended style of the control in the gwl_exstyle attribute? Because the property value is a 32-bit DWORD type, the General extended property of the form is the property prefixed with ws_ex, it has been used up, So Microsoft can only put the extended style of listctrl elsewhere.
How to set the clistctrl extended style-Comparison Between setextendedstyle and modifystyleex