func main() { hWindow = xcgui.XWnd_Create(0, 0, 300, 200, "炫彩界面库窗口", 0, xcgui.XC_WINDOW_STYLE_DEFAULT) xcgui.CloseBtn(hWindow) hButton := xcgui.XBtn_Create(20, 50, 80, 20, "弹出菜单", xcgui.HXCGUI(hWindow)) xcgui.XEle_RegEventC1(hButton, xcgui.XE_BNCLICK, xcgui.CallBack(OnbtnClick)) xcgui.XWnd_RegEventC(hWindow, xcgui.XWM_MENU_POPUP, xcgui.CallBack(OnWndMenuPopup)) xcgui.XWnd_RegEventC(hWindow, xcgui.XWM_MENU_POPUP_WND, xcgui.CallBack(OnWndMenuPopupWnd)) xcgui.XWnd_RegEventC(hWindow, xcgui.XWM_MENU_SELECT, xcgui.CallBack(OnWndMenuSelect)) xcgui.XWnd_RegEventC(hWindow, xcgui.XWM_MENU_EXIT, xcgui.CallBack(OnWndMenuExit)) xcgui.XWnd_RegEventC(hWindow, xcgui.XWM_MENU_DRAW_BACKGROUND, xcgui.CallBack(OnWndMenuDrawBackground)) xcgui.XWnd_ShowWindow(hWindow, xcgui.SW_SHOW) xcgui.XRunXCGUI() xcgui.XExitXCGUI() }
func main() { hWindow = xcgui.XWnd_Create(0, 0, 0, 0, "炫彩界面库窗口", 0, xcgui.XC_WINDOW_STYLE_NOTHING) // We load our icon from a file. icon, err := walk.NewIconFromFile("../../img/x.ico") if err != nil { log.Fatal(err) } // Create the notify icon and make sure we clean it up on exit. ni, err = walk.NewNotifyIcon() if err != nil { log.Fatal(err) } defer ni.Dispose() // Set the icon and a tool tip text. if err := ni.SetIcon(icon); err != nil { log.Fatal(err) } if err := ni.SetToolTip("托盘"); err != nil { log.Fatal(err) } // When the left mouse button is pressed, bring up our balloon. ni.MouseDown().Attach(func(x, y int, button walk.MouseButton) { if button == walk.LeftButton { if err := ni.ShowCustom( "自定义消息", "这是一个带图标的自定义消息."); err != nil { log.Fatal(err) } } else { RunXCMenu() } }) // 托盘图标默认为隐藏状态,需设置为显示。 if err := ni.SetVisible(true); err != nil { log.Fatal(err) } // Now that the icon is visible, we can bring up an info balloon. if err := ni.ShowInfo("托盘", "正在运行中."); err != nil { log.Fatal(err) } // 注册菜单选择事件 xcgui.XWnd_RegEventC(hWindow, xcgui.XWM_MENU_SELECT, xcgui.CallBack(OnWndMenuSelect)) // Run the message loop. xcgui.XRunXCGUI() }
func main() { mw = xcgui.XFrameWnd_Create(0, 0, 600, 400, "炫彩界面库窗口", 0, xcgui.XC_WINDOW_STYLE_DEFAULT) xcgui.XBtn_SetType(xcgui.XBtn_Create(3, 3, 20, 20, "X", xcgui.HXCGUI(mw)), xcgui.BUTTON_TYPE_CLOSE) hPane1 := xcgui.XPane_Create("111", 200, 200, mw) hPane2 := xcgui.XPane_Create("2222222222", 200, 200, mw) hPane3 := xcgui.XPane_Create("333", 200, 200, mw) xcgui.XFrameWnd_AddPane(mw, 0, hPane1, xcgui.Align_left) xcgui.XFrameWnd_AddPane(mw, 0, hPane2, xcgui.Align_bottom) xcgui.XFrameWnd_AddPane(mw, 0, hPane3, xcgui.Align_right) xcgui.XWnd_RegEventC(mw, xcgui.WM_RBUTTONUP, xcgui.CallBack(OnWndButtonUp)) xcgui.XWnd_AdjustLayout(mw) xcgui.XWnd_ShowWindow(mw, xcgui.SW_SHOW) xcgui.XRunXCGUI() xcgui.XExitXCGUI() }
func main() { xcgui.XC_LoadResource("xml/resource.xml", "") hxcgui := xcgui.XC_LoadLayout("xml/layout.xml", 0) hWindow = xcgui.HWINDOW(hxcgui) xcgui.XWnd_AdjustLayout(hWindow) // 后退 hGoBack = xcgui.XC_GetObjectByID(130) // xcgui.XEle_RegEventC1(xcgui.HELE(hGoBack), xcgui.XE_BNCLICK, xcgui.CallBack(onBtnClick)) xcgui.XEle_RegEventC1(xcgui.HELE(hGoBack), xcgui.XE_BNCLICK, xcgui.CallBackGo(func() { fmt.Println("后退中...") web.XWeb_GoBack(hWeb) })) // url地址栏 hEditUrl = xcgui.XC_GetObjectByID(131) xcgui.XEle_EnableSwitchFocus(xcgui.HELE(hEditUrl), true) xcgui.XEle_RegEventC(xcgui.HELE(hEditUrl), xcgui.XE_CHAR, xcgui.CallBack(onEventChar)) // 解决焦点丢失问题 xcgui.XEle_RegEventC(xcgui.HELE(hEditUrl), xcgui.XE_LBUTTONDOWN, xcgui.CallBack(onLButtonDown)) // 前进 hGoForward = xcgui.XC_GetObjectByID(132) xcgui.XEle_RegEventC1(xcgui.HELE(hGoForward), xcgui.XE_BNCLICK, xcgui.CallBack(onBtnClick)) // 浏览器body区 xcgui.XWnd_GetBodyRect(hWindow, &rtBody) hWeb = web.XWeb_Create( int(rtBody.Left), int(rtBody.Top), int(rtBody.Right-rtBody.Left), int(rtBody.Bottom-rtBody.Top), xcgui.XWnd_GetHWND(hWindow)) // 更多 hMenuBar = xcgui.XC_GetObjectByID(133) xcgui.XMenuBar_AddButton(xcgui.HELE(hMenuBar), "更多") hMenu = xcgui.XMenuBar_GetMenu(xcgui.HELE(hMenuBar), 0) if hMenu != 0 { xcgui.XMenu_AddItem(hMenu, 1330, "主页", 0, 0) xcgui.XMenu_AddItem(hMenu, 1331, "重新载入", 0, 0) xcgui.XMenu_AddItem(hMenu, 1332, "停止载入", 0, 0) xcgui.XMenu_AddItem(hMenu, 1333, "代理加载谷歌", 0, 0) xcgui.XMenu_AddItem(hMenu, 1334, "放大", 0, 0) xcgui.XMenu_AddItem(hMenu, 1335, "缩小", 0, 0) xcgui.XMenu_AddItem(hMenu, 1336, "恢复缩放", 0, 0) xcgui.XMenu_AddItem(hMenu, 1337, "获取Cookie", 0, 0) xcgui.XMenu_AddItem(hMenu, 1338, "js调用vs函数", 0, 0) xcgui.XMenu_AddItem(hMenu, 1340, "设置网页可编辑", 0, 0) xcgui.XMenu_AddItem(hMenu, 1341, "设置网页不可编辑", 0, 0) xcgui.XMenu_AddItem(hMenu, 1351, "执行js脚本", 0, 0) xcgui.XMenu_AddItem(hMenu, 1352, "取浏览器状态", 0, 0) xcgui.XMenu_AddItem(hMenu, 1353, "js模拟填写", 0, 0) xcgui.XMenu_AddItem(hMenu, 1360, "关于", 0, 0) } // 菜单选择 xcgui.XEle_RegEventC(xcgui.HELE(hMenuBar), xcgui.XE_MENU_SELECT, xcgui.CallBack(onWndMenuSelect)) // 默认打开百度 web.XWeb_LoadUrl(hWeb, "http://www.baidu.com") // URL变化 web.XWeb_OnURLChanged(hWeb, xcgui.CallBack(onURLChanged), 1) // Title 变化修改状态栏 hState = xcgui.XC_GetObjectByID(311) web.XWeb_OnTitleChanged(hWeb, xcgui.CallBack(onTitleChanged), 1) // 窗口变化web窗体自适应 xcgui.XWnd_RegEventC(hWindow, xcgui.WM_SIZE, xcgui.CallBack(OnWndSize)) xcgui.XWnd_ShowWindow(hWindow, xcgui.SW_SHOW) xcgui.XRunXCGUI() xcgui.XExitXCGUI() }