func NewButton(parent Window, rect Rectangle) (*Button, error) { btn := new(Button) btn.hEle = xc.XBtnCreate( rect.X, rect.Y, rect.Width, rect.Height, xc.StringToUTF16Ptr(""), xc.HXCGUI(parent.AsWindowBase().hWindow)) if btn.hEle == 0 { return nil, lastError("XBtnCreate") } // var OnEventProc = func(hEventEle xc.HELE, nEvent int, wParam, lParam uintptr, pbHandled *xc.BOOL) uintptr { // fmt.Println(nEvent, wParam, lParam) // fmt.Println("事件正常.") // return uintptr(0) // } // xc.XEleRegEventC(btn.hEle, xc.XE_BNCLICK, syscall.NewCallback(OnEventProc)) return btn, nil }
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() }
func main() { mw = xcgui.XFrameWndCreate(0, 0, 600, 400, xcgui.StringToUTF16Ptr("炫彩界面库窗口"), xcgui.NULL, xcgui.XC_WINDOW_STYLE_DEFAULT) xcgui.XBtnSetType(xcgui.XBtnCreate(3, 3, 20, 20, xcgui.StringToUTF16Ptr("X"), xcgui.HXCGUI(mw)), xcgui.BUTTON_TYPE_CLOSE) hPane1 := xcgui.XPaneCreate(xcgui.StringToUTF16Ptr("111"), 200, 200, mw) hPane2 := xcgui.XPaneCreate(xcgui.StringToUTF16Ptr("2222222222"), 200, 200, mw) hPane3 := xcgui.XPaneCreate(xcgui.StringToUTF16Ptr("333"), 200, 200, mw) xcgui.XFrameWndAddPane(mw, xcgui.NULL, hPane1, xcgui.Align_left) xcgui.XFrameWndAddPane(mw, xcgui.NULL, hPane2, xcgui.Align_bottom) xcgui.XFrameWndAddPane(mw, xcgui.NULL, hPane3, xcgui.Align_right) xcgui.XWndRegEventC(mw, xcgui.WM_RBUTTONUP, xcgui.CallBack(OnWndButtonUp)) xcgui.XWndAdjustLayout(mw) xcgui.XWndShowWindow(mw, xcgui.SW_SHOW) xcgui.XRunXCGUI() xcgui.XExitXCGUI() }