Started implementing the public API: added the Window and Control types and the skeleton of the Windows implementation.
This commit is contained in:
parent
394bf3ed9c
commit
9794814e93
|
@ -0,0 +1,14 @@
|
|||
// 11 february 2014
|
||||
//package ui
|
||||
package main
|
||||
|
||||
import (
|
||||
// ...
|
||||
)
|
||||
|
||||
// A Control represents an UI control. Note that Control contains unexported members; this has the consequence that you can't build custom controls that interface directly with the system-specific code (fo rinstance, to import an unsupported control), or at least not without some hackery. If you want to make your own controls, embed Area and provide its necessities.
|
||||
type Control interface {
|
||||
apply() error
|
||||
unapply() error
|
||||
setParent(c Control)
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
// 11 february 2014
|
||||
package main
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// The sysData type contains all system data. It provides the system-specific underlying implementation. It is guaranteed to have the following by embedding:
|
||||
type cSysData struct {
|
||||
ctype int
|
||||
text string
|
||||
}
|
||||
func (c *cSysData) make() error {
|
||||
panic(runtime.GOOS + " sysData does not define make()")
|
||||
}
|
||||
func (c *cSysData) show() error {
|
||||
panic(runtime.GOOS + " sysData does not define show()")
|
||||
}
|
||||
func (c *cSysData) show() error {
|
||||
panic(runtime.GOOS + " sysData does not define hide()")
|
||||
}
|
||||
|
||||
const (
|
||||
c_window = iota
|
||||
c_button
|
||||
)
|
|
@ -0,0 +1,66 @@
|
|||
// 11 february 2014
|
||||
package main
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type sysData struct {
|
||||
cSysData
|
||||
|
||||
hwnd _HWND
|
||||
cid _HMENU
|
||||
}
|
||||
|
||||
type classData struct {
|
||||
name uintptr
|
||||
style uint32
|
||||
xstyle uint32
|
||||
}
|
||||
|
||||
//const controlstyle = _WS_CHILD | _WS_VISIBLE | _WS_TABSTOP
|
||||
//const controlxstyle = 0
|
||||
|
||||
var classTypes = [nctypes]*classData{
|
||||
c_window: &classData{
|
||||
name: uintptr(unsafe.Pointer(windowclass)),
|
||||
style: xxxx,
|
||||
xstyle: xxxx,
|
||||
},
|
||||
// c_button: &classData{
|
||||
// name: uintptr(unsafe.Pointer("BUTTON"))
|
||||
// style: _BS_PUSHBUTTON | controlstyle,
|
||||
// xstyle: 0 | controlxstyle,
|
||||
// },
|
||||
}
|
||||
|
||||
func (s *sysData) make() (err error) {
|
||||
|
||||
}
|
||||
|
||||
func (s *sysData) show() (err error) {
|
||||
ret := make(chan uiret)
|
||||
defer close(ret)
|
||||
uitask <- &uimsg{
|
||||
call: os_showWindow,
|
||||
p: []uintptr{uintptr(s.hwnd, _SW_SHOW},
|
||||
ret: ret,
|
||||
}
|
||||
r := <-ret
|
||||
close(ret)
|
||||
return r.err
|
||||
}
|
||||
|
||||
func (s *sysData) hide() (err error) {
|
||||
ret := make(chan uiret)
|
||||
defer close(ret)
|
||||
uitask <- &uimsg{
|
||||
call: _showWindow,
|
||||
p: []uintptr{uintptr(s.hwnd), _SW_HIDE},
|
||||
ret: ret,
|
||||
}
|
||||
r := <-ret
|
||||
close(ret)
|
||||
return r.err
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// 11 february 2014
|
||||
//package ui
|
||||
package main
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var uitask chan *uimsg
|
||||
|
||||
type uimsg struct {
|
||||
call *syscall.LazyProc
|
||||
p []uintptr
|
||||
ret chan uiret
|
||||
}
|
||||
|
||||
type uiret struct {
|
||||
ret uintptr
|
||||
err error
|
||||
}
|
||||
|
||||
func ui(initDone chan error) {
|
||||
runtime.LockOSThread()
|
||||
|
||||
// initialize hInstance
|
||||
// initialize nCmdShow
|
||||
// initialize the common window class
|
||||
uitask = make(chan *uimsg)
|
||||
initDone <- nil
|
||||
|
||||
for m := range uitask {
|
||||
r1, _, err := m.msg.Call(m.p...)
|
||||
m.ret <- uiret{
|
||||
ret: r1,
|
||||
err: err,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
// 11 february 2014
|
||||
//package ui
|
||||
package main
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// TODO adorn errors in each stage with which stage failed?
|
||||
|
||||
// Window represents an on-screen window.
|
||||
type Window struct {
|
||||
// If this channel is non-nil, the event loop will receive on this when the user clicks the window's close button.
|
||||
// This channel can only be set before initially opening the window.
|
||||
Closing chan struct{}
|
||||
|
||||
lock sync.Mutex
|
||||
created bool
|
||||
control Control
|
||||
sysData *sysData
|
||||
}
|
||||
|
||||
// NewWindow creates a new window with the given title. The window is not constructed at the OS level until a call to Open().
|
||||
func NewWindow(title string) *Window {
|
||||
return &Window{
|
||||
sysData: &sysData{
|
||||
ctype: c_window,
|
||||
text: title,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// SetControl sets the window's central control to control.
|
||||
func (w *Window) SetControl(control Control) (err error) {
|
||||
w.lock.Lock()
|
||||
defer w.lock.Unlock()
|
||||
|
||||
w.control = control
|
||||
err = w.control.unapply()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.control.setParent(w)
|
||||
if w.created {
|
||||
err = w.control.apply()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Open opens the window. If the OS window has not been created yet, this function will.
|
||||
func (w *Window) Open() (err error) {
|
||||
w.lock.Lock()
|
||||
defer w.lock.Unlock()
|
||||
|
||||
// If the window has already been created, show it.
|
||||
if !w.created {
|
||||
err = w.sysData.make()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if w.control != nil {
|
||||
err = w.control.apply()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return w.sysData.show()
|
||||
}
|
||||
|
||||
// Close closes the window. The window is not destroyed; it is merely hidden.
|
||||
func (w *Window) Close() (err error) {
|
||||
return w.sysData.hide()
|
||||
}
|
||||
|
||||
// These satisfy the Control interface, allowing a window to own a control. As a consequence, Windows are themselves Controls. THIS IS UNDOCUMENTED AND UNSUPPORTED. I can make it supported in the future, but for now, no. You shouldn't be depending on the internals of the library to develop your programs: if the documentation is incomplete and/or wrong, get the person responsible to fix it, as the documentation, not the implementation, is your contract to what you can or cannot do. Don't worry, this package is in good company: Go itself was designed spec-first for this reason.
|
||||
// If I decide not to support windows as controls, a better way to deal with controls would be in order. Perhaps separate interfaces...? Making Windows Controls seems the cleanest option for now (and with correct usage of the library costs nothing).
|
||||
func (w *Window) apply() error {
|
||||
panic("Window.apply() should never be called")
|
||||
}
|
||||
func (w *Window) unapply() error {
|
||||
panic("Window.unapply() should never be called")
|
||||
}
|
||||
func (w *Window) setParent(c Control) {
|
||||
panic("Window.setParent() should never be called")
|
||||
}
|
|
@ -8,169 +8,169 @@ import (
|
|||
|
||||
// Window styles.
|
||||
const (
|
||||
WS_BORDER = 0x00800000
|
||||
WS_CAPTION = 0x00C00000
|
||||
WS_CHILD = 0x40000000
|
||||
WS_CHILDWINDOW = 0x40000000
|
||||
WS_CLIPCHILDREN = 0x02000000
|
||||
WS_CLIPSIBLINGS = 0x04000000
|
||||
WS_DISABLED = 0x08000000
|
||||
WS_DLGFRAME = 0x00400000
|
||||
WS_GROUP = 0x00020000
|
||||
WS_HSCROLL = 0x00100000
|
||||
WS_ICONIC = 0x20000000
|
||||
WS_MAXIMIZE = 0x01000000
|
||||
WS_MAXIMIZEBOX = 0x00010000
|
||||
WS_MINIMIZE = 0x20000000
|
||||
WS_MINIMIZEBOX = 0x00020000
|
||||
WS_OVERLAPPED = 0x00000000
|
||||
WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
|
||||
WS_POPUP = 0x80000000
|
||||
WS_POPUPWINDOW = (WS_POPUP | WS_BORDER | WS_SYSMENU)
|
||||
WS_SIZEBOX = 0x00040000
|
||||
WS_SYSMENU = 0x00080000
|
||||
WS_TABSTOP = 0x00010000
|
||||
WS_THICKFRAME = 0x00040000
|
||||
WS_TILED = 0x00000000
|
||||
WS_TILEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
|
||||
WS_VISIBLE = 0x10000000
|
||||
WS_VSCROLL = 0x00200000
|
||||
_WS_BORDER = 0x00800000
|
||||
_WS_CAPTION = 0x00C00000
|
||||
_WS_CHILD = 0x40000000
|
||||
_WS_CHILDWINDOW = 0x40000000
|
||||
_WS_CLIPCHILDREN = 0x02000000
|
||||
_WS_CLIPSIBLINGS = 0x04000000
|
||||
_WS_DISABLED = 0x08000000
|
||||
_WS_DLGFRAME = 0x00400000
|
||||
_WS_GROUP = 0x00020000
|
||||
_WS_HSCROLL = 0x00100000
|
||||
_WS_ICONIC = 0x20000000
|
||||
_WS_MAXIMIZE = 0x01000000
|
||||
_WS_MAXIMIZEBOX = 0x00010000
|
||||
_WS_MINIMIZE = 0x20000000
|
||||
_WS_MINIMIZEBOX = 0x00020000
|
||||
_WS_OVERLAPPED = 0x00000000
|
||||
_WS_OVERLAPPEDWINDOW = (_WS_OVERLAPPED | _WS_CAPTION | _WS_SYSMENU | _WS_THICKFRAME | _WS_MINIMIZEBOX | _WS_MAXIMIZEBOX)
|
||||
_WS_POPUP = 0x80000000
|
||||
_WS_POPUPWINDOW = (_WS_POPUP | _WS_BORDER | _WS_SYSMENU)
|
||||
_WS_SIZEBOX = 0x00040000
|
||||
_WS_SYSMENU = 0x00080000
|
||||
_WS_TABSTOP = 0x00010000
|
||||
_WS_THICKFRAME = 0x00040000
|
||||
_WS_TILED = 0x00000000
|
||||
_WS_TILEDWINDOW = (_WS_OVERLAPPED | _WS_CAPTION | _WS_SYSMENU | _WS_THICKFRAME | _WS_MINIMIZEBOX | _WS_MAXIMIZEBOX)
|
||||
_WS_VISIBLE = 0x10000000
|
||||
_WS_VSCROLL = 0x00200000
|
||||
)
|
||||
|
||||
// Extended window styles.
|
||||
const (
|
||||
WS_EX_ACCEPTFILES = 0x00000010
|
||||
WS_EX_APPWINDOW = 0x00040000
|
||||
WS_EX_CLIENTEDGE = 0x00000200
|
||||
// WS_EX_COMPOSITED = 0x02000000 // [Windows 2000:This style is not supported.]
|
||||
WS_EX_CONTEXTHELP = 0x00000400
|
||||
WS_EX_CONTROLPARENT = 0x00010000
|
||||
WS_EX_DLGMODALFRAME = 0x00000001
|
||||
WS_EX_LAYERED = 0x00080000
|
||||
WS_EX_LAYOUTRTL = 0x00400000
|
||||
WS_EX_LEFT = 0x00000000
|
||||
WS_EX_LEFTSCROLLBAR = 0x00004000
|
||||
WS_EX_LTRREADING = 0x00000000
|
||||
WS_EX_MDICHILD = 0x00000040
|
||||
WS_EX_NOACTIVATE = 0x08000000
|
||||
WS_EX_NOINHERITLAYOUT = 0x00100000
|
||||
WS_EX_NOPARENTNOTIFY = 0x00000004
|
||||
WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
|
||||
WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
|
||||
WS_EX_RIGHT = 0x00001000
|
||||
WS_EX_RIGHTSCROLLBAR = 0x00000000
|
||||
WS_EX_RTLREADING = 0x00002000
|
||||
WS_EX_STATICEDGE = 0x00020000
|
||||
WS_EX_TOOLWINDOW = 0x00000080
|
||||
WS_EX_TOPMOST = 0x00000008
|
||||
WS_EX_TRANSPARENT = 0x00000020
|
||||
WS_EX_WINDOWEDGE = 0x00000100
|
||||
_WS_EX_ACCEPTFILES = 0x00000010
|
||||
_WS_EX_APPWINDOW = 0x00040000
|
||||
_WS_EX_CLIENTEDGE = 0x00000200
|
||||
// _WS_EX_COMPOSITED = 0x02000000 // [Windows 2000:This style is not supported.]
|
||||
_WS_EX_CONTEXTHELP = 0x00000400
|
||||
_WS_EX_CONTROLPARENT = 0x00010000
|
||||
_WS_EX_DLGMODALFRAME = 0x00000001
|
||||
_WS_EX_LAYERED = 0x00080000
|
||||
_WS_EX_LAYOUTRTL = 0x00400000
|
||||
_WS_EX_LEFT = 0x00000000
|
||||
_WS_EX_LEFTSCROLLBAR = 0x00004000
|
||||
_WS_EX_LTRREADING = 0x00000000
|
||||
_WS_EX_MDICHILD = 0x00000040
|
||||
_WS_EX_NOACTIVATE = 0x08000000
|
||||
_WS_EX_NOINHERITLAYOUT = 0x00100000
|
||||
_WS_EX_NOPARENTNOTIFY = 0x00000004
|
||||
_WS_EX_OVERLAPPEDWINDOW = (_WS_EX_WINDOWEDGE | _WS_EX_CLIENTEDGE)
|
||||
_WS_EX_PALETTEWINDOW = (_WS_EX_WINDOWEDGE | _WS_EX_TOOLWINDOW | _WS_EX_TOPMOST)
|
||||
_WS_EX_RIGHT = 0x00001000
|
||||
_WS_EX_RIGHTSCROLLBAR = 0x00000000
|
||||
_WS_EX_RTLREADING = 0x00002000
|
||||
_WS_EX_STATICEDGE = 0x00020000
|
||||
_WS_EX_TOOLWINDOW = 0x00000080
|
||||
_WS_EX_TOPMOST = 0x00000008
|
||||
_WS_EX_TRANSPARENT = 0x00000020
|
||||
_WS_EX_WINDOWEDGE = 0x00000100
|
||||
)
|
||||
|
||||
// bizarrely, this value is given on the page for CreateMDIWindow, but not CreateWindow or CreateWindowEx
|
||||
// I do it this way because Go won't let me shove the exact value into an int
|
||||
var (
|
||||
_uCW_USEDEFAULT uint = 0x80000000
|
||||
CW_USEDEFAULT = int(_uCW_USEDEFAULT)
|
||||
__CW_USEDEFAULT uint = 0x80000000
|
||||
_CW_USEDEFAULT = int(__CW_USEDEFAULT)
|
||||
)
|
||||
|
||||
// GetSysColor values. These can be cast to HBRUSH (after adding 1) for WNDCLASS as well.
|
||||
const (
|
||||
COLOR_3DDKSHADOW = 21
|
||||
COLOR_3DFACE = 15
|
||||
COLOR_3DHIGHLIGHT = 20
|
||||
COLOR_3DHILIGHT = 20
|
||||
COLOR_3DLIGHT = 22
|
||||
COLOR_3DSHADOW = 16
|
||||
COLOR_ACTIVEBORDER = 10
|
||||
COLOR_ACTIVECAPTION = 2
|
||||
COLOR_APPWORKSPACE = 12
|
||||
COLOR_BACKGROUND = 1
|
||||
COLOR_BTNFACE = 15
|
||||
COLOR_BTNHIGHLIGHT = 20
|
||||
COLOR_BTNHILIGHT = 20
|
||||
COLOR_BTNSHADOW = 16
|
||||
COLOR_BTNTEXT = 18
|
||||
COLOR_CAPTIONTEXT = 9
|
||||
COLOR_DESKTOP = 1
|
||||
COLOR_GRADIENTACTIVECAPTION = 27
|
||||
COLOR_GRADIENTINACTIVECAPTION = 28
|
||||
COLOR_GRAYTEXT = 17
|
||||
COLOR_HIGHLIGHT = 13
|
||||
COLOR_HIGHLIGHTTEXT = 14
|
||||
COLOR_HOTLIGHT = 26
|
||||
COLOR_INACTIVEBORDER = 11
|
||||
COLOR_INACTIVECAPTION = 3
|
||||
COLOR_INACTIVECAPTIONTEXT = 19
|
||||
COLOR_INFOBK = 24
|
||||
COLOR_INFOTEXT = 23
|
||||
COLOR_MENU = 4
|
||||
_COLOR_3DDKSHADOW = 21
|
||||
_COLOR_3DFACE = 15
|
||||
_COLOR_3DHIGHLIGHT = 20
|
||||
_COLOR_3DHILIGHT = 20
|
||||
_COLOR_3DLIGHT = 22
|
||||
_COLOR_3DSHADOW = 16
|
||||
_COLOR_ACTIVEBORDER = 10
|
||||
_COLOR_ACTIVECAPTION = 2
|
||||
_COLOR_APPWORKSPACE = 12
|
||||
_COLOR_BACKGROUND = 1
|
||||
_COLOR_BTNFACE = 15
|
||||
_COLOR_BTNHIGHLIGHT = 20
|
||||
_COLOR_BTNHILIGHT = 20
|
||||
_COLOR_BTNSHADOW = 16
|
||||
_COLOR_BTNTEXT = 18
|
||||
_COLOR_CAPTIONTEXT = 9
|
||||
_COLOR_DESKTOP = 1
|
||||
_COLOR_GRADIENTACTIVECAPTION = 27
|
||||
_COLOR_GRADIENTINACTIVECAPTION = 28
|
||||
_COLOR_GRAYTEXT = 17
|
||||
_COLOR_HIGHLIGHT = 13
|
||||
_COLOR_HIGHLIGHTTEXT = 14
|
||||
_COLOR_HOTLIGHT = 26
|
||||
_COLOR_INACTIVEBORDER = 11
|
||||
_COLOR_INACTIVECAPTION = 3
|
||||
_COLOR_INACTIVECAPTIONTEXT = 19
|
||||
_COLOR_INFOBK = 24
|
||||
_COLOR_INFOTEXT = 23
|
||||
_COLOR_MENU = 4
|
||||
// COLOR_MENUHILIGHT = 29 // [Windows 2000:This value is not supported.]
|
||||
// COLOR_MENUBAR = 30 // [Windows 2000:This value is not supported.]
|
||||
COLOR_MENUTEXT = 7
|
||||
COLOR_SCROLLBAR = 0
|
||||
COLOR_WINDOW = 5
|
||||
COLOR_WINDOWFRAME = 6
|
||||
COLOR_WINDOWTEXT = 8
|
||||
_COLOR_MENUTEXT = 7
|
||||
_COLOR_SCROLLBAR = 0
|
||||
_COLOR_WINDOW = 5
|
||||
_COLOR_WINDOWFRAME = 6
|
||||
_COLOR_WINDOWTEXT = 8
|
||||
)
|
||||
|
||||
// SetWindowPos hWndInsertAfter values.
|
||||
const (
|
||||
HWND_BOTTOM = HWND(1)
|
||||
HWND_TOP = HWND(0)
|
||||
_HWND_BOTTOM = _HWND(1)
|
||||
_HWND_TOP = _HWND(0)
|
||||
)
|
||||
|
||||
// SetWindowPos hWndInsertAfter values that Go won't allow as constants.
|
||||
var (
|
||||
_HWND_NOTOPMOST = -2
|
||||
HWND_NOTOPMOST = HWND(_HWND_NOTOPMOST)
|
||||
_HWND_TOPMOST = -1
|
||||
HWND_TOPMOST = HWND(_HWND_TOPMOST)
|
||||
__HWND_NOTOPMOST = -2
|
||||
_HWND_NOTOPMOST = _HWND(__HWND_NOTOPMOST)
|
||||
__HWND_TOPMOST = -1
|
||||
_HWND_TOPMOST = _HWND(__HWND_TOPMOST)
|
||||
)
|
||||
|
||||
// SetWindowPos uFlags values.
|
||||
const (
|
||||
SWP_DRAWFRAME = 0x0020
|
||||
SWP_FRAMECHANGED = 0x0020
|
||||
SWP_HIDEWINDOW = 0x0080
|
||||
SWP_NOACTIVATE = 0x0010
|
||||
SWP_NOCOPYBITS = 0x0100
|
||||
SWP_NOMOVE = 0x0002
|
||||
SWP_NOOWNERZORDER = 0x0200
|
||||
SWP_NOREDRAW = 0x0008
|
||||
SWP_NOREPOSITION = 0x0200
|
||||
SWP_NOSENDCHANGING = 0x0400
|
||||
SWP_NOSIZE = 0x0001
|
||||
SWP_NOZORDER = 0x0004
|
||||
SWP_SHOWWINDOW = 0x0040
|
||||
SWP_ASYNCWINDOWPOS = 0x4000
|
||||
SWP_DEFERERASE = 0x2000
|
||||
_SWP_DRAWFRAME = 0x0020
|
||||
_SWP_FRAMECHANGED = 0x0020
|
||||
_SWP_HIDEWINDOW = 0x0080
|
||||
_SWP_NOACTIVATE = 0x0010
|
||||
_SWP_NOCOPYBITS = 0x0100
|
||||
_SWP_NOMOVE = 0x0002
|
||||
_SWP_NOOWNERZORDER = 0x0200
|
||||
_SWP_NOREDRAW = 0x0008
|
||||
_SWP_NOREPOSITION = 0x0200
|
||||
_SWP_NOSENDCHANGING = 0x0400
|
||||
_SWP_NOSIZE = 0x0001
|
||||
_SWP_NOZORDER = 0x0004
|
||||
_SWP_SHOWWINDOW = 0x0040
|
||||
_SWP_ASYNCWINDOWPOS = 0x4000
|
||||
_SWP_DEFERERASE = 0x2000
|
||||
)
|
||||
|
||||
// ShowWindow settings.
|
||||
const (
|
||||
SW_FORCEMINIMIZE = 11
|
||||
SW_HIDE = 0
|
||||
SW_MAXIMIZE = 3
|
||||
SW_MINIMIZE = 6
|
||||
SW_RESTORE = 9
|
||||
SW_SHOW = 5
|
||||
SW_SHOWDEFAULT = 10
|
||||
SW_SHOWMAXIMIZED = 3
|
||||
SW_SHOWMINIMIZED = 2
|
||||
SW_SHOWMINNOACTIVE = 7
|
||||
SW_SHOWNA = 8
|
||||
SW_SHOWNOACTIVATE = 4
|
||||
SW_SHOWNORMAL = 1
|
||||
_SW_FORCEMINIMIZE = 11
|
||||
_SW_HIDE = 0
|
||||
_SW_MAXIMIZE = 3
|
||||
_SW_MINIMIZE = 6
|
||||
_SW_RESTORE = 9
|
||||
_SW_SHOW = 5
|
||||
_SW_SHOWDEFAULT = 10
|
||||
_SW_SHOWMAXIMIZED = 3
|
||||
_SW_SHOWMINIMIZED = 2
|
||||
_SW_SHOWMINNOACTIVE = 7
|
||||
_SW_SHOWNA = 8
|
||||
_SW_SHOWNOACTIVATE = 4
|
||||
_SW_SHOWNORMAL = 1
|
||||
)
|
||||
|
||||
var (
|
||||
createWindowEx = user32.NewProc("CreateWindowExW")
|
||||
destroyWindow = user32.NewProc("DestroyWindow")
|
||||
getClientRect = user32.NewProc("GetClientRect")
|
||||
enumChildWindows = user32.NewProc("EnumChildWindows")
|
||||
setWindowPos = user32.NewProc("SetWindowPos")
|
||||
showWindow = user32.NewProc("ShowWindow")
|
||||
_createWindowEx = user32.NewProc("CreateWindowExW")
|
||||
_destroyWindow = user32.NewProc("DestroyWindow")
|
||||
_getClientRect = user32.NewProc("GetClientRect")
|
||||
_enumChildWindows = user32.NewProc("EnumChildWindows")
|
||||
_setWindowPos = user32.NewProc("SetWindowPos")
|
||||
_showWindow = user32.NewProc("ShowWindow")
|
||||
)
|
||||
|
||||
// TODO use lpParam
|
||||
|
@ -260,123 +260,123 @@ func ShowWindow(hWnd HWND, nCmdShow int) (previouslyVisible bool, err error) {
|
|||
|
||||
// WM_SETICON and WM_GETICON values.
|
||||
const (
|
||||
ICON_BIG = 1
|
||||
ICON_SMALL = 0
|
||||
ICON_SMALL2 = 2 // WM_GETICON only?
|
||||
_ICON_BIG = 1
|
||||
_ICON_SMALL = 0
|
||||
_ICON_SMALL2 = 2 // WM_GETICON only?
|
||||
)
|
||||
|
||||
// Window messages.
|
||||
const (
|
||||
MN_GETHMENU = 0x01E1
|
||||
WM_ERASEBKGND = 0x0014
|
||||
WM_GETFONT = 0x0031
|
||||
WM_GETTEXT = 0x000D
|
||||
WM_GETTEXTLENGTH = 0x000E
|
||||
WM_SETFONT = 0x0030
|
||||
WM_SETICON = 0x0080
|
||||
WM_SETTEXT = 0x000C
|
||||
_MN_GETHMENU = 0x01E1
|
||||
_WM_ERASEBKGND = 0x0014
|
||||
_WM_GETFONT = 0x0031
|
||||
_WM_GETTEXT = 0x000D
|
||||
_WM_GETTEXTLENGTH = 0x000E
|
||||
_WM_SETFONT = 0x0030
|
||||
_WM_SETICON = 0x0080
|
||||
_WM_SETTEXT = 0x000C
|
||||
)
|
||||
|
||||
// WM_INPUTLANGCHANGEREQUEST values.
|
||||
const (
|
||||
INPUTLANGCHANGE_BACKWARD = 0x0004
|
||||
INPUTLANGCHANGE_FORWARD = 0x0002
|
||||
INPUTLANGCHANGE_SYSCHARSET = 0x0001
|
||||
_INPUTLANGCHANGE_BACKWARD = 0x0004
|
||||
_INPUTLANGCHANGE_FORWARD = 0x0002
|
||||
_INPUTLANGCHANGE_SYSCHARSET = 0x0001
|
||||
)
|
||||
|
||||
// WM_NCCALCSIZE return values.
|
||||
const (
|
||||
WVR_ALIGNTOP = 0x0010
|
||||
WVR_ALIGNRIGHT = 0x0080
|
||||
WVR_ALIGNLEFT = 0x0020
|
||||
WVR_ALIGNBOTTOM = 0x0040
|
||||
WVR_HREDRAW = 0x0100
|
||||
WVR_VREDRAW = 0x0200
|
||||
WVR_REDRAW = 0x0300
|
||||
WVR_VALIDRECTS = 0x0400
|
||||
_WVR_ALIGNTOP = 0x0010
|
||||
_WVR_ALIGNRIGHT = 0x0080
|
||||
_WVR_ALIGNLEFT = 0x0020
|
||||
_WVR_ALIGNBOTTOM = 0x0040
|
||||
_WVR_HREDRAW = 0x0100
|
||||
_WVR_VREDRAW = 0x0200
|
||||
_WVR_REDRAW = 0x0300
|
||||
_WVR_VALIDRECTS = 0x0400
|
||||
)
|
||||
|
||||
// WM_SHOWWINDOW reasons (lParam).
|
||||
const (
|
||||
SW_OTHERUNZOOM = 4
|
||||
SW_OTHERZOOM = 2
|
||||
SW_PARENTCLOSING = 1
|
||||
SW_PARENTOPENING = 3
|
||||
_SW_OTHERUNZOOM = 4
|
||||
_SW_OTHERZOOM = 2
|
||||
_SW_PARENTCLOSING = 1
|
||||
_SW_PARENTOPENING = 3
|
||||
)
|
||||
|
||||
// WM_SIZE values.
|
||||
const (
|
||||
SIZE_MAXHIDE = 4
|
||||
SIZE_MAXIMIZED = 2
|
||||
SIZE_MAXSHOW = 3
|
||||
SIZE_MINIMIZED = 1
|
||||
SIZE_RESTORED = 0
|
||||
_SIZE_MAXHIDE = 4
|
||||
_SIZE_MAXIMIZED = 2
|
||||
_SIZE_MAXSHOW = 3
|
||||
_SIZE_MINIMIZED = 1
|
||||
_SIZE_RESTORED = 0
|
||||
)
|
||||
|
||||
// WM_SIZING edge values (wParam).
|
||||
const (
|
||||
WMSZ_BOTTOM = 6
|
||||
WMSZ_BOTTOMLEFT = 7
|
||||
WMSZ_BOTTOMRIGHT = 8
|
||||
WMSZ_LEFT = 1
|
||||
WMSZ_RIGHT = 2
|
||||
WMSZ_TOP = 3
|
||||
WMSZ_TOPLEFT = 4
|
||||
WMSZ_TOPRIGHT = 5
|
||||
_WMSZ_BOTTOM = 6
|
||||
_WMSZ_BOTTOMLEFT = 7
|
||||
_WMSZ_BOTTOMRIGHT = 8
|
||||
_WMSZ_LEFT = 1
|
||||
_WMSZ_RIGHT = 2
|
||||
_WMSZ_TOP = 3
|
||||
_WMSZ_TOPLEFT = 4
|
||||
_WMSZ_TOPRIGHT = 5
|
||||
)
|
||||
|
||||
// WM_STYLECHANGED and WM_STYLECHANGING values (wParam).
|
||||
const (
|
||||
GWL_EXSTYLE = -20
|
||||
GWL_STYLE = -16
|
||||
_GWL_EXSTYLE = -20
|
||||
_GWL_STYLE = -16
|
||||
)
|
||||
|
||||
// Window notifications.
|
||||
const (
|
||||
WM_ACTIVATEAPP = 0x001C
|
||||
WM_CANCELMODE = 0x001F
|
||||
WM_CHILDACTIVATE = 0x0022
|
||||
WM_CLOSE = 0x0010
|
||||
WM_COMPACTING = 0x0041
|
||||
WM_CREATE = 0x0001
|
||||
WM_DESTROY = 0x0002
|
||||
// WM_DPICHANGED = 0x02E0 // Windows 8.1 and newer only
|
||||
WM_ENABLE = 0x000A
|
||||
WM_ENTERSIZEMOVE = 0x0231
|
||||
WM_EXITSIZEMOVE = 0x0232
|
||||
WM_GETICON = 0x007F
|
||||
WM_GETMINMAXINFO = 0x0024
|
||||
WM_INPUTLANGCHANGE = 0x0051
|
||||
WM_INPUTLANGCHANGEREQUEST = 0x0050
|
||||
WM_MOVE = 0x0003
|
||||
WM_MOVING = 0x0216
|
||||
WM_NCACTIVATE = 0x0086
|
||||
WM_NCCALCSIZE = 0x0083
|
||||
WM_NCCREATE = 0x0081
|
||||
WM_NCDESTROY = 0x0082
|
||||
WM_NULL = 0x0000
|
||||
WM_QUERYDRAGICON = 0x0037
|
||||
WM_QUERYOPEN = 0x0013
|
||||
WM_QUIT = 0x0012
|
||||
WM_SHOWWINDOW = 0x0018
|
||||
WM_SIZE = 0x0005
|
||||
WM_SIZING = 0x0214
|
||||
WM_STYLECHANGED = 0x007D
|
||||
WM_STYLECHANGING = 0x007C
|
||||
// WM_THEMECHANGED = 0x031A // Windows XP and newer only
|
||||
// WM_USERCHANGED = 0x0054 // Windows XP only: [Note This message is not supported as of Windows Vista.; also listed as not supported by server Windows]
|
||||
WM_WINDOWPOSCHANGED = 0x0047
|
||||
WM_WINDOWPOSCHANGING = 0x0046
|
||||
_WM_ACTIVATEAPP = 0x001C
|
||||
_WM_CANCELMODE = 0x001F
|
||||
_WM_CHILDACTIVATE = 0x0022
|
||||
_WM_CLOSE = 0x0010
|
||||
_WM_COMPACTING = 0x0041
|
||||
_WM_CREATE = 0x0001
|
||||
_WM_DESTROY = 0x0002
|
||||
// _WM_DPICHANGED = 0x02E0 // Windows 8.1 and newer only
|
||||
_WM_ENABLE = 0x000A
|
||||
_WM_ENTERSIZEMOVE = 0x0231
|
||||
_WM_EXITSIZEMOVE = 0x0232
|
||||
_WM_GETICON = 0x007F
|
||||
_WM_GETMINMAXINFO = 0x0024
|
||||
_WM_INPUTLANGCHANGE = 0x0051
|
||||
_WM_INPUTLANGCHANGEREQUEST = 0x0050
|
||||
_WM_MOVE = 0x0003
|
||||
_WM_MOVING = 0x0216
|
||||
_WM_NCACTIVATE = 0x0086
|
||||
_WM_NCCALCSIZE = 0x0083
|
||||
_WM_NCCREATE = 0x0081
|
||||
_WM_NCDESTROY = 0x0082
|
||||
_WM_NULL = 0x0000
|
||||
_WM_QUERYDRAGICON = 0x0037
|
||||
_WM_QUERYOPEN = 0x0013
|
||||
_WM_QUIT = 0x0012
|
||||
_WM_SHOWWINDOW = 0x0018
|
||||
_WM_SIZE = 0x0005
|
||||
_WM_SIZING = 0x0214
|
||||
_WM_STYLECHANGED = 0x007D
|
||||
_WM_STYLECHANGING = 0x007C
|
||||
// _WM_THEMECHANGED = 0x031A // Windows XP and newer only
|
||||
// _WM_USERCHANGED = 0x0054 // Windows XP only: [Note This message is not supported as of Windows Vista.; also listed as not supported by server Windows]
|
||||
_WM_WINDOWPOSCHANGED = 0x0047
|
||||
_WM_WINDOWPOSCHANGING = 0x0046
|
||||
)
|
||||
|
||||
type MINMAXINFO struct {
|
||||
PtReserved POINT
|
||||
PtMaxSize POINT
|
||||
PtMaxPosition POINT
|
||||
PtMinTrackSize POINT
|
||||
PtMaxTrackSize POINT
|
||||
type _MINMAXINFO struct {
|
||||
PtReserved _POINT
|
||||
PtMaxSize _POINT
|
||||
PtMaxPosition _POINT
|
||||
PtMinTrackSize _POINT
|
||||
PtMaxTrackSize _POINT
|
||||
}
|
||||
|
||||
func (l LPARAM) MINMAXINFO() *MINMAXINFO {
|
||||
return (*MINMAXINFO)(unsafe.Pointer(l))
|
||||
func (l _LPARAM) MINMAXINFO() *MINMAXINFO {
|
||||
return (*_MINMAXINFO)(unsafe.Pointer(l))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue