win32

package
v0.0.0-...-3c317a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OBJ_PEN         = 1
	OBJ_BRUSH       = 2
	OBJ_DC          = 3
	OBJ_METADC      = 4
	OBJ_PAL         = 5
	OBJ_FONT        = 6
	OBJ_BITMAP      = 7
	OBJ_REGION      = 8
	OBJ_METAFILE    = 9
	OBJ_MEMDC       = 10
	OBJ_EXTPEN      = 11
	OBJ_ENHMETADC   = 12
	OBJ_ENHMETAFILE = 13
	OBJ_COLORSPACE  = 14
)

Object Definitions for EnumObjects()

View Source
const (
	Arial         = "Arial"
	TimesNewRoman = "Times New Roman"
	CourierNew    = "Courier New"
	Verdana       = "Verdana"
)
View Source
const (
	PRINTER_ATTRIBUTE_LOCAL   uint32 = 0x00000040
	PRINTER_ATTRIBUTE_NETWORK uint32 = 0x00000010
)
View Source
const (
	HFONT = 6 // Object type for getCurrentFont
)

Constants

Variables

This section is empty.

Functions

func ClosePrinter

func ClosePrinter(handle Printer) (err error)

func Default

func Default() (string, error)

func DrawDIImage

func DrawDIImage(dc HDC, dx, dy, dw, dh, sx, sy uint32, sw, sh int32, image []byte) (err error)

func EndPage

func EndPage(dc HDC) (err error)

func EndPagePrinter

func EndPagePrinter(handle Printer) (err error)

func EnumPrinter

func EnumPrinter(flag EnumFlag, name *uint16, level uint32, info *byte, bufLen uint32, bufSize *uint32, returnLen *uint32) (err error)

EnumPrinter https://learn.microsoft.com/zh-cn/windows/win32/printdocs/enumprinters

func GetDefaultPrinter

func GetDefaultPrinter(buf *uint16, bufN *uint32) (err error)

func GetDeviceCaps

func GetDeviceCaps(dc HDC, index PropType) (number uint32, err error)

func GetTextExtentPoint32

func GetTextExtentPoint32(hdc syscall.Handle, text string) (uint32, uint32, error)

Calcule la largeur et la hauteur de la chaîne passée en paramètre

func LineTo

func LineTo(dc HDC, x, y uint32) (err error)

func MoveTo

func MoveTo(dc HDC, x, y uint32) (rect *image.Point, err error)

func SetBoldFont

func SetBoldFont(hdc HDC, bold bool) (err error)

func SetDefaultPrinter

func SetDefaultPrinter(buf *uint16) (err error)

func SetFont

func SetFont(hdc HDC, fontName string) (err error)

func SetItalicFont

func SetItalicFont(hdc HDC, italic bool) (err error)

func SetTextSize

func SetTextSize(hdc HDC, size int32) (i int32, err error)

SetTextSize changes the text height for the specified device context Parameters:

  • hdc: Handle to the device context
  • size: Text height in logical units (points)

Returns:

  • error: nil if successful, error object otherwise

func StartDCPrinter

func StartDCPrinter(dc HDC, docName string) (err error)

func StartPagePrinter

func StartPagePrinter(handle Printer) (err error)

func StretchDIBits

func StretchDIBits(dc HDC, dx, dy, dw, dh, sx, sy uint32, sw, sh int32, image []byte, bitmap *BITMAPINFO, color DIBColors, operation RasterOperationCode) (err error)

func TextOut

func TextOut(dc HDC, x, y uint32, text string, len uint32) (err error)

func WritePrinter

func WritePrinter(handle Printer, buf *byte, bufN uint32, written *uint32) (err error)

Types

type BITMAPINFO

type BITMAPINFO struct {
	BmiHeader BITMAPINFOHEADER
	BmiColors RGBQUAD
}

type BITMAPINFOHEADER

type BITMAPINFOHEADER struct {
	// contains filtered or unexported fields
}

type BiCompression

