We help IT Professionals succeed at work.

Locking width on Listview colums

MELeBlanc
MELeBlanc asked
on
207 Views
Last Modified: 2012-06-08
I have a listview control that has a number of columns.. I want to be able to disable the ability to resize the width of these columns.  How does one go about doing this?

-M
Comment
Watch Question

Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Commented:
You might want to trap other clicks.. such as the mouse double click since that also resizes the windows...

so you would need to add something like this...

Public Const WM_LBUTTONDBLCLK = &H203


If uMsg = WM_LBUTTONDOWN or uMsg = WM_LBUTTONDBLCLK Then
   Debug.Print "button down"
   Exit Function
 End If
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
bobbit, the link only shows how to avoid resize dragging but not prevents from resizing with double click.
The link for the ocx is broken, i found it in another place:
http://www.geocities.com/CapeCanaveral/6740/subcls32.zip
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
Code for aeklund shold works with a little modification to last code posted by him:

Function WindowProc(ByVal hw As Long, _
 ByVal uMsg As Long, _
 ByVal wParam As Long, _
 ByVal lParam As Long) As Long
   
 Select Case uMsg
    Case WM_LBUTTONDOWN
        Debug.Print "button down"
        uMsg = 0
    Case WM_LBUTTONDBLCLK
        Debug.Print "Double click"
        uMsg = 0
 End Select
 
 WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Function
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
Mel, if code posted by me works for you, DON'T ACCETP IT as an answer.
Cheers

Commented:
Richie,

What is the advantage of setting the uMsg = 0 and letting it go back to the original window compared to just exit the function and send nothing to the original window?

Author

Commented:
That would be exactly what I am looking for!  Thanks!

-M
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
doing that way, we don't have exit the function and let pass all messages to original window proc. I think it is less intrusive that way. That's all.

Commented:
Your welcome... Good luck!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions