Hi Konrad,
The BackgroundImage does not take effect for ListView, as a work around
you may draw the Background Image
via the LVM_SETBKIMAGE Message, here is a code snippet.
If you still have problems on this issue, please be free to let me know!
Thanks for using MSDN Newsgroup!
<code>
[DllImport("ole32.dll")]
public extern static void CoUninitialize();
[DllImport("ole32.dll")]
public extern static int CoInitialize(int pReserved);
[DllImport("user32.dll")]
public extern static int SendMessage(IntPtr hwnd, uint msg, uint wParam,
uint lParam);
[DllImport("user32.dll")]
public extern static int SendMessage(IntPtr hwnd, uint msg, uint wParam,
LVBKIMAGE lParam);
private const int NOERROR = 0x0;
private const int S_OK = 0x0;
private const int S_FALSE = 0x1;
private const int LVM_FIRST = 0x1000;
private const int LVM_SETBKIMAGE = LVM_FIRST + 68;
private const int LVM_SETTEXTBKCOLOR = LVM_FIRST + 38;
private const int LVBKIF_SOURCE_URL = 0x02;
private const int LVBKIF_STYLE_TILE = 0x10;
private const uint CLR_NONE = 0xFFFFFFFF;
[StructLayout(LayoutKind.Sequential)]
public class LVBKIMAGE
{
public int ulFlags;
public IntPtr hbm;
public string pszImage;
public int cchImageMax;
public int xOffsetPercent;
public int yOffsetPercent;
}
void SetBackground()
{
string bkImgFile = @"C:\CoughDrop.JPG";
LVBKIMAGE tLBI = new LVBKIMAGE();
tLBI.pszImage = bkImgFile;
tLBI.cchImageMax = bkImgFile.Length + 1;
tLBI.ulFlags = LVBKIF_SOURCE_URL | LVBKIF_STYLE_TILE;
SendMessage(listView1.Handle, LVM_SETBKIMAGE,0,tLBI);
int res = SendMessage(this.listView1.Handle
,LVM_SETTEXTBKCOLOR,0,CLR_NONE);
}
</code>
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
--------------------
| From: "Konrad" <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Subject: ListView BackgroundImage
| Date: Mon, 6 Oct 2003 05:31:38 +0200
| Organization: tp.internet -
http://www.tpi.pl/
| Lines: 11
| Message-ID: <
[email protected]>
| NNTP-Posting-Host: pj12.szczecin.sdi.tpnet.pl
| X-Trace: atlantis.news.tpi.pl 1065411118 23239 217.98.201.12 (6 Oct 2003
03:31:58 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Mon, 6 Oct 2003 03:31:58 +0000 (UTC)
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!newsfee
d01.sul.t-online.de!t-online.de!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!
news.tpi.pl!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:53782
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Hi
|
| I'am trying to use BackgroundImage property
| of ListView but it doesn't work.
| Can you point me how to use it?
|
| Thanks
| Konrad
|
|
|
|