Monday, May 20, 2013
 
    Search Web Link
Search Software
    
API Home » Brush » CreateHatchBrush

CreateHatchBrush

Category: Brush
Hits: 4413 Rating: CreateHatchBrush has been rated 3.36 by  1182 users (3.36) votes 1182
Rate: 1-star  2-stars  3-stars  4-stars  5-stars
E-mail this API to friend E-mail this Code to a friend  save Bookmark this VB API Function
API Explanation
CreateHatchBrush creates a hatched brush object. When used to fill an area or shape, this brush produces a pattern of lines (a "hatch pattern") in a single color using an 8x8 unit cell. After the program finishes using the hatched brush, it should use DeleteObject to delete the brush and free system resources. The function returns a handle to the newly created hatched brush if successful, or 0 if an error occured.

Parameter Information
Declare Function CreateHatchBrush Lib "gdi32.dll" (ByVal nIndex As Long, _
ByVal crColor As Long) As Long

nIndex
Exactly one of the following flags specifying which hatch pattern to use to make the brush:
HS_BDIAGONAL = 3
Diagonal lines from the bottom-left to the upper-right.
HS_CROSS = 4
Cross pattern of horizontal and vertical lines.
HS_DIAGCROSS = 5
Cross pattern of perpendicular diagonal lines.
HS_FDIAGONAL = 2
Diagonal lines from the upper-left to the bottom-right.
HS_HORIZONTAL = 0
Horizontal lines.
HS_VERTICAL = 1
Vertical lines.
crColor
The RGB value of the color to give the hatched brush. Visual Basic users can use the RGB() function to generate this value.
Code



' Draw a rectangle with corners (10,20) and (175,100)
' on window Form1. Use a yellow brush with a diagonal cross pattern to fill the rectangle.
Dim hbrush As Long ' receives handle to the hatched yellow brush
Dim holdbrush As Long ' receives handle to Form1's default brush
Dim retval As Long ' return value

hbrush = CreateHatchBrush(HS_DIAGCROSS, RGB(255, 255, 0)) ' create a hatched yellow brush
' Save Form1's default brush so we can restore it after the program is finished
holdbrush = SelectObject(Form1.hDC, hbrush) ' select the brush
' Draw the rectangle filled using the hatched yellow brush
retval = Rectangle(Form1.hDC, 10, 20, 175, 100)
' Restore Form1's previous brush before destroying the created one
retval = SelectObject(Form1.hDC, holdbrush) ' select old brush
retval = DeleteObject(hbrush) ' destroy the hatched yellow brush




HOME | MUSIC | DOWNLOADS |  GAMES | TEST-QUIZZES | SITEMAP | ABOUT | HELP
Copyright © 2000 - 2013 Ex-designz. All rights reserved. Website Developed By Dexter Zafra of Myasp-net.com
Link to us | Advertisement | Contact us | Privacy Policy | Terms of use | Accessibility