Macro - Draggable borderless form.

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Macro - Draggable borderless form.

Postby kig23 » Mon Apr 16, 2018 2:07 pm

Here is an example of how to create draggable borderless form.

Code: Select all
Button myButton = new Button ();
myButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(211)))), ((int)(((byte)(87)))), ((int)(((byte)(40)))));
myButton.FlatAppearance.BorderSize = 0;
myButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
myButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(52)))), ((int)(((byte)(63)))));
myButton.Location = new System.Drawing.Point(105, 197);
myButton.Size = new System.Drawing.Size(75, 23);
myButton.TabIndex = 0;
myButton.Text = "Close";
myButton.UseVisualStyleBackColor = false;
myButton.Click += new System.EventHandler(myButton_Click);

myForm = new Form ();
myForm.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(73)))), ((int)(((byte)(94)))));
myForm.ClientSize = new System.Drawing.Size(284, 261);
myForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
myForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
myForm.MouseDown += new System.Windows.Forms.MouseEventHandler(myForm_MouseDown);
myForm.MouseMove += new System.Windows.Forms.MouseEventHandler(myForm_MouseMove);
myForm.Controls.Add(myButton);
myForm.ResumeLayout(false);
myForm.BringToFront();
myForm.ShowDialog (exec.mainform);

#Events

Form myForm;

public Point mouseLocation;

private void myForm_MouseDown(object sender, MouseEventArgs e)
{
   mouseLocation = new Point(-e.X, -e.Y);
}

private void myForm_MouseMove(object sender, MouseEventArgs e)
{
   if (e.Button == MouseButtons.Left)
   {
      Point mousePos = Control.MousePosition;
      mousePos.Offset(mouseLocation.X, mouseLocation.Y);
      myForm.Location = mousePos;
   }
}

private void myButton_Click(object sender, EventArgs e)
{
   myForm.Close();
}
kig23
 
Posts: 114
Joined: Sat Mar 31, 2018 6:58 am
Location: Italy

Re: Macro - Draggable borderless form.

Postby Vmax549 » Mon Apr 16, 2018 3:22 pm

VERY interesting :P

Thank you for the example code.

(;-) TP
Vmax549
 
Posts: 1274
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Macro - Draggable borderless form.

Postby kig23 » Mon Apr 16, 2018 3:27 pm

You're welcome.
kig23
 
Posts: 114
Joined: Sat Mar 31, 2018 6:58 am
Location: Italy


Return to Macros

Who is online

Users browsing this forum: No registered users and 2 guests