Comments (4)
Switch to dev branch, then:
package main
import (
"github.com/ying32/govcl/vcl"
)
var (
mainForm *vcl.TForm
)
// ControlType is the variable used as an enum
type ControlType int
const (
Label ControlType = 1 + iota
Button
)
type Form struct {
*vcl.TForm
}
func main() {
vcl.Application.Initialize()
mainForm = vcl.Application.CreateForm()
mainForm.SetCaption("Hello to you!!")
mainForm.ScreenCenter()
AddLabel(mainForm, mainForm, 10, 10, 100, 22, "A functional label!")
AddButton(mainForm, mainForm, 10, 40, 40, 20, "Click Me!")
vcl.Application.Run()
}
// AddLabel adds a new Label
func AddLabel(owner vcl.IComponent, parent vcl.IWinControl, left int32, top int32, width int32, height int32, caption string) *vcl.TLabel {
label := CreateControl(owner, Label)
label.SetParent(parent)
label.SetBounds(left, top, width, height)
label.SetCaption(caption)
return label.(*vcl.TLabel)
}
// AddButton adds a new button
func AddButton(owner vcl.IComponent, parent vcl.IWinControl, left int32, top int32, width int32, height int32, caption string) *vcl.TButton {
button := CreateControl(owner, Button)
button.SetParent(parent)
button.SetBounds(left, top, width, height)
button.SetCaption(caption)
return button.(*vcl.TButton)
}
// CreateControl is a "Generic" factory method for Control creation
func CreateControl(owner vcl.IComponent, controlType ControlType) vcl.IControl {
switch controlType {
case Label:
return vcl.NewLabel(owner)
case Button:
return vcl.NewButton(owner)
default:
return nil
}
}
You can use the res2go tool to convert Delphi or Lazarus form resource files.
from govcl.
I am not greatly experienced with Git, but I did
git checkout dev
I updated my code to match your changes, then tried to build it again. I got...
./main.go:36:7: label.SetParent undefined (type vcl.IControl has no field or method SetParent)
./main.go:38:7: label.SetCaption undefined (type vcl.IControl has no field or method SetCaption)
./main.go:45:8: button.SetParent undefined (type vcl.IControl has no field or method SetParent)
./main.go:47:8: button.SetCaption undefined (type vcl.IControl has no field or method SetCaption)
I expect I've made a mistake on the Git side of things!
from govcl.
′git pull′
from govcl.
git pull
worked fine. Thanks for the changes, they work perfectly!
from govcl.
Related Issues (20)
- 去掉黑框问题 HOT 4
- TPageControl has no TabVisible property available HOT 2
- 请问GoVCLDesigner😍是开源的吗? HOT 2
- initFile 中readDate、readTime、readDateTime三个返回的是0,导致解析成1970-01-01.... HOT 2
- res2go doesn't work. HOT 8
- 这几个组件是不支持吗? HOT 2
- res2go插件包名无法删除 HOT 1
- 生成名称属性已更改的控件时出错 HOT 2
- 怎么将go image包的Image转换成vcl.IGraphic实例? HOT 15
- 怎么让一个画布重绘? HOT 2
- example中有很多gfm文件,用lazarus也打不开啊。要怎么转换格式才能打开呢 HOT 1
- 报错 HOT 3
- Button的Caption值能否支持换行,或使用其他控件 HOT 1
- TreeView再SetData后,用Data函数得到的指针总是错的。TreeNode的地址总是在改变,尽管里面的Instance指针是不变的 HOT 1
- 能否支持Virtual TreeView呢? HOT 1
- windows系统下,管理员检测不对 HOT 2
- MacOS 下面XButton的Caption字体模糊 HOT 7
- 为什么不使用 syscall.LazyDLL 加载 liblcl 模块? 应该允许用户在调用 vcl.Application.Initialize 初始化之前动态释放 liblcl模块. HOT 1
- mac平台go build报错 HOT 3
- 自定义 LibName 不支持 go1.21.1 以上版本 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from govcl.