win32util

package
v0.0.0-...-2f48622 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CString

func CString(str string, p *[]win32.WCHAR)

func ClientToScreen

func ClientToScreen(hwnd win32.HWND, rect *win32.RECT) error

func CopyCString

func CopyCString(dest, src []win32.WCHAR) (charCopied int)

CopyCString copies null terminated C string src to dest. Returns the count of win32.WCHAR copied, includes terminating null.

func CreatePen

func CreatePen(style win32.PEN_STYLE, width win32.DWORD, color win32.COLORREF) (win32.HPEN, error)

CreatePen simulates CreatePen API using ExtCreatePen. Style can be one of PS_SOLID, PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT, PS_NULL, PS_INSIDEFRAME.

func CreateWindow

func CreateWindow(spec *Wnd) (win32.HWND, error)

func DPIConv

func DPIConv[T ~int32 | ~uint32](oldValue T, oldDPI, newDPI win32.UINT) (newValue T)

DPIConv converts a value from old DPI to new DPI.

func EmptyDialogTemplate

func EmptyDialogTemplate(style win32.DWORD, exStyle win32.DWORD, x win32.SHORT, y win32.SHORT, cx win32.SHORT, cy win32.SHORT) *win32.DLGTEMPLATE

EmptyDialogTemplate allocates an empty dialog template. x, y, cx, cy are in pixel format in screen coordinates.

func FromDefaultDPI

func FromDefaultDPI[T ~int32 | ~uint32](value T, dpi win32.UINT) T

FromDefaultDPI convert value from USER_DEFAULT_SCREEN_DPI(96) to a new DPI.

func GetWindowText

func GetWindowText(hwnd win32.HWND) (string, error)

func GoString

func GoString(p *win32.WCHAR, size int) string

GoString converts a null terminated C string to go string. size is the buffer length of C string, includes terminating null.

func MessageBox

func MessageBox(owner win32.HWND, text string, caption string, typ win32.MESSAGE_BOX_TYPE) (int, error)

func MessageBoxEx

func MessageBoxEx(owner win32.HWND, text string, caption string, typ win32.MESSAGE_BOX_TYPE, langID win32.WORD) (int, error)

func RegisterClass

func RegisterClass(cls *WndClass) (win32.ATOM, error)

func ScreenToClient

func ScreenToClient(hwnd win32.HWND, rect *win32.RECT) error

func SetWindowText

func SetWindowText(hwnd win32.HWND, str string) error

Types

type Wnd

type Wnd struct {
	ClassName   string
	WindowName  string
	Style       win32.WINDOW_STYLE
	ExStyle     win32.WINDOW_EX_STYLE
	X           win32.INT
	Y           win32.INT
	Width       win32.INT
	Height      win32.INT
	WndParent   win32.HWND
	InParentDPI bool // Whether X, Y, Width and Height are in WndParent's DPI. USER_DEFAULT_SCREEN_DPI is used if false.
	Menu        win32.HMENU
	Instance    win32.HINSTANCE // 0 for this module.
	Param       win32.UINT_PTR
}

type WndClass

type WndClass struct {
	ClassName  string
	WndProc    win32.WndProc
	Instance   win32.HINSTANCE // 0 for this module.
	Style      win32.CLASS_STYLE
	ClsExtra   win32.INT
	WndExtra   win32.INT
	Icon       win32.HICON
	Cursor     win32.HCURSOR
	Background win32.HBRUSH
	MenuName   string
	IconSm     win32.HICON
}

Jump to

Keyboard shortcuts

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