summaryrefslogtreecommitdiff
path: root/wndclass.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-02-11 13:06:12 -0500
committerPietro Gagliardi <[email protected]>2014-02-11 13:06:12 -0500
commit42229820d2a47594f68d92356f8e8a86133a29f5 (patch)
tree3cd5deef283b4540bae2f75c049a5e69d4e9db20 /wndclass.go
parenta488e3ab36de1d6a329110fbaae44cd5747c854b (diff)
Added _windows.go extensions to all the files in preparation for the library writing.
Diffstat (limited to 'wndclass.go')
-rw-r--r--wndclass.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/wndclass.go b/wndclass.go
deleted file mode 100644
index 38ff4ae..0000000
--- a/wndclass.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// 8 february 2014
-package main
-
-import (
- "syscall"
- "unsafe"
-)
-
-type WNDCLASS struct {
- Style uint32
- LpfnWndProc WNDPROC
- CbClsExtra int // TODO exact Go type for C int? MSDN says C int
- CbWndExtra int // TODO exact Go type for C int? MSDN says C int
- HInstance HANDLE // actually HINSTANCE
- HIcon HANDLE // actually HICON
- HCursor HANDLE // actually HCURSOR
- HbrBackground HBRUSH
- LpszMenuName *string // TODO this should probably just be a regular string with "" indicating no name but MSDN doesn't say if that's legal or not
- LpszClassName string
-}
-
-type _WNDCLASSW struct {
- style uint32
- lpfnWndProc uintptr
- cbClsExtra int
- cbWndExtra int
- hInstance HANDLE
- hIcon HANDLE
- hCursor HANDLE
- hbrBackground HBRUSH
- lpszMenuName *uint16
- lpszClassName *uint16
-}
-
-func (w *WNDCLASS) toNative() *_WNDCLASSW {
- menuName := (*uint16)(nil)
- if w.LpszMenuName != nil {
- menuName = syscall.StringToUTF16Ptr(*w.LpszMenuName)
- }
- return &_WNDCLASSW{
- style: w.Style,
- lpfnWndProc: syscall.NewCallback(w.LpfnWndProc),
- cbClsExtra: w.CbClsExtra,
- cbWndExtra: w.CbWndExtra,
- hInstance: w.HInstance,
- hIcon: w.HIcon,
- hCursor: w.HCursor,
- hbrBackground: w.HbrBackground,
- lpszMenuName: menuName,
- lpszClassName: syscall.StringToUTF16Ptr(w.LpszClassName),
- }
-}
-
-var (
- registerClass = user32.NewProc("RegisterClassW")
-)
-
-func RegisterClass(lpWndClass *WNDCLASS) (class ATOM, err error) {
- r1, _, err := registerClass.Call(uintptr(unsafe.Pointer(lpWndClass.toNative())))
- if r1 == 0 { // failure
- return 0, err
- }
- return ATOM(r1), nil
-}