Tuesday, May 21, 2013
 
    Search Web Link
Search Software
    
API Home » Brush » SetBrushOrgEx

SetBrushOrgEx

Category: Brush
Hits: 3356 Rating: SetBrushOrgEx has been rated 2.75 by  587 users (2.75) votes 587
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
SetBrushOrgEx sets the origin point for using a brush on a given device. Note that this function only takes effect on the next brush the device selects -- the currently selected brush in unaffected! The brush origin point determines the offset of the 8x8 block used to fill in areas (the brush). For example, an origin point of (2,3) would shift the fill pattern 2 pixels to the right and 3 pixels downward. The old brush origin point is put into the variable passed as lppt. The function returns 1 if successful, or 0 if an error occured.

Parameter Information
Declare Function SetBrushOrgEx Lib "gdi32.dll" (ByVal hdc _
As Long, ByVal nXOrg As Long, ByVal nYOrg As _
Long, lppt As POINT_TYPE) As Long

hdc
A device context to the device to set the brush origin point of.
nXOrg
The x-coordinate of the new brush origin point. This must be between 0 and 7 inclusive.
nYOrg
The y-coordinate of the new brush origin point. This must be between 0 and 7 inclusive.
lppt
Receives the former brush origin point.
Code



' Fill in rectange (10,20)-(200,150) on window Form1 with a double diagonal-
' cross hatch pattern: one in green, one in blue. After the first draw/paint, the brush
' origin is adjusted to make a nice overlay effect.
Dim hbrush As Long ' receives handle to the brushes the program creates
Dim holdbrush As Long ' receives handle to the device's default brush
Dim oldorg As POINT_TYPE ' receives original origin point
Dim xorg As POINT_TYPE ' throw-away value
Dim retval As Long ' return value

' ** First, draw the rectangle using the green hatched pattern **
' Create the green hatched brush
hbrush = CreateHatchBrush(HS_DIAGCROSS, RGB(0, 255, 0))
' Set the brush origin point to (0,0) and store the old value (we'll restore it later)
retval = SetBrushOrgEx(Form1.hDC, 0, 0, oldorg)
' Select the hatched brush and create the rectangle
holdbrush = SelectObject(Form1.hDC, hbrush) ' select the brush
retval = Rectangle(Form1.hDC, 10, 20, 200, 150) ' make the rectangle
' Restore the default brush temporarily and destroy the hatched brush
retval = SelectObject(Form1.hDC, holdbrush) ' restore old brush
retval = DeleteObject(hbrush) ' delete the hatched brush

' ** Now, redraw the rectangle using an offset blue hatched pattern **
' Create the blue hatched brush
hbrush = CreateHatchBrush(HS_DIAGCROSS, RGB(0, 0, 255))
' Set the brush origin point to (4,4) and ignore the old value
retval = SetBrushOrgEx(Form1.hDC, 0, 0, xorg) ' we don't care about xorg
' Select the hatched brush and recreate the rectangle
holdbrush = SelectObject(Form1.hDC, hbrush) ' select the brush
retval = Rectangle(Form1.hDC, 10, 20, 200, 150) ' make the rectangle
' Restore the default brush and destroy the hatched brush
retval = SelectObject(Form1.hDC, holdbrush) ' restore old brush
retval = DeleteObject(hbrush) ' delete the hatched brush
' Now, restore the device's old brush origin point
retval = SetBrushOrgEx(Form1.hDC, oldorg.x, oldorg.y, xorg)




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