Пример #1
0
func main() {
	xcgui.XInitXCGUI()
	hwnd := xcgui.XWndCreate(400, 200, 300, 200, "标题",
		xcgui.NULL, xcgui.XC_WINDOW_STYLE_DEFAULT)

	parent := xcgui.HXCGUI(hwnd)
	//button
	btn := xcgui.XBtnCreate(10, 5, 80, 22, "关闭", parent)
	xcgui.XBtnSetType(btn, xcgui.BUTTON_TYPE_CLOSE)
	//监听btn事件
	xcgui.XEleRegEventC(btn, xcgui.XE_BNCLICK, syscall.NewCallback(OnBtnClick))
	//label
	lb := xcgui.XShapeTextCreate(50, 100, 100, 22, "hello world!", parent)
	xcgui.XShapeTextSetText(lb, "hello 世界!")
	xcgui.XShapeTextSetTextColor(lb, 0xff0000, 255)

	//取text及长度
	str := xcgui.XShapeTextGetTextGo(lb)
	fmt.Println(str)
	fmt.Println(xcgui.XShapeTextGetTextLength(lb))

	xcgui.XWndShowWindow(hwnd, xcgui.SW_SHOW)
	xcgui.XRunXCGUI()
	xcgui.XExitXCGUI()
}
Пример #2
0
func InitWindow(window, parent Window, width, height int, title string, style uint32) error {
	wb := window.AsWindowBase()
	wb.window = window

	var hwndParent xc.HWND
	if parent != nil {
		hwndParent = parent.Handle()
	}

	if wb.hWnd != 0 {
		return lastError("XWndCreate")
	}

	wb.hWindow = xc.XWndCreate(
		xc.CW_USEDEFAULT,
		xc.CW_USEDEFAULT,
		width,
		height,
		title,
		hwndParent,
		int(style))

	xc.CloseBtn(wb.hWindow)

	if wb.hWindow == 0 {
		return lastError("XWndCreate")
	}

	succeeded := false
	go func() {
		if !succeeded {
			newErrorNoPanic("XWndCreate")
		}
	}()

	succeeded = true

	return nil
}