Tuesday, September 16, 2014
 
    Search Web Link
Search Software
    
API Home » Objects » GetStockObject

GetStockObject

Category: Objects
Hits: 4825 Rating: GetStockObject has been rated 2.16 by  892 users (2.16) votes 892
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
GetStockObject accesses one of Windows's stock pens, brushes, fonts, or palettes. This function provides fast access to these commonly used objects, instead of having to use more complicated functions. The function returns a handle to the pen, brush, font, or palette which the function accesses. Although the program isn't required to delete the handle using DeleteObject, doing so doesn't have any adverse effects.

Parameter Information
Declare Function GetStockObject Lib "gdi32.dll" (ByVal nIndex As Long) As Long

nIndex
Exactly one of the following flags specifying which of the stock objects to create a handle to:
ANSI_FIXED_FONT = 11
The system's normal monospaced font.
ANSI_VAR_FONT = 12
The system's normal proportional-width font.
BLACK_BRUSH = 4
A solid black brush.
BLACK_PEN = 7
A solid black pen.
DEFAULT_GUI_FONT = 17
Win 95/98 only: The default font for user objects under Windows.
DEFAULT_PALETTE = 15
The default system palette.
DEVICE_DEFAULT_FONT = 14
Win NT only: a device-dependent font.
DKGRAY_BRUSH = 3
A solid dark gray brush.
GRAY_BRUSH = 2
A solid gray brush.
HOLLOW_BRUSH = 5
Same as NULL_BRUSH.
LTGRAY_BRUSH = 1
A solid light gray brush.
NULL_BRUSH = 5
A null brush; i.e., a brush that does not draw anything on the device.
NULL_PEN = 8
A null pen; i.e., a pen that does not draw anything on the device.
OEM_FIXED_FONT = 10
The Original Equipment Manufacturer's default monospaced font.
SYSTEM_FIXED_FONT = 16
The system monospaced font under pre-3.x versions of Windows.
SYSTEM_FONT = 13
The system font (used for most system objects under Windows).
WHITE_BRUSH = 0
A solid white brush.
WHITE_PEN = 6
A solid white pen.
Code



' Draw a rectangle with a black border and light gray filled interior
' on window Form1. Use stock pens and brushes to do this.
Dim hbrush As Long, holdbrush As Long ' handles to stock brush & default brush
Dim hpen As Long, holdpen As Long ' handles to stock pen & default pen
Dim retval As Long ' return value

' Load the stock pen and brush needed for this operation
hpen = GetStockObject(BLACK_PEN) ' load the black solid pen
hbrush = GetStockObject(LTGRAY_BRUSH) ' load the light gray solid brush
' Select the two objects in Form1 and save the defaults
holdpen = SelectObject(Form1.hDC, hpen) ' select the pen
holdbrush = SelectObject(Form1.hDC, hbrush) ' select the brush
' Draw the rectangle using the pen and brush. The rectangle has corners (20,25)-(200,175)
retval = Rectangle(Form1.hDC, 20, 25, 200, 175)
' Restore Form1's previously selected pen and brush
retval = SelectObject(Form1.hDC, holdpen) ' reselect old pen
retval = SelectObject(Form1.hDC, holdbrush) ' reselect old brush
' Note that it is not necessary to delete hpen and hbrush, but we could if we wanted.





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