update clipmessage

master
兔子 8 months ago
parent ad19f5cd42
commit f7baa82534

@ -321,3 +321,37 @@ func SetClipboardViewer(hWndNewViewer HWND) (HWND, error) {
} }
return HWND(r), nil return HWND(r), nil
} }
func CreateWindowEx(dwExStyle DWORD, lpClassName, lpWindowName string, dwStyle DWORD, x, y, nWidth, nHeight int, hWndParent HWND, hMenu HMENU, hInstance HINSTANCE, lpParam unsafe.Pointer) (HWND, error) {
user32, err := syscall.LoadLibrary("user32.dll")
if err != nil {
return 0, errors.New("Can't Load User32 API")
}
defer syscall.FreeLibrary(user32)
cwe, err := syscall.GetProcAddress(syscall.Handle(user32), "CreateWindowExW")
if err != nil {
return 0, errors.New("Can't Load CreateWindowEx API")
}
r, _, errno := syscall.Syscall12(cwe, 11, uintptr(dwExStyle), uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpClassName))), uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpWindowName))), uintptr(dwStyle), uintptr(x), uintptr(y), uintptr(nWidth), uintptr(nHeight), uintptr(hWndParent), uintptr(hMenu), uintptr(hInstance), uintptr(lpParam))
if r == 0 {
return 0, error(errno)
}
return HWND(r), nil
}
func GetMessage(lpMsg *MSG, hWnd HWND, wMsgFilterMin, wMsgFilterMax DWORD) (DWORD, error) {
user32, err := syscall.LoadLibrary("user32.dll")
if err != nil {
return 0, errors.New("Can't Load User32 API")
}
defer syscall.FreeLibrary(user32)
gm, err := syscall.GetProcAddress(syscall.Handle(user32), "GetMessageW")
if err != nil {
return 0, errors.New("Can't Load GetMessage API")
}
r, _, errno := syscall.Syscall6(gm, 4, uintptr(unsafe.Pointer(lpMsg)), uintptr(hWnd), uintptr(wMsgFilterMin), uintptr(wMsgFilterMax), 0, 0)
if r == 0 {
return 0, error(errno)
}
return DWORD(r), nil
}

@ -1,5 +1,7 @@
package win32api package win32api
import "syscall"
const ( const (
VK_SHIFT = 0x10 VK_SHIFT = 0x10
VK_CTRL = 0x11 VK_CTRL = 0x11
@ -209,3 +211,20 @@ const (
CF_WAVE DWORD = 12 CF_WAVE DWORD = 12
CF_HENHMETAFILE DWORD = 14 CF_HENHMETAFILE DWORD = 14
) )
type MSG struct {
Hwnd syscall.Handle
Message uint32
WParam uintptr
LParam uintptr
Time uint32
Pt POINT
}
type POINT struct {
X, Y int32
}
const (
WM_CLIPBOARDUPDATE DWORD = 0x031D
)

Loading…
Cancel
Save