From c13b697fddcb1ed223be35ffca221143d376dad3 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 15 Sep 2013 14:47:58 +0200 Subject: [PATCH 001/138] Fix XP trouble by not requiring PdhAddEnglishCounterW --- kernel32.go | 1 + pdh.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel32.go b/kernel32.go index ce1bfcec..b08a9f62 100644 --- a/kernel32.go +++ b/kernel32.go @@ -14,6 +14,7 @@ const MAX_PATH = 260 // Error codes const ( ERROR_SUCCESS = 0 + ERROR_INVALID_FUNCTION = 1 ERROR_FILE_NOT_FOUND = 2 ERROR_INVALID_PARAMETER = 87 ERROR_INSUFFICIENT_BUFFER = 122 diff --git a/pdh.go b/pdh.go index 318ae47d..1d3d1845 100644 --- a/pdh.go +++ b/pdh.go @@ -178,7 +178,7 @@ func init() { // Functions pdh_AddCounterW = libpdhDll.MustFindProc("PdhAddCounterW") - pdh_AddEnglishCounterW = libpdhDll.MustFindProc("PdhAddEnglishCounterW") // XXX: only supported on versions > Vista. + pdh_AddEnglishCounterW, _ = libpdhDll.FindProc("PdhAddEnglishCounterW") // XXX: only supported on versions > Vista. pdh_CloseQuery = libpdhDll.MustFindProc("PdhCloseQuery") pdh_CollectQueryData = libpdhDll.MustFindProc("PdhCollectQueryData") pdh_GetFormattedCounterValue = libpdhDll.MustFindProc("PdhGetFormattedCounterValue") @@ -239,6 +239,10 @@ func PdhAddCounter(hQuery PDH_HQUERY, szFullCounterPath string, dwUserData uintp // Adds the specified language-neutral counter to the query. See the PdhAddCounter function. This function only exists on // Windows versions higher than Vista. func PdhAddEnglishCounter(hQuery PDH_HQUERY, szFullCounterPath string, dwUserData uintptr, phCounter *PDH_HCOUNTER) uint32 { + if pdh_AddEnglishCounterW == nil { + return ERROR_INVALID_FUNCTION + } + ptxt, _ := syscall.UTF16PtrFromString(szFullCounterPath) ret, _, _ := pdh_AddEnglishCounterW.Call( uintptr(hQuery), From 5764fba6a14f875db4b91e50ab6c92fe60c9b6f3 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 30 Dec 2013 12:49:29 +0100 Subject: [PATCH 002/138] Call correct api function in GetStockObject, fixes #4 --- gdi32.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdi32.go b/gdi32.go index 5798b8ca..2d49a6f3 100644 --- a/gdi32.go +++ b/gdi32.go @@ -1317,7 +1317,7 @@ func GetPixel(hdc HDC, nXPos, nYPos int32) COLORREF { } func GetStockObject(fnObject int32) HGDIOBJ { - ret, _, _ := syscall.Syscall(getDeviceCaps, 1, + ret, _, _ := syscall.Syscall(getStockObject, 1, uintptr(fnObject), 0, 0) From 83b90faaf1e60ae1da7e2ef6c613a07b2e0d1615 Mon Sep 17 00:00:00 2001 From: Bruno Bigras Date: Thu, 16 Jan 2014 14:06:23 -0500 Subject: [PATCH 003/138] Use syscall.GUID --- AUTHORS | 1 + ole32.go | 4 ++-- shell32.go | 2 +- win.go | 7 ------- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/AUTHORS b/AUTHORS index 86b306ba..295d558d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,6 +12,7 @@ Alexander Neumann Anton Lahti Benny Siegert +Bruno Bigras Cary Cherng Hill Kevin Pors diff --git a/ole32.go b/ole32.go index 7e733cf7..c8c69a52 100644 --- a/ole32.go +++ b/ole32.go @@ -53,8 +53,8 @@ const ( OLECLOSE_PROMPTSAVE = 2 ) -type IID GUID -type CLSID GUID +type IID syscall.GUID +type CLSID syscall.GUID type REFIID *IID type REFCLSID *CLSID diff --git a/shell32.go b/shell32.go index f51c3845..6598993f 100644 --- a/shell32.go +++ b/shell32.go @@ -148,7 +148,7 @@ type NOTIFYICONDATA struct { UVersion uint32 SzInfoTitle [64]uint16 DwInfoFlags uint32 - GuidItem GUID + GuidItem syscall.GUID } type SHFILEINFO struct { diff --git a/win.go b/win.go index f5d660af..46703118 100644 --- a/win.go +++ b/win.go @@ -40,13 +40,6 @@ type ( HRESULT int32 ) -type GUID struct { - Data1 uint32 - Data2 uint16 - Data3 uint16 - Data4 [8]byte -} - func MustLoadLibrary(name string) uintptr { lib, err := syscall.LoadLibrary(name) if err != nil { From a7d13adcd8dbd8d44e81f519a989b16554193400 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 10 Mar 2014 11:35:54 +0100 Subject: [PATCH 004/138] Add some ScrollBar stuff --- user32.go | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/user32.go b/user32.go index 84272e61..7a131ec7 100644 --- a/user32.go +++ b/user32.go @@ -1170,6 +1170,43 @@ const ( CF_WAVE = 12 ) +// ScrollBar constants +const ( + SB_HORZ = 0 + SB_VERT = 1 + SB_CTL = 2 + SB_BOTH = 3 +) + +// ScrollBar commands +const ( + SB_LINEUP = 0 + SB_LINELEFT = 0 + SB_LINEDOWN = 1 + SB_LINERIGHT = 1 + SB_PAGEUP = 2 + SB_PAGELEFT = 2 + SB_PAGEDOWN = 3 + SB_PAGERIGHT = 3 + SB_THUMBPOSITION = 4 + SB_THUMBTRACK = 5 + SB_TOP = 6 + SB_LEFT = 6 + SB_BOTTOM = 7 + SB_RIGHT = 7 + SB_ENDSCROLL = 8 +) + +// [Get|Set]ScrollInfo mask constants +const ( + SIF_RANGE = 1 + SIF_PAGE = 2 + SIF_POS = 4 + SIF_DISABLENOSCROLL = 8 + SIF_TRACKPOS = 16 + SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS +) + type MONITORINFO struct { CbSize uint32 RcMonitor RECT @@ -1413,6 +1450,16 @@ type HARDWAREINPUT struct { Unused [16]byte } +type SCROLLINFO struct { + CbSize uint32 + FMask uint32 + NMin int32 + NMax int32 + NPage uint32 + NPos int32 + NTrackPos int32 +} + func GET_X_LPARAM(lp uintptr) int32 { return int32(int16(LOWORD(uint32(lp)))) } @@ -1467,6 +1514,7 @@ var ( getMonitorInfo uintptr getParent uintptr getRawInputData uintptr + getScrollInfo uintptr getSysColor uintptr getSysColorBrush uintptr getSystemMetrics uintptr @@ -1519,6 +1567,7 @@ var ( setMenuItemInfo uintptr setParent uintptr setRect uintptr + setScrollInfo uintptr setTimer uintptr setWindowLong uintptr setWindowLongPtr uintptr @@ -1580,6 +1629,7 @@ func init() { getMonitorInfo = MustGetProcAddress(libuser32, "GetMonitorInfoW") getParent = MustGetProcAddress(libuser32, "GetParent") getRawInputData = MustGetProcAddress(libuser32, "GetRawInputData") + getScrollInfo = MustGetProcAddress(libuser32, "GetScrollInfo") getSysColor = MustGetProcAddress(libuser32, "GetSysColor") getSysColorBrush = MustGetProcAddress(libuser32, "GetSysColorBrush") getSystemMetrics = MustGetProcAddress(libuser32, "GetSystemMetrics") @@ -1637,6 +1687,7 @@ func init() { setMenuItemInfo = MustGetProcAddress(libuser32, "SetMenuItemInfoW") setRect = MustGetProcAddress(libuser32, "SetRect") setParent = MustGetProcAddress(libuser32, "SetParent") + setScrollInfo = MustGetProcAddress(libuser32, "SetScrollInfo") setTimer = MustGetProcAddress(libuser32, "SetTimer") setWindowLong = MustGetProcAddress(libuser32, "SetWindowLongW") // On 32 bit SetWindowLongPtrW is not available @@ -2061,6 +2112,15 @@ func GetRawInputData(hRawInput HRAWINPUT, uiCommand uint32, pData unsafe.Pointer return uint32(ret) } +func GetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO) bool { + ret, _, _ := syscall.Syscall(getScrollInfo, 3, + uintptr(hwnd), + uintptr(fnBar), + uintptr(unsafe.Pointer(lpsi))) + + return ret != 0 +} + func GetSysColor(nIndex int) uint32 { ret, _, _ := syscall.Syscall(getSysColor, 1, uintptr(nIndex), @@ -2574,6 +2634,18 @@ func SetRect(lprc *RECT, xLeft, yTop, xRight, yBottom uint32) BOOL { return BOOL(ret) } +func SetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO, fRedraw bool) int32 { + ret, _, _ := syscall.Syscall6(setScrollInfo, 4, + uintptr(hwnd), + uintptr(fnBar), + uintptr(unsafe.Pointer(lpsi)), + uintptr(BoolToBOOL(fRedraw)), + 0, + 0) + + return int32(ret) +} + func SetTimer(hWnd HWND, nIDEvent uintptr, uElapse uint32, lpTimerFunc uintptr) uintptr { ret, _, _ := syscall.Syscall6(setTimer, 4, uintptr(hWnd), From ead013225dc2823fe9b51fa1c3cf387e4c4d7181 Mon Sep 17 00:00:00 2001 From: Carlos Cobo Date: Fri, 7 Mar 2014 12:08:49 +0100 Subject: [PATCH 005/138] Some useful documentation for SendInput. Might help newcomers or people unfamiliarized with the syscall and/or unsafe packages. --- AUTHORS | 2 +- user32.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 295d558d..e2fa5825 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,4 +18,4 @@ Hill Kevin Pors mycaosf wsf01 - +Carlos Cobo diff --git a/user32.go b/user32.go index 84272e61..d6636472 100644 --- a/user32.go +++ b/user32.go @@ -2439,6 +2439,7 @@ func SendDlgItemMessage(hWnd HWND, id int32, msg uint32, wParam, lParam uintptr) return ret } +// pInputs expects a unsafe.Pointer to a slice of MOUSE_INPUT or KEYBD_INPUT or HARDWARE_INPUT structs. func SendInput(nInputs uint32, pInputs unsafe.Pointer, cbSize int32) uint32 { ret, _, _ := syscall.Syscall(sendInput, 3, uintptr(nInputs), From 93ec4d8632ccf6962410d96d4667fb6e1aa36bb2 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 25 Jun 2015 09:58:48 +0200 Subject: [PATCH 006/138] Don't ask... --- comctl32.go | 31 ++++++++++++-- comdlg32.go | 36 ++++++++++++++++ kernel32.go | 22 ++++++++++ treeview.go | 14 +++++++ user32.go | 27 ++++++++++++ uxtheme.go | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 242 insertions(+), 4 deletions(-) diff --git a/comctl32.go b/comctl32.go index f25fb936..10615479 100644 --- a/comctl32.go +++ b/comctl32.go @@ -131,19 +131,44 @@ const ( ) const ( - CDDS_PREPAINT = 0x00000001 - CDDS_ITEM = 0x00010000 - CDDS_ITEMPREPAINT = CDDS_ITEM | CDDS_PREPAINT + CDDS_PREPAINT = 0x00000001 + CDDS_POSTPAINT = 0x00000002 + CDDS_PREERASE = 0x00000003 + CDDS_POSTERASE = 0x00000004 + CDDS_ITEM = 0x00010000 + CDDS_ITEMPREPAINT = CDDS_ITEM | CDDS_PREPAINT + CDDS_ITEMPOSTPAINT = CDDS_ITEM | CDDS_POSTPAINT + CDDS_ITEMPREERASE = CDDS_ITEM | CDDS_PREERASE + CDDS_ITEMPOSTERASE = CDDS_ITEM | CDDS_POSTERASE + CDDS_SUBITEM = 0x00020000 +) + +const ( + CDIS_SELECTED = 0x0001 + CDIS_GRAYED = 0x0002 + CDIS_DISABLED = 0x0004 + CDIS_CHECKED = 0x0008 + CDIS_FOCUS = 0x0010 + CDIS_DEFAULT = 0x0020 + CDIS_HOT = 0x0040 + CDIS_MARKED = 0x0080 + CDIS_INDETERMINATE = 0x0100 + CDIS_SHOWKEYBOARDCUES = 0x0200 + CDIS_NEARHOT = 0x0400 + CDIS_OTHERSIDEHOT = 0x0800 + CDIS_DROPHILITED = 0x1000 ) const ( CDRF_DODEFAULT = 0x00000000 CDRF_NEWFONT = 0x00000002 CDRF_SKIPDEFAULT = 0x00000004 + CDRF_DOERASE = 0x00000008 CDRF_NOTIFYPOSTPAINT = 0x00000010 CDRF_NOTIFYITEMDRAW = 0x00000020 CDRF_NOTIFYSUBITEMDRAW = 0x00000020 CDRF_NOTIFYPOSTERASE = 0x00000040 + CDRF_SKIPPOSTPAINT = 0x00000100 ) const ( diff --git a/comdlg32.go b/comdlg32.go index f7334d16..d5892ccd 100644 --- a/comdlg32.go +++ b/comdlg32.go @@ -26,6 +26,31 @@ const ( CDERR_STRUCTSIZE = 0x0001 ) +// CHOOSECOLOR flags +const ( + CC_ANYCOLOR = 0x00000100 + CC_ENABLEHOOK = 0x00000010 + CC_ENABLETEMPLATE = 0x00000020 + CC_ENABLETEMPLATEHANDLE = 0x00000040 + CC_FULLOPEN = 0x00000002 + CC_PREVENTFULLOPEN = 0x00000004 + CC_RGBINIT = 0x00000001 + CC_SHOWHELP = 0x00000008 + CC_SOLIDCOLOR = 0x00000080 +) + +type CHOOSECOLOR struct { + LStructSize uint32 + HwndOwner HWND + HInstance HWND + RgbResult COLORREF + LpCustColors *COLORREF + Flags uint32 + LCustData uintptr + LpfnHook uintptr + LpTemplateName *uint16 +} + // PrintDlg specific error codes const ( PDERR_CREATEICFAILURE = 0x100A @@ -207,6 +232,7 @@ var ( libcomdlg32 uintptr // Functions + chooseColor uintptr commDlgExtendedError uintptr getOpenFileName uintptr getSaveFileName uintptr @@ -218,12 +244,22 @@ func init() { libcomdlg32 = MustLoadLibrary("comdlg32.dll") // Functions + chooseColor = MustGetProcAddress(libcomdlg32, "ChooseColorW") commDlgExtendedError = MustGetProcAddress(libcomdlg32, "CommDlgExtendedError") getOpenFileName = MustGetProcAddress(libcomdlg32, "GetOpenFileNameW") getSaveFileName = MustGetProcAddress(libcomdlg32, "GetSaveFileNameW") printDlgEx = MustGetProcAddress(libcomdlg32, "PrintDlgExW") } +func ChooseColor(lpcc *CHOOSECOLOR) bool { + ret, _, _ := syscall.Syscall(chooseColor, 1, + uintptr(unsafe.Pointer(lpcc)), + 0, + 0) + + return ret != 0 +} + func CommDlgExtendedError() uint32 { ret, _, _ := syscall.Syscall(commDlgExtendedError, 0, 0, diff --git a/kernel32.go b/kernel32.go index b08a9f62..3aa11559 100644 --- a/kernel32.go +++ b/kernel32.go @@ -57,6 +57,8 @@ var ( // Functions closeHandle uintptr fileTimeToSystemTime uintptr + getConsoleTitle uintptr + getConsoleWindow uintptr getLastError uintptr getLocaleInfo uintptr getLogicalDriveStrings uintptr @@ -116,6 +118,8 @@ func init() { // Functions closeHandle = MustGetProcAddress(libkernel32, "CloseHandle") fileTimeToSystemTime = MustGetProcAddress(libkernel32, "FileTimeToSystemTime") + getConsoleTitle = MustGetProcAddress(libkernel32, "GetConsoleTitleW") + getConsoleWindow = MustGetProcAddress(libkernel32, "GetConsoleWindow") getLastError = MustGetProcAddress(libkernel32, "GetLastError") getLocaleInfo = MustGetProcAddress(libkernel32, "GetLocaleInfoW") getLogicalDriveStrings = MustGetProcAddress(libkernel32, "GetLogicalDriveStringsW") @@ -153,6 +157,24 @@ func FileTimeToSystemTime(lpFileTime *FILETIME, lpSystemTime *SYSTEMTIME) bool { return ret != 0 } +func GetConsoleTitle(lpConsoleTitle *uint16, nSize uint32) uint32 { + ret, _, _ := syscall.Syscall(getConsoleTitle, 2, + uintptr(unsafe.Pointer(lpConsoleTitle)), + uintptr(nSize), + 0) + + return uint32(ret) +} + +func GetConsoleWindow() HWND { + ret, _, _ := syscall.Syscall(getConsoleWindow, 0, + 0, + 0, + 0) + + return HWND(ret) +} + func GetLastError() uint32 { ret, _, _ := syscall.Syscall(getLastError, 0, 0, diff --git a/treeview.go b/treeview.go index ce51ef75..16721c5f 100644 --- a/treeview.go +++ b/treeview.go @@ -24,6 +24,20 @@ const ( TVS_NOHSCROLL = 0x8000 ) +const ( + TVS_EX_NOSINGLECOLLAPSE = 0x0001 + TVS_EX_MULTISELECT = 0x0002 + TVS_EX_DOUBLEBUFFER = 0x0004 + TVS_EX_NOINDENTSTATE = 0x0008 + TVS_EX_RICHTOOLTIP = 0x0010 + TVS_EX_AUTOHSCROLL = 0x0020 + TVS_EX_FADEINOUTEXPANDOS = 0x0040 + TVS_EX_PARTIALCHECKBOXES = 0x0080 + TVS_EX_EXCLUSIONCHECKBOXES = 0x0100 + TVS_EX_DIMMEDCHECKBOXES = 0x0200 + TVS_EX_DRAWIMAGEASYNC = 0x0400 +) + const ( TVIF_TEXT = 0x0001 TVIF_IMAGE = 0x0002 diff --git a/user32.go b/user32.go index 7a131ec7..c5c06828 100644 --- a/user32.go +++ b/user32.go @@ -1207,6 +1207,16 @@ const ( SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS ) +// DrawIconEx flags +const ( + DI_COMPAT = 0x0004 + DI_DEFAULTSIZE = 0x0008 + DI_IMAGE = 0x0002 + DI_MASK = 0x0001 + DI_NOMIRROR = 0x0010 + DI_NORMAL = DI_IMAGE | DI_MASK +) + type MONITORINFO struct { CbSize uint32 RcMonitor RECT @@ -1491,6 +1501,7 @@ var ( destroyWindow uintptr dialogBoxParam uintptr dispatchMessage uintptr + drawIconEx uintptr drawMenuBar uintptr drawFocusRect uintptr drawTextEx uintptr @@ -1606,6 +1617,7 @@ func init() { destroyWindow = MustGetProcAddress(libuser32, "DestroyWindow") dialogBoxParam = MustGetProcAddress(libuser32, "DialogBoxParamW") dispatchMessage = MustGetProcAddress(libuser32, "DispatchMessageW") + drawIconEx = MustGetProcAddress(libuser32, "DrawIconEx") drawFocusRect = MustGetProcAddress(libuser32, "DrawFocusRect") drawMenuBar = MustGetProcAddress(libuser32, "DrawMenuBar") drawTextEx = MustGetProcAddress(libuser32, "DrawTextExW") @@ -1905,6 +1917,21 @@ func DrawFocusRect(hDC HDC, lprc *RECT) bool { return ret != 0 } +func DrawIconEx(hdc HDC, xLeft, yTop int32, hIcon HICON, cxWidth, cyWidth int32, istepIfAniCur uint32, hbrFlickerFreeDraw HBRUSH, diFlags uint32) bool { + ret, _, _ := syscall.Syscall9(drawIconEx, 9, + uintptr(hdc), + uintptr(xLeft), + uintptr(yTop), + uintptr(hIcon), + uintptr(cxWidth), + uintptr(cyWidth), + uintptr(istepIfAniCur), + uintptr(hbrFlickerFreeDraw), + uintptr(diFlags)) + + return ret != 0 +} + func DrawMenuBar(hWnd HWND) bool { ret, _, _ := syscall.Syscall(drawMenuBar, 1, uintptr(hWnd), diff --git a/uxtheme.go b/uxtheme.go index a9f4c836..803dba79 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -9,12 +9,61 @@ import ( "unsafe" ) +// LISTVIEW parts +const ( + LVP_LISTITEM = 1 + LVP_LISTGROUP = 2 + LVP_LISTDETAIL = 3 + LVP_LISTSORTEDDETAIL = 4 + LVP_EMPTYTEXT = 5 + LVP_GROUPHEADER = 6 + LVP_GROUPHEADERLINE = 7 + LVP_EXPANDBUTTON = 8 + LVP_COLLAPSEBUTTON = 9 + LVP_COLUMNDETAIL = 10 +) + +// LVP_LISTITEM states +const ( + LISS_NORMAL = 1 + LISS_HOT = 2 + LISS_SELECTED = 3 + LISS_DISABLED = 4 + LISS_SELECTEDNOTFOCUS = 5 + LISS_HOTSELECTED = 6 +) + +// TREEVIEW parts +const ( + TVP_TREEITEM = 1 + TVP_GLYPH = 2 + TVP_BRANCH = 3 + TVP_HOTGLYPH = 4 +) + +// TVP_TREEITEM states +const ( + TREIS_NORMAL = 1 + TREIS_HOT = 2 + TREIS_SELECTED = 3 + TREIS_DISABLED = 4 + TREIS_SELECTEDNOTFOCUS = 5 + TREIS_HOTSELECTED = 6 +) + +type HTHEME HANDLE + var ( // Library libuxtheme uintptr // Functions - setWindowTheme uintptr + closeThemeData uintptr + drawThemeBackground uintptr + drawThemeText uintptr + getThemeTextExtent uintptr + openThemeData uintptr + setWindowTheme uintptr ) func init() { @@ -22,9 +71,74 @@ func init() { libuxtheme = MustLoadLibrary("uxtheme.dll") // Functions + closeThemeData = MustGetProcAddress(libuxtheme, "CloseThemeData") + drawThemeBackground = MustGetProcAddress(libuxtheme, "DrawThemeBackground") + drawThemeText = MustGetProcAddress(libuxtheme, "DrawThemeText") + getThemeTextExtent = MustGetProcAddress(libuxtheme, "GetThemeTextExtent") + openThemeData = MustGetProcAddress(libuxtheme, "OpenThemeData") setWindowTheme = MustGetProcAddress(libuxtheme, "SetWindowTheme") } +func CloseThemeData(hTheme HTHEME) HRESULT { + ret, _, _ := syscall.Syscall(closeThemeData, 1, + uintptr(hTheme), + 0, + 0) + + return HRESULT(ret) +} + +func DrawThemeBackground(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pRect, pClipRect *RECT) HRESULT { + ret, _, _ := syscall.Syscall6(drawThemeBackground, 6, + uintptr(hTheme), + uintptr(hdc), + uintptr(iPartId), + uintptr(iStateId), + uintptr(unsafe.Pointer(pRect)), + uintptr(unsafe.Pointer(pClipRect))) + + return HRESULT(ret) +} + +func DrawThemeText(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uint16, iCharCount int32, dwTextFlags, dwTextFlags2 uint32, pRect *RECT) HRESULT { + ret, _, _ := syscall.Syscall9(drawThemeText, 9, + uintptr(hTheme), + uintptr(hdc), + uintptr(iPartId), + uintptr(iStateId), + uintptr(unsafe.Pointer(pszText)), + uintptr(iCharCount), + uintptr(dwTextFlags), + uintptr(dwTextFlags2), + uintptr(unsafe.Pointer(pRect))) + + return HRESULT(ret) +} + +func GetThemeTextExtent(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uint16, iCharCount int32, dwTextFlags uint32, pBoundingRect, pExtentRect *RECT) HRESULT { + ret, _, _ := syscall.Syscall9(getThemeTextExtent, 9, + uintptr(hTheme), + uintptr(hdc), + uintptr(iPartId), + uintptr(iStateId), + uintptr(unsafe.Pointer(pszText)), + uintptr(iCharCount), + uintptr(dwTextFlags), + uintptr(unsafe.Pointer(pBoundingRect)), + uintptr(unsafe.Pointer(pExtentRect))) + + return HRESULT(ret) +} + +func OpenThemeData(hwnd HWND, pszClassList *uint16) HTHEME { + ret, _, _ := syscall.Syscall(openThemeData, 2, + uintptr(hwnd), + uintptr(unsafe.Pointer(pszClassList)), + 0) + + return HTHEME(ret) +} + func SetWindowTheme(hwnd HWND, pszSubAppName, pszSubIdList *uint16) HRESULT { ret, _, _ := syscall.Syscall(setWindowTheme, 3, uintptr(hwnd), From 4a8aafceea3bc19e96bddd9fa97cfbc423518475 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 11 Aug 2015 14:27:45 +0200 Subject: [PATCH 007/138] Add some clipboard stuff --- user32.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/user32.go b/user32.go index f637dbcc..308cd067 100644 --- a/user32.go +++ b/user32.go @@ -868,6 +868,7 @@ const ( WM_MOUSELAST = 525 WM_MOUSEHOVER = 0X2A1 WM_MOUSELEAVE = 0X2A3 + WM_CLIPBOARDUPDATE = 0x031D ) // mouse button constants @@ -1483,6 +1484,7 @@ var ( libuser32 uintptr // Functions + addClipboardFormatListener uintptr adjustWindowRect uintptr beginDeferWindowPos uintptr beginPaint uintptr @@ -1599,6 +1601,7 @@ func init() { libuser32 = MustLoadLibrary("user32.dll") // Functions + addClipboardFormatListener = MustGetProcAddress(libuser32, "AddClipboardFormatListener") adjustWindowRect = MustGetProcAddress(libuser32, "AdjustWindowRect") beginDeferWindowPos = MustGetProcAddress(libuser32, "BeginDeferWindowPos") beginPaint = MustGetProcAddress(libuser32, "BeginPaint") @@ -1718,6 +1721,15 @@ func init() { windowFromPoint = MustGetProcAddress(libuser32, "WindowFromPoint") } +func AddClipboardFormatListener(hwnd HWND) bool { + ret, _, _ := syscall.Syscall(addClipboardFormatListener, 1, + uintptr(hwnd), + 0, + 0) + + return ret != 0 +} + func AdjustWindowRect(lpRect *RECT, dwStyle uint32, bMenu bool) bool { ret, _, _ := syscall.Syscall(adjustWindowRect, 3, uintptr(unsafe.Pointer(lpRect)), From a5bc251392bfb6e2f3ee1689aebaa2353d05526a Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 12 Aug 2015 18:06:57 +0200 Subject: [PATCH 008/138] Add a tree view struct + some constant changes --- comctl32.go | 34 +++++++++++++++++----------------- listview.go | 2 +- treeview.go | 6 ++++++ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/comctl32.go b/comctl32.go index 10615479..62e06780 100644 --- a/comctl32.go +++ b/comctl32.go @@ -81,23 +81,23 @@ const ( // WM_NOTITY messages const ( NM_FIRST = 0 - NM_OUTOFMEMORY = NM_FIRST - 1 - NM_CLICK = NM_FIRST - 2 - NM_DBLCLK = NM_FIRST - 3 - NM_RETURN = NM_FIRST - 4 - NM_RCLICK = NM_FIRST - 5 - NM_RDBLCLK = NM_FIRST - 6 - NM_SETFOCUS = NM_FIRST - 7 - NM_KILLFOCUS = NM_FIRST - 8 - NM_CUSTOMDRAW = NM_FIRST - 12 - NM_HOVER = NM_FIRST - 13 - NM_NCHITTEST = NM_FIRST - 14 - NM_KEYDOWN = NM_FIRST - 15 - NM_RELEASEDCAPTURE = NM_FIRST - 16 - NM_SETCURSOR = NM_FIRST - 17 - NM_CHAR = NM_FIRST - 18 - NM_TOOLTIPSCREATED = NM_FIRST - 19 - NM_LAST = NM_FIRST - 99 + NM_OUTOFMEMORY = ^uint32(0) // NM_FIRST - 1 + NM_CLICK = ^uint32(1) // NM_FIRST - 2 + NM_DBLCLK = ^uint32(2) // NM_FIRST - 3 + NM_RETURN = ^uint32(3) // NM_FIRST - 4 + NM_RCLICK = ^uint32(4) // NM_FIRST - 5 + NM_RDBLCLK = ^uint32(5) // NM_FIRST - 6 + NM_SETFOCUS = ^uint32(6) // NM_FIRST - 7 + NM_KILLFOCUS = ^uint32(7) // NM_FIRST - 8 + NM_CUSTOMDRAW = ^uint32(11) // NM_FIRST - 12 + NM_HOVER = ^uint32(12) // NM_FIRST - 13 + NM_NCHITTEST = ^uint32(13) // NM_FIRST - 14 + NM_KEYDOWN = ^uint32(14) // NM_FIRST - 15 + NM_RELEASEDCAPTURE = ^uint32(15) // NM_FIRST - 16 + NM_SETCURSOR = ^uint32(16) // NM_FIRST - 17 + NM_CHAR = ^uint32(17) // NM_FIRST - 18 + NM_TOOLTIPSCREATED = ^uint32(18) // NM_FIRST - 19 + NM_LAST = ^uint32(98) // NM_FIRST - 99 ) // ProgressBar messages diff --git a/listview.go b/listview.go index b48df5fc..9ab8de6a 100644 --- a/listview.go +++ b/listview.go @@ -133,7 +133,7 @@ const ( // ListView notifications const ( - LVN_FIRST = -100 + LVN_FIRST = ^uint32(99) // -100 LVN_ITEMCHANGING = LVN_FIRST - 0 LVN_ITEMCHANGED = LVN_FIRST - 1 diff --git a/treeview.go b/treeview.go index 16721c5f..4fce1e02 100644 --- a/treeview.go +++ b/treeview.go @@ -232,6 +232,12 @@ type NMTVDISPINFO struct { Item TVITEM } +type NMTVKEYDOWN struct { + Hdr NMHDR + WVKey uint16 + Flags uint32 +} + type TVHITTESTINFO struct { Pt POINT Flags uint32 From 3d5ba1e082891b0051b332cdae475fa018111d16 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 27 Aug 2015 15:37:11 +0200 Subject: [PATCH 009/138] Add GetThreadUILanguage --- kernel32.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel32.go b/kernel32.go index 3aa11559..42c120d6 100644 --- a/kernel32.go +++ b/kernel32.go @@ -65,6 +65,7 @@ var ( getModuleHandle uintptr getNumberFormat uintptr getThreadLocale uintptr + getThreadUILanguage uintptr getVersion uintptr globalAlloc uintptr globalFree uintptr @@ -84,6 +85,7 @@ type ( HINSTANCE HANDLE LCID uint32 LCTYPE uint32 + LANGID uint16 ) type FILETIME struct { @@ -127,6 +129,7 @@ func init() { getNumberFormat = MustGetProcAddress(libkernel32, "GetNumberFormatW") getProfileString = MustGetProcAddress(libkernel32, "GetProfileStringW") getThreadLocale = MustGetProcAddress(libkernel32, "GetThreadLocale") + getThreadUILanguage = MustGetProcAddress(libkernel32, "GetThreadUILanguage") getVersion = MustGetProcAddress(libkernel32, "GetVersion") globalAlloc = MustGetProcAddress(libkernel32, "GlobalAlloc") globalFree = MustGetProcAddress(libkernel32, "GlobalFree") @@ -246,6 +249,15 @@ func GetThreadLocale() LCID { return LCID(ret) } +func GetThreadUILanguage() LANGID { + ret, _, _ := syscall.Syscall(getThreadUILanguage, 0, + 0, + 0, + 0) + + return LANGID(ret) +} + func GetVersion() int64 { ret, _, _ := syscall.Syscall(getVersion, 0, 0, From 2b1cddcaaa3652a98c8a967c7c66d2f73e79c85c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 11 Sep 2015 12:16:10 +0200 Subject: [PATCH 010/138] XP doesn't have the GetThreadUILanguage function --- kernel32.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel32.go b/kernel32.go index 42c120d6..eb9e390e 100644 --- a/kernel32.go +++ b/kernel32.go @@ -129,7 +129,7 @@ func init() { getNumberFormat = MustGetProcAddress(libkernel32, "GetNumberFormatW") getProfileString = MustGetProcAddress(libkernel32, "GetProfileStringW") getThreadLocale = MustGetProcAddress(libkernel32, "GetThreadLocale") - getThreadUILanguage = MustGetProcAddress(libkernel32, "GetThreadUILanguage") + getThreadUILanguage, _ = syscall.GetProcAddress(syscall.Handle(libkernel32), "GetThreadUILanguage") getVersion = MustGetProcAddress(libkernel32, "GetVersion") globalAlloc = MustGetProcAddress(libkernel32, "GlobalAlloc") globalFree = MustGetProcAddress(libkernel32, "GlobalFree") @@ -250,6 +250,10 @@ func GetThreadLocale() LCID { } func GetThreadUILanguage() LANGID { + if getThreadUILanguage == 0 { + return 0 + } + ret, _, _ := syscall.Syscall(getThreadUILanguage, 0, 0, 0, From 6d12498cae49f4264182e3a6edfaed37232e100e Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 11 Sep 2015 12:18:16 +0200 Subject: [PATCH 011/138] XP doesn't have AddClipboardFormatListener either --- user32.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/user32.go b/user32.go index 308cd067..edd67482 100644 --- a/user32.go +++ b/user32.go @@ -1601,7 +1601,7 @@ func init() { libuser32 = MustLoadLibrary("user32.dll") // Functions - addClipboardFormatListener = MustGetProcAddress(libuser32, "AddClipboardFormatListener") + addClipboardFormatListener, _ = syscall.GetProcAddress(syscall.Handle(libuser32), "AddClipboardFormatListener") adjustWindowRect = MustGetProcAddress(libuser32, "AdjustWindowRect") beginDeferWindowPos = MustGetProcAddress(libuser32, "BeginDeferWindowPos") beginPaint = MustGetProcAddress(libuser32, "BeginPaint") @@ -1722,6 +1722,10 @@ func init() { } func AddClipboardFormatListener(hwnd HWND) bool { + if addClipboardFormatListener == 0 { + return false + } + ret, _, _ := syscall.Syscall(addClipboardFormatListener, 1, uintptr(hwnd), 0, From 56f61a4ffea1d07e2ba9c847d0638e42d1b70571 Mon Sep 17 00:00:00 2001 From: Joseph Watson Date: Tue, 15 Sep 2015 13:11:49 -0400 Subject: [PATCH 012/138] Add build tags to allow this library to be included in a cross platform program. This allows for several things: - Develop on something other then a windows box, and cross compile the program to target windows. - Develop a program that will run on the command line for any OS, but also have a gui when run on windows. - Use the walk library for the windows gui, and some other library for a gui on other platforms. --- advapi32.go | 2 ++ combobox.go | 2 ++ comctl32.go | 2 ++ comdlg32.go | 2 ++ datetimepicker.go | 2 ++ edit.go | 2 ++ gdi32.go | 2 ++ gdiplus.go | 2 ++ header.go | 2 ++ kernel32.go | 2 ++ listbox.go | 2 ++ listview.go | 2 ++ menu.go | 2 ++ nonwin.go | 7 +++++++ ole32.go | 2 ++ oleaut32.go | 2 ++ oleaut32_amd64.go | 2 ++ opengl32.go | 2 ++ pdh.go | 2 ++ shdocvw.go | 2 ++ shell32.go | 2 ++ shobj.go | 2 ++ shobj_amd64.go | 2 ++ statusbar.go | 2 ++ tab.go | 2 ++ toolbar.go | 2 ++ tooltip.go | 2 ++ treeview.go | 2 ++ updown.go | 2 ++ user32.go | 2 ++ uxtheme.go | 2 ++ win.go | 2 ++ winspool.go | 2 ++ 33 files changed, 71 insertions(+) create mode 100644 nonwin.go diff --git a/advapi32.go b/advapi32.go index 9853eb6a..31e4ffe8 100644 --- a/advapi32.go +++ b/advapi32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/combobox.go b/combobox.go index 8a3fdb0b..3fdc782c 100644 --- a/combobox.go +++ b/combobox.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win // ComboBox return values diff --git a/comctl32.go b/comctl32.go index 62e06780..75226055 100644 --- a/comctl32.go +++ b/comctl32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/comdlg32.go b/comdlg32.go index d5892ccd..56c55647 100644 --- a/comdlg32.go +++ b/comdlg32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/datetimepicker.go b/datetimepicker.go index 0699d251..07a65324 100644 --- a/datetimepicker.go +++ b/datetimepicker.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win const DTM_FIRST = 0x1000 diff --git a/edit.go b/edit.go index 45594959..38509cf7 100644 --- a/edit.go +++ b/edit.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win // Edit styles diff --git a/gdi32.go b/gdi32.go index 2d49a6f3..02ab6d11 100644 --- a/gdi32.go +++ b/gdi32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/gdiplus.go b/gdiplus.go index ed6774d8..17522622 100644 --- a/gdiplus.go +++ b/gdiplus.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/header.go b/header.go index d3674f98..6e15fb09 100644 --- a/header.go +++ b/header.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win const ( diff --git a/kernel32.go b/kernel32.go index eb9e390e..802eda04 100644 --- a/kernel32.go +++ b/kernel32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/listbox.go b/listbox.go index 99ef3ab3..abb872bb 100644 --- a/listbox.go +++ b/listbox.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win // ListBox style diff --git a/listview.go b/listview.go index 9ab8de6a..ef1db0ec 100644 --- a/listview.go +++ b/listview.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win const ( diff --git a/menu.go b/menu.go index 69fc3738..0773f29a 100644 --- a/menu.go +++ b/menu.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win // Constants for MENUITEMINFO.fMask diff --git a/nonwin.go b/nonwin.go new file mode 100644 index 00000000..e79e055c --- /dev/null +++ b/nonwin.go @@ -0,0 +1,7 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !windows + +package win diff --git a/ole32.go b/ole32.go index c8c69a52..d75dee74 100644 --- a/ole32.go +++ b/ole32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/oleaut32.go b/oleaut32.go index 36bd2c2d..b02e02eb 100644 --- a/oleaut32.go +++ b/oleaut32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/oleaut32_amd64.go b/oleaut32_amd64.go index 0f7d92bf..1af64f06 100644 --- a/oleaut32_amd64.go +++ b/oleaut32_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win type VAR_BSTR struct { diff --git a/opengl32.go b/opengl32.go index 0dfc84fe..dbacc220 100644 --- a/opengl32.go +++ b/opengl32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/pdh.go b/pdh.go index 1d3d1845..ca594fe4 100644 --- a/pdh.go +++ b/pdh.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/shdocvw.go b/shdocvw.go index e8004ba1..3f180943 100644 --- a/shdocvw.go +++ b/shdocvw.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/shell32.go b/shell32.go index 6598993f..87952dc1 100644 --- a/shell32.go +++ b/shell32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/shobj.go b/shobj.go index c9392a46..b3aeefae 100644 --- a/shobj.go +++ b/shobj.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/shobj_amd64.go b/shobj_amd64.go index f33d9c14..312fa21e 100644 --- a/shobj_amd64.go +++ b/shobj_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/statusbar.go b/statusbar.go index be694ca3..41b7067c 100644 --- a/statusbar.go +++ b/statusbar.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win // Styles diff --git a/tab.go b/tab.go index 400223eb..10dbd3de 100644 --- a/tab.go +++ b/tab.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win const TCM_FIRST = 0x1300 diff --git a/toolbar.go b/toolbar.go index 85656d6e..6d005090 100644 --- a/toolbar.go +++ b/toolbar.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win // ToolBar messages diff --git a/tooltip.go b/tooltip.go index 9a11533e..8e2aec71 100644 --- a/tooltip.go +++ b/tooltip.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/treeview.go b/treeview.go index 4fce1e02..b21e42fd 100644 --- a/treeview.go +++ b/treeview.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win // TreeView styles diff --git a/updown.go b/updown.go index 672dde08..f315c3f0 100644 --- a/updown.go +++ b/updown.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win const UDN_FIRST = ^uint32(720) diff --git a/user32.go b/user32.go index edd67482..0e9e5363 100644 --- a/user32.go +++ b/user32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/uxtheme.go b/uxtheme.go index 803dba79..f8ec1594 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/win.go b/win.go index 46703118..312cf962 100644 --- a/win.go +++ b/win.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( diff --git a/winspool.go b/winspool.go index 153b7cb7..c69214d4 100644 --- a/winspool.go +++ b/winspool.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( From a500fc386bd9ded08ac86f2876e4cbf2f33bc399 Mon Sep 17 00:00:00 2001 From: Joseph Watson Date: Thu, 17 Sep 2015 14:38:24 -0400 Subject: [PATCH 013/138] Added myself to AUTHORS, and sorted the list. --- AUTHORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index e2fa5825..dd767532 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,9 +13,10 @@ Alexander Neumann Anton Lahti Benny Siegert Bruno Bigras +Carlos Cobo Cary Cherng Hill +Joseph Watson Kevin Pors mycaosf wsf01 -Carlos Cobo From ef6f49128dd08e33b5041de9a499bb9e750820b3 Mon Sep 17 00:00:00 2001 From: Joseph Watson Date: Fri, 18 Sep 2015 22:49:24 -0400 Subject: [PATCH 014/138] Remove the nonwin.go file because it causes a problem with GoDoc. GoDoc will default to GOOS=linux, so when this file is present, the package becomes empty. Changing it to a windows only package fixes the issue. --- nonwin.go | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 nonwin.go diff --git a/nonwin.go b/nonwin.go deleted file mode 100644 index e79e055c..00000000 --- a/nonwin.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2010 The win Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !windows - -package win From 26b706608f259110d249117e4831d907cc972f60 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 12 Nov 2015 17:50:16 +0100 Subject: [PATCH 015/138] Add some progress bar stuff --- comctl32.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/comctl32.go b/comctl32.go index 62e06780..36a909f4 100644 --- a/comctl32.go +++ b/comctl32.go @@ -106,13 +106,19 @@ const ( PBM_DELTAPOS = WM_USER + 3 PBM_SETSTEP = WM_USER + 4 PBM_STEPIT = WM_USER + 5 + PBM_SETMARQUEE = WM_USER + 10 PBM_SETRANGE32 = 1030 PBM_GETRANGE = 1031 PBM_GETPOS = 1032 PBM_SETBARCOLOR = 1033 PBM_SETBKCOLOR = CCM_SETBKCOLOR - PBS_SMOOTH = 1 - PBS_VERTICAL = 4 +) + +// ProgressBar styles +const ( + PBS_SMOOTH = 0x01 + PBS_VERTICAL = 0x04 + PBS_MARQUEE = 0x08 ) // ImageList creation flags From 18bb0f565627b67a5af5eb0bfb261534f5773d4a Mon Sep 17 00:00:00 2001 From: Attila Tajti Date: Sat, 21 Nov 2015 18:59:49 +0100 Subject: [PATCH 016/138] add CreateCompatibleBitmap API necessary for double buffered painting --- gdi32.go | 107 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 48 deletions(-) diff --git a/gdi32.go b/gdi32.go index 2d49a6f3..36f1f26f 100644 --- a/gdi32.go +++ b/gdi32.go @@ -958,54 +958,55 @@ var ( libgdi32 uintptr // Functions - abortDoc uintptr - bitBlt uintptr - choosePixelFormat uintptr - closeEnhMetaFile uintptr - copyEnhMetaFile uintptr - createBitmap uintptr - createBrushIndirect uintptr - createCompatibleDC uintptr - createDC uintptr - createDIBSection uintptr - createFontIndirect uintptr - createEnhMetaFile uintptr - createIC uintptr - deleteDC uintptr - deleteEnhMetaFile uintptr - deleteObject uintptr - ellipse uintptr - endDoc uintptr - endPage uintptr - extCreatePen uintptr - getDeviceCaps uintptr - getEnhMetaFile uintptr - getEnhMetaFileHeader uintptr - getObject uintptr - getPixel uintptr - getStockObject uintptr - getTextExtentExPoint uintptr - getTextExtentPoint32 uintptr - getTextMetrics uintptr - lineTo uintptr - moveToEx uintptr - playEnhMetaFile uintptr - rectangle uintptr - resetDC uintptr - restoreDC uintptr - selectObject uintptr - setBkMode uintptr - setBrushOrgEx uintptr - setPixel uintptr - setPixelFormat uintptr - setStretchBltMode uintptr - setTextColor uintptr - saveDC uintptr - startDoc uintptr - startPage uintptr - stretchBlt uintptr - swapBuffers uintptr - textOut uintptr + abortDoc uintptr + bitBlt uintptr + choosePixelFormat uintptr + closeEnhMetaFile uintptr + copyEnhMetaFile uintptr + createBitmap uintptr + createCompatibleBitmap uintptr + createBrushIndirect uintptr + createCompatibleDC uintptr + createDC uintptr + createDIBSection uintptr + createFontIndirect uintptr + createEnhMetaFile uintptr + createIC uintptr + deleteDC uintptr + deleteEnhMetaFile uintptr + deleteObject uintptr + ellipse uintptr + endDoc uintptr + endPage uintptr + extCreatePen uintptr + getDeviceCaps uintptr + getEnhMetaFile uintptr + getEnhMetaFileHeader uintptr + getObject uintptr + getPixel uintptr + getStockObject uintptr + getTextExtentExPoint uintptr + getTextExtentPoint32 uintptr + getTextMetrics uintptr + lineTo uintptr + moveToEx uintptr + playEnhMetaFile uintptr + rectangle uintptr + resetDC uintptr + restoreDC uintptr + selectObject uintptr + setBkMode uintptr + setBrushOrgEx uintptr + setPixel uintptr + setPixelFormat uintptr + setStretchBltMode uintptr + setTextColor uintptr + saveDC uintptr + startDoc uintptr + startPage uintptr + stretchBlt uintptr + swapBuffers uintptr + textOut uintptr ) func init() { @@ -1019,6 +1020,7 @@ func init() { closeEnhMetaFile = MustGetProcAddress(libgdi32, "CloseEnhMetaFile") copyEnhMetaFile = MustGetProcAddress(libgdi32, "CopyEnhMetaFileW") createBitmap = MustGetProcAddress(libgdi32, "CreateBitmap") + createCompatibleBitmap = MustGetProcAddress(libgdi32, "CreateCompatibleBitmap") createBrushIndirect = MustGetProcAddress(libgdi32, "CreateBrushIndirect") createCompatibleDC = MustGetProcAddress(libgdi32, "CreateCompatibleDC") createDC = MustGetProcAddress(libgdi32, "CreateDCW") @@ -1127,6 +1129,15 @@ func CreateBitmap(nWidth, nHeight int32, cPlanes, cBitsPerPel uint32, lpvBits un return HBITMAP(ret) } +func CreateCompatibleBitmap(hdc HDC, nWidth, nHeight int32) HBITMAP { + ret, _, _ := syscall.Syscall(createCompatibleBitmap, 3, + uintptr(hdc), + uintptr(nWidth), + uintptr(nHeight)) + + return HBITMAP(ret) +} + func CreateBrushIndirect(lplb *LOGBRUSH) HBRUSH { ret, _, _ := syscall.Syscall(createBrushIndirect, 1, uintptr(unsafe.Pointer(lplb)), From e19dea1ee09ab96ecef2b8e509794c81eba42e8a Mon Sep 17 00:00:00 2001 From: Attila Tajti Date: Wed, 25 Nov 2015 10:36:43 +0100 Subject: [PATCH 017/138] add (Set|Get)ViewportOrgEx --- gdi32.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gdi32.go b/gdi32.go index 36f1f26f..1d388ce0 100644 --- a/gdi32.go +++ b/gdi32.go @@ -988,6 +988,7 @@ var ( getTextExtentExPoint uintptr getTextExtentPoint32 uintptr getTextMetrics uintptr + getViewportOrgEx uintptr lineTo uintptr moveToEx uintptr playEnhMetaFile uintptr @@ -1001,6 +1002,7 @@ var ( setPixelFormat uintptr setStretchBltMode uintptr setTextColor uintptr + setViewportOrgEx uintptr saveDC uintptr startDoc uintptr startPage uintptr @@ -1044,6 +1046,7 @@ func init() { getTextExtentExPoint = MustGetProcAddress(libgdi32, "GetTextExtentExPointW") getTextExtentPoint32 = MustGetProcAddress(libgdi32, "GetTextExtentPoint32W") getTextMetrics = MustGetProcAddress(libgdi32, "GetTextMetricsW") + getViewportOrgEx = MustGetProcAddress(libgdi32, "GetViewportOrgEx") lineTo = MustGetProcAddress(libgdi32, "LineTo") moveToEx = MustGetProcAddress(libgdi32, "MoveToEx") playEnhMetaFile = MustGetProcAddress(libgdi32, "PlayEnhMetaFile") @@ -1058,6 +1061,7 @@ func init() { setPixelFormat = MustGetProcAddress(libgdi32, "SetPixelFormat") setStretchBltMode = MustGetProcAddress(libgdi32, "SetStretchBltMode") setTextColor = MustGetProcAddress(libgdi32, "SetTextColor") + setViewportOrgEx = MustGetProcAddress(libgdi32, "SetViewportOrgEx") startDoc = MustGetProcAddress(libgdi32, "StartDocW") startPage = MustGetProcAddress(libgdi32, "StartPage") stretchBlt = MustGetProcAddress(libgdi32, "StretchBlt") @@ -1372,6 +1376,15 @@ func GetTextMetrics(hdc HDC, lptm *TEXTMETRIC) bool { return ret != 0 } +func GetViewportOrgEx(hdc HDC, lpPoint *POINT) bool { + ret, _, _ := syscall.Syscall(getViewportOrgEx, 2, + uintptr(hdc), + uintptr(unsafe.Pointer(lpPoint)), + 0) + + return ret != 0 +} + func LineTo(hdc HDC, nXEnd, nYEnd int32) bool { ret, _, _ := syscall.Syscall(lineTo, 3, uintptr(hdc), @@ -1508,6 +1521,18 @@ func SetTextColor(hdc HDC, crColor COLORREF) COLORREF { return COLORREF(ret) } +func SetViewportOrgEx(hdc HDC, x, y int32, lpPoint *POINT) COLORREF { + ret, _, _ := syscall.Syscall6(setViewportOrgEx, 4, + uintptr(hdc), + uintptr(x), + uintptr(y), + uintptr(unsafe.Pointer(lpPoint)), + 0, + 0) + + return COLORREF(ret) +} + func StartDoc(hdc HDC, lpdi *DOCINFO) int32 { ret, _, _ := syscall.Syscall(startDoc, 2, uintptr(hdc), From b55c7ce08d4088c2fea1ddfbbd167e25116b5e83 Mon Sep 17 00:00:00 2001 From: "U-ultrahorst\\elmar" Date: Fri, 27 Nov 2015 23:59:34 +0100 Subject: [PATCH 018/138] add dropfile api --- AUTHORS | 1 + shell32.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/AUTHORS b/AUTHORS index dd767532..4b2e7e94 100644 --- a/AUTHORS +++ b/AUTHORS @@ -20,3 +20,4 @@ Joseph Watson Kevin Pors mycaosf wsf01 +ktye diff --git a/shell32.go b/shell32.go index 87952dc1..b39e03f9 100644 --- a/shell32.go +++ b/shell32.go @@ -12,6 +12,7 @@ import ( ) type CSIDL uint32 +type HDROP HANDLE const ( CSIDL_DESKTOP = 0x00 @@ -182,6 +183,9 @@ var ( shGetPathFromIDList uintptr shGetSpecialFolderPath uintptr shell_NotifyIcon uintptr + dragAcceptFiles uintptr + dragQueryFile uintptr + dragFinish uintptr ) func init() { @@ -194,6 +198,9 @@ func init() { shGetPathFromIDList = MustGetProcAddress(libshell32, "SHGetPathFromIDListW") shGetSpecialFolderPath = MustGetProcAddress(libshell32, "SHGetSpecialFolderPathW") shell_NotifyIcon = MustGetProcAddress(libshell32, "Shell_NotifyIconW") + dragAcceptFiles = MustGetProcAddress(libshell32, "DragAcceptFiles") + dragQueryFile = MustGetProcAddress(libshell32, "DragQueryFileW") + dragFinish = MustGetProcAddress(libshell32, "DragFinish") } func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr { @@ -246,3 +253,31 @@ func Shell_NotifyIcon(dwMessage uint32, lpdata *NOTIFYICONDATA) bool { return ret != 0 } + +func DragAcceptFiles(hWnd HWND, fAccept bool) bool { + ret, _, _ := syscall.Syscall(dragAcceptFiles, 2, + uintptr(hWnd), + uintptr(BoolToBOOL(fAccept)), + 0) + + return ret != 0 +} + +func DragQueryFile(hDrop HDROP, iFile uint, lpszFile *uint16, cch uint) uint { + ret, _, _ := syscall.Syscall6(dragQueryFile, 4, + uintptr(hDrop), + uintptr(iFile), + uintptr(unsafe.Pointer(lpszFile)), + uintptr(cch), + 0, + 0) + + return uint(ret) +} + +func DragFinish(hDrop HDROP) { + syscall.Syscall(dragAcceptFiles, 1, + uintptr(hDrop), + 0, + 0) +} From 964847549066ff15a61b15b857bcff2941b52c01 Mon Sep 17 00:00:00 2001 From: "U-ultrahorst\\elmar" Date: Sun, 6 Dec 2015 13:50:18 +0100 Subject: [PATCH 019/138] Add dropfiles api --- AUTHORS | 2 +- shell32.go | 68 +++++++++++++++++++++++++++--------------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4b2e7e94..0abe6ce8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,6 +18,6 @@ Cary Cherng Hill Joseph Watson Kevin Pors +ktye mycaosf wsf01 -ktye diff --git a/shell32.go b/shell32.go index b39e03f9..047bb988 100644 --- a/shell32.go +++ b/shell32.go @@ -178,14 +178,14 @@ var ( libshell32 uintptr // Functions + dragAcceptFiles uintptr + dragFinish uintptr + dragQueryFile uintptr shBrowseForFolder uintptr shGetFileInfo uintptr shGetPathFromIDList uintptr shGetSpecialFolderPath uintptr shell_NotifyIcon uintptr - dragAcceptFiles uintptr - dragQueryFile uintptr - dragFinish uintptr ) func init() { @@ -193,14 +193,42 @@ func init() { libshell32 = MustLoadLibrary("shell32.dll") // Functions + dragAcceptFiles = MustGetProcAddress(libshell32, "DragAcceptFiles") + dragFinish = MustGetProcAddress(libshell32, "DragFinish") + dragQueryFile = MustGetProcAddress(libshell32, "DragQueryFileW") shBrowseForFolder = MustGetProcAddress(libshell32, "SHBrowseForFolderW") shGetFileInfo = MustGetProcAddress(libshell32, "SHGetFileInfoW") shGetPathFromIDList = MustGetProcAddress(libshell32, "SHGetPathFromIDListW") shGetSpecialFolderPath = MustGetProcAddress(libshell32, "SHGetSpecialFolderPathW") shell_NotifyIcon = MustGetProcAddress(libshell32, "Shell_NotifyIconW") - dragAcceptFiles = MustGetProcAddress(libshell32, "DragAcceptFiles") - dragQueryFile = MustGetProcAddress(libshell32, "DragQueryFileW") - dragFinish = MustGetProcAddress(libshell32, "DragFinish") +} + +func DragAcceptFiles(hWnd HWND, fAccept bool) bool { + ret, _, _ := syscall.Syscall(dragAcceptFiles, 2, + uintptr(hWnd), + uintptr(BoolToBOOL(fAccept)), + 0) + + return ret != 0 +} + +func DragQueryFile(hDrop HDROP, iFile uint, lpszFile *uint16, cch uint) uint { + ret, _, _ := syscall.Syscall6(dragQueryFile, 4, + uintptr(hDrop), + uintptr(iFile), + uintptr(unsafe.Pointer(lpszFile)), + uintptr(cch), + 0, + 0) + + return uint(ret) +} + +func DragFinish(hDrop HDROP) { + syscall.Syscall(dragAcceptFiles, 1, + uintptr(hDrop), + 0, + 0) } func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr { @@ -253,31 +281,3 @@ func Shell_NotifyIcon(dwMessage uint32, lpdata *NOTIFYICONDATA) bool { return ret != 0 } - -func DragAcceptFiles(hWnd HWND, fAccept bool) bool { - ret, _, _ := syscall.Syscall(dragAcceptFiles, 2, - uintptr(hWnd), - uintptr(BoolToBOOL(fAccept)), - 0) - - return ret != 0 -} - -func DragQueryFile(hDrop HDROP, iFile uint, lpszFile *uint16, cch uint) uint { - ret, _, _ := syscall.Syscall6(dragQueryFile, 4, - uintptr(hDrop), - uintptr(iFile), - uintptr(unsafe.Pointer(lpszFile)), - uintptr(cch), - 0, - 0) - - return uint(ret) -} - -func DragFinish(hDrop HDROP) { - syscall.Syscall(dragAcceptFiles, 1, - uintptr(hDrop), - 0, - 0) -} From 32cb77c6e5b1f77ff7768c55ff2710e86626dc3b Mon Sep 17 00:00:00 2001 From: "U-ultrahorst\\elmar" Date: Thu, 7 Jan 2016 04:51:21 +0100 Subject: [PATCH 020/138] add support for trackbar --- comctl32.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/comctl32.go b/comctl32.go index e48d1c39..d63ae3ba 100644 --- a/comctl32.go +++ b/comctl32.go @@ -123,6 +123,22 @@ const ( PBS_MARQUEE = 0x08 ) +// TrackBar messages +const ( + TBM_GETPOS = WM_USER + TBM_GETRANGEMIN = WM_USER + 1 + TBM_GETRANGEMAX = WM_USER + 2 + TBM_SETPOS = WM_USER + 5 + TBM_SETRANGEMIN = WM_USER + 7 + TBM_SETRANGEMAX = WM_USER + 8 +) + +// TrackBar styles +const ( + TBS_VERT = 0x002 + TBS_TOOLTIPS = 0x100 +) + // ImageList creation flags const ( ILC_MASK = 0x00000001 From 29a088699b08bf9c3f6894a0e11e19ca5cca042b Mon Sep 17 00:00:00 2001 From: "U-ultrahorst\\elmar" Date: Fri, 8 Jan 2016 23:35:10 +0100 Subject: [PATCH 021/138] update slider control --- comctl32.go | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/comctl32.go b/comctl32.go index d63ae3ba..86924bda 100644 --- a/comctl32.go +++ b/comctl32.go @@ -1,4 +1,4 @@ -// Copyright 2010 The win Authors. All rights reserved. +// Copyright 2016 The win Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -82,24 +82,25 @@ const ( // WM_NOTITY messages const ( - NM_FIRST = 0 - NM_OUTOFMEMORY = ^uint32(0) // NM_FIRST - 1 - NM_CLICK = ^uint32(1) // NM_FIRST - 2 - NM_DBLCLK = ^uint32(2) // NM_FIRST - 3 - NM_RETURN = ^uint32(3) // NM_FIRST - 4 - NM_RCLICK = ^uint32(4) // NM_FIRST - 5 - NM_RDBLCLK = ^uint32(5) // NM_FIRST - 6 - NM_SETFOCUS = ^uint32(6) // NM_FIRST - 7 - NM_KILLFOCUS = ^uint32(7) // NM_FIRST - 8 - NM_CUSTOMDRAW = ^uint32(11) // NM_FIRST - 12 - NM_HOVER = ^uint32(12) // NM_FIRST - 13 - NM_NCHITTEST = ^uint32(13) // NM_FIRST - 14 - NM_KEYDOWN = ^uint32(14) // NM_FIRST - 15 - NM_RELEASEDCAPTURE = ^uint32(15) // NM_FIRST - 16 - NM_SETCURSOR = ^uint32(16) // NM_FIRST - 17 - NM_CHAR = ^uint32(17) // NM_FIRST - 18 - NM_TOOLTIPSCREATED = ^uint32(18) // NM_FIRST - 19 - NM_LAST = ^uint32(98) // NM_FIRST - 99 + NM_FIRST = 0 + NM_OUTOFMEMORY = ^uint32(0) // NM_FIRST - 1 + NM_CLICK = ^uint32(1) // NM_FIRST - 2 + NM_DBLCLK = ^uint32(2) // NM_FIRST - 3 + NM_RETURN = ^uint32(3) // NM_FIRST - 4 + NM_RCLICK = ^uint32(4) // NM_FIRST - 5 + NM_RDBLCLK = ^uint32(5) // NM_FIRST - 6 + NM_SETFOCUS = ^uint32(6) // NM_FIRST - 7 + NM_KILLFOCUS = ^uint32(7) // NM_FIRST - 8 + NM_CUSTOMDRAW = ^uint32(11) // NM_FIRST - 12 + NM_HOVER = ^uint32(12) // NM_FIRST - 13 + NM_NCHITTEST = ^uint32(13) // NM_FIRST - 14 + NM_KEYDOWN = ^uint32(14) // NM_FIRST - 15 + NM_RELEASEDCAPTURE = ^uint32(15) // NM_FIRST - 16 + NM_SETCURSOR = ^uint32(16) // NM_FIRST - 17 + NM_CHAR = ^uint32(17) // NM_FIRST - 18 + NM_TOOLTIPSCREATED = ^uint32(18) // NM_FIRST - 19 + NM_LAST = ^uint32(98) // NM_FIRST - 99 + TRBN_THUMBPOSCHANGING = 0xfffffa22 // TRBN_FIRST - 1 ) // ProgressBar messages @@ -123,7 +124,7 @@ const ( PBS_MARQUEE = 0x08 ) -// TrackBar messages +// TrackBar (Slider) messages const ( TBM_GETPOS = WM_USER TBM_GETRANGEMIN = WM_USER + 1 @@ -133,7 +134,7 @@ const ( TBM_SETRANGEMAX = WM_USER + 8 ) -// TrackBar styles +// TrackBar (Slider) styles const ( TBS_VERT = 0x002 TBS_TOOLTIPS = 0x100 From 9a7734ea4db26bc593d52f6a8a957afdad39c5c1 Mon Sep 17 00:00:00 2001 From: "U-ultrahorst\\elmar" Date: Tue, 12 Jan 2016 16:58:05 +0100 Subject: [PATCH 022/138] add slider constants --- toolbar.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/toolbar.go b/toolbar.go index 6d005090..88c5e8b2 100644 --- a/toolbar.go +++ b/toolbar.go @@ -8,6 +8,8 @@ package win // ToolBar messages const ( + TB_THUMBPOSITION = 4 + TB_ENDTRACK = 8 TB_ENABLEBUTTON = WM_USER + 1 TB_CHECKBUTTON = WM_USER + 2 TB_PRESSBUTTON = WM_USER + 3 From a7d55488c81c8beb6134f82bae7d75371713a2dc Mon Sep 17 00:00:00 2001 From: csd0117 Date: Thu, 3 Mar 2016 19:36:06 +0100 Subject: [PATCH 023/138] add polyline --- gdi32.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gdi32.go b/gdi32.go index 9589ff38..acbbd7ea 100644 --- a/gdi32.go +++ b/gdi32.go @@ -994,6 +994,7 @@ var ( lineTo uintptr moveToEx uintptr playEnhMetaFile uintptr + polyline uintptr rectangle uintptr resetDC uintptr restoreDC uintptr @@ -1052,6 +1053,7 @@ func init() { lineTo = MustGetProcAddress(libgdi32, "LineTo") moveToEx = MustGetProcAddress(libgdi32, "MoveToEx") playEnhMetaFile = MustGetProcAddress(libgdi32, "PlayEnhMetaFile") + polyline = MustGetProcAddress(libgdi32, "Polyline") rectangle = MustGetProcAddress(libgdi32, "Rectangle") resetDC = MustGetProcAddress(libgdi32, "ResetDCW") restoreDC = MustGetProcAddress(libgdi32, "RestoreDC") @@ -1417,6 +1419,15 @@ func PlayEnhMetaFile(hdc HDC, hemf HENHMETAFILE, lpRect *RECT) bool { return ret != 0 } +func Polyline(hdc HDC, lppt unsafe.Pointer, cPoints int32) bool { + ret, _, _ := syscall.Syscall(polyline, 3, + uintptr(hdc), + uintptr(lppt), + uintptr(cPoints)) + + return ret != 0 +} + func Rectangle_(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool { ret, _, _ := syscall.Syscall6(rectangle, 5, uintptr(hdc), From 0c21e985dbbf2ca4434233bdd847b2a2f55419fe Mon Sep 17 00:00:00 2001 From: csd0117 Date: Tue, 8 Mar 2016 16:17:12 +0100 Subject: [PATCH 024/138] add getDIBits --- gdi32.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gdi32.go b/gdi32.go index acbbd7ea..ebf2e21f 100644 --- a/gdi32.go +++ b/gdi32.go @@ -982,6 +982,7 @@ var ( endPage uintptr extCreatePen uintptr getDeviceCaps uintptr + getDIBits uintptr getEnhMetaFile uintptr getEnhMetaFileHeader uintptr getObject uintptr @@ -1041,6 +1042,7 @@ func init() { endPage = MustGetProcAddress(libgdi32, "EndPage") extCreatePen = MustGetProcAddress(libgdi32, "ExtCreatePen") getDeviceCaps = MustGetProcAddress(libgdi32, "GetDeviceCaps") + getDIBits = MustGetProcAddress(libgdi32, "GetDIBits") getEnhMetaFile = MustGetProcAddress(libgdi32, "GetEnhMetaFileW") getEnhMetaFileHeader = MustGetProcAddress(libgdi32, "GetEnhMetaFileHeader") getObject = MustGetProcAddress(libgdi32, "GetObjectW") @@ -1299,6 +1301,20 @@ func GetDeviceCaps(hdc HDC, nIndex int32) int32 { return int32(ret) } +func GetDIBits(hdc HDC, hbmp HBITMAP, uStartScan uint32, cScanLines uint32, lpvBits *byte, lpbi *BITMAPINFO, uUsage uint32) int32 { + ret, _, _ := syscall.Syscall9(getDIBits, 7, + uintptr(hdc), + uintptr(hbmp), + uintptr(uStartScan), + uintptr(cScanLines), + uintptr(unsafe.Pointer(lpvBits)), + uintptr(unsafe.Pointer(lpbi)), + uintptr(uUsage), + 0, + 0) + return int32(ret) +} + func GetEnhMetaFile(lpszMetaFile *uint16) HENHMETAFILE { ret, _, _ := syscall.Syscall(getEnhMetaFile, 1, uintptr(unsafe.Pointer(lpszMetaFile)), From e1da2853f0b60b3f7dd0ac811eb3122b1de28c5f Mon Sep 17 00:00:00 2001 From: csd0117 Date: Sun, 13 Mar 2016 13:36:26 +0100 Subject: [PATCH 025/138] add screenshot --- gdi32.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdi32.go b/gdi32.go index ebf2e21f..18a62ca0 100644 --- a/gdi32.go +++ b/gdi32.go @@ -226,6 +226,15 @@ const ( PS_JOIN_MASK = 0x0000F000 ) +// Print constants +const ( + PRF_NONCLIENT = 0x00000002 + PRF_CLIENT = 0x00000004 + PRF_ERASEBKGND = 0x00000008 + PRF_CHILDREN = 0x00000010 + PRF_OWNED = 0x00000020 +) + // Stock logical objects const ( WHITE_BRUSH = 0 From 4f035bc068707bf5b106c3b24eb00d0805e93d6f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 1 Aug 2016 10:35:57 +0200 Subject: [PATCH 026/138] Add some split button stuff --- user32.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/user32.go b/user32.go index 0e9e5363..ea91385c 100644 --- a/user32.go +++ b/user32.go @@ -127,6 +127,7 @@ const ( // Button notifications const ( + BCN_DROPDOWN = 0xfffffb20 BN_CLICKED = 0 BN_PAINT = 1 BN_HILITE = 2 @@ -187,6 +188,7 @@ const ( BS_RADIOBUTTON = 4 BS_RIGHT = 512 BS_RIGHTBUTTON = 32 + BS_SPLITBUTTON = 0x0000000c BS_TEXT = 0 BS_TOP = 0X400 BS_USERBUTTON = 8 @@ -1220,6 +1222,11 @@ const ( DI_NORMAL = DI_IMAGE | DI_MASK ) +type NMBCDROPDOWN struct { + Hdr NMHDR + RcButton RECT +} + type MONITORINFO struct { CbSize uint32 RcMonitor RECT From 8855eceee83ca086d647feb3d359a1d2ab6c7ccf Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 1 Aug 2016 12:34:12 +0200 Subject: [PATCH 027/138] Add SHParseDisplayName --- shell32.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shell32.go b/shell32.go index 047bb988..373097ff 100644 --- a/shell32.go +++ b/shell32.go @@ -185,6 +185,7 @@ var ( shGetFileInfo uintptr shGetPathFromIDList uintptr shGetSpecialFolderPath uintptr + shParseDisplayName uintptr shell_NotifyIcon uintptr ) @@ -200,6 +201,7 @@ func init() { shGetFileInfo = MustGetProcAddress(libshell32, "SHGetFileInfoW") shGetPathFromIDList = MustGetProcAddress(libshell32, "SHGetPathFromIDListW") shGetSpecialFolderPath = MustGetProcAddress(libshell32, "SHGetSpecialFolderPathW") + shParseDisplayName = MustGetProcAddress(libshell32, "SHParseDisplayName") shell_NotifyIcon = MustGetProcAddress(libshell32, "Shell_NotifyIconW") } @@ -273,6 +275,18 @@ func SHGetSpecialFolderPath(hwndOwner HWND, lpszPath *uint16, csidl CSIDL, fCrea return ret != 0 } +func SHParseDisplayName(pszName *uint16, pbc uintptr, ppidl *uintptr, sfgaoIn uint32, psfgaoOut *uint32) HRESULT { + ret, _, _ := syscall.Syscall6(shParseDisplayName, 5, + uintptr(unsafe.Pointer(pszName)), + pbc, + uintptr(unsafe.Pointer(ppidl)), + 0, + uintptr(unsafe.Pointer(psfgaoOut)), + 0) + + return HRESULT(ret) +} + func Shell_NotifyIcon(dwMessage uint32, lpdata *NOTIFYICONDATA) bool { ret, _, _ := syscall.Syscall(shell_NotifyIcon, 2, uintptr(dwMessage), From e05a4bd739efdf92a0dd3fb2864134114b3eadfb Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 24 Jan 2017 11:15:21 +0100 Subject: [PATCH 028/138] Add a missing toolbar constant --- toolbar.go | 1 + 1 file changed, 1 insertion(+) diff --git a/toolbar.go b/toolbar.go index 88c5e8b2..f2a8f4c6 100644 --- a/toolbar.go +++ b/toolbar.go @@ -87,6 +87,7 @@ const ( TB_GETINSERTMARKCOLOR = WM_USER + 89 TB_MAPACCELERATOR = WM_USER + 90 TB_GETSTRING = WM_USER + 91 + TB_GETIDEALSIZE = WM_USER + 99 TB_SETCOLORSCHEME = CCM_SETCOLORSCHEME TB_GETCOLORSCHEME = CCM_GETCOLORSCHEME TB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT From 938414c1673500ba71c5a8ba5bcf39d62d08a228 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 7 Mar 2017 12:07:40 +0100 Subject: [PATCH 029/138] Add TB_THUMBTRACK --- toolbar.go | 1 + 1 file changed, 1 insertion(+) diff --git a/toolbar.go b/toolbar.go index f2a8f4c6..80f0b0a4 100644 --- a/toolbar.go +++ b/toolbar.go @@ -9,6 +9,7 @@ package win // ToolBar messages const ( TB_THUMBPOSITION = 4 + TB_THUMBTRACK = 5 TB_ENDTRACK = 8 TB_ENABLEBUTTON = WM_USER + 1 TB_CHECKBUTTON = WM_USER + 2 From b09ac907c7b2365960324301b42e730b78da0c28 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 7 Mar 2017 12:08:07 +0100 Subject: [PATCH 030/138] Add SetBkColor --- gdi32.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gdi32.go b/gdi32.go index 18a62ca0..a707ac24 100644 --- a/gdi32.go +++ b/gdi32.go @@ -1009,6 +1009,7 @@ var ( resetDC uintptr restoreDC uintptr selectObject uintptr + setBkColor uintptr setBkMode uintptr setBrushOrgEx uintptr setPixel uintptr @@ -1070,6 +1071,7 @@ func init() { restoreDC = MustGetProcAddress(libgdi32, "RestoreDC") saveDC = MustGetProcAddress(libgdi32, "SaveDC") selectObject = MustGetProcAddress(libgdi32, "SelectObject") + setBkColor = MustGetProcAddress(libgdi32, "SetBkColor") setBkMode = MustGetProcAddress(libgdi32, "SetBkMode") setBrushOrgEx = MustGetProcAddress(libgdi32, "SetBrushOrgEx") setPixel = MustGetProcAddress(libgdi32, "SetPixel") @@ -1499,6 +1501,15 @@ func SelectObject(hdc HDC, hgdiobj HGDIOBJ) HGDIOBJ { return HGDIOBJ(ret) } +func SetBkColor(hdc HDC, crColor COLORREF) COLORREF { + ret, _, _ := syscall.Syscall(setBkColor, 2, + uintptr(hdc), + uintptr(crColor), + 0) + + return COLORREF(ret) +} + func SetBkMode(hdc HDC, iBkMode int32) int32 { ret, _, _ := syscall.Syscall(setBkMode, 2, uintptr(hdc), From 47e81714b93faeee07c93434b8ef730a27c86343 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 7 Mar 2017 12:08:26 +0100 Subject: [PATCH 031/138] Add IsAppThemed --- uxtheme.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/uxtheme.go b/uxtheme.go index f8ec1594..136936db 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -64,6 +64,7 @@ var ( drawThemeBackground uintptr drawThemeText uintptr getThemeTextExtent uintptr + isAppThemed uintptr openThemeData uintptr setWindowTheme uintptr ) @@ -77,6 +78,7 @@ func init() { drawThemeBackground = MustGetProcAddress(libuxtheme, "DrawThemeBackground") drawThemeText = MustGetProcAddress(libuxtheme, "DrawThemeText") getThemeTextExtent = MustGetProcAddress(libuxtheme, "GetThemeTextExtent") + isAppThemed = MustGetProcAddress(libuxtheme, "IsAppThemed") openThemeData = MustGetProcAddress(libuxtheme, "OpenThemeData") setWindowTheme = MustGetProcAddress(libuxtheme, "SetWindowTheme") } @@ -132,6 +134,15 @@ func GetThemeTextExtent(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText return HRESULT(ret) } +func IsAppThemed() bool { + ret, _, _ := syscall.Syscall(isAppThemed, 0, + 0, + 0, + 0) + + return ret != 0 +} + func OpenThemeData(hwnd HWND, pszClassList *uint16) HTHEME { ret, _, _ := syscall.Syscall(openThemeData, 2, uintptr(hwnd), From b29438058f3dd89a353f2a27bb5c88410579de00 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 23 Mar 2017 16:46:20 +0100 Subject: [PATCH 032/138] Add CreatePatternBrush + GradientFill --- gdi32.go | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/gdi32.go b/gdi32.go index a707ac24..72ec15c9 100644 --- a/gdi32.go +++ b/gdi32.go @@ -724,6 +724,13 @@ const ( PFD_STEREO_DONTCARE = 0x80000000 ) +// GradientFill constants +const ( + GRADIENT_FILL_RECT_H = 0x00 + GRADIENT_FILL_RECT_V = 0x01 + GRADIENT_FILL_TRIANGLE = 0x02 +) + type ( COLORREF uint32 HBITMAP HGDIOBJ @@ -964,9 +971,30 @@ type ENHMETAHEADER struct { SzlMicrometers SIZE } +type TRIVERTEX struct { + X int32 + Y int32 + Red uint16 + Green uint16 + Blue uint16 + Alpha uint16 +} + +type GRADIENT_RECT struct { + UpperLeft uint32 + LowerRight uint32 +} + +type GRADIENT_TRIANGLE struct { + Vertex1 uint32 + Vertex2 uint32 + Vertex3 uint32 +} + var ( // Library - libgdi32 uintptr + libgdi32 uintptr + libmsimg32 uintptr // Functions abortDoc uintptr @@ -983,6 +1011,7 @@ var ( createFontIndirect uintptr createEnhMetaFile uintptr createIC uintptr + createPatternBrush uintptr deleteDC uintptr deleteEnhMetaFile uintptr deleteObject uintptr @@ -1001,6 +1030,7 @@ var ( getTextExtentPoint32 uintptr getTextMetrics uintptr getViewportOrgEx uintptr + gradientFill uintptr lineTo uintptr moveToEx uintptr playEnhMetaFile uintptr @@ -1028,6 +1058,7 @@ var ( func init() { // Library libgdi32 = MustLoadLibrary("gdi32.dll") + libmsimg32 = MustLoadLibrary("msimg32.dll") // Functions abortDoc = MustGetProcAddress(libgdi32, "AbortDoc") @@ -1044,6 +1075,7 @@ func init() { createEnhMetaFile = MustGetProcAddress(libgdi32, "CreateEnhMetaFileW") createFontIndirect = MustGetProcAddress(libgdi32, "CreateFontIndirectW") createIC = MustGetProcAddress(libgdi32, "CreateICW") + createPatternBrush = MustGetProcAddress(libgdi32, "CreatePatternBrush") deleteDC = MustGetProcAddress(libgdi32, "DeleteDC") deleteEnhMetaFile = MustGetProcAddress(libgdi32, "DeleteEnhMetaFile") deleteObject = MustGetProcAddress(libgdi32, "DeleteObject") @@ -1085,6 +1117,7 @@ func init() { swapBuffers = MustGetProcAddress(libgdi32, "SwapBuffers") textOut = MustGetProcAddress(libgdi32, "TextOutW") + gradientFill = MustGetProcAddress(libmsimg32, "GradientFill") } func AbortDoc(hdc HDC) int32 { @@ -1234,6 +1267,15 @@ func CreateIC(lpszDriver, lpszDevice, lpszOutput *uint16, lpdvmInit *DEVMODE) HD return HDC(ret) } +func CreatePatternBrush(hbmp HBITMAP) HBRUSH { + ret, _, _ := syscall.Syscall(createPatternBrush, 1, + uintptr(hbmp), + 0, + 0) + + return HBRUSH(ret) +} + func DeleteDC(hdc HDC) bool { ret, _, _ := syscall.Syscall(deleteDC, 1, uintptr(hdc), @@ -1416,6 +1458,18 @@ func GetViewportOrgEx(hdc HDC, lpPoint *POINT) bool { return ret != 0 } +func GradientFill(hdc HDC, pVertex *TRIVERTEX, nVertex uint32, pMesh unsafe.Pointer, nMesh, ulMode uint32) bool { + ret, _, _ := syscall.Syscall6(gradientFill, 6, + uintptr(hdc), + uintptr(unsafe.Pointer(pVertex)), + uintptr(nVertex), + uintptr(pMesh), + uintptr(nMesh), + uintptr(ulMode)) + + return ret != 0 +} + func LineTo(hdc HDC, nXEnd, nYEnd int32) bool { ret, _, _ := syscall.Syscall(lineTo, 3, uintptr(hdc), From 360332d6c78de5ca51f3870fdc4f0d8848e4f101 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 11 Apr 2017 14:11:22 +0200 Subject: [PATCH 033/138] Add GetThemePartSize --- uxtheme.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/uxtheme.go b/uxtheme.go index 136936db..5f4d55f9 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -11,6 +11,16 @@ import ( "unsafe" ) +// CheckBox parts +const ( + BP_CHECKBOX = 3 +) + +// CheckBox states +const ( + CBS_UNCHECKEDNORMAL = 1 +) + // LISTVIEW parts const ( LVP_LISTITEM = 1 @@ -55,6 +65,14 @@ const ( type HTHEME HANDLE +type THEMESIZE int + +const ( + TS_MIN THEMESIZE = iota + TS_TRUE + TS_DRAW +) + var ( // Library libuxtheme uintptr @@ -63,6 +81,7 @@ var ( closeThemeData uintptr drawThemeBackground uintptr drawThemeText uintptr + getThemePartSize uintptr getThemeTextExtent uintptr isAppThemed uintptr openThemeData uintptr @@ -77,6 +96,7 @@ func init() { closeThemeData = MustGetProcAddress(libuxtheme, "CloseThemeData") drawThemeBackground = MustGetProcAddress(libuxtheme, "DrawThemeBackground") drawThemeText = MustGetProcAddress(libuxtheme, "DrawThemeText") + getThemePartSize = MustGetProcAddress(libuxtheme, "GetThemePartSize") getThemeTextExtent = MustGetProcAddress(libuxtheme, "GetThemeTextExtent") isAppThemed = MustGetProcAddress(libuxtheme, "IsAppThemed") openThemeData = MustGetProcAddress(libuxtheme, "OpenThemeData") @@ -119,6 +139,21 @@ func DrawThemeText(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uin return HRESULT(ret) } +func GetThemePartSize(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, prc *RECT, eSize THEMESIZE, psz *SIZE) HRESULT { + ret, _, _ := syscall.Syscall9(getThemePartSize, 7, + uintptr(hTheme), + uintptr(hdc), + uintptr(iPartId), + uintptr(iStateId), + uintptr(unsafe.Pointer(prc)), + uintptr(eSize), + uintptr(unsafe.Pointer(psz)), + 0, + 0) + + return HRESULT(ret) +} + func GetThemeTextExtent(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uint16, iCharCount int32, dwTextFlags uint32, pBoundingRect, pExtentRect *RECT) HRESULT { ret, _, _ := syscall.Syscall9(getThemeTextExtent, 9, uintptr(hTheme), From 3f1a513141eeedd5d40d76c6f07a15ef67e0bc8c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 11 Apr 2017 14:30:17 +0200 Subject: [PATCH 034/138] Add GetActiveWindow and GetForegroundWindow --- user32.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/user32.go b/user32.go index ea91385c..9ee0b166 100644 --- a/user32.go +++ b/user32.go @@ -1523,6 +1523,7 @@ var ( endPaint uintptr enumChildWindows uintptr findWindow uintptr + getActiveWindow uintptr getAncestor uintptr getCaretPos uintptr getClientRect uintptr @@ -1530,6 +1531,7 @@ var ( getCursorPos uintptr getDC uintptr getFocus uintptr + getForegroundWindow uintptr getKeyState uintptr getMenuInfo uintptr getMessage uintptr @@ -1640,6 +1642,7 @@ func init() { endPaint = MustGetProcAddress(libuser32, "EndPaint") enumChildWindows = MustGetProcAddress(libuser32, "EnumChildWindows") findWindow = MustGetProcAddress(libuser32, "FindWindowW") + getActiveWindow = MustGetProcAddress(libuser32, "GetActiveWindow") getAncestor = MustGetProcAddress(libuser32, "GetAncestor") getCaretPos = MustGetProcAddress(libuser32, "GetCaretPos") getClientRect = MustGetProcAddress(libuser32, "GetClientRect") @@ -1647,6 +1650,7 @@ func init() { getCursorPos = MustGetProcAddress(libuser32, "GetCursorPos") getDC = MustGetProcAddress(libuser32, "GetDC") getFocus = MustGetProcAddress(libuser32, "GetFocus") + getForegroundWindow = MustGetProcAddress(libuser32, "GetForegroundWindow") getKeyState = MustGetProcAddress(libuser32, "GetKeyState") getMenuInfo = MustGetProcAddress(libuser32, "GetMenuInfo") getMessage = MustGetProcAddress(libuser32, "GetMessageW") @@ -2041,6 +2045,15 @@ func FindWindow(lpClassName, lpWindowName *uint16) HWND { return HWND(ret) } +func GetActiveWindow() HWND { + ret, _, _ := syscall.Syscall(getActiveWindow, 0, + 0, + 0, + 0) + + return HWND(ret) +} + func GetAncestor(hWnd HWND, gaFlags uint32) HWND { ret, _, _ := syscall.Syscall(getAncestor, 2, uintptr(hWnd), @@ -2104,6 +2117,15 @@ func GetFocus() HWND { return HWND(ret) } +func GetForegroundWindow() HWND { + ret, _, _ := syscall.Syscall(getForegroundWindow, 0, + 0, + 0, + 0) + + return HWND(ret) +} + func GetKeyState(nVirtKey int32) int16 { ret, _, _ := syscall.Syscall(getKeyState, 1, uintptr(nVirtKey), From 79b67e89f293c0f9fe8f3aac109cec98559ea12c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 11 Apr 2017 16:10:31 +0200 Subject: [PATCH 035/138] Add ExcludeClipRect and IntersectClipRect --- gdi32.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gdi32.go b/gdi32.go index 72ec15c9..f1da60b9 100644 --- a/gdi32.go +++ b/gdi32.go @@ -1018,6 +1018,7 @@ var ( ellipse uintptr endDoc uintptr endPage uintptr + excludeClipRect uintptr extCreatePen uintptr getDeviceCaps uintptr getDIBits uintptr @@ -1031,6 +1032,7 @@ var ( getTextMetrics uintptr getViewportOrgEx uintptr gradientFill uintptr + intersectClipRect uintptr lineTo uintptr moveToEx uintptr playEnhMetaFile uintptr @@ -1082,6 +1084,7 @@ func init() { ellipse = MustGetProcAddress(libgdi32, "Ellipse") endDoc = MustGetProcAddress(libgdi32, "EndDoc") endPage = MustGetProcAddress(libgdi32, "EndPage") + excludeClipRect = MustGetProcAddress(libgdi32, "ExcludeClipRect") extCreatePen = MustGetProcAddress(libgdi32, "ExtCreatePen") getDeviceCaps = MustGetProcAddress(libgdi32, "GetDeviceCaps") getDIBits = MustGetProcAddress(libgdi32, "GetDIBits") @@ -1094,6 +1097,7 @@ func init() { getTextExtentPoint32 = MustGetProcAddress(libgdi32, "GetTextExtentPoint32W") getTextMetrics = MustGetProcAddress(libgdi32, "GetTextMetricsW") getViewportOrgEx = MustGetProcAddress(libgdi32, "GetViewportOrgEx") + intersectClipRect = MustGetProcAddress(libgdi32, "IntersectClipRect") lineTo = MustGetProcAddress(libgdi32, "LineTo") moveToEx = MustGetProcAddress(libgdi32, "MoveToEx") playEnhMetaFile = MustGetProcAddress(libgdi32, "PlayEnhMetaFile") @@ -1333,6 +1337,18 @@ func EndPage(hdc HDC) int32 { return int32(ret) } +func ExcludeClipRect(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) int32 { + ret, _, _ := syscall.Syscall6(excludeClipRect, 5, + uintptr(hdc), + uintptr(nLeftRect), + uintptr(nTopRect), + uintptr(nRightRect), + uintptr(nBottomRect), + 0) + + return int32(ret) +} + func ExtCreatePen(dwPenStyle, dwWidth uint32, lplb *LOGBRUSH, dwStyleCount uint32, lpStyle *uint32) HPEN { ret, _, _ := syscall.Syscall6(extCreatePen, 5, uintptr(dwPenStyle), @@ -1470,6 +1486,18 @@ func GradientFill(hdc HDC, pVertex *TRIVERTEX, nVertex uint32, pMesh unsafe.Poin return ret != 0 } +func IntersectClipRect(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) int32 { + ret, _, _ := syscall.Syscall6(intersectClipRect, 5, + uintptr(hdc), + uintptr(nLeftRect), + uintptr(nTopRect), + uintptr(nRightRect), + uintptr(nBottomRect), + 0) + + return int32(ret) +} + func LineTo(hdc HDC, nXEnd, nYEnd int32) bool { ret, _, _ := syscall.Syscall(lineTo, 3, uintptr(hdc), From 248bf3fa46735e16cc4249e993721a13bb9da838 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 17 Apr 2017 13:06:10 +0200 Subject: [PATCH 036/138] Replace DrawThemeText with DrawThemeTextEx --- uxtheme.go | 77 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/uxtheme.go b/uxtheme.go index 5f4d55f9..fff30224 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -45,6 +45,20 @@ const ( LISS_HOTSELECTED = 6 ) +// TAB parts +const ( + TABP_TABITEM = 1 +) + +// TABP_TABITEM states +const ( + TIS_NORMAL = 1 + TIS_HOT = 2 + TIS_SELECTED = 3 + TIS_DISABLED = 4 + TIS_FOCUSED = 5 +) + // TREEVIEW parts const ( TVP_TREEITEM = 1 @@ -63,6 +77,37 @@ const ( TREIS_HOTSELECTED = 6 ) +// DTTOPTS flags +const ( + DTT_TEXTCOLOR = 1 << 0 + DTT_BORDERCOLOR = 1 << 1 + DTT_SHADOWCOLOR = 1 << 2 + DTT_SHADOWTYPE = 1 << 3 + DTT_SHADOWOFFSET = 1 << 4 + DTT_BORDERSIZE = 1 << 5 + DTT_FONTPROP = 1 << 6 + DTT_COLORPROP = 1 << 7 + DTT_STATEID = 1 << 8 + DTT_CALCRECT = 1 << 9 + DTT_APPLYOVERLAY = 1 << 10 + DTT_GLOWSIZE = 1 << 11 + DTT_CALLBACK = 1 << 12 + DTT_COMPOSITED = 1 << 13 + DTT_VALIDBITS = DTT_TEXTCOLOR | + DTT_BORDERCOLOR | + DTT_SHADOWCOLOR | + DTT_SHADOWTYPE | + DTT_SHADOWOFFSET | + DTT_BORDERSIZE | + DTT_FONTPROP | + DTT_COLORPROP | + DTT_STATEID | + DTT_CALCRECT | + DTT_APPLYOVERLAY | + DTT_GLOWSIZE | + DTT_COMPOSITED +) + type HTHEME HANDLE type THEMESIZE int @@ -73,6 +118,24 @@ const ( TS_DRAW ) +type DTTOPTS struct { + DwSize uint32 + DwFlags uint32 + CrText COLORREF + CrBorder COLORREF + CrShadow COLORREF + ITextShadowType int + PtShadowOffset POINT + IBorderSize int + IFontPropId int + IColorPropId int + IStateId int + FApplyOverlay BOOL + IGlowSize int + PfnDrawTextCallback uintptr + LParam uintptr +} + var ( // Library libuxtheme uintptr @@ -80,7 +143,7 @@ var ( // Functions closeThemeData uintptr drawThemeBackground uintptr - drawThemeText uintptr + drawThemeTextEx uintptr getThemePartSize uintptr getThemeTextExtent uintptr isAppThemed uintptr @@ -95,7 +158,7 @@ func init() { // Functions closeThemeData = MustGetProcAddress(libuxtheme, "CloseThemeData") drawThemeBackground = MustGetProcAddress(libuxtheme, "DrawThemeBackground") - drawThemeText = MustGetProcAddress(libuxtheme, "DrawThemeText") + drawThemeTextEx = MustGetProcAddress(libuxtheme, "DrawThemeTextEx") getThemePartSize = MustGetProcAddress(libuxtheme, "GetThemePartSize") getThemeTextExtent = MustGetProcAddress(libuxtheme, "GetThemeTextExtent") isAppThemed = MustGetProcAddress(libuxtheme, "IsAppThemed") @@ -124,17 +187,17 @@ func DrawThemeBackground(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pRect, return HRESULT(ret) } -func DrawThemeText(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uint16, iCharCount int32, dwTextFlags, dwTextFlags2 uint32, pRect *RECT) HRESULT { - ret, _, _ := syscall.Syscall9(drawThemeText, 9, +func DrawThemeTextEx(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uint16, iCharCount int32, dwFlags uint32, pRect *RECT, pOptions *DTTOPTS) HRESULT { + ret, _, _ := syscall.Syscall9(drawThemeTextEx, 9, uintptr(hTheme), uintptr(hdc), uintptr(iPartId), uintptr(iStateId), uintptr(unsafe.Pointer(pszText)), uintptr(iCharCount), - uintptr(dwTextFlags), - uintptr(dwTextFlags2), - uintptr(unsafe.Pointer(pRect))) + uintptr(dwFlags), + uintptr(unsafe.Pointer(pRect)), + uintptr(unsafe.Pointer(pOptions))) return HRESULT(ret) } From cd28d435f783e79477f1ebbd983dd8dd72315064 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 17 Apr 2017 13:06:59 +0200 Subject: [PATCH 037/138] Add some region functions + TransparentBlt --- gdi32.go | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/gdi32.go b/gdi32.go index f1da60b9..184ba871 100644 --- a/gdi32.go +++ b/gdi32.go @@ -731,6 +731,23 @@ const ( GRADIENT_FILL_TRIANGLE = 0x02 ) +// Region Combine Modes +const ( + RGN_AND = 1 + RGN_OR = 2 + RGN_XOR = 3 + RGN_DIFF = 4 + RGN_COPY = 5 +) + +// Region Types +const ( + REGIONERROR = 0 + NULLREGION = 1 + SIMPLEREGION = 2 + COMPLEXREGION = 3 +) + type ( COLORREF uint32 HBITMAP HGDIOBJ @@ -741,7 +758,7 @@ type ( HENHMETAFILE HANDLE HPALETTE HGDIOBJ HPEN HGDIOBJ - HREGION HGDIOBJ + HRGN HGDIOBJ ) type PIXELFORMATDESCRIPTOR struct { @@ -1001,6 +1018,7 @@ var ( bitBlt uintptr choosePixelFormat uintptr closeEnhMetaFile uintptr + combineRgn uintptr copyEnhMetaFile uintptr createBitmap uintptr createCompatibleBitmap uintptr @@ -1012,6 +1030,7 @@ var ( createEnhMetaFile uintptr createIC uintptr createPatternBrush uintptr + createRectRgn uintptr deleteDC uintptr deleteEnhMetaFile uintptr deleteObject uintptr @@ -1020,12 +1039,14 @@ var ( endPage uintptr excludeClipRect uintptr extCreatePen uintptr + fillRgn uintptr getDeviceCaps uintptr getDIBits uintptr getEnhMetaFile uintptr getEnhMetaFileHeader uintptr getObject uintptr getPixel uintptr + getRgnBox uintptr getStockObject uintptr getTextExtentExPoint uintptr getTextExtentPoint32 uintptr @@ -1055,6 +1076,7 @@ var ( stretchBlt uintptr swapBuffers uintptr textOut uintptr + transparentBlt uintptr ) func init() { @@ -1067,6 +1089,7 @@ func init() { bitBlt = MustGetProcAddress(libgdi32, "BitBlt") choosePixelFormat = MustGetProcAddress(libgdi32, "ChoosePixelFormat") closeEnhMetaFile = MustGetProcAddress(libgdi32, "CloseEnhMetaFile") + combineRgn = MustGetProcAddress(libgdi32, "CombineRgn") copyEnhMetaFile = MustGetProcAddress(libgdi32, "CopyEnhMetaFileW") createBitmap = MustGetProcAddress(libgdi32, "CreateBitmap") createCompatibleBitmap = MustGetProcAddress(libgdi32, "CreateCompatibleBitmap") @@ -1078,6 +1101,7 @@ func init() { createFontIndirect = MustGetProcAddress(libgdi32, "CreateFontIndirectW") createIC = MustGetProcAddress(libgdi32, "CreateICW") createPatternBrush = MustGetProcAddress(libgdi32, "CreatePatternBrush") + createRectRgn = MustGetProcAddress(libgdi32, "CreateRectRgn") deleteDC = MustGetProcAddress(libgdi32, "DeleteDC") deleteEnhMetaFile = MustGetProcAddress(libgdi32, "DeleteEnhMetaFile") deleteObject = MustGetProcAddress(libgdi32, "DeleteObject") @@ -1086,12 +1110,14 @@ func init() { endPage = MustGetProcAddress(libgdi32, "EndPage") excludeClipRect = MustGetProcAddress(libgdi32, "ExcludeClipRect") extCreatePen = MustGetProcAddress(libgdi32, "ExtCreatePen") + fillRgn = MustGetProcAddress(libgdi32, "FillRgn") getDeviceCaps = MustGetProcAddress(libgdi32, "GetDeviceCaps") getDIBits = MustGetProcAddress(libgdi32, "GetDIBits") getEnhMetaFile = MustGetProcAddress(libgdi32, "GetEnhMetaFileW") getEnhMetaFileHeader = MustGetProcAddress(libgdi32, "GetEnhMetaFileHeader") getObject = MustGetProcAddress(libgdi32, "GetObjectW") getPixel = MustGetProcAddress(libgdi32, "GetPixel") + getRgnBox = MustGetProcAddress(libgdi32, "GetRgnBox") getStockObject = MustGetProcAddress(libgdi32, "GetStockObject") getTextExtentExPoint = MustGetProcAddress(libgdi32, "GetTextExtentExPointW") getTextExtentPoint32 = MustGetProcAddress(libgdi32, "GetTextExtentPoint32W") @@ -1122,6 +1148,7 @@ func init() { textOut = MustGetProcAddress(libgdi32, "TextOutW") gradientFill = MustGetProcAddress(libmsimg32, "GradientFill") + transparentBlt = MustGetProcAddress(libmsimg32, "TransparentBlt") } func AbortDoc(hdc HDC) int32 { @@ -1166,6 +1193,18 @@ func CloseEnhMetaFile(hdc HDC) HENHMETAFILE { return HENHMETAFILE(ret) } +func CombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2 HRGN, fnCombineMode int32) int32 { + ret, _, _ := syscall.Syscall6(combineRgn, 4, + uintptr(hrgnDest), + uintptr(hrgnSrc1), + uintptr(hrgnSrc2), + uintptr(fnCombineMode), + 0, + 0) + + return int32(ret) +} + func CopyEnhMetaFile(hemfSrc HENHMETAFILE, lpszFile *uint16) HENHMETAFILE { ret, _, _ := syscall.Syscall(copyEnhMetaFile, 2, uintptr(hemfSrc), @@ -1280,6 +1319,18 @@ func CreatePatternBrush(hbmp HBITMAP) HBRUSH { return HBRUSH(ret) } +func CreateRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect int32) HRGN { + ret, _, _ := syscall.Syscall6(createRectRgn, 4, + uintptr(nLeftRect), + uintptr(nTopRect), + uintptr(nRightRect), + uintptr(nBottomRect), + 0, + 0) + + return HRGN(ret) +} + func DeleteDC(hdc HDC) bool { ret, _, _ := syscall.Syscall(deleteDC, 1, uintptr(hdc), @@ -1361,6 +1412,15 @@ func ExtCreatePen(dwPenStyle, dwWidth uint32, lplb *LOGBRUSH, dwStyleCount uint3 return HPEN(ret) } +func FillRgn(hdc HDC, hrgn HRGN, hbr HBRUSH) bool { + ret, _, _ := syscall.Syscall(fillRgn, 3, + uintptr(hdc), + uintptr(hrgn), + uintptr(hbr)) + + return ret != 0 +} + func GetDeviceCaps(hdc HDC, nIndex int32) int32 { ret, _, _ := syscall.Syscall(getDeviceCaps, 2, uintptr(hdc), @@ -1420,6 +1480,15 @@ func GetPixel(hdc HDC, nXPos, nYPos int32) COLORREF { return COLORREF(ret) } +func GetRgnBox(hrgn HRGN, lprc *RECT) int32 { + ret, _, _ := syscall.Syscall(getRgnBox, 2, + uintptr(hrgn), + uintptr(unsafe.Pointer(lprc)), + 0) + + return int32(ret) +} + func GetStockObject(fnObject int32) HGDIOBJ { ret, _, _ := syscall.Syscall(getStockObject, 1, uintptr(fnObject), @@ -1719,3 +1788,21 @@ func TextOut(hdc HDC, nXStart, nYStart int32, lpString *uint16, cchString int32) 0) return ret != 0 } + +func TransparentBlt(hdcDest HDC, xoriginDest, yoriginDest, wDest, hDest int32, hdcSrc HDC, xoriginSrc, yoriginSrc, wSrc, hSrc int32, crTransparent uint32) bool { + ret, _, _ := syscall.Syscall12(transparentBlt, 11, + uintptr(hdcDest), + uintptr(xoriginDest), + uintptr(yoriginDest), + uintptr(wDest), + uintptr(hDest), + uintptr(hdcSrc), + uintptr(xoriginSrc), + uintptr(yoriginSrc), + uintptr(wSrc), + uintptr(hSrc), + uintptr(crTransparent), + 0) + + return ret != 0 +} From 1ea027c10d94f177fbf6f0a232a72d5f6faebde4 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 11 Jul 2017 12:11:54 +0200 Subject: [PATCH 038/138] Add missing // +build windows, fixes #28 --- oleaut32_386.go | 2 ++ shobj_386.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/oleaut32_386.go b/oleaut32_386.go index b057bd62..6d453317 100644 --- a/oleaut32_386.go +++ b/oleaut32_386.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win type VAR_BSTR struct { diff --git a/shobj_386.go b/shobj_386.go index 6c5e9c35..5e028a36 100644 --- a/shobj_386.go +++ b/shobj_386.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build windows + package win import ( From bf37f791d5c899c44ac72505b8a0c3536c6a3518 Mon Sep 17 00:00:00 2001 From: David Porter Date: Tue, 1 Aug 2017 19:44:33 +0000 Subject: [PATCH 039/138] Add GetPhysicallyInstalledSystemMemory system call. --- kernel32.go | 53 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/kernel32.go b/kernel32.go index 802eda04..b16d6ff8 100644 --- a/kernel32.go +++ b/kernel32.go @@ -57,27 +57,28 @@ var ( libkernel32 uintptr // Functions - closeHandle uintptr - fileTimeToSystemTime uintptr - getConsoleTitle uintptr - getConsoleWindow uintptr - getLastError uintptr - getLocaleInfo uintptr - getLogicalDriveStrings uintptr - getModuleHandle uintptr - getNumberFormat uintptr - getThreadLocale uintptr - getThreadUILanguage uintptr - getVersion uintptr - globalAlloc uintptr - globalFree uintptr - globalLock uintptr - globalUnlock uintptr - moveMemory uintptr - mulDiv uintptr - setLastError uintptr - systemTimeToFileTime uintptr - getProfileString uintptr + closeHandle uintptr + fileTimeToSystemTime uintptr + getConsoleTitle uintptr + getConsoleWindow uintptr + getLastError uintptr + getLocaleInfo uintptr + getLogicalDriveStrings uintptr + getModuleHandle uintptr + getNumberFormat uintptr + getThreadLocale uintptr + getThreadUILanguage uintptr + getVersion uintptr + globalAlloc uintptr + globalFree uintptr + globalLock uintptr + globalUnlock uintptr + moveMemory uintptr + mulDiv uintptr + setLastError uintptr + systemTimeToFileTime uintptr + getProfileString uintptr + getPhysicallyInstalledSystemMemory uintptr ) type ( @@ -141,6 +142,7 @@ func init() { mulDiv = MustGetProcAddress(libkernel32, "MulDiv") setLastError = MustGetProcAddress(libkernel32, "SetLastError") systemTimeToFileTime = MustGetProcAddress(libkernel32, "SystemTimeToFileTime") + getPhysicallyInstalledSystemMemory = MustGetProcAddress(libkernel32, "GetPhysicallyInstalledSystemMemory") } @@ -339,3 +341,12 @@ func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { return ret != 0 } + +func GetPhysicallyInstalledSystemMemory(totalMemoryInKilobytes *uint64) bool { + ret, _, _ := syscall.Syscall(getPhysicallyInstalledSystemMemory, 1, + uintptr(unsafe.Pointer(totalMemoryInKilobytes)), + 0, + 0) + + return ret != 0 +} From aa5a1207ac5e8772fd6164f4f99e9cd7040a4b67 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 3 Aug 2017 10:52:42 +0200 Subject: [PATCH 040/138] Add WM_NCHITTEST constants --- user32.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/user32.go b/user32.go index 9ee0b166..5a857f3f 100644 --- a/user32.go +++ b/user32.go @@ -1222,6 +1222,36 @@ const ( DI_NORMAL = DI_IMAGE | DI_MASK ) +// WM_NCHITTEST constants +const ( + HTBORDER = 18 + HTBOTTOM = 15 + HTBOTTOMLEFT = 16 + HTBOTTOMRIGHT = 17 + HTCAPTION = 2 + HTCLIENT = 1 + HTCLOSE = 20 + HTERROR = -2 + HTGROWBOX = 4 + HTHELP = 21 + HTHSCROLL = 6 + HTLEFT = 10 + HTMENU = 5 + HTMAXBUTTON = 9 + HTMINBUTTON = 8 + HTNOWHERE = 0 + HTREDUCE = 8 + HTRIGHT = 11 + HTSIZE = 4 + HTSYSMENU = 3 + HTTOP = 12 + HTTOPLEFT = 13 + HTTOPRIGHT = 14 + HTTRANSPARENT = -1 + HTVSCROLL = 7 + HTZOOM = 9 +) + type NMBCDROPDOWN struct { Hdr NMHDR RcButton RECT From 9ea9015966732dac11a8be6f0616f241070cf467 Mon Sep 17 00:00:00 2001 From: David Porter Date: Thu, 3 Aug 2017 18:41:00 +0000 Subject: [PATCH 041/138] Add myself to authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 0abe6ce8..fd1738bb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -15,6 +15,7 @@ Benny Siegert Bruno Bigras Carlos Cobo Cary Cherng +David Porter Hill Joseph Watson Kevin Pors From 812a38a8702ffc9be958e1b03c3c81a74081c022 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 8 Aug 2017 20:34:55 +0200 Subject: [PATCH 042/138] Add SysLink stuff --- comctl32.go | 2 +- syslink.go | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 syslink.go diff --git a/comctl32.go b/comctl32.go index 86924bda..31564e0b 100644 --- a/comctl32.go +++ b/comctl32.go @@ -245,7 +245,7 @@ func init() { // Initialize the common controls we support var initCtrls INITCOMMONCONTROLSEX initCtrls.DwSize = uint32(unsafe.Sizeof(initCtrls)) - initCtrls.DwICC = ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES + initCtrls.DwICC = ICC_LINK_CLASS | ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES InitCommonControlsEx(&initCtrls) } diff --git a/syslink.go b/syslink.go new file mode 100644 index 00000000..289e7bc8 --- /dev/null +++ b/syslink.go @@ -0,0 +1,65 @@ +// Copyright 2017 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +const ( + INVALID_LINK_INDEX = -1 + MAX_LINKID_TEXT = 48 + L_MAX_URL_LENGTH = 2048 + 32 + len("://") + WC_LINK = "SysLink" +) + +const ( + LWS_TRANSPARENT = 0x0001 + LWS_IGNORERETURN = 0x0002 + LWS_NOPREFIX = 0x0004 + LWS_USEVISUALSTYLE = 0x0008 + LWS_USECUSTOMTEXT = 0x0010 + LWS_RIGHT = 0x0020 +) + +const ( + LIF_ITEMINDEX = 0x00000001 + LIF_STATE = 0x00000002 + LIF_ITEMID = 0x00000004 + LIF_URL = 0x00000008 +) + +const ( + LIS_FOCUSED = 0x00000001 + LIS_ENABLED = 0x00000002 + LIS_VISITED = 0x00000004 + LIS_HOTTRACK = 0x00000008 + LIS_DEFAULTCOLORS = 0x00000010 +) + +const ( + LM_HITTEST = WM_USER + 0x300 + LM_GETIDEALHEIGHT = WM_USER + 0x301 + LM_SETITEM = WM_USER + 0x302 + LM_GETITEM = WM_USER + 0x303 + LM_GETIDEALSIZE = LM_GETIDEALHEIGHT +) + +type LITEM struct { + Mask uint32 + ILink int32 + State uint32 + StateMask uint32 + SzID [MAX_LINKID_TEXT]uint16 + SzUrl [L_MAX_URL_LENGTH]uint16 +} + +type LHITTESTINFO struct { + Pt POINT + Item LITEM +} + +type NMLINK struct { + Hdr NMHDR + Item LITEM +} From c27269d66b2a45a6fec047c71665f8619c171f19 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 23 Aug 2017 13:59:04 +0200 Subject: [PATCH 043/138] Don't panic if GetPhysicallyInstalledSystemMemory is not available (before Vista) --- kernel32.go | 3 +-- syslink.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel32.go b/kernel32.go index b16d6ff8..eff95239 100644 --- a/kernel32.go +++ b/kernel32.go @@ -142,8 +142,7 @@ func init() { mulDiv = MustGetProcAddress(libkernel32, "MulDiv") setLastError = MustGetProcAddress(libkernel32, "SetLastError") systemTimeToFileTime = MustGetProcAddress(libkernel32, "SystemTimeToFileTime") - getPhysicallyInstalledSystemMemory = MustGetProcAddress(libkernel32, "GetPhysicallyInstalledSystemMemory") - + getPhysicallyInstalledSystemMemory, _ = syscall.GetProcAddress(syscall.Handle(libkernel32), "GetPhysicallyInstalledSystemMemory") } func CloseHandle(hObject HANDLE) bool { diff --git a/syslink.go b/syslink.go index 289e7bc8..26455d0a 100644 --- a/syslink.go +++ b/syslink.go @@ -10,7 +10,7 @@ const ( INVALID_LINK_INDEX = -1 MAX_LINKID_TEXT = 48 L_MAX_URL_LENGTH = 2048 + 32 + len("://") - WC_LINK = "SysLink" + WC_LINK = "SysLink" ) const ( From c882970ad9e8f053d864b16ede99db7bba4db280 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 23 Aug 2017 14:29:15 +0200 Subject: [PATCH 044/138] Move some stuff around --- kernel32.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kernel32.go b/kernel32.go index eff95239..2baacf62 100644 --- a/kernel32.go +++ b/kernel32.go @@ -66,6 +66,8 @@ var ( getLogicalDriveStrings uintptr getModuleHandle uintptr getNumberFormat uintptr + getPhysicallyInstalledSystemMemory uintptr + getProfileString uintptr getThreadLocale uintptr getThreadUILanguage uintptr getVersion uintptr @@ -77,8 +79,6 @@ var ( mulDiv uintptr setLastError uintptr systemTimeToFileTime uintptr - getProfileString uintptr - getPhysicallyInstalledSystemMemory uintptr ) type ( @@ -130,6 +130,7 @@ func init() { getLogicalDriveStrings = MustGetProcAddress(libkernel32, "GetLogicalDriveStringsW") getModuleHandle = MustGetProcAddress(libkernel32, "GetModuleHandleW") getNumberFormat = MustGetProcAddress(libkernel32, "GetNumberFormatW") + getPhysicallyInstalledSystemMemory, _ = syscall.GetProcAddress(syscall.Handle(libkernel32), "GetPhysicallyInstalledSystemMemory") getProfileString = MustGetProcAddress(libkernel32, "GetProfileStringW") getThreadLocale = MustGetProcAddress(libkernel32, "GetThreadLocale") getThreadUILanguage, _ = syscall.GetProcAddress(syscall.Handle(libkernel32), "GetThreadUILanguage") @@ -142,7 +143,6 @@ func init() { mulDiv = MustGetProcAddress(libkernel32, "MulDiv") setLastError = MustGetProcAddress(libkernel32, "SetLastError") systemTimeToFileTime = MustGetProcAddress(libkernel32, "SystemTimeToFileTime") - getPhysicallyInstalledSystemMemory, _ = syscall.GetProcAddress(syscall.Handle(libkernel32), "GetPhysicallyInstalledSystemMemory") } func CloseHandle(hObject HANDLE) bool { @@ -232,6 +232,15 @@ func GetNumberFormat(Locale LCID, dwFlags uint32, lpValue *uint16, lpFormat *NUM return int32(ret) } +func GetPhysicallyInstalledSystemMemory(totalMemoryInKilobytes *uint64) bool { + ret, _, _ := syscall.Syscall(getPhysicallyInstalledSystemMemory, 1, + uintptr(unsafe.Pointer(totalMemoryInKilobytes)), + 0, + 0) + + return ret != 0 +} + func GetProfileString(lpAppName, lpKeyName, lpDefault *uint16, lpReturnedString uintptr, nSize uint32) bool { ret, _, _ := syscall.Syscall6(getProfileString, 5, uintptr(unsafe.Pointer(lpAppName)), @@ -340,12 +349,3 @@ func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { return ret != 0 } - -func GetPhysicallyInstalledSystemMemory(totalMemoryInKilobytes *uint64) bool { - ret, _, _ := syscall.Syscall(getPhysicallyInstalledSystemMemory, 1, - uintptr(unsafe.Pointer(totalMemoryInKilobytes)), - 0, - 0) - - return ret != 0 -} From 9722d44279787dbe9f55ece1b6fc18255aab3a99 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 24 Aug 2017 09:04:16 +0200 Subject: [PATCH 045/138] Don't panic on startup if DrawThemeTextEx is not available --- uxtheme.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uxtheme.go b/uxtheme.go index fff30224..3f641439 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -158,7 +158,7 @@ func init() { // Functions closeThemeData = MustGetProcAddress(libuxtheme, "CloseThemeData") drawThemeBackground = MustGetProcAddress(libuxtheme, "DrawThemeBackground") - drawThemeTextEx = MustGetProcAddress(libuxtheme, "DrawThemeTextEx") + drawThemeTextEx, _ = syscall.GetProcAddress(syscall.Handle(libuxtheme), "DrawThemeTextEx") getThemePartSize = MustGetProcAddress(libuxtheme, "GetThemePartSize") getThemeTextExtent = MustGetProcAddress(libuxtheme, "GetThemeTextExtent") isAppThemed = MustGetProcAddress(libuxtheme, "IsAppThemed") From 63c4be36f635cd578649804012407a668f512b8b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 18 Sep 2017 16:14:04 +0200 Subject: [PATCH 046/138] Fix DTTOPTS for 64 bit --- uxtheme.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/uxtheme.go b/uxtheme.go index 3f641439..2714ed13 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -124,14 +124,14 @@ type DTTOPTS struct { CrText COLORREF CrBorder COLORREF CrShadow COLORREF - ITextShadowType int + ITextShadowType int32 PtShadowOffset POINT - IBorderSize int - IFontPropId int - IColorPropId int - IStateId int + IBorderSize int32 + IFontPropId int32 + IColorPropId int32 + IStateId int32 FApplyOverlay BOOL - IGlowSize int + IGlowSize int32 PfnDrawTextCallback uintptr LParam uintptr } From 6089bc412dd0ad5aef087cc517a35e9e217776e8 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 26 Sep 2017 14:30:24 +0200 Subject: [PATCH 047/138] Add AnimateWindow --- user32.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/user32.go b/user32.go index 5a857f3f..7702a0d9 100644 --- a/user32.go +++ b/user32.go @@ -1252,6 +1252,19 @@ const ( HTZOOM = 9 ) +// AnimateWindow flags +const ( + AW_ACTIVATE = 0x00020000 + AW_BLEND = 0x00080000 + AW_CENTER = 0x00000010 + AW_HIDE = 0x00010000 + AW_HOR_POSITIVE = 0x00000001 + AW_HOR_NEGATIVE = 0x00000002 + AW_SLIDE = 0x00040000 + AW_VER_POSITIVE = 0x00000004 + AW_VER_NEGATIVE = 0x00000008 +) + type NMBCDROPDOWN struct { Hdr NMHDR RcButton RECT @@ -1525,6 +1538,7 @@ var ( // Functions addClipboardFormatListener uintptr adjustWindowRect uintptr + animateWindow uintptr beginDeferWindowPos uintptr beginPaint uintptr callWindowProc uintptr @@ -1644,6 +1658,7 @@ func init() { // Functions addClipboardFormatListener, _ = syscall.GetProcAddress(syscall.Handle(libuser32), "AddClipboardFormatListener") adjustWindowRect = MustGetProcAddress(libuser32, "AdjustWindowRect") + animateWindow = MustGetProcAddress(libuser32, "AnimateWindow") beginDeferWindowPos = MustGetProcAddress(libuser32, "BeginDeferWindowPos") beginPaint = MustGetProcAddress(libuser32, "BeginPaint") callWindowProc = MustGetProcAddress(libuser32, "CallWindowProcW") @@ -1786,6 +1801,15 @@ func AdjustWindowRect(lpRect *RECT, dwStyle uint32, bMenu bool) bool { return ret != 0 } +func AnimateWindow(hwnd HWND, dwTime, dwFlags uint32) bool { + ret, _, _ := syscall.Syscall(animateWindow, 3, + uintptr(hwnd), + uintptr(dwTime), + uintptr(dwFlags)) + + return ret != 0 +} + func BeginDeferWindowPos(nNumWindows int32) HDWP { ret, _, _ := syscall.Syscall(beginDeferWindowPos, 1, uintptr(nNumWindows), From 177bd924f64836167eefda525d274e8db0cc081f Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Mon, 30 Oct 2017 17:26:33 -0700 Subject: [PATCH 048/138] add SHGetStockIconInfo --- shell32.go | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/shell32.go b/shell32.go index 373097ff..a1447131 100644 --- a/shell32.go +++ b/shell32.go @@ -137,6 +137,116 @@ const ( SHGFI_ATTR_SPECIFIED = 0x000020000 ) +// SHGetStockIconInfo flags +const ( + SHGSI_ICONLOCATION = 0 + SHGSI_ICON = 0x000000100 + SHGSI_SYSICONINDEX = 0x000004000 + SHGSI_LINKOVERLAY = 0x000008000 + SHGSI_SELECTED = 0x000010000 + SHGSI_LARGEICON = 0x000000000 + SHGSI_SMALLICON = 0x000000001 + SHGSI_SHELLICONSIZE = 0x000000004 +) + +// SHSTOCKICONID values +const ( + SIID_DOCNOASSOC = 0 + SIID_DOCASSOC = 1 + SIID_APPLICATION = 2 + SIID_FOLDER = 3 + SIID_FOLDEROPEN = 4 + SIID_DRIVE525 = 5 + SIID_DRIVE35 = 6 + SIID_DRIVEREMOVE = 7 + SIID_DRIVEFIXED = 8 + SIID_DRIVENET = 9 + SIID_DRIVENETDISABLED = 10 + SIID_DRIVECD = 11 + SIID_DRIVERAM = 12 + SIID_WORLD = 13 + SIID_SERVER = 15 + SIID_PRINTER = 16 + SIID_MYNETWORK = 17 + SIID_FIND = 22 + SIID_HELP = 23 + SIID_SHARE = 28 + SIID_LINK = 29 + SIID_SLOWFILE = 30 + SIID_RECYCLER = 31 + SIID_RECYCLERFULL = 32 + SIID_MEDIACDAUDIO = 40 + SIID_LOCK = 47 + SIID_AUTOLIST = 49 + SIID_PRINTERNET = 50 + SIID_SERVERSHARE = 51 + SIID_PRINTERFAX = 52 + SIID_PRINTERFAXNET = 53 + SIID_PRINTERFILE = 54 + SIID_STACK = 55 + SIID_MEDIASVCD = 56 + SIID_STUFFEDFOLDER = 57 + SIID_DRIVEUNKNOWN = 58 + SIID_DRIVEDVD = 59 + SIID_MEDIADVD = 60 + SIID_MEDIADVDRAM = 61 + SIID_MEDIADVDRW = 62 + SIID_MEDIADVDR = 63 + SIID_MEDIADVDROM = 64 + SIID_MEDIACDAUDIOPLUS = 65 + SIID_MEDIACDRW = 66 + SIID_MEDIACDR = 67 + SIID_MEDIACDBURN = 68 + SIID_MEDIABLANKCD = 69 + SIID_MEDIACDROM = 70 + SIID_AUDIOFILES = 71 + SIID_IMAGEFILES = 72 + SIID_VIDEOFILES = 73 + SIID_MIXEDFILES = 74 + SIID_FOLDERBACK = 75 + SIID_FOLDERFRONT = 76 + SIID_SHIELD = 77 + SIID_WARNING = 78 + SIID_INFO = 79 + SIID_ERROR = 80 + SIID_KEY = 81 + SIID_SOFTWARE = 82 + SIID_RENAME = 83 + SIID_DELETE = 84 + SIID_MEDIAAUDIODVD = 85 + SIID_MEDIAMOVIEDVD = 86 + SIID_MEDIAENHANCEDCD = 87 + SIID_MEDIAENHANCEDDVD = 88 + SIID_MEDIAHDDVD = 89 + SIID_MEDIABLURAY = 90 + SIID_MEDIAVCD = 91 + SIID_MEDIADVDPLUSR = 92 + SIID_MEDIADVDPLUSRW = 93 + SIID_DESKTOPPC = 94 + SIID_MOBILEPC = 95 + SIID_USERS = 96 + SIID_MEDIASMARTMEDIA = 97 + SIID_MEDIACOMPACTFLASH = 98 + SIID_DEVICECELLPHONE = 99 + SIID_DEVICECAMERA = 100 + SIID_DEVICEVIDEOCAMERA = 101 + SIID_DEVICEAUDIOPLAYER = 102 + SIID_NETWORKCONNECT = 103 + SIID_INTERNET = 104 + SIID_ZIPFILE = 105 + SIID_SETTINGS = 106 + SIID_DRIVEHDDVD = 132 + SIID_DRIVEBD = 133 + SIID_MEDIAHDDVDROM = 134 + SIID_MEDIAHDDVDR = 135 + SIID_MEDIAHDDVDRAM = 136 + SIID_MEDIABDROM = 137 + SIID_MEDIABDR = 138 + SIID_MEDIABDRE = 139 + SIID_CLUSTEREDDRIVE = 140 + SIID_MAX_ICONS = 175 +) + type NOTIFYICONDATA struct { CbSize uint32 HWnd HWND @@ -173,6 +283,14 @@ type BROWSEINFO struct { IImage int32 } +type SHSTOCKICONINFO struct { + CbSize uint32 + HIcon HICON + ISysImageIndex int32 + IIcon int32 + SzPath [MAX_PATH]uint16 +} + var ( // Library libshell32 uintptr @@ -186,6 +304,7 @@ var ( shGetPathFromIDList uintptr shGetSpecialFolderPath uintptr shParseDisplayName uintptr + shGetStockIconInfo uintptr shell_NotifyIcon uintptr ) @@ -202,6 +321,7 @@ func init() { shGetPathFromIDList = MustGetProcAddress(libshell32, "SHGetPathFromIDListW") shGetSpecialFolderPath = MustGetProcAddress(libshell32, "SHGetSpecialFolderPathW") shParseDisplayName = MustGetProcAddress(libshell32, "SHParseDisplayName") + shGetStockIconInfo = MustGetProcAddress(libshell32, "SHGetStockIconInfo") shell_NotifyIcon = MustGetProcAddress(libshell32, "Shell_NotifyIconW") } @@ -287,6 +407,18 @@ func SHParseDisplayName(pszName *uint16, pbc uintptr, ppidl *uintptr, sfgaoIn ui return HRESULT(ret) } +func SHGetStockIconInfo(stockIconId int32, uFlags uint32, stockIcon *SHSTOCKICONINFO) HRESULT { + ret, _, _ := syscall.Syscall6(shGetStockIconInfo, 3, + uintptr(stockIconId), + uintptr(uFlags), + uintptr(unsafe.Pointer(stockIcon)), + 0, + 0, + 0, + ) + return HRESULT(ret) +} + func Shell_NotifyIcon(dwMessage uint32, lpdata *NOTIFYICONDATA) bool { ret, _, _ := syscall.Syscall(shell_NotifyIcon, 2, uintptr(dwMessage), From 94dce02f3967884da0386707c6bca71952fea7b9 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Thu, 2 Nov 2017 18:31:58 -0700 Subject: [PATCH 049/138] add BCM_SETSHIELD --- comctl32.go | 1 + 1 file changed, 1 insertion(+) diff --git a/comctl32.go b/comctl32.go index 31564e0b..e9c7e914 100644 --- a/comctl32.go +++ b/comctl32.go @@ -25,6 +25,7 @@ const ( BCM_SETNOTE = BCM_FIRST + 0x0009 BCM_GETNOTE = BCM_FIRST + 0x000A BCM_GETNOTELENGTH = BCM_FIRST + 0x000B + BCM_SETSHIELD = BCM_FIRST + 0x000C ) const ( From d0eb643460308569ca00687680b3245ecfee3b50 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Thu, 2 Nov 2017 19:03:34 -0700 Subject: [PATCH 050/138] add LoadIcon* --- comctl32.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/comctl32.go b/comctl32.go index 31564e0b..2476bdfe 100644 --- a/comctl32.go +++ b/comctl32.go @@ -155,6 +155,12 @@ const ( ILC_PERITEMMIRROR = 0x00008000 ) +// LoadIconMetric flags +const ( + LIM_SMALL = 0 + LIM_LARGE = 1 +) + const ( CDDS_PREPAINT = 0x00000001 CDDS_POSTPAINT = 0x00000002 @@ -228,6 +234,8 @@ var ( imageList_Destroy uintptr imageList_ReplaceIcon uintptr initCommonControlsEx uintptr + loadIconMetric uintptr + loadIconWithScaleDown uintptr ) func init() { @@ -241,6 +249,8 @@ func init() { imageList_Destroy = MustGetProcAddress(libcomctl32, "ImageList_Destroy") imageList_ReplaceIcon = MustGetProcAddress(libcomctl32, "ImageList_ReplaceIcon") initCommonControlsEx = MustGetProcAddress(libcomctl32, "InitCommonControlsEx") + loadIconMetric = MustGetProcAddress(libcomctl32, "LoadIconMetric") + loadIconWithScaleDown = MustGetProcAddress(libcomctl32, "LoadIconWithScaleDown") // Initialize the common controls we support var initCtrls INITCOMMONCONTROLSEX @@ -306,3 +316,27 @@ func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool { return ret != 0 } + +func LoadIconMetric(hInstance HINSTANCE, lpIconName *uint16, lims int32, hicon *HICON) HRESULT { + ret, _, _ := syscall.Syscall6(loadIconMetric, 4, + uintptr(hInstance), + uintptr(unsafe.Pointer(lpIconName)), + uintptr(lims), + uintptr(unsafe.Pointer(hicon)), + 0, + 0) + + return HRESULT(ret) +} + +func LoadIconWithScaleDown(hInstance HINSTANCE, lpIconName *uint16, w int32, h int32, hicon *HICON) HRESULT { + ret, _, _ := syscall.Syscall6(loadIconWithScaleDown, 5, + uintptr(hInstance), + uintptr(unsafe.Pointer(lpIconName)), + uintptr(w), + uintptr(h), + uintptr(unsafe.Pointer(hicon)), + 0) + + return HRESULT(ret) +} From af1cb437fba8d1fb459bbb2eb1063062f022495c Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Sun, 5 Nov 2017 18:40:14 +0100 Subject: [PATCH 051/138] Implement WindowFromDC from user32. --- user32.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/user32.go b/user32.go index 7702a0d9..3207c068 100644 --- a/user32.go +++ b/user32.go @@ -1646,6 +1646,7 @@ var ( trackPopupMenuEx uintptr translateMessage uintptr updateWindow uintptr + windowFromDC uintptr windowFromPoint uintptr ) @@ -1776,6 +1777,7 @@ func init() { trackPopupMenuEx = MustGetProcAddress(libuser32, "TrackPopupMenuEx") translateMessage = MustGetProcAddress(libuser32, "TranslateMessage") updateWindow = MustGetProcAddress(libuser32, "UpdateWindow") + windowFromDC = MustGetProcAddress(libuser32, "WindowFromDC") windowFromPoint = MustGetProcAddress(libuser32, "WindowFromPoint") } @@ -2879,6 +2881,16 @@ func UpdateWindow(hwnd HWND) bool { return ret != 0 } + +func WindowFromDC(hDC HDC) HWND { + ret, _, _ := syscall.Syscall(windowFromDC, 1, + uintptr(hDC), + 0, + 0) + + return HWND(ret) +} + func WindowFromPoint(Point POINT) HWND { ret, _, _ := syscall.Syscall(windowFromPoint, 2, uintptr(Point.X), From 27b44ab7e20e8cb26c0cf609114d03147da4a718 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Mon, 6 Nov 2017 15:32:04 +0100 Subject: [PATCH 052/138] Add Carl Kittelberger to AUTHORS file. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index fd1738bb..bd7c4ca0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,6 +13,7 @@ Alexander Neumann Anton Lahti Benny Siegert Bruno Bigras +Carl Kittelberger Carlos Cobo Cary Cherng David Porter From 1e0d6a9229bfb5986ba8b54e2ffc827233faa3e4 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Mon, 6 Nov 2017 11:27:09 -0800 Subject: [PATCH 053/138] Update AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index fd1738bb..1b612dc6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,7 @@ # ============ Alexander Neumann +Aman Gupta Anton Lahti Benny Siegert Bruno Bigras From 59fcf4bc6ab3b152c0b0efddce415c801bb32f03 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 14 Nov 2017 13:42:25 +0100 Subject: [PATCH 054/138] Add AlphaBlend --- gdi32.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gdi32.go b/gdi32.go index 184ba871..a6e2a186 100644 --- a/gdi32.go +++ b/gdi32.go @@ -748,6 +748,11 @@ const ( COMPLEXREGION = 3 ) +// AlphaBlend operations +const ( + AC_SRC_ALPHA = 0x1 +) + type ( COLORREF uint32 HBITMAP HGDIOBJ @@ -1008,6 +1013,13 @@ type GRADIENT_TRIANGLE struct { Vertex3 uint32 } +type BLENDFUNCTION struct { + BlendOp byte + BlendFlags byte + SourceConstantAlpha byte + AlphaFormat byte +} + var ( // Library libgdi32 uintptr @@ -1015,6 +1027,7 @@ var ( // Functions abortDoc uintptr + alphaBlend uintptr bitBlt uintptr choosePixelFormat uintptr closeEnhMetaFile uintptr @@ -1147,6 +1160,7 @@ func init() { swapBuffers = MustGetProcAddress(libgdi32, "SwapBuffers") textOut = MustGetProcAddress(libgdi32, "TextOutW") + alphaBlend = MustGetProcAddress(libmsimg32, "AlphaBlend") gradientFill = MustGetProcAddress(libmsimg32, "GradientFill") transparentBlt = MustGetProcAddress(libmsimg32, "TransparentBlt") } @@ -1160,6 +1174,24 @@ func AbortDoc(hdc HDC) int32 { return int32(ret) } +func AlphaBlend(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int32, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int32, ftn BLENDFUNCTION) bool { + ret, _, _ := syscall.Syscall12(alphaBlend, 11, + uintptr(hdcDest), + uintptr(nXOriginDest), + uintptr(nYOriginDest), + uintptr(nWidthDest), + uintptr(nHeightDest), + uintptr(hdcSrc), + uintptr(nXOriginSrc), + uintptr(nYOriginSrc), + uintptr(nWidthSrc), + uintptr(nHeightSrc), + uintptr(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&ftn))))), + 0) + + return ret != 0 +} + func BitBlt(hdcDest HDC, nXDest, nYDest, nWidth, nHeight int32, hdcSrc HDC, nXSrc, nYSrc int32, dwRop uint32) bool { ret, _, _ := syscall.Syscall9(bitBlt, 9, uintptr(hdcDest), From 38b6e935a7a8f3883bfba9de0db145eb63bed948 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 16 Nov 2017 11:37:03 +0100 Subject: [PATCH 055/138] Add some more GDI functions --- gdi32.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/gdi32.go b/gdi32.go index a6e2a186..23bcd7a5 100644 --- a/gdi32.go +++ b/gdi32.go @@ -1053,6 +1053,7 @@ var ( excludeClipRect uintptr extCreatePen uintptr fillRgn uintptr + gdiFlush uintptr getDeviceCaps uintptr getDIBits uintptr getEnhMetaFile uintptr @@ -1074,10 +1075,12 @@ var ( rectangle uintptr resetDC uintptr restoreDC uintptr + roundRect uintptr selectObject uintptr setBkColor uintptr setBkMode uintptr setBrushOrgEx uintptr + setDIBits uintptr setPixel uintptr setPixelFormat uintptr setStretchBltMode uintptr @@ -1124,6 +1127,7 @@ func init() { excludeClipRect = MustGetProcAddress(libgdi32, "ExcludeClipRect") extCreatePen = MustGetProcAddress(libgdi32, "ExtCreatePen") fillRgn = MustGetProcAddress(libgdi32, "FillRgn") + gdiFlush = MustGetProcAddress(libgdi32, "GdiFlush") getDeviceCaps = MustGetProcAddress(libgdi32, "GetDeviceCaps") getDIBits = MustGetProcAddress(libgdi32, "GetDIBits") getEnhMetaFile = MustGetProcAddress(libgdi32, "GetEnhMetaFileW") @@ -1144,11 +1148,13 @@ func init() { rectangle = MustGetProcAddress(libgdi32, "Rectangle") resetDC = MustGetProcAddress(libgdi32, "ResetDCW") restoreDC = MustGetProcAddress(libgdi32, "RestoreDC") + roundRect = MustGetProcAddress(libgdi32, "RoundRect") saveDC = MustGetProcAddress(libgdi32, "SaveDC") selectObject = MustGetProcAddress(libgdi32, "SelectObject") setBkColor = MustGetProcAddress(libgdi32, "SetBkColor") setBkMode = MustGetProcAddress(libgdi32, "SetBkMode") setBrushOrgEx = MustGetProcAddress(libgdi32, "SetBrushOrgEx") + setDIBits = MustGetProcAddress(libgdi32, "SetDIBits") setPixel = MustGetProcAddress(libgdi32, "SetPixel") setPixelFormat = MustGetProcAddress(libgdi32, "SetPixelFormat") setStretchBltMode = MustGetProcAddress(libgdi32, "SetStretchBltMode") @@ -1453,6 +1459,15 @@ func FillRgn(hdc HDC, hrgn HRGN, hbr HBRUSH) bool { return ret != 0 } +func GdiFlush() bool { + ret, _, _ := syscall.Syscall(gdiFlush, 0, + 0, + 0, + 0) + + return ret != 0 +} + func GetDeviceCaps(hdc HDC, nIndex int32) int32 { ret, _, _ := syscall.Syscall(getDeviceCaps, 2, uintptr(hdc), @@ -1667,6 +1682,21 @@ func RestoreDC(hdc HDC, nSaveDC int32) bool { return ret != 0 } +func RoundRect(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect, nWidth, nHeight int32) bool { + ret, _, _ := syscall.Syscall9(roundRect, 7, + uintptr(hdc), + uintptr(nLeftRect), + uintptr(nTopRect), + uintptr(nRightRect), + uintptr(nBottomRect), + uintptr(nWidth), + uintptr(nHeight), + 0, + 0) + + return ret != 0 +} + func SaveDC(hdc HDC) int32 { ret, _, _ := syscall.Syscall(saveDC, 1, uintptr(hdc), @@ -1714,6 +1744,21 @@ func SetBrushOrgEx(hdc HDC, nXOrg, nYOrg int32, lppt *POINT) bool { return ret != 0 } +func SetDIBits(hdc HDC, hbmp HBITMAP, uStartScan, cScanLines uint32, lpvBits *byte, lpbmi *BITMAPINFO, fuColorUse uint32) int32 { + ret, _, _ := syscall.Syscall9(setDIBits, 7, + uintptr(hdc), + uintptr(hbmp), + uintptr(uStartScan), + uintptr(cScanLines), + uintptr(unsafe.Pointer(lpvBits)), + uintptr(unsafe.Pointer(lpbmi)), + uintptr(fuColorUse), + 0, + 0) + + return int32(ret) +} + func SetPixel(hdc HDC, X, Y int32, crColor COLORREF) COLORREF { ret, _, _ := syscall.Syscall6(setPixel, 4, uintptr(hdc), From aaf8f59e531a7f484381fbc5453def0cffe9c526 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 20 Nov 2017 11:49:25 +0100 Subject: [PATCH 056/138] Don't panic on post XP stuff. At least not on startup. --- comctl32.go | 4 ++-- shell32.go | 4 ++-- win.go | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/comctl32.go b/comctl32.go index 830f87e8..3e204a28 100644 --- a/comctl32.go +++ b/comctl32.go @@ -250,8 +250,8 @@ func init() { imageList_Destroy = MustGetProcAddress(libcomctl32, "ImageList_Destroy") imageList_ReplaceIcon = MustGetProcAddress(libcomctl32, "ImageList_ReplaceIcon") initCommonControlsEx = MustGetProcAddress(libcomctl32, "InitCommonControlsEx") - loadIconMetric = MustGetProcAddress(libcomctl32, "LoadIconMetric") - loadIconWithScaleDown = MustGetProcAddress(libcomctl32, "LoadIconWithScaleDown") + loadIconMetric = MaybeGetProcAddress(libcomctl32, "LoadIconMetric") + loadIconWithScaleDown = MaybeGetProcAddress(libcomctl32, "LoadIconWithScaleDown") // Initialize the common controls we support var initCtrls INITCOMMONCONTROLSEX diff --git a/shell32.go b/shell32.go index a1447131..e9aa4bf7 100644 --- a/shell32.go +++ b/shell32.go @@ -320,9 +320,9 @@ func init() { shGetFileInfo = MustGetProcAddress(libshell32, "SHGetFileInfoW") shGetPathFromIDList = MustGetProcAddress(libshell32, "SHGetPathFromIDListW") shGetSpecialFolderPath = MustGetProcAddress(libshell32, "SHGetSpecialFolderPathW") - shParseDisplayName = MustGetProcAddress(libshell32, "SHParseDisplayName") - shGetStockIconInfo = MustGetProcAddress(libshell32, "SHGetStockIconInfo") + shGetStockIconInfo = MaybeGetProcAddress(libshell32, "SHGetStockIconInfo") shell_NotifyIcon = MustGetProcAddress(libshell32, "Shell_NotifyIconW") + shParseDisplayName = MustGetProcAddress(libshell32, "SHParseDisplayName") } func DragAcceptFiles(hWnd HWND, fAccept bool) bool { diff --git a/win.go b/win.go index 312cf962..3e9f84b9 100644 --- a/win.go +++ b/win.go @@ -60,6 +60,12 @@ func MustGetProcAddress(lib uintptr, name string) uintptr { return uintptr(addr) } +func MaybeGetProcAddress(lib uintptr, name string) uintptr { + addr, _ := syscall.GetProcAddress(syscall.Handle(lib), name) + + return uintptr(addr) +} + func SUCCEEDED(hr HRESULT) bool { return hr >= 0 } From 8df69d74f93abf442d805b3ad69919b4a4bfa0e2 Mon Sep 17 00:00:00 2001 From: Alan Henager Date: Fri, 16 Feb 2018 08:05:06 -0600 Subject: [PATCH 057/138] Fix GPTR flag to correct value --- kernel32.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel32.go b/kernel32.go index 2baacf62..0cb8834f 100644 --- a/kernel32.go +++ b/kernel32.go @@ -29,7 +29,7 @@ const ( GMEM_FIXED = 0x0000 GMEM_MOVEABLE = 0x0002 GMEM_ZEROINIT = 0x0040 - GPTR = 0x004 + GPTR = GMEM_FIXED | GMEM_ZEROINIT ) // Predefined locale ids From dae64ff453563c2467864cc4d832bcf401513044 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 23 Mar 2018 12:34:42 +0100 Subject: [PATCH 058/138] Add NMLVSCROLL --- listview.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/listview.go b/listview.go index ef1db0ec..a705534f 100644 --- a/listview.go +++ b/listview.go @@ -368,3 +368,9 @@ type NMLVDISPINFO struct { Hdr NMHDR Item LVITEM } + +type NMLVSCROLL struct { + Hdr NMHDR + Dx int32 + Dy int32 +} From d3b5b63dbde2ccbcad21970eb7080e90c2d631b3 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 23 Mar 2018 12:35:02 +0100 Subject: [PATCH 059/138] Add some header control stuff --- header.go | 121 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 106 insertions(+), 15 deletions(-) diff --git a/header.go b/header.go index 6e15fb09..7465d570 100644 --- a/header.go +++ b/header.go @@ -6,21 +6,6 @@ package win -const ( - HDF_SORTDOWN = 0x200 - HDF_SORTUP = 0x400 -) - -const ( - HDI_FORMAT = 4 -) - -const ( - HDM_FIRST = 0x1200 - HDM_GETITEM = HDM_FIRST + 11 - HDM_SETITEM = HDM_FIRST + 12 -) - const ( HDS_NOSIZING = 0x0800 ) @@ -38,3 +23,109 @@ type HDITEM struct { Type uint32 PvFilter uintptr } + +const ( + HDI_WIDTH = 0x0001 + HDI_HEIGHT = HDI_WIDTH + HDI_TEXT = 0x0002 + HDI_FORMAT = 0x0004 + HDI_LPARAM = 0x0008 + HDI_BITMAP = 0x0010 + HDI_IMAGE = 0x0020 + HDI_DI_SETITEM = 0x0040 + HDI_ORDER = 0x0080 + HDI_FILTER = 0x0100 + HDI_STATE = 0x0200 +) + +const ( + HDF_LEFT = 0x0000 + HDF_RIGHT = 0x0001 + HDF_CENTER = 0x0002 + HDF_JUSTIFYMASK = 0x0003 + HDF_RTLREADING = 0x0004 + HDF_CHECKBOX = 0x0040 + HDF_CHECKED = 0x0080 + HDF_FIXEDWIDTH = 0x0100 + HDF_SORTDOWN = 0x0200 + HDF_SORTUP = 0x0400 + HDF_IMAGE = 0x0800 + HDF_BITMAP_ON_RIGHT = 0x1000 + HDF_BITMAP = 0x2000 + HDF_STRING = 0x4000 + HDF_OWNERDRAW = 0x8000 + HDF_SPLITBUTTON = 0x1000000 +) + +const ( + HDIS_FOCUSED = 0x00000001 +) + +const ( + HDM_FIRST = 0x1200 + HDM_GETITEMCOUNT = HDM_FIRST + 0 + HDM_DELETEITEM = HDM_FIRST + 2 + HDM_LAYOUT = HDM_FIRST + 5 + HDM_HITTEST = HDM_FIRST + 6 + HDM_GETITEMRECT = HDM_FIRST + 7 + HDM_SETIMAGELIST = HDM_FIRST + 8 + HDM_GETIMAGELIST = HDM_FIRST + 9 + HDM_INSERTITEM = HDM_FIRST + 10 + HDM_GETITEM = HDM_FIRST + 11 + HDM_SETITEM = HDM_FIRST + 12 + HDM_ORDERTOINDEX = HDM_FIRST + 15 + HDM_CREATEDRAGIMAGE = HDM_FIRST + 16 + HDM_GETORDERARRAY = HDM_FIRST + 17 + HDM_SETORDERARRAY = HDM_FIRST + 18 + HDM_SETHOTDIVIDER = HDM_FIRST + 19 + HDM_SETBITMAPMARGIN = HDM_FIRST + 20 + HDM_GETBITMAPMARGIN = HDM_FIRST + 21 + HDM_SETFILTERCHANGETIMEOUT = HDM_FIRST + 22 + HDM_EDITFILTER = HDM_FIRST + 23 + HDM_CLEARFILTER = HDM_FIRST + 24 + HDM_GETITEMDROPDOWNRECT = HDM_FIRST + 25 + HDM_GETOVERFLOWRECT = HDM_FIRST + 26 + HDM_GETFOCUSEDITEM = HDM_FIRST + 27 + HDM_SETFOCUSEDITEM = HDM_FIRST + 28 + HDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT + HDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT +) + +const ( + HHT_NOWHERE = 0x0001 + HHT_ONHEADER = 0x0002 + HHT_ONDIVIDER = 0x0004 + HHT_ONDIVOPEN = 0x0008 + HHT_ONFILTER = 0x0010 + HHT_ONFILTERBUTTON = 0x0020 + HHT_ABOVE = 0x0100 + HHT_BELOW = 0x0200 + HHT_TORIGHT = 0x0400 + HHT_TOLEFT = 0x0800 + HHT_ONITEMSTATEICON = 0x1000 + HHT_ONDROPDOWN = 0x2000 + HHT_ONOVERFLOW = 0x4000 +) + +const ( + HDN_FIRST = ^uint32(300) + HDN_BEGINDRAG = HDN_FIRST - 10 + HDN_ENDDRAG = HDN_FIRST - 11 + HDN_FILTERCHANGE = HDN_FIRST - 12 + HDN_FILTERBTNCLICK = HDN_FIRST - 13 + HDN_BEGINFILTEREDIT = HDN_FIRST - 14 + HDN_ENDFILTEREDIT = HDN_FIRST - 15 + HDN_ITEMSTATEICONCLICK = HDN_FIRST - 16 + HDN_ITEMKEYDOWN = HDN_FIRST - 17 + HDN_DROPDOWN = HDN_FIRST - 18 + HDN_OVERFLOWCLICK = HDN_FIRST - 19 + HDN_ITEMCHANGING = HDN_FIRST - 20 + HDN_ITEMCHANGED = HDN_FIRST - 21 + HDN_ITEMCLICK = HDN_FIRST - 22 + HDN_ITEMDBLCLICK = HDN_FIRST - 23 + HDN_DIVIDERDBLCLICK = HDN_FIRST - 25 + HDN_BEGINTRACK = HDN_FIRST - 26 + HDN_ENDTRACK = HDN_FIRST - 27 + HDN_TRACK = HDN_FIRST - 28 + HDN_GETDISPINFO = HDN_FIRST - 29 +) From 97a2b7e1cbdb35eaf38b0b4f3ad62d1f5e4a0e0b Mon Sep 17 00:00:00 2001 From: ryujimiya Date: Sun, 8 Apr 2018 21:58:14 +0900 Subject: [PATCH 060/138] (1) Fix VARIANT type for Windows10 (x64) which was invalid at Windows 64bit (2) Implement IOleInPlaceActiveObject for Accelerator Keys --- oleaut32.go | 225 ++++++++++++++++++++++++++++++++++++++++++---- oleaut32_386.go | 54 +++++++++++ oleaut32_amd64.go | 55 ++++++++++++ shdocvw.go | 62 ++++++++++++- 4 files changed, 373 insertions(+), 23 deletions(-) diff --git a/oleaut32.go b/oleaut32.go index b02e02eb..fde29791 100644 --- a/oleaut32.go +++ b/oleaut32.go @@ -7,6 +7,8 @@ package win import ( + "fmt" + "log" "syscall" "unsafe" ) @@ -55,6 +57,7 @@ const ( DISPID_FILEDOWNLOAD DISPID = 270 DISPID_NAVIGATEERROR DISPID = 271 DISPID_PRIVACYIMPACTEDSTATECHANGE DISPID = 272 + DISPID_NEWWINDOW3 DISPID = 273 ) var ( @@ -65,6 +68,26 @@ const ( DISP_E_MEMBERNOTFOUND = 0x80020003 ) +const ( + CSC_UPDATECOMMANDS = int(0xFFFFFFFF) + CSC_NAVIGATEFORWARD = 0x1 + CSC_NAVIGATEBACK = 0x2 +) + +type IDispatchVtbl struct { + QueryInterface uintptr + AddRef uintptr + Release uintptr + GetTypeInfoCount uintptr + GetTypeInfo uintptr + GetIDsOfNames uintptr + Invoke uintptr +} + +type IDispatch struct { + LpVtbl *IDispatchVtbl +} + type VARTYPE uint16 const ( @@ -122,15 +145,17 @@ const ( VT_TYPEMASK VARTYPE = 0xfff ) -type VARIANT struct { - Vt VARTYPE - reserved [14]byte +type VARIANTARG struct { + VARIANT } -type VARIANTARG VARIANT - type VARIANT_BOOL int16 +const ( + VARIANT_TRUE VARIANT_BOOL = -1 + VARIANT_FALSE VARIANT_BOOL = 0 +) + //type BSTR *uint16 func StringToBSTR(value string) *uint16 /*BSTR*/ { @@ -148,13 +173,6 @@ func BSTRToString(value *uint16 /*BSTR*/) string { return syscall.UTF16ToString(bstrSlice) } -type VAR_I4 struct { - vt VARTYPE - reserved1 [6]byte - lVal int32 - reserved2 [4]byte -} - func IntToVariantI4(value int32) *VAR_I4 { return &VAR_I4{vt: VT_I4, lVal: value} } @@ -163,13 +181,6 @@ func VariantI4ToInt(value *VAR_I4) int32 { return value.lVal } -type VAR_BOOL struct { - vt VARTYPE - reserved1 [6]byte - boolVal VARIANT_BOOL - reserved2 [6]byte -} - func BoolToVariantBool(value bool) *VAR_BOOL { return &VAR_BOOL{vt: VT_BOOL, boolVal: VARIANT_BOOL(BoolToBOOL(value))} } @@ -187,6 +198,182 @@ func VariantBSTRToString(value *VAR_BSTR) string { return BSTRToString(value.bstrVal) } +func (v *VARIANT) LVal() int32 { + value, err := v.GetLVal() + if err != nil { + log.Fatal(err) + } + return value +} + +func (v *VARIANT) GetLVal() (int32, error) { + if v.Vt != VT_I4 { + return 0, fmt.Errorf("Error: LVal() v.Vt != VT_I4, ptr=%p, value=%+v", v, v) + } + p := (*VAR_I4)(unsafe.Pointer(v)) + return p.lVal, nil +} + +func (v *VARIANT) SetLVal(value int32) { + v.Vt = VT_I4 + p := (*VAR_I4)(unsafe.Pointer(v)) + p.lVal = value +} + +func (v *VARIANT) ULVal() uint32 { + value, err := v.GetULVal() + if err != nil { + log.Fatal(err) + } + return value +} + +func (v *VARIANT) GetULVal() (uint32, error) { + if v.Vt != VT_UI4 { + return 0, fmt.Errorf("Error: LVal() v.Vt != VT_UI4, ptr=%p, value=%+v", v, v) + } + p := (*VAR_UI4)(unsafe.Pointer(v)) + return p.ulVal, nil +} + +func (v *VARIANT) SetULVal(value uint32) { + v.Vt = VT_UI4 + p := (*VAR_UI4)(unsafe.Pointer(v)) + p.ulVal = value +} + +func (v *VARIANT) BoolVal() VARIANT_BOOL { + value, err := v.GetBoolVal() + if err != nil { + log.Fatal(err) + } + return value +} + +func (v *VARIANT) GetBoolVal() (VARIANT_BOOL, error) { + if v.Vt != VT_BOOL { + return VARIANT_FALSE, fmt.Errorf("Error: BoolVal() v.Vt != VT_BOOL, ptr=%p, value=%+v", v, v) + } + p := (*VAR_BOOL)(unsafe.Pointer(v)) + return p.boolVal, nil +} + +func (v *VARIANT) SetBoolVal(value VARIANT_BOOL) { + v.Vt = VT_BOOL + p := (*VAR_BOOL)(unsafe.Pointer(v)) + p.boolVal = value +} + +func (v *VARIANT) BstrVal() *uint16 { + value, err := v.GetBstrVal() + if err != nil { + log.Fatal(err) + } + return value +} + +func (v *VARIANT) GetBstrVal() (*uint16, error) { + if v.Vt != VT_BSTR { + return nil, fmt.Errorf("Error: BstrVal() v.Vt != VT_BSTR, ptr=%p, value=%+v", v, v) + } + p := (*VAR_BSTR)(unsafe.Pointer(v)) + return p.bstrVal, nil +} + +func (v *VARIANT) SetBstrVal(value *uint16) { + v.Vt = VT_BSTR + p := (*VAR_BSTR)(unsafe.Pointer(v)) + p.bstrVal = value +} + +func (v *VARIANT) PDispVal() *IDispatch { + value, err := v.GetPDispVal() + if err != nil { + log.Fatal(err) + } + return value +} + +func (v *VARIANT) GetPDispVal() (*IDispatch, error) { + if v.Vt != VT_DISPATCH { + return nil, fmt.Errorf("Error: PDispVal() v.Vt != VT_DISPATCH, ptr=%p, value=%+v", v, v) + } + p := (*VAR_PDISP)(unsafe.Pointer(v)) + return p.pdispVal, nil +} + +func (v *VARIANT) SetPDispVal(value *IDispatch) { + v.Vt = VT_DISPATCH + p := (*VAR_PDISP)(unsafe.Pointer(v)) + p.pdispVal = value +} + +func (v *VARIANT) PVarVal() *VARIANT { + value, err := v.GetPVarVal() + if err != nil { + log.Fatal(err) + } + return value +} + +func (v *VARIANT) GetPVarVal() (*VARIANT, error) { + if v.Vt != VT_BYREF|VT_VARIANT { + return nil, fmt.Errorf("Error: PVarVal() v.Vt != VT_BYREF|VT_VARIANT, ptr=%p, value=%+v", v, v) + } + p := (*VAR_PVAR)(unsafe.Pointer(v)) + return p.pvarVal, nil +} + +func (v *VARIANT) SetPVarVal(value *VARIANT) { + v.Vt = VT_BYREF | VT_VARIANT + p := (*VAR_PVAR)(unsafe.Pointer(v)) + p.pvarVal = value +} + +func (v *VARIANT) PBoolVal() *VARIANT_BOOL { + value, err := v.GetPBoolVal() + if err != nil { + log.Fatal(err) + } + return value +} + +func (v *VARIANT) GetPBoolVal() (*VARIANT_BOOL, error) { + if v.Vt != VT_BYREF|VT_BOOL { + return nil, fmt.Errorf("Error: PBoolVal() v.Vt != VT_BYREF|VT_BOOL, ptr=%p, value=%+v", v, v) + } + p := (*VAR_PBOOL)(unsafe.Pointer(v)) + return p.pboolVal, nil +} + +func (v *VARIANT) SetPBoolVal(value *VARIANT_BOOL) { + v.Vt = VT_BYREF | VT_BOOL + p := (*VAR_PBOOL)(unsafe.Pointer(v)) + p.pboolVal = value +} + +func (v *VARIANT) PPDispVal() **IDispatch { + value, err := v.GetPPDispVal() + if err != nil { + log.Fatal(err) + } + return value +} + +func (v *VARIANT) GetPPDispVal() (**IDispatch, error) { + if v.Vt != VT_BYREF|VT_DISPATCH { + return nil, fmt.Errorf("PPDispVal() v.Vt != VT_BYREF|VT_DISPATCH, ptr=%p, value=%+v", v, v) + } + p := (*VAR_PPDISP)(unsafe.Pointer(v)) + return p.ppdispVal, nil +} + +func (v *VARIANT) SetPPDispVal(value **IDispatch) { + v.Vt = VT_BYREF | VT_DISPATCH + p := (*VAR_PPDISP)(unsafe.Pointer(v)) + p.ppdispVal = value +} + type DISPPARAMS struct { Rgvarg *VARIANTARG RgdispidNamedArgs *DISPID diff --git a/oleaut32_386.go b/oleaut32_386.go index 6d453317..64a43590 100644 --- a/oleaut32_386.go +++ b/oleaut32_386.go @@ -6,9 +6,63 @@ package win +type VARIANT struct { + Vt VARTYPE + reserved [14]byte +} + +type VAR_I4 struct { + vt VARTYPE + reserved1 [6]byte + lVal int32 + reserved2 [4]byte +} + +type VAR_UI4 struct { + vt VARTYPE + reserved1 [6]byte + ulVal uint32 + reserved2 [4]byte +} + +type VAR_BOOL struct { + vt VARTYPE + reserved1 [6]byte + boolVal VARIANT_BOOL + reserved2 [6]byte +} + type VAR_BSTR struct { vt VARTYPE reserved1 [6]byte bstrVal *uint16 /*BSTR*/ reserved2 [4]byte } + +type VAR_PDISP struct { + vt VARTYPE + reserved1 [6]byte + pdispVal *IDispatch + reserved2 [4]byte +} + +type VAR_PVAR struct { + vt VARTYPE + reserved1 [6]byte + pvarVal *VARIANT + reserved2 [4]byte +} + +type VAR_PBOOL struct { + vt VARTYPE + reserved1 [6]byte + pboolVal *VARIANT_BOOL + reserved2 [4]byte +} + +type VAR_PPDISP struct { + vt VARTYPE + reserved1 [6]byte + ppdispVal **IDispatch + reserved2 [4]byte +} diff --git a/oleaut32_amd64.go b/oleaut32_amd64.go index 1af64f06..65021720 100644 --- a/oleaut32_amd64.go +++ b/oleaut32_amd64.go @@ -6,8 +6,63 @@ package win +type VARIANT struct { + Vt VARTYPE + reserved [22]byte +} + +type VAR_I4 struct { + vt VARTYPE + reserved1 [6]byte + lVal int32 + reserved2 [12]byte +} + +type VAR_UI4 struct { + vt VARTYPE + reserved1 [6]byte + ulVal uint32 + reserved2 [12]byte +} + +type VAR_BOOL struct { + vt VARTYPE + reserved1 [6]byte + boolVal VARIANT_BOOL + reserved2 [14]byte +} + type VAR_BSTR struct { vt VARTYPE reserved1 [6]byte bstrVal *uint16 /*BSTR*/ + reserved2 [8]byte +} + +type VAR_PDISP struct { + vt VARTYPE + reserved1 [6]byte + pdispVal *IDispatch + reserved2 [8]byte +} + +type VAR_PVAR struct { + vt VARTYPE + reserved1 [6]byte + pvarVal *VARIANT + reserved2 [8]byte +} + +type VAR_PBOOL struct { + vt VARTYPE + reserved1 [6]byte + pboolVal *VARIANT_BOOL + reserved2 [8]byte +} + +type VAR_PPDISP struct { + vt VARTYPE + reserved1 [6]byte + ppdispVal **IDispatch + reserved2 [8]byte } diff --git a/shdocvw.go b/shdocvw.go index 3f180943..6d1e81a5 100644 --- a/shdocvw.go +++ b/shdocvw.go @@ -66,10 +66,11 @@ const ( ) var ( - CLSID_WebBrowser = CLSID{0x8856F961, 0x340A, 0x11D0, [8]byte{0xA9, 0x6B, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2}} - DIID_DWebBrowserEvents2 = IID{0x34A715A0, 0x6587, 0x11D0, [8]byte{0x92, 0x4A, 0x00, 0x20, 0xAF, 0xC7, 0xAC, 0x4D}} - IID_IWebBrowser2 = IID{0xD30C1661, 0xCDAF, 0x11D0, [8]byte{0x8A, 0x3E, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E}} - IID_IDocHostUIHandler = IID{0xBD3F23C0, 0xD43E, 0x11CF, [8]byte{0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A}} + CLSID_WebBrowser = CLSID{0x8856F961, 0x340A, 0x11D0, [8]byte{0xA9, 0x6B, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2}} + DIID_DWebBrowserEvents2 = IID{0x34A715A0, 0x6587, 0x11D0, [8]byte{0x92, 0x4A, 0x00, 0x20, 0xAF, 0xC7, 0xAC, 0x4D}} + IID_IWebBrowser2 = IID{0xD30C1661, 0xCDAF, 0x11D0, [8]byte{0x8A, 0x3E, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E}} + IID_IDocHostUIHandler = IID{0xBD3F23C0, 0xD43E, 0x11CF, [8]byte{0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A}} + IID_IOleInPlaceActiveObject = IID{0x00000117, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} ) type DWebBrowserEvents2Vtbl struct { @@ -164,6 +165,15 @@ type IWebBrowser2 struct { LpVtbl *IWebBrowser2Vtbl } +func (wb2 *IWebBrowser2) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { + ret, _, _ := syscall.Syscall(wb2.LpVtbl.QueryInterface, 3, + uintptr(unsafe.Pointer(wb2)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(ppvObject))) + + return HRESULT(ret) +} + func (wb2 *IWebBrowser2) Release() HRESULT { ret, _, _ := syscall.Syscall(wb2.LpVtbl.Release, 1, uintptr(unsafe.Pointer(wb2)), @@ -271,3 +281,47 @@ type DOCHOSTUIINFO struct { PchHostCss *uint16 PchHostNS *uint16 } + +type IOleInPlaceActiveObjectVtbl struct { + QueryInterface uintptr + AddRef uintptr + Release uintptr + GetWindow uintptr + ContextSensitiveHelp uintptr + TranslateAccelerator uintptr + OnFrameWindowActivate uintptr + OnDocWindowActivate uintptr + ResizeBorder uintptr + EnableModeless uintptr +} + +type IOleInPlaceActiveObject struct { + LpVtbl *IOleInPlaceActiveObjectVtbl +} + +func (activeObj *IOleInPlaceActiveObject) Release() HRESULT { + ret, _, _ := syscall.Syscall(activeObj.LpVtbl.Release, 1, + uintptr(unsafe.Pointer(activeObj)), + 0, + 0) + + return HRESULT(ret) +} + +func (activeObj *IOleInPlaceActiveObject) GetWindow(hWndPtr *HWND) HRESULT { + ret, _, _ := syscall.Syscall(activeObj.LpVtbl.GetWindow, 2, + uintptr(unsafe.Pointer(activeObj)), + uintptr(unsafe.Pointer(hWndPtr)), + 0) + + return HRESULT(ret) +} + +func (activeObj *IOleInPlaceActiveObject) TranslateAccelerator(msg *MSG) HRESULT { + ret, _, _ := syscall.Syscall(activeObj.LpVtbl.TranslateAccelerator, 2, + uintptr(unsafe.Pointer(activeObj)), + uintptr(unsafe.Pointer(msg)), + 0) + + return HRESULT(ret) +} From b823cb1531857f4713b10f9e12074d7e3af78835 Mon Sep 17 00:00:00 2001 From: ryujimiya Date: Sun, 15 Apr 2018 09:03:57 +0900 Subject: [PATCH 061/138] The VARIANT-type method names are changed: e.g. LVal() to MustLong(). Add myself to AUTHORS file. --- AUTHORS | 1 + oleaut32.go | 97 ++++++++++++++++++++++++++--------------------------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/AUTHORS b/AUTHORS index 642d5b4d..c7390509 100644 --- a/AUTHORS +++ b/AUTHORS @@ -23,4 +23,5 @@ Joseph Watson Kevin Pors ktye mycaosf +ryujimiya wsf01 diff --git a/oleaut32.go b/oleaut32.go index fde29791..f50333f2 100644 --- a/oleaut32.go +++ b/oleaut32.go @@ -8,7 +8,6 @@ package win import ( "fmt" - "log" "syscall" "unsafe" ) @@ -198,177 +197,177 @@ func VariantBSTRToString(value *VAR_BSTR) string { return BSTRToString(value.bstrVal) } -func (v *VARIANT) LVal() int32 { - value, err := v.GetLVal() +func (v *VARIANT) MustLong() int32 { + value, err := v.GetLong() if err != nil { - log.Fatal(err) + panic(err) } return value } -func (v *VARIANT) GetLVal() (int32, error) { +func (v *VARIANT) GetLong() (int32, error) { if v.Vt != VT_I4 { - return 0, fmt.Errorf("Error: LVal() v.Vt != VT_I4, ptr=%p, value=%+v", v, v) + return 0, fmt.Errorf("Error: GetLong() v.Vt != VT_I4, ptr=%p, value=%+v", v, v) } p := (*VAR_I4)(unsafe.Pointer(v)) return p.lVal, nil } -func (v *VARIANT) SetLVal(value int32) { +func (v *VARIANT) SetLong(value int32) { v.Vt = VT_I4 p := (*VAR_I4)(unsafe.Pointer(v)) p.lVal = value } -func (v *VARIANT) ULVal() uint32 { - value, err := v.GetULVal() +func (v *VARIANT) MustULong() uint32 { + value, err := v.GetULong() if err != nil { - log.Fatal(err) + panic(err) } return value } -func (v *VARIANT) GetULVal() (uint32, error) { +func (v *VARIANT) GetULong() (uint32, error) { if v.Vt != VT_UI4 { - return 0, fmt.Errorf("Error: LVal() v.Vt != VT_UI4, ptr=%p, value=%+v", v, v) + return 0, fmt.Errorf("Error: GetULong() v.Vt != VT_UI4, ptr=%p, value=%+v", v, v) } p := (*VAR_UI4)(unsafe.Pointer(v)) return p.ulVal, nil } -func (v *VARIANT) SetULVal(value uint32) { +func (v *VARIANT) SetULong(value uint32) { v.Vt = VT_UI4 p := (*VAR_UI4)(unsafe.Pointer(v)) p.ulVal = value } -func (v *VARIANT) BoolVal() VARIANT_BOOL { - value, err := v.GetBoolVal() +func (v *VARIANT) MustBool() VARIANT_BOOL { + value, err := v.GetBool() if err != nil { - log.Fatal(err) + panic(err) } return value } -func (v *VARIANT) GetBoolVal() (VARIANT_BOOL, error) { +func (v *VARIANT) GetBool() (VARIANT_BOOL, error) { if v.Vt != VT_BOOL { - return VARIANT_FALSE, fmt.Errorf("Error: BoolVal() v.Vt != VT_BOOL, ptr=%p, value=%+v", v, v) + return VARIANT_FALSE, fmt.Errorf("Error: GetBool() v.Vt != VT_BOOL, ptr=%p, value=%+v", v, v) } p := (*VAR_BOOL)(unsafe.Pointer(v)) return p.boolVal, nil } -func (v *VARIANT) SetBoolVal(value VARIANT_BOOL) { +func (v *VARIANT) SetBool(value VARIANT_BOOL) { v.Vt = VT_BOOL p := (*VAR_BOOL)(unsafe.Pointer(v)) p.boolVal = value } -func (v *VARIANT) BstrVal() *uint16 { - value, err := v.GetBstrVal() +func (v *VARIANT) MustBSTR() *uint16 { + value, err := v.GetBSTR() if err != nil { - log.Fatal(err) + panic(err) } return value } -func (v *VARIANT) GetBstrVal() (*uint16, error) { +func (v *VARIANT) GetBSTR() (*uint16, error) { if v.Vt != VT_BSTR { - return nil, fmt.Errorf("Error: BstrVal() v.Vt != VT_BSTR, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("Error: GetBSTR() v.Vt != VT_BSTR, ptr=%p, value=%+v", v, v) } p := (*VAR_BSTR)(unsafe.Pointer(v)) return p.bstrVal, nil } -func (v *VARIANT) SetBstrVal(value *uint16) { +func (v *VARIANT) SetBSTR(value *uint16) { v.Vt = VT_BSTR p := (*VAR_BSTR)(unsafe.Pointer(v)) p.bstrVal = value } -func (v *VARIANT) PDispVal() *IDispatch { - value, err := v.GetPDispVal() +func (v *VARIANT) MustPDispatch() *IDispatch { + value, err := v.GetPDispatch() if err != nil { - log.Fatal(err) + panic(err) } return value } -func (v *VARIANT) GetPDispVal() (*IDispatch, error) { +func (v *VARIANT) GetPDispatch() (*IDispatch, error) { if v.Vt != VT_DISPATCH { - return nil, fmt.Errorf("Error: PDispVal() v.Vt != VT_DISPATCH, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("Error: GetPDispatch() v.Vt != VT_DISPATCH, ptr=%p, value=%+v", v, v) } p := (*VAR_PDISP)(unsafe.Pointer(v)) return p.pdispVal, nil } -func (v *VARIANT) SetPDispVal(value *IDispatch) { +func (v *VARIANT) SetPDispatch(value *IDispatch) { v.Vt = VT_DISPATCH p := (*VAR_PDISP)(unsafe.Pointer(v)) p.pdispVal = value } -func (v *VARIANT) PVarVal() *VARIANT { - value, err := v.GetPVarVal() +func (v *VARIANT) MustPVariant() *VARIANT { + value, err := v.GetPVariant() if err != nil { - log.Fatal(err) + panic(err) } return value } -func (v *VARIANT) GetPVarVal() (*VARIANT, error) { +func (v *VARIANT) GetPVariant() (*VARIANT, error) { if v.Vt != VT_BYREF|VT_VARIANT { - return nil, fmt.Errorf("Error: PVarVal() v.Vt != VT_BYREF|VT_VARIANT, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("Error: GetPVariant() v.Vt != VT_BYREF|VT_VARIANT, ptr=%p, value=%+v", v, v) } p := (*VAR_PVAR)(unsafe.Pointer(v)) return p.pvarVal, nil } -func (v *VARIANT) SetPVarVal(value *VARIANT) { +func (v *VARIANT) SetPVariant(value *VARIANT) { v.Vt = VT_BYREF | VT_VARIANT p := (*VAR_PVAR)(unsafe.Pointer(v)) p.pvarVal = value } -func (v *VARIANT) PBoolVal() *VARIANT_BOOL { - value, err := v.GetPBoolVal() +func (v *VARIANT) MustPBool() *VARIANT_BOOL { + value, err := v.GetPBool() if err != nil { - log.Fatal(err) + panic(err) } return value } -func (v *VARIANT) GetPBoolVal() (*VARIANT_BOOL, error) { +func (v *VARIANT) GetPBool() (*VARIANT_BOOL, error) { if v.Vt != VT_BYREF|VT_BOOL { - return nil, fmt.Errorf("Error: PBoolVal() v.Vt != VT_BYREF|VT_BOOL, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("Error: GetPBool() v.Vt != VT_BYREF|VT_BOOL, ptr=%p, value=%+v", v, v) } p := (*VAR_PBOOL)(unsafe.Pointer(v)) return p.pboolVal, nil } -func (v *VARIANT) SetPBoolVal(value *VARIANT_BOOL) { +func (v *VARIANT) SetPBool(value *VARIANT_BOOL) { v.Vt = VT_BYREF | VT_BOOL p := (*VAR_PBOOL)(unsafe.Pointer(v)) p.pboolVal = value } -func (v *VARIANT) PPDispVal() **IDispatch { - value, err := v.GetPPDispVal() +func (v *VARIANT) MustPPDispatch() **IDispatch { + value, err := v.GetPPDispatch() if err != nil { - log.Fatal(err) + panic(err) } return value } -func (v *VARIANT) GetPPDispVal() (**IDispatch, error) { +func (v *VARIANT) GetPPDispatch() (**IDispatch, error) { if v.Vt != VT_BYREF|VT_DISPATCH { - return nil, fmt.Errorf("PPDispVal() v.Vt != VT_BYREF|VT_DISPATCH, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("GetPPDispatch() v.Vt != VT_BYREF|VT_DISPATCH, ptr=%p, value=%+v", v, v) } p := (*VAR_PPDISP)(unsafe.Pointer(v)) return p.ppdispVal, nil } -func (v *VARIANT) SetPPDispVal(value **IDispatch) { +func (v *VARIANT) SetPPDispatch(value **IDispatch) { v.Vt = VT_BYREF | VT_DISPATCH p := (*VAR_PPDISP)(unsafe.Pointer(v)) p.ppdispVal = value From 7fd4c80abc743dac2b5cef7f172c2163bda4b092 Mon Sep 17 00:00:00 2001 From: ryujimiya Date: Tue, 17 Apr 2018 00:29:29 +0900 Subject: [PATCH 062/138] rename VARIANT methods: e.g. GetLong -> Long --- oleaut32.go | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/oleaut32.go b/oleaut32.go index f50333f2..6a184a6f 100644 --- a/oleaut32.go +++ b/oleaut32.go @@ -198,16 +198,16 @@ func VariantBSTRToString(value *VAR_BSTR) string { } func (v *VARIANT) MustLong() int32 { - value, err := v.GetLong() + value, err := v.Long() if err != nil { panic(err) } return value } -func (v *VARIANT) GetLong() (int32, error) { +func (v *VARIANT) Long() (int32, error) { if v.Vt != VT_I4 { - return 0, fmt.Errorf("Error: GetLong() v.Vt != VT_I4, ptr=%p, value=%+v", v, v) + return 0, fmt.Errorf("Error: Long() v.Vt != VT_I4, ptr=%p, value=%+v", v, v) } p := (*VAR_I4)(unsafe.Pointer(v)) return p.lVal, nil @@ -220,16 +220,16 @@ func (v *VARIANT) SetLong(value int32) { } func (v *VARIANT) MustULong() uint32 { - value, err := v.GetULong() + value, err := v.ULong() if err != nil { panic(err) } return value } -func (v *VARIANT) GetULong() (uint32, error) { +func (v *VARIANT) ULong() (uint32, error) { if v.Vt != VT_UI4 { - return 0, fmt.Errorf("Error: GetULong() v.Vt != VT_UI4, ptr=%p, value=%+v", v, v) + return 0, fmt.Errorf("Error: ULong() v.Vt != VT_UI4, ptr=%p, value=%+v", v, v) } p := (*VAR_UI4)(unsafe.Pointer(v)) return p.ulVal, nil @@ -242,16 +242,16 @@ func (v *VARIANT) SetULong(value uint32) { } func (v *VARIANT) MustBool() VARIANT_BOOL { - value, err := v.GetBool() + value, err := v.Bool() if err != nil { panic(err) } return value } -func (v *VARIANT) GetBool() (VARIANT_BOOL, error) { +func (v *VARIANT) Bool() (VARIANT_BOOL, error) { if v.Vt != VT_BOOL { - return VARIANT_FALSE, fmt.Errorf("Error: GetBool() v.Vt != VT_BOOL, ptr=%p, value=%+v", v, v) + return VARIANT_FALSE, fmt.Errorf("Error: Bool() v.Vt != VT_BOOL, ptr=%p, value=%+v", v, v) } p := (*VAR_BOOL)(unsafe.Pointer(v)) return p.boolVal, nil @@ -264,16 +264,16 @@ func (v *VARIANT) SetBool(value VARIANT_BOOL) { } func (v *VARIANT) MustBSTR() *uint16 { - value, err := v.GetBSTR() + value, err := v.BSTR() if err != nil { panic(err) } return value } -func (v *VARIANT) GetBSTR() (*uint16, error) { +func (v *VARIANT) BSTR() (*uint16, error) { if v.Vt != VT_BSTR { - return nil, fmt.Errorf("Error: GetBSTR() v.Vt != VT_BSTR, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("Error: BSTR() v.Vt != VT_BSTR, ptr=%p, value=%+v", v, v) } p := (*VAR_BSTR)(unsafe.Pointer(v)) return p.bstrVal, nil @@ -286,16 +286,16 @@ func (v *VARIANT) SetBSTR(value *uint16) { } func (v *VARIANT) MustPDispatch() *IDispatch { - value, err := v.GetPDispatch() + value, err := v.PDispatch() if err != nil { panic(err) } return value } -func (v *VARIANT) GetPDispatch() (*IDispatch, error) { +func (v *VARIANT) PDispatch() (*IDispatch, error) { if v.Vt != VT_DISPATCH { - return nil, fmt.Errorf("Error: GetPDispatch() v.Vt != VT_DISPATCH, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("Error: PDispatch() v.Vt != VT_DISPATCH, ptr=%p, value=%+v", v, v) } p := (*VAR_PDISP)(unsafe.Pointer(v)) return p.pdispVal, nil @@ -308,16 +308,16 @@ func (v *VARIANT) SetPDispatch(value *IDispatch) { } func (v *VARIANT) MustPVariant() *VARIANT { - value, err := v.GetPVariant() + value, err := v.PVariant() if err != nil { panic(err) } return value } -func (v *VARIANT) GetPVariant() (*VARIANT, error) { +func (v *VARIANT) PVariant() (*VARIANT, error) { if v.Vt != VT_BYREF|VT_VARIANT { - return nil, fmt.Errorf("Error: GetPVariant() v.Vt != VT_BYREF|VT_VARIANT, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("Error: PVariant() v.Vt != VT_BYREF|VT_VARIANT, ptr=%p, value=%+v", v, v) } p := (*VAR_PVAR)(unsafe.Pointer(v)) return p.pvarVal, nil @@ -330,16 +330,16 @@ func (v *VARIANT) SetPVariant(value *VARIANT) { } func (v *VARIANT) MustPBool() *VARIANT_BOOL { - value, err := v.GetPBool() + value, err := v.PBool() if err != nil { panic(err) } return value } -func (v *VARIANT) GetPBool() (*VARIANT_BOOL, error) { +func (v *VARIANT) PBool() (*VARIANT_BOOL, error) { if v.Vt != VT_BYREF|VT_BOOL { - return nil, fmt.Errorf("Error: GetPBool() v.Vt != VT_BYREF|VT_BOOL, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("Error: PBool() v.Vt != VT_BYREF|VT_BOOL, ptr=%p, value=%+v", v, v) } p := (*VAR_PBOOL)(unsafe.Pointer(v)) return p.pboolVal, nil @@ -352,16 +352,16 @@ func (v *VARIANT) SetPBool(value *VARIANT_BOOL) { } func (v *VARIANT) MustPPDispatch() **IDispatch { - value, err := v.GetPPDispatch() + value, err := v.PPDispatch() if err != nil { panic(err) } return value } -func (v *VARIANT) GetPPDispatch() (**IDispatch, error) { +func (v *VARIANT) PPDispatch() (**IDispatch, error) { if v.Vt != VT_BYREF|VT_DISPATCH { - return nil, fmt.Errorf("GetPPDispatch() v.Vt != VT_BYREF|VT_DISPATCH, ptr=%p, value=%+v", v, v) + return nil, fmt.Errorf("PPDispatch() v.Vt != VT_BYREF|VT_DISPATCH, ptr=%p, value=%+v", v, v) } p := (*VAR_PPDISP)(unsafe.Pointer(v)) return p.ppdispVal, nil From d66bec92f335fda50a0ecfaecffaf36b149ca30c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 17 Apr 2018 15:12:48 +0200 Subject: [PATCH 063/138] oleaut32: Fix constant for 32 bit --- oleaut32.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oleaut32.go b/oleaut32.go index 6a184a6f..77037ba7 100644 --- a/oleaut32.go +++ b/oleaut32.go @@ -68,7 +68,7 @@ const ( ) const ( - CSC_UPDATECOMMANDS = int(0xFFFFFFFF) + CSC_UPDATECOMMANDS = ^0x0 CSC_NAVIGATEFORWARD = 0x1 CSC_NAVIGATEBACK = 0x2 ) From dbd1ff5530444438a4426f4e906d488ae6df34fc Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 23 Apr 2018 17:22:32 +0200 Subject: [PATCH 064/138] Add some gdi32 stuff --- gdi32.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/gdi32.go b/gdi32.go index 23bcd7a5..f438853d 100644 --- a/gdi32.go +++ b/gdi32.go @@ -753,6 +753,12 @@ const ( AC_SRC_ALPHA = 0x1 ) +// AddFontResourceEx flags +const ( + FR_PRIVATE = 0x10 + FR_NOT_ENUM = 0x20 +) + type ( COLORREF uint32 HBITMAP HGDIOBJ @@ -1027,6 +1033,7 @@ var ( // Functions abortDoc uintptr + addFontResourceEx uintptr alphaBlend uintptr bitBlt uintptr choosePixelFormat uintptr @@ -1054,6 +1061,7 @@ var ( extCreatePen uintptr fillRgn uintptr gdiFlush uintptr + getBkColor uintptr getDeviceCaps uintptr getDIBits uintptr getEnhMetaFile uintptr @@ -1062,6 +1070,7 @@ var ( getPixel uintptr getRgnBox uintptr getStockObject uintptr + getTextColor uintptr getTextExtentExPoint uintptr getTextExtentPoint32 uintptr getTextMetrics uintptr @@ -1073,6 +1082,7 @@ var ( playEnhMetaFile uintptr polyline uintptr rectangle uintptr + removeFontResourceEx uintptr resetDC uintptr restoreDC uintptr roundRect uintptr @@ -1102,6 +1112,7 @@ func init() { // Functions abortDoc = MustGetProcAddress(libgdi32, "AbortDoc") + addFontResourceEx = MustGetProcAddress(libgdi32, "AddFontResourceExW") bitBlt = MustGetProcAddress(libgdi32, "BitBlt") choosePixelFormat = MustGetProcAddress(libgdi32, "ChoosePixelFormat") closeEnhMetaFile = MustGetProcAddress(libgdi32, "CloseEnhMetaFile") @@ -1128,6 +1139,7 @@ func init() { extCreatePen = MustGetProcAddress(libgdi32, "ExtCreatePen") fillRgn = MustGetProcAddress(libgdi32, "FillRgn") gdiFlush = MustGetProcAddress(libgdi32, "GdiFlush") + getBkColor = MustGetProcAddress(libgdi32, "GetBkColor") getDeviceCaps = MustGetProcAddress(libgdi32, "GetDeviceCaps") getDIBits = MustGetProcAddress(libgdi32, "GetDIBits") getEnhMetaFile = MustGetProcAddress(libgdi32, "GetEnhMetaFileW") @@ -1136,6 +1148,7 @@ func init() { getPixel = MustGetProcAddress(libgdi32, "GetPixel") getRgnBox = MustGetProcAddress(libgdi32, "GetRgnBox") getStockObject = MustGetProcAddress(libgdi32, "GetStockObject") + getTextColor = MustGetProcAddress(libgdi32, "GetTextColor") getTextExtentExPoint = MustGetProcAddress(libgdi32, "GetTextExtentExPointW") getTextExtentPoint32 = MustGetProcAddress(libgdi32, "GetTextExtentPoint32W") getTextMetrics = MustGetProcAddress(libgdi32, "GetTextMetricsW") @@ -1146,6 +1159,7 @@ func init() { playEnhMetaFile = MustGetProcAddress(libgdi32, "PlayEnhMetaFile") polyline = MustGetProcAddress(libgdi32, "Polyline") rectangle = MustGetProcAddress(libgdi32, "Rectangle") + removeFontResourceEx = MustGetProcAddress(libgdi32, "RemoveFontResourceExW") resetDC = MustGetProcAddress(libgdi32, "ResetDCW") restoreDC = MustGetProcAddress(libgdi32, "RestoreDC") roundRect = MustGetProcAddress(libgdi32, "RoundRect") @@ -1180,6 +1194,15 @@ func AbortDoc(hdc HDC) int32 { return int32(ret) } +func AddFontResourceEx(lpszFilename *uint16, fl uint32, pdv unsafe.Pointer) int32 { + ret, _, _ := syscall.Syscall(addFontResourceEx, 3, + uintptr(unsafe.Pointer(lpszFilename)), + uintptr(fl), + uintptr(pdv)) + + return int32(ret) +} + func AlphaBlend(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int32, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int32, ftn BLENDFUNCTION) bool { ret, _, _ := syscall.Syscall12(alphaBlend, 11, uintptr(hdcDest), @@ -1468,6 +1491,15 @@ func GdiFlush() bool { return ret != 0 } +func GetBkColor(hdc HDC) COLORREF { + ret, _, _ := syscall.Syscall(getBkColor, 1, + uintptr(hdc), + 0, + 0) + + return COLORREF(ret) +} + func GetDeviceCaps(hdc HDC, nIndex int32) int32 { ret, _, _ := syscall.Syscall(getDeviceCaps, 2, uintptr(hdc), @@ -1545,6 +1577,15 @@ func GetStockObject(fnObject int32) HGDIOBJ { return HGDIOBJ(ret) } +func GetTextColor(hdc HDC) COLORREF { + ret, _, _ := syscall.Syscall(getTextColor, 1, + uintptr(hdc), + 0, + 0) + + return COLORREF(ret) +} + func GetTextExtentExPoint(hdc HDC, lpszStr *uint16, cchString, nMaxExtent int32, lpnFit, alpDx *int32, lpSize *SIZE) bool { ret, _, _ := syscall.Syscall9(getTextExtentExPoint, 7, uintptr(hdc), @@ -1665,6 +1706,15 @@ func Rectangle_(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) boo return ret != 0 } +func RemoveFontResourceEx(lpszFilename *uint16, fl uint32, pdv unsafe.Pointer) bool { + ret, _, _ := syscall.Syscall(removeFontResourceEx, 3, + uintptr(unsafe.Pointer(lpszFilename)), + uintptr(fl), + uintptr(pdv)) + + return ret != 0 +} + func ResetDC(hdc HDC, lpInitData *DEVMODE) HDC { ret, _, _ := syscall.Syscall(resetDC, 2, uintptr(hdc), From 822cdfe5c4a5d728198a8ae8a3251043073454ba Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 23 Apr 2018 17:22:51 +0200 Subject: [PATCH 065/138] Add HDLAYOUT --- header.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/header.go b/header.go index 7465d570..7f675052 100644 --- a/header.go +++ b/header.go @@ -24,6 +24,11 @@ type HDITEM struct { PvFilter uintptr } +type HDLAYOUT struct { + Prc *RECT + Pwpos *WINDOWPOS +} + const ( HDI_WIDTH = 0x0001 HDI_HEIGHT = HDI_WIDTH From 4186f96d2a55e408edcc2b65499118ead6667a32 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 23 Apr 2018 17:23:12 +0200 Subject: [PATCH 066/138] Add WINDOWPOS --- user32.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/user32.go b/user32.go index 3207c068..30b4449e 100644 --- a/user32.go +++ b/user32.go @@ -1523,6 +1523,16 @@ type SCROLLINFO struct { NTrackPos int32 } +type WINDOWPOS struct { + Hwnd HWND + HwndInsertAfter HWND + X int32 + Y int32 + Cx int32 + Cy int32 + Flags uint32 +} + func GET_X_LPARAM(lp uintptr) int32 { return int32(int16(LOWORD(uint32(lp)))) } From 3906055cf471aee3f5300e1e9c474dea14ffb7d8 Mon Sep 17 00:00:00 2001 From: ryujimiya Date: Fri, 27 Apr 2018 19:23:25 +0900 Subject: [PATCH 067/138] SAFEARRAY is added --- oleaut32.go | 36 ++++++++++++++++++++++++++++++++++++ oleaut32_386.go | 7 +++++++ oleaut32_amd64.go | 7 +++++++ 3 files changed, 50 insertions(+) diff --git a/oleaut32.go b/oleaut32.go index 77037ba7..9d0e0167 100644 --- a/oleaut32.go +++ b/oleaut32.go @@ -155,6 +155,20 @@ const ( VARIANT_FALSE VARIANT_BOOL = 0 ) +type SAFEARRAYBOUND struct { + CElements uint32 + LLbound int32 +} + +type SAFEARRAY struct { + CDims uint16 + FFeatures uint16 + CbElements uint32 + CLocks uint32 + PvData uintptr + Rgsabound [1]SAFEARRAYBOUND +} + //type BSTR *uint16 func StringToBSTR(value string) *uint16 /*BSTR*/ { @@ -373,6 +387,28 @@ func (v *VARIANT) SetPPDispatch(value **IDispatch) { p.ppdispVal = value } +func (v *VARIANT) MustPSafeArray() *SAFEARRAY { + value, err := v.PSafeArray() + if err != nil { + panic(err) + } + return value +} + +func (v *VARIANT) PSafeArray() (*SAFEARRAY, error) { + if (v.Vt & VT_ARRAY) != VT_ARRAY { + return nil, fmt.Errorf("Error: PSafeArray() (v.Vt & VT_ARRAY) != VT_ARRAY, ptr=%p, value=%+v", v, v) + } + p := (*VAR_PSAFEARRAY)(unsafe.Pointer(v)) + return p.parray, nil +} + +func (v *VARIANT) SetPSafeArray(value *SAFEARRAY, elementVt VARTYPE) { + v.Vt = VT_ARRAY | elementVt + p := (*VAR_PSAFEARRAY)(unsafe.Pointer(v)) + p.parray = value +} + type DISPPARAMS struct { Rgvarg *VARIANTARG RgdispidNamedArgs *DISPID diff --git a/oleaut32_386.go b/oleaut32_386.go index 64a43590..5f3ce1f1 100644 --- a/oleaut32_386.go +++ b/oleaut32_386.go @@ -46,6 +46,13 @@ type VAR_PDISP struct { reserved2 [4]byte } +type VAR_PSAFEARRAY struct { + vt VARTYPE + reserved1 [6]byte + parray *SAFEARRAY + reserved2 [4]byte +} + type VAR_PVAR struct { vt VARTYPE reserved1 [6]byte diff --git a/oleaut32_amd64.go b/oleaut32_amd64.go index 65021720..331a5504 100644 --- a/oleaut32_amd64.go +++ b/oleaut32_amd64.go @@ -46,6 +46,13 @@ type VAR_PDISP struct { reserved2 [8]byte } +type VAR_PSAFEARRAY struct { + vt VARTYPE + reserved1 [6]byte + parray *SAFEARRAY + reserved2 [8]byte +} + type VAR_PVAR struct { vt VARTYPE reserved1 [6]byte From 940d4d7d7c2cc3a178d88b158b8cac90461a4191 Mon Sep 17 00:00:00 2001 From: Tiago Carvalho Date: Fri, 13 Jul 2018 00:35:02 +0000 Subject: [PATCH 068/138] added GetDesktopWindow() --- user32.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/user32.go b/user32.go index 30b4449e..98462853 100644 --- a/user32.go +++ b/user32.go @@ -1583,6 +1583,7 @@ var ( getClientRect uintptr getClipboardData uintptr getCursorPos uintptr + getDesktopWindow uintptr getDC uintptr getFocus uintptr getForegroundWindow uintptr @@ -1704,6 +1705,7 @@ func init() { getClientRect = MustGetProcAddress(libuser32, "GetClientRect") getClipboardData = MustGetProcAddress(libuser32, "GetClipboardData") getCursorPos = MustGetProcAddress(libuser32, "GetCursorPos") + getDesktopWindow = MustGetProcAddress(libuser32, "GetDesktopWindow") getDC = MustGetProcAddress(libuser32, "GetDC") getFocus = MustGetProcAddress(libuser32, "GetFocus") getForegroundWindow = MustGetProcAddress(libuser32, "GetForegroundWindow") @@ -2165,6 +2167,15 @@ func GetCursorPos(lpPoint *POINT) bool { return ret != 0 } +func GetDesktopWindow() HWND { + ret, _, _ := syscall.Syscall(getDesktopWindow, 0, + 0, + 0, + 0) + + return HWND(ret) +} + func GetDC(hWnd HWND) HDC { ret, _, _ := syscall.Syscall(getDC, 1, uintptr(hWnd), From 4fd9dd785bcf00e84abaa71cef89213d07e05034 Mon Sep 17 00:00:00 2001 From: Lars Date: Mon, 20 Aug 2018 12:41:03 +0200 Subject: [PATCH 069/138] Add CreateActCtx and ActivateActCtx --- kernel32.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/kernel32.go b/kernel32.go index 2baacf62..176fdb07 100644 --- a/kernel32.go +++ b/kernel32.go @@ -79,6 +79,8 @@ var ( mulDiv uintptr setLastError uintptr systemTimeToFileTime uintptr + createActCtx uintptr + activateActCtx uintptr ) type ( @@ -89,6 +91,7 @@ type ( LCID uint32 LCTYPE uint32 LANGID uint16 + HMODULE uintptr ) type FILETIME struct { @@ -116,6 +119,18 @@ type SYSTEMTIME struct { WMilliseconds uint16 } +type ACTCTX struct { + size uint32 + Flags uint32 + Source *uint16 // UTF-16 string + ProcessorArchitecture uint16 + LangID uint16 + AssemblyDirectory *uint16 // UTF-16 string + ResourceName *uint16 // UTF-16 string + ApplicationName *uint16 // UTF-16 string + Module HMODULE +} + func init() { // Library libkernel32 = MustLoadLibrary("kernel32.dll") @@ -143,6 +158,8 @@ func init() { mulDiv = MustGetProcAddress(libkernel32, "MulDiv") setLastError = MustGetProcAddress(libkernel32, "SetLastError") systemTimeToFileTime = MustGetProcAddress(libkernel32, "SystemTimeToFileTime") + createActCtx = MustGetProcAddress(libkernel32, "CreateActCtxW") + activateActCtx = MustGetProcAddress(libkernel32, "ActivateActCtx") } func CloseHandle(hObject HANDLE) bool { @@ -349,3 +366,25 @@ func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { return ret != 0 } + +func ActivateActCtx(ctx HANDLE) (uintptr, bool) { + var cookie uintptr + ret, _, _ := syscall.Syscall(activateActCtx, 2, + uintptr(ctx), + uintptr(unsafe.Pointer(&cookie)), + 0) + return cookie, ret != 0 +} + +func CreateActCtx(ctx *ACTCTX) HANDLE { + if ctx != nil { + ctx.size = uint32(unsafe.Sizeof(*ctx)) + } + ret, _, _ := syscall.Syscall( + createActCtx, + 1, + uintptr(unsafe.Pointer(ctx)), + 0, + 0) + return HANDLE(ret) +} From 31b28bccf43b78a10887bde803b4c462140b6861 Mon Sep 17 00:00:00 2001 From: gonutz Date: Mon, 20 Aug 2018 23:44:23 +0200 Subject: [PATCH 070/138] Add gonutz to AUTHORS and sort functions by name --- AUTHORS | 1 + kernel32.go | 52 ++++++++++++++++++++++++++-------------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/AUTHORS b/AUTHORS index c7390509..d20d899d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -25,3 +25,4 @@ ktye mycaosf ryujimiya wsf01 +gonutz diff --git a/kernel32.go b/kernel32.go index 176fdb07..33c9c364 100644 --- a/kernel32.go +++ b/kernel32.go @@ -57,7 +57,9 @@ var ( libkernel32 uintptr // Functions + activateActCtx uintptr closeHandle uintptr + createActCtx uintptr fileTimeToSystemTime uintptr getConsoleTitle uintptr getConsoleWindow uintptr @@ -79,8 +81,6 @@ var ( mulDiv uintptr setLastError uintptr systemTimeToFileTime uintptr - createActCtx uintptr - activateActCtx uintptr ) type ( @@ -136,7 +136,9 @@ func init() { libkernel32 = MustLoadLibrary("kernel32.dll") // Functions + activateActCtx = MustGetProcAddress(libkernel32, "ActivateActCtx") closeHandle = MustGetProcAddress(libkernel32, "CloseHandle") + createActCtx = MustGetProcAddress(libkernel32, "CreateActCtxW") fileTimeToSystemTime = MustGetProcAddress(libkernel32, "FileTimeToSystemTime") getConsoleTitle = MustGetProcAddress(libkernel32, "GetConsoleTitleW") getConsoleWindow = MustGetProcAddress(libkernel32, "GetConsoleWindow") @@ -158,8 +160,15 @@ func init() { mulDiv = MustGetProcAddress(libkernel32, "MulDiv") setLastError = MustGetProcAddress(libkernel32, "SetLastError") systemTimeToFileTime = MustGetProcAddress(libkernel32, "SystemTimeToFileTime") - createActCtx = MustGetProcAddress(libkernel32, "CreateActCtxW") - activateActCtx = MustGetProcAddress(libkernel32, "ActivateActCtx") +} + +func ActivateActCtx(ctx HANDLE) (uintptr, bool) { + var cookie uintptr + ret, _, _ := syscall.Syscall(activateActCtx, 2, + uintptr(ctx), + uintptr(unsafe.Pointer(&cookie)), + 0) + return cookie, ret != 0 } func CloseHandle(hObject HANDLE) bool { @@ -171,6 +180,19 @@ func CloseHandle(hObject HANDLE) bool { return ret != 0 } +func CreateActCtx(ctx *ACTCTX) HANDLE { + if ctx != nil { + ctx.size = uint32(unsafe.Sizeof(*ctx)) + } + ret, _, _ := syscall.Syscall( + createActCtx, + 1, + uintptr(unsafe.Pointer(ctx)), + 0, + 0) + return HANDLE(ret) +} + func FileTimeToSystemTime(lpFileTime *FILETIME, lpSystemTime *SYSTEMTIME) bool { ret, _, _ := syscall.Syscall(fileTimeToSystemTime, 2, uintptr(unsafe.Pointer(lpFileTime)), @@ -366,25 +388,3 @@ func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { return ret != 0 } - -func ActivateActCtx(ctx HANDLE) (uintptr, bool) { - var cookie uintptr - ret, _, _ := syscall.Syscall(activateActCtx, 2, - uintptr(ctx), - uintptr(unsafe.Pointer(&cookie)), - 0) - return cookie, ret != 0 -} - -func CreateActCtx(ctx *ACTCTX) HANDLE { - if ctx != nil { - ctx.size = uint32(unsafe.Sizeof(*ctx)) - } - ret, _, _ := syscall.Syscall( - createActCtx, - 1, - uintptr(unsafe.Pointer(ctx)), - 0, - 0) - return HANDLE(ret) -} From 623526aecd983d86925ed711c723e8ab8da1f74c Mon Sep 17 00:00:00 2001 From: Cory Ory Date: Wed, 19 Sep 2018 01:18:00 +0100 Subject: [PATCH 071/138] Proper custom color handling https://docs.microsoft.com/en-gb/windows/desktop/api/commdlg/ns-commdlg-tagchoosecolora The Microsoft documentation says that type `LpCustColors` is as follows: >A pointer to an array of 16 values that contain red, green, blue (RGB) values for the custom color boxes in the dialog box. If the user modifies these colors, the system updates the array with the new RGB values. --- comdlg32.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comdlg32.go b/comdlg32.go index 56c55647..6ba9d050 100644 --- a/comdlg32.go +++ b/comdlg32.go @@ -46,7 +46,7 @@ type CHOOSECOLOR struct { HwndOwner HWND HInstance HWND RgbResult COLORREF - LpCustColors *COLORREF + LpCustColors *[16]COLORREF Flags uint32 LCustData uintptr LpfnHook uintptr From b5bcf2629aa84252c1088566f4ad9a5f0b89f1af Mon Sep 17 00:00:00 2001 From: sugoiuguu Date: Wed, 10 Oct 2018 20:30:06 +0100 Subject: [PATCH 072/138] Updated GetDesktopWindow() pos, added myself to AUTHORS --- AUTHORS | 1 + user32.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index c7390509..e8e235cd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -25,3 +25,4 @@ ktye mycaosf ryujimiya wsf01 +Tiago Carvalho diff --git a/user32.go b/user32.go index 98462853..5d21dae9 100644 --- a/user32.go +++ b/user32.go @@ -1583,8 +1583,8 @@ var ( getClientRect uintptr getClipboardData uintptr getCursorPos uintptr - getDesktopWindow uintptr getDC uintptr + getDesktopWindow uintptr getFocus uintptr getForegroundWindow uintptr getKeyState uintptr @@ -1705,8 +1705,8 @@ func init() { getClientRect = MustGetProcAddress(libuser32, "GetClientRect") getClipboardData = MustGetProcAddress(libuser32, "GetClipboardData") getCursorPos = MustGetProcAddress(libuser32, "GetCursorPos") - getDesktopWindow = MustGetProcAddress(libuser32, "GetDesktopWindow") getDC = MustGetProcAddress(libuser32, "GetDC") + getDesktopWindow = MustGetProcAddress(libuser32, "GetDesktopWindow") getFocus = MustGetProcAddress(libuser32, "GetFocus") getForegroundWindow = MustGetProcAddress(libuser32, "GetForegroundWindow") getKeyState = MustGetProcAddress(libuser32, "GetKeyState") From 05ef07831fd319560a34d05df9d3cbd0d74ad1e5 Mon Sep 17 00:00:00 2001 From: Cory Ory Date: Sat, 13 Oct 2018 18:11:14 +0100 Subject: [PATCH 073/138] Add myself (Cory Redmond) to authors. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index d20d899d..acecbe81 100644 --- a/AUTHORS +++ b/AUTHORS @@ -26,3 +26,4 @@ mycaosf ryujimiya wsf01 gonutz +Cory Redmond From 6d5520624b7b4487185429fa5b26e48951f3ad56 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 25 Feb 2019 16:35:02 +0100 Subject: [PATCH 074/138] Add CheckMenuRadioItem --- user32.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/user32.go b/user32.go index 5d21dae9..2ab3700f 100644 --- a/user32.go +++ b/user32.go @@ -1552,6 +1552,7 @@ var ( beginDeferWindowPos uintptr beginPaint uintptr callWindowProc uintptr + checkMenuRadioItem uintptr clientToScreen uintptr closeClipboard uintptr createDialogParam uintptr @@ -1674,6 +1675,7 @@ func init() { beginDeferWindowPos = MustGetProcAddress(libuser32, "BeginDeferWindowPos") beginPaint = MustGetProcAddress(libuser32, "BeginPaint") callWindowProc = MustGetProcAddress(libuser32, "CallWindowProcW") + checkMenuRadioItem = MustGetProcAddress(libuser32, "CheckMenuRadioItem") clientToScreen = MustGetProcAddress(libuser32, "ClientToScreen") closeClipboard = MustGetProcAddress(libuser32, "CloseClipboard") createDialogParam = MustGetProcAddress(libuser32, "CreateDialogParamW") @@ -1854,6 +1856,18 @@ func CallWindowProc(lpPrevWndFunc uintptr, hWnd HWND, Msg uint32, wParam, lParam return ret } +func CheckMenuRadioItem(hmenu HMENU, first, last, check, flags uint32) bool { + ret, _, _ := syscall.Syscall6(checkMenuRadioItem, 5, + uintptr(hmenu), + uintptr(first), + uintptr(last), + uintptr(check), + uintptr(flags), + 0) + + return ret != 0 +} + func ClientToScreen(hwnd HWND, lpPoint *POINT) bool { ret, _, _ := syscall.Syscall(clientToScreen, 2, uintptr(hwnd), From dc7d9e9d1edd743c106d145b33e4a94f101413bf Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 25 Feb 2019 21:04:40 +0100 Subject: [PATCH 075/138] user32: Support hooking window events and querying class names --- kernel32.go | 17 +++++----- user32.go | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 8 deletions(-) diff --git a/kernel32.go b/kernel32.go index 33c9c364..dba014d8 100644 --- a/kernel32.go +++ b/kernel32.go @@ -84,14 +84,15 @@ var ( ) type ( - ATOM uint16 - HANDLE uintptr - HGLOBAL HANDLE - HINSTANCE HANDLE - LCID uint32 - LCTYPE uint32 - LANGID uint16 - HMODULE uintptr + ATOM uint16 + HANDLE uintptr + HGLOBAL HANDLE + HINSTANCE HANDLE + LCID uint32 + LCTYPE uint32 + LANGID uint16 + HMODULE uintptr + HWINEVENTHOOK HANDLE ) type FILETIME struct { diff --git a/user32.go b/user32.go index 2ab3700f..550f16bb 100644 --- a/user32.go +++ b/user32.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -875,6 +876,54 @@ const ( WM_CLIPBOARDUPDATE = 0x031D ) +// event constants +const ( + EVENT_OBJECT_CREATE = 0x8000 + EVENT_OBJECT_DESTROY = 0x8001 + EVENT_OBJECT_SHOW = 0x8002 + EVENT_OBJECT_HIDE = 0x8003 + EVENT_OBJECT_REORDER = 0x8004 + EVENT_OBJECT_FOCUS = 0x8005 + EVENT_OBJECT_SELECTION = 0x8006 + EVENT_OBJECT_SELECTIONADD = 0x8007 + EVENT_OBJECT_SELECTIONREMOVE = 0x8008 + EVENT_OBJECT_SELECTIONWITHIN = 0x8009 + EVENT_OBJECT_STATECHANGE = 0x800A + EVENT_OBJECT_LOCATIONCHANGE = 0x800B + EVENT_OBJECT_NAMECHANGE = 0x800C + EVENT_OBJECT_DESCRIPTIONCHANGE = 0x800D + EVENT_OBJECT_VALUECHANGE = 0x800E + EVENT_OBJECT_PARENTCHANGE = 0x800F + EVENT_OBJECT_HELPCHANGE = 0x8010 + EVENT_OBJECT_DEFACTIONCHANGE = 0x8011 + EVENT_OBJECT_ACCELERATORCHANGE = 0x8012 + EVENT_OBJECT_INVOKED = 0x8013 + EVENT_OBJECT_TEXTSELECTIONCHANGED = 0x8014 + EVENT_OBJECT_CONTENTSCROLLED = 0x8015 + EVENT_SYSTEM_ARRANGMENTPREVIEW = 0x8016 + EVENT_OBJECT_CLOAKED = 0x8017 + EVENT_OBJECT_UNCLOAKED = 0x8018 + EVENT_OBJECT_LIVEREGIONCHANGED = 0x8019 + EVENT_OBJECT_HOSTEDOBJECTSINVALIDATED = 0x8020 + EVENT_OBJECT_DRAGSTART = 0x8021 + EVENT_OBJECT_DRAGCANCEL = 0x8022 + EVENT_OBJECT_DRAGCOMPLETE = 0x8023 + EVENT_OBJECT_DRAGENTER = 0x8024 + EVENT_OBJECT_DRAGLEAVE = 0x8025 + EVENT_OBJECT_DRAGDROPPED = 0x8026 + EVENT_OBJECT_IME_SHOW = 0x8027 + EVENT_OBJECT_IME_HIDE = 0x8028 + EVENT_OBJECT_IME_CHANGE = 0x8029 + EVENT_OBJECT_END = 0x80ff + EVENT_AIA_START = 0xa000 + EVENT_AIA_END = 0xafff + + WINEVENT_OUTOFCONTEXT = 0x0000 + WINEVENT_SKIPOWNTHREAD = 0x0001 + WINEVENT_SKIPOWNPROCESS = 0x0002 + WINEVENT_INCONTEXT = 0x0004 +) + // mouse button constants const ( MK_CONTROL = 0x0008 @@ -1581,6 +1630,7 @@ var ( getActiveWindow uintptr getAncestor uintptr getCaretPos uintptr + getClassName uintptr getClientRect uintptr getClipboardData uintptr getCursorPos uintptr @@ -1649,6 +1699,7 @@ var ( setRect uintptr setScrollInfo uintptr setTimer uintptr + setWinEventHook uintptr setWindowLong uintptr setWindowLongPtr uintptr setWindowPlacement uintptr @@ -1657,6 +1708,7 @@ var ( systemParametersInfo uintptr trackPopupMenuEx uintptr translateMessage uintptr + unhookWinEvent uintptr updateWindow uintptr windowFromDC uintptr windowFromPoint uintptr @@ -1704,6 +1756,7 @@ func init() { getActiveWindow = MustGetProcAddress(libuser32, "GetActiveWindow") getAncestor = MustGetProcAddress(libuser32, "GetAncestor") getCaretPos = MustGetProcAddress(libuser32, "GetCaretPos") + getClassName = MustGetProcAddress(libuser32, "GetClassNameW") getClientRect = MustGetProcAddress(libuser32, "GetClientRect") getClipboardData = MustGetProcAddress(libuser32, "GetClipboardData") getCursorPos = MustGetProcAddress(libuser32, "GetCursorPos") @@ -1777,6 +1830,7 @@ func init() { setParent = MustGetProcAddress(libuser32, "SetParent") setScrollInfo = MustGetProcAddress(libuser32, "SetScrollInfo") setTimer = MustGetProcAddress(libuser32, "SetTimer") + setWinEventHook = MustGetProcAddress(libuser32, "SetWinEventHook") setWindowLong = MustGetProcAddress(libuser32, "SetWindowLongW") // On 32 bit SetWindowLongPtrW is not available if is64bit { @@ -1790,6 +1844,7 @@ func init() { systemParametersInfo = MustGetProcAddress(libuser32, "SystemParametersInfoW") trackPopupMenuEx = MustGetProcAddress(libuser32, "TrackPopupMenuEx") translateMessage = MustGetProcAddress(libuser32, "TranslateMessage") + unhookWinEvent = MustGetProcAddress(libuser32, "UnhookWinEvent") updateWindow = MustGetProcAddress(libuser32, "UpdateWindow") windowFromDC = MustGetProcAddress(libuser32, "WindowFromDC") windowFromPoint = MustGetProcAddress(libuser32, "WindowFromPoint") @@ -2154,6 +2209,17 @@ func GetCaretPos(lpPoint *POINT) bool { return ret != 0 } +func GetClassName(hWnd HWND, className *uint16, maxCount int) (int, error) { + ret, _, e := syscall.Syscall(getClassName, 3, + uintptr(hWnd), + uintptr(unsafe.Pointer(className)), + uintptr(maxCount)) + if ret == 0 { + return 0, e + } + return int(ret), nil +} + func GetClientRect(hWnd HWND, rect *RECT) bool { ret, _, _ := syscall.Syscall(getClientRect, 2, uintptr(hWnd), @@ -2824,6 +2890,26 @@ func SetTimer(hWnd HWND, nIDEvent uintptr, uElapse uint32, lpTimerFunc uintptr) return ret } +type WINEVENTPROC func(hWinEventHook HWINEVENTHOOK, event uint32, hwnd HWND, idObject int32, idChild int32, idEventThread uint32, dwmsEventTime uint32) uintptr + +func SetWinEventHook(eventMin uint32, eventMax uint32, hmodWinEventProc HMODULE, callbackFunction WINEVENTPROC, idProcess uint32, idThread uint32, dwFlags uint32) (HWINEVENTHOOK, error) { + ret, _, err := syscall.Syscall9(setWinEventHook, 7, + uintptr(eventMin), + uintptr(eventMax), + uintptr(hmodWinEventProc), + windows.NewCallback(callbackFunction), + uintptr(idProcess), + uintptr(idThread), + uintptr(dwFlags), + 0, 0) + + if ret == 0 { + return 0, err + } + + return HWINEVENTHOOK(ret), nil +} + func SetWindowLong(hWnd HWND, index, value int32) int32 { ret, _, _ := syscall.Syscall(setWindowLong, 3, uintptr(hWnd), @@ -2908,6 +2994,11 @@ func TranslateMessage(msg *MSG) bool { return ret != 0 } +func UnhookWinEvent(hWinHookEvent HWINEVENTHOOK) bool { + ret, _, _ := syscall.Syscall(unhookWinEvent, 1, uintptr(hWinHookEvent), 0, 0) + return ret != 0 +} + func UpdateWindow(hwnd HWND) bool { ret, _, _ := syscall.Syscall(updateWindow, 1, uintptr(hwnd), From 089c0f59b5ffafb061798e25f0a74b6188892200 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 25 Feb 2019 21:05:26 +0100 Subject: [PATCH 076/138] AUTHORS: Add self to list --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index e93ff83c..41723e32 100644 --- a/AUTHORS +++ b/AUTHORS @@ -20,6 +20,7 @@ Cary Cherng David Porter gonutz Hill +Jason A. Donenfeld Joseph Watson Kevin Pors ktye From 4c025d22e1be95ad11923c1a68f4f2f3e436463e Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 26 Feb 2019 11:23:24 +0100 Subject: [PATCH 077/138] Add some TrackBar / Slider message constants --- comctl32.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/comctl32.go b/comctl32.go index 3e204a28..2965d783 100644 --- a/comctl32.go +++ b/comctl32.go @@ -133,6 +133,10 @@ const ( TBM_SETPOS = WM_USER + 5 TBM_SETRANGEMIN = WM_USER + 7 TBM_SETRANGEMAX = WM_USER + 8 + TBM_SETPAGESIZE = WM_USER + 21 + TBM_GETPAGESIZE = WM_USER + 22 + TBM_SETLINESIZE = WM_USER + 23 + TBM_GETLINESIZE = WM_USER + 24 ) // TrackBar (Slider) styles From e90c084872a829e2193ded9dbdb9a0180ddcfac0 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 6 Mar 2019 20:17:52 +0100 Subject: [PATCH 078/138] Safely load DLLs Prior this was vulnerable to DLL injection attacks. While the syscall package whitelists a few DLLs for safe loading, it doesn't whitelist all of the ones we need. Hence our only solution is x/sys/windows, which can do this right. On the plus side, however, we get to do this lazily, which means we're not loading tons of useless DLLs in polyglot apps that have win linked in but don't use it all or in all modes of the app. --- advapi32.go | 35 +-- comctl32.go | 59 +++-- comdlg32.go | 35 +-- gdi32.go | 437 ++++++++++++++++---------------- gdiplus.go | 43 ++-- kernel32.go | 154 ++++++------ ole32.go | 41 +-- oleaut32.go | 23 +- opengl32.go | 101 ++++---- pdh.go | 39 +-- shell32.go | 68 ++--- user32.go | 712 ++++++++++++++++++++++++++-------------------------- uxtheme.go | 56 +++-- win.go | 24 -- winspool.go | 29 +-- 15 files changed, 930 insertions(+), 926 deletions(-) diff --git a/advapi32.go b/advapi32.go index 31e4ffe8..4420ffbd 100644 --- a/advapi32.go +++ b/advapi32.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -55,30 +56,30 @@ const ( var ( // Library - libadvapi32 uintptr + libadvapi32 *windows.LazyDLL // Functions - regCloseKey uintptr - regOpenKeyEx uintptr - regQueryValueEx uintptr - regEnumValue uintptr - regSetValueEx uintptr + regCloseKey *windows.LazyProc + regOpenKeyEx *windows.LazyProc + regQueryValueEx *windows.LazyProc + regEnumValue *windows.LazyProc + regSetValueEx *windows.LazyProc ) func init() { // Library - libadvapi32 = MustLoadLibrary("advapi32.dll") + libadvapi32 = windows.NewLazySystemDLL("advapi32.dll") // Functions - regCloseKey = MustGetProcAddress(libadvapi32, "RegCloseKey") - regOpenKeyEx = MustGetProcAddress(libadvapi32, "RegOpenKeyExW") - regQueryValueEx = MustGetProcAddress(libadvapi32, "RegQueryValueExW") - regEnumValue = MustGetProcAddress(libadvapi32, "RegEnumValueW") - regSetValueEx = MustGetProcAddress(libadvapi32, "RegSetValueExW") + regCloseKey = libadvapi32.NewProc("RegCloseKey") + regOpenKeyEx = libadvapi32.NewProc("RegOpenKeyExW") + regQueryValueEx = libadvapi32.NewProc("RegQueryValueExW") + regEnumValue = libadvapi32.NewProc("RegEnumValueW") + regSetValueEx = libadvapi32.NewProc("RegSetValueExW") } func RegCloseKey(hKey HKEY) int32 { - ret, _, _ := syscall.Syscall(regCloseKey, 1, + ret, _, _ := syscall.Syscall(regCloseKey.Addr(), 1, uintptr(hKey), 0, 0) @@ -87,7 +88,7 @@ func RegCloseKey(hKey HKEY) int32 { } func RegOpenKeyEx(hKey HKEY, lpSubKey *uint16, ulOptions uint32, samDesired REGSAM, phkResult *HKEY) int32 { - ret, _, _ := syscall.Syscall6(regOpenKeyEx, 5, + ret, _, _ := syscall.Syscall6(regOpenKeyEx.Addr(), 5, uintptr(hKey), uintptr(unsafe.Pointer(lpSubKey)), uintptr(ulOptions), @@ -99,7 +100,7 @@ func RegOpenKeyEx(hKey HKEY, lpSubKey *uint16, ulOptions uint32, samDesired REGS } func RegQueryValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpType *uint32, lpData *byte, lpcbData *uint32) int32 { - ret, _, _ := syscall.Syscall6(regQueryValueEx, 6, + ret, _, _ := syscall.Syscall6(regQueryValueEx.Addr(), 6, uintptr(hKey), uintptr(unsafe.Pointer(lpValueName)), uintptr(unsafe.Pointer(lpReserved)), @@ -111,7 +112,7 @@ func RegQueryValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpType *uint32, } func RegEnumValue(hKey HKEY, index uint32, lpValueName *uint16, lpcchValueName *uint32, lpReserved, lpType *uint32, lpData *byte, lpcbData *uint32) int32 { - ret, _, _ := syscall.Syscall9(regEnumValue, 8, + ret, _, _ := syscall.Syscall9(regEnumValue.Addr(), 8, uintptr(hKey), uintptr(index), uintptr(unsafe.Pointer(lpValueName)), @@ -125,7 +126,7 @@ func RegEnumValue(hKey HKEY, index uint32, lpValueName *uint16, lpcchValueName * } func RegSetValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpDataType uint64, lpData *byte, cbData uint32) int32 { - ret, _, _ := syscall.Syscall6(regSetValueEx, 6, + ret, _, _ := syscall.Syscall6(regSetValueEx.Addr(), 6, uintptr(hKey), uintptr(unsafe.Pointer(lpValueName)), uintptr(lpReserved), diff --git a/comctl32.go b/comctl32.go index 2965d783..503ce443 100644 --- a/comctl32.go +++ b/comctl32.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -230,32 +231,32 @@ type NMCUSTOMDRAW struct { var ( // Library - libcomctl32 uintptr + libcomctl32 *windows.LazyDLL // Functions - imageList_Add uintptr - imageList_AddMasked uintptr - imageList_Create uintptr - imageList_Destroy uintptr - imageList_ReplaceIcon uintptr - initCommonControlsEx uintptr - loadIconMetric uintptr - loadIconWithScaleDown uintptr + imageList_Add *windows.LazyProc + imageList_AddMasked *windows.LazyProc + imageList_Create *windows.LazyProc + imageList_Destroy *windows.LazyProc + imageList_ReplaceIcon *windows.LazyProc + initCommonControlsEx *windows.LazyProc + loadIconMetric *windows.LazyProc + loadIconWithScaleDown *windows.LazyProc ) func init() { // Library - libcomctl32 = MustLoadLibrary("comctl32.dll") + libcomctl32 = windows.NewLazySystemDLL("comctl32.dll") // Functions - imageList_Add = MustGetProcAddress(libcomctl32, "ImageList_Add") - imageList_AddMasked = MustGetProcAddress(libcomctl32, "ImageList_AddMasked") - imageList_Create = MustGetProcAddress(libcomctl32, "ImageList_Create") - imageList_Destroy = MustGetProcAddress(libcomctl32, "ImageList_Destroy") - imageList_ReplaceIcon = MustGetProcAddress(libcomctl32, "ImageList_ReplaceIcon") - initCommonControlsEx = MustGetProcAddress(libcomctl32, "InitCommonControlsEx") - loadIconMetric = MaybeGetProcAddress(libcomctl32, "LoadIconMetric") - loadIconWithScaleDown = MaybeGetProcAddress(libcomctl32, "LoadIconWithScaleDown") + imageList_Add = libcomctl32.NewProc("ImageList_Add") + imageList_AddMasked = libcomctl32.NewProc("ImageList_AddMasked") + imageList_Create = libcomctl32.NewProc("ImageList_Create") + imageList_Destroy = libcomctl32.NewProc("ImageList_Destroy") + imageList_ReplaceIcon = libcomctl32.NewProc("ImageList_ReplaceIcon") + initCommonControlsEx = libcomctl32.NewProc("InitCommonControlsEx") + loadIconMetric = libcomctl32.NewProc("LoadIconMetric") + loadIconWithScaleDown = libcomctl32.NewProc("LoadIconWithScaleDown") // Initialize the common controls we support var initCtrls INITCOMMONCONTROLSEX @@ -266,7 +267,7 @@ func init() { } func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int32 { - ret, _, _ := syscall.Syscall(imageList_Add, 3, + ret, _, _ := syscall.Syscall(imageList_Add.Addr(), 3, uintptr(himl), uintptr(hbmImage), uintptr(hbmMask)) @@ -275,7 +276,7 @@ func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int32 { } func ImageList_AddMasked(himl HIMAGELIST, hbmImage HBITMAP, crMask COLORREF) int32 { - ret, _, _ := syscall.Syscall(imageList_AddMasked, 3, + ret, _, _ := syscall.Syscall(imageList_AddMasked.Addr(), 3, uintptr(himl), uintptr(hbmImage), uintptr(crMask)) @@ -284,7 +285,7 @@ func ImageList_AddMasked(himl HIMAGELIST, hbmImage HBITMAP, crMask COLORREF) int } func ImageList_Create(cx, cy int32, flags uint32, cInitial, cGrow int32) HIMAGELIST { - ret, _, _ := syscall.Syscall6(imageList_Create, 5, + ret, _, _ := syscall.Syscall6(imageList_Create.Addr(), 5, uintptr(cx), uintptr(cy), uintptr(flags), @@ -296,7 +297,7 @@ func ImageList_Create(cx, cy int32, flags uint32, cInitial, cGrow int32) HIMAGEL } func ImageList_Destroy(hIml HIMAGELIST) bool { - ret, _, _ := syscall.Syscall(imageList_Destroy, 1, + ret, _, _ := syscall.Syscall(imageList_Destroy.Addr(), 1, uintptr(hIml), 0, 0) @@ -305,7 +306,7 @@ func ImageList_Destroy(hIml HIMAGELIST) bool { } func ImageList_ReplaceIcon(himl HIMAGELIST, i int32, hicon HICON) int32 { - ret, _, _ := syscall.Syscall(imageList_ReplaceIcon, 3, + ret, _, _ := syscall.Syscall(imageList_ReplaceIcon.Addr(), 3, uintptr(himl), uintptr(i), uintptr(hicon)) @@ -314,7 +315,7 @@ func ImageList_ReplaceIcon(himl HIMAGELIST, i int32, hicon HICON) int32 { } func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool { - ret, _, _ := syscall.Syscall(initCommonControlsEx, 1, + ret, _, _ := syscall.Syscall(initCommonControlsEx.Addr(), 1, uintptr(unsafe.Pointer(lpInitCtrls)), 0, 0) @@ -323,7 +324,10 @@ func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool { } func LoadIconMetric(hInstance HINSTANCE, lpIconName *uint16, lims int32, hicon *HICON) HRESULT { - ret, _, _ := syscall.Syscall6(loadIconMetric, 4, + if loadIconMetric.Find() != nil { + return HRESULT(0) + } + ret, _, _ := syscall.Syscall6(loadIconMetric.Addr(), 4, uintptr(hInstance), uintptr(unsafe.Pointer(lpIconName)), uintptr(lims), @@ -335,7 +339,10 @@ func LoadIconMetric(hInstance HINSTANCE, lpIconName *uint16, lims int32, hicon * } func LoadIconWithScaleDown(hInstance HINSTANCE, lpIconName *uint16, w int32, h int32, hicon *HICON) HRESULT { - ret, _, _ := syscall.Syscall6(loadIconWithScaleDown, 5, + if loadIconWithScaleDown.Find() != nil { + return HRESULT(0) + } + ret, _, _ := syscall.Syscall6(loadIconWithScaleDown.Addr(), 5, uintptr(hInstance), uintptr(unsafe.Pointer(lpIconName)), uintptr(w), diff --git a/comdlg32.go b/comdlg32.go index 6ba9d050..e8611181 100644 --- a/comdlg32.go +++ b/comdlg32.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -231,30 +232,30 @@ type PRINTDLGEX struct { var ( // Library - libcomdlg32 uintptr + libcomdlg32 *windows.LazyDLL // Functions - chooseColor uintptr - commDlgExtendedError uintptr - getOpenFileName uintptr - getSaveFileName uintptr - printDlgEx uintptr + chooseColor *windows.LazyProc + commDlgExtendedError *windows.LazyProc + getOpenFileName *windows.LazyProc + getSaveFileName *windows.LazyProc + printDlgEx *windows.LazyProc ) func init() { // Library - libcomdlg32 = MustLoadLibrary("comdlg32.dll") + libcomdlg32 = windows.NewLazySystemDLL("comdlg32.dll") // Functions - chooseColor = MustGetProcAddress(libcomdlg32, "ChooseColorW") - commDlgExtendedError = MustGetProcAddress(libcomdlg32, "CommDlgExtendedError") - getOpenFileName = MustGetProcAddress(libcomdlg32, "GetOpenFileNameW") - getSaveFileName = MustGetProcAddress(libcomdlg32, "GetSaveFileNameW") - printDlgEx = MustGetProcAddress(libcomdlg32, "PrintDlgExW") + chooseColor = libcomdlg32.NewProc("ChooseColorW") + commDlgExtendedError = libcomdlg32.NewProc("CommDlgExtendedError") + getOpenFileName = libcomdlg32.NewProc("GetOpenFileNameW") + getSaveFileName = libcomdlg32.NewProc("GetSaveFileNameW") + printDlgEx = libcomdlg32.NewProc("PrintDlgExW") } func ChooseColor(lpcc *CHOOSECOLOR) bool { - ret, _, _ := syscall.Syscall(chooseColor, 1, + ret, _, _ := syscall.Syscall(chooseColor.Addr(), 1, uintptr(unsafe.Pointer(lpcc)), 0, 0) @@ -263,7 +264,7 @@ func ChooseColor(lpcc *CHOOSECOLOR) bool { } func CommDlgExtendedError() uint32 { - ret, _, _ := syscall.Syscall(commDlgExtendedError, 0, + ret, _, _ := syscall.Syscall(commDlgExtendedError.Addr(), 0, 0, 0, 0) @@ -272,7 +273,7 @@ func CommDlgExtendedError() uint32 { } func GetOpenFileName(lpofn *OPENFILENAME) bool { - ret, _, _ := syscall.Syscall(getOpenFileName, 1, + ret, _, _ := syscall.Syscall(getOpenFileName.Addr(), 1, uintptr(unsafe.Pointer(lpofn)), 0, 0) @@ -281,7 +282,7 @@ func GetOpenFileName(lpofn *OPENFILENAME) bool { } func GetSaveFileName(lpofn *OPENFILENAME) bool { - ret, _, _ := syscall.Syscall(getSaveFileName, 1, + ret, _, _ := syscall.Syscall(getSaveFileName.Addr(), 1, uintptr(unsafe.Pointer(lpofn)), 0, 0) @@ -290,7 +291,7 @@ func GetSaveFileName(lpofn *OPENFILENAME) bool { } func PrintDlgEx(lppd *PRINTDLGEX) HRESULT { - ret, _, _ := syscall.Syscall(printDlgEx, 1, + ret, _, _ := syscall.Syscall(printDlgEx.Addr(), 1, uintptr(unsafe.Pointer(lppd)), 0, 0) diff --git a/gdi32.go b/gdi32.go index f438853d..d988ee52 100644 --- a/gdi32.go +++ b/gdi32.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -1028,165 +1029,165 @@ type BLENDFUNCTION struct { var ( // Library - libgdi32 uintptr - libmsimg32 uintptr + libgdi32 *windows.LazyDLL + libmsimg32 *windows.LazyDLL // Functions - abortDoc uintptr - addFontResourceEx uintptr - alphaBlend uintptr - bitBlt uintptr - choosePixelFormat uintptr - closeEnhMetaFile uintptr - combineRgn uintptr - copyEnhMetaFile uintptr - createBitmap uintptr - createCompatibleBitmap uintptr - createBrushIndirect uintptr - createCompatibleDC uintptr - createDC uintptr - createDIBSection uintptr - createFontIndirect uintptr - createEnhMetaFile uintptr - createIC uintptr - createPatternBrush uintptr - createRectRgn uintptr - deleteDC uintptr - deleteEnhMetaFile uintptr - deleteObject uintptr - ellipse uintptr - endDoc uintptr - endPage uintptr - excludeClipRect uintptr - extCreatePen uintptr - fillRgn uintptr - gdiFlush uintptr - getBkColor uintptr - getDeviceCaps uintptr - getDIBits uintptr - getEnhMetaFile uintptr - getEnhMetaFileHeader uintptr - getObject uintptr - getPixel uintptr - getRgnBox uintptr - getStockObject uintptr - getTextColor uintptr - getTextExtentExPoint uintptr - getTextExtentPoint32 uintptr - getTextMetrics uintptr - getViewportOrgEx uintptr - gradientFill uintptr - intersectClipRect uintptr - lineTo uintptr - moveToEx uintptr - playEnhMetaFile uintptr - polyline uintptr - rectangle uintptr - removeFontResourceEx uintptr - resetDC uintptr - restoreDC uintptr - roundRect uintptr - selectObject uintptr - setBkColor uintptr - setBkMode uintptr - setBrushOrgEx uintptr - setDIBits uintptr - setPixel uintptr - setPixelFormat uintptr - setStretchBltMode uintptr - setTextColor uintptr - setViewportOrgEx uintptr - saveDC uintptr - startDoc uintptr - startPage uintptr - stretchBlt uintptr - swapBuffers uintptr - textOut uintptr - transparentBlt uintptr + abortDoc *windows.LazyProc + addFontResourceEx *windows.LazyProc + alphaBlend *windows.LazyProc + bitBlt *windows.LazyProc + choosePixelFormat *windows.LazyProc + closeEnhMetaFile *windows.LazyProc + combineRgn *windows.LazyProc + copyEnhMetaFile *windows.LazyProc + createBitmap *windows.LazyProc + createCompatibleBitmap *windows.LazyProc + createBrushIndirect *windows.LazyProc + createCompatibleDC *windows.LazyProc + createDC *windows.LazyProc + createDIBSection *windows.LazyProc + createFontIndirect *windows.LazyProc + createEnhMetaFile *windows.LazyProc + createIC *windows.LazyProc + createPatternBrush *windows.LazyProc + createRectRgn *windows.LazyProc + deleteDC *windows.LazyProc + deleteEnhMetaFile *windows.LazyProc + deleteObject *windows.LazyProc + ellipse *windows.LazyProc + endDoc *windows.LazyProc + endPage *windows.LazyProc + excludeClipRect *windows.LazyProc + extCreatePen *windows.LazyProc + fillRgn *windows.LazyProc + gdiFlush *windows.LazyProc + getBkColor *windows.LazyProc + getDeviceCaps *windows.LazyProc + getDIBits *windows.LazyProc + getEnhMetaFile *windows.LazyProc + getEnhMetaFileHeader *windows.LazyProc + getObject *windows.LazyProc + getPixel *windows.LazyProc + getRgnBox *windows.LazyProc + getStockObject *windows.LazyProc + getTextColor *windows.LazyProc + getTextExtentExPoint *windows.LazyProc + getTextExtentPoint32 *windows.LazyProc + getTextMetrics *windows.LazyProc + getViewportOrgEx *windows.LazyProc + gradientFill *windows.LazyProc + intersectClipRect *windows.LazyProc + lineTo *windows.LazyProc + moveToEx *windows.LazyProc + playEnhMetaFile *windows.LazyProc + polyline *windows.LazyProc + rectangle *windows.LazyProc + removeFontResourceEx *windows.LazyProc + resetDC *windows.LazyProc + restoreDC *windows.LazyProc + roundRect *windows.LazyProc + selectObject *windows.LazyProc + setBkColor *windows.LazyProc + setBkMode *windows.LazyProc + setBrushOrgEx *windows.LazyProc + setDIBits *windows.LazyProc + setPixel *windows.LazyProc + setPixelFormat *windows.LazyProc + setStretchBltMode *windows.LazyProc + setTextColor *windows.LazyProc + setViewportOrgEx *windows.LazyProc + saveDC *windows.LazyProc + startDoc *windows.LazyProc + startPage *windows.LazyProc + stretchBlt *windows.LazyProc + swapBuffers *windows.LazyProc + textOut *windows.LazyProc + transparentBlt *windows.LazyProc ) func init() { // Library - libgdi32 = MustLoadLibrary("gdi32.dll") - libmsimg32 = MustLoadLibrary("msimg32.dll") + libgdi32 = windows.NewLazySystemDLL("gdi32.dll") + libmsimg32 = windows.NewLazySystemDLL("msimg32.dll") // Functions - abortDoc = MustGetProcAddress(libgdi32, "AbortDoc") - addFontResourceEx = MustGetProcAddress(libgdi32, "AddFontResourceExW") - bitBlt = MustGetProcAddress(libgdi32, "BitBlt") - choosePixelFormat = MustGetProcAddress(libgdi32, "ChoosePixelFormat") - closeEnhMetaFile = MustGetProcAddress(libgdi32, "CloseEnhMetaFile") - combineRgn = MustGetProcAddress(libgdi32, "CombineRgn") - copyEnhMetaFile = MustGetProcAddress(libgdi32, "CopyEnhMetaFileW") - createBitmap = MustGetProcAddress(libgdi32, "CreateBitmap") - createCompatibleBitmap = MustGetProcAddress(libgdi32, "CreateCompatibleBitmap") - createBrushIndirect = MustGetProcAddress(libgdi32, "CreateBrushIndirect") - createCompatibleDC = MustGetProcAddress(libgdi32, "CreateCompatibleDC") - createDC = MustGetProcAddress(libgdi32, "CreateDCW") - createDIBSection = MustGetProcAddress(libgdi32, "CreateDIBSection") - createEnhMetaFile = MustGetProcAddress(libgdi32, "CreateEnhMetaFileW") - createFontIndirect = MustGetProcAddress(libgdi32, "CreateFontIndirectW") - createIC = MustGetProcAddress(libgdi32, "CreateICW") - createPatternBrush = MustGetProcAddress(libgdi32, "CreatePatternBrush") - createRectRgn = MustGetProcAddress(libgdi32, "CreateRectRgn") - deleteDC = MustGetProcAddress(libgdi32, "DeleteDC") - deleteEnhMetaFile = MustGetProcAddress(libgdi32, "DeleteEnhMetaFile") - deleteObject = MustGetProcAddress(libgdi32, "DeleteObject") - ellipse = MustGetProcAddress(libgdi32, "Ellipse") - endDoc = MustGetProcAddress(libgdi32, "EndDoc") - endPage = MustGetProcAddress(libgdi32, "EndPage") - excludeClipRect = MustGetProcAddress(libgdi32, "ExcludeClipRect") - extCreatePen = MustGetProcAddress(libgdi32, "ExtCreatePen") - fillRgn = MustGetProcAddress(libgdi32, "FillRgn") - gdiFlush = MustGetProcAddress(libgdi32, "GdiFlush") - getBkColor = MustGetProcAddress(libgdi32, "GetBkColor") - getDeviceCaps = MustGetProcAddress(libgdi32, "GetDeviceCaps") - getDIBits = MustGetProcAddress(libgdi32, "GetDIBits") - getEnhMetaFile = MustGetProcAddress(libgdi32, "GetEnhMetaFileW") - getEnhMetaFileHeader = MustGetProcAddress(libgdi32, "GetEnhMetaFileHeader") - getObject = MustGetProcAddress(libgdi32, "GetObjectW") - getPixel = MustGetProcAddress(libgdi32, "GetPixel") - getRgnBox = MustGetProcAddress(libgdi32, "GetRgnBox") - getStockObject = MustGetProcAddress(libgdi32, "GetStockObject") - getTextColor = MustGetProcAddress(libgdi32, "GetTextColor") - getTextExtentExPoint = MustGetProcAddress(libgdi32, "GetTextExtentExPointW") - getTextExtentPoint32 = MustGetProcAddress(libgdi32, "GetTextExtentPoint32W") - getTextMetrics = MustGetProcAddress(libgdi32, "GetTextMetricsW") - getViewportOrgEx = MustGetProcAddress(libgdi32, "GetViewportOrgEx") - intersectClipRect = MustGetProcAddress(libgdi32, "IntersectClipRect") - lineTo = MustGetProcAddress(libgdi32, "LineTo") - moveToEx = MustGetProcAddress(libgdi32, "MoveToEx") - playEnhMetaFile = MustGetProcAddress(libgdi32, "PlayEnhMetaFile") - polyline = MustGetProcAddress(libgdi32, "Polyline") - rectangle = MustGetProcAddress(libgdi32, "Rectangle") - removeFontResourceEx = MustGetProcAddress(libgdi32, "RemoveFontResourceExW") - resetDC = MustGetProcAddress(libgdi32, "ResetDCW") - restoreDC = MustGetProcAddress(libgdi32, "RestoreDC") - roundRect = MustGetProcAddress(libgdi32, "RoundRect") - saveDC = MustGetProcAddress(libgdi32, "SaveDC") - selectObject = MustGetProcAddress(libgdi32, "SelectObject") - setBkColor = MustGetProcAddress(libgdi32, "SetBkColor") - setBkMode = MustGetProcAddress(libgdi32, "SetBkMode") - setBrushOrgEx = MustGetProcAddress(libgdi32, "SetBrushOrgEx") - setDIBits = MustGetProcAddress(libgdi32, "SetDIBits") - setPixel = MustGetProcAddress(libgdi32, "SetPixel") - setPixelFormat = MustGetProcAddress(libgdi32, "SetPixelFormat") - setStretchBltMode = MustGetProcAddress(libgdi32, "SetStretchBltMode") - setTextColor = MustGetProcAddress(libgdi32, "SetTextColor") - setViewportOrgEx = MustGetProcAddress(libgdi32, "SetViewportOrgEx") - startDoc = MustGetProcAddress(libgdi32, "StartDocW") - startPage = MustGetProcAddress(libgdi32, "StartPage") - stretchBlt = MustGetProcAddress(libgdi32, "StretchBlt") - swapBuffers = MustGetProcAddress(libgdi32, "SwapBuffers") - textOut = MustGetProcAddress(libgdi32, "TextOutW") - - alphaBlend = MustGetProcAddress(libmsimg32, "AlphaBlend") - gradientFill = MustGetProcAddress(libmsimg32, "GradientFill") - transparentBlt = MustGetProcAddress(libmsimg32, "TransparentBlt") + abortDoc = libgdi32.NewProc("AbortDoc") + addFontResourceEx = libgdi32.NewProc("AddFontResourceExW") + bitBlt = libgdi32.NewProc("BitBlt") + choosePixelFormat = libgdi32.NewProc("ChoosePixelFormat") + closeEnhMetaFile = libgdi32.NewProc("CloseEnhMetaFile") + combineRgn = libgdi32.NewProc("CombineRgn") + copyEnhMetaFile = libgdi32.NewProc("CopyEnhMetaFileW") + createBitmap = libgdi32.NewProc("CreateBitmap") + createCompatibleBitmap = libgdi32.NewProc("CreateCompatibleBitmap") + createBrushIndirect = libgdi32.NewProc("CreateBrushIndirect") + createCompatibleDC = libgdi32.NewProc("CreateCompatibleDC") + createDC = libgdi32.NewProc("CreateDCW") + createDIBSection = libgdi32.NewProc("CreateDIBSection") + createEnhMetaFile = libgdi32.NewProc("CreateEnhMetaFileW") + createFontIndirect = libgdi32.NewProc("CreateFontIndirectW") + createIC = libgdi32.NewProc("CreateICW") + createPatternBrush = libgdi32.NewProc("CreatePatternBrush") + createRectRgn = libgdi32.NewProc("CreateRectRgn") + deleteDC = libgdi32.NewProc("DeleteDC") + deleteEnhMetaFile = libgdi32.NewProc("DeleteEnhMetaFile") + deleteObject = libgdi32.NewProc("DeleteObject") + ellipse = libgdi32.NewProc("Ellipse") + endDoc = libgdi32.NewProc("EndDoc") + endPage = libgdi32.NewProc("EndPage") + excludeClipRect = libgdi32.NewProc("ExcludeClipRect") + extCreatePen = libgdi32.NewProc("ExtCreatePen") + fillRgn = libgdi32.NewProc("FillRgn") + gdiFlush = libgdi32.NewProc("GdiFlush") + getBkColor = libgdi32.NewProc("GetBkColor") + getDeviceCaps = libgdi32.NewProc("GetDeviceCaps") + getDIBits = libgdi32.NewProc("GetDIBits") + getEnhMetaFile = libgdi32.NewProc("GetEnhMetaFileW") + getEnhMetaFileHeader = libgdi32.NewProc("GetEnhMetaFileHeader") + getObject = libgdi32.NewProc("GetObjectW") + getPixel = libgdi32.NewProc("GetPixel") + getRgnBox = libgdi32.NewProc("GetRgnBox") + getStockObject = libgdi32.NewProc("GetStockObject") + getTextColor = libgdi32.NewProc("GetTextColor") + getTextExtentExPoint = libgdi32.NewProc("GetTextExtentExPointW") + getTextExtentPoint32 = libgdi32.NewProc("GetTextExtentPoint32W") + getTextMetrics = libgdi32.NewProc("GetTextMetricsW") + getViewportOrgEx = libgdi32.NewProc("GetViewportOrgEx") + intersectClipRect = libgdi32.NewProc("IntersectClipRect") + lineTo = libgdi32.NewProc("LineTo") + moveToEx = libgdi32.NewProc("MoveToEx") + playEnhMetaFile = libgdi32.NewProc("PlayEnhMetaFile") + polyline = libgdi32.NewProc("Polyline") + rectangle = libgdi32.NewProc("Rectangle") + removeFontResourceEx = libgdi32.NewProc("RemoveFontResourceExW") + resetDC = libgdi32.NewProc("ResetDCW") + restoreDC = libgdi32.NewProc("RestoreDC") + roundRect = libgdi32.NewProc("RoundRect") + saveDC = libgdi32.NewProc("SaveDC") + selectObject = libgdi32.NewProc("SelectObject") + setBkColor = libgdi32.NewProc("SetBkColor") + setBkMode = libgdi32.NewProc("SetBkMode") + setBrushOrgEx = libgdi32.NewProc("SetBrushOrgEx") + setDIBits = libgdi32.NewProc("SetDIBits") + setPixel = libgdi32.NewProc("SetPixel") + setPixelFormat = libgdi32.NewProc("SetPixelFormat") + setStretchBltMode = libgdi32.NewProc("SetStretchBltMode") + setTextColor = libgdi32.NewProc("SetTextColor") + setViewportOrgEx = libgdi32.NewProc("SetViewportOrgEx") + startDoc = libgdi32.NewProc("StartDocW") + startPage = libgdi32.NewProc("StartPage") + stretchBlt = libgdi32.NewProc("StretchBlt") + swapBuffers = libgdi32.NewProc("SwapBuffers") + textOut = libgdi32.NewProc("TextOutW") + + alphaBlend = libmsimg32.NewProc("AlphaBlend") + gradientFill = libmsimg32.NewProc("GradientFill") + transparentBlt = libmsimg32.NewProc("TransparentBlt") } func AbortDoc(hdc HDC) int32 { - ret, _, _ := syscall.Syscall(abortDoc, 1, + ret, _, _ := syscall.Syscall(abortDoc.Addr(), 1, uintptr(hdc), 0, 0) @@ -1195,7 +1196,7 @@ func AbortDoc(hdc HDC) int32 { } func AddFontResourceEx(lpszFilename *uint16, fl uint32, pdv unsafe.Pointer) int32 { - ret, _, _ := syscall.Syscall(addFontResourceEx, 3, + ret, _, _ := syscall.Syscall(addFontResourceEx.Addr(), 3, uintptr(unsafe.Pointer(lpszFilename)), uintptr(fl), uintptr(pdv)) @@ -1204,7 +1205,7 @@ func AddFontResourceEx(lpszFilename *uint16, fl uint32, pdv unsafe.Pointer) int3 } func AlphaBlend(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int32, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int32, ftn BLENDFUNCTION) bool { - ret, _, _ := syscall.Syscall12(alphaBlend, 11, + ret, _, _ := syscall.Syscall12(alphaBlend.Addr(), 11, uintptr(hdcDest), uintptr(nXOriginDest), uintptr(nYOriginDest), @@ -1222,7 +1223,7 @@ func AlphaBlend(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest } func BitBlt(hdcDest HDC, nXDest, nYDest, nWidth, nHeight int32, hdcSrc HDC, nXSrc, nYSrc int32, dwRop uint32) bool { - ret, _, _ := syscall.Syscall9(bitBlt, 9, + ret, _, _ := syscall.Syscall9(bitBlt.Addr(), 9, uintptr(hdcDest), uintptr(nXDest), uintptr(nYDest), @@ -1237,7 +1238,7 @@ func BitBlt(hdcDest HDC, nXDest, nYDest, nWidth, nHeight int32, hdcSrc HDC, nXSr } func ChoosePixelFormat(hdc HDC, ppfd *PIXELFORMATDESCRIPTOR) int32 { - ret, _, _ := syscall.Syscall(choosePixelFormat, 2, + ret, _, _ := syscall.Syscall(choosePixelFormat.Addr(), 2, uintptr(hdc), uintptr(unsafe.Pointer(ppfd)), 0) @@ -1246,7 +1247,7 @@ func ChoosePixelFormat(hdc HDC, ppfd *PIXELFORMATDESCRIPTOR) int32 { } func CloseEnhMetaFile(hdc HDC) HENHMETAFILE { - ret, _, _ := syscall.Syscall(closeEnhMetaFile, 1, + ret, _, _ := syscall.Syscall(closeEnhMetaFile.Addr(), 1, uintptr(hdc), 0, 0) @@ -1255,7 +1256,7 @@ func CloseEnhMetaFile(hdc HDC) HENHMETAFILE { } func CombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2 HRGN, fnCombineMode int32) int32 { - ret, _, _ := syscall.Syscall6(combineRgn, 4, + ret, _, _ := syscall.Syscall6(combineRgn.Addr(), 4, uintptr(hrgnDest), uintptr(hrgnSrc1), uintptr(hrgnSrc2), @@ -1267,7 +1268,7 @@ func CombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2 HRGN, fnCombineMode int32) int32 { } func CopyEnhMetaFile(hemfSrc HENHMETAFILE, lpszFile *uint16) HENHMETAFILE { - ret, _, _ := syscall.Syscall(copyEnhMetaFile, 2, + ret, _, _ := syscall.Syscall(copyEnhMetaFile.Addr(), 2, uintptr(hemfSrc), uintptr(unsafe.Pointer(lpszFile)), 0) @@ -1276,7 +1277,7 @@ func CopyEnhMetaFile(hemfSrc HENHMETAFILE, lpszFile *uint16) HENHMETAFILE { } func CreateBitmap(nWidth, nHeight int32, cPlanes, cBitsPerPel uint32, lpvBits unsafe.Pointer) HBITMAP { - ret, _, _ := syscall.Syscall6(createBitmap, 5, + ret, _, _ := syscall.Syscall6(createBitmap.Addr(), 5, uintptr(nWidth), uintptr(nHeight), uintptr(cPlanes), @@ -1288,7 +1289,7 @@ func CreateBitmap(nWidth, nHeight int32, cPlanes, cBitsPerPel uint32, lpvBits un } func CreateCompatibleBitmap(hdc HDC, nWidth, nHeight int32) HBITMAP { - ret, _, _ := syscall.Syscall(createCompatibleBitmap, 3, + ret, _, _ := syscall.Syscall(createCompatibleBitmap.Addr(), 3, uintptr(hdc), uintptr(nWidth), uintptr(nHeight)) @@ -1297,7 +1298,7 @@ func CreateCompatibleBitmap(hdc HDC, nWidth, nHeight int32) HBITMAP { } func CreateBrushIndirect(lplb *LOGBRUSH) HBRUSH { - ret, _, _ := syscall.Syscall(createBrushIndirect, 1, + ret, _, _ := syscall.Syscall(createBrushIndirect.Addr(), 1, uintptr(unsafe.Pointer(lplb)), 0, 0) @@ -1306,7 +1307,7 @@ func CreateBrushIndirect(lplb *LOGBRUSH) HBRUSH { } func CreateCompatibleDC(hdc HDC) HDC { - ret, _, _ := syscall.Syscall(createCompatibleDC, 1, + ret, _, _ := syscall.Syscall(createCompatibleDC.Addr(), 1, uintptr(hdc), 0, 0) @@ -1315,7 +1316,7 @@ func CreateCompatibleDC(hdc HDC) HDC { } func CreateDC(lpszDriver, lpszDevice, lpszOutput *uint16, lpInitData *DEVMODE) HDC { - ret, _, _ := syscall.Syscall6(createDC, 4, + ret, _, _ := syscall.Syscall6(createDC.Addr(), 4, uintptr(unsafe.Pointer(lpszDriver)), uintptr(unsafe.Pointer(lpszDevice)), uintptr(unsafe.Pointer(lpszOutput)), @@ -1327,7 +1328,7 @@ func CreateDC(lpszDriver, lpszDevice, lpszOutput *uint16, lpInitData *DEVMODE) H } func CreateDIBSection(hdc HDC, pbmih *BITMAPINFOHEADER, iUsage uint32, ppvBits *unsafe.Pointer, hSection HANDLE, dwOffset uint32) HBITMAP { - ret, _, _ := syscall.Syscall6(createDIBSection, 6, + ret, _, _ := syscall.Syscall6(createDIBSection.Addr(), 6, uintptr(hdc), uintptr(unsafe.Pointer(pbmih)), uintptr(iUsage), @@ -1339,7 +1340,7 @@ func CreateDIBSection(hdc HDC, pbmih *BITMAPINFOHEADER, iUsage uint32, ppvBits * } func CreateEnhMetaFile(hdcRef HDC, lpFilename *uint16, lpRect *RECT, lpDescription *uint16) HDC { - ret, _, _ := syscall.Syscall6(createEnhMetaFile, 4, + ret, _, _ := syscall.Syscall6(createEnhMetaFile.Addr(), 4, uintptr(hdcRef), uintptr(unsafe.Pointer(lpFilename)), uintptr(unsafe.Pointer(lpRect)), @@ -1351,7 +1352,7 @@ func CreateEnhMetaFile(hdcRef HDC, lpFilename *uint16, lpRect *RECT, lpDescripti } func CreateFontIndirect(lplf *LOGFONT) HFONT { - ret, _, _ := syscall.Syscall(createFontIndirect, 1, + ret, _, _ := syscall.Syscall(createFontIndirect.Addr(), 1, uintptr(unsafe.Pointer(lplf)), 0, 0) @@ -1360,7 +1361,7 @@ func CreateFontIndirect(lplf *LOGFONT) HFONT { } func CreateIC(lpszDriver, lpszDevice, lpszOutput *uint16, lpdvmInit *DEVMODE) HDC { - ret, _, _ := syscall.Syscall6(createIC, 4, + ret, _, _ := syscall.Syscall6(createIC.Addr(), 4, uintptr(unsafe.Pointer(lpszDriver)), uintptr(unsafe.Pointer(lpszDevice)), uintptr(unsafe.Pointer(lpszOutput)), @@ -1372,7 +1373,7 @@ func CreateIC(lpszDriver, lpszDevice, lpszOutput *uint16, lpdvmInit *DEVMODE) HD } func CreatePatternBrush(hbmp HBITMAP) HBRUSH { - ret, _, _ := syscall.Syscall(createPatternBrush, 1, + ret, _, _ := syscall.Syscall(createPatternBrush.Addr(), 1, uintptr(hbmp), 0, 0) @@ -1381,7 +1382,7 @@ func CreatePatternBrush(hbmp HBITMAP) HBRUSH { } func CreateRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect int32) HRGN { - ret, _, _ := syscall.Syscall6(createRectRgn, 4, + ret, _, _ := syscall.Syscall6(createRectRgn.Addr(), 4, uintptr(nLeftRect), uintptr(nTopRect), uintptr(nRightRect), @@ -1393,7 +1394,7 @@ func CreateRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect int32) HRGN { } func DeleteDC(hdc HDC) bool { - ret, _, _ := syscall.Syscall(deleteDC, 1, + ret, _, _ := syscall.Syscall(deleteDC.Addr(), 1, uintptr(hdc), 0, 0) @@ -1402,7 +1403,7 @@ func DeleteDC(hdc HDC) bool { } func DeleteEnhMetaFile(hemf HENHMETAFILE) bool { - ret, _, _ := syscall.Syscall(deleteEnhMetaFile, 1, + ret, _, _ := syscall.Syscall(deleteEnhMetaFile.Addr(), 1, uintptr(hemf), 0, 0) @@ -1411,7 +1412,7 @@ func DeleteEnhMetaFile(hemf HENHMETAFILE) bool { } func DeleteObject(hObject HGDIOBJ) bool { - ret, _, _ := syscall.Syscall(deleteObject, 1, + ret, _, _ := syscall.Syscall(deleteObject.Addr(), 1, uintptr(hObject), 0, 0) @@ -1420,7 +1421,7 @@ func DeleteObject(hObject HGDIOBJ) bool { } func Ellipse(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool { - ret, _, _ := syscall.Syscall6(ellipse, 5, + ret, _, _ := syscall.Syscall6(ellipse.Addr(), 5, uintptr(hdc), uintptr(nLeftRect), uintptr(nTopRect), @@ -1432,7 +1433,7 @@ func Ellipse(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool { } func EndDoc(hdc HDC) int32 { - ret, _, _ := syscall.Syscall(endDoc, 1, + ret, _, _ := syscall.Syscall(endDoc.Addr(), 1, uintptr(hdc), 0, 0) @@ -1441,7 +1442,7 @@ func EndDoc(hdc HDC) int32 { } func EndPage(hdc HDC) int32 { - ret, _, _ := syscall.Syscall(endPage, 1, + ret, _, _ := syscall.Syscall(endPage.Addr(), 1, uintptr(hdc), 0, 0) @@ -1450,7 +1451,7 @@ func EndPage(hdc HDC) int32 { } func ExcludeClipRect(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) int32 { - ret, _, _ := syscall.Syscall6(excludeClipRect, 5, + ret, _, _ := syscall.Syscall6(excludeClipRect.Addr(), 5, uintptr(hdc), uintptr(nLeftRect), uintptr(nTopRect), @@ -1462,7 +1463,7 @@ func ExcludeClipRect(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32 } func ExtCreatePen(dwPenStyle, dwWidth uint32, lplb *LOGBRUSH, dwStyleCount uint32, lpStyle *uint32) HPEN { - ret, _, _ := syscall.Syscall6(extCreatePen, 5, + ret, _, _ := syscall.Syscall6(extCreatePen.Addr(), 5, uintptr(dwPenStyle), uintptr(dwWidth), uintptr(unsafe.Pointer(lplb)), @@ -1474,7 +1475,7 @@ func ExtCreatePen(dwPenStyle, dwWidth uint32, lplb *LOGBRUSH, dwStyleCount uint3 } func FillRgn(hdc HDC, hrgn HRGN, hbr HBRUSH) bool { - ret, _, _ := syscall.Syscall(fillRgn, 3, + ret, _, _ := syscall.Syscall(fillRgn.Addr(), 3, uintptr(hdc), uintptr(hrgn), uintptr(hbr)) @@ -1483,7 +1484,7 @@ func FillRgn(hdc HDC, hrgn HRGN, hbr HBRUSH) bool { } func GdiFlush() bool { - ret, _, _ := syscall.Syscall(gdiFlush, 0, + ret, _, _ := syscall.Syscall(gdiFlush.Addr(), 0, 0, 0, 0) @@ -1492,7 +1493,7 @@ func GdiFlush() bool { } func GetBkColor(hdc HDC) COLORREF { - ret, _, _ := syscall.Syscall(getBkColor, 1, + ret, _, _ := syscall.Syscall(getBkColor.Addr(), 1, uintptr(hdc), 0, 0) @@ -1501,7 +1502,7 @@ func GetBkColor(hdc HDC) COLORREF { } func GetDeviceCaps(hdc HDC, nIndex int32) int32 { - ret, _, _ := syscall.Syscall(getDeviceCaps, 2, + ret, _, _ := syscall.Syscall(getDeviceCaps.Addr(), 2, uintptr(hdc), uintptr(nIndex), 0) @@ -1510,7 +1511,7 @@ func GetDeviceCaps(hdc HDC, nIndex int32) int32 { } func GetDIBits(hdc HDC, hbmp HBITMAP, uStartScan uint32, cScanLines uint32, lpvBits *byte, lpbi *BITMAPINFO, uUsage uint32) int32 { - ret, _, _ := syscall.Syscall9(getDIBits, 7, + ret, _, _ := syscall.Syscall9(getDIBits.Addr(), 7, uintptr(hdc), uintptr(hbmp), uintptr(uStartScan), @@ -1524,7 +1525,7 @@ func GetDIBits(hdc HDC, hbmp HBITMAP, uStartScan uint32, cScanLines uint32, lpvB } func GetEnhMetaFile(lpszMetaFile *uint16) HENHMETAFILE { - ret, _, _ := syscall.Syscall(getEnhMetaFile, 1, + ret, _, _ := syscall.Syscall(getEnhMetaFile.Addr(), 1, uintptr(unsafe.Pointer(lpszMetaFile)), 0, 0) @@ -1533,7 +1534,7 @@ func GetEnhMetaFile(lpszMetaFile *uint16) HENHMETAFILE { } func GetEnhMetaFileHeader(hemf HENHMETAFILE, cbBuffer uint32, lpemh *ENHMETAHEADER) uint32 { - ret, _, _ := syscall.Syscall(getEnhMetaFileHeader, 3, + ret, _, _ := syscall.Syscall(getEnhMetaFileHeader.Addr(), 3, uintptr(hemf), uintptr(cbBuffer), uintptr(unsafe.Pointer(lpemh))) @@ -1542,7 +1543,7 @@ func GetEnhMetaFileHeader(hemf HENHMETAFILE, cbBuffer uint32, lpemh *ENHMETAHEAD } func GetObject(hgdiobj HGDIOBJ, cbBuffer uintptr, lpvObject unsafe.Pointer) int32 { - ret, _, _ := syscall.Syscall(getObject, 3, + ret, _, _ := syscall.Syscall(getObject.Addr(), 3, uintptr(hgdiobj), uintptr(cbBuffer), uintptr(lpvObject)) @@ -1551,7 +1552,7 @@ func GetObject(hgdiobj HGDIOBJ, cbBuffer uintptr, lpvObject unsafe.Pointer) int3 } func GetPixel(hdc HDC, nXPos, nYPos int32) COLORREF { - ret, _, _ := syscall.Syscall(getPixel, 3, + ret, _, _ := syscall.Syscall(getPixel.Addr(), 3, uintptr(hdc), uintptr(nXPos), uintptr(nYPos)) @@ -1560,7 +1561,7 @@ func GetPixel(hdc HDC, nXPos, nYPos int32) COLORREF { } func GetRgnBox(hrgn HRGN, lprc *RECT) int32 { - ret, _, _ := syscall.Syscall(getRgnBox, 2, + ret, _, _ := syscall.Syscall(getRgnBox.Addr(), 2, uintptr(hrgn), uintptr(unsafe.Pointer(lprc)), 0) @@ -1569,7 +1570,7 @@ func GetRgnBox(hrgn HRGN, lprc *RECT) int32 { } func GetStockObject(fnObject int32) HGDIOBJ { - ret, _, _ := syscall.Syscall(getStockObject, 1, + ret, _, _ := syscall.Syscall(getStockObject.Addr(), 1, uintptr(fnObject), 0, 0) @@ -1578,7 +1579,7 @@ func GetStockObject(fnObject int32) HGDIOBJ { } func GetTextColor(hdc HDC) COLORREF { - ret, _, _ := syscall.Syscall(getTextColor, 1, + ret, _, _ := syscall.Syscall(getTextColor.Addr(), 1, uintptr(hdc), 0, 0) @@ -1587,7 +1588,7 @@ func GetTextColor(hdc HDC) COLORREF { } func GetTextExtentExPoint(hdc HDC, lpszStr *uint16, cchString, nMaxExtent int32, lpnFit, alpDx *int32, lpSize *SIZE) bool { - ret, _, _ := syscall.Syscall9(getTextExtentExPoint, 7, + ret, _, _ := syscall.Syscall9(getTextExtentExPoint.Addr(), 7, uintptr(hdc), uintptr(unsafe.Pointer(lpszStr)), uintptr(cchString), @@ -1602,7 +1603,7 @@ func GetTextExtentExPoint(hdc HDC, lpszStr *uint16, cchString, nMaxExtent int32, } func GetTextExtentPoint32(hdc HDC, lpString *uint16, c int32, lpSize *SIZE) bool { - ret, _, _ := syscall.Syscall6(getTextExtentPoint32, 4, + ret, _, _ := syscall.Syscall6(getTextExtentPoint32.Addr(), 4, uintptr(hdc), uintptr(unsafe.Pointer(lpString)), uintptr(c), @@ -1614,7 +1615,7 @@ func GetTextExtentPoint32(hdc HDC, lpString *uint16, c int32, lpSize *SIZE) bool } func GetTextMetrics(hdc HDC, lptm *TEXTMETRIC) bool { - ret, _, _ := syscall.Syscall(getTextMetrics, 2, + ret, _, _ := syscall.Syscall(getTextMetrics.Addr(), 2, uintptr(hdc), uintptr(unsafe.Pointer(lptm)), 0) @@ -1623,7 +1624,7 @@ func GetTextMetrics(hdc HDC, lptm *TEXTMETRIC) bool { } func GetViewportOrgEx(hdc HDC, lpPoint *POINT) bool { - ret, _, _ := syscall.Syscall(getViewportOrgEx, 2, + ret, _, _ := syscall.Syscall(getViewportOrgEx.Addr(), 2, uintptr(hdc), uintptr(unsafe.Pointer(lpPoint)), 0) @@ -1632,7 +1633,7 @@ func GetViewportOrgEx(hdc HDC, lpPoint *POINT) bool { } func GradientFill(hdc HDC, pVertex *TRIVERTEX, nVertex uint32, pMesh unsafe.Pointer, nMesh, ulMode uint32) bool { - ret, _, _ := syscall.Syscall6(gradientFill, 6, + ret, _, _ := syscall.Syscall6(gradientFill.Addr(), 6, uintptr(hdc), uintptr(unsafe.Pointer(pVertex)), uintptr(nVertex), @@ -1644,7 +1645,7 @@ func GradientFill(hdc HDC, pVertex *TRIVERTEX, nVertex uint32, pMesh unsafe.Poin } func IntersectClipRect(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) int32 { - ret, _, _ := syscall.Syscall6(intersectClipRect, 5, + ret, _, _ := syscall.Syscall6(intersectClipRect.Addr(), 5, uintptr(hdc), uintptr(nLeftRect), uintptr(nTopRect), @@ -1656,7 +1657,7 @@ func IntersectClipRect(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int } func LineTo(hdc HDC, nXEnd, nYEnd int32) bool { - ret, _, _ := syscall.Syscall(lineTo, 3, + ret, _, _ := syscall.Syscall(lineTo.Addr(), 3, uintptr(hdc), uintptr(nXEnd), uintptr(nYEnd)) @@ -1665,7 +1666,7 @@ func LineTo(hdc HDC, nXEnd, nYEnd int32) bool { } func MoveToEx(hdc HDC, x, y int, lpPoint *POINT) bool { - ret, _, _ := syscall.Syscall6(moveToEx, 4, + ret, _, _ := syscall.Syscall6(moveToEx.Addr(), 4, uintptr(hdc), uintptr(x), uintptr(y), @@ -1677,7 +1678,7 @@ func MoveToEx(hdc HDC, x, y int, lpPoint *POINT) bool { } func PlayEnhMetaFile(hdc HDC, hemf HENHMETAFILE, lpRect *RECT) bool { - ret, _, _ := syscall.Syscall(playEnhMetaFile, 3, + ret, _, _ := syscall.Syscall(playEnhMetaFile.Addr(), 3, uintptr(hdc), uintptr(hemf), uintptr(unsafe.Pointer(lpRect))) @@ -1686,7 +1687,7 @@ func PlayEnhMetaFile(hdc HDC, hemf HENHMETAFILE, lpRect *RECT) bool { } func Polyline(hdc HDC, lppt unsafe.Pointer, cPoints int32) bool { - ret, _, _ := syscall.Syscall(polyline, 3, + ret, _, _ := syscall.Syscall(polyline.Addr(), 3, uintptr(hdc), uintptr(lppt), uintptr(cPoints)) @@ -1695,7 +1696,7 @@ func Polyline(hdc HDC, lppt unsafe.Pointer, cPoints int32) bool { } func Rectangle_(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool { - ret, _, _ := syscall.Syscall6(rectangle, 5, + ret, _, _ := syscall.Syscall6(rectangle.Addr(), 5, uintptr(hdc), uintptr(nLeftRect), uintptr(nTopRect), @@ -1707,7 +1708,7 @@ func Rectangle_(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) boo } func RemoveFontResourceEx(lpszFilename *uint16, fl uint32, pdv unsafe.Pointer) bool { - ret, _, _ := syscall.Syscall(removeFontResourceEx, 3, + ret, _, _ := syscall.Syscall(removeFontResourceEx.Addr(), 3, uintptr(unsafe.Pointer(lpszFilename)), uintptr(fl), uintptr(pdv)) @@ -1716,7 +1717,7 @@ func RemoveFontResourceEx(lpszFilename *uint16, fl uint32, pdv unsafe.Pointer) b } func ResetDC(hdc HDC, lpInitData *DEVMODE) HDC { - ret, _, _ := syscall.Syscall(resetDC, 2, + ret, _, _ := syscall.Syscall(resetDC.Addr(), 2, uintptr(hdc), uintptr(unsafe.Pointer(lpInitData)), 0) @@ -1725,7 +1726,7 @@ func ResetDC(hdc HDC, lpInitData *DEVMODE) HDC { } func RestoreDC(hdc HDC, nSaveDC int32) bool { - ret, _, _ := syscall.Syscall(restoreDC, 2, + ret, _, _ := syscall.Syscall(restoreDC.Addr(), 2, uintptr(hdc), uintptr(nSaveDC), 0) @@ -1733,7 +1734,7 @@ func RestoreDC(hdc HDC, nSaveDC int32) bool { } func RoundRect(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect, nWidth, nHeight int32) bool { - ret, _, _ := syscall.Syscall9(roundRect, 7, + ret, _, _ := syscall.Syscall9(roundRect.Addr(), 7, uintptr(hdc), uintptr(nLeftRect), uintptr(nTopRect), @@ -1748,7 +1749,7 @@ func RoundRect(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect, nWidth, nH } func SaveDC(hdc HDC) int32 { - ret, _, _ := syscall.Syscall(saveDC, 1, + ret, _, _ := syscall.Syscall(saveDC.Addr(), 1, uintptr(hdc), 0, 0) @@ -1756,7 +1757,7 @@ func SaveDC(hdc HDC) int32 { } func SelectObject(hdc HDC, hgdiobj HGDIOBJ) HGDIOBJ { - ret, _, _ := syscall.Syscall(selectObject, 2, + ret, _, _ := syscall.Syscall(selectObject.Addr(), 2, uintptr(hdc), uintptr(hgdiobj), 0) @@ -1765,7 +1766,7 @@ func SelectObject(hdc HDC, hgdiobj HGDIOBJ) HGDIOBJ { } func SetBkColor(hdc HDC, crColor COLORREF) COLORREF { - ret, _, _ := syscall.Syscall(setBkColor, 2, + ret, _, _ := syscall.Syscall(setBkColor.Addr(), 2, uintptr(hdc), uintptr(crColor), 0) @@ -1774,7 +1775,7 @@ func SetBkColor(hdc HDC, crColor COLORREF) COLORREF { } func SetBkMode(hdc HDC, iBkMode int32) int32 { - ret, _, _ := syscall.Syscall(setBkMode, 2, + ret, _, _ := syscall.Syscall(setBkMode.Addr(), 2, uintptr(hdc), uintptr(iBkMode), 0) @@ -1783,7 +1784,7 @@ func SetBkMode(hdc HDC, iBkMode int32) int32 { } func SetBrushOrgEx(hdc HDC, nXOrg, nYOrg int32, lppt *POINT) bool { - ret, _, _ := syscall.Syscall6(setBrushOrgEx, 4, + ret, _, _ := syscall.Syscall6(setBrushOrgEx.Addr(), 4, uintptr(hdc), uintptr(nXOrg), uintptr(nYOrg), @@ -1795,7 +1796,7 @@ func SetBrushOrgEx(hdc HDC, nXOrg, nYOrg int32, lppt *POINT) bool { } func SetDIBits(hdc HDC, hbmp HBITMAP, uStartScan, cScanLines uint32, lpvBits *byte, lpbmi *BITMAPINFO, fuColorUse uint32) int32 { - ret, _, _ := syscall.Syscall9(setDIBits, 7, + ret, _, _ := syscall.Syscall9(setDIBits.Addr(), 7, uintptr(hdc), uintptr(hbmp), uintptr(uStartScan), @@ -1810,7 +1811,7 @@ func SetDIBits(hdc HDC, hbmp HBITMAP, uStartScan, cScanLines uint32, lpvBits *by } func SetPixel(hdc HDC, X, Y int32, crColor COLORREF) COLORREF { - ret, _, _ := syscall.Syscall6(setPixel, 4, + ret, _, _ := syscall.Syscall6(setPixel.Addr(), 4, uintptr(hdc), uintptr(X), uintptr(Y), @@ -1822,7 +1823,7 @@ func SetPixel(hdc HDC, X, Y int32, crColor COLORREF) COLORREF { } func SetPixelFormat(hdc HDC, iPixelFormat int32, ppfd *PIXELFORMATDESCRIPTOR) bool { - ret, _, _ := syscall.Syscall(setPixelFormat, 3, + ret, _, _ := syscall.Syscall(setPixelFormat.Addr(), 3, uintptr(hdc), uintptr(iPixelFormat), uintptr(unsafe.Pointer(ppfd))) @@ -1831,7 +1832,7 @@ func SetPixelFormat(hdc HDC, iPixelFormat int32, ppfd *PIXELFORMATDESCRIPTOR) bo } func SetStretchBltMode(hdc HDC, iStretchMode int32) int32 { - ret, _, _ := syscall.Syscall(setStretchBltMode, 2, + ret, _, _ := syscall.Syscall(setStretchBltMode.Addr(), 2, uintptr(hdc), uintptr(iStretchMode), 0) @@ -1840,7 +1841,7 @@ func SetStretchBltMode(hdc HDC, iStretchMode int32) int32 { } func SetTextColor(hdc HDC, crColor COLORREF) COLORREF { - ret, _, _ := syscall.Syscall(setTextColor, 2, + ret, _, _ := syscall.Syscall(setTextColor.Addr(), 2, uintptr(hdc), uintptr(crColor), 0) @@ -1849,7 +1850,7 @@ func SetTextColor(hdc HDC, crColor COLORREF) COLORREF { } func SetViewportOrgEx(hdc HDC, x, y int32, lpPoint *POINT) COLORREF { - ret, _, _ := syscall.Syscall6(setViewportOrgEx, 4, + ret, _, _ := syscall.Syscall6(setViewportOrgEx.Addr(), 4, uintptr(hdc), uintptr(x), uintptr(y), @@ -1861,7 +1862,7 @@ func SetViewportOrgEx(hdc HDC, x, y int32, lpPoint *POINT) COLORREF { } func StartDoc(hdc HDC, lpdi *DOCINFO) int32 { - ret, _, _ := syscall.Syscall(startDoc, 2, + ret, _, _ := syscall.Syscall(startDoc.Addr(), 2, uintptr(hdc), uintptr(unsafe.Pointer(lpdi)), 0) @@ -1870,7 +1871,7 @@ func StartDoc(hdc HDC, lpdi *DOCINFO) int32 { } func StartPage(hdc HDC) int32 { - ret, _, _ := syscall.Syscall(startPage, 1, + ret, _, _ := syscall.Syscall(startPage.Addr(), 1, uintptr(hdc), 0, 0) @@ -1879,7 +1880,7 @@ func StartPage(hdc HDC) int32 { } func StretchBlt(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int32, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int32, dwRop uint32) bool { - ret, _, _ := syscall.Syscall12(stretchBlt, 11, + ret, _, _ := syscall.Syscall12(stretchBlt.Addr(), 11, uintptr(hdcDest), uintptr(nXOriginDest), uintptr(nYOriginDest), @@ -1897,7 +1898,7 @@ func StretchBlt(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest } func SwapBuffers(hdc HDC) bool { - ret, _, _ := syscall.Syscall(swapBuffers, 1, + ret, _, _ := syscall.Syscall(swapBuffers.Addr(), 1, uintptr(hdc), 0, 0) @@ -1906,7 +1907,7 @@ func SwapBuffers(hdc HDC) bool { } func TextOut(hdc HDC, nXStart, nYStart int32, lpString *uint16, cchString int32) bool { - ret, _, _ := syscall.Syscall6(textOut, 5, + ret, _, _ := syscall.Syscall6(textOut.Addr(), 5, uintptr(hdc), uintptr(nXStart), uintptr(nYStart), @@ -1917,7 +1918,7 @@ func TextOut(hdc HDC, nXStart, nYStart int32, lpString *uint16, cchString int32) } func TransparentBlt(hdcDest HDC, xoriginDest, yoriginDest, wDest, hDest int32, hdcSrc HDC, xoriginSrc, yoriginSrc, wSrc, hSrc int32, crTransparent uint32) bool { - ret, _, _ := syscall.Syscall12(transparentBlt, 11, + ret, _, _ := syscall.Syscall12(transparentBlt.Addr(), 11, uintptr(hdcDest), uintptr(xoriginDest), uintptr(yoriginDest), diff --git a/gdiplus.go b/gdiplus.go index 17522622..ac2654b2 100644 --- a/gdiplus.go +++ b/gdiplus.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -130,15 +131,15 @@ type ARGB uint32 var ( // Library - libgdiplus uintptr + libgdiplus *windows.LazyDLL // Functions - gdipCreateBitmapFromFile uintptr - gdipCreateBitmapFromHBITMAP uintptr - gdipCreateHBITMAPFromBitmap uintptr - gdipDisposeImage uintptr - gdiplusShutdown uintptr - gdiplusStartup uintptr + gdipCreateBitmapFromFile *windows.LazyProc + gdipCreateBitmapFromHBITMAP *windows.LazyProc + gdipCreateHBITMAPFromBitmap *windows.LazyProc + gdipDisposeImage *windows.LazyProc + gdiplusShutdown *windows.LazyProc + gdiplusStartup *windows.LazyProc ) var ( @@ -147,19 +148,19 @@ var ( func init() { // Library - libgdiplus = MustLoadLibrary("gdiplus.dll") + libgdiplus = windows.NewLazySystemDLL("gdiplus.dll") // Functions - gdipCreateBitmapFromFile = MustGetProcAddress(libgdiplus, "GdipCreateBitmapFromFile") - gdipCreateBitmapFromHBITMAP = MustGetProcAddress(libgdiplus, "GdipCreateBitmapFromHBITMAP") - gdipCreateHBITMAPFromBitmap = MustGetProcAddress(libgdiplus, "GdipCreateHBITMAPFromBitmap") - gdipDisposeImage = MustGetProcAddress(libgdiplus, "GdipDisposeImage") - gdiplusShutdown = MustGetProcAddress(libgdiplus, "GdiplusShutdown") - gdiplusStartup = MustGetProcAddress(libgdiplus, "GdiplusStartup") + gdipCreateBitmapFromFile = libgdiplus.NewProc("GdipCreateBitmapFromFile") + gdipCreateBitmapFromHBITMAP = libgdiplus.NewProc("GdipCreateBitmapFromHBITMAP") + gdipCreateHBITMAPFromBitmap = libgdiplus.NewProc("GdipCreateHBITMAPFromBitmap") + gdipDisposeImage = libgdiplus.NewProc("GdipDisposeImage") + gdiplusShutdown = libgdiplus.NewProc("GdiplusShutdown") + gdiplusStartup = libgdiplus.NewProc("GdiplusStartup") } func GdipCreateBitmapFromFile(filename *uint16, bitmap **GpBitmap) GpStatus { - ret, _, _ := syscall.Syscall(gdipCreateBitmapFromFile, 2, + ret, _, _ := syscall.Syscall(gdipCreateBitmapFromFile.Addr(), 2, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(bitmap)), 0) @@ -168,7 +169,7 @@ func GdipCreateBitmapFromFile(filename *uint16, bitmap **GpBitmap) GpStatus { } func GdipCreateBitmapFromHBITMAP(hbm HBITMAP, hpal HPALETTE, bitmap **GpBitmap) GpStatus { - ret, _, _ := syscall.Syscall(gdipCreateBitmapFromHBITMAP, 3, + ret, _, _ := syscall.Syscall(gdipCreateBitmapFromHBITMAP.Addr(), 3, uintptr(hbm), uintptr(hpal), uintptr(unsafe.Pointer(bitmap))) @@ -177,7 +178,7 @@ func GdipCreateBitmapFromHBITMAP(hbm HBITMAP, hpal HPALETTE, bitmap **GpBitmap) } func GdipCreateHBITMAPFromBitmap(bitmap *GpBitmap, hbmReturn *HBITMAP, background ARGB) GpStatus { - ret, _, _ := syscall.Syscall(gdipCreateHBITMAPFromBitmap, 3, + ret, _, _ := syscall.Syscall(gdipCreateHBITMAPFromBitmap.Addr(), 3, uintptr(unsafe.Pointer(bitmap)), uintptr(unsafe.Pointer(hbmReturn)), uintptr(background)) @@ -186,7 +187,7 @@ func GdipCreateHBITMAPFromBitmap(bitmap *GpBitmap, hbmReturn *HBITMAP, backgroun } func GdipDisposeImage(image *GpImage) GpStatus { - ret, _, _ := syscall.Syscall(gdipDisposeImage, 1, + ret, _, _ := syscall.Syscall(gdipDisposeImage.Addr(), 1, uintptr(unsafe.Pointer(image)), 0, 0) @@ -195,14 +196,14 @@ func GdipDisposeImage(image *GpImage) GpStatus { } func GdiplusShutdown() { - syscall.Syscall(gdiplusShutdown, 1, + syscall.Syscall(gdiplusShutdown.Addr(), 1, token, 0, 0) } func GdiplusStartup(input *GdiplusStartupInput, output *GdiplusStartupOutput) GpStatus { - ret, _, _ := syscall.Syscall(gdiplusStartup, 3, + ret, _, _ := syscall.Syscall(gdiplusStartup.Addr(), 3, uintptr(unsafe.Pointer(&token)), uintptr(unsafe.Pointer(input)), uintptr(unsafe.Pointer(output))) @@ -211,7 +212,7 @@ func GdiplusStartup(input *GdiplusStartupInput, output *GdiplusStartupOutput) Gp } /*GdipSaveImageToFile(image *GpImage, filename *uint16, clsidEncoder *CLSID, encoderParams *EncoderParameters) GpStatus { - ret, _, _ := syscall.Syscall6(gdipSaveImageToFile, 4, + ret, _, _ := syscall.Syscall6(gdipSaveImageToFile.Addr(), 4, uintptr(unsafe.Pointer(image)), uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(clsidEncoder)), diff --git a/kernel32.go b/kernel32.go index dba014d8..b81b7573 100644 --- a/kernel32.go +++ b/kernel32.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -54,33 +55,33 @@ const ( var ( // Library - libkernel32 uintptr + libkernel32 *windows.LazyDLL // Functions - activateActCtx uintptr - closeHandle uintptr - createActCtx uintptr - fileTimeToSystemTime uintptr - getConsoleTitle uintptr - getConsoleWindow uintptr - getLastError uintptr - getLocaleInfo uintptr - getLogicalDriveStrings uintptr - getModuleHandle uintptr - getNumberFormat uintptr - getPhysicallyInstalledSystemMemory uintptr - getProfileString uintptr - getThreadLocale uintptr - getThreadUILanguage uintptr - getVersion uintptr - globalAlloc uintptr - globalFree uintptr - globalLock uintptr - globalUnlock uintptr - moveMemory uintptr - mulDiv uintptr - setLastError uintptr - systemTimeToFileTime uintptr + activateActCtx *windows.LazyProc + closeHandle *windows.LazyProc + createActCtx *windows.LazyProc + fileTimeToSystemTime *windows.LazyProc + getConsoleTitle *windows.LazyProc + getConsoleWindow *windows.LazyProc + getLastError *windows.LazyProc + getLocaleInfo *windows.LazyProc + getLogicalDriveStrings *windows.LazyProc + getModuleHandle *windows.LazyProc + getNumberFormat *windows.LazyProc + getPhysicallyInstalledSystemMemory *windows.LazyProc + getProfileString *windows.LazyProc + getThreadLocale *windows.LazyProc + getThreadUILanguage *windows.LazyProc + getVersion *windows.LazyProc + globalAlloc *windows.LazyProc + globalFree *windows.LazyProc + globalLock *windows.LazyProc + globalUnlock *windows.LazyProc + moveMemory *windows.LazyProc + mulDiv *windows.LazyProc + setLastError *windows.LazyProc + systemTimeToFileTime *windows.LazyProc ) type ( @@ -134,38 +135,38 @@ type ACTCTX struct { func init() { // Library - libkernel32 = MustLoadLibrary("kernel32.dll") + libkernel32 = windows.NewLazySystemDLL("kernel32.dll") // Functions - activateActCtx = MustGetProcAddress(libkernel32, "ActivateActCtx") - closeHandle = MustGetProcAddress(libkernel32, "CloseHandle") - createActCtx = MustGetProcAddress(libkernel32, "CreateActCtxW") - fileTimeToSystemTime = MustGetProcAddress(libkernel32, "FileTimeToSystemTime") - getConsoleTitle = MustGetProcAddress(libkernel32, "GetConsoleTitleW") - getConsoleWindow = MustGetProcAddress(libkernel32, "GetConsoleWindow") - getLastError = MustGetProcAddress(libkernel32, "GetLastError") - getLocaleInfo = MustGetProcAddress(libkernel32, "GetLocaleInfoW") - getLogicalDriveStrings = MustGetProcAddress(libkernel32, "GetLogicalDriveStringsW") - getModuleHandle = MustGetProcAddress(libkernel32, "GetModuleHandleW") - getNumberFormat = MustGetProcAddress(libkernel32, "GetNumberFormatW") - getPhysicallyInstalledSystemMemory, _ = syscall.GetProcAddress(syscall.Handle(libkernel32), "GetPhysicallyInstalledSystemMemory") - getProfileString = MustGetProcAddress(libkernel32, "GetProfileStringW") - getThreadLocale = MustGetProcAddress(libkernel32, "GetThreadLocale") - getThreadUILanguage, _ = syscall.GetProcAddress(syscall.Handle(libkernel32), "GetThreadUILanguage") - getVersion = MustGetProcAddress(libkernel32, "GetVersion") - globalAlloc = MustGetProcAddress(libkernel32, "GlobalAlloc") - globalFree = MustGetProcAddress(libkernel32, "GlobalFree") - globalLock = MustGetProcAddress(libkernel32, "GlobalLock") - globalUnlock = MustGetProcAddress(libkernel32, "GlobalUnlock") - moveMemory = MustGetProcAddress(libkernel32, "RtlMoveMemory") - mulDiv = MustGetProcAddress(libkernel32, "MulDiv") - setLastError = MustGetProcAddress(libkernel32, "SetLastError") - systemTimeToFileTime = MustGetProcAddress(libkernel32, "SystemTimeToFileTime") + activateActCtx = libkernel32.NewProc("ActivateActCtx") + closeHandle = libkernel32.NewProc("CloseHandle") + createActCtx = libkernel32.NewProc("CreateActCtxW") + fileTimeToSystemTime = libkernel32.NewProc("FileTimeToSystemTime") + getConsoleTitle = libkernel32.NewProc("GetConsoleTitleW") + getConsoleWindow = libkernel32.NewProc("GetConsoleWindow") + getLastError = libkernel32.NewProc("GetLastError") + getLocaleInfo = libkernel32.NewProc("GetLocaleInfoW") + getLogicalDriveStrings = libkernel32.NewProc("GetLogicalDriveStringsW") + getModuleHandle = libkernel32.NewProc("GetModuleHandleW") + getNumberFormat = libkernel32.NewProc("GetNumberFormatW") + getPhysicallyInstalledSystemMemory = libkernel32.NewProc("GetPhysicallyInstalledSystemMemory") + getProfileString = libkernel32.NewProc("GetProfileStringW") + getThreadLocale = libkernel32.NewProc("GetThreadLocale") + getThreadUILanguage = libkernel32.NewProc("GetThreadUILanguage") + getVersion = libkernel32.NewProc("GetVersion") + globalAlloc = libkernel32.NewProc("GlobalAlloc") + globalFree = libkernel32.NewProc("GlobalFree") + globalLock = libkernel32.NewProc("GlobalLock") + globalUnlock = libkernel32.NewProc("GlobalUnlock") + moveMemory = libkernel32.NewProc("RtlMoveMemory") + mulDiv = libkernel32.NewProc("MulDiv") + setLastError = libkernel32.NewProc("SetLastError") + systemTimeToFileTime = libkernel32.NewProc("SystemTimeToFileTime") } func ActivateActCtx(ctx HANDLE) (uintptr, bool) { var cookie uintptr - ret, _, _ := syscall.Syscall(activateActCtx, 2, + ret, _, _ := syscall.Syscall(activateActCtx.Addr(), 2, uintptr(ctx), uintptr(unsafe.Pointer(&cookie)), 0) @@ -173,7 +174,7 @@ func ActivateActCtx(ctx HANDLE) (uintptr, bool) { } func CloseHandle(hObject HANDLE) bool { - ret, _, _ := syscall.Syscall(closeHandle, 1, + ret, _, _ := syscall.Syscall(closeHandle.Addr(), 1, uintptr(hObject), 0, 0) @@ -186,7 +187,7 @@ func CreateActCtx(ctx *ACTCTX) HANDLE { ctx.size = uint32(unsafe.Sizeof(*ctx)) } ret, _, _ := syscall.Syscall( - createActCtx, + createActCtx.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, @@ -195,7 +196,7 @@ func CreateActCtx(ctx *ACTCTX) HANDLE { } func FileTimeToSystemTime(lpFileTime *FILETIME, lpSystemTime *SYSTEMTIME) bool { - ret, _, _ := syscall.Syscall(fileTimeToSystemTime, 2, + ret, _, _ := syscall.Syscall(fileTimeToSystemTime.Addr(), 2, uintptr(unsafe.Pointer(lpFileTime)), uintptr(unsafe.Pointer(lpSystemTime)), 0) @@ -204,7 +205,7 @@ func FileTimeToSystemTime(lpFileTime *FILETIME, lpSystemTime *SYSTEMTIME) bool { } func GetConsoleTitle(lpConsoleTitle *uint16, nSize uint32) uint32 { - ret, _, _ := syscall.Syscall(getConsoleTitle, 2, + ret, _, _ := syscall.Syscall(getConsoleTitle.Addr(), 2, uintptr(unsafe.Pointer(lpConsoleTitle)), uintptr(nSize), 0) @@ -213,7 +214,7 @@ func GetConsoleTitle(lpConsoleTitle *uint16, nSize uint32) uint32 { } func GetConsoleWindow() HWND { - ret, _, _ := syscall.Syscall(getConsoleWindow, 0, + ret, _, _ := syscall.Syscall(getConsoleWindow.Addr(), 0, 0, 0, 0) @@ -222,7 +223,7 @@ func GetConsoleWindow() HWND { } func GetLastError() uint32 { - ret, _, _ := syscall.Syscall(getLastError, 0, + ret, _, _ := syscall.Syscall(getLastError.Addr(), 0, 0, 0, 0) @@ -231,7 +232,7 @@ func GetLastError() uint32 { } func GetLocaleInfo(Locale LCID, LCType LCTYPE, lpLCData *uint16, cchData int32) int32 { - ret, _, _ := syscall.Syscall6(getLocaleInfo, 4, + ret, _, _ := syscall.Syscall6(getLocaleInfo.Addr(), 4, uintptr(Locale), uintptr(LCType), uintptr(unsafe.Pointer(lpLCData)), @@ -243,7 +244,7 @@ func GetLocaleInfo(Locale LCID, LCType LCTYPE, lpLCData *uint16, cchData int32) } func GetLogicalDriveStrings(nBufferLength uint32, lpBuffer *uint16) uint32 { - ret, _, _ := syscall.Syscall(getLogicalDriveStrings, 2, + ret, _, _ := syscall.Syscall(getLogicalDriveStrings.Addr(), 2, uintptr(nBufferLength), uintptr(unsafe.Pointer(lpBuffer)), 0) @@ -252,7 +253,7 @@ func GetLogicalDriveStrings(nBufferLength uint32, lpBuffer *uint16) uint32 { } func GetModuleHandle(lpModuleName *uint16) HINSTANCE { - ret, _, _ := syscall.Syscall(getModuleHandle, 1, + ret, _, _ := syscall.Syscall(getModuleHandle.Addr(), 1, uintptr(unsafe.Pointer(lpModuleName)), 0, 0) @@ -261,7 +262,7 @@ func GetModuleHandle(lpModuleName *uint16) HINSTANCE { } func GetNumberFormat(Locale LCID, dwFlags uint32, lpValue *uint16, lpFormat *NUMBERFMT, lpNumberStr *uint16, cchNumber int32) int32 { - ret, _, _ := syscall.Syscall6(getNumberFormat, 6, + ret, _, _ := syscall.Syscall6(getNumberFormat.Addr(), 6, uintptr(Locale), uintptr(dwFlags), uintptr(unsafe.Pointer(lpValue)), @@ -273,7 +274,10 @@ func GetNumberFormat(Locale LCID, dwFlags uint32, lpValue *uint16, lpFormat *NUM } func GetPhysicallyInstalledSystemMemory(totalMemoryInKilobytes *uint64) bool { - ret, _, _ := syscall.Syscall(getPhysicallyInstalledSystemMemory, 1, + if getPhysicallyInstalledSystemMemory.Find() != nil { + return false + } + ret, _, _ := syscall.Syscall(getPhysicallyInstalledSystemMemory.Addr(), 1, uintptr(unsafe.Pointer(totalMemoryInKilobytes)), 0, 0) @@ -282,7 +286,7 @@ func GetPhysicallyInstalledSystemMemory(totalMemoryInKilobytes *uint64) bool { } func GetProfileString(lpAppName, lpKeyName, lpDefault *uint16, lpReturnedString uintptr, nSize uint32) bool { - ret, _, _ := syscall.Syscall6(getProfileString, 5, + ret, _, _ := syscall.Syscall6(getProfileString.Addr(), 5, uintptr(unsafe.Pointer(lpAppName)), uintptr(unsafe.Pointer(lpKeyName)), uintptr(unsafe.Pointer(lpDefault)), @@ -293,7 +297,7 @@ func GetProfileString(lpAppName, lpKeyName, lpDefault *uint16, lpReturnedString } func GetThreadLocale() LCID { - ret, _, _ := syscall.Syscall(getThreadLocale, 0, + ret, _, _ := syscall.Syscall(getThreadLocale.Addr(), 0, 0, 0, 0) @@ -302,11 +306,11 @@ func GetThreadLocale() LCID { } func GetThreadUILanguage() LANGID { - if getThreadUILanguage == 0 { + if getThreadUILanguage.Find() != nil { return 0 } - ret, _, _ := syscall.Syscall(getThreadUILanguage, 0, + ret, _, _ := syscall.Syscall(getThreadUILanguage.Addr(), 0, 0, 0, 0) @@ -315,7 +319,7 @@ func GetThreadUILanguage() LANGID { } func GetVersion() int64 { - ret, _, _ := syscall.Syscall(getVersion, 0, + ret, _, _ := syscall.Syscall(getVersion.Addr(), 0, 0, 0, 0) @@ -323,7 +327,7 @@ func GetVersion() int64 { } func GlobalAlloc(uFlags uint32, dwBytes uintptr) HGLOBAL { - ret, _, _ := syscall.Syscall(globalAlloc, 2, + ret, _, _ := syscall.Syscall(globalAlloc.Addr(), 2, uintptr(uFlags), dwBytes, 0) @@ -332,7 +336,7 @@ func GlobalAlloc(uFlags uint32, dwBytes uintptr) HGLOBAL { } func GlobalFree(hMem HGLOBAL) HGLOBAL { - ret, _, _ := syscall.Syscall(globalFree, 1, + ret, _, _ := syscall.Syscall(globalFree.Addr(), 1, uintptr(hMem), 0, 0) @@ -341,7 +345,7 @@ func GlobalFree(hMem HGLOBAL) HGLOBAL { } func GlobalLock(hMem HGLOBAL) unsafe.Pointer { - ret, _, _ := syscall.Syscall(globalLock, 1, + ret, _, _ := syscall.Syscall(globalLock.Addr(), 1, uintptr(hMem), 0, 0) @@ -350,7 +354,7 @@ func GlobalLock(hMem HGLOBAL) unsafe.Pointer { } func GlobalUnlock(hMem HGLOBAL) bool { - ret, _, _ := syscall.Syscall(globalUnlock, 1, + ret, _, _ := syscall.Syscall(globalUnlock.Addr(), 1, uintptr(hMem), 0, 0) @@ -359,14 +363,14 @@ func GlobalUnlock(hMem HGLOBAL) bool { } func MoveMemory(destination, source unsafe.Pointer, length uintptr) { - syscall.Syscall(moveMemory, 3, + syscall.Syscall(moveMemory.Addr(), 3, uintptr(unsafe.Pointer(destination)), uintptr(source), uintptr(length)) } func MulDiv(nNumber, nNumerator, nDenominator int32) int32 { - ret, _, _ := syscall.Syscall(mulDiv, 3, + ret, _, _ := syscall.Syscall(mulDiv.Addr(), 3, uintptr(nNumber), uintptr(nNumerator), uintptr(nDenominator)) @@ -375,14 +379,14 @@ func MulDiv(nNumber, nNumerator, nDenominator int32) int32 { } func SetLastError(dwErrorCode uint32) { - syscall.Syscall(setLastError, 1, + syscall.Syscall(setLastError.Addr(), 1, uintptr(dwErrorCode), 0, 0) } func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { - ret, _, _ := syscall.Syscall(systemTimeToFileTime, 2, + ret, _, _ := syscall.Syscall(systemTimeToFileTime.Addr(), 2, uintptr(unsafe.Pointer(lpSystemTime)), uintptr(unsafe.Pointer(lpFileTime)), 0) diff --git a/ole32.go b/ole32.go index d75dee74..15d6fd27 100644 --- a/ole32.go +++ b/ole32.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -419,32 +420,32 @@ type COSERVERINFO struct { var ( // Library - libole32 uintptr + libole32 *windows.LazyDLL // Functions - coCreateInstance uintptr - coGetClassObject uintptr - coTaskMemFree uintptr - oleInitialize uintptr - oleSetContainedObject uintptr - oleUninitialize uintptr + coCreateInstance *windows.LazyProc + coGetClassObject *windows.LazyProc + coTaskMemFree *windows.LazyProc + oleInitialize *windows.LazyProc + oleSetContainedObject *windows.LazyProc + oleUninitialize *windows.LazyProc ) func init() { // Library - libole32 = MustLoadLibrary("ole32.dll") + libole32 = windows.NewLazySystemDLL("ole32.dll") // Functions - coCreateInstance = MustGetProcAddress(libole32, "CoCreateInstance") - coGetClassObject = MustGetProcAddress(libole32, "CoGetClassObject") - coTaskMemFree = MustGetProcAddress(libole32, "CoTaskMemFree") - oleInitialize = MustGetProcAddress(libole32, "OleInitialize") - oleSetContainedObject = MustGetProcAddress(libole32, "OleSetContainedObject") - oleUninitialize = MustGetProcAddress(libole32, "OleUninitialize") + coCreateInstance = libole32.NewProc("CoCreateInstance") + coGetClassObject = libole32.NewProc("CoGetClassObject") + coTaskMemFree = libole32.NewProc("CoTaskMemFree") + oleInitialize = libole32.NewProc("OleInitialize") + oleSetContainedObject = libole32.NewProc("OleSetContainedObject") + oleUninitialize = libole32.NewProc("OleUninitialize") } func CoCreateInstance(rclsid REFCLSID, pUnkOuter *IUnknown, dwClsContext uint32, riid REFIID, ppv *unsafe.Pointer) HRESULT { - ret, _, _ := syscall.Syscall6(coCreateInstance, 5, + ret, _, _ := syscall.Syscall6(coCreateInstance.Addr(), 5, uintptr(unsafe.Pointer(rclsid)), uintptr(unsafe.Pointer(pUnkOuter)), uintptr(dwClsContext), @@ -456,7 +457,7 @@ func CoCreateInstance(rclsid REFCLSID, pUnkOuter *IUnknown, dwClsContext uint32, } func CoGetClassObject(rclsid REFCLSID, dwClsContext uint32, pServerInfo *COSERVERINFO, riid REFIID, ppv *unsafe.Pointer) HRESULT { - ret, _, _ := syscall.Syscall6(coGetClassObject, 5, + ret, _, _ := syscall.Syscall6(coGetClassObject.Addr(), 5, uintptr(unsafe.Pointer(rclsid)), uintptr(dwClsContext), uintptr(unsafe.Pointer(pServerInfo)), @@ -468,14 +469,14 @@ func CoGetClassObject(rclsid REFCLSID, dwClsContext uint32, pServerInfo *COSERVE } func CoTaskMemFree(pv uintptr) { - syscall.Syscall(coTaskMemFree, 1, + syscall.Syscall(coTaskMemFree.Addr(), 1, pv, 0, 0) } func OleInitialize() HRESULT { - ret, _, _ := syscall.Syscall(oleInitialize, 1, // WTF, why does 0 not work here? + ret, _, _ := syscall.Syscall(oleInitialize.Addr(), 1, // WTF, why does 0 not work here? 0, 0, 0) @@ -484,7 +485,7 @@ func OleInitialize() HRESULT { } func OleSetContainedObject(pUnknown *IUnknown, fContained bool) HRESULT { - ret, _, _ := syscall.Syscall(oleSetContainedObject, 2, + ret, _, _ := syscall.Syscall(oleSetContainedObject.Addr(), 2, uintptr(unsafe.Pointer(pUnknown)), uintptr(BoolToBOOL(fContained)), 0) @@ -493,7 +494,7 @@ func OleSetContainedObject(pUnknown *IUnknown, fContained bool) HRESULT { } func OleUninitialize() { - syscall.Syscall(oleUninitialize, 0, + syscall.Syscall(oleUninitialize.Addr(), 0, 0, 0, 0) diff --git a/oleaut32.go b/oleaut32.go index 9d0e0167..e693fffc 100644 --- a/oleaut32.go +++ b/oleaut32.go @@ -8,6 +8,7 @@ package win import ( "fmt" + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -418,26 +419,26 @@ type DISPPARAMS struct { var ( // Library - liboleaut32 uintptr + liboleaut32 *windows.LazyDLL // Functions - sysAllocString uintptr - sysFreeString uintptr - sysStringLen uintptr + sysAllocString *windows.LazyProc + sysFreeString *windows.LazyProc + sysStringLen *windows.LazyProc ) func init() { // Library - liboleaut32 = MustLoadLibrary("oleaut32.dll") + liboleaut32 = windows.NewLazySystemDLL("oleaut32.dll") // Functions - sysAllocString = MustGetProcAddress(liboleaut32, "SysAllocString") - sysFreeString = MustGetProcAddress(liboleaut32, "SysFreeString") - sysStringLen = MustGetProcAddress(liboleaut32, "SysStringLen") + sysAllocString = liboleaut32.NewProc("SysAllocString") + sysFreeString = liboleaut32.NewProc("SysFreeString") + sysStringLen = liboleaut32.NewProc("SysStringLen") } func SysAllocString(s string) *uint16 /*BSTR*/ { - ret, _, _ := syscall.Syscall(sysAllocString, 1, + ret, _, _ := syscall.Syscall(sysAllocString.Addr(), 1, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s))), 0, 0) @@ -446,14 +447,14 @@ func SysAllocString(s string) *uint16 /*BSTR*/ { } func SysFreeString(bstr *uint16 /*BSTR*/) { - syscall.Syscall(sysFreeString, 1, + syscall.Syscall(sysFreeString.Addr(), 1, uintptr(unsafe.Pointer(bstr)), 0, 0) } func SysStringLen(bstr *uint16 /*BSTR*/) uint32 { - ret, _, _ := syscall.Syscall(sysStringLen, 1, + ret, _, _ := syscall.Syscall(sysStringLen.Addr(), 1, uintptr(unsafe.Pointer(bstr)), 0, 0) diff --git a/opengl32.go b/opengl32.go index dbacc220..1dbd6c38 100644 --- a/opengl32.go +++ b/opengl32.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -91,52 +92,52 @@ type GLYPHMETRICSFLOAT struct { var ( // Library - lib uintptr + lib *windows.LazyDLL // Functions - wglCopyContext uintptr - wglCreateContext uintptr - wglCreateLayerContext uintptr - wglDeleteContext uintptr - wglDescribeLayerPlane uintptr - wglGetCurrentContext uintptr - wglGetCurrentDC uintptr - wglGetLayerPaletteEntries uintptr - wglGetProcAddress uintptr - wglMakeCurrent uintptr - wglRealizeLayerPalette uintptr - wglSetLayerPaletteEntries uintptr - wglShareLists uintptr - wglSwapLayerBuffers uintptr - wglUseFontBitmaps uintptr - wglUseFontOutlines uintptr + wglCopyContext *windows.LazyProc + wglCreateContext *windows.LazyProc + wglCreateLayerContext *windows.LazyProc + wglDeleteContext *windows.LazyProc + wglDescribeLayerPlane *windows.LazyProc + wglGetCurrentContext *windows.LazyProc + wglGetCurrentDC *windows.LazyProc + wglGetLayerPaletteEntries *windows.LazyProc + wglGetProcAddress *windows.LazyProc + wglMakeCurrent *windows.LazyProc + wglRealizeLayerPalette *windows.LazyProc + wglSetLayerPaletteEntries *windows.LazyProc + wglShareLists *windows.LazyProc + wglSwapLayerBuffers *windows.LazyProc + wglUseFontBitmaps *windows.LazyProc + wglUseFontOutlines *windows.LazyProc ) func init() { // Library - lib = MustLoadLibrary("opengl32.dll") + lib = windows.NewLazySystemDLL("opengl32.dll") // Functions - wglCopyContext = MustGetProcAddress(lib, "wglCopyContext") - wglCreateContext = MustGetProcAddress(lib, "wglCreateContext") - wglCreateLayerContext = MustGetProcAddress(lib, "wglCreateLayerContext") - wglDeleteContext = MustGetProcAddress(lib, "wglDeleteContext") - wglDescribeLayerPlane = MustGetProcAddress(lib, "wglDescribeLayerPlane") - wglGetCurrentContext = MustGetProcAddress(lib, "wglGetCurrentContext") - wglGetCurrentDC = MustGetProcAddress(lib, "wglGetCurrentDC") - wglGetLayerPaletteEntries = MustGetProcAddress(lib, "wglGetLayerPaletteEntries") - wglGetProcAddress = MustGetProcAddress(lib, "wglGetProcAddress") - wglMakeCurrent = MustGetProcAddress(lib, "wglMakeCurrent") - wglRealizeLayerPalette = MustGetProcAddress(lib, "wglRealizeLayerPalette") - wglSetLayerPaletteEntries = MustGetProcAddress(lib, "wglSetLayerPaletteEntries") - wglShareLists = MustGetProcAddress(lib, "wglShareLists") - wglSwapLayerBuffers = MustGetProcAddress(lib, "wglSwapLayerBuffers") - wglUseFontBitmaps = MustGetProcAddress(lib, "wglUseFontBitmapsW") - wglUseFontOutlines = MustGetProcAddress(lib, "wglUseFontOutlinesW") + wglCopyContext = lib.NewProc("wglCopyContext") + wglCreateContext = lib.NewProc("wglCreateContext") + wglCreateLayerContext = lib.NewProc("wglCreateLayerContext") + wglDeleteContext = lib.NewProc("wglDeleteContext") + wglDescribeLayerPlane = lib.NewProc("wglDescribeLayerPlane") + wglGetCurrentContext = lib.NewProc("wglGetCurrentContext") + wglGetCurrentDC = lib.NewProc("wglGetCurrentDC") + wglGetLayerPaletteEntries = lib.NewProc("wglGetLayerPaletteEntries") + wglGetProcAddress = lib.NewProc("wglGetProcAddress") + wglMakeCurrent = lib.NewProc("wglMakeCurrent") + wglRealizeLayerPalette = lib.NewProc("wglRealizeLayerPalette") + wglSetLayerPaletteEntries = lib.NewProc("wglSetLayerPaletteEntries") + wglShareLists = lib.NewProc("wglShareLists") + wglSwapLayerBuffers = lib.NewProc("wglSwapLayerBuffers") + wglUseFontBitmaps = lib.NewProc("wglUseFontBitmapsW") + wglUseFontOutlines = lib.NewProc("wglUseFontOutlinesW") } func WglCopyContext(hglrcSrc, hglrcDst HGLRC, mask uint) bool { - ret, _, _ := syscall.Syscall(wglCopyContext, 3, + ret, _, _ := syscall.Syscall(wglCopyContext.Addr(), 3, uintptr(hglrcSrc), uintptr(hglrcDst), uintptr(mask)) @@ -145,7 +146,7 @@ func WglCopyContext(hglrcSrc, hglrcDst HGLRC, mask uint) bool { } func WglCreateContext(hdc HDC) HGLRC { - ret, _, _ := syscall.Syscall(wglCreateContext, 1, + ret, _, _ := syscall.Syscall(wglCreateContext.Addr(), 1, uintptr(hdc), 0, 0) @@ -154,7 +155,7 @@ func WglCreateContext(hdc HDC) HGLRC { } func WglCreateLayerContext(hdc HDC, iLayerPlane int) HGLRC { - ret, _, _ := syscall.Syscall(wglCreateLayerContext, 2, + ret, _, _ := syscall.Syscall(wglCreateLayerContext.Addr(), 2, uintptr(hdc), uintptr(iLayerPlane), 0) @@ -163,7 +164,7 @@ func WglCreateLayerContext(hdc HDC, iLayerPlane int) HGLRC { } func WglDeleteContext(hglrc HGLRC) bool { - ret, _, _ := syscall.Syscall(wglDeleteContext, 1, + ret, _, _ := syscall.Syscall(wglDeleteContext.Addr(), 1, uintptr(hglrc), 0, 0) @@ -172,7 +173,7 @@ func WglDeleteContext(hglrc HGLRC) bool { } func WglDescribeLayerPlane(hdc HDC, iPixelFormat, iLayerPlane int, nBytes uint8, plpd *LAYERPLANEDESCRIPTOR) bool { - ret, _, _ := syscall.Syscall6(wglDescribeLayerPlane, 5, + ret, _, _ := syscall.Syscall6(wglDescribeLayerPlane.Addr(), 5, uintptr(hdc), uintptr(iPixelFormat), uintptr(iLayerPlane), @@ -184,7 +185,7 @@ func WglDescribeLayerPlane(hdc HDC, iPixelFormat, iLayerPlane int, nBytes uint8, } func WglGetCurrentContext() HGLRC { - ret, _, _ := syscall.Syscall(wglGetCurrentContext, 0, + ret, _, _ := syscall.Syscall(wglGetCurrentContext.Addr(), 0, 0, 0, 0) @@ -193,7 +194,7 @@ func WglGetCurrentContext() HGLRC { } func WglGetCurrentDC() HDC { - ret, _, _ := syscall.Syscall(wglGetCurrentDC, 0, + ret, _, _ := syscall.Syscall(wglGetCurrentDC.Addr(), 0, 0, 0, 0) @@ -202,7 +203,7 @@ func WglGetCurrentDC() HDC { } func WglGetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr *COLORREF) int { - ret, _, _ := syscall.Syscall6(wglGetLayerPaletteEntries, 5, + ret, _, _ := syscall.Syscall6(wglGetLayerPaletteEntries.Addr(), 5, uintptr(hdc), uintptr(iLayerPlane), uintptr(iStart), @@ -214,7 +215,7 @@ func WglGetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr * } func WglGetProcAddress(lpszProc *byte) uintptr { - ret, _, _ := syscall.Syscall(wglGetProcAddress, 1, + ret, _, _ := syscall.Syscall(wglGetProcAddress.Addr(), 1, uintptr(unsafe.Pointer(lpszProc)), 0, 0) @@ -223,7 +224,7 @@ func WglGetProcAddress(lpszProc *byte) uintptr { } func WglMakeCurrent(hdc HDC, hglrc HGLRC) bool { - ret, _, _ := syscall.Syscall(wglMakeCurrent, 2, + ret, _, _ := syscall.Syscall(wglMakeCurrent.Addr(), 2, uintptr(hdc), uintptr(hglrc), 0) @@ -232,7 +233,7 @@ func WglMakeCurrent(hdc HDC, hglrc HGLRC) bool { } func WglRealizeLayerPalette(hdc HDC, iLayerPlane int, bRealize bool) bool { - ret, _, _ := syscall.Syscall(wglRealizeLayerPalette, 3, + ret, _, _ := syscall.Syscall(wglRealizeLayerPalette.Addr(), 3, uintptr(hdc), uintptr(iLayerPlane), uintptr(BoolToBOOL(bRealize))) @@ -241,7 +242,7 @@ func WglRealizeLayerPalette(hdc HDC, iLayerPlane int, bRealize bool) bool { } func WglSetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr *COLORREF) int { - ret, _, _ := syscall.Syscall6(wglSetLayerPaletteEntries, 5, + ret, _, _ := syscall.Syscall6(wglSetLayerPaletteEntries.Addr(), 5, uintptr(hdc), uintptr(iLayerPlane), uintptr(iStart), @@ -253,7 +254,7 @@ func WglSetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr * } func WglShareLists(hglrc1, hglrc2 HGLRC) bool { - ret, _, _ := syscall.Syscall(wglShareLists, 2, + ret, _, _ := syscall.Syscall(wglShareLists.Addr(), 2, uintptr(hglrc1), uintptr(hglrc2), 0) @@ -262,7 +263,7 @@ func WglShareLists(hglrc1, hglrc2 HGLRC) bool { } func WglSwapLayerBuffers(hdc HDC, fuPlanes uint) bool { - ret, _, _ := syscall.Syscall(wglSwapLayerBuffers, 2, + ret, _, _ := syscall.Syscall(wglSwapLayerBuffers.Addr(), 2, uintptr(hdc), uintptr(fuPlanes), 0) @@ -271,7 +272,7 @@ func WglSwapLayerBuffers(hdc HDC, fuPlanes uint) bool { } func WglUseFontBitmaps(hdc HDC, first, count, listbase uint32) bool { - ret, _, _ := syscall.Syscall6(wglUseFontBitmaps, 4, + ret, _, _ := syscall.Syscall6(wglUseFontBitmaps.Addr(), 4, uintptr(hdc), uintptr(first), uintptr(count), @@ -283,7 +284,7 @@ func WglUseFontBitmaps(hdc HDC, first, count, listbase uint32) bool { } func WglUseFontOutlines(hdc HDC, first, count, listbase uint32, deviation, extrusion float32, format int, pgmf *GLYPHMETRICSFLOAT) bool { - ret, _, _ := syscall.Syscall12(wglUseFontBitmaps, 8, + ret, _, _ := syscall.Syscall12(wglUseFontBitmaps.Addr(), 8, uintptr(hdc), uintptr(first), uintptr(count), diff --git a/pdh.go b/pdh.go index ca594fe4..a18b2608 100644 --- a/pdh.go +++ b/pdh.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -161,32 +162,32 @@ type PDH_FMT_COUNTERVALUE_ITEM_LONG struct { var ( // Library - libpdhDll *syscall.DLL + libpdhDll *windows.LazyDLL // Functions - pdh_AddCounterW *syscall.Proc - pdh_AddEnglishCounterW *syscall.Proc - pdh_CloseQuery *syscall.Proc - pdh_CollectQueryData *syscall.Proc - pdh_GetFormattedCounterValue *syscall.Proc - pdh_GetFormattedCounterArrayW *syscall.Proc - pdh_OpenQuery *syscall.Proc - pdh_ValidatePathW *syscall.Proc + pdh_AddCounterW *windows.LazyProc + pdh_AddEnglishCounterW *windows.LazyProc + pdh_CloseQuery *windows.LazyProc + pdh_CollectQueryData *windows.LazyProc + pdh_GetFormattedCounterValue *windows.LazyProc + pdh_GetFormattedCounterArrayW *windows.LazyProc + pdh_OpenQuery *windows.LazyProc + pdh_ValidatePathW *windows.LazyProc ) func init() { // Library - libpdhDll = syscall.MustLoadDLL("pdh.dll") + libpdhDll = windows.NewLazySystemDLL("pdh.dll") // Functions - pdh_AddCounterW = libpdhDll.MustFindProc("PdhAddCounterW") - pdh_AddEnglishCounterW, _ = libpdhDll.FindProc("PdhAddEnglishCounterW") // XXX: only supported on versions > Vista. - pdh_CloseQuery = libpdhDll.MustFindProc("PdhCloseQuery") - pdh_CollectQueryData = libpdhDll.MustFindProc("PdhCollectQueryData") - pdh_GetFormattedCounterValue = libpdhDll.MustFindProc("PdhGetFormattedCounterValue") - pdh_GetFormattedCounterArrayW = libpdhDll.MustFindProc("PdhGetFormattedCounterArrayW") - pdh_OpenQuery = libpdhDll.MustFindProc("PdhOpenQuery") - pdh_ValidatePathW = libpdhDll.MustFindProc("PdhValidatePathW") + pdh_AddCounterW = libpdhDll.NewProc("PdhAddCounterW") + pdh_AddEnglishCounterW = libpdhDll.NewProc("PdhAddEnglishCounterW") + pdh_CloseQuery = libpdhDll.NewProc("PdhCloseQuery") + pdh_CollectQueryData = libpdhDll.NewProc("PdhCollectQueryData") + pdh_GetFormattedCounterValue = libpdhDll.NewProc("PdhGetFormattedCounterValue") + pdh_GetFormattedCounterArrayW = libpdhDll.NewProc("PdhGetFormattedCounterArrayW") + pdh_OpenQuery = libpdhDll.NewProc("PdhOpenQuery") + pdh_ValidatePathW = libpdhDll.NewProc("PdhValidatePathW") } // Adds the specified counter to the query. This is the internationalized version. Preferably, use the @@ -241,7 +242,7 @@ func PdhAddCounter(hQuery PDH_HQUERY, szFullCounterPath string, dwUserData uintp // Adds the specified language-neutral counter to the query. See the PdhAddCounter function. This function only exists on // Windows versions higher than Vista. func PdhAddEnglishCounter(hQuery PDH_HQUERY, szFullCounterPath string, dwUserData uintptr, phCounter *PDH_HCOUNTER) uint32 { - if pdh_AddEnglishCounterW == nil { + if pdh_AddEnglishCounterW.Find() != nil { return ERROR_INVALID_FUNCTION } diff --git a/shell32.go b/shell32.go index e9aa4bf7..d530b8a2 100644 --- a/shell32.go +++ b/shell32.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -293,40 +294,40 @@ type SHSTOCKICONINFO struct { var ( // Library - libshell32 uintptr + libshell32 *windows.LazyDLL // Functions - dragAcceptFiles uintptr - dragFinish uintptr - dragQueryFile uintptr - shBrowseForFolder uintptr - shGetFileInfo uintptr - shGetPathFromIDList uintptr - shGetSpecialFolderPath uintptr - shParseDisplayName uintptr - shGetStockIconInfo uintptr - shell_NotifyIcon uintptr + dragAcceptFiles *windows.LazyProc + dragFinish *windows.LazyProc + dragQueryFile *windows.LazyProc + shBrowseForFolder *windows.LazyProc + shGetFileInfo *windows.LazyProc + shGetPathFromIDList *windows.LazyProc + shGetSpecialFolderPath *windows.LazyProc + shParseDisplayName *windows.LazyProc + shGetStockIconInfo *windows.LazyProc + shell_NotifyIcon *windows.LazyProc ) func init() { // Library - libshell32 = MustLoadLibrary("shell32.dll") + libshell32 = windows.NewLazySystemDLL("shell32.dll") // Functions - dragAcceptFiles = MustGetProcAddress(libshell32, "DragAcceptFiles") - dragFinish = MustGetProcAddress(libshell32, "DragFinish") - dragQueryFile = MustGetProcAddress(libshell32, "DragQueryFileW") - shBrowseForFolder = MustGetProcAddress(libshell32, "SHBrowseForFolderW") - shGetFileInfo = MustGetProcAddress(libshell32, "SHGetFileInfoW") - shGetPathFromIDList = MustGetProcAddress(libshell32, "SHGetPathFromIDListW") - shGetSpecialFolderPath = MustGetProcAddress(libshell32, "SHGetSpecialFolderPathW") - shGetStockIconInfo = MaybeGetProcAddress(libshell32, "SHGetStockIconInfo") - shell_NotifyIcon = MustGetProcAddress(libshell32, "Shell_NotifyIconW") - shParseDisplayName = MustGetProcAddress(libshell32, "SHParseDisplayName") + dragAcceptFiles = libshell32.NewProc("DragAcceptFiles") + dragFinish = libshell32.NewProc("DragFinish") + dragQueryFile = libshell32.NewProc("DragQueryFileW") + shBrowseForFolder = libshell32.NewProc("SHBrowseForFolderW") + shGetFileInfo = libshell32.NewProc("SHGetFileInfoW") + shGetPathFromIDList = libshell32.NewProc("SHGetPathFromIDListW") + shGetSpecialFolderPath = libshell32.NewProc("SHGetSpecialFolderPathW") + shGetStockIconInfo = libshell32.NewProc("SHGetStockIconInfo") + shell_NotifyIcon = libshell32.NewProc("Shell_NotifyIconW") + shParseDisplayName = libshell32.NewProc("SHParseDisplayName") } func DragAcceptFiles(hWnd HWND, fAccept bool) bool { - ret, _, _ := syscall.Syscall(dragAcceptFiles, 2, + ret, _, _ := syscall.Syscall(dragAcceptFiles.Addr(), 2, uintptr(hWnd), uintptr(BoolToBOOL(fAccept)), 0) @@ -335,7 +336,7 @@ func DragAcceptFiles(hWnd HWND, fAccept bool) bool { } func DragQueryFile(hDrop HDROP, iFile uint, lpszFile *uint16, cch uint) uint { - ret, _, _ := syscall.Syscall6(dragQueryFile, 4, + ret, _, _ := syscall.Syscall6(dragQueryFile.Addr(), 4, uintptr(hDrop), uintptr(iFile), uintptr(unsafe.Pointer(lpszFile)), @@ -347,14 +348,14 @@ func DragQueryFile(hDrop HDROP, iFile uint, lpszFile *uint16, cch uint) uint { } func DragFinish(hDrop HDROP) { - syscall.Syscall(dragAcceptFiles, 1, + syscall.Syscall(dragAcceptFiles.Addr(), 1, uintptr(hDrop), 0, 0) } func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr { - ret, _, _ := syscall.Syscall(shBrowseForFolder, 1, + ret, _, _ := syscall.Syscall(shBrowseForFolder.Addr(), 1, uintptr(unsafe.Pointer(lpbi)), 0, 0) @@ -363,7 +364,7 @@ func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr { } func SHGetFileInfo(pszPath *uint16, dwFileAttributes uint32, psfi *SHFILEINFO, cbFileInfo, uFlags uint32) uintptr { - ret, _, _ := syscall.Syscall6(shGetFileInfo, 5, + ret, _, _ := syscall.Syscall6(shGetFileInfo.Addr(), 5, uintptr(unsafe.Pointer(pszPath)), uintptr(dwFileAttributes), uintptr(unsafe.Pointer(psfi)), @@ -375,7 +376,7 @@ func SHGetFileInfo(pszPath *uint16, dwFileAttributes uint32, psfi *SHFILEINFO, c } func SHGetPathFromIDList(pidl uintptr, pszPath *uint16) bool { - ret, _, _ := syscall.Syscall(shGetPathFromIDList, 2, + ret, _, _ := syscall.Syscall(shGetPathFromIDList.Addr(), 2, pidl, uintptr(unsafe.Pointer(pszPath)), 0) @@ -384,7 +385,7 @@ func SHGetPathFromIDList(pidl uintptr, pszPath *uint16) bool { } func SHGetSpecialFolderPath(hwndOwner HWND, lpszPath *uint16, csidl CSIDL, fCreate bool) bool { - ret, _, _ := syscall.Syscall6(shGetSpecialFolderPath, 4, + ret, _, _ := syscall.Syscall6(shGetSpecialFolderPath.Addr(), 4, uintptr(hwndOwner), uintptr(unsafe.Pointer(lpszPath)), uintptr(csidl), @@ -396,7 +397,7 @@ func SHGetSpecialFolderPath(hwndOwner HWND, lpszPath *uint16, csidl CSIDL, fCrea } func SHParseDisplayName(pszName *uint16, pbc uintptr, ppidl *uintptr, sfgaoIn uint32, psfgaoOut *uint32) HRESULT { - ret, _, _ := syscall.Syscall6(shParseDisplayName, 5, + ret, _, _ := syscall.Syscall6(shParseDisplayName.Addr(), 5, uintptr(unsafe.Pointer(pszName)), pbc, uintptr(unsafe.Pointer(ppidl)), @@ -408,7 +409,10 @@ func SHParseDisplayName(pszName *uint16, pbc uintptr, ppidl *uintptr, sfgaoIn ui } func SHGetStockIconInfo(stockIconId int32, uFlags uint32, stockIcon *SHSTOCKICONINFO) HRESULT { - ret, _, _ := syscall.Syscall6(shGetStockIconInfo, 3, + if shGetStockIconInfo.Find() != nil { + return HRESULT(0) + } + ret, _, _ := syscall.Syscall6(shGetStockIconInfo.Addr(), 3, uintptr(stockIconId), uintptr(uFlags), uintptr(unsafe.Pointer(stockIcon)), @@ -420,7 +424,7 @@ func SHGetStockIconInfo(stockIconId int32, uFlags uint32, stockIcon *SHSTOCKICON } func Shell_NotifyIcon(dwMessage uint32, lpdata *NOTIFYICONDATA) bool { - ret, _, _ := syscall.Syscall(shell_NotifyIcon, 2, + ret, _, _ := syscall.Syscall(shell_NotifyIcon.Addr(), 2, uintptr(dwMessage), uintptr(unsafe.Pointer(lpdata)), 0) diff --git a/user32.go b/user32.go index 550f16bb..625ed240 100644 --- a/user32.go +++ b/user32.go @@ -1592,270 +1592,270 @@ func GET_Y_LPARAM(lp uintptr) int32 { var ( // Library - libuser32 uintptr + libuser32 *windows.LazyDLL // Functions - addClipboardFormatListener uintptr - adjustWindowRect uintptr - animateWindow uintptr - beginDeferWindowPos uintptr - beginPaint uintptr - callWindowProc uintptr - checkMenuRadioItem uintptr - clientToScreen uintptr - closeClipboard uintptr - createDialogParam uintptr - createIconIndirect uintptr - createMenu uintptr - createPopupMenu uintptr - createWindowEx uintptr - deferWindowPos uintptr - defWindowProc uintptr - destroyIcon uintptr - destroyMenu uintptr - destroyWindow uintptr - dialogBoxParam uintptr - dispatchMessage uintptr - drawIconEx uintptr - drawMenuBar uintptr - drawFocusRect uintptr - drawTextEx uintptr - emptyClipboard uintptr - enableWindow uintptr - endDeferWindowPos uintptr - endDialog uintptr - endPaint uintptr - enumChildWindows uintptr - findWindow uintptr - getActiveWindow uintptr - getAncestor uintptr - getCaretPos uintptr - getClassName uintptr - getClientRect uintptr - getClipboardData uintptr - getCursorPos uintptr - getDC uintptr - getDesktopWindow uintptr - getFocus uintptr - getForegroundWindow uintptr - getKeyState uintptr - getMenuInfo uintptr - getMessage uintptr - getMonitorInfo uintptr - getParent uintptr - getRawInputData uintptr - getScrollInfo uintptr - getSysColor uintptr - getSysColorBrush uintptr - getSystemMetrics uintptr - getWindow uintptr - getWindowLong uintptr - getWindowLongPtr uintptr - getWindowPlacement uintptr - getWindowRect uintptr - insertMenuItem uintptr - invalidateRect uintptr - isChild uintptr - isClipboardFormatAvailable uintptr - isDialogMessage uintptr - isWindowEnabled uintptr - isWindowVisible uintptr - killTimer uintptr - loadCursor uintptr - loadIcon uintptr - loadImage uintptr - loadMenu uintptr - loadString uintptr - messageBeep uintptr - messageBox uintptr - monitorFromWindow uintptr - moveWindow uintptr - unregisterClass uintptr - openClipboard uintptr - peekMessage uintptr - postMessage uintptr - postQuitMessage uintptr - registerClassEx uintptr - registerRawInputDevices uintptr - registerWindowMessage uintptr - releaseCapture uintptr - releaseDC uintptr - removeMenu uintptr - screenToClient uintptr - sendDlgItemMessage uintptr - sendInput uintptr - sendMessage uintptr - setActiveWindow uintptr - setCapture uintptr - setClipboardData uintptr - setCursor uintptr - setCursorPos uintptr - setFocus uintptr - setForegroundWindow uintptr - setMenu uintptr - setMenuInfo uintptr - setMenuItemInfo uintptr - setParent uintptr - setRect uintptr - setScrollInfo uintptr - setTimer uintptr - setWinEventHook uintptr - setWindowLong uintptr - setWindowLongPtr uintptr - setWindowPlacement uintptr - setWindowPos uintptr - showWindow uintptr - systemParametersInfo uintptr - trackPopupMenuEx uintptr - translateMessage uintptr - unhookWinEvent uintptr - updateWindow uintptr - windowFromDC uintptr - windowFromPoint uintptr + addClipboardFormatListener *windows.LazyProc + adjustWindowRect *windows.LazyProc + animateWindow *windows.LazyProc + beginDeferWindowPos *windows.LazyProc + beginPaint *windows.LazyProc + callWindowProc *windows.LazyProc + checkMenuRadioItem *windows.LazyProc + clientToScreen *windows.LazyProc + closeClipboard *windows.LazyProc + createDialogParam *windows.LazyProc + createIconIndirect *windows.LazyProc + createMenu *windows.LazyProc + createPopupMenu *windows.LazyProc + createWindowEx *windows.LazyProc + deferWindowPos *windows.LazyProc + defWindowProc *windows.LazyProc + destroyIcon *windows.LazyProc + destroyMenu *windows.LazyProc + destroyWindow *windows.LazyProc + dialogBoxParam *windows.LazyProc + dispatchMessage *windows.LazyProc + drawIconEx *windows.LazyProc + drawMenuBar *windows.LazyProc + drawFocusRect *windows.LazyProc + drawTextEx *windows.LazyProc + emptyClipboard *windows.LazyProc + enableWindow *windows.LazyProc + endDeferWindowPos *windows.LazyProc + endDialog *windows.LazyProc + endPaint *windows.LazyProc + enumChildWindows *windows.LazyProc + findWindow *windows.LazyProc + getActiveWindow *windows.LazyProc + getAncestor *windows.LazyProc + getCaretPos *windows.LazyProc + getClassName *windows.LazyProc + getClientRect *windows.LazyProc + getClipboardData *windows.LazyProc + getCursorPos *windows.LazyProc + getDC *windows.LazyProc + getDesktopWindow *windows.LazyProc + getFocus *windows.LazyProc + getForegroundWindow *windows.LazyProc + getKeyState *windows.LazyProc + getMenuInfo *windows.LazyProc + getMessage *windows.LazyProc + getMonitorInfo *windows.LazyProc + getParent *windows.LazyProc + getRawInputData *windows.LazyProc + getScrollInfo *windows.LazyProc + getSysColor *windows.LazyProc + getSysColorBrush *windows.LazyProc + getSystemMetrics *windows.LazyProc + getWindow *windows.LazyProc + getWindowLong *windows.LazyProc + getWindowLongPtr *windows.LazyProc + getWindowPlacement *windows.LazyProc + getWindowRect *windows.LazyProc + insertMenuItem *windows.LazyProc + invalidateRect *windows.LazyProc + isChild *windows.LazyProc + isClipboardFormatAvailable *windows.LazyProc + isDialogMessage *windows.LazyProc + isWindowEnabled *windows.LazyProc + isWindowVisible *windows.LazyProc + killTimer *windows.LazyProc + loadCursor *windows.LazyProc + loadIcon *windows.LazyProc + loadImage *windows.LazyProc + loadMenu *windows.LazyProc + loadString *windows.LazyProc + messageBeep *windows.LazyProc + messageBox *windows.LazyProc + monitorFromWindow *windows.LazyProc + moveWindow *windows.LazyProc + unregisterClass *windows.LazyProc + openClipboard *windows.LazyProc + peekMessage *windows.LazyProc + postMessage *windows.LazyProc + postQuitMessage *windows.LazyProc + registerClassEx *windows.LazyProc + registerRawInputDevices *windows.LazyProc + registerWindowMessage *windows.LazyProc + releaseCapture *windows.LazyProc + releaseDC *windows.LazyProc + removeMenu *windows.LazyProc + screenToClient *windows.LazyProc + sendDlgItemMessage *windows.LazyProc + sendInput *windows.LazyProc + sendMessage *windows.LazyProc + setActiveWindow *windows.LazyProc + setCapture *windows.LazyProc + setClipboardData *windows.LazyProc + setCursor *windows.LazyProc + setCursorPos *windows.LazyProc + setFocus *windows.LazyProc + setForegroundWindow *windows.LazyProc + setMenu *windows.LazyProc + setMenuInfo *windows.LazyProc + setMenuItemInfo *windows.LazyProc + setParent *windows.LazyProc + setRect *windows.LazyProc + setScrollInfo *windows.LazyProc + setTimer *windows.LazyProc + setWinEventHook *windows.LazyProc + setWindowLong *windows.LazyProc + setWindowLongPtr *windows.LazyProc + setWindowPlacement *windows.LazyProc + setWindowPos *windows.LazyProc + showWindow *windows.LazyProc + systemParametersInfo *windows.LazyProc + trackPopupMenuEx *windows.LazyProc + translateMessage *windows.LazyProc + unhookWinEvent *windows.LazyProc + updateWindow *windows.LazyProc + windowFromDC *windows.LazyProc + windowFromPoint *windows.LazyProc ) func init() { is64bit := unsafe.Sizeof(uintptr(0)) == 8 // Library - libuser32 = MustLoadLibrary("user32.dll") + libuser32 = windows.NewLazySystemDLL("user32.dll") // Functions - addClipboardFormatListener, _ = syscall.GetProcAddress(syscall.Handle(libuser32), "AddClipboardFormatListener") - adjustWindowRect = MustGetProcAddress(libuser32, "AdjustWindowRect") - animateWindow = MustGetProcAddress(libuser32, "AnimateWindow") - beginDeferWindowPos = MustGetProcAddress(libuser32, "BeginDeferWindowPos") - beginPaint = MustGetProcAddress(libuser32, "BeginPaint") - callWindowProc = MustGetProcAddress(libuser32, "CallWindowProcW") - checkMenuRadioItem = MustGetProcAddress(libuser32, "CheckMenuRadioItem") - clientToScreen = MustGetProcAddress(libuser32, "ClientToScreen") - closeClipboard = MustGetProcAddress(libuser32, "CloseClipboard") - createDialogParam = MustGetProcAddress(libuser32, "CreateDialogParamW") - createIconIndirect = MustGetProcAddress(libuser32, "CreateIconIndirect") - createMenu = MustGetProcAddress(libuser32, "CreateMenu") - createPopupMenu = MustGetProcAddress(libuser32, "CreatePopupMenu") - createWindowEx = MustGetProcAddress(libuser32, "CreateWindowExW") - deferWindowPos = MustGetProcAddress(libuser32, "DeferWindowPos") - defWindowProc = MustGetProcAddress(libuser32, "DefWindowProcW") - destroyIcon = MustGetProcAddress(libuser32, "DestroyIcon") - destroyMenu = MustGetProcAddress(libuser32, "DestroyMenu") - destroyWindow = MustGetProcAddress(libuser32, "DestroyWindow") - dialogBoxParam = MustGetProcAddress(libuser32, "DialogBoxParamW") - dispatchMessage = MustGetProcAddress(libuser32, "DispatchMessageW") - drawIconEx = MustGetProcAddress(libuser32, "DrawIconEx") - drawFocusRect = MustGetProcAddress(libuser32, "DrawFocusRect") - drawMenuBar = MustGetProcAddress(libuser32, "DrawMenuBar") - drawTextEx = MustGetProcAddress(libuser32, "DrawTextExW") - emptyClipboard = MustGetProcAddress(libuser32, "EmptyClipboard") - enableWindow = MustGetProcAddress(libuser32, "EnableWindow") - endDeferWindowPos = MustGetProcAddress(libuser32, "EndDeferWindowPos") - endDialog = MustGetProcAddress(libuser32, "EndDialog") - endPaint = MustGetProcAddress(libuser32, "EndPaint") - enumChildWindows = MustGetProcAddress(libuser32, "EnumChildWindows") - findWindow = MustGetProcAddress(libuser32, "FindWindowW") - getActiveWindow = MustGetProcAddress(libuser32, "GetActiveWindow") - getAncestor = MustGetProcAddress(libuser32, "GetAncestor") - getCaretPos = MustGetProcAddress(libuser32, "GetCaretPos") - getClassName = MustGetProcAddress(libuser32, "GetClassNameW") - getClientRect = MustGetProcAddress(libuser32, "GetClientRect") - getClipboardData = MustGetProcAddress(libuser32, "GetClipboardData") - getCursorPos = MustGetProcAddress(libuser32, "GetCursorPos") - getDC = MustGetProcAddress(libuser32, "GetDC") - getDesktopWindow = MustGetProcAddress(libuser32, "GetDesktopWindow") - getFocus = MustGetProcAddress(libuser32, "GetFocus") - getForegroundWindow = MustGetProcAddress(libuser32, "GetForegroundWindow") - getKeyState = MustGetProcAddress(libuser32, "GetKeyState") - getMenuInfo = MustGetProcAddress(libuser32, "GetMenuInfo") - getMessage = MustGetProcAddress(libuser32, "GetMessageW") - getMonitorInfo = MustGetProcAddress(libuser32, "GetMonitorInfoW") - getParent = MustGetProcAddress(libuser32, "GetParent") - getRawInputData = MustGetProcAddress(libuser32, "GetRawInputData") - getScrollInfo = MustGetProcAddress(libuser32, "GetScrollInfo") - getSysColor = MustGetProcAddress(libuser32, "GetSysColor") - getSysColorBrush = MustGetProcAddress(libuser32, "GetSysColorBrush") - getSystemMetrics = MustGetProcAddress(libuser32, "GetSystemMetrics") - getWindow = MustGetProcAddress(libuser32, "GetWindow") - getWindowLong = MustGetProcAddress(libuser32, "GetWindowLongW") + addClipboardFormatListener = libuser32.NewProc("AddClipboardFormatListener") + adjustWindowRect = libuser32.NewProc("AdjustWindowRect") + animateWindow = libuser32.NewProc("AnimateWindow") + beginDeferWindowPos = libuser32.NewProc("BeginDeferWindowPos") + beginPaint = libuser32.NewProc("BeginPaint") + callWindowProc = libuser32.NewProc("CallWindowProcW") + checkMenuRadioItem = libuser32.NewProc("CheckMenuRadioItem") + clientToScreen = libuser32.NewProc("ClientToScreen") + closeClipboard = libuser32.NewProc("CloseClipboard") + createDialogParam = libuser32.NewProc("CreateDialogParamW") + createIconIndirect = libuser32.NewProc("CreateIconIndirect") + createMenu = libuser32.NewProc("CreateMenu") + createPopupMenu = libuser32.NewProc("CreatePopupMenu") + createWindowEx = libuser32.NewProc("CreateWindowExW") + deferWindowPos = libuser32.NewProc("DeferWindowPos") + defWindowProc = libuser32.NewProc("DefWindowProcW") + destroyIcon = libuser32.NewProc("DestroyIcon") + destroyMenu = libuser32.NewProc("DestroyMenu") + destroyWindow = libuser32.NewProc("DestroyWindow") + dialogBoxParam = libuser32.NewProc("DialogBoxParamW") + dispatchMessage = libuser32.NewProc("DispatchMessageW") + drawIconEx = libuser32.NewProc("DrawIconEx") + drawFocusRect = libuser32.NewProc("DrawFocusRect") + drawMenuBar = libuser32.NewProc("DrawMenuBar") + drawTextEx = libuser32.NewProc("DrawTextExW") + emptyClipboard = libuser32.NewProc("EmptyClipboard") + enableWindow = libuser32.NewProc("EnableWindow") + endDeferWindowPos = libuser32.NewProc("EndDeferWindowPos") + endDialog = libuser32.NewProc("EndDialog") + endPaint = libuser32.NewProc("EndPaint") + enumChildWindows = libuser32.NewProc("EnumChildWindows") + findWindow = libuser32.NewProc("FindWindowW") + getActiveWindow = libuser32.NewProc("GetActiveWindow") + getAncestor = libuser32.NewProc("GetAncestor") + getCaretPos = libuser32.NewProc("GetCaretPos") + getClassName = libuser32.NewProc("GetClassNameW") + getClientRect = libuser32.NewProc("GetClientRect") + getClipboardData = libuser32.NewProc("GetClipboardData") + getCursorPos = libuser32.NewProc("GetCursorPos") + getDC = libuser32.NewProc("GetDC") + getDesktopWindow = libuser32.NewProc("GetDesktopWindow") + getFocus = libuser32.NewProc("GetFocus") + getForegroundWindow = libuser32.NewProc("GetForegroundWindow") + getKeyState = libuser32.NewProc("GetKeyState") + getMenuInfo = libuser32.NewProc("GetMenuInfo") + getMessage = libuser32.NewProc("GetMessageW") + getMonitorInfo = libuser32.NewProc("GetMonitorInfoW") + getParent = libuser32.NewProc("GetParent") + getRawInputData = libuser32.NewProc("GetRawInputData") + getScrollInfo = libuser32.NewProc("GetScrollInfo") + getSysColor = libuser32.NewProc("GetSysColor") + getSysColorBrush = libuser32.NewProc("GetSysColorBrush") + getSystemMetrics = libuser32.NewProc("GetSystemMetrics") + getWindow = libuser32.NewProc("GetWindow") + getWindowLong = libuser32.NewProc("GetWindowLongW") // On 32 bit GetWindowLongPtrW is not available if is64bit { - getWindowLongPtr = MustGetProcAddress(libuser32, "GetWindowLongPtrW") + getWindowLongPtr = libuser32.NewProc("GetWindowLongPtrW") } else { - getWindowLongPtr = MustGetProcAddress(libuser32, "GetWindowLongW") + getWindowLongPtr = libuser32.NewProc("GetWindowLongW") } - getWindowPlacement = MustGetProcAddress(libuser32, "GetWindowPlacement") - getWindowRect = MustGetProcAddress(libuser32, "GetWindowRect") - insertMenuItem = MustGetProcAddress(libuser32, "InsertMenuItemW") - invalidateRect = MustGetProcAddress(libuser32, "InvalidateRect") - isChild = MustGetProcAddress(libuser32, "IsChild") - isClipboardFormatAvailable = MustGetProcAddress(libuser32, "IsClipboardFormatAvailable") - isDialogMessage = MustGetProcAddress(libuser32, "IsDialogMessageW") - isWindowEnabled = MustGetProcAddress(libuser32, "IsWindowEnabled") - isWindowVisible = MustGetProcAddress(libuser32, "IsWindowVisible") - killTimer = MustGetProcAddress(libuser32, "KillTimer") - loadCursor = MustGetProcAddress(libuser32, "LoadCursorW") - loadIcon = MustGetProcAddress(libuser32, "LoadIconW") - loadImage = MustGetProcAddress(libuser32, "LoadImageW") - loadMenu = MustGetProcAddress(libuser32, "LoadMenuW") - loadString = MustGetProcAddress(libuser32, "LoadStringW") - messageBeep = MustGetProcAddress(libuser32, "MessageBeep") - messageBox = MustGetProcAddress(libuser32, "MessageBoxW") - monitorFromWindow = MustGetProcAddress(libuser32, "MonitorFromWindow") - moveWindow = MustGetProcAddress(libuser32, "MoveWindow") - unregisterClass = MustGetProcAddress(libuser32, "UnregisterClassW") - openClipboard = MustGetProcAddress(libuser32, "OpenClipboard") - peekMessage = MustGetProcAddress(libuser32, "PeekMessageW") - postMessage = MustGetProcAddress(libuser32, "PostMessageW") - postQuitMessage = MustGetProcAddress(libuser32, "PostQuitMessage") - registerClassEx = MustGetProcAddress(libuser32, "RegisterClassExW") - registerRawInputDevices = MustGetProcAddress(libuser32, "RegisterRawInputDevices") - registerWindowMessage = MustGetProcAddress(libuser32, "RegisterWindowMessageW") - releaseCapture = MustGetProcAddress(libuser32, "ReleaseCapture") - releaseDC = MustGetProcAddress(libuser32, "ReleaseDC") - removeMenu = MustGetProcAddress(libuser32, "RemoveMenu") - screenToClient = MustGetProcAddress(libuser32, "ScreenToClient") - sendDlgItemMessage = MustGetProcAddress(libuser32, "SendDlgItemMessageW") - sendInput = MustGetProcAddress(libuser32, "SendInput") - sendMessage = MustGetProcAddress(libuser32, "SendMessageW") - setActiveWindow = MustGetProcAddress(libuser32, "SetActiveWindow") - setCapture = MustGetProcAddress(libuser32, "SetCapture") - setClipboardData = MustGetProcAddress(libuser32, "SetClipboardData") - setCursor = MustGetProcAddress(libuser32, "SetCursor") - setCursorPos = MustGetProcAddress(libuser32, "SetCursorPos") - setFocus = MustGetProcAddress(libuser32, "SetFocus") - setForegroundWindow = MustGetProcAddress(libuser32, "SetForegroundWindow") - setMenu = MustGetProcAddress(libuser32, "SetMenu") - setMenuInfo = MustGetProcAddress(libuser32, "SetMenuInfo") - setMenuItemInfo = MustGetProcAddress(libuser32, "SetMenuItemInfoW") - setRect = MustGetProcAddress(libuser32, "SetRect") - setParent = MustGetProcAddress(libuser32, "SetParent") - setScrollInfo = MustGetProcAddress(libuser32, "SetScrollInfo") - setTimer = MustGetProcAddress(libuser32, "SetTimer") - setWinEventHook = MustGetProcAddress(libuser32, "SetWinEventHook") - setWindowLong = MustGetProcAddress(libuser32, "SetWindowLongW") + getWindowPlacement = libuser32.NewProc("GetWindowPlacement") + getWindowRect = libuser32.NewProc("GetWindowRect") + insertMenuItem = libuser32.NewProc("InsertMenuItemW") + invalidateRect = libuser32.NewProc("InvalidateRect") + isChild = libuser32.NewProc("IsChild") + isClipboardFormatAvailable = libuser32.NewProc("IsClipboardFormatAvailable") + isDialogMessage = libuser32.NewProc("IsDialogMessageW") + isWindowEnabled = libuser32.NewProc("IsWindowEnabled") + isWindowVisible = libuser32.NewProc("IsWindowVisible") + killTimer = libuser32.NewProc("KillTimer") + loadCursor = libuser32.NewProc("LoadCursorW") + loadIcon = libuser32.NewProc("LoadIconW") + loadImage = libuser32.NewProc("LoadImageW") + loadMenu = libuser32.NewProc("LoadMenuW") + loadString = libuser32.NewProc("LoadStringW") + messageBeep = libuser32.NewProc("MessageBeep") + messageBox = libuser32.NewProc("MessageBoxW") + monitorFromWindow = libuser32.NewProc("MonitorFromWindow") + moveWindow = libuser32.NewProc("MoveWindow") + unregisterClass = libuser32.NewProc("UnregisterClassW") + openClipboard = libuser32.NewProc("OpenClipboard") + peekMessage = libuser32.NewProc("PeekMessageW") + postMessage = libuser32.NewProc("PostMessageW") + postQuitMessage = libuser32.NewProc("PostQuitMessage") + registerClassEx = libuser32.NewProc("RegisterClassExW") + registerRawInputDevices = libuser32.NewProc("RegisterRawInputDevices") + registerWindowMessage = libuser32.NewProc("RegisterWindowMessageW") + releaseCapture = libuser32.NewProc("ReleaseCapture") + releaseDC = libuser32.NewProc("ReleaseDC") + removeMenu = libuser32.NewProc("RemoveMenu") + screenToClient = libuser32.NewProc("ScreenToClient") + sendDlgItemMessage = libuser32.NewProc("SendDlgItemMessageW") + sendInput = libuser32.NewProc("SendInput") + sendMessage = libuser32.NewProc("SendMessageW") + setActiveWindow = libuser32.NewProc("SetActiveWindow") + setCapture = libuser32.NewProc("SetCapture") + setClipboardData = libuser32.NewProc("SetClipboardData") + setCursor = libuser32.NewProc("SetCursor") + setCursorPos = libuser32.NewProc("SetCursorPos") + setFocus = libuser32.NewProc("SetFocus") + setForegroundWindow = libuser32.NewProc("SetForegroundWindow") + setMenu = libuser32.NewProc("SetMenu") + setMenuInfo = libuser32.NewProc("SetMenuInfo") + setMenuItemInfo = libuser32.NewProc("SetMenuItemInfoW") + setRect = libuser32.NewProc("SetRect") + setParent = libuser32.NewProc("SetParent") + setScrollInfo = libuser32.NewProc("SetScrollInfo") + setTimer = libuser32.NewProc("SetTimer") + setWinEventHook = libuser32.NewProc("SetWinEventHook") + setWindowLong = libuser32.NewProc("SetWindowLongW") // On 32 bit SetWindowLongPtrW is not available if is64bit { - setWindowLongPtr = MustGetProcAddress(libuser32, "SetWindowLongPtrW") + setWindowLongPtr = libuser32.NewProc("SetWindowLongPtrW") } else { - setWindowLongPtr = MustGetProcAddress(libuser32, "SetWindowLongW") + setWindowLongPtr = libuser32.NewProc("SetWindowLongW") } - setWindowPlacement = MustGetProcAddress(libuser32, "SetWindowPlacement") - setWindowPos = MustGetProcAddress(libuser32, "SetWindowPos") - showWindow = MustGetProcAddress(libuser32, "ShowWindow") - systemParametersInfo = MustGetProcAddress(libuser32, "SystemParametersInfoW") - trackPopupMenuEx = MustGetProcAddress(libuser32, "TrackPopupMenuEx") - translateMessage = MustGetProcAddress(libuser32, "TranslateMessage") - unhookWinEvent = MustGetProcAddress(libuser32, "UnhookWinEvent") - updateWindow = MustGetProcAddress(libuser32, "UpdateWindow") - windowFromDC = MustGetProcAddress(libuser32, "WindowFromDC") - windowFromPoint = MustGetProcAddress(libuser32, "WindowFromPoint") + setWindowPlacement = libuser32.NewProc("SetWindowPlacement") + setWindowPos = libuser32.NewProc("SetWindowPos") + showWindow = libuser32.NewProc("ShowWindow") + systemParametersInfo = libuser32.NewProc("SystemParametersInfoW") + trackPopupMenuEx = libuser32.NewProc("TrackPopupMenuEx") + translateMessage = libuser32.NewProc("TranslateMessage") + unhookWinEvent = libuser32.NewProc("UnhookWinEvent") + updateWindow = libuser32.NewProc("UpdateWindow") + windowFromDC = libuser32.NewProc("WindowFromDC") + windowFromPoint = libuser32.NewProc("WindowFromPoint") } func AddClipboardFormatListener(hwnd HWND) bool { - if addClipboardFormatListener == 0 { + if addClipboardFormatListener.Find() != nil { return false } - ret, _, _ := syscall.Syscall(addClipboardFormatListener, 1, + ret, _, _ := syscall.Syscall(addClipboardFormatListener.Addr(), 1, uintptr(hwnd), 0, 0) @@ -1864,7 +1864,7 @@ func AddClipboardFormatListener(hwnd HWND) bool { } func AdjustWindowRect(lpRect *RECT, dwStyle uint32, bMenu bool) bool { - ret, _, _ := syscall.Syscall(adjustWindowRect, 3, + ret, _, _ := syscall.Syscall(adjustWindowRect.Addr(), 3, uintptr(unsafe.Pointer(lpRect)), uintptr(dwStyle), uintptr(BoolToBOOL(bMenu))) @@ -1873,7 +1873,7 @@ func AdjustWindowRect(lpRect *RECT, dwStyle uint32, bMenu bool) bool { } func AnimateWindow(hwnd HWND, dwTime, dwFlags uint32) bool { - ret, _, _ := syscall.Syscall(animateWindow, 3, + ret, _, _ := syscall.Syscall(animateWindow.Addr(), 3, uintptr(hwnd), uintptr(dwTime), uintptr(dwFlags)) @@ -1882,7 +1882,7 @@ func AnimateWindow(hwnd HWND, dwTime, dwFlags uint32) bool { } func BeginDeferWindowPos(nNumWindows int32) HDWP { - ret, _, _ := syscall.Syscall(beginDeferWindowPos, 1, + ret, _, _ := syscall.Syscall(beginDeferWindowPos.Addr(), 1, uintptr(nNumWindows), 0, 0) @@ -1891,7 +1891,7 @@ func BeginDeferWindowPos(nNumWindows int32) HDWP { } func BeginPaint(hwnd HWND, lpPaint *PAINTSTRUCT) HDC { - ret, _, _ := syscall.Syscall(beginPaint, 2, + ret, _, _ := syscall.Syscall(beginPaint.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(lpPaint)), 0) @@ -1900,7 +1900,7 @@ func BeginPaint(hwnd HWND, lpPaint *PAINTSTRUCT) HDC { } func CallWindowProc(lpPrevWndFunc uintptr, hWnd HWND, Msg uint32, wParam, lParam uintptr) uintptr { - ret, _, _ := syscall.Syscall6(callWindowProc, 5, + ret, _, _ := syscall.Syscall6(callWindowProc.Addr(), 5, lpPrevWndFunc, uintptr(hWnd), uintptr(Msg), @@ -1912,7 +1912,7 @@ func CallWindowProc(lpPrevWndFunc uintptr, hWnd HWND, Msg uint32, wParam, lParam } func CheckMenuRadioItem(hmenu HMENU, first, last, check, flags uint32) bool { - ret, _, _ := syscall.Syscall6(checkMenuRadioItem, 5, + ret, _, _ := syscall.Syscall6(checkMenuRadioItem.Addr(), 5, uintptr(hmenu), uintptr(first), uintptr(last), @@ -1924,7 +1924,7 @@ func CheckMenuRadioItem(hmenu HMENU, first, last, check, flags uint32) bool { } func ClientToScreen(hwnd HWND, lpPoint *POINT) bool { - ret, _, _ := syscall.Syscall(clientToScreen, 2, + ret, _, _ := syscall.Syscall(clientToScreen.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(lpPoint)), 0) @@ -1933,7 +1933,7 @@ func ClientToScreen(hwnd HWND, lpPoint *POINT) bool { } func CloseClipboard() bool { - ret, _, _ := syscall.Syscall(closeClipboard, 0, + ret, _, _ := syscall.Syscall(closeClipboard.Addr(), 0, 0, 0, 0) @@ -1943,7 +1943,7 @@ func CloseClipboard() bool { func CreateDialogParam(instRes HINSTANCE, name *uint16, parent HWND, proc, param uintptr) HWND { - ret, _, _ := syscall.Syscall6(createDialogParam, 5, + ret, _, _ := syscall.Syscall6(createDialogParam.Addr(), 5, uintptr(instRes), uintptr(unsafe.Pointer(name)), uintptr(parent), @@ -1955,7 +1955,7 @@ func CreateDialogParam(instRes HINSTANCE, name *uint16, parent HWND, } func CreateIconIndirect(lpiconinfo *ICONINFO) HICON { - ret, _, _ := syscall.Syscall(createIconIndirect, 1, + ret, _, _ := syscall.Syscall(createIconIndirect.Addr(), 1, uintptr(unsafe.Pointer(lpiconinfo)), 0, 0) @@ -1964,7 +1964,7 @@ func CreateIconIndirect(lpiconinfo *ICONINFO) HICON { } func CreateMenu() HMENU { - ret, _, _ := syscall.Syscall(createMenu, 0, + ret, _, _ := syscall.Syscall(createMenu.Addr(), 0, 0, 0, 0) @@ -1973,7 +1973,7 @@ func CreateMenu() HMENU { } func CreatePopupMenu() HMENU { - ret, _, _ := syscall.Syscall(createPopupMenu, 0, + ret, _, _ := syscall.Syscall(createPopupMenu.Addr(), 0, 0, 0, 0) @@ -1982,7 +1982,7 @@ func CreatePopupMenu() HMENU { } func CreateWindowEx(dwExStyle uint32, lpClassName, lpWindowName *uint16, dwStyle uint32, x, y, nWidth, nHeight int32, hWndParent HWND, hMenu HMENU, hInstance HINSTANCE, lpParam unsafe.Pointer) HWND { - ret, _, _ := syscall.Syscall12(createWindowEx, 12, + ret, _, _ := syscall.Syscall12(createWindowEx.Addr(), 12, uintptr(dwExStyle), uintptr(unsafe.Pointer(lpClassName)), uintptr(unsafe.Pointer(lpWindowName)), @@ -2000,7 +2000,7 @@ func CreateWindowEx(dwExStyle uint32, lpClassName, lpWindowName *uint16, dwStyle } func DeferWindowPos(hWinPosInfo HDWP, hWnd, hWndInsertAfter HWND, x, y, cx, cy int32, uFlags uint32) HDWP { - ret, _, _ := syscall.Syscall9(deferWindowPos, 8, + ret, _, _ := syscall.Syscall9(deferWindowPos.Addr(), 8, uintptr(hWinPosInfo), uintptr(hWnd), uintptr(hWndInsertAfter), @@ -2015,7 +2015,7 @@ func DeferWindowPos(hWinPosInfo HDWP, hWnd, hWndInsertAfter HWND, x, y, cx, cy i } func DefWindowProc(hWnd HWND, Msg uint32, wParam, lParam uintptr) uintptr { - ret, _, _ := syscall.Syscall6(defWindowProc, 4, + ret, _, _ := syscall.Syscall6(defWindowProc.Addr(), 4, uintptr(hWnd), uintptr(Msg), wParam, @@ -2027,7 +2027,7 @@ func DefWindowProc(hWnd HWND, Msg uint32, wParam, lParam uintptr) uintptr { } func DestroyIcon(hIcon HICON) bool { - ret, _, _ := syscall.Syscall(destroyIcon, 1, + ret, _, _ := syscall.Syscall(destroyIcon.Addr(), 1, uintptr(hIcon), 0, 0) @@ -2036,7 +2036,7 @@ func DestroyIcon(hIcon HICON) bool { } func DestroyMenu(hMenu HMENU) bool { - ret, _, _ := syscall.Syscall(destroyMenu, 1, + ret, _, _ := syscall.Syscall(destroyMenu.Addr(), 1, uintptr(hMenu), 0, 0) @@ -2045,7 +2045,7 @@ func DestroyMenu(hMenu HMENU) bool { } func DestroyWindow(hWnd HWND) bool { - ret, _, _ := syscall.Syscall(destroyWindow, 1, + ret, _, _ := syscall.Syscall(destroyWindow.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2054,7 +2054,7 @@ func DestroyWindow(hWnd HWND) bool { } func DialogBoxParam(instRes HINSTANCE, name *uint16, parent HWND, proc, param uintptr) int { - ret, _, _ := syscall.Syscall6(dialogBoxParam, 5, + ret, _, _ := syscall.Syscall6(dialogBoxParam.Addr(), 5, uintptr(instRes), uintptr(unsafe.Pointer(name)), uintptr(parent), @@ -2066,7 +2066,7 @@ func DialogBoxParam(instRes HINSTANCE, name *uint16, parent HWND, proc, param ui } func DispatchMessage(msg *MSG) uintptr { - ret, _, _ := syscall.Syscall(dispatchMessage, 1, + ret, _, _ := syscall.Syscall(dispatchMessage.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0) @@ -2075,7 +2075,7 @@ func DispatchMessage(msg *MSG) uintptr { } func DrawFocusRect(hDC HDC, lprc *RECT) bool { - ret, _, _ := syscall.Syscall(drawFocusRect, 2, + ret, _, _ := syscall.Syscall(drawFocusRect.Addr(), 2, uintptr(hDC), uintptr(unsafe.Pointer(lprc)), 0) @@ -2084,7 +2084,7 @@ func DrawFocusRect(hDC HDC, lprc *RECT) bool { } func DrawIconEx(hdc HDC, xLeft, yTop int32, hIcon HICON, cxWidth, cyWidth int32, istepIfAniCur uint32, hbrFlickerFreeDraw HBRUSH, diFlags uint32) bool { - ret, _, _ := syscall.Syscall9(drawIconEx, 9, + ret, _, _ := syscall.Syscall9(drawIconEx.Addr(), 9, uintptr(hdc), uintptr(xLeft), uintptr(yTop), @@ -2099,7 +2099,7 @@ func DrawIconEx(hdc HDC, xLeft, yTop int32, hIcon HICON, cxWidth, cyWidth int32, } func DrawMenuBar(hWnd HWND) bool { - ret, _, _ := syscall.Syscall(drawMenuBar, 1, + ret, _, _ := syscall.Syscall(drawMenuBar.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2108,7 +2108,7 @@ func DrawMenuBar(hWnd HWND) bool { } func DrawTextEx(hdc HDC, lpchText *uint16, cchText int32, lprc *RECT, dwDTFormat uint32, lpDTParams *DRAWTEXTPARAMS) int32 { - ret, _, _ := syscall.Syscall6(drawTextEx, 6, + ret, _, _ := syscall.Syscall6(drawTextEx.Addr(), 6, uintptr(hdc), uintptr(unsafe.Pointer(lpchText)), uintptr(cchText), @@ -2120,7 +2120,7 @@ func DrawTextEx(hdc HDC, lpchText *uint16, cchText int32, lprc *RECT, dwDTFormat } func EmptyClipboard() bool { - ret, _, _ := syscall.Syscall(emptyClipboard, 0, + ret, _, _ := syscall.Syscall(emptyClipboard.Addr(), 0, 0, 0, 0) @@ -2129,7 +2129,7 @@ func EmptyClipboard() bool { } func EnableWindow(hWnd HWND, bEnable bool) bool { - ret, _, _ := syscall.Syscall(enableWindow, 2, + ret, _, _ := syscall.Syscall(enableWindow.Addr(), 2, uintptr(hWnd), uintptr(BoolToBOOL(bEnable)), 0) @@ -2138,7 +2138,7 @@ func EnableWindow(hWnd HWND, bEnable bool) bool { } func EndDeferWindowPos(hWinPosInfo HDWP) bool { - ret, _, _ := syscall.Syscall(endDeferWindowPos, 1, + ret, _, _ := syscall.Syscall(endDeferWindowPos.Addr(), 1, uintptr(hWinPosInfo), 0, 0) @@ -2147,7 +2147,7 @@ func EndDeferWindowPos(hWinPosInfo HDWP) bool { } func EndDialog(hwnd HWND, result int) bool { - ret, _, _ := syscall.Syscall(endDialog, 2, + ret, _, _ := syscall.Syscall(endDialog.Addr(), 2, uintptr(hwnd), uintptr(result), 0) @@ -2156,7 +2156,7 @@ func EndDialog(hwnd HWND, result int) bool { } func EndPaint(hwnd HWND, lpPaint *PAINTSTRUCT) bool { - ret, _, _ := syscall.Syscall(endPaint, 2, + ret, _, _ := syscall.Syscall(endPaint.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(lpPaint)), 0) @@ -2165,7 +2165,7 @@ func EndPaint(hwnd HWND, lpPaint *PAINTSTRUCT) bool { } func EnumChildWindows(hWndParent HWND, lpEnumFunc, lParam uintptr) bool { - ret, _, _ := syscall.Syscall(enumChildWindows, 3, + ret, _, _ := syscall.Syscall(enumChildWindows.Addr(), 3, uintptr(hWndParent), lpEnumFunc, lParam) @@ -2174,7 +2174,7 @@ func EnumChildWindows(hWndParent HWND, lpEnumFunc, lParam uintptr) bool { } func FindWindow(lpClassName, lpWindowName *uint16) HWND { - ret, _, _ := syscall.Syscall(findWindow, 2, + ret, _, _ := syscall.Syscall(findWindow.Addr(), 2, uintptr(unsafe.Pointer(lpClassName)), uintptr(unsafe.Pointer(lpWindowName)), 0) @@ -2183,7 +2183,7 @@ func FindWindow(lpClassName, lpWindowName *uint16) HWND { } func GetActiveWindow() HWND { - ret, _, _ := syscall.Syscall(getActiveWindow, 0, + ret, _, _ := syscall.Syscall(getActiveWindow.Addr(), 0, 0, 0, 0) @@ -2192,7 +2192,7 @@ func GetActiveWindow() HWND { } func GetAncestor(hWnd HWND, gaFlags uint32) HWND { - ret, _, _ := syscall.Syscall(getAncestor, 2, + ret, _, _ := syscall.Syscall(getAncestor.Addr(), 2, uintptr(hWnd), uintptr(gaFlags), 0) @@ -2201,7 +2201,7 @@ func GetAncestor(hWnd HWND, gaFlags uint32) HWND { } func GetCaretPos(lpPoint *POINT) bool { - ret, _, _ := syscall.Syscall(getCaretPos, 1, + ret, _, _ := syscall.Syscall(getCaretPos.Addr(), 1, uintptr(unsafe.Pointer(lpPoint)), 0, 0) @@ -2210,7 +2210,7 @@ func GetCaretPos(lpPoint *POINT) bool { } func GetClassName(hWnd HWND, className *uint16, maxCount int) (int, error) { - ret, _, e := syscall.Syscall(getClassName, 3, + ret, _, e := syscall.Syscall(getClassName.Addr(), 3, uintptr(hWnd), uintptr(unsafe.Pointer(className)), uintptr(maxCount)) @@ -2221,7 +2221,7 @@ func GetClassName(hWnd HWND, className *uint16, maxCount int) (int, error) { } func GetClientRect(hWnd HWND, rect *RECT) bool { - ret, _, _ := syscall.Syscall(getClientRect, 2, + ret, _, _ := syscall.Syscall(getClientRect.Addr(), 2, uintptr(hWnd), uintptr(unsafe.Pointer(rect)), 0) @@ -2230,7 +2230,7 @@ func GetClientRect(hWnd HWND, rect *RECT) bool { } func GetClipboardData(uFormat uint32) HANDLE { - ret, _, _ := syscall.Syscall(getClipboardData, 1, + ret, _, _ := syscall.Syscall(getClipboardData.Addr(), 1, uintptr(uFormat), 0, 0) @@ -2239,7 +2239,7 @@ func GetClipboardData(uFormat uint32) HANDLE { } func GetCursorPos(lpPoint *POINT) bool { - ret, _, _ := syscall.Syscall(getCursorPos, 1, + ret, _, _ := syscall.Syscall(getCursorPos.Addr(), 1, uintptr(unsafe.Pointer(lpPoint)), 0, 0) @@ -2248,7 +2248,7 @@ func GetCursorPos(lpPoint *POINT) bool { } func GetDesktopWindow() HWND { - ret, _, _ := syscall.Syscall(getDesktopWindow, 0, + ret, _, _ := syscall.Syscall(getDesktopWindow.Addr(), 0, 0, 0, 0) @@ -2257,7 +2257,7 @@ func GetDesktopWindow() HWND { } func GetDC(hWnd HWND) HDC { - ret, _, _ := syscall.Syscall(getDC, 1, + ret, _, _ := syscall.Syscall(getDC.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2266,7 +2266,7 @@ func GetDC(hWnd HWND) HDC { } func GetFocus() HWND { - ret, _, _ := syscall.Syscall(getFocus, 0, + ret, _, _ := syscall.Syscall(getFocus.Addr(), 0, 0, 0, 0) @@ -2275,7 +2275,7 @@ func GetFocus() HWND { } func GetForegroundWindow() HWND { - ret, _, _ := syscall.Syscall(getForegroundWindow, 0, + ret, _, _ := syscall.Syscall(getForegroundWindow.Addr(), 0, 0, 0, 0) @@ -2284,7 +2284,7 @@ func GetForegroundWindow() HWND { } func GetKeyState(nVirtKey int32) int16 { - ret, _, _ := syscall.Syscall(getKeyState, 1, + ret, _, _ := syscall.Syscall(getKeyState.Addr(), 1, uintptr(nVirtKey), 0, 0) @@ -2293,7 +2293,7 @@ func GetKeyState(nVirtKey int32) int16 { } func GetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { - ret, _, _ := syscall.Syscall(getMenuInfo, 2, + ret, _, _ := syscall.Syscall(getMenuInfo.Addr(), 2, uintptr(hmenu), uintptr(unsafe.Pointer(lpcmi)), 0) @@ -2302,7 +2302,7 @@ func GetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { } func GetMessage(msg *MSG, hWnd HWND, msgFilterMin, msgFilterMax uint32) BOOL { - ret, _, _ := syscall.Syscall6(getMessage, 4, + ret, _, _ := syscall.Syscall6(getMessage.Addr(), 4, uintptr(unsafe.Pointer(msg)), uintptr(hWnd), uintptr(msgFilterMin), @@ -2314,7 +2314,7 @@ func GetMessage(msg *MSG, hWnd HWND, msgFilterMin, msgFilterMax uint32) BOOL { } func GetMonitorInfo(hMonitor HMONITOR, lpmi *MONITORINFO) bool { - ret, _, _ := syscall.Syscall(getMonitorInfo, 2, + ret, _, _ := syscall.Syscall(getMonitorInfo.Addr(), 2, uintptr(hMonitor), uintptr(unsafe.Pointer(lpmi)), 0) @@ -2323,7 +2323,7 @@ func GetMonitorInfo(hMonitor HMONITOR, lpmi *MONITORINFO) bool { } func GetParent(hWnd HWND) HWND { - ret, _, _ := syscall.Syscall(getParent, 1, + ret, _, _ := syscall.Syscall(getParent.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2332,7 +2332,7 @@ func GetParent(hWnd HWND) HWND { } func GetRawInputData(hRawInput HRAWINPUT, uiCommand uint32, pData unsafe.Pointer, pcbSize *uint32, cBSizeHeader uint32) uint32 { - ret, _, _ := syscall.Syscall6(getRawInputData, 5, + ret, _, _ := syscall.Syscall6(getRawInputData.Addr(), 5, uintptr(hRawInput), uintptr(uiCommand), uintptr(pData), @@ -2344,7 +2344,7 @@ func GetRawInputData(hRawInput HRAWINPUT, uiCommand uint32, pData unsafe.Pointer } func GetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO) bool { - ret, _, _ := syscall.Syscall(getScrollInfo, 3, + ret, _, _ := syscall.Syscall(getScrollInfo.Addr(), 3, uintptr(hwnd), uintptr(fnBar), uintptr(unsafe.Pointer(lpsi))) @@ -2353,7 +2353,7 @@ func GetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO) bool { } func GetSysColor(nIndex int) uint32 { - ret, _, _ := syscall.Syscall(getSysColor, 1, + ret, _, _ := syscall.Syscall(getSysColor.Addr(), 1, uintptr(nIndex), 0, 0) @@ -2362,7 +2362,7 @@ func GetSysColor(nIndex int) uint32 { } func GetSysColorBrush(nIndex int) HBRUSH { - ret, _, _ := syscall.Syscall(getSysColorBrush, 1, + ret, _, _ := syscall.Syscall(getSysColorBrush.Addr(), 1, uintptr(nIndex), 0, 0) @@ -2371,7 +2371,7 @@ func GetSysColorBrush(nIndex int) HBRUSH { } func GetSystemMetrics(nIndex int32) int32 { - ret, _, _ := syscall.Syscall(getSystemMetrics, 1, + ret, _, _ := syscall.Syscall(getSystemMetrics.Addr(), 1, uintptr(nIndex), 0, 0) @@ -2380,7 +2380,7 @@ func GetSystemMetrics(nIndex int32) int32 { } func GetWindow(hWnd HWND, uCmd uint32) HWND { - ret, _, _ := syscall.Syscall(getWindow, 2, + ret, _, _ := syscall.Syscall(getWindow.Addr(), 2, uintptr(hWnd), uintptr(uCmd), 0) @@ -2389,7 +2389,7 @@ func GetWindow(hWnd HWND, uCmd uint32) HWND { } func GetWindowLong(hWnd HWND, index int32) int32 { - ret, _, _ := syscall.Syscall(getWindowLong, 2, + ret, _, _ := syscall.Syscall(getWindowLong.Addr(), 2, uintptr(hWnd), uintptr(index), 0) @@ -2398,7 +2398,7 @@ func GetWindowLong(hWnd HWND, index int32) int32 { } func GetWindowLongPtr(hWnd HWND, index int32) uintptr { - ret, _, _ := syscall.Syscall(getWindowLongPtr, 2, + ret, _, _ := syscall.Syscall(getWindowLongPtr.Addr(), 2, uintptr(hWnd), uintptr(index), 0) @@ -2407,7 +2407,7 @@ func GetWindowLongPtr(hWnd HWND, index int32) uintptr { } func GetWindowPlacement(hWnd HWND, lpwndpl *WINDOWPLACEMENT) bool { - ret, _, _ := syscall.Syscall(getWindowPlacement, 2, + ret, _, _ := syscall.Syscall(getWindowPlacement.Addr(), 2, uintptr(hWnd), uintptr(unsafe.Pointer(lpwndpl)), 0) @@ -2416,7 +2416,7 @@ func GetWindowPlacement(hWnd HWND, lpwndpl *WINDOWPLACEMENT) bool { } func GetWindowRect(hWnd HWND, rect *RECT) bool { - ret, _, _ := syscall.Syscall(getWindowRect, 2, + ret, _, _ := syscall.Syscall(getWindowRect.Addr(), 2, uintptr(hWnd), uintptr(unsafe.Pointer(rect)), 0) @@ -2425,7 +2425,7 @@ func GetWindowRect(hWnd HWND, rect *RECT) bool { } func InsertMenuItem(hMenu HMENU, uItem uint32, fByPosition bool, lpmii *MENUITEMINFO) bool { - ret, _, _ := syscall.Syscall6(insertMenuItem, 4, + ret, _, _ := syscall.Syscall6(insertMenuItem.Addr(), 4, uintptr(hMenu), uintptr(uItem), uintptr(BoolToBOOL(fByPosition)), @@ -2437,7 +2437,7 @@ func InsertMenuItem(hMenu HMENU, uItem uint32, fByPosition bool, lpmii *MENUITEM } func InvalidateRect(hWnd HWND, lpRect *RECT, bErase bool) bool { - ret, _, _ := syscall.Syscall(invalidateRect, 3, + ret, _, _ := syscall.Syscall(invalidateRect.Addr(), 3, uintptr(hWnd), uintptr(unsafe.Pointer(lpRect)), uintptr(BoolToBOOL(bErase))) @@ -2446,7 +2446,7 @@ func InvalidateRect(hWnd HWND, lpRect *RECT, bErase bool) bool { } func IsChild(hWndParent, hWnd HWND) bool { - ret, _, _ := syscall.Syscall(isChild, 2, + ret, _, _ := syscall.Syscall(isChild.Addr(), 2, uintptr(hWndParent), uintptr(hWnd), 0) @@ -2455,7 +2455,7 @@ func IsChild(hWndParent, hWnd HWND) bool { } func IsClipboardFormatAvailable(format uint32) bool { - ret, _, _ := syscall.Syscall(isClipboardFormatAvailable, 1, + ret, _, _ := syscall.Syscall(isClipboardFormatAvailable.Addr(), 1, uintptr(format), 0, 0) @@ -2464,7 +2464,7 @@ func IsClipboardFormatAvailable(format uint32) bool { } func IsDialogMessage(hWnd HWND, msg *MSG) bool { - ret, _, _ := syscall.Syscall(isDialogMessage, 2, + ret, _, _ := syscall.Syscall(isDialogMessage.Addr(), 2, uintptr(hWnd), uintptr(unsafe.Pointer(msg)), 0) @@ -2473,7 +2473,7 @@ func IsDialogMessage(hWnd HWND, msg *MSG) bool { } func IsWindowEnabled(hWnd HWND) bool { - ret, _, _ := syscall.Syscall(isWindowEnabled, 1, + ret, _, _ := syscall.Syscall(isWindowEnabled.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2482,7 +2482,7 @@ func IsWindowEnabled(hWnd HWND) bool { } func IsWindowVisible(hWnd HWND) bool { - ret, _, _ := syscall.Syscall(isWindowVisible, 1, + ret, _, _ := syscall.Syscall(isWindowVisible.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2491,7 +2491,7 @@ func IsWindowVisible(hWnd HWND) bool { } func KillTimer(hWnd HWND, uIDEvent uintptr) bool { - ret, _, _ := syscall.Syscall(killTimer, 2, + ret, _, _ := syscall.Syscall(killTimer.Addr(), 2, uintptr(hWnd), uIDEvent, 0) @@ -2500,7 +2500,7 @@ func KillTimer(hWnd HWND, uIDEvent uintptr) bool { } func LoadCursor(hInstance HINSTANCE, lpCursorName *uint16) HCURSOR { - ret, _, _ := syscall.Syscall(loadCursor, 2, + ret, _, _ := syscall.Syscall(loadCursor.Addr(), 2, uintptr(hInstance), uintptr(unsafe.Pointer(lpCursorName)), 0) @@ -2509,7 +2509,7 @@ func LoadCursor(hInstance HINSTANCE, lpCursorName *uint16) HCURSOR { } func LoadIcon(hInstance HINSTANCE, lpIconName *uint16) HICON { - ret, _, _ := syscall.Syscall(loadIcon, 2, + ret, _, _ := syscall.Syscall(loadIcon.Addr(), 2, uintptr(hInstance), uintptr(unsafe.Pointer(lpIconName)), 0) @@ -2518,7 +2518,7 @@ func LoadIcon(hInstance HINSTANCE, lpIconName *uint16) HICON { } func LoadImage(hinst HINSTANCE, lpszName *uint16, uType uint32, cxDesired, cyDesired int32, fuLoad uint32) HANDLE { - ret, _, _ := syscall.Syscall6(loadImage, 6, + ret, _, _ := syscall.Syscall6(loadImage.Addr(), 6, uintptr(hinst), uintptr(unsafe.Pointer(lpszName)), uintptr(uType), @@ -2530,7 +2530,7 @@ func LoadImage(hinst HINSTANCE, lpszName *uint16, uType uint32, cxDesired, cyDes } func LoadMenu(hinst HINSTANCE, name *uint16) HMENU { - ret, _, _ := syscall.Syscall(loadMenu, 2, + ret, _, _ := syscall.Syscall(loadMenu.Addr(), 2, uintptr(hinst), uintptr(unsafe.Pointer(name)), 0) @@ -2539,7 +2539,7 @@ func LoadMenu(hinst HINSTANCE, name *uint16) HMENU { } func LoadString(instRes HINSTANCE, id uint32, buf *uint16, length int32) int32 { - ret, _, _ := syscall.Syscall6(loadString, 4, + ret, _, _ := syscall.Syscall6(loadString.Addr(), 4, uintptr(instRes), uintptr(id), uintptr(unsafe.Pointer(buf)), @@ -2565,7 +2565,7 @@ func LoadString(instRes HINSTANCE, id uint32, buf *uint16, length int32) int32 { // // The function will return true if the function succeeds, false if otherwise. func MessageBeep(uType uint32) bool { - ret, _, _ := syscall.Syscall(messageBeep, 2, + ret, _, _ := syscall.Syscall(messageBeep.Addr(), 2, uintptr(uType), 0, 0) @@ -2574,7 +2574,7 @@ func MessageBeep(uType uint32) bool { } func MessageBox(hWnd HWND, lpText, lpCaption *uint16, uType uint32) int32 { - ret, _, _ := syscall.Syscall6(messageBox, 4, + ret, _, _ := syscall.Syscall6(messageBox.Addr(), 4, uintptr(hWnd), uintptr(unsafe.Pointer(lpText)), uintptr(unsafe.Pointer(lpCaption)), @@ -2586,7 +2586,7 @@ func MessageBox(hWnd HWND, lpText, lpCaption *uint16, uType uint32) int32 { } func MonitorFromWindow(hwnd HWND, dwFlags uint32) HMONITOR { - ret, _, _ := syscall.Syscall(monitorFromWindow, 2, + ret, _, _ := syscall.Syscall(monitorFromWindow.Addr(), 2, uintptr(hwnd), uintptr(dwFlags), 0) @@ -2595,7 +2595,7 @@ func MonitorFromWindow(hwnd HWND, dwFlags uint32) HMONITOR { } func MoveWindow(hWnd HWND, x, y, width, height int32, repaint bool) bool { - ret, _, _ := syscall.Syscall6(moveWindow, 6, + ret, _, _ := syscall.Syscall6(moveWindow.Addr(), 6, uintptr(hWnd), uintptr(x), uintptr(y), @@ -2607,7 +2607,7 @@ func MoveWindow(hWnd HWND, x, y, width, height int32, repaint bool) bool { } func UnregisterClass(name *uint16) bool { - ret, _, _ := syscall.Syscall(unregisterClass, 1, + ret, _, _ := syscall.Syscall(unregisterClass.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) @@ -2616,7 +2616,7 @@ func UnregisterClass(name *uint16) bool { } func OpenClipboard(hWndNewOwner HWND) bool { - ret, _, _ := syscall.Syscall(openClipboard, 1, + ret, _, _ := syscall.Syscall(openClipboard.Addr(), 1, uintptr(hWndNewOwner), 0, 0) @@ -2625,7 +2625,7 @@ func OpenClipboard(hWndNewOwner HWND) bool { } func PeekMessage(lpMsg *MSG, hWnd HWND, wMsgFilterMin, wMsgFilterMax, wRemoveMsg uint32) bool { - ret, _, _ := syscall.Syscall6(peekMessage, 5, + ret, _, _ := syscall.Syscall6(peekMessage.Addr(), 5, uintptr(unsafe.Pointer(lpMsg)), uintptr(hWnd), uintptr(wMsgFilterMin), @@ -2637,7 +2637,7 @@ func PeekMessage(lpMsg *MSG, hWnd HWND, wMsgFilterMin, wMsgFilterMax, wRemoveMsg } func PostMessage(hWnd HWND, msg uint32, wParam, lParam uintptr) uintptr { - ret, _, _ := syscall.Syscall6(postMessage, 4, + ret, _, _ := syscall.Syscall6(postMessage.Addr(), 4, uintptr(hWnd), uintptr(msg), wParam, @@ -2649,14 +2649,14 @@ func PostMessage(hWnd HWND, msg uint32, wParam, lParam uintptr) uintptr { } func PostQuitMessage(exitCode int32) { - syscall.Syscall(postQuitMessage, 1, + syscall.Syscall(postQuitMessage.Addr(), 1, uintptr(exitCode), 0, 0) } func RegisterClassEx(windowClass *WNDCLASSEX) ATOM { - ret, _, _ := syscall.Syscall(registerClassEx, 1, + ret, _, _ := syscall.Syscall(registerClassEx.Addr(), 1, uintptr(unsafe.Pointer(windowClass)), 0, 0) @@ -2665,7 +2665,7 @@ func RegisterClassEx(windowClass *WNDCLASSEX) ATOM { } func RegisterRawInputDevices(pRawInputDevices *RAWINPUTDEVICE, uiNumDevices uint32, cbSize uint32) bool { - ret, _, _ := syscall.Syscall(registerRawInputDevices, 3, + ret, _, _ := syscall.Syscall(registerRawInputDevices.Addr(), 3, uintptr(unsafe.Pointer(pRawInputDevices)), uintptr(uiNumDevices), uintptr(cbSize)) @@ -2674,7 +2674,7 @@ func RegisterRawInputDevices(pRawInputDevices *RAWINPUTDEVICE, uiNumDevices uint } func RegisterWindowMessage(lpString *uint16) uint32 { - ret, _, _ := syscall.Syscall(registerWindowMessage, 1, + ret, _, _ := syscall.Syscall(registerWindowMessage.Addr(), 1, uintptr(unsafe.Pointer(lpString)), 0, 0) @@ -2683,7 +2683,7 @@ func RegisterWindowMessage(lpString *uint16) uint32 { } func ReleaseCapture() bool { - ret, _, _ := syscall.Syscall(releaseCapture, 0, + ret, _, _ := syscall.Syscall(releaseCapture.Addr(), 0, 0, 0, 0) @@ -2692,7 +2692,7 @@ func ReleaseCapture() bool { } func ReleaseDC(hWnd HWND, hDC HDC) bool { - ret, _, _ := syscall.Syscall(releaseDC, 2, + ret, _, _ := syscall.Syscall(releaseDC.Addr(), 2, uintptr(hWnd), uintptr(hDC), 0) @@ -2701,7 +2701,7 @@ func ReleaseDC(hWnd HWND, hDC HDC) bool { } func RemoveMenu(hMenu HMENU, uPosition, uFlags uint32) bool { - ret, _, _ := syscall.Syscall(removeMenu, 3, + ret, _, _ := syscall.Syscall(removeMenu.Addr(), 3, uintptr(hMenu), uintptr(uPosition), uintptr(uFlags)) @@ -2710,7 +2710,7 @@ func RemoveMenu(hMenu HMENU, uPosition, uFlags uint32) bool { } func ScreenToClient(hWnd HWND, point *POINT) bool { - ret, _, _ := syscall.Syscall(screenToClient, 2, + ret, _, _ := syscall.Syscall(screenToClient.Addr(), 2, uintptr(hWnd), uintptr(unsafe.Pointer(point)), 0) @@ -2719,7 +2719,7 @@ func ScreenToClient(hWnd HWND, point *POINT) bool { } func SendDlgItemMessage(hWnd HWND, id int32, msg uint32, wParam, lParam uintptr) uintptr { - ret, _, _ := syscall.Syscall6(sendDlgItemMessage, 5, + ret, _, _ := syscall.Syscall6(sendDlgItemMessage.Addr(), 5, uintptr(hWnd), uintptr(id), uintptr(msg), @@ -2732,7 +2732,7 @@ func SendDlgItemMessage(hWnd HWND, id int32, msg uint32, wParam, lParam uintptr) // pInputs expects a unsafe.Pointer to a slice of MOUSE_INPUT or KEYBD_INPUT or HARDWARE_INPUT structs. func SendInput(nInputs uint32, pInputs unsafe.Pointer, cbSize int32) uint32 { - ret, _, _ := syscall.Syscall(sendInput, 3, + ret, _, _ := syscall.Syscall(sendInput.Addr(), 3, uintptr(nInputs), uintptr(pInputs), uintptr(cbSize)) @@ -2741,7 +2741,7 @@ func SendInput(nInputs uint32, pInputs unsafe.Pointer, cbSize int32) uint32 { } func SendMessage(hWnd HWND, msg uint32, wParam, lParam uintptr) uintptr { - ret, _, _ := syscall.Syscall6(sendMessage, 4, + ret, _, _ := syscall.Syscall6(sendMessage.Addr(), 4, uintptr(hWnd), uintptr(msg), wParam, @@ -2753,7 +2753,7 @@ func SendMessage(hWnd HWND, msg uint32, wParam, lParam uintptr) uintptr { } func SetActiveWindow(hWnd HWND) HWND { - ret, _, _ := syscall.Syscall(setActiveWindow, 1, + ret, _, _ := syscall.Syscall(setActiveWindow.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2762,7 +2762,7 @@ func SetActiveWindow(hWnd HWND) HWND { } func SetCapture(hWnd HWND) HWND { - ret, _, _ := syscall.Syscall(setCapture, 1, + ret, _, _ := syscall.Syscall(setCapture.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2771,7 +2771,7 @@ func SetCapture(hWnd HWND) HWND { } func SetClipboardData(uFormat uint32, hMem HANDLE) HANDLE { - ret, _, _ := syscall.Syscall(setClipboardData, 2, + ret, _, _ := syscall.Syscall(setClipboardData.Addr(), 2, uintptr(uFormat), uintptr(hMem), 0) @@ -2780,7 +2780,7 @@ func SetClipboardData(uFormat uint32, hMem HANDLE) HANDLE { } func SetCursor(hCursor HCURSOR) HCURSOR { - ret, _, _ := syscall.Syscall(setCursor, 1, + ret, _, _ := syscall.Syscall(setCursor.Addr(), 1, uintptr(hCursor), 0, 0) @@ -2789,7 +2789,7 @@ func SetCursor(hCursor HCURSOR) HCURSOR { } func SetCursorPos(X, Y int32) bool { - ret, _, _ := syscall.Syscall(setCursorPos, 2, + ret, _, _ := syscall.Syscall(setCursorPos.Addr(), 2, uintptr(X), uintptr(Y), 0) @@ -2798,7 +2798,7 @@ func SetCursorPos(X, Y int32) bool { } func SetFocus(hWnd HWND) HWND { - ret, _, _ := syscall.Syscall(setFocus, 1, + ret, _, _ := syscall.Syscall(setFocus.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2807,7 +2807,7 @@ func SetFocus(hWnd HWND) HWND { } func SetForegroundWindow(hWnd HWND) bool { - ret, _, _ := syscall.Syscall(setForegroundWindow, 1, + ret, _, _ := syscall.Syscall(setForegroundWindow.Addr(), 1, uintptr(hWnd), 0, 0) @@ -2816,7 +2816,7 @@ func SetForegroundWindow(hWnd HWND) bool { } func SetMenu(hWnd HWND, hMenu HMENU) bool { - ret, _, _ := syscall.Syscall(setMenu, 2, + ret, _, _ := syscall.Syscall(setMenu.Addr(), 2, uintptr(hWnd), uintptr(hMenu), 0) @@ -2825,7 +2825,7 @@ func SetMenu(hWnd HWND, hMenu HMENU) bool { } func SetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { - ret, _, _ := syscall.Syscall(setMenuInfo, 2, + ret, _, _ := syscall.Syscall(setMenuInfo.Addr(), 2, uintptr(hmenu), uintptr(unsafe.Pointer(lpcmi)), 0) @@ -2834,7 +2834,7 @@ func SetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { } func SetMenuItemInfo(hMenu HMENU, uItem uint32, fByPosition bool, lpmii *MENUITEMINFO) bool { - ret, _, _ := syscall.Syscall6(setMenuItemInfo, 4, + ret, _, _ := syscall.Syscall6(setMenuItemInfo.Addr(), 4, uintptr(hMenu), uintptr(uItem), uintptr(BoolToBOOL(fByPosition)), @@ -2846,7 +2846,7 @@ func SetMenuItemInfo(hMenu HMENU, uItem uint32, fByPosition bool, lpmii *MENUITE } func SetParent(hWnd HWND, parentHWnd HWND) HWND { - ret, _, _ := syscall.Syscall(setParent, 2, + ret, _, _ := syscall.Syscall(setParent.Addr(), 2, uintptr(hWnd), uintptr(parentHWnd), 0) @@ -2855,7 +2855,7 @@ func SetParent(hWnd HWND, parentHWnd HWND) HWND { } func SetRect(lprc *RECT, xLeft, yTop, xRight, yBottom uint32) BOOL { - ret, _, _ := syscall.Syscall6(setRect, 5, + ret, _, _ := syscall.Syscall6(setRect.Addr(), 5, uintptr(unsafe.Pointer(lprc)), uintptr(xLeft), uintptr(yTop), @@ -2867,7 +2867,7 @@ func SetRect(lprc *RECT, xLeft, yTop, xRight, yBottom uint32) BOOL { } func SetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO, fRedraw bool) int32 { - ret, _, _ := syscall.Syscall6(setScrollInfo, 4, + ret, _, _ := syscall.Syscall6(setScrollInfo.Addr(), 4, uintptr(hwnd), uintptr(fnBar), uintptr(unsafe.Pointer(lpsi)), @@ -2879,7 +2879,7 @@ func SetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO, fRedraw bool) int32 } func SetTimer(hWnd HWND, nIDEvent uintptr, uElapse uint32, lpTimerFunc uintptr) uintptr { - ret, _, _ := syscall.Syscall6(setTimer, 4, + ret, _, _ := syscall.Syscall6(setTimer.Addr(), 4, uintptr(hWnd), nIDEvent, uintptr(uElapse), @@ -2893,7 +2893,7 @@ func SetTimer(hWnd HWND, nIDEvent uintptr, uElapse uint32, lpTimerFunc uintptr) type WINEVENTPROC func(hWinEventHook HWINEVENTHOOK, event uint32, hwnd HWND, idObject int32, idChild int32, idEventThread uint32, dwmsEventTime uint32) uintptr func SetWinEventHook(eventMin uint32, eventMax uint32, hmodWinEventProc HMODULE, callbackFunction WINEVENTPROC, idProcess uint32, idThread uint32, dwFlags uint32) (HWINEVENTHOOK, error) { - ret, _, err := syscall.Syscall9(setWinEventHook, 7, + ret, _, err := syscall.Syscall9(setWinEventHook.Addr(), 7, uintptr(eventMin), uintptr(eventMax), uintptr(hmodWinEventProc), @@ -2911,7 +2911,7 @@ func SetWinEventHook(eventMin uint32, eventMax uint32, hmodWinEventProc HMODULE, } func SetWindowLong(hWnd HWND, index, value int32) int32 { - ret, _, _ := syscall.Syscall(setWindowLong, 3, + ret, _, _ := syscall.Syscall(setWindowLong.Addr(), 3, uintptr(hWnd), uintptr(index), uintptr(value)) @@ -2920,7 +2920,7 @@ func SetWindowLong(hWnd HWND, index, value int32) int32 { } func SetWindowLongPtr(hWnd HWND, index int, value uintptr) uintptr { - ret, _, _ := syscall.Syscall(setWindowLongPtr, 3, + ret, _, _ := syscall.Syscall(setWindowLongPtr.Addr(), 3, uintptr(hWnd), uintptr(index), value) @@ -2929,7 +2929,7 @@ func SetWindowLongPtr(hWnd HWND, index int, value uintptr) uintptr { } func SetWindowPlacement(hWnd HWND, lpwndpl *WINDOWPLACEMENT) bool { - ret, _, _ := syscall.Syscall(setWindowPlacement, 2, + ret, _, _ := syscall.Syscall(setWindowPlacement.Addr(), 2, uintptr(hWnd), uintptr(unsafe.Pointer(lpwndpl)), 0) @@ -2938,7 +2938,7 @@ func SetWindowPlacement(hWnd HWND, lpwndpl *WINDOWPLACEMENT) bool { } func SetWindowPos(hWnd, hWndInsertAfter HWND, x, y, width, height int32, flags uint32) bool { - ret, _, _ := syscall.Syscall9(setWindowPos, 7, + ret, _, _ := syscall.Syscall9(setWindowPos.Addr(), 7, uintptr(hWnd), uintptr(hWndInsertAfter), uintptr(x), @@ -2953,7 +2953,7 @@ func SetWindowPos(hWnd, hWndInsertAfter HWND, x, y, width, height int32, flags u } func ShowWindow(hWnd HWND, nCmdShow int32) bool { - ret, _, _ := syscall.Syscall(showWindow, 2, + ret, _, _ := syscall.Syscall(showWindow.Addr(), 2, uintptr(hWnd), uintptr(nCmdShow), 0) @@ -2962,7 +2962,7 @@ func ShowWindow(hWnd HWND, nCmdShow int32) bool { } func SystemParametersInfo(uiAction, uiParam uint32, pvParam unsafe.Pointer, fWinIni uint32) bool { - ret, _, _ := syscall.Syscall6(systemParametersInfo, 4, + ret, _, _ := syscall.Syscall6(systemParametersInfo.Addr(), 4, uintptr(uiAction), uintptr(uiParam), uintptr(pvParam), @@ -2974,7 +2974,7 @@ func SystemParametersInfo(uiAction, uiParam uint32, pvParam unsafe.Pointer, fWin } func TrackPopupMenuEx(hMenu HMENU, fuFlags uint32, x, y int32, hWnd HWND, lptpm *TPMPARAMS) BOOL { - ret, _, _ := syscall.Syscall6(trackPopupMenuEx, 6, + ret, _, _ := syscall.Syscall6(trackPopupMenuEx.Addr(), 6, uintptr(hMenu), uintptr(fuFlags), uintptr(x), @@ -2986,7 +2986,7 @@ func TrackPopupMenuEx(hMenu HMENU, fuFlags uint32, x, y int32, hWnd HWND, lptpm } func TranslateMessage(msg *MSG) bool { - ret, _, _ := syscall.Syscall(translateMessage, 1, + ret, _, _ := syscall.Syscall(translateMessage.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0) @@ -2995,12 +2995,12 @@ func TranslateMessage(msg *MSG) bool { } func UnhookWinEvent(hWinHookEvent HWINEVENTHOOK) bool { - ret, _, _ := syscall.Syscall(unhookWinEvent, 1, uintptr(hWinHookEvent), 0, 0) + ret, _, _ := syscall.Syscall(unhookWinEvent.Addr(), 1, uintptr(hWinHookEvent), 0, 0) return ret != 0 } func UpdateWindow(hwnd HWND) bool { - ret, _, _ := syscall.Syscall(updateWindow, 1, + ret, _, _ := syscall.Syscall(updateWindow.Addr(), 1, uintptr(hwnd), 0, 0) @@ -3009,7 +3009,7 @@ func UpdateWindow(hwnd HWND) bool { } func WindowFromDC(hDC HDC) HWND { - ret, _, _ := syscall.Syscall(windowFromDC, 1, + ret, _, _ := syscall.Syscall(windowFromDC.Addr(), 1, uintptr(hDC), 0, 0) @@ -3018,7 +3018,7 @@ func WindowFromDC(hDC HDC) HWND { } func WindowFromPoint(Point POINT) HWND { - ret, _, _ := syscall.Syscall(windowFromPoint, 2, + ret, _, _ := syscall.Syscall(windowFromPoint.Addr(), 2, uintptr(Point.X), uintptr(Point.Y), 0) diff --git a/uxtheme.go b/uxtheme.go index 2714ed13..66f52a6e 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -138,36 +139,36 @@ type DTTOPTS struct { var ( // Library - libuxtheme uintptr + libuxtheme *windows.LazyDLL // Functions - closeThemeData uintptr - drawThemeBackground uintptr - drawThemeTextEx uintptr - getThemePartSize uintptr - getThemeTextExtent uintptr - isAppThemed uintptr - openThemeData uintptr - setWindowTheme uintptr + closeThemeData *windows.LazyProc + drawThemeBackground *windows.LazyProc + drawThemeTextEx *windows.LazyProc + getThemePartSize *windows.LazyProc + getThemeTextExtent *windows.LazyProc + isAppThemed *windows.LazyProc + openThemeData *windows.LazyProc + setWindowTheme *windows.LazyProc ) func init() { // Library - libuxtheme = MustLoadLibrary("uxtheme.dll") + libuxtheme = windows.NewLazySystemDLL("uxtheme.dll") // Functions - closeThemeData = MustGetProcAddress(libuxtheme, "CloseThemeData") - drawThemeBackground = MustGetProcAddress(libuxtheme, "DrawThemeBackground") - drawThemeTextEx, _ = syscall.GetProcAddress(syscall.Handle(libuxtheme), "DrawThemeTextEx") - getThemePartSize = MustGetProcAddress(libuxtheme, "GetThemePartSize") - getThemeTextExtent = MustGetProcAddress(libuxtheme, "GetThemeTextExtent") - isAppThemed = MustGetProcAddress(libuxtheme, "IsAppThemed") - openThemeData = MustGetProcAddress(libuxtheme, "OpenThemeData") - setWindowTheme = MustGetProcAddress(libuxtheme, "SetWindowTheme") + closeThemeData = libuxtheme.NewProc("CloseThemeData") + drawThemeBackground = libuxtheme.NewProc("DrawThemeBackground") + drawThemeTextEx = libuxtheme.NewProc("DrawThemeTextEx") + getThemePartSize = libuxtheme.NewProc("GetThemePartSize") + getThemeTextExtent = libuxtheme.NewProc("GetThemeTextExtent") + isAppThemed = libuxtheme.NewProc("IsAppThemed") + openThemeData = libuxtheme.NewProc("OpenThemeData") + setWindowTheme = libuxtheme.NewProc("SetWindowTheme") } func CloseThemeData(hTheme HTHEME) HRESULT { - ret, _, _ := syscall.Syscall(closeThemeData, 1, + ret, _, _ := syscall.Syscall(closeThemeData.Addr(), 1, uintptr(hTheme), 0, 0) @@ -176,7 +177,7 @@ func CloseThemeData(hTheme HTHEME) HRESULT { } func DrawThemeBackground(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pRect, pClipRect *RECT) HRESULT { - ret, _, _ := syscall.Syscall6(drawThemeBackground, 6, + ret, _, _ := syscall.Syscall6(drawThemeBackground.Addr(), 6, uintptr(hTheme), uintptr(hdc), uintptr(iPartId), @@ -188,7 +189,10 @@ func DrawThemeBackground(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pRect, } func DrawThemeTextEx(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uint16, iCharCount int32, dwFlags uint32, pRect *RECT, pOptions *DTTOPTS) HRESULT { - ret, _, _ := syscall.Syscall9(drawThemeTextEx, 9, + if drawThemeTextEx.Find() != nil { + return HRESULT(0) + } + ret, _, _ := syscall.Syscall9(drawThemeTextEx.Addr(), 9, uintptr(hTheme), uintptr(hdc), uintptr(iPartId), @@ -203,7 +207,7 @@ func DrawThemeTextEx(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *u } func GetThemePartSize(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, prc *RECT, eSize THEMESIZE, psz *SIZE) HRESULT { - ret, _, _ := syscall.Syscall9(getThemePartSize, 7, + ret, _, _ := syscall.Syscall9(getThemePartSize.Addr(), 7, uintptr(hTheme), uintptr(hdc), uintptr(iPartId), @@ -218,7 +222,7 @@ func GetThemePartSize(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, prc *RECT } func GetThemeTextExtent(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uint16, iCharCount int32, dwTextFlags uint32, pBoundingRect, pExtentRect *RECT) HRESULT { - ret, _, _ := syscall.Syscall9(getThemeTextExtent, 9, + ret, _, _ := syscall.Syscall9(getThemeTextExtent.Addr(), 9, uintptr(hTheme), uintptr(hdc), uintptr(iPartId), @@ -233,7 +237,7 @@ func GetThemeTextExtent(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText } func IsAppThemed() bool { - ret, _, _ := syscall.Syscall(isAppThemed, 0, + ret, _, _ := syscall.Syscall(isAppThemed.Addr(), 0, 0, 0, 0) @@ -242,7 +246,7 @@ func IsAppThemed() bool { } func OpenThemeData(hwnd HWND, pszClassList *uint16) HTHEME { - ret, _, _ := syscall.Syscall(openThemeData, 2, + ret, _, _ := syscall.Syscall(openThemeData.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(pszClassList)), 0) @@ -251,7 +255,7 @@ func OpenThemeData(hwnd HWND, pszClassList *uint16) HTHEME { } func SetWindowTheme(hwnd HWND, pszSubAppName, pszSubIdList *uint16) HRESULT { - ret, _, _ := syscall.Syscall(setWindowTheme, 3, + ret, _, _ := syscall.Syscall(setWindowTheme.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(pszSubAppName)), uintptr(unsafe.Pointer(pszSubIdList))) diff --git a/win.go b/win.go index 3e9f84b9..152375e7 100644 --- a/win.go +++ b/win.go @@ -42,30 +42,6 @@ type ( HRESULT int32 ) -func MustLoadLibrary(name string) uintptr { - lib, err := syscall.LoadLibrary(name) - if err != nil { - panic(err) - } - - return uintptr(lib) -} - -func MustGetProcAddress(lib uintptr, name string) uintptr { - addr, err := syscall.GetProcAddress(syscall.Handle(lib), name) - if err != nil { - panic(err) - } - - return uintptr(addr) -} - -func MaybeGetProcAddress(lib uintptr, name string) uintptr { - addr, _ := syscall.GetProcAddress(syscall.Handle(lib), name) - - return uintptr(addr) -} - func SUCCEEDED(hr HRESULT) bool { return hr >= 0 } diff --git a/winspool.go b/winspool.go index c69214d4..4ee34eff 100644 --- a/winspool.go +++ b/winspool.go @@ -7,6 +7,7 @@ package win import ( + "golang.org/x/sys/windows" "syscall" "unsafe" ) @@ -31,28 +32,28 @@ type PRINTER_INFO_4 struct { var ( // Library - libwinspool uintptr + libwinspool *windows.LazyDLL // Functions - deviceCapabilities uintptr - documentProperties uintptr - enumPrinters uintptr - getDefaultPrinter uintptr + deviceCapabilities *windows.LazyProc + documentProperties *windows.LazyProc + enumPrinters *windows.LazyProc + getDefaultPrinter *windows.LazyProc ) func init() { // Library - libwinspool = MustLoadLibrary("winspool.drv") + libwinspool = windows.NewLazySystemDLL("winspool.drv") // Functions - deviceCapabilities = MustGetProcAddress(libwinspool, "DeviceCapabilitiesW") - documentProperties = MustGetProcAddress(libwinspool, "DocumentPropertiesW") - enumPrinters = MustGetProcAddress(libwinspool, "EnumPrintersW") - getDefaultPrinter = MustGetProcAddress(libwinspool, "GetDefaultPrinterW") + deviceCapabilities = libwinspool.NewProc("DeviceCapabilitiesW") + documentProperties = libwinspool.NewProc("DocumentPropertiesW") + enumPrinters = libwinspool.NewProc("EnumPrintersW") + getDefaultPrinter = libwinspool.NewProc("GetDefaultPrinterW") } func DeviceCapabilities(pDevice, pPort *uint16, fwCapability uint16, pOutput *uint16, pDevMode *DEVMODE) uint32 { - ret, _, _ := syscall.Syscall6(deviceCapabilities, 5, + ret, _, _ := syscall.Syscall6(deviceCapabilities.Addr(), 5, uintptr(unsafe.Pointer(pDevice)), uintptr(unsafe.Pointer(pPort)), uintptr(fwCapability), @@ -64,7 +65,7 @@ func DeviceCapabilities(pDevice, pPort *uint16, fwCapability uint16, pOutput *ui } func DocumentProperties(hWnd HWND, hPrinter HANDLE, pDeviceName *uint16, pDevModeOutput, pDevModeInput *DEVMODE, fMode uint32) int32 { - ret, _, _ := syscall.Syscall6(documentProperties, 6, + ret, _, _ := syscall.Syscall6(documentProperties.Addr(), 6, uintptr(hWnd), uintptr(hPrinter), uintptr(unsafe.Pointer(pDeviceName)), @@ -76,7 +77,7 @@ func DocumentProperties(hWnd HWND, hPrinter HANDLE, pDeviceName *uint16, pDevMod } func EnumPrinters(Flags uint32, Name *uint16, Level uint32, pPrinterEnum *byte, cbBuf uint32, pcbNeeded, pcReturned *uint32) bool { - ret, _, _ := syscall.Syscall9(enumPrinters, 7, + ret, _, _ := syscall.Syscall9(enumPrinters.Addr(), 7, uintptr(Flags), uintptr(unsafe.Pointer(Name)), uintptr(Level), @@ -91,7 +92,7 @@ func EnumPrinters(Flags uint32, Name *uint16, Level uint32, pPrinterEnum *byte, } func GetDefaultPrinter(pszBuffer *uint16, pcchBuffer *uint32) bool { - ret, _, _ := syscall.Syscall(getDefaultPrinter, 2, + ret, _, _ := syscall.Syscall(getDefaultPrinter.Addr(), 2, uintptr(unsafe.Pointer(pszBuffer)), uintptr(unsafe.Pointer(pcchBuffer)), 0) From 41550ccc5ca0dee917c68bfa70b7160d7dd11d75 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 9 Mar 2019 05:41:24 +0100 Subject: [PATCH 079/138] Add BringWindowToTop --- user32.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/user32.go b/user32.go index 625ed240..7e5f663b 100644 --- a/user32.go +++ b/user32.go @@ -1600,6 +1600,7 @@ var ( animateWindow *windows.LazyProc beginDeferWindowPos *windows.LazyProc beginPaint *windows.LazyProc + bringWindowToTop *windows.LazyProc callWindowProc *windows.LazyProc checkMenuRadioItem *windows.LazyProc clientToScreen *windows.LazyProc @@ -1726,6 +1727,7 @@ func init() { animateWindow = libuser32.NewProc("AnimateWindow") beginDeferWindowPos = libuser32.NewProc("BeginDeferWindowPos") beginPaint = libuser32.NewProc("BeginPaint") + bringWindowToTop = libuser32.NewProc("BringWindowToTop") callWindowProc = libuser32.NewProc("CallWindowProcW") checkMenuRadioItem = libuser32.NewProc("CheckMenuRadioItem") clientToScreen = libuser32.NewProc("ClientToScreen") @@ -1899,6 +1901,14 @@ func BeginPaint(hwnd HWND, lpPaint *PAINTSTRUCT) HDC { return HDC(ret) } +func BringWindowToTop(hwnd HWND) bool { + ret, _, _ := syscall.Syscall(bringWindowToTop.Addr(), 1, + uintptr(hwnd), + 0, + 0) + return ret != 0 +} + func CallWindowProc(lpPrevWndFunc uintptr, hWnd HWND, Msg uint32, wParam, lParam uintptr) uintptr { ret, _, _ := syscall.Syscall6(callWindowProc.Addr(), 5, lpPrevWndFunc, From c5fe80e27b16f201e2244945cc1c777eb4250dcb Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 9 Mar 2019 12:31:53 +0100 Subject: [PATCH 080/138] Add ExtractIcon --- shell32.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/shell32.go b/shell32.go index d530b8a2..f14a6140 100644 --- a/shell32.go +++ b/shell32.go @@ -300,6 +300,7 @@ var ( dragAcceptFiles *windows.LazyProc dragFinish *windows.LazyProc dragQueryFile *windows.LazyProc + extractIcon *windows.LazyProc shBrowseForFolder *windows.LazyProc shGetFileInfo *windows.LazyProc shGetPathFromIDList *windows.LazyProc @@ -317,6 +318,7 @@ func init() { dragAcceptFiles = libshell32.NewProc("DragAcceptFiles") dragFinish = libshell32.NewProc("DragFinish") dragQueryFile = libshell32.NewProc("DragQueryFileW") + extractIcon = libshell32.NewProc("ExtractIconW") shBrowseForFolder = libshell32.NewProc("SHBrowseForFolderW") shGetFileInfo = libshell32.NewProc("SHGetFileInfoW") shGetPathFromIDList = libshell32.NewProc("SHGetPathFromIDListW") @@ -354,6 +356,15 @@ func DragFinish(hDrop HDROP) { 0) } +func ExtractIcon(hInst HINSTANCE, exeFileName *uint16, iconIndex int32) HICON { + ret, _, _ := syscall.Syscall(extractIcon.Addr(), 3, + uintptr(hInst), + uintptr(unsafe.Pointer(exeFileName)), + uintptr(iconIndex)) + + return HICON(ret) +} + func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr { ret, _, _ := syscall.Syscall(shBrowseForFolder.Addr(), 1, uintptr(unsafe.Pointer(lpbi)), From ecea61d6d774b0345876233fa6c3a870decd7adf Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 11 Apr 2019 11:22:12 +0200 Subject: [PATCH 081/138] Add missing MessageBox constants --- user32.go | 53 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/user32.go b/user32.go index 7e5f663b..7a3d86ff 100644 --- a/user32.go +++ b/user32.go @@ -7,35 +7,46 @@ package win import ( - "golang.org/x/sys/windows" "syscall" "unsafe" + + "golang.org/x/sys/windows" ) const CW_USEDEFAULT = ^0x7fffffff // MessageBox constants const ( - MB_OK = 0x00000000 - MB_OKCANCEL = 0x00000001 - MB_ABORTRETRYIGNORE = 0x00000002 - MB_YESNOCANCEL = 0x00000003 - MB_YESNO = 0x00000004 - MB_RETRYCANCEL = 0x00000005 - MB_CANCELTRYCONTINUE = 0x00000006 - MB_ICONHAND = 0x00000010 - MB_ICONQUESTION = 0x00000020 - MB_ICONEXCLAMATION = 0x00000030 - MB_ICONASTERISK = 0x00000040 - MB_USERICON = 0x00000080 - MB_ICONWARNING = MB_ICONEXCLAMATION - MB_ICONERROR = MB_ICONHAND - MB_ICONINFORMATION = MB_ICONASTERISK - MB_ICONSTOP = MB_ICONHAND - MB_DEFBUTTON1 = 0x00000000 - MB_DEFBUTTON2 = 0x00000100 - MB_DEFBUTTON3 = 0x00000200 - MB_DEFBUTTON4 = 0x00000300 + MB_OK = 0x00000000 + MB_OKCANCEL = 0x00000001 + MB_ABORTRETRYIGNORE = 0x00000002 + MB_YESNOCANCEL = 0x00000003 + MB_YESNO = 0x00000004 + MB_RETRYCANCEL = 0x00000005 + MB_CANCELTRYCONTINUE = 0x00000006 + MB_ICONHAND = 0x00000010 + MB_ICONQUESTION = 0x00000020 + MB_ICONEXCLAMATION = 0x00000030 + MB_ICONASTERISK = 0x00000040 + MB_USERICON = 0x00000080 + MB_ICONWARNING = MB_ICONEXCLAMATION + MB_ICONERROR = MB_ICONHAND + MB_ICONINFORMATION = MB_ICONASTERISK + MB_ICONSTOP = MB_ICONHAND + MB_DEFBUTTON1 = 0x00000000 + MB_DEFBUTTON2 = 0x00000100 + MB_DEFBUTTON3 = 0x00000200 + MB_DEFBUTTON4 = 0x00000300 + MB_APPLMODAL = 0x00000000 + MB_SYSTEMMODAL = 0x00001000 + MB_TASKMODAL = 0x00002000 + MB_HELP = 0x00004000 + MB_SETFOREGROUND = 0x00010000 + MB_DEFAULT_DESKTOP_ONLY = 0x00020000 + MB_TOPMOST = 0x00040000 + MB_RIGHT = 0x00080000 + MB_RTLREADING = 0x00100000 + MB_SERVICE_NOTIFICATION = 0x00200000 ) // Dialog box command ids From c34dbc13543be77de7ee23c3d617f8172ca5ce1c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 23 Apr 2019 15:17:18 +0200 Subject: [PATCH 082/138] Add some image retrieval constants --- comctl32.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/comctl32.go b/comctl32.go index 503ce443..3ec4b84c 100644 --- a/comctl32.go +++ b/comctl32.go @@ -7,9 +7,10 @@ package win import ( - "golang.org/x/sys/windows" "syscall" "unsafe" + + "golang.org/x/sys/windows" ) // Button control messages @@ -211,6 +212,8 @@ const ( const ( LPSTR_TEXTCALLBACK = ^uintptr(0) I_CHILDRENCALLBACK = -1 + I_IMAGECALLBACK = -1 + I_IMAGENONE = -2 ) type HIMAGELIST HANDLE From 10664f96c528c305c9fa4711ff889b3f5bbb2cb2 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 27 Apr 2019 15:17:07 +0200 Subject: [PATCH 083/138] user32: add missing constant for double buffering Signed-off-by: Jason A. Donenfeld --- user32.go | 1 + 1 file changed, 1 insertion(+) diff --git a/user32.go b/user32.go index 7a3d86ff..2830ba2f 100644 --- a/user32.go +++ b/user32.go @@ -676,6 +676,7 @@ const ( WS_EX_LAYERED = 0X00080000 WS_EX_NOINHERITLAYOUT = 0X00100000 WS_EX_LAYOUTRTL = 0X00400000 + WS_EX_COMPOSITED = 0X02000000 WS_EX_NOACTIVATE = 0X08000000 ) From cd24045cd49925439c32dfa9fa6d03202b6166d4 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 30 Apr 2019 17:51:33 +0200 Subject: [PATCH 084/138] Add some hidpi stuff --- user32.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/user32.go b/user32.go index 2830ba2f..fe02eadd 100644 --- a/user32.go +++ b/user32.go @@ -720,6 +720,7 @@ const ( WM_DEVICECHANGE = 537 WM_DEVMODECHANGE = 27 WM_DISPLAYCHANGE = 126 + WM_DPICHANGED = 0x02E0 WM_DRAWCLIPBOARD = 776 WM_DRAWITEM = 43 WM_DROPFILES = 563 @@ -1649,6 +1650,7 @@ var ( getCursorPos *windows.LazyProc getDC *windows.LazyProc getDesktopWindow *windows.LazyProc + getDpiForWindow *windows.LazyProc getFocus *windows.LazyProc getForegroundWindow *windows.LazyProc getKeyState *windows.LazyProc @@ -1661,6 +1663,7 @@ var ( getSysColor *windows.LazyProc getSysColorBrush *windows.LazyProc getSystemMetrics *windows.LazyProc + getSystemMetricsForDpi *windows.LazyProc getWindow *windows.LazyProc getWindowLong *windows.LazyProc getWindowLongPtr *windows.LazyProc @@ -1776,6 +1779,7 @@ func init() { getCursorPos = libuser32.NewProc("GetCursorPos") getDC = libuser32.NewProc("GetDC") getDesktopWindow = libuser32.NewProc("GetDesktopWindow") + getDpiForWindow = libuser32.NewProc("GetDpiForWindow") getFocus = libuser32.NewProc("GetFocus") getForegroundWindow = libuser32.NewProc("GetForegroundWindow") getKeyState = libuser32.NewProc("GetKeyState") @@ -1788,6 +1792,7 @@ func init() { getSysColor = libuser32.NewProc("GetSysColor") getSysColorBrush = libuser32.NewProc("GetSysColorBrush") getSystemMetrics = libuser32.NewProc("GetSystemMetrics") + getSystemMetricsForDpi = libuser32.NewProc("GetSystemMetricsForDpi") getWindow = libuser32.NewProc("GetWindow") getWindowLong = libuser32.NewProc("GetWindowLongW") // On 32 bit GetWindowLongPtrW is not available @@ -2287,6 +2292,22 @@ func GetDC(hWnd HWND) HDC { return HDC(ret) } +func GetDpiForWindow(hwnd HWND) uint32 { + if getDpiForWindow.Find() != nil { + hdc := GetDC(hwnd) + defer ReleaseDC(hwnd, hdc) + + return uint32(GetDeviceCaps(hdc, LOGPIXELSY)) + } + + ret, _, _ := syscall.Syscall(getDpiForWindow.Addr(), 1, + uintptr(hwnd), + 0, + 0) + + return uint32(ret) +} + func GetFocus() HWND { ret, _, _ := syscall.Syscall(getFocus.Addr(), 0, 0, @@ -2401,6 +2422,15 @@ func GetSystemMetrics(nIndex int32) int32 { return int32(ret) } +func GetSystemMetricsForDpi(nIndex int32, dpi uint32) int32 { + ret, _, _ := syscall.Syscall(getSystemMetricsForDpi.Addr(), 2, + uintptr(nIndex), + uintptr(dpi), + 0) + + return int32(ret) +} + func GetWindow(hWnd HWND, uCmd uint32) HWND { ret, _, _ := syscall.Syscall(getWindow.Addr(), 2, uintptr(hWnd), From 4eb6814c518749ad2f499e81383c373b3fac4358 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 1 May 2019 17:28:23 +0200 Subject: [PATCH 085/138] Fix GetSystemMetricsForDpi crash --- user32.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user32.go b/user32.go index fe02eadd..00a929d9 100644 --- a/user32.go +++ b/user32.go @@ -2423,6 +2423,10 @@ func GetSystemMetrics(nIndex int32) int32 { } func GetSystemMetricsForDpi(nIndex int32, dpi uint32) int32 { + if getSystemMetricsForDpi.Find() != nil { + return GetSystemMetrics(nIndex) + } + ret, _, _ := syscall.Syscall(getSystemMetricsForDpi.Addr(), 2, uintptr(nIndex), uintptr(dpi), From f8e2a851e1fa0a91164865963424adb664304ded Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 2 May 2019 09:56:19 +0200 Subject: [PATCH 086/138] Add ShellExecute Signed-off-by: Jason A. Donenfeld --- shell32.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shell32.go b/shell32.go index f14a6140..9fc209ae 100644 --- a/shell32.go +++ b/shell32.go @@ -307,6 +307,7 @@ var ( shGetSpecialFolderPath *windows.LazyProc shParseDisplayName *windows.LazyProc shGetStockIconInfo *windows.LazyProc + shellExecute *windows.LazyProc shell_NotifyIcon *windows.LazyProc ) @@ -324,6 +325,7 @@ func init() { shGetPathFromIDList = libshell32.NewProc("SHGetPathFromIDListW") shGetSpecialFolderPath = libshell32.NewProc("SHGetSpecialFolderPathW") shGetStockIconInfo = libshell32.NewProc("SHGetStockIconInfo") + shellExecute = libshell32.NewProc("ShellExecuteW") shell_NotifyIcon = libshell32.NewProc("Shell_NotifyIconW") shParseDisplayName = libshell32.NewProc("SHParseDisplayName") } @@ -434,6 +436,18 @@ func SHGetStockIconInfo(stockIconId int32, uFlags uint32, stockIcon *SHSTOCKICON return HRESULT(ret) } +func ShellExecute(hWnd HWND, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int) bool { + ret, _, _ := syscall.Syscall6(shellExecute.Addr(), 6, + uintptr(hWnd), + uintptr(unsafe.Pointer(verb)), + uintptr(unsafe.Pointer(file)), + uintptr(unsafe.Pointer(args)), + uintptr(unsafe.Pointer(cwd)), + uintptr(showCmd), + ) + return ret != 0 +} + func Shell_NotifyIcon(dwMessage uint32, lpdata *NOTIFYICONDATA) bool { ret, _, _ := syscall.Syscall(shell_NotifyIcon.Addr(), 2, uintptr(dwMessage), From 06ff5d1f89f8ddce520a241bf3fbf3f8524a4db2 Mon Sep 17 00:00:00 2001 From: Dmitry Bagdanov Date: Thu, 2 May 2019 19:52:45 +0700 Subject: [PATCH 087/138] add several Win32 API functions for finding and loading data from the application's resources --- gdi32.go | 170 ++++++++++++++++++++++++++++++---------------------- kernel32.go | 45 ++++++++++++++ 2 files changed, 143 insertions(+), 72 deletions(-) diff --git a/gdi32.go b/gdi32.go index d988ee52..a6e3fac0 100644 --- a/gdi32.go +++ b/gdi32.go @@ -7,9 +7,10 @@ package win import ( - "golang.org/x/sys/windows" "syscall" "unsafe" + + "golang.org/x/sys/windows" ) // GetDeviceCaps index constants @@ -1033,77 +1034,79 @@ var ( libmsimg32 *windows.LazyDLL // Functions - abortDoc *windows.LazyProc - addFontResourceEx *windows.LazyProc - alphaBlend *windows.LazyProc - bitBlt *windows.LazyProc - choosePixelFormat *windows.LazyProc - closeEnhMetaFile *windows.LazyProc - combineRgn *windows.LazyProc - copyEnhMetaFile *windows.LazyProc - createBitmap *windows.LazyProc - createCompatibleBitmap *windows.LazyProc - createBrushIndirect *windows.LazyProc - createCompatibleDC *windows.LazyProc - createDC *windows.LazyProc - createDIBSection *windows.LazyProc - createFontIndirect *windows.LazyProc - createEnhMetaFile *windows.LazyProc - createIC *windows.LazyProc - createPatternBrush *windows.LazyProc - createRectRgn *windows.LazyProc - deleteDC *windows.LazyProc - deleteEnhMetaFile *windows.LazyProc - deleteObject *windows.LazyProc - ellipse *windows.LazyProc - endDoc *windows.LazyProc - endPage *windows.LazyProc - excludeClipRect *windows.LazyProc - extCreatePen *windows.LazyProc - fillRgn *windows.LazyProc - gdiFlush *windows.LazyProc - getBkColor *windows.LazyProc - getDeviceCaps *windows.LazyProc - getDIBits *windows.LazyProc - getEnhMetaFile *windows.LazyProc - getEnhMetaFileHeader *windows.LazyProc - getObject *windows.LazyProc - getPixel *windows.LazyProc - getRgnBox *windows.LazyProc - getStockObject *windows.LazyProc - getTextColor *windows.LazyProc - getTextExtentExPoint *windows.LazyProc - getTextExtentPoint32 *windows.LazyProc - getTextMetrics *windows.LazyProc - getViewportOrgEx *windows.LazyProc - gradientFill *windows.LazyProc - intersectClipRect *windows.LazyProc - lineTo *windows.LazyProc - moveToEx *windows.LazyProc - playEnhMetaFile *windows.LazyProc - polyline *windows.LazyProc - rectangle *windows.LazyProc - removeFontResourceEx *windows.LazyProc - resetDC *windows.LazyProc - restoreDC *windows.LazyProc - roundRect *windows.LazyProc - selectObject *windows.LazyProc - setBkColor *windows.LazyProc - setBkMode *windows.LazyProc - setBrushOrgEx *windows.LazyProc - setDIBits *windows.LazyProc - setPixel *windows.LazyProc - setPixelFormat *windows.LazyProc - setStretchBltMode *windows.LazyProc - setTextColor *windows.LazyProc - setViewportOrgEx *windows.LazyProc - saveDC *windows.LazyProc - startDoc *windows.LazyProc - startPage *windows.LazyProc - stretchBlt *windows.LazyProc - swapBuffers *windows.LazyProc - textOut *windows.LazyProc - transparentBlt *windows.LazyProc + abortDoc *windows.LazyProc + addFontResourceEx *windows.LazyProc + addFontMemResourceEx *windows.LazyProc + alphaBlend *windows.LazyProc + bitBlt *windows.LazyProc + choosePixelFormat *windows.LazyProc + closeEnhMetaFile *windows.LazyProc + combineRgn *windows.LazyProc + copyEnhMetaFile *windows.LazyProc + createBitmap *windows.LazyProc + createCompatibleBitmap *windows.LazyProc + createBrushIndirect *windows.LazyProc + createCompatibleDC *windows.LazyProc + createDC *windows.LazyProc + createDIBSection *windows.LazyProc + createFontIndirect *windows.LazyProc + createEnhMetaFile *windows.LazyProc + createIC *windows.LazyProc + createPatternBrush *windows.LazyProc + createRectRgn *windows.LazyProc + deleteDC *windows.LazyProc + deleteEnhMetaFile *windows.LazyProc + deleteObject *windows.LazyProc + ellipse *windows.LazyProc + endDoc *windows.LazyProc + endPage *windows.LazyProc + excludeClipRect *windows.LazyProc + extCreatePen *windows.LazyProc + fillRgn *windows.LazyProc + gdiFlush *windows.LazyProc + getBkColor *windows.LazyProc + getDeviceCaps *windows.LazyProc + getDIBits *windows.LazyProc + getEnhMetaFile *windows.LazyProc + getEnhMetaFileHeader *windows.LazyProc + getObject *windows.LazyProc + getPixel *windows.LazyProc + getRgnBox *windows.LazyProc + getStockObject *windows.LazyProc + getTextColor *windows.LazyProc + getTextExtentExPoint *windows.LazyProc + getTextExtentPoint32 *windows.LazyProc + getTextMetrics *windows.LazyProc + getViewportOrgEx *windows.LazyProc + gradientFill *windows.LazyProc + intersectClipRect *windows.LazyProc + lineTo *windows.LazyProc + moveToEx *windows.LazyProc + playEnhMetaFile *windows.LazyProc + polyline *windows.LazyProc + rectangle *windows.LazyProc + removeFontResourceEx *windows.LazyProc + removeFontMemResourceEx *windows.LazyProc + resetDC *windows.LazyProc + restoreDC *windows.LazyProc + roundRect *windows.LazyProc + selectObject *windows.LazyProc + setBkColor *windows.LazyProc + setBkMode *windows.LazyProc + setBrushOrgEx *windows.LazyProc + setDIBits *windows.LazyProc + setPixel *windows.LazyProc + setPixelFormat *windows.LazyProc + setStretchBltMode *windows.LazyProc + setTextColor *windows.LazyProc + setViewportOrgEx *windows.LazyProc + saveDC *windows.LazyProc + startDoc *windows.LazyProc + startPage *windows.LazyProc + stretchBlt *windows.LazyProc + swapBuffers *windows.LazyProc + textOut *windows.LazyProc + transparentBlt *windows.LazyProc ) func init() { @@ -1114,6 +1117,7 @@ func init() { // Functions abortDoc = libgdi32.NewProc("AbortDoc") addFontResourceEx = libgdi32.NewProc("AddFontResourceExW") + addFontMemResourceEx = libgdi32.NewProc("AddFontMemResourceEx") bitBlt = libgdi32.NewProc("BitBlt") choosePixelFormat = libgdi32.NewProc("ChoosePixelFormat") closeEnhMetaFile = libgdi32.NewProc("CloseEnhMetaFile") @@ -1161,6 +1165,7 @@ func init() { polyline = libgdi32.NewProc("Polyline") rectangle = libgdi32.NewProc("Rectangle") removeFontResourceEx = libgdi32.NewProc("RemoveFontResourceExW") + removeFontMemResourceEx = libgdi32.NewProc("RemoveFontMemResourceEx") resetDC = libgdi32.NewProc("ResetDCW") restoreDC = libgdi32.NewProc("RestoreDC") roundRect = libgdi32.NewProc("RoundRect") @@ -1204,6 +1209,18 @@ func AddFontResourceEx(lpszFilename *uint16, fl uint32, pdv unsafe.Pointer) int3 return int32(ret) } +func AddFontMemResourceEx(pFileView uintptr, cjSize uint32, pvReserved unsafe.Pointer, pNumFonts *uint32) HANDLE { + ret, _, _ := syscall.Syscall6(addFontMemResourceEx.Addr(), 4, + pFileView, + uintptr(cjSize), + uintptr(pvReserved), + uintptr(unsafe.Pointer(pNumFonts)), + 0, + 0) + + return HANDLE(ret) +} + func AlphaBlend(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int32, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int32, ftn BLENDFUNCTION) bool { ret, _, _ := syscall.Syscall12(alphaBlend.Addr(), 11, uintptr(hdcDest), @@ -1716,6 +1733,15 @@ func RemoveFontResourceEx(lpszFilename *uint16, fl uint32, pdv unsafe.Pointer) b return ret != 0 } +func RemoveFontMemResourceEx(h HANDLE) bool { + ret, _, _ := syscall.Syscall(removeFontMemResourceEx.Addr(), 1, + uintptr(h), + 0, + 0) + + return ret != 0 +} + func ResetDC(hdc HDC, lpInitData *DEVMODE) HDC { ret, _, _ := syscall.Syscall(resetDC.Addr(), 2, uintptr(hdc), diff --git a/kernel32.go b/kernel32.go index b81b7573..4ba068b4 100644 --- a/kernel32.go +++ b/kernel32.go @@ -62,6 +62,7 @@ var ( closeHandle *windows.LazyProc createActCtx *windows.LazyProc fileTimeToSystemTime *windows.LazyProc + findResource *windows.LazyProc getConsoleTitle *windows.LazyProc getConsoleWindow *windows.LazyProc getLastError *windows.LazyProc @@ -80,7 +81,10 @@ var ( globalUnlock *windows.LazyProc moveMemory *windows.LazyProc mulDiv *windows.LazyProc + loadResource *windows.LazyProc + lockResource *windows.LazyProc setLastError *windows.LazyProc + sizeofResource *windows.LazyProc systemTimeToFileTime *windows.LazyProc ) @@ -94,6 +98,7 @@ type ( LANGID uint16 HMODULE uintptr HWINEVENTHOOK HANDLE + HRSRC uintptr ) type FILETIME struct { @@ -142,6 +147,7 @@ func init() { closeHandle = libkernel32.NewProc("CloseHandle") createActCtx = libkernel32.NewProc("CreateActCtxW") fileTimeToSystemTime = libkernel32.NewProc("FileTimeToSystemTime") + findResource = libkernel32.NewProc("FindResourceW") getConsoleTitle = libkernel32.NewProc("GetConsoleTitleW") getConsoleWindow = libkernel32.NewProc("GetConsoleWindow") getLastError = libkernel32.NewProc("GetLastError") @@ -160,7 +166,10 @@ func init() { globalUnlock = libkernel32.NewProc("GlobalUnlock") moveMemory = libkernel32.NewProc("RtlMoveMemory") mulDiv = libkernel32.NewProc("MulDiv") + loadResource = libkernel32.NewProc("LoadResource") + lockResource = libkernel32.NewProc("LockResource") setLastError = libkernel32.NewProc("SetLastError") + sizeofResource = libkernel32.NewProc("SizeofResource") systemTimeToFileTime = libkernel32.NewProc("SystemTimeToFileTime") } @@ -204,6 +213,15 @@ func FileTimeToSystemTime(lpFileTime *FILETIME, lpSystemTime *SYSTEMTIME) bool { return ret != 0 } +func FindResource(hModule HMODULE, lpName, lpType *uint16) HRSRC { + ret, _, _ := syscall.Syscall(findResource.Addr(), 3, + uintptr(hModule), + uintptr(unsafe.Pointer(lpName)), + uintptr(unsafe.Pointer(lpType))); + + return HRSRC(ret) +} + func GetConsoleTitle(lpConsoleTitle *uint16, nSize uint32) uint32 { ret, _, _ := syscall.Syscall(getConsoleTitle.Addr(), 2, uintptr(unsafe.Pointer(lpConsoleTitle)), @@ -378,6 +396,24 @@ func MulDiv(nNumber, nNumerator, nDenominator int32) int32 { return int32(ret) } +func LoadResource(hModule HMODULE, hResInfo HRSRC) HGLOBAL { + ret, _, _ := syscall.Syscall(loadResource.Addr(), 2, + uintptr(hModule), + uintptr(hResInfo), + 0); + + return HGLOBAL(ret) +} + +func LockResource(hResData HGLOBAL) uintptr { + ret, _, _ := syscall.Syscall(lockResource.Addr(), 1, + uintptr(hResData), + 0, + 0); + + return ret +} + func SetLastError(dwErrorCode uint32) { syscall.Syscall(setLastError.Addr(), 1, uintptr(dwErrorCode), @@ -385,6 +421,15 @@ func SetLastError(dwErrorCode uint32) { 0) } +func SizeofResource(hModule HMODULE, hResInfo HRSRC) uint32 { + ret, _, _ := syscall.Syscall(sizeofResource.Addr(), 2, + uintptr(hModule), + uintptr(hResInfo), + 0); + + return uint32(ret) +} + func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { ret, _, _ := syscall.Syscall(systemTimeToFileTime.Addr(), 2, uintptr(unsafe.Pointer(lpSystemTime)), From 186b73330cff36247eb53e4b88a438853b06ef25 Mon Sep 17 00:00:00 2001 From: Dmitry Bagdanov Date: Thu, 2 May 2019 23:29:19 +0700 Subject: [PATCH 088/138] Update AUTHORS file --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 41723e32..019ddc42 100644 --- a/AUTHORS +++ b/AUTHORS @@ -30,3 +30,4 @@ Tiago Carvalho wsf01 gonutz Cory Redmond +Dmitry Bagdanov From 6a5038c64271c6c144f842a070f10796a0aacb65 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 4 May 2019 10:10:39 +0200 Subject: [PATCH 089/138] kernel32: GetVersion returns a DWORD Signed-off-by: Jason A. Donenfeld --- kernel32.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel32.go b/kernel32.go index b81b7573..a6414f44 100644 --- a/kernel32.go +++ b/kernel32.go @@ -318,12 +318,12 @@ func GetThreadUILanguage() LANGID { return LANGID(ret) } -func GetVersion() int64 { +func GetVersion() uint32 { ret, _, _ := syscall.Syscall(getVersion.Addr(), 0, 0, 0, 0) - return int64(ret) + return uint32(ret) } func GlobalAlloc(uFlags uint32, dwBytes uintptr) HGLOBAL { From 4acbabbcec8d1bcb898079ba71f8f41383940594 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 4 May 2019 10:42:42 +0200 Subject: [PATCH 090/138] user32/kernel32: add thread attachment functions These generally help with raising windows to the foreground forcibly. Resolves: https://github.com/lxn/win/pull/22 Signed-off-by: Jason A. Donenfeld --- kernel32.go | 11 +++++++++++ user32.go | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/kernel32.go b/kernel32.go index b81b7573..0a50aee1 100644 --- a/kernel32.go +++ b/kernel32.go @@ -64,6 +64,7 @@ var ( fileTimeToSystemTime *windows.LazyProc getConsoleTitle *windows.LazyProc getConsoleWindow *windows.LazyProc + getCurrentThreadId *windows.LazyProc getLastError *windows.LazyProc getLocaleInfo *windows.LazyProc getLogicalDriveStrings *windows.LazyProc @@ -144,6 +145,7 @@ func init() { fileTimeToSystemTime = libkernel32.NewProc("FileTimeToSystemTime") getConsoleTitle = libkernel32.NewProc("GetConsoleTitleW") getConsoleWindow = libkernel32.NewProc("GetConsoleWindow") + getCurrentThreadId = libkernel32.NewProc("GetCurrentThreadId") getLastError = libkernel32.NewProc("GetLastError") getLocaleInfo = libkernel32.NewProc("GetLocaleInfoW") getLogicalDriveStrings = libkernel32.NewProc("GetLogicalDriveStringsW") @@ -222,6 +224,15 @@ func GetConsoleWindow() HWND { return HWND(ret) } +func GetCurrentThreadId() uint32 { + ret, _, _ := syscall.Syscall(getCurrentThreadId.Addr(), 0, + 0, + 0, + 0) + + return uint32(ret) +} + func GetLastError() uint32 { ret, _, _ := syscall.Syscall(getLastError.Addr(), 0, 0, diff --git a/user32.go b/user32.go index 00a929d9..abbe9446 100644 --- a/user32.go +++ b/user32.go @@ -1610,6 +1610,7 @@ var ( // Functions addClipboardFormatListener *windows.LazyProc adjustWindowRect *windows.LazyProc + attachThreadInput *windows.LazyProc animateWindow *windows.LazyProc beginDeferWindowPos *windows.LazyProc beginPaint *windows.LazyProc @@ -1669,6 +1670,7 @@ var ( getWindowLongPtr *windows.LazyProc getWindowPlacement *windows.LazyProc getWindowRect *windows.LazyProc + getWindowThreadProcessId *windows.LazyProc insertMenuItem *windows.LazyProc invalidateRect *windows.LazyProc isChild *windows.LazyProc @@ -1739,6 +1741,7 @@ func init() { // Functions addClipboardFormatListener = libuser32.NewProc("AddClipboardFormatListener") adjustWindowRect = libuser32.NewProc("AdjustWindowRect") + attachThreadInput = libuser32.NewProc("AttachThreadInput") animateWindow = libuser32.NewProc("AnimateWindow") beginDeferWindowPos = libuser32.NewProc("BeginDeferWindowPos") beginPaint = libuser32.NewProc("BeginPaint") @@ -1803,6 +1806,7 @@ func init() { } getWindowPlacement = libuser32.NewProc("GetWindowPlacement") getWindowRect = libuser32.NewProc("GetWindowRect") + getWindowThreadProcessId = libuser32.NewProc("GetWindowThreadProcessId") insertMenuItem = libuser32.NewProc("InsertMenuItemW") invalidateRect = libuser32.NewProc("InvalidateRect") isChild = libuser32.NewProc("IsChild") @@ -1891,6 +1895,15 @@ func AdjustWindowRect(lpRect *RECT, dwStyle uint32, bMenu bool) bool { return ret != 0 } +func AttachThreadInput(idAttach int32, idAttachTo int32, fAttach bool) bool { + ret, _, _ := syscall.Syscall(attachThreadInput.Addr(), 3, + uintptr(idAttach), + uintptr(idAttachTo), + uintptr(BoolToBOOL(fAttach))) + + return ret != 0 +} + func AnimateWindow(hwnd HWND, dwTime, dwFlags uint32) bool { ret, _, _ := syscall.Syscall(animateWindow.Addr(), 3, uintptr(hwnd), @@ -1909,6 +1922,15 @@ func BeginDeferWindowPos(nNumWindows int32) HDWP { return HDWP(ret) } +func GetWindowThreadProcessId(hwnd HWND, processId *uint32) uint32 { + ret, _, _ := syscall.Syscall(getWindowThreadProcessId.Addr(), 2, + uintptr(hwnd), + uintptr(unsafe.Pointer(processId)), + 0) + + return uint32(ret) +} + func BeginPaint(hwnd HWND, lpPaint *PAINTSTRUCT) HDC { ret, _, _ := syscall.Syscall(beginPaint.Addr(), 2, uintptr(hwnd), From 644e9ec767fff0b31c59b1f49584604d259de5f6 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 4 May 2019 11:20:46 +0200 Subject: [PATCH 091/138] user32: allow unsetting the default item --- user32.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/user32.go b/user32.go index 00a929d9..d63c99d3 100644 --- a/user32.go +++ b/user32.go @@ -1709,6 +1709,7 @@ var ( setFocus *windows.LazyProc setForegroundWindow *windows.LazyProc setMenu *windows.LazyProc + setMenuDefaultItem *windows.LazyProc setMenuInfo *windows.LazyProc setMenuItemInfo *windows.LazyProc setParent *windows.LazyProc @@ -1843,6 +1844,7 @@ func init() { setFocus = libuser32.NewProc("SetFocus") setForegroundWindow = libuser32.NewProc("SetForegroundWindow") setMenu = libuser32.NewProc("SetMenu") + setMenuDefaultItem = libuser32.NewProc("SetMenuDefaultItem") setMenuInfo = libuser32.NewProc("SetMenuInfo") setMenuItemInfo = libuser32.NewProc("SetMenuItemInfoW") setRect = libuser32.NewProc("SetRect") @@ -2880,6 +2882,15 @@ func SetMenu(hWnd HWND, hMenu HMENU) bool { return ret != 0 } +func SetMenuDefaultItem(hMenu HMENU, uItem uint32, fByPosition bool) bool { + ret, _, _ := syscall.Syscall(setMenuDefaultItem.Addr(), 3, + uintptr(hMenu), + uintptr(uItem), + uintptr(BoolToBOOL(fByPosition))) + + return ret != 0 +} + func SetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { ret, _, _ := syscall.Syscall(setMenuInfo.Addr(), 2, uintptr(hmenu), From 7fbdd103bab1fd540a60f2195f3f4f0351451d11 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 4 May 2019 09:50:42 +0200 Subject: [PATCH 092/138] shell32: add missing notify icon constants Signed-off-by: Jason A. Donenfeld --- shell32.go | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/shell32.go b/shell32.go index 9fc209ae..d9c62cca 100644 --- a/shell32.go +++ b/shell32.go @@ -82,11 +82,14 @@ const ( // NotifyIcon flags const ( - NIF_MESSAGE = 0x00000001 - NIF_ICON = 0x00000002 - NIF_TIP = 0x00000004 - NIF_STATE = 0x00000008 - NIF_INFO = 0x00000010 + NIF_MESSAGE = 0x00000001 + NIF_ICON = 0x00000002 + NIF_TIP = 0x00000004 + NIF_STATE = 0x00000008 + NIF_INFO = 0x00000010 + NIF_GUID = 0x00000020 + NIF_REALTIME = 0x00000040 + NIF_SHOWTIP = 0x00000080 ) // NotifyIcon messages @@ -106,15 +109,33 @@ const ( // NotifyIcon info flags const ( - NIIF_NONE = 0x00000000 - NIIF_INFO = 0x00000001 - NIIF_WARNING = 0x00000002 - NIIF_ERROR = 0x00000003 - NIIF_USER = 0x00000004 - NIIF_NOSOUND = 0x00000010 + NIIF_NONE = 0x00000000 + NIIF_INFO = 0x00000001 + NIIF_WARNING = 0x00000002 + NIIF_ERROR = 0x00000003 + NIIF_USER = 0x00000004 + NIIF_NOSOUND = 0x00000010 + NIIF_LARGE_ICON = 0x00000020 + NIIF_RESPECT_QUIET_TIME = 0x00000080 ) -const NOTIFYICON_VERSION = 3 +// NotifyIcon notifications +const ( + NIN_SELECT = WM_USER + 0 + NIN_KEYSELECT = WM_USER + 1 + NIN_BALLOONSHOW = WM_USER + 2 + NIN_BALLOONHIDE = WM_USER + 3 + NIN_BALLOONTIMEOUT = WM_USER + 4 + NIN_BALLOONUSERCLICK = WM_USER + 5 + NIN_POPUPOPEN = WM_USER + 6 + NIN_POPUPCLOSE = WM_USER + 7 +) + +// NotifyIcon versions +const ( + NOTIFYICON_VERSION = 3 + NOTIFYICON_VERSION_4 = 4 +) // SHGetFileInfo flags const ( @@ -263,6 +284,7 @@ type NOTIFYICONDATA struct { SzInfoTitle [64]uint16 DwInfoFlags uint32 GuidItem syscall.GUID + HBalloonIcon HICON } type SHFILEINFO struct { From f6f761e05768065062fb5809731773a3820c2ecc Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 7 May 2019 10:21:39 +0200 Subject: [PATCH 093/138] user32: add session end constants --- user32.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/user32.go b/user32.go index 7f580c40..3f16ef5d 100644 --- a/user32.go +++ b/user32.go @@ -1327,6 +1327,13 @@ const ( AW_VER_NEGATIVE = 0x00000008 ) +// Session ending constants +const ( + ENDSESSION_CLOSEAPP = 0x00000001 + ENDSESSION_CRITICAL = 0x40000000 + ENDSESSION_LOGOFF = 0x80000000 +) + type NMBCDROPDOWN struct { Hdr NMHDR RcButton RECT From 261b4e665afe1d9cd8b0681208288e513660c6fe Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 8 May 2019 11:18:11 +0200 Subject: [PATCH 094/138] Add SHDefExtractIcon; go fmt --- kernel32.go | 14 +++++++------- shell32.go | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/kernel32.go b/kernel32.go index 168f0d5e..4c9e512d 100644 --- a/kernel32.go +++ b/kernel32.go @@ -219,7 +219,7 @@ func FindResource(hModule HMODULE, lpName, lpType *uint16) HRSRC { ret, _, _ := syscall.Syscall(findResource.Addr(), 3, uintptr(hModule), uintptr(unsafe.Pointer(lpName)), - uintptr(unsafe.Pointer(lpType))); + uintptr(unsafe.Pointer(lpType))) return HRSRC(ret) } @@ -408,10 +408,10 @@ func MulDiv(nNumber, nNumerator, nDenominator int32) int32 { } func LoadResource(hModule HMODULE, hResInfo HRSRC) HGLOBAL { - ret, _, _ := syscall.Syscall(loadResource.Addr(), 2, - uintptr(hModule), - uintptr(hResInfo), - 0); + ret, _, _ := syscall.Syscall(loadResource.Addr(), 2, + uintptr(hModule), + uintptr(hResInfo), + 0) return HGLOBAL(ret) } @@ -420,7 +420,7 @@ func LockResource(hResData HGLOBAL) uintptr { ret, _, _ := syscall.Syscall(lockResource.Addr(), 1, uintptr(hResData), 0, - 0); + 0) return ret } @@ -436,7 +436,7 @@ func SizeofResource(hModule HMODULE, hResInfo HRSRC) uint32 { ret, _, _ := syscall.Syscall(sizeofResource.Addr(), 2, uintptr(hModule), uintptr(hResInfo), - 0); + 0) return uint32(ret) } diff --git a/shell32.go b/shell32.go index d9c62cca..27f20da7 100644 --- a/shell32.go +++ b/shell32.go @@ -324,6 +324,7 @@ var ( dragQueryFile *windows.LazyProc extractIcon *windows.LazyProc shBrowseForFolder *windows.LazyProc + shDefExtractIcon *windows.LazyProc shGetFileInfo *windows.LazyProc shGetPathFromIDList *windows.LazyProc shGetSpecialFolderPath *windows.LazyProc @@ -343,6 +344,7 @@ func init() { dragQueryFile = libshell32.NewProc("DragQueryFileW") extractIcon = libshell32.NewProc("ExtractIconW") shBrowseForFolder = libshell32.NewProc("SHBrowseForFolderW") + shDefExtractIcon = libshell32.NewProc("SHDefExtractIconW") shGetFileInfo = libshell32.NewProc("SHGetFileInfoW") shGetPathFromIDList = libshell32.NewProc("SHGetPathFromIDListW") shGetSpecialFolderPath = libshell32.NewProc("SHGetSpecialFolderPathW") @@ -398,6 +400,18 @@ func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr { return ret } +func SHDefExtractIconW(pszIconFile *uint16, iIndex int32, uFlags uint32, phiconLarge, phiconSmall *HICON, nIconSize uint32) HRESULT { + ret, _, _ := syscall.Syscall6(shDefExtractIcon.Addr(), 6, + uintptr(unsafe.Pointer(pszIconFile)), + uintptr(iIndex), + uintptr(uFlags), + uintptr(unsafe.Pointer(phiconLarge)), + uintptr(unsafe.Pointer(phiconSmall)), + uintptr(nIconSize)) + + return HRESULT(ret) +} + func SHGetFileInfo(pszPath *uint16, dwFileAttributes uint32, psfi *SHFILEINFO, cbFileInfo, uFlags uint32) uintptr { ret, _, _ := syscall.Syscall6(shGetFileInfo.Addr(), 5, uintptr(unsafe.Pointer(pszPath)), From 10b82f329a11076854b662dd29025194d9048bb4 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 8 May 2019 11:21:09 +0200 Subject: [PATCH 095/138] Fix for previous commit --- shell32.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell32.go b/shell32.go index 27f20da7..8c683aec 100644 --- a/shell32.go +++ b/shell32.go @@ -400,7 +400,7 @@ func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr { return ret } -func SHDefExtractIconW(pszIconFile *uint16, iIndex int32, uFlags uint32, phiconLarge, phiconSmall *HICON, nIconSize uint32) HRESULT { +func SHDefExtractIcon(pszIconFile *uint16, iIndex int32, uFlags uint32, phiconLarge, phiconSmall *HICON, nIconSize uint32) HRESULT { ret, _, _ := syscall.Syscall6(shDefExtractIcon.Addr(), 6, uintptr(unsafe.Pointer(pszIconFile)), uintptr(iIndex), From 168a55d0754105ee20965b225bf1113c9a71a99f Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 8 May 2019 13:17:46 +0200 Subject: [PATCH 096/138] Add IsIconic Signed-off-by: Simon Rozman --- AUTHORS | 1 + user32.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/AUTHORS b/AUTHORS index 019ddc42..ccc26294 100644 --- a/AUTHORS +++ b/AUTHORS @@ -26,6 +26,7 @@ Kevin Pors ktye mycaosf ryujimiya +Simon Rozman Tiago Carvalho wsf01 gonutz diff --git a/user32.go b/user32.go index 3f16ef5d..4411256e 100644 --- a/user32.go +++ b/user32.go @@ -1683,6 +1683,7 @@ var ( isChild *windows.LazyProc isClipboardFormatAvailable *windows.LazyProc isDialogMessage *windows.LazyProc + isIconic *windows.LazyProc isWindowEnabled *windows.LazyProc isWindowVisible *windows.LazyProc killTimer *windows.LazyProc @@ -1820,6 +1821,7 @@ func init() { isChild = libuser32.NewProc("IsChild") isClipboardFormatAvailable = libuser32.NewProc("IsClipboardFormatAvailable") isDialogMessage = libuser32.NewProc("IsDialogMessageW") + isIconic = libuser32.NewProc("IsIconic") isWindowEnabled = libuser32.NewProc("IsWindowEnabled") isWindowVisible = libuser32.NewProc("IsWindowVisible") killTimer = libuser32.NewProc("KillTimer") @@ -2559,6 +2561,15 @@ func IsDialogMessage(hWnd HWND, msg *MSG) bool { return ret != 0 } +func IsIconic(hWnd HWND) bool { + ret, _, _ := syscall.Syscall(isIconic.Addr(), 1, + uintptr(hWnd), + 0, + 0) + + return ret != 0 +} + func IsWindowEnabled(hWnd HWND) bool { ret, _, _ := syscall.Syscall(isWindowEnabled.Addr(), 1, uintptr(hWnd), From c45cc0805cd64a837f6a3b80c4c6d9b1d2b8a359 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 8 May 2019 13:54:50 +0200 Subject: [PATCH 097/138] Add IsZoomed Signed-off-by: Simon Rozman --- user32.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/user32.go b/user32.go index 4411256e..6b76a8b4 100644 --- a/user32.go +++ b/user32.go @@ -1686,6 +1686,7 @@ var ( isIconic *windows.LazyProc isWindowEnabled *windows.LazyProc isWindowVisible *windows.LazyProc + isZoomed *windows.LazyProc killTimer *windows.LazyProc loadCursor *windows.LazyProc loadIcon *windows.LazyProc @@ -1824,6 +1825,7 @@ func init() { isIconic = libuser32.NewProc("IsIconic") isWindowEnabled = libuser32.NewProc("IsWindowEnabled") isWindowVisible = libuser32.NewProc("IsWindowVisible") + isZoomed = libuser32.NewProc("IsZoomed") killTimer = libuser32.NewProc("KillTimer") loadCursor = libuser32.NewProc("LoadCursorW") loadIcon = libuser32.NewProc("LoadIconW") @@ -2588,6 +2590,15 @@ func IsWindowVisible(hWnd HWND) bool { return ret != 0 } +func IsZoomed(hWnd HWND) bool { + ret, _, _ := syscall.Syscall(isZoomed.Addr(), 1, + uintptr(hWnd), + 0, + 0) + + return ret != 0 +} + func KillTimer(hWnd HWND, uIDEvent uintptr) bool { ret, _, _ := syscall.Syscall(killTimer.Addr(), 2, uintptr(hWnd), From 128b91335ca07c8e185b67c99eee1fce03642def Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 8 May 2019 16:46:31 +0200 Subject: [PATCH 098/138] Add GetIconInfo --- user32.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/user32.go b/user32.go index 3f16ef5d..aeded251 100644 --- a/user32.go +++ b/user32.go @@ -1661,6 +1661,7 @@ var ( getDpiForWindow *windows.LazyProc getFocus *windows.LazyProc getForegroundWindow *windows.LazyProc + getIconInfo *windows.LazyProc getKeyState *windows.LazyProc getMenuInfo *windows.LazyProc getMessage *windows.LazyProc @@ -1793,6 +1794,7 @@ func init() { getDpiForWindow = libuser32.NewProc("GetDpiForWindow") getFocus = libuser32.NewProc("GetFocus") getForegroundWindow = libuser32.NewProc("GetForegroundWindow") + getIconInfo = libuser32.NewProc("GetIconInfo") getKeyState = libuser32.NewProc("GetKeyState") getMenuInfo = libuser32.NewProc("GetMenuInfo") getMessage = libuser32.NewProc("GetMessageW") @@ -2357,6 +2359,15 @@ func GetForegroundWindow() HWND { return HWND(ret) } +func GetIconInfo(hicon HICON, piconinfo *ICONINFO) bool { + ret, _, _ := syscall.Syscall(getIconInfo.Addr(), 2, + uintptr(hicon), + uintptr(unsafe.Pointer(piconinfo)), + 0) + + return ret != 0 +} + func GetKeyState(nVirtKey int32) int16 { ret, _, _ := syscall.Syscall(getKeyState.Addr(), 1, uintptr(nVirtKey), From 438afda62e32fee64a6e62bf771ce1173c07f6c6 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Thu, 9 May 2019 21:01:52 -0700 Subject: [PATCH 099/138] add go.mod --- go.mod | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 go.mod diff --git a/go.mod b/go.mod new file mode 100644 index 00000000..d000c521 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/lxn/win + +go 1.12 From bad535d53b6dd69e1b2ea6608bc8fb75279c94fa Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 12 May 2019 11:35:09 +0200 Subject: [PATCH 100/138] user32: add UIPI filter modifying function and constants Signed-off-by: Jason A. Donenfeld --- user32.go | 282 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 156 insertions(+), 126 deletions(-) diff --git a/user32.go b/user32.go index 7c29e0a2..9b3244b2 100644 --- a/user32.go +++ b/user32.go @@ -1334,6 +1334,18 @@ const ( ENDSESSION_LOGOFF = 0x80000000 ) +// ChangeWindowMessageFilterEx constants +const ( + MSGFLT_RESET = 0 + MSGFLT_ALLOW = 1 + MSGFLT_DISALLOW = 2 + + MSGFLTINFO_NONE = 0 + MSGFLTINFO_ALREADYALLOWED_FORWND = 1 + MSGFLTINFO_ALREADYDISALLOWED_FORWND = 2 + MSGFLTINFO_ALLOWED_HIGHER = 3 +) + type NMBCDROPDOWN struct { Hdr NMHDR RcButton RECT @@ -1441,6 +1453,11 @@ type CREATESTRUCT struct { ExStyle uint32 } +type CHANGEFILTERSTRUCT struct { + size uint32 + extStatus uint32 +} + type WNDCLASSEX struct { CbSize uint32 Style uint32 @@ -1615,132 +1632,133 @@ var ( libuser32 *windows.LazyDLL // Functions - addClipboardFormatListener *windows.LazyProc - adjustWindowRect *windows.LazyProc - attachThreadInput *windows.LazyProc - animateWindow *windows.LazyProc - beginDeferWindowPos *windows.LazyProc - beginPaint *windows.LazyProc - bringWindowToTop *windows.LazyProc - callWindowProc *windows.LazyProc - checkMenuRadioItem *windows.LazyProc - clientToScreen *windows.LazyProc - closeClipboard *windows.LazyProc - createDialogParam *windows.LazyProc - createIconIndirect *windows.LazyProc - createMenu *windows.LazyProc - createPopupMenu *windows.LazyProc - createWindowEx *windows.LazyProc - deferWindowPos *windows.LazyProc - defWindowProc *windows.LazyProc - destroyIcon *windows.LazyProc - destroyMenu *windows.LazyProc - destroyWindow *windows.LazyProc - dialogBoxParam *windows.LazyProc - dispatchMessage *windows.LazyProc - drawIconEx *windows.LazyProc - drawMenuBar *windows.LazyProc - drawFocusRect *windows.LazyProc - drawTextEx *windows.LazyProc - emptyClipboard *windows.LazyProc - enableWindow *windows.LazyProc - endDeferWindowPos *windows.LazyProc - endDialog *windows.LazyProc - endPaint *windows.LazyProc - enumChildWindows *windows.LazyProc - findWindow *windows.LazyProc - getActiveWindow *windows.LazyProc - getAncestor *windows.LazyProc - getCaretPos *windows.LazyProc - getClassName *windows.LazyProc - getClientRect *windows.LazyProc - getClipboardData *windows.LazyProc - getCursorPos *windows.LazyProc - getDC *windows.LazyProc - getDesktopWindow *windows.LazyProc - getDpiForWindow *windows.LazyProc - getFocus *windows.LazyProc - getForegroundWindow *windows.LazyProc - getIconInfo *windows.LazyProc - getKeyState *windows.LazyProc - getMenuInfo *windows.LazyProc - getMessage *windows.LazyProc - getMonitorInfo *windows.LazyProc - getParent *windows.LazyProc - getRawInputData *windows.LazyProc - getScrollInfo *windows.LazyProc - getSysColor *windows.LazyProc - getSysColorBrush *windows.LazyProc - getSystemMetrics *windows.LazyProc - getSystemMetricsForDpi *windows.LazyProc - getWindow *windows.LazyProc - getWindowLong *windows.LazyProc - getWindowLongPtr *windows.LazyProc - getWindowPlacement *windows.LazyProc - getWindowRect *windows.LazyProc - getWindowThreadProcessId *windows.LazyProc - insertMenuItem *windows.LazyProc - invalidateRect *windows.LazyProc - isChild *windows.LazyProc - isClipboardFormatAvailable *windows.LazyProc - isDialogMessage *windows.LazyProc - isIconic *windows.LazyProc - isWindowEnabled *windows.LazyProc - isWindowVisible *windows.LazyProc - isZoomed *windows.LazyProc - killTimer *windows.LazyProc - loadCursor *windows.LazyProc - loadIcon *windows.LazyProc - loadImage *windows.LazyProc - loadMenu *windows.LazyProc - loadString *windows.LazyProc - messageBeep *windows.LazyProc - messageBox *windows.LazyProc - monitorFromWindow *windows.LazyProc - moveWindow *windows.LazyProc - unregisterClass *windows.LazyProc - openClipboard *windows.LazyProc - peekMessage *windows.LazyProc - postMessage *windows.LazyProc - postQuitMessage *windows.LazyProc - registerClassEx *windows.LazyProc - registerRawInputDevices *windows.LazyProc - registerWindowMessage *windows.LazyProc - releaseCapture *windows.LazyProc - releaseDC *windows.LazyProc - removeMenu *windows.LazyProc - screenToClient *windows.LazyProc - sendDlgItemMessage *windows.LazyProc - sendInput *windows.LazyProc - sendMessage *windows.LazyProc - setActiveWindow *windows.LazyProc - setCapture *windows.LazyProc - setClipboardData *windows.LazyProc - setCursor *windows.LazyProc - setCursorPos *windows.LazyProc - setFocus *windows.LazyProc - setForegroundWindow *windows.LazyProc - setMenu *windows.LazyProc - setMenuDefaultItem *windows.LazyProc - setMenuInfo *windows.LazyProc - setMenuItemInfo *windows.LazyProc - setParent *windows.LazyProc - setRect *windows.LazyProc - setScrollInfo *windows.LazyProc - setTimer *windows.LazyProc - setWinEventHook *windows.LazyProc - setWindowLong *windows.LazyProc - setWindowLongPtr *windows.LazyProc - setWindowPlacement *windows.LazyProc - setWindowPos *windows.LazyProc - showWindow *windows.LazyProc - systemParametersInfo *windows.LazyProc - trackPopupMenuEx *windows.LazyProc - translateMessage *windows.LazyProc - unhookWinEvent *windows.LazyProc - updateWindow *windows.LazyProc - windowFromDC *windows.LazyProc - windowFromPoint *windows.LazyProc + addClipboardFormatListener *windows.LazyProc + adjustWindowRect *windows.LazyProc + attachThreadInput *windows.LazyProc + animateWindow *windows.LazyProc + beginDeferWindowPos *windows.LazyProc + beginPaint *windows.LazyProc + bringWindowToTop *windows.LazyProc + callWindowProc *windows.LazyProc + changeWindowMessageFilterEx *windows.LazyProc + checkMenuRadioItem *windows.LazyProc + clientToScreen *windows.LazyProc + closeClipboard *windows.LazyProc + createDialogParam *windows.LazyProc + createIconIndirect *windows.LazyProc + createMenu *windows.LazyProc + createPopupMenu *windows.LazyProc + createWindowEx *windows.LazyProc + deferWindowPos *windows.LazyProc + defWindowProc *windows.LazyProc + destroyIcon *windows.LazyProc + destroyMenu *windows.LazyProc + destroyWindow *windows.LazyProc + dialogBoxParam *windows.LazyProc + dispatchMessage *windows.LazyProc + drawIconEx *windows.LazyProc + drawMenuBar *windows.LazyProc + drawFocusRect *windows.LazyProc + drawTextEx *windows.LazyProc + emptyClipboard *windows.LazyProc + enableWindow *windows.LazyProc + endDeferWindowPos *windows.LazyProc + endDialog *windows.LazyProc + endPaint *windows.LazyProc + enumChildWindows *windows.LazyProc + findWindow *windows.LazyProc + getActiveWindow *windows.LazyProc + getAncestor *windows.LazyProc + getCaretPos *windows.LazyProc + getClassName *windows.LazyProc + getClientRect *windows.LazyProc + getClipboardData *windows.LazyProc + getCursorPos *windows.LazyProc + getDC *windows.LazyProc + getDesktopWindow *windows.LazyProc + getDpiForWindow *windows.LazyProc + getFocus *windows.LazyProc + getForegroundWindow *windows.LazyProc + getIconInfo *windows.LazyProc + getKeyState *windows.LazyProc + getMenuInfo *windows.LazyProc + getMessage *windows.LazyProc + getMonitorInfo *windows.LazyProc + getParent *windows.LazyProc + getRawInputData *windows.LazyProc + getScrollInfo *windows.LazyProc + getSysColor *windows.LazyProc + getSysColorBrush *windows.LazyProc + getSystemMetrics *windows.LazyProc + getSystemMetricsForDpi *windows.LazyProc + getWindow *windows.LazyProc + getWindowLong *windows.LazyProc + getWindowLongPtr *windows.LazyProc + getWindowPlacement *windows.LazyProc + getWindowRect *windows.LazyProc + getWindowThreadProcessId *windows.LazyProc + insertMenuItem *windows.LazyProc + invalidateRect *windows.LazyProc + isChild *windows.LazyProc + isClipboardFormatAvailable *windows.LazyProc + isDialogMessage *windows.LazyProc + isIconic *windows.LazyProc + isWindowEnabled *windows.LazyProc + isWindowVisible *windows.LazyProc + isZoomed *windows.LazyProc + killTimer *windows.LazyProc + loadCursor *windows.LazyProc + loadIcon *windows.LazyProc + loadImage *windows.LazyProc + loadMenu *windows.LazyProc + loadString *windows.LazyProc + messageBeep *windows.LazyProc + messageBox *windows.LazyProc + monitorFromWindow *windows.LazyProc + moveWindow *windows.LazyProc + unregisterClass *windows.LazyProc + openClipboard *windows.LazyProc + peekMessage *windows.LazyProc + postMessage *windows.LazyProc + postQuitMessage *windows.LazyProc + registerClassEx *windows.LazyProc + registerRawInputDevices *windows.LazyProc + registerWindowMessage *windows.LazyProc + releaseCapture *windows.LazyProc + releaseDC *windows.LazyProc + removeMenu *windows.LazyProc + screenToClient *windows.LazyProc + sendDlgItemMessage *windows.LazyProc + sendInput *windows.LazyProc + sendMessage *windows.LazyProc + setActiveWindow *windows.LazyProc + setCapture *windows.LazyProc + setClipboardData *windows.LazyProc + setCursor *windows.LazyProc + setCursorPos *windows.LazyProc + setFocus *windows.LazyProc + setForegroundWindow *windows.LazyProc + setMenu *windows.LazyProc + setMenuDefaultItem *windows.LazyProc + setMenuInfo *windows.LazyProc + setMenuItemInfo *windows.LazyProc + setParent *windows.LazyProc + setRect *windows.LazyProc + setScrollInfo *windows.LazyProc + setTimer *windows.LazyProc + setWinEventHook *windows.LazyProc + setWindowLong *windows.LazyProc + setWindowLongPtr *windows.LazyProc + setWindowPlacement *windows.LazyProc + setWindowPos *windows.LazyProc + showWindow *windows.LazyProc + systemParametersInfo *windows.LazyProc + trackPopupMenuEx *windows.LazyProc + translateMessage *windows.LazyProc + unhookWinEvent *windows.LazyProc + updateWindow *windows.LazyProc + windowFromDC *windows.LazyProc + windowFromPoint *windows.LazyProc ) func init() { @@ -1758,6 +1776,7 @@ func init() { beginPaint = libuser32.NewProc("BeginPaint") bringWindowToTop = libuser32.NewProc("BringWindowToTop") callWindowProc = libuser32.NewProc("CallWindowProcW") + changeWindowMessageFilterEx = libuser32.NewProc("ChangeWindowMessageFilterEx") checkMenuRadioItem = libuser32.NewProc("CheckMenuRadioItem") clientToScreen = libuser32.NewProc("ClientToScreen") closeClipboard = libuser32.NewProc("CloseClipboard") @@ -1975,6 +1994,17 @@ func CallWindowProc(lpPrevWndFunc uintptr, hWnd HWND, Msg uint32, wParam, lParam return ret } +func ChangeWindowMessageFilterEx(hwnd HWND, msg uint32, action uint32, changeFilterStruct *CHANGEFILTERSTRUCT) bool { + ret, _, _ := syscall.Syscall6(changeWindowMessageFilterEx.Addr(), 4, + uintptr(hwnd), + uintptr(msg), + uintptr(action), + uintptr(unsafe.Pointer(changeFilterStruct)), + 0, + 0) + return ret != 0 +} + func CheckMenuRadioItem(hmenu HMENU, first, last, check, flags uint32) bool { ret, _, _ := syscall.Syscall6(checkMenuRadioItem.Addr(), 5, uintptr(hmenu), From d9566253ae00d0a7dc7e4c9bda651dcfee029001 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 3 Apr 2019 02:12:46 +0200 Subject: [PATCH 101/138] Leave it up to the app to lock thread There's no good reason to impose this on everybody who imports the win library for a single task. Signed-off-by: Jason A. Donenfeld --- win.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/win.go b/win.go index 152375e7..43d07462 100644 --- a/win.go +++ b/win.go @@ -7,15 +7,10 @@ package win import ( - "runtime" "syscall" "unsafe" ) -func init() { - runtime.LockOSThread() -} - const ( S_OK = 0x00000000 S_FALSE = 0x00000001 From b972ac3251f6e61b2c9ebfabd504fd855402fc70 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 14 May 2019 12:46:07 +0200 Subject: [PATCH 102/138] user32: GetSystemMenu --- user32.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/user32.go b/user32.go index 9b3244b2..6301d16d 100644 --- a/user32.go +++ b/user32.go @@ -1689,6 +1689,7 @@ var ( getScrollInfo *windows.LazyProc getSysColor *windows.LazyProc getSysColorBrush *windows.LazyProc + getSystemMenu *windows.LazyProc getSystemMetrics *windows.LazyProc getSystemMetricsForDpi *windows.LazyProc getWindow *windows.LazyProc @@ -1825,6 +1826,7 @@ func init() { getScrollInfo = libuser32.NewProc("GetScrollInfo") getSysColor = libuser32.NewProc("GetSysColor") getSysColorBrush = libuser32.NewProc("GetSysColorBrush") + getSystemMenu = libuser32.NewProc("GetSystemMenu") getSystemMetrics = libuser32.NewProc("GetSystemMetrics") getSystemMetricsForDpi = libuser32.NewProc("GetSystemMetricsForDpi") getWindow = libuser32.NewProc("GetWindow") @@ -2489,6 +2491,14 @@ func GetSysColorBrush(nIndex int) HBRUSH { return HBRUSH(ret) } +func GetSystemMenu(hWnd HWND, revert bool) HMENU { + ret, _, _ := syscall.Syscall(getSystemMenu.Addr(), 2, + uintptr(hWnd), + uintptr(BoolToBOOL(revert)), + 0) + return HMENU(ret) +} + func GetSystemMetrics(nIndex int32) int32 { ret, _, _ := syscall.Syscall(getSystemMetrics.Addr(), 1, uintptr(nIndex), From eca8fa91158526205f9daead26562e435f30836f Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 14 May 2019 14:18:54 +0200 Subject: [PATCH 103/138] shobj: expose overlay icon --- shobj.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/shobj.go b/shobj.go index b3aeefae..656e02d2 100644 --- a/shobj.go +++ b/shobj.go @@ -60,3 +60,14 @@ func (obj *ITaskbarList3) SetProgressState(hwnd HWND, state int) HRESULT { uintptr(state)) return HRESULT(ret) } + +func (obj *ITaskbarList3) SetOverlayIcon(hwnd HWND, icon HICON, description *uint16) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetOverlayIcon, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(icon), + uintptr(unsafe.Pointer(description)), + 0, + 0) + return HRESULT(ret) +} From 61dfaf28f424710f63ba99b6bde19efbd7f0d858 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 29 May 2019 14:06:10 +0200 Subject: [PATCH 104/138] Add LVM_SETBKCOLOR --- listview.go | 1 + 1 file changed, 1 insertion(+) diff --git a/listview.go b/listview.go index a705534f..31893a00 100644 --- a/listview.go +++ b/listview.go @@ -20,6 +20,7 @@ const ( // ListView messages const ( LVM_FIRST = 0x1000 + LVM_SETBKCOLOR = LVM_FIRST + 1 LVM_SETIMAGELIST = LVM_FIRST + 3 LVM_GETITEM = LVM_FIRST + 75 LVM_SETITEM = LVM_FIRST + 76 From 270e6e4be94d3a5068e75225f1013ad723e0dabc Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 29 May 2019 14:07:26 +0200 Subject: [PATCH 105/138] Add GetThemeColor and some related constants --- uxtheme.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/uxtheme.go b/uxtheme.go index 66f52a6e..7f0ba6e9 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -7,9 +7,16 @@ package win import ( - "golang.org/x/sys/windows" "syscall" "unsafe" + + "golang.org/x/sys/windows" +) + +// TMT_COLOR property ids +const ( + TMT_FILLCOLOR = 3802 + TMT_TEXTCOLOR = 3803 ) // CheckBox parts @@ -145,6 +152,7 @@ var ( closeThemeData *windows.LazyProc drawThemeBackground *windows.LazyProc drawThemeTextEx *windows.LazyProc + getThemeColor *windows.LazyProc getThemePartSize *windows.LazyProc getThemeTextExtent *windows.LazyProc isAppThemed *windows.LazyProc @@ -160,6 +168,7 @@ func init() { closeThemeData = libuxtheme.NewProc("CloseThemeData") drawThemeBackground = libuxtheme.NewProc("DrawThemeBackground") drawThemeTextEx = libuxtheme.NewProc("DrawThemeTextEx") + getThemeColor = libuxtheme.NewProc("GetThemeColor") getThemePartSize = libuxtheme.NewProc("GetThemePartSize") getThemeTextExtent = libuxtheme.NewProc("GetThemeTextExtent") isAppThemed = libuxtheme.NewProc("IsAppThemed") @@ -206,6 +215,18 @@ func DrawThemeTextEx(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *u return HRESULT(ret) } +func GetThemeColor(hTheme HTHEME, iPartId, iStateId, iPropId int32, pColor *COLORREF) HRESULT { + ret, _, _ := syscall.Syscall6(getThemeColor.Addr(), 5, + uintptr(hTheme), + uintptr(iPartId), + uintptr(iStateId), + uintptr(iPropId), + uintptr(unsafe.Pointer(pColor)), + 0) + + return HRESULT(ret) +} + func GetThemePartSize(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, prc *RECT, eSize THEMESIZE, psz *SIZE) HRESULT { ret, _, _ := syscall.Syscall9(getThemePartSize.Addr(), 7, uintptr(hTheme), From ae0fa62f2cb7885849a524b4a0ab4ac966b3a781 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 12 Jun 2019 15:24:44 +0200 Subject: [PATCH 106/138] Add some stuff required for list box owner drawing --- user32.go | 18 ++++++++++++++++++ uxtheme.go | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/user32.go b/user32.go index 6301d16d..48b335b4 100644 --- a/user32.go +++ b/user32.go @@ -1070,6 +1070,13 @@ const ( WA_INACTIVE = 0 ) +// Owner drawing actions +const ( + ODA_DRAWENTIRE = 0x0001 + ODA_FOCUS = 0x0002 + ODA_SELECT = 0x0004 +) + // Owner drawing states const ( ODS_CHECKED = 0x0001 @@ -1676,6 +1683,7 @@ var ( getCursorPos *windows.LazyProc getDC *windows.LazyProc getDesktopWindow *windows.LazyProc + getDlgItem *windows.LazyProc getDpiForWindow *windows.LazyProc getFocus *windows.LazyProc getForegroundWindow *windows.LazyProc @@ -1813,6 +1821,7 @@ func init() { getCursorPos = libuser32.NewProc("GetCursorPos") getDC = libuser32.NewProc("GetDC") getDesktopWindow = libuser32.NewProc("GetDesktopWindow") + getDlgItem = libuser32.NewProc("GetDlgItem") getDpiForWindow = libuser32.NewProc("GetDpiForWindow") getFocus = libuser32.NewProc("GetFocus") getForegroundWindow = libuser32.NewProc("GetForegroundWindow") @@ -2361,6 +2370,15 @@ func GetDC(hWnd HWND) HDC { return HDC(ret) } +func GetDlgItem(hDlg HWND, nIDDlgItem int32) HWND { + ret, _, _ := syscall.Syscall(getDlgItem.Addr(), 2, + uintptr(hDlg), + uintptr(nIDDlgItem), + 0) + + return HWND(ret) +} + func GetDpiForWindow(hwnd HWND) uint32 { if getDpiForWindow.Find() != nil { hdc := GetDC(hwnd) diff --git a/uxtheme.go b/uxtheme.go index 7f0ba6e9..3f551f38 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -29,6 +29,19 @@ const ( CBS_UNCHECKEDNORMAL = 1 ) +// ListBox parts +const ( + LBCP_ITEM = 5 +) + +// LBCP_ITEM states +const ( + LBPSI_HOT = 1 + LBPSI_HOTSELECTED = 2 + LBPSI_SELECTED = 3 + LBPSI_SELECTEDNOTFOCUS = 4 +) + // LISTVIEW parts const ( LVP_LISTITEM = 1 From 9c04a4e8d0b8dd261f82ac35fb3d3d298c679d20 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 18 Jun 2019 17:32:33 +0200 Subject: [PATCH 107/138] Add TrackMouseEvent and high contrast detection stuff --- user32.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/user32.go b/user32.go index 48b335b4..42767a57 100644 --- a/user32.go +++ b/user32.go @@ -1026,6 +1026,7 @@ const ( // SystemParametersInfo actions const ( SPI_GETNONCLIENTMETRICS = 0x0029 + SPI_GETHIGHCONTRAST = 0x0042 ) // Dialog styles @@ -1353,6 +1354,26 @@ const ( MSGFLTINFO_ALLOWED_HIGHER = 3 ) +// TRACKMOUSEEVENT flags +const ( + TME_CANCEL = 0x80000000 + TME_HOVER = 0x00000001 + TME_LEAVE = 0x00000002 + TME_NONCLIENT = 0x00000010 + TME_QUERY = 0x40000000 +) + +// HIGHCONTRAST flags +const ( + HCF_HIGHCONTRASTON = 0x00000001 + HCF_AVAILABLE = 0x00000002 + HCF_HOTKEYACTIVE = 0x00000004 + HCF_CONFIRMHOTKEY = 0x00000008 + HCF_HOTKEYSOUND = 0x00000010 + HCF_INDICATOR = 0x00000020 + HCF_HOTKEYAVAILABLE = 0x00000040 +) + type NMBCDROPDOWN struct { Hdr NMHDR RcButton RECT @@ -1626,6 +1647,19 @@ type WINDOWPOS struct { Flags uint32 } +type TRACKMOUSEEVENT struct { + CbSize uint32 + DwFlags uint32 + HwndTrack HWND + DwHoverTime uint32 +} + +type HIGHCONTRAST struct { + CbSize uint32 + DwFlags uint32 + LpszDefaultScheme *uint16 +} + func GET_X_LPARAM(lp uintptr) int32 { return int32(int16(LOWORD(uint32(lp)))) } @@ -1762,6 +1796,7 @@ var ( setWindowPos *windows.LazyProc showWindow *windows.LazyProc systemParametersInfo *windows.LazyProc + trackMouseEvent *windows.LazyProc trackPopupMenuEx *windows.LazyProc translateMessage *windows.LazyProc unhookWinEvent *windows.LazyProc @@ -1910,6 +1945,7 @@ func init() { setWindowPos = libuser32.NewProc("SetWindowPos") showWindow = libuser32.NewProc("ShowWindow") systemParametersInfo = libuser32.NewProc("SystemParametersInfoW") + trackMouseEvent = libuser32.NewProc("TrackMouseEvent") trackPopupMenuEx = libuser32.NewProc("TrackPopupMenuEx") translateMessage = libuser32.NewProc("TranslateMessage") unhookWinEvent = libuser32.NewProc("UnhookWinEvent") @@ -3160,6 +3196,15 @@ func SystemParametersInfo(uiAction, uiParam uint32, pvParam unsafe.Pointer, fWin return ret != 0 } +func TrackMouseEvent(lpEventTrack *TRACKMOUSEEVENT) bool { + ret, _, _ := syscall.Syscall(trackMouseEvent.Addr(), 1, + uintptr(unsafe.Pointer(lpEventTrack)), + 0, + 0) + + return ret != 0 +} + func TrackPopupMenuEx(hMenu HMENU, fuFlags uint32, x, y int32, hWnd HWND, lptpm *TPMPARAMS) BOOL { ret, _, _ := syscall.Syscall6(trackPopupMenuEx.Addr(), 6, uintptr(hMenu), From d1d36f0e4f482d3e75b5145232a2d5f50d76bac4 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 16 Jul 2019 20:53:35 +0200 Subject: [PATCH 108/138] Add EDITWORDBREAKPROC codes --- user32.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/user32.go b/user32.go index 42767a57..38d6d70b 100644 --- a/user32.go +++ b/user32.go @@ -1374,6 +1374,13 @@ const ( HCF_HOTKEYAVAILABLE = 0x00000040 ) +// EDITWORDBREAKPROC codes +const ( + WB_LEFT = 0 + WB_RIGHT = 1 + WB_ISDELIMITER = 2 +) + type NMBCDROPDOWN struct { Hdr NMHDR RcButton RECT From 811cbd40fccfe82bf82a5ed348edf40ea959ce70 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 4 Sep 2019 10:02:58 +0200 Subject: [PATCH 109/138] Add more uxtheme constants Signed-off-by: Simon Rozman --- uxtheme.go | 303 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 297 insertions(+), 6 deletions(-) diff --git a/uxtheme.go b/uxtheme.go index 3f551f38..a7c43b0a 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -13,20 +13,311 @@ import ( "golang.org/x/sys/windows" ) -// TMT_COLOR property ids +// TMT property ids const ( - TMT_FILLCOLOR = 3802 - TMT_TEXTCOLOR = 3803 + TMT_RESERVEDLOW = 0 + TMT_RESERVEDHIGH = 7999 + + TMT_DIBDATA = 2 + TMT_GLYPHDIBDATA = 8 + TMT_ENUM = 200 + TMT_STRING = 201 + TMT_INT = 202 + TMT_BOOL = 203 + TMT_COLOR = 204 + TMT_MARGINS = 205 + TMT_FILENAME = 206 + TMT_SIZE = 207 + TMT_POSITION = 208 + TMT_RECT = 209 + TMT_FONT = 210 + TMT_INTLIST = 211 + TMT_HBITMAP = 212 + TMT_DISKSTREAM = 213 + TMT_STREAM = 214 + TMT_BITMAPREF = 215 + TMT_FLOAT = 216 + TMT_FLOATLIST = 217 + TMT_COLORSCHEMES = 401 + TMT_SIZES = 402 + TMT_CHARSET = 403 + TMT_NAME = 600 + TMT_DISPLAYNAME = 601 + TMT_TOOLTIP = 602 + TMT_COMPANY = 603 + TMT_AUTHOR = 604 + TMT_COPYRIGHT = 605 + TMT_URL = 606 + TMT_VERSION = 607 + TMT_DESCRIPTION = 608 + TMT_FIRST_RCSTRING_NAME = TMT_DISPLAYNAME + TMT_LAST_RCSTRING_NAME = TMT_DESCRIPTION + TMT_CAPTIONFONT = 801 + TMT_SMALLCAPTIONFONT = 802 + TMT_MENUFONT = 803 + TMT_STATUSFONT = 804 + TMT_MSGBOXFONT = 805 + TMT_ICONTITLEFONT = 806 + TMT_HEADING1FONT = 807 + TMT_HEADING2FONT = 808 + TMT_BODYFONT = 809 + TMT_FIRSTFONT = TMT_CAPTIONFONT + TMT_LASTFONT = TMT_BODYFONT + TMT_FLATMENUS = 1001 + TMT_FIRSTBOOL = TMT_FLATMENUS + TMT_LASTBOOL = TMT_FLATMENUS + TMT_SIZINGBORDERWIDTH = 1201 + TMT_SCROLLBARWIDTH = 1202 + TMT_SCROLLBARHEIGHT = 1203 + TMT_CAPTIONBARWIDTH = 1204 + TMT_CAPTIONBARHEIGHT = 1205 + TMT_SMCAPTIONBARWIDTH = 1206 + TMT_SMCAPTIONBARHEIGHT = 1207 + TMT_MENUBARWIDTH = 1208 + TMT_MENUBARHEIGHT = 1209 + TMT_PADDEDBORDERWIDTH = 1210 + TMT_FIRSTSIZE = TMT_SIZINGBORDERWIDTH + TMT_LASTSIZE = TMT_PADDEDBORDERWIDTH + TMT_MINCOLORDEPTH = 1301 + TMT_FIRSTINT = TMT_MINCOLORDEPTH + TMT_LASTINT = TMT_MINCOLORDEPTH + TMT_CSSNAME = 1401 + TMT_XMLNAME = 1402 + TMT_LASTUPDATED = 1403 + TMT_ALIAS = 1404 + TMT_FIRSTSTRING = TMT_CSSNAME + TMT_LASTSTRING = TMT_ALIAS + TMT_SCROLLBAR = 1601 + TMT_BACKGROUND = 1602 + TMT_ACTIVECAPTION = 1603 + TMT_INACTIVECAPTION = 1604 + TMT_MENU = 1605 + TMT_WINDOW = 1606 + TMT_WINDOWFRAME = 1607 + TMT_MENUTEXT = 1608 + TMT_WINDOWTEXT = 1609 + TMT_CAPTIONTEXT = 1610 + TMT_ACTIVEBORDER = 1611 + TMT_INACTIVEBORDER = 1612 + TMT_APPWORKSPACE = 1613 + TMT_HIGHLIGHT = 1614 + TMT_HIGHLIGHTTEXT = 1615 + TMT_BTNFACE = 1616 + TMT_BTNSHADOW = 1617 + TMT_GRAYTEXT = 1618 + TMT_BTNTEXT = 1619 + TMT_INACTIVECAPTIONTEXT = 1620 + TMT_BTNHIGHLIGHT = 1621 + TMT_DKSHADOW3D = 1622 + TMT_LIGHT3D = 1623 + TMT_INFOTEXT = 1624 + TMT_INFOBK = 1625 + TMT_BUTTONALTERNATEFACE = 1626 + TMT_HOTTRACKING = 1627 + TMT_GRADIENTACTIVECAPTION = 1628 + TMT_GRADIENTINACTIVECAPTION = 1629 + TMT_MENUHILIGHT = 1630 + TMT_MENUBAR = 1631 + TMT_FIRSTCOLOR = TMT_SCROLLBAR + TMT_LASTCOLOR = TMT_MENUBAR + TMT_FROMHUE1 = 1801 + TMT_FROMHUE2 = 1802 + TMT_FROMHUE3 = 1803 + TMT_FROMHUE4 = 1804 + TMT_FROMHUE5 = 1805 + TMT_TOHUE1 = 1806 + TMT_TOHUE2 = 1807 + TMT_TOHUE3 = 1808 + TMT_TOHUE4 = 1809 + TMT_TOHUE5 = 1810 + TMT_FROMCOLOR1 = 2001 + TMT_FROMCOLOR2 = 2002 + TMT_FROMCOLOR3 = 2003 + TMT_FROMCOLOR4 = 2004 + TMT_FROMCOLOR5 = 2005 + TMT_TOCOLOR1 = 2006 + TMT_TOCOLOR2 = 2007 + TMT_TOCOLOR3 = 2008 + TMT_TOCOLOR4 = 2009 + TMT_TOCOLOR5 = 2010 + TMT_TRANSPARENT = 2201 + TMT_AUTOSIZE = 2202 + TMT_BORDERONLY = 2203 + TMT_COMPOSITED = 2204 + TMT_BGFILL = 2205 + TMT_GLYPHTRANSPARENT = 2206 + TMT_GLYPHONLY = 2207 + TMT_ALWAYSSHOWSIZINGBAR = 2208 + TMT_MIRRORIMAGE = 2209 + TMT_UNIFORMSIZING = 2210 + TMT_INTEGRALSIZING = 2211 + TMT_SOURCEGROW = 2212 + TMT_SOURCESHRINK = 2213 + TMT_DRAWBORDERS = 2214 + TMT_NOETCHEDEFFECT = 2215 + TMT_TEXTAPPLYOVERLAY = 2216 + TMT_TEXTGLOW = 2217 + TMT_TEXTITALIC = 2218 + TMT_COMPOSITEDOPAQUE = 2219 + TMT_LOCALIZEDMIRRORIMAGE = 2220 + TMT_IMAGECOUNT = 2401 + TMT_ALPHALEVEL = 2402 + TMT_BORDERSIZE = 2403 + TMT_ROUNDCORNERWIDTH = 2404 + TMT_ROUNDCORNERHEIGHT = 2405 + TMT_GRADIENTRATIO1 = 2406 + TMT_GRADIENTRATIO2 = 2407 + TMT_GRADIENTRATIO3 = 2408 + TMT_GRADIENTRATIO4 = 2409 + TMT_GRADIENTRATIO5 = 2410 + TMT_PROGRESSCHUNKSIZE = 2411 + TMT_PROGRESSSPACESIZE = 2412 + TMT_SATURATION = 2413 + TMT_TEXTBORDERSIZE = 2414 + TMT_ALPHATHRESHOLD = 2415 + TMT_WIDTH = 2416 + TMT_HEIGHT = 2417 + TMT_GLYPHINDEX = 2418 + TMT_TRUESIZESTRETCHMARK = 2419 + TMT_MINDPI1 = 2420 + TMT_MINDPI2 = 2421 + TMT_MINDPI3 = 2422 + TMT_MINDPI4 = 2423 + TMT_MINDPI5 = 2424 + TMT_TEXTGLOWSIZE = 2425 + TMT_FRAMESPERSECOND = 2426 + TMT_PIXELSPERFRAME = 2427 + TMT_ANIMATIONDELAY = 2428 + TMT_GLOWINTENSITY = 2429 + TMT_OPACITY = 2430 + TMT_COLORIZATIONCOLOR = 2431 + TMT_COLORIZATIONOPACITY = 2432 + TMT_MINDPI6 = 2433 + TMT_MINDPI7 = 2434 + TMT_GLYPHFONT = 2601 + TMT_IMAGEFILE = 3001 + TMT_IMAGEFILE1 = 3002 + TMT_IMAGEFILE2 = 3003 + TMT_IMAGEFILE3 = 3004 + TMT_IMAGEFILE4 = 3005 + TMT_IMAGEFILE5 = 3006 + TMT_GLYPHIMAGEFILE = 3008 + TMT_IMAGEFILE6 = 3009 + TMT_IMAGEFILE7 = 3010 + TMT_TEXT = 3201 + TMT_CLASSICVALUE = 3202 + TMT_OFFSET = 3401 + TMT_TEXTSHADOWOFFSET = 3402 + TMT_MINSIZE = 3403 + TMT_MINSIZE1 = 3404 + TMT_MINSIZE2 = 3405 + TMT_MINSIZE3 = 3406 + TMT_MINSIZE4 = 3407 + TMT_MINSIZE5 = 3408 + TMT_NORMALSIZE = 3409 + TMT_MINSIZE6 = 3410 + TMT_MINSIZE7 = 3411 + TMT_SIZINGMARGINS = 3601 + TMT_CONTENTMARGINS = 3602 + TMT_CAPTIONMARGINS = 3603 + TMT_BORDERCOLOR = 3801 + TMT_FILLCOLOR = 3802 + TMT_TEXTCOLOR = 3803 + TMT_EDGELIGHTCOLOR = 3804 + TMT_EDGEHIGHLIGHTCOLOR = 3805 + TMT_EDGESHADOWCOLOR = 3806 + TMT_EDGEDKSHADOWCOLOR = 3807 + TMT_EDGEFILLCOLOR = 3808 + TMT_TRANSPARENTCOLOR = 3809 + TMT_GRADIENTCOLOR1 = 3810 + TMT_GRADIENTCOLOR2 = 3811 + TMT_GRADIENTCOLOR3 = 3812 + TMT_GRADIENTCOLOR4 = 3813 + TMT_GRADIENTCOLOR5 = 3814 + TMT_SHADOWCOLOR = 3815 + TMT_GLOWCOLOR = 3816 + TMT_TEXTBORDERCOLOR = 3817 + TMT_TEXTSHADOWCOLOR = 3818 + TMT_GLYPHTEXTCOLOR = 3819 + TMT_GLYPHTRANSPARENTCOLOR = 3820 + TMT_FILLCOLORHINT = 3821 + TMT_BORDERCOLORHINT = 3822 + TMT_ACCENTCOLORHINT = 3823 + TMT_TEXTCOLORHINT = 3824 + TMT_HEADING1TEXTCOLOR = 3825 + TMT_HEADING2TEXTCOLOR = 3826 + TMT_BODYTEXTCOLOR = 3827 + TMT_BGTYPE = 4001 + TMT_BORDERTYPE = 4002 + TMT_FILLTYPE = 4003 + TMT_SIZINGTYPE = 4004 + TMT_HALIGN = 4005 + TMT_CONTENTALIGNMENT = 4006 + TMT_VALIGN = 4007 + TMT_OFFSETTYPE = 4008 + TMT_ICONEFFECT = 4009 + TMT_TEXTSHADOWTYPE = 4010 + TMT_IMAGELAYOUT = 4011 + TMT_GLYPHTYPE = 4012 + TMT_IMAGESELECTTYPE = 4013 + TMT_GLYPHFONTSIZINGTYPE = 4014 + TMT_TRUESIZESCALINGTYPE = 4015 + TMT_USERPICTURE = 5001 + TMT_DEFAULTPANESIZE = 5002 + TMT_BLENDCOLOR = 5003 + TMT_CUSTOMSPLITRECT = 5004 + TMT_ANIMATIONBUTTONRECT = 5005 + TMT_ANIMATIONDURATION = 5006 + TMT_TRANSITIONDURATIONS = 6000 + TMT_SCALEDBACKGROUND = 7001 + TMT_ATLASIMAGE = 8000 + TMT_ATLASINPUTIMAGE = 8001 + TMT_ATLASRECT = 8002 ) -// CheckBox parts +// Button parts const ( - BP_CHECKBOX = 3 + BP_PUSHBUTTON = 1 + BP_RADIOBUTTON = 2 + BP_CHECKBOX = 3 + BP_GROUPBOX = 4 + BP_USERBUTTON = 5 + BP_COMMANDLINK = 6 + BP_COMMANDLINKGLYPH = 7 +) + +// Push-button states +const ( + PBS_NORMAL = 1 + PBS_HOT = 2 + PBS_PRESSED = 3 + PBS_DISABLED = 4 + PBS_DEFAULTED = 5 + PBS_DEFAULTED_ANIMATING = 6 ) // CheckBox states const ( - CBS_UNCHECKEDNORMAL = 1 + CBS_UNCHECKEDNORMAL = 1 + CBS_UNCHECKEDHOT = 2 + CBS_UNCHECKEDPRESSED = 3 + CBS_UNCHECKEDDISABLED = 4 + CBS_CHECKEDNORMAL = 5 + CBS_CHECKEDHOT = 6 + CBS_CHECKEDPRESSED = 7 + CBS_CHECKEDDISABLED = 8 + CBS_MIXEDNORMAL = 9 + CBS_MIXEDHOT = 10 + CBS_MIXEDPRESSED = 11 + CBS_MIXEDDISABLED = 12 + CBS_IMPLICITNORMAL = 13 + CBS_IMPLICITHOT = 14 + CBS_IMPLICITPRESSED = 15 + CBS_IMPLICITDISABLED = 16 + CBS_EXCLUDEDNORMAL = 17 + CBS_EXCLUDEDHOT = 18 + CBS_EXCLUDEDPRESSED = 19 + CBS_EXCLUDEDDISABLED = 20 ) // ListBox parts From a04254561f5fec47dbd9bab679d0b45ae7804a58 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 4 Sep 2019 11:00:51 -0600 Subject: [PATCH 110/138] comctl32: do not call win32 api in init function --- comctl32.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/comctl32.go b/comctl32.go index 3ec4b84c..b0e22954 100644 --- a/comctl32.go +++ b/comctl32.go @@ -260,13 +260,6 @@ func init() { initCommonControlsEx = libcomctl32.NewProc("InitCommonControlsEx") loadIconMetric = libcomctl32.NewProc("LoadIconMetric") loadIconWithScaleDown = libcomctl32.NewProc("LoadIconWithScaleDown") - - // Initialize the common controls we support - var initCtrls INITCOMMONCONTROLSEX - initCtrls.DwSize = uint32(unsafe.Sizeof(initCtrls)) - initCtrls.DwICC = ICC_LINK_CLASS | ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES - - InitCommonControlsEx(&initCtrls) } func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int32 { From 06b45938820a31f1fe967ad59214843cfe12a3e7 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 9 Sep 2019 12:48:53 +0200 Subject: [PATCH 111/138] Add various user32 constants Signed-off-by: Simon Rozman --- user32.go | 153 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 114 insertions(+), 39 deletions(-) diff --git a/user32.go b/user32.go index 38d6d70b..d19e2548 100644 --- a/user32.go +++ b/user32.go @@ -889,47 +889,122 @@ const ( WM_CLIPBOARDUPDATE = 0x031D ) +const ( + CHILDID_SELF = 0 + INDEXID_OBJECT = 0 + INDEXID_CONTAINER = 0 + + OBJID_WINDOW = int32(0x00000000) + OBJID_SYSMENU = int32(-((0xFFFFFFFF ^ 0xFFFFFFFF) + 1)) + OBJID_TITLEBAR = int32(-((0xFFFFFFFE ^ 0xFFFFFFFF) + 1)) + OBJID_MENU = int32(-((0xFFFFFFFD ^ 0xFFFFFFFF) + 1)) + OBJID_CLIENT = int32(-((0xFFFFFFFC ^ 0xFFFFFFFF) + 1)) + OBJID_VSCROLL = int32(-((0xFFFFFFFB ^ 0xFFFFFFFF) + 1)) + OBJID_HSCROLL = int32(-((0xFFFFFFFA ^ 0xFFFFFFFF) + 1)) + OBJID_SIZEGRIP = int32(-((0xFFFFFFF9 ^ 0xFFFFFFFF) + 1)) + OBJID_CARET = int32(-((0xFFFFFFF8 ^ 0xFFFFFFFF) + 1)) + OBJID_CURSOR = int32(-((0xFFFFFFF7 ^ 0xFFFFFFFF) + 1)) + OBJID_ALERT = int32(-((0xFFFFFFF6 ^ 0xFFFFFFFF) + 1)) + OBJID_SOUND = int32(-((0xFFFFFFF5 ^ 0xFFFFFFFF) + 1)) + OBJID_QUERYCLASSNAMEIDX = int32(-((0xFFFFFFF4 ^ 0xFFFFFFFF) + 1)) + OBJID_NATIVEOM = int32(-((0xFFFFFFF0 ^ 0xFFFFFFFF) + 1)) +) + // event constants const ( - EVENT_OBJECT_CREATE = 0x8000 - EVENT_OBJECT_DESTROY = 0x8001 - EVENT_OBJECT_SHOW = 0x8002 - EVENT_OBJECT_HIDE = 0x8003 - EVENT_OBJECT_REORDER = 0x8004 - EVENT_OBJECT_FOCUS = 0x8005 - EVENT_OBJECT_SELECTION = 0x8006 - EVENT_OBJECT_SELECTIONADD = 0x8007 - EVENT_OBJECT_SELECTIONREMOVE = 0x8008 - EVENT_OBJECT_SELECTIONWITHIN = 0x8009 - EVENT_OBJECT_STATECHANGE = 0x800A - EVENT_OBJECT_LOCATIONCHANGE = 0x800B - EVENT_OBJECT_NAMECHANGE = 0x800C - EVENT_OBJECT_DESCRIPTIONCHANGE = 0x800D - EVENT_OBJECT_VALUECHANGE = 0x800E - EVENT_OBJECT_PARENTCHANGE = 0x800F - EVENT_OBJECT_HELPCHANGE = 0x8010 - EVENT_OBJECT_DEFACTIONCHANGE = 0x8011 - EVENT_OBJECT_ACCELERATORCHANGE = 0x8012 - EVENT_OBJECT_INVOKED = 0x8013 - EVENT_OBJECT_TEXTSELECTIONCHANGED = 0x8014 - EVENT_OBJECT_CONTENTSCROLLED = 0x8015 - EVENT_SYSTEM_ARRANGMENTPREVIEW = 0x8016 - EVENT_OBJECT_CLOAKED = 0x8017 - EVENT_OBJECT_UNCLOAKED = 0x8018 - EVENT_OBJECT_LIVEREGIONCHANGED = 0x8019 - EVENT_OBJECT_HOSTEDOBJECTSINVALIDATED = 0x8020 - EVENT_OBJECT_DRAGSTART = 0x8021 - EVENT_OBJECT_DRAGCANCEL = 0x8022 - EVENT_OBJECT_DRAGCOMPLETE = 0x8023 - EVENT_OBJECT_DRAGENTER = 0x8024 - EVENT_OBJECT_DRAGLEAVE = 0x8025 - EVENT_OBJECT_DRAGDROPPED = 0x8026 - EVENT_OBJECT_IME_SHOW = 0x8027 - EVENT_OBJECT_IME_HIDE = 0x8028 - EVENT_OBJECT_IME_CHANGE = 0x8029 - EVENT_OBJECT_END = 0x80ff - EVENT_AIA_START = 0xa000 - EVENT_AIA_END = 0xafff + EVENT_MIN = 0x00000001 + EVENT_MAX = 0x7FFFFFFF + + EVENT_SYSTEM_SOUND = 0x0001 + EVENT_SYSTEM_ALERT = 0x0002 + EVENT_SYSTEM_FOREGROUND = 0x0003 + EVENT_SYSTEM_MENUSTART = 0x0004 + EVENT_SYSTEM_MENUEND = 0x0005 + EVENT_SYSTEM_MENUPOPUPSTART = 0x0006 + EVENT_SYSTEM_MENUPOPUPEND = 0x0007 + EVENT_SYSTEM_CAPTURESTART = 0x0008 + EVENT_SYSTEM_CAPTUREEND = 0x0009 + EVENT_SYSTEM_MOVESIZESTART = 0x000A + EVENT_SYSTEM_MOVESIZEEND = 0x000B + EVENT_SYSTEM_CONTEXTHELPSTART = 0x000C + EVENT_SYSTEM_CONTEXTHELPEND = 0x000D + EVENT_SYSTEM_DRAGDROPSTART = 0x000E + EVENT_SYSTEM_DRAGDROPEND = 0x000F + EVENT_SYSTEM_DIALOGSTART = 0x0010 + EVENT_SYSTEM_DIALOGEND = 0x0011 + EVENT_SYSTEM_SCROLLINGSTART = 0x0012 + EVENT_SYSTEM_SCROLLINGEND = 0x0013 + EVENT_SYSTEM_SWITCHSTART = 0x0014 + EVENT_SYSTEM_SWITCHEND = 0x0015 + EVENT_SYSTEM_MINIMIZESTART = 0x0016 + EVENT_SYSTEM_MINIMIZEEND = 0x0017 + EVENT_SYSTEM_DESKTOPSWITCH = 0x0020 + EVENT_SYSTEM_SWITCHER_APPGRABBED = 0x0024 + EVENT_SYSTEM_SWITCHER_APPOVERTARGET = 0x0025 + EVENT_SYSTEM_SWITCHER_APPDROPPED = 0x0026 + EVENT_SYSTEM_SWITCHER_CANCELLED = 0x0027 + EVENT_SYSTEM_IME_KEY_NOTIFICATION = 0x0029 + EVENT_SYSTEM_END = 0x00FF + + EVENT_OEM_DEFINED_START = 0x0101 + EVENT_OEM_DEFINED_END = 0x01FF + + EVENT_CONSOLE_CARET = 0x4001 + EVENT_CONSOLE_UPDATE_REGION = 0x4002 + EVENT_CONSOLE_UPDATE_SIMPLE = 0x4003 + EVENT_CONSOLE_UPDATE_SCROLL = 0x4004 + EVENT_CONSOLE_LAYOUT = 0x4005 + EVENT_CONSOLE_START_APPLICATION = 0x4006 + EVENT_CONSOLE_END_APPLICATION = 0x4007 + EVENT_CONSOLE_END = 0x40FF + + EVENT_UIA_EVENTID_START = 0x4E00 + EVENT_UIA_EVENTID_END = 0x4EFF + + EVENT_UIA_PROPID_START = 0x7500 + EVENT_UIA_PROPID_END = 0x75FF + + EVENT_OBJECT_CREATE = 0x8000 + EVENT_OBJECT_DESTROY = 0x8001 + EVENT_OBJECT_SHOW = 0x8002 + EVENT_OBJECT_HIDE = 0x8003 + EVENT_OBJECT_REORDER = 0x8004 + EVENT_OBJECT_FOCUS = 0x8005 + EVENT_OBJECT_SELECTION = 0x8006 + EVENT_OBJECT_SELECTIONADD = 0x8007 + EVENT_OBJECT_SELECTIONREMOVE = 0x8008 + EVENT_OBJECT_SELECTIONWITHIN = 0x8009 + EVENT_OBJECT_STATECHANGE = 0x800A + EVENT_OBJECT_LOCATIONCHANGE = 0x800B + EVENT_OBJECT_NAMECHANGE = 0x800C + EVENT_OBJECT_DESCRIPTIONCHANGE = 0x800D + EVENT_OBJECT_VALUECHANGE = 0x800E + EVENT_OBJECT_PARENTCHANGE = 0x800F + EVENT_OBJECT_HELPCHANGE = 0x8010 + EVENT_OBJECT_DEFACTIONCHANGE = 0x8011 + EVENT_OBJECT_ACCELERATORCHANGE = 0x8012 + EVENT_OBJECT_INVOKED = 0x8013 + EVENT_OBJECT_TEXTSELECTIONCHANGED = 0x8014 + EVENT_OBJECT_CONTENTSCROLLED = 0x8015 + EVENT_SYSTEM_ARRANGMENTPREVIEW = 0x8016 + EVENT_OBJECT_CLOAKED = 0x8017 + EVENT_OBJECT_UNCLOAKED = 0x8018 + EVENT_OBJECT_LIVEREGIONCHANGED = 0x8019 + EVENT_OBJECT_HOSTEDOBJECTSINVALIDATED = 0x8020 + EVENT_OBJECT_DRAGSTART = 0x8021 + EVENT_OBJECT_DRAGCANCEL = 0x8022 + EVENT_OBJECT_DRAGCOMPLETE = 0x8023 + EVENT_OBJECT_DRAGENTER = 0x8024 + EVENT_OBJECT_DRAGLEAVE = 0x8025 + EVENT_OBJECT_DRAGDROPPED = 0x8026 + EVENT_OBJECT_IME_SHOW = 0x8027 + EVENT_OBJECT_IME_HIDE = 0x8028 + EVENT_OBJECT_IME_CHANGE = 0x8029 + EVENT_OBJECT_TEXTEDIT_CONVERSIONTARGETCHANGED = 0x8030 + EVENT_OBJECT_END = 0x80FF + + EVENT_AIA_START = 0xa000 + EVENT_AIA_END = 0xafff WINEVENT_OUTOFCONTEXT = 0x0000 WINEVENT_SKIPOWNTHREAD = 0x0001 From fdaad66018acd7c4b0d94d9d9fab70f1f42edb5a Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 9 Sep 2019 12:49:27 +0200 Subject: [PATCH 112/138] Add NotifyWinEvent Signed-off-by: Simon Rozman --- user32.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/user32.go b/user32.go index d19e2548..478813db 100644 --- a/user32.go +++ b/user32.go @@ -1841,6 +1841,7 @@ var ( messageBox *windows.LazyProc monitorFromWindow *windows.LazyProc moveWindow *windows.LazyProc + notifyWinEvent *windows.LazyProc unregisterClass *windows.LazyProc openClipboard *windows.LazyProc peekMessage *windows.LazyProc @@ -1985,6 +1986,7 @@ func init() { messageBox = libuser32.NewProc("MessageBoxW") monitorFromWindow = libuser32.NewProc("MonitorFromWindow") moveWindow = libuser32.NewProc("MoveWindow") + notifyWinEvent = libuser32.NewProc("NotifyWinEvent") unregisterClass = libuser32.NewProc("UnregisterClassW") openClipboard = libuser32.NewProc("OpenClipboard") peekMessage = libuser32.NewProc("PeekMessageW") @@ -2902,6 +2904,16 @@ func MoveWindow(hWnd HWND, x, y, width, height int32, repaint bool) bool { return ret != 0 } +func NotifyWinEvent(event uint32, hwnd HWND, idObject, idChild int32) { + syscall.Syscall6(notifyWinEvent.Addr(), 4, + uintptr(event), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + 0, + 0) +} + func UnregisterClass(name *uint16) bool { ret, _, _ := syscall.Syscall(unregisterClass.Addr(), 1, uintptr(unsafe.Pointer(name)), From fa47aa1843c475415c2c9ac54fff9b3d5e4af64d Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 9 Sep 2019 12:49:58 +0200 Subject: [PATCH 113/138] Add CLSCTX_INPROC and CLSCTX_SERVER constants Signed-off-by: Simon Rozman --- ole32.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ole32.go b/ole32.go index 15d6fd27..927b275d 100644 --- a/ole32.go +++ b/ole32.go @@ -7,9 +7,10 @@ package win import ( - "golang.org/x/sys/windows" "syscall" "unsafe" + + "golang.org/x/sys/windows" ) const ( @@ -35,7 +36,9 @@ const ( CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000 CLSCTX_ENABLE_CLOAKING = 0x100000 CLSCTX_PS_DLL = 0x80000000 + CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER + CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER ) // Verbs for IOleObject.DoVerb From e8b6982ca5da35b33e82536ea9033cb4f7cf78e9 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 10 Sep 2019 08:26:32 +0200 Subject: [PATCH 114/138] Add CoInitializeEx and CoUninitialize Signed-off-by: Simon Rozman --- ole32.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ole32.go b/ole32.go index 15d6fd27..c95f88e5 100644 --- a/ole32.go +++ b/ole32.go @@ -38,6 +38,13 @@ const ( CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER ) +const ( + COINIT_APARTMENTTHREADED = 0x2 // Apartment model + COINIT_MULTITHREADED = 0x0 // OLE calls objects on any thread. + COINIT_DISABLE_OLE1DDE = 0x4 // Don't use DDE for Ole1 support. + COINIT_SPEED_OVER_MEMORY = 0x8 // Trade memory for speed. +) + // Verbs for IOleObject.DoVerb const ( OLEIVERB_PRIMARY = 0 @@ -425,7 +432,9 @@ var ( // Functions coCreateInstance *windows.LazyProc coGetClassObject *windows.LazyProc + coInitializeEx *windows.LazyProc coTaskMemFree *windows.LazyProc + coUninitialize *windows.LazyProc oleInitialize *windows.LazyProc oleSetContainedObject *windows.LazyProc oleUninitialize *windows.LazyProc @@ -438,7 +447,9 @@ func init() { // Functions coCreateInstance = libole32.NewProc("CoCreateInstance") coGetClassObject = libole32.NewProc("CoGetClassObject") + coInitializeEx = libole32.NewProc("CoInitializeEx") coTaskMemFree = libole32.NewProc("CoTaskMemFree") + coUninitialize = libole32.NewProc("CoUninitialize") oleInitialize = libole32.NewProc("OleInitialize") oleSetContainedObject = libole32.NewProc("OleSetContainedObject") oleUninitialize = libole32.NewProc("OleUninitialize") @@ -468,6 +479,22 @@ func CoGetClassObject(rclsid REFCLSID, dwClsContext uint32, pServerInfo *COSERVE return HRESULT(ret) } +func CoInitializeEx(reserved unsafe.Pointer, coInit uint32) HRESULT { + ret, _, _ := syscall.Syscall(coInitializeEx.Addr(), 2, + uintptr(reserved), + uintptr(coInit), + 0) + + return HRESULT(ret) +} + +func CoUninitialize() { + syscall.Syscall(coUninitialize.Addr(), 0, + 0, + 0, + 0) +} + func CoTaskMemFree(pv uintptr) { syscall.Syscall(coTaskMemFree.Addr(), 1, pv, From bdbc78e4188bdbab4027030096844a5f1d921ea2 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 10 Sep 2019 08:08:42 +0200 Subject: [PATCH 115/138] Make HRESULT constants typed Signed-off-by: Simon Rozman --- win.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/win.go b/win.go index 43d07462..e8a39fdb 100644 --- a/win.go +++ b/win.go @@ -12,19 +12,19 @@ import ( ) const ( - S_OK = 0x00000000 - S_FALSE = 0x00000001 - E_UNEXPECTED = 0x8000FFFF - E_NOTIMPL = 0x80004001 - E_OUTOFMEMORY = 0x8007000E - E_INVALIDARG = 0x80070057 - E_NOINTERFACE = 0x80004002 - E_POINTER = 0x80004003 - E_HANDLE = 0x80070006 - E_ABORT = 0x80004004 - E_FAIL = 0x80004005 - E_ACCESSDENIED = 0x80070005 - E_PENDING = 0x8000000A + S_OK = HRESULT(0x00000000) + S_FALSE = HRESULT(0x00000001) + E_UNEXPECTED = HRESULT(-((0x8000FFFF ^ 0xFFFFFFFF) + 1)) + E_NOTIMPL = HRESULT(-((0x80004001 ^ 0xFFFFFFFF) + 1)) + E_OUTOFMEMORY = HRESULT(-((0x8007000E ^ 0xFFFFFFFF) + 1)) + E_INVALIDARG = HRESULT(-((0x80070057 ^ 0xFFFFFFFF) + 1)) + E_NOINTERFACE = HRESULT(-((0x80004002 ^ 0xFFFFFFFF) + 1)) + E_POINTER = HRESULT(-((0x80004003 ^ 0xFFFFFFFF) + 1)) + E_HANDLE = HRESULT(-((0x80070006 ^ 0xFFFFFFFF) + 1)) + E_ABORT = HRESULT(-((0x80004004 ^ 0xFFFFFFFF) + 1)) + E_FAIL = HRESULT(-((0x80004005 ^ 0xFFFFFFFF) + 1)) + E_ACCESSDENIED = HRESULT(-((0x80070005 ^ 0xFFFFFFFF) + 1)) + E_PENDING = HRESULT(-((0x8000000A ^ 0xFFFFFFFF) + 1)) ) const ( From 14509000663326e621f71267c730f83d4a2e450b Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 9 Sep 2019 12:51:26 +0200 Subject: [PATCH 116/138] Add support for Dynamic Annotation Source: https://msdn.microsoft.com/en-us/library/windows/desktop/cc307286.aspx Signed-off-by: Simon Rozman --- oleacc.go | 439 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 439 insertions(+) create mode 100644 oleacc.go diff --git a/oleacc.go b/oleacc.go new file mode 100644 index 00000000..6e2a6d16 --- /dev/null +++ b/oleacc.go @@ -0,0 +1,439 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +type AnnoScope int + +const ( + ANNO_THIS = AnnoScope(0) + ANNO_CONTAINER = AnnoScope(1) +) + +type MSAAPROPID syscall.GUID + +var ( + PROPID_ACC_NAME = MSAAPROPID{0x608d3df8, 0x8128, 0x4aa7, [8]byte{0xa4, 0x28, 0xf5, 0x5e, 0x49, 0x26, 0x72, 0x91}} + PROPID_ACC_VALUE = MSAAPROPID{0x123fe443, 0x211a, 0x4615, [8]byte{0x95, 0x27, 0xc4, 0x5a, 0x7e, 0x93, 0x71, 0x7a}} + PROPID_ACC_DESCRIPTION = MSAAPROPID{0x4d48dfe4, 0xbd3f, 0x491f, [8]byte{0xa6, 0x48, 0x49, 0x2d, 0x6f, 0x20, 0xc5, 0x88}} + PROPID_ACC_ROLE = MSAAPROPID{0xcb905ff2, 0x7bd1, 0x4c05, [8]byte{0xb3, 0xc8, 0xe6, 0xc2, 0x41, 0x36, 0x4d, 0x70}} + PROPID_ACC_STATE = MSAAPROPID{0xa8d4d5b0, 0x0a21, 0x42d0, [8]byte{0xa5, 0xc0, 0x51, 0x4e, 0x98, 0x4f, 0x45, 0x7b}} + PROPID_ACC_HELP = MSAAPROPID{0xc831e11f, 0x44db, 0x4a99, [8]byte{0x97, 0x68, 0xcb, 0x8f, 0x97, 0x8b, 0x72, 0x31}} + PROPID_ACC_KEYBOARDSHORTCUT = MSAAPROPID{0x7d9bceee, 0x7d1e, 0x4979, [8]byte{0x93, 0x82, 0x51, 0x80, 0xf4, 0x17, 0x2c, 0x34}} + PROPID_ACC_DEFAULTACTION = MSAAPROPID{0x180c072b, 0xc27f, 0x43c7, [8]byte{0x99, 0x22, 0xf6, 0x35, 0x62, 0xa4, 0x63, 0x2b}} + PROPID_ACC_HELPTOPIC = MSAAPROPID{0x787d1379, 0x8ede, 0x440b, [8]byte{0x8a, 0xec, 0x11, 0xf7, 0xbf, 0x90, 0x30, 0xb3}} + PROPID_ACC_FOCUS = MSAAPROPID{0x6eb335df, 0x1c29, 0x4127, [8]byte{0xb1, 0x2c, 0xde, 0xe9, 0xfd, 0x15, 0x7f, 0x2b}} + PROPID_ACC_SELECTION = MSAAPROPID{0xb99d073c, 0xd731, 0x405b, [8]byte{0x90, 0x61, 0xd9, 0x5e, 0x8f, 0x84, 0x29, 0x84}} + PROPID_ACC_PARENT = MSAAPROPID{0x474c22b6, 0xffc2, 0x467a, [8]byte{0xb1, 0xb5, 0xe9, 0x58, 0xb4, 0x65, 0x73, 0x30}} + PROPID_ACC_NAV_UP = MSAAPROPID{0x016e1a2b, 0x1a4e, 0x4767, [8]byte{0x86, 0x12, 0x33, 0x86, 0xf6, 0x69, 0x35, 0xec}} + PROPID_ACC_NAV_DOWN = MSAAPROPID{0x031670ed, 0x3cdf, 0x48d2, [8]byte{0x96, 0x13, 0x13, 0x8f, 0x2d, 0xd8, 0xa6, 0x68}} + PROPID_ACC_NAV_LEFT = MSAAPROPID{0x228086cb, 0x82f1, 0x4a39, [8]byte{0x87, 0x05, 0xdc, 0xdc, 0x0f, 0xff, 0x92, 0xf5}} + PROPID_ACC_NAV_RIGHT = MSAAPROPID{0xcd211d9f, 0xe1cb, 0x4fe5, [8]byte{0xa7, 0x7c, 0x92, 0x0b, 0x88, 0x4d, 0x09, 0x5b}} + PROPID_ACC_NAV_PREV = MSAAPROPID{0x776d3891, 0xc73b, 0x4480, [8]byte{0xb3, 0xf6, 0x07, 0x6a, 0x16, 0xa1, 0x5a, 0xf6}} + PROPID_ACC_NAV_NEXT = MSAAPROPID{0x1cdc5455, 0x8cd9, 0x4c92, [8]byte{0xa3, 0x71, 0x39, 0x39, 0xa2, 0xfe, 0x3e, 0xee}} + PROPID_ACC_NAV_FIRSTCHILD = MSAAPROPID{0xcfd02558, 0x557b, 0x4c67, [8]byte{0x84, 0xf9, 0x2a, 0x09, 0xfc, 0xe4, 0x07, 0x49}} + PROPID_ACC_NAV_LASTCHILD = MSAAPROPID{0x302ecaa5, 0x48d5, 0x4f8d, [8]byte{0xb6, 0x71, 0x1a, 0x8d, 0x20, 0xa7, 0x78, 0x32}} + PROPID_ACC_ROLEMAP = MSAAPROPID{0xf79acda2, 0x140d, 0x4fe6, [8]byte{0x89, 0x14, 0x20, 0x84, 0x76, 0x32, 0x82, 0x69}} + PROPID_ACC_VALUEMAP = MSAAPROPID{0xda1c3d79, 0xfc5c, 0x420e, [8]byte{0xb3, 0x99, 0x9d, 0x15, 0x33, 0x54, 0x9e, 0x75}} + PROPID_ACC_STATEMAP = MSAAPROPID{0x43946c5e, 0x0ac0, 0x4042, [8]byte{0xb5, 0x25, 0x07, 0xbb, 0xdb, 0xe1, 0x7f, 0xa7}} + PROPID_ACC_DESCRIPTIONMAP = MSAAPROPID{0x1ff1435f, 0x8a14, 0x477b, [8]byte{0xb2, 0x26, 0xa0, 0xab, 0xe2, 0x79, 0x97, 0x5d}} + PROPID_ACC_DODEFAULTACTION = MSAAPROPID{0x1ba09523, 0x2e3b, 0x49a6, [8]byte{0xa0, 0x59, 0x59, 0x68, 0x2a, 0x3c, 0x48, 0xfd}} +) + +const ( + STATE_SYSTEM_NORMAL = 0 + STATE_SYSTEM_UNAVAILABLE = 0x1 + STATE_SYSTEM_SELECTED = 0x2 + STATE_SYSTEM_FOCUSED = 0x4 + STATE_SYSTEM_PRESSED = 0x8 + STATE_SYSTEM_CHECKED = 0x10 + STATE_SYSTEM_MIXED = 0x20 + STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED + STATE_SYSTEM_READONLY = 0x40 + STATE_SYSTEM_HOTTRACKED = 0x80 + STATE_SYSTEM_DEFAULT = 0x100 + STATE_SYSTEM_EXPANDED = 0x200 + STATE_SYSTEM_COLLAPSED = 0x400 + STATE_SYSTEM_BUSY = 0x800 + STATE_SYSTEM_FLOATING = 0x1000 + STATE_SYSTEM_MARQUEED = 0x2000 + STATE_SYSTEM_ANIMATED = 0x4000 + STATE_SYSTEM_INVISIBLE = 0x8000 + STATE_SYSTEM_OFFSCREEN = 0x10000 + STATE_SYSTEM_SIZEABLE = 0x20000 + STATE_SYSTEM_MOVEABLE = 0x40000 + STATE_SYSTEM_SELFVOICING = 0x80000 + STATE_SYSTEM_FOCUSABLE = 0x100000 + STATE_SYSTEM_SELECTABLE = 0x200000 + STATE_SYSTEM_LINKED = 0x400000 + STATE_SYSTEM_TRAVERSED = 0x800000 + STATE_SYSTEM_MULTISELECTABLE = 0x1000000 + STATE_SYSTEM_EXTSELECTABLE = 0x2000000 + STATE_SYSTEM_ALERT_LOW = 0x4000000 + STATE_SYSTEM_ALERT_MEDIUM = 0x8000000 + STATE_SYSTEM_ALERT_HIGH = 0x10000000 + STATE_SYSTEM_PROTECTED = 0x20000000 + STATE_SYSTEM_HASPOPUP = 0x40000000 + STATE_SYSTEM_VALID = 0x7fffffff +) + +const ( + ROLE_SYSTEM_TITLEBAR = 0x1 + ROLE_SYSTEM_MENUBAR = 0x2 + ROLE_SYSTEM_SCROLLBAR = 0x3 + ROLE_SYSTEM_GRIP = 0x4 + ROLE_SYSTEM_SOUND = 0x5 + ROLE_SYSTEM_CURSOR = 0x6 + ROLE_SYSTEM_CARET = 0x7 + ROLE_SYSTEM_ALERT = 0x8 + ROLE_SYSTEM_WINDOW = 0x9 + ROLE_SYSTEM_CLIENT = 0xa + ROLE_SYSTEM_MENUPOPUP = 0xb + ROLE_SYSTEM_MENUITEM = 0xc + ROLE_SYSTEM_TOOLTIP = 0xd + ROLE_SYSTEM_APPLICATION = 0xe + ROLE_SYSTEM_DOCUMENT = 0xf + ROLE_SYSTEM_PANE = 0x10 + ROLE_SYSTEM_CHART = 0x11 + ROLE_SYSTEM_DIALOG = 0x12 + ROLE_SYSTEM_BORDER = 0x13 + ROLE_SYSTEM_GROUPING = 0x14 + ROLE_SYSTEM_SEPARATOR = 0x15 + ROLE_SYSTEM_TOOLBAR = 0x16 + ROLE_SYSTEM_STATUSBAR = 0x17 + ROLE_SYSTEM_TABLE = 0x18 + ROLE_SYSTEM_COLUMNHEADER = 0x19 + ROLE_SYSTEM_ROWHEADER = 0x1a + ROLE_SYSTEM_COLUMN = 0x1b + ROLE_SYSTEM_ROW = 0x1c + ROLE_SYSTEM_CELL = 0x1d + ROLE_SYSTEM_LINK = 0x1e + ROLE_SYSTEM_HELPBALLOON = 0x1f + ROLE_SYSTEM_CHARACTER = 0x20 + ROLE_SYSTEM_LIST = 0x21 + ROLE_SYSTEM_LISTITEM = 0x22 + ROLE_SYSTEM_OUTLINE = 0x23 + ROLE_SYSTEM_OUTLINEITEM = 0x24 + ROLE_SYSTEM_PAGETAB = 0x25 + ROLE_SYSTEM_PROPERTYPAGE = 0x26 + ROLE_SYSTEM_INDICATOR = 0x27 + ROLE_SYSTEM_GRAPHIC = 0x28 + ROLE_SYSTEM_STATICTEXT = 0x29 + ROLE_SYSTEM_TEXT = 0x2a + ROLE_SYSTEM_PUSHBUTTON = 0x2b + ROLE_SYSTEM_CHECKBUTTON = 0x2c + ROLE_SYSTEM_RADIOBUTTON = 0x2d + ROLE_SYSTEM_COMBOBOX = 0x2e + ROLE_SYSTEM_DROPLIST = 0x2f + ROLE_SYSTEM_PROGRESSBAR = 0x30 + ROLE_SYSTEM_DIAL = 0x31 + ROLE_SYSTEM_HOTKEYFIELD = 0x32 + ROLE_SYSTEM_SLIDER = 0x33 + ROLE_SYSTEM_SPINBUTTON = 0x34 + ROLE_SYSTEM_DIAGRAM = 0x35 + ROLE_SYSTEM_ANIMATION = 0x36 + ROLE_SYSTEM_EQUATION = 0x37 + ROLE_SYSTEM_BUTTONDROPDOWN = 0x38 + ROLE_SYSTEM_BUTTONMENU = 0x39 + ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x3a + ROLE_SYSTEM_WHITESPACE = 0x3b + ROLE_SYSTEM_PAGETABLIST = 0x3c + ROLE_SYSTEM_CLOCK = 0x3d + ROLE_SYSTEM_SPLITBUTTON = 0x3e + ROLE_SYSTEM_IPADDRESS = 0x3f + ROLE_SYSTEM_OUTLINEBUTTON = 0x40 +) + +var ( + IID_IAccPropServer = IID{0x76c0dbbb, 0x15e0, 0x4e7b, [8]byte{0xb6, 0x1b, 0x20, 0xee, 0xea, 0x20, 0x01, 0xe0}} + IID_IAccPropServices = IID{0x6e26e776, 0x04f0, 0x495d, [8]byte{0x80, 0xe4, 0x33, 0x30, 0x35, 0x2e, 0x31, 0x69}} + CLSID_AccPropServices = CLSID{0xb5f8350b, 0x0548, 0x48b1, [8]byte{0xa6, 0xee, 0x88, 0xbd, 0x00, 0xb4, 0xa5, 0xe7}} +) + +type IAccPropServerVtbl struct { + QueryInterface uintptr + AddRef uintptr + Release uintptr + GetPropValue uintptr +} + +type IAccPropServer struct { + LpVtbl *IAccPropServerVtbl +} + +type IAccPropServicesVtbl struct { + QueryInterface uintptr + AddRef uintptr + Release uintptr + SetPropValue uintptr + SetPropServer uintptr + ClearProps uintptr + SetHwndProp uintptr + SetHwndPropStr uintptr + SetHwndPropServer uintptr + ClearHwndProps uintptr + ComposeHwndIdentityString uintptr + DecomposeHwndIdentityString uintptr + SetHmenuProp uintptr + SetHmenuPropStr uintptr + SetHmenuPropServer uintptr + ClearHmenuProps uintptr + ComposeHmenuIdentityString uintptr + DecomposeHmenuIdentityString uintptr +} + +type IAccPropServices struct { + LpVtbl *IAccPropServicesVtbl +} + +func (obj *IAccPropServices) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(ppvObject))) + return HRESULT(ret) +} + +func (obj *IAccPropServices) AddRef() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *IAccPropServices) Release() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. +// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer +func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(&idString[0])), + uintptr(len(idString)), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(v)), + 0) + return HRESULT(ret) +} + +// SetPropServer specifies a callback object to be used to annotate an array of properties for the accessible element. You can also specify whether the annotation is to be applied to this accessible element or to the element and its children. This method is used for server annotation. +// If server developers know the HWND of the accessible element they want to annotate, they can use SetHwndPropServer. +func (obj *IAccPropServices) SetPropServer(idString []byte, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetPropServer, 7, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(&idString[0])), + uintptr(len(idString)), + uintptr(unsafe.Pointer(&idProps[0])), + uintptr(len(idProps)), + uintptr(unsafe.Pointer(server)), + uintptr(annoScope), + 0, + 0) + return HRESULT(ret) +} + +// ClearProps restores default values to properties of accessible elements that they had previously annotated. +// If servers know the HWND of the object they want to clear, they can use ClearHwndProps. +func (obj *IAccPropServices) ClearProps(idString []byte, idProps []MSAAPROPID) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearProps, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(&idString[0])), + uintptr(len(idString)), + uintptr(unsafe.Pointer(&idProps[0])), + uintptr(len(idProps)), + 0) + return HRESULT(ret) +} + +// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead. +func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndProp, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(v))) + return HRESULT(ret) +} + +// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. +func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return E_INVALIDARG + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndPropStr, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(str16))) + return HRESULT(ret) +} + +// SetHwndPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HWND-based accessible elements. +func (obj *IAccPropServices) SetHwndPropServer(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropServer, 8, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(&idProps[0])), + uintptr(len(idProps)), + uintptr(unsafe.Pointer(server)), + uintptr(annoScope), + 0) + return HRESULT(ret) +} + +// ClearHwndProps wraps SetPropValue, SetPropServer, and ClearProps, and provides a convenient entry point for callers who are annotating HWND-based accessible elements. +func (obj *IAccPropServices) ClearHwndProps(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHwndProps, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(&idProps[0])), + uintptr(len(idProps))) + return HRESULT(ret) +} + +// ComposeHwndIdentityString retrievs an identity string. +func (obj *IAccPropServices) ComposeHwndIdentityString(hwnd HWND, idObject int32, idChild uint32) (hr HRESULT, idString []byte) { + var data *[1<<31 - 1]byte + var len uint32 + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHwndIdentityString, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(&data)), + uintptr(unsafe.Pointer(&len))) + hr = HRESULT(ret) + if FAILED(hr) { + return + } + defer CoTaskMemFree(uintptr(unsafe.Pointer(data))) + idString = make([]byte, len) + copy(idString, data[:len]) + return +} + +// DecomposeHwndIdentityString determines the HWND, object ID, and child ID for the accessible element identified by the identity string. +func (obj *IAccPropServices) DecomposeHwndIdentityString(idString []byte) (hr HRESULT, hwnd HWND, idObject int32, idChild uint32) { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHwndIdentityString, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(&idString[0])), + uintptr(len(idString)), + uintptr(unsafe.Pointer(&hwnd)), + uintptr(unsafe.Pointer(&idObject)), + uintptr(unsafe.Pointer(&idChild))) + hr = HRESULT(ret) + return +} + +// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead. +func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(v)), + 0) + return HRESULT(ret) +} + +// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. +func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return E_INVALIDARG + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(str16)), + 0) + return HRESULT(ret) +} + +// SetHmenuPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. +func (obj *IAccPropServices) SetHmenuPropServer(hmenu HMENU, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuPropServer, 7, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(&idProps[0])), + uintptr(len(idProps)), + uintptr(unsafe.Pointer(server)), + uintptr(annoScope), + 0, + 0) + return HRESULT(ret) +} + +// ClearHmenuProps wraps ClearProps, and provides a convenient entry point for callers who are annotating HMENU-based accessible elements. +func (obj *IAccPropServices) ClearHmenuProps(hmenu HMENU, idChild uint32, idProps []MSAAPROPID) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHmenuProps, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(&idProps[0])), + uintptr(len(idProps)), + 0) + return HRESULT(ret) +} + +// ComposeHmenuIdentityString retrieves an identity string for an HMENU-based accessible element. +func (obj *IAccPropServices) ComposeHmenuIdentityString(hmenu HMENU, idChild uint32) (hr HRESULT, idString []byte) { + var data *[1<<31 - 1]byte + var len uint32 + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHmenuIdentityString, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(&data)), + uintptr(unsafe.Pointer(&len)), + 0) + hr = HRESULT(ret) + if FAILED(hr) { + return + } + defer CoTaskMemFree(uintptr(unsafe.Pointer(data))) + idString = make([]byte, len) + copy(idString, data[:len]) + return +} + +// DecomposeHmenuIdentityString determines the HMENU, object ID, and child ID for the accessible element identified by the identity string. +func (obj *IAccPropServices) DecomposeHmenuIdentityString(idString []byte) (hr HRESULT, hmenu HMENU, idChild uint32) { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHmenuIdentityString, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(&idString[0])), + uintptr(len(idString)), + uintptr(unsafe.Pointer(&hmenu)), + uintptr(unsafe.Pointer(&idChild)), + 0) + hr = HRESULT(ret) + return +} From 8acf7beedf25d9397d2dba96708c2597f46fa768 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 10 Sep 2019 10:32:00 +0200 Subject: [PATCH 117/138] Revert "Add support for Dynamic Annotation" This reverts commit 14509000663326e621f71267c730f83d4a2e450b. --- go.mod | 2 + oleacc.go | 439 ------------------------------------------------------ 2 files changed, 2 insertions(+), 439 deletions(-) delete mode 100644 oleacc.go diff --git a/go.mod b/go.mod index d000c521..bda1929e 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/lxn/win go 1.12 + +require golang.org/x/sys v0.0.0-20190904154756-749cb33beabd diff --git a/oleacc.go b/oleacc.go deleted file mode 100644 index 6e2a6d16..00000000 --- a/oleacc.go +++ /dev/null @@ -1,439 +0,0 @@ -// Copyright 2010 The win Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package win - -import ( - "syscall" - "unsafe" -) - -type AnnoScope int - -const ( - ANNO_THIS = AnnoScope(0) - ANNO_CONTAINER = AnnoScope(1) -) - -type MSAAPROPID syscall.GUID - -var ( - PROPID_ACC_NAME = MSAAPROPID{0x608d3df8, 0x8128, 0x4aa7, [8]byte{0xa4, 0x28, 0xf5, 0x5e, 0x49, 0x26, 0x72, 0x91}} - PROPID_ACC_VALUE = MSAAPROPID{0x123fe443, 0x211a, 0x4615, [8]byte{0x95, 0x27, 0xc4, 0x5a, 0x7e, 0x93, 0x71, 0x7a}} - PROPID_ACC_DESCRIPTION = MSAAPROPID{0x4d48dfe4, 0xbd3f, 0x491f, [8]byte{0xa6, 0x48, 0x49, 0x2d, 0x6f, 0x20, 0xc5, 0x88}} - PROPID_ACC_ROLE = MSAAPROPID{0xcb905ff2, 0x7bd1, 0x4c05, [8]byte{0xb3, 0xc8, 0xe6, 0xc2, 0x41, 0x36, 0x4d, 0x70}} - PROPID_ACC_STATE = MSAAPROPID{0xa8d4d5b0, 0x0a21, 0x42d0, [8]byte{0xa5, 0xc0, 0x51, 0x4e, 0x98, 0x4f, 0x45, 0x7b}} - PROPID_ACC_HELP = MSAAPROPID{0xc831e11f, 0x44db, 0x4a99, [8]byte{0x97, 0x68, 0xcb, 0x8f, 0x97, 0x8b, 0x72, 0x31}} - PROPID_ACC_KEYBOARDSHORTCUT = MSAAPROPID{0x7d9bceee, 0x7d1e, 0x4979, [8]byte{0x93, 0x82, 0x51, 0x80, 0xf4, 0x17, 0x2c, 0x34}} - PROPID_ACC_DEFAULTACTION = MSAAPROPID{0x180c072b, 0xc27f, 0x43c7, [8]byte{0x99, 0x22, 0xf6, 0x35, 0x62, 0xa4, 0x63, 0x2b}} - PROPID_ACC_HELPTOPIC = MSAAPROPID{0x787d1379, 0x8ede, 0x440b, [8]byte{0x8a, 0xec, 0x11, 0xf7, 0xbf, 0x90, 0x30, 0xb3}} - PROPID_ACC_FOCUS = MSAAPROPID{0x6eb335df, 0x1c29, 0x4127, [8]byte{0xb1, 0x2c, 0xde, 0xe9, 0xfd, 0x15, 0x7f, 0x2b}} - PROPID_ACC_SELECTION = MSAAPROPID{0xb99d073c, 0xd731, 0x405b, [8]byte{0x90, 0x61, 0xd9, 0x5e, 0x8f, 0x84, 0x29, 0x84}} - PROPID_ACC_PARENT = MSAAPROPID{0x474c22b6, 0xffc2, 0x467a, [8]byte{0xb1, 0xb5, 0xe9, 0x58, 0xb4, 0x65, 0x73, 0x30}} - PROPID_ACC_NAV_UP = MSAAPROPID{0x016e1a2b, 0x1a4e, 0x4767, [8]byte{0x86, 0x12, 0x33, 0x86, 0xf6, 0x69, 0x35, 0xec}} - PROPID_ACC_NAV_DOWN = MSAAPROPID{0x031670ed, 0x3cdf, 0x48d2, [8]byte{0x96, 0x13, 0x13, 0x8f, 0x2d, 0xd8, 0xa6, 0x68}} - PROPID_ACC_NAV_LEFT = MSAAPROPID{0x228086cb, 0x82f1, 0x4a39, [8]byte{0x87, 0x05, 0xdc, 0xdc, 0x0f, 0xff, 0x92, 0xf5}} - PROPID_ACC_NAV_RIGHT = MSAAPROPID{0xcd211d9f, 0xe1cb, 0x4fe5, [8]byte{0xa7, 0x7c, 0x92, 0x0b, 0x88, 0x4d, 0x09, 0x5b}} - PROPID_ACC_NAV_PREV = MSAAPROPID{0x776d3891, 0xc73b, 0x4480, [8]byte{0xb3, 0xf6, 0x07, 0x6a, 0x16, 0xa1, 0x5a, 0xf6}} - PROPID_ACC_NAV_NEXT = MSAAPROPID{0x1cdc5455, 0x8cd9, 0x4c92, [8]byte{0xa3, 0x71, 0x39, 0x39, 0xa2, 0xfe, 0x3e, 0xee}} - PROPID_ACC_NAV_FIRSTCHILD = MSAAPROPID{0xcfd02558, 0x557b, 0x4c67, [8]byte{0x84, 0xf9, 0x2a, 0x09, 0xfc, 0xe4, 0x07, 0x49}} - PROPID_ACC_NAV_LASTCHILD = MSAAPROPID{0x302ecaa5, 0x48d5, 0x4f8d, [8]byte{0xb6, 0x71, 0x1a, 0x8d, 0x20, 0xa7, 0x78, 0x32}} - PROPID_ACC_ROLEMAP = MSAAPROPID{0xf79acda2, 0x140d, 0x4fe6, [8]byte{0x89, 0x14, 0x20, 0x84, 0x76, 0x32, 0x82, 0x69}} - PROPID_ACC_VALUEMAP = MSAAPROPID{0xda1c3d79, 0xfc5c, 0x420e, [8]byte{0xb3, 0x99, 0x9d, 0x15, 0x33, 0x54, 0x9e, 0x75}} - PROPID_ACC_STATEMAP = MSAAPROPID{0x43946c5e, 0x0ac0, 0x4042, [8]byte{0xb5, 0x25, 0x07, 0xbb, 0xdb, 0xe1, 0x7f, 0xa7}} - PROPID_ACC_DESCRIPTIONMAP = MSAAPROPID{0x1ff1435f, 0x8a14, 0x477b, [8]byte{0xb2, 0x26, 0xa0, 0xab, 0xe2, 0x79, 0x97, 0x5d}} - PROPID_ACC_DODEFAULTACTION = MSAAPROPID{0x1ba09523, 0x2e3b, 0x49a6, [8]byte{0xa0, 0x59, 0x59, 0x68, 0x2a, 0x3c, 0x48, 0xfd}} -) - -const ( - STATE_SYSTEM_NORMAL = 0 - STATE_SYSTEM_UNAVAILABLE = 0x1 - STATE_SYSTEM_SELECTED = 0x2 - STATE_SYSTEM_FOCUSED = 0x4 - STATE_SYSTEM_PRESSED = 0x8 - STATE_SYSTEM_CHECKED = 0x10 - STATE_SYSTEM_MIXED = 0x20 - STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED - STATE_SYSTEM_READONLY = 0x40 - STATE_SYSTEM_HOTTRACKED = 0x80 - STATE_SYSTEM_DEFAULT = 0x100 - STATE_SYSTEM_EXPANDED = 0x200 - STATE_SYSTEM_COLLAPSED = 0x400 - STATE_SYSTEM_BUSY = 0x800 - STATE_SYSTEM_FLOATING = 0x1000 - STATE_SYSTEM_MARQUEED = 0x2000 - STATE_SYSTEM_ANIMATED = 0x4000 - STATE_SYSTEM_INVISIBLE = 0x8000 - STATE_SYSTEM_OFFSCREEN = 0x10000 - STATE_SYSTEM_SIZEABLE = 0x20000 - STATE_SYSTEM_MOVEABLE = 0x40000 - STATE_SYSTEM_SELFVOICING = 0x80000 - STATE_SYSTEM_FOCUSABLE = 0x100000 - STATE_SYSTEM_SELECTABLE = 0x200000 - STATE_SYSTEM_LINKED = 0x400000 - STATE_SYSTEM_TRAVERSED = 0x800000 - STATE_SYSTEM_MULTISELECTABLE = 0x1000000 - STATE_SYSTEM_EXTSELECTABLE = 0x2000000 - STATE_SYSTEM_ALERT_LOW = 0x4000000 - STATE_SYSTEM_ALERT_MEDIUM = 0x8000000 - STATE_SYSTEM_ALERT_HIGH = 0x10000000 - STATE_SYSTEM_PROTECTED = 0x20000000 - STATE_SYSTEM_HASPOPUP = 0x40000000 - STATE_SYSTEM_VALID = 0x7fffffff -) - -const ( - ROLE_SYSTEM_TITLEBAR = 0x1 - ROLE_SYSTEM_MENUBAR = 0x2 - ROLE_SYSTEM_SCROLLBAR = 0x3 - ROLE_SYSTEM_GRIP = 0x4 - ROLE_SYSTEM_SOUND = 0x5 - ROLE_SYSTEM_CURSOR = 0x6 - ROLE_SYSTEM_CARET = 0x7 - ROLE_SYSTEM_ALERT = 0x8 - ROLE_SYSTEM_WINDOW = 0x9 - ROLE_SYSTEM_CLIENT = 0xa - ROLE_SYSTEM_MENUPOPUP = 0xb - ROLE_SYSTEM_MENUITEM = 0xc - ROLE_SYSTEM_TOOLTIP = 0xd - ROLE_SYSTEM_APPLICATION = 0xe - ROLE_SYSTEM_DOCUMENT = 0xf - ROLE_SYSTEM_PANE = 0x10 - ROLE_SYSTEM_CHART = 0x11 - ROLE_SYSTEM_DIALOG = 0x12 - ROLE_SYSTEM_BORDER = 0x13 - ROLE_SYSTEM_GROUPING = 0x14 - ROLE_SYSTEM_SEPARATOR = 0x15 - ROLE_SYSTEM_TOOLBAR = 0x16 - ROLE_SYSTEM_STATUSBAR = 0x17 - ROLE_SYSTEM_TABLE = 0x18 - ROLE_SYSTEM_COLUMNHEADER = 0x19 - ROLE_SYSTEM_ROWHEADER = 0x1a - ROLE_SYSTEM_COLUMN = 0x1b - ROLE_SYSTEM_ROW = 0x1c - ROLE_SYSTEM_CELL = 0x1d - ROLE_SYSTEM_LINK = 0x1e - ROLE_SYSTEM_HELPBALLOON = 0x1f - ROLE_SYSTEM_CHARACTER = 0x20 - ROLE_SYSTEM_LIST = 0x21 - ROLE_SYSTEM_LISTITEM = 0x22 - ROLE_SYSTEM_OUTLINE = 0x23 - ROLE_SYSTEM_OUTLINEITEM = 0x24 - ROLE_SYSTEM_PAGETAB = 0x25 - ROLE_SYSTEM_PROPERTYPAGE = 0x26 - ROLE_SYSTEM_INDICATOR = 0x27 - ROLE_SYSTEM_GRAPHIC = 0x28 - ROLE_SYSTEM_STATICTEXT = 0x29 - ROLE_SYSTEM_TEXT = 0x2a - ROLE_SYSTEM_PUSHBUTTON = 0x2b - ROLE_SYSTEM_CHECKBUTTON = 0x2c - ROLE_SYSTEM_RADIOBUTTON = 0x2d - ROLE_SYSTEM_COMBOBOX = 0x2e - ROLE_SYSTEM_DROPLIST = 0x2f - ROLE_SYSTEM_PROGRESSBAR = 0x30 - ROLE_SYSTEM_DIAL = 0x31 - ROLE_SYSTEM_HOTKEYFIELD = 0x32 - ROLE_SYSTEM_SLIDER = 0x33 - ROLE_SYSTEM_SPINBUTTON = 0x34 - ROLE_SYSTEM_DIAGRAM = 0x35 - ROLE_SYSTEM_ANIMATION = 0x36 - ROLE_SYSTEM_EQUATION = 0x37 - ROLE_SYSTEM_BUTTONDROPDOWN = 0x38 - ROLE_SYSTEM_BUTTONMENU = 0x39 - ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x3a - ROLE_SYSTEM_WHITESPACE = 0x3b - ROLE_SYSTEM_PAGETABLIST = 0x3c - ROLE_SYSTEM_CLOCK = 0x3d - ROLE_SYSTEM_SPLITBUTTON = 0x3e - ROLE_SYSTEM_IPADDRESS = 0x3f - ROLE_SYSTEM_OUTLINEBUTTON = 0x40 -) - -var ( - IID_IAccPropServer = IID{0x76c0dbbb, 0x15e0, 0x4e7b, [8]byte{0xb6, 0x1b, 0x20, 0xee, 0xea, 0x20, 0x01, 0xe0}} - IID_IAccPropServices = IID{0x6e26e776, 0x04f0, 0x495d, [8]byte{0x80, 0xe4, 0x33, 0x30, 0x35, 0x2e, 0x31, 0x69}} - CLSID_AccPropServices = CLSID{0xb5f8350b, 0x0548, 0x48b1, [8]byte{0xa6, 0xee, 0x88, 0xbd, 0x00, 0xb4, 0xa5, 0xe7}} -) - -type IAccPropServerVtbl struct { - QueryInterface uintptr - AddRef uintptr - Release uintptr - GetPropValue uintptr -} - -type IAccPropServer struct { - LpVtbl *IAccPropServerVtbl -} - -type IAccPropServicesVtbl struct { - QueryInterface uintptr - AddRef uintptr - Release uintptr - SetPropValue uintptr - SetPropServer uintptr - ClearProps uintptr - SetHwndProp uintptr - SetHwndPropStr uintptr - SetHwndPropServer uintptr - ClearHwndProps uintptr - ComposeHwndIdentityString uintptr - DecomposeHwndIdentityString uintptr - SetHmenuProp uintptr - SetHmenuPropStr uintptr - SetHmenuPropServer uintptr - ClearHmenuProps uintptr - ComposeHmenuIdentityString uintptr - DecomposeHmenuIdentityString uintptr -} - -type IAccPropServices struct { - LpVtbl *IAccPropServicesVtbl -} - -func (obj *IAccPropServices) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { - ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, - uintptr(unsafe.Pointer(obj)), - uintptr(unsafe.Pointer(riid)), - uintptr(unsafe.Pointer(ppvObject))) - return HRESULT(ret) -} - -func (obj *IAccPropServices) AddRef() uint32 { - ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, - uintptr(unsafe.Pointer(obj)), - 0, - 0) - return uint32(ret) -} - -func (obj *IAccPropServices) Release() uint32 { - ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, - uintptr(unsafe.Pointer(obj)), - 0, - 0) - return uint32(ret) -} - -// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. -// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer -func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(unsafe.Pointer(&idString[0])), - uintptr(len(idString)), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(v)), - 0) - return HRESULT(ret) -} - -// SetPropServer specifies a callback object to be used to annotate an array of properties for the accessible element. You can also specify whether the annotation is to be applied to this accessible element or to the element and its children. This method is used for server annotation. -// If server developers know the HWND of the accessible element they want to annotate, they can use SetHwndPropServer. -func (obj *IAccPropServices) SetPropServer(idString []byte, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { - ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetPropServer, 7, - uintptr(unsafe.Pointer(obj)), - uintptr(unsafe.Pointer(&idString[0])), - uintptr(len(idString)), - uintptr(unsafe.Pointer(&idProps[0])), - uintptr(len(idProps)), - uintptr(unsafe.Pointer(server)), - uintptr(annoScope), - 0, - 0) - return HRESULT(ret) -} - -// ClearProps restores default values to properties of accessible elements that they had previously annotated. -// If servers know the HWND of the object they want to clear, they can use ClearHwndProps. -func (obj *IAccPropServices) ClearProps(idString []byte, idProps []MSAAPROPID) HRESULT { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearProps, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(unsafe.Pointer(&idString[0])), - uintptr(len(idString)), - uintptr(unsafe.Pointer(&idProps[0])), - uintptr(len(idProps)), - 0) - return HRESULT(ret) -} - -// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead. -func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndProp, 6, - uintptr(unsafe.Pointer(obj)), - uintptr(hwnd), - uintptr(idObject), - uintptr(idChild), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(v))) - return HRESULT(ret) -} - -// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. -func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { - str16, err := syscall.UTF16PtrFromString(str) - if err != nil { - return E_INVALIDARG - } - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndPropStr, 6, - uintptr(unsafe.Pointer(obj)), - uintptr(hwnd), - uintptr(idObject), - uintptr(idChild), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(str16))) - return HRESULT(ret) -} - -// SetHwndPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HWND-based accessible elements. -func (obj *IAccPropServices) SetHwndPropServer(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { - ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropServer, 8, - uintptr(unsafe.Pointer(obj)), - uintptr(hwnd), - uintptr(idObject), - uintptr(idChild), - uintptr(unsafe.Pointer(&idProps[0])), - uintptr(len(idProps)), - uintptr(unsafe.Pointer(server)), - uintptr(annoScope), - 0) - return HRESULT(ret) -} - -// ClearHwndProps wraps SetPropValue, SetPropServer, and ClearProps, and provides a convenient entry point for callers who are annotating HWND-based accessible elements. -func (obj *IAccPropServices) ClearHwndProps(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID) HRESULT { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHwndProps, 6, - uintptr(unsafe.Pointer(obj)), - uintptr(hwnd), - uintptr(idObject), - uintptr(idChild), - uintptr(unsafe.Pointer(&idProps[0])), - uintptr(len(idProps))) - return HRESULT(ret) -} - -// ComposeHwndIdentityString retrievs an identity string. -func (obj *IAccPropServices) ComposeHwndIdentityString(hwnd HWND, idObject int32, idChild uint32) (hr HRESULT, idString []byte) { - var data *[1<<31 - 1]byte - var len uint32 - ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHwndIdentityString, 6, - uintptr(unsafe.Pointer(obj)), - uintptr(hwnd), - uintptr(idObject), - uintptr(idChild), - uintptr(unsafe.Pointer(&data)), - uintptr(unsafe.Pointer(&len))) - hr = HRESULT(ret) - if FAILED(hr) { - return - } - defer CoTaskMemFree(uintptr(unsafe.Pointer(data))) - idString = make([]byte, len) - copy(idString, data[:len]) - return -} - -// DecomposeHwndIdentityString determines the HWND, object ID, and child ID for the accessible element identified by the identity string. -func (obj *IAccPropServices) DecomposeHwndIdentityString(idString []byte) (hr HRESULT, hwnd HWND, idObject int32, idChild uint32) { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHwndIdentityString, 6, - uintptr(unsafe.Pointer(obj)), - uintptr(unsafe.Pointer(&idString[0])), - uintptr(len(idString)), - uintptr(unsafe.Pointer(&hwnd)), - uintptr(unsafe.Pointer(&idObject)), - uintptr(unsafe.Pointer(&idChild))) - hr = HRESULT(ret) - return -} - -// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead. -func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(hmenu), - uintptr(idChild), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(v)), - 0) - return HRESULT(ret) -} - -// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. -func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { - str16, err := syscall.UTF16PtrFromString(str) - if err != nil { - return E_INVALIDARG - } - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(hmenu), - uintptr(idChild), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(str16)), - 0) - return HRESULT(ret) -} - -// SetHmenuPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. -func (obj *IAccPropServices) SetHmenuPropServer(hmenu HMENU, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { - ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuPropServer, 7, - uintptr(unsafe.Pointer(obj)), - uintptr(hmenu), - uintptr(idChild), - uintptr(unsafe.Pointer(&idProps[0])), - uintptr(len(idProps)), - uintptr(unsafe.Pointer(server)), - uintptr(annoScope), - 0, - 0) - return HRESULT(ret) -} - -// ClearHmenuProps wraps ClearProps, and provides a convenient entry point for callers who are annotating HMENU-based accessible elements. -func (obj *IAccPropServices) ClearHmenuProps(hmenu HMENU, idChild uint32, idProps []MSAAPROPID) HRESULT { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHmenuProps, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(hmenu), - uintptr(idChild), - uintptr(unsafe.Pointer(&idProps[0])), - uintptr(len(idProps)), - 0) - return HRESULT(ret) -} - -// ComposeHmenuIdentityString retrieves an identity string for an HMENU-based accessible element. -func (obj *IAccPropServices) ComposeHmenuIdentityString(hmenu HMENU, idChild uint32) (hr HRESULT, idString []byte) { - var data *[1<<31 - 1]byte - var len uint32 - ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHmenuIdentityString, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(hmenu), - uintptr(idChild), - uintptr(unsafe.Pointer(&data)), - uintptr(unsafe.Pointer(&len)), - 0) - hr = HRESULT(ret) - if FAILED(hr) { - return - } - defer CoTaskMemFree(uintptr(unsafe.Pointer(data))) - idString = make([]byte, len) - copy(idString, data[:len]) - return -} - -// DecomposeHmenuIdentityString determines the HMENU, object ID, and child ID for the accessible element identified by the identity string. -func (obj *IAccPropServices) DecomposeHmenuIdentityString(idString []byte) (hr HRESULT, hmenu HMENU, idChild uint32) { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHmenuIdentityString, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(unsafe.Pointer(&idString[0])), - uintptr(len(idString)), - uintptr(unsafe.Pointer(&hmenu)), - uintptr(unsafe.Pointer(&idChild)), - 0) - hr = HRESULT(ret) - return -} From ae3bd9765f4622e3ed9650894d4cba23c9fc9b1a Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 10 Sep 2019 10:39:38 +0200 Subject: [PATCH 118/138] Revert "Make HRESULT constants typed" This reverts commit bdbc78e4188bdbab4027030096844a5f1d921ea2. --- win.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/win.go b/win.go index e8a39fdb..43d07462 100644 --- a/win.go +++ b/win.go @@ -12,19 +12,19 @@ import ( ) const ( - S_OK = HRESULT(0x00000000) - S_FALSE = HRESULT(0x00000001) - E_UNEXPECTED = HRESULT(-((0x8000FFFF ^ 0xFFFFFFFF) + 1)) - E_NOTIMPL = HRESULT(-((0x80004001 ^ 0xFFFFFFFF) + 1)) - E_OUTOFMEMORY = HRESULT(-((0x8007000E ^ 0xFFFFFFFF) + 1)) - E_INVALIDARG = HRESULT(-((0x80070057 ^ 0xFFFFFFFF) + 1)) - E_NOINTERFACE = HRESULT(-((0x80004002 ^ 0xFFFFFFFF) + 1)) - E_POINTER = HRESULT(-((0x80004003 ^ 0xFFFFFFFF) + 1)) - E_HANDLE = HRESULT(-((0x80070006 ^ 0xFFFFFFFF) + 1)) - E_ABORT = HRESULT(-((0x80004004 ^ 0xFFFFFFFF) + 1)) - E_FAIL = HRESULT(-((0x80004005 ^ 0xFFFFFFFF) + 1)) - E_ACCESSDENIED = HRESULT(-((0x80070005 ^ 0xFFFFFFFF) + 1)) - E_PENDING = HRESULT(-((0x8000000A ^ 0xFFFFFFFF) + 1)) + S_OK = 0x00000000 + S_FALSE = 0x00000001 + E_UNEXPECTED = 0x8000FFFF + E_NOTIMPL = 0x80004001 + E_OUTOFMEMORY = 0x8007000E + E_INVALIDARG = 0x80070057 + E_NOINTERFACE = 0x80004002 + E_POINTER = 0x80004003 + E_HANDLE = 0x80070006 + E_ABORT = 0x80004004 + E_FAIL = 0x80004005 + E_ACCESSDENIED = 0x80070005 + E_PENDING = 0x8000000A ) const ( From d765bbe7d02b50a1ae48cce88fc344b33b80c1bf Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 10 Sep 2019 16:17:10 +0200 Subject: [PATCH 119/138] Add LVIR_* constants Signed-off-by: Simon Rozman --- comctl32.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/comctl32.go b/comctl32.go index b0e22954..28b37939 100644 --- a/comctl32.go +++ b/comctl32.go @@ -209,6 +209,13 @@ const ( CDRF_SKIPPOSTPAINT = 0x00000100 ) +const ( + LVIR_BOUNDS = 0 + LVIR_ICON = 1 + LVIR_LABEL = 2 + LVIR_SELECTBOUNDS = 3 +) + const ( LPSTR_TEXTCALLBACK = ^uintptr(0) I_CHILDRENCALLBACK = -1 From 1d503f5be71f1492bd19b29c44574840bf732b4b Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 10 Sep 2019 16:17:36 +0200 Subject: [PATCH 120/138] Add EM_SETCARETINDEX and EM_GETCARETINDEX Signed-off-by: Simon Rozman --- edit.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/edit.go b/edit.go index 38509cf7..a7b3b125 100644 --- a/edit.go +++ b/edit.go @@ -81,4 +81,6 @@ const ( EM_GETIMESTATUS = 0x00D9 EM_SETCUEBANNER = 0x1501 EM_GETCUEBANNER = 0x1502 + EM_SETCARETINDEX = 0x1511 + EM_GETCARETINDEX = 0x1512 ) From 14e5fc32335c8aa9cac38516ded5ad7e2c1ff46d Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 12 Sep 2019 11:58:25 +0200 Subject: [PATCH 121/138] Add support for Dynamic Annotation Dynamic Annotation provides an API to annotate controls to make them accessibility friendly. While stock controls are auto-annotated by the Windows, while custom controls need to be (re)annotated to make screen readers read them reasonably. Signed-off-by: Simon Rozman --- oleacc.go | 494 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 494 insertions(+) create mode 100644 oleacc.go diff --git a/oleacc.go b/oleacc.go new file mode 100644 index 00000000..7c5f8662 --- /dev/null +++ b/oleacc.go @@ -0,0 +1,494 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +type AnnoScope int + +const ( + ANNO_THIS = AnnoScope(0) + ANNO_CONTAINER = AnnoScope(1) +) + +type MSAAPROPID syscall.GUID + +var ( + PROPID_ACC_NAME = MSAAPROPID{0x608d3df8, 0x8128, 0x4aa7, [8]byte{0xa4, 0x28, 0xf5, 0x5e, 0x49, 0x26, 0x72, 0x91}} + PROPID_ACC_VALUE = MSAAPROPID{0x123fe443, 0x211a, 0x4615, [8]byte{0x95, 0x27, 0xc4, 0x5a, 0x7e, 0x93, 0x71, 0x7a}} + PROPID_ACC_DESCRIPTION = MSAAPROPID{0x4d48dfe4, 0xbd3f, 0x491f, [8]byte{0xa6, 0x48, 0x49, 0x2d, 0x6f, 0x20, 0xc5, 0x88}} + PROPID_ACC_ROLE = MSAAPROPID{0xcb905ff2, 0x7bd1, 0x4c05, [8]byte{0xb3, 0xc8, 0xe6, 0xc2, 0x41, 0x36, 0x4d, 0x70}} + PROPID_ACC_STATE = MSAAPROPID{0xa8d4d5b0, 0x0a21, 0x42d0, [8]byte{0xa5, 0xc0, 0x51, 0x4e, 0x98, 0x4f, 0x45, 0x7b}} + PROPID_ACC_HELP = MSAAPROPID{0xc831e11f, 0x44db, 0x4a99, [8]byte{0x97, 0x68, 0xcb, 0x8f, 0x97, 0x8b, 0x72, 0x31}} + PROPID_ACC_KEYBOARDSHORTCUT = MSAAPROPID{0x7d9bceee, 0x7d1e, 0x4979, [8]byte{0x93, 0x82, 0x51, 0x80, 0xf4, 0x17, 0x2c, 0x34}} + PROPID_ACC_DEFAULTACTION = MSAAPROPID{0x180c072b, 0xc27f, 0x43c7, [8]byte{0x99, 0x22, 0xf6, 0x35, 0x62, 0xa4, 0x63, 0x2b}} + PROPID_ACC_HELPTOPIC = MSAAPROPID{0x787d1379, 0x8ede, 0x440b, [8]byte{0x8a, 0xec, 0x11, 0xf7, 0xbf, 0x90, 0x30, 0xb3}} + PROPID_ACC_FOCUS = MSAAPROPID{0x6eb335df, 0x1c29, 0x4127, [8]byte{0xb1, 0x2c, 0xde, 0xe9, 0xfd, 0x15, 0x7f, 0x2b}} + PROPID_ACC_SELECTION = MSAAPROPID{0xb99d073c, 0xd731, 0x405b, [8]byte{0x90, 0x61, 0xd9, 0x5e, 0x8f, 0x84, 0x29, 0x84}} + PROPID_ACC_PARENT = MSAAPROPID{0x474c22b6, 0xffc2, 0x467a, [8]byte{0xb1, 0xb5, 0xe9, 0x58, 0xb4, 0x65, 0x73, 0x30}} + PROPID_ACC_NAV_UP = MSAAPROPID{0x016e1a2b, 0x1a4e, 0x4767, [8]byte{0x86, 0x12, 0x33, 0x86, 0xf6, 0x69, 0x35, 0xec}} + PROPID_ACC_NAV_DOWN = MSAAPROPID{0x031670ed, 0x3cdf, 0x48d2, [8]byte{0x96, 0x13, 0x13, 0x8f, 0x2d, 0xd8, 0xa6, 0x68}} + PROPID_ACC_NAV_LEFT = MSAAPROPID{0x228086cb, 0x82f1, 0x4a39, [8]byte{0x87, 0x05, 0xdc, 0xdc, 0x0f, 0xff, 0x92, 0xf5}} + PROPID_ACC_NAV_RIGHT = MSAAPROPID{0xcd211d9f, 0xe1cb, 0x4fe5, [8]byte{0xa7, 0x7c, 0x92, 0x0b, 0x88, 0x4d, 0x09, 0x5b}} + PROPID_ACC_NAV_PREV = MSAAPROPID{0x776d3891, 0xc73b, 0x4480, [8]byte{0xb3, 0xf6, 0x07, 0x6a, 0x16, 0xa1, 0x5a, 0xf6}} + PROPID_ACC_NAV_NEXT = MSAAPROPID{0x1cdc5455, 0x8cd9, 0x4c92, [8]byte{0xa3, 0x71, 0x39, 0x39, 0xa2, 0xfe, 0x3e, 0xee}} + PROPID_ACC_NAV_FIRSTCHILD = MSAAPROPID{0xcfd02558, 0x557b, 0x4c67, [8]byte{0x84, 0xf9, 0x2a, 0x09, 0xfc, 0xe4, 0x07, 0x49}} + PROPID_ACC_NAV_LASTCHILD = MSAAPROPID{0x302ecaa5, 0x48d5, 0x4f8d, [8]byte{0xb6, 0x71, 0x1a, 0x8d, 0x20, 0xa7, 0x78, 0x32}} + PROPID_ACC_ROLEMAP = MSAAPROPID{0xf79acda2, 0x140d, 0x4fe6, [8]byte{0x89, 0x14, 0x20, 0x84, 0x76, 0x32, 0x82, 0x69}} + PROPID_ACC_VALUEMAP = MSAAPROPID{0xda1c3d79, 0xfc5c, 0x420e, [8]byte{0xb3, 0x99, 0x9d, 0x15, 0x33, 0x54, 0x9e, 0x75}} + PROPID_ACC_STATEMAP = MSAAPROPID{0x43946c5e, 0x0ac0, 0x4042, [8]byte{0xb5, 0x25, 0x07, 0xbb, 0xdb, 0xe1, 0x7f, 0xa7}} + PROPID_ACC_DESCRIPTIONMAP = MSAAPROPID{0x1ff1435f, 0x8a14, 0x477b, [8]byte{0xb2, 0x26, 0xa0, 0xab, 0xe2, 0x79, 0x97, 0x5d}} + PROPID_ACC_DODEFAULTACTION = MSAAPROPID{0x1ba09523, 0x2e3b, 0x49a6, [8]byte{0xa0, 0x59, 0x59, 0x68, 0x2a, 0x3c, 0x48, 0xfd}} +) + +const ( + STATE_SYSTEM_NORMAL = 0 + STATE_SYSTEM_UNAVAILABLE = 0x1 + STATE_SYSTEM_SELECTED = 0x2 + STATE_SYSTEM_FOCUSED = 0x4 + STATE_SYSTEM_PRESSED = 0x8 + STATE_SYSTEM_CHECKED = 0x10 + STATE_SYSTEM_MIXED = 0x20 + STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED + STATE_SYSTEM_READONLY = 0x40 + STATE_SYSTEM_HOTTRACKED = 0x80 + STATE_SYSTEM_DEFAULT = 0x100 + STATE_SYSTEM_EXPANDED = 0x200 + STATE_SYSTEM_COLLAPSED = 0x400 + STATE_SYSTEM_BUSY = 0x800 + STATE_SYSTEM_FLOATING = 0x1000 + STATE_SYSTEM_MARQUEED = 0x2000 + STATE_SYSTEM_ANIMATED = 0x4000 + STATE_SYSTEM_INVISIBLE = 0x8000 + STATE_SYSTEM_OFFSCREEN = 0x10000 + STATE_SYSTEM_SIZEABLE = 0x20000 + STATE_SYSTEM_MOVEABLE = 0x40000 + STATE_SYSTEM_SELFVOICING = 0x80000 + STATE_SYSTEM_FOCUSABLE = 0x100000 + STATE_SYSTEM_SELECTABLE = 0x200000 + STATE_SYSTEM_LINKED = 0x400000 + STATE_SYSTEM_TRAVERSED = 0x800000 + STATE_SYSTEM_MULTISELECTABLE = 0x1000000 + STATE_SYSTEM_EXTSELECTABLE = 0x2000000 + STATE_SYSTEM_ALERT_LOW = 0x4000000 + STATE_SYSTEM_ALERT_MEDIUM = 0x8000000 + STATE_SYSTEM_ALERT_HIGH = 0x10000000 + STATE_SYSTEM_PROTECTED = 0x20000000 + STATE_SYSTEM_HASPOPUP = 0x40000000 + STATE_SYSTEM_VALID = 0x7fffffff +) + +const ( + ROLE_SYSTEM_TITLEBAR = 0x1 + ROLE_SYSTEM_MENUBAR = 0x2 + ROLE_SYSTEM_SCROLLBAR = 0x3 + ROLE_SYSTEM_GRIP = 0x4 + ROLE_SYSTEM_SOUND = 0x5 + ROLE_SYSTEM_CURSOR = 0x6 + ROLE_SYSTEM_CARET = 0x7 + ROLE_SYSTEM_ALERT = 0x8 + ROLE_SYSTEM_WINDOW = 0x9 + ROLE_SYSTEM_CLIENT = 0xa + ROLE_SYSTEM_MENUPOPUP = 0xb + ROLE_SYSTEM_MENUITEM = 0xc + ROLE_SYSTEM_TOOLTIP = 0xd + ROLE_SYSTEM_APPLICATION = 0xe + ROLE_SYSTEM_DOCUMENT = 0xf + ROLE_SYSTEM_PANE = 0x10 + ROLE_SYSTEM_CHART = 0x11 + ROLE_SYSTEM_DIALOG = 0x12 + ROLE_SYSTEM_BORDER = 0x13 + ROLE_SYSTEM_GROUPING = 0x14 + ROLE_SYSTEM_SEPARATOR = 0x15 + ROLE_SYSTEM_TOOLBAR = 0x16 + ROLE_SYSTEM_STATUSBAR = 0x17 + ROLE_SYSTEM_TABLE = 0x18 + ROLE_SYSTEM_COLUMNHEADER = 0x19 + ROLE_SYSTEM_ROWHEADER = 0x1a + ROLE_SYSTEM_COLUMN = 0x1b + ROLE_SYSTEM_ROW = 0x1c + ROLE_SYSTEM_CELL = 0x1d + ROLE_SYSTEM_LINK = 0x1e + ROLE_SYSTEM_HELPBALLOON = 0x1f + ROLE_SYSTEM_CHARACTER = 0x20 + ROLE_SYSTEM_LIST = 0x21 + ROLE_SYSTEM_LISTITEM = 0x22 + ROLE_SYSTEM_OUTLINE = 0x23 + ROLE_SYSTEM_OUTLINEITEM = 0x24 + ROLE_SYSTEM_PAGETAB = 0x25 + ROLE_SYSTEM_PROPERTYPAGE = 0x26 + ROLE_SYSTEM_INDICATOR = 0x27 + ROLE_SYSTEM_GRAPHIC = 0x28 + ROLE_SYSTEM_STATICTEXT = 0x29 + ROLE_SYSTEM_TEXT = 0x2a + ROLE_SYSTEM_PUSHBUTTON = 0x2b + ROLE_SYSTEM_CHECKBUTTON = 0x2c + ROLE_SYSTEM_RADIOBUTTON = 0x2d + ROLE_SYSTEM_COMBOBOX = 0x2e + ROLE_SYSTEM_DROPLIST = 0x2f + ROLE_SYSTEM_PROGRESSBAR = 0x30 + ROLE_SYSTEM_DIAL = 0x31 + ROLE_SYSTEM_HOTKEYFIELD = 0x32 + ROLE_SYSTEM_SLIDER = 0x33 + ROLE_SYSTEM_SPINBUTTON = 0x34 + ROLE_SYSTEM_DIAGRAM = 0x35 + ROLE_SYSTEM_ANIMATION = 0x36 + ROLE_SYSTEM_EQUATION = 0x37 + ROLE_SYSTEM_BUTTONDROPDOWN = 0x38 + ROLE_SYSTEM_BUTTONMENU = 0x39 + ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x3a + ROLE_SYSTEM_WHITESPACE = 0x3b + ROLE_SYSTEM_PAGETABLIST = 0x3c + ROLE_SYSTEM_CLOCK = 0x3d + ROLE_SYSTEM_SPLITBUTTON = 0x3e + ROLE_SYSTEM_IPADDRESS = 0x3f + ROLE_SYSTEM_OUTLINEBUTTON = 0x40 +) + +var ( + IID_IAccPropServer = IID{0x76c0dbbb, 0x15e0, 0x4e7b, [8]byte{0xb6, 0x1b, 0x20, 0xee, 0xea, 0x20, 0x01, 0xe0}} + IID_IAccPropServices = IID{0x6e26e776, 0x04f0, 0x495d, [8]byte{0x80, 0xe4, 0x33, 0x30, 0x35, 0x2e, 0x31, 0x69}} + CLSID_AccPropServices = CLSID{0xb5f8350b, 0x0548, 0x48b1, [8]byte{0xa6, 0xee, 0x88, 0xbd, 0x00, 0xb4, 0xa5, 0xe7}} +) + +type IAccPropServerVtbl struct { + QueryInterface uintptr + AddRef uintptr + Release uintptr + GetPropValue uintptr +} + +type IAccPropServer struct { + LpVtbl *IAccPropServerVtbl +} + +type IAccPropServicesVtbl struct { + QueryInterface uintptr + AddRef uintptr + Release uintptr + SetPropValue uintptr + SetPropServer uintptr + ClearProps uintptr + SetHwndProp uintptr + SetHwndPropStr uintptr + SetHwndPropServer uintptr + ClearHwndProps uintptr + ComposeHwndIdentityString uintptr + DecomposeHwndIdentityString uintptr + SetHmenuProp uintptr + SetHmenuPropStr uintptr + SetHmenuPropServer uintptr + ClearHmenuProps uintptr + ComposeHmenuIdentityString uintptr + DecomposeHmenuIdentityString uintptr +} + +type IAccPropServices struct { + LpVtbl *IAccPropServicesVtbl +} + +func (obj *IAccPropServices) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(ppvObject))) + return HRESULT(ret) +} + +func (obj *IAccPropServices) AddRef() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *IAccPropServices) Release() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. +// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer +func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { + var idStringPtr unsafe.Pointer + idStringLen := len(idString) + if idStringLen != 0 { + idStringPtr = unsafe.Pointer(&idString[0]) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(idStringPtr), + uintptr(idStringLen), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(v)), + 0) + return HRESULT(ret) +} + +// SetPropServer specifies a callback object to be used to annotate an array of properties for the accessible element. You can also specify whether the annotation is to be applied to this accessible element or to the element and its children. This method is used for server annotation. +// If server developers know the HWND of the accessible element they want to annotate, they can use SetHwndPropServer. +func (obj *IAccPropServices) SetPropServer(idString []byte, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { + var idStringPtr unsafe.Pointer + idStringLen := len(idString) + if idStringLen != 0 { + idStringPtr = unsafe.Pointer(&idString[0]) + } + var idPropsPtr unsafe.Pointer + idPropsLen := len(idProps) + if idPropsLen != 0 { + idPropsPtr = unsafe.Pointer(&idProps[0]) + } + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetPropServer, 7, + uintptr(unsafe.Pointer(obj)), + uintptr(idStringPtr), + uintptr(idStringLen), + uintptr(idPropsPtr), + uintptr(idPropsLen), + uintptr(unsafe.Pointer(server)), + uintptr(annoScope), + 0, + 0) + return HRESULT(ret) +} + +// ClearProps restores default values to properties of accessible elements that they had previously annotated. +// If servers know the HWND of the object they want to clear, they can use ClearHwndProps. +func (obj *IAccPropServices) ClearProps(idString []byte, idProps []MSAAPROPID) HRESULT { + var idStringPtr unsafe.Pointer + idStringLen := len(idString) + if idStringLen != 0 { + idStringPtr = unsafe.Pointer(&idString[0]) + } + var idPropsPtr unsafe.Pointer + idPropsLen := len(idProps) + if idPropsLen != 0 { + idPropsPtr = unsafe.Pointer(&idProps[0]) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearProps, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(idStringPtr), + uintptr(idStringLen), + uintptr(idPropsPtr), + uintptr(idPropsLen), + 0) + return HRESULT(ret) +} + +// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead. +func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndProp, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(v))) + return HRESULT(ret) +} + +// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. +func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndPropStr, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(str16))) + return HRESULT(ret) +} + +// SetHwndPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HWND-based accessible elements. +func (obj *IAccPropServices) SetHwndPropServer(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { + var idPropsPtr unsafe.Pointer + idPropsLen := len(idProps) + if idPropsLen != 0 { + idPropsPtr = unsafe.Pointer(&idProps[0]) + } + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropServer, 8, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(idPropsPtr), + uintptr(idPropsLen), + uintptr(unsafe.Pointer(server)), + uintptr(annoScope), + 0) + return HRESULT(ret) +} + +// ClearHwndProps wraps SetPropValue, SetPropServer, and ClearProps, and provides a convenient entry point for callers who are annotating HWND-based accessible elements. +func (obj *IAccPropServices) ClearHwndProps(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID) HRESULT { + var idPropsPtr unsafe.Pointer + idPropsLen := len(idProps) + if idPropsLen != 0 { + idPropsPtr = unsafe.Pointer(&idProps[0]) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHwndProps, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(idPropsPtr), + uintptr(idPropsLen)) + return HRESULT(ret) +} + +// ComposeHwndIdentityString retrievs an identity string. +func (obj *IAccPropServices) ComposeHwndIdentityString(hwnd HWND, idObject int32, idChild uint32) (hr HRESULT, idString []byte) { + var data *[1<<31 - 1]byte + var len uint32 + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHwndIdentityString, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(&data)), + uintptr(unsafe.Pointer(&len))) + hr = HRESULT(ret) + if FAILED(hr) { + return + } + defer CoTaskMemFree(uintptr(unsafe.Pointer(data))) + idString = make([]byte, len) + copy(idString, data[:len]) + return +} + +// DecomposeHwndIdentityString determines the HWND, object ID, and child ID for the accessible element identified by the identity string. +func (obj *IAccPropServices) DecomposeHwndIdentityString(idString []byte) (hr HRESULT, hwnd HWND, idObject int32, idChild uint32) { + var idStringPtr unsafe.Pointer + idStringLen := len(idString) + if idStringLen != 0 { + idStringPtr = unsafe.Pointer(&idString[0]) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHwndIdentityString, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(idStringPtr), + uintptr(idStringLen), + uintptr(unsafe.Pointer(&hwnd)), + uintptr(unsafe.Pointer(&idObject)), + uintptr(unsafe.Pointer(&idChild))) + hr = HRESULT(ret) + return +} + +// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead. +func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(v)), + 0) + return HRESULT(ret) +} + +// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. +func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(str16)), + 0) + return HRESULT(ret) +} + +// SetHmenuPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. +func (obj *IAccPropServices) SetHmenuPropServer(hmenu HMENU, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { + var idPropsPtr unsafe.Pointer + idPropsLen := len(idProps) + if idPropsLen != 0 { + idPropsPtr = unsafe.Pointer(&idProps[0]) + } + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuPropServer, 7, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(idPropsPtr), + uintptr(idPropsLen), + uintptr(unsafe.Pointer(server)), + uintptr(annoScope), + 0, + 0) + return HRESULT(ret) +} + +// ClearHmenuProps wraps ClearProps, and provides a convenient entry point for callers who are annotating HMENU-based accessible elements. +func (obj *IAccPropServices) ClearHmenuProps(hmenu HMENU, idChild uint32, idProps []MSAAPROPID) HRESULT { + var idPropsPtr unsafe.Pointer + idPropsLen := len(idProps) + if idPropsLen != 0 { + idPropsPtr = unsafe.Pointer(&idProps[0]) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHmenuProps, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(idPropsPtr), + uintptr(idPropsLen), + 0) + return HRESULT(ret) +} + +// ComposeHmenuIdentityString retrieves an identity string for an HMENU-based accessible element. +func (obj *IAccPropServices) ComposeHmenuIdentityString(hmenu HMENU, idChild uint32) (hr HRESULT, idString []byte) { + var data *[1<<31 - 1]byte + var len uint32 + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHmenuIdentityString, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(&data)), + uintptr(unsafe.Pointer(&len)), + 0) + hr = HRESULT(ret) + if FAILED(hr) { + return + } + defer CoTaskMemFree(uintptr(unsafe.Pointer(data))) + idString = make([]byte, len) + copy(idString, data[:len]) + return +} + +// DecomposeHmenuIdentityString determines the HMENU, object ID, and child ID for the accessible element identified by the identity string. +func (obj *IAccPropServices) DecomposeHmenuIdentityString(idString []byte) (hr HRESULT, hmenu HMENU, idChild uint32) { + var idStringPtr unsafe.Pointer + idStringLen := len(idString) + if idStringLen != 0 { + idStringPtr = unsafe.Pointer(&idString[0]) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHmenuIdentityString, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(idStringPtr), + uintptr(idStringLen), + uintptr(unsafe.Pointer(&hmenu)), + uintptr(unsafe.Pointer(&idChild)), + 0) + hr = HRESULT(ret) + return +} From 24c5960b03d885e4fb67113029e0afe2e0d23db0 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 19 Sep 2019 11:06:05 +0200 Subject: [PATCH 122/138] Add PROGRESS theme part and state constants --- uxtheme.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/uxtheme.go b/uxtheme.go index a7c43b0a..1f24cac9 100644 --- a/uxtheme.go +++ b/uxtheme.go @@ -357,6 +357,38 @@ const ( LISS_HOTSELECTED = 6 ) +// PROGRESS parts +const ( + PP_BAR = 1 + PP_BARVERT = 2 + PP_CHUNK = 3 + PP_CHUNKVERT = 4 + PP_FILL = 5 + PP_FILLVERT = 6 + PP_PULSEOVERLAY = 7 + PP_MOVEOVERLAY = 8 + PP_PULSEOVERLAYVERT = 9 + PP_MOVEOVERLAYVERT = 10 + PP_TRANSPARENTBAR = 11 + PP_TRANSPARENTBARVERT = 12 +) + +// PP_FILL states +const ( + PBFS_NORMAL = 1 + PBFS_ERROR = 2 + PBFS_PAUSED = 3 + PBFS_PARTIAL = 4 +) + +// PP_FILLVERT states +const ( + PBFVS_NORMAL = 1 + PBFVS_ERROR = 2 + PBFVS_PAUSED = 3 + PBFVS_PARTIAL = 4 +) + // TAB parts const ( TABP_TABITEM = 1 From c5100a61d29c9ea1c935d3dae5d963e5b9f2cb57 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 24 Oct 2019 11:16:55 +0200 Subject: [PATCH 123/138] oleacc: pass structs on stack for 32-bit calling convention The original author of this code never tested it. Fixes #95 --- oleacc.go | 74 ------------------------------------ oleacc_386.go | 99 +++++++++++++++++++++++++++++++++++++++++++++++++ oleacc_amd64.go | 88 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+), 74 deletions(-) create mode 100644 oleacc_386.go create mode 100644 oleacc_amd64.go diff --git a/oleacc.go b/oleacc.go index 7c5f8662..4891cc16 100644 --- a/oleacc.go +++ b/oleacc.go @@ -218,24 +218,6 @@ func (obj *IAccPropServices) Release() uint32 { return uint32(ret) } -// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. -// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer -func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { - var idStringPtr unsafe.Pointer - idStringLen := len(idString) - if idStringLen != 0 { - idStringPtr = unsafe.Pointer(&idString[0]) - } - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(idStringPtr), - uintptr(idStringLen), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(v)), - 0) - return HRESULT(ret) -} - // SetPropServer specifies a callback object to be used to annotate an array of properties for the accessible element. You can also specify whether the annotation is to be applied to this accessible element or to the element and its children. This method is used for server annotation. // If server developers know the HWND of the accessible element they want to annotate, they can use SetHwndPropServer. func (obj *IAccPropServices) SetPropServer(idString []byte, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { @@ -285,34 +267,6 @@ func (obj *IAccPropServices) ClearProps(idString []byte, idProps []MSAAPROPID) H return HRESULT(ret) } -// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead. -func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndProp, 6, - uintptr(unsafe.Pointer(obj)), - uintptr(hwnd), - uintptr(idObject), - uintptr(idChild), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(v))) - return HRESULT(ret) -} - -// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. -func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { - str16, err := syscall.UTF16PtrFromString(str) - if err != nil { - return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) - } - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndPropStr, 6, - uintptr(unsafe.Pointer(obj)), - uintptr(hwnd), - uintptr(idObject), - uintptr(idChild), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(str16))) - return HRESULT(ret) -} - // SetHwndPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HWND-based accessible elements. func (obj *IAccPropServices) SetHwndPropServer(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { var idPropsPtr unsafe.Pointer @@ -389,34 +343,6 @@ func (obj *IAccPropServices) DecomposeHwndIdentityString(idString []byte) (hr HR return } -// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead. -func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(hmenu), - uintptr(idChild), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(v)), - 0) - return HRESULT(ret) -} - -// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. -func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { - str16, err := syscall.UTF16PtrFromString(str) - if err != nil { - return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) - } - ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 5, - uintptr(unsafe.Pointer(obj)), - uintptr(hmenu), - uintptr(idChild), - uintptr(unsafe.Pointer(idProp)), - uintptr(unsafe.Pointer(str16)), - 0) - return HRESULT(ret) -} - // SetHmenuPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. func (obj *IAccPropServices) SetHmenuPropServer(hmenu HMENU, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { var idPropsPtr unsafe.Pointer diff --git a/oleacc_386.go b/oleacc_386.go new file mode 100644 index 00000000..d3164c18 --- /dev/null +++ b/oleacc_386.go @@ -0,0 +1,99 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +func (idProp *MSAAPROPID) split() (uintptr, uintptr, uintptr, uintptr) { + if idProp == nil { + return 0, 0, 0, 0 + } + x := (*struct { a, b, c, d uintptr })(unsafe.Pointer(idProp)) + return x.a, x.b, x.c, x.d +} + +// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. +// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer +func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { + var idStringPtr unsafe.Pointer + idStringLen := len(idString) + if idStringLen != 0 { + idStringPtr = unsafe.Pointer(&idString[0]) + } + propA, propB, propC, propD := idProp.split() + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetPropValue, 8, + uintptr(unsafe.Pointer(obj)), + uintptr(idStringPtr), + uintptr(idStringLen), + propA, propB, propC, propD, + uintptr(unsafe.Pointer(v)), + 0) + return HRESULT(ret) +} + +// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead. +func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + propA, propB, propC, propD := idProp.split() + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndProp, 9, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + propA, propB, propC, propD, + uintptr(unsafe.Pointer(v))) + return HRESULT(ret) +} + +// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. +func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) + } + propA, propB, propC, propD := idProp.split() + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropStr, 9, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + propA, propB, propC, propD, + uintptr(unsafe.Pointer(str16))) + return HRESULT(ret) +} + +// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead. +func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + propA, propB, propC, propD := idProp.split() + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuProp, 8, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + propA, propB, propC, propD, + uintptr(unsafe.Pointer(v)), + 0) + return HRESULT(ret) +} + +// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. +func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) + } + propA, propB, propC, propD := idProp.split() + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuPropStr, 8, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + propA, propB, propC, propD, + uintptr(unsafe.Pointer(str16)), + 0) + return HRESULT(ret) +} diff --git a/oleacc_amd64.go b/oleacc_amd64.go new file mode 100644 index 00000000..b88858b4 --- /dev/null +++ b/oleacc_amd64.go @@ -0,0 +1,88 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. +// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer +func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { + var idStringPtr unsafe.Pointer + idStringLen := len(idString) + if idStringLen != 0 { + idStringPtr = unsafe.Pointer(&idString[0]) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(idStringPtr), + uintptr(idStringLen), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(v)), + 0) + return HRESULT(ret) +} + +// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead. +func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndProp, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(v))) + return HRESULT(ret) +} + +// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. +func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) + } + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropStr, 7, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + 0, + uintptr(unsafe.Pointer(str16)), + 0, 0) + return HRESULT(ret) +} + +// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead. +func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(v)), + 0) + return HRESULT(ret) +} + +// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. +func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) + } + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 5, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + uintptr(unsafe.Pointer(idProp)), + uintptr(unsafe.Pointer(str16)), + 0) + return HRESULT(ret) +} From d61b1af716ca73eb65476490279a86365096b9af Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 24 Oct 2019 12:53:42 +0200 Subject: [PATCH 124/138] oleacc: fix debug leftover mess cruft Sorry. --- oleacc_amd64.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/oleacc_amd64.go b/oleacc_amd64.go index b88858b4..8bea12af 100644 --- a/oleacc_amd64.go +++ b/oleacc_amd64.go @@ -47,15 +47,13 @@ func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild u if err != nil { return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) } - ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropStr, 7, + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndPropStr, 6, uintptr(unsafe.Pointer(obj)), uintptr(hwnd), uintptr(idObject), uintptr(idChild), uintptr(unsafe.Pointer(idProp)), - 0, - uintptr(unsafe.Pointer(str16)), - 0, 0) + uintptr(unsafe.Pointer(str16))) return HRESULT(ret) } From 121afc750dd37aacd66aa4744b403f7b0b97e37c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 6 Nov 2019 13:38:02 +0100 Subject: [PATCH 125/138] Add ImageList_DrawEx and related constants --- comctl32.go | 33 +++++++++++++++++++++++++++++++++ gdi32.go | 6 +++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/comctl32.go b/comctl32.go index 28b37939..144affa7 100644 --- a/comctl32.go +++ b/comctl32.go @@ -162,6 +162,19 @@ const ( ILC_PERITEMMIRROR = 0x00008000 ) +// ImageList_Draw[Ex] flags +const ( + ILD_NORMAL = 0x00000000 + ILD_TRANSPARENT = 0x00000001 + ILD_BLEND25 = 0x00000002 + ILD_BLEND50 = 0x00000004 + ILD_MASK = 0x00000010 + ILD_IMAGE = 0x00000020 + ILD_SELECTED = ILD_BLEND50 + ILD_FOCUS = ILD_BLEND25 + ILD_BLEND = ILD_BLEND50 +) + // LoadIconMetric flags const ( LIM_SMALL = 0 @@ -248,6 +261,7 @@ var ( imageList_AddMasked *windows.LazyProc imageList_Create *windows.LazyProc imageList_Destroy *windows.LazyProc + imageList_DrawEx *windows.LazyProc imageList_ReplaceIcon *windows.LazyProc initCommonControlsEx *windows.LazyProc loadIconMetric *windows.LazyProc @@ -263,6 +277,7 @@ func init() { imageList_AddMasked = libcomctl32.NewProc("ImageList_AddMasked") imageList_Create = libcomctl32.NewProc("ImageList_Create") imageList_Destroy = libcomctl32.NewProc("ImageList_Destroy") + imageList_DrawEx = libcomctl32.NewProc("ImageList_DrawEx") imageList_ReplaceIcon = libcomctl32.NewProc("ImageList_ReplaceIcon") initCommonControlsEx = libcomctl32.NewProc("InitCommonControlsEx") loadIconMetric = libcomctl32.NewProc("LoadIconMetric") @@ -308,6 +323,24 @@ func ImageList_Destroy(hIml HIMAGELIST) bool { return ret != 0 } +func ImageList_DrawEx(himl HIMAGELIST, i int32, hdcDst HDC, x, y, dx, dy int32, rgbBk COLORREF, rgbFg COLORREF, fStyle uint32) bool { + ret, _, _ := syscall.Syscall12(imageList_DrawEx.Addr(), 10, + uintptr(himl), + uintptr(i), + uintptr(hdcDst), + uintptr(x), + uintptr(y), + uintptr(dx), + uintptr(dy), + uintptr(rgbBk), + uintptr(rgbFg), + uintptr(fStyle), + 0, + 0) + + return ret != 0 +} + func ImageList_ReplaceIcon(himl HIMAGELIST, i int32, hicon HICON) int32 { ret, _, _ := syscall.Syscall(imageList_ReplaceIcon.Addr(), 3, uintptr(himl), diff --git a/gdi32.go b/gdi32.go index a6e3fac0..ba8dd91d 100644 --- a/gdi32.go +++ b/gdi32.go @@ -692,7 +692,11 @@ const ( const CBM_INIT = 4 -const CLR_INVALID = 0xFFFFFFFF +const ( + CLR_INVALID = 0xFFFFFFFF + CLR_NONE = CLR_INVALID + CLR_DEFAULT = 0xFF000000 +) const ( /* pixel types */ From 2e40b13bacd88bdc6669b1e9cedbbb8b20d6191e Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 28 Nov 2019 11:58:21 +0100 Subject: [PATCH 126/138] Add tool bar metrics stuff --- toolbar.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/toolbar.go b/toolbar.go index 80f0b0a4..74efe94c 100644 --- a/toolbar.go +++ b/toolbar.go @@ -89,6 +89,7 @@ const ( TB_MAPACCELERATOR = WM_USER + 90 TB_GETSTRING = WM_USER + 91 TB_GETIDEALSIZE = WM_USER + 99 + TB_GETMETRICS = WM_USER + 101 TB_SETCOLORSCHEME = CCM_SETCOLORSCHEME TB_GETCOLORSCHEME = CCM_GETCOLORSCHEME TB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT @@ -174,6 +175,13 @@ const ( TBIF_BYINDEX = 0x80000000 ) +// TBMETRICS mask flags +const ( + TBMF_PAD = 0x00000001 + TBMF_BARPAD = 0x00000002 + TBMF_BUTTONSPACING = 0x00000004 +) + type NMMOUSE struct { Hdr NMHDR DwItemSpec uintptr @@ -217,3 +225,14 @@ type TBBUTTONINFO struct { PszText uintptr CchText int32 } + +type TBMETRICS struct { + CbSize uint32 + DwMask uint32 + CxPad int32 + CyPad int32 + CxBarPad int32 + CyBarPad int32 + CxButtonSpacing int32 + CyButtonSpacing int32 +} From 2da648fda5b433b3d074415cf2c1b05038194fa0 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 28 Nov 2019 11:58:42 +0100 Subject: [PATCH 127/138] Add HDHITTESTINFO --- header.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/header.go b/header.go index 7f675052..4edff2b1 100644 --- a/header.go +++ b/header.go @@ -29,6 +29,12 @@ type HDLAYOUT struct { Pwpos *WINDOWPOS } +type HDHITTESTINFO struct { + Pt POINT + Flags uint32 + IItem int32 +} + const ( HDI_WIDTH = 0x0001 HDI_HEIGHT = HDI_WIDTH From 43e9f18404d075f24cf4899d0fa0d8a5be74d214 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 19 Oct 2020 10:10:17 -0700 Subject: [PATCH 128/138] Fix Go 1.15 checkptr failure; use golang.org/x/sys/windows.UTF16PtrToString The UTF16PtrToString version in golang.org/x/sys/windows doesn't make slices pointing past the end of an allocation. Use it instead. This lets programs using lxn/win and built with Go's race detector get a bit further. Other race/checkptr issues with lxn/win and lxn/walk remain for subsequent changes. Signed-off-by: Brad Fitzpatrick --- AUTHORS | 6 +++--- go.mod | 2 +- win.go | 8 +++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/AUTHORS b/AUTHORS index ccc26294..3b767637 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,11 +13,14 @@ Alexander Neumann Aman Gupta Anton Lahti Benny Siegert +Brad Fitzpatrick Bruno Bigras Carl Kittelberger Carlos Cobo Cary Cherng +Cory Redmond David Porter +Dmitry Bagdanov gonutz Hill Jason A. Donenfeld @@ -29,6 +32,3 @@ ryujimiya Simon Rozman Tiago Carvalho wsf01 -gonutz -Cory Redmond -Dmitry Bagdanov diff --git a/go.mod b/go.mod index bda1929e..c765df89 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/lxn/win go 1.12 -require golang.org/x/sys v0.0.0-20190904154756-749cb33beabd +require golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13 diff --git a/win.go b/win.go index 43d07462..b8f00cd6 100644 --- a/win.go +++ b/win.go @@ -7,8 +7,9 @@ package win import ( - "syscall" "unsafe" + + "golang.org/x/sys/windows" ) const ( @@ -70,10 +71,7 @@ func HIWORD(dw uint32) uint16 { } func UTF16PtrToString(s *uint16) string { - if s == nil { - return "" - } - return syscall.UTF16ToString((*[1 << 29]uint16)(unsafe.Pointer(s))[0:]) + return windows.UTF16PtrToString(s) } func MAKEINTRESOURCE(id uintptr) *uint16 { From 2097c612486684fec410701f5b4d16720515c8ef Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 10 Oct 2020 08:58:47 +0200 Subject: [PATCH 129/138] Copy 386 to arm GOARCH 1. Golang doesn/t support windows/arm64 yet. 2. The 32-bit ARM Go binaries appears to compile and work on Windows 10 for ARM64 devices 3. 32-bit ARM binaries execute faster vs. x86 on ARM64, as they run native vs. over emulation layer. This commit duplicates 386 to arm code to make compiling windows/arm binaries possible. Testing so far, the 386 and ARMv7 structs proved compatible. Signed-off-by: Simon Rozman --- oleacc_386.go => oleacc_32.go | 2 +- oleacc_amd64.go => oleacc_64.go | 2 +- oleaut32_386.go => oleaut32_32.go | 2 +- oleaut32_amd64.go => oleaut32_64.go | 2 +- shobj_386.go => shobj_32.go | 2 +- shobj_amd64.go => shobj_64.go | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename oleacc_386.go => oleacc_32.go (99%) rename oleacc_amd64.go => oleacc_64.go (99%) rename oleaut32_386.go => oleaut32_32.go (97%) rename oleaut32_amd64.go => oleaut32_64.go (98%) rename shobj_386.go => shobj_32.go (93%) rename shobj_amd64.go => shobj_64.go (95%) diff --git a/oleacc_386.go b/oleacc_32.go similarity index 99% rename from oleacc_386.go rename to oleacc_32.go index d3164c18..be12e107 100644 --- a/oleacc_386.go +++ b/oleacc_32.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build windows +// +build windows,386 windows,arm package win diff --git a/oleacc_amd64.go b/oleacc_64.go similarity index 99% rename from oleacc_amd64.go rename to oleacc_64.go index 8bea12af..1a210b01 100644 --- a/oleacc_amd64.go +++ b/oleacc_64.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build windows +// +build windows,amd64 package win diff --git a/oleaut32_386.go b/oleaut32_32.go similarity index 97% rename from oleaut32_386.go rename to oleaut32_32.go index 5f3ce1f1..3c2cc3da 100644 --- a/oleaut32_386.go +++ b/oleaut32_32.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build windows +// +build windows,386 windows,arm package win diff --git a/oleaut32_amd64.go b/oleaut32_64.go similarity index 98% rename from oleaut32_amd64.go rename to oleaut32_64.go index 331a5504..20bc7cb9 100644 --- a/oleaut32_amd64.go +++ b/oleaut32_64.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build windows +// +build windows,amd64 package win diff --git a/shobj_386.go b/shobj_32.go similarity index 93% rename from shobj_386.go rename to shobj_32.go index 5e028a36..a5a5c289 100644 --- a/shobj_386.go +++ b/shobj_32.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build windows +// +build windows,386 windows,arm package win diff --git a/shobj_amd64.go b/shobj_64.go similarity index 95% rename from shobj_amd64.go rename to shobj_64.go index 312fa21e..60978d75 100644 --- a/shobj_amd64.go +++ b/shobj_64.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build windows +// +build windows,amd64 package win From 5e58350a59667fade08f183762455eabdc7a01c2 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 12 Oct 2020 10:24:10 +0200 Subject: [PATCH 130/138] Add WM_UNICHAR constant Signed-off-by: Simon Rozman --- user32.go | 1 + 1 file changed, 1 insertion(+) diff --git a/user32.go b/user32.go index 478813db..5be421cc 100644 --- a/user32.go +++ b/user32.go @@ -887,6 +887,7 @@ const ( WM_MOUSEHOVER = 0X2A1 WM_MOUSELEAVE = 0X2A3 WM_CLIPBOARDUPDATE = 0x031D + WM_UNICHAR = 0x0109 ) const ( From d3deed4aa2b50c7688137e5fb1da1c274572274b Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 12 Oct 2020 10:24:54 +0200 Subject: [PATCH 131/138] Add Richedit.h constants and message parameter structs Signed-off-by: Simon Rozman --- richedit.go | 656 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 656 insertions(+) create mode 100644 richedit.go diff --git a/richedit.go b/richedit.go new file mode 100644 index 00000000..947247f0 --- /dev/null +++ b/richedit.go @@ -0,0 +1,656 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +const ( + // NOTE: MSFTEDIT.DLL only registers MSFTEDIT_CLASS. If an application wants + // to use the following RichEdit classes, it needs to load riched20.dll. + // Otherwise, CreateWindow with RICHEDIT_CLASS will fail. + // This also applies to any dialog that uses RICHEDIT_CLASS + // RichEdit 2.0 Window Class + MSFTEDIT_CLASS = "RICHEDIT50W" + RICHEDIT_CLASS = "RichEdit20W" +) + +// RichEdit messages +const ( + EM_CANPASTE = WM_USER + 50 + EM_DISPLAYBAND = WM_USER + 51 + EM_EXGETSEL = WM_USER + 52 + EM_EXLIMITTEXT = WM_USER + 53 + EM_EXLINEFROMCHAR = WM_USER + 54 + EM_EXSETSEL = WM_USER + 55 + EM_FINDTEXT = WM_USER + 56 + EM_FORMATRANGE = WM_USER + 57 + EM_GETCHARFORMAT = WM_USER + 58 + EM_GETEVENTMASK = WM_USER + 59 + EM_GETOLEINTERFACE = WM_USER + 60 + EM_GETPARAFORMAT = WM_USER + 61 + EM_GETSELTEXT = WM_USER + 62 + EM_HIDESELECTION = WM_USER + 63 + EM_PASTESPECIAL = WM_USER + 64 + EM_REQUESTRESIZE = WM_USER + 65 + EM_SELECTIONTYPE = WM_USER + 66 + EM_SETBKGNDCOLOR = WM_USER + 67 + EM_SETCHARFORMAT = WM_USER + 68 + EM_SETEVENTMASK = WM_USER + 69 + EM_SETOLECALLBACK = WM_USER + 70 + EM_SETPARAFORMAT = WM_USER + 71 + EM_SETTARGETDEVICE = WM_USER + 72 + EM_STREAMIN = WM_USER + 73 + EM_STREAMOUT = WM_USER + 74 + EM_GETTEXTRANGE = WM_USER + 75 + EM_FINDWORDBREAK = WM_USER + 76 + EM_SETOPTIONS = WM_USER + 77 + EM_GETOPTIONS = WM_USER + 78 + EM_FINDTEXTEX = WM_USER + 79 + EM_GETWORDBREAKPROCEX = WM_USER + 80 + EM_SETWORDBREAKPROCEX = WM_USER + 81 +) + +// RichEdit 2.0 messages +const ( + EM_SETUNDOLIMIT = WM_USER + 82 + EM_REDO = WM_USER + 84 + EM_CANREDO = WM_USER + 85 + EM_GETUNDONAME = WM_USER + 86 + EM_GETREDONAME = WM_USER + 87 + EM_STOPGROUPTYPING = WM_USER + 88 + + EM_SETTEXTMODE = WM_USER + 89 + EM_GETTEXTMODE = WM_USER + 90 +) + +type TEXTMODE int + +const ( + TM_PLAINTEXT TEXTMODE = 1 + TM_RICHTEXT TEXTMODE = 2 // Default behavior + TM_SINGLELEVELUNDO TEXTMODE = 4 + TM_MULTILEVELUNDO TEXTMODE = 8 // Default behavior + TM_SINGLECODEPAGE TEXTMODE = 16 + TM_MULTICODEPAGE TEXTMODE = 32 // Default behavior +) + +const ( + EM_AUTOURLDETECT = WM_USER + 91 +) + +// RichEdit 8.0 messages +const ( + AURL_ENABLEURL = 1 + AURL_ENABLEEMAILADDR = 2 + AURL_ENABLETELNO = 4 + AURL_ENABLEEAURLS = 8 + AURL_ENABLEDRIVELETTERS = 16 + AURL_DISABLEMIXEDLGC = 32 // Disable mixed Latin Greek Cyrillic IDNs +) + +const ( + EM_GETAUTOURLDETECT = WM_USER + 92 + EM_SETPALETTE = WM_USER + 93 + EM_GETTEXTEX = WM_USER + 94 + EM_GETTEXTLENGTHEX = WM_USER + 95 + EM_SHOWSCROLLBAR = WM_USER + 96 + EM_SETTEXTEX = WM_USER + 97 +) + +// East Asia specific messages +const ( + EM_SETPUNCTUATION = WM_USER + 100 + EM_GETPUNCTUATION = WM_USER + 101 + EM_SETWORDWRAPMODE = WM_USER + 102 + EM_GETWORDWRAPMODE = WM_USER + 103 + EM_SETIMECOLOR = WM_USER + 104 + EM_GETIMECOLOR = WM_USER + 105 + EM_SETIMEOPTIONS = WM_USER + 106 + EM_GETIMEOPTIONS = WM_USER + 107 + EM_CONVPOSITION = WM_USER + 108 +) + +const ( + EM_SETLANGOPTIONS = WM_USER + 120 + EM_GETLANGOPTIONS = WM_USER + 121 + EM_GETIMECOMPMODE = WM_USER + 122 + + EM_FINDTEXTW = WM_USER + 123 + EM_FINDTEXTEXW = WM_USER + 124 +) + +// RE3.0 FE messages +const ( + EM_RECONVERSION = WM_USER + 125 + EM_SETIMEMODEBIAS = WM_USER + 126 + EM_GETIMEMODEBIAS = WM_USER + 127 +) + +// BiDi specific messages +const ( + EM_SETBIDIOPTIONS = WM_USER + 200 + EM_GETBIDIOPTIONS = WM_USER + 201 + + EM_SETTYPOGRAPHYOPTIONS = WM_USER + 202 + EM_GETTYPOGRAPHYOPTIONS = WM_USER + 203 +) + +// Extended edit style specific messages +const ( + EM_SETEDITSTYLE = WM_USER + 204 + EM_GETEDITSTYLE = WM_USER + 205 +) + +// Extended edit style masks +const ( + SES_EMULATESYSEDIT = 1 + SES_BEEPONMAXTEXT = 2 + SES_EXTENDBACKCOLOR = 4 + SES_MAPCPS = 8 // Obsolete (never used) + SES_HYPERLINKTOOLTIPS = 8 + SES_EMULATE10 = 16 // Obsolete (never used) + SES_DEFAULTLATINLIGA = 16 + SES_USECRLF = 32 // Obsolete (never used) + SES_NOFOCUSLINKNOTIFY = 32 + SES_USEAIMM = 64 + SES_NOIME = 128 + + SES_ALLOWBEEPS = 256 + SES_UPPERCASE = 512 + SES_LOWERCASE = 1024 + SES_NOINPUTSEQUENCECHK = 2048 + SES_BIDI = 4096 + SES_SCROLLONKILLFOCUS = 8192 + SES_XLTCRCRLFTOCR = 16384 + SES_DRAFTMODE = 32768 + + SES_USECTF = 0x00010000 + SES_HIDEGRIDLINES = 0x00020000 + SES_USEATFONT = 0x00040000 + SES_CUSTOMLOOK = 0x00080000 + SES_LBSCROLLNOTIFY = 0x00100000 + SES_CTFALLOWEMBED = 0x00200000 + SES_CTFALLOWSMARTTAG = 0x00400000 + SES_CTFALLOWPROOFING = 0x00800000 + SES_LOGICALCARET = 0x01000000 + SES_WORDDRAGDROP = 0x02000000 + SES_SMARTDRAGDROP = 0x04000000 + SES_MULTISELECT = 0x08000000 + SES_CTFNOLOCK = 0x10000000 + SES_NOEALINEHEIGHTADJUST = 0x20000000 + SES_MAX = 0x20000000 +) + +// Options for EM_SETLANGOPTIONS and EM_GETLANGOPTIONS +const ( + IMF_AUTOKEYBOARD = 0x0001 + IMF_AUTOFONT = 0x0002 + IMF_IMECANCELCOMPLETE = 0x0004 // High completes comp string when aborting, low cancels + IMF_IMEALWAYSSENDNOTIFY = 0x0008 + IMF_AUTOFONTSIZEADJUST = 0x0010 + IMF_UIFONTS = 0x0020 + IMF_NOIMPLICITLANG = 0x0040 + IMF_DUALFONT = 0x0080 + IMF_NOKBDLIDFIXUP = 0x0200 + IMF_NORTFFONTSUBSTITUTE = 0x0400 + IMF_SPELLCHECKING = 0x0800 + IMF_TKBPREDICTION = 0x1000 + IMF_IMEUIINTEGRATION = 0x2000 +) + +// Values for EM_GETIMECOMPMODE +const ( + ICM_NOTOPEN = 0x0000 + ICM_LEVEL3 = 0x0001 + ICM_LEVEL2 = 0x0002 + ICM_LEVEL2_5 = 0x0003 + ICM_LEVEL2_SUI = 0x0004 + ICM_CTF = 0x0005 +) + +// Options for EM_SETTYPOGRAPHYOPTIONS +const ( + TO_ADVANCEDTYPOGRAPHY = 0x0001 + TO_SIMPLELINEBREAK = 0x0002 + TO_DISABLECUSTOMTEXTOUT = 0x0004 + TO_ADVANCEDLAYOUT = 0x0008 +) + +// Pegasus outline mode messages (RE 3.0) +const ( + // Outline mode message + EM_OUTLINE = WM_USER + 220 + + // Message for getting and restoring scroll pos + EM_GETSCROLLPOS = WM_USER + 221 + EM_SETSCROLLPOS = WM_USER + 222 + + // Change fontsize in current selection by wParam + EM_SETFONTSIZE = WM_USER + 223 + EM_GETZOOM = WM_USER + 224 + EM_SETZOOM = WM_USER + 225 + EM_GETVIEWKIND = WM_USER + 226 + EM_SETVIEWKIND = WM_USER + 227 +) + +// RichEdit 4.0 messages +const ( + EM_GETPAGE = WM_USER + 228 + EM_SETPAGE = WM_USER + 229 + EM_GETHYPHENATEINFO = WM_USER + 230 + EM_SETHYPHENATEINFO = WM_USER + 231 + + EM_GETPAGEROTATE = WM_USER + 235 + EM_SETPAGEROTATE = WM_USER + 236 + EM_GETCTFMODEBIAS = WM_USER + 237 + EM_SETCTFMODEBIAS = WM_USER + 238 + EM_GETCTFOPENSTATUS = WM_USER + 240 + EM_SETCTFOPENSTATUS = WM_USER + 241 + EM_GETIMECOMPTEXT = WM_USER + 242 + EM_ISIME = WM_USER + 243 + EM_GETIMEPROPERTY = WM_USER + 244 +) + +// These messages control what rich edit does when it comes accross +// OLE objects during RTF stream in. Normally rich edit queries the client +// application only after OleLoad has been called. With these messages it is possible to +// set the rich edit control to a mode where it will query the client application before +// OleLoad is called +const ( + EM_GETQUERYRTFOBJ = WM_USER + 269 + EM_SETQUERYRTFOBJ = WM_USER + 270 +) + +// EM_SETPAGEROTATE wparam values +const ( + EPR_0 = 0 // Text flows left to right and top to bottom + EPR_270 = 1 // Text flows top to bottom and right to left + EPR_180 = 2 // Text flows right to left and bottom to top + EPR_90 = 3 // Text flows bottom to top and left to right + EPR_SE = 5 // Text flows top to bottom and left to right (Mongolian text layout) +) + +// EM_SETCTFMODEBIAS wparam values +const ( + CTFMODEBIAS_DEFAULT = 0x0000 + CTFMODEBIAS_FILENAME = 0x0001 + CTFMODEBIAS_NAME = 0x0002 + CTFMODEBIAS_READING = 0x0003 + CTFMODEBIAS_DATETIME = 0x0004 + CTFMODEBIAS_CONVERSATION = 0x0005 + CTFMODEBIAS_NUMERIC = 0x0006 + CTFMODEBIAS_HIRAGANA = 0x0007 + CTFMODEBIAS_KATAKANA = 0x0008 + CTFMODEBIAS_HANGUL = 0x0009 + CTFMODEBIAS_HALFWIDTHKATAKANA = 0x000A + CTFMODEBIAS_FULLWIDTHALPHANUMERIC = 0x000B + CTFMODEBIAS_HALFWIDTHALPHANUMERIC = 0x000C +) + +// EM_SETIMEMODEBIAS lparam values +const ( + IMF_SMODE_PLAURALCLAUSE = 0x0001 + IMF_SMODE_NONE = 0x0002 +) + +// EM_GETIMECOMPTEXT wparam structure +type IMECOMPTEXT struct { + // count of bytes in the output buffer. + Cb int32 + + // value specifying the composition string type. + // Currently only support ICT_RESULTREADSTR + Flags uint32 +} + +const ICT_RESULTREADSTR = 1 + +// Outline mode wparam values +const ( + // Enter normal mode, lparam ignored + EMO_EXIT = 0 + + // Enter outline mode, lparam ignored + EMO_ENTER = 1 + + // LOWORD(lparam) == 0 ==> + // promote to body-text + // LOWORD(lparam) != 0 ==> + // promote/demote current selection + // by indicated number of levels + EMO_PROMOTE = 2 + + // HIWORD(lparam) = EMO_EXPANDSELECTION + // -> expands selection to level + // indicated in LOWORD(lparam) + // LOWORD(lparam) = -1/+1 corresponds + // to collapse/expand button presses + // in winword (other values are + // equivalent to having pressed these + // buttons more than once) + // HIWORD(lparam) = EMO_EXPANDDOCUMENT + // -> expands whole document to + // indicated level + EMO_EXPAND = 3 + + // LOWORD(lparam) != 0 -> move current + // selection up/down by indicated amount + EMO_MOVESELECTION = 4 + + // Returns VM_NORMAL or VM_OUTLINE + EMO_GETVIEWMODE = 5 +) + +// EMO_EXPAND options +const ( + EMO_EXPANDSELECTION = 0 + EMO_EXPANDDOCUMENT = 1 +) + +const ( + // Agrees with RTF \viewkindN + VM_NORMAL = 4 + + VM_OUTLINE = 2 + + // Screen page view (not print layout) + VM_PAGE = 9 +) + +// New messages as of Win8 +const ( + EM_INSERTTABLE = WM_USER + 232 +) + +// Data type defining table rows for EM_INSERTTABLE +// Note: The Richedit.h is completely #pragma pack(4)-ed +type TABLEROWPARMS struct { // EM_INSERTTABLE wparam is a (TABLEROWPARMS *) + CbRow uint32 // Count of bytes in this structure + CbCell uint32 // Count of bytes in TABLECELLPARMS + CCell uint32 // Count of cells + CRow uint32 // Count of rows + DxCellMargin int32 // Cell left/right margin (\trgaph) + DxIndent int32 // Row left (right if fRTL indent (similar to \trleft) + DyHeight int32 // Row height (\trrh) + + // nAlignment:3 Row alignment (like PARAFORMAT::bAlignment, \trql, trqr, \trqc) + // fRTL:1 Display cells in RTL order (\rtlrow) + // fKeep:1 Keep row together (\trkeep} + // fKeepFollow:1 Keep row on same page as following row (\trkeepfollow) + // fWrap:1 Wrap text to right/left (depending on bAlignment) (see \tdfrmtxtLeftN, \tdfrmtxtRightN) + // fIdentCells:1 lparam points at single struct valid for all cells + Flags uint32 + + CpStartRow int32 // cp where to insert table (-1 for selection cp) (can be used for either TRD by EM_GETTABLEPARMS) + BTableLevel uint32 // Table nesting level (EM_GETTABLEPARMS only) + ICell uint32 // Index of cell to insert/delete (EM_SETTABLEPARMS only) +} + +// Data type defining table cells for EM_INSERTTABLE +// Note: The Richedit.h is completely #pragma pack(4)-ed +type TABLECELLPARMS struct { // EM_INSERTTABLE lparam is a (TABLECELLPARMS *) + DxWidth int32 // Cell width (\cellx) + + // nVertAlign:2 Vertical alignment (0/1/2 = top/center/bottom \clvertalt (def), \clvertalc, \clvertalb) + // fMergeTop:1 Top cell for vertical merge (\clvmgf) + // fMergePrev:1 Merge with cell above (\clvmrg) + // fVertical:1 Display text top to bottom, right to left (\cltxtbrlv) + // fMergeStart:1 Start set of horizontally merged cells (\clmgf) + // fMergeCont:1 Merge with previous cell (\clmrg) + Flags uint32 + + WShading uint32 // Shading in .01% (\clshdng) e.g., 10000 flips fore/back + + DxBrdrLeft int32 // Left border width (\clbrdrl\brdrwN) (in twips) + DyBrdrTop int32 // Top border width (\clbrdrt\brdrwN) + DxBrdrRight int32 // Right border width (\clbrdrr\brdrwN) + DyBrdrBottom int32 // Bottom border width (\clbrdrb\brdrwN) + + CrBrdrLeft COLORREF // Left border color (\clbrdrl\brdrcf) + CrBrdrTop COLORREF // Top border color (\clbrdrt\brdrcf) + CrBrdrRight COLORREF // Right border color (\clbrdrr\brdrcf) + CrBrdrBottom COLORREF // Bottom border color (\clbrdrb\brdrcf) + CrBackPat COLORREF // Background color (\clcbpat) + CrForePat COLORREF // Foreground color (\clcfpat) +} + +const ( + EM_GETAUTOCORRECTPROC = WM_USER + 233 + EM_SETAUTOCORRECTPROC = WM_USER + 234 + EM_CALLAUTOCORRECTPROC = WM_USER + 255 +) + +// AutoCorrect callback +type AutoCorrectProc func(langid LANGID, pszBefore *uint16, pszAfter *uint16, cchAfter int32, pcchReplaced *int32) int + +const ( + ATP_NOCHANGE = 0 + ATP_CHANGE = 1 + ATP_NODELIMITER = 2 + ATP_REPLACEALLTEXT = 4 +) + +const ( + EM_GETTABLEPARMS = WM_USER + 265 + + EM_SETEDITSTYLEEX = WM_USER + 275 + EM_GETEDITSTYLEEX = WM_USER + 276 +) + +// wparam values for EM_SETEDITSTYLEEX/EM_GETEDITSTYLEEX +// All unused bits are reserved. +const ( + SES_EX_NOTABLE = 0x00000004 + SES_EX_NOMATH = 0x00000040 + SES_EX_HANDLEFRIENDLYURL = 0x00000100 + SES_EX_NOTHEMING = 0x00080000 + SES_EX_NOACETATESELECTION = 0x00100000 + SES_EX_USESINGLELINE = 0x00200000 + SES_EX_MULTITOUCH = 0x08000000 // Only works under Win8+ + SES_EX_HIDETEMPFORMAT = 0x10000000 + SES_EX_USEMOUSEWPARAM = 0x20000000 // Use wParam when handling WM_MOUSEMOVE message and do not call GetAsyncKeyState +) + +const ( + EM_GETSTORYTYPE = WM_USER + 290 + EM_SETSTORYTYPE = WM_USER + 291 + + EM_GETELLIPSISMODE = WM_USER + 305 + EM_SETELLIPSISMODE = WM_USER + 306 +) + +// DWORD: *lparam for EM_GETELLIPSISMODE, lparam for EM_SETELLIPSISMODE +const ( + ELLIPSIS_MASK = 0x00000003 // all meaningful bits + ELLIPSIS_NONE = 0x00000000 // ellipsis disabled + ELLIPSIS_END = 0x00000001 // ellipsis at the end (forced break) + ELLIPSIS_WORD = 0x00000003 // ellipsis at the end (word break) +) + +const ( + EM_SETTABLEPARMS = WM_USER + 307 + + EM_GETTOUCHOPTIONS = WM_USER + 310 + EM_SETTOUCHOPTIONS = WM_USER + 311 + EM_INSERTIMAGE = WM_USER + 314 + EM_SETUIANAME = WM_USER + 320 + EM_GETELLIPSISSTATE = WM_USER + 322 +) + +// Values for EM_SETTOUCHOPTIONS/EM_GETTOUCHOPTIONS +const ( + RTO_SHOWHANDLES = 1 + RTO_DISABLEHANDLES = 2 + RTO_READINGMODE = 3 +) + +// lparam for EM_INSERTIMAGE +type RICHEDIT_IMAGE_PARAMETERS struct { + XWidth int32 // Units are HIMETRIC + YHeight int32 // Units are HIMETRIC + Ascent int32 // Units are HIMETRIC + Type int32 // Valid values are TA_TOP, TA_BOTTOM and TA_BASELINE + PwszAlternateText *uint16 + PIStream uintptr +} + +// New notifications +const ( + EN_MSGFILTER = 0x0700 + EN_REQUESTRESIZE = 0x0701 + EN_SELCHANGE = 0x0702 + EN_DROPFILES = 0x0703 + EN_PROTECTED = 0x0704 + EN_CORRECTTEXT = 0x0705 // PenWin specific + EN_STOPNOUNDO = 0x0706 + EN_IMECHANGE = 0x0707 // East Asia specific + EN_SAVECLIPBOARD = 0x0708 + EN_OLEOPFAILED = 0x0709 + EN_OBJECTPOSITIONS = 0x070a + EN_LINK = 0x070b + EN_DRAGDROPDONE = 0x070c + EN_PARAGRAPHEXPANDED = 0x070d + EN_PAGECHANGE = 0x070e + EN_LOWFIRTF = 0x070f + EN_ALIGNLTR = 0x0710 // BiDi specific notification + EN_ALIGNRTL = 0x0711 // BiDi specific notification + EN_CLIPFORMAT = 0x0712 + EN_STARTCOMPOSITION = 0x0713 + EN_ENDCOMPOSITION = 0x0714 +) + +// Notification structure for EN_ENDCOMPOSITION +type ENDCOMPOSITIONNOTIFY struct { + Nmhdr NMHDR + DwCode uint32 +} + +// Constants for ENDCOMPOSITIONNOTIFY dwCode +const ( + ECN_ENDCOMPOSITION = 0x0001 + ECN_NEWTEXT = 0x0002 +) + +// Event notification masks +const ( + ENM_NONE = 0x00000000 + ENM_CHANGE = 0x00000001 + ENM_UPDATE = 0x00000002 + ENM_SCROLL = 0x00000004 + ENM_SCROLLEVENTS = 0x00000008 + ENM_DRAGDROPDONE = 0x00000010 + ENM_PARAGRAPHEXPANDED = 0x00000020 + ENM_PAGECHANGE = 0x00000040 + ENM_CLIPFORMAT = 0x00000080 + ENM_KEYEVENTS = 0x00010000 + ENM_MOUSEEVENTS = 0x00020000 + ENM_REQUESTRESIZE = 0x00040000 + ENM_SELCHANGE = 0x00080000 + ENM_DROPFILES = 0x00100000 + ENM_PROTECTED = 0x00200000 + ENM_CORRECTTEXT = 0x00400000 // PenWin specific + ENM_IMECHANGE = 0x00800000 // Used by RE1.0 compatibility + ENM_LANGCHANGE = 0x01000000 + ENM_OBJECTPOSITIONS = 0x02000000 + ENM_LINK = 0x04000000 + ENM_LOWFIRTF = 0x08000000 + ENM_STARTCOMPOSITION = 0x10000000 + ENM_ENDCOMPOSITION = 0x20000000 + ENM_GROUPTYPINGCHANGE = 0x40000000 + ENM_HIDELINKTOOLTIP = 0x80000000 +) + +// New edit control styles +const ( + ES_SAVESEL = 0x00008000 + ES_SUNKEN = 0x00004000 + ES_DISABLENOSCROLL = 0x00002000 + // Same as WS_MAXIMIZE, but that doesn't make sense so we re-use the value + ES_SELECTIONBAR = 0x01000000 + // Same as ES_UPPERCASE, but re-used to completely disable OLE drag'n'drop + ES_NOOLEDRAGDROP = 0x00000008 +) + +// Obsolete Edit Style +const ( + ES_EX_NOCALLOLEINIT = 0x00000000 // Not supported in RE 2.0/3.0 +) + +// These flags are used in FE Windows +const ( + ES_VERTICAL = 0x00400000 // Not supported in RE 2.0/3.0 + ES_NOIME = 0x00080000 + ES_SELFIME = 0x00040000 +) + +// Edit control options +const ( + ECO_AUTOWORDSELECTION = 0x00000001 + ECO_AUTOVSCROLL = 0x00000040 + ECO_AUTOHSCROLL = 0x00000080 + ECO_NOHIDESEL = 0x00000100 + ECO_READONLY = 0x00000800 + ECO_WANTRETURN = 0x00001000 + ECO_SAVESEL = 0x00008000 + ECO_SELECTIONBAR = 0x01000000 + ECO_VERTICAL = 0x00400000 // FE specific +) + +// ECO operations +const ( + ECOOP_SET = 0x0001 + ECOOP_OR = 0x0002 + ECOOP_AND = 0x0003 + ECOOP_XOR = 0x0004 +) + +// New word break function actions +const ( + WB_CLASSIFY = 3 + WB_MOVEWORDLEFT = 4 + WB_MOVEWORDRIGHT = 5 + WB_LEFTBREAK = 6 + WB_RIGHTBREAK = 7 +) + +// East Asia specific flags +const ( + WB_MOVEWORDPREV = 4 + WB_MOVEWORDNEXT = 5 + WB_PREVBREAK = 6 + WB_NEXTBREAK = 7 + + PC_FOLLOWING = 1 + PC_LEADING = 2 + PC_OVERFLOW = 3 + PC_DELIMITER = 4 + WBF_WORDWRAP = 0x010 + WBF_WORDBREAK = 0x020 + WBF_OVERFLOW = 0x040 + WBF_LEVEL1 = 0x080 + WBF_LEVEL2 = 0x100 + WBF_CUSTOM = 0x200 +) + +// East Asia specific flags +const ( + IMF_FORCENONE = 0x0001 + IMF_FORCEENABLE = 0x0002 + IMF_FORCEDISABLE = 0x0004 + IMF_CLOSESTATUSWINDOW = 0x0008 + IMF_VERTICAL = 0x0020 + IMF_FORCEACTIVE = 0x0040 + IMF_FORCEINACTIVE = 0x0080 + IMF_FORCEREMEMBER = 0x0100 + IMF_MULTIPLEEDIT = 0x0400 +) + +// Word break flags (used with WB_CLASSIFY) +const ( + WBF_CLASS byte = 0x0F + WBF_ISWHITE byte = 0x10 + WBF_BREAKLINE byte = 0x20 + WBF_BREAKAFTER byte = 0x40 +) From 7a0e89ef24d73506bf442ccdced4f1d5488cec46 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:46:00 +0100 Subject: [PATCH 132/138] Define more menu manipulation functions and constants Signed-off-by: Simon Rozman --- menu.go | 69 +++++++++++++++++++------- user32.go | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+), 17 deletions(-) diff --git a/menu.go b/menu.go index 0773f29a..c9dad192 100644 --- a/menu.go +++ b/menu.go @@ -21,27 +21,27 @@ const ( // Constants for MENUITEMINFO.fType const ( - MFT_BITMAP = 4 - MFT_MENUBARBREAK = 32 - MFT_MENUBREAK = 64 - MFT_OWNERDRAW = 256 - MFT_RADIOCHECK = 512 - MFT_RIGHTJUSTIFY = 0x4000 - MFT_SEPARATOR = 0x800 - MFT_RIGHTORDER = 0x2000 - MFT_STRING = 0 + MFT_STRING = MF_STRING + MFT_BITMAP = MF_BITMAP + MFT_MENUBARBREAK = MF_MENUBARBREAK + MFT_MENUBREAK = MF_MENUBREAK + MFT_OWNERDRAW = MF_OWNERDRAW + MFT_RADIOCHECK = 0x00000200 + MFT_SEPARATOR = MF_SEPARATOR + MFT_RIGHTORDER = 0x00002000 + MFT_RIGHTJUSTIFY = MF_RIGHTJUSTIFY ) // Constants for MENUITEMINFO.fState const ( - MFS_CHECKED = 8 - MFS_DEFAULT = 4096 - MFS_DISABLED = 3 - MFS_ENABLED = 0 - MFS_GRAYED = 3 - MFS_HILITE = 128 - MFS_UNCHECKED = 0 - MFS_UNHILITE = 0 + MFS_GRAYED = 0x00000003 + MFS_DISABLED = MFS_GRAYED + MFS_CHECKED = MF_CHECKED + MFS_HILITE = MF_HILITE + MFS_ENABLED = MF_ENABLED + MFS_UNCHECKED = MF_UNCHECKED + MFS_UNHILITE = MF_UNHILITE + MFS_DEFAULT = MF_DEFAULT ) // Constants for MENUITEMINFO.hbmp* @@ -80,8 +80,43 @@ const ( ) const ( + // Menu flags for Add/Check/EnableMenuItem() + MF_INSERT = 0x00000000 + MF_CHANGE = 0x00000080 + MF_APPEND = 0x00000100 + MF_DELETE = 0x00000200 + MF_REMOVE = 0x00001000 + MF_BYCOMMAND = 0x00000000 MF_BYPOSITION = 0x00000400 + + MF_SEPARATOR = 0x00000800 + + MF_ENABLED = 0x00000000 + MF_GRAYED = 0x00000001 + MF_DISABLED = 0x00000002 + + MF_UNCHECKED = 0x00000000 + MF_CHECKED = 0x00000008 + MF_USECHECKBITMAPS = 0x00000200 + + MF_STRING = 0x00000000 + MF_BITMAP = 0x00000004 + MF_OWNERDRAW = 0x00000100 + + MF_POPUP = 0x00000010 + MF_MENUBARBREAK = 0x00000020 + MF_MENUBREAK = 0x00000040 + + MF_UNHILITE = 0x00000000 + MF_HILITE = 0x00000080 + + MF_DEFAULT = 0x00001000 + MF_SYSMENU = 0x00002000 + MF_HELP = 0x00004000 + MF_RIGHTJUSTIFY = 0x00004000 + + MF_MOUSESELECT = 0x00008000 ) type MENUITEMINFO struct { diff --git a/user32.go b/user32.go index 5be421cc..fd5eb4e1 100644 --- a/user32.go +++ b/user32.go @@ -1775,6 +1775,7 @@ var ( createWindowEx *windows.LazyProc deferWindowPos *windows.LazyProc defWindowProc *windows.LazyProc + deleteMenu *windows.LazyProc destroyIcon *windows.LazyProc destroyMenu *windows.LazyProc destroyWindow *windows.LazyProc @@ -1785,6 +1786,7 @@ var ( drawFocusRect *windows.LazyProc drawTextEx *windows.LazyProc emptyClipboard *windows.LazyProc + enableMenuItem *windows.LazyProc enableWindow *windows.LazyProc endDeferWindowPos *windows.LazyProc endDialog *windows.LazyProc @@ -1806,12 +1808,17 @@ var ( getForegroundWindow *windows.LazyProc getIconInfo *windows.LazyProc getKeyState *windows.LazyProc + getMenuCheckMarkDimensions *windows.LazyProc getMenuInfo *windows.LazyProc + getMenuItemCount *windows.LazyProc + getMenuItemID *windows.LazyProc + getMenuItemInfo *windows.LazyProc getMessage *windows.LazyProc getMonitorInfo *windows.LazyProc getParent *windows.LazyProc getRawInputData *windows.LazyProc getScrollInfo *windows.LazyProc + getSubMenu *windows.LazyProc getSysColor *windows.LazyProc getSysColorBrush *windows.LazyProc getSystemMenu *windows.LazyProc @@ -1848,6 +1855,7 @@ var ( peekMessage *windows.LazyProc postMessage *windows.LazyProc postQuitMessage *windows.LazyProc + redrawWindow *windows.LazyProc registerClassEx *windows.LazyProc registerRawInputDevices *windows.LazyProc registerWindowMessage *windows.LazyProc @@ -1868,6 +1876,7 @@ var ( setMenu *windows.LazyProc setMenuDefaultItem *windows.LazyProc setMenuInfo *windows.LazyProc + setMenuItemBitmaps *windows.LazyProc setMenuItemInfo *windows.LazyProc setParent *windows.LazyProc setRect *windows.LazyProc @@ -1881,6 +1890,7 @@ var ( showWindow *windows.LazyProc systemParametersInfo *windows.LazyProc trackMouseEvent *windows.LazyProc + trackPopupMenu *windows.LazyProc trackPopupMenuEx *windows.LazyProc translateMessage *windows.LazyProc unhookWinEvent *windows.LazyProc @@ -1915,6 +1925,7 @@ func init() { createWindowEx = libuser32.NewProc("CreateWindowExW") deferWindowPos = libuser32.NewProc("DeferWindowPos") defWindowProc = libuser32.NewProc("DefWindowProcW") + deleteMenu = libuser32.NewProc("DeleteMenu") destroyIcon = libuser32.NewProc("DestroyIcon") destroyMenu = libuser32.NewProc("DestroyMenu") destroyWindow = libuser32.NewProc("DestroyWindow") @@ -1925,6 +1936,7 @@ func init() { drawMenuBar = libuser32.NewProc("DrawMenuBar") drawTextEx = libuser32.NewProc("DrawTextExW") emptyClipboard = libuser32.NewProc("EmptyClipboard") + enableMenuItem = libuser32.NewProc("EnableMenuItem") enableWindow = libuser32.NewProc("EnableWindow") endDeferWindowPos = libuser32.NewProc("EndDeferWindowPos") endDialog = libuser32.NewProc("EndDialog") @@ -1946,12 +1958,17 @@ func init() { getForegroundWindow = libuser32.NewProc("GetForegroundWindow") getIconInfo = libuser32.NewProc("GetIconInfo") getKeyState = libuser32.NewProc("GetKeyState") + getMenuCheckMarkDimensions = libuser32.NewProc("GetMenuCheckMarkDimensions") getMenuInfo = libuser32.NewProc("GetMenuInfo") + getMenuItemCount = libuser32.NewProc("GetMenuItemCount") + getMenuItemID = libuser32.NewProc("GetMenuItemID") + getMenuItemInfo = libuser32.NewProc("GetMenuItemInfoW") getMessage = libuser32.NewProc("GetMessageW") getMonitorInfo = libuser32.NewProc("GetMonitorInfoW") getParent = libuser32.NewProc("GetParent") getRawInputData = libuser32.NewProc("GetRawInputData") getScrollInfo = libuser32.NewProc("GetScrollInfo") + getSubMenu = libuser32.NewProc("GetSubMenu") getSysColor = libuser32.NewProc("GetSysColor") getSysColorBrush = libuser32.NewProc("GetSysColorBrush") getSystemMenu = libuser32.NewProc("GetSystemMenu") @@ -1993,6 +2010,7 @@ func init() { peekMessage = libuser32.NewProc("PeekMessageW") postMessage = libuser32.NewProc("PostMessageW") postQuitMessage = libuser32.NewProc("PostQuitMessage") + redrawWindow = libuser32.NewProc("RedrawWindow") registerClassEx = libuser32.NewProc("RegisterClassExW") registerRawInputDevices = libuser32.NewProc("RegisterRawInputDevices") registerWindowMessage = libuser32.NewProc("RegisterWindowMessageW") @@ -2013,6 +2031,7 @@ func init() { setMenu = libuser32.NewProc("SetMenu") setMenuDefaultItem = libuser32.NewProc("SetMenuDefaultItem") setMenuInfo = libuser32.NewProc("SetMenuInfo") + setMenuItemBitmaps = libuser32.NewProc("SetMenuItemBitmaps") setMenuItemInfo = libuser32.NewProc("SetMenuItemInfoW") setRect = libuser32.NewProc("SetRect") setParent = libuser32.NewProc("SetParent") @@ -2031,6 +2050,7 @@ func init() { showWindow = libuser32.NewProc("ShowWindow") systemParametersInfo = libuser32.NewProc("SystemParametersInfoW") trackMouseEvent = libuser32.NewProc("TrackMouseEvent") + trackPopupMenu = libuser32.NewProc("TrackPopupMenu") trackPopupMenuEx = libuser32.NewProc("TrackPopupMenuEx") translateMessage = libuser32.NewProc("TranslateMessage") unhookWinEvent = libuser32.NewProc("UnhookWinEvent") @@ -2252,6 +2272,15 @@ func DefWindowProc(hWnd HWND, Msg uint32, wParam, lParam uintptr) uintptr { return ret } +func DeleteMenu(hMenu HMENU, uPosition uint32, uFlags uint32) bool { + ret, _, _ := syscall.Syscall(deleteMenu.Addr(), 3, + uintptr(hMenu), + uintptr(uPosition), + uintptr(uFlags)) + + return ret != 0 +} + func DestroyIcon(hIcon HICON) bool { ret, _, _ := syscall.Syscall(destroyIcon.Addr(), 1, uintptr(hIcon), @@ -2354,6 +2383,15 @@ func EmptyClipboard() bool { return ret != 0 } +func EnableMenuItem(hMenu HMENU, uIDEnableItem uint32, uEnable uint32) bool { + ret, _, _ := syscall.Syscall(enableMenuItem.Addr(), 3, + uintptr(hMenu), + uintptr(uIDEnableItem), + uintptr(uEnable)) + + return ret != 0 +} + func EnableWindow(hWnd HWND, bEnable bool) bool { ret, _, _ := syscall.Syscall(enableWindow.Addr(), 2, uintptr(hWnd), @@ -2552,6 +2590,15 @@ func GetKeyState(nVirtKey int32) int16 { return int16(ret) } +func GetMenuCheckMarkDimensions() int32 { + ret, _, _ := syscall.Syscall(getMenuCheckMarkDimensions.Addr(), 0, + 0, + 0, + 0) + + return int32(ret) +} + func GetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { ret, _, _ := syscall.Syscall(getMenuInfo.Addr(), 2, uintptr(hmenu), @@ -2561,6 +2608,36 @@ func GetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { return ret != 0 } +func GetMenuItemCount(hMenu HMENU) int32 { + ret, _, _ := syscall.Syscall(getMenuItemCount.Addr(), 1, + uintptr(hMenu), + 0, + 0) + + return int32(ret) +} + +func GetMenuItemID(hMenu HMENU, nPos int32) uint32 { + ret, _, _ := syscall.Syscall(getMenuItemID.Addr(), 2, + uintptr(hMenu), + uintptr(nPos), + 0) + + return uint32(ret) +} + +func GetMenuItemInfo(hmenu HMENU, item uint32, fByPosition BOOL, lpmii *MENUITEMINFO) bool { + ret, _, _ := syscall.Syscall6(getMenuItemInfo.Addr(), 4, + uintptr(hmenu), + uintptr(item), + uintptr(fByPosition), + uintptr(unsafe.Pointer(lpmii)), + 0, + 0) + + return ret != 0 +} + func GetMessage(msg *MSG, hWnd HWND, msgFilterMin, msgFilterMax uint32) BOOL { ret, _, _ := syscall.Syscall6(getMessage.Addr(), 4, uintptr(unsafe.Pointer(msg)), @@ -2612,6 +2689,15 @@ func GetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO) bool { return ret != 0 } +func GetSubMenu(hMenu HMENU, nPos int32) HMENU { + ret, _, _ := syscall.Syscall(getSubMenu.Addr(), 2, + uintptr(hMenu), + uintptr(nPos), + 0) + + return HMENU(ret) +} + func GetSysColor(nIndex int) uint32 { ret, _, _ := syscall.Syscall(getSysColor.Addr(), 1, uintptr(nIndex), @@ -2964,6 +3050,38 @@ func PostQuitMessage(exitCode int32) { 0) } +const ( + // RedrawWindow() flags + RDW_INVALIDATE = 0x0001 + RDW_INTERNALPAINT = 0x0002 + RDW_ERASE = 0x0004 + + RDW_VALIDATE = 0x0008 + RDW_NOINTERNALPAINT = 0x0010 + RDW_NOERASE = 0x0020 + + RDW_NOCHILDREN = 0x0040 + RDW_ALLCHILDREN = 0x0080 + + RDW_UPDATENOW = 0x0100 + RDW_ERASENOW = 0x0200 + + RDW_FRAME = 0x0400 + RDW_NOFRAME = 0x0800 +) + +func RedrawWindow(hWnd HWND, lprcUpdate *RECT, hrgnUpdate HRGN, flags uint32) bool { + ret, _, _ := syscall.Syscall6(redrawWindow.Addr(), 4, + uintptr(hWnd), + uintptr(unsafe.Pointer(lprcUpdate)), + uintptr(hrgnUpdate), + uintptr(flags), + 0, + 0) + + return ret != 0 +} + func RegisterClassEx(windowClass *WNDCLASSEX) ATOM { ret, _, _ := syscall.Syscall(registerClassEx.Addr(), 1, uintptr(unsafe.Pointer(windowClass)), @@ -3151,6 +3269,18 @@ func SetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { return ret != 0 } +func SetMenuItemBitmaps(hMenu HMENU, uPosition uint32, uFlags uint32, hBitmapUnchecked HBITMAP, hBitmapChecked HBITMAP) bool { + ret, _, _ := syscall.Syscall6(setMenuItemBitmaps.Addr(), 5, + uintptr(hMenu), + uintptr(uPosition), + uintptr(uFlags), + uintptr(hBitmapUnchecked), + uintptr(hBitmapChecked), + 0) + + return ret != 0 +} + func SetMenuItemInfo(hMenu HMENU, uItem uint32, fByPosition bool, lpmii *MENUITEMINFO) bool { ret, _, _ := syscall.Syscall6(setMenuItemInfo.Addr(), 4, uintptr(hMenu), @@ -3300,6 +3430,21 @@ func TrackMouseEvent(lpEventTrack *TRACKMOUSEEVENT) bool { return ret != 0 } +func TrackPopupMenu(hMenu HMENU, uFlags uint32, x, y int32, nReserved int32, hWnd HWND, prcRect *RECT) uint32 { + ret, _, _ := syscall.Syscall9(trackPopupMenu.Addr(), 7, + uintptr(hMenu), + uintptr(uFlags), + uintptr(x), + uintptr(y), + uintptr(nReserved), + uintptr(hWnd), + uintptr(unsafe.Pointer(prcRect)), + 0, + 0) + + return uint32(ret) +} + func TrackPopupMenuEx(hMenu HMENU, fuFlags uint32, x, y int32, hWnd HWND, lptpm *TPMPARAMS) BOOL { ret, _, _ := syscall.Syscall6(trackPopupMenuEx.Addr(), 6, uintptr(hMenu), From 12ccdd60ac7ac388850372af725a6e4d5b3ef6ae Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:47:48 +0100 Subject: [PATCH 133/138] Extend RichEdit support Signed-off-by: Simon Rozman --- richedit.go | 639 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 628 insertions(+), 11 deletions(-) diff --git a/richedit.go b/richedit.go index 947247f0..aa51204b 100644 --- a/richedit.go +++ b/richedit.go @@ -65,15 +65,15 @@ const ( EM_GETTEXTMODE = WM_USER + 90 ) -type TEXTMODE int +type TEXTMODE int32 const ( TM_PLAINTEXT TEXTMODE = 1 - TM_RICHTEXT TEXTMODE = 2 // Default behavior - TM_SINGLELEVELUNDO TEXTMODE = 4 - TM_MULTILEVELUNDO TEXTMODE = 8 // Default behavior - TM_SINGLECODEPAGE TEXTMODE = 16 - TM_MULTICODEPAGE TEXTMODE = 32 // Default behavior + TM_RICHTEXT = 2 // Default behavior + TM_SINGLELEVELUNDO = 4 + TM_MULTILEVELUNDO = 8 // Default behavior + TM_SINGLECODEPAGE = 16 + TM_MULTICODEPAGE = 32 // Default behavior ) const ( @@ -461,7 +461,7 @@ const ( EM_SETELLIPSISMODE = WM_USER + 306 ) -// DWORD: *lparam for EM_GETELLIPSISMODE, lparam for EM_SETELLIPSISMODE +// uint32: *lparam for EM_GETELLIPSISMODE, lparam for EM_SETELLIPSISMODE const ( ELLIPSIS_MASK = 0x00000003 // all meaningful bits ELLIPSIS_NONE = 0x00000000 // ellipsis disabled @@ -567,10 +567,8 @@ const ( ES_SAVESEL = 0x00008000 ES_SUNKEN = 0x00004000 ES_DISABLENOSCROLL = 0x00002000 - // Same as WS_MAXIMIZE, but that doesn't make sense so we re-use the value - ES_SELECTIONBAR = 0x01000000 - // Same as ES_UPPERCASE, but re-used to completely disable OLE drag'n'drop - ES_NOOLEDRAGDROP = 0x00000008 + ES_SELECTIONBAR = 0x01000000 // Same as WS_MAXIMIZE, but that doesn't make sense so we re-use the value + ES_NOOLEDRAGDROP = 0x00000008 // Same as ES_UPPERCASE, but re-used to completely disable OLE drag'n'drop ) // Obsolete Edit Style @@ -654,3 +652,622 @@ const ( WBF_BREAKLINE byte = 0x20 WBF_BREAKAFTER byte = 0x40 ) + +type CHARFORMAT struct { + CbSize uint32 + DwMask uint32 + DwEffects uint32 + YHeight int32 + YOffset int32 + CrTextColor COLORREF + BCharSet byte + BPitchAndFamily byte + SzFaceName [LF_FACESIZE]uint16 +} + +type CHARFORMAT2 struct { + CHARFORMAT + WWeight uint16 // Font weight (LOGFONT value) + SSpacing int16 // Amount to space between letters + CrBackColor COLORREF // Background color + Lcid LCID // Locale ID + DwCookie uint32 // Client cookie opaque to RichEdit + SStyle int16 // Style handle + WKerning uint16 // Twip size above which to kern char pair + BUnderlineType byte // Underline type + BAnimation byte // Animated text like marching ants + BRevAuthor byte // Revision author index + BUnderlineColor byte // Underline color +} + +// CHARFORMAT masks +const ( + CFM_BOLD = 0x00000001 + CFM_ITALIC = 0x00000002 + CFM_UNDERLINE = 0x00000004 + CFM_STRIKEOUT = 0x00000008 + CFM_PROTECTED = 0x00000010 + CFM_LINK = 0x00000020 // Exchange hyperlink extension + CFM_SIZE = 0x80000000 + CFM_COLOR = 0x40000000 + CFM_FACE = 0x20000000 + CFM_OFFSET = 0x10000000 + CFM_CHARSET = 0x08000000 +) + +// CHARFORMAT effects +const ( + CFE_BOLD = 0x00000001 + CFE_ITALIC = 0x00000002 + CFE_UNDERLINE = 0x00000004 + CFE_STRIKEOUT = 0x00000008 + CFE_PROTECTED = 0x00000010 + CFE_LINK = 0x00000020 + CFE_AUTOCOLOR = 0x40000000 // NOTE: this corresponds to CFM_COLOR, which controls it + + // Masks and effects defined for CHARFORMAT2 -- an (*) indicates that the data is stored by RichEdit 2.0/3.0, but not displayed + CFM_SMALLCAPS = 0x00000040 // (*) + CFM_ALLCAPS = 0x00000080 // Displayed by 3.0 + CFM_HIDDEN = 0x00000100 // Hidden by 3.0 + CFM_OUTLINE = 0x00000200 // (*) + CFM_SHADOW = 0x00000400 // (*) + CFM_EMBOSS = 0x00000800 // (*) + CFM_IMPRINT = 0x00001000 // (*) + CFM_DISABLED = 0x00002000 + CFM_REVISED = 0x00004000 + + CFM_REVAUTHOR = 0x00008000 + CFE_SUBSCRIPT = 0x00010000 // Superscript and subscript are + CFE_SUPERSCRIPT = 0x00020000 // mutually exclusive + CFM_ANIMATION = 0x00040000 // (*) + CFM_STYLE = 0x00080000 // (*) + CFM_KERNING = 0x00100000 + CFM_SPACING = 0x00200000 // Displayed by 3.0 + CFM_WEIGHT = 0x00400000 + CFM_UNDERLINETYPE = 0x00800000 // Many displayed by 3.0 + CFM_COOKIE = 0x01000000 // RE 6.0 + CFM_LCID = 0x02000000 + CFM_BACKCOLOR = 0x04000000 // Higher mask bits defined above + + CFM_SUBSCRIPT = (CFE_SUBSCRIPT | CFE_SUPERSCRIPT) + CFM_SUPERSCRIPT = CFM_SUBSCRIPT + + // CHARFORMAT "ALL" masks + CFM_EFFECTS = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_COLOR | CFM_STRIKEOUT | CFE_PROTECTED | CFM_LINK + CFM_ALL = CFM_EFFECTS | CFM_SIZE | CFM_FACE | CFM_OFFSET | CFM_CHARSET + CFM_EFFECTS2 = CFM_EFFECTS | CFM_DISABLED | CFM_SMALLCAPS | CFM_ALLCAPS | CFM_HIDDEN | CFM_OUTLINE | CFM_SHADOW | CFM_EMBOSS | CFM_IMPRINT | CFM_REVISED | CFM_SUBSCRIPT | CFM_SUPERSCRIPT | CFM_BACKCOLOR + CFM_ALL2 = CFM_ALL | CFM_EFFECTS2 | CFM_BACKCOLOR | CFM_LCID | CFM_UNDERLINETYPE | CFM_WEIGHT | CFM_REVAUTHOR | CFM_SPACING | CFM_KERNING | CFM_STYLE | CFM_ANIMATION | CFM_COOKIE + + CFE_SMALLCAPS = CFM_SMALLCAPS + CFE_ALLCAPS = CFM_ALLCAPS + CFE_HIDDEN = CFM_HIDDEN + CFE_OUTLINE = CFM_OUTLINE + CFE_SHADOW = CFM_SHADOW + CFE_EMBOSS = CFM_EMBOSS + CFE_IMPRINT = CFM_IMPRINT + CFE_DISABLED = CFM_DISABLED + CFE_REVISED = CFM_REVISED + + // CFE_AUTOCOLOR and CFE_AUTOBACKCOLOR correspond to CFM_COLOR and + // CFM_BACKCOLOR, respectively, which control them + CFE_AUTOBACKCOLOR = CFM_BACKCOLOR + + CFM_FONTBOUND = 0x00100000 + CFM_LINKPROTECTED = 0x00800000 // Word hyperlink field + CFM_EXTENDED = 0x02000000 + CFM_MATHNOBUILDUP = 0x08000000 + CFM_MATH = 0x10000000 + CFM_MATHORDINARY = 0x20000000 + + CFM_ALLEFFECTS = (CFM_EFFECTS2 | CFM_FONTBOUND | CFM_EXTENDED | CFM_MATHNOBUILDUP | CFM_MATH | CFM_MATHORDINARY) + + CFE_FONTBOUND = 0x00100000 // Font chosen by binder, not user + CFE_LINKPROTECTED = 0x00800000 + CFE_EXTENDED = 0x02000000 + CFE_MATHNOBUILDUP = 0x08000000 + CFE_MATH = 0x10000000 + CFE_MATHORDINARY = 0x20000000 + + // Underline types. RE 1.0 displays only CFU_UNDERLINE + CFU_CF1UNDERLINE = 0xFF // Map charformat's bit underline to CF2 + CFU_INVERT = 0xFE // For IME composition fake a selection + CFU_UNDERLINETHICKLONGDASH = 18 // (*) display as dash + CFU_UNDERLINETHICKDOTTED = 17 // (*) display as dot + CFU_UNDERLINETHICKDASHDOTDOT = 16 // (*) display as dash dot dot + CFU_UNDERLINETHICKDASHDOT = 15 // (*) display as dash dot + CFU_UNDERLINETHICKDASH = 14 // (*) display as dash + CFU_UNDERLINELONGDASH = 13 // (*) display as dash + CFU_UNDERLINEHEAVYWAVE = 12 // (*) display as wave + CFU_UNDERLINEDOUBLEWAVE = 11 // (*) display as wave + CFU_UNDERLINEHAIRLINE = 10 // (*) display as single + CFU_UNDERLINETHICK = 9 + CFU_UNDERLINEWAVE = 8 + CFU_UNDERLINEDASHDOTDOT = 7 + CFU_UNDERLINEDASHDOT = 6 + CFU_UNDERLINEDASH = 5 + CFU_UNDERLINEDOTTED = 4 + CFU_UNDERLINEDOUBLE = 3 // (*) display as single + CFU_UNDERLINEWORD = 2 // (*) display as single + CFU_UNDERLINE = 1 + CFU_UNDERLINENONE = 0 +) + +const YHeightCharPtsMost = 1638 + +const ( + // EM_SETCHARFORMAT wParam masks + SCF_SELECTION = 0x0001 + SCF_WORD = 0x0002 + SCF_DEFAULT = 0x0000 // Set default charformat or paraformat + SCF_ALL = 0x0004 // Not valid with SCF_SELECTION or SCF_WORD + SCF_USEUIRULES = 0x0008 // Modifier for SCF_SELECTION; says that came from a toolbar, etc., and UI formatting rules should be instead of literal formatting + SCF_ASSOCIATEFONT = 0x0010 // Associate fontname with bCharSet (one possible for each of Western, ME, FE, Thai) + SCF_NOKBUPDATE = 0x0020 // Do not update KB layout for this change even if autokeyboard is on + SCF_ASSOCIATEFONT2 = 0x0040 // Associate plane-2 (surrogate) font + SCF_SMARTFONT = 0x0080 // Apply font only if it can handle script (5.0) + SCF_CHARREPFROMLCID = 0x0100 // Get character repertoire from lcid (5.0) + + SPF_DONTSETDEFAULT = 0x0002 // Suppress setting default on empty control + SPF_SETDEFAULT = 0x0004 // Set the default paraformat +) + +type CHARRANGE struct { + CpMin int32 + CpMax int32 +} + +type TEXTRANGE struct { + Chrg CHARRANGE + LpstrText *uint16 // Allocated by caller, zero terminated by RichEdit +} + +type EDITSTREAM struct { + DwCookie uintptr // User value passed to callback as first parameter + DwError uint32 // Last error + PfnCallback uintptr +} + +const ( + // Stream formats. Flags are all in low word, since high word gives possible codepage choice. + SF_TEXT = 0x0001 + SF_RTF = 0x0002 + SF_RTFNOOBJS = 0x0003 // Write only + SF_TEXTIZED = 0x0004 // Write only + + SF_UNICODE = 0x0010 // Unicode file (UCS2 little endian) + SF_USECODEPAGE = 0x0020 // CodePage given by high word + SF_NCRFORNONASCII = 0x40 // Output \uN for nonASCII + SFF_WRITEXTRAPAR = 0x80 // Output \par at end + + // Flag telling stream operations to operate on selection only + // EM_STREAMIN replaces current selection + // EM_STREAMOUT streams out current selection + SFF_SELECTION = 0x8000 + + // Flag telling stream operations to ignore some FE control words having to do with FE word breaking and horiz vs vertical text. + // Not used in RichEdit 2.0 and later + SFF_PLAINRTF = 0x4000 + + // Flag telling file stream output (SFF_SELECTION flag not set) to persist // \viewscaleN control word. + SFF_PERSISTVIEWSCALE = 0x2000 + + // Flag telling file stream input with SFF_SELECTION flag not set not to // close the document + SFF_KEEPDOCINFO = 0x1000 + + // Flag telling stream operations to output in Pocket Word format + SFF_PWD = 0x0800 + + // 3-bit field specifying the value of N - 1 to use for \rtfN or \pwdN + SF_RTFVAL = 0x0700 +) + +type FINDTEXT struct { + Chrg CHARRANGE + LpstrText *uint16 +} + +type FINDTEXTEX struct { + chrg CHARRANGE + lpstrText *uint16 + chrgText CHARRANGE +} + +type FORMATRANGE struct { + hdc HDC + hdcTarget HDC + rc RECT + rcPage RECT + chrg CHARRANGE +} + +// All paragraph measurements are in twips +const ( + MAX_TAB_STOPS = 32 + LDefaultTab = 720 + MAX_TABLE_CELLS = 63 +) + +type PARAFORMAT struct { + CbSize uint32 + DwMask uint32 + WNumbering uint16 + WEffects uint16 + DxStartIndent int32 + DxRightIndent int32 + DxOffset int32 + WAlignment uint16 + CTabCount int16 + RgxTabs [MAX_TAB_STOPS]int32 +} + +type PARAFORMAT2 struct { + PARAFORMAT + DySpaceBefore int32 // Vertical spacing before para + DySpaceAfter int32 // Vertical spacing after para + DyLineSpacing int32 // Line spacing depending on Rule + SStyle int16 // Style handle + BLineSpacingRule byte // Rule for line spacing (see tom.doc) + BOutlineLevel byte // Outline level + WShadingWeight uint16 // Shading in hundredths of a per cent + WShadingStyle uint16 // Nibble 0: style, 1: cfpat, 2: cbpat + WNumberingStart uint16 // Starting value for numbering + WNumberingStyle uint16 // Alignment, roman/arabic, (), ), ., etc. + WNumberingTab uint16 // Space bet FirstIndent & 1st-line text + WBorderSpace uint16 // Border-text spaces (nbl/bdr in pts) + WBorderWidth uint16 // Pen widths (nbl/bdr in half pts) + WBorders uint16 // Border styles (nibble/border) +} + +const ( + // PARAFORMAT mask values + PFM_STARTINDENT = 0x00000001 + PFM_RIGHTINDENT = 0x00000002 + PFM_OFFSET = 0x00000004 + PFM_ALIGNMENT = 0x00000008 + PFM_TABSTOPS = 0x00000010 + PFM_NUMBERING = 0x00000020 + PFM_OFFSETINDENT = 0x80000000 + + // PARAFORMAT 2.0 masks and effects + PFM_SPACEBEFORE = 0x00000040 + PFM_SPACEAFTER = 0x00000080 + PFM_LINESPACING = 0x00000100 + PFM_STYLE = 0x00000400 + PFM_BORDER = 0x00000800 // (*) + PFM_SHADING = 0x00001000 // (*) + PFM_NUMBERINGSTYLE = 0x00002000 // RE 3.0 + PFM_NUMBERINGTAB = 0x00004000 // RE 3.0 + PFM_NUMBERINGSTART = 0x00008000 // RE 3.0 + + PFM_RTLPARA = 0x00010000 + PFM_KEEP = 0x00020000 // (*) + PFM_KEEPNEXT = 0x00040000 // (*) + PFM_PAGEBREAKBEFORE = 0x00080000 // (*) + PFM_NOLINENUMBER = 0x00100000 // (*) + PFM_NOWIDOWCONTROL = 0x00200000 // (*) + PFM_DONOTHYPHEN = 0x00400000 // (*) + PFM_SIDEBYSIDE = 0x00800000 // (*) + + // The following two paragraph-format properties are read only + PFM_COLLAPSED = 0x01000000 // RE 3.0 + PFM_OUTLINELEVEL = 0x02000000 // RE 3.0 + PFM_BOX = 0x04000000 // RE 3.0 + PFM_RESERVED2 = 0x08000000 // RE 4.0 + PFM_TABLEROWDELIMITER = 0x10000000 // RE 4.0 + PFM_TEXTWRAPPINGBREAK = 0x20000000 // RE 3.0 + PFM_TABLE = 0x40000000 // RE 3.0 + + // PARAFORMAT "ALL" masks + PFM_ALL = PFM_STARTINDENT | PFM_RIGHTINDENT | PFM_OFFSET | PFM_ALIGNMENT | PFM_TABSTOPS | PFM_NUMBERING | PFM_OFFSETINDENT | PFM_RTLPARA + + // Note: PARAFORMAT has no effects (BiDi RichEdit 1.0 does have PFE_RTLPARA) + PFM_EFFECTS = PFM_RTLPARA | PFM_KEEP | PFM_KEEPNEXT | PFM_TABLE | PFM_PAGEBREAKBEFORE | PFM_NOLINENUMBER | PFM_NOWIDOWCONTROL | PFM_DONOTHYPHEN | PFM_SIDEBYSIDE | PFM_TABLE | PFM_TABLEROWDELIMITER + + PFM_ALL2 = PFM_ALL | PFM_EFFECTS | PFM_SPACEBEFORE | PFM_SPACEAFTER | PFM_LINESPACING | PFM_STYLE | PFM_SHADING | PFM_BORDER | PFM_NUMBERINGTAB | PFM_NUMBERINGSTART | PFM_NUMBERINGSTYLE + + PFE_RTLPARA = PFM_RTLPARA >> 16 + PFE_KEEP = PFM_KEEP >> 16 // (*) + PFE_KEEPNEXT = PFM_KEEPNEXT >> 16 // (*) + PFE_PAGEBREAKBEFORE = PFM_PAGEBREAKBEFORE >> 16 // (*) + PFE_NOLINENUMBER = PFM_NOLINENUMBER >> 16 // (*) + PFE_NOWIDOWCONTROL = PFM_NOWIDOWCONTROL >> 16 // (*) + PFE_DONOTHYPHEN = PFM_DONOTHYPHEN >> 16 // (*) + PFE_SIDEBYSIDE = PFM_SIDEBYSIDE >> 16 // (*) + PFE_TEXTWRAPPINGBREAK = PFM_TEXTWRAPPINGBREAK >> 16 // (*) + + // The following four effects are read only + PFE_COLLAPSED = PFM_COLLAPSED >> 16 // (+) + PFE_BOX = PFM_BOX >> 16 // (+) + PFE_TABLE = PFM_TABLE >> 16 // Inside table row. RE 3.0 + PFE_TABLEROWDELIMITER = PFM_TABLEROWDELIMITER >> 16 // Table row start. RE 4.0 + + // PARAFORMAT numbering options + PFN_BULLET = 1 // tomListBullet + + // PARAFORMAT2 wNumbering options + PFN_ARABIC = 2 // tomListNumberAsArabic: 0, 1, 2, ... + PFN_LCLETTER = 3 // tomListNumberAsLCLetter: a, b, c, ... + PFN_UCLETTER = 4 // tomListNumberAsUCLetter: A, B, C, ... + PFN_LCROMAN = 5 // tomListNumberAsLCRoman: i, ii, iii, ... + PFN_UCROMAN = 6 // tomListNumberAsUCRoman: I, II, III, ... + + // PARAFORMAT2 wNumberingStyle options + PFNS_PAREN = 0x000 // default, e.g., 1) + PFNS_PARENS = 0x100 // tomListParentheses/256, e.g., (1) + PFNS_PERIOD = 0x200 // tomListPeriod/256, e.g., 1. + PFNS_PLAIN = 0x300 // tomListPlain/256, e.g., 1 + PFNS_NONUMBER = 0x400 // Used for continuation w/o number + + PFNS_NEWNUMBER = 0x8000 // Start new number with wNumberingStart + // (can be combined with other PFNS_xxx) + // PARAFORMAT alignment options + PFA_LEFT = 1 + PFA_RIGHT = 2 + PFA_CENTER = 3 + + // PARAFORMAT2 alignment options + PFA_JUSTIFY = 4 // New paragraph-alignment option 2.0 (*) + PFA_FULL_INTERWORD = 4 // These are supported in 3.0 with advanced +) + +type MSGFILTER struct { + Nmhdr NMHDR + Msg uint32 + WParam uintptr + LParam uintptr +} + +type REQRESIZE struct { + Nmhdr NMHDR + Rc RECT +} + +type SELCHANGE struct { + Nmhdr NMHDR + Chrg CHARRANGE + Seltyp uint16 +} + +type GROUPTYPINGCHANGE struct { + Nmhdr NMHDR + FGroupTyping BOOL +} + +type CLIPBOARDFORMAT struct { + Nmhdr NMHDR + Cf CLIPFORMAT +} + +const ( + SEL_EMPTY = 0x0000 + SEL_TEXT = 0x0001 + SEL_OBJECT = 0x0002 + SEL_MULTICHAR = 0x0004 + SEL_MULTIOBJECT = 0x0008 +) + +const ( + // Used with IRichEditOleCallback::GetContextMenu, this flag will be passed as a "selection type". It indicates that a context menu for a right-mouse drag drop should be generated. The IOleObject parameter will really be the IDataObject for the drop + GCM_RIGHTMOUSEDROP = 0x8000 +) + +type GETCONTEXTMENUEX struct { + Chrg CHARRANGE + DwFlags uint32 + Pt POINT + PvReserved uintptr +} + +const ( + // bits for GETCONTEXTMENUEX::dwFlags + GCMF_GRIPPER = 0x00000001 + GCMF_SPELLING = 0x00000002 // pSpellingSuggestions is valid and points to the list of spelling suggestions + GCMF_TOUCHMENU = 0x00004000 + GCMF_MOUSEMENU = 0x00002000 +) + +type ENDROPFILES struct { + Nmhdr NMHDR + HDrop HANDLE + Cp int32 + FProtected BOOL +} + +type ENPROTECTED struct { + Nmhdr NMHDR + Msg uint32 + WParam uintptr + LParam uintptr + Chrg CHARRANGE +} + +type ENSAVECLIPBOARD struct { + Nmhdr NMHDR + CObjectCount int32 + Cch int32 +} + +type ENOLEOPFAILED struct { + Nmhdr NMHDR + Iob int32 + LOper int32 + Hr HRESULT +} + +const OLEOP_DOVERB = 1 + +type OBJECTPOSITIONS struct { + Nmhdr NMHDR + CObjectCount int32 + PcpPositions *int32 +} + +type ENLINK struct { + Nmhdr NMHDR + Msg uint32 + WParam uintptr + LParam uintptr + Chrg CHARRANGE +} + +type ENLOWFIRTF struct { + Nmhdr NMHDR + SzControl *byte +} + +// PenWin specific +type ENCORRECTTEXT struct { + Nmhdr NMHDR + Chrg CHARRANGE + Seltyp uint16 +} + +// East Asia specific +type PUNCTUATION struct { + ISize uint32 + SzPunctuation *byte +} + +// East Asia specific +type COMPCOLOR struct { + CrText COLORREF + CrBackground COLORREF + DwEffects uint32 +} + +const ( + // Clipboard formats - use as parameter to RegisterClipboardFormat() + CF_RTF = "Rich Text Format" + CF_RTFNOOBJS = "Rich Text Format Without Objects" + CF_RETEXTOBJ = "RichEdit Text and Objects" +) + +// Paste Special +type REPASTESPECIAL struct { + DwAspect uint32 + DwParam uintptr +} + +// UndoName info +type UNDONAMEID int32 + +const ( + UID_UNKNOWN UNDONAMEID = 0 + UID_TYPING = 1 + UID_DELETE = 2 + UID_DRAGDROP = 3 + UID_CUT = 4 + UID_PASTE = 5 + UID_AUTOTABLE = 6 +) + +const ( + // Flags for the SETEXTEX data structure + ST_DEFAULT = 0 + ST_KEEPUNDO = 1 + ST_SELECTION = 2 + ST_NEuint16S = 4 + ST_UNICODE = 8 +) + +// EM_SETTEXTEX info; this struct is passed in the wparam of the message +type SETTEXTEX struct { + Flags uint32 // Flags (see the ST_XXX defines) + Codepage uint32 // Code page for translation (CP_ACP for sys default, 1200 for Unicode, -1 for control default) +} + +const ( + // Flags for the GETEXTEX data structure + GT_DEFAULT = 0 + GT_USECRLF = 1 + GT_SELECTION = 2 + GT_RAWTEXT = 4 + GT_NOHIDDENTEXT = 8 +) + +// EM_GETTEXTEX info; this struct is passed in the wparam of the message +type GETTEXTEX struct { + Cb uint32 // Count of bytes in the string + Flags uint32 // Flags (see the GT_XXX defines + Codepage uint32 // Code page for translation (CP_ACP for sys default, 1200 for Unicode, -1 for control default) + LpDefaultChar *byte // Replacement for unmappable chars + LpUsedDefChar *BOOL // Pointer to flag set when def char used +} + +const ( + // Flags for the GETTEXTLENGTHEX data structure + GTL_DEFAULT = 0 // Do default (return # of chars) + GTL_USECRLF = 1 // Compute answer using CRLFs for paragraphs + GTL_PRECISE = 2 // Compute a precise answer + GTL_CLOSE = 4 // Fast computation of a "close" answer + GTL_NUMCHARS = 8 // Return number of characters + GTL_NUMBYTES = 16 // Return number of _bytes_ +) + +// EM_GETTEXTLENGTHEX info; this struct is passed in the wparam of the msg +type GETTEXTLENGTHEX struct { + Flags uint32 // Flags (see GTL_XXX defines) + Codepage uint32 // Code page for translation (CP_ACP for default, 1200 for Unicode) +} + +// BiDi specific features +type BIDIOPTIONS struct { + CbSize uint32 + WMask uint16 + WEffects uint16 +} + +const ( + // BIDIOPTIONS masks + BOM_NEUTRALOVERRIDE = 0x0004 // Override neutral layout (obsolete) + BOM_CONTEXTREADING = 0x0008 // Context reading order + BOM_CONTEXTALIGNMENT = 0x0010 // Context alignment + BOM_LEGACYBIDICLASS = 0x0040 // Legacy Bidi classification (obsolete) + BOM_UNICODEBIDI = 0x0080 // Use Unicode BiDi algorithm + + // BIDIOPTIONS effects + BOE_NEUTRALOVERRIDE = 0x0004 // Override neutral layout (obsolete) + BOE_CONTEXTREADING = 0x0008 // Context reading order + BOE_CONTEXTALIGNMENT = 0x0010 // Context alignment + BOE_FORCERECALC = 0x0020 // Force recalc and redraw + BOE_LEGACYBIDICLASS = 0x0040 // Legacy Bidi classification (obsolete) + BOE_UNICODEBIDI = 0x0080 // Use Unicode BiDi algorithm + + // Additional EM_FINDTEXT[EX] flags + FR_MATCHDIAC = 0x20000000 + FR_MATCHKASHIDA = 0x40000000 + FR_MATCHALEFHAMZA = 0x80000000 + + // UNICODE embedding character + WCH_EMBEDDING uint16 = 0xFFFC +) + +// khyph - Kind of hyphenation +type KHYPH int32 + +const ( + KhyphNil KHYPH = iota // No Hyphenation + KhyphNormal // Normal Hyphenation + KhyphAddBefore // Add letter before hyphen + KhyphChangeBefore // Change letter before hyphen + KhyphDeleteBefore // Delete letter before hyphen + KhyphChangeAfter // Change letter after hyphen + KhyphDelAndChange // Delete letter before hyphen and change letter preceding hyphen +) + +type HYPHRESULT struct { + Khyph KHYPH // Kind of hyphenation + IchHyph int32 // Character which was hyphenated + ChHyph uint16 // Depending on hyphenation type, character added, changed, etc. +} + +type HYPHENATEINFO struct { + CbSize int16 // Size of HYPHENATEINFO structure + DxHyphenateZone int16 // If a space character is closer to the margin than this value, don't hyphenate (in TWIPs) + PfnHyphenate uintptr +} + +const ( + // Additional class for Richedit 6.0 + RICHEDIT60_CLASS = "RICHEDIT60W" +) From 86c95bacda4f7d53e25a0b161babc4bcd5634bcf Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:51:04 +0100 Subject: [PATCH 134/138] Add RGB "macro" Signed-off-by: Simon Rozman --- gdi32.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gdi32.go b/gdi32.go index ba8dd91d..69e43c35 100644 --- a/gdi32.go +++ b/gdi32.go @@ -765,6 +765,10 @@ const ( FR_NOT_ENUM = 0x20 ) +func RGB(r, g, b byte) COLORREF { + return COLORREF(r) | (COLORREF(g) << 8) | (COLORREF(b) << 16) +} + type ( COLORREF uint32 HBITMAP HGDIOBJ From 7611bb921256d89a6c9061e760e96e91c670323e Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:53:08 +0100 Subject: [PATCH 135/138] Add CLIPFORMAT type Signed-off-by: Simon Rozman --- gdi32.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gdi32.go b/gdi32.go index 69e43c35..1842b9e5 100644 --- a/gdi32.go +++ b/gdi32.go @@ -780,6 +780,7 @@ type ( HPALETTE HGDIOBJ HPEN HGDIOBJ HRGN HGDIOBJ + CLIPFORMAT uint16 ) type PIXELFORMATDESCRIPTOR struct { From c69f391b4b0ae1486a468efff1e39995fa1d1e9e Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:53:29 +0100 Subject: [PATCH 136/138] Add CP_... constants Signed-off-by: Simon Rozman --- winnls.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 winnls.go diff --git a/winnls.go b/winnls.go new file mode 100644 index 00000000..13845962 --- /dev/null +++ b/winnls.go @@ -0,0 +1,20 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +const ( + // Code Page Default Values. + // Please Use Unicode, either UTF-16 (as in WCHAR) or UTF-8 (code page CP_ACP) + CP_ACP = 0 // default to ANSI code page + CP_OEMCP = 1 // default to OEM code page + CP_MACCP = 2 // default to MAC code page + CP_THREAD_ACP = 3 // current thread's ANSI code page + CP_SYMBOL = 42 // SYMBOL translations + + CP_UTF7 = 65000 // UTF-7 translation + CP_UTF8 = 65001 // UTF-8 translation +) From 441d9836c3655081ef1750c54f2f1a648309006e Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 10:13:50 +0100 Subject: [PATCH 137/138] Add text editing OLE interfaces Signed-off-by: Simon Rozman --- oaidl.go | 81 +++++ objidl.go | 47 +++ richole.go | 213 ++++++++++++ tom.go | 989 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1330 insertions(+) create mode 100644 oaidl.go create mode 100644 objidl.go create mode 100644 richole.go create mode 100644 tom.go diff --git a/oaidl.go b/oaidl.go new file mode 100644 index 00000000..c209866a --- /dev/null +++ b/oaidl.go @@ -0,0 +1,81 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +type SCODE int32 + +type EXCEPINFO struct { + wCode uint16 + wReserved uint16 + bstrSource *uint16 /*BSTR*/ + bstrDescription *uint16 /*BSTR*/ + bstrHelpFile *uint16 /*BSTR*/ + dwHelpContext uint32 + pvReserved uintptr + pfnDeferredFillIn uintptr + scode SCODE +} + +var ( + IID_ITypeInfo = IID{0x00020401, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} +) + +type ITypeInfoVtbl struct { + IUnknownVtbl + GetTypeAttr uintptr + GetTypeComp uintptr + GetFuncDesc uintptr + GetVarDesc uintptr + GetNames uintptr + GetRefTypeOfImplType uintptr + GetImplTypeFlags uintptr + GetIDsOfNames uintptr + Invoke uintptr + GetDocumentation uintptr + GetDllEntry uintptr + GetRefTypeInfo uintptr + AddressOfMember uintptr + CreateInstance uintptr + GetMops uintptr + GetContainingTypeLib uintptr + ReleaseTypeAttr uintptr + ReleaseFuncDesc uintptr + ReleaseVarDesc uintptr +} + +type ITypeInfo struct { + LpVtbl *ITypeInfoVtbl +} + +func (obj *ITypeInfo) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(ppvObject))) + return HRESULT(ret) +} + +func (obj *ITypeInfo) AddRef() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *ITypeInfo) Release() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} diff --git a/objidl.go b/objidl.go new file mode 100644 index 00000000..12f1ceb3 --- /dev/null +++ b/objidl.go @@ -0,0 +1,47 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +type IDataObjectVtbl struct { + IUnknownVtbl + GetData uintptr + GetDataHere uintptr + QueryGetData uintptr + GetCanonicalFormatEtc uintptr + SetData uintptr + EnumFormatEtc uintptr + DAdvise uintptr + DUnadvise uintptr + EnumDAdvise uintptr +} + +type IDataObject struct { + LpVtbl *IDataObjectVtbl +} + +type IStorageVtbl struct { + IUnknownVtbl + CreateStream uintptr + OpenStream uintptr + CreateStorage uintptr + OpenStorage uintptr + CopyTo uintptr + MoveElementTo uintptr + Commit uintptr + Revert uintptr + EnumElements uintptr + DestroyElement uintptr + RenameElement uintptr + SetElementTimes uintptr + SetClass uintptr + SetStateBits uintptr + Stat uintptr +} + +type IStorage struct { + LpVtbl *IStorageVtbl +} diff --git a/richole.go b/richole.go new file mode 100644 index 00000000..e1e3fa65 --- /dev/null +++ b/richole.go @@ -0,0 +1,213 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +type REOBJECT struct { + cbStruct uint32 // Size of structure + cp int32 // Character position of object + clsid CLSID // Class ID of object + poleobj *IOleObject // OLE object interface + pstg *IStorage // Associated storage interface + polesite *IOleClientSite // Associated client site interface + sizel SIZE // Size of object (may be 0,0) + dvaspect uint32 // Display aspect to use + dwFlags uint32 // Object status flags + dwUser uint32 // Dword for user's use +} + +type IRichEditOleVtbl struct { + IUnknownVtbl + GetClientSite uintptr + GetObjectCount uintptr + GetLinkCount uintptr + GetObject uintptr + InsertObject uintptr + ConvertObject uintptr + ActivateAs uintptr + SetHostNames uintptr + SetLinkAvailable uintptr + SetDvaspect uintptr + HandsOffStorage uintptr + SaveCompleted uintptr + InPlaceDeactivate uintptr + ContextSensitiveHelp uintptr + GetClipboardData uintptr + ImportDataObject uintptr +} + +type IRichEditOle struct { + LpVtbl *IRichEditOleVtbl +} + +func (obj *IRichEditOle) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(ppvObject))) + return HRESULT(ret) +} + +func (obj *IRichEditOle) AddRef() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *IRichEditOle) Release() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *IRichEditOle) GetClientSite(lplpolesite **IOleClientSite) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetClientSite, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lplpolesite)), + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) GetObjectCount() int32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetObjectCount, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return int32(ret) +} + +func (obj *IRichEditOle) GetLinkCount() int32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetLinkCount, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return int32(ret) +} + +func (obj *IRichEditOle) GetObject(iob int32, lpreobject *REOBJECT, dwFlags uint32) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetObject, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(unsafe.Pointer(lpreobject)), + uintptr(dwFlags), + 0, + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) InsertObject(lpreobject *REOBJECT) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.InsertObject, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lpreobject)), + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) ConvertObject(iob int32, rclsidNew REFCLSID, lpstrUserTypeNew *byte) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ConvertObject, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(unsafe.Pointer(rclsidNew)), + uintptr(unsafe.Pointer(lpstrUserTypeNew)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) ActivateAs(rclsid REFCLSID, rclsidAs REFCLSID) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.ActivateAs, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(rclsid)), + uintptr(unsafe.Pointer(rclsidAs))) + return HRESULT(ret) +} + +func (obj *IRichEditOle) SetHostNames(lpstrContainerApp *byte, lpstrContainerObj *byte) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetHostNames, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lpstrContainerApp)), + uintptr(unsafe.Pointer(lpstrContainerObj))) + return HRESULT(ret) +} + +func (obj *IRichEditOle) SetLinkAvailable(iob int32, fAvailable BOOL) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetLinkAvailable, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(fAvailable)) + return HRESULT(ret) +} + +func (obj *IRichEditOle) SetDvaspect(iob int32, dvaspect uint32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetDvaspect, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(dvaspect)) + return HRESULT(ret) +} + +func (obj *IRichEditOle) HandsOffStorage(iob int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.HandsOffStorage, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) SaveCompleted(iob int32, lpstg *IStorage) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SaveCompleted, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(unsafe.Pointer(lpstg))) + return HRESULT(ret) +} + +func (obj *IRichEditOle) InPlaceDeactivate() HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.InPlaceDeactivate, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) ContextSensitiveHelp(fEnterMode BOOL) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.ContextSensitiveHelp, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(fEnterMode), + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) GetClipboardData(lpchrg *CHARRANGE, reco uint32, lplpdataobj **IDataObject) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetClipboardData, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lpchrg)), + uintptr(reco), + uintptr(unsafe.Pointer(lplpdataobj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) ImportDataObject(lpdataobj *IDataObject, cf CLIPFORMAT, hMetaPict HGLOBAL) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ImportDataObject, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lpdataobj)), + uintptr(cf), + uintptr(hMetaPict), + 0, + 0) + return HRESULT(ret) +} diff --git a/tom.go b/tom.go new file mode 100644 index 00000000..7587c2fb --- /dev/null +++ b/tom.go @@ -0,0 +1,989 @@ +// Copyright 2011 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +type TomConstants uint32 + +const ( + TomFalse TomConstants = 0 + TomTrue = -1 + TomUndefined = -9999999 + TomToggle = -9999998 + TomAutoColor = -9999997 + TomDefault = -9999996 + TomSuspend = -9999995 + TomResume = -9999994 + TomApplyNow = 0 + TomApplyLater = 1 + TomTrackParms = 2 + TomCacheParms = 3 + TomApplyTmp = 4 + TomDisableSmartFont = 8 + TomEnableSmartFont = 9 + TomUsePoints = 10 + TomUseTwips = 11 + TomBackward = 0xc0000001 + TomForward = 0x3fffffff + TomMove = 0 + TomExtend = 1 + TomNoSelection = 0 + TomSelectionIP = 1 + TomSelectionNormal = 2 + TomSelectionFrame = 3 + TomSelectionColumn = 4 + TomSelectionRow = 5 + TomSelectionBlock = 6 + TomSelectionInlineShape = 7 + TomSelectionShape = 8 + TomSelStartActive = 1 + TomSelAtEOL = 2 + TomSelOvertype = 4 + TomSelActive = 8 + TomSelReplace = 16 + TomEnd = 0 + TomStart = 32 + TomCollapseEnd = 0 + TomCollapseStart = 1 + TomClientCoord = 256 + TomAllowOffClient = 512 + TomTransform = 1024 + TomObjectArg = 2048 + TomAtEnd = 4096 + TomNone = 0 + TomSingle = 1 + TomWords = 2 + TomDouble = 3 + TomDotted = 4 + TomDash = 5 + TomDashDot = 6 + TomDashDotDot = 7 + TomWave = 8 + TomThick = 9 + TomHair = 10 + TomDoubleWave = 11 + TomHeavyWave = 12 + TomLongDash = 13 + TomThickDash = 14 + TomThickDashDot = 15 + TomThickDashDotDot = 16 + TomThickDotted = 17 + TomThickLongDash = 18 + TomLineSpaceSingle = 0 + TomLineSpace1pt5 = 1 + TomLineSpaceDouble = 2 + TomLineSpaceAtLeast = 3 + TomLineSpaceExactly = 4 + TomLineSpaceMultiple = 5 + TomLineSpacePercent = 6 + TomAlignLeft = 0 + TomAlignCenter = 1 + TomAlignRight = 2 + TomAlignJustify = 3 + TomAlignDecimal = 3 + TomAlignBar = 4 + TomDefaultTab = 5 + TomAlignInterWord = 3 + TomAlignNewspaper = 4 + TomAlignInterLetter = 5 + TomAlignScaled = 6 + TomSpaces = 0 + TomDots = 1 + TomDashes = 2 + TomLines = 3 + TomThickLines = 4 + TomEquals = 5 + TomTabBack = -3 + TomTabNext = -2 + TomTabHere = -1 + TomListNone = 0 + TomListBullet = 1 + TomListNumberAsArabic = 2 + TomListNumberAsLCLetter = 3 + TomListNumberAsUCLetter = 4 + TomListNumberAsLCRoman = 5 + TomListNumberAsUCRoman = 6 + TomListNumberAsSequence = 7 + TomListNumberedCircle = 8 + TomListNumberedBlackCircleWingding = 9 + TomListNumberedWhiteCircleWingding = 10 + TomListNumberedArabicWide = 11 + TomListNumberedChS = 12 + TomListNumberedChT = 13 + TomListNumberedJpnChS = 14 + TomListNumberedJpnKor = 15 + TomListNumberedArabic1 = 16 + TomListNumberedArabic2 = 17 + TomListNumberedHebrew = 18 + TomListNumberedThaiAlpha = 19 + TomListNumberedThaiNum = 20 + TomListNumberedHindiAlpha = 21 + TomListNumberedHindiAlpha1 = 22 + TomListNumberedHindiNum = 23 + TomListParentheses = 0x10000 + TomListPeriod = 0x20000 + TomListPlain = 0x30000 + TomListNoNumber = 0x40000 + TomListMinus = 0x80000 + TomIgnoreNumberStyle = 0x1000000 + TomParaStyleNormal = -1 + TomParaStyleHeading1 = -2 + TomParaStyleHeading2 = -3 + TomParaStyleHeading3 = -4 + TomParaStyleHeading4 = -5 + TomParaStyleHeading5 = -6 + TomParaStyleHeading6 = -7 + TomParaStyleHeading7 = -8 + TomParaStyleHeading8 = -9 + TomParaStyleHeading9 = -10 + TomCharacter = 1 + TomWord = 2 + TomSentence = 3 + TomParagraph = 4 + TomLine = 5 + TomStory = 6 + TomScreen = 7 + TomSection = 8 + TomTableColumn = 9 + TomColumn = 9 + TomRow = 10 + TomWindow = 11 + TomCell = 12 + TomCharFormat = 13 + TomParaFormat = 14 + TomTable = 15 + TomObject = 16 + TomPage = 17 + TomHardParagraph = 18 + TomCluster = 19 + TomInlineObject = 20 + TomInlineObjectArg = 21 + TomLeafLine = 22 + TomLayoutColumn = 23 + TomProcessId = 0x40000001 + TomMatchWord = 2 + TomMatchCase = 4 + TomMatchPattern = 8 + TomUnknownStory = 0 + TomMainTextStory = 1 + TomFootnotesStory = 2 + TomEndnotesStory = 3 + TomCommentsStory = 4 + TomTextFrameStory = 5 + TomEvenPagesHeaderStory = 6 + TomPrimaryHeaderStory = 7 + TomEvenPagesFooterStory = 8 + TomPrimaryFooterStory = 9 + TomFirstPageHeaderStory = 10 + TomFirstPageFooterStory = 11 + TomScratchStory = 127 + TomFindStory = 128 + TomReplaceStory = 129 + TomStoryInactive = 0 + TomStoryActiveDisplay = 1 + TomStoryActiveUI = 2 + TomStoryActiveDisplayUI = 3 + TomNoAnimation = 0 + TomLasVegasLights = 1 + TomBlinkingBackground = 2 + TomSparkleText = 3 + TomMarchingBlackAnts = 4 + TomMarchingRedAnts = 5 + TomShimmer = 6 + TomWipeDown = 7 + TomWipeRight = 8 + TomAnimationMax = 8 + TomLowerCase = 0 + TomUpperCase = 1 + TomTitleCase = 2 + TomSentenceCase = 4 + TomToggleCase = 5 + TomReadOnly = 0x100 + TomShareDenyRead = 0x200 + TomShareDenyWrite = 0x400 + TomPasteFile = 0x1000 + TomCreateNew = 0x10 + TomCreateAlways = 0x20 + TomOpenExisting = 0x30 + TomOpenAlways = 0x40 + TomTruncateExisting = 0x50 + TomRTF = 0x1 + TomText = 0x2 + TomHTML = 0x3 + TomWordDocument = 0x4 + TomBold = 0x80000001 + TomItalic = 0x80000002 + TomUnderline = 0x80000004 + TomStrikeout = 0x80000008 + TomProtected = 0x80000010 + TomLink = 0x80000020 + TomSmallCaps = 0x80000040 + TomAllCaps = 0x80000080 + TomHidden = 0x80000100 + TomOutline = 0x80000200 + TomShadow = 0x80000400 + TomEmboss = 0x80000800 + TomImprint = 0x80001000 + TomDisabled = 0x80002000 + TomRevised = 0x80004000 + TomSubscriptCF = 0x80010000 + TomSuperscriptCF = 0x80020000 + TomFontBound = 0x80100000 + TomLinkProtected = 0x80800000 + TomInlineObjectStart = 0x81000000 + TomExtendedChar = 0x82000000 + TomAutoBackColor = 0x84000000 + TomMathZoneNoBuildUp = 0x88000000 + TomMathZone = 0x90000000 + TomMathZoneOrdinary = 0xa0000000 + TomAutoTextColor = 0xc0000000 + TomMathZoneDisplay = 0x40000 + TomParaEffectRTL = 0x1 + TomParaEffectKeep = 0x2 + TomParaEffectKeepNext = 0x4 + TomParaEffectPageBreakBefore = 0x8 + TomParaEffectNoLineNumber = 0x10 + TomParaEffectNoWidowControl = 0x20 + TomParaEffectDoNotHyphen = 0x40 + TomParaEffectSideBySide = 0x80 + TomParaEffectCollapsed = 0x100 + TomParaEffectOutlineLevel = 0x200 + TomParaEffectBox = 0x400 + TomParaEffectTableRowDelimiter = 0x1000 + TomParaEffectTable = 0x4000 + TomModWidthPairs = 0x1 + TomModWidthSpace = 0x2 + TomAutoSpaceAlpha = 0x4 + TomAutoSpaceNumeric = 0x8 + TomAutoSpaceParens = 0x10 + TomEmbeddedFont = 0x20 + TomDoublestrike = 0x40 + TomOverlapping = 0x80 + TomNormalCaret = 0 + TomKoreanBlockCaret = 0x1 + TomNullCaret = 0x2 + TomIncludeInset = 0x1 + TomUnicodeBiDi = 0x1 + TomMathCFCheck = 0x4 + TomUnlink = 0x8 + TomUnhide = 0x10 + TomCheckTextLimit = 0x20 + TomIgnoreCurrentFont = 0 + TomMatchCharRep = 0x1 + TomMatchFontSignature = 0x2 + TomMatchAscii = 0x4 + TomGetHeightOnly = 0x8 + TomMatchMathFont = 0x10 + TomCharset = 0x80000000 + TomCharRepFromLcid = 0x40000000 + TomAnsi = 0 + TomEastEurope = 1 + TomCyrillic = 2 + TomGreek = 3 + TomTurkish = 4 + TomHebrew = 5 + TomArabic = 6 + TomBaltic = 7 + TomVietnamese = 8 + TomDefaultCharRep = 9 + TomSymbol = 10 + TomThai = 11 + TomShiftJIS = 12 + TomGB2312 = 13 + TomHangul = 14 + TomBIG5 = 15 + TomPC437 = 16 + TomOEM = 17 + TomMac = 18 + TomArmenian = 19 + TomSyriac = 20 + TomThaana = 21 + TomDevanagari = 22 + TomBengali = 23 + TomGurmukhi = 24 + TomGujarati = 25 + TomOriya = 26 + TomTamil = 27 + TomTelugu = 28 + TomKannada = 29 + TomMalayalam = 30 + TomSinhala = 31 + TomLao = 32 + TomTibetan = 33 + TomMyanmar = 34 + TomGeorgian = 35 + TomJamo = 36 + TomEthiopic = 37 + TomCherokee = 38 + TomAboriginal = 39 + TomOgham = 40 + TomRunic = 41 + TomKhmer = 42 + TomMongolian = 43 + TomBraille = 44 + TomYi = 45 + TomLimbu = 46 + TomTaiLe = 47 + TomNewTaiLue = 48 + TomSylotiNagri = 49 + TomKharoshthi = 50 + TomKayahli = 51 + TomUsymbol = 52 + TomEmoji = 53 + TomGlagolitic = 54 + TomLisu = 55 + TomVai = 56 + TomNKo = 57 + TomOsmanya = 58 + TomPhagsPa = 59 + TomGothic = 60 + TomDeseret = 61 + TomTifinagh = 62 + TomCharRepMax = 63 + TomRE10Mode = 0x1 + TomUseAtFont = 0x2 + TomTextFlowMask = 0xc + TomTextFlowES = 0 + TomTextFlowSW = 0x4 + TomTextFlowWN = 0x8 + TomTextFlowNE = 0xc + TomNoIME = 0x80000 + TomSelfIME = 0x40000 + TomNoUpScroll = 0x10000 + TomNoVpScroll = 0x40000 + TomNoLink = 0 + TomClientLink = 1 + TomFriendlyLinkName = 2 + TomFriendlyLinkAddress = 3 + TomAutoLinkURL = 4 + TomAutoLinkEmail = 5 + TomAutoLinkPhone = 6 + TomAutoLinkPath = 7 + TomCompressNone = 0 + TomCompressPunctuation = 1 + TomCompressPunctuationAndKana = 2 + TomCompressMax = 2 + TomUnderlinePositionAuto = 0 + TomUnderlinePositionBelow = 1 + TomUnderlinePositionAbove = 2 + TomUnderlinePositionMax = 2 + TomFontAlignmentAuto = 0 + TomFontAlignmentTop = 1 + TomFontAlignmentBaseline = 2 + TomFontAlignmentBottom = 3 + TomFontAlignmentCenter = 4 + TomFontAlignmentMax = 4 + TomRubyBelow = 0x80 + TomRubyAlignCenter = 0 + TomRubyAlign010 = 1 + TomRubyAlign121 = 2 + TomRubyAlignLeft = 3 + TomRubyAlignRight = 4 + TomLimitsDefault = 0 + TomLimitsUnderOver = 1 + TomLimitsSubSup = 2 + TomUpperLimitAsSuperScript = 3 + TomLimitsOpposite = 4 + TomShowLLimPlaceHldr = 8 + TomShowULimPlaceHldr = 16 + TomDontGrowWithContent = 64 + TomGrowWithContent = 128 + TomSubSupAlign = 1 + TomLimitAlignMask = 3 + TomLimitAlignCenter = 0 + TomLimitAlignLeft = 1 + TomLimitAlignRight = 2 + TomShowDegPlaceHldr = 8 + TomAlignDefault = 0 + TomAlignMatchAscentDescent = 2 + TomMathVariant = 0x20 + TomStyleDefault = 0 + TomStyleScriptScriptCramped = 1 + TomStyleScriptScript = 2 + TomStyleScriptCramped = 3 + TomStyleScript = 4 + TomStyleTextCramped = 5 + TomStyleText = 6 + TomStyleDisplayCramped = 7 + TomStyleDisplay = 8 + TomMathRelSize = 0x40 + TomDecDecSize = 0xfe + TomDecSize = 0xff + TomIncSize = (1 | TomMathRelSize) + TomIncIncSize = (2 | TomMathRelSize) + TomGravityUI = 0 + TomGravityBack = 1 + TomGravityFore = 2 + TomGravityIn = 3 + TomGravityOut = 4 + TomGravityBackward = 0x20000000 + TomGravityForward = 0x40000000 + TomAdjustCRLF = 1 + TomUseCRLF = 2 + TomTextize = 4 + TomAllowFinalEOP = 8 + TomFoldMathAlpha = 16 + TomNoHidden = 32 + TomIncludeNumbering = 64 + TomTranslateTableCell = 128 + TomNoMathZoneBrackets = 0x100 + TomConvertMathChar = 0x200 + TomNoUCGreekItalic = 0x400 + TomAllowMathBold = 0x800 + TomLanguageTag = 0x1000 + TomConvertRTF = 0x2000 + TomApplyRtfDocProps = 0x4000 + TomPhantomShow = 1 + TomPhantomZeroWidth = 2 + TomPhantomZeroAscent = 4 + TomPhantomZeroDescent = 8 + TomPhantomTransparent = 16 + TomPhantomASmash = (TomPhantomShow | TomPhantomZeroAscent) + TomPhantomDSmash = (TomPhantomShow | TomPhantomZeroDescent) + TomPhantomHSmash = (TomPhantomShow | TomPhantomZeroWidth) + TomPhantomSmash = ((TomPhantomShow | TomPhantomZeroAscent) | TomPhantomZeroDescent) + TomPhantomHorz = (TomPhantomZeroAscent | TomPhantomZeroDescent) + TomPhantomVert = TomPhantomZeroWidth + TomBoxHideTop = 1 + TomBoxHideBottom = 2 + TomBoxHideLeft = 4 + TomBoxHideRight = 8 + TomBoxStrikeH = 16 + TomBoxStrikeV = 32 + TomBoxStrikeTLBR = 64 + TomBoxStrikeBLTR = 128 + TomBoxAlignCenter = 1 + TomSpaceMask = 0x1c + TomSpaceDefault = 0 + TomSpaceUnary = 4 + TomSpaceBinary = 8 + TomSpaceRelational = 12 + TomSpaceSkip = 16 + TomSpaceOrd = 20 + TomSpaceDifferential = 24 + TomSizeText = 32 + TomSizeScript = 64 + TomSizeScriptScript = 96 + TomNoBreak = 128 + TomTransparentForPositioning = 256 + TomTransparentForSpacing = 512 + TomStretchCharBelow = 0 + TomStretchCharAbove = 1 + TomStretchBaseBelow = 2 + TomStretchBaseAbove = 3 + TomMatrixAlignMask = 3 + TomMatrixAlignCenter = 0 + TomMatrixAlignTopRow = 1 + TomMatrixAlignBottomRow = 3 + TomShowMatPlaceHldr = 8 + TomEqArrayLayoutWidth = 1 + TomEqArrayAlignMask = 0xc + TomEqArrayAlignCenter = 0 + TomEqArrayAlignTopRow = 4 + TomEqArrayAlignBottomRow = 0xc + TomMathManualBreakMask = 0x7f + TomMathBreakLeft = 0x7d + TomMathBreakCenter = 0x7e + TomMathBreakRight = 0x7f + TomMathEqAlign = 0x80 + TomMathArgShadingStart = 0x251 + TomMathArgShadingEnd = 0x252 + TomMathObjShadingStart = 0x253 + TomMathObjShadingEnd = 0x254 + TomFunctionTypeNone = 0 + TomFunctionTypeTakesArg = 1 + TomFunctionTypeTakesLim = 2 + TomFunctionTypeTakesLim2 = 3 + TomFunctionTypeIsLim = 4 + TomMathParaAlignDefault = 0 + TomMathParaAlignCenterGroup = 1 + TomMathParaAlignCenter = 2 + TomMathParaAlignLeft = 3 + TomMathParaAlignRight = 4 + TomMathDispAlignMask = 3 + TomMathDispAlignCenterGroup = 0 + TomMathDispAlignCenter = 1 + TomMathDispAlignLeft = 2 + TomMathDispAlignRight = 3 + TomMathDispIntUnderOver = 4 + TomMathDispFracTeX = 8 + TomMathDispNaryGrow = 0x10 + TomMathDocEmptyArgMask = 0x60 + TomMathDocEmptyArgAuto = 0 + TomMathDocEmptyArgAlways = 0x20 + TomMathDocEmptyArgNever = 0x40 + TomMathDocSbSpOpUnchanged = 0x80 + TomMathDocDiffMask = 0x300 + TomMathDocDiffDefault = 0 + TomMathDocDiffUpright = 0x100 + TomMathDocDiffItalic = 0x200 + TomMathDocDiffOpenItalic = 0x300 + TomMathDispNarySubSup = 0x400 + TomMathDispDef = 0x800 + TomMathEnableRtl = 0x1000 + TomMathBrkBinMask = 0x30000 + TomMathBrkBinBefore = 0 + TomMathBrkBinAfter = 0x10000 + TomMathBrkBinDup = 0x20000 + TomMathBrkBinSubMask = 0xc0000 + TomMathBrkBinSubMM = 0 + TomMathBrkBinSubPM = 0x40000 + TomMathBrkBinSubMP = 0x80000 + TomSelRange = 0x255 + TomHstring = 0x254 + TomFontPropTeXStyle = 0x33c + TomFontPropAlign = 0x33d + TomFontStretch = 0x33e + TomFontStyle = 0x33f + TomFontStyleUpright = 0 + TomFontStyleOblique = 1 + TomFontStyleItalic = 2 + TomFontStretchDefault = 0 + TomFontStretchUltraCondensed = 1 + TomFontStretchExtraCondensed = 2 + TomFontStretchCondensed = 3 + TomFontStretchSemiCondensed = 4 + TomFontStretchNormal = 5 + TomFontStretchSemiExpanded = 6 + TomFontStretchExpanded = 7 + TomFontStretchExtraExpanded = 8 + TomFontStretchUltraExpanded = 9 + TomFontWeightDefault = 0 + TomFontWeightThin = 100 + TomFontWeightExtraLight = 200 + TomFontWeightLight = 300 + TomFontWeightNormal = 400 + TomFontWeightRegular = 400 + TomFontWeightMedium = 500 + TomFontWeightSemiBold = 600 + TomFontWeightBold = 700 + TomFontWeightExtraBold = 800 + TomFontWeightBlack = 900 + TomFontWeightHeavy = 900 + TomFontWeightExtraBlack = 950 + TomParaPropMathAlign = 0x437 + TomDocMathBuild = 0x80 + TomMathLMargin = 0x81 + TomMathRMargin = 0x82 + TomMathWrapIndent = 0x83 + TomMathWrapRight = 0x84 + TomMathPostSpace = 0x86 + TomMathPreSpace = 0x85 + TomMathInterSpace = 0x87 + TomMathIntraSpace = 0x88 + TomCanCopy = 0x89 + TomCanRedo = 0x8a + TomCanUndo = 0x8b + TomUndoLimit = 0x8c + TomDocAutoLink = 0x8d + TomEllipsisMode = 0x8e + TomEllipsisState = 0x8f + TomEllipsisNone = 0 + TomEllipsisEnd = 1 + TomEllipsisWord = 3 + TomEllipsisPresent = 1 + TomVTopCell = 1 + TomVLowCell = 2 + TomHStartCell = 4 + TomHContCell = 8 + TomRowUpdate = 1 + TomRowApplyDefault = 0 + TomCellStructureChangeOnly = 1 + TomRowHeightActual = 0x80b +) + +type OBJECTTYPE int32 + +const ( + TomSimpleText OBJECTTYPE = 0 + TomRuby = (TomSimpleText + 1) + TomHorzVert = (TomRuby + 1) + TomWarichu = (TomHorzVert + 1) + TomEq = 9 + TomMath = 10 + TomAccent = TomMath + TomBox = (TomAccent + 1) + TomBoxedFormula = (TomBox + 1) + TomBrackets = (TomBoxedFormula + 1) + TomBracketsWithSeps = (TomBrackets + 1) + TomEquationArray = (TomBracketsWithSeps + 1) + TomFraction = (TomEquationArray + 1) + TomFunctionApply = (TomFraction + 1) + TomLeftSubSup = (TomFunctionApply + 1) + TomLowerLimit = (TomLeftSubSup + 1) + TomMatrix = (TomLowerLimit + 1) + TomNary = (TomMatrix + 1) + TomOpChar = (TomNary + 1) + TomOverbar = (TomOpChar + 1) + TomPhanTom = (TomOverbar + 1) + TomRadical = (TomPhanTom + 1) + TomSlashedFraction = (TomRadical + 1) + TomStack = (TomSlashedFraction + 1) + TomStretchStack = (TomStack + 1) + TomSubscript = (TomStretchStack + 1) + TomSubSup = (TomSubscript + 1) + TomSuperscript = (TomSubSup + 1) + TomUnderbar = (TomSuperscript + 1) + TomUpperLimit = (TomUnderbar + 1) + TomObjectMax = TomUpperLimit +) + +type ITextRangeVtbl struct { + IDispatchVtbl + GetText uintptr + SetText uintptr + GetChar uintptr + SetChar uintptr + GetDuplicate uintptr + GetFormattedText uintptr + SetFormattedText uintptr + GetStart uintptr + SetStart uintptr + GetEnd uintptr + SetEnd uintptr + GetFont uintptr + SetFont uintptr + GetPara uintptr + SetPara uintptr + GetStoryLength uintptr + GetStoryType uintptr + Collapse uintptr + Expand uintptr + GetIndex uintptr + SetIndex uintptr + SetRange uintptr + InRange uintptr + InStory uintptr + IsEqual uintptr + Select uintptr + StartOf uintptr + EndOf uintptr + Move uintptr + MoveStart uintptr + MoveEnd uintptr + MoveWhile uintptr + MoveStartWhile uintptr + MoveEndWhile uintptr + MoveUntil uintptr + MoveStartUntil uintptr + MoveEndUntil uintptr + FindText uintptr + FindTextStart uintptr + FindTextEnd uintptr + Delete uintptr + Cut uintptr + Copy uintptr + Paste uintptr + CanPaste uintptr + CanEdit uintptr + ChangeCase uintptr + GetPoint uintptr + SetPoint uintptr + ScrollIntoView uintptr + GetEmbeddedObject uintptr +} + +type ITextRange struct { + LpVtbl *ITextRangeVtbl +} + +type ITextSelectionVtbl struct { + ITextRangeVtbl + GetFlags uintptr + SetFlags uintptr + GetType uintptr + MoveLeft uintptr + MoveRight uintptr + MoveUp uintptr + MoveDown uintptr + HomeKey uintptr + EndKey uintptr + TypeText uintptr +} + +type ITextSelection struct { + LpVtbl *ITextSelectionVtbl +} + +type ITextDocumentVtbl struct { + IDispatchVtbl + GetName uintptr + GetSelection uintptr + GetStoryCount uintptr + GetStoryRanges uintptr + GetSaved uintptr + SetSaved uintptr + GetDefaultTabStop uintptr + SetDefaultTabStop uintptr + New uintptr + Open uintptr + Save uintptr + Freeze uintptr + Unfreeze uintptr + BeginEditCollection uintptr + EndEditCollection uintptr + Undo uintptr + Redo uintptr + Range uintptr + RangeFromPoint uintptr +} + +type ITextStoryRangesVtbl struct { + IDispatchVtbl + NewEnum uintptr + Item uintptr + GetCount uintptr +} + +type ITextStoryRanges struct { + LpVtbl *ITextStoryRangesVtbl +} + +var ( + IID_ITextDocument = IID{0x8CC497C0, 0xA1DF, 0x11CE, [8]byte{0x80, 0x98, 0x00, 0xAA, 0x00, 0x47, 0xBE, 0x5D}} +) + +type ITextDocument struct { + LpVtbl *ITextDocumentVtbl +} + +func (obj *ITextDocument) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(ppvObject))) + return HRESULT(ret) +} + +func (obj *ITextDocument) AddRef() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *ITextDocument) Release() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *ITextDocument) GetTypeInfoCount(pctinfo *uint32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetTypeInfoCount, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pctinfo)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetTypeInfo(iTInfo uint32, lcid LCID, ppTInfo **ITypeInfo) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetTypeInfo, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(iTInfo), + uintptr(lcid), + uintptr(unsafe.Pointer(ppTInfo)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetIDsOfNames(riid REFIID, rgszNames **uint16, cNames uint32, lcid LCID, rgDispId *DISPID) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetIDsOfNames, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(rgszNames)), + uintptr(cNames), + uintptr(lcid), + uintptr(unsafe.Pointer(rgDispId))) + return HRESULT(ret) +} + +func (obj *ITextDocument) Invoke(dispIdMember DISPID, riid REFIID, lcid LCID, wFlags uint16, pDispParams *DISPPARAMS, pVarResult *VARIANT, pExcepInfo *EXCEPINFO, puArgErr *uint32) HRESULT { + ret, _, _ := syscall.Syscall9(obj.LpVtbl.Invoke, 9, + uintptr(unsafe.Pointer(obj)), + uintptr(dispIdMember), + uintptr(unsafe.Pointer(riid)), + uintptr(lcid), + uintptr(wFlags), + uintptr(unsafe.Pointer(pDispParams)), + uintptr(unsafe.Pointer(pVarResult)), + uintptr(unsafe.Pointer(pExcepInfo)), + uintptr(unsafe.Pointer(puArgErr))) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetName(pName **uint16 /*BSTR*/) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetName, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pName)), + 0) + return HRESULT(ret) + +} + +func (obj *ITextDocument) GetSelection(ppSel **ITextSelection) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetSelection, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(ppSel)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetStoryCount(pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetStoryCount, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pCount)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetStoryRanges(ppStories **ITextStoryRanges) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetStoryRanges, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(ppStories)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetSaved(pValue *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetSaved, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pValue)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) SetSaved(Value int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetSaved, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(Value), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetDefaultTabStop(pValue *float32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetDefaultTabStop, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pValue)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) SetDefaultTabStop(Value float32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetDefaultTabStop, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(Value), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) New() HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.New, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Open(pVar *VARIANT, Flags int32, CodePage int32) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.Open, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pVar)), + uintptr(Flags), + uintptr(CodePage), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Save(pVar *VARIANT, Flags int32, CodePage int32) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.Save, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pVar)), + uintptr(Flags), + uintptr(CodePage), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Freeze(pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Freeze, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pCount)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Unfreeze(pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Freeze, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pCount)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) BeginEditCollection() HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.BeginEditCollection, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) EndEditCollection() HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.EndEditCollection, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Undo(Count int32, pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Undo, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(Count), + uintptr(unsafe.Pointer(pCount))) + return HRESULT(ret) +} + +func (obj *ITextDocument) Redo(Count int32, pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Redo, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(Count), + uintptr(unsafe.Pointer(pCount))) + return HRESULT(ret) +} + +func (obj *ITextDocument) Range(cpActive int32, cpAnchor int32, ppRange **ITextRange) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.Range, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(cpActive), + uintptr(cpAnchor), + uintptr(unsafe.Pointer(ppRange)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) RangeFromPoint(x int32, y int32, ppRange **ITextRange) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.RangeFromPoint, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(x), + uintptr(y), + uintptr(unsafe.Pointer(ppRange)), + 0, + 0) + return HRESULT(ret) +} From 83d447139eb246f787f33215aa9edd54aa61b847 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 3 Feb 2021 23:57:23 +0100 Subject: [PATCH 138/138] Port to arm64 Updates: https://github.com/golang/go/issues/36439 Updates: https://github.com/golang/go/issues/44020 Signed-off-by: Jason A. Donenfeld --- oleacc_64.go => oleacc_amd64.go | 0 oleacc_arm64.go | 98 +++++++++++++++++++++++++++++++++ oleaut32_64.go | 2 +- shobj_64.go | 2 +- 4 files changed, 100 insertions(+), 2 deletions(-) rename oleacc_64.go => oleacc_amd64.go (100%) create mode 100644 oleacc_arm64.go diff --git a/oleacc_64.go b/oleacc_amd64.go similarity index 100% rename from oleacc_64.go rename to oleacc_amd64.go diff --git a/oleacc_arm64.go b/oleacc_arm64.go new file mode 100644 index 00000000..0b029e5a --- /dev/null +++ b/oleacc_arm64.go @@ -0,0 +1,98 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows,arm64 + +package win + +import ( + "syscall" + "unsafe" +) + +func (idProp *MSAAPROPID) split() (uintptr, uintptr) { + if idProp == nil { + return 0, 0 + } + x := (*struct { a, b uintptr })(unsafe.Pointer(idProp)) + return x.a, x.b +} + +// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. +// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer +func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { + var idStringPtr unsafe.Pointer + idStringLen := len(idString) + if idStringLen != 0 { + idStringPtr = unsafe.Pointer(&idString[0]) + } + propA, propB := idProp.split() + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(idStringPtr), + uintptr(idStringLen), + propA, propB, + uintptr(unsafe.Pointer(v))) + return HRESULT(ret) +} + +// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead. +func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + propA, propB := idProp.split() + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndProp, 7, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + propA, propB, + uintptr(unsafe.Pointer(v)), + 0, 0) + return HRESULT(ret) +} + +// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. +func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) + } + propA, propB := idProp.split() + ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropStr, 7, + uintptr(unsafe.Pointer(obj)), + uintptr(hwnd), + uintptr(idObject), + uintptr(idChild), + propA, propB, + uintptr(unsafe.Pointer(str16)), + 0, 0) + return HRESULT(ret) +} + +// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead. +func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { + propA, propB := idProp.split() + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + propA, propB, + uintptr(unsafe.Pointer(v))) + return HRESULT(ret) +} + +// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. +func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { + str16, err := syscall.UTF16PtrFromString(str) + if err != nil { + return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) + } + propA, propB := idProp.split() + ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(hmenu), + uintptr(idChild), + propA, propB, + uintptr(unsafe.Pointer(str16))) + return HRESULT(ret) +} diff --git a/oleaut32_64.go b/oleaut32_64.go index 20bc7cb9..4046a008 100644 --- a/oleaut32_64.go +++ b/oleaut32_64.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build windows,amd64 +// +build windows,amd64 windows,arm64 package win diff --git a/shobj_64.go b/shobj_64.go index 60978d75..6e75ffd4 100644 --- a/shobj_64.go +++ b/shobj_64.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build windows,amd64 +// +build windows,amd64 windows,arm64 package win