Link to home
Start Free TrialLog in
Avatar of MELeBlanc
MELeBlancFlag for United States of America

asked on

Locking width on Listview colums

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
Avatar of bobbit31
bobbit31
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of aeklund
aeklund

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aeklund
aeklund

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
Avatar of Richie_Simonetti
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
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
Mel, if code posted by me works for you, DON'T ACCETP IT as an answer.
Cheers
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?
Avatar of MELeBlanc

ASKER

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

-M
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.
Your welcome... Good luck!