VB API 11th Lesson Draw Rectangle

Source: Internet
Author: User

Let's introduce several functions of rectangle drawing:

DrawFocusRect (): Draw a focus rectangle;
Rectangle (): Draws a rectangle with the currently selected brush and fills it with the currently selected paint brush;
Drawedge (): depicts a rectangle's border with the specified style;
RoundRect (): Draws a rounded rectangle with the currently selected brush and fills it with the currently selected paint brush.

Today is the DrawFocusRect () function, the function prototype is as follows

Private Declare Function drawfocusrect Lib "user32" Alias "DrawFocusRect"
(
ByVal HDC as Long,
LpRect as RECT
) as Long

Hdc:long//Handle of the device

Lprect:rect the structure, drawing the coordinates of the rectangle.

A return value of 0, indicating failure, not 0, succeeds

Example: Drawing a rectangle

Option explicitprivate type Rectleft as longtop as longright as longbottom as Longend Type'type declarationPrivate Declare Function DrawFocusRect Lib"User32"(ByVal hdc as Long, LpRect as RECT) as Longdim Flag as Booleandim Start as Booleandim Pos as Rectdim Temppos as RECTP Rivate Sub Command1_Click () Flag=True'Start DrawingEnd subprivate Sub command2_click () Flag=Falsepicture1.cls'End DrawingEnd subprivate Sub form_load () Flag=Falsestart=False'Prohibit drawingMe.scalemode =3Me.Picture1.ScaleMode=3'set object coordinates in pixelsEnd subprivate Sub picture1_mousedown (Button As Integer, Shift As Integer, X as single, Y as single) If Flag Thenstart =Truepos.left=Xpos.top=Yelsestart=falseend IfEnd SubPrivate Sub picture1_mousemove (Button As Integer, Shift As Integer, X as single, Y as single) If Sta RT Thendrawfocusrect Me.Picture1.hdc, Pos'Erase original Focus RectanglePos.right =Xpos.bottom=ydrawfocusrect Me.Picture1.hdc, Pos'draw a new focus rectangleEnd IfEnd SubPrivate Sub picture1_mouseup (Button As Integer, Shift As Integer, X as single, Y as single) If Start thend Rawfocusrect Me.Picture1.hdc, Pos'Erase original Focus RectanglePos.right =Xpos.bottom=ydrawfocusrect Me.Picture1.hdc, Pos'draw a new focus rectangleStart =FalseEnd IfEnd Sub

VB API 11th Lesson Draw Rectangle

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.