3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

goでwindowsでwindow

Last updated at Posted at 2015-06-17

インストール

go get github.com/ohisama/win

画像

image

サンプルコード

package main
import (
	"syscall"
	"github.com/ohisama/win"
)
var x int32
func WndProc(hWnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr {
	switch msg {
	case win.WM_PAINT:
		x++
		var strMessage = "Hello"
		var ps win.PAINTSTRUCT
		hdc := win.BeginPaint(hWnd, &ps)
		for i := 0; i < 256; i++ {
			for j := 0; j < 256; j++ {
				iro := i * 256 * 256 + j
				win.SetPixelV(hdc, int32(i), int32(j), int32(iro))
			}
		}
		win.Ellipse(hdc, x,  200, 200 + x, 400)
		win.TextOut(hdc, 100, 100, strMessage, int32(len(strMessage)))
		win.EndPaint(hWnd, &ps)
		return 0
	case win.WM_COMMAND:
		return 0
	case win.WM_DESTROY:
		win.PostQuitMessage(0)
		return 0
	default:
		return win.DefWindowProc(hWnd, msg, wParam, lParam)
	}
	return 0
}
func main() {
	win.WinMain(syscall.NewCallback(WndProc))
}


3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?