ListView Control - prevent change to column widths

ListView Control - prevent change to column widths

mdhutchinson
Advisor Advisor
2,774 Views
37 Replies
Message 1 of 38

ListView Control - prevent change to column widths

mdhutchinson
Advisor
Advisor
Other than not displaying them, is there a way to prevent the user from changing the column widths when in 'Report' mode?
0 Likes
2,775 Views
37 Replies
Replies (37)
Message 21 of 38

Anonymous
Not applicable
i checked his solution and it does not work. would have been nice if you had
done the same.

"Kerry Brown" wrote in message
news:5436457@discussion.autodesk.com...
heh, bob, Just make sure you pay homage to Galen Nickerson the author of
that ...
http://www.vbcodemagician.dk/tips/cctrls_lvpreventresize.htm

"Bob" wrote in message
news:5436391@discussion.autodesk.com...
here is your second installment. enjoy!

Public Sub Hook()
'establish hook to capture messages to this window
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Unhook()
Dim temp As Long
'reset the message handler for this window
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim nmh As NMHDR
Dim nmhd As NMHEADER

Select Case uMsg
Case WM_NOTIFY
'fill the NMHDR struct from the lParam pointer.
'(for any WM_NOTIFY msg, lParam always points to a struct
'which is either the NMHDR struct, or whose 1st member is the
'NMHDR struct)
Call MoveMemory(nmh, ByVal lParam, Len(nmh))

'could combine HDN_BEGINTRACK
'and HDN_DIVIDERDBLCLICK into one
'(i.e.,Case HDN_BEGINTRACK, HDN_DIVIDERDBLCLICK:)
Select Case nmh.code
Case HDN_BEGINTRACK
'User began dragging a divider
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index you want to prevent
tracking.
'Note API is 0 based unlike ColumnHeaders collection which is 1
based.
Case 0
'ListView ColumnHeader Index 1 prevent tracking
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2 prevent tracking
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select

Case HDN_DIVIDERDBLCLICK
'user double clicked the divider area
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index
'you want to prevent resizing if the user double clicks on a
Column separator
'Note API is 0 based unlike ColumnHeaders collection which is 1
based
Case 0
'ListView ColumnHeader Index 1
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select
End Select
End Select

'Pass message on to the original window message handler
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Function


"Tony Tanzillo" wrote in message
news:5435599@discussion.autodesk.com...
Bobo....

Any idiot can copy commonly-used WinAPI
function import declarations that can be found
in thousands of places on the net and in books,
and paste them into a post here.

So, who do you think you're fooling?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5435528@discussion.autodesk.com...
yeah, i figured you didn't know. so i'll start educating you. here is your
first installment.
0 Likes
Message 22 of 38

Anonymous
Not applicable
hardly, i dispelled the rumor that tony knows all ...

about the only thing he really knows well is how to spew his vial at
unsuspecting users on this group and criticize their attempts at getting
their work done! most of the people using this group are here for answers
not his condescending attitude about how they don't know anything.

he said, "without using the Windows API and
subclassing the control to handle the notifications
that are fired when it happens."

maybe i'm wrong, but so far i haven't seen his answer to the contrary.


Bob

"Allen Johnson" wrote in message
news:5436494@discussion.autodesk.com...
Aw, you take all of his fun away!
0 Likes
Message 23 of 38

Anonymous
Not applicable
Instead of

ListView1.SmallImages = ilsSmall

it should be

ListView1.SmallIcons = ilsSmall
ListView1.View = lvwReport

in the Form_Load event and it works fine.
0 Likes
Message 24 of 38

Anonymous
Not applicable
Yeah, but I thought his response had no vitriolic content in it this time.
BTW, your method uses subclassing as well.
0 Likes
Message 25 of 38

Anonymous
Not applicable
thanks for pointing that out, i didn't bother looking into it ...

"Allen Johnson" wrote in message
news:5436549@discussion.autodesk.com...
Instead of

ListView1.SmallImages = ilsSmall

it should be

