Browse Source

first commit

xx 2 years ago
commit
ca511a3b61
6 changed files with 86 additions and 0 deletions
  1. 6 0
      log.md
  2. 0 0
      redme.md
  3. 11 0
      工具包/gcc/go.mod
  4. 9 0
      工具包/gcc/go.sum
  5. 60 0
      工具包/gcc/main.go
  6. BIN
      工具包/gcc/mingw64.rar

+ 6 - 0
log.md

@@ -0,0 +1,6 @@
+## 1.windows下编译去除黑窗口
+    go build -ldflags "-s -w -H=windowsgui"
+## 2.gcc
+    工具包/gcc/mingw64.rar 解压并配置环境变量,根据路径
+    在项目主目录放置工具包/gcc/rsrc.syso,编译,即可完成。
+    示例代码

+ 0 - 0
redme.md


+ 11 - 0
工具包/gcc/go.mod

@@ -0,0 +1,11 @@
+module main
+
+go 1.19
+
+require github.com/lxn/walk v0.0.0-20210112085537-c389da54e794
+
+require (
+	github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
+	golang.org/x/sys v0.2.0 // indirect
+	gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect
+)

+ 9 - 0
工具包/gcc/go.sum

@@ -0,0 +1,9 @@
+github.com/lxn/walk v0.0.0-20210112085537-c389da54e794 h1:NVRJ0Uy0SOFcXSKLsS65OmI1sgCCfiDUPj+cwnH7GZw=
+github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ=
+github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
+github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
+golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
+golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc=
+gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E=

+ 60 - 0
工具包/gcc/main.go

@@ -0,0 +1,60 @@
+package main
+
+import (
+	"fmt"
+	"os"
+
+	"github.com/lxn/walk"
+	"github.com/lxn/walk/declarative"
+)
+
+type MyMainWindow struct {
+	*walk.MainWindow
+	edit *walk.TextEdit
+}
+
+func main() {
+	mw := &MyMainWindow{}
+	err := declarative.MainWindow{
+		AssignTo: &mw.MainWindow, //窗口重定向至mw,重定向后可由重定向变量控制控件
+		// Icon:     "test.ico",     //窗体图标
+		Title:   "文件选择对话框", //标题
+		MinSize: declarative.Size{Width: 150, Height: 200},
+		Size:    declarative.Size{300, 400},
+		Layout:  declarative.VBox{}, //样式,纵向
+		Children: []declarative.Widget{ //控件组
+			declarative.TextEdit{
+				AssignTo: &mw.edit,
+			},
+			declarative.PushButton{
+				Text:      "打开",
+				OnClicked: mw.selectFile, //点击事件响应函数
+			},
+		},
+	}.Create() //创建
+
+	if err != nil {
+		fmt.Fprintln(os.Stderr, err)
+		os.Exit(1)
+	}
+
+	mw.Run() //运行
+}
+
+func (mw *MyMainWindow) selectFile() {
+
+	dlg := new(walk.FileDialog)
+	dlg.Title = "选择文件"
+	dlg.Filter = "可执行文件 (*.exe)|*.exe|所有文件 (*.*)|*.*"
+
+	mw.edit.SetText("") //通过重定向变量设置TextEdit的Text
+	if ok, err := dlg.ShowOpen(mw); err != nil {
+		mw.edit.AppendText("Error : File Open\r\n")
+		return
+	} else if !ok {
+		mw.edit.AppendText("Cancel\r\n")
+		return
+	}
+	s := fmt.Sprintf("Select : %s\r\n", dlg.FilePath)
+	mw.edit.AppendText(s)
+}

BIN
工具包/gcc/mingw64.rar