Exemplo n.º 1
0
// Register a new window class for the current process. A window with the specified
// class name will use the given WndProc callback function.
func registerWindowClass(className string, callback _WindowProc) error {
	classNamePtr, _ := syscall.UTF16PtrFromString(className)
	var winClass w32.WNDCLASSEX
	winClass.Size = uint32(unsafe.Sizeof(winClass))
	winClass.Instance = w32.GetModuleHandle("")
	winClass.ClassName = classNamePtr
	winClass.WndProc = syscall.NewCallback(callback)

	if w32.RegisterClassEx(&winClass) == 0 {
		return syscall.GetLastError()
	}
	return nil
}
Exemplo n.º 2
0
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
}
Exemplo n.º 3
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())
	}
}