Exemplo n.º 1
0
Arquivo: frame.go Projeto: maxid/xcgui
func OnWndButtonUp(nFlags uint32, pPt *xcgui.POINT, pbHandled *bool) int {
	pt := *pPt

	hMenu := xcgui.XMenuCreate()
	xcgui.XMenuAddItem(hMenu, 201, xcgui.StringToUTF16Ptr("窗格1"), xcgui.NULL, xcgui.NULL)
	xcgui.XMenuAddItem(hMenu, 202, xcgui.StringToUTF16Ptr("窗格2"), xcgui.NULL, xcgui.NULL)
	xcgui.XMenuAddItem(hMenu, 203, xcgui.StringToUTF16Ptr("窗格3"), xcgui.NULL, xcgui.NULL)

	xcgui.ClientToScreen(xcgui.XWndGetHWND(mw), &pt)
	xcgui.XMenuPopup(hMenu, xcgui.XWndGetHWND(mw), pt.X, pt.Y, xcgui.NULL, xcgui.NULL)

	return 0
}
Exemplo n.º 2
0
func DebugToFileInfo(str string) {
	// 中文转换为Ansi
	buffer := make([]byte, len(str)+1)
	xc.XC_UnicodeToAnsi(xc.StringToUTF16Ptr(str), len(str), &buffer[0], len(str)*2)

	xc.XC_DebugToFileInfo(&buffer[0])
}
Exemplo n.º 3
0
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
}
Exemplo n.º 4
0
Arquivo: frame.go Projeto: maxid/xcgui
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()
}
Exemplo n.º 5
0
Arquivo: image.go Projeto: maxid/xcgui
func NewIconFromFile(filePath string) (hIcon xc.HIMAGE, err error) {
	absFilePath, err := filepath.Abs(filePath)
	if err != nil {
		return 0, wrapError(err)
	}

	hIcon = xc.HIMAGE(xc.XImageLoadFile(
		xc.StringToUTF16Ptr(absFilePath),
		false))

	if hIcon == 0 {
		return 0, lastError("LoadImage")
	}

	return hIcon, nil
}
Exemplo n.º 6
0
func (b *Button) SetText(value string) {
	xc.XBtnSetText(b.hEle, xc.StringToUTF16Ptr(value))
}