1.If we want to beautify ourProgram.
2.Some specific windows,Different display resolutions,Button controls can be zoomed in or out.,
This will affect the appearance of the program,If we use the image area to implement the same button function,In this way, different resolutions can be solved..
The following example shows how to implement this function..
The picture is designed,Through threeLabelGet the location we need,Place them on our images.,Cover the corresponding part of the image.
Obtain the set image area and return the specified integer.
Private Function getmouselocation () Function Getmouselocation ( Byval X As Integer , Byval Y As Integer ) As Integer
' Use the label we designed to determine the region. You can also write the region by yourself.
Dim Rect1 As New System. Drawing. rectangle (lblsetdomain. Location, lblsetdomain. Size)
Dim Rect2 As New System. Drawing. rectangle (lblok. Location, lblok. Size)
Dim Rect3 As New System. Drawing. rectangle (lblcancel. Location, lblcancel. Size)
If Rect1.contains (x, y) Then
Return 1
Elseif Rect2.contains (x, y) Then
Return 2
Elseif Rect3.contains (x, y) Then
Return 3
Else
Return 0
End If
End Function
' When you move the cursor over the specified image area
Private Sub pbxlogin_mousemove () Sub Pbxlogin_mousemove ( Byval Sender As Object , Byval E As System. Windows. Forms. mouseeventargs) Handles Pbxlogin. mousemove
Select Case Getmouselocation (E. X, E. Y) ' Obtain a specific image area
Case 0
' Change the Mouse shape
Me. cursor = Cursors. Default
Case Else
Me. cursor = Cursors. Hand
End Select
End sub
' When you release the mouse in the Image Selection Area
Private Sub pbxlogin_mouseup () Sub Pbxlogin_mouseup ( Byval Sender As Object , Byval E As System. Windows. Forms. mouseeventargs) Handles Pbxlogin. mouseup
Select Case Getmouselocation (E. X, E. Y)
' Add yourCodeHere
Case 1
' Add your code
Case 2
' Add your code
Case 3
' Add your code
End Select
End sub