Implemented the new MsgBox() transience on Windows.
This commit is contained in:
parent
4e6f6cd147
commit
7acc70c39e
|
@ -13,21 +13,27 @@ var (
|
||||||
_messageBox = user32.NewProc("MessageBoxW")
|
_messageBox = user32.NewProc("MessageBoxW")
|
||||||
)
|
)
|
||||||
|
|
||||||
func _msgBox(primarytext string, secondarytext string, uType uint32) (result int) {
|
func _msgBox(parent *Window, primarytext string, secondarytext string, uType uint32) (result int) {
|
||||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa511267.aspx says "Use task dialogs whenever appropriate to achieve a consistent look and layout. Task dialogs require Windows Vista® or later, so they aren't suitable for earlier versions of Windows. If you must use a message box, separate the main instruction from the supplemental instruction with two line breaks."
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa511267.aspx says "Use task dialogs whenever appropriate to achieve a consistent look and layout. Task dialogs require Windows Vista® or later, so they aren't suitable for earlier versions of Windows. If you must use a message box, separate the main instruction from the supplemental instruction with two line breaks."
|
||||||
text := primarytext
|
text := primarytext
|
||||||
if secondarytext != "" {
|
if secondarytext != "" {
|
||||||
text += "\n\n" + secondarytext
|
text += "\n\n" + secondarytext
|
||||||
}
|
}
|
||||||
uType |= _MB_TASKMODAL // make modal to every window in the program (they're all windows of the uitask, which is a single thread)
|
|
||||||
ptext := toUTF16(text)
|
ptext := toUTF16(text)
|
||||||
ptitle := toUTF16(os.Args[0])
|
ptitle := toUTF16(os.Args[0])
|
||||||
ret := make(chan uiret)
|
ret := make(chan uiret)
|
||||||
defer close(ret)
|
defer close(ret)
|
||||||
|
parenthwnd := _HWND(_NULL)
|
||||||
|
if parent != nil {
|
||||||
|
parenthwnd = parent.sysData.hwnd
|
||||||
|
uType |= _MB_APPLMODAL // only for this window
|
||||||
|
} else {
|
||||||
|
uType |= _MB_TASKMODAL // make modal to every window in the program (they're all windows of the uitask, which is a single thread)
|
||||||
|
}
|
||||||
uitask <- &uimsg{
|
uitask <- &uimsg{
|
||||||
call: _messageBox,
|
call: _messageBox,
|
||||||
p: []uintptr{
|
p: []uintptr{
|
||||||
uintptr(_NULL),
|
uintptr(parenthwnd),
|
||||||
utf16ToArg(ptext),
|
utf16ToArg(ptext),
|
||||||
utf16ToArg(ptitle),
|
utf16ToArg(ptitle),
|
||||||
uintptr(uType),
|
uintptr(uType),
|
||||||
|
@ -41,10 +47,10 @@ func _msgBox(primarytext string, secondarytext string, uType uint32) (result int
|
||||||
return int(r.ret)
|
return int(r.ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
func msgBox(primarytext string, secondarytext string) {
|
func msgBox(parent *Window, primarytext string, secondarytext string) {
|
||||||
_msgBox(primarytext, secondarytext, _MB_OK)
|
_msgBox(parent, primarytext, secondarytext, _MB_OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func msgBoxError(primarytext string, secondarytext string) {
|
func msgBoxError(parent *Window, primarytext string, secondarytext string) {
|
||||||
_msgBox(primarytext, secondarytext, _MB_OK | _MB_ICONERROR)
|
_msgBox(parent, primarytext, secondarytext, _MB_OK | _MB_ICONERROR)
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ const _LB_GETTEXTLEN = 394
|
||||||
const _LB_INSERTSTRING = 385
|
const _LB_INSERTSTRING = 385
|
||||||
const _LF_FACESIZE = 32
|
const _LF_FACESIZE = 32
|
||||||
const _MA_ACTIVATE = 1
|
const _MA_ACTIVATE = 1
|
||||||
|
const _MB_APPLMODAL = 0
|
||||||
const _MB_ICONERROR = 16
|
const _MB_ICONERROR = 16
|
||||||
const _MB_OK = 0
|
const _MB_OK = 0
|
||||||
const _MB_TASKMODAL = 8192
|
const _MB_TASKMODAL = 8192
|
||||||
|
|
|
@ -48,6 +48,7 @@ const _LB_GETTEXTLEN = 394
|
||||||
const _LB_INSERTSTRING = 385
|
const _LB_INSERTSTRING = 385
|
||||||
const _LF_FACESIZE = 32
|
const _LF_FACESIZE = 32
|
||||||
const _MA_ACTIVATE = 1
|
const _MA_ACTIVATE = 1
|
||||||
|
const _MB_APPLMODAL = 0
|
||||||
const _MB_ICONERROR = 16
|
const _MB_ICONERROR = 16
|
||||||
const _MB_OK = 0
|
const _MB_OK = 0
|
||||||
const _MB_TASKMODAL = 8192
|
const _MB_TASKMODAL = 8192
|
||||||
|
|
Loading…
Reference in New Issue