Skip to content

Commit 2f1bc62

Browse files
committed
自定义窗口颜色
1 parent 145c24a commit 2f1bc62

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

WindowBkColor/1.jpg

8.73 KB
Loading

WindowBkColor/WindowBkColor.go

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// 自定义窗口不同区域的背景颜色.
2+
package main
3+
4+
import (
5+
"github.com/twgh/xcgui/app"
6+
"github.com/twgh/xcgui/imagex"
7+
"github.com/twgh/xcgui/window"
8+
"github.com/twgh/xcgui/xc"
9+
"github.com/twgh/xcgui/xcc"
10+
)
11+
12+
func main() {
13+
// 1.初始化UI库
14+
a := app.New(true)
15+
a.EnableDPI(true)
16+
a.EnableAutoDPI(true)
17+
// 2.创建窗口
18+
w := window.New(0, 0, 430, 300, "xcgui window", 0, xcc.Window_Style_Default|xcc.Window_Style_Drag_Window)
19+
// 设置窗口边框大小
20+
w.SetBorderSize(1, 30, 1, 1)
21+
// 设置窗口图标
22+
a.SetWindowIcon(imagex.NewBySvgStringW(svgIcon).Handle)
23+
24+
// 设置窗口主体颜色
25+
w.AddBkFill(xcc.Window_State_Flag_Body_Leave, xc.RGBA(248, 249, 251, 255))
26+
// 设置窗口边框颜色
27+
w.AddBkFill(xcc.Window_State_Flag_Top_Leave, xc.RGBA(39, 40, 46, 255))
28+
w.AddBkFill(xcc.Window_State_Flag_Left_Leave, xc.RGBA(177, 177, 177, 255))
29+
w.AddBkFill(xcc.Window_State_Flag_Right_Leave, xc.RGBA(177, 177, 177, 255))
30+
w.AddBkFill(xcc.Window_State_Flag_Bottom_Leave, xc.RGBA(177, 177, 177, 255))
31+
32+
// 3.显示窗口
33+
w.Show(true)
34+
// 4.运行程序
35+
a.Run()
36+
// 5.释放UI库
37+
a.Exit()
38+
}
39+
40+
const svgIcon = `<svg t="1690463587383" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6388" width="22" height="22"><path d="M511.97 318.12m-224.46 0a224.46 224.46 0 1 0 448.92 0 224.46 224.46 0 1 0-448.92 0Z" fill="#386BF3" p-id="6389"></path><path d="M735.51 705.31m-224.46 0a224.46 224.46 0 1 0 448.92 0 224.46 224.46 0 1 0-448.92 0Z" fill="#3D4265" p-id="6390"></path><path d="M288.42 705.31m-224.46 0a224.46 224.46 0 1 0 448.92 0 224.46 224.46 0 1 0-448.92 0Z" fill="#386BF3" p-id="6391"></path></svg>`

0 commit comments

Comments
 (0)