Determine Some operation regions on the image and click event processing in the region.

Source: Internet
Author: User

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

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.