ListView1.SmallIcons = ilsSmall
ListView1.View = lvwReport

in the Form_Load event and it works fine.
0 Likes
Message 26 of 38

Anonymous
Not applicable
since i never said it wouldn't, what is your point?


"Allen Johnson" wrote in message
news:5436534@discussion.autodesk.com...
Yeah, but I thought his response had no vitriolic content in it this time.
BTW, your method uses subclassing as well.
0 Likes
Message 27 of 38

Anonymous
Not applicable
since there are at least a couple dozen different variations of the exacg
same code available, who do I really honor [other than tony of course]?
galen nickerson, dan apleman, randall wrath, joe sutfin, etc.

and whoever else has posted or otherwise seen this code to the world, thank
you.

frankly i don't remember exactly where i got my version i've had it my
library for years.


"Kerry Brown" wrote in message
news:5436457@discussion.autodesk.com...
heh, bob, Just make sure you pay homage to Galen Nickerson the author of
that ...
http://www.vbcodemagician.dk/tips/cctrls_lvpreventresize.htm

"Bob" wrote in message
news:5436391@discussion.autodesk.com...
here is your second installment. enjoy!

Public Sub Hook()
'establish hook to capture messages to this window
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Unhook()
Dim temp As Long
'reset the message handler for this window
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim nmh As NMHDR
Dim nmhd As NMHEADER

Select Case uMsg
Case WM_NOTIFY
'fill the NMHDR struct from the lParam pointer.
'(for any WM_NOTIFY msg, lParam always points to a struct
'which is either the NMHDR struct, or whose 1st member is the
'NMHDR struct)
Call MoveMemory(nmh, ByVal lParam, Len(nmh))

'could combine HDN_BEGINTRACK
'and HDN_DIVIDERDBLCLICK into one
'(i.e.,Case HDN_BEGINTRACK, HDN_DIVIDERDBLCLICK:)
Select Case nmh.code
Case HDN_BEGINTRACK
'User began dragging a divider
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index you want to prevent
tracking.
'Note API is 0 based unlike ColumnHeaders collection which is 1
based.
Case 0
'ListView ColumnHeader Index 1 prevent tracking
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2 prevent tracking
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select

Case HDN_DIVIDERDBLCLICK
'user double clicked the divider area
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index
'you want to prevent resizing if the user double clicks on a
Column separator
'Note API is 0 based unlike ColumnHeaders collection which is 1
based
Case 0
'ListView ColumnHeader Index 1
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select
End Select
End Select

'Pass message on to the original window message handler
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Function


"Tony Tanzillo" wrote in message
news:5435599@discussion.autodesk.com...
Bobo....

Any idiot can copy commonly-used WinAPI
function import declarations that can be found
in thousands of places on the net and in books,
and paste them into a post here.

So, who do you think you're fooling?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5435528@discussion.autodesk.com...
yeah, i figured you didn't know. so i'll start educating you. here is your
first installment.
0 Likes
Message 28 of 38

Anonymous
Not applicable
The solution you found is exactly what Tony said was the only way to do it. So all you have done is prove his point and made an even bigger fool of yourself.

Regards - Nathan
0 Likes
Message 29 of 38

Anonymous
Not applicable
no, he said it could be done without using the windows api or subclassing
and i'm saying that it can't.

wrote in message news:5436885@discussion.autodesk.com...
The solution you found is exactly what Tony said was the only way to do it.
So all you have done is prove his point and made an even bigger fool of
yourself.

Regards - Nathan
0 Likes
Message 30 of 38

Anonymous
Not applicable
So this whole tirade is because you misunderstood him.

Regards - Nathan
0 Likes
Message 31 of 38

Anonymous
Not applicable
i went back and re-read his original post and perhaps i did misread it.
tony, i apologize for exploding on you with back and forth posts.

Bob

wrote in message news:5436956@discussion.autodesk.com...
So this whole tirade is because you misunderstood him.

Regards - Nathan
0 Likes
Message 32 of 38

