From 506f06bb385ee770de7b8dd3d9dac64b946dd432 Mon Sep 17 00:00:00 2001 From: VIVIMAN Date: Wed, 7 Sep 2022 22:04:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E4=B9=A0xsgui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data_func/go_to_xcgui/main02/demo.zip | Bin 1184 -> 0 bytes .../data_func/go_to_xcgui/main02/main.go | 17 +++----- .../data_func/go_to_xcgui/main03/demo.zip | Bin 0 -> 1187 bytes .../data_func/go_to_xcgui/main03/main.go | 40 ++++++++++++++++++ 4 files changed, 46 insertions(+), 11 deletions(-) delete mode 100644 golang_learn/data_func/go_to_xcgui/main02/demo.zip create mode 100644 golang_learn/data_func/go_to_xcgui/main03/demo.zip create mode 100644 golang_learn/data_func/go_to_xcgui/main03/main.go diff --git a/golang_learn/data_func/go_to_xcgui/main02/demo.zip b/golang_learn/data_func/go_to_xcgui/main02/demo.zip deleted file mode 100644 index 506f2e8a20be354237edd63bbd2a35a843c6fed4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1184 zcmWIWW@a&F;N?hWun|!YWq^X?j0_AM4EhYYiJ5tN6}dTF3<_WwMg|Fn28m=#`9n7t zVKhU(eYG5r&p4Bvfsw({m6?Mf=+$kR)tBcp1+RT~`at1^C^xCaNf(Z>TO8zwNmbb( z67=D}grGD-ZPU@Cw(VPO=PYMoyOCvdl3VPyt48j2hF2Mn-e#yS+je*6w>|2d*}@xr zv;IwC{%-om_mZj@`x9S{)@uf*rXPw6T&uVGRO>2Pxq}PE9m~C#3f|pFDSx=fCD;alzE(=5w?4YLB~dP0J2c%be4`vCSmQ^~gG(`z-hG@oWhZ z&9^V~-{+&Quk}uT;k1}&G%bp5~3ci_JJqpW(%Iho)2*KF%9 zeYJ3h!he(bQ`qla+jV|JsozeqnzFa4PrYmzW8cj;*l6_hVZ>?W{Q=(W9Obdcx$}UL z28y@+8AV(`K8qsN_Xnp8wa@@-%qIPkdt#FwqRME!oTb2K(I91bw_sfgn5IH>jVno;)pn1k#GUw?m?`8I0z z+Tz>iwU;>LEH6^l5IDj4XWD!2gw$RO%hxfly!jfkeG58#3Yc;@?g6YNoP{7IH%urlXnUkuQTwKh^AOKFb$OMUgzW+-> zpIwwizx3boWy|+pTrU>Cc(YAQ(SO;@#%;%^g4_i%Tn^a=AUnXDkx7>ek*|=W2b8Z+ z0hzfB*%DApBL@&DrV-#WFjY_x@8}kR42Job6UCx!Obm$7Co!Z0yjj^mCNl$}3DCh| H%pe{BzU+3s diff --git a/golang_learn/data_func/go_to_xcgui/main02/main.go b/golang_learn/data_func/go_to_xcgui/main02/main.go index f3b91bf..5ee0782 100644 --- a/golang_learn/data_func/go_to_xcgui/main02/main.go +++ b/golang_learn/data_func/go_to_xcgui/main02/main.go @@ -5,24 +5,19 @@ import ( "github.com/twgh/xcgui/app" "github.com/twgh/xcgui/widget" "github.com/twgh/xcgui/window" - "github.com/twgh/xcgui/xc" ) // TODO 失败 -//go:embed XCGUI.dll -var dll []byte - -//go:embed demo.zip -var zip []byte - func main() { - // 把 xcgui.dll 写出到windows临时目录 - _ = xc.WriteDll(dll) a := app.New(true) - // 创建窗口从内存压缩包中的布局文件 - w := window.NewByLayoutZipMem(zip, "main.xml", "123456", 0, 0) + // 添加文件搜索路径, 因为main.xml没有在程序运行目录 + a.AddFileSearchPath(`D:\XcCodes\demo`) + // 创建窗口从布局文件 + w := window.NewByLayout("main.xml", 0, 0) // 获取窗口布局文件中的按钮 + // btn := widget.NewButtonByHandle(1000) + // btn := widget.NewButtonByUID(1000) btn := widget.NewButtonByName("viviman") // 注册按钮被单击事件 btn.Event_BnClick(func(pbHandled *bool) int { diff --git a/golang_learn/data_func/go_to_xcgui/main03/demo.zip b/golang_learn/data_func/go_to_xcgui/main03/demo.zip new file mode 100644 index 0000000000000000000000000000000000000000..654c43addca862e3fb28203a730cd77ead7b664f GIT binary patch literal 1187 zcmWIWW@a&F;N?hW*tt+WlmQCPGcqu6Fz7SnCT8a8RpjPyF(`m#7#SoO7%m_2+4l zOs|P+{oWDoVS_ti-= z&mEc)njHH$A}2um>Eq&;hE{rR$t!H8hsZDUFKHLfQ=YJ@S2fmDw&}FOHiyU$^S*pv zTCH2$#~xZkd%#oCF>BIJv06f3{)dR~W>yUpgm z*yX*7Pj%@xkvdZe)l7$LCX>rlJl^e8H(c3$d#fz6tZi!UeoVV~u@3i;AJNMsGy}Y^qu~hQ2H96+*x2;M$`1I4+^9$eo zx$dxwL2HJJRpbl*oU^U3mGzA$=9kXRc>E`+%d)YMkbp{zMzv!#N|`L^lYezU)dm+&5r>Z}2|3uL$)vJF6X zfHxzPE*BzeAx94=YoP)%Ga9lbpqNGuAW%#rz%^j1pdjASEdm(~^D!riMLU@o5TQ?E VNC$YcvVlxy20{~{gCm(iJOB-;inIU# literal 0 HcmV?d00001 diff --git a/golang_learn/data_func/go_to_xcgui/main03/main.go b/golang_learn/data_func/go_to_xcgui/main03/main.go new file mode 100644 index 0000000..b7f4e45 --- /dev/null +++ b/golang_learn/data_func/go_to_xcgui/main03/main.go @@ -0,0 +1,40 @@ +package main + +import ( + _ "embed" + "github.com/twgh/xcgui/app" + "github.com/twgh/xcgui/widget" + "github.com/twgh/xcgui/window" + "github.com/twgh/xcgui/xc" +) + +// TODO 失败 +//go:embed XCGUI.dll +var dll []byte + +//go:embed demo.zip +var zip []byte + +func main() { + // 把 xcgui.dll 写出到windows临时目录 + _ = xc.WriteDll(dll) + a := app.New(true) + // 创建窗口从内存压缩包中的布局文件 + w := window.NewByLayoutZipMem(zip, "main.xml", "123456", 0, 0) + + // 获取窗口布局文件中的按钮 + btn := widget.NewButtonByUID(0) + // btn := widget.NewButtonByName("viviman") + // 注册按钮被单击事件 + btn.Event_BnClick(func(pbHandled *bool) int { + a.Alert("提示", btn.GetText()+"被点击") + return 0 + }) + + // 调整布局, 必须 + w.AdjustLayout() + // 显示窗口 + w.Show(true) + a.Run() + a.Exit() +}