WinForm no border form and timer control

Source: Internet
Author: User

A. Borderless form

1. How to make the control button
is to place a clickable control, not limited to the use of buttons or anything else,
As long as you can click to trigger the Click event.

Do a little better, is the mouse move in, move out, press three events will let the button change style

How to get the relative path of a picture
Application.startuppath + "\ \". \\.. \\images\\btn_close_highlight.png "

\.. \ folder name ... Turn up a folder

2. How to make a form move
Calling the form to move the API

If there are other controls covering the form, then write the event delegate on the mouse down to

//Form Mobile API[DllImport ("user32.dll")]         Public Static extern BOOLreleasecapture (); [DllImport ("user32.dll")]         Public Static extern BOOLSendMessage (INTPTR hwnd,intWmsg,intWParam,intIparam);  Public Const intWm_syscommand =0x0112;  Public Const intSc_move =0xf010;  Public Const intHtcaption =0x0002; [DllImport ("User32")]        Private Static extern intSendMessage (INTPTR hwnd,intWmsg,intWParam, IntPtr lParam); Private Const intWm_setredraw =0xB; Private voidForm1_mousedown (Objectsender, MouseEventArgs e) {            if( This. WindowState = =formwindowstate.normal) {releasecapture (); SendMessage ( This. Handle, Wm_syscommand, Sc_move + htcaption,0); }        }

3. How to make a form shaded

  

//form two-side shadow     Public Partial classForm1:form//form's Class    {        Private Const intCs_dropshadow =0x20000; Private Const intGcl_style = (- -); [DllImport ("user32.dll", CharSet =CharSet.Auto)] Public Static extern intSetclasslong (INTPTR hwnd,intNIndex,intDwnewlong); [DllImport ("user32.dll", CharSet =CharSet.Auto)] Public Static extern intGetclasslong (INTPTR hwnd,intNIndex);  PublicForm1 ()//the constructor of the form itself{InitializeComponent ();//constructor Self-signed statementSetclasslong ( This. Handle, Gcl_style, Getclasslong ( This. Handle, Gcl_style) |Cs_dropshadow); }    }

Form four-sided shadows: http://bbs.csdn.net/topics/390069539?page=1#post-395227949

Second, the Timer control simple communication
Timer in the component:
Enabled-whether this control is enabled
Interval-interval time, milliseconds
Tick event-code snippet to execute after a specified time interval

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

WinForm no border form and timer control

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.