All Projects → rodrigocfd → windigo

rodrigocfd / windigo

Licence: MIT license
Windows API and GUI in idiomatic Go.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to windigo

winsafe
Windows API and GUI in safe, idiomatic Rust.
Stars: ✭ 110 (-41.18%)
Mutual labels:  native, ffi, win32
Win32
Build Win32 apps with Dart!
Stars: ✭ 256 (+36.9%)
Mutual labels:  ffi, win32
sqlite3
The fastest and correct module for SQLite3 in Deno.
Stars: ✭ 143 (-23.53%)
Mutual labels:  native, ffi
PointerScript
Scripting language with pointers and native library access.
Stars: ✭ 26 (-86.1%)
Mutual labels:  native, ffi
Dart native
Write iOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.
Stars: ✭ 564 (+201.6%)
Mutual labels:  native, ffi
Arcgis Appstudio Samples
Collection of samples available in AppStudio for ArcGIS desktop to learn and help build your next app.
Stars: ✭ 78 (-58.29%)
Mutual labels:  native, win32
Node Win32 Api
win32 api
Stars: ✭ 214 (+14.44%)
Mutual labels:  ffi, win32
Xtd forms
Modern c++17 library to create native gui for Microsoft Windows, Apple macOS and Linux.
Stars: ✭ 25 (-86.63%)
Mutual labels:  native, win32
Android Luajit Launcher
Android NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI
Stars: ✭ 87 (-53.48%)
Mutual labels:  native, ffi
rust-flutter-reactive
This is a sample app to improve consistency over Mobile App Development.
Stars: ✭ 25 (-86.63%)
Mutual labels:  native, ffi
parcl
Gradle plugin for bundling your Java application for distribution on Windows, Mac and Linux
Stars: ✭ 52 (-72.19%)
Mutual labels:  native
native-java-examples
Native Java Apps with Micronaut, Quarkus, and Spring Boot
Stars: ✭ 44 (-76.47%)
Mutual labels:  native
tasit-sdk
A JavaScript / TypeScript SDK for making native mobile Ethereum dapps using React Native
Stars: ✭ 93 (-50.27%)
Mutual labels:  native
Multiplatform-LiveData
Multiplatorm implementation of LiveDatas / MVVM in kotlin android & native ios
Stars: ✭ 95 (-49.2%)
Mutual labels:  native
windows taskbar
Flutter plugin serving utilities related to Windows taskbar. 💙
Stars: ✭ 84 (-55.08%)
Mutual labels:  win32
auth0-ios-swift-sample
Auth0 Integration Samples for iOS Swift
Stars: ✭ 55 (-70.59%)
Mutual labels:  native
generator-omaha
Yeoman generator designed to help you craft sustainable code for the modern web
Stars: ✭ 12 (-93.58%)
Mutual labels:  native
dicomweb-pacs
Easy to use DICOMWEB enabled PACS with DIMSE services based on sqlite database
Stars: ✭ 42 (-77.54%)
Mutual labels:  native
pony-sodium
Safe Pony FFI wrapper for the libsodium cryptography library. 🐴 🔐
Stars: ✭ 24 (-87.17%)
Mutual labels:  ffi
titanium-arkit
Use the iOS 11 ARKit API in Axway Titanium
Stars: ✭ 28 (-85.03%)
Mutual labels:  native

Go Reference GitHub go.mod Go version of a Go module Lines of code License: MIT

Windigo

Win32 API and GUI in idiomatic Go.

Overview

The UI library is divided in the following packages:

Package Description
ui High-level UI wrappers for windows and controls.
ui/wm High-level event parameters (Windows message callbacks).

For the Win32 API bindings:

Package Description
win Native Win32 structs, handles and functions.
win/co Native Win32 constants, all typed.
win/errco Native Win32 error codes, with types errco.ERROR and errco.CDERR.

For the COM bindings, there is the main package, and two subpackages – the co suffix contains the constants, and the vt contains the virtual tables:

Packages Description
win/com/autom
win/com/autom/automco
win/com/autom/automvt
Native Win32 Automation COM interfaces.
win/com/com
win/com/com/comco
win/com/com/comvt
Native Win32 COM API base.
win/com/d2d1
win/com/d2d1/d2d1co
win/com/d2d1/d2d1vt
Native Win32 Direct2D COM interfaces.
win/com/dshow
win/com/dshow/dshowco
win/com/dshow/dshowvt
Native Win32 DirectShow COM interfaces.
win/com/shell
win/com/shell/shellco
win/com/shell/shellvt
Native Win32 Shell COM interfaces.

Windigo is designed to be familiar to Win32 programmers, using the same concepts, so most C/C++ Win32 tutorials should be applicable.

Windows and controls can be created in two ways:

  • programmatically, by specifying the options used in the underlying CreateWindowEx;
  • by loading resources from a .rc or a .res file.

CGo is not used, just syscalls.

Error treatment

The native Win32 functions deal with errors in two ways:

  • Recoverable errors will return an errco.ERROR value, which implements the error interface;

  • Unrecoverable errors will simply panic. This avoids the excess of if err != nil with errors that cannot be recovered anyway, like internal Windows errors.

Example

The example below creates a window programmatically, and handles the button click. Also, it uses the minimal.syso provided in the resources folder.

Screen capture

package main

import (
    "fmt"
    "runtime"

    "github.com/rodrigocfd/windigo/ui"
    "github.com/rodrigocfd/windigo/win"
    "github.com/rodrigocfd/windigo/win/co"
)

func main() {
    runtime.LockOSThread()

    myWindow := NewMyWindow() // instantiate
    myWindow.wnd.RunAsMain()  // ...and run
}

// This struct represents our main window.
type MyWindow struct {
    wnd     ui.WindowMain
    lblName ui.Static
    txtName ui.Edit
    btnShow ui.Button
}

// Creates a new instance of our main window.
func NewMyWindow() *MyWindow {
    wnd := ui.NewWindowMain(
        ui.WindowMainOpts().
            Title("Hello you").
            ClientArea(win.SIZE{Cx: 340, Cy: 80}).
            IconId(101), // ID of icon resource, see resources folder
    )

    me := &MyWindow{
        wnd: wnd,
        lblName: ui.NewStatic(wnd,
            ui.StaticOpts().
                Text("Your name").
                Position(win.POINT{X: 10, Y: 22}),
        ),
        txtName: ui.NewEdit(wnd,
            ui.EditOpts().
                Position(win.POINT{X: 80, Y: 20}).
                Size(win.SIZE{Cx: 150}),
        ),
        btnShow: ui.NewButton(wnd,
            ui.ButtonOpts().
                Text("&Show").
                Position(win.POINT{X: 240, Y: 19}),
        ),
    }

    me.btnShow.On().BnClicked(func() {
        msg := fmt.Sprintf("Hello, %s!", me.txtName.Text())
        me.wnd.Hwnd().MessageBox(msg, "Saying hello", co.MB_ICONINFORMATION)
    })

    return me
}

License

Licensed under MIT license, see LICENSE.md for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].