2014-02-07 20:17:24 -06:00
// 7 february 2014
2014-03-12 20:55:45 -05:00
2014-02-19 10:41:10 -06:00
package ui
2014-02-07 20:17:24 -06:00
import (
"syscall"
2014-02-10 11:44:11 -06:00
"unsafe"
2014-02-07 20:17:24 -06:00
)
var (
user32 = syscall . NewLazyDLL ( "user32.dll" )
2014-02-08 22:51:11 -06:00
kernel32 = syscall . NewLazyDLL ( "kernel32.dll" )
2014-02-10 19:48:08 -06:00
gdi32 = syscall . NewLazyDLL ( "gdi32.dll" )
2014-04-02 12:47:11 -05:00
comctl32 * syscall . LazyDLL // comctl32 not defined here; see comctl_windows.go
2014-04-11 20:30:19 -05:00
msimg32 = syscall . NewLazyDLL ( "msimg32.dll" )
2014-02-07 20:17:24 -06:00
)
2014-02-11 17:36:13 -06:00
type _HANDLE uintptr
type _HWND _HANDLE
type _HBRUSH _HANDLE
type _HMENU _HANDLE
2014-02-07 20:17:24 -06:00
const (
2014-02-11 17:36:13 -06:00
_NULL = 0
_FALSE = 0 // from windef.h
_TRUE = 1 // from windef.h
2014-02-07 20:17:24 -06:00
)
2014-02-15 14:41:50 -06:00
// In MSDN, _LPARAM and _LRESULT are listed as signed pointers, however their interpretation is message-specific. Ergo, just cast them yourself; it'll be the same. (Thanks to Tv` in #go-nuts for helping me realize this.)
2014-02-11 17:36:13 -06:00
type _WPARAM uintptr
type _LPARAM uintptr
type _LRESULT uintptr
2014-02-08 22:51:11 -06:00
2014-02-11 17:36:13 -06:00
func ( w _WPARAM ) LOWORD ( ) uint16 {
2014-02-10 03:59:39 -06:00
// according to windef.h
return uint16 ( w & 0xFFFF )
}
2014-02-11 17:36:13 -06:00
func ( w _WPARAM ) HIWORD ( ) uint16 {
2014-02-10 03:59:39 -06:00
// according to windef.h
return uint16 ( ( w >> 16 ) & 0xFFFF )
}
2014-02-11 17:36:13 -06:00
func _LPARAMFromString ( str string ) _LPARAM {
return _LPARAM ( unsafe . Pointer ( syscall . StringToUTF16Ptr ( str ) ) )
2014-02-10 11:44:11 -06:00
}
2014-02-08 22:51:11 -06:00
// microsoft's header files do this
2014-02-11 17:36:13 -06:00
func _MAKEINTRESOURCE ( what uint16 ) uintptr {
2014-02-08 22:51:11 -06:00
return uintptr ( what )
}
2014-02-10 11:44:11 -06:00
2014-03-25 14:06:43 -05:00
func ( l _LPARAM ) _X ( ) int32 {
// according to windowsx.h
loword := uint16 ( l & 0xFFFF )
short := int16 ( loword ) // convert to signed...
return int32 ( short ) // ...and sign extend
}
func ( l _LPARAM ) _Y ( ) int32 {
// according to windowsx.h
hiword := uint16 ( ( l & 0xFFFF0000 ) >> 16 )
short := int16 ( hiword ) // convert to signed...
return int32 ( short ) // ...and sign extend
}
2014-02-11 17:36:13 -06:00
type _POINT struct {
2014-05-11 10:11:00 -05:00
x int32
y int32
2014-02-11 17:36:13 -06:00
}
type _RECT struct {
2014-05-11 10:11:00 -05:00
left int32
top int32
right int32
bottom int32
2014-02-11 17:36:13 -06:00
}
2014-04-13 12:11:17 -05:00
// Predefined cursor resource IDs.
const (
_IDC_APPSTARTING = 32650
_IDC_ARROW = 32512
_IDC_CROSS = 32515
_IDC_HAND = 32649
_IDC_HELP = 32651
_IDC_IBEAM = 32513
// _IDC_ICON = 32641 // [Obsolete for applications marked version 4.0 or later.]
_IDC_NO = 32648
// _IDC_SIZE = 32640 // [Obsolete for applications marked version 4.0 or later. Use IDC_SIZEALL.]
_IDC_SIZEALL = 32646
_IDC_SIZENESW = 32643
_IDC_SIZENS = 32645
_IDC_SIZENWSE = 32642
_IDC_SIZEWE = 32644
_IDC_UPARROW = 32516
_IDC_WAIT = 32514
)
// Predefined icon resource IDs.
const (
_IDI_APPLICATION = 32512
_IDI_ASTERISK = 32516
_IDI_ERROR = 32513
_IDI_EXCLAMATION = 32515
_IDI_HAND = 32513
_IDI_INFORMATION = 32516
_IDI_QUESTION = 32514
_IDI_SHIELD = 32518
_IDI_WARNING = 32515
_IDI_WINLOGO = 32517
)