func NewIconFromResource(instance w32.HINSTANCE, resId uint16) (*Icon, error) { ico := new(Icon) var err error if ico.handle = w32.LoadIcon(instance, w32.MakeIntResource(resId)); ico.handle == 0 { err = errors.New(fmt.Sprintf("Cannot load icon from resource with id %v", resId)) } return ico, err }
func NewIconFromFile(path string) (*Icon, error) { ico := new(Icon) var err error if ico.handle = w32.LoadIcon(0, syscall.StringToUTF16Ptr(path)); ico.handle == 0 { err = errors.New(fmt.Sprintf("Cannot load icon from %s", path)) } return ico, err }
func RegisterClass(className string, wndproc uintptr) error { icon := w32.LoadIcon(gAppInstance, w32.MakeIntResource(w32.IDI_APPLICATION)) var wc w32.WNDCLASSEX wc.Size = uint32(unsafe.Sizeof(wc)) wc.Style = w32.CS_HREDRAW | w32.CS_VREDRAW wc.WndProc = wndproc wc.Instance = gAppInstance wc.Background = w32.COLOR_BTNFACE + 1 wc.Icon = icon wc.ClassName = syscall.StringToUTF16Ptr(className) wc.MenuName = nil wc.IconSm = icon if ret := w32.RegisterClassEx(&wc); ret == 0 { return syscall.GetLastError() } return nil }
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()) } }
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) }