تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
استدعاء method تقوم باضافة ظل للفورم
#1
السلام عليكم 

لدي كود يقوم باضافة ظل للفورم ، حاولت ان احولة ل class اقوم باستدعائة عند الحاجة 
لكن طهر لي مشاكل.
احتاج لجعل هذا الكود في class لاستدعائة عند الحاجة 

الكود :

PHP كود :
/***********************************************************************/
 
       //                          SHADOW FORM START
 
       /***********************************************************************/

 
       [DllImport("Gdi32.dll"EntryPoint "CreateRoundRectRgn")]
 
       private static extern IntPtr CreateRoundRectRgn
        
(
 
       int nLeftRect// x-coordinate of upper-left corner
 
       int nTopRect// y-coordinate of upper-left corner
 
       int nRightRect// x-coordinate of lower-right corner
 
       int nBottomRect// y-coordinate of lower-right corner
 
       int nWidthEllipse// height of ellipse
 
       int nHeightEllipse // width of ellipse
 
       );

 
       [DllImport("dwmapi.dll")]
 
       public static extern int DwmExtendFrameIntoClientArea(IntPtr hWndref MARGINS pMarInset);

 
       [DllImport("dwmapi.dll")]
 
       public static extern int DwmSetWindowAttribute(IntPtr hwndint attrref int attrValueint attrSize);

 
       [DllImport("dwmapi.dll")]
 
       public static extern int DwmIsCompositionEnabled(ref int pfEnabled);

 
       private bool m_aeroEnabled                    // variables for box shadow
 
       private const int CS_DROPSHADOW 0x00020000;
 
       private const int WM_NCPAINT 0x0085;
 
       private const int WM_ACTIVATEAPP 0x001C;

 
       public struct MARGINS                           // struct for box shadow
 
       {
 
           public int leftWidth;
 
           public int rightWidth;
 
           public int topHeight;
 
           public int bottomHeight;
 
       }

 
       private const int WM_NCHITTEST 0x84         // variables for dragging the form
 
       private const int HTCLIENT 0x1;
 
       private const int HTCAPTION 0x2;

 
       protected override CreateParams CreateParams
        
{
 
           get
            
{
 
               m_aeroEnabled CheckAeroEnabled();

 
               CreateParams cp base.CreateParams;
 
               if (!m_aeroEnabled)
 
                   cp.ClassStyle |= CS_DROPSHADOW;

 
               return cp;
 
           }
 
       }

 
       private bool CheckAeroEnabled()
 
       {
 
           if (Environment.OSVersion.Version.Major >= 6)
 
           {
 
               int enabled 0;
 
               DwmIsCompositionEnabled(ref enabled);
 
               return (enabled == 1) ? true false;
 
           }
 
           return false;
 
       }

 
       protected override void WndProc(ref Message m)
 
       {
 
           switch (m.Msg)
 
           {
 
               case WM_NCPAINT                       // box shadow
 
                   if (m_aeroEnabled)
 
                   {
 
                       var v 2;
 
                       DwmSetWindowAttribute(this.Handle2ref v4);
 
                       MARGINS margins = new MARGINS()
 
                       {
 
                           bottomHeight 1,
 
                           leftWidth 1,
 
                           rightWidth 1,
 
                           topHeight 1
                        
};
 
                       DwmExtendFrameIntoClientArea(this.Handleref margins);

 
                   }
 
                   break;
 
               default:
 
                   break;
 
           }
 
           base.WndProc(ref m);

 
           if (m.Msg == WM_NCHITTEST && (int)m.Result == HTCLIENT    // drag the form
 
               m.Result = (IntPtr)HTCAPTION;

 
       }
 
       /***********************************************************************/
 
       //                          SHADOW FORM END
 
       /***********************************************************************/ 

الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
استدعاء method تقوم باضافة ظل للفورم - بواسطة Rabeea Qbaha - 03-10-19, 10:45 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  استفسار باضافة الاجازة السنوية بالهجري samer1402 0 649 17-05-23, 02:32 PM
آخر رد: samer1402
  [سؤال] استفسار عنطريقة استدعاء الفورم باكتر من شكل Abo_Hegab 4 1,693 02-12-21, 12:44 PM
آخر رد: Abo_Hegab
  [C#.NET] اريد استدعاء كود من ملف نصي الى حدث بتون محمد جلال 1 1,555 12-08-21, 04:20 PM
آخر رد: Eng27
  مشكلة في إستدعاء Method maxruined 7 2,406 01-12-20, 01:38 PM
آخر رد: maxruined
  دالة تقوم بترقيم السجلات حسب السنة الهجرية علي كعبي 15 4,704 19-06-20, 07:06 PM
آخر رد: علي كعبي
  طلب مساعدة في انشاء استدعاء بيانات من قاعدة اكسس العريفي 0 1,462 31-08-19, 01:45 PM
آخر رد: العريفي
  [C#.NET] مناداه method موجودة في ال user control من ال main form Rabeea Qbaha 13 5,964 19-03-19, 04:48 AM
آخر رد: Rabeea Qbaha
  تحديث بيانات ال datadridview من فورم اخر ( استدعاء ميثود من فورم اخر) Rabeea Qbaha 1 2,304 14-02-19, 09:00 AM
آخر رد: أحمد النجار
  [C#.NET] method ترجع قيمتين نعيم 3 1,855 10-12-18, 10:56 PM
آخر رد: نعيم
  محتاج مساعده فى اكواد استدعاء صنف الى الداتا جريد فيو فقط ghost 4 2,845 28-05-18, 11:02 PM
آخر رد: ghost

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم