How to set the clistctrl extended style-Comparison Between setextendedstyle and modifystyleex

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.