Borderless forms and background creation controls

Source: Internet
Author: User

1. No Border form

Minimizing the Maximize Close button does not necessarily have to be done with a button,

You can use the picture to write the event, plus the mouse move in the move out click to operate

mouseenter-events that occur when the mouse is moved in

private void Picturebox1_mouseenter (object sender, EventArgs e)        {            picturebox1.backgroundimage = Image.FromFile (Application.startuppath + "\ \". \\.. \\images\\btn_close_highlight.png ");        }

mouseleave-events that occur when the mouse is moved out

private void Picturebox1_mouseleave (object sender, EventArgs e)        {            picturebox1.backgroundimage = Image.FromFile (Application.startuppath + "\ \". \\.. \\images\\btn_close_disable.png ");        }

mousedown-events that occur when the mouse is pressed

The picture that is displayed when the mouse is pressed        private void Picturebox1_mousedown (object sender, MouseEventArgs e)        {            Picturebox1.backgroundimage = Image.FromFile (application.startuppath + "\ \". \\.. \\images\\btn_close_down.png ");        }


A borderless form sets the FormBorderStyle property to None

How to get the relative path of a picture:

Application.startuppath + "\ \". \\.. \\images\\btn_close_highlight.png "

The default borderless box is that you cannot drag the window and you can enter code to move the window:

Form Mobile API
[DllImport ("User32.dll")]
public static extern bool ReleaseCapture ();
[DllImport ("User32.dll")]
public static extern bool SendMessage (INTPTR hwnd, int wmsg, int wParam, int iparam);
public const int wm_syscommand = 0x0112;
public const int sc_move = 0xf010;
public const int htcaption = 0x0002;
[DllImport ("user32")]
private static extern int SendMessage (INTPTR hwnd, int wmsg, int wParam, IntPtr lParam);
Private Const int wm_setredraw = 0xB;

private void Form1_mousedown (object sender, MouseEventArgs e)
{
if (this. WindowState = = formwindowstate.normal)
{
ReleaseCapture ();
SendMessage (this. Handle, Wm_syscommand, Sc_move + htcaption, 0);
}
}

Let the form have a shadow, lower right shadow (no four-sided shadow is found)

Shadow on both sides
Private Const int Cs_dropshadow = 0x20000;
Private Const int Gcl_style = (-26);

[DllImport ("user32.dll", CharSet = CharSet.Auto)]
public static extern int Setclasslong (INTPTR hwnd, int nIndex, int dwnewlong);
[DllImport ("user32.dll", CharSet = CharSet.Auto)]
public static extern int Getclasslong (INTPTR hwnd, int nIndex);

Timer Control:

----timer is a thread that can access objects by default across threads

There are two properties commonly used:

Enabled-whether this control is enabled

--timer1. Enabled=false; not available
--timer1. Enabled=true; available

Interval-interval time, milliseconds

-------------

Creating controls

PictureBox p = new PictureBox ();//Create picture control, instantiate picture control            //Set Picture
P.backgroundimage = Image.FromFile (Application.startuppath + "\\dota_img5.jpg"); P.backgroundimagelayout = Imagelayout.stretch; TextBox TB = new TextBox ();//Create a TextBox control, instantiate FLOWLAYOUTPANEL1.CONTROLS.ADD (p);//Put in a collection of streaming layouts FLOWLAYOUTPANEL1.CONTROLS.ADD (TB);


Change properties:
foreach (Control ct in flowlayoutpanel1.controls)            {                if (CT is TextBox)                {                    (textbox) CT). Text = "123123";                               }              }

Borderless forms and background creation controls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.