Anonymous
Not applicable
Stop posting code that is not yours; which
you did not write; which could not write; which
you do not have a clue about or understand;
and for which you are not crediting the original
source or author.

You're violating the forum rules; infringing on the
intellectual property rights of the original author;
and most importantly; You are fooling no one here,
Bobo.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message news:5436391@discussion.autodesk.com...
here is your second installment. enjoy!

Public Sub Hook()
'establish hook to capture messages to this window
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Unhook()
Dim temp As Long
'reset the message handler for this window
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim nmh As NMHDR
Dim nmhd As NMHEADER

Select Case uMsg
Case WM_NOTIFY
'fill the NMHDR struct from the lParam pointer.
'(for any WM_NOTIFY msg, lParam always points to a struct
'which is either the NMHDR struct, or whose 1st member is the
'NMHDR struct)
Call MoveMemory(nmh, ByVal lParam, Len(nmh))

'could combine HDN_BEGINTRACK
'and HDN_DIVIDERDBLCLICK into one
'(i.e.,Case HDN_BEGINTRACK, HDN_DIVIDERDBLCLICK:)
Select Case nmh.code
Case HDN_BEGINTRACK
'User began dragging a divider
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index you want to prevent
tracking.
'Note API is 0 based unlike ColumnHeaders collection which is 1
based.
Case 0
'ListView ColumnHeader Index 1 prevent tracking
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2 prevent tracking
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select

Case HDN_DIVIDERDBLCLICK
'user double clicked the divider area
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index
'you want to prevent resizing if the user double clicks on a
Column separator
'Note API is 0 based unlike ColumnHeaders collection which is 1
based
Case 0
'ListView ColumnHeader Index 1
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select
End Select
End Select

'Pass message on to the original window message handler
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Function


"Tony Tanzillo" wrote in message
news:5435599@discussion.autodesk.com...
Bobo....

Any idiot can copy commonly-used WinAPI
function import declarations that can be found
in thousands of places on the net and in books,
and paste them into a post here.

So, who do you think you're fooling?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5435528@discussion.autodesk.com...
yeah, i figured you didn't know. so i'll start educating you. here is your
first installment.
0 Likes
Message 33 of 38

Anonymous
Not applicable
yeah, yeah - you never give it a rest do you? what you meant to say was you
don't know what it does or how to write it. but since you don't know basic
then why would anyone be surprised?

that code has been written and re-written so many times and all the same
way, it's pathetic [much like you]. and unlike you, i'm not trying to fool
anyone ...

for the last time, moron, it's Bob - you're the bobo ...


"Tony Tanzillo" wrote in message
news:5437737@discussion.autodesk.com...
Stop posting code that is not yours; which
you did not write; which could not write; which
you do not have a clue about or understand;
and for which you are not crediting the original
source or author.

You're violating the forum rules; infringing on the
intellectual property rights of the original author;
and most importantly; You are fooling no one here,
Bobo.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5436391@discussion.autodesk.com...
here is your second installment. enjoy!

Public Sub Hook()
'establish hook to capture messages to this window
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Unhook()
Dim temp As Long
'reset the message handler for this window
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim nmh As NMHDR
Dim nmhd As NMHEADER

Select Case uMsg
Case WM_NOTIFY
'fill the NMHDR struct from the lParam pointer.
'(for any WM_NOTIFY msg, lParam always points to a struct
'which is either the NMHDR struct, or whose 1st member is the
'NMHDR struct)
Call MoveMemory(nmh, ByVal lParam, Len(nmh))

'could combine HDN_BEGINTRACK
'and HDN_DIVIDERDBLCLICK into one
'(i.e.,Case HDN_BEGINTRACK, HDN_DIVIDERDBLCLICK:)
Select Case nmh.code
Case HDN_BEGINTRACK
'User began dragging a divider
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index you want to prevent
tracking.
'Note API is 0 based unlike ColumnHeaders collection which is 1
based.
Case 0
'ListView ColumnHeader Index 1 prevent tracking
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2 prevent tracking
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select

