You've probably noticed that some of the applications on Pocket
PC 2003 and SmartPhones have
this fancy looking gradient background. In all these cases it looks like a system
list view control have been used... A quick search through a PPC 2003 SDK returns
this result in the List View Styles: "LVS_EX_GRADIENT Draws a background
with a gradient. " Bingo! We're almost there. We know that ListView control in
Compact Framework is just a wrapper for a native one, so here is the code that'll
do the job:
//Some PInvokes and constants
[DllImport("coredll.dll")]
public static extern IntPtr GetCapture();
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
const int LVS_EX_GRADIENT = 0x20000000;
const int LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1000 + 54;
private void SetGradient(ListView listView)
{
//Get a list view handle
listView.Capture = true;
IntPtr hList = GetCapture();
//Apply extended style
SendMessage(hList, (uint)LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
LVS_EX_GRADIENT);
listView.Capture = false;
listView.Refresh();
}