Go + Qt は前回の記事から実用は難しそうなので、結局 GUI は Win32 API をたたく方向にした。
Windows でしか動かなくなるが、自分はサービスを作ったり Hotkey 登録したり API フックしたりいろいろやりたいけど C++ 使うほど大仰にはしたくないって用途なのと Go に対して C++ と同じレベルのポテンシャルを感じているので Go を使いたいってだけなのでこれでよしとする。
一から作るよりはある程度あったほうがいいので、以下を利用する。
https://github.com/lxn/win
main.go
package main
import (
"syscall"
"github.com/lxn/win"
)
func UTF16PtrFromString(s string) *uint16 {
result, _ := syscall.UTF16PtrFromString(s)
return result
}
func main() {
win.MessageBox(win.HWND(0), UTF16PtrFromString("メッセージ"), UTF16PtrFromString("タイトル"), win.MB_OKCANCEL)
}