govcl

module
v0.0.0-...-112c496 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2020 License: Apache-2.0

README


当前版本已不再支持Delphi/VCL了。最后一个支持vcl版本的分支:last-vcl-support

跨平台的Golang GUI库,底层绑定自Lazarus LCL

从1.2.0版本开始govcl将最低要求go1.9。

截图查看 | 中文文档 | 更新日志 | 加入QQ群 | GoVCL视频教程(第三方) | 赞助GoVCL


支持的平台

Windows | Linux | macOS

如果你想要支持linux arm及linux 32bit则需要自己编译对应的liblcl二进制。


预编译GUI库二进制下载

Librarys

res2go工具下载(文档

res2go

注:用Lazarus设计界面,用Golang写代码。

GoVCL扩展包

注:扩展包里面的inc或者pas文件需要自己放到liblcl目录下编译。


使用方法

步骤一:获取govcl代码

go get -u github.com/ying32/govcl

步骤二:编写代码

  • 方法一(使用Lazarus设计界面。推荐):
package main


import (
   "github.com/topxeq/govcl/vcl"
   // 如果你使用自定义的syso文件则不要引用此包
   _ "github.com/topxeq/govcl/pkgs/winappres"
)

type TMainForm struct {
    *vcl.TForm
    Btn1     *vcl.TButton
}

type TAboutForm struct {
    *vcl.TForm
    Btn1    *vcl.TButton
}

var (
    mainForm *TMainForm
    aboutForm *TAboutForm
)

func main() {
    vcl.Application.Initialize()
    vcl.Application.SetMainFormOnTaskBar(true)
    vcl.Application.CreateForm(&mainForm)
    vcl.Application.CreateForm(&aboutForm)
    vcl.Application.Run()
}

// -- TMainForm

func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
    
}

func (f *TMainForm) OnBtn1Click(sender vcl.IObject) {
    aboutForm.Show()
}

// -- TAboutForm

func (f *TAboutForm) OnFormCreate(sender vcl.IObject) {
 
}

func (f *TAboutForm) OnBtn1Click(sender vcl.IObject) {
    vcl.ShowMessage("Hello!")
}

方法一需要配合res2go工具使用。

  • 方法二(纯代码,仿照FreePascal类的方式,可自动绑定事件。):
package main


import (
   "github.com/topxeq/govcl/vcl"
   // 如果你使用自定义的syso文件则不要引用此包
   _ "github.com/topxeq/govcl/pkgs/winappres"
)

type TMainForm struct {
    *vcl.TForm
    Btn1     *vcl.TButton
}

type TAboutForm struct {
    *vcl.TForm
    Btn1    *vcl.TButton
}

var (
    mainForm *TMainForm
    aboutForm *TAboutForm
)

func main() {
    vcl.RunApp(&mainForm, &aboutForm)
}

// -- TMainForm

func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
    f.SetCaption("MainForm")
    
    f.Btn1 = vcl.NewButton(f)
    f.Btn1.SetParent(f)
    f.Btn1.SetBounds(10, 10, 88, 28)
    f.Btn1.SetCaption("Button1")
    //f.Btn1.SetOnClick(f.OnBtn1Click)  
}

func (f *TMainForm) OnBtn1Click(sender vcl.IObject) {
    vcl.ShowMessage("Hello!")
}


// -- TAboutForm

func (f *TAboutForm) OnFormCreate(sender vcl.IObject) {
    f.SetCaption("About")
    f.Btn1 = vcl.NewButton(f)
    //f.Btn1.SetName("Btn1")
    f.Btn1.SetParent(f)
    f.Btn1.SetBounds(10, 10, 88, 28)
    f.Btn1.SetCaption("Button1")
}

func (f *TAboutForm) OnBtn1Click(sender vcl.IObject) {
    vcl.ShowMessage("Hello!")
}

  • 方法三
// 不推荐,所以不给出示例了。  

