summaryrefslogtreecommitdiff
path: root/prevlib/dialog_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
committerPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
commit8a81650b3da7ce00725336df9e03b38e935c5a65 (patch)
tree08af843f0460e7226f305cf7162021ef54e8c3f7 /prevlib/dialog_windows.go
parent4dd5ceb11d62bd6b9af4847936314a9d8c45707f (diff)
Moved it all back; the preemptive multitaksing during an event handler kills us on all platforms. Going to have to restrict ALL GUI accss to happening from one t hread, so going to need to drop uitask entirely and have just a start() callback for startup code and a post() function for posting requests to windows (like channel sends but into a perpetual buffer).
Diffstat (limited to 'prevlib/dialog_windows.go')
-rw-r--r--prevlib/dialog_windows.go50
1 files changed, 0 insertions, 50 deletions
diff --git a/prevlib/dialog_windows.go b/prevlib/dialog_windows.go
deleted file mode 100644
index 5095999..0000000
--- a/prevlib/dialog_windows.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// 7 february 2014
-
-package ui
-
-import (
- "fmt"
- "os"
-)
-
-var (
- _messageBox = user32.NewProc("MessageBoxW")
-)
-
-var dialogResponses = map[uintptr]Response{
- _IDOK: OK,
-}
-
-func _msgBox(parent *Window, primarytext string, secondarytext string, uType uint32) Response {
- // 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
- if secondarytext != "" {
- text += "\n\n" + secondarytext
- }
- ptext := toUTF16(text)
- ptitle := toUTF16(os.Args[0])
- parenthwnd := _HWND(_NULL)
- if parent != dialogWindow {
- 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)
- }
- r1, _, err := _messageBox.Call(
- uintptr(parenthwnd),
- utf16ToArg(ptext),
- utf16ToArg(ptitle),
- uintptr(uType))
- if r1 == 0 { // failure
- panic(fmt.Sprintf("error displaying message box to user: %v\nstyle: 0x%08X\ntitle: %q\ntext:\n%s", err, uType, os.Args[0], text))
- }
- return dialogResponses[r1]
-}
-
-func (w *Window) msgBox(primarytext string, secondarytext string) {
- _msgBox(w, primarytext, secondarytext, _MB_OK)
-}
-
-func (w *Window) msgBoxError(primarytext string, secondarytext string) {
- _msgBox(w, primarytext, secondarytext, _MB_OK|_MB_ICONERROR)
-}