window

package
v0.0.0-...-3929c03 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CW_USEDEFAULT = metrics.Px(win32.CW_USEDEFAULT)
View Source
var ErrAlreadyAttached = errors.New("already attached")

wiErrAlreadyAttached is returned by Attach if the HWND or *WindowBase is already attached.

Functions

func Attach

func Attach(hwnd win32.HWND, window *WindowBase) error

func PreTranslateMessage

func PreTranslateMessage(msg *win32.MSG) bool

Types

type MouseClickOpt

type MouseClickOpt win32.WPARAM

func (MouseClickOpt) Control

func (mk MouseClickOpt) Control() bool

func (MouseClickOpt) LButton

func (mk MouseClickOpt) LButton() bool

func (MouseClickOpt) MButton

func (mk MouseClickOpt) MButton() bool

func (MouseClickOpt) RDown

func (mk MouseClickOpt) RDown() bool

func (MouseClickOpt) Shift

func (mk MouseClickOpt) Shift() bool

func (MouseClickOpt) XButton1

func (mk MouseClickOpt) XButton1() bool

func (MouseClickOpt) XButton2

func (mk MouseClickOpt) XButton2() bool

type MsgListenerKey

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

MsgListenerKey represents a message listener added by WindowBase.AddMsgListener.

func (MsgListenerKey) Remove

func (k MsgListenerKey) Remove()

Remove removes the listener.

type PopupMenuSpec

type PopupMenuSpec struct {
	Flags   win32.TRACK_POPUP_MENU_FLAG
	X, Y    win32.LONG // Screen coordinates.
	Exclude *win32.RECT
}

type Spec

type Spec struct {
	ClassName string
	Text      string
	Style     win32.WINDOW_STYLE
	ExStyle   win32.WINDOW_EX_STYLE
	X         metrics.Dimension
	Y         metrics.Dimension
	Width     metrics.Dimension
	Height    metrics.Dimension
	WndParent win32.HWND
	Menu      *menu.Menu
	Instance  win32.HINSTANCE // 0 for this module.
	OnCreate  func()
	OnClose   func() bool // Return true to allow closing, false to prevent.
	OnDestroy func()
}

type Window

type Window struct {
	WindowBase
	OnCreate  func()
	OnClose   func() bool
	OnDestroy func()
}

func New

func New(spec *Spec) (*Window, error)

func (*Window) SetMenu

func (w *Window) SetMenu(menu *menu.Menu) error

type WindowBase

type WindowBase struct {
	OnLButtonUp   func(opt MouseClickOpt, x int, y int)
	OnLButtonDown func(opt MouseClickOpt, x int, y int)
	OnRButtonUp   func(opt MouseClickOpt, x int, y int)
	OnRButtonDown func(opt MouseClickOpt, x int, y int)
	// contains filtered or unexported fields
}

func LookupWindowBase

func LookupWindowBase(hwnd win32.HWND) *WindowBase

LookupWindowBase looks up the WindowBase associated with hwnd. It returns nil if not found.

func Query

func Query(hwnd win32.HWND) *WindowBase

func (*WindowBase) AddDoubleBufferingPaintCallback

func (w *WindowBase) AddDoubleBufferingPaintCallback() (err error)

func (*WindowBase) AddMsgListener

func (w *WindowBase) AddMsgListener(message win32.UINT,
	listener func(hwnd win32.HWND, message win32.UINT, wParam win32.WPARAM, lParam win32.LPARAM)) MsgListenerKey

AddMsgListener adds a listener that is called when the message is received in the window procedure. To remove the listener, call Remove() of the returned MsgListenerKey.

func (*WindowBase) AddPaintCallback

func (w *WindowBase) AddPaintCallback(f func(data *paint.PaintData, prev func(*paint.PaintData)))

func (*WindowBase) DPI

func (w *WindowBase) DPI() (win32.UINT, error)

func (*WindowBase) Destroy

func (w *WindowBase) Destroy() error

func (*WindowBase) GetClientRect

func (w *WindowBase) GetClientRect() (*win32.RECT, error)

func (*WindowBase) GetWindowRect

func (w *WindowBase) GetWindowRect() (*win32.RECT, error)

func (*WindowBase) HWND

func (w *WindowBase) HWND() win32.HWND

func (*WindowBase) InvalidateRect

func (w *WindowBase) InvalidateRect(rect *win32.RECT, eraseBk bool) error

func (*WindowBase) SetText

func (w *WindowBase) SetText(text string) error

func (*WindowBase) SetValue

func (w *WindowBase) SetValue(key, value any)

Value sets the value associated with this window for key. Setting A nil value deletes the value associated with key if any. See Context.Value() in context package for the concept and usage of associated value.

func (*WindowBase) SetWndProc

func (w *WindowBase) SetWndProc(wndProc WndProc)

SetWndProc sets the window procedure of w. It panics if wndProc is nil.

func (*WindowBase) Show

func (w *WindowBase) Show(cmd win32.SHOW_WINDOW_CMD)

func (*WindowBase) Text

func (w *WindowBase) Text() (string, error)

func (*WindowBase) TrackPopupMenu

func (w *WindowBase) TrackPopupMenu(menu *menu.Menu, spec *PopupMenuSpec) error

TrackPopupMenu tracks a popup menu. If spec is nil, default flag, empty exclude RECT and GetCursorPos() are used.

func (*WindowBase) Value

func (w *WindowBase) Value(key any) any

Value returns the value associated with this window for key, or nil if no value is associated with key. See Context.Value() in context package for the concept and usage of associated value.

type WndProc

type WndProc func(hwnd win32.HWND, message win32.UINT, wParam win32.WPARAM, lParam win32.LPARAM, prevWndProc win32.WndProc) win32.LRESULT

Jump to

Keyboard shortcuts

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