We help IT Professionals succeed at work.

Check out this week's podcast, "Dairy Farms to Databases: Community's Hand in Technology"Listen Now

x

Locking width on Listview colums

MELeBlanc
MELeBlanc asked
on
198 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 one is on us!
(Get your first solution completely free - no credit card required)
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!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.