ListView control
-
hi! can anyone tell me how to prevent the user from resizing the listview column header? i'm using MFC btw. thx!
-
hi! can anyone tell me how to prevent the user from resizing the listview column header? i'm using MFC btw. thx!
I have not used column headers in a list view before but let me hazard a guess. Try subclassing the listview and capturing the LVM_SETCOLUMNWIDTH message. Replace the new column width with your own hard-coded width then send the LVM_SETCOLUMNWIDTH message to the default control proc. Tell me if it works.
-
I have not used column headers in a list view before but let me hazard a guess. Try subclassing the listview and capturing the LVM_SETCOLUMNWIDTH message. Replace the new column width with your own hard-coded width then send the LVM_SETCOLUMNWIDTH message to the default control proc. Tell me if it works.
umm, how do i catch the LVM_SETCOLUMNWIDTH message? it's not available in the ClassWizard event list...
-
umm, how do i catch the LVM_SETCOLUMNWIDTH message? it's not available in the ClassWizard event list...
You should be able find LVM_SETCOLUMNWIDTH in the ClassWizard. Open the Class Wizard and (in the Message Maps tab) look at the list box labeled "Object IDs:". By default the class name of the dialog will be selected. Search further down the list until you find the resource ID of your ListView control then select it. The "Messages:" list box to the right will then show the messages appropriate for ListView controls. Search through the list to find the one you want. Good luck.
-
umm, how do i catch the LVM_SETCOLUMNWIDTH message? it's not available in the ClassWizard event list...
I must appologize. I went through the steps that I previously gave you and didn't find LVM_SETCOLUMNWIDTH. After further thought I feel that you will have to subclass the ListView control (CListCtrl) with your own class that inherits from CListCtrl. Override the WindowProc function. (You'll find WindowProc in class CWnd.) The prototype should look as follows: (I hope all this formatting doesn't get lost. I'll double space to be certain.) LRESULT CYourClass::WindowProc(UINT message, WPARAM wParam, LPARAM lParam); And the body should appear somewhat as follows: (I have not actually done this with CListCtrl but it should work.) // Begin Body { int nFixedWidth = 100; // Hard-coded width switch ( message ) { case LVM_SETCOLUMNWIDTH: // override lParam lParam = MAKELPARAM( nFixedWidth, 0); break; } return CListCtrl::WindowProc(message, wParam, lParam); } // End body The value assigned to nFixedWidth is in list view coordinates. It looks fairly simple. I hope this works for you
-
hi! can anyone tell me how to prevent the user from resizing the listview column header? i'm using MFC btw. thx!