summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-05-25 15:23:11 -0400
committerPietro Gagliardi <[email protected]>2014-05-25 15:23:11 -0400
commit2e6254ec61593d3da36bab2c855b2c7fd7f229ac (patch)
tree385f63de5b2ab0a3b1126c923995cdd45f093d01
parent51469fffb57cef9624f53a744409475fc14c6208 (diff)
Finished migrating the Windows code to using the pregenerated constants.
-rw-r--r--experiments/windowsconstgen.go4
-rw-r--r--init_windows.go1
-rw-r--r--menus_windows.go13
-rw-r--r--stdfont_windows.go5
-rw-r--r--uitask_windows.go15
-rw-r--r--zconstants_windows_386.go6
6 files changed, 12 insertions, 32 deletions
diff --git a/experiments/windowsconstgen.go b/experiments/windowsconstgen.go
index d840a1a..448b549 100644
--- a/experiments/windowsconstgen.go
+++ b/experiments/windowsconstgen.go
@@ -80,6 +80,7 @@ var hacknames = map[string]string{
"_NULL": "x_NULL",
"_IDI_APPLICATION": "x_IDI_APPLICATION",
"_IDC_ARROW": "x_IDC_ARROW",
+ "_HWND_MESSAGE": "x_HWND_MESSAGE",
}
func hacknamesPreamble() string {
@@ -126,8 +127,7 @@ func main() {
knowns += "\n" + ident + " (" + kind + ")"
}
if knowns != "" {
-//ignore for now while I still migrate everything
-// panic("error: the following are still known!" + knowns) // has a newline already
+ panic("error: the following are still known!" + knowns) // has a newline already
}
// keep sorted for git
diff --git a/init_windows.go b/init_windows.go
index e079409..08420be 100644
--- a/init_windows.go
+++ b/init_windows.go
@@ -45,7 +45,6 @@ func getWinMainnCmdShow() {
hStdOutput _HANDLE
hStdError _HANDLE
}
- const _STARTF_USESHOWWINDOW = 0x00000001
// does not fail according to MSDN
kernel32.NewProc("GetStartupInfoW").Call(uintptr(unsafe.Pointer(&info)))
diff --git a/menus_windows.go b/menus_windows.go
deleted file mode 100644
index 4c7809b..0000000
--- a/menus_windows.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// 10 february 2014
-
-package ui
-
-import (
-// "syscall"
-// "unsafe"
-)
-
-// Menu notifications.
-const (
- _WM_COMMAND = 0x0111
-)
diff --git a/stdfont_windows.go b/stdfont_windows.go
index 6083b7f..47d90aa 100644
--- a/stdfont_windows.go
+++ b/stdfont_windows.go
@@ -16,11 +16,6 @@ var (
statusbarFont _HANDLE
)
-const (
- _SPI_GETNONCLIENTMETRICS = 0x0029
- _LF_FACESIZE = 32 // from wingdi.h
-)
-
type _LOGFONT struct {
lfHeight int32
lfWidth int32
diff --git a/uitask_windows.go b/uitask_windows.go
index fed035b..65c6c4e 100644
--- a/uitask_windows.go
+++ b/uitask_windows.go
@@ -36,8 +36,7 @@ type uiret struct {
}
const (
- _WM_APP = 0x8000 + iota
- msgRequested
+ msgRequested = _WM_APP + iota + 1 // + 1 just to be safe
msgQuit
msgSetAreaSize
)
@@ -98,8 +97,6 @@ var (
_translateMessage = user32.NewProc("TranslateMessage")
)
-var getMessageFail = -1 // because Go doesn't let me
-
func msgloop() {
var msg struct {
hwnd _HWND
@@ -116,7 +113,7 @@ func msgloop() {
uintptr(_NULL),
uintptr(0),
uintptr(0))
- if r1 == uintptr(getMessageFail) { // error
+ if r1 == negConst(-1) { // error
panic("error getting message in message loop: " + err.Error())
}
if r1 == 0 { // WM_QUIT message
@@ -133,11 +130,6 @@ const (
msghandlerclass = "gomsghandler"
)
-const (
- // fron winuser.h
- _HWND_MESSAGE = -3
-)
-
func makeMessageHandler() (hwnd _HWND, err error) {
wc := &_WNDCLASS{
lpszClassName: uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(msghandlerclass))),
@@ -162,7 +154,8 @@ func makeMessageHandler() (hwnd _HWND, err error) {
negConst(_CW_USEDEFAULT),
negConst(_CW_USEDEFAULT),
negConst(_CW_USEDEFAULT),
- negConst(_HWND_MESSAGE),
+ // don't negConst() HWND_MESSAGE; windowsconstgen was given a pointer by windows.h, and pointers are unsigned, so converting it back to signed doesn't work
+ uintptr(_HWND_MESSAGE),
uintptr(_NULL),
uintptr(hInstance),
uintptr(_NULL))
diff --git a/zconstants_windows_386.go b/zconstants_windows_386.go
index 33d2998..4c63c62 100644
--- a/zconstants_windows_386.go
+++ b/zconstants_windows_386.go
@@ -44,6 +44,7 @@ const _LB_GETSELITEMS = 401
const _LB_GETTEXT = 393
const _LB_GETTEXTLEN = 394
const _LB_INSERTSTRING = 385
+const _LF_FACESIZE = 32
const _MA_ACTIVATE = 1
const _MB_ICONERROR = 16
const _MB_OK = 0
@@ -72,9 +73,11 @@ const _SIF_RANGE = 1
const _SIF_TRACKPOS = 16
const _SM_CXDOUBLECLK = 36
const _SM_CYDOUBLECLK = 37
+const _SPI_GETNONCLIENTMETRICS = 41
const _SRCCOPY = 13369376
const _SS_LEFTNOWORDWRAP = 12
const _SS_NOPREFIX = 128
+const _STARTF_USESHOWWINDOW = 1
const _SW_ERASE = 4
const _SW_HIDE = 0
const _SW_INVALIDATE = 2
@@ -115,7 +118,9 @@ const _VK_SHIFT = 16
const _VK_SUBTRACT = 109
const _VK_UP = 38
const _WM_ACTIVATE = 6
+const _WM_APP = 32768
const _WM_CLOSE = 16
+const _WM_COMMAND = 273
const _WM_ERASEBKGND = 20
const _WM_GETMINMAXINFO = 36
const _WM_GETTEXT = 13
@@ -146,6 +151,7 @@ const _WS_OVERLAPPEDWINDOW = 13565952
const _WS_TABSTOP = 65536
const _WS_VISIBLE = 268435456
const _WS_VSCROLL = 2097152
+const _HWND_MESSAGE = 4294967293
const _IDC_ARROW = 32512
const _IDI_APPLICATION = 32512
const _INVALID_HANDLE_VALUE = 4294967295