Renames.
This commit is contained in:
parent
31912f59fa
commit
537e3cbab3
3 changed files with 129 additions and 126 deletions
113
entry_windows.go
113
entry_windows.go
|
@ -17,8 +17,8 @@ func entry(text string, opts options) (string, error) {
|
|||
}
|
||||
|
||||
defer setup()()
|
||||
wnd := &entryWnd{font: getFont()}
|
||||
defer wnd.font.delete()
|
||||
dlg := &entryDialog{font: getFont()}
|
||||
defer dlg.font.delete()
|
||||
|
||||
if opts.ctx != nil && opts.ctx.Err() != nil {
|
||||
return "", opts.ctx.Err()
|
||||
|
@ -35,47 +35,47 @@ func entry(text string, opts options) (string, error) {
|
|||
}
|
||||
defer unregisterClass.Call(cls, instance)
|
||||
|
||||
wnd.handle, _, _ = createWindowEx.Call(0x10101, // WS_EX_CONTROLPARENT|WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME
|
||||
dlg.wnd, _, _ = createWindowEx.Call(0x10101, // WS_EX_CONTROLPARENT|WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME
|
||||
cls, strptr(*opts.title),
|
||||
0x84c80000, // WS_POPUPWINDOW|WS_CLIPSIBLINGS|WS_DLGFRAME
|
||||
0x80000000, // CW_USEDEFAULT
|
||||
0x80000000, // CW_USEDEFAULT
|
||||
281, 141, 0, 0, instance, uintptr(unsafe.Pointer(wnd)))
|
||||
281, 141, 0, 0, instance, uintptr(unsafe.Pointer(dlg)))
|
||||
|
||||
wnd.textCtl, _, _ = createWindowEx.Call(0,
|
||||
dlg.textCtl, _, _ = createWindowEx.Call(0,
|
||||
strptr("STATIC"), strptr(text),
|
||||
0x5002e080, // WS_CHILD|WS_VISIBLE|WS_GROUP|SS_WORDELLIPSIS|SS_EDITCONTROL|SS_NOPREFIX
|
||||
12, 10, 241, 16, wnd.handle, 0, instance, 0)
|
||||
12, 10, 241, 16, dlg.wnd, 0, instance, 0)
|
||||
|
||||
var flags uintptr = 0x50030080 // WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP|ES_AUTOHSCROLL
|
||||
if opts.hideText {
|
||||
flags |= 0x20 // ES_PASSWORD
|
||||
}
|
||||
wnd.editCtl, _, _ = createWindowEx.Call(0x200, // WS_EX_CLIENTEDGE
|
||||
dlg.editCtl, _, _ = createWindowEx.Call(0x200, // WS_EX_CLIENTEDGE
|
||||
strptr("EDIT"), strptr(opts.entryText),
|
||||
flags,
|
||||
12, 30, 241, 24, wnd.handle, 0, instance, 0)
|
||||
12, 30, 241, 24, dlg.wnd, 0, instance, 0)
|
||||
|
||||
wnd.okBtn, _, _ = createWindowEx.Call(0,
|
||||
dlg.okBtn, _, _ = createWindowEx.Call(0,
|
||||
strptr("BUTTON"), strptr(*opts.okLabel),
|
||||
0x50030001, // WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP|BS_DEFPUSHBUTTON
|
||||
12, 66, 75, 24, wnd.handle, 1 /* IDOK */, instance, 0)
|
||||
wnd.cancelBtn, _, _ = createWindowEx.Call(0,
|
||||
12, 66, 75, 24, dlg.wnd, 1 /* IDOK */, instance, 0)
|
||||
dlg.cancelBtn, _, _ = createWindowEx.Call(0,
|
||||
strptr("BUTTON"), strptr(*opts.cancelLabel),
|
||||
0x50010000, // WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP
|
||||
12, 66, 75, 24, wnd.handle, 2 /* IDCANCEL */, instance, 0)
|
||||
12, 66, 75, 24, dlg.wnd, 2 /* IDCANCEL */, instance, 0)
|
||||
if opts.extraButton != nil {
|
||||
wnd.extraBtn, _, _ = createWindowEx.Call(0,
|
||||
dlg.extraBtn, _, _ = createWindowEx.Call(0,
|
||||
strptr("BUTTON"), strptr(*opts.extraButton),
|
||||
0x50010000, // WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP
|
||||
12, 66, 75, 24, wnd.handle, 7 /* IDNO */, instance, 0)
|
||||
12, 66, 75, 24, dlg.wnd, 7 /* IDNO */, instance, 0)
|
||||
}
|
||||
|
||||
wnd.layout(getDPI(wnd.handle))
|
||||
centerWindow(wnd.handle)
|
||||
setFocus.Call(wnd.editCtl)
|
||||
showWindow.Call(wnd.handle, 1 /* SW_SHOWNORMAL */, 0)
|
||||
sendMessage.Call(wnd.editCtl, 0xb1 /* EM_SETSEL */, 0, intptr(-1))
|
||||
dlg.layout(getDPI(dlg.wnd))
|
||||
centerWindow(dlg.wnd)
|
||||
setFocus.Call(dlg.editCtl)
|
||||
showWindow.Call(dlg.wnd, 1 /* SW_SHOWNORMAL */, 0)
|
||||
sendMessage.Call(dlg.editCtl, 0xb1 /* EM_SETSEL */, 0, intptr(-1))
|
||||
|
||||
if opts.ctx != nil {
|
||||
wait := make(chan struct{})
|
||||
|
@ -83,63 +83,64 @@ func entry(text string, opts options) (string, error) {
|
|||
go func() {
|
||||
select {
|
||||
case <-opts.ctx.Done():
|
||||
sendMessage.Call(wnd.handle, 0x0112 /* WM_SYSCOMMAND */, 0xf060 /* SC_CLOSE */, 0)
|
||||
sendMessage.Call(dlg.wnd, 0x0112 /* WM_SYSCOMMAND */, 0xf060 /* SC_CLOSE */, 0)
|
||||
case <-wait:
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if err := messageLoop(wnd.handle); err != nil {
|
||||
if err := messageLoop(dlg.wnd); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if opts.ctx != nil && opts.ctx.Err() != nil {
|
||||
return "", opts.ctx.Err()
|
||||
}
|
||||
return wnd.out, wnd.err
|
||||
return dlg.out, dlg.err
|
||||
}
|
||||
|
||||
type entryWnd struct {
|
||||
handle uintptr
|
||||
type entryDialog struct {
|
||||
out string
|
||||
err error
|
||||
|
||||
wnd uintptr
|
||||
textCtl uintptr
|
||||
editCtl uintptr
|
||||
okBtn uintptr
|
||||
cancelBtn uintptr
|
||||
extraBtn uintptr
|
||||
out string
|
||||
err error
|
||||
font font
|
||||
}
|
||||
|
||||
func (wnd *entryWnd) layout(dpi dpi) {
|
||||
font := wnd.font.forDPI(dpi)
|
||||
sendMessage.Call(wnd.textCtl, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(wnd.editCtl, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(wnd.okBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(wnd.cancelBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(wnd.extraBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
setWindowPos.Call(wnd.handle, 0, 0, 0, dpi.scale(281), dpi.scale(141), 0x6) // SWP_NOZORDER|SWP_NOMOVE
|
||||
setWindowPos.Call(wnd.textCtl, 0, dpi.scale(12), dpi.scale(10), dpi.scale(241), dpi.scale(16), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(wnd.editCtl, 0, dpi.scale(12), dpi.scale(30), dpi.scale(241), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
if wnd.extraBtn == 0 {
|
||||
setWindowPos.Call(wnd.okBtn, 0, dpi.scale(95), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(wnd.cancelBtn, 0, dpi.scale(178), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
func (d *entryDialog) layout(dpi dpi) {
|
||||
font := d.font.forDPI(dpi)
|
||||
sendMessage.Call(d.textCtl, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(d.editCtl, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(d.okBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(d.cancelBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(d.extraBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
setWindowPos.Call(d.wnd, 0, 0, 0, dpi.scale(281), dpi.scale(141), 0x6) // SWP_NOZORDER|SWP_NOMOVE
|
||||
setWindowPos.Call(d.textCtl, 0, dpi.scale(12), dpi.scale(10), dpi.scale(241), dpi.scale(16), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.editCtl, 0, dpi.scale(12), dpi.scale(30), dpi.scale(241), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
if d.extraBtn == 0 {
|
||||
setWindowPos.Call(d.okBtn, 0, dpi.scale(95), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.cancelBtn, 0, dpi.scale(178), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
} else {
|
||||
setWindowPos.Call(wnd.okBtn, 0, dpi.scale(12), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(wnd.extraBtn, 0, dpi.scale(95), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(wnd.cancelBtn, 0, dpi.scale(178), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.okBtn, 0, dpi.scale(12), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.extraBtn, 0, dpi.scale(95), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.cancelBtn, 0, dpi.scale(178), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
}
|
||||
}
|
||||
|
||||
func entryProc(hwnd uintptr, msg uint32, wparam uintptr, lparam *unsafe.Pointer) uintptr {
|
||||
var wnd *entryWnd
|
||||
func entryProc(wnd uintptr, msg uint32, wparam uintptr, lparam *unsafe.Pointer) uintptr {
|
||||
var dlg *entryDialog
|
||||
switch msg {
|
||||
case 0x0081: // WM_NCCREATE
|
||||
saveBackRef(hwnd, *lparam)
|
||||
wnd = (*entryWnd)(*lparam)
|
||||
saveBackRef(wnd, *lparam)
|
||||
dlg = (*entryDialog)(*lparam)
|
||||
case 0x0082: // WM_NCDESTROY
|
||||
deleteBackRef(hwnd)
|
||||
deleteBackRef(wnd)
|
||||
default:
|
||||
wnd = (*entryWnd)(loadBackRef(hwnd))
|
||||
dlg = (*entryDialog)(loadBackRef(wnd))
|
||||
}
|
||||
|
||||
switch msg {
|
||||
|
@ -147,27 +148,27 @@ func entryProc(hwnd uintptr, msg uint32, wparam uintptr, lparam *unsafe.Pointer)
|
|||
postQuitMessage.Call(0)
|
||||
|
||||
case 0x0010: // WM_CLOSE
|
||||
wnd.err = ErrCanceled
|
||||
destroyWindow.Call(hwnd)
|
||||
dlg.err = ErrCanceled
|
||||
destroyWindow.Call(wnd)
|
||||
|
||||
case 0x0111: // WM_COMMAND
|
||||
switch wparam {
|
||||
default:
|
||||
return 1
|
||||
case 1, 6: // IDOK, IDYES
|
||||
wnd.out = getWindowString(wnd.editCtl)
|
||||
dlg.out = getWindowString(dlg.editCtl)
|
||||
case 2: // IDCANCEL
|
||||
wnd.err = ErrCanceled
|
||||
dlg.err = ErrCanceled
|
||||
case 7: // IDNO
|
||||
wnd.err = ErrExtraButton
|
||||
dlg.err = ErrExtraButton
|
||||
}
|
||||
destroyWindow.Call(hwnd)
|
||||
destroyWindow.Call(wnd)
|
||||
|
||||
case 0x02e0: // WM_DPICHANGED
|
||||
wnd.layout(dpi(uint32(wparam) >> 16))
|
||||
dlg.layout(dpi(uint32(wparam) >> 16))
|
||||
|
||||
default:
|
||||
res, _, _ := syscall.Syscall6(defWindowProc.Addr(), 4, hwnd, uintptr(msg), wparam, uintptr(unsafe.Pointer(lparam)), 0, 0)
|
||||
res, _, _ := defWindowProc.Call(wnd, uintptr(msg), wparam, uintptr(unsafe.Pointer(lparam)))
|
||||
return res
|
||||
}
|
||||
|
||||
|
|
131
list_windows.go
131
list_windows.go
|
@ -29,12 +29,12 @@ func listDlg(text string, items []string, multiple bool, opts options) ([]string
|
|||
}
|
||||
|
||||
defer setup()()
|
||||
wnd := &listWnd{
|
||||
dlg := &listDialog{
|
||||
items: items,
|
||||
multiple: multiple,
|
||||
font: getFont(),
|
||||
}
|
||||
defer wnd.font.delete()
|
||||
defer dlg.font.delete()
|
||||
|
||||
if opts.ctx != nil && opts.ctx.Err() != nil {
|
||||
return nil, opts.ctx.Err()
|
||||
|
@ -51,50 +51,50 @@ func listDlg(text string, items []string, multiple bool, opts options) ([]string
|
|||
}
|
||||
defer unregisterClass.Call(cls, instance)
|
||||
|
||||
wnd.handle, _, _ = createWindowEx.Call(0x10101, // WS_EX_CONTROLPARENT|WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME
|
||||
dlg.wnd, _, _ = createWindowEx.Call(0x10101, // WS_EX_CONTROLPARENT|WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME
|
||||
cls, strptr(*opts.title),
|
||||
0x84c80000, // WS_POPUPWINDOW|WS_CLIPSIBLINGS|WS_DLGFRAME
|
||||
0x80000000, // CW_USEDEFAULT
|
||||
0x80000000, // CW_USEDEFAULT
|
||||
281, 281, 0, 0, instance, uintptr(unsafe.Pointer(wnd)))
|
||||
281, 281, 0, 0, instance, uintptr(unsafe.Pointer(dlg)))
|
||||
|
||||
wnd.textCtl, _, _ = createWindowEx.Call(0,
|
||||
dlg.textCtl, _, _ = createWindowEx.Call(0,
|
||||
strptr("STATIC"), strptr(text),
|
||||
0x5002e080, // WS_CHILD|WS_VISIBLE|WS_GROUP|SS_WORDELLIPSIS|SS_EDITCONTROL|SS_NOPREFIX
|
||||
12, 10, 241, 16, wnd.handle, 0, instance, 0)
|
||||
12, 10, 241, 16, dlg.wnd, 0, instance, 0)
|
||||
|
||||
var flags uintptr = 0x50320000 // WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_GROUP|WS_TABSTOP
|
||||
if multiple {
|
||||
flags |= 0x0800 // LBS_EXTENDEDSEL
|
||||
}
|
||||
wnd.listCtl, _, _ = createWindowEx.Call(0x200, // WS_EX_CLIENTEDGE
|
||||
dlg.listCtl, _, _ = createWindowEx.Call(0x200, // WS_EX_CLIENTEDGE
|
||||
strptr("LISTBOX"), strptr(opts.entryText),
|
||||
flags,
|
||||
12, 30, 241, 164, wnd.handle, 0, instance, 0)
|
||||
12, 30, 241, 164, dlg.wnd, 0, instance, 0)
|
||||
|
||||
wnd.okBtn, _, _ = createWindowEx.Call(0,
|
||||
dlg.okBtn, _, _ = createWindowEx.Call(0,
|
||||
strptr("BUTTON"), strptr(*opts.okLabel),
|
||||
0x50030001, // WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP|BS_DEFPUSHBUTTON
|
||||
12, 206, 75, 24, wnd.handle, 1 /* IDOK */, instance, 0)
|
||||
wnd.cancelBtn, _, _ = createWindowEx.Call(0,
|
||||
12, 206, 75, 24, dlg.wnd, 1 /* IDOK */, instance, 0)
|
||||
dlg.cancelBtn, _, _ = createWindowEx.Call(0,
|
||||
strptr("BUTTON"), strptr(*opts.cancelLabel),
|
||||
0x50010000, // WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP
|
||||
12, 206, 75, 24, wnd.handle, 2 /* IDCANCEL */, instance, 0)
|
||||
12, 206, 75, 24, dlg.wnd, 2 /* IDCANCEL */, instance, 0)
|
||||
if opts.extraButton != nil {
|
||||
wnd.extraBtn, _, _ = createWindowEx.Call(0,
|
||||
dlg.extraBtn, _, _ = createWindowEx.Call(0,
|
||||
strptr("BUTTON"), strptr(*opts.extraButton),
|
||||
0x50010000, // WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP
|
||||
12, 206, 75, 24, wnd.handle, 7 /* IDNO */, instance, 0)
|
||||
12, 206, 75, 24, dlg.wnd, 7 /* IDNO */, instance, 0)
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
sendMessage.Call(wnd.listCtl, 0x180 /* LB_ADDSTRING */, 0, strptr(item))
|
||||
sendMessage.Call(dlg.listCtl, 0x180 /* LB_ADDSTRING */, 0, strptr(item))
|
||||
}
|
||||
|
||||
wnd.layout(getDPI(wnd.handle))
|
||||
centerWindow(wnd.handle)
|
||||
setFocus.Call(wnd.listCtl)
|
||||
showWindow.Call(wnd.handle, 1 /* SW_SHOWNORMAL */, 0)
|
||||
dlg.layout(getDPI(dlg.wnd))
|
||||
centerWindow(dlg.wnd)
|
||||
setFocus.Call(dlg.listCtl)
|
||||
showWindow.Call(dlg.wnd, 1 /* SW_SHOWNORMAL */, 0)
|
||||
|
||||
if opts.ctx != nil {
|
||||
wait := make(chan struct{})
|
||||
|
@ -102,65 +102,66 @@ func listDlg(text string, items []string, multiple bool, opts options) ([]string
|
|||
go func() {
|
||||
select {
|
||||
case <-opts.ctx.Done():
|
||||
sendMessage.Call(wnd.handle, 0x0112 /* WM_SYSCOMMAND */, 0xf060 /* SC_CLOSE */, 0)
|
||||
sendMessage.Call(dlg.wnd, 0x0112 /* WM_SYSCOMMAND */, 0xf060 /* SC_CLOSE */, 0)
|
||||
case <-wait:
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if err := messageLoop(wnd.handle); err != nil {
|
||||
if err := messageLoop(dlg.wnd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if opts.ctx != nil && opts.ctx.Err() != nil {
|
||||
return nil, opts.ctx.Err()
|
||||
}
|
||||
return wnd.out, wnd.err
|
||||
return dlg.out, dlg.err
|
||||
}
|
||||
|
||||
type listWnd struct {
|
||||
handle uintptr
|
||||
type listDialog struct {
|
||||
items []string
|
||||
multiple bool
|
||||
out []string
|
||||
err error
|
||||
|
||||
wnd uintptr
|
||||
textCtl uintptr
|
||||
listCtl uintptr
|
||||
okBtn uintptr
|
||||
cancelBtn uintptr
|
||||
extraBtn uintptr
|
||||
multiple bool
|
||||
items []string
|
||||
out []string
|
||||
err error
|
||||
font font
|
||||
}
|
||||
|
||||
func (wnd *listWnd) layout(dpi dpi) {
|
||||
font := wnd.font.forDPI(dpi)
|
||||
sendMessage.Call(wnd.textCtl, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(wnd.listCtl, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(wnd.okBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(wnd.cancelBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(wnd.extraBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
setWindowPos.Call(wnd.handle, 0, 0, 0, dpi.scale(281), dpi.scale(281), 0x6) // SWP_NOZORDER|SWP_NOMOVE
|
||||
setWindowPos.Call(wnd.textCtl, 0, dpi.scale(12), dpi.scale(10), dpi.scale(241), dpi.scale(16), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(wnd.listCtl, 0, dpi.scale(12), dpi.scale(30), dpi.scale(241), dpi.scale(164), 0x4) // SWP_NOZORDER
|
||||
if wnd.extraBtn == 0 {
|
||||
setWindowPos.Call(wnd.okBtn, 0, dpi.scale(95), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(wnd.cancelBtn, 0, dpi.scale(178), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
func (d *listDialog) layout(dpi dpi) {
|
||||
font := d.font.forDPI(dpi)
|
||||
sendMessage.Call(d.textCtl, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(d.listCtl, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(d.okBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(d.cancelBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
sendMessage.Call(d.extraBtn, 0x0030 /* WM_SETFONT */, font, 1)
|
||||
setWindowPos.Call(d.wnd, 0, 0, 0, dpi.scale(281), dpi.scale(281), 0x6) // SWP_NOZORDER|SWP_NOMOVE
|
||||
setWindowPos.Call(d.textCtl, 0, dpi.scale(12), dpi.scale(10), dpi.scale(241), dpi.scale(16), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.listCtl, 0, dpi.scale(12), dpi.scale(30), dpi.scale(241), dpi.scale(164), 0x4) // SWP_NOZORDER
|
||||
if d.extraBtn == 0 {
|
||||
setWindowPos.Call(d.okBtn, 0, dpi.scale(95), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.cancelBtn, 0, dpi.scale(178), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
} else {
|
||||
setWindowPos.Call(wnd.okBtn, 0, dpi.scale(12), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(wnd.extraBtn, 0, dpi.scale(95), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(wnd.cancelBtn, 0, dpi.scale(178), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.okBtn, 0, dpi.scale(12), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.extraBtn, 0, dpi.scale(95), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
setWindowPos.Call(d.cancelBtn, 0, dpi.scale(178), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER
|
||||
}
|
||||
}
|
||||
|
||||
func listProc(hwnd uintptr, msg uint32, wparam uintptr, lparam *unsafe.Pointer) uintptr {
|
||||
var wnd *listWnd
|
||||
func listProc(wnd uintptr, msg uint32, wparam uintptr, lparam *unsafe.Pointer) uintptr {
|
||||
var dlg *listDialog
|
||||
switch msg {
|
||||
case 0x0081: // WM_NCCREATE
|
||||
saveBackRef(hwnd, *lparam)
|
||||
wnd = (*listWnd)(*lparam)
|
||||
saveBackRef(wnd, *lparam)
|
||||
dlg = (*listDialog)(*lparam)
|
||||
case 0x0082: // WM_NCDESTROY
|
||||
deleteBackRef(hwnd)
|
||||
deleteBackRef(wnd)
|
||||
default:
|
||||
wnd = (*listWnd)(loadBackRef(hwnd))
|
||||
dlg = (*listDialog)(loadBackRef(wnd))
|
||||
}
|
||||
|
||||
switch msg {
|
||||
|
@ -168,44 +169,44 @@ func listProc(hwnd uintptr, msg uint32, wparam uintptr, lparam *unsafe.Pointer)
|
|||
postQuitMessage.Call(0)
|
||||
|
||||
case 0x0010: // WM_CLOSE
|
||||
wnd.err = ErrCanceled
|
||||
destroyWindow.Call(hwnd)
|
||||
dlg.err = ErrCanceled
|
||||
destroyWindow.Call(wnd)
|
||||
|
||||
case 0x0111: // WM_COMMAND
|
||||
switch wparam {
|
||||
default:
|
||||
return 1
|
||||
case 1, 6: // IDOK, IDYES
|
||||
if wnd.multiple {
|
||||
if len, _, _ := sendMessage.Call(wnd.listCtl, 0x190 /* LB_GETSELCOUNT */, 0, 0); int32(len) >= 0 {
|
||||
wnd.out = make([]string, len)
|
||||
if dlg.multiple {
|
||||
if len, _, _ := sendMessage.Call(dlg.listCtl, 0x190 /* LB_GETSELCOUNT */, 0, 0); int32(len) >= 0 {
|
||||
dlg.out = make([]string, len)
|
||||
if len > 0 {
|
||||
indices := make([]int32, len)
|
||||
sendMessage.Call(wnd.listCtl, 0x191 /* LB_GETSELITEMS */, len, uintptr(unsafe.Pointer(&indices[0])))
|
||||
sendMessage.Call(dlg.listCtl, 0x191 /* LB_GETSELITEMS */, len, uintptr(unsafe.Pointer(&indices[0])))
|
||||
for i, idx := range indices {
|
||||
wnd.out[i] = wnd.items[idx]
|
||||
dlg.out[i] = dlg.items[idx]
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if idx, _, _ := sendMessage.Call(wnd.listCtl, 0x188 /* LB_GETCURSEL */, 0, 0); int32(idx) >= 0 {
|
||||
wnd.out = []string{wnd.items[idx]}
|
||||
if idx, _, _ := sendMessage.Call(dlg.listCtl, 0x188 /* LB_GETCURSEL */, 0, 0); int32(idx) >= 0 {
|
||||
dlg.out = []string{dlg.items[idx]}
|
||||
} else {
|
||||
wnd.out = []string{}
|
||||
dlg.out = []string{}
|
||||
}
|
||||
}
|
||||
case 2: // IDCANCEL
|
||||
wnd.err = ErrCanceled
|
||||
dlg.err = ErrCanceled
|
||||
case 7: // IDNO
|
||||
wnd.err = ErrExtraButton
|
||||
dlg.err = ErrExtraButton
|
||||
}
|
||||
destroyWindow.Call(hwnd)
|
||||
destroyWindow.Call(wnd)
|
||||
|
||||
case 0x02e0: // WM_DPICHANGED
|
||||
wnd.layout(dpi(uint32(wparam) >> 16))
|
||||
dlg.layout(dpi(uint32(wparam) >> 16))
|
||||
|
||||
default:
|
||||
res, _, _ := syscall.Syscall6(defWindowProc.Addr(), 4, hwnd, uintptr(msg), wparam, uintptr(unsafe.Pointer(lparam)), 0, 0)
|
||||
res, _, _ := defWindowProc.Call(wnd, uintptr(msg), wparam, uintptr(unsafe.Pointer(lparam)))
|
||||
return res
|
||||
}
|
||||
|
||||
|
|
|
@ -137,16 +137,17 @@ func progressDlg(opts options, dlg *progressDialog) error {
|
|||
}
|
||||
|
||||
type progressDialog struct {
|
||||
max int
|
||||
done chan struct{}
|
||||
init sync.WaitGroup
|
||||
max int
|
||||
err error
|
||||
|
||||
wnd uintptr
|
||||
textCtl uintptr
|
||||
progCtl uintptr
|
||||
okBtn uintptr
|
||||
cancelBtn uintptr
|
||||
extraBtn uintptr
|
||||
err error
|
||||
font font
|
||||
}
|
||||
|
||||
|
@ -269,7 +270,7 @@ func progressProc(wnd uintptr, msg uint32, wparam uintptr, lparam *unsafe.Pointe
|
|||
dlg.layout(dpi(uint32(wparam) >> 16))
|
||||
|
||||
default:
|
||||
res, _, _ := syscall.Syscall6(defWindowProc.Addr(), 4, wnd, uintptr(msg), wparam, uintptr(unsafe.Pointer(lparam)), 0, 0)
|
||||
res, _, _ := defWindowProc.Call(wnd, uintptr(msg), wparam, uintptr(unsafe.Pointer(lparam)))
|
||||
return res
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue