Split out the dialog functions into portable and non-portable code to keep the package documentation in the portable code only.
This commit is contained in:
parent
56923d0bda
commit
316e5e9db4
|
@ -0,0 +1,17 @@
|
||||||
|
// 7 february 2014
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
// MsgBox displays an informational message box to the user with just an OK button.
|
||||||
|
func MsgBox(title string, textfmt string, args ...interface{}) {
|
||||||
|
msgBox(title, fmt.Sprintf(textfmt, args...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgBoxError displays a message box to the user with just an OK button and an icon indicating an error.
|
||||||
|
func MsgBoxError(title string, textfmt string, args ...interface{}) {
|
||||||
|
msgBoxError(title, fmt.Sprintf(textfmt, args...))
|
||||||
|
}
|
|
@ -73,7 +73,7 @@ var (
|
||||||
_messageBox = user32.NewProc("MessageBoxW")
|
_messageBox = user32.NewProc("MessageBoxW")
|
||||||
)
|
)
|
||||||
|
|
||||||
func msgBox(lpText string, lpCaption string, uType uint32) (result int) {
|
func _msgBox(lpText string, lpCaption string, uType uint32) (result int) {
|
||||||
r1, _, err := _messageBox.Call(
|
r1, _, err := _messageBox.Call(
|
||||||
uintptr(_NULL),
|
uintptr(_NULL),
|
||||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpText))),
|
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpText))),
|
||||||
|
@ -85,13 +85,11 @@ func msgBox(lpText string, lpCaption string, uType uint32) (result int) {
|
||||||
return int(r1)
|
return int(r1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgBox displays an informational message box to the user with just an OK button.
|
func msgBox(title string, text string) {
|
||||||
func MsgBox(title string, textfmt string, args ...interface{}) {
|
|
||||||
// TODO add an icon?
|
// TODO add an icon?
|
||||||
msgBox(fmt.Sprintf(textfmt, args...), title, _MB_OK)
|
_msgBox(text, title, _MB_OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgBoxError displays a message box to the user with just an OK button and an icon indicating an error.
|
func msgBoxError(title string, text string) {
|
||||||
func MsgBoxError(title string, textfmt string, args ...interface{}) {
|
_msgBox(text, title, _MB_OK | _MB_ICONERROR)
|
||||||
msgBox(fmt.Sprintf(textfmt, args...), title, _MB_OK | _MB_ICONERROR)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue