Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

GetStockObject (gdi32)
 
.
Summary
The GetStockObject function retrieves a handle to one of the stock pens, brushes, fonts, or palettes.
Summary

C# Signature:

    [DllImport("gdi32.dll")]
    static extern IntPtr GetStockObject(StockObjects fnObject);

VB.NET Signature:

    <DllImport("gdi32.dll")> _
    Private Shared Function GetStockObject(fnObject As StockObjects) As IntPtr
    End Function

User-Defined Types C#:

public enum StockObjects {
[DllImport("gdi32.dll")]
static extern IntPtr GetStockObject(int fnObject);

Constants:

private const int WHITE_BRUSH     = 0;
private const int LTGRAY_BRUSH    = 1;
private const int GRAY_BRUSH      = 2;
private const int DKGRAY_BRUSH    = 3;
private const int BLACK_BRUSH     = 4;
private const int NULL_BRUSH      = 5;
private const int HOLLOW_BRUSH    = NULL_BRUSH;
private const int WHITE_PEN       = 6;
private const int BLACK_PEN       = 7;
private const int NULL_PEN        = 8;
private const int OEM_FIXED_FONT      = 10;
private const int ANSI_FIXED_FONT     = 11;
private const int ANSI_VAR_FONT       = 12;
private const int SYSTEM_FONT     = 13;
private const int DEVICE_DEFAULT_FONT = 14;
private const int DEFAULT_PALETTE     = 15;
private const int SYSTEM_FIXED_FONT   = 16;
private const int DEFAULT_GUI_FONT    = 17;
private const int DC_BRUSH        = 18;
private const int DC_PEN          = 19;

User-Defined Types:

public enum StockObjects {

    WHITE_BRUSH     = 0,
    LTGRAY_BRUSH    = 1,
    GRAY_BRUSH      = 2,
    DKGRAY_BRUSH    = 3,
    BLACK_BRUSH     = 4,
    NULL_BRUSH      = 5,
    HOLLOW_BRUSH    = NULL_BRUSH,
    WHITE_PEN       = 6,
    BLACK_PEN       = 7,
    NULL_PEN    = 8,
    OEM_FIXED_FONT  = 10,
    ANSI_FIXED_FONT = 11,
    ANSI_VAR_FONT   = 12,
    SYSTEM_FONT     = 13,
    DEVICE_DEFAULT_FONT = 14,
    DEFAULT_PALETTE     = 15,
    SYSTEM_FIXED_FONT   = 16,
    DEFAULT_GUI_FONT    = 17,
    DC_BRUSH    = 18,
    DC_PEN      = 19,
    }

User-Defined Types VB.NET:

Public Enum StockObjects
    WHITE_BRUSH = 0
    LTGRAY_BRUSH = 1
    GRAY_BRUSH = 2
    DKGRAY_BRUSH = 3
    BLACK_BRUSH = 4
    NULL_BRUSH = 5
    HOLLOW_BRUSH = NULL_BRUSH
    WHITE_PEN = 6
    BLACK_PEN = 7
    NULL_PEN = 8
    OEM_FIXED_FONT = 10
    ANSI_FIXED_FONT = 11
    ANSI_VAR_FONT = 12
    SYSTEM_FONT = 13
    DEVICE_DEFAULT_FONT = 14
    DEFAULT_PALETTE = 15
    SYSTEM_FIXED_FONT = 16
    DEFAULT_GUI_FONT = 17
    DC_BRUSH = 18
    DC_PEN = 19
End Enum

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions