Click here to Skip to main content
15,902,786 members
Home / Discussions / C#
   

C#

 
AnswerRe: Converting a 20-page pdf to 20 single page pdf? Pin
leppie23-Oct-03 9:17
leppie23-Oct-03 9:17 
GeneralRe: Converting a 20-page pdf to 20 single page pdf? Pin
mistery2225-Oct-03 3:20
mistery2225-Oct-03 3:20 
Generalprint page number, header and footer Pin
hkl22-Oct-03 14:33
hkl22-Oct-03 14:33 
GeneralSorting Pin
totig22-Oct-03 11:04
totig22-Oct-03 11:04 
GeneralRe: Sorting Pin
ankita patel22-Oct-03 11:25
ankita patel22-Oct-03 11:25 
GeneralRe: Sorting Pin
bjoernen22-Oct-03 22:11
bjoernen22-Oct-03 22:11 
GeneralOverlay Icons in ListView Pin
Heath Stewart22-Oct-03 9:47
protectorHeath Stewart22-Oct-03 9:47 
GeneralRe: Overlay Icons in ListView Pin
Stephane Rodriguez.22-Oct-03 12:11
Stephane Rodriguez.22-Oct-03 12:11 
Heath Stewart wrote:
I want to expose this functionality in a ".NET-like" manner.

You can derive the ListView class, or the ListViewItem class. I would also consider implementing IExtenderProvider instead since winforms are by design a bit cloaked. Nice article from Esposito in this month's MSDN mag.


Heath Stewart wrote:
So, the docs say to use ImageList_SetOverlayImage. What exactly is this doing? I give it a handle to the ImageList (no problem there), a 0-based index to an image (?) and a 1-based index to an overlay mask (?).

Looks odd but you don't have to mind. The function creates a new image in the image list by taking the passed image index, applying transparent background to it and have that image ready to use. Any time this masked image has to be used, you need to pass his index to the ImageList_Draw method (which you don't actually do if you are using a listview where you have already attached an image list ; things would be nicely taken care of in due time), and since you don't know the index of this masked image, you have to use a macro : INDEXTOOVERLAYMASK(i), where i is the index of the original non-masked image.

From your point of view, you end up creating a list view, attaching an image list to it, and then explicitely setting an overlay image to an arbitrary list view item by setting the item state. Basically with C# you would use the ListView.SetItemState(int nIndex, int nState) method, unfortunately it's internal. I think you are better off sending a Windows message instead, which is anyway what ListView.SetItemState does in the end.

// sequential layout
struct LVITEM
{
... // TODO : setup the struct
}

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);

public const int LVM_SETITEMSTATE = 4139;
// in listview report mode only
SendMessage(listview1.Handle, LVM_SETITEMSTATE, nIndex, lvitem);


To set the overlay image, you need to appropriately fill the state field in the LVITEM structure. Only bits 8-11 are useful for the overlay. Again, the INDEXTOOVERLAYMASK macro found in commctrl.h does all this dirty bit work.

Finally, regarding overlay images, they are images that are drawn on top of item images. They differ with item images in that overlay images are masked images, i.e. a mask is applied to filter out all background color first (the color is defined when the imagelist is created).

Hope this helps.







  RSS feed
GeneralRe: Overlay Icons in ListView Pin
Heath Stewart22-Oct-03 12:20
protectorHeath Stewart22-Oct-03 12:20 
GeneralRe: Overlay Icons in ListView Pin
Heath Stewart22-Oct-03 12:44
protectorHeath Stewart22-Oct-03 12:44 
GeneralColumn Name wrapping in Listview ! Pin
pahluwalia22-Oct-03 8:19
pahluwalia22-Oct-03 8:19 
GeneralRe: Column Name wrapping in Listview ! Pin
Heath Stewart22-Oct-03 9:40
protectorHeath Stewart22-Oct-03 9:40 
GeneralRe: Column Name wrapping in Listview ! Pin
pahluwalia22-Oct-03 10:26
pahluwalia22-Oct-03 10:26 
GeneralRe: Column Name wrapping in Listview ! Pin
Heath Stewart22-Oct-03 10:29
protectorHeath Stewart22-Oct-03 10:29 
GeneralRe: Column Name wrapping in Listview ! Pin
Stephane Rodriguez.22-Oct-03 11:50
Stephane Rodriguez.22-Oct-03 11:50 
GeneralSimplest of Things are Hard Pin
antoine@orchus-tech22-Oct-03 6:35
antoine@orchus-tech22-Oct-03 6:35 
GeneralRe: Simplest of Things are Hard Pin
leppie22-Oct-03 7:02
leppie22-Oct-03 7:02 
GeneralRe: Simplest of Things are Hard Pin
Philip Fitzsimons22-Oct-03 7:57
Philip Fitzsimons22-Oct-03 7:57 
GeneralRe: Simplest of Things are Hard Pin
antoine@orchus-tech22-Oct-03 18:36
antoine@orchus-tech22-Oct-03 18:36 
GeneralRe: Simplest of Things are Hard Pin
antoine@orchus-tech23-Oct-03 9:49
antoine@orchus-tech23-Oct-03 9:49 
GeneralIcon for EXE file Pin
Khang Nguyen22-Oct-03 6:12
Khang Nguyen22-Oct-03 6:12 
GeneralRe: Icon for EXE file Pin
Daniel M. Edwards22-Oct-03 8:33
Daniel M. Edwards22-Oct-03 8:33 
GeneralRe: Icon for EXE file Pin
Khang Nguyen22-Oct-03 9:31
Khang Nguyen22-Oct-03 9:31 
QuestionCreating Event ID's for Eventlog ? Pin
LongRange.Shooter22-Oct-03 6:11
LongRange.Shooter22-Oct-03 6:11 
GeneralCombobox index Pin
Mike Osbahr22-Oct-03 4:56
Mike Osbahr22-Oct-03 4:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.