Advertisement
Yassine_Abbani

Costume [Drag Control], [Custome Control]

May 23rd, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.67 KB | None | 0 0
  1.      #region Directives
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Runtime.InteropServices;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. #endregion
  11.      #region Browse
  12. /* Copyright & Contact
  13. * --------------------------------------------------------------------------------<
  14. * Tool Name    : Drag Control                                                     *
  15. * From Project : Creator Eye                                                      *
  16. * Project Lang : C#                                                               *
  17. * Creator      : Yassine Abbani                                                   *
  18. * Facebook     : https://www.facebook.com/YassineAbbani.user                      *
  19. * Pastebin     : https://pastebin.com/u/Yassine_Abbani                            *
  20. * Youtube      : https://www.youtube.com/channel/UCqvOCRs3HWbPH4yuZuTx8mw         *
  21. * Version      : 1.0 Beta                                                         *
  22. *>--------------------------------------------------------------------------------<
  23. */
  24. /* Features
  25. * ------------------------
  26. *   Custom Properties:
  27.  *  Select control > Get select a panel into drag control Properties and start your project then move (that panel) where you want.
  28. */
  29. /*  history
  30. * ------------------------
  31. * 1.0 (23 May 2018):
  32.  * In my Source Code Get Drag Control Component code and use it at your project to drag any panel to any location you want.
  33. *
  34. */
  35. #endregion
  36.      #region DragControl
  37. class Ce_DragControl : Component
  38. {
  39.     #region Variables
  40.     private Control handleControl;
  41.     #endregion
  42.     #region Properties
  43.     public Control SelectControl
  44.         {
  45.             get
  46.             {
  47.                 return this.handleControl;
  48.             }
  49.             set
  50.             {
  51.                 this.handleControl = value;
  52.                 this.handleControl.MouseDown += new MouseEventHandler(this.DragForm_MouseDown);
  53.             }
  54.         }
  55.     #endregion
  56.     #region Method
  57.         [DllImport("user32.dll")]
  58.         public static extern int SendMessage(IntPtr a, int msg, int wParam,int lParam);
  59.         [DllImport("user32.dll")]
  60.         public static extern bool ReleaseCapture();
  61.     #endregion
  62.     #region Event Method
  63.         private void DragForm_MouseDown(object sender, MouseEventArgs e)
  64.         {
  65.             bool flage = e.Button == MouseButtons.Left;
  66.             if (flage)
  67.             {
  68.                 Ce_DragControl.ReleaseCapture();
  69.                 Ce_DragControl.SendMessage(this.SelectControl.FindForm().Handle,161,2,0);
  70.             }
  71.         }
  72.         #endregion
  73. }
  74. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement