Merge branch 'sbinet-github-imports'

This commit is contained in:
Laurent Le Goff 2015-04-17 11:17:23 +02:00
commit 3d2a09c9e2
43 changed files with 941 additions and 921 deletions

View File

@ -1,7 +1,7 @@
#include $(GOROOT)/src/Make.inc #include $(GOROOT)/src/Make.inc
all: install all: install test
install: install:
cd draw2d && go install cd draw2d && go install
@ -15,6 +15,16 @@ build:
cd postscript && go build cd postscript && go build
# cd wingui && make build # cd wingui && make build
test:
#cd cmd && go build draw2dgl.go
cd cmd && go build gettingStarted.go
cd cmd && go build testandroid.go
cd cmd && go build testdraw2d.go
cd cmd && go build testgopher.go
cd cmd && go build testimage.go
cd cmd && go build testpostscript.go
#cd cmd && go build testX11draw.go
clean: clean:
cd draw2d && go clean cd draw2d && go clean
# cd draw2dgl && make clean # cd draw2dgl && make clean

8
README
View File

@ -11,14 +11,14 @@ Some algorithm have been translated from http://www.antigrain.com project ([http
Once you have Go installed, to install draw2d: Once you have Go installed, to install draw2d:
* First see the installation procedure of [http://code.google.com/p/freetype-go/ freetype-go] * First see the installation procedure of [http://code.google.com/p/freetype-go/ freetype-go]
* goinstall draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d * `go get github.com/llgcode/draw2d/draw2d`
a good starting point is the [http://code.google.com/p/draw2d/wiki/GettingStarted getting started] a good starting point is the [http://github.com/llgcode/draw2d/wiki/GettingStarted getting started]
=== [http://code.google.com/p/draw2d/wiki/Samples Samples] === === [http://github.com/llgcode/draw2d/wiki/Samples Samples] ===
Sample images generated by draw2d (inspired by [http://cairographics.org/samples/ cairo samples]): Sample images generated by draw2d (inspired by [http://cairographics.org/samples/ cairo samples]):
there's already some bugs please refer to [http://code.google.com/p/draw2d/issues/list issue tracking] there's already some bugs please refer to [http://github.com/llgcode/draw2d/issues issue tracking]
[http://draw2d.googlecode.com/svn/wiki/test_results/TestPath.png] [http://draw2d.googlecode.com/svn/wiki/test_results/TestPath.png]
[http://draw2d.googlecode.com/svn/wiki/test_results/TestDrawArc.png] [http://draw2d.googlecode.com/svn/wiki/test_results/TestDrawArc.png]

View File

@ -18,8 +18,6 @@
package main package main
import ( import (
"code.google.com/p/draw2d/draw2dgl"
"code.google.com/p/draw2d/postscript"
"gl" "gl"
"glut" "glut"
"io/ioutil" "io/ioutil"
@ -28,6 +26,9 @@ import (
"os" "os"
"strings" "strings"
"time" "time"
"github.com/llgcode/draw2d/draw2dgl"
"github.com/llgcode/draw2d/postscript"
) )
var postscriptContent string var postscriptContent string

View File

@ -6,12 +6,12 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"image"
"image/png"
"log" "log"
"os" "os"
"code.google.com/p/draw2d/draw2d" "github.com/llgcode/draw2d/draw2d"
"image"
"image/png"
) )
func saveToPngFile(filePath string, m image.Image) { func saveToPngFile(filePath string, m image.Image) {

View File

@ -1,12 +1,13 @@
package main package main
import ( import (
"code.google.com/p/draw2d/draw2d"
"exp/gui" "exp/gui"
"exp/gui/x11" "exp/gui/x11"
"fmt" "fmt"
"image" "image"
"math" "math"
"github.com/llgcode/draw2d/draw2d"
) )
func main() { func main() {

View File

@ -3,14 +3,14 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"log"
"os"
"code.google.com/p/draw2d/draw2d"
"image" "image"
"image/color" "image/color"
"image/png" "image/png"
"log"
"math" "math"
"os"
"github.com/llgcode/draw2d/draw2d"
) )
const ( const (

View File

@ -6,14 +6,14 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"log"
"os"
"code.google.com/p/draw2d/draw2d"
"image" "image"
"image/color" "image/color"
"image/png" "image/png"
"log"
"math" "math"
"os"
"github.com/llgcode/draw2d/draw2d"
) )
const ( const (

View File

@ -3,14 +3,14 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"image"
"image/color"
"image/png"
"log" "log"
"math" "math"
"os" "os"
"code.google.com/p/draw2d/draw2d" "github.com/llgcode/draw2d/draw2d"
"image"
"image/color"
"image/png"
) )
const ( const (

View File

@ -2,7 +2,6 @@ package main
import ( import (
"bufio" "bufio"
"code.google.com/p/draw2d/draw2d"
"fmt" "fmt"
"image" "image"
"image/draw" "image/draw"
@ -10,6 +9,8 @@ import (
"log" "log"
"math" "math"
"os" "os"
"github.com/llgcode/draw2d/draw2d"
) )
func saveToPngFile(filePath string, m image.Image) { func saveToPngFile(filePath string, m image.Image) {

View File

@ -2,8 +2,6 @@ package main
import ( import (
"bufio" "bufio"
"code.google.com/p/draw2d/draw2d"
"code.google.com/p/draw2d/postscript"
"fmt" "fmt"
"image" "image"
"image/png" "image/png"
@ -11,6 +9,9 @@ import (
"log" "log"
"os" "os"
"strings" "strings"
"github.com/llgcode/draw2d/draw2d"
"github.com/llgcode/draw2d/postscript"
) )
func saveToPngFile(filePath string, m image.Image) { func saveToPngFile(filePath string, m image.Image) {

View File

@ -4,8 +4,9 @@
package draw2d package draw2d
import ( import (
"code.google.com/p/freetype-go/freetype/raster"
"math" "math"
"code.google.com/p/freetype-go/freetype/raster"
) )
func arc(t VertexConverter, x, y, rx, ry, start, angle, scale float64) (lastX, lastY float64) { func arc(t VertexConverter, x, y, rx, ry, start, angle, scale float64) (lastX, lastY float64) {

View File

@ -1,6 +1,6 @@
package main package main
import "code.google.com/p/draw2d/draw2d/curve" import "github.com/llgcode/draw2d/draw2d/curve"
import "testing" import "testing"
import __os__ "os" import __os__ "os"
import __regexp__ "regexp" import __regexp__ "regexp"

View File

@ -24,7 +24,7 @@ func SegmentArc(t LineTracer, x, y, rx, ry, start, angle, scale float64) {
if (angle < end-da/4) != clockWise { if (angle < end-da/4) != clockWise {
curX = x + math.Cos(end)*rx curX = x + math.Cos(end)*rx
curY = y + math.Sin(end)*ry curY = y + math.Sin(end)*ry
break; break
} }
curX = x + math.Cos(angle)*rx curX = x + math.Cos(angle)*rx
curY = y + math.Sin(angle)*ry curY = y + math.Sin(angle)*ry

View File

@ -2,7 +2,6 @@ package curve
import ( import (
"bufio" "bufio"
"code.google.com/p/draw2d/draw2d/raster"
"fmt" "fmt"
"image" "image"
"image/color" "image/color"
@ -11,6 +10,8 @@ import (
"log" "log"
"os" "os"
"testing" "testing"
"github.com/llgcode/draw2d/draw2d/raster"
) )
var ( var (

View File

@ -4,10 +4,11 @@
package draw2d package draw2d
import ( import (
"code.google.com/p/freetype-go/freetype/truetype"
"io/ioutil" "io/ioutil"
"log" "log"
"path" "path"
"code.google.com/p/freetype-go/freetype/truetype"
) )
var ( var (

View File

@ -4,14 +4,15 @@
package draw2d package draw2d
import ( import (
"code.google.com/p/freetype-go/freetype/raster"
"code.google.com/p/freetype-go/freetype/truetype"
"errors" "errors"
"image" "image"
"image/color" "image/color"
"image/draw" "image/draw"
"log" "log"
"math" "math"
"code.google.com/p/freetype-go/freetype/raster"
"code.google.com/p/freetype-go/freetype/truetype"
) )
type Painter interface { type Painter interface {

View File

@ -2,14 +2,15 @@ package raster
import ( import (
"bufio" "bufio"
"code.google.com/p/draw2d/draw2d/curve"
"code.google.com/p/freetype-go/freetype/raster"
"image" "image"
"image/color" "image/color"
"image/png" "image/png"
"log" "log"
"os" "os"
"testing" "testing"
"code.google.com/p/freetype-go/freetype/raster"
"github.com/llgcode/draw2d/draw2d/curve"
) )
var flattening_threshold float64 = 0.5 var flattening_threshold float64 = 0.5

View File

@ -4,9 +4,10 @@
package draw2d package draw2d
import ( import (
"code.google.com/p/freetype-go/freetype/truetype"
"image" "image"
"image/color" "image/color"
"code.google.com/p/freetype-go/freetype/truetype"
) )
type StackGraphicContext struct { type StackGraphicContext struct {

View File

@ -4,8 +4,9 @@
package draw2d package draw2d
import ( import (
"code.google.com/p/freetype-go/freetype/raster"
"math" "math"
"code.google.com/p/freetype-go/freetype/raster"
) )
type MatrixTransform [6]float64 type MatrixTransform [6]float64

View File

@ -1,12 +1,13 @@
package draw2dgl package draw2dgl
import ( import (
"code.google.com/p/draw2d/draw2d"
"code.google.com/p/freetype-go/freetype/raster"
"gl" "gl"
"image" "image"
"image/color" "image/color"
"image/draw" "image/draw"
"code.google.com/p/freetype-go/freetype/raster"
"github.com/llgcode/draw2d/draw2d"
//"log" //"log"
) )

View File

@ -3,14 +3,14 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"log"
"os"
"code.google.com/p/draw2d/draw2d"
"image" "image"
"image/draw" "image/draw"
"image/png" "image/png"
"log"
"math" "math"
"os"
"github.com/llgcode/draw2d/draw2d"
) )
func saveToPngFile(filePath string, m image.Image) { func saveToPngFile(filePath string, m image.Image) {
@ -36,7 +36,7 @@ func saveToPngFile(filePath string, m image.Image) {
func main() { func main() {
file, err := os.Open("android.png") file, err := os.Open("android.png")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
defer file.Close() defer file.Close()
a, _, err := image.Decode(file) a, _, err := image.Decode(file)
@ -44,13 +44,13 @@ func main() {
//load go icon image //load go icon image
file2, err := os.Open("go.png") file2, err := os.Open("go.png")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
defer file2.Close() defer file2.Close()
g, _, err := image.Decode(file2) g, _, err := image.Decode(file2)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
ar := a.Bounds() ar := a.Bounds()
@ -58,7 +58,7 @@ func main() {
i := image.NewRGBA(image.Rect(0, 0, w, h)) i := image.NewRGBA(image.Rect(0, 0, w, h))
draw.Draw(i, ar, a, ar.Min, draw.Src) draw.Draw(i, ar, a, ar.Min, draw.Src)
tr := draw2d.NewRotationMatrix(x*(math.Pi / 180.0)) tr := draw2d.NewRotationMatrix(x * (math.Pi / 180.0))
draw2d.DrawImage(g, i, tr, draw.Over, draw2d.LinearFilter) draw2d.DrawImage(g, i, tr, draw.Over, draw2d.LinearFilter)
saveToPngFile("Test2.png", i) saveToPngFile("Test2.png", i)
} }

View File

@ -4,11 +4,12 @@
package postscript package postscript
import ( import (
"code.google.com/p/draw2d/draw2d"
"io" "io"
"log" "log"
"os" "os"
"strconv" "strconv"
"github.com/llgcode/draw2d/draw2d"
) )
type Interpreter struct { type Interpreter struct {
@ -44,7 +45,7 @@ func NewDictionary(prealloc int) Dictionary {
return make(Dictionary, prealloc) return make(Dictionary, prealloc)
} }
func (interpreter *Interpreter) SetGraphicContext(gc draw2d.GraphicContext) { func (interpreter *Interpreter) SetGraphicContext(gc draw2d.GraphicContext) {
interpreter.gc = gc interpreter.gc = gc
} }

View File

@ -3,8 +3,6 @@
package postscript package postscript
import ()
//int array array -> Create array of length int //int array array -> Create array of length int
func array(interpreter *Interpreter) { func array(interpreter *Interpreter) {
interpreter.Push(make([]Value, interpreter.PopInt())) interpreter.Push(make([]Value, interpreter.PopInt()))

View File

@ -5,10 +5,11 @@
package postscript package postscript
import ( import (
"code.google.com/p/draw2d/draw2d"
"image/color" "image/color"
"log" "log"
"math" "math"
"github.com/llgcode/draw2d/draw2d"
) )
//Path Construction Operators //Path Construction Operators
@ -198,7 +199,7 @@ func setcmybcolor(interpreter *Interpreter) {
} }
func setdash(interpreter *Interpreter) { func setdash(interpreter *Interpreter) {
interpreter.PopInt() // offset interpreter.PopInt() // offset
interpreter.PopArray() // dash interpreter.PopArray() // dash
//log.Printf("setdash not yet implemented dash: %v, offset: %d \n", dash, offset) //log.Printf("setdash not yet implemented dash: %v, offset: %d \n", dash, offset)
} }

View File

@ -4,10 +4,6 @@
// Miscellaneous Operators // Miscellaneous Operators
package postscript package postscript
import (
//"log"
)
//proc bind proc Replace operator names in proc with operators; perform idiom recognition //proc bind proc Replace operator names in proc with operators; perform idiom recognition
func bind(interpreter *Interpreter) { func bind(interpreter *Interpreter) {
pdef := interpreter.PopProcedureDefinition() pdef := interpreter.PopProcedureDefinition()

View File

@ -7,109 +7,109 @@
package wingui package wingui
import ( import (
"syscall" "syscall"
"unsafe" "unsafe"
) )
type Wndclassex struct { type Wndclassex struct {
Size uint32 Size uint32
Style uint32 Style uint32
WndProc uintptr WndProc uintptr
ClsExtra int32 ClsExtra int32
WndExtra int32 WndExtra int32
Instance syscall.Handle Instance syscall.Handle
Icon syscall.Handle Icon syscall.Handle
Cursor syscall.Handle Cursor syscall.Handle
Background syscall.Handle Background syscall.Handle
MenuName *uint16 MenuName *uint16
ClassName *uint16 ClassName *uint16
IconSm syscall.Handle IconSm syscall.Handle
} }
type Point struct { type Point struct {
X uintptr X uintptr
Y uintptr Y uintptr
} }
type Msg struct { type Msg struct {
Hwnd syscall.Handle Hwnd syscall.Handle
Message uint32 Message uint32
Wparam uintptr Wparam uintptr
Lparam uintptr Lparam uintptr
Time uint32 Time uint32
Pt Point Pt Point
} }
const ( const (
// Window styles // Window styles
WS_OVERLAPPED = 0 WS_OVERLAPPED = 0
WS_POPUP = 0x80000000 WS_POPUP = 0x80000000
WS_CHILD = 0x40000000 WS_CHILD = 0x40000000
WS_MINIMIZE = 0x20000000 WS_MINIMIZE = 0x20000000
WS_VISIBLE = 0x10000000 WS_VISIBLE = 0x10000000
WS_DISABLED = 0x8000000 WS_DISABLED = 0x8000000
WS_CLIPSIBLINGS = 0x4000000 WS_CLIPSIBLINGS = 0x4000000
WS_CLIPCHILDREN = 0x2000000 WS_CLIPCHILDREN = 0x2000000
WS_MAXIMIZE = 0x1000000 WS_MAXIMIZE = 0x1000000
WS_CAPTION = WS_BORDER | WS_DLGFRAME WS_CAPTION = WS_BORDER | WS_DLGFRAME
WS_BORDER = 0x800000 WS_BORDER = 0x800000
WS_DLGFRAME = 0x400000 WS_DLGFRAME = 0x400000
WS_VSCROLL = 0x200000 WS_VSCROLL = 0x200000
WS_HSCROLL = 0x100000 WS_HSCROLL = 0x100000
WS_SYSMENU = 0x80000 WS_SYSMENU = 0x80000
WS_THICKFRAME = 0x40000 WS_THICKFRAME = 0x40000
WS_GROUP = 0x20000 WS_GROUP = 0x20000
WS_TABSTOP = 0x10000 WS_TABSTOP = 0x10000
WS_MINIMIZEBOX = 0x20000 WS_MINIMIZEBOX = 0x20000
WS_MAXIMIZEBOX = 0x10000 WS_MAXIMIZEBOX = 0x10000
WS_TILED = WS_OVERLAPPED WS_TILED = WS_OVERLAPPED
WS_ICONIC = WS_MINIMIZE WS_ICONIC = WS_MINIMIZE
WS_SIZEBOX = WS_THICKFRAME WS_SIZEBOX = WS_THICKFRAME
// Common Window Styles // Common Window Styles
WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU
WS_CHILDWINDOW = WS_CHILD WS_CHILDWINDOW = WS_CHILD
WS_EX_CLIENTEDGE = 0x200 WS_EX_CLIENTEDGE = 0x200
// Some windows messages // Some windows messages
WM_CREATE = 1 WM_CREATE = 1
WM_DESTROY = 2 WM_DESTROY = 2
WM_CLOSE = 16 WM_CLOSE = 16
WM_COMMAND = 273 WM_COMMAND = 273
// Some button control styles // Some button control styles
BS_DEFPUSHBUTTON = 1 BS_DEFPUSHBUTTON = 1
// Some color constants // Some color constants
COLOR_WINDOW = 5 COLOR_WINDOW = 5
COLOR_BTNFACE = 15 COLOR_BTNFACE = 15
// Default window position // Default window position
CW_USEDEFAULT = 0x80000000 - 0x100000000 CW_USEDEFAULT = 0x80000000 - 0x100000000
// Show window default style // Show window default style
SW_SHOWDEFAULT = 10 SW_SHOWDEFAULT = 10
) )
var ( var (
// Some globally known cursors // Some globally known cursors
IDC_ARROW = MakeIntResource(32512) IDC_ARROW = MakeIntResource(32512)
IDC_IBEAM = MakeIntResource(32513) IDC_IBEAM = MakeIntResource(32513)
IDC_WAIT = MakeIntResource(32514) IDC_WAIT = MakeIntResource(32514)
IDC_CROSS = MakeIntResource(32515) IDC_CROSS = MakeIntResource(32515)
// Some globally known icons // Some globally known icons
IDI_APPLICATION = MakeIntResource(32512) IDI_APPLICATION = MakeIntResource(32512)
IDI_HAND = MakeIntResource(32513) IDI_HAND = MakeIntResource(32513)
IDI_QUESTION = MakeIntResource(32514) IDI_QUESTION = MakeIntResource(32514)
IDI_EXCLAMATION = MakeIntResource(32515) IDI_EXCLAMATION = MakeIntResource(32515)
IDI_ASTERISK = MakeIntResource(32516) IDI_ASTERISK = MakeIntResource(32516)
IDI_WINLOGO = MakeIntResource(32517) IDI_WINLOGO = MakeIntResource(32517)
IDI_WARNING = IDI_EXCLAMATION IDI_WARNING = IDI_EXCLAMATION
IDI_ERROR = IDI_HAND IDI_ERROR = IDI_HAND
IDI_INFORMATION = IDI_ASTERISK IDI_INFORMATION = IDI_ASTERISK
) )
//sys GetModuleHandle(modname *uint16) (handle syscall.Handle, err error) = GetModuleHandleW //sys GetModuleHandle(modname *uint16) (handle syscall.Handle, err error) = GetModuleHandleW
@ -130,5 +130,5 @@ var (
//sys PostMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (err error) = user32.PostMessageW //sys PostMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (err error) = user32.PostMessageW
func MakeIntResource(id uint16) *uint16 { func MakeIntResource(id uint16) *uint16 {
return (*uint16)(unsafe.Pointer(uintptr(id))) return (*uint16)(unsafe.Pointer(uintptr(id)))
} }

View File

@ -8,27 +8,27 @@ import (
const ( const (
WM_PAINT = 15 WM_PAINT = 15
BI_RGB = 0 BI_RGB = 0
BI_BITFIELDS = 3 BI_BITFIELDS = 3
DIB_PAL_COLORS = 1 DIB_PAL_COLORS = 1
DIB_RGB_COLORS = 0 DIB_RGB_COLORS = 0
BLACKNESS = 0x42 BLACKNESS = 0x42
DSTINVERT = 0x550009 DSTINVERT = 0x550009
MERGECOPY = 0xC000CA MERGECOPY = 0xC000CA
MERGEPAINT = 0xBB0226 MERGEPAINT = 0xBB0226
NOTSRCCOPY = 0x330008 NOTSRCCOPY = 0x330008
NOTSRCERASE = 0x1100A6 NOTSRCERASE = 0x1100A6
PATCOPY = 0xF00021 PATCOPY = 0xF00021
PATINVERT = 0x5A0049 PATINVERT = 0x5A0049
PATPAINT = 0xFB0A09 PATPAINT = 0xFB0A09
SRCAND = 0x8800C6 SRCAND = 0x8800C6
SRCCOPY = 0xCC0020 SRCCOPY = 0xCC0020
SRCERASE = 0x440328 SRCERASE = 0x440328
SRCINVERT = 0x660046 SRCINVERT = 0x660046
SRCPAINT = 0xEE0086 SRCPAINT = 0xEE0086
WHITENESS = 0xFF0062 WHITENESS = 0xFF0062
) )
type RECT struct { type RECT struct {
@ -120,7 +120,7 @@ func SelectObject(hdc syscall.Handle, hgdiobj syscall.Handle) syscall.Handle {
return syscall.Handle(r0) return syscall.Handle(r0)
} }
func BeginPaint(hwnd syscall.Handle, ps *PAINTSTRUCT) (hdc syscall.Handle){ func BeginPaint(hwnd syscall.Handle, ps *PAINTSTRUCT) (hdc syscall.Handle) {
r0, _, _ := syscall.Syscall(procBeginPaint.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(ps)), 0) r0, _, _ := syscall.Syscall(procBeginPaint.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(ps)), 0)
hdc = syscall.Handle(r0) hdc = syscall.Handle(r0)
return return

View File

@ -1,151 +1,152 @@
package main package main
import ( import (
"fmt" "fmt"
"os" "os"
"syscall" "syscall"
"unsafe" "unsafe"
. "code.google.com/p/draw2d/wingui"
. "github.com/llgcode/draw2d/wingui"
) )
// some help functions // some help functions
func abortf(format string, a ...interface{}) { func abortf(format string, a ...interface{}) {
fmt.Fprintf(os.Stdout, format, a...) fmt.Fprintf(os.Stdout, format, a...)
os.Exit(1) os.Exit(1)
} }
func abortErrNo(funcname string, err error) { func abortErrNo(funcname string, err error) {
errno, _ := err.(syscall.Errno) errno, _ := err.(syscall.Errno)
abortf("%s failed: %d %s\n", funcname, uint32(errno), err) abortf("%s failed: %d %s\n", funcname, uint32(errno), err)
} }
// global vars // global vars
var ( var (
mh syscall.Handle mh syscall.Handle
bh syscall.Handle bh syscall.Handle
) )
// WinProc called by windows to notify us of all windows events we might be interested in. // WinProc called by windows to notify us of all windows events we might be interested in.
func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintptr) { func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintptr) {
_ = make([]int, 100000) _ = make([]int, 100000)
switch msg { switch msg {
case WM_CREATE: case WM_CREATE:
var e error var e error
// CreateWindowEx // CreateWindowEx
bh, e = CreateWindowEx( bh, e = CreateWindowEx(
0, 0,
syscall.StringToUTF16Ptr("button"), syscall.StringToUTF16Ptr("button"),
syscall.StringToUTF16Ptr("Quit"), syscall.StringToUTF16Ptr("Quit"),
WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON,
75, 70, 140, 25, 75, 70, 140, 25,
hwnd, 1, mh, 0) hwnd, 1, mh, 0)
if e != nil { if e != nil {
abortErrNo("CreateWindowEx", e) abortErrNo("CreateWindowEx", e)
} }
fmt.Printf("button handle is %x\n", bh) fmt.Printf("button handle is %x\n", bh)
rc = DefWindowProc(hwnd, msg, wparam, lparam) rc = DefWindowProc(hwnd, msg, wparam, lparam)
case WM_COMMAND: case WM_COMMAND:
switch syscall.Handle(lparam) { switch syscall.Handle(lparam) {
case bh: case bh:
e := PostMessage(hwnd, WM_CLOSE, 0, 0) e := PostMessage(hwnd, WM_CLOSE, 0, 0)
if e != nil { if e != nil {
abortErrNo("PostMessage", e) abortErrNo("PostMessage", e)
} }
default: default:
rc = DefWindowProc(hwnd, msg, wparam, lparam) rc = DefWindowProc(hwnd, msg, wparam, lparam)
} }
case WM_CLOSE: case WM_CLOSE:
DestroyWindow(hwnd) DestroyWindow(hwnd)
case WM_DESTROY: case WM_DESTROY:
PostQuitMessage(0) PostQuitMessage(0)
default: default:
rc = DefWindowProc(hwnd, msg, wparam, lparam) rc = DefWindowProc(hwnd, msg, wparam, lparam)
} }
//fmt.Printf("WndProc(0x%08x, %d, 0x%08x, 0x%08x) (%d)\n", hwnd, msg, wparam, lparam, rc) //fmt.Printf("WndProc(0x%08x, %d, 0x%08x, 0x%08x) (%d)\n", hwnd, msg, wparam, lparam, rc)
return return
} }
func rungui() int { func rungui() int {
var e error var e error
// GetModuleHandle // GetModuleHandle
mh, e = GetModuleHandle(nil) mh, e = GetModuleHandle(nil)
if e != nil { if e != nil {
abortErrNo("GetModuleHandle", e) abortErrNo("GetModuleHandle", e)
} }
// Get icon we're going to use. // Get icon we're going to use.
myicon, e := LoadIcon(0, IDI_APPLICATION) myicon, e := LoadIcon(0, IDI_APPLICATION)
if e != nil { if e != nil {
abortErrNo("LoadIcon", e) abortErrNo("LoadIcon", e)
} }
// Get cursor we're going to use. // Get cursor we're going to use.
mycursor, e := LoadCursor(0, IDC_ARROW) mycursor, e := LoadCursor(0, IDC_ARROW)
if e != nil { if e != nil {
abortErrNo("LoadCursor", e) abortErrNo("LoadCursor", e)
} }
// Create callback // Create callback
wproc := syscall.NewCallback(WndProc) wproc := syscall.NewCallback(WndProc)
// RegisterClassEx // RegisterClassEx
wcname := syscall.StringToUTF16Ptr("myWindowClass") wcname := syscall.StringToUTF16Ptr("myWindowClass")
var wc Wndclassex var wc Wndclassex
wc.Size = uint32(unsafe.Sizeof(wc)) wc.Size = uint32(unsafe.Sizeof(wc))
wc.WndProc = wproc wc.WndProc = wproc
wc.Instance = mh wc.Instance = mh
wc.Icon = myicon wc.Icon = myicon
wc.Cursor = mycursor wc.Cursor = mycursor
wc.Background = COLOR_BTNFACE + 1 wc.Background = COLOR_BTNFACE + 1
wc.MenuName = nil wc.MenuName = nil
wc.ClassName = wcname wc.ClassName = wcname
wc.IconSm = myicon wc.IconSm = myicon
if _, e := RegisterClassEx(&wc); e != nil { if _, e := RegisterClassEx(&wc); e != nil {
abortErrNo("RegisterClassEx", e) abortErrNo("RegisterClassEx", e)
} }
// CreateWindowEx // CreateWindowEx
wh, e := CreateWindowEx( wh, e := CreateWindowEx(
WS_EX_CLIENTEDGE, WS_EX_CLIENTEDGE,
wcname, wcname,
syscall.StringToUTF16Ptr("My window"), syscall.StringToUTF16Ptr("My window"),
WS_OVERLAPPEDWINDOW, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 300, 200, CW_USEDEFAULT, CW_USEDEFAULT, 300, 200,
0, 0, mh, 0) 0, 0, mh, 0)
if e != nil { if e != nil {
abortErrNo("CreateWindowEx", e) abortErrNo("CreateWindowEx", e)
} }
fmt.Printf("main window handle is %x\n", wh) fmt.Printf("main window handle is %x\n", wh)
// ShowWindow // ShowWindow
ShowWindow(wh, SW_SHOWDEFAULT) ShowWindow(wh, SW_SHOWDEFAULT)
// UpdateWindow // UpdateWindow
if e := UpdateWindow(wh); e != nil { if e := UpdateWindow(wh); e != nil {
abortErrNo("UpdateWindow", e) abortErrNo("UpdateWindow", e)
} }
// Process all windows messages until WM_QUIT. // Process all windows messages until WM_QUIT.
var m Msg var m Msg
for { for {
r, e := GetMessage(&m, 0, 0, 0) r, e := GetMessage(&m, 0, 0, 0)
if e != nil { if e != nil {
abortErrNo("GetMessage", e) abortErrNo("GetMessage", e)
} }
if r == 0 { if r == 0 {
// WM_QUIT received -> get out // WM_QUIT received -> get out
break break
} }
TranslateMessage(&m) TranslateMessage(&m)
DispatchMessage(&m) DispatchMessage(&m)
} }
return int(m.Wparam) return int(m.Wparam)
} }
func main() { func main() {
rc := rungui() rc := rungui()
os.Exit(rc) os.Exit(rc)
} }

View File

@ -5,18 +5,19 @@
package main package main
import ( import (
"code.google.com/p/draw2d/draw2d"
"code.google.com/p/draw2d/wingui"
"code.google.com/p/draw2d/postscript"
"fmt" "fmt"
"image" "image"
"io/ioutil"
"image/color" "image/color"
"strings" "io/ioutil"
"os" "os"
"strings"
"syscall" "syscall"
"time" "time"
"unsafe" "unsafe"
"github.com/llgcode/draw2d/draw2d"
"github.com/llgcode/draw2d/postscript"
"github.com/llgcode/draw2d/wingui"
) )
// some help functions // some help functions
@ -56,7 +57,7 @@ func TestDrawCubicCurve(gc draw2d.GraphicContext) {
gc.Stroke() gc.Stroke()
} }
func DrawTiger(gc draw2d.GraphicContext){ func DrawTiger(gc draw2d.GraphicContext) {
if postscriptContent == "" { if postscriptContent == "" {
src, err := os.OpenFile("../../resource/postscript/tiger.ps", 0, 0) src, err := os.OpenFile("../../resource/postscript/tiger.ps", 0, 0)
if err != nil { if err != nil {
@ -73,12 +74,12 @@ func DrawTiger(gc draw2d.GraphicContext){
} }
var ( var (
mh syscall.Handle mh syscall.Handle
hdcWndBuffer syscall.Handle hdcWndBuffer syscall.Handle
wndBufferHeader syscall.Handle wndBufferHeader syscall.Handle
wndBuffer wingui.BITMAP wndBuffer wingui.BITMAP
ppvBits *uint8 ppvBits *uint8
backBuffer *image.RGBA backBuffer *image.RGBA
postscriptContent string postscriptContent string
) )
@ -119,7 +120,7 @@ func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintpt
pixel := (*[600 * 800 * 4]uint8)(unsafe.Pointer(ppvBits)) pixel := (*[600 * 800 * 4]uint8)(unsafe.Pointer(ppvBits))
pixelSlice := pixel[:] pixelSlice := pixel[:]
backBuffer = &image.RGBA{pixelSlice, 4*600, image.Rect(0, 0, 600, 800)} backBuffer = &image.RGBA{pixelSlice, 4 * 600, image.Rect(0, 0, 600, 800)}
fmt.Println("Create windows") fmt.Println("Create windows")
rc = wingui.DefWindowProc(hwnd, msg, wparam, lparam) rc = wingui.DefWindowProc(hwnd, msg, wparam, lparam)
case wingui.WM_COMMAND: case wingui.WM_COMMAND:
@ -134,7 +135,7 @@ func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintpt
gc := draw2d.NewGraphicContext(backBuffer) gc := draw2d.NewGraphicContext(backBuffer)
/*gc.SetFillColor(color.RGBA{0xFF, 0xFF, 0xFF, 0xFF}) /*gc.SetFillColor(color.RGBA{0xFF, 0xFF, 0xFF, 0xFF})
gc.Clear()*/ gc.Clear()*/
for i := 0; i < len(backBuffer.Pix); i+=1 { for i := 0; i < len(backBuffer.Pix); i += 1 {
backBuffer.Pix[i] = 0xff backBuffer.Pix[i] = 0xff
} }
gc.Save() gc.Save()
@ -143,7 +144,7 @@ func WndProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintpt
gc.Restore() gc.Restore()
// back buf in // back buf in
var tmp uint8 var tmp uint8
for i := 0; i < len(backBuffer.Pix); i+=4 { for i := 0; i < len(backBuffer.Pix); i += 4 {
tmp = backBuffer.Pix[i] tmp = backBuffer.Pix[i]
backBuffer.Pix[i] = backBuffer.Pix[i+2] backBuffer.Pix[i] = backBuffer.Pix[i+2]
backBuffer.Pix[i+2] = tmp backBuffer.Pix[i+2] = tmp

View File

@ -8,185 +8,185 @@ import "unsafe"
import "syscall" import "syscall"
var ( var (
modkernel32 = syscall.NewLazyDLL("kernel32.dll") modkernel32 = syscall.NewLazyDLL("kernel32.dll")
moduser32 = syscall.NewLazyDLL("user32.dll") moduser32 = syscall.NewLazyDLL("user32.dll")
procGetModuleHandleW = modkernel32.NewProc("GetModuleHandleW") procGetModuleHandleW = modkernel32.NewProc("GetModuleHandleW")
procRegisterClassExW = moduser32.NewProc("RegisterClassExW") procRegisterClassExW = moduser32.NewProc("RegisterClassExW")
procCreateWindowExW = moduser32.NewProc("CreateWindowExW") procCreateWindowExW = moduser32.NewProc("CreateWindowExW")
procDefWindowProcW = moduser32.NewProc("DefWindowProcW") procDefWindowProcW = moduser32.NewProc("DefWindowProcW")
procDestroyWindow = moduser32.NewProc("DestroyWindow") procDestroyWindow = moduser32.NewProc("DestroyWindow")
procPostQuitMessage = moduser32.NewProc("PostQuitMessage") procPostQuitMessage = moduser32.NewProc("PostQuitMessage")
procShowWindow = moduser32.NewProc("ShowWindow") procShowWindow = moduser32.NewProc("ShowWindow")
procUpdateWindow = moduser32.NewProc("UpdateWindow") procUpdateWindow = moduser32.NewProc("UpdateWindow")
procGetMessageW = moduser32.NewProc("GetMessageW") procGetMessageW = moduser32.NewProc("GetMessageW")
procTranslateMessage = moduser32.NewProc("TranslateMessage") procTranslateMessage = moduser32.NewProc("TranslateMessage")
procDispatchMessageW = moduser32.NewProc("DispatchMessageW") procDispatchMessageW = moduser32.NewProc("DispatchMessageW")
procLoadIconW = moduser32.NewProc("LoadIconW") procLoadIconW = moduser32.NewProc("LoadIconW")
procLoadCursorW = moduser32.NewProc("LoadCursorW") procLoadCursorW = moduser32.NewProc("LoadCursorW")
procSetCursor = moduser32.NewProc("SetCursor") procSetCursor = moduser32.NewProc("SetCursor")
procSendMessageW = moduser32.NewProc("SendMessageW") procSendMessageW = moduser32.NewProc("SendMessageW")
procPostMessageW = moduser32.NewProc("PostMessageW") procPostMessageW = moduser32.NewProc("PostMessageW")
) )
func GetModuleHandle(modname *uint16) (handle syscall.Handle, err error) { func GetModuleHandle(modname *uint16) (handle syscall.Handle, err error) {
r0, _, e1 := syscall.Syscall(procGetModuleHandleW.Addr(), 1, uintptr(unsafe.Pointer(modname)), 0, 0) r0, _, e1 := syscall.Syscall(procGetModuleHandleW.Addr(), 1, uintptr(unsafe.Pointer(modname)), 0, 0)
handle = syscall.Handle(r0) handle = syscall.Handle(r0)
if handle == 0 { if handle == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }
func RegisterClassEx(wndclass *Wndclassex) (atom uint16, err error) { func RegisterClassEx(wndclass *Wndclassex) (atom uint16, err error) {
r0, _, e1 := syscall.Syscall(procRegisterClassExW.Addr(), 1, uintptr(unsafe.Pointer(wndclass)), 0, 0) r0, _, e1 := syscall.Syscall(procRegisterClassExW.Addr(), 1, uintptr(unsafe.Pointer(wndclass)), 0, 0)
atom = uint16(r0) atom = uint16(r0)
if atom == 0 { if atom == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }
func CreateWindowEx(exstyle uint32, classname *uint16, windowname *uint16, style uint32, x int32, y int32, width int32, height int32, wndparent syscall.Handle, menu syscall.Handle, instance syscall.Handle, param uintptr) (hwnd syscall.Handle, err error) { func CreateWindowEx(exstyle uint32, classname *uint16, windowname *uint16, style uint32, x int32, y int32, width int32, height int32, wndparent syscall.Handle, menu syscall.Handle, instance syscall.Handle, param uintptr) (hwnd syscall.Handle, err error) {
r0, _, e1 := syscall.Syscall12(procCreateWindowExW.Addr(), 12, uintptr(exstyle), uintptr(unsafe.Pointer(classname)), uintptr(unsafe.Pointer(windowname)), uintptr(style), uintptr(x), uintptr(y), uintptr(width), uintptr(height), uintptr(wndparent), uintptr(menu), uintptr(instance), uintptr(param)) r0, _, e1 := syscall.Syscall12(procCreateWindowExW.Addr(), 12, uintptr(exstyle), uintptr(unsafe.Pointer(classname)), uintptr(unsafe.Pointer(windowname)), uintptr(style), uintptr(x), uintptr(y), uintptr(width), uintptr(height), uintptr(wndparent), uintptr(menu), uintptr(instance), uintptr(param))
hwnd = syscall.Handle(r0) hwnd = syscall.Handle(r0)
if hwnd == 0 { if hwnd == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }
func DefWindowProc(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) { func DefWindowProc(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) {
r0, _, _ := syscall.Syscall6(procDefWindowProcW.Addr(), 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0) r0, _, _ := syscall.Syscall6(procDefWindowProcW.Addr(), 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
lresult = uintptr(r0) lresult = uintptr(r0)
return return
} }
func DestroyWindow(hwnd syscall.Handle) (err error) { func DestroyWindow(hwnd syscall.Handle) (err error) {
r1, _, e1 := syscall.Syscall(procDestroyWindow.Addr(), 1, uintptr(hwnd), 0, 0) r1, _, e1 := syscall.Syscall(procDestroyWindow.Addr(), 1, uintptr(hwnd), 0, 0)
if int(r1) == 0 { if int(r1) == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }
func PostQuitMessage(exitcode int32) { func PostQuitMessage(exitcode int32) {
syscall.Syscall(procPostQuitMessage.Addr(), 1, uintptr(exitcode), 0, 0) syscall.Syscall(procPostQuitMessage.Addr(), 1, uintptr(exitcode), 0, 0)
return return
} }
func ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) { func ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) {
r0, _, _ := syscall.Syscall(procShowWindow.Addr(), 2, uintptr(hwnd), uintptr(cmdshow), 0) r0, _, _ := syscall.Syscall(procShowWindow.Addr(), 2, uintptr(hwnd), uintptr(cmdshow), 0)
wasvisible = bool(r0 != 0) wasvisible = bool(r0 != 0)
return return
} }
func UpdateWindow(hwnd syscall.Handle) (err error) { func UpdateWindow(hwnd syscall.Handle) (err error) {
r1, _, e1 := syscall.Syscall(procUpdateWindow.Addr(), 1, uintptr(hwnd), 0, 0) r1, _, e1 := syscall.Syscall(procUpdateWindow.Addr(), 1, uintptr(hwnd), 0, 0)
if int(r1) == 0 { if int(r1) == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }
func GetMessage(msg *Msg, hwnd syscall.Handle, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error) { func GetMessage(msg *Msg, hwnd syscall.Handle, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error) {
r0, _, e1 := syscall.Syscall6(procGetMessageW.Addr(), 4, uintptr(unsafe.Pointer(msg)), uintptr(hwnd), uintptr(MsgFilterMin), uintptr(MsgFilterMax), 0, 0) r0, _, e1 := syscall.Syscall6(procGetMessageW.Addr(), 4, uintptr(unsafe.Pointer(msg)), uintptr(hwnd), uintptr(MsgFilterMin), uintptr(MsgFilterMax), 0, 0)
ret = int32(r0) ret = int32(r0)
if ret == -1 { if ret == -1 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }
func TranslateMessage(msg *Msg) (done bool) { func TranslateMessage(msg *Msg) (done bool) {
r0, _, _ := syscall.Syscall(procTranslateMessage.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0) r0, _, _ := syscall.Syscall(procTranslateMessage.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0)
done = bool(r0 != 0) done = bool(r0 != 0)
return return
} }
func DispatchMessage(msg *Msg) (ret int32) { func DispatchMessage(msg *Msg) (ret int32) {
r0, _, _ := syscall.Syscall(procDispatchMessageW.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0) r0, _, _ := syscall.Syscall(procDispatchMessageW.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0)
ret = int32(r0) ret = int32(r0)
return return
} }
func LoadIcon(instance syscall.Handle, iconname *uint16) (icon syscall.Handle, err error) { func LoadIcon(instance syscall.Handle, iconname *uint16) (icon syscall.Handle, err error) {
r0, _, e1 := syscall.Syscall(procLoadIconW.Addr(), 2, uintptr(instance), uintptr(unsafe.Pointer(iconname)), 0) r0, _, e1 := syscall.Syscall(procLoadIconW.Addr(), 2, uintptr(instance), uintptr(unsafe.Pointer(iconname)), 0)
icon = syscall.Handle(r0) icon = syscall.Handle(r0)
if icon == 0 { if icon == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }
func LoadCursor(instance syscall.Handle, cursorname *uint16) (cursor syscall.Handle, err error) { func LoadCursor(instance syscall.Handle, cursorname *uint16) (cursor syscall.Handle, err error) {
r0, _, e1 := syscall.Syscall(procLoadCursorW.Addr(), 2, uintptr(instance), uintptr(unsafe.Pointer(cursorname)), 0) r0, _, e1 := syscall.Syscall(procLoadCursorW.Addr(), 2, uintptr(instance), uintptr(unsafe.Pointer(cursorname)), 0)
cursor = syscall.Handle(r0) cursor = syscall.Handle(r0)
if cursor == 0 { if cursor == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }
func SetCursor(cursor syscall.Handle) (precursor syscall.Handle, err error) { func SetCursor(cursor syscall.Handle) (precursor syscall.Handle, err error) {
r0, _, e1 := syscall.Syscall(procSetCursor.Addr(), 1, uintptr(cursor), 0, 0) r0, _, e1 := syscall.Syscall(procSetCursor.Addr(), 1, uintptr(cursor), 0, 0)
precursor = syscall.Handle(r0) precursor = syscall.Handle(r0)
if precursor == 0 { if precursor == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }
func SendMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) { func SendMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) {
r0, _, _ := syscall.Syscall6(procSendMessageW.Addr(), 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0) r0, _, _ := syscall.Syscall6(procSendMessageW.Addr(), 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
lresult = uintptr(r0) lresult = uintptr(r0)
return return
} }
func PostMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (err error) { func PostMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (err error) {
r1, _, e1 := syscall.Syscall6(procPostMessageW.Addr(), 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0) r1, _, e1 := syscall.Syscall6(procPostMessageW.Addr(), 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
if int(r1) == 0 { if int(r1) == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = error(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
} }
return return
} }