type BiCompression uint32
const (
	BI_RGB       BiCompression = 0
	BI_RLE8      BiCompression = 1
	BI_RLE4      BiCompression = 2
	BI_BITFIELDS BiCompression = 3
	BI_JPEG      BiCompression = 4
	BI_PNG       BiCompression = 5
)

type COLORREF

type COLORREF uint32

COLORREF represents a Windows color value in BGR format

func RGB

func RGB(r, g, b byte) COLORREF

RGB creates a COLORREF value from red, green, and blue components

func SetTextColor

func SetTextColor(hdc HDC, color COLORREF) (COLORREF, error)

SetTextColor sets the text color for the specified device context Parameters:

  • hdc: Handle to the device context
  • color: Color value created using RGB()

Returns:

  • Previous text color value
  • error: nil if successful, error object otherwise

type DIBColors

type DIBColors uint32
const (
	DIB_RGB_COLORS  DIBColors = 0x00
	DIB_PAL_COLORS  DIBColors = 0x01
	DIB_PAL_INDICES DIBColors = 0x02
)

type DOCINFOA

type DOCINFOA struct {
	Size     uintptr
	DocName  *uint16
	Output   *uint16
	DataType *uint16
	Type     uint32
}

type DOC_INFO_1

type DOC_INFO_1 struct {
	DocName    *uint16
	OutputFile *uint16
	Datatype   *uint16
}

https://learn.microsoft.com/en-us/windows/win32/printdocs/doc-info-1

type EnumFlag

type EnumFlag uint32
const (
	PRINTER_ENUM_DEFAULT     EnumFlag = 0x00000001
	PRINTER_ENUM_LOCAL       EnumFlag = 0x00000002
	PRINTER_ENUM_CONNECTIONS EnumFlag = 0x00000004
	PRINTER_ENUM_FAVORITE    EnumFlag = 0x00000004
	PRINTER_ENUM_NAME        EnumFlag = 0x00000008
	PRINTER_ENUM_REMOTE      EnumFlag = 0x00000010
	PRINTER_ENUM_SHARED      EnumFlag = 0x00000020
	PRINTER_ENUM_NETWORK     EnumFlag = 0x00000040
)

type HDC

type HDC syscall.Handle

func CreateDC

func CreateDC(printerName string) (dc HDC, err error)

CreateDC

type LOGFONT

type LOGFONT struct {
	Height         int32
	Width          int32
	Escapement     int32
	Orientation    int32
	Weight         int32
	Italic         byte
	Underline      byte
	StrikeOut      byte
	CharSet        byte
	OutPrecision   byte
	ClipPrecision  byte
	Quality        byte
	PitchAndFamily byte
	FaceName       [32]uint16
}

LOGFONT contains information about a logical font

type PRINT_INFO_4 struct {
	PrinterName *uint16
	ServerName  *uint16
	Attributes  uint32
}

type Printer

type Printer syscall.Handle

func OpenPrinter

func OpenPrinter(name string) (Printer, error)

type PrinterInfo

type PrinterInfo struct {
	PrinterName string
	ServerName  string
	Attributes  uint32
}

type PropType

type PropType uint32
const (
	DRIVERVERSION         PropType = 0  /* Device driver version                    */
	TECHNOLOGYPropType    PropType = 2  /* Device classification                    */
	HORZSIZE              PropType = 4  /* Horizontal size in millimeters           */
	VERTSIZE              PropType = 6  /* Vertical size in millimeters             */
	HORZRES               PropType = 8  /* Horizontal width in pixels               */
	VERTRES               PropType = 10 /* Vertical height in pixels                */
	BITSPIXEL             PropType = 12 /* Number of bits per pixel                 */
	PLANES                PropType = 14 /* Number of planes                         */
	NUMBRUSHES            PropType = 16 /* Number of brushes the device has         */
	NUMPENS               PropType = 18 /* Number of pens the device has            */
	NUMMARKERS            PropType = 20 /* Number of markers the device has         */
	NUMFONTS              PropType = 22 /* Number of fonts the device has           */
	NUMCOLORS             PropType = 24 /* Number of colors the device supports     */
	PDEVICESIZE           PropType = 26 /* Size required for device descriptor      */
	CURVECAPS             PropType = 28 /* Curve capabilities                       */
	LINECAPSPropType      PropType = 30 /* Line capabilities                        */
	POLYGONALCAPSPropType PropType = 32 /* Polygonal capabilities                   */
	TEXTCAPSPropType      PropType = 34 /* Text capabilities                        */
	CLIPCAPSPropType      PropType = 36 /* Clipping capabilities                    */
	RASTERCAPS            PropType = 38 /* Bitblt capabilities                      */
	ASPECTX               PropType = 40 /* Length of the X leg                      */
	ASPECTY               PropType = 42 /* Length of the Y leg                      */
	ASPECTXYPropType      PropType = 44 /* Length of the hypotenuse                 */

	LOGPIXELSX PropType = 88 /* Logical pixels/inch in X                 */
	LOGPIXELSY PropType = 90 /* Logical pixels/inch in Y                 */

	SIZEPALETTE PropType = 104 /* Number of entries in physical palette    */
	NUMRESERVED PropType = 106 /* Number of reserved entries in palette    */
	COLORRES    PropType = 108 /* Actual color resolution                  */

	PHYSICALWIDTH   PropType = 110 /* Physical Width in device units           */
	PHYSICALHEIGHT  PropType = 111 /* Physical Height in device units          */
	PHYSICALOFFSETX PropType = 112 /* Physical Printable Area x margin         */
	PHYSICALOFFSETY PropType = 113 /* Physical Printable Area y margin         */
	SCALINGFACTORX  PropType = 114 /* Scaling factor x                         */
	SCALINGFACTORY  PropType = 115 /* Scaling factor y                         */

	VREFRESH PropType = 116 /* Current vertical refresh rate of the    */
	/* display device (for displays only) in Hz*/
	DESKTOPVERTRES PropType = 117 /* Horizontal width of entire desktop in   */
	/* pixels                                  */
	DESKTOPHORZRES PropType = 118 /* Vertical height of entire desktop in    */
	/* pixels                                  */
	BLTALIGNMENT PropType = 119 /* Preferred blt alignment                 */

	SHADEBLENDCAPS PropType = 120 /* Shading and blending caps               */
	COLORMGMTCAPS  PropType = 121 /* Color Management caps                   */
)

type RGBQUAD

type RGBQUAD struct {
	RgbBlue     uint8
	RgbGreen    uint8
	RgbRed      uint8
	RgbReserved uint8
}

type RasterOperationCode

type RasterOperationCode uint32
const (
	SRCCOPY     RasterOperationCode = 0x00CC0020 /* dest = source                   */
	SRCPAINT    RasterOperationCode = 0x00EE0086 /* dest = source OR dest           */
	SRCAND      RasterOperationCode = 0x008800C6 /* dest = source AND dest          */
	SRCINVERT   RasterOperationCode = 0x00660046 /* dest = source XOR dest          */
	SRCERASE    RasterOperationCode = 0x00440328 /* dest = source AND (NOT dest )   */
	NOTSRCCOPY  RasterOperationCode = 0x00330008 /* dest = (NOT source)             */
	NOTSRCERASE RasterOperationCode = 0x001100A6 /* dest = (NOT src) AND (NOT dest) */
	MERGECOPY   RasterOperationCode = 0x00C000CA /* dest = (source AND pattern)     */
	MERGEPAINT  RasterOperationCode = 0x00BB0226 /* dest = (NOT source) OR dest     */
	PATCOPY     RasterOperationCode = 0x00F00021 /* dest = pattern                  */
	PATPAINT    RasterOperationCode = 0x00FB0A09 /* dest = DPSnoo                   */
	PATINVERT   RasterOperationCode = 0x005A0049 /* dest = pattern XOR dest         */
	DSTINVERT   RasterOperationCode = 0x00550009 /* dest = (NOT dest)               */
	BLACKNESS   RasterOperationCode = 0x00000042 /* dest = BLACK                    */
	WHITENESS   RasterOperationCode = 0x00FF0062 /* dest = WHITE                    */
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL