More error corrections; not done yet...
This commit is contained in:
parent
09a42e0c34
commit
ecb2205e02
|
@ -8,24 +8,24 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
hInstance HANDLE
|
||||
hInstance _HANDLE
|
||||
nCmdShow int
|
||||
// TODO font
|
||||
)
|
||||
|
||||
// TODO is this trick documented in MSDN?
|
||||
func getWinMainhInstance() (err error) {
|
||||
r1, _, err := kernel32.NewProc("GetModuleHandleW").Call(uintptr(NULL))
|
||||
r1, _, err := kernel32.NewProc("GetModuleHandleW").Call(uintptr(_NULL))
|
||||
if r1 == 0 { // failure
|
||||
return err
|
||||
}
|
||||
hInstance = HANDLE(r1)
|
||||
hInstance = _HANDLE(r1)
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO this is what MinGW-w64's crt (svn revision xxx) does; is it best? is any of this documented anywhere on MSDN?
|
||||
// TODO this is what MinGW-w64's crt (svn revision TODO) does; is it best? is any of this documented anywhere on MSDN?
|
||||
// TODO I highly doubt Windows API functions ever not fail, so figure out what to do should an error actually occur
|
||||
func getWinMainnCmdShow() (nCmdShow int, err error) {
|
||||
func getWinMainnCmdShow() (err error) {
|
||||
var info struct {
|
||||
cb uint32
|
||||
lpReserved *uint16
|
||||
|
@ -42,9 +42,9 @@ func getWinMainnCmdShow() (nCmdShow int, err error) {
|
|||
wShowWindow uint16
|
||||
cbReserved2 uint16
|
||||
lpReserved2 *byte
|
||||
hStdInput HANDLE
|
||||
hStdOutput HANDLE
|
||||
hStdError HANDLE
|
||||
hStdInput _HANDLE
|
||||
hStdOutput _HANDLE
|
||||
hStdError _HANDLE
|
||||
}
|
||||
const _STARTF_USESHOWWINDOW = 0x00000001
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// +build ignore
|
||||
|
||||
// 7 february 2014
|
||||
package main
|
||||
|
||||
//+build skip
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
|
|
@ -26,4 +26,5 @@ func (c *cSysData) hide() error {
|
|||
const (
|
||||
c_window = iota
|
||||
c_button
|
||||
nctypes
|
||||
)
|
||||
|
|
|
@ -26,7 +26,7 @@ type classData struct {
|
|||
|
||||
var classTypes = [nctypes]*classData{
|
||||
c_window: &classData{
|
||||
name: uintptr(unsafe.Pointer(stdWndClass)),
|
||||
name: uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(stdWndClass))),
|
||||
style: _WS_OVERLAPPEDWINDOW,
|
||||
xstyle: 0,
|
||||
},
|
||||
|
@ -57,7 +57,7 @@ func (s *sysData) make() (err error) {
|
|||
uintptr(hInstance),
|
||||
uintptr(_NULL),
|
||||
},
|
||||
ret: ret
|
||||
ret: ret,
|
||||
}
|
||||
r := <-ret
|
||||
if r.err != nil {
|
||||
|
@ -87,7 +87,7 @@ func (s *sysData) show() (err error) {
|
|||
defer close(ret)
|
||||
uitask <- &uimsg{
|
||||
call: _showWindow,
|
||||
p: []uintptr{uintptr(s.hwnd, show},
|
||||
p: []uintptr{uintptr(s.hwnd), show},
|
||||
ret: ret,
|
||||
}
|
||||
r := <-ret
|
||||
|
|
|
@ -15,7 +15,7 @@ type sdcEntry struct {
|
|||
|
||||
var (
|
||||
sysDatas = map[_HWND]*sdcEntry{}
|
||||
sysDatasLock sys.Mutex
|
||||
sysDatasLock sync.Mutex
|
||||
)
|
||||
|
||||
func addSysData(hwnd _HWND, s *sysData) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
// "syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
|
@ -173,27 +173,7 @@ var (
|
|||
_showWindow = user32.NewProc("ShowWindow")
|
||||
)
|
||||
|
||||
// TODO use lpParam
|
||||
func CreateWindowEx(dwExStyle uint32, lpClassName string, lpWindowName string, dwStyle uint32, x int, y int, nWidth int, nHeight int, hwndParent HWND, hMenu HMENU, hInstance HANDLE, lpParam interface{}) (hwnd HWND, err error) {
|
||||
r1, _, err := createWindowEx.Call(
|
||||
uintptr(dwExStyle),
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpClassName))),
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpWindowName))),
|
||||
uintptr(dwStyle),
|
||||
uintptr(x),
|
||||
uintptr(y),
|
||||
uintptr(nWidth),
|
||||
uintptr(nHeight),
|
||||
uintptr(hwndParent),
|
||||
uintptr(hMenu),
|
||||
uintptr(hInstance),
|
||||
uintptr(0))
|
||||
if r1 == 0 { // failure
|
||||
return NULL, err
|
||||
}
|
||||
return HWND(r1), nil
|
||||
}
|
||||
|
||||
/*
|
||||
func DestroyWindow(hWnd HWND) (err error) {
|
||||
r1, _, err := destroyWindow.Call(uintptr(hWnd))
|
||||
if r1 == 0 { // failure
|
||||
|
@ -249,14 +229,7 @@ func SetWindowPos(hWnd HWND, hWndInsertAfter HWND, X int, Y int, cx int, cy int,
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO figure out how to handle errors
|
||||
func ShowWindow(hWnd HWND, nCmdShow int) (previouslyVisible bool, err error) {
|
||||
r1, _, _ := showWindow.Call(
|
||||
uintptr(hWnd),
|
||||
uintptr(nCmdShow))
|
||||
return r1 != 0, nil
|
||||
}
|
||||
*/
|
||||
|
||||
// WM_SETICON and WM_GETICON values.
|
||||
const (
|
||||
|
@ -377,6 +350,6 @@ type _MINMAXINFO struct {
|
|||
PtMaxTrackSize _POINT
|
||||
}
|
||||
|
||||
func (l _LPARAM) MINMAXINFO() *MINMAXINFO {
|
||||
func (l _LPARAM) MINMAXINFO() *_MINMAXINFO {
|
||||
return (*_MINMAXINFO)(unsafe.Pointer(l))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue