How to set a minimum column width


How to Help Your Business Become an AI Early Adopter

Again we have to override the OnNotify() function. The code below restricts the columns to a minimum width of 80 pixels. The logic can be extended to restrict the width within a range or even specify different range for different columns. To extend the functionality, you would need to add member variables to the class to track the different settings.
BOOL CMyListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
    HD_NOTIFY   *pHDN = (HD_NOTIFY*)lParam;

        if((pHDN->hdr.code == HDN_ITEMCHANGINGW || pHDN->hdr.code == HDN_ITEMCHANGINGA) 
                && pHDN->pitem->cxy < 80)
                *pResult = TRUE;                // disable change
                return TRUE;                    // Processed message
        return CListCtrl::OnNotify(wParam, lParam, pResult);


  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Agencies that integrate back-office processed with cloud-based services, advanced analytics and talent management solutions can reduce costs, maximize efficiencies and transform employee recruitment and retention. Learn more by reading this interview brief by GovLoop with Infor industry thought leaders.

  • How does this impact your content strategy? Content management markets are changing rapidly. Due to increased expectations of users, changes in IT and the need for organizations to rethink their digital strategy, Gartner has launched new Magic Quadrants (MQs) for Content Services Platforms (CSP) and Content Collaboration Platforms (CCP). These MQs have updated the definition of previous Enterprise Content Management (ECM) and Enterprise File Sync and Share (EFSS) markets respectively, and are tightly connected …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date