public static void SetVistaExplorerStyle(this TreeView tv, bool fadeoutExpandos, bool showTreeLines) { if (IsWindowsVistaOrLater) { NativeApi.SetWindowTheme(tv.Handle, NativeApi.UX_EXPLORER, null); if (fadeoutExpandos) { NativeApi.SendMessage(tv.Handle, NativeApi.TVM_SETEXTENDEDSTYLE, 0, NativeApi.TVS_EX_FADEINOUTEXPANDOS); } tv.ShowLines = showTreeLines; } }
void SetBackground( ) { IntPtr hBmp = GetBitmap(this.WatermarkImage); NativeApi.LVBKIMAGE lv = new NativeApi.LVBKIMAGE( ); lv.hbm = hBmp; lv.ulFlags = /*NativeApi.LVBKIF_SOURCE_URL | NativeApi.LVBKIF_STYLE_TILE | */ NativeApi.LVBKIF_TYPE_WATERMARK; IntPtr lvPTR = Marshal.AllocCoTaskMem(Marshal.SizeOf(lv)); Marshal.StructureToPtr(lv, lvPTR, false); /*NativeApi.SendMessage ( this.Handle, NativeApi.LVM_SETBKIMAGE, 0, lvPTR );*/ NativeApi.SendMessage(this.Handle, NativeApi.LVM_SETBKIMAGEW, 0, lvPTR); NativeApi.SendMessage(this.Handle, NativeApi.LVM_SETTEXTBKCOLOR, 0, NativeApi.CLR_NONE); Marshal.FreeCoTaskMem(lvPTR); }