473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

ListView images in header (sort indicator) -- converted code from vb6 not working


I'm trying to put icons in the header of my ListView. All the .net
posts I found refer to an example on thecodeproject which is no longer
there (part of commercial package now).

I converted the code I used in VB6 which all appears to run ok but
doesn't actually create the images ever. These are generic functions
to set the images for any listview.

Please help,

Thanks,

Sam
' Win32 is a custom class that has the necessary Win32 constants,
structures, and function declarations

Public Sub ListViewSetHeaderImages(ByVal lvw As ListView, ByVal
images As ImageList)
Dim headerHandle As IntPtr = Win32.SendMessage(lvw.Handle,
Win32.LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero)
Win32.SendMessage(headerHandle, Win32.HDM_SETIMAGELIST,
IntPtr.Zero, images.Handle)
End Sub

Public Sub ListViewSetHeaderIcon(ByVal lvw As ListView, ByVal
headerText As String, ByVal columnIndex As Integer, ByVal imageIndex
As Integer)

Dim headerHandle As IntPtr
Dim HD As New Win32.HDITEM

headerHandle = Win32.SendMessage(lvw.Handle,
Win32.LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero)

With HD
.mask = Win32.HDI_IMAGE Or Win32.HDI_FORMAT
.pszText = headerText
.fmt = Win32.HDF_STRING Or Win32.HDF_IMAGE Or
Win32.HDF_BITMAP_ON_RIGHT
.iImage = imageIndex
End With

Win32.SendMessage(headerHandle, Win32.HDM_SETITEM, columnIndex,
HD)

End Sub

Private Sub ListViewRemoveHeaderIcon(ByVal lvw As ListView, ByVal
columnIndex As Integer)
Dim headerHandle As IntPtr
Dim hdHeader As New Win32.HDITEM

headerHandle = Win32.SendMessage(lvw.Handle,
Win32.LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero)

hdHeader.mask = Win32.HDI_FORMAT
hdHeader.fmt = hdHeader.fmt Or Win32.HDF_STRING
Win32.SendMessage(headerHandle, Win32.HDM_SETITEM, columnIndex,
hdHeader)

End Sub

Nov 21 '05 #1
6 6827
"Samuel R. Neff" <sr********@spampleasespeakeasy.net> schrieb:
I'm trying to put icons in the header of my ListView. All the .net
posts I found refer to an example on thecodeproject which is no longer
there (part of commercial package now).


Customizing the header control in a ListView
<URL:http://www.codeproject.com/cs/miscctrl/customheader.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
"Samuel R. Neff" <sr********@spampleasespeakeasy.net> schrieb:
I'm trying to put icons in the header of my ListView. All the .net
posts I found refer to an example on thecodeproject which is no longer
there (part of commercial package now).


Customizing the header control in a ListView
<URL:http://www.codeproject.com/cs/miscctrl/customheader.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

That example does a lot more than just put images in the headers. It
takes over creation and drawing of the columns and seems to have a lot
more overhead than is necessary for the task (it does more than what I
and most people asking the question want). I'm looking for something
much smaller.

Really, the VB6 converted code I posted should work--I'm not sure why
it doesn't. It's just SendMessage calls.

Sam
On Tue, 7 Dec 2004 19:08:06 +0100, "Herfried K. Wagner [MVP]"
<hi***************@gmx.at> wrote:
"Samuel R. Neff" <sr********@spampleasespeakeasy.net> schrieb:
I'm trying to put icons in the header of my ListView. All the .net
posts I found refer to an example on thecodeproject which is no longer
there (part of commercial package now).


Customizing the header control in a ListView
<URL:http://www.codeproject.com/cs/miscctrl/customheader.asp>


Nov 21 '05 #4

That example does a lot more than just put images in the headers. It
takes over creation and drawing of the columns and seems to have a lot
more overhead than is necessary for the task (it does more than what I
and most people asking the question want). I'm looking for something
much smaller.

Really, the VB6 converted code I posted should work--I'm not sure why
it doesn't. It's just SendMessage calls.

Sam
On Tue, 7 Dec 2004 19:08:06 +0100, "Herfried K. Wagner [MVP]"
<hi***************@gmx.at> wrote:
"Samuel R. Neff" <sr********@spampleasespeakeasy.net> schrieb:
I'm trying to put icons in the header of my ListView. All the .net
posts I found refer to an example on thecodeproject which is no longer
there (part of commercial package now).


Customizing the header control in a ListView
<URL:http://www.codeproject.com/cs/miscctrl/customheader.asp>


Nov 21 '05 #5
Found the problem. The functions I posted actually do work as
intended--as only as the Win32 declarations are correct. :-)

I had copied the Win32 declarations from the other project posted,
after automatically converting from C# to VB.NET. The converter
reorded the members alphabetically including the structure members
(which is really bad sine they were even marked as sequential). After
I recreated the Win32 type declaration for HDITEM the helper functions
for setting the image worked fine.

Sam

Nov 21 '05 #6
Found the problem. The functions I posted actually do work as
intended--as only as the Win32 declarations are correct. :-)

I had copied the Win32 declarations from the other project posted,
after automatically converting from C# to VB.NET. The converter
reorded the members alphabetically including the structure members
(which is really bad sine they were even marked as sequential). After
I recreated the Win32 type declaration for HDITEM the helper functions
for setting the image worked fine.

Sam

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve | last post by:
I have windows form with ListView control. The ListView control has few columns which user can sort by clicking the column header. I want the column header have the small triangle indicator of...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
6
by: ReMEn | last post by:
My question is this: How can I apply some kind of a function to a listview that allows it to sort by both string and numbers whenever a header is clicked? For example: -------------------...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
1
by: Mamatha | last post by:
Hi I have one application ,that diplays data from database into the listview control.While adding data to the listview i want to display an icon to the leftside of the first column's data.Here...
0
by: Samuel R. Neff | last post by:
I'm trying to put icons in the header of my ListView. All the .net posts I found refer to an example on thecodeproject which is no longer there (part of commercial package now). I converted the...
11
by: Alan T | last post by:
Does the ListView supports sort? I want to have a up/down arrow/triangle that show it is sorted asc or desc on the column headers when I click the column header. May be I need a third-party...
1
by: --== Alain ==-- | last post by:
Hi, I'm still working with my ListView custom control and i would like to have some confirmation and help. 1. If i understood well the OnPaint event is never thrown to ListView control ? I...
0
by: bharathreddy | last post by:
Hi All, I am using a listview control in my usercontrol so that it can be used in more than one form. This user control has one column extraw, so i want to make it invisible depending on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.