Go VC Dynamic Change CComboBox style

Source: Internet
Author: User

Most of the time, the style of CComboBox is chosen by design time, but sometimes it needs to be changed dynamically by the program, and we find that the ModifyStyle function that comes with it does not work: GetWindowLong gets its style and then joins or removes our target style again:: SetWindowLong We find it doesn't work, so how do you change its style dynamically?

We know that there is a create function in CComboBox for creating the CComboBox instance, so we can change its style dynamically using the Create method, but we need to destroy the original window before the create, the code is as follows:

CRect Rrect; UINT UnID=0; DWORD Dwstyleex=0; CFont* pfont=NULL; Pfont=M_rghs.getfont (); Dwstyleex=M_rghs.getexstyle (); //Remove the original cbs_dropdownlist style, add Cbs_dropdown styleDwstyleex= Dwstyleex & ~cbs_dropdownlist |Cbs_dropdown; M_rghs.getwindowrect (&rrect); ScreenToClient (&rrect); UnID=m_rghs.getdlgctrlid (); M_rghs.destroywindow (); M_rghs.create (Dwstyleex, Rrect, This, UnID); M_rghs.showwindow (sw_show); M_rghs.setfont (Pfont, TRUE) ;

Go VC Dynamic Change CComboBox style

Related Article

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.