步骤三:复制对应的二进制

  • Windows: 根据编译的二进制是32还是64位的,复制对应的liblcl.dll到当前exe目录或系统环境路径下。

    • Go环境变量: GOARCH = amd64 386 GOOS = windows CGO_ENABLED=0
  • Linux: 复制liblcl.so可执行文件目录下(也可复制liblcl.so到/usr/lib/(32bit liblcl)或者/usr/lib/x86_64-linux-gnu/(64bit liblcl)目录中,作为公共库使用)。

    • Go环境变量: GOARCH = amd64 GOOS = linux CGO_ENABLED=1
  • MacOS: 复制liblcl.dylib可执行文件目录下(MacOS下注意:需要自行创建info.plist文件),或者参考:MacOS上应用打包

    • Go环境变量: GOARCH = amd64 GOOS = darwin CGO_ENABLED=1

注意:

特别注意:所有UI组件都是非线程/协程安全的,当在goroutine中使用时,请使用vcl.ThreadSync来同步更新到UI上。

API文档

Directories

Path Synopsis
Tools
LazarusPatch command
libBuild command
pkgs
samples
OSVersion command
WindowsMessages command
WindowsProcess command
WindowsTest command
action command
basic command
basicResForm command
由GOVCL UI设计器自动生成,不要编辑。
由GOVCL UI设计器自动生成,不要编辑。
checklistbox command
clock command
comboboxEx command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
customLibTest command
draganddrop command
draw command
drawchart command
drawrose command
drawusegg command
dropfiles command
eventpublic command
fileshelltree command
formEvents command
formscale command
gdiplustest command
gdiplustest2 command
govcl command
govcl project main.go go.exe build -i -ldflags="-H windowsgui"
govcl project main.go go.exe build -i -ldflags="-H windowsgui"
grids/drawgrid command
imagebutton command
imageviewer command
inifile command
intfTest command
jsonTogo command
jsonViewer command
layout command
listview command
listviewadv1 command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
listviewcustomdraw command
由GOVCL UI设计器自动生成,不要编辑。
由GOVCL UI设计器自动生成,不要编辑。
listviewitemedit command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
login command
由GOVCL UI设计器自动生成,不要编辑 由GOVCL UI设计器自动生成,不要编辑
由GOVCL UI设计器自动生成,不要编辑 由GOVCL UI设计器自动生成,不要编辑
markdownEd command
memloaddll command
由GOVCL UI设计器自动生成,不要编辑 由GOVCL UI设计器自动生成,不要编辑。
由GOVCL UI设计器自动生成,不要编辑 由GOVCL UI设计器自动生成,不要编辑。
memstream command
menu command
messageTest command
miniblinkWebview command
由GOVCL UI设计器自动生成,不要编辑 由GOVCL UI设计器自动生成,不要编辑 由GOVCL UI设计器自动生成,不要编辑
由GOVCL UI设计器自动生成,不要编辑 由GOVCL UI设计器自动生成,不要编辑 由GOVCL UI设计器自动生成,不要编辑
miniwebview command
由GOVCL UI设计器自动生成,不要编辑
由GOVCL UI设计器自动生成,不要编辑
mp3Player command
msgbox command
multilanguage command
myext command
由GOVCL UI设计器自动生成,不要编辑
由GOVCL UI设计器自动生成,不要编辑
notepad command
nswindowTest command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
printer command
redisViewer command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
registerHotKey command
registry command
res2goTest/Lazarus/gocode command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
res2goTest/Test/gocode command
由res2go自动生成,不要编辑。
由res2go自动生成,不要编辑。
richedit command
shortcut command
simplelibvlc command
statusbar command
stdcontrols command
sysdialog command
syslocale command
taskdialog command
threadid command
trayicon command
treeview command
valuelisteditor command
windowsspy command
wingif command
winole command
xbuttonTest command
vcl
api
---------------------------------------- 加载文件或者内存中的窗口资源文件功能 需要配合窗口设计器使用 ----------------------------------------
---------------------------------------- 加载文件或者内存中的窗口资源文件功能 需要配合窗口设计器使用 ----------------------------------------
bitmap
实现一些Go的Image转vcl/lcl的
实现一些Go的Image转vcl/lcl的
rtl
win

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL