please dont rip this site Prev Next

GetStockObject info  Overview  Group

The GetStockObject function retrieves a handle to one of the predefined stock pens, brushes, fonts, or palettes.

HGDIOBJ GetStockObject(

    int fnObject 

// type of stock object



Specifies the type of stock object. This parameter can be any one of the following values:




Black brush.


Dark gray brush.


Gray brush.


Hollow brush (equivalent to NULL_BRUSH).


Light gray brush.


Null brush (equivalent to HOLLOW_BRUSH).


White brush.


Black pen.


Null pen.


White pen.


Windows fixed-pitch (monospace) system font.


Windows variable-pitch (proportional space) system font.


Windows NT only: Device-dependent font.


Windows 95 only: Default font for user interface objects such as menus and dialog boxes.


Original equipment manufacturer (OEM) dependent fixed-pitch (monospace) font.


System font. By default, Windows uses the system font to draw menus, dialog box controls, and text. In Windows versions 3.0 and later, the system font is a proportionally spaced font; earlier versions of Windows used a monospace system font.


Fixed-pitch (monospace) system font used in Windows versions earlier than 3.0. This stock object is provided for compatibility with earlier versions of Windows.


Default palette. This palette consists of the static colors in the system palette.

Return Values

If the function succeeds, the return value identifies the logical object requested.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.


Use the DKGRAY_BRUSH, GRAY_BRUSH, and LTGRAY_BRUSH stock objects only in windows with the CS_HREDRAW and CS_VREDRAW styles. Using a gray stock brush in any other style of window can lead to misalignment of brush patterns after a window is moved or sized. The origins of stock brushes cannot be adjusted.

The HOLLOW_BRUSH and NULL_BRUSH stock objects are equivalent.

The font used by the DEFAULT_GUI_FONT stock object could change. Use this stock object when you want to use the font that menus, dialog boxes, and other user interface objects use.

It is not necessary (but it is not harmful) to delete stock objects by calling DeleteObject.

See Also

DeleteObject, SelectObject

See also:

file: /Techref/os/win/api/win32/func/src/f39_8.htm, 6KB, , updated: 2000/4/7 12:19, local time: 2022/5/21 16:01,

 ©2022 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> GetStockObject</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2022 contributors:
o List host: MIT, Site host, Top posters @20220521
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!