Exemplo n.º 1
0
 private void OnCustomDraw(ref NMTBCUSTOMDRAW customDraw, ref Message m)
 {
     if (customDraw.hdr.dwDrawStage == Win32Declarations.CDDS_PREPAINT)
     {
         using (Graphics g = Graphics.FromHdc(customDraw.hdr.hdc))
         {
             Rectangle rect = Win32Declarations.RECTToRectangle(customDraw.hdr.rc);
             g.FillRectangle(_backBrush, rect);
             if (PaintBackground != null)
             {
                 PaintBackground(this, new PaintEventArgs(g, rect));
             }
         }
         m.Result = (IntPtr)Win32Declarations.CDRF_DODEFAULT;
     }
 }
Exemplo n.º 2
0
 protected override void WndProc(ref Message m)
 {
     base.WndProc(ref m);
     try
     {
         if (m.Msg == Win32Declarations.OCM_NOTIFY)
         {
             NMHDR hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR));
             if (hdr.hwndFrom == Handle)
             {
                 if (hdr.code == Win32Declarations.NM_CUSTOMDRAW)
                 {
                     NMTBCUSTOMDRAW customDraw = (NMTBCUSTOMDRAW)Marshal.PtrToStructure(m.LParam, typeof(NMTBCUSTOMDRAW));
                     OnCustomDraw(ref customDraw, ref m);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Core.ReportBackgroundException(ex);
     }
 }