Example #1
0
func cursorHandle(id wde.Cursor) w32.HCURSOR {
	h, ok := cursorCache[id]
	if !ok {
		idc, ok := cursorIDC[id]
		if !ok {
			idc = w32.IDC_ARROW
		}
		h = w32.LoadCursor(0, w32.MakeIntResource(idc))
		cursorCache[id] = h
	}
	return h
}
Example #2
0
func RegisterClass(className string, wndproc uintptr) {
	instance := GetAppInstance()
	icon := w32.LoadIcon(instance, w32.MakeIntResource(w32.IDI_APPLICATION))

	var wc w32.WNDCLASSEX
	wc.Size = uint(unsafe.Sizeof(wc))
	wc.Style = w32.CS_HREDRAW | w32.CS_VREDRAW
	wc.WndProc = wndproc
	wc.Instance = instance
	wc.Background = w32.COLOR_BTNFACE + 1
	wc.Icon = icon
	wc.Cursor = w32.LoadCursor(0, w32.MakeIntResource(w32.IDC_ARROW))
	wc.ClassName = syscall.StringToUTF16Ptr(className)
	wc.MenuName = nil
	wc.IconSm = icon

	if ret := w32.RegisterClassEx(&wc); ret == 0 {
		panic(syscall.GetLastError())
	}
}
Example #3
0
func (app *DemoApp) Initialize() {
	app.CreateDeviceIndependentResources()
	hInstance := w32.GetModuleHandle("")
	icon := w32.LoadIcon(0, w32.MakeIntResource(w32.IDI_APPLICATION))
	wndProc := func(hwnd w32.HWND, msg uint, wParam, lParam uintptr) uintptr {
		return app.WndProc(hwnd, msg, wParam, lParam)
	}
	wndClass := w32.WNDCLASSEX{
		Size:       uint(unsafe.Sizeof(w32.WNDCLASSEX{})),
		Style:      w32.CS_HREDRAW | w32.CS_VREDRAW,
		WndProc:    syscall.NewCallback(wndProc),
		ClsExtra:   0,
		WndExtra:   0,
		Instance:   hInstance,
		Icon:       icon,
		Cursor:     w32.LoadCursor(0, w32.MakeIntResource(w32.IDC_ARROW)),
		Background: 0,
		MenuName:   nil,
		ClassName:  syscall.StringToUTF16Ptr("D2DDemoApp"),
		IconSm:     icon,
	}
	w32.RegisterClassEx(&wndClass)

	dpiX, dpiY := app.factory.GetDesktopDpi(app.factory)

	app.hwnd = w32.CreateWindowEx(
		0,
		syscall.StringToUTF16Ptr("D2DDemoApp"),
		syscall.StringToUTF16Ptr("Hello Windows"),
		w32.WS_OVERLAPPEDWINDOW,
		w32.CW_USEDEFAULT,
		w32.CW_USEDEFAULT,
		int(math.Ceil(float64(640*dpiX/96))),
		int(math.Ceil(float64(640*dpiY/96))),
		0,
		0,
		hInstance,
		nil)
	w32.ShowWindow(app.hwnd, w32.SW_SHOW)
	w32.UpdateWindow(app.hwnd)
}