Case HDN_DIVIDERDBLCLICK
'user double clicked the divider area
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index
'you want to prevent resizing if the user double clicks on a
Column separator
'Note API is 0 based unlike ColumnHeaders collection which is 1
based
Case 0
'ListView ColumnHeader Index 1
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select
End Select
End Select

'Pass message on to the original window message handler
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Function


"Tony Tanzillo" wrote in message
news:5435599@discussion.autodesk.com...
Bobo....

Any idiot can copy commonly-used WinAPI
function import declarations that can be found
in thousands of places on the net and in books,
and paste them into a post here.

So, who do you think you're fooling?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5435528@discussion.autodesk.com...
yeah, i figured you didn't know. so i'll start educating you. here is your
first installment.
0 Likes
Message 34 of 38

Anonymous
Not applicable
here is your final installment tony. i hope you have learned something ...

Private Sub Form_Load()
With ListView1
'start listview in upper left-hand corner
.Move 0, 0, ScaleWidth, ScaleHeight
'change the view style to report
.View = lvwReport
'add some columns to demonstrate
.ColumnHeaders.Add , , "Column1"
.ColumnHeaders.Add , , "Column2"
.ColumnHeaders.Add , , "Column3"
.ColumnHeaders.Add , , "Column4"
'store listview handle
gHW = .hwnd
End With

Hook
End Sub

Private Sub Form_Unload(Cancel As Integer)
Unhook
End Sub

oh, one final note ... thanks to everyone who has ever posted the code
contained in these lessons. although it has been written and re-written by
everyone and his first cousin i give each and everyoe of you credit [except
for tony].

Bob


"Tony Tanzillo" wrote in message
news:5437737@discussion.autodesk.com...
Stop posting code that is not yours; which
you did not write; which could not write; which
you do not have a clue about or understand;
and for which you are not crediting the original
source or author.

You're violating the forum rules; infringing on the
intellectual property rights of the original author;
and most importantly; You are fooling no one here,
Bobo.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5436391@discussion.autodesk.com...
here is your second installment. enjoy!

Public Sub Hook()
'establish hook to capture messages to this window
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Unhook()
Dim temp As Long
'reset the message handler for this window
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim nmh As NMHDR
Dim nmhd As NMHEADER

Select Case uMsg
Case WM_NOTIFY
'fill the NMHDR struct from the lParam pointer.
'(for any WM_NOTIFY msg, lParam always points to a struct
'which is either the NMHDR struct, or whose 1st member is the
'NMHDR struct)
Call MoveMemory(nmh, ByVal lParam, Len(nmh))

'could combine HDN_BEGINTRACK
'and HDN_DIVIDERDBLCLICK into one
'(i.e.,Case HDN_BEGINTRACK, HDN_DIVIDERDBLCLICK:)
Select Case nmh.code
Case HDN_BEGINTRACK
'User began dragging a divider
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index you want to prevent
tracking.
'Note API is 0 based unlike ColumnHeaders collection which is 1
based.
Case 0
'ListView ColumnHeader Index 1 prevent tracking
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2 prevent tracking
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select

Case HDN_DIVIDERDBLCLICK
'user double clicked the divider area
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index
'you want to prevent resizing if the user double clicks on a
Column separator
'Note API is 0 based unlike ColumnHeaders collection which is 1
based
Case 0
'ListView ColumnHeader Index 1
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select
End Select
End Select

'Pass message on to the original window message handler
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Function


"Tony Tanzillo" wrote in message
news:5435599@discussion.autodesk.com...
Bobo....

Any idiot can copy commonly-used WinAPI
function import declarations that can be found
in thousands of places on the net and in books,
and paste them into a post here.

So, who do you think you're fooling?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5435528@discussion.autodesk.com...
yeah, i figured you didn't know. so i'll start educating you. here is your
first installment.
0 Likes
Message 35 of 38

Anonymous
Not applicable
what a vile little attitude.

"Bob" wrote in message
news:5437927@discussion.autodesk.com...
here is your final installment tony. i hope you have learned something ...

