Custom form styles and personal summary

Source: Internet
Author: User

Objective

========================================================

Now I'm working, and I don't feel as busy as I thought I was. In my heart, a dry writing program of the people, is should be compared to busy, now I remember a school teacher said, a programmer did not write the program all night is not a real programmer, now I do not care that the teacher said the extreme not extreme, But at least in my mind, so I'm not a real programmer yet.

I am still me, or a I think I do not like to follow the trend of people, the following I will talk about is some old things, is a share, the master floated.

Say one more, now the garden has the homepage question, if everybody thinks this article puts on the homepage to have the question, I immediately withdraws.

=========================================================

1, customize the custom form style

The first step is to set the form style

this.FormBorderStyle=System.Windows.Forms.FormBorderStyle.None

Once set, the form has no borders, and there is no zoom and move function, and even the shutdown is gone.

Step two, crazy panel.

//窗体上面放panel1(System.Windows.Forms.DockStyle.Fill)
//panel1里面有panel2,panel3,panel4,panel5,panel6
//分别用于上,左,右,中,底
Me.Panel1 = New System.Windows.Forms.Panel
Me.Panel2 = New System.Windows.Forms.Panel
Me.Panel3 = New System.Windows.Forms.Panel
Me.Panel4 = New System.Windows.Forms.Panel
Me.Panel5 = New System.Windows.Forms.Panel
Me.Panel6 = New System.Windows.Forms.Panel
Me.Panel1.Controls.Add(Me.Panel6)
Me.Panel1.Controls.Add(Me.Panel5)
Me.Panel1.Controls.Add(Me.Panel4)
Me.Panel1.Controls.Add(Me.Panel3)
Me.Panel1.Controls.Add(Me.Panel2)
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
Me.Panel2.Dock = System.Windows.Forms.DockStyle.Top
Me.Panel3.Dock = System.Windows.Forms.DockStyle.Left
Me.Panel4.Dock = System.Windows.Forms.DockStyle.Right
Me.Panel5.Dock = System.Windows.Forms.DockStyle.Fill
Me.Panel6.Dock = System.Windows.Forms.DockStyle.Bottom

So we have a rough model.

Step three, add the things you should have in each panel

For example, add a title bar to the Panel2, add a left border in the Panel3,

Fourth step, move, Min/Dahua

You can add your own buttons in the Panel2 (I do PictureBox)

I did the following

The event response is as follows

Private Sub PictureBox1_Click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Picturebox1.click
Me.windowstate = formwindowstate.minimized
End Sub
' Magnify event response
Private Sub Picturebox2_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Picturebox2.click
Me.windowstate = formwindowstate.maximized
End Sub

And there's a bad place to do it, that's moving,

To use the System API

<dllimport ("User32.dll") > _
Public Shared Function releasecapture () as Boolean
End Function
<dllimport ("User32.dll") > _
Public Shared Function SendMessage (ByVal hwnd as INTPTR, ByVal imsg As Integer, ByVal wParam As Integer, ByVal lParam as I Nteger) as Boolean
End Function
Public Const wm_syscommand as Integer = &h112
Public Const sc_move as Integer = &hf010
Public Const htcaption as Integer = &h2

And then join the event response to achieve the effect of the move

' Response when clicking on the panel on the top border
Private Sub Panel1_mousedomn (ByVal sender as Object, ByVal e as MouseEventArgs) Handles Panel2.mousedown
If E.button = Windows.Forms.MouseButtons.Left Then
Awardlistform2.releasecapture ()
Awardlistform2.sendmessage (Me.handle, Wm_syscommand, Sc_move + htcaption, 0)
End If
End Sub

Well, with the zoom, shrink, close the function to do it yourself, now this custom form of the difficult points are said, the others do it yourself

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.