Click here to Skip to main content
15,922,533 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# with Mac OS-X Pin
robi@robisoft.it24-Oct-03 21:44
robi@robisoft.it24-Oct-03 21:44 
GeneralRe: C# with Mac OS-X Pin
leppie24-Oct-03 22:02
leppie24-Oct-03 22:02 
GeneralDataGrid Columns Pin
Mazdak23-Oct-03 0:26
Mazdak23-Oct-03 0:26 
GeneralRe: DataGrid Columns Pin
Ryan_Roberts23-Oct-03 3:06
Ryan_Roberts23-Oct-03 3:06 
GeneralCustom Rich Edit Box Pin
SaeidehV23-Oct-03 0:12
SaeidehV23-Oct-03 0:12 
GeneralForm opacity Pin
Georgi Atanasov22-Oct-03 23:57
Georgi Atanasov22-Oct-03 23:57 
Generalprinting Pin
brain2cpu22-Oct-03 23:33
professionalbrain2cpu22-Oct-03 23:33 
GeneralUpdating Database Pin
Mazdak22-Oct-03 20:20
Mazdak22-Oct-03 20:20 
GeneralA question for the GURUs Pin
Anonymous22-Oct-03 20:13
Anonymous22-Oct-03 20:13 
GeneralRe: A question for the GURUs Pin
bjoernen22-Oct-03 22:06
bjoernen22-Oct-03 22:06 
GeneralChildWindow.Callback and NullReferenceException Pin
Anonymous22-Oct-03 19:37
Anonymous22-Oct-03 19:37 
GeneralRe: ChildWindow.Callback and NullReferenceException Pin
Guillermo Rivero23-Oct-03 4:32
Guillermo Rivero23-Oct-03 4:32 
GeneralRetrieving Table Cell Style from a Word Table using C# Pin
moriancumur22-Oct-03 18:20
moriancumur22-Oct-03 18:20 
GeneralRe: Retrieving Table Cell Style from a Word Table using C# Pin
Edbert P22-Oct-03 20:58
Edbert P22-Oct-03 20:58 
QuestionConverting a 20-page pdf to 20 single page pdf? Pin
NotProfessional22-Oct-03 15:00
NotProfessional22-Oct-03 15:00 
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 

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.