gw

module
v0.0.0-...-3929c03 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT

README

gw

简体中文

A Go GUI framework on the Windows platform.

Usage

package main

import (
    "github.com/mkch/gw/app"
    "github.com/mkch/gw/button"
    "github.com/mkch/gw/win32"
    "github.com/mkch/gw/win32/win32util"
    "github.com/mkch/gw/window"
)

func main() {
    win, _ := window.New(&window.Spec{
        Text:  "Hello, Go!",
        Style: win32.WS_OVERLAPPEDWINDOW,
        X:     win32.CW_USEDEFAULT,
        Width: 500, Height: 300,
        OnClose: func() { app.Quit(0) },
    })
    button.New(win.HWND(), &button.Spec{
        Text:  "Hello",
        Style: win32.WS_VISIBLE,
        X:     200, Y: 120,
        Width: 100, Height: 60,
        OnClick: func() {
            win32util.MessageBox(win.HWND(),
                "Hello GUI!", "Button clicked",
                win32.MB_ICONINFORMATION)
        },
    })
    win.Show(win32.SW_SHOW)
    app.Run()
}

The Go program above creates a window and a button. When the button is clicked, a message box pops up.

FAQ

  1. How to remove the console window when the executable is run?

    Add -ldflags "-H=windowsgui" when running go build, for example: go build -ldflags "-H=windowsgui".

  2. How to specify an icon or other resources for the executable?

    You can use a third-party tool, such as rsrc.

    First, use the command go get github.com/akavel/rsrc to install rsrc.

    Then use a command such as rsrc -arch amd64 -ico FILE.ico to compile the *.ico file into *.syso resource file.

    Finally, place the *.syso file in the same directory as the *.go source files, and then run go build.

Directories

Path Synopsis
app
Package app implements application initialization and message loop that can be used in main goroutine only.
Package app implements application initialization and message loop that can be used in main goroutine only.
gwapp
Package gwapp implements application initialization and message loop that can be used in any goroutine.
Package gwapp implements application initialization and message loop that can be used in any goroutine.
Package menu manipulates windows menus.
Package menu manipulates windows menus.
Package metrics implements conversion between physical pixels(PX) and device-independent pixels(DIP).
Package metrics implements conversion between physical pixels(PX) and device-independent pixels(DIP).
Package mscom implements COM(The Microsoft Component Object Model) object creation and invocation.
Package mscom implements COM(The Microsoft Component Object Model) object creation and invocation.
sys
sys
pen
samples
choosefont command
demo command
msgproc command
notifyicon command
panel command
static command
testpaint command
tools
addres command
util
bitmap
Package bitmap implements *.BMP bitmap image file reading.
Package bitmap implements *.BMP bitmap image file reading.
ref
Package ref implements reference counted resource management.
Package ref implements reference counted resource management.

Jump to

Keyboard shortcuts

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