Private Sub Form_Load()
With ListView1
'start listview in upper left-hand corner
.Move 0, 0, ScaleWidth, ScaleHeight
'change the view style to report
.View = lvwReport
'add some columns to demonstrate
.ColumnHeaders.Add , , "Column1"
.ColumnHeaders.Add , , "Column2"
.ColumnHeaders.Add , , "Column3"
.ColumnHeaders.Add , , "Column4"
'store listview handle
gHW = .hwnd
End With

Hook
End Sub

Private Sub Form_Unload(Cancel As Integer)
Unhook
End Sub

oh, one final note ... thanks to everyone who has ever posted the code
contained in these lessons. although it has been written and re-written by
everyone and his first cousin i give each and everyoe of you credit [except
for tony].

Bob


"Tony Tanzillo" wrote in message
news:5437737@discussion.autodesk.com...
Stop posting code that is not yours; which
you did not write; which could not write; which
you do not have a clue about or understand;
and for which you are not crediting the original
source or author.

You're violating the forum rules; infringing on the
intellectual property rights of the original author;
and most importantly; You are fooling no one here,
Bobo.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5436391@discussion.autodesk.com...
here is your second installment. enjoy!

Public Sub Hook()
'establish hook to capture messages to this window
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Unhook()
Dim temp As Long
'reset the message handler for this window
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim nmh As NMHDR
Dim nmhd As NMHEADER

Select Case uMsg
Case WM_NOTIFY
'fill the NMHDR struct from the lParam pointer.
'(for any WM_NOTIFY msg, lParam always points to a struct
'which is either the NMHDR struct, or whose 1st member is the
'NMHDR struct)
Call MoveMemory(nmh, ByVal lParam, Len(nmh))

'could combine HDN_BEGINTRACK
'and HDN_DIVIDERDBLCLICK into one
'(i.e.,Case HDN_BEGINTRACK, HDN_DIVIDERDBLCLICK:)
Select Case nmh.code
Case HDN_BEGINTRACK
'User began dragging a divider
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index you want to prevent
tracking.
'Note API is 0 based unlike ColumnHeaders collection which is 1
based.
Case 0
'ListView ColumnHeader Index 1 prevent tracking
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2 prevent tracking
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select

Case HDN_DIVIDERDBLCLICK
'user double clicked the divider area
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index
'you want to prevent resizing if the user double clicks on a
Column separator
'Note API is 0 based unlike ColumnHeaders collection which is 1
based
Case 0
'ListView ColumnHeader Index 1
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select
End Select
End Select

'Pass message on to the original window message handler
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Function


"Tony Tanzillo" wrote in message
news:5435599@discussion.autodesk.com...
Bobo....

Any idiot can copy commonly-used WinAPI
function import declarations that can be found
in thousands of places on the net and in books,
and paste them into a post here.

So, who do you think you're fooling?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5435528@discussion.autodesk.com...
yeah, i figured you didn't know. so i'll start educating you. here is your
first installment.
0 Likes
Message 36 of 38

Anonymous
Not applicable
yeah tony will appreciate you more if act just like him ...

"Kerry Brown" wrote in message
news:5437928@discussion.autodesk.com...
what a vile little attitude.

"Bob" wrote in message
news:5437927@discussion.autodesk.com...
here is your final installment tony. i hope you have learned something ...

Private Sub Form_Load()
With ListView1
'start listview in upper left-hand corner
.Move 0, 0, ScaleWidth, ScaleHeight
'change the view style to report
.View = lvwReport
'add some columns to demonstrate
.ColumnHeaders.Add , , "Column1"
.ColumnHeaders.Add , , "Column2"
.ColumnHeaders.Add , , "Column3"
.ColumnHeaders.Add , , "Column4"
'store listview handle
gHW = .hwnd
End With

Hook
End Sub

Private Sub Form_Unload(Cancel As Integer)
Unhook
End Sub

oh, one final note ... thanks to everyone who has ever posted the code
contained in these lessons. although it has been written and re-written by
everyone and his first cousin i give each and everyoe of you credit [except
for tony].

Bob


"Tony Tanzillo" wrote in message
news:5437737@discussion.autodesk.com...
Stop posting code that is not yours; which
you did not write; which could not write; which
you do not have a clue about or understand;
and for which you are not crediting the original
source or author.

You're violating the forum rules; infringing on the
intellectual property rights of the original author;
and most importantly; You are fooling no one here,
Bobo.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5436391@discussion.autodesk.com...
here is your second installment. enjoy!

Public Sub Hook()
'establish hook to capture messages to this window
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Unhook()
Dim temp As Long
'reset the message handler for this window
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim nmh As NMHDR
Dim nmhd As NMHEADER

Select Case uMsg
Case WM_NOTIFY
'fill the NMHDR struct from the lParam pointer.
'(for any WM_NOTIFY msg, lParam always points to a struct
'which is either the NMHDR struct, or whose 1st member is the
'NMHDR struct)
Call MoveMemory(nmh, ByVal lParam, Len(nmh))

'could combine HDN_BEGINTRACK
'and HDN_DIVIDERDBLCLICK into one
'(i.e.,Case HDN_BEGINTRACK, HDN_DIVIDERDBLCLICK:)
Select Case nmh.code
Case HDN_BEGINTRACK
'User began dragging a divider
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index you want to prevent
tracking.
'Note API is 0 based unlike ColumnHeaders collection which is 1
based.
Case 0
'ListView ColumnHeader Index 1 prevent tracking
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2 prevent tracking
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select

Case HDN_DIVIDERDBLCLICK
'user double clicked the divider area
Call MoveMemory(nmhd, ByVal lParam, Len(nmhd))

Select Case nmhd.iItem
'Select Case ListView ColumnHeader Index
'you want to prevent resizing if the user double clicks on a
Column separator
'Note API is 0 based unlike ColumnHeaders collection which is 1
based
Case 0
'ListView ColumnHeader Index 1
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case 1
'ListView ColumnHeader Index 2
'prevent resizing if the user double clicks on a Column
separator
WindowProc = 1
Exit Function

Case Else
'other ColumnHeaders allow resizing

End Select
End Select
End Select

'Pass message on to the original window message handler
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Function


"Tony Tanzillo" wrote in message
news:5435599@discussion.autodesk.com...
Bobo....

Any idiot can copy commonly-used WinAPI
function import declarations that can be found
in thousands of places on the net and in books,
and paste them into a post here.

So, who do you think you're fooling?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Bob" wrote in message
news:5435528@discussion.autodesk.com...
yeah, i figured you didn't know. so i'll start educating you. here is your
first installment.
0 Likes
Message 37 of 38

Anonymous
Not applicable
"Bob" wrote

>> no, he said it could be done without using the
>> windows api or subclassing and i'm saying that it can't.

Bobo....

Not only are you incompetent with regards to
programming, you can't read either.

You couldn't be more wrong, Bobo...

I said that the only way to do it was with the
Windows API and subclassing.

And yes, thanks for posting the plagurized code
you didn't and couldn't write yourself, to prove
my point.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com
0 Likes
Message 38 of 38

Anonymous
Not applicable
An tony o ...

then read this ...

you are such a dumb a$$ ... you make assumptions you have no idea about. i
never said that i wrote the code idiot, i only posted it for your ignorant
and arrogant a$$ ... so now who can't read?

if you had half the brains you think you have, you still would have nothing.

chances are you don't even know how to use it inside a vb app!!!

Bob


"Tony Tanzillo" wrote in message
news:5438054@discussion.autodesk.com...
"Bob" wrote

>> no, he said it could be done without using the
>> windows api or subclassing and i'm saying that it can't.

Bobo....

Not only are you incompetent with regards to
programming, you can't read either.

You couldn't be more wrong, Bobo...

I said that the only way to do it was with the
Windows API and subclassing.

And yes, thanks for posting the plagurized code
you didn't and couldn't write yourself, to prove
my point.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com
0 Likes