├── AUTHORS ├── LICENSE ├── README.mdown ├── advapi32.go ├── combobox.go ├── comctl32.go ├── comdlg32.go ├── datetimepicker.go ├── edit.go ├── gdi32.go ├── gdiplus.go ├── go.mod ├── header.go ├── kernel32.go ├── listbox.go ├── listview.go ├── menu.go ├── oaidl.go ├── objidl.go ├── ole32.go ├── oleacc.go ├── oleacc_32.go ├── oleacc_amd64.go ├── oleacc_arm64.go ├── oleaut32.go ├── oleaut32_32.go ├── oleaut32_64.go ├── opengl32.go ├── pdh.go ├── richedit.go ├── richole.go ├── shdocvw.go ├── shell32.go ├── shobj.go ├── shobj_32.go ├── shobj_64.go ├── statusbar.go ├── syslink.go ├── tab.go ├── tom.go ├── toolbar.go ├── tooltip.go ├── treeview.go ├── updown.go ├── user32.go ├── uxtheme.go ├── win.go ├── winnls.go └── winspool.go /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of 'win' authors for copyright purposes. 2 | 3 | # Names should be added to this file as 4 | # Name or Organization 5 | # The email address is not required for organizations. 6 | 7 | # Please keep the list sorted. 8 | 9 | # Contributors 10 | # ============ 11 | 12 | Alexander Neumann 13 | Aman Gupta 14 | Anton Lahti 15 | Benny Siegert 16 | Brad Fitzpatrick 17 | Bruno Bigras 18 | Carl Kittelberger 19 | Carlos Cobo 20 | Cary Cherng 21 | Cory Redmond 22 | David Porter 23 | Dmitry Bagdanov 24 | gonutz 25 | Hill 26 | Jason A. Donenfeld 27 | Joseph Watson 28 | Kevin Pors 29 | ktye 30 | mycaosf 31 | ryujimiya 32 | Simon Rozman 33 | Tiago Carvalho 34 | wsf01 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 The win Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 1. Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. The names of the authors may not be used to endorse or promote products 12 | derived from this software without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /README.mdown: -------------------------------------------------------------------------------- 1 | About win 2 | ========= 3 | 4 | win is a Windows API wrapper package for Go. 5 | 6 | Originally part of [walk](https://github.com/lxn/walk), it is now a separate 7 | project. 8 | 9 | Setup 10 | ===== 11 | 12 | Make sure you have a working Go installation. 13 | See [Getting Started](http://golang.org/doc/install.html) 14 | 15 | Now run `go get github.com/lxn/win` 16 | -------------------------------------------------------------------------------- /advapi32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "golang.org/x/sys/windows" 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | const KEY_READ REGSAM = 0x20019 16 | const KEY_WRITE REGSAM = 0x20006 17 | 18 | const ( 19 | HKEY_CLASSES_ROOT HKEY = 0x80000000 20 | HKEY_CURRENT_USER HKEY = 0x80000001 21 | HKEY_LOCAL_MACHINE HKEY = 0x80000002 22 | HKEY_USERS HKEY = 0x80000003 23 | HKEY_PERFORMANCE_DATA HKEY = 0x80000004 24 | HKEY_CURRENT_CONFIG HKEY = 0x80000005 25 | HKEY_DYN_DATA HKEY = 0x80000006 26 | ) 27 | 28 | const ( 29 | ERROR_NO_MORE_ITEMS = 259 30 | ) 31 | 32 | type ( 33 | ACCESS_MASK uint32 34 | HKEY HANDLE 35 | REGSAM ACCESS_MASK 36 | ) 37 | 38 | const ( 39 | REG_NONE uint64 = 0 // No value type 40 | REG_SZ = 1 // Unicode nul terminated string 41 | REG_EXPAND_SZ = 2 // Unicode nul terminated string 42 | // (with environment variable references) 43 | REG_BINARY = 3 // Free form binary 44 | REG_DWORD = 4 // 32-bit number 45 | REG_DWORD_LITTLE_ENDIAN = 4 // 32-bit number (same as REG_DWORD) 46 | REG_DWORD_BIG_ENDIAN = 5 // 32-bit number 47 | REG_LINK = 6 // Symbolic Link (unicode) 48 | REG_MULTI_SZ = 7 // Multiple Unicode strings 49 | REG_RESOURCE_LIST = 8 // Resource list in the resource map 50 | REG_FULL_RESOURCE_DESCRIPTOR = 9 // Resource list in the hardware description 51 | REG_RESOURCE_REQUIREMENTS_LIST = 10 52 | REG_QWORD = 11 // 64-bit number 53 | REG_QWORD_LITTLE_ENDIAN = 11 // 64-bit number (same as REG_QWORD) 54 | 55 | ) 56 | 57 | var ( 58 | // Library 59 | libadvapi32 *windows.LazyDLL 60 | 61 | // Functions 62 | regCloseKey *windows.LazyProc 63 | regOpenKeyEx *windows.LazyProc 64 | regQueryValueEx *windows.LazyProc 65 | regEnumValue *windows.LazyProc 66 | regSetValueEx *windows.LazyProc 67 | ) 68 | 69 | func init() { 70 | // Library 71 | libadvapi32 = windows.NewLazySystemDLL("advapi32.dll") 72 | 73 | // Functions 74 | regCloseKey = libadvapi32.NewProc("RegCloseKey") 75 | regOpenKeyEx = libadvapi32.NewProc("RegOpenKeyExW") 76 | regQueryValueEx = libadvapi32.NewProc("RegQueryValueExW") 77 | regEnumValue = libadvapi32.NewProc("RegEnumValueW") 78 | regSetValueEx = libadvapi32.NewProc("RegSetValueExW") 79 | } 80 | 81 | func RegCloseKey(hKey HKEY) int32 { 82 | ret, _, _ := syscall.Syscall(regCloseKey.Addr(), 1, 83 | uintptr(hKey), 84 | 0, 85 | 0) 86 | 87 | return int32(ret) 88 | } 89 | 90 | func RegOpenKeyEx(hKey HKEY, lpSubKey *uint16, ulOptions uint32, samDesired REGSAM, phkResult *HKEY) int32 { 91 | ret, _, _ := syscall.Syscall6(regOpenKeyEx.Addr(), 5, 92 | uintptr(hKey), 93 | uintptr(unsafe.Pointer(lpSubKey)), 94 | uintptr(ulOptions), 95 | uintptr(samDesired), 96 | uintptr(unsafe.Pointer(phkResult)), 97 | 0) 98 | 99 | return int32(ret) 100 | } 101 | 102 | func RegQueryValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpType *uint32, lpData *byte, lpcbData *uint32) int32 { 103 | ret, _, _ := syscall.Syscall6(regQueryValueEx.Addr(), 6, 104 | uintptr(hKey), 105 | uintptr(unsafe.Pointer(lpValueName)), 106 | uintptr(unsafe.Pointer(lpReserved)), 107 | uintptr(unsafe.Pointer(lpType)), 108 | uintptr(unsafe.Pointer(lpData)), 109 | uintptr(unsafe.Pointer(lpcbData))) 110 | 111 | return int32(ret) 112 | } 113 | 114 | func RegEnumValue(hKey HKEY, index uint32, lpValueName *uint16, lpcchValueName *uint32, lpReserved, lpType *uint32, lpData *byte, lpcbData *uint32) int32 { 115 | ret, _, _ := syscall.Syscall9(regEnumValue.Addr(), 8, 116 | uintptr(hKey), 117 | uintptr(index), 118 | uintptr(unsafe.Pointer(lpValueName)), 119 | uintptr(unsafe.Pointer(lpcchValueName)), 120 | uintptr(unsafe.Pointer(lpReserved)), 121 | uintptr(unsafe.Pointer(lpType)), 122 | uintptr(unsafe.Pointer(lpData)), 123 | uintptr(unsafe.Pointer(lpcbData)), 124 | 0) 125 | return int32(ret) 126 | } 127 | 128 | func RegSetValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpDataType uint64, lpData *byte, cbData uint32) int32 { 129 | ret, _, _ := syscall.Syscall6(regSetValueEx.Addr(), 6, 130 | uintptr(hKey), 131 | uintptr(unsafe.Pointer(lpValueName)), 132 | uintptr(lpReserved), 133 | uintptr(lpDataType), 134 | uintptr(unsafe.Pointer(lpData)), 135 | uintptr(cbData)) 136 | return int32(ret) 137 | } 138 | -------------------------------------------------------------------------------- /combobox.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | // ComboBox return values 10 | const ( 11 | CB_OKAY = 0 12 | CB_ERR = ^uintptr(0) // -1 13 | CB_ERRSPACE = ^uintptr(1) // -2 14 | ) 15 | 16 | // ComboBox notifications 17 | const ( 18 | CBN_ERRSPACE = -1 19 | CBN_SELCHANGE = 1 20 | CBN_DBLCLK = 2 21 | CBN_SETFOCUS = 3 22 | CBN_KILLFOCUS = 4 23 | CBN_EDITCHANGE = 5 24 | CBN_EDITUPDATE = 6 25 | CBN_DROPDOWN = 7 26 | CBN_CLOSEUP = 8 27 | CBN_SELENDOK = 9 28 | CBN_SELENDCANCEL = 10 29 | ) 30 | 31 | // ComboBox styles 32 | const ( 33 | CBS_SIMPLE = 0x0001 34 | CBS_DROPDOWN = 0x0002 35 | CBS_DROPDOWNLIST = 0x0003 36 | CBS_OWNERDRAWFIXED = 0x0010 37 | CBS_OWNERDRAWVARIABLE = 0x0020 38 | CBS_AUTOHSCROLL = 0x0040 39 | CBS_OEMCONVERT = 0x0080 40 | CBS_SORT = 0x0100 41 | CBS_HASSTRINGS = 0x0200 42 | CBS_NOINTEGRALHEIGHT = 0x0400 43 | CBS_DISABLENOSCROLL = 0x0800 44 | CBS_UPPERCASE = 0x2000 45 | CBS_LOWERCASE = 0x4000 46 | ) 47 | 48 | // ComboBox messages 49 | const ( 50 | CB_GETEDITSEL = 0x0140 51 | CB_LIMITTEXT = 0x0141 52 | CB_SETEDITSEL = 0x0142 53 | CB_ADDSTRING = 0x0143 54 | CB_DELETESTRING = 0x0144 55 | CB_DIR = 0x0145 56 | CB_GETCOUNT = 0x0146 57 | CB_GETCURSEL = 0x0147 58 | CB_GETLBTEXT = 0x0148 59 | CB_GETLBTEXTLEN = 0x0149 60 | CB_INSERTSTRING = 0x014A 61 | CB_RESETCONTENT = 0x014B 62 | CB_FINDSTRING = 0x014C 63 | CB_SELECTSTRING = 0x014D 64 | CB_SETCURSEL = 0x014E 65 | CB_SHOWDROPDOWN = 0x014F 66 | CB_GETITEMDATA = 0x0150 67 | CB_SETITEMDATA = 0x0151 68 | CB_GETDROPPEDCONTROLRECT = 0x0152 69 | CB_SETITEMHEIGHT = 0x0153 70 | CB_GETITEMHEIGHT = 0x0154 71 | CB_SETEXTENDEDUI = 0x0155 72 | CB_GETEXTENDEDUI = 0x0156 73 | CB_GETDROPPEDSTATE = 0x0157 74 | CB_FINDSTRINGEXACT = 0x0158 75 | CB_SETLOCALE = 0x0159 76 | CB_GETLOCALE = 0x015A 77 | CB_GETTOPINDEX = 0x015b 78 | CB_SETTOPINDEX = 0x015c 79 | CB_GETHORIZONTALEXTENT = 0x015d 80 | CB_SETHORIZONTALEXTENT = 0x015e 81 | CB_GETDROPPEDWIDTH = 0x015f 82 | CB_SETDROPPEDWIDTH = 0x0160 83 | CB_INITSTORAGE = 0x0161 84 | CB_MULTIPLEADDSTRING = 0x0163 85 | CB_GETCOMBOBOXINFO = 0x0164 86 | ) 87 | -------------------------------------------------------------------------------- /comctl32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | 13 | "golang.org/x/sys/windows" 14 | ) 15 | 16 | // Button control messages 17 | const ( 18 | BCM_FIRST = 0x1600 19 | BCM_GETIDEALSIZE = BCM_FIRST + 0x0001 20 | BCM_SETIMAGELIST = BCM_FIRST + 0x0002 21 | BCM_GETIMAGELIST = BCM_FIRST + 0x0003 22 | BCM_SETTEXTMARGIN = BCM_FIRST + 0x0004 23 | BCM_GETTEXTMARGIN = BCM_FIRST + 0x0005 24 | BCM_SETDROPDOWNSTATE = BCM_FIRST + 0x0006 25 | BCM_SETSPLITINFO = BCM_FIRST + 0x0007 26 | BCM_GETSPLITINFO = BCM_FIRST + 0x0008 27 | BCM_SETNOTE = BCM_FIRST + 0x0009 28 | BCM_GETNOTE = BCM_FIRST + 0x000A 29 | BCM_GETNOTELENGTH = BCM_FIRST + 0x000B 30 | BCM_SETSHIELD = BCM_FIRST + 0x000C 31 | ) 32 | 33 | const ( 34 | CCM_FIRST = 0x2000 35 | CCM_LAST = CCM_FIRST + 0x200 36 | CCM_SETBKCOLOR = 8193 37 | CCM_SETCOLORSCHEME = 8194 38 | CCM_GETCOLORSCHEME = 8195 39 | CCM_GETDROPTARGET = 8196 40 | CCM_SETUNICODEFORMAT = 8197 41 | CCM_GETUNICODEFORMAT = 8198 42 | CCM_SETVERSION = 0x2007 43 | CCM_GETVERSION = 0x2008 44 | CCM_SETNOTIFYWINDOW = 0x2009 45 | CCM_SETWINDOWTHEME = 0x200b 46 | CCM_DPISCALE = 0x200c 47 | ) 48 | 49 | // Common controls styles 50 | const ( 51 | CCS_TOP = 1 52 | CCS_NOMOVEY = 2 53 | CCS_BOTTOM = 3 54 | CCS_NORESIZE = 4 55 | CCS_NOPARENTALIGN = 8 56 | CCS_ADJUSTABLE = 32 57 | CCS_NODIVIDER = 64 58 | CCS_VERT = 128 59 | CCS_LEFT = 129 60 | CCS_NOMOVEX = 130 61 | CCS_RIGHT = 131 62 | ) 63 | 64 | // InitCommonControlsEx flags 65 | const ( 66 | ICC_LISTVIEW_CLASSES = 1 67 | ICC_TREEVIEW_CLASSES = 2 68 | ICC_BAR_CLASSES = 4 69 | ICC_TAB_CLASSES = 8 70 | ICC_UPDOWN_CLASS = 16 71 | ICC_PROGRESS_CLASS = 32 72 | ICC_HOTKEY_CLASS = 64 73 | ICC_ANIMATE_CLASS = 128 74 | ICC_WIN95_CLASSES = 255 75 | ICC_DATE_CLASSES = 256 76 | ICC_USEREX_CLASSES = 512 77 | ICC_COOL_CLASSES = 1024 78 | ICC_INTERNET_CLASSES = 2048 79 | ICC_PAGESCROLLER_CLASS = 4096 80 | ICC_NATIVEFNTCTL_CLASS = 8192 81 | INFOTIPSIZE = 1024 82 | ICC_STANDARD_CLASSES = 0x00004000 83 | ICC_LINK_CLASS = 0x00008000 84 | ) 85 | 86 | // WM_NOTITY messages 87 | const ( 88 | NM_FIRST = 0 89 | NM_OUTOFMEMORY = ^uint32(0) // NM_FIRST - 1 90 | NM_CLICK = ^uint32(1) // NM_FIRST - 2 91 | NM_DBLCLK = ^uint32(2) // NM_FIRST - 3 92 | NM_RETURN = ^uint32(3) // NM_FIRST - 4 93 | NM_RCLICK = ^uint32(4) // NM_FIRST - 5 94 | NM_RDBLCLK = ^uint32(5) // NM_FIRST - 6 95 | NM_SETFOCUS = ^uint32(6) // NM_FIRST - 7 96 | NM_KILLFOCUS = ^uint32(7) // NM_FIRST - 8 97 | NM_CUSTOMDRAW = ^uint32(11) // NM_FIRST - 12 98 | NM_HOVER = ^uint32(12) // NM_FIRST - 13 99 | NM_NCHITTEST = ^uint32(13) // NM_FIRST - 14 100 | NM_KEYDOWN = ^uint32(14) // NM_FIRST - 15 101 | NM_RELEASEDCAPTURE = ^uint32(15) // NM_FIRST - 16 102 | NM_SETCURSOR = ^uint32(16) // NM_FIRST - 17 103 | NM_CHAR = ^uint32(17) // NM_FIRST - 18 104 | NM_TOOLTIPSCREATED = ^uint32(18) // NM_FIRST - 19 105 | NM_LAST = ^uint32(98) // NM_FIRST - 99 106 | TRBN_THUMBPOSCHANGING = 0xfffffa22 // TRBN_FIRST - 1 107 | ) 108 | 109 | // ProgressBar messages 110 | const ( 111 | PBM_SETPOS = WM_USER + 2 112 | PBM_DELTAPOS = WM_USER + 3 113 | PBM_SETSTEP = WM_USER + 4 114 | PBM_STEPIT = WM_USER + 5 115 | PBM_SETMARQUEE = WM_USER + 10 116 | PBM_SETRANGE32 = 1030 117 | PBM_GETRANGE = 1031 118 | PBM_GETPOS = 1032 119 | PBM_SETBARCOLOR = 1033 120 | PBM_SETBKCOLOR = CCM_SETBKCOLOR 121 | ) 122 | 123 | // ProgressBar styles 124 | const ( 125 | PBS_SMOOTH = 0x01 126 | PBS_VERTICAL = 0x04 127 | PBS_MARQUEE = 0x08 128 | ) 129 | 130 | // TrackBar (Slider) messages 131 | const ( 132 | TBM_GETPOS = WM_USER 133 | TBM_GETRANGEMIN = WM_USER + 1 134 | TBM_GETRANGEMAX = WM_USER + 2 135 | TBM_SETPOS = WM_USER + 5 136 | TBM_SETRANGEMIN = WM_USER + 7 137 | TBM_SETRANGEMAX = WM_USER + 8 138 | TBM_SETPAGESIZE = WM_USER + 21 139 | TBM_GETPAGESIZE = WM_USER + 22 140 | TBM_SETLINESIZE = WM_USER + 23 141 | TBM_GETLINESIZE = WM_USER + 24 142 | ) 143 | 144 | // TrackBar (Slider) styles 145 | const ( 146 | TBS_VERT = 0x002 147 | TBS_TOOLTIPS = 0x100 148 | ) 149 | 150 | // ImageList creation flags 151 | const ( 152 | ILC_MASK = 0x00000001 153 | ILC_COLOR = 0x00000000 154 | ILC_COLORDDB = 0x000000FE 155 | ILC_COLOR4 = 0x00000004 156 | ILC_COLOR8 = 0x00000008 157 | ILC_COLOR16 = 0x00000010 158 | ILC_COLOR24 = 0x00000018 159 | ILC_COLOR32 = 0x00000020 160 | ILC_PALETTE = 0x00000800 161 | ILC_MIRROR = 0x00002000 162 | ILC_PERITEMMIRROR = 0x00008000 163 | ) 164 | 165 | // ImageList_Draw[Ex] flags 166 | const ( 167 | ILD_NORMAL = 0x00000000 168 | ILD_TRANSPARENT = 0x00000001 169 | ILD_BLEND25 = 0x00000002 170 | ILD_BLEND50 = 0x00000004 171 | ILD_MASK = 0x00000010 172 | ILD_IMAGE = 0x00000020 173 | ILD_SELECTED = ILD_BLEND50 174 | ILD_FOCUS = ILD_BLEND25 175 | ILD_BLEND = ILD_BLEND50 176 | ) 177 | 178 | // LoadIconMetric flags 179 | const ( 180 | LIM_SMALL = 0 181 | LIM_LARGE = 1 182 | ) 183 | 184 | const ( 185 | CDDS_PREPAINT = 0x00000001 186 | CDDS_POSTPAINT = 0x00000002 187 | CDDS_PREERASE = 0x00000003 188 | CDDS_POSTERASE = 0x00000004 189 | CDDS_ITEM = 0x00010000 190 | CDDS_ITEMPREPAINT = CDDS_ITEM | CDDS_PREPAINT 191 | CDDS_ITEMPOSTPAINT = CDDS_ITEM | CDDS_POSTPAINT 192 | CDDS_ITEMPREERASE = CDDS_ITEM | CDDS_PREERASE 193 | CDDS_ITEMPOSTERASE = CDDS_ITEM | CDDS_POSTERASE 194 | CDDS_SUBITEM = 0x00020000 195 | ) 196 | 197 | const ( 198 | CDIS_SELECTED = 0x0001 199 | CDIS_GRAYED = 0x0002 200 | CDIS_DISABLED = 0x0004 201 | CDIS_CHECKED = 0x0008 202 | CDIS_FOCUS = 0x0010 203 | CDIS_DEFAULT = 0x0020 204 | CDIS_HOT = 0x0040 205 | CDIS_MARKED = 0x0080 206 | CDIS_INDETERMINATE = 0x0100 207 | CDIS_SHOWKEYBOARDCUES = 0x0200 208 | CDIS_NEARHOT = 0x0400 209 | CDIS_OTHERSIDEHOT = 0x0800 210 | CDIS_DROPHILITED = 0x1000 211 | ) 212 | 213 | const ( 214 | CDRF_DODEFAULT = 0x00000000 215 | CDRF_NEWFONT = 0x00000002 216 | CDRF_SKIPDEFAULT = 0x00000004 217 | CDRF_DOERASE = 0x00000008 218 | CDRF_NOTIFYPOSTPAINT = 0x00000010 219 | CDRF_NOTIFYITEMDRAW = 0x00000020 220 | CDRF_NOTIFYSUBITEMDRAW = 0x00000020 221 | CDRF_NOTIFYPOSTERASE = 0x00000040 222 | CDRF_SKIPPOSTPAINT = 0x00000100 223 | ) 224 | 225 | const ( 226 | LVIR_BOUNDS = 0 227 | LVIR_ICON = 1 228 | LVIR_LABEL = 2 229 | LVIR_SELECTBOUNDS = 3 230 | ) 231 | 232 | const ( 233 | LPSTR_TEXTCALLBACK = ^uintptr(0) 234 | I_CHILDRENCALLBACK = -1 235 | I_IMAGECALLBACK = -1 236 | I_IMAGENONE = -2 237 | ) 238 | 239 | type HIMAGELIST HANDLE 240 | 241 | type INITCOMMONCONTROLSEX struct { 242 | DwSize, DwICC uint32 243 | } 244 | 245 | type NMCUSTOMDRAW struct { 246 | Hdr NMHDR 247 | DwDrawStage uint32 248 | Hdc HDC 249 | Rc RECT 250 | DwItemSpec uintptr 251 | UItemState uint32 252 | LItemlParam uintptr 253 | } 254 | 255 | var ( 256 | // Library 257 | libcomctl32 *windows.LazyDLL 258 | 259 | // Functions 260 | imageList_Add *windows.LazyProc 261 | imageList_AddMasked *windows.LazyProc 262 | imageList_Create *windows.LazyProc 263 | imageList_Destroy *windows.LazyProc 264 | imageList_DrawEx *windows.LazyProc 265 | imageList_ReplaceIcon *windows.LazyProc 266 | initCommonControlsEx *windows.LazyProc 267 | loadIconMetric *windows.LazyProc 268 | loadIconWithScaleDown *windows.LazyProc 269 | ) 270 | 271 | func init() { 272 | // Library 273 | libcomctl32 = windows.NewLazySystemDLL("comctl32.dll") 274 | 275 | // Functions 276 | imageList_Add = libcomctl32.NewProc("ImageList_Add") 277 | imageList_AddMasked = libcomctl32.NewProc("ImageList_AddMasked") 278 | imageList_Create = libcomctl32.NewProc("ImageList_Create") 279 | imageList_Destroy = libcomctl32.NewProc("ImageList_Destroy") 280 | imageList_DrawEx = libcomctl32.NewProc("ImageList_DrawEx") 281 | imageList_ReplaceIcon = libcomctl32.NewProc("ImageList_ReplaceIcon") 282 | initCommonControlsEx = libcomctl32.NewProc("InitCommonControlsEx") 283 | loadIconMetric = libcomctl32.NewProc("LoadIconMetric") 284 | loadIconWithScaleDown = libcomctl32.NewProc("LoadIconWithScaleDown") 285 | } 286 | 287 | func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int32 { 288 | ret, _, _ := syscall.Syscall(imageList_Add.Addr(), 3, 289 | uintptr(himl), 290 | uintptr(hbmImage), 291 | uintptr(hbmMask)) 292 | 293 | return int32(ret) 294 | } 295 | 296 | func ImageList_AddMasked(himl HIMAGELIST, hbmImage HBITMAP, crMask COLORREF) int32 { 297 | ret, _, _ := syscall.Syscall(imageList_AddMasked.Addr(), 3, 298 | uintptr(himl), 299 | uintptr(hbmImage), 300 | uintptr(crMask)) 301 | 302 | return int32(ret) 303 | } 304 | 305 | func ImageList_Create(cx, cy int32, flags uint32, cInitial, cGrow int32) HIMAGELIST { 306 | ret, _, _ := syscall.Syscall6(imageList_Create.Addr(), 5, 307 | uintptr(cx), 308 | uintptr(cy), 309 | uintptr(flags), 310 | uintptr(cInitial), 311 | uintptr(cGrow), 312 | 0) 313 | 314 | return HIMAGELIST(ret) 315 | } 316 | 317 | func ImageList_Destroy(hIml HIMAGELIST) bool { 318 | ret, _, _ := syscall.Syscall(imageList_Destroy.Addr(), 1, 319 | uintptr(hIml), 320 | 0, 321 | 0) 322 | 323 | return ret != 0 324 | } 325 | 326 | func ImageList_DrawEx(himl HIMAGELIST, i int32, hdcDst HDC, x, y, dx, dy int32, rgbBk COLORREF, rgbFg COLORREF, fStyle uint32) bool { 327 | ret, _, _ := syscall.Syscall12(imageList_DrawEx.Addr(), 10, 328 | uintptr(himl), 329 | uintptr(i), 330 | uintptr(hdcDst), 331 | uintptr(x), 332 | uintptr(y), 333 | uintptr(dx), 334 | uintptr(dy), 335 | uintptr(rgbBk), 336 | uintptr(rgbFg), 337 | uintptr(fStyle), 338 | 0, 339 | 0) 340 | 341 | return ret != 0 342 | } 343 | 344 | func ImageList_ReplaceIcon(himl HIMAGELIST, i int32, hicon HICON) int32 { 345 | ret, _, _ := syscall.Syscall(imageList_ReplaceIcon.Addr(), 3, 346 | uintptr(himl), 347 | uintptr(i), 348 | uintptr(hicon)) 349 | 350 | return int32(ret) 351 | } 352 | 353 | func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool { 354 | ret, _, _ := syscall.Syscall(initCommonControlsEx.Addr(), 1, 355 | uintptr(unsafe.Pointer(lpInitCtrls)), 356 | 0, 357 | 0) 358 | 359 | return ret != 0 360 | } 361 | 362 | func LoadIconMetric(hInstance HINSTANCE, lpIconName *uint16, lims int32, hicon *HICON) HRESULT { 363 | if loadIconMetric.Find() != nil { 364 | return HRESULT(0) 365 | } 366 | ret, _, _ := syscall.Syscall6(loadIconMetric.Addr(), 4, 367 | uintptr(hInstance), 368 | uintptr(unsafe.Pointer(lpIconName)), 369 | uintptr(lims), 370 | uintptr(unsafe.Pointer(hicon)), 371 | 0, 372 | 0) 373 | 374 | return HRESULT(ret) 375 | } 376 | 377 | func LoadIconWithScaleDown(hInstance HINSTANCE, lpIconName *uint16, w int32, h int32, hicon *HICON) HRESULT { 378 | if loadIconWithScaleDown.Find() != nil { 379 | return HRESULT(0) 380 | } 381 | ret, _, _ := syscall.Syscall6(loadIconWithScaleDown.Addr(), 5, 382 | uintptr(hInstance), 383 | uintptr(unsafe.Pointer(lpIconName)), 384 | uintptr(w), 385 | uintptr(h), 386 | uintptr(unsafe.Pointer(hicon)), 387 | 0) 388 | 389 | return HRESULT(ret) 390 | } 391 | -------------------------------------------------------------------------------- /comdlg32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "golang.org/x/sys/windows" 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // Common error codes 16 | const ( 17 | CDERR_DIALOGFAILURE = 0xFFFF 18 | CDERR_FINDRESFAILURE = 0x0006 19 | CDERR_INITIALIZATION = 0x0002 20 | CDERR_LOADRESFAILURE = 0x0007 21 | CDERR_LOADSTRFAILURE = 0x0005 22 | CDERR_LOCKRESFAILURE = 0x0008 23 | CDERR_MEMALLOCFAILURE = 0x0009 24 | CDERR_MEMLOCKFAILURE = 0x000A 25 | CDERR_NOHINSTANCE = 0x0004 26 | CDERR_NOHOOK = 0x000B 27 | CDERR_NOTEMPLATE = 0x0003 28 | CDERR_REGISTERMSGFAIL = 0x000C 29 | CDERR_STRUCTSIZE = 0x0001 30 | ) 31 | 32 | // CHOOSECOLOR flags 33 | const ( 34 | CC_ANYCOLOR = 0x00000100 35 | CC_ENABLEHOOK = 0x00000010 36 | CC_ENABLETEMPLATE = 0x00000020 37 | CC_ENABLETEMPLATEHANDLE = 0x00000040 38 | CC_FULLOPEN = 0x00000002 39 | CC_PREVENTFULLOPEN = 0x00000004 40 | CC_RGBINIT = 0x00000001 41 | CC_SHOWHELP = 0x00000008 42 | CC_SOLIDCOLOR = 0x00000080 43 | ) 44 | 45 | type CHOOSECOLOR struct { 46 | LStructSize uint32 47 | HwndOwner HWND 48 | HInstance HWND 49 | RgbResult COLORREF 50 | LpCustColors *[16]COLORREF 51 | Flags uint32 52 | LCustData uintptr 53 | LpfnHook uintptr 54 | LpTemplateName *uint16 55 | } 56 | 57 | // PrintDlg specific error codes 58 | const ( 59 | PDERR_CREATEICFAILURE = 0x100A 60 | PDERR_DEFAULTDIFFERENT = 0x100C 61 | PDERR_DNDMMISMATCH = 0x1009 62 | PDERR_GETDEVMODEFAIL = 0x1005 63 | PDERR_INITFAILURE = 0x1006 64 | PDERR_LOADDRVFAILURE = 0x1004 65 | PDERR_NODEFAULTPRN = 0x1008 66 | PDERR_NODEVICES = 0x1007 67 | PDERR_PARSEFAILURE = 0x1002 68 | PDERR_PRINTERNOTFOUND = 0x100B 69 | PDERR_RETDEFFAILURE = 0x1003 70 | PDERR_SETUPFAILURE = 0x1001 71 | ) 72 | 73 | // ChooseFont specific error codes 74 | const ( 75 | CFERR_MAXLESSTHANMIN = 0x2002 76 | CFERR_NOFONTS = 0x2001 77 | ) 78 | 79 | // GetOpenFileName and GetSaveFileName specific error codes 80 | const ( 81 | FNERR_BUFFERTOOSMALL = 0x3003 82 | FNERR_INVALIDFILENAME = 0x3002 83 | FNERR_SUBCLASSFAILURE = 0x3001 84 | ) 85 | 86 | // FindText and ReplaceText specific error codes 87 | const ( 88 | FRERR_BUFFERLENGTHZERO = 0x4001 89 | ) 90 | 91 | // GetOpenFileName and GetSaveFileName flags 92 | const ( 93 | OFN_ALLOWMULTISELECT = 0x00000200 94 | OFN_CREATEPROMPT = 0x00002000 95 | OFN_DONTADDTORECENT = 0x02000000 96 | OFN_ENABLEHOOK = 0x00000020 97 | OFN_ENABLEINCLUDENOTIFY = 0x00400000 98 | OFN_ENABLESIZING = 0x00800000 99 | OFN_ENABLETEMPLATE = 0x00000040 100 | OFN_ENABLETEMPLATEHANDLE = 0x00000080 101 | OFN_EXPLORER = 0x00080000 102 | OFN_EXTENSIONDIFFERENT = 0x00000400 103 | OFN_FILEMUSTEXIST = 0x00001000 104 | OFN_FORCESHOWHIDDEN = 0x10000000 105 | OFN_HIDEREADONLY = 0x00000004 106 | OFN_LONGNAMES = 0x00200000 107 | OFN_NOCHANGEDIR = 0x00000008 108 | OFN_NODEREFERENCELINKS = 0x00100000 109 | OFN_NOLONGNAMES = 0x00040000 110 | OFN_NONETWORKBUTTON = 0x00020000 111 | OFN_NOREADONLYRETURN = 0x00008000 112 | OFN_NOTESTFILECREATE = 0x00010000 113 | OFN_NOVALIDATE = 0x00000100 114 | OFN_OVERWRITEPROMPT = 0x00000002 115 | OFN_PATHMUSTEXIST = 0x00000800 116 | OFN_READONLY = 0x00000001 117 | OFN_SHAREAWARE = 0x00004000 118 | OFN_SHOWHELP = 0x00000010 119 | ) 120 | 121 | // GetOpenFileName and GetSaveFileName extended flags 122 | const ( 123 | OFN_EX_NOPLACESBAR = 0x00000001 124 | ) 125 | 126 | // PrintDlg[Ex] result actions 127 | const ( 128 | PD_RESULT_APPLY = 2 129 | PD_RESULT_CANCEL = 0 130 | PD_RESULT_PRINT = 1 131 | ) 132 | 133 | // PrintDlg[Ex] flags 134 | const ( 135 | PD_ALLPAGES = 0x00000000 136 | PD_COLLATE = 0x00000010 137 | PD_CURRENTPAGE = 0x00400000 138 | PD_DISABLEPRINTTOFILE = 0x00080000 139 | PD_ENABLEPRINTTEMPLATE = 0x00004000 140 | PD_ENABLEPRINTTEMPLATEHANDLE = 0x00010000 141 | PD_EXCLUSIONFLAGS = 0x01000000 142 | PD_HIDEPRINTTOFILE = 0x00100000 143 | PD_NOCURRENTPAGE = 0x00800000 144 | PD_NOPAGENUMS = 0x00000008 145 | PD_NOSELECTION = 0x00000004 146 | PD_NOWARNING = 0x00000080 147 | PD_PAGENUMS = 0x00000002 148 | PD_PRINTTOFILE = 0x00000020 149 | PD_RETURNDC = 0x00000100 150 | PD_RETURNDEFAULT = 0x00000400 151 | PD_RETURNIC = 0x00000200 152 | PD_SELECTION = 0x00000001 153 | PD_USEDEVMODECOPIES = 0x00040000 154 | PD_USEDEVMODECOPIESANDCOLLATE = 0x00040000 155 | PD_USELARGETEMPLATE = 0x10000000 156 | ) 157 | 158 | // PrintDlgEx exclusion flags 159 | const ( 160 | PD_EXCL_COPIESANDCOLLATE = DM_COPIES | DM_COLLATE 161 | ) 162 | 163 | const START_PAGE_GENERAL = 0xffffffff 164 | 165 | type ( 166 | LPOFNHOOKPROC uintptr 167 | HPROPSHEETPAGE HANDLE 168 | LPUNKNOWN uintptr 169 | ) 170 | 171 | type OPENFILENAME struct { 172 | LStructSize uint32 173 | HwndOwner HWND 174 | HInstance HINSTANCE 175 | LpstrFilter *uint16 176 | LpstrCustomFilter *uint16 177 | NMaxCustFilter uint32 178 | NFilterIndex uint32 179 | LpstrFile *uint16 180 | NMaxFile uint32 181 | LpstrFileTitle *uint16 182 | NMaxFileTitle uint32 183 | LpstrInitialDir *uint16 184 | LpstrTitle *uint16 185 | Flags uint32 186 | NFileOffset uint16 187 | NFileExtension uint16 188 | LpstrDefExt *uint16 189 | LCustData uintptr 190 | LpfnHook LPOFNHOOKPROC 191 | LpTemplateName *uint16 192 | PvReserved unsafe.Pointer 193 | DwReserved uint32 194 | FlagsEx uint32 195 | } 196 | 197 | type PRINTPAGERANGE struct { 198 | NFromPage uint32 199 | NToPage uint32 200 | } 201 | 202 | type DEVNAMES struct { 203 | WDriverOffset uint16 204 | WDeviceOffset uint16 205 | WOutputOffset uint16 206 | WDefault uint16 207 | } 208 | 209 | type PRINTDLGEX struct { 210 | LStructSize uint32 211 | HwndOwner HWND 212 | HDevMode HGLOBAL 213 | HDevNames HGLOBAL 214 | HDC HDC 215 | Flags uint32 216 | Flags2 uint32 217 | ExclusionFlags uint32 218 | NPageRanges uint32 219 | NMaxPageRanges uint32 220 | LpPageRanges *PRINTPAGERANGE 221 | NMinPage uint32 222 | NMaxPage uint32 223 | NCopies uint32 224 | HInstance HINSTANCE 225 | LpPrintTemplateName *uint16 226 | LpCallback LPUNKNOWN 227 | NPropertyPages uint32 228 | LphPropertyPages *HPROPSHEETPAGE 229 | NStartPage uint32 230 | DwResultAction uint32 231 | } 232 | 233 | var ( 234 | // Library 235 | libcomdlg32 *windows.LazyDLL 236 | 237 | // Functions 238 | chooseColor *windows.LazyProc 239 | commDlgExtendedError *windows.LazyProc 240 | getOpenFileName *windows.LazyProc 241 | getSaveFileName *windows.LazyProc 242 | printDlgEx *windows.LazyProc 243 | ) 244 | 245 | func init() { 246 | // Library 247 | libcomdlg32 = windows.NewLazySystemDLL("comdlg32.dll") 248 | 249 | // Functions 250 | chooseColor = libcomdlg32.NewProc("ChooseColorW") 251 | commDlgExtendedError = libcomdlg32.NewProc("CommDlgExtendedError") 252 | getOpenFileName = libcomdlg32.NewProc("GetOpenFileNameW") 253 | getSaveFileName = libcomdlg32.NewProc("GetSaveFileNameW") 254 | printDlgEx = libcomdlg32.NewProc("PrintDlgExW") 255 | } 256 | 257 | func ChooseColor(lpcc *CHOOSECOLOR) bool { 258 | ret, _, _ := syscall.Syscall(chooseColor.Addr(), 1, 259 | uintptr(unsafe.Pointer(lpcc)), 260 | 0, 261 | 0) 262 | 263 | return ret != 0 264 | } 265 | 266 | func CommDlgExtendedError() uint32 { 267 | ret, _, _ := syscall.Syscall(commDlgExtendedError.Addr(), 0, 268 | 0, 269 | 0, 270 | 0) 271 | 272 | return uint32(ret) 273 | } 274 | 275 | func GetOpenFileName(lpofn *OPENFILENAME) bool { 276 | ret, _, _ := syscall.Syscall(getOpenFileName.Addr(), 1, 277 | uintptr(unsafe.Pointer(lpofn)), 278 | 0, 279 | 0) 280 | 281 | return ret != 0 282 | } 283 | 284 | func GetSaveFileName(lpofn *OPENFILENAME) bool { 285 | ret, _, _ := syscall.Syscall(getSaveFileName.Addr(), 1, 286 | uintptr(unsafe.Pointer(lpofn)), 287 | 0, 288 | 0) 289 | 290 | return ret != 0 291 | } 292 | 293 | func PrintDlgEx(lppd *PRINTDLGEX) HRESULT { 294 | ret, _, _ := syscall.Syscall(printDlgEx.Addr(), 1, 295 | uintptr(unsafe.Pointer(lppd)), 296 | 0, 297 | 0) 298 | 299 | return HRESULT(ret) 300 | } 301 | -------------------------------------------------------------------------------- /datetimepicker.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | const DTM_FIRST = 0x1000 10 | const DTN_FIRST = ^uint32(739) // -740 11 | const DTN_FIRST2 = ^uint32(752) // -753 12 | 13 | const ( 14 | GDTR_MIN = 0x0001 15 | GDTR_MAX = 0x0002 16 | ) 17 | 18 | const ( 19 | GDT_ERROR = -1 20 | GDT_VALID = 0 21 | GDT_NONE = 1 22 | ) 23 | 24 | // Messages 25 | const ( 26 | DTM_GETSYSTEMTIME = DTM_FIRST + 1 27 | DTM_SETSYSTEMTIME = DTM_FIRST + 2 28 | DTM_GETRANGE = DTM_FIRST + 3 29 | DTM_SETRANGE = DTM_FIRST + 4 30 | DTM_SETFORMAT = DTM_FIRST + 50 31 | DTM_SETMCCOLOR = DTM_FIRST + 6 32 | DTM_GETMCCOLOR = DTM_FIRST + 7 33 | DTM_GETMONTHCAL = DTM_FIRST + 8 34 | DTM_SETMCFONT = DTM_FIRST + 9 35 | DTM_GETMCFONT = DTM_FIRST + 10 36 | ) 37 | 38 | // Styles 39 | const ( 40 | DTS_UPDOWN = 0x0001 41 | DTS_SHOWNONE = 0x0002 42 | DTS_SHORTDATEFORMAT = 0x0000 43 | DTS_LONGDATEFORMAT = 0x0004 44 | DTS_SHORTDATECENTURYFORMAT = 0x000C 45 | DTS_TIMEFORMAT = 0x0009 46 | DTS_APPCANPARSE = 0x0010 47 | DTS_RIGHTALIGN = 0x0020 48 | ) 49 | 50 | // Notifications 51 | const ( 52 | DTN_DATETIMECHANGE = DTN_FIRST2 - 6 53 | DTN_USERSTRING = DTN_FIRST - 5 54 | DTN_WMKEYDOWN = DTN_FIRST - 4 55 | DTN_FORMAT = DTN_FIRST - 3 56 | DTN_FORMATQUERY = DTN_FIRST - 2 57 | DTN_DROPDOWN = DTN_FIRST2 - 1 58 | DTN_CLOSEUP = DTN_FIRST2 59 | ) 60 | 61 | // Structs 62 | type ( 63 | NMDATETIMECHANGE struct { 64 | Nmhdr NMHDR 65 | DwFlags uint32 66 | St SYSTEMTIME 67 | } 68 | 69 | NMDATETIMESTRING struct { 70 | Nmhdr NMHDR 71 | PszUserString *uint16 72 | St SYSTEMTIME 73 | DwFlags uint32 74 | } 75 | 76 | NMDATETIMEWMKEYDOWN struct { 77 | Nmhdr NMHDR 78 | NVirtKey int 79 | PszFormat *uint16 80 | St SYSTEMTIME 81 | } 82 | 83 | NMDATETIMEFORMAT struct { 84 | Nmhdr NMHDR 85 | PszFormat *uint16 86 | St SYSTEMTIME 87 | PszDisplay *uint16 88 | SzDisplay [64]uint16 89 | } 90 | 91 | NMDATETIMEFORMATQUERY struct { 92 | Nmhdr NMHDR 93 | PszFormat *uint16 94 | SzMax SIZE 95 | } 96 | ) 97 | -------------------------------------------------------------------------------- /edit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | // Edit styles 10 | const ( 11 | ES_LEFT = 0x0000 12 | ES_CENTER = 0x0001 13 | ES_RIGHT = 0x0002 14 | ES_MULTILINE = 0x0004 15 | ES_UPPERCASE = 0x0008 16 | ES_LOWERCASE = 0x0010 17 | ES_PASSWORD = 0x0020 18 | ES_AUTOVSCROLL = 0x0040 19 | ES_AUTOHSCROLL = 0x0080 20 | ES_NOHIDESEL = 0x0100 21 | ES_OEMCONVERT = 0x0400 22 | ES_READONLY = 0x0800 23 | ES_WANTRETURN = 0x1000 24 | ES_NUMBER = 0x2000 25 | ) 26 | 27 | // Edit notifications 28 | const ( 29 | EN_SETFOCUS = 0x0100 30 | EN_KILLFOCUS = 0x0200 31 | EN_CHANGE = 0x0300 32 | EN_UPDATE = 0x0400 33 | EN_ERRSPACE = 0x0500 34 | EN_MAXTEXT = 0x0501 35 | EN_HSCROLL = 0x0601 36 | EN_VSCROLL = 0x0602 37 | EN_ALIGN_LTR_EC = 0x0700 38 | EN_ALIGN_RTL_EC = 0x0701 39 | ) 40 | 41 | // Edit messages 42 | const ( 43 | EM_GETSEL = 0x00B0 44 | EM_SETSEL = 0x00B1 45 | EM_GETRECT = 0x00B2 46 | EM_SETRECT = 0x00B3 47 | EM_SETRECTNP = 0x00B4 48 | EM_SCROLL = 0x00B5 49 | EM_LINESCROLL = 0x00B6 50 | EM_SCROLLCARET = 0x00B7 51 | EM_GETMODIFY = 0x00B8 52 | EM_SETMODIFY = 0x00B9 53 | EM_GETLINECOUNT = 0x00BA 54 | EM_LINEINDEX = 0x00BB 55 | EM_SETHANDLE = 0x00BC 56 | EM_GETHANDLE = 0x00BD 57 | EM_GETTHUMB = 0x00BE 58 | EM_LINELENGTH = 0x00C1 59 | EM_REPLACESEL = 0x00C2 60 | EM_GETLINE = 0x00C4 61 | EM_LIMITTEXT = 0x00C5 62 | EM_CANUNDO = 0x00C6 63 | EM_UNDO = 0x00C7 64 | EM_FMTLINES = 0x00C8 65 | EM_LINEFROMCHAR = 0x00C9 66 | EM_SETTABSTOPS = 0x00CB 67 | EM_SETPASSWORDCHAR = 0x00CC 68 | EM_EMPTYUNDOBUFFER = 0x00CD 69 | EM_GETFIRSTVISIBLELINE = 0x00CE 70 | EM_SETREADONLY = 0x00CF 71 | EM_SETWORDBREAKPROC = 0x00D0 72 | EM_GETWORDBREAKPROC = 0x00D1 73 | EM_GETPASSWORDCHAR = 0x00D2 74 | EM_SETMARGINS = 0x00D3 75 | EM_GETMARGINS = 0x00D4 76 | EM_SETLIMITTEXT = EM_LIMITTEXT 77 | EM_GETLIMITTEXT = 0x00D5 78 | EM_POSFROMCHAR = 0x00D6 79 | EM_CHARFROMPOS = 0x00D7 80 | EM_SETIMESTATUS = 0x00D8 81 | EM_GETIMESTATUS = 0x00D9 82 | EM_SETCUEBANNER = 0x1501 83 | EM_GETCUEBANNER = 0x1502 84 | EM_SETCARETINDEX = 0x1511 85 | EM_GETCARETINDEX = 0x1512 86 | ) 87 | -------------------------------------------------------------------------------- /gdiplus.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "golang.org/x/sys/windows" 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | type GpStatus int32 16 | 17 | const ( 18 | Ok GpStatus = 0 19 | GenericError GpStatus = 1 20 | InvalidParameter GpStatus = 2 21 | OutOfMemory GpStatus = 3 22 | ObjectBusy GpStatus = 4 23 | InsufficientBuffer GpStatus = 5 24 | NotImplemented GpStatus = 6 25 | Win32Error GpStatus = 7 26 | WrongState GpStatus = 8 27 | Aborted GpStatus = 9 28 | FileNotFound GpStatus = 10 29 | ValueOverflow GpStatus = 11 30 | AccessDenied GpStatus = 12 31 | UnknownImageFormat GpStatus = 13 32 | FontFamilyNotFound GpStatus = 14 33 | FontStyleNotFound GpStatus = 15 34 | NotTrueTypeFont GpStatus = 16 35 | UnsupportedGdiplusVersion GpStatus = 17 36 | GdiplusNotInitialized GpStatus = 18 37 | PropertyNotFound GpStatus = 19 38 | PropertyNotSupported GpStatus = 20 39 | ProfileNotFound GpStatus = 21 40 | ) 41 | 42 | func (s GpStatus) String() string { 43 | switch s { 44 | case Ok: 45 | return "Ok" 46 | 47 | case GenericError: 48 | return "GenericError" 49 | 50 | case InvalidParameter: 51 | return "InvalidParameter" 52 | 53 | case OutOfMemory: 54 | return "OutOfMemory" 55 | 56 | case ObjectBusy: 57 | return "ObjectBusy" 58 | 59 | case InsufficientBuffer: 60 | return "InsufficientBuffer" 61 | 62 | case NotImplemented: 63 | return "NotImplemented" 64 | 65 | case Win32Error: 66 | return "Win32Error" 67 | 68 | case WrongState: 69 | return "WrongState" 70 | 71 | case Aborted: 72 | return "Aborted" 73 | 74 | case FileNotFound: 75 | return "FileNotFound" 76 | 77 | case ValueOverflow: 78 | return "ValueOverflow" 79 | 80 | case AccessDenied: 81 | return "AccessDenied" 82 | 83 | case UnknownImageFormat: 84 | return "UnknownImageFormat" 85 | 86 | case FontFamilyNotFound: 87 | return "FontFamilyNotFound" 88 | 89 | case FontStyleNotFound: 90 | return "FontStyleNotFound" 91 | 92 | case NotTrueTypeFont: 93 | return "NotTrueTypeFont" 94 | 95 | case UnsupportedGdiplusVersion: 96 | return "UnsupportedGdiplusVersion" 97 | 98 | case GdiplusNotInitialized: 99 | return "GdiplusNotInitialized" 100 | 101 | case PropertyNotFound: 102 | return "PropertyNotFound" 103 | 104 | case PropertyNotSupported: 105 | return "PropertyNotSupported" 106 | 107 | case ProfileNotFound: 108 | return "ProfileNotFound" 109 | } 110 | 111 | return "Unknown Status Value" 112 | } 113 | 114 | type GdiplusStartupInput struct { 115 | GdiplusVersion uint32 116 | DebugEventCallback uintptr 117 | SuppressBackgroundThread BOOL 118 | SuppressExternalCodecs BOOL 119 | } 120 | 121 | type GdiplusStartupOutput struct { 122 | NotificationHook uintptr 123 | NotificationUnhook uintptr 124 | } 125 | 126 | type GpImage struct{} 127 | 128 | type GpBitmap GpImage 129 | 130 | type ARGB uint32 131 | 132 | var ( 133 | // Library 134 | libgdiplus *windows.LazyDLL 135 | 136 | // Functions 137 | gdipCreateBitmapFromFile *windows.LazyProc 138 | gdipCreateBitmapFromHBITMAP *windows.LazyProc 139 | gdipCreateHBITMAPFromBitmap *windows.LazyProc 140 | gdipDisposeImage *windows.LazyProc 141 | gdiplusShutdown *windows.LazyProc 142 | gdiplusStartup *windows.LazyProc 143 | ) 144 | 145 | var ( 146 | token uintptr 147 | ) 148 | 149 | func init() { 150 | // Library 151 | libgdiplus = windows.NewLazySystemDLL("gdiplus.dll") 152 | 153 | // Functions 154 | gdipCreateBitmapFromFile = libgdiplus.NewProc("GdipCreateBitmapFromFile") 155 | gdipCreateBitmapFromHBITMAP = libgdiplus.NewProc("GdipCreateBitmapFromHBITMAP") 156 | gdipCreateHBITMAPFromBitmap = libgdiplus.NewProc("GdipCreateHBITMAPFromBitmap") 157 | gdipDisposeImage = libgdiplus.NewProc("GdipDisposeImage") 158 | gdiplusShutdown = libgdiplus.NewProc("GdiplusShutdown") 159 | gdiplusStartup = libgdiplus.NewProc("GdiplusStartup") 160 | } 161 | 162 | func GdipCreateBitmapFromFile(filename *uint16, bitmap **GpBitmap) GpStatus { 163 | ret, _, _ := syscall.Syscall(gdipCreateBitmapFromFile.Addr(), 2, 164 | uintptr(unsafe.Pointer(filename)), 165 | uintptr(unsafe.Pointer(bitmap)), 166 | 0) 167 | 168 | return GpStatus(ret) 169 | } 170 | 171 | func GdipCreateBitmapFromHBITMAP(hbm HBITMAP, hpal HPALETTE, bitmap **GpBitmap) GpStatus { 172 | ret, _, _ := syscall.Syscall(gdipCreateBitmapFromHBITMAP.Addr(), 3, 173 | uintptr(hbm), 174 | uintptr(hpal), 175 | uintptr(unsafe.Pointer(bitmap))) 176 | 177 | return GpStatus(ret) 178 | } 179 | 180 | func GdipCreateHBITMAPFromBitmap(bitmap *GpBitmap, hbmReturn *HBITMAP, background ARGB) GpStatus { 181 | ret, _, _ := syscall.Syscall(gdipCreateHBITMAPFromBitmap.Addr(), 3, 182 | uintptr(unsafe.Pointer(bitmap)), 183 | uintptr(unsafe.Pointer(hbmReturn)), 184 | uintptr(background)) 185 | 186 | return GpStatus(ret) 187 | } 188 | 189 | func GdipDisposeImage(image *GpImage) GpStatus { 190 | ret, _, _ := syscall.Syscall(gdipDisposeImage.Addr(), 1, 191 | uintptr(unsafe.Pointer(image)), 192 | 0, 193 | 0) 194 | 195 | return GpStatus(ret) 196 | } 197 | 198 | func GdiplusShutdown() { 199 | syscall.Syscall(gdiplusShutdown.Addr(), 1, 200 | token, 201 | 0, 202 | 0) 203 | } 204 | 205 | func GdiplusStartup(input *GdiplusStartupInput, output *GdiplusStartupOutput) GpStatus { 206 | ret, _, _ := syscall.Syscall(gdiplusStartup.Addr(), 3, 207 | uintptr(unsafe.Pointer(&token)), 208 | uintptr(unsafe.Pointer(input)), 209 | uintptr(unsafe.Pointer(output))) 210 | 211 | return GpStatus(ret) 212 | } 213 | 214 | /*GdipSaveImageToFile(image *GpImage, filename *uint16, clsidEncoder *CLSID, encoderParams *EncoderParameters) GpStatus { 215 | ret, _, _ := syscall.Syscall6(gdipSaveImageToFile.Addr(), 4, 216 | uintptr(unsafe.Pointer(image)), 217 | uintptr(unsafe.Pointer(filename)), 218 | uintptr(unsafe.Pointer(clsidEncoder)), 219 | uintptr(unsafe.Pointer(encoderParams)), 220 | 0, 221 | 0) 222 | 223 | return GpStatus(ret) 224 | }*/ 225 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lxn/win 2 | 3 | go 1.12 4 | 5 | require golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13 6 | -------------------------------------------------------------------------------- /header.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | const ( 10 | HDS_NOSIZING = 0x0800 11 | ) 12 | 13 | type HDITEM struct { 14 | Mask uint32 15 | Cxy int32 16 | PszText *uint16 17 | Hbm HBITMAP 18 | CchTextMax int32 19 | Fmt int32 20 | LParam uintptr 21 | IImage int32 22 | IOrder int32 23 | Type uint32 24 | PvFilter uintptr 25 | } 26 | 27 | type HDLAYOUT struct { 28 | Prc *RECT 29 | Pwpos *WINDOWPOS 30 | } 31 | 32 | type HDHITTESTINFO struct { 33 | Pt POINT 34 | Flags uint32 35 | IItem int32 36 | } 37 | 38 | const ( 39 | HDI_WIDTH = 0x0001 40 | HDI_HEIGHT = HDI_WIDTH 41 | HDI_TEXT = 0x0002 42 | HDI_FORMAT = 0x0004 43 | HDI_LPARAM = 0x0008 44 | HDI_BITMAP = 0x0010 45 | HDI_IMAGE = 0x0020 46 | HDI_DI_SETITEM = 0x0040 47 | HDI_ORDER = 0x0080 48 | HDI_FILTER = 0x0100 49 | HDI_STATE = 0x0200 50 | ) 51 | 52 | const ( 53 | HDF_LEFT = 0x0000 54 | HDF_RIGHT = 0x0001 55 | HDF_CENTER = 0x0002 56 | HDF_JUSTIFYMASK = 0x0003 57 | HDF_RTLREADING = 0x0004 58 | HDF_CHECKBOX = 0x0040 59 | HDF_CHECKED = 0x0080 60 | HDF_FIXEDWIDTH = 0x0100 61 | HDF_SORTDOWN = 0x0200 62 | HDF_SORTUP = 0x0400 63 | HDF_IMAGE = 0x0800 64 | HDF_BITMAP_ON_RIGHT = 0x1000 65 | HDF_BITMAP = 0x2000 66 | HDF_STRING = 0x4000 67 | HDF_OWNERDRAW = 0x8000 68 | HDF_SPLITBUTTON = 0x1000000 69 | ) 70 | 71 | const ( 72 | HDIS_FOCUSED = 0x00000001 73 | ) 74 | 75 | const ( 76 | HDM_FIRST = 0x1200 77 | HDM_GETITEMCOUNT = HDM_FIRST + 0 78 | HDM_DELETEITEM = HDM_FIRST + 2 79 | HDM_LAYOUT = HDM_FIRST + 5 80 | HDM_HITTEST = HDM_FIRST + 6 81 | HDM_GETITEMRECT = HDM_FIRST + 7 82 | HDM_SETIMAGELIST = HDM_FIRST + 8 83 | HDM_GETIMAGELIST = HDM_FIRST + 9 84 | HDM_INSERTITEM = HDM_FIRST + 10 85 | HDM_GETITEM = HDM_FIRST + 11 86 | HDM_SETITEM = HDM_FIRST + 12 87 | HDM_ORDERTOINDEX = HDM_FIRST + 15 88 | HDM_CREATEDRAGIMAGE = HDM_FIRST + 16 89 | HDM_GETORDERARRAY = HDM_FIRST + 17 90 | HDM_SETORDERARRAY = HDM_FIRST + 18 91 | HDM_SETHOTDIVIDER = HDM_FIRST + 19 92 | HDM_SETBITMAPMARGIN = HDM_FIRST + 20 93 | HDM_GETBITMAPMARGIN = HDM_FIRST + 21 94 | HDM_SETFILTERCHANGETIMEOUT = HDM_FIRST + 22 95 | HDM_EDITFILTER = HDM_FIRST + 23 96 | HDM_CLEARFILTER = HDM_FIRST + 24 97 | HDM_GETITEMDROPDOWNRECT = HDM_FIRST + 25 98 | HDM_GETOVERFLOWRECT = HDM_FIRST + 26 99 | HDM_GETFOCUSEDITEM = HDM_FIRST + 27 100 | HDM_SETFOCUSEDITEM = HDM_FIRST + 28 101 | HDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 102 | HDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 103 | ) 104 | 105 | const ( 106 | HHT_NOWHERE = 0x0001 107 | HHT_ONHEADER = 0x0002 108 | HHT_ONDIVIDER = 0x0004 109 | HHT_ONDIVOPEN = 0x0008 110 | HHT_ONFILTER = 0x0010 111 | HHT_ONFILTERBUTTON = 0x0020 112 | HHT_ABOVE = 0x0100 113 | HHT_BELOW = 0x0200 114 | HHT_TORIGHT = 0x0400 115 | HHT_TOLEFT = 0x0800 116 | HHT_ONITEMSTATEICON = 0x1000 117 | HHT_ONDROPDOWN = 0x2000 118 | HHT_ONOVERFLOW = 0x4000 119 | ) 120 | 121 | const ( 122 | HDN_FIRST = ^uint32(300) 123 | HDN_BEGINDRAG = HDN_FIRST - 10 124 | HDN_ENDDRAG = HDN_FIRST - 11 125 | HDN_FILTERCHANGE = HDN_FIRST - 12 126 | HDN_FILTERBTNCLICK = HDN_FIRST - 13 127 | HDN_BEGINFILTEREDIT = HDN_FIRST - 14 128 | HDN_ENDFILTEREDIT = HDN_FIRST - 15 129 | HDN_ITEMSTATEICONCLICK = HDN_FIRST - 16 130 | HDN_ITEMKEYDOWN = HDN_FIRST - 17 131 | HDN_DROPDOWN = HDN_FIRST - 18 132 | HDN_OVERFLOWCLICK = HDN_FIRST - 19 133 | HDN_ITEMCHANGING = HDN_FIRST - 20 134 | HDN_ITEMCHANGED = HDN_FIRST - 21 135 | HDN_ITEMCLICK = HDN_FIRST - 22 136 | HDN_ITEMDBLCLICK = HDN_FIRST - 23 137 | HDN_DIVIDERDBLCLICK = HDN_FIRST - 25 138 | HDN_BEGINTRACK = HDN_FIRST - 26 139 | HDN_ENDTRACK = HDN_FIRST - 27 140 | HDN_TRACK = HDN_FIRST - 28 141 | HDN_GETDISPINFO = HDN_FIRST - 29 142 | ) 143 | -------------------------------------------------------------------------------- /kernel32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "golang.org/x/sys/windows" 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | const MAX_PATH = 260 16 | 17 | // Error codes 18 | const ( 19 | ERROR_SUCCESS = 0 20 | ERROR_INVALID_FUNCTION = 1 21 | ERROR_FILE_NOT_FOUND = 2 22 | ERROR_INVALID_PARAMETER = 87 23 | ERROR_INSUFFICIENT_BUFFER = 122 24 | ERROR_MORE_DATA = 234 25 | ) 26 | 27 | // GlobalAlloc flags 28 | const ( 29 | GHND = 0x0042 30 | GMEM_FIXED = 0x0000 31 | GMEM_MOVEABLE = 0x0002 32 | GMEM_ZEROINIT = 0x0040 33 | GPTR = GMEM_FIXED | GMEM_ZEROINIT 34 | ) 35 | 36 | // Predefined locale ids 37 | const ( 38 | LOCALE_CUSTOM_DEFAULT LCID = 0x0c00 39 | LOCALE_CUSTOM_UI_DEFAULT LCID = 0x1400 40 | LOCALE_CUSTOM_UNSPECIFIED LCID = 0x1000 41 | LOCALE_INVARIANT LCID = 0x007f 42 | LOCALE_USER_DEFAULT LCID = 0x0400 43 | LOCALE_SYSTEM_DEFAULT LCID = 0x0800 44 | ) 45 | 46 | // LCTYPE constants 47 | const ( 48 | LOCALE_SDECIMAL LCTYPE = 14 49 | LOCALE_STHOUSAND LCTYPE = 15 50 | LOCALE_SISO3166CTRYNAME LCTYPE = 0x5a 51 | LOCALE_SISO3166CTRYNAME2 LCTYPE = 0x68 52 | LOCALE_SISO639LANGNAME LCTYPE = 0x59 53 | LOCALE_SISO639LANGNAME2 LCTYPE = 0x67 54 | ) 55 | 56 | var ( 57 | // Library 58 | libkernel32 *windows.LazyDLL 59 | 60 | // Functions 61 | activateActCtx *windows.LazyProc 62 | closeHandle *windows.LazyProc 63 | createActCtx *windows.LazyProc 64 | fileTimeToSystemTime *windows.LazyProc 65 | findResource *windows.LazyProc 66 | getConsoleTitle *windows.LazyProc 67 | getConsoleWindow *windows.LazyProc 68 | getCurrentThreadId *windows.LazyProc 69 | getLastError *windows.LazyProc 70 | getLocaleInfo *windows.LazyProc 71 | getLogicalDriveStrings *windows.LazyProc 72 | getModuleHandle *windows.LazyProc 73 | getNumberFormat *windows.LazyProc 74 | getPhysicallyInstalledSystemMemory *windows.LazyProc 75 | getProfileString *windows.LazyProc 76 | getThreadLocale *windows.LazyProc 77 | getThreadUILanguage *windows.LazyProc 78 | getVersion *windows.LazyProc 79 | globalAlloc *windows.LazyProc 80 | globalFree *windows.LazyProc 81 | globalLock *windows.LazyProc 82 | globalUnlock *windows.LazyProc 83 | moveMemory *windows.LazyProc 84 | mulDiv *windows.LazyProc 85 | loadResource *windows.LazyProc 86 | lockResource *windows.LazyProc 87 | setLastError *windows.LazyProc 88 | sizeofResource *windows.LazyProc 89 | systemTimeToFileTime *windows.LazyProc 90 | ) 91 | 92 | type ( 93 | ATOM uint16 94 | HANDLE uintptr 95 | HGLOBAL HANDLE 96 | HINSTANCE HANDLE 97 | LCID uint32 98 | LCTYPE uint32 99 | LANGID uint16 100 | HMODULE uintptr 101 | HWINEVENTHOOK HANDLE 102 | HRSRC uintptr 103 | ) 104 | 105 | type FILETIME struct { 106 | DwLowDateTime uint32 107 | DwHighDateTime uint32 108 | } 109 | 110 | type NUMBERFMT struct { 111 | NumDigits uint32 112 | LeadingZero uint32 113 | Grouping uint32 114 | LpDecimalSep *uint16 115 | LpThousandSep *uint16 116 | NegativeOrder uint32 117 | } 118 | 119 | type SYSTEMTIME struct { 120 | WYear uint16 121 | WMonth uint16 122 | WDayOfWeek uint16 123 | WDay uint16 124 | WHour uint16 125 | WMinute uint16 126 | WSecond uint16 127 | WMilliseconds uint16 128 | } 129 | 130 | type ACTCTX struct { 131 | size uint32 132 | Flags uint32 133 | Source *uint16 // UTF-16 string 134 | ProcessorArchitecture uint16 135 | LangID uint16 136 | AssemblyDirectory *uint16 // UTF-16 string 137 | ResourceName *uint16 // UTF-16 string 138 | ApplicationName *uint16 // UTF-16 string 139 | Module HMODULE 140 | } 141 | 142 | func init() { 143 | // Library 144 | libkernel32 = windows.NewLazySystemDLL("kernel32.dll") 145 | 146 | // Functions 147 | activateActCtx = libkernel32.NewProc("ActivateActCtx") 148 | closeHandle = libkernel32.NewProc("CloseHandle") 149 | createActCtx = libkernel32.NewProc("CreateActCtxW") 150 | fileTimeToSystemTime = libkernel32.NewProc("FileTimeToSystemTime") 151 | findResource = libkernel32.NewProc("FindResourceW") 152 | getConsoleTitle = libkernel32.NewProc("GetConsoleTitleW") 153 | getConsoleWindow = libkernel32.NewProc("GetConsoleWindow") 154 | getCurrentThreadId = libkernel32.NewProc("GetCurrentThreadId") 155 | getLastError = libkernel32.NewProc("GetLastError") 156 | getLocaleInfo = libkernel32.NewProc("GetLocaleInfoW") 157 | getLogicalDriveStrings = libkernel32.NewProc("GetLogicalDriveStringsW") 158 | getModuleHandle = libkernel32.NewProc("GetModuleHandleW") 159 | getNumberFormat = libkernel32.NewProc("GetNumberFormatW") 160 | getPhysicallyInstalledSystemMemory = libkernel32.NewProc("GetPhysicallyInstalledSystemMemory") 161 | getProfileString = libkernel32.NewProc("GetProfileStringW") 162 | getThreadLocale = libkernel32.NewProc("GetThreadLocale") 163 | getThreadUILanguage = libkernel32.NewProc("GetThreadUILanguage") 164 | getVersion = libkernel32.NewProc("GetVersion") 165 | globalAlloc = libkernel32.NewProc("GlobalAlloc") 166 | globalFree = libkernel32.NewProc("GlobalFree") 167 | globalLock = libkernel32.NewProc("GlobalLock") 168 | globalUnlock = libkernel32.NewProc("GlobalUnlock") 169 | moveMemory = libkernel32.NewProc("RtlMoveMemory") 170 | mulDiv = libkernel32.NewProc("MulDiv") 171 | loadResource = libkernel32.NewProc("LoadResource") 172 | lockResource = libkernel32.NewProc("LockResource") 173 | setLastError = libkernel32.NewProc("SetLastError") 174 | sizeofResource = libkernel32.NewProc("SizeofResource") 175 | systemTimeToFileTime = libkernel32.NewProc("SystemTimeToFileTime") 176 | } 177 | 178 | func ActivateActCtx(ctx HANDLE) (uintptr, bool) { 179 | var cookie uintptr 180 | ret, _, _ := syscall.Syscall(activateActCtx.Addr(), 2, 181 | uintptr(ctx), 182 | uintptr(unsafe.Pointer(&cookie)), 183 | 0) 184 | return cookie, ret != 0 185 | } 186 | 187 | func CloseHandle(hObject HANDLE) bool { 188 | ret, _, _ := syscall.Syscall(closeHandle.Addr(), 1, 189 | uintptr(hObject), 190 | 0, 191 | 0) 192 | 193 | return ret != 0 194 | } 195 | 196 | func CreateActCtx(ctx *ACTCTX) HANDLE { 197 | if ctx != nil { 198 | ctx.size = uint32(unsafe.Sizeof(*ctx)) 199 | } 200 | ret, _, _ := syscall.Syscall( 201 | createActCtx.Addr(), 202 | 1, 203 | uintptr(unsafe.Pointer(ctx)), 204 | 0, 205 | 0) 206 | return HANDLE(ret) 207 | } 208 | 209 | func FileTimeToSystemTime(lpFileTime *FILETIME, lpSystemTime *SYSTEMTIME) bool { 210 | ret, _, _ := syscall.Syscall(fileTimeToSystemTime.Addr(), 2, 211 | uintptr(unsafe.Pointer(lpFileTime)), 212 | uintptr(unsafe.Pointer(lpSystemTime)), 213 | 0) 214 | 215 | return ret != 0 216 | } 217 | 218 | func FindResource(hModule HMODULE, lpName, lpType *uint16) HRSRC { 219 | ret, _, _ := syscall.Syscall(findResource.Addr(), 3, 220 | uintptr(hModule), 221 | uintptr(unsafe.Pointer(lpName)), 222 | uintptr(unsafe.Pointer(lpType))) 223 | 224 | return HRSRC(ret) 225 | } 226 | 227 | func GetConsoleTitle(lpConsoleTitle *uint16, nSize uint32) uint32 { 228 | ret, _, _ := syscall.Syscall(getConsoleTitle.Addr(), 2, 229 | uintptr(unsafe.Pointer(lpConsoleTitle)), 230 | uintptr(nSize), 231 | 0) 232 | 233 | return uint32(ret) 234 | } 235 | 236 | func GetConsoleWindow() HWND { 237 | ret, _, _ := syscall.Syscall(getConsoleWindow.Addr(), 0, 238 | 0, 239 | 0, 240 | 0) 241 | 242 | return HWND(ret) 243 | } 244 | 245 | func GetCurrentThreadId() uint32 { 246 | ret, _, _ := syscall.Syscall(getCurrentThreadId.Addr(), 0, 247 | 0, 248 | 0, 249 | 0) 250 | 251 | return uint32(ret) 252 | } 253 | 254 | func GetLastError() uint32 { 255 | ret, _, _ := syscall.Syscall(getLastError.Addr(), 0, 256 | 0, 257 | 0, 258 | 0) 259 | 260 | return uint32(ret) 261 | } 262 | 263 | func GetLocaleInfo(Locale LCID, LCType LCTYPE, lpLCData *uint16, cchData int32) int32 { 264 | ret, _, _ := syscall.Syscall6(getLocaleInfo.Addr(), 4, 265 | uintptr(Locale), 266 | uintptr(LCType), 267 | uintptr(unsafe.Pointer(lpLCData)), 268 | uintptr(cchData), 269 | 0, 270 | 0) 271 | 272 | return int32(ret) 273 | } 274 | 275 | func GetLogicalDriveStrings(nBufferLength uint32, lpBuffer *uint16) uint32 { 276 | ret, _, _ := syscall.Syscall(getLogicalDriveStrings.Addr(), 2, 277 | uintptr(nBufferLength), 278 | uintptr(unsafe.Pointer(lpBuffer)), 279 | 0) 280 | 281 | return uint32(ret) 282 | } 283 | 284 | func GetModuleHandle(lpModuleName *uint16) HINSTANCE { 285 | ret, _, _ := syscall.Syscall(getModuleHandle.Addr(), 1, 286 | uintptr(unsafe.Pointer(lpModuleName)), 287 | 0, 288 | 0) 289 | 290 | return HINSTANCE(ret) 291 | } 292 | 293 | func GetNumberFormat(Locale LCID, dwFlags uint32, lpValue *uint16, lpFormat *NUMBERFMT, lpNumberStr *uint16, cchNumber int32) int32 { 294 | ret, _, _ := syscall.Syscall6(getNumberFormat.Addr(), 6, 295 | uintptr(Locale), 296 | uintptr(dwFlags), 297 | uintptr(unsafe.Pointer(lpValue)), 298 | uintptr(unsafe.Pointer(lpFormat)), 299 | uintptr(unsafe.Pointer(lpNumberStr)), 300 | uintptr(cchNumber)) 301 | 302 | return int32(ret) 303 | } 304 | 305 | func GetPhysicallyInstalledSystemMemory(totalMemoryInKilobytes *uint64) bool { 306 | if getPhysicallyInstalledSystemMemory.Find() != nil { 307 | return false 308 | } 309 | ret, _, _ := syscall.Syscall(getPhysicallyInstalledSystemMemory.Addr(), 1, 310 | uintptr(unsafe.Pointer(totalMemoryInKilobytes)), 311 | 0, 312 | 0) 313 | 314 | return ret != 0 315 | } 316 | 317 | func GetProfileString(lpAppName, lpKeyName, lpDefault *uint16, lpReturnedString uintptr, nSize uint32) bool { 318 | ret, _, _ := syscall.Syscall6(getProfileString.Addr(), 5, 319 | uintptr(unsafe.Pointer(lpAppName)), 320 | uintptr(unsafe.Pointer(lpKeyName)), 321 | uintptr(unsafe.Pointer(lpDefault)), 322 | lpReturnedString, 323 | uintptr(nSize), 324 | 0) 325 | return ret != 0 326 | } 327 | 328 | func GetThreadLocale() LCID { 329 | ret, _, _ := syscall.Syscall(getThreadLocale.Addr(), 0, 330 | 0, 331 | 0, 332 | 0) 333 | 334 | return LCID(ret) 335 | } 336 | 337 | func GetThreadUILanguage() LANGID { 338 | if getThreadUILanguage.Find() != nil { 339 | return 0 340 | } 341 | 342 | ret, _, _ := syscall.Syscall(getThreadUILanguage.Addr(), 0, 343 | 0, 344 | 0, 345 | 0) 346 | 347 | return LANGID(ret) 348 | } 349 | 350 | func GetVersion() uint32 { 351 | ret, _, _ := syscall.Syscall(getVersion.Addr(), 0, 352 | 0, 353 | 0, 354 | 0) 355 | return uint32(ret) 356 | } 357 | 358 | func GlobalAlloc(uFlags uint32, dwBytes uintptr) HGLOBAL { 359 | ret, _, _ := syscall.Syscall(globalAlloc.Addr(), 2, 360 | uintptr(uFlags), 361 | dwBytes, 362 | 0) 363 | 364 | return HGLOBAL(ret) 365 | } 366 | 367 | func GlobalFree(hMem HGLOBAL) HGLOBAL { 368 | ret, _, _ := syscall.Syscall(globalFree.Addr(), 1, 369 | uintptr(hMem), 370 | 0, 371 | 0) 372 | 373 | return HGLOBAL(ret) 374 | } 375 | 376 | func GlobalLock(hMem HGLOBAL) unsafe.Pointer { 377 | ret, _, _ := syscall.Syscall(globalLock.Addr(), 1, 378 | uintptr(hMem), 379 | 0, 380 | 0) 381 | 382 | return unsafe.Pointer(ret) 383 | } 384 | 385 | func GlobalUnlock(hMem HGLOBAL) bool { 386 | ret, _, _ := syscall.Syscall(globalUnlock.Addr(), 1, 387 | uintptr(hMem), 388 | 0, 389 | 0) 390 | 391 | return ret != 0 392 | } 393 | 394 | func MoveMemory(destination, source unsafe.Pointer, length uintptr) { 395 | syscall.Syscall(moveMemory.Addr(), 3, 396 | uintptr(unsafe.Pointer(destination)), 397 | uintptr(source), 398 | uintptr(length)) 399 | } 400 | 401 | func MulDiv(nNumber, nNumerator, nDenominator int32) int32 { 402 | ret, _, _ := syscall.Syscall(mulDiv.Addr(), 3, 403 | uintptr(nNumber), 404 | uintptr(nNumerator), 405 | uintptr(nDenominator)) 406 | 407 | return int32(ret) 408 | } 409 | 410 | func LoadResource(hModule HMODULE, hResInfo HRSRC) HGLOBAL { 411 | ret, _, _ := syscall.Syscall(loadResource.Addr(), 2, 412 | uintptr(hModule), 413 | uintptr(hResInfo), 414 | 0) 415 | 416 | return HGLOBAL(ret) 417 | } 418 | 419 | func LockResource(hResData HGLOBAL) uintptr { 420 | ret, _, _ := syscall.Syscall(lockResource.Addr(), 1, 421 | uintptr(hResData), 422 | 0, 423 | 0) 424 | 425 | return ret 426 | } 427 | 428 | func SetLastError(dwErrorCode uint32) { 429 | syscall.Syscall(setLastError.Addr(), 1, 430 | uintptr(dwErrorCode), 431 | 0, 432 | 0) 433 | } 434 | 435 | func SizeofResource(hModule HMODULE, hResInfo HRSRC) uint32 { 436 | ret, _, _ := syscall.Syscall(sizeofResource.Addr(), 2, 437 | uintptr(hModule), 438 | uintptr(hResInfo), 439 | 0) 440 | 441 | return uint32(ret) 442 | } 443 | 444 | func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { 445 | ret, _, _ := syscall.Syscall(systemTimeToFileTime.Addr(), 2, 446 | uintptr(unsafe.Pointer(lpSystemTime)), 447 | uintptr(unsafe.Pointer(lpFileTime)), 448 | 0) 449 | 450 | return ret != 0 451 | } 452 | -------------------------------------------------------------------------------- /listbox.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | // ListBox style 10 | const ( 11 | LBS_NOTIFY = 0x0001 12 | LBS_SORT = 0x0002 13 | LBS_NOREDRAW = 0x0004 14 | LBS_MULTIPLESEL = 0x0008 15 | LBS_OWNERDRAWFIXED = 0x0010 16 | LBS_OWNERDRAWVARIABLE = 0x0020 17 | LBS_HASSTRINGS = 0x0040 18 | LBS_USETABSTOPS = 0x0080 19 | LBS_NOINTEGRALHEIGHT = 0x0100 20 | LBS_MULTICOLUMN = 0x0200 21 | LBS_WANTKEYBOARDINPUT = 0x0400 22 | LBS_EXTENDEDSEL = 0x0800 23 | LBS_DISABLENOSCROLL = 0x1000 24 | LBS_NODATA = 0x2000 25 | LBS_NOSEL = 0x4000 26 | LBS_COMBOBOX = 0x8000 27 | LBS_STANDARD = LBS_NOTIFY | LBS_SORT | WS_BORDER | WS_VSCROLL 28 | ) 29 | 30 | // ListBox messages 31 | const ( 32 | LB_ADDSTRING = 0x0180 33 | LB_INSERTSTRING = 0x0181 34 | LB_DELETESTRING = 0x0182 35 | LB_SELITEMRANGEEX = 0x0183 36 | LB_RESETCONTENT = 0x0184 37 | LB_SETSEL = 0x0185 38 | LB_SETCURSEL = 0x0186 39 | LB_GETSEL = 0x0187 40 | LB_GETCURSEL = 0x0188 41 | LB_GETTEXT = 0x0189 42 | LB_GETTEXTLEN = 0x018A 43 | LB_GETCOUNT = 0x018B 44 | LB_SELECTSTRING = 0x018C 45 | LB_DIR = 0x018D 46 | LB_GETTOPINDEX = 0x018E 47 | LB_FINDSTRING = 0x018F 48 | LB_GETSELCOUNT = 0x0190 49 | LB_GETSELITEMS = 0x0191 50 | LB_SETTABSTOPS = 0x0192 51 | LB_GETHORIZONTALEXTENT = 0x0193 52 | LB_SETHORIZONTALEXTENT = 0x0194 53 | LB_SETCOLUMNWIDTH = 0x0195 54 | LB_ADDFILE = 0x0196 55 | LB_SETTOPINDEX = 0x0197 56 | LB_GETITEMRECT = 0x0198 57 | LB_GETITEMDATA = 0x0199 58 | LB_SETITEMDATA = 0x019A 59 | LB_SELITEMRANGE = 0x019B 60 | LB_SETANCHORINDEX = 0x019C 61 | LB_GETANCHORINDEX = 0x019D 62 | LB_SETCARETINDEX = 0x019E 63 | LB_GETCARETINDEX = 0x019F 64 | LB_SETITEMHEIGHT = 0x01A0 65 | LB_GETITEMHEIGHT = 0x01A1 66 | LB_FINDSTRINGEXACT = 0x01A2 67 | LB_SETLOCALE = 0x01A5 68 | LB_GETLOCALE = 0x01A6 69 | LB_SETCOUNT = 0x01A7 70 | LB_INITSTORAGE = 0x01A8 71 | LB_ITEMFROMPOINT = 0x01A9 72 | LB_MULTIPLEADDSTRING = 0x01B1 73 | ) 74 | 75 | //Listbox Notification Codes 76 | const ( 77 | LBN_ERRSPACE = -2 78 | LBN_SELCHANGE = 1 79 | LBN_DBLCLK = 2 80 | LBN_SELCANCEL = 3 81 | LBN_SETFOCUS = 4 82 | LBN_KILLFOCUS = 5 83 | ) 84 | const ( 85 | LB_ERR = -1 86 | LB_ERRSPACE = -2 87 | ) 88 | -------------------------------------------------------------------------------- /listview.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | const ( 10 | LVSCW_AUTOSIZE = ^uintptr(0) 11 | LVSCW_AUTOSIZE_USEHEADER = ^uintptr(1) 12 | ) 13 | 14 | // LVM_SETITEMCOUNT flags 15 | const ( 16 | LVSICF_NOINVALIDATEALL = 0x0001 17 | LVSICF_NOSCROLL = 0x0002 18 | ) 19 | 20 | // ListView messages 21 | const ( 22 | LVM_FIRST = 0x1000 23 | LVM_SETBKCOLOR = LVM_FIRST + 1 24 | LVM_SETIMAGELIST = LVM_FIRST + 3 25 | LVM_GETITEM = LVM_FIRST + 75 26 | LVM_SETITEM = LVM_FIRST + 76 27 | LVM_INSERTITEM = LVM_FIRST + 77 28 | LVM_DELETEITEM = LVM_FIRST + 8 29 | LVM_DELETEALLITEMS = LVM_FIRST + 9 30 | LVM_GETCALLBACKMASK = LVM_FIRST + 10 31 | LVM_SETCALLBACKMASK = LVM_FIRST + 11 32 | LVM_GETNEXTITEM = LVM_FIRST + 12 33 | LVM_FINDITEM = LVM_FIRST + 83 34 | LVM_GETITEMRECT = LVM_FIRST + 14 35 | LVM_GETSTRINGWIDTH = LVM_FIRST + 87 36 | LVM_HITTEST = LVM_FIRST + 18 37 | LVM_ENSUREVISIBLE = LVM_FIRST + 19 38 | LVM_SCROLL = LVM_FIRST + 20 39 | LVM_REDRAWITEMS = LVM_FIRST + 21 40 | LVM_ARRANGE = LVM_FIRST + 22 41 | LVM_EDITLABEL = LVM_FIRST + 118 42 | LVM_GETEDITCONTROL = LVM_FIRST + 24 43 | LVM_GETCOLUMN = LVM_FIRST + 95 44 | LVM_SETCOLUMN = LVM_FIRST + 96 45 | LVM_INSERTCOLUMN = LVM_FIRST + 97 46 | LVM_DELETECOLUMN = LVM_FIRST + 28 47 | LVM_GETCOLUMNWIDTH = LVM_FIRST + 29 48 | LVM_SETCOLUMNWIDTH = LVM_FIRST + 30 49 | LVM_GETHEADER = LVM_FIRST + 31 50 | LVM_CREATEDRAGIMAGE = LVM_FIRST + 33 51 | LVM_GETVIEWRECT = LVM_FIRST + 34 52 | LVM_GETTEXTCOLOR = LVM_FIRST + 35 53 | LVM_SETTEXTCOLOR = LVM_FIRST + 36 54 | LVM_GETTEXTBKCOLOR = LVM_FIRST + 37 55 | LVM_SETTEXTBKCOLOR = LVM_FIRST + 38 56 | LVM_GETTOPINDEX = LVM_FIRST + 39 57 | LVM_GETCOUNTPERPAGE = LVM_FIRST + 40 58 | LVM_GETORIGIN = LVM_FIRST + 41 59 | LVM_UPDATE = LVM_FIRST + 42 60 | LVM_SETITEMSTATE = LVM_FIRST + 43 61 | LVM_GETITEMSTATE = LVM_FIRST + 44 62 | LVM_GETITEMTEXT = LVM_FIRST + 115 63 | LVM_SETITEMTEXT = LVM_FIRST + 116 64 | LVM_SETITEMCOUNT = LVM_FIRST + 47 65 | LVM_SORTITEMS = LVM_FIRST + 48 66 | LVM_SETITEMPOSITION32 = LVM_FIRST + 49 67 | LVM_GETSELECTEDCOUNT = LVM_FIRST + 50 68 | LVM_GETITEMSPACING = LVM_FIRST + 51 69 | LVM_GETISEARCHSTRING = LVM_FIRST + 117 70 | LVM_SETICONSPACING = LVM_FIRST + 53 71 | LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54 72 | LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55 73 | LVM_GETSUBITEMRECT = LVM_FIRST + 56 74 | LVM_SUBITEMHITTEST = LVM_FIRST + 57 75 | LVM_SETCOLUMNORDERARRAY = LVM_FIRST + 58 76 | LVM_GETCOLUMNORDERARRAY = LVM_FIRST + 59 77 | LVM_SETHOTITEM = LVM_FIRST + 60 78 | LVM_GETHOTITEM = LVM_FIRST + 61 79 | LVM_SETHOTCURSOR = LVM_FIRST + 62 80 | LVM_GETHOTCURSOR = LVM_FIRST + 63 81 | LVM_APPROXIMATEVIEWRECT = LVM_FIRST + 64 82 | LVM_SETWORKAREAS = LVM_FIRST + 65 83 | LVM_GETWORKAREAS = LVM_FIRST + 70 84 | LVM_GETNUMBEROFWORKAREAS = LVM_FIRST + 73 85 | LVM_GETSELECTIONMARK = LVM_FIRST + 66 86 | LVM_SETSELECTIONMARK = LVM_FIRST + 67 87 | LVM_SETHOVERTIME = LVM_FIRST + 71 88 | LVM_GETHOVERTIME = LVM_FIRST + 72 89 | LVM_SETTOOLTIPS = LVM_FIRST + 74 90 | LVM_GETTOOLTIPS = LVM_FIRST + 78 91 | LVM_SORTITEMSEX = LVM_FIRST + 81 92 | LVM_SETBKIMAGE = LVM_FIRST + 138 93 | LVM_GETBKIMAGE = LVM_FIRST + 139 94 | LVM_SETSELECTEDCOLUMN = LVM_FIRST + 140 95 | LVM_SETVIEW = LVM_FIRST + 142 96 | LVM_GETVIEW = LVM_FIRST + 143 97 | LVM_INSERTGROUP = LVM_FIRST + 145 98 | LVM_SETGROUPINFO = LVM_FIRST + 147 99 | LVM_GETGROUPINFO = LVM_FIRST + 149 100 | LVM_REMOVEGROUP = LVM_FIRST + 150 101 | LVM_MOVEGROUP = LVM_FIRST + 151 102 | LVM_GETGROUPCOUNT = LVM_FIRST + 152 103 | LVM_GETGROUPINFOBYINDEX = LVM_FIRST + 153 104 | LVM_MOVEITEMTOGROUP = LVM_FIRST + 154 105 | LVM_GETGROUPRECT = LVM_FIRST + 98 106 | LVM_SETGROUPMETRICS = LVM_FIRST + 155 107 | LVM_GETGROUPMETRICS = LVM_FIRST + 156 108 | LVM_ENABLEGROUPVIEW = LVM_FIRST + 157 109 | LVM_SORTGROUPS = LVM_FIRST + 158 110 | LVM_INSERTGROUPSORTED = LVM_FIRST + 159 111 | LVM_REMOVEALLGROUPS = LVM_FIRST + 160 112 | LVM_HASGROUP = LVM_FIRST + 161 113 | LVM_GETGROUPSTATE = LVM_FIRST + 92 114 | LVM_GETFOCUSEDGROUP = LVM_FIRST + 93 115 | LVM_SETTILEVIEWINFO = LVM_FIRST + 162 116 | LVM_GETTILEVIEWINFO = LVM_FIRST + 163 117 | LVM_SETTILEINFO = LVM_FIRST + 164 118 | LVM_GETTILEINFO = LVM_FIRST + 165 119 | LVM_SETINSERTMARK = LVM_FIRST + 166 120 | LVM_GETINSERTMARK = LVM_FIRST + 167 121 | LVM_INSERTMARKHITTEST = LVM_FIRST + 168 122 | LVM_GETINSERTMARKRECT = LVM_FIRST + 169 123 | LVM_SETINSERTMARKCOLOR = LVM_FIRST + 170 124 | LVM_GETINSERTMARKCOLOR = LVM_FIRST + 171 125 | LVM_SETINFOTIP = LVM_FIRST + 173 126 | LVM_GETSELECTEDCOLUMN = LVM_FIRST + 174 127 | LVM_ISGROUPVIEWENABLED = LVM_FIRST + 175 128 | LVM_GETOUTLINECOLOR = LVM_FIRST + 176 129 | LVM_SETOUTLINECOLOR = LVM_FIRST + 177 130 | LVM_CANCELEDITLABEL = LVM_FIRST + 179 131 | LVM_MAPINDEXTOID = LVM_FIRST + 180 132 | LVM_MAPIDTOINDEX = LVM_FIRST + 181 133 | LVM_ISITEMVISIBLE = LVM_FIRST + 182 134 | LVM_GETNEXTITEMINDEX = LVM_FIRST + 211 135 | ) 136 | 137 | // ListView notifications 138 | const ( 139 | LVN_FIRST = ^uint32(99) // -100 140 | 141 | LVN_ITEMCHANGING = LVN_FIRST - 0 142 | LVN_ITEMCHANGED = LVN_FIRST - 1 143 | LVN_INSERTITEM = LVN_FIRST - 2 144 | LVN_DELETEITEM = LVN_FIRST - 3 145 | LVN_DELETEALLITEMS = LVN_FIRST - 4 146 | LVN_BEGINLABELEDIT = LVN_FIRST - 75 147 | LVN_ENDLABELEDIT = LVN_FIRST - 76 148 | LVN_COLUMNCLICK = LVN_FIRST - 8 149 | LVN_BEGINDRAG = LVN_FIRST - 9 150 | LVN_BEGINRDRAG = LVN_FIRST - 11 151 | LVN_ODCACHEHINT = LVN_FIRST - 13 152 | LVN_ODFINDITEM = LVN_FIRST - 79 153 | LVN_ITEMACTIVATE = LVN_FIRST - 14 154 | LVN_ODSTATECHANGED = LVN_FIRST - 15 155 | LVN_HOTTRACK = LVN_FIRST - 21 156 | LVN_GETDISPINFO = LVN_FIRST - 77 157 | LVN_SETDISPINFO = LVN_FIRST - 78 158 | LVN_KEYDOWN = LVN_FIRST - 55 159 | LVN_MARQUEEBEGIN = LVN_FIRST - 56 160 | LVN_GETINFOTIP = LVN_FIRST - 58 161 | LVN_INCREMENTALSEARCH = LVN_FIRST - 63 162 | LVN_BEGINSCROLL = LVN_FIRST - 80 163 | LVN_ENDSCROLL = LVN_FIRST - 81 164 | ) 165 | 166 | // ListView LVNI constants 167 | const ( 168 | LVNI_ALL = 0 169 | LVNI_FOCUSED = 1 170 | LVNI_SELECTED = 2 171 | LVNI_CUT = 4 172 | LVNI_DROPHILITED = 8 173 | LVNI_ABOVE = 256 174 | LVNI_BELOW = 512 175 | LVNI_TOLEFT = 1024 176 | LVNI_TORIGHT = 2048 177 | ) 178 | 179 | // ListView styles 180 | const ( 181 | LVS_ICON = 0x0000 182 | LVS_REPORT = 0x0001 183 | LVS_SMALLICON = 0x0002 184 | LVS_LIST = 0x0003 185 | LVS_TYPEMASK = 0x0003 186 | LVS_SINGLESEL = 0x0004 187 | LVS_SHOWSELALWAYS = 0x0008 188 | LVS_SORTASCENDING = 0x0010 189 | LVS_SORTDESCENDING = 0x0020 190 | LVS_SHAREIMAGELISTS = 0x0040 191 | LVS_NOLABELWRAP = 0x0080 192 | LVS_AUTOARRANGE = 0x0100 193 | LVS_EDITLABELS = 0x0200 194 | LVS_OWNERDATA = 0x1000 195 | LVS_NOSCROLL = 0x2000 196 | LVS_TYPESTYLEMASK = 0xfc00 197 | LVS_ALIGNTOP = 0x0000 198 | LVS_ALIGNLEFT = 0x0800 199 | LVS_ALIGNMASK = 0x0c00 200 | LVS_OWNERDRAWFIXED = 0x0400 201 | LVS_NOCOLUMNHEADER = 0x4000 202 | LVS_NOSORTHEADER = 0x8000 203 | ) 204 | 205 | // ListView extended styles 206 | const ( 207 | LVS_EX_GRIDLINES = 0x00000001 208 | LVS_EX_SUBITEMIMAGES = 0x00000002 209 | LVS_EX_CHECKBOXES = 0x00000004 210 | LVS_EX_TRACKSELECT = 0x00000008 211 | LVS_EX_HEADERDRAGDROP = 0x00000010 212 | LVS_EX_FULLROWSELECT = 0x00000020 213 | LVS_EX_ONECLICKACTIVATE = 0x00000040 214 | LVS_EX_TWOCLICKACTIVATE = 0x00000080 215 | LVS_EX_FLATSB = 0x00000100 216 | LVS_EX_REGIONAL = 0x00000200 217 | LVS_EX_INFOTIP = 0x00000400 218 | LVS_EX_UNDERLINEHOT = 0x00000800 219 | LVS_EX_UNDERLINECOLD = 0x00001000 220 | LVS_EX_MULTIWORKAREAS = 0x00002000 221 | LVS_EX_LABELTIP = 0x00004000 222 | LVS_EX_BORDERSELECT = 0x00008000 223 | LVS_EX_DOUBLEBUFFER = 0x00010000 224 | LVS_EX_HIDELABELS = 0x00020000 225 | LVS_EX_SINGLEROW = 0x00040000 226 | LVS_EX_SNAPTOGRID = 0x00080000 227 | LVS_EX_SIMPLESELECT = 0x00100000 228 | ) 229 | 230 | // ListView column flags 231 | const ( 232 | LVCF_FMT = 0x0001 233 | LVCF_WIDTH = 0x0002 234 | LVCF_TEXT = 0x0004 235 | LVCF_SUBITEM = 0x0008 236 | LVCF_IMAGE = 0x0010 237 | LVCF_ORDER = 0x0020 238 | ) 239 | 240 | // ListView column format constants 241 | const ( 242 | LVCFMT_LEFT = 0x0000 243 | LVCFMT_RIGHT = 0x0001 244 | LVCFMT_CENTER = 0x0002 245 | LVCFMT_JUSTIFYMASK = 0x0003 246 | LVCFMT_IMAGE = 0x0800 247 | LVCFMT_BITMAP_ON_RIGHT = 0x1000 248 | LVCFMT_COL_HAS_IMAGES = 0x8000 249 | ) 250 | 251 | // ListView item flags 252 | const ( 253 | LVIF_TEXT = 0x00000001 254 | LVIF_IMAGE = 0x00000002 255 | LVIF_PARAM = 0x00000004 256 | LVIF_STATE = 0x00000008 257 | LVIF_INDENT = 0x00000010 258 | LVIF_NORECOMPUTE = 0x00000800 259 | LVIF_GROUPID = 0x00000100 260 | LVIF_COLUMNS = 0x00000200 261 | ) 262 | 263 | // ListView item states 264 | const ( 265 | LVIS_FOCUSED = 1 266 | LVIS_SELECTED = 2 267 | LVIS_CUT = 4 268 | LVIS_DROPHILITED = 8 269 | LVIS_OVERLAYMASK = 0xF00 270 | LVIS_STATEIMAGEMASK = 0xF000 271 | ) 272 | 273 | // ListView hit test constants 274 | const ( 275 | LVHT_NOWHERE = 0x00000001 276 | LVHT_ONITEMICON = 0x00000002 277 | LVHT_ONITEMLABEL = 0x00000004 278 | LVHT_ONITEMSTATEICON = 0x00000008 279 | LVHT_ONITEM = LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON 280 | 281 | LVHT_ABOVE = 0x00000008 282 | LVHT_BELOW = 0x00000010 283 | LVHT_TORIGHT = 0x00000020 284 | LVHT_TOLEFT = 0x00000040 285 | ) 286 | 287 | // ListView image list types 288 | const ( 289 | LVSIL_NORMAL = 0 290 | LVSIL_SMALL = 1 291 | LVSIL_STATE = 2 292 | LVSIL_GROUPHEADER = 3 293 | ) 294 | 295 | type LVCOLUMN struct { 296 | Mask uint32 297 | Fmt int32 298 | Cx int32 299 | PszText *uint16 300 | CchTextMax int32 301 | ISubItem int32 302 | IImage int32 303 | IOrder int32 304 | } 305 | 306 | type LVITEM struct { 307 | Mask uint32 308 | IItem int32 309 | ISubItem int32 310 | State uint32 311 | StateMask uint32 312 | PszText *uint16 313 | CchTextMax int32 314 | IImage int32 315 | LParam uintptr 316 | IIndent int32 317 | IGroupId int32 318 | CColumns uint32 319 | PuColumns uint32 320 | } 321 | 322 | type LVHITTESTINFO struct { 323 | Pt POINT 324 | Flags uint32 325 | IItem int32 326 | ISubItem int32 327 | IGroup int32 328 | } 329 | 330 | type NMITEMACTIVATE struct { 331 | Hdr NMHDR 332 | IItem int32 333 | ISubItem int32 334 | UNewState uint32 335 | UOldState uint32 336 | UChanged uint32 337 | PtAction POINT 338 | LParam uintptr 339 | UKeyFlags uint32 340 | } 341 | 342 | type NMLISTVIEW struct { 343 | Hdr NMHDR 344 | IItem int32 345 | ISubItem int32 346 | UNewState uint32 347 | UOldState uint32 348 | UChanged uint32 349 | PtAction POINT 350 | LParam uintptr 351 | } 352 | 353 | type NMLVCUSTOMDRAW struct { 354 | Nmcd NMCUSTOMDRAW 355 | ClrText COLORREF 356 | ClrTextBk COLORREF 357 | ISubItem int32 358 | DwItemType uint32 359 | ClrFace COLORREF 360 | IIconEffect int32 361 | IIconPhase int32 362 | IPartId int32 363 | IStateId int32 364 | RcText RECT 365 | UAlign uint32 366 | } 367 | 368 | type NMLVDISPINFO struct { 369 | Hdr NMHDR 370 | Item LVITEM 371 | } 372 | 373 | type NMLVSCROLL struct { 374 | Hdr NMHDR 375 | Dx int32 376 | Dy int32 377 | } 378 | -------------------------------------------------------------------------------- /menu.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | // Constants for MENUITEMINFO.fMask 10 | const ( 11 | MIIM_STATE = 1 12 | MIIM_ID = 2 13 | MIIM_SUBMENU = 4 14 | MIIM_CHECKMARKS = 8 15 | MIIM_TYPE = 16 16 | MIIM_DATA = 32 17 | MIIM_STRING = 64 18 | MIIM_BITMAP = 128 19 | MIIM_FTYPE = 256 20 | ) 21 | 22 | // Constants for MENUITEMINFO.fType 23 | const ( 24 | MFT_STRING = MF_STRING 25 | MFT_BITMAP = MF_BITMAP 26 | MFT_MENUBARBREAK = MF_MENUBARBREAK 27 | MFT_MENUBREAK = MF_MENUBREAK 28 | MFT_OWNERDRAW = MF_OWNERDRAW 29 | MFT_RADIOCHECK = 0x00000200 30 | MFT_SEPARATOR = MF_SEPARATOR 31 | MFT_RIGHTORDER = 0x00002000 32 | MFT_RIGHTJUSTIFY = MF_RIGHTJUSTIFY 33 | ) 34 | 35 | // Constants for MENUITEMINFO.fState 36 | const ( 37 | MFS_GRAYED = 0x00000003 38 | MFS_DISABLED = MFS_GRAYED 39 | MFS_CHECKED = MF_CHECKED 40 | MFS_HILITE = MF_HILITE 41 | MFS_ENABLED = MF_ENABLED 42 | MFS_UNCHECKED = MF_UNCHECKED 43 | MFS_UNHILITE = MF_UNHILITE 44 | MFS_DEFAULT = MF_DEFAULT 45 | ) 46 | 47 | // Constants for MENUITEMINFO.hbmp* 48 | const ( 49 | HBMMENU_CALLBACK = -1 50 | HBMMENU_SYSTEM = 1 51 | HBMMENU_MBAR_RESTORE = 2 52 | HBMMENU_MBAR_MINIMIZE = 3 53 | HBMMENU_MBAR_CLOSE = 5 54 | HBMMENU_MBAR_CLOSE_D = 6 55 | HBMMENU_MBAR_MINIMIZE_D = 7 56 | HBMMENU_POPUP_CLOSE = 8 57 | HBMMENU_POPUP_RESTORE = 9 58 | HBMMENU_POPUP_MAXIMIZE = 10 59 | HBMMENU_POPUP_MINIMIZE = 11 60 | ) 61 | 62 | // MENUINFO mask constants 63 | const ( 64 | MIM_APPLYTOSUBMENUS = 0x80000000 65 | MIM_BACKGROUND = 0x00000002 66 | MIM_HELPID = 0x00000004 67 | MIM_MAXHEIGHT = 0x00000001 68 | MIM_MENUDATA = 0x00000008 69 | MIM_STYLE = 0x00000010 70 | ) 71 | 72 | // MENUINFO style constants 73 | const ( 74 | MNS_AUTODISMISS = 0x10000000 75 | MNS_CHECKORBMP = 0x04000000 76 | MNS_DRAGDROP = 0x20000000 77 | MNS_MODELESS = 0x40000000 78 | MNS_NOCHECK = 0x80000000 79 | MNS_NOTIFYBYPOS = 0x08000000 80 | ) 81 | 82 | const ( 83 | // Menu flags for Add/Check/EnableMenuItem() 84 | MF_INSERT = 0x00000000 85 | MF_CHANGE = 0x00000080 86 | MF_APPEND = 0x00000100 87 | MF_DELETE = 0x00000200 88 | MF_REMOVE = 0x00001000 89 | 90 | MF_BYCOMMAND = 0x00000000 91 | MF_BYPOSITION = 0x00000400 92 | 93 | MF_SEPARATOR = 0x00000800 94 | 95 | MF_ENABLED = 0x00000000 96 | MF_GRAYED = 0x00000001 97 | MF_DISABLED = 0x00000002 98 | 99 | MF_UNCHECKED = 0x00000000 100 | MF_CHECKED = 0x00000008 101 | MF_USECHECKBITMAPS = 0x00000200 102 | 103 | MF_STRING = 0x00000000 104 | MF_BITMAP = 0x00000004 105 | MF_OWNERDRAW = 0x00000100 106 | 107 | MF_POPUP = 0x00000010 108 | MF_MENUBARBREAK = 0x00000020 109 | MF_MENUBREAK = 0x00000040 110 | 111 | MF_UNHILITE = 0x00000000 112 | MF_HILITE = 0x00000080 113 | 114 | MF_DEFAULT = 0x00001000 115 | MF_SYSMENU = 0x00002000 116 | MF_HELP = 0x00004000 117 | MF_RIGHTJUSTIFY = 0x00004000 118 | 119 | MF_MOUSESELECT = 0x00008000 120 | ) 121 | 122 | type MENUITEMINFO struct { 123 | CbSize uint32 124 | FMask uint32 125 | FType uint32 126 | FState uint32 127 | WID uint32 128 | HSubMenu HMENU 129 | HbmpChecked HBITMAP 130 | HbmpUnchecked HBITMAP 131 | DwItemData uintptr 132 | DwTypeData *uint16 133 | Cch uint32 134 | HbmpItem HBITMAP 135 | } 136 | 137 | type MENUINFO struct { 138 | CbSize uint32 139 | FMask uint32 140 | DwStyle uint32 141 | CyMax uint32 142 | HbrBack HBRUSH 143 | DwContextHelpID uint32 144 | DwMenuData uintptr 145 | } 146 | -------------------------------------------------------------------------------- /oaidl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | type SCODE int32 15 | 16 | type EXCEPINFO struct { 17 | wCode uint16 18 | wReserved uint16 19 | bstrSource *uint16 /*BSTR*/ 20 | bstrDescription *uint16 /*BSTR*/ 21 | bstrHelpFile *uint16 /*BSTR*/ 22 | dwHelpContext uint32 23 | pvReserved uintptr 24 | pfnDeferredFillIn uintptr 25 | scode SCODE 26 | } 27 | 28 | var ( 29 | IID_ITypeInfo = IID{0x00020401, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 30 | ) 31 | 32 | type ITypeInfoVtbl struct { 33 | IUnknownVtbl 34 | GetTypeAttr uintptr 35 | GetTypeComp uintptr 36 | GetFuncDesc uintptr 37 | GetVarDesc uintptr 38 | GetNames uintptr 39 | GetRefTypeOfImplType uintptr 40 | GetImplTypeFlags uintptr 41 | GetIDsOfNames uintptr 42 | Invoke uintptr 43 | GetDocumentation uintptr 44 | GetDllEntry uintptr 45 | GetRefTypeInfo uintptr 46 | AddressOfMember uintptr 47 | CreateInstance uintptr 48 | GetMops uintptr 49 | GetContainingTypeLib uintptr 50 | ReleaseTypeAttr uintptr 51 | ReleaseFuncDesc uintptr 52 | ReleaseVarDesc uintptr 53 | } 54 | 55 | type ITypeInfo struct { 56 | LpVtbl *ITypeInfoVtbl 57 | } 58 | 59 | func (obj *ITypeInfo) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 60 | ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, 61 | uintptr(unsafe.Pointer(obj)), 62 | uintptr(unsafe.Pointer(riid)), 63 | uintptr(unsafe.Pointer(ppvObject))) 64 | return HRESULT(ret) 65 | } 66 | 67 | func (obj *ITypeInfo) AddRef() uint32 { 68 | ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, 69 | uintptr(unsafe.Pointer(obj)), 70 | 0, 71 | 0) 72 | return uint32(ret) 73 | } 74 | 75 | func (obj *ITypeInfo) Release() uint32 { 76 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, 77 | uintptr(unsafe.Pointer(obj)), 78 | 0, 79 | 0) 80 | return uint32(ret) 81 | } 82 | -------------------------------------------------------------------------------- /objidl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | type IDataObjectVtbl struct { 10 | IUnknownVtbl 11 | GetData uintptr 12 | GetDataHere uintptr 13 | QueryGetData uintptr 14 | GetCanonicalFormatEtc uintptr 15 | SetData uintptr 16 | EnumFormatEtc uintptr 17 | DAdvise uintptr 18 | DUnadvise uintptr 19 | EnumDAdvise uintptr 20 | } 21 | 22 | type IDataObject struct { 23 | LpVtbl *IDataObjectVtbl 24 | } 25 | 26 | type IStorageVtbl struct { 27 | IUnknownVtbl 28 | CreateStream uintptr 29 | OpenStream uintptr 30 | CreateStorage uintptr 31 | OpenStorage uintptr 32 | CopyTo uintptr 33 | MoveElementTo uintptr 34 | Commit uintptr 35 | Revert uintptr 36 | EnumElements uintptr 37 | DestroyElement uintptr 38 | RenameElement uintptr 39 | SetElementTimes uintptr 40 | SetClass uintptr 41 | SetStateBits uintptr 42 | Stat uintptr 43 | } 44 | 45 | type IStorage struct { 46 | LpVtbl *IStorageVtbl 47 | } 48 | -------------------------------------------------------------------------------- /ole32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | 13 | "golang.org/x/sys/windows" 14 | ) 15 | 16 | const ( 17 | CLSCTX_INPROC_SERVER = 0x1 18 | CLSCTX_INPROC_HANDLER = 0x2 19 | CLSCTX_LOCAL_SERVER = 0x4 20 | CLSCTX_INPROC_SERVER16 = 0x8 21 | CLSCTX_REMOTE_SERVER = 0x10 22 | CLSCTX_INPROC_HANDLER16 = 0x20 23 | CLSCTX_RESERVED1 = 0x40 24 | CLSCTX_RESERVED2 = 0x80 25 | CLSCTX_RESERVED3 = 0x100 26 | CLSCTX_RESERVED4 = 0x200 27 | CLSCTX_NO_CODE_DOWNLOAD = 0x400 28 | CLSCTX_RESERVED5 = 0x800 29 | CLSCTX_NO_CUSTOM_MARSHAL = 0x1000 30 | CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000 31 | CLSCTX_NO_FAILURE_LOG = 0x4000 32 | CLSCTX_DISABLE_AAA = 0x8000 33 | CLSCTX_ENABLE_AAA = 0x10000 34 | CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000 35 | CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000 36 | CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000 37 | CLSCTX_ENABLE_CLOAKING = 0x100000 38 | CLSCTX_PS_DLL = 0x80000000 39 | CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER 40 | CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER 41 | CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER 42 | ) 43 | 44 | const ( 45 | COINIT_APARTMENTTHREADED = 0x2 // Apartment model 46 | COINIT_MULTITHREADED = 0x0 // OLE calls objects on any thread. 47 | COINIT_DISABLE_OLE1DDE = 0x4 // Don't use DDE for Ole1 support. 48 | COINIT_SPEED_OVER_MEMORY = 0x8 // Trade memory for speed. 49 | ) 50 | 51 | // Verbs for IOleObject.DoVerb 52 | const ( 53 | OLEIVERB_PRIMARY = 0 54 | OLEIVERB_SHOW = -1 55 | OLEIVERB_OPEN = -2 56 | OLEIVERB_HIDE = -3 57 | OLEIVERB_UIACTIVATE = -4 58 | OLEIVERB_INPLACEACTIVATE = -5 59 | OLEIVERB_DISCARDUNDOSTATE = -6 60 | ) 61 | 62 | // OLECLOSE constants 63 | const ( 64 | OLECLOSE_SAVEIFDIRTY = 0 65 | OLECLOSE_NOSAVE = 1 66 | OLECLOSE_PROMPTSAVE = 2 67 | ) 68 | 69 | type IID syscall.GUID 70 | type CLSID syscall.GUID 71 | type REFIID *IID 72 | type REFCLSID *CLSID 73 | 74 | var ( 75 | IID_IClassFactory = IID{0x00000001, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 76 | IID_IConnectionPointContainer = IID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} 77 | IID_IOleClientSite = IID{0x00000118, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 78 | IID_IOleInPlaceObject = IID{0x00000113, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 79 | IID_IOleInPlaceSite = IID{0x00000119, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 80 | IID_IOleObject = IID{0x00000112, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 81 | IID_IUnknown = IID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 82 | ) 83 | 84 | func EqualREFIID(a, b REFIID) bool { 85 | if a == b { 86 | return true 87 | } 88 | if a == nil || b == nil { 89 | return false 90 | } 91 | 92 | if a.Data1 != b.Data1 || a.Data2 != b.Data2 || a.Data3 != b.Data3 { 93 | return false 94 | } 95 | 96 | for i := 0; i < 8; i++ { 97 | if a.Data4[i] != b.Data4[i] { 98 | return false 99 | } 100 | } 101 | 102 | return true 103 | } 104 | 105 | type IClassFactoryVtbl struct { 106 | QueryInterface uintptr 107 | AddRef uintptr 108 | Release uintptr 109 | CreateInstance uintptr 110 | LockServer uintptr 111 | } 112 | 113 | type IClassFactory struct { 114 | LpVtbl *IClassFactoryVtbl 115 | } 116 | 117 | func (cf *IClassFactory) Release() uint32 { 118 | ret, _, _ := syscall.Syscall(cf.LpVtbl.Release, 1, 119 | uintptr(unsafe.Pointer(cf)), 120 | 0, 121 | 0) 122 | 123 | return uint32(ret) 124 | } 125 | 126 | func (cf *IClassFactory) CreateInstance(pUnkOuter *IUnknown, riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 127 | ret, _, _ := syscall.Syscall6(cf.LpVtbl.CreateInstance, 4, 128 | uintptr(unsafe.Pointer(cf)), 129 | uintptr(unsafe.Pointer(pUnkOuter)), 130 | uintptr(unsafe.Pointer(riid)), 131 | uintptr(unsafe.Pointer(ppvObject)), 132 | 0, 133 | 0) 134 | 135 | return HRESULT(ret) 136 | } 137 | 138 | type IConnectionPointVtbl struct { 139 | QueryInterface uintptr 140 | AddRef uintptr 141 | Release uintptr 142 | GetConnectionInterface uintptr 143 | GetConnectionPointContainer uintptr 144 | Advise uintptr 145 | Unadvise uintptr 146 | EnumConnections uintptr 147 | } 148 | 149 | type IConnectionPoint struct { 150 | LpVtbl *IConnectionPointVtbl 151 | } 152 | 153 | func (cp *IConnectionPoint) Release() uint32 { 154 | ret, _, _ := syscall.Syscall(cp.LpVtbl.Release, 1, 155 | uintptr(unsafe.Pointer(cp)), 156 | 0, 157 | 0) 158 | 159 | return uint32(ret) 160 | } 161 | 162 | func (cp *IConnectionPoint) Advise(pUnkSink unsafe.Pointer, pdwCookie *uint32) HRESULT { 163 | ret, _, _ := syscall.Syscall(cp.LpVtbl.Advise, 3, 164 | uintptr(unsafe.Pointer(cp)), 165 | uintptr(pUnkSink), 166 | uintptr(unsafe.Pointer(pdwCookie))) 167 | 168 | return HRESULT(ret) 169 | } 170 | 171 | type IConnectionPointContainerVtbl struct { 172 | QueryInterface uintptr 173 | AddRef uintptr 174 | Release uintptr 175 | EnumConnectionPoints uintptr 176 | FindConnectionPoint uintptr 177 | } 178 | 179 | type IConnectionPointContainer struct { 180 | LpVtbl *IConnectionPointContainerVtbl 181 | } 182 | 183 | func (cpc *IConnectionPointContainer) Release() uint32 { 184 | ret, _, _ := syscall.Syscall(cpc.LpVtbl.Release, 1, 185 | uintptr(unsafe.Pointer(cpc)), 186 | 0, 187 | 0) 188 | 189 | return uint32(ret) 190 | } 191 | 192 | func (cpc *IConnectionPointContainer) FindConnectionPoint(riid REFIID, ppCP **IConnectionPoint) HRESULT { 193 | ret, _, _ := syscall.Syscall(cpc.LpVtbl.FindConnectionPoint, 3, 194 | uintptr(unsafe.Pointer(cpc)), 195 | uintptr(unsafe.Pointer(riid)), 196 | uintptr(unsafe.Pointer(ppCP))) 197 | 198 | return HRESULT(ret) 199 | } 200 | 201 | type IOleClientSiteVtbl struct { 202 | QueryInterface uintptr 203 | AddRef uintptr 204 | Release uintptr 205 | SaveObject uintptr 206 | GetMoniker uintptr 207 | GetContainer uintptr 208 | ShowObject uintptr 209 | OnShowWindow uintptr 210 | RequestNewObjectLayout uintptr 211 | } 212 | 213 | type IOleClientSite struct { 214 | LpVtbl *IOleClientSiteVtbl 215 | } 216 | 217 | type IOleInPlaceFrameVtbl struct { 218 | QueryInterface uintptr 219 | AddRef uintptr 220 | Release uintptr 221 | GetWindow uintptr 222 | ContextSensitiveHelp uintptr 223 | GetBorder uintptr 224 | RequestBorderSpace uintptr 225 | SetBorderSpace uintptr 226 | SetActiveObject uintptr 227 | InsertMenus uintptr 228 | SetMenu uintptr 229 | RemoveMenus uintptr 230 | SetStatusText uintptr 231 | EnableModeless uintptr 232 | TranslateAccelerator uintptr 233 | } 234 | 235 | type IOleInPlaceFrame struct { 236 | LpVtbl *IOleInPlaceFrameVtbl 237 | } 238 | 239 | type IOleInPlaceObjectVtbl struct { 240 | QueryInterface uintptr 241 | AddRef uintptr 242 | Release uintptr 243 | GetWindow uintptr 244 | ContextSensitiveHelp uintptr 245 | InPlaceDeactivate uintptr 246 | UIDeactivate uintptr 247 | SetObjectRects uintptr 248 | ReactivateAndUndo uintptr 249 | } 250 | 251 | type IOleInPlaceObject struct { 252 | LpVtbl *IOleInPlaceObjectVtbl 253 | } 254 | 255 | func (obj *IOleInPlaceObject) Release() uint32 { 256 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, 257 | uintptr(unsafe.Pointer(obj)), 258 | 0, 259 | 0) 260 | 261 | return uint32(ret) 262 | } 263 | 264 | func (obj *IOleInPlaceObject) SetObjectRects(lprcPosRect, lprcClipRect *RECT) HRESULT { 265 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetObjectRects, 3, 266 | uintptr(unsafe.Pointer(obj)), 267 | uintptr(unsafe.Pointer(lprcPosRect)), 268 | uintptr(unsafe.Pointer(lprcClipRect))) 269 | 270 | return HRESULT(ret) 271 | } 272 | 273 | type IOleInPlaceSiteVtbl struct { 274 | QueryInterface uintptr 275 | AddRef uintptr 276 | Release uintptr 277 | GetWindow uintptr 278 | ContextSensitiveHelp uintptr 279 | CanInPlaceActivate uintptr 280 | OnInPlaceActivate uintptr 281 | OnUIActivate uintptr 282 | GetWindowContext uintptr 283 | Scroll uintptr 284 | OnUIDeactivate uintptr 285 | OnInPlaceDeactivate uintptr 286 | DiscardUndoState uintptr 287 | DeactivateAndUndo uintptr 288 | OnPosRectChange uintptr 289 | } 290 | 291 | type IOleInPlaceSite struct { 292 | LpVtbl *IOleInPlaceSiteVtbl 293 | } 294 | 295 | type IOleObjectVtbl struct { 296 | QueryInterface uintptr 297 | AddRef uintptr 298 | Release uintptr 299 | SetClientSite uintptr 300 | GetClientSite uintptr 301 | SetHostNames uintptr 302 | Close uintptr 303 | SetMoniker uintptr 304 | GetMoniker uintptr 305 | InitFromData uintptr 306 | GetClipboardData uintptr 307 | DoVerb uintptr 308 | EnumVerbs uintptr 309 | Update uintptr 310 | IsUpToDate uintptr 311 | GetUserClassID uintptr 312 | GetUserType uintptr 313 | SetExtent uintptr 314 | GetExtent uintptr 315 | Advise uintptr 316 | Unadvise uintptr 317 | EnumAdvise uintptr 318 | GetMiscStatus uintptr 319 | SetColorScheme uintptr 320 | } 321 | 322 | type IOleObject struct { 323 | LpVtbl *IOleObjectVtbl 324 | } 325 | 326 | func (obj *IOleObject) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 327 | ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, 328 | uintptr(unsafe.Pointer(obj)), 329 | uintptr(unsafe.Pointer(riid)), 330 | uintptr(unsafe.Pointer(ppvObject))) 331 | 332 | return HRESULT(ret) 333 | } 334 | 335 | func (obj *IOleObject) Release() uint32 { 336 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, 337 | uintptr(unsafe.Pointer(obj)), 338 | 0, 339 | 0) 340 | 341 | return uint32(ret) 342 | } 343 | 344 | func (obj *IOleObject) SetClientSite(pClientSite *IOleClientSite) HRESULT { 345 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetClientSite, 2, 346 | uintptr(unsafe.Pointer(obj)), 347 | uintptr(unsafe.Pointer(pClientSite)), 348 | 0) 349 | 350 | return HRESULT(ret) 351 | } 352 | 353 | func (obj *IOleObject) SetHostNames(szContainerApp, szContainerObj *uint16) HRESULT { 354 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetHostNames, 3, 355 | uintptr(unsafe.Pointer(obj)), 356 | uintptr(unsafe.Pointer(szContainerApp)), 357 | uintptr(unsafe.Pointer(szContainerObj))) 358 | 359 | return HRESULT(ret) 360 | } 361 | 362 | func (obj *IOleObject) Close(dwSaveOption uint32) HRESULT { 363 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Close, 2, 364 | uintptr(unsafe.Pointer(obj)), 365 | uintptr(dwSaveOption), 366 | 0) 367 | 368 | return HRESULT(ret) 369 | } 370 | 371 | func (obj *IOleObject) DoVerb(iVerb int32, lpmsg *MSG, pActiveSite *IOleClientSite, lindex int32, hwndParent HWND, lprcPosRect *RECT) HRESULT { 372 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.DoVerb, 7, 373 | uintptr(unsafe.Pointer(obj)), 374 | uintptr(iVerb), 375 | uintptr(unsafe.Pointer(lpmsg)), 376 | uintptr(unsafe.Pointer(pActiveSite)), 377 | uintptr(lindex), 378 | uintptr(hwndParent), 379 | uintptr(unsafe.Pointer(lprcPosRect)), 380 | 0, 381 | 0) 382 | 383 | return HRESULT(ret) 384 | } 385 | 386 | type IUnknownVtbl struct { 387 | QueryInterface uintptr 388 | AddRef uintptr 389 | Release uintptr 390 | } 391 | 392 | type IUnknown struct { 393 | LpVtbl *IUnknownVtbl 394 | } 395 | 396 | type OLEINPLACEFRAMEINFO struct { 397 | Cb uint32 398 | FMDIApp BOOL 399 | HwndFrame HWND 400 | Haccel HACCEL 401 | CAccelEntries uint32 402 | } 403 | 404 | type COAUTHIDENTITY struct { 405 | User *uint16 406 | UserLength uint32 407 | Domain *uint16 408 | DomainLength uint32 409 | Password *uint16 410 | PasswordLength uint32 411 | Flags uint32 412 | } 413 | 414 | type COAUTHINFO struct { 415 | dwAuthnSvc uint32 416 | dwAuthzSvc uint32 417 | pwszServerPrincName *uint16 418 | dwAuthnLevel uint32 419 | dwImpersonationLevel uint32 420 | pAuthIdentityData *COAUTHIDENTITY 421 | dwCapabilities uint32 422 | } 423 | 424 | type COSERVERINFO struct { 425 | dwReserved1 uint32 426 | pwszName *uint16 427 | pAuthInfo *COAUTHINFO 428 | dwReserved2 uint32 429 | } 430 | 431 | var ( 432 | // Library 433 | libole32 *windows.LazyDLL 434 | 435 | // Functions 436 | coCreateInstance *windows.LazyProc 437 | coGetClassObject *windows.LazyProc 438 | coInitializeEx *windows.LazyProc 439 | coTaskMemFree *windows.LazyProc 440 | coUninitialize *windows.LazyProc 441 | oleInitialize *windows.LazyProc 442 | oleSetContainedObject *windows.LazyProc 443 | oleUninitialize *windows.LazyProc 444 | ) 445 | 446 | func init() { 447 | // Library 448 | libole32 = windows.NewLazySystemDLL("ole32.dll") 449 | 450 | // Functions 451 | coCreateInstance = libole32.NewProc("CoCreateInstance") 452 | coGetClassObject = libole32.NewProc("CoGetClassObject") 453 | coInitializeEx = libole32.NewProc("CoInitializeEx") 454 | coTaskMemFree = libole32.NewProc("CoTaskMemFree") 455 | coUninitialize = libole32.NewProc("CoUninitialize") 456 | oleInitialize = libole32.NewProc("OleInitialize") 457 | oleSetContainedObject = libole32.NewProc("OleSetContainedObject") 458 | oleUninitialize = libole32.NewProc("OleUninitialize") 459 | } 460 | 461 | func CoCreateInstance(rclsid REFCLSID, pUnkOuter *IUnknown, dwClsContext uint32, riid REFIID, ppv *unsafe.Pointer) HRESULT { 462 | ret, _, _ := syscall.Syscall6(coCreateInstance.Addr(), 5, 463 | uintptr(unsafe.Pointer(rclsid)), 464 | uintptr(unsafe.Pointer(pUnkOuter)), 465 | uintptr(dwClsContext), 466 | uintptr(unsafe.Pointer(riid)), 467 | uintptr(unsafe.Pointer(ppv)), 468 | 0) 469 | 470 | return HRESULT(ret) 471 | } 472 | 473 | func CoGetClassObject(rclsid REFCLSID, dwClsContext uint32, pServerInfo *COSERVERINFO, riid REFIID, ppv *unsafe.Pointer) HRESULT { 474 | ret, _, _ := syscall.Syscall6(coGetClassObject.Addr(), 5, 475 | uintptr(unsafe.Pointer(rclsid)), 476 | uintptr(dwClsContext), 477 | uintptr(unsafe.Pointer(pServerInfo)), 478 | uintptr(unsafe.Pointer(riid)), 479 | uintptr(unsafe.Pointer(ppv)), 480 | 0) 481 | 482 | return HRESULT(ret) 483 | } 484 | 485 | func CoInitializeEx(reserved unsafe.Pointer, coInit uint32) HRESULT { 486 | ret, _, _ := syscall.Syscall(coInitializeEx.Addr(), 2, 487 | uintptr(reserved), 488 | uintptr(coInit), 489 | 0) 490 | 491 | return HRESULT(ret) 492 | } 493 | 494 | func CoUninitialize() { 495 | syscall.Syscall(coUninitialize.Addr(), 0, 496 | 0, 497 | 0, 498 | 0) 499 | } 500 | 501 | func CoTaskMemFree(pv uintptr) { 502 | syscall.Syscall(coTaskMemFree.Addr(), 1, 503 | pv, 504 | 0, 505 | 0) 506 | } 507 | 508 | func OleInitialize() HRESULT { 509 | ret, _, _ := syscall.Syscall(oleInitialize.Addr(), 1, // WTF, why does 0 not work here? 510 | 0, 511 | 0, 512 | 0) 513 | 514 | return HRESULT(ret) 515 | } 516 | 517 | func OleSetContainedObject(pUnknown *IUnknown, fContained bool) HRESULT { 518 | ret, _, _ := syscall.Syscall(oleSetContainedObject.Addr(), 2, 519 | uintptr(unsafe.Pointer(pUnknown)), 520 | uintptr(BoolToBOOL(fContained)), 521 | 0) 522 | 523 | return HRESULT(ret) 524 | } 525 | 526 | func OleUninitialize() { 527 | syscall.Syscall(oleUninitialize.Addr(), 0, 528 | 0, 529 | 0, 530 | 0) 531 | } 532 | -------------------------------------------------------------------------------- /oleacc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | type AnnoScope int 15 | 16 | const ( 17 | ANNO_THIS = AnnoScope(0) 18 | ANNO_CONTAINER = AnnoScope(1) 19 | ) 20 | 21 | type MSAAPROPID syscall.GUID 22 | 23 | var ( 24 | PROPID_ACC_NAME = MSAAPROPID{0x608d3df8, 0x8128, 0x4aa7, [8]byte{0xa4, 0x28, 0xf5, 0x5e, 0x49, 0x26, 0x72, 0x91}} 25 | PROPID_ACC_VALUE = MSAAPROPID{0x123fe443, 0x211a, 0x4615, [8]byte{0x95, 0x27, 0xc4, 0x5a, 0x7e, 0x93, 0x71, 0x7a}} 26 | PROPID_ACC_DESCRIPTION = MSAAPROPID{0x4d48dfe4, 0xbd3f, 0x491f, [8]byte{0xa6, 0x48, 0x49, 0x2d, 0x6f, 0x20, 0xc5, 0x88}} 27 | PROPID_ACC_ROLE = MSAAPROPID{0xcb905ff2, 0x7bd1, 0x4c05, [8]byte{0xb3, 0xc8, 0xe6, 0xc2, 0x41, 0x36, 0x4d, 0x70}} 28 | PROPID_ACC_STATE = MSAAPROPID{0xa8d4d5b0, 0x0a21, 0x42d0, [8]byte{0xa5, 0xc0, 0x51, 0x4e, 0x98, 0x4f, 0x45, 0x7b}} 29 | PROPID_ACC_HELP = MSAAPROPID{0xc831e11f, 0x44db, 0x4a99, [8]byte{0x97, 0x68, 0xcb, 0x8f, 0x97, 0x8b, 0x72, 0x31}} 30 | PROPID_ACC_KEYBOARDSHORTCUT = MSAAPROPID{0x7d9bceee, 0x7d1e, 0x4979, [8]byte{0x93, 0x82, 0x51, 0x80, 0xf4, 0x17, 0x2c, 0x34}} 31 | PROPID_ACC_DEFAULTACTION = MSAAPROPID{0x180c072b, 0xc27f, 0x43c7, [8]byte{0x99, 0x22, 0xf6, 0x35, 0x62, 0xa4, 0x63, 0x2b}} 32 | PROPID_ACC_HELPTOPIC = MSAAPROPID{0x787d1379, 0x8ede, 0x440b, [8]byte{0x8a, 0xec, 0x11, 0xf7, 0xbf, 0x90, 0x30, 0xb3}} 33 | PROPID_ACC_FOCUS = MSAAPROPID{0x6eb335df, 0x1c29, 0x4127, [8]byte{0xb1, 0x2c, 0xde, 0xe9, 0xfd, 0x15, 0x7f, 0x2b}} 34 | PROPID_ACC_SELECTION = MSAAPROPID{0xb99d073c, 0xd731, 0x405b, [8]byte{0x90, 0x61, 0xd9, 0x5e, 0x8f, 0x84, 0x29, 0x84}} 35 | PROPID_ACC_PARENT = MSAAPROPID{0x474c22b6, 0xffc2, 0x467a, [8]byte{0xb1, 0xb5, 0xe9, 0x58, 0xb4, 0x65, 0x73, 0x30}} 36 | PROPID_ACC_NAV_UP = MSAAPROPID{0x016e1a2b, 0x1a4e, 0x4767, [8]byte{0x86, 0x12, 0x33, 0x86, 0xf6, 0x69, 0x35, 0xec}} 37 | PROPID_ACC_NAV_DOWN = MSAAPROPID{0x031670ed, 0x3cdf, 0x48d2, [8]byte{0x96, 0x13, 0x13, 0x8f, 0x2d, 0xd8, 0xa6, 0x68}} 38 | PROPID_ACC_NAV_LEFT = MSAAPROPID{0x228086cb, 0x82f1, 0x4a39, [8]byte{0x87, 0x05, 0xdc, 0xdc, 0x0f, 0xff, 0x92, 0xf5}} 39 | PROPID_ACC_NAV_RIGHT = MSAAPROPID{0xcd211d9f, 0xe1cb, 0x4fe5, [8]byte{0xa7, 0x7c, 0x92, 0x0b, 0x88, 0x4d, 0x09, 0x5b}} 40 | PROPID_ACC_NAV_PREV = MSAAPROPID{0x776d3891, 0xc73b, 0x4480, [8]byte{0xb3, 0xf6, 0x07, 0x6a, 0x16, 0xa1, 0x5a, 0xf6}} 41 | PROPID_ACC_NAV_NEXT = MSAAPROPID{0x1cdc5455, 0x8cd9, 0x4c92, [8]byte{0xa3, 0x71, 0x39, 0x39, 0xa2, 0xfe, 0x3e, 0xee}} 42 | PROPID_ACC_NAV_FIRSTCHILD = MSAAPROPID{0xcfd02558, 0x557b, 0x4c67, [8]byte{0x84, 0xf9, 0x2a, 0x09, 0xfc, 0xe4, 0x07, 0x49}} 43 | PROPID_ACC_NAV_LASTCHILD = MSAAPROPID{0x302ecaa5, 0x48d5, 0x4f8d, [8]byte{0xb6, 0x71, 0x1a, 0x8d, 0x20, 0xa7, 0x78, 0x32}} 44 | PROPID_ACC_ROLEMAP = MSAAPROPID{0xf79acda2, 0x140d, 0x4fe6, [8]byte{0x89, 0x14, 0x20, 0x84, 0x76, 0x32, 0x82, 0x69}} 45 | PROPID_ACC_VALUEMAP = MSAAPROPID{0xda1c3d79, 0xfc5c, 0x420e, [8]byte{0xb3, 0x99, 0x9d, 0x15, 0x33, 0x54, 0x9e, 0x75}} 46 | PROPID_ACC_STATEMAP = MSAAPROPID{0x43946c5e, 0x0ac0, 0x4042, [8]byte{0xb5, 0x25, 0x07, 0xbb, 0xdb, 0xe1, 0x7f, 0xa7}} 47 | PROPID_ACC_DESCRIPTIONMAP = MSAAPROPID{0x1ff1435f, 0x8a14, 0x477b, [8]byte{0xb2, 0x26, 0xa0, 0xab, 0xe2, 0x79, 0x97, 0x5d}} 48 | PROPID_ACC_DODEFAULTACTION = MSAAPROPID{0x1ba09523, 0x2e3b, 0x49a6, [8]byte{0xa0, 0x59, 0x59, 0x68, 0x2a, 0x3c, 0x48, 0xfd}} 49 | ) 50 | 51 | const ( 52 | STATE_SYSTEM_NORMAL = 0 53 | STATE_SYSTEM_UNAVAILABLE = 0x1 54 | STATE_SYSTEM_SELECTED = 0x2 55 | STATE_SYSTEM_FOCUSED = 0x4 56 | STATE_SYSTEM_PRESSED = 0x8 57 | STATE_SYSTEM_CHECKED = 0x10 58 | STATE_SYSTEM_MIXED = 0x20 59 | STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED 60 | STATE_SYSTEM_READONLY = 0x40 61 | STATE_SYSTEM_HOTTRACKED = 0x80 62 | STATE_SYSTEM_DEFAULT = 0x100 63 | STATE_SYSTEM_EXPANDED = 0x200 64 | STATE_SYSTEM_COLLAPSED = 0x400 65 | STATE_SYSTEM_BUSY = 0x800 66 | STATE_SYSTEM_FLOATING = 0x1000 67 | STATE_SYSTEM_MARQUEED = 0x2000 68 | STATE_SYSTEM_ANIMATED = 0x4000 69 | STATE_SYSTEM_INVISIBLE = 0x8000 70 | STATE_SYSTEM_OFFSCREEN = 0x10000 71 | STATE_SYSTEM_SIZEABLE = 0x20000 72 | STATE_SYSTEM_MOVEABLE = 0x40000 73 | STATE_SYSTEM_SELFVOICING = 0x80000 74 | STATE_SYSTEM_FOCUSABLE = 0x100000 75 | STATE_SYSTEM_SELECTABLE = 0x200000 76 | STATE_SYSTEM_LINKED = 0x400000 77 | STATE_SYSTEM_TRAVERSED = 0x800000 78 | STATE_SYSTEM_MULTISELECTABLE = 0x1000000 79 | STATE_SYSTEM_EXTSELECTABLE = 0x2000000 80 | STATE_SYSTEM_ALERT_LOW = 0x4000000 81 | STATE_SYSTEM_ALERT_MEDIUM = 0x8000000 82 | STATE_SYSTEM_ALERT_HIGH = 0x10000000 83 | STATE_SYSTEM_PROTECTED = 0x20000000 84 | STATE_SYSTEM_HASPOPUP = 0x40000000 85 | STATE_SYSTEM_VALID = 0x7fffffff 86 | ) 87 | 88 | const ( 89 | ROLE_SYSTEM_TITLEBAR = 0x1 90 | ROLE_SYSTEM_MENUBAR = 0x2 91 | ROLE_SYSTEM_SCROLLBAR = 0x3 92 | ROLE_SYSTEM_GRIP = 0x4 93 | ROLE_SYSTEM_SOUND = 0x5 94 | ROLE_SYSTEM_CURSOR = 0x6 95 | ROLE_SYSTEM_CARET = 0x7 96 | ROLE_SYSTEM_ALERT = 0x8 97 | ROLE_SYSTEM_WINDOW = 0x9 98 | ROLE_SYSTEM_CLIENT = 0xa 99 | ROLE_SYSTEM_MENUPOPUP = 0xb 100 | ROLE_SYSTEM_MENUITEM = 0xc 101 | ROLE_SYSTEM_TOOLTIP = 0xd 102 | ROLE_SYSTEM_APPLICATION = 0xe 103 | ROLE_SYSTEM_DOCUMENT = 0xf 104 | ROLE_SYSTEM_PANE = 0x10 105 | ROLE_SYSTEM_CHART = 0x11 106 | ROLE_SYSTEM_DIALOG = 0x12 107 | ROLE_SYSTEM_BORDER = 0x13 108 | ROLE_SYSTEM_GROUPING = 0x14 109 | ROLE_SYSTEM_SEPARATOR = 0x15 110 | ROLE_SYSTEM_TOOLBAR = 0x16 111 | ROLE_SYSTEM_STATUSBAR = 0x17 112 | ROLE_SYSTEM_TABLE = 0x18 113 | ROLE_SYSTEM_COLUMNHEADER = 0x19 114 | ROLE_SYSTEM_ROWHEADER = 0x1a 115 | ROLE_SYSTEM_COLUMN = 0x1b 116 | ROLE_SYSTEM_ROW = 0x1c 117 | ROLE_SYSTEM_CELL = 0x1d 118 | ROLE_SYSTEM_LINK = 0x1e 119 | ROLE_SYSTEM_HELPBALLOON = 0x1f 120 | ROLE_SYSTEM_CHARACTER = 0x20 121 | ROLE_SYSTEM_LIST = 0x21 122 | ROLE_SYSTEM_LISTITEM = 0x22 123 | ROLE_SYSTEM_OUTLINE = 0x23 124 | ROLE_SYSTEM_OUTLINEITEM = 0x24 125 | ROLE_SYSTEM_PAGETAB = 0x25 126 | ROLE_SYSTEM_PROPERTYPAGE = 0x26 127 | ROLE_SYSTEM_INDICATOR = 0x27 128 | ROLE_SYSTEM_GRAPHIC = 0x28 129 | ROLE_SYSTEM_STATICTEXT = 0x29 130 | ROLE_SYSTEM_TEXT = 0x2a 131 | ROLE_SYSTEM_PUSHBUTTON = 0x2b 132 | ROLE_SYSTEM_CHECKBUTTON = 0x2c 133 | ROLE_SYSTEM_RADIOBUTTON = 0x2d 134 | ROLE_SYSTEM_COMBOBOX = 0x2e 135 | ROLE_SYSTEM_DROPLIST = 0x2f 136 | ROLE_SYSTEM_PROGRESSBAR = 0x30 137 | ROLE_SYSTEM_DIAL = 0x31 138 | ROLE_SYSTEM_HOTKEYFIELD = 0x32 139 | ROLE_SYSTEM_SLIDER = 0x33 140 | ROLE_SYSTEM_SPINBUTTON = 0x34 141 | ROLE_SYSTEM_DIAGRAM = 0x35 142 | ROLE_SYSTEM_ANIMATION = 0x36 143 | ROLE_SYSTEM_EQUATION = 0x37 144 | ROLE_SYSTEM_BUTTONDROPDOWN = 0x38 145 | ROLE_SYSTEM_BUTTONMENU = 0x39 146 | ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x3a 147 | ROLE_SYSTEM_WHITESPACE = 0x3b 148 | ROLE_SYSTEM_PAGETABLIST = 0x3c 149 | ROLE_SYSTEM_CLOCK = 0x3d 150 | ROLE_SYSTEM_SPLITBUTTON = 0x3e 151 | ROLE_SYSTEM_IPADDRESS = 0x3f 152 | ROLE_SYSTEM_OUTLINEBUTTON = 0x40 153 | ) 154 | 155 | var ( 156 | IID_IAccPropServer = IID{0x76c0dbbb, 0x15e0, 0x4e7b, [8]byte{0xb6, 0x1b, 0x20, 0xee, 0xea, 0x20, 0x01, 0xe0}} 157 | IID_IAccPropServices = IID{0x6e26e776, 0x04f0, 0x495d, [8]byte{0x80, 0xe4, 0x33, 0x30, 0x35, 0x2e, 0x31, 0x69}} 158 | CLSID_AccPropServices = CLSID{0xb5f8350b, 0x0548, 0x48b1, [8]byte{0xa6, 0xee, 0x88, 0xbd, 0x00, 0xb4, 0xa5, 0xe7}} 159 | ) 160 | 161 | type IAccPropServerVtbl struct { 162 | QueryInterface uintptr 163 | AddRef uintptr 164 | Release uintptr 165 | GetPropValue uintptr 166 | } 167 | 168 | type IAccPropServer struct { 169 | LpVtbl *IAccPropServerVtbl 170 | } 171 | 172 | type IAccPropServicesVtbl struct { 173 | QueryInterface uintptr 174 | AddRef uintptr 175 | Release uintptr 176 | SetPropValue uintptr 177 | SetPropServer uintptr 178 | ClearProps uintptr 179 | SetHwndProp uintptr 180 | SetHwndPropStr uintptr 181 | SetHwndPropServer uintptr 182 | ClearHwndProps uintptr 183 | ComposeHwndIdentityString uintptr 184 | DecomposeHwndIdentityString uintptr 185 | SetHmenuProp uintptr 186 | SetHmenuPropStr uintptr 187 | SetHmenuPropServer uintptr 188 | ClearHmenuProps uintptr 189 | ComposeHmenuIdentityString uintptr 190 | DecomposeHmenuIdentityString uintptr 191 | } 192 | 193 | type IAccPropServices struct { 194 | LpVtbl *IAccPropServicesVtbl 195 | } 196 | 197 | func (obj *IAccPropServices) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 198 | ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, 199 | uintptr(unsafe.Pointer(obj)), 200 | uintptr(unsafe.Pointer(riid)), 201 | uintptr(unsafe.Pointer(ppvObject))) 202 | return HRESULT(ret) 203 | } 204 | 205 | func (obj *IAccPropServices) AddRef() uint32 { 206 | ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, 207 | uintptr(unsafe.Pointer(obj)), 208 | 0, 209 | 0) 210 | return uint32(ret) 211 | } 212 | 213 | func (obj *IAccPropServices) Release() uint32 { 214 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, 215 | uintptr(unsafe.Pointer(obj)), 216 | 0, 217 | 0) 218 | return uint32(ret) 219 | } 220 | 221 | // 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. 222 | // If server developers know the HWND of the accessible element they want to annotate, they can use SetHwndPropServer. 223 | func (obj *IAccPropServices) SetPropServer(idString []byte, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { 224 | var idStringPtr unsafe.Pointer 225 | idStringLen := len(idString) 226 | if idStringLen != 0 { 227 | idStringPtr = unsafe.Pointer(&idString[0]) 228 | } 229 | var idPropsPtr unsafe.Pointer 230 | idPropsLen := len(idProps) 231 | if idPropsLen != 0 { 232 | idPropsPtr = unsafe.Pointer(&idProps[0]) 233 | } 234 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetPropServer, 7, 235 | uintptr(unsafe.Pointer(obj)), 236 | uintptr(idStringPtr), 237 | uintptr(idStringLen), 238 | uintptr(idPropsPtr), 239 | uintptr(idPropsLen), 240 | uintptr(unsafe.Pointer(server)), 241 | uintptr(annoScope), 242 | 0, 243 | 0) 244 | return HRESULT(ret) 245 | } 246 | 247 | // ClearProps restores default values to properties of accessible elements that they had previously annotated. 248 | // If servers know the HWND of the object they want to clear, they can use ClearHwndProps. 249 | func (obj *IAccPropServices) ClearProps(idString []byte, idProps []MSAAPROPID) HRESULT { 250 | var idStringPtr unsafe.Pointer 251 | idStringLen := len(idString) 252 | if idStringLen != 0 { 253 | idStringPtr = unsafe.Pointer(&idString[0]) 254 | } 255 | var idPropsPtr unsafe.Pointer 256 | idPropsLen := len(idProps) 257 | if idPropsLen != 0 { 258 | idPropsPtr = unsafe.Pointer(&idProps[0]) 259 | } 260 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearProps, 5, 261 | uintptr(unsafe.Pointer(obj)), 262 | uintptr(idStringPtr), 263 | uintptr(idStringLen), 264 | uintptr(idPropsPtr), 265 | uintptr(idPropsLen), 266 | 0) 267 | return HRESULT(ret) 268 | } 269 | 270 | // SetHwndPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HWND-based accessible elements. 271 | func (obj *IAccPropServices) SetHwndPropServer(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { 272 | var idPropsPtr unsafe.Pointer 273 | idPropsLen := len(idProps) 274 | if idPropsLen != 0 { 275 | idPropsPtr = unsafe.Pointer(&idProps[0]) 276 | } 277 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropServer, 8, 278 | uintptr(unsafe.Pointer(obj)), 279 | uintptr(hwnd), 280 | uintptr(idObject), 281 | uintptr(idChild), 282 | uintptr(idPropsPtr), 283 | uintptr(idPropsLen), 284 | uintptr(unsafe.Pointer(server)), 285 | uintptr(annoScope), 286 | 0) 287 | return HRESULT(ret) 288 | } 289 | 290 | // ClearHwndProps wraps SetPropValue, SetPropServer, and ClearProps, and provides a convenient entry point for callers who are annotating HWND-based accessible elements. 291 | func (obj *IAccPropServices) ClearHwndProps(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID) HRESULT { 292 | var idPropsPtr unsafe.Pointer 293 | idPropsLen := len(idProps) 294 | if idPropsLen != 0 { 295 | idPropsPtr = unsafe.Pointer(&idProps[0]) 296 | } 297 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHwndProps, 6, 298 | uintptr(unsafe.Pointer(obj)), 299 | uintptr(hwnd), 300 | uintptr(idObject), 301 | uintptr(idChild), 302 | uintptr(idPropsPtr), 303 | uintptr(idPropsLen)) 304 | return HRESULT(ret) 305 | } 306 | 307 | // ComposeHwndIdentityString retrievs an identity string. 308 | func (obj *IAccPropServices) ComposeHwndIdentityString(hwnd HWND, idObject int32, idChild uint32) (hr HRESULT, idString []byte) { 309 | var data *[1<<31 - 1]byte 310 | var len uint32 311 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHwndIdentityString, 6, 312 | uintptr(unsafe.Pointer(obj)), 313 | uintptr(hwnd), 314 | uintptr(idObject), 315 | uintptr(idChild), 316 | uintptr(unsafe.Pointer(&data)), 317 | uintptr(unsafe.Pointer(&len))) 318 | hr = HRESULT(ret) 319 | if FAILED(hr) { 320 | return 321 | } 322 | defer CoTaskMemFree(uintptr(unsafe.Pointer(data))) 323 | idString = make([]byte, len) 324 | copy(idString, data[:len]) 325 | return 326 | } 327 | 328 | // DecomposeHwndIdentityString determines the HWND, object ID, and child ID for the accessible element identified by the identity string. 329 | func (obj *IAccPropServices) DecomposeHwndIdentityString(idString []byte) (hr HRESULT, hwnd HWND, idObject int32, idChild uint32) { 330 | var idStringPtr unsafe.Pointer 331 | idStringLen := len(idString) 332 | if idStringLen != 0 { 333 | idStringPtr = unsafe.Pointer(&idString[0]) 334 | } 335 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHwndIdentityString, 6, 336 | uintptr(unsafe.Pointer(obj)), 337 | uintptr(idStringPtr), 338 | uintptr(idStringLen), 339 | uintptr(unsafe.Pointer(&hwnd)), 340 | uintptr(unsafe.Pointer(&idObject)), 341 | uintptr(unsafe.Pointer(&idChild))) 342 | hr = HRESULT(ret) 343 | return 344 | } 345 | 346 | // SetHmenuPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. 347 | func (obj *IAccPropServices) SetHmenuPropServer(hmenu HMENU, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT { 348 | var idPropsPtr unsafe.Pointer 349 | idPropsLen := len(idProps) 350 | if idPropsLen != 0 { 351 | idPropsPtr = unsafe.Pointer(&idProps[0]) 352 | } 353 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuPropServer, 7, 354 | uintptr(unsafe.Pointer(obj)), 355 | uintptr(hmenu), 356 | uintptr(idChild), 357 | uintptr(idPropsPtr), 358 | uintptr(idPropsLen), 359 | uintptr(unsafe.Pointer(server)), 360 | uintptr(annoScope), 361 | 0, 362 | 0) 363 | return HRESULT(ret) 364 | } 365 | 366 | // ClearHmenuProps wraps ClearProps, and provides a convenient entry point for callers who are annotating HMENU-based accessible elements. 367 | func (obj *IAccPropServices) ClearHmenuProps(hmenu HMENU, idChild uint32, idProps []MSAAPROPID) HRESULT { 368 | var idPropsPtr unsafe.Pointer 369 | idPropsLen := len(idProps) 370 | if idPropsLen != 0 { 371 | idPropsPtr = unsafe.Pointer(&idProps[0]) 372 | } 373 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHmenuProps, 5, 374 | uintptr(unsafe.Pointer(obj)), 375 | uintptr(hmenu), 376 | uintptr(idChild), 377 | uintptr(idPropsPtr), 378 | uintptr(idPropsLen), 379 | 0) 380 | return HRESULT(ret) 381 | } 382 | 383 | // ComposeHmenuIdentityString retrieves an identity string for an HMENU-based accessible element. 384 | func (obj *IAccPropServices) ComposeHmenuIdentityString(hmenu HMENU, idChild uint32) (hr HRESULT, idString []byte) { 385 | var data *[1<<31 - 1]byte 386 | var len uint32 387 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHmenuIdentityString, 5, 388 | uintptr(unsafe.Pointer(obj)), 389 | uintptr(hmenu), 390 | uintptr(idChild), 391 | uintptr(unsafe.Pointer(&data)), 392 | uintptr(unsafe.Pointer(&len)), 393 | 0) 394 | hr = HRESULT(ret) 395 | if FAILED(hr) { 396 | return 397 | } 398 | defer CoTaskMemFree(uintptr(unsafe.Pointer(data))) 399 | idString = make([]byte, len) 400 | copy(idString, data[:len]) 401 | return 402 | } 403 | 404 | // DecomposeHmenuIdentityString determines the HMENU, object ID, and child ID for the accessible element identified by the identity string. 405 | func (obj *IAccPropServices) DecomposeHmenuIdentityString(idString []byte) (hr HRESULT, hmenu HMENU, idChild uint32) { 406 | var idStringPtr unsafe.Pointer 407 | idStringLen := len(idString) 408 | if idStringLen != 0 { 409 | idStringPtr = unsafe.Pointer(&idString[0]) 410 | } 411 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHmenuIdentityString, 5, 412 | uintptr(unsafe.Pointer(obj)), 413 | uintptr(idStringPtr), 414 | uintptr(idStringLen), 415 | uintptr(unsafe.Pointer(&hmenu)), 416 | uintptr(unsafe.Pointer(&idChild)), 417 | 0) 418 | hr = HRESULT(ret) 419 | return 420 | } 421 | -------------------------------------------------------------------------------- /oleacc_32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,386 windows,arm 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func (idProp *MSAAPROPID) split() (uintptr, uintptr, uintptr, uintptr) { 15 | if idProp == nil { 16 | return 0, 0, 0, 0 17 | } 18 | x := (*struct { a, b, c, d uintptr })(unsafe.Pointer(idProp)) 19 | return x.a, x.b, x.c, x.d 20 | } 21 | 22 | // SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. 23 | // 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 24 | func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { 25 | var idStringPtr unsafe.Pointer 26 | idStringLen := len(idString) 27 | if idStringLen != 0 { 28 | idStringPtr = unsafe.Pointer(&idString[0]) 29 | } 30 | propA, propB, propC, propD := idProp.split() 31 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetPropValue, 8, 32 | uintptr(unsafe.Pointer(obj)), 33 | uintptr(idStringPtr), 34 | uintptr(idStringLen), 35 | propA, propB, propC, propD, 36 | uintptr(unsafe.Pointer(v)), 37 | 0) 38 | return HRESULT(ret) 39 | } 40 | 41 | // 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. 42 | func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { 43 | propA, propB, propC, propD := idProp.split() 44 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndProp, 9, 45 | uintptr(unsafe.Pointer(obj)), 46 | uintptr(hwnd), 47 | uintptr(idObject), 48 | uintptr(idChild), 49 | propA, propB, propC, propD, 50 | uintptr(unsafe.Pointer(v))) 51 | return HRESULT(ret) 52 | } 53 | 54 | // SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. 55 | func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { 56 | str16, err := syscall.UTF16PtrFromString(str) 57 | if err != nil { 58 | return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) 59 | } 60 | propA, propB, propC, propD := idProp.split() 61 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropStr, 9, 62 | uintptr(unsafe.Pointer(obj)), 63 | uintptr(hwnd), 64 | uintptr(idObject), 65 | uintptr(idChild), 66 | propA, propB, propC, propD, 67 | uintptr(unsafe.Pointer(str16))) 68 | return HRESULT(ret) 69 | } 70 | 71 | // 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. 72 | func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { 73 | propA, propB, propC, propD := idProp.split() 74 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuProp, 8, 75 | uintptr(unsafe.Pointer(obj)), 76 | uintptr(hmenu), 77 | uintptr(idChild), 78 | propA, propB, propC, propD, 79 | uintptr(unsafe.Pointer(v)), 80 | 0) 81 | return HRESULT(ret) 82 | } 83 | 84 | // SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. 85 | func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { 86 | str16, err := syscall.UTF16PtrFromString(str) 87 | if err != nil { 88 | return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) 89 | } 90 | propA, propB, propC, propD := idProp.split() 91 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuPropStr, 8, 92 | uintptr(unsafe.Pointer(obj)), 93 | uintptr(hmenu), 94 | uintptr(idChild), 95 | propA, propB, propC, propD, 96 | uintptr(unsafe.Pointer(str16)), 97 | 0) 98 | return HRESULT(ret) 99 | } 100 | -------------------------------------------------------------------------------- /oleacc_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,amd64 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | // SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. 15 | // 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 16 | func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { 17 | var idStringPtr unsafe.Pointer 18 | idStringLen := len(idString) 19 | if idStringLen != 0 { 20 | idStringPtr = unsafe.Pointer(&idString[0]) 21 | } 22 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 5, 23 | uintptr(unsafe.Pointer(obj)), 24 | uintptr(idStringPtr), 25 | uintptr(idStringLen), 26 | uintptr(unsafe.Pointer(idProp)), 27 | uintptr(unsafe.Pointer(v)), 28 | 0) 29 | return HRESULT(ret) 30 | } 31 | 32 | // 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. 33 | func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { 34 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndProp, 6, 35 | uintptr(unsafe.Pointer(obj)), 36 | uintptr(hwnd), 37 | uintptr(idObject), 38 | uintptr(idChild), 39 | uintptr(unsafe.Pointer(idProp)), 40 | uintptr(unsafe.Pointer(v))) 41 | return HRESULT(ret) 42 | } 43 | 44 | // SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. 45 | func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { 46 | str16, err := syscall.UTF16PtrFromString(str) 47 | if err != nil { 48 | return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) 49 | } 50 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndPropStr, 6, 51 | uintptr(unsafe.Pointer(obj)), 52 | uintptr(hwnd), 53 | uintptr(idObject), 54 | uintptr(idChild), 55 | uintptr(unsafe.Pointer(idProp)), 56 | uintptr(unsafe.Pointer(str16))) 57 | return HRESULT(ret) 58 | } 59 | 60 | // 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. 61 | func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { 62 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 5, 63 | uintptr(unsafe.Pointer(obj)), 64 | uintptr(hmenu), 65 | uintptr(idChild), 66 | uintptr(unsafe.Pointer(idProp)), 67 | uintptr(unsafe.Pointer(v)), 68 | 0) 69 | return HRESULT(ret) 70 | } 71 | 72 | // SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. 73 | func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { 74 | str16, err := syscall.UTF16PtrFromString(str) 75 | if err != nil { 76 | return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) 77 | } 78 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 5, 79 | uintptr(unsafe.Pointer(obj)), 80 | uintptr(hmenu), 81 | uintptr(idChild), 82 | uintptr(unsafe.Pointer(idProp)), 83 | uintptr(unsafe.Pointer(str16)), 84 | 0) 85 | return HRESULT(ret) 86 | } 87 | -------------------------------------------------------------------------------- /oleacc_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,arm64 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func (idProp *MSAAPROPID) split() (uintptr, uintptr) { 15 | if idProp == nil { 16 | return 0, 0 17 | } 18 | x := (*struct { a, b uintptr })(unsafe.Pointer(idProp)) 19 | return x.a, x.b 20 | } 21 | 22 | // SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property. 23 | // 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 24 | func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT { 25 | var idStringPtr unsafe.Pointer 26 | idStringLen := len(idString) 27 | if idStringLen != 0 { 28 | idStringPtr = unsafe.Pointer(&idString[0]) 29 | } 30 | propA, propB := idProp.split() 31 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 6, 32 | uintptr(unsafe.Pointer(obj)), 33 | uintptr(idStringPtr), 34 | uintptr(idStringLen), 35 | propA, propB, 36 | uintptr(unsafe.Pointer(v))) 37 | return HRESULT(ret) 38 | } 39 | 40 | // 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. 41 | func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { 42 | propA, propB := idProp.split() 43 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndProp, 7, 44 | uintptr(unsafe.Pointer(obj)), 45 | uintptr(hwnd), 46 | uintptr(idObject), 47 | uintptr(idChild), 48 | propA, propB, 49 | uintptr(unsafe.Pointer(v)), 50 | 0, 0) 51 | return HRESULT(ret) 52 | } 53 | 54 | // SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements. 55 | func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { 56 | str16, err := syscall.UTF16PtrFromString(str) 57 | if err != nil { 58 | return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) 59 | } 60 | propA, propB := idProp.split() 61 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropStr, 7, 62 | uintptr(unsafe.Pointer(obj)), 63 | uintptr(hwnd), 64 | uintptr(idObject), 65 | uintptr(idChild), 66 | propA, propB, 67 | uintptr(unsafe.Pointer(str16)), 68 | 0, 0) 69 | return HRESULT(ret) 70 | } 71 | 72 | // 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. 73 | func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT { 74 | propA, propB := idProp.split() 75 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 6, 76 | uintptr(unsafe.Pointer(obj)), 77 | uintptr(hmenu), 78 | uintptr(idChild), 79 | propA, propB, 80 | uintptr(unsafe.Pointer(v))) 81 | return HRESULT(ret) 82 | } 83 | 84 | // SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements. 85 | func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT { 86 | str16, err := syscall.UTF16PtrFromString(str) 87 | if err != nil { 88 | return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1) 89 | } 90 | propA, propB := idProp.split() 91 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 6, 92 | uintptr(unsafe.Pointer(obj)), 93 | uintptr(hmenu), 94 | uintptr(idChild), 95 | propA, propB, 96 | uintptr(unsafe.Pointer(str16))) 97 | return HRESULT(ret) 98 | } 99 | -------------------------------------------------------------------------------- /oleaut32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "fmt" 11 | "golang.org/x/sys/windows" 12 | "syscall" 13 | "unsafe" 14 | ) 15 | 16 | type DISPID int32 17 | 18 | const ( 19 | DISPID_BEFORENAVIGATE DISPID = 100 20 | DISPID_NAVIGATECOMPLETE DISPID = 101 21 | DISPID_STATUSTEXTCHANGE DISPID = 102 22 | DISPID_QUIT DISPID = 103 23 | DISPID_DOWNLOADCOMPLETE DISPID = 104 24 | DISPID_COMMANDSTATECHANGE DISPID = 105 25 | DISPID_DOWNLOADBEGIN DISPID = 106 26 | DISPID_NEWWINDOW DISPID = 107 27 | DISPID_PROGRESSCHANGE DISPID = 108 28 | DISPID_WINDOWMOVE DISPID = 109 29 | DISPID_WINDOWRESIZE DISPID = 110 30 | DISPID_WINDOWACTIVATE DISPID = 111 31 | DISPID_PROPERTYCHANGE DISPID = 112 32 | DISPID_TITLECHANGE DISPID = 113 33 | DISPID_TITLEICONCHANGE DISPID = 114 34 | DISPID_FRAMEBEFORENAVIGATE DISPID = 200 35 | DISPID_FRAMENAVIGATECOMPLETE DISPID = 201 36 | DISPID_FRAMENEWWINDOW DISPID = 204 37 | DISPID_BEFORENAVIGATE2 DISPID = 250 38 | DISPID_NEWWINDOW2 DISPID = 251 39 | DISPID_NAVIGATECOMPLETE2 DISPID = 252 40 | DISPID_ONQUIT DISPID = 253 41 | DISPID_ONVISIBLE DISPID = 254 42 | DISPID_ONTOOLBAR DISPID = 255 43 | DISPID_ONMENUBAR DISPID = 256 44 | DISPID_ONSTATUSBAR DISPID = 257 45 | DISPID_ONFULLSCREEN DISPID = 258 46 | DISPID_DOCUMENTCOMPLETE DISPID = 259 47 | DISPID_ONTHEATERMODE DISPID = 260 48 | DISPID_ONADDRESSBAR DISPID = 261 49 | DISPID_WINDOWSETRESIZABLE DISPID = 262 50 | DISPID_WINDOWCLOSING DISPID = 263 51 | DISPID_WINDOWSETLEFT DISPID = 264 52 | DISPID_WINDOWSETTOP DISPID = 265 53 | DISPID_WINDOWSETWIDTH DISPID = 266 54 | DISPID_WINDOWSETHEIGHT DISPID = 267 55 | DISPID_CLIENTTOHOSTWINDOW DISPID = 268 56 | DISPID_SETSECURELOCKICON DISPID = 269 57 | DISPID_FILEDOWNLOAD DISPID = 270 58 | DISPID_NAVIGATEERROR DISPID = 271 59 | DISPID_PRIVACYIMPACTEDSTATECHANGE DISPID = 272 60 | DISPID_NEWWINDOW3 DISPID = 273 61 | ) 62 | 63 | var ( 64 | IID_IDispatch = IID{0x00020400, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 65 | ) 66 | 67 | const ( 68 | DISP_E_MEMBERNOTFOUND = 0x80020003 69 | ) 70 | 71 | const ( 72 | CSC_UPDATECOMMANDS = ^0x0 73 | CSC_NAVIGATEFORWARD = 0x1 74 | CSC_NAVIGATEBACK = 0x2 75 | ) 76 | 77 | type IDispatchVtbl struct { 78 | QueryInterface uintptr 79 | AddRef uintptr 80 | Release uintptr 81 | GetTypeInfoCount uintptr 82 | GetTypeInfo uintptr 83 | GetIDsOfNames uintptr 84 | Invoke uintptr 85 | } 86 | 87 | type IDispatch struct { 88 | LpVtbl *IDispatchVtbl 89 | } 90 | 91 | type VARTYPE uint16 92 | 93 | const ( 94 | VT_EMPTY VARTYPE = 0 95 | VT_NULL VARTYPE = 1 96 | VT_I2 VARTYPE = 2 97 | VT_I4 VARTYPE = 3 98 | VT_R4 VARTYPE = 4 99 | VT_R8 VARTYPE = 5 100 | VT_CY VARTYPE = 6 101 | VT_DATE VARTYPE = 7 102 | VT_BSTR VARTYPE = 8 103 | VT_DISPATCH VARTYPE = 9 104 | VT_ERROR VARTYPE = 10 105 | VT_BOOL VARTYPE = 11 106 | VT_VARIANT VARTYPE = 12 107 | VT_UNKNOWN VARTYPE = 13 108 | VT_DECIMAL VARTYPE = 14 109 | VT_I1 VARTYPE = 16 110 | VT_UI1 VARTYPE = 17 111 | VT_UI2 VARTYPE = 18 112 | VT_UI4 VARTYPE = 19 113 | VT_I8 VARTYPE = 20 114 | VT_UI8 VARTYPE = 21 115 | VT_INT VARTYPE = 22 116 | VT_UINT VARTYPE = 23 117 | VT_VOID VARTYPE = 24 118 | VT_HRESULT VARTYPE = 25 119 | VT_PTR VARTYPE = 26 120 | VT_SAFEARRAY VARTYPE = 27 121 | VT_CARRAY VARTYPE = 28 122 | VT_USERDEFINED VARTYPE = 29 123 | VT_LPSTR VARTYPE = 30 124 | VT_LPWSTR VARTYPE = 31 125 | VT_RECORD VARTYPE = 36 126 | VT_INT_PTR VARTYPE = 37 127 | VT_UINT_PTR VARTYPE = 38 128 | VT_FILETIME VARTYPE = 64 129 | VT_BLOB VARTYPE = 65 130 | VT_STREAM VARTYPE = 66 131 | VT_STORAGE VARTYPE = 67 132 | VT_STREAMED_OBJECT VARTYPE = 68 133 | VT_STORED_OBJECT VARTYPE = 69 134 | VT_BLOB_OBJECT VARTYPE = 70 135 | VT_CF VARTYPE = 71 136 | VT_CLSID VARTYPE = 72 137 | VT_VERSIONED_STREAM VARTYPE = 73 138 | VT_BSTR_BLOB VARTYPE = 0xfff 139 | VT_VECTOR VARTYPE = 0x1000 140 | VT_ARRAY VARTYPE = 0x2000 141 | VT_BYREF VARTYPE = 0x4000 142 | VT_RESERVED VARTYPE = 0x8000 143 | VT_ILLEGAL VARTYPE = 0xffff 144 | VT_ILLEGALMASKED VARTYPE = 0xfff 145 | VT_TYPEMASK VARTYPE = 0xfff 146 | ) 147 | 148 | type VARIANTARG struct { 149 | VARIANT 150 | } 151 | 152 | type VARIANT_BOOL int16 153 | 154 | const ( 155 | VARIANT_TRUE VARIANT_BOOL = -1 156 | VARIANT_FALSE VARIANT_BOOL = 0 157 | ) 158 | 159 | type SAFEARRAYBOUND struct { 160 | CElements uint32 161 | LLbound int32 162 | } 163 | 164 | type SAFEARRAY struct { 165 | CDims uint16 166 | FFeatures uint16 167 | CbElements uint32 168 | CLocks uint32 169 | PvData uintptr 170 | Rgsabound [1]SAFEARRAYBOUND 171 | } 172 | 173 | //type BSTR *uint16 174 | 175 | func StringToBSTR(value string) *uint16 /*BSTR*/ { 176 | // IMPORTANT: Don't forget to free the BSTR value when no longer needed! 177 | return SysAllocString(value) 178 | } 179 | 180 | func BSTRToString(value *uint16 /*BSTR*/) string { 181 | // ISSUE: Is this really ok? 182 | bstrArrPtr := (*[200000000]uint16)(unsafe.Pointer(value)) 183 | 184 | bstrSlice := make([]uint16, SysStringLen(value)) 185 | copy(bstrSlice, bstrArrPtr[:]) 186 | 187 | return syscall.UTF16ToString(bstrSlice) 188 | } 189 | 190 | func IntToVariantI4(value int32) *VAR_I4 { 191 | return &VAR_I4{vt: VT_I4, lVal: value} 192 | } 193 | 194 | func VariantI4ToInt(value *VAR_I4) int32 { 195 | return value.lVal 196 | } 197 | 198 | func BoolToVariantBool(value bool) *VAR_BOOL { 199 | return &VAR_BOOL{vt: VT_BOOL, boolVal: VARIANT_BOOL(BoolToBOOL(value))} 200 | } 201 | 202 | func VariantBoolToBool(value *VAR_BOOL) bool { 203 | return value.boolVal != 0 204 | } 205 | 206 | func StringToVariantBSTR(value string) *VAR_BSTR { 207 | // IMPORTANT: Don't forget to free the BSTR value when no longer needed! 208 | return &VAR_BSTR{vt: VT_BSTR, bstrVal: StringToBSTR(value)} 209 | } 210 | 211 | func VariantBSTRToString(value *VAR_BSTR) string { 212 | return BSTRToString(value.bstrVal) 213 | } 214 | 215 | func (v *VARIANT) MustLong() int32 { 216 | value, err := v.Long() 217 | if err != nil { 218 | panic(err) 219 | } 220 | return value 221 | } 222 | 223 | func (v *VARIANT) Long() (int32, error) { 224 | if v.Vt != VT_I4 { 225 | return 0, fmt.Errorf("Error: Long() v.Vt != VT_I4, ptr=%p, value=%+v", v, v) 226 | } 227 | p := (*VAR_I4)(unsafe.Pointer(v)) 228 | return p.lVal, nil 229 | } 230 | 231 | func (v *VARIANT) SetLong(value int32) { 232 | v.Vt = VT_I4 233 | p := (*VAR_I4)(unsafe.Pointer(v)) 234 | p.lVal = value 235 | } 236 | 237 | func (v *VARIANT) MustULong() uint32 { 238 | value, err := v.ULong() 239 | if err != nil { 240 | panic(err) 241 | } 242 | return value 243 | } 244 | 245 | func (v *VARIANT) ULong() (uint32, error) { 246 | if v.Vt != VT_UI4 { 247 | return 0, fmt.Errorf("Error: ULong() v.Vt != VT_UI4, ptr=%p, value=%+v", v, v) 248 | } 249 | p := (*VAR_UI4)(unsafe.Pointer(v)) 250 | return p.ulVal, nil 251 | } 252 | 253 | func (v *VARIANT) SetULong(value uint32) { 254 | v.Vt = VT_UI4 255 | p := (*VAR_UI4)(unsafe.Pointer(v)) 256 | p.ulVal = value 257 | } 258 | 259 | func (v *VARIANT) MustBool() VARIANT_BOOL { 260 | value, err := v.Bool() 261 | if err != nil { 262 | panic(err) 263 | } 264 | return value 265 | } 266 | 267 | func (v *VARIANT) Bool() (VARIANT_BOOL, error) { 268 | if v.Vt != VT_BOOL { 269 | return VARIANT_FALSE, fmt.Errorf("Error: Bool() v.Vt != VT_BOOL, ptr=%p, value=%+v", v, v) 270 | } 271 | p := (*VAR_BOOL)(unsafe.Pointer(v)) 272 | return p.boolVal, nil 273 | } 274 | 275 | func (v *VARIANT) SetBool(value VARIANT_BOOL) { 276 | v.Vt = VT_BOOL 277 | p := (*VAR_BOOL)(unsafe.Pointer(v)) 278 | p.boolVal = value 279 | } 280 | 281 | func (v *VARIANT) MustBSTR() *uint16 { 282 | value, err := v.BSTR() 283 | if err != nil { 284 | panic(err) 285 | } 286 | return value 287 | } 288 | 289 | func (v *VARIANT) BSTR() (*uint16, error) { 290 | if v.Vt != VT_BSTR { 291 | return nil, fmt.Errorf("Error: BSTR() v.Vt != VT_BSTR, ptr=%p, value=%+v", v, v) 292 | } 293 | p := (*VAR_BSTR)(unsafe.Pointer(v)) 294 | return p.bstrVal, nil 295 | } 296 | 297 | func (v *VARIANT) SetBSTR(value *uint16) { 298 | v.Vt = VT_BSTR 299 | p := (*VAR_BSTR)(unsafe.Pointer(v)) 300 | p.bstrVal = value 301 | } 302 | 303 | func (v *VARIANT) MustPDispatch() *IDispatch { 304 | value, err := v.PDispatch() 305 | if err != nil { 306 | panic(err) 307 | } 308 | return value 309 | } 310 | 311 | func (v *VARIANT) PDispatch() (*IDispatch, error) { 312 | if v.Vt != VT_DISPATCH { 313 | return nil, fmt.Errorf("Error: PDispatch() v.Vt != VT_DISPATCH, ptr=%p, value=%+v", v, v) 314 | } 315 | p := (*VAR_PDISP)(unsafe.Pointer(v)) 316 | return p.pdispVal, nil 317 | } 318 | 319 | func (v *VARIANT) SetPDispatch(value *IDispatch) { 320 | v.Vt = VT_DISPATCH 321 | p := (*VAR_PDISP)(unsafe.Pointer(v)) 322 | p.pdispVal = value 323 | } 324 | 325 | func (v *VARIANT) MustPVariant() *VARIANT { 326 | value, err := v.PVariant() 327 | if err != nil { 328 | panic(err) 329 | } 330 | return value 331 | } 332 | 333 | func (v *VARIANT) PVariant() (*VARIANT, error) { 334 | if v.Vt != VT_BYREF|VT_VARIANT { 335 | return nil, fmt.Errorf("Error: PVariant() v.Vt != VT_BYREF|VT_VARIANT, ptr=%p, value=%+v", v, v) 336 | } 337 | p := (*VAR_PVAR)(unsafe.Pointer(v)) 338 | return p.pvarVal, nil 339 | } 340 | 341 | func (v *VARIANT) SetPVariant(value *VARIANT) { 342 | v.Vt = VT_BYREF | VT_VARIANT 343 | p := (*VAR_PVAR)(unsafe.Pointer(v)) 344 | p.pvarVal = value 345 | } 346 | 347 | func (v *VARIANT) MustPBool() *VARIANT_BOOL { 348 | value, err := v.PBool() 349 | if err != nil { 350 | panic(err) 351 | } 352 | return value 353 | } 354 | 355 | func (v *VARIANT) PBool() (*VARIANT_BOOL, error) { 356 | if v.Vt != VT_BYREF|VT_BOOL { 357 | return nil, fmt.Errorf("Error: PBool() v.Vt != VT_BYREF|VT_BOOL, ptr=%p, value=%+v", v, v) 358 | } 359 | p := (*VAR_PBOOL)(unsafe.Pointer(v)) 360 | return p.pboolVal, nil 361 | } 362 | 363 | func (v *VARIANT) SetPBool(value *VARIANT_BOOL) { 364 | v.Vt = VT_BYREF | VT_BOOL 365 | p := (*VAR_PBOOL)(unsafe.Pointer(v)) 366 | p.pboolVal = value 367 | } 368 | 369 | func (v *VARIANT) MustPPDispatch() **IDispatch { 370 | value, err := v.PPDispatch() 371 | if err != nil { 372 | panic(err) 373 | } 374 | return value 375 | } 376 | 377 | func (v *VARIANT) PPDispatch() (**IDispatch, error) { 378 | if v.Vt != VT_BYREF|VT_DISPATCH { 379 | return nil, fmt.Errorf("PPDispatch() v.Vt != VT_BYREF|VT_DISPATCH, ptr=%p, value=%+v", v, v) 380 | } 381 | p := (*VAR_PPDISP)(unsafe.Pointer(v)) 382 | return p.ppdispVal, nil 383 | } 384 | 385 | func (v *VARIANT) SetPPDispatch(value **IDispatch) { 386 | v.Vt = VT_BYREF | VT_DISPATCH 387 | p := (*VAR_PPDISP)(unsafe.Pointer(v)) 388 | p.ppdispVal = value 389 | } 390 | 391 | func (v *VARIANT) MustPSafeArray() *SAFEARRAY { 392 | value, err := v.PSafeArray() 393 | if err != nil { 394 | panic(err) 395 | } 396 | return value 397 | } 398 | 399 | func (v *VARIANT) PSafeArray() (*SAFEARRAY, error) { 400 | if (v.Vt & VT_ARRAY) != VT_ARRAY { 401 | return nil, fmt.Errorf("Error: PSafeArray() (v.Vt & VT_ARRAY) != VT_ARRAY, ptr=%p, value=%+v", v, v) 402 | } 403 | p := (*VAR_PSAFEARRAY)(unsafe.Pointer(v)) 404 | return p.parray, nil 405 | } 406 | 407 | func (v *VARIANT) SetPSafeArray(value *SAFEARRAY, elementVt VARTYPE) { 408 | v.Vt = VT_ARRAY | elementVt 409 | p := (*VAR_PSAFEARRAY)(unsafe.Pointer(v)) 410 | p.parray = value 411 | } 412 | 413 | type DISPPARAMS struct { 414 | Rgvarg *VARIANTARG 415 | RgdispidNamedArgs *DISPID 416 | CArgs int32 417 | CNamedArgs int32 418 | } 419 | 420 | var ( 421 | // Library 422 | liboleaut32 *windows.LazyDLL 423 | 424 | // Functions 425 | sysAllocString *windows.LazyProc 426 | sysFreeString *windows.LazyProc 427 | sysStringLen *windows.LazyProc 428 | ) 429 | 430 | func init() { 431 | // Library 432 | liboleaut32 = windows.NewLazySystemDLL("oleaut32.dll") 433 | 434 | // Functions 435 | sysAllocString = liboleaut32.NewProc("SysAllocString") 436 | sysFreeString = liboleaut32.NewProc("SysFreeString") 437 | sysStringLen = liboleaut32.NewProc("SysStringLen") 438 | } 439 | 440 | func SysAllocString(s string) *uint16 /*BSTR*/ { 441 | ret, _, _ := syscall.Syscall(sysAllocString.Addr(), 1, 442 | uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s))), 443 | 0, 444 | 0) 445 | 446 | return (*uint16) /*BSTR*/ (unsafe.Pointer(ret)) 447 | } 448 | 449 | func SysFreeString(bstr *uint16 /*BSTR*/) { 450 | syscall.Syscall(sysFreeString.Addr(), 1, 451 | uintptr(unsafe.Pointer(bstr)), 452 | 0, 453 | 0) 454 | } 455 | 456 | func SysStringLen(bstr *uint16 /*BSTR*/) uint32 { 457 | ret, _, _ := syscall.Syscall(sysStringLen.Addr(), 1, 458 | uintptr(unsafe.Pointer(bstr)), 459 | 0, 460 | 0) 461 | 462 | return uint32(ret) 463 | } 464 | -------------------------------------------------------------------------------- /oleaut32_32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,386 windows,arm 6 | 7 | package win 8 | 9 | type VARIANT struct { 10 | Vt VARTYPE 11 | reserved [14]byte 12 | } 13 | 14 | type VAR_I4 struct { 15 | vt VARTYPE 16 | reserved1 [6]byte 17 | lVal int32 18 | reserved2 [4]byte 19 | } 20 | 21 | type VAR_UI4 struct { 22 | vt VARTYPE 23 | reserved1 [6]byte 24 | ulVal uint32 25 | reserved2 [4]byte 26 | } 27 | 28 | type VAR_BOOL struct { 29 | vt VARTYPE 30 | reserved1 [6]byte 31 | boolVal VARIANT_BOOL 32 | reserved2 [6]byte 33 | } 34 | 35 | type VAR_BSTR struct { 36 | vt VARTYPE 37 | reserved1 [6]byte 38 | bstrVal *uint16 /*BSTR*/ 39 | reserved2 [4]byte 40 | } 41 | 42 | type VAR_PDISP struct { 43 | vt VARTYPE 44 | reserved1 [6]byte 45 | pdispVal *IDispatch 46 | reserved2 [4]byte 47 | } 48 | 49 | type VAR_PSAFEARRAY struct { 50 | vt VARTYPE 51 | reserved1 [6]byte 52 | parray *SAFEARRAY 53 | reserved2 [4]byte 54 | } 55 | 56 | type VAR_PVAR struct { 57 | vt VARTYPE 58 | reserved1 [6]byte 59 | pvarVal *VARIANT 60 | reserved2 [4]byte 61 | } 62 | 63 | type VAR_PBOOL struct { 64 | vt VARTYPE 65 | reserved1 [6]byte 66 | pboolVal *VARIANT_BOOL 67 | reserved2 [4]byte 68 | } 69 | 70 | type VAR_PPDISP struct { 71 | vt VARTYPE 72 | reserved1 [6]byte 73 | ppdispVal **IDispatch 74 | reserved2 [4]byte 75 | } 76 | -------------------------------------------------------------------------------- /oleaut32_64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,amd64 windows,arm64 6 | 7 | package win 8 | 9 | type VARIANT struct { 10 | Vt VARTYPE 11 | reserved [22]byte 12 | } 13 | 14 | type VAR_I4 struct { 15 | vt VARTYPE 16 | reserved1 [6]byte 17 | lVal int32 18 | reserved2 [12]byte 19 | } 20 | 21 | type VAR_UI4 struct { 22 | vt VARTYPE 23 | reserved1 [6]byte 24 | ulVal uint32 25 | reserved2 [12]byte 26 | } 27 | 28 | type VAR_BOOL struct { 29 | vt VARTYPE 30 | reserved1 [6]byte 31 | boolVal VARIANT_BOOL 32 | reserved2 [14]byte 33 | } 34 | 35 | type VAR_BSTR struct { 36 | vt VARTYPE 37 | reserved1 [6]byte 38 | bstrVal *uint16 /*BSTR*/ 39 | reserved2 [8]byte 40 | } 41 | 42 | type VAR_PDISP struct { 43 | vt VARTYPE 44 | reserved1 [6]byte 45 | pdispVal *IDispatch 46 | reserved2 [8]byte 47 | } 48 | 49 | type VAR_PSAFEARRAY struct { 50 | vt VARTYPE 51 | reserved1 [6]byte 52 | parray *SAFEARRAY 53 | reserved2 [8]byte 54 | } 55 | 56 | type VAR_PVAR struct { 57 | vt VARTYPE 58 | reserved1 [6]byte 59 | pvarVal *VARIANT 60 | reserved2 [8]byte 61 | } 62 | 63 | type VAR_PBOOL struct { 64 | vt VARTYPE 65 | reserved1 [6]byte 66 | pboolVal *VARIANT_BOOL 67 | reserved2 [8]byte 68 | } 69 | 70 | type VAR_PPDISP struct { 71 | vt VARTYPE 72 | reserved1 [6]byte 73 | ppdispVal **IDispatch 74 | reserved2 [8]byte 75 | } 76 | -------------------------------------------------------------------------------- /opengl32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "golang.org/x/sys/windows" 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // for second parameter of WglSwapLayerBuffers 16 | const ( 17 | WGL_SWAP_MAIN_PLANE = (1 << 0) 18 | WGL_SWAP_OVERLAY1 = (1 << 1) 19 | WGL_SWAP_OVERLAY2 = (1 << 2) 20 | WGL_SWAP_OVERLAY3 = (1 << 3) 21 | WGL_SWAP_OVERLAY4 = (1 << 4) 22 | WGL_SWAP_OVERLAY5 = (1 << 5) 23 | WGL_SWAP_OVERLAY6 = (1 << 6) 24 | WGL_SWAP_OVERLAY7 = (1 << 7) 25 | WGL_SWAP_OVERLAY8 = (1 << 8) 26 | WGL_SWAP_OVERLAY9 = (1 << 9) 27 | WGL_SWAP_OVERLAY10 = (1 << 10) 28 | WGL_SWAP_OVERLAY11 = (1 << 11) 29 | WGL_SWAP_OVERLAY12 = (1 << 12) 30 | WGL_SWAP_OVERLAY13 = (1 << 13) 31 | WGL_SWAP_OVERLAY14 = (1 << 14) 32 | WGL_SWAP_OVERLAY15 = (1 << 15) 33 | WGL_SWAP_UNDERLAY1 = (1 << 16) 34 | WGL_SWAP_UNDERLAY2 = (1 << 17) 35 | WGL_SWAP_UNDERLAY3 = (1 << 18) 36 | WGL_SWAP_UNDERLAY4 = (1 << 19) 37 | WGL_SWAP_UNDERLAY5 = (1 << 20) 38 | WGL_SWAP_UNDERLAY6 = (1 << 21) 39 | WGL_SWAP_UNDERLAY7 = (1 << 22) 40 | WGL_SWAP_UNDERLAY8 = (1 << 23) 41 | WGL_SWAP_UNDERLAY9 = (1 << 24) 42 | WGL_SWAP_UNDERLAY10 = (1 << 25) 43 | WGL_SWAP_UNDERLAY11 = (1 << 26) 44 | WGL_SWAP_UNDERLAY12 = (1 << 27) 45 | WGL_SWAP_UNDERLAY13 = (1 << 28) 46 | WGL_SWAP_UNDERLAY14 = (1 << 29) 47 | WGL_SWAP_UNDERLAY15 = (1 << 30) 48 | ) 49 | 50 | type ( 51 | HGLRC HANDLE 52 | ) 53 | 54 | type LAYERPLANEDESCRIPTOR struct { 55 | NSize uint16 56 | NVersion uint16 57 | DwFlags uint32 58 | IPixelType uint8 59 | CColorBits uint8 60 | CRedBits uint8 61 | CRedShift uint8 62 | CGreenBits uint8 63 | CGreenShift uint8 64 | CBlueBits uint8 65 | CBlueShift uint8 66 | CAlphaBits uint8 67 | CAlphaShift uint8 68 | CAccumBits uint8 69 | CAccumRedBits uint8 70 | CAccumGreenBits uint8 71 | CAccumBlueBits uint8 72 | CAccumAlphaBits uint8 73 | CDepthBits uint8 74 | CStencilBits uint8 75 | CAuxBuffers uint8 76 | ILayerType uint8 77 | BReserved uint8 78 | CrTransparent COLORREF 79 | } 80 | 81 | type POINTFLOAT struct { 82 | X, Y float32 83 | } 84 | 85 | type GLYPHMETRICSFLOAT struct { 86 | GmfBlackBoxX float32 87 | GmfBlackBoxY float32 88 | GmfptGlyphOrigin POINTFLOAT 89 | GmfCellIncX float32 90 | GmfCellIncY float32 91 | } 92 | 93 | var ( 94 | // Library 95 | lib *windows.LazyDLL 96 | 97 | // Functions 98 | wglCopyContext *windows.LazyProc 99 | wglCreateContext *windows.LazyProc 100 | wglCreateLayerContext *windows.LazyProc 101 | wglDeleteContext *windows.LazyProc 102 | wglDescribeLayerPlane *windows.LazyProc 103 | wglGetCurrentContext *windows.LazyProc 104 | wglGetCurrentDC *windows.LazyProc 105 | wglGetLayerPaletteEntries *windows.LazyProc 106 | wglGetProcAddress *windows.LazyProc 107 | wglMakeCurrent *windows.LazyProc 108 | wglRealizeLayerPalette *windows.LazyProc 109 | wglSetLayerPaletteEntries *windows.LazyProc 110 | wglShareLists *windows.LazyProc 111 | wglSwapLayerBuffers *windows.LazyProc 112 | wglUseFontBitmaps *windows.LazyProc 113 | wglUseFontOutlines *windows.LazyProc 114 | ) 115 | 116 | func init() { 117 | // Library 118 | lib = windows.NewLazySystemDLL("opengl32.dll") 119 | 120 | // Functions 121 | wglCopyContext = lib.NewProc("wglCopyContext") 122 | wglCreateContext = lib.NewProc("wglCreateContext") 123 | wglCreateLayerContext = lib.NewProc("wglCreateLayerContext") 124 | wglDeleteContext = lib.NewProc("wglDeleteContext") 125 | wglDescribeLayerPlane = lib.NewProc("wglDescribeLayerPlane") 126 | wglGetCurrentContext = lib.NewProc("wglGetCurrentContext") 127 | wglGetCurrentDC = lib.NewProc("wglGetCurrentDC") 128 | wglGetLayerPaletteEntries = lib.NewProc("wglGetLayerPaletteEntries") 129 | wglGetProcAddress = lib.NewProc("wglGetProcAddress") 130 | wglMakeCurrent = lib.NewProc("wglMakeCurrent") 131 | wglRealizeLayerPalette = lib.NewProc("wglRealizeLayerPalette") 132 | wglSetLayerPaletteEntries = lib.NewProc("wglSetLayerPaletteEntries") 133 | wglShareLists = lib.NewProc("wglShareLists") 134 | wglSwapLayerBuffers = lib.NewProc("wglSwapLayerBuffers") 135 | wglUseFontBitmaps = lib.NewProc("wglUseFontBitmapsW") 136 | wglUseFontOutlines = lib.NewProc("wglUseFontOutlinesW") 137 | } 138 | 139 | func WglCopyContext(hglrcSrc, hglrcDst HGLRC, mask uint) bool { 140 | ret, _, _ := syscall.Syscall(wglCopyContext.Addr(), 3, 141 | uintptr(hglrcSrc), 142 | uintptr(hglrcDst), 143 | uintptr(mask)) 144 | 145 | return ret != 0 146 | } 147 | 148 | func WglCreateContext(hdc HDC) HGLRC { 149 | ret, _, _ := syscall.Syscall(wglCreateContext.Addr(), 1, 150 | uintptr(hdc), 151 | 0, 152 | 0) 153 | 154 | return HGLRC(ret) 155 | } 156 | 157 | func WglCreateLayerContext(hdc HDC, iLayerPlane int) HGLRC { 158 | ret, _, _ := syscall.Syscall(wglCreateLayerContext.Addr(), 2, 159 | uintptr(hdc), 160 | uintptr(iLayerPlane), 161 | 0) 162 | 163 | return HGLRC(ret) 164 | } 165 | 166 | func WglDeleteContext(hglrc HGLRC) bool { 167 | ret, _, _ := syscall.Syscall(wglDeleteContext.Addr(), 1, 168 | uintptr(hglrc), 169 | 0, 170 | 0) 171 | 172 | return ret != 0 173 | } 174 | 175 | func WglDescribeLayerPlane(hdc HDC, iPixelFormat, iLayerPlane int, nBytes uint8, plpd *LAYERPLANEDESCRIPTOR) bool { 176 | ret, _, _ := syscall.Syscall6(wglDescribeLayerPlane.Addr(), 5, 177 | uintptr(hdc), 178 | uintptr(iPixelFormat), 179 | uintptr(iLayerPlane), 180 | uintptr(nBytes), 181 | uintptr(unsafe.Pointer(plpd)), 182 | 0) 183 | 184 | return ret != 0 185 | } 186 | 187 | func WglGetCurrentContext() HGLRC { 188 | ret, _, _ := syscall.Syscall(wglGetCurrentContext.Addr(), 0, 189 | 0, 190 | 0, 191 | 0) 192 | 193 | return HGLRC(ret) 194 | } 195 | 196 | func WglGetCurrentDC() HDC { 197 | ret, _, _ := syscall.Syscall(wglGetCurrentDC.Addr(), 0, 198 | 0, 199 | 0, 200 | 0) 201 | 202 | return HDC(ret) 203 | } 204 | 205 | func WglGetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr *COLORREF) int { 206 | ret, _, _ := syscall.Syscall6(wglGetLayerPaletteEntries.Addr(), 5, 207 | uintptr(hdc), 208 | uintptr(iLayerPlane), 209 | uintptr(iStart), 210 | uintptr(cEntries), 211 | uintptr(unsafe.Pointer(pcr)), 212 | 0) 213 | 214 | return int(ret) 215 | } 216 | 217 | func WglGetProcAddress(lpszProc *byte) uintptr { 218 | ret, _, _ := syscall.Syscall(wglGetProcAddress.Addr(), 1, 219 | uintptr(unsafe.Pointer(lpszProc)), 220 | 0, 221 | 0) 222 | 223 | return uintptr(ret) 224 | } 225 | 226 | func WglMakeCurrent(hdc HDC, hglrc HGLRC) bool { 227 | ret, _, _ := syscall.Syscall(wglMakeCurrent.Addr(), 2, 228 | uintptr(hdc), 229 | uintptr(hglrc), 230 | 0) 231 | 232 | return ret != 0 233 | } 234 | 235 | func WglRealizeLayerPalette(hdc HDC, iLayerPlane int, bRealize bool) bool { 236 | ret, _, _ := syscall.Syscall(wglRealizeLayerPalette.Addr(), 3, 237 | uintptr(hdc), 238 | uintptr(iLayerPlane), 239 | uintptr(BoolToBOOL(bRealize))) 240 | 241 | return ret != 0 242 | } 243 | 244 | func WglSetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr *COLORREF) int { 245 | ret, _, _ := syscall.Syscall6(wglSetLayerPaletteEntries.Addr(), 5, 246 | uintptr(hdc), 247 | uintptr(iLayerPlane), 248 | uintptr(iStart), 249 | uintptr(cEntries), 250 | uintptr(unsafe.Pointer(pcr)), 251 | 0) 252 | 253 | return int(ret) 254 | } 255 | 256 | func WglShareLists(hglrc1, hglrc2 HGLRC) bool { 257 | ret, _, _ := syscall.Syscall(wglShareLists.Addr(), 2, 258 | uintptr(hglrc1), 259 | uintptr(hglrc2), 260 | 0) 261 | 262 | return ret != 0 263 | } 264 | 265 | func WglSwapLayerBuffers(hdc HDC, fuPlanes uint) bool { 266 | ret, _, _ := syscall.Syscall(wglSwapLayerBuffers.Addr(), 2, 267 | uintptr(hdc), 268 | uintptr(fuPlanes), 269 | 0) 270 | 271 | return ret != 0 272 | } 273 | 274 | func WglUseFontBitmaps(hdc HDC, first, count, listbase uint32) bool { 275 | ret, _, _ := syscall.Syscall6(wglUseFontBitmaps.Addr(), 4, 276 | uintptr(hdc), 277 | uintptr(first), 278 | uintptr(count), 279 | uintptr(listbase), 280 | 0, 281 | 0) 282 | 283 | return ret != 0 284 | } 285 | 286 | func WglUseFontOutlines(hdc HDC, first, count, listbase uint32, deviation, extrusion float32, format int, pgmf *GLYPHMETRICSFLOAT) bool { 287 | ret, _, _ := syscall.Syscall12(wglUseFontBitmaps.Addr(), 8, 288 | uintptr(hdc), 289 | uintptr(first), 290 | uintptr(count), 291 | uintptr(listbase), 292 | uintptr(deviation), 293 | uintptr(extrusion), 294 | uintptr(format), 295 | uintptr(unsafe.Pointer(pgmf)), 296 | 0, 297 | 0, 298 | 0, 299 | 0) 300 | 301 | return ret != 0 302 | } 303 | -------------------------------------------------------------------------------- /richole.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | type REOBJECT struct { 15 | cbStruct uint32 // Size of structure 16 | cp int32 // Character position of object 17 | clsid CLSID // Class ID of object 18 | poleobj *IOleObject // OLE object interface 19 | pstg *IStorage // Associated storage interface 20 | polesite *IOleClientSite // Associated client site interface 21 | sizel SIZE // Size of object (may be 0,0) 22 | dvaspect uint32 // Display aspect to use 23 | dwFlags uint32 // Object status flags 24 | dwUser uint32 // Dword for user's use 25 | } 26 | 27 | type IRichEditOleVtbl struct { 28 | IUnknownVtbl 29 | GetClientSite uintptr 30 | GetObjectCount uintptr 31 | GetLinkCount uintptr 32 | GetObject uintptr 33 | InsertObject uintptr 34 | ConvertObject uintptr 35 | ActivateAs uintptr 36 | SetHostNames uintptr 37 | SetLinkAvailable uintptr 38 | SetDvaspect uintptr 39 | HandsOffStorage uintptr 40 | SaveCompleted uintptr 41 | InPlaceDeactivate uintptr 42 | ContextSensitiveHelp uintptr 43 | GetClipboardData uintptr 44 | ImportDataObject uintptr 45 | } 46 | 47 | type IRichEditOle struct { 48 | LpVtbl *IRichEditOleVtbl 49 | } 50 | 51 | func (obj *IRichEditOle) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 52 | ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, 53 | uintptr(unsafe.Pointer(obj)), 54 | uintptr(unsafe.Pointer(riid)), 55 | uintptr(unsafe.Pointer(ppvObject))) 56 | return HRESULT(ret) 57 | } 58 | 59 | func (obj *IRichEditOle) AddRef() uint32 { 60 | ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, 61 | uintptr(unsafe.Pointer(obj)), 62 | 0, 63 | 0) 64 | return uint32(ret) 65 | } 66 | 67 | func (obj *IRichEditOle) Release() uint32 { 68 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, 69 | uintptr(unsafe.Pointer(obj)), 70 | 0, 71 | 0) 72 | return uint32(ret) 73 | } 74 | 75 | func (obj *IRichEditOle) GetClientSite(lplpolesite **IOleClientSite) HRESULT { 76 | ret, _, _ := syscall.Syscall(obj.LpVtbl.GetClientSite, 2, 77 | uintptr(unsafe.Pointer(obj)), 78 | uintptr(unsafe.Pointer(lplpolesite)), 79 | 0) 80 | return HRESULT(ret) 81 | } 82 | 83 | func (obj *IRichEditOle) GetObjectCount() int32 { 84 | ret, _, _ := syscall.Syscall(obj.LpVtbl.GetObjectCount, 1, 85 | uintptr(unsafe.Pointer(obj)), 86 | 0, 87 | 0) 88 | return int32(ret) 89 | } 90 | 91 | func (obj *IRichEditOle) GetLinkCount() int32 { 92 | ret, _, _ := syscall.Syscall(obj.LpVtbl.GetLinkCount, 1, 93 | uintptr(unsafe.Pointer(obj)), 94 | 0, 95 | 0) 96 | return int32(ret) 97 | } 98 | 99 | func (obj *IRichEditOle) GetObject(iob int32, lpreobject *REOBJECT, dwFlags uint32) HRESULT { 100 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetObject, 4, 101 | uintptr(unsafe.Pointer(obj)), 102 | uintptr(iob), 103 | uintptr(unsafe.Pointer(lpreobject)), 104 | uintptr(dwFlags), 105 | 0, 106 | 0) 107 | return HRESULT(ret) 108 | } 109 | 110 | func (obj *IRichEditOle) InsertObject(lpreobject *REOBJECT) HRESULT { 111 | ret, _, _ := syscall.Syscall(obj.LpVtbl.InsertObject, 2, 112 | uintptr(unsafe.Pointer(obj)), 113 | uintptr(unsafe.Pointer(lpreobject)), 114 | 0) 115 | return HRESULT(ret) 116 | } 117 | 118 | func (obj *IRichEditOle) ConvertObject(iob int32, rclsidNew REFCLSID, lpstrUserTypeNew *byte) HRESULT { 119 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.ConvertObject, 4, 120 | uintptr(unsafe.Pointer(obj)), 121 | uintptr(iob), 122 | uintptr(unsafe.Pointer(rclsidNew)), 123 | uintptr(unsafe.Pointer(lpstrUserTypeNew)), 124 | 0, 125 | 0) 126 | return HRESULT(ret) 127 | } 128 | 129 | func (obj *IRichEditOle) ActivateAs(rclsid REFCLSID, rclsidAs REFCLSID) HRESULT { 130 | ret, _, _ := syscall.Syscall(obj.LpVtbl.ActivateAs, 3, 131 | uintptr(unsafe.Pointer(obj)), 132 | uintptr(unsafe.Pointer(rclsid)), 133 | uintptr(unsafe.Pointer(rclsidAs))) 134 | return HRESULT(ret) 135 | } 136 | 137 | func (obj *IRichEditOle) SetHostNames(lpstrContainerApp *byte, lpstrContainerObj *byte) HRESULT { 138 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetHostNames, 3, 139 | uintptr(unsafe.Pointer(obj)), 140 | uintptr(unsafe.Pointer(lpstrContainerApp)), 141 | uintptr(unsafe.Pointer(lpstrContainerObj))) 142 | return HRESULT(ret) 143 | } 144 | 145 | func (obj *IRichEditOle) SetLinkAvailable(iob int32, fAvailable BOOL) HRESULT { 146 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetLinkAvailable, 3, 147 | uintptr(unsafe.Pointer(obj)), 148 | uintptr(iob), 149 | uintptr(fAvailable)) 150 | return HRESULT(ret) 151 | } 152 | 153 | func (obj *IRichEditOle) SetDvaspect(iob int32, dvaspect uint32) HRESULT { 154 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetDvaspect, 3, 155 | uintptr(unsafe.Pointer(obj)), 156 | uintptr(iob), 157 | uintptr(dvaspect)) 158 | return HRESULT(ret) 159 | } 160 | 161 | func (obj *IRichEditOle) HandsOffStorage(iob int32) HRESULT { 162 | ret, _, _ := syscall.Syscall(obj.LpVtbl.HandsOffStorage, 2, 163 | uintptr(unsafe.Pointer(obj)), 164 | uintptr(iob), 165 | 0) 166 | return HRESULT(ret) 167 | } 168 | 169 | func (obj *IRichEditOle) SaveCompleted(iob int32, lpstg *IStorage) HRESULT { 170 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SaveCompleted, 3, 171 | uintptr(unsafe.Pointer(obj)), 172 | uintptr(iob), 173 | uintptr(unsafe.Pointer(lpstg))) 174 | return HRESULT(ret) 175 | } 176 | 177 | func (obj *IRichEditOle) InPlaceDeactivate() HRESULT { 178 | ret, _, _ := syscall.Syscall(obj.LpVtbl.InPlaceDeactivate, 1, 179 | uintptr(unsafe.Pointer(obj)), 180 | 0, 181 | 0) 182 | return HRESULT(ret) 183 | } 184 | 185 | func (obj *IRichEditOle) ContextSensitiveHelp(fEnterMode BOOL) HRESULT { 186 | ret, _, _ := syscall.Syscall(obj.LpVtbl.ContextSensitiveHelp, 2, 187 | uintptr(unsafe.Pointer(obj)), 188 | uintptr(fEnterMode), 189 | 0) 190 | return HRESULT(ret) 191 | } 192 | 193 | func (obj *IRichEditOle) GetClipboardData(lpchrg *CHARRANGE, reco uint32, lplpdataobj **IDataObject) HRESULT { 194 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetClipboardData, 4, 195 | uintptr(unsafe.Pointer(obj)), 196 | uintptr(unsafe.Pointer(lpchrg)), 197 | uintptr(reco), 198 | uintptr(unsafe.Pointer(lplpdataobj)), 199 | 0, 200 | 0) 201 | return HRESULT(ret) 202 | } 203 | 204 | func (obj *IRichEditOle) ImportDataObject(lpdataobj *IDataObject, cf CLIPFORMAT, hMetaPict HGLOBAL) HRESULT { 205 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.ImportDataObject, 4, 206 | uintptr(unsafe.Pointer(obj)), 207 | uintptr(unsafe.Pointer(lpdataobj)), 208 | uintptr(cf), 209 | uintptr(hMetaPict), 210 | 0, 211 | 0) 212 | return HRESULT(ret) 213 | } 214 | -------------------------------------------------------------------------------- /shdocvw.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | const ( 15 | DOCHOSTUIDBLCLK_DEFAULT = 0 16 | DOCHOSTUIDBLCLK_SHOWPROPERTIES = 1 17 | DOCHOSTUIDBLCLK_SHOWCODE = 2 18 | ) 19 | 20 | const ( 21 | DOCHOSTUIFLAG_DIALOG = 0x1 22 | DOCHOSTUIFLAG_DISABLE_HELP_MENU = 0x2 23 | DOCHOSTUIFLAG_NO3DBORDER = 0x4 24 | DOCHOSTUIFLAG_SCROLL_NO = 0x8 25 | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 0x10 26 | DOCHOSTUIFLAG_OPENNEWWIN = 0x20 27 | DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 0x40 28 | DOCHOSTUIFLAG_FLAT_SCROLLBAR = 0x80 29 | DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 0x100 30 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 0x200 31 | DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY = 0x400 32 | DOCHOSTUIFLAG_CODEPAGELINKEDFONTS = 0x800 33 | DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8 = 0x1000 34 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 = 0x2000 35 | DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE = 0x4000 36 | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION = 0x10000 37 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION = 0x20000 38 | DOCHOSTUIFLAG_THEME = 0x40000 39 | DOCHOSTUIFLAG_NOTHEME = 0x80000 40 | DOCHOSTUIFLAG_NOPICS = 0x100000 41 | DOCHOSTUIFLAG_NO3DOUTERBORDER = 0x200000 42 | DOCHOSTUIFLAG_DISABLE_EDIT_NS_FIXUP = 0x400000 43 | DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK = 0x800000 44 | DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL = 0x1000000 45 | ) 46 | 47 | // BrowserNavConstants 48 | const ( 49 | NavOpenInNewWindow = 0x1 50 | NavNoHistory = 0x2 51 | NavNoReadFromCache = 0x4 52 | NavNoWriteToCache = 0x8 53 | NavAllowAutosearch = 0x10 54 | NavBrowserBar = 0x20 55 | NavHyperlink = 0x40 56 | NavEnforceRestricted = 0x80 57 | NavNewWindowsManaged = 0x0100 58 | NavUntrustedForDownload = 0x0200 59 | NavTrustedForActiveX = 0x0400 60 | NavOpenInNewTab = 0x0800 61 | NavOpenInBackgroundTab = 0x1000 62 | NavKeepWordWheelText = 0x2000 63 | NavVirtualTab = 0x4000 64 | NavBlockRedirectsXDomain = 0x8000 65 | NavOpenNewForegroundTab = 0x10000 66 | ) 67 | 68 | var ( 69 | CLSID_WebBrowser = CLSID{0x8856F961, 0x340A, 0x11D0, [8]byte{0xA9, 0x6B, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2}} 70 | DIID_DWebBrowserEvents2 = IID{0x34A715A0, 0x6587, 0x11D0, [8]byte{0x92, 0x4A, 0x00, 0x20, 0xAF, 0xC7, 0xAC, 0x4D}} 71 | IID_IWebBrowser2 = IID{0xD30C1661, 0xCDAF, 0x11D0, [8]byte{0x8A, 0x3E, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E}} 72 | IID_IDocHostUIHandler = IID{0xBD3F23C0, 0xD43E, 0x11CF, [8]byte{0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A}} 73 | IID_IOleInPlaceActiveObject = IID{0x00000117, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 74 | ) 75 | 76 | type DWebBrowserEvents2Vtbl struct { 77 | QueryInterface uintptr 78 | AddRef uintptr 79 | Release uintptr 80 | GetTypeInfoCount uintptr 81 | GetTypeInfo uintptr 82 | GetIDsOfNames uintptr 83 | Invoke uintptr 84 | } 85 | 86 | type DWebBrowserEvents2 struct { 87 | LpVtbl *DWebBrowserEvents2Vtbl 88 | } 89 | 90 | type IWebBrowser2Vtbl struct { 91 | QueryInterface uintptr 92 | AddRef uintptr 93 | Release uintptr 94 | GetTypeInfoCount uintptr 95 | GetTypeInfo uintptr 96 | GetIDsOfNames uintptr 97 | Invoke uintptr 98 | GoBack uintptr 99 | GoForward uintptr 100 | GoHome uintptr 101 | GoSearch uintptr 102 | Navigate uintptr 103 | Refresh uintptr 104 | Refresh2 uintptr 105 | Stop uintptr 106 | Get_Application uintptr 107 | Get_Parent uintptr 108 | Get_Container uintptr 109 | Get_Document uintptr 110 | Get_TopLevelContainer uintptr 111 | Get_Type uintptr 112 | Get_Left uintptr 113 | Put_Left uintptr 114 | Get_Top uintptr 115 | Put_Top uintptr 116 | Get_Width uintptr 117 | Put_Width uintptr 118 | Get_Height uintptr 119 | Put_Height uintptr 120 | Get_LocationName uintptr 121 | Get_LocationURL uintptr 122 | Get_Busy uintptr 123 | Quit uintptr 124 | ClientToWindow uintptr 125 | PutProperty uintptr 126 | GetProperty uintptr 127 | Get_Name uintptr 128 | Get_HWND uintptr 129 | Get_FullName uintptr 130 | Get_Path uintptr 131 | Get_Visible uintptr 132 | Put_Visible uintptr 133 | Get_StatusBar uintptr 134 | Put_StatusBar uintptr 135 | Get_StatusText uintptr 136 | Put_StatusText uintptr 137 | Get_ToolBar uintptr 138 | Put_ToolBar uintptr 139 | Get_MenuBar uintptr 140 | Put_MenuBar uintptr 141 | Get_FullScreen uintptr 142 | Put_FullScreen uintptr 143 | Navigate2 uintptr 144 | QueryStatusWB uintptr 145 | ExecWB uintptr 146 | ShowBrowserBar uintptr 147 | Get_ReadyState uintptr 148 | Get_Offline uintptr 149 | Put_Offline uintptr 150 | Get_Silent uintptr 151 | Put_Silent uintptr 152 | Get_RegisterAsBrowser uintptr 153 | Put_RegisterAsBrowser uintptr 154 | Get_RegisterAsDropTarget uintptr 155 | Put_RegisterAsDropTarget uintptr 156 | Get_TheaterMode uintptr 157 | Put_TheaterMode uintptr 158 | Get_AddressBar uintptr 159 | Put_AddressBar uintptr 160 | Get_Resizable uintptr 161 | Put_Resizable uintptr 162 | } 163 | 164 | type IWebBrowser2 struct { 165 | LpVtbl *IWebBrowser2Vtbl 166 | } 167 | 168 | func (wb2 *IWebBrowser2) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 169 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.QueryInterface, 3, 170 | uintptr(unsafe.Pointer(wb2)), 171 | uintptr(unsafe.Pointer(riid)), 172 | uintptr(unsafe.Pointer(ppvObject))) 173 | 174 | return HRESULT(ret) 175 | } 176 | 177 | func (wb2 *IWebBrowser2) Release() HRESULT { 178 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Release, 1, 179 | uintptr(unsafe.Pointer(wb2)), 180 | 0, 181 | 0) 182 | 183 | return HRESULT(ret) 184 | } 185 | 186 | func (wb2 *IWebBrowser2) Refresh() HRESULT { 187 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Refresh, 1, 188 | uintptr(unsafe.Pointer(wb2)), 189 | 0, 190 | 0) 191 | 192 | return HRESULT(ret) 193 | } 194 | 195 | func (wb2 *IWebBrowser2) Put_Left(Left int32) HRESULT { 196 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Left, 2, 197 | uintptr(unsafe.Pointer(wb2)), 198 | uintptr(Left), 199 | 0) 200 | 201 | return HRESULT(ret) 202 | } 203 | 204 | func (wb2 *IWebBrowser2) Put_Top(Top int32) HRESULT { 205 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Top, 2, 206 | uintptr(unsafe.Pointer(wb2)), 207 | uintptr(Top), 208 | 0) 209 | 210 | return HRESULT(ret) 211 | } 212 | 213 | func (wb2 *IWebBrowser2) Put_Width(Width int32) HRESULT { 214 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Width, 2, 215 | uintptr(unsafe.Pointer(wb2)), 216 | uintptr(Width), 217 | 0) 218 | 219 | return HRESULT(ret) 220 | } 221 | 222 | func (wb2 *IWebBrowser2) Put_Height(Height int32) HRESULT { 223 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Height, 2, 224 | uintptr(unsafe.Pointer(wb2)), 225 | uintptr(Height), 226 | 0) 227 | 228 | return HRESULT(ret) 229 | } 230 | 231 | func (wb2 *IWebBrowser2) Get_LocationURL(pbstrLocationURL **uint16 /*BSTR*/) HRESULT { 232 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Get_LocationURL, 2, 233 | uintptr(unsafe.Pointer(wb2)), 234 | uintptr(unsafe.Pointer(pbstrLocationURL)), 235 | 0) 236 | 237 | return HRESULT(ret) 238 | } 239 | 240 | func (wb2 *IWebBrowser2) Navigate2(URL *VAR_BSTR, Flags *VAR_I4, TargetFrameName *VAR_BSTR, PostData unsafe.Pointer, Headers *VAR_BSTR) HRESULT { 241 | ret, _, _ := syscall.Syscall6(wb2.LpVtbl.Navigate2, 6, 242 | uintptr(unsafe.Pointer(wb2)), 243 | uintptr(unsafe.Pointer(URL)), 244 | uintptr(unsafe.Pointer(Flags)), 245 | uintptr(unsafe.Pointer(TargetFrameName)), 246 | uintptr(PostData), 247 | uintptr(unsafe.Pointer(Headers))) 248 | 249 | return HRESULT(ret) 250 | } 251 | 252 | type IDocHostUIHandlerVtbl struct { 253 | QueryInterface uintptr 254 | AddRef uintptr 255 | Release uintptr 256 | ShowContextMenu uintptr 257 | GetHostInfo uintptr 258 | ShowUI uintptr 259 | HideUI uintptr 260 | UpdateUI uintptr 261 | EnableModeless uintptr 262 | OnDocWindowActivate uintptr 263 | OnFrameWindowActivate uintptr 264 | ResizeBorder uintptr 265 | TranslateAccelerator uintptr 266 | GetOptionKeyPath uintptr 267 | GetDropTarget uintptr 268 | GetExternal uintptr 269 | TranslateUrl uintptr 270 | FilterDataObject uintptr 271 | } 272 | 273 | type IDocHostUIHandler struct { 274 | LpVtbl *IDocHostUIHandlerVtbl 275 | } 276 | 277 | type DOCHOSTUIINFO struct { 278 | CbSize uint32 279 | DwFlags uint32 280 | DwDoubleClick uint32 281 | PchHostCss *uint16 282 | PchHostNS *uint16 283 | } 284 | 285 | type IOleInPlaceActiveObjectVtbl struct { 286 | QueryInterface uintptr 287 | AddRef uintptr 288 | Release uintptr 289 | GetWindow uintptr 290 | ContextSensitiveHelp uintptr 291 | TranslateAccelerator uintptr 292 | OnFrameWindowActivate uintptr 293 | OnDocWindowActivate uintptr 294 | ResizeBorder uintptr 295 | EnableModeless uintptr 296 | } 297 | 298 | type IOleInPlaceActiveObject struct { 299 | LpVtbl *IOleInPlaceActiveObjectVtbl 300 | } 301 | 302 | func (activeObj *IOleInPlaceActiveObject) Release() HRESULT { 303 | ret, _, _ := syscall.Syscall(activeObj.LpVtbl.Release, 1, 304 | uintptr(unsafe.Pointer(activeObj)), 305 | 0, 306 | 0) 307 | 308 | return HRESULT(ret) 309 | } 310 | 311 | func (activeObj *IOleInPlaceActiveObject) GetWindow(hWndPtr *HWND) HRESULT { 312 | ret, _, _ := syscall.Syscall(activeObj.LpVtbl.GetWindow, 2, 313 | uintptr(unsafe.Pointer(activeObj)), 314 | uintptr(unsafe.Pointer(hWndPtr)), 315 | 0) 316 | 317 | return HRESULT(ret) 318 | } 319 | 320 | func (activeObj *IOleInPlaceActiveObject) TranslateAccelerator(msg *MSG) HRESULT { 321 | ret, _, _ := syscall.Syscall(activeObj.LpVtbl.TranslateAccelerator, 2, 322 | uintptr(unsafe.Pointer(activeObj)), 323 | uintptr(unsafe.Pointer(msg)), 324 | 0) 325 | 326 | return HRESULT(ret) 327 | } 328 | -------------------------------------------------------------------------------- /shell32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "golang.org/x/sys/windows" 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | type CSIDL uint32 16 | type HDROP HANDLE 17 | 18 | const ( 19 | CSIDL_DESKTOP = 0x00 20 | CSIDL_INTERNET = 0x01 21 | CSIDL_PROGRAMS = 0x02 22 | CSIDL_CONTROLS = 0x03 23 | CSIDL_PRINTERS = 0x04 24 | CSIDL_PERSONAL = 0x05 25 | CSIDL_FAVORITES = 0x06 26 | CSIDL_STARTUP = 0x07 27 | CSIDL_RECENT = 0x08 28 | CSIDL_SENDTO = 0x09 29 | CSIDL_BITBUCKET = 0x0A 30 | CSIDL_STARTMENU = 0x0B 31 | CSIDL_MYDOCUMENTS = 0x0C 32 | CSIDL_MYMUSIC = 0x0D 33 | CSIDL_MYVIDEO = 0x0E 34 | CSIDL_DESKTOPDIRECTORY = 0x10 35 | CSIDL_DRIVES = 0x11 36 | CSIDL_NETWORK = 0x12 37 | CSIDL_NETHOOD = 0x13 38 | CSIDL_FONTS = 0x14 39 | CSIDL_TEMPLATES = 0x15 40 | CSIDL_COMMON_STARTMENU = 0x16 41 | CSIDL_COMMON_PROGRAMS = 0x17 42 | CSIDL_COMMON_STARTUP = 0x18 43 | CSIDL_COMMON_DESKTOPDIRECTORY = 0x19 44 | CSIDL_APPDATA = 0x1A 45 | CSIDL_PRINTHOOD = 0x1B 46 | CSIDL_LOCAL_APPDATA = 0x1C 47 | CSIDL_ALTSTARTUP = 0x1D 48 | CSIDL_COMMON_ALTSTARTUP = 0x1E 49 | CSIDL_COMMON_FAVORITES = 0x1F 50 | CSIDL_INTERNET_CACHE = 0x20 51 | CSIDL_COOKIES = 0x21 52 | CSIDL_HISTORY = 0x22 53 | CSIDL_COMMON_APPDATA = 0x23 54 | CSIDL_WINDOWS = 0x24 55 | CSIDL_SYSTEM = 0x25 56 | CSIDL_PROGRAM_FILES = 0x26 57 | CSIDL_MYPICTURES = 0x27 58 | CSIDL_PROFILE = 0x28 59 | CSIDL_SYSTEMX86 = 0x29 60 | CSIDL_PROGRAM_FILESX86 = 0x2A 61 | CSIDL_PROGRAM_FILES_COMMON = 0x2B 62 | CSIDL_PROGRAM_FILES_COMMONX86 = 0x2C 63 | CSIDL_COMMON_TEMPLATES = 0x2D 64 | CSIDL_COMMON_DOCUMENTS = 0x2E 65 | CSIDL_COMMON_ADMINTOOLS = 0x2F 66 | CSIDL_ADMINTOOLS = 0x30 67 | CSIDL_CONNECTIONS = 0x31 68 | CSIDL_COMMON_MUSIC = 0x35 69 | CSIDL_COMMON_PICTURES = 0x36 70 | CSIDL_COMMON_VIDEO = 0x37 71 | CSIDL_RESOURCES = 0x38 72 | CSIDL_RESOURCES_LOCALIZED = 0x39 73 | CSIDL_COMMON_OEM_LINKS = 0x3A 74 | CSIDL_CDBURN_AREA = 0x3B 75 | CSIDL_COMPUTERSNEARME = 0x3D 76 | CSIDL_FLAG_CREATE = 0x8000 77 | CSIDL_FLAG_DONT_VERIFY = 0x4000 78 | CSIDL_FLAG_NO_ALIAS = 0x1000 79 | CSIDL_FLAG_PER_USER_INIT = 0x8000 80 | CSIDL_FLAG_MASK = 0xFF00 81 | ) 82 | 83 | // NotifyIcon flags 84 | const ( 85 | NIF_MESSAGE = 0x00000001 86 | NIF_ICON = 0x00000002 87 | NIF_TIP = 0x00000004 88 | NIF_STATE = 0x00000008 89 | NIF_INFO = 0x00000010 90 | NIF_GUID = 0x00000020 91 | NIF_REALTIME = 0x00000040 92 | NIF_SHOWTIP = 0x00000080 93 | ) 94 | 95 | // NotifyIcon messages 96 | const ( 97 | NIM_ADD = 0x00000000 98 | NIM_MODIFY = 0x00000001 99 | NIM_DELETE = 0x00000002 100 | NIM_SETFOCUS = 0x00000003 101 | NIM_SETVERSION = 0x00000004 102 | ) 103 | 104 | // NotifyIcon states 105 | const ( 106 | NIS_HIDDEN = 0x00000001 107 | NIS_SHAREDICON = 0x00000002 108 | ) 109 | 110 | // NotifyIcon info flags 111 | const ( 112 | NIIF_NONE = 0x00000000 113 | NIIF_INFO = 0x00000001 114 | NIIF_WARNING = 0x00000002 115 | NIIF_ERROR = 0x00000003 116 | NIIF_USER = 0x00000004 117 | NIIF_NOSOUND = 0x00000010 118 | NIIF_LARGE_ICON = 0x00000020 119 | NIIF_RESPECT_QUIET_TIME = 0x00000080 120 | ) 121 | 122 | // NotifyIcon notifications 123 | const ( 124 | NIN_SELECT = WM_USER + 0 125 | NIN_KEYSELECT = WM_USER + 1 126 | NIN_BALLOONSHOW = WM_USER + 2 127 | NIN_BALLOONHIDE = WM_USER + 3 128 | NIN_BALLOONTIMEOUT = WM_USER + 4 129 | NIN_BALLOONUSERCLICK = WM_USER + 5 130 | NIN_POPUPOPEN = WM_USER + 6 131 | NIN_POPUPCLOSE = WM_USER + 7 132 | ) 133 | 134 | // NotifyIcon versions 135 | const ( 136 | NOTIFYICON_VERSION = 3 137 | NOTIFYICON_VERSION_4 = 4 138 | ) 139 | 140 | // SHGetFileInfo flags 141 | const ( 142 | SHGFI_LARGEICON = 0x000000000 143 | SHGFI_SMALLICON = 0x000000001 144 | SHGFI_OPENICON = 0x000000002 145 | SHGFI_SHELLICONSIZE = 0x000000004 146 | SHGFI_PIDL = 0x000000008 147 | SHGFI_USEFILEATTRIBUTES = 0x000000010 148 | SHGFI_ADDOVERLAYS = 0x000000020 149 | SHGFI_OVERLAYINDEX = 0x000000040 150 | SHGFI_ICON = 0x000000100 151 | SHGFI_DISPLAYNAME = 0x000000200 152 | SHGFI_TYPENAME = 0x000000400 153 | SHGFI_ATTRIBUTES = 0x000000800 154 | SHGFI_ICONLOCATION = 0x000001000 155 | SHGFI_EXETYPE = 0x000002000 156 | SHGFI_SYSICONINDEX = 0x000004000 157 | SHGFI_LINKOVERLAY = 0x000008000 158 | SHGFI_SELECTED = 0x000010000 159 | SHGFI_ATTR_SPECIFIED = 0x000020000 160 | ) 161 | 162 | // SHGetStockIconInfo flags 163 | const ( 164 | SHGSI_ICONLOCATION = 0 165 | SHGSI_ICON = 0x000000100 166 | SHGSI_SYSICONINDEX = 0x000004000 167 | SHGSI_LINKOVERLAY = 0x000008000 168 | SHGSI_SELECTED = 0x000010000 169 | SHGSI_LARGEICON = 0x000000000 170 | SHGSI_SMALLICON = 0x000000001 171 | SHGSI_SHELLICONSIZE = 0x000000004 172 | ) 173 | 174 | // SHSTOCKICONID values 175 | const ( 176 | SIID_DOCNOASSOC = 0 177 | SIID_DOCASSOC = 1 178 | SIID_APPLICATION = 2 179 | SIID_FOLDER = 3 180 | SIID_FOLDEROPEN = 4 181 | SIID_DRIVE525 = 5 182 | SIID_DRIVE35 = 6 183 | SIID_DRIVEREMOVE = 7 184 | SIID_DRIVEFIXED = 8 185 | SIID_DRIVENET = 9 186 | SIID_DRIVENETDISABLED = 10 187 | SIID_DRIVECD = 11 188 | SIID_DRIVERAM = 12 189 | SIID_WORLD = 13 190 | SIID_SERVER = 15 191 | SIID_PRINTER = 16 192 | SIID_MYNETWORK = 17 193 | SIID_FIND = 22 194 | SIID_HELP = 23 195 | SIID_SHARE = 28 196 | SIID_LINK = 29 197 | SIID_SLOWFILE = 30 198 | SIID_RECYCLER = 31 199 | SIID_RECYCLERFULL = 32 200 | SIID_MEDIACDAUDIO = 40 201 | SIID_LOCK = 47 202 | SIID_AUTOLIST = 49 203 | SIID_PRINTERNET = 50 204 | SIID_SERVERSHARE = 51 205 | SIID_PRINTERFAX = 52 206 | SIID_PRINTERFAXNET = 53 207 | SIID_PRINTERFILE = 54 208 | SIID_STACK = 55 209 | SIID_MEDIASVCD = 56 210 | SIID_STUFFEDFOLDER = 57 211 | SIID_DRIVEUNKNOWN = 58 212 | SIID_DRIVEDVD = 59 213 | SIID_MEDIADVD = 60 214 | SIID_MEDIADVDRAM = 61 215 | SIID_MEDIADVDRW = 62 216 | SIID_MEDIADVDR = 63 217 | SIID_MEDIADVDROM = 64 218 | SIID_MEDIACDAUDIOPLUS = 65 219 | SIID_MEDIACDRW = 66 220 | SIID_MEDIACDR = 67 221 | SIID_MEDIACDBURN = 68 222 | SIID_MEDIABLANKCD = 69 223 | SIID_MEDIACDROM = 70 224 | SIID_AUDIOFILES = 71 225 | SIID_IMAGEFILES = 72 226 | SIID_VIDEOFILES = 73 227 | SIID_MIXEDFILES = 74 228 | SIID_FOLDERBACK = 75 229 | SIID_FOLDERFRONT = 76 230 | SIID_SHIELD = 77 231 | SIID_WARNING = 78 232 | SIID_INFO = 79 233 | SIID_ERROR = 80 234 | SIID_KEY = 81 235 | SIID_SOFTWARE = 82 236 | SIID_RENAME = 83 237 | SIID_DELETE = 84 238 | SIID_MEDIAAUDIODVD = 85 239 | SIID_MEDIAMOVIEDVD = 86 240 | SIID_MEDIAENHANCEDCD = 87 241 | SIID_MEDIAENHANCEDDVD = 88 242 | SIID_MEDIAHDDVD = 89 243 | SIID_MEDIABLURAY = 90 244 | SIID_MEDIAVCD = 91 245 | SIID_MEDIADVDPLUSR = 92 246 | SIID_MEDIADVDPLUSRW = 93 247 | SIID_DESKTOPPC = 94 248 | SIID_MOBILEPC = 95 249 | SIID_USERS = 96 250 | SIID_MEDIASMARTMEDIA = 97 251 | SIID_MEDIACOMPACTFLASH = 98 252 | SIID_DEVICECELLPHONE = 99 253 | SIID_DEVICECAMERA = 100 254 | SIID_DEVICEVIDEOCAMERA = 101 255 | SIID_DEVICEAUDIOPLAYER = 102 256 | SIID_NETWORKCONNECT = 103 257 | SIID_INTERNET = 104 258 | SIID_ZIPFILE = 105 259 | SIID_SETTINGS = 106 260 | SIID_DRIVEHDDVD = 132 261 | SIID_DRIVEBD = 133 262 | SIID_MEDIAHDDVDROM = 134 263 | SIID_MEDIAHDDVDR = 135 264 | SIID_MEDIAHDDVDRAM = 136 265 | SIID_MEDIABDROM = 137 266 | SIID_MEDIABDR = 138 267 | SIID_MEDIABDRE = 139 268 | SIID_CLUSTEREDDRIVE = 140 269 | SIID_MAX_ICONS = 175 270 | ) 271 | 272 | type NOTIFYICONDATA struct { 273 | CbSize uint32 274 | HWnd HWND 275 | UID uint32 276 | UFlags uint32 277 | UCallbackMessage uint32 278 | HIcon HICON 279 | SzTip [128]uint16 280 | DwState uint32 281 | DwStateMask uint32 282 | SzInfo [256]uint16 283 | UVersion uint32 284 | SzInfoTitle [64]uint16 285 | DwInfoFlags uint32 286 | GuidItem syscall.GUID 287 | HBalloonIcon HICON 288 | } 289 | 290 | type SHFILEINFO struct { 291 | HIcon HICON 292 | IIcon int32 293 | DwAttributes uint32 294 | SzDisplayName [MAX_PATH]uint16 295 | SzTypeName [80]uint16 296 | } 297 | 298 | type BROWSEINFO struct { 299 | HwndOwner HWND 300 | PidlRoot uintptr 301 | PszDisplayName *uint16 302 | LpszTitle *uint16 303 | UlFlags uint32 304 | Lpfn uintptr 305 | LParam uintptr 306 | IImage int32 307 | } 308 | 309 | type SHSTOCKICONINFO struct { 310 | CbSize uint32 311 | HIcon HICON 312 | ISysImageIndex int32 313 | IIcon int32 314 | SzPath [MAX_PATH]uint16 315 | } 316 | 317 | var ( 318 | // Library 319 | libshell32 *windows.LazyDLL 320 | 321 | // Functions 322 | dragAcceptFiles *windows.LazyProc 323 | dragFinish *windows.LazyProc 324 | dragQueryFile *windows.LazyProc 325 | extractIcon *windows.LazyProc 326 | shBrowseForFolder *windows.LazyProc 327 | shDefExtractIcon *windows.LazyProc 328 | shGetFileInfo *windows.LazyProc 329 | shGetPathFromIDList *windows.LazyProc 330 | shGetSpecialFolderPath *windows.LazyProc 331 | shParseDisplayName *windows.LazyProc 332 | shGetStockIconInfo *windows.LazyProc 333 | shellExecute *windows.LazyProc 334 | shell_NotifyIcon *windows.LazyProc 335 | ) 336 | 337 | func init() { 338 | // Library 339 | libshell32 = windows.NewLazySystemDLL("shell32.dll") 340 | 341 | // Functions 342 | dragAcceptFiles = libshell32.NewProc("DragAcceptFiles") 343 | dragFinish = libshell32.NewProc("DragFinish") 344 | dragQueryFile = libshell32.NewProc("DragQueryFileW") 345 | extractIcon = libshell32.NewProc("ExtractIconW") 346 | shBrowseForFolder = libshell32.NewProc("SHBrowseForFolderW") 347 | shDefExtractIcon = libshell32.NewProc("SHDefExtractIconW") 348 | shGetFileInfo = libshell32.NewProc("SHGetFileInfoW") 349 | shGetPathFromIDList = libshell32.NewProc("SHGetPathFromIDListW") 350 | shGetSpecialFolderPath = libshell32.NewProc("SHGetSpecialFolderPathW") 351 | shGetStockIconInfo = libshell32.NewProc("SHGetStockIconInfo") 352 | shellExecute = libshell32.NewProc("ShellExecuteW") 353 | shell_NotifyIcon = libshell32.NewProc("Shell_NotifyIconW") 354 | shParseDisplayName = libshell32.NewProc("SHParseDisplayName") 355 | } 356 | 357 | func DragAcceptFiles(hWnd HWND, fAccept bool) bool { 358 | ret, _, _ := syscall.Syscall(dragAcceptFiles.Addr(), 2, 359 | uintptr(hWnd), 360 | uintptr(BoolToBOOL(fAccept)), 361 | 0) 362 | 363 | return ret != 0 364 | } 365 | 366 | func DragQueryFile(hDrop HDROP, iFile uint, lpszFile *uint16, cch uint) uint { 367 | ret, _, _ := syscall.Syscall6(dragQueryFile.Addr(), 4, 368 | uintptr(hDrop), 369 | uintptr(iFile), 370 | uintptr(unsafe.Pointer(lpszFile)), 371 | uintptr(cch), 372 | 0, 373 | 0) 374 | 375 | return uint(ret) 376 | } 377 | 378 | func DragFinish(hDrop HDROP) { 379 | syscall.Syscall(dragAcceptFiles.Addr(), 1, 380 | uintptr(hDrop), 381 | 0, 382 | 0) 383 | } 384 | 385 | func ExtractIcon(hInst HINSTANCE, exeFileName *uint16, iconIndex int32) HICON { 386 | ret, _, _ := syscall.Syscall(extractIcon.Addr(), 3, 387 | uintptr(hInst), 388 | uintptr(unsafe.Pointer(exeFileName)), 389 | uintptr(iconIndex)) 390 | 391 | return HICON(ret) 392 | } 393 | 394 | func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr { 395 | ret, _, _ := syscall.Syscall(shBrowseForFolder.Addr(), 1, 396 | uintptr(unsafe.Pointer(lpbi)), 397 | 0, 398 | 0) 399 | 400 | return ret 401 | } 402 | 403 | func SHDefExtractIcon(pszIconFile *uint16, iIndex int32, uFlags uint32, phiconLarge, phiconSmall *HICON, nIconSize uint32) HRESULT { 404 | ret, _, _ := syscall.Syscall6(shDefExtractIcon.Addr(), 6, 405 | uintptr(unsafe.Pointer(pszIconFile)), 406 | uintptr(iIndex), 407 | uintptr(uFlags), 408 | uintptr(unsafe.Pointer(phiconLarge)), 409 | uintptr(unsafe.Pointer(phiconSmall)), 410 | uintptr(nIconSize)) 411 | 412 | return HRESULT(ret) 413 | } 414 | 415 | func SHGetFileInfo(pszPath *uint16, dwFileAttributes uint32, psfi *SHFILEINFO, cbFileInfo, uFlags uint32) uintptr { 416 | ret, _, _ := syscall.Syscall6(shGetFileInfo.Addr(), 5, 417 | uintptr(unsafe.Pointer(pszPath)), 418 | uintptr(dwFileAttributes), 419 | uintptr(unsafe.Pointer(psfi)), 420 | uintptr(cbFileInfo), 421 | uintptr(uFlags), 422 | 0) 423 | 424 | return ret 425 | } 426 | 427 | func SHGetPathFromIDList(pidl uintptr, pszPath *uint16) bool { 428 | ret, _, _ := syscall.Syscall(shGetPathFromIDList.Addr(), 2, 429 | pidl, 430 | uintptr(unsafe.Pointer(pszPath)), 431 | 0) 432 | 433 | return ret != 0 434 | } 435 | 436 | func SHGetSpecialFolderPath(hwndOwner HWND, lpszPath *uint16, csidl CSIDL, fCreate bool) bool { 437 | ret, _, _ := syscall.Syscall6(shGetSpecialFolderPath.Addr(), 4, 438 | uintptr(hwndOwner), 439 | uintptr(unsafe.Pointer(lpszPath)), 440 | uintptr(csidl), 441 | uintptr(BoolToBOOL(fCreate)), 442 | 0, 443 | 0) 444 | 445 | return ret != 0 446 | } 447 | 448 | func SHParseDisplayName(pszName *uint16, pbc uintptr, ppidl *uintptr, sfgaoIn uint32, psfgaoOut *uint32) HRESULT { 449 | ret, _, _ := syscall.Syscall6(shParseDisplayName.Addr(), 5, 450 | uintptr(unsafe.Pointer(pszName)), 451 | pbc, 452 | uintptr(unsafe.Pointer(ppidl)), 453 | 0, 454 | uintptr(unsafe.Pointer(psfgaoOut)), 455 | 0) 456 | 457 | return HRESULT(ret) 458 | } 459 | 460 | func SHGetStockIconInfo(stockIconId int32, uFlags uint32, stockIcon *SHSTOCKICONINFO) HRESULT { 461 | if shGetStockIconInfo.Find() != nil { 462 | return HRESULT(0) 463 | } 464 | ret, _, _ := syscall.Syscall6(shGetStockIconInfo.Addr(), 3, 465 | uintptr(stockIconId), 466 | uintptr(uFlags), 467 | uintptr(unsafe.Pointer(stockIcon)), 468 | 0, 469 | 0, 470 | 0, 471 | ) 472 | return HRESULT(ret) 473 | } 474 | 475 | func ShellExecute(hWnd HWND, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int) bool { 476 | ret, _, _ := syscall.Syscall6(shellExecute.Addr(), 6, 477 | uintptr(hWnd), 478 | uintptr(unsafe.Pointer(verb)), 479 | uintptr(unsafe.Pointer(file)), 480 | uintptr(unsafe.Pointer(args)), 481 | uintptr(unsafe.Pointer(cwd)), 482 | uintptr(showCmd), 483 | ) 484 | return ret != 0 485 | } 486 | 487 | func Shell_NotifyIcon(dwMessage uint32, lpdata *NOTIFYICONDATA) bool { 488 | ret, _, _ := syscall.Syscall(shell_NotifyIcon.Addr(), 2, 489 | uintptr(dwMessage), 490 | uintptr(unsafe.Pointer(lpdata)), 491 | 0) 492 | 493 | return ret != 0 494 | } 495 | -------------------------------------------------------------------------------- /shobj.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | var ( 15 | CLSID_TaskbarList = CLSID{0x56FDF344, 0xFD6D, 0x11d0, [8]byte{0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}} 16 | IID_ITaskbarList3 = IID{0xea1afb91, 0x9e28, 0x4b86, [8]byte{0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf}} 17 | ) 18 | 19 | //TBPFLAG 20 | const ( 21 | TBPF_NOPROGRESS = 0 22 | TBPF_INDETERMINATE = 0x1 23 | TBPF_NORMAL = 0x2 24 | TBPF_ERROR = 0x4 25 | TBPF_PAUSED = 0x8 26 | ) 27 | 28 | type ITaskbarList3Vtbl struct { 29 | QueryInterface uintptr 30 | AddRef uintptr 31 | Release uintptr 32 | HrInit uintptr 33 | AddTab uintptr 34 | DeleteTab uintptr 35 | ActivateTab uintptr 36 | SetActiveAlt uintptr 37 | MarkFullscreenWindow uintptr 38 | SetProgressValue uintptr 39 | SetProgressState uintptr 40 | RegisterTab uintptr 41 | UnregisterTab uintptr 42 | SetTabOrder uintptr 43 | SetTabActive uintptr 44 | ThumbBarAddButtons uintptr 45 | ThumbBarUpdateButtons uintptr 46 | ThumbBarSetImageList uintptr 47 | SetOverlayIcon uintptr 48 | SetThumbnailTooltip uintptr 49 | SetThumbnailClip uintptr 50 | } 51 | 52 | type ITaskbarList3 struct { 53 | LpVtbl *ITaskbarList3Vtbl 54 | } 55 | 56 | func (obj *ITaskbarList3) SetProgressState(hwnd HWND, state int) HRESULT { 57 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetProgressState, 3, 58 | uintptr(unsafe.Pointer(obj)), 59 | uintptr(hwnd), 60 | uintptr(state)) 61 | return HRESULT(ret) 62 | } 63 | 64 | func (obj *ITaskbarList3) SetOverlayIcon(hwnd HWND, icon HICON, description *uint16) HRESULT { 65 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetOverlayIcon, 4, 66 | uintptr(unsafe.Pointer(obj)), 67 | uintptr(hwnd), 68 | uintptr(icon), 69 | uintptr(unsafe.Pointer(description)), 70 | 0, 71 | 0) 72 | return HRESULT(ret) 73 | } 74 | -------------------------------------------------------------------------------- /shobj_32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,386 windows,arm 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func (obj *ITaskbarList3) SetProgressValue(hwnd HWND, current uint32, length uint32) HRESULT { 15 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetProgressValue, 6, 16 | uintptr(unsafe.Pointer(obj)), 17 | uintptr(hwnd), 18 | uintptr(current), 19 | 0, 20 | uintptr(length), 21 | 0) 22 | 23 | return HRESULT(ret) 24 | } 25 | -------------------------------------------------------------------------------- /shobj_64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,amd64 windows,arm64 6 | 7 | package win 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func (obj *ITaskbarList3) SetProgressValue(hwnd HWND, current uint32, length uint32) HRESULT { 15 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetProgressValue, 4, 16 | uintptr(unsafe.Pointer(obj)), 17 | uintptr(hwnd), 18 | uintptr(current), 19 | uintptr(length), 20 | 0, 21 | 0) 22 | 23 | return HRESULT(ret) 24 | } 25 | -------------------------------------------------------------------------------- /statusbar.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | // Styles 10 | const ( 11 | SBARS_SIZEGRIP = 0x100 12 | SBARS_TOOLTIPS = 0x800 13 | ) 14 | 15 | // Messages 16 | const ( 17 | SB_SETPARTS = WM_USER + 4 18 | SB_GETPARTS = WM_USER + 6 19 | SB_GETBORDERS = WM_USER + 7 20 | SB_SETMINHEIGHT = WM_USER + 8 21 | SB_SIMPLE = WM_USER + 9 22 | SB_GETRECT = WM_USER + 10 23 | SB_SETTEXT = WM_USER + 11 24 | SB_GETTEXTLENGTH = WM_USER + 12 25 | SB_GETTEXT = WM_USER + 13 26 | SB_ISSIMPLE = WM_USER + 14 27 | SB_SETICON = WM_USER + 15 28 | SB_SETTIPTEXT = WM_USER + 17 29 | SB_GETTIPTEXT = WM_USER + 19 30 | SB_GETICON = WM_USER + 20 31 | SB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 32 | SB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 33 | SB_SETBKCOLOR = CCM_SETBKCOLOR 34 | ) 35 | 36 | // SB_SETTEXT options 37 | const ( 38 | SBT_NOBORDERS = 0x100 39 | SBT_POPOUT = 0x200 40 | SBT_RTLREADING = 0x400 41 | SBT_NOTABPARSING = 0x800 42 | SBT_OWNERDRAW = 0x1000 43 | ) 44 | 45 | const ( 46 | SBN_FIRST = -880 47 | SBN_SIMPLEMODECHANGE = SBN_FIRST - 0 48 | ) 49 | 50 | const SB_SIMPLEID = 0xff 51 | -------------------------------------------------------------------------------- /syslink.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | const ( 10 | INVALID_LINK_INDEX = -1 11 | MAX_LINKID_TEXT = 48 12 | L_MAX_URL_LENGTH = 2048 + 32 + len("://") 13 | WC_LINK = "SysLink" 14 | ) 15 | 16 | const ( 17 | LWS_TRANSPARENT = 0x0001 18 | LWS_IGNORERETURN = 0x0002 19 | LWS_NOPREFIX = 0x0004 20 | LWS_USEVISUALSTYLE = 0x0008 21 | LWS_USECUSTOMTEXT = 0x0010 22 | LWS_RIGHT = 0x0020 23 | ) 24 | 25 | const ( 26 | LIF_ITEMINDEX = 0x00000001 27 | LIF_STATE = 0x00000002 28 | LIF_ITEMID = 0x00000004 29 | LIF_URL = 0x00000008 30 | ) 31 | 32 | const ( 33 | LIS_FOCUSED = 0x00000001 34 | LIS_ENABLED = 0x00000002 35 | LIS_VISITED = 0x00000004 36 | LIS_HOTTRACK = 0x00000008 37 | LIS_DEFAULTCOLORS = 0x00000010 38 | ) 39 | 40 | const ( 41 | LM_HITTEST = WM_USER + 0x300 42 | LM_GETIDEALHEIGHT = WM_USER + 0x301 43 | LM_SETITEM = WM_USER + 0x302 44 | LM_GETITEM = WM_USER + 0x303 45 | LM_GETIDEALSIZE = LM_GETIDEALHEIGHT 46 | ) 47 | 48 | type LITEM struct { 49 | Mask uint32 50 | ILink int32 51 | State uint32 52 | StateMask uint32 53 | SzID [MAX_LINKID_TEXT]uint16 54 | SzUrl [L_MAX_URL_LENGTH]uint16 55 | } 56 | 57 | type LHITTESTINFO struct { 58 | Pt POINT 59 | Item LITEM 60 | } 61 | 62 | type NMLINK struct { 63 | Hdr NMHDR 64 | Item LITEM 65 | } 66 | -------------------------------------------------------------------------------- /tab.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | const TCM_FIRST = 0x1300 10 | const TCN_FIRST = -550 11 | 12 | const ( 13 | TCS_SCROLLOPPOSITE = 0x0001 14 | TCS_BOTTOM = 0x0002 15 | TCS_RIGHT = 0x0002 16 | TCS_MULTISELECT = 0x0004 17 | TCS_FLATBUTTONS = 0x0008 18 | TCS_FORCEICONLEFT = 0x0010 19 | TCS_FORCELABELLEFT = 0x0020 20 | TCS_HOTTRACK = 0x0040 21 | TCS_VERTICAL = 0x0080 22 | TCS_TABS = 0x0000 23 | TCS_BUTTONS = 0x0100 24 | TCS_SINGLELINE = 0x0000 25 | TCS_MULTILINE = 0x0200 26 | TCS_RIGHTJUSTIFY = 0x0000 27 | TCS_FIXEDWIDTH = 0x0400 28 | TCS_RAGGEDRIGHT = 0x0800 29 | TCS_FOCUSONBUTTONDOWN = 0x1000 30 | TCS_OWNERDRAWFIXED = 0x2000 31 | TCS_TOOLTIPS = 0x4000 32 | TCS_FOCUSNEVER = 0x8000 33 | ) 34 | 35 | const ( 36 | TCS_EX_FLATSEPARATORS = 0x00000001 37 | TCS_EX_REGISTERDROP = 0x00000002 38 | ) 39 | 40 | const ( 41 | TCM_GETIMAGELIST = TCM_FIRST + 2 42 | TCM_SETIMAGELIST = TCM_FIRST + 3 43 | TCM_GETITEMCOUNT = TCM_FIRST + 4 44 | TCM_GETITEM = TCM_FIRST + 60 45 | TCM_SETITEM = TCM_FIRST + 61 46 | TCM_INSERTITEM = TCM_FIRST + 62 47 | TCM_DELETEITEM = TCM_FIRST + 8 48 | TCM_DELETEALLITEMS = TCM_FIRST + 9 49 | TCM_GETITEMRECT = TCM_FIRST + 10 50 | TCM_GETCURSEL = TCM_FIRST + 11 51 | TCM_SETCURSEL = TCM_FIRST + 12 52 | TCM_HITTEST = TCM_FIRST + 13 53 | TCM_SETITEMEXTRA = TCM_FIRST + 14 54 | TCM_ADJUSTRECT = TCM_FIRST + 40 55 | TCM_SETITEMSIZE = TCM_FIRST + 41 56 | TCM_REMOVEIMAGE = TCM_FIRST + 42 57 | TCM_SETPADDING = TCM_FIRST + 43 58 | TCM_GETROWCOUNT = TCM_FIRST + 44 59 | TCM_GETTOOLTIPS = TCM_FIRST + 45 60 | TCM_SETTOOLTIPS = TCM_FIRST + 46 61 | TCM_GETCURFOCUS = TCM_FIRST + 47 62 | TCM_SETCURFOCUS = TCM_FIRST + 48 63 | TCM_SETMINTABWIDTH = TCM_FIRST + 49 64 | TCM_DESELECTALL = TCM_FIRST + 50 65 | TCM_HIGHLIGHTITEM = TCM_FIRST + 51 66 | TCM_SETEXTENDEDSTYLE = TCM_FIRST + 52 67 | TCM_GETEXTENDEDSTYLE = TCM_FIRST + 53 68 | TCM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 69 | TCM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 70 | ) 71 | 72 | const ( 73 | TCIF_TEXT = 0x0001 74 | TCIF_IMAGE = 0x0002 75 | TCIF_RTLREADING = 0x0004 76 | TCIF_PARAM = 0x0008 77 | TCIF_STATE = 0x0010 78 | ) 79 | 80 | const ( 81 | TCIS_BUTTONPRESSED = 0x0001 82 | TCIS_HIGHLIGHTED = 0x0002 83 | ) 84 | 85 | const ( 86 | TCHT_NOWHERE = 0x0001 87 | TCHT_ONITEMICON = 0x0002 88 | TCHT_ONITEMLABEL = 0x0004 89 | TCHT_ONITEM = TCHT_ONITEMICON | TCHT_ONITEMLABEL 90 | ) 91 | 92 | const ( 93 | TCN_KEYDOWN = TCN_FIRST - 0 94 | TCN_SELCHANGE = TCN_FIRST - 1 95 | TCN_SELCHANGING = TCN_FIRST - 2 96 | TCN_GETOBJECT = TCN_FIRST - 3 97 | TCN_FOCUSCHANGE = TCN_FIRST - 4 98 | ) 99 | 100 | type TCITEMHEADER struct { 101 | Mask uint32 102 | LpReserved1 uint32 103 | LpReserved2 uint32 104 | PszText *uint16 105 | CchTextMax int32 106 | IImage int32 107 | } 108 | 109 | type TCITEM struct { 110 | Mask uint32 111 | DwState uint32 112 | DwStateMask uint32 113 | PszText *uint16 114 | CchTextMax int32 115 | IImage int32 116 | LParam uintptr 117 | } 118 | 119 | type TCHITTESTINFO struct { 120 | Pt POINT 121 | flags uint32 122 | } 123 | 124 | type NMTCKEYDOWN struct { 125 | Hdr NMHDR 126 | WVKey uint16 127 | Flags uint32 128 | } 129 | -------------------------------------------------------------------------------- /toolbar.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | // ToolBar messages 10 | const ( 11 | TB_THUMBPOSITION = 4 12 | TB_THUMBTRACK = 5 13 | TB_ENDTRACK = 8 14 | TB_ENABLEBUTTON = WM_USER + 1 15 | TB_CHECKBUTTON = WM_USER + 2 16 | TB_PRESSBUTTON = WM_USER + 3 17 | TB_HIDEBUTTON = WM_USER + 4 18 | TB_INDETERMINATE = WM_USER + 5 19 | TB_MARKBUTTON = WM_USER + 6 20 | TB_ISBUTTONENABLED = WM_USER + 9 21 | TB_ISBUTTONCHECKED = WM_USER + 10 22 | TB_ISBUTTONPRESSED = WM_USER + 11 23 | TB_ISBUTTONHIDDEN = WM_USER + 12 24 | TB_ISBUTTONINDETERMINATE = WM_USER + 13 25 | TB_ISBUTTONHIGHLIGHTED = WM_USER + 14 26 | TB_SETSTATE = WM_USER + 17 27 | TB_GETSTATE = WM_USER + 18 28 | TB_ADDBITMAP = WM_USER + 19 29 | TB_DELETEBUTTON = WM_USER + 22 30 | TB_GETBUTTON = WM_USER + 23 31 | TB_BUTTONCOUNT = WM_USER + 24 32 | TB_COMMANDTOINDEX = WM_USER + 25 33 | TB_SAVERESTORE = WM_USER + 76 34 | TB_CUSTOMIZE = WM_USER + 27 35 | TB_ADDSTRING = WM_USER + 77 36 | TB_GETITEMRECT = WM_USER + 29 37 | TB_BUTTONSTRUCTSIZE = WM_USER + 30 38 | TB_SETBUTTONSIZE = WM_USER + 31 39 | TB_SETBITMAPSIZE = WM_USER + 32 40 | TB_AUTOSIZE = WM_USER + 33 41 | TB_GETTOOLTIPS = WM_USER + 35 42 | TB_SETTOOLTIPS = WM_USER + 36 43 | TB_SETPARENT = WM_USER + 37 44 | TB_SETROWS = WM_USER + 39 45 | TB_GETROWS = WM_USER + 40 46 | TB_GETBITMAPFLAGS = WM_USER + 41 47 | TB_SETCMDID = WM_USER + 42 48 | TB_CHANGEBITMAP = WM_USER + 43 49 | TB_GETBITMAP = WM_USER + 44 50 | TB_GETBUTTONTEXT = WM_USER + 75 51 | TB_REPLACEBITMAP = WM_USER + 46 52 | TB_GETBUTTONSIZE = WM_USER + 58 53 | TB_SETBUTTONWIDTH = WM_USER + 59 54 | TB_SETINDENT = WM_USER + 47 55 | TB_SETIMAGELIST = WM_USER + 48 56 | TB_GETIMAGELIST = WM_USER + 49 57 | TB_LOADIMAGES = WM_USER + 50 58 | TB_GETRECT = WM_USER + 51 59 | TB_SETHOTIMAGELIST = WM_USER + 52 60 | TB_GETHOTIMAGELIST = WM_USER + 53 61 | TB_SETDISABLEDIMAGELIST = WM_USER + 54 62 | TB_GETDISABLEDIMAGELIST = WM_USER + 55 63 | TB_SETSTYLE = WM_USER + 56 64 | TB_GETSTYLE = WM_USER + 57 65 | TB_SETMAXTEXTROWS = WM_USER + 60 66 | TB_GETTEXTROWS = WM_USER + 61 67 | TB_GETOBJECT = WM_USER + 62 68 | TB_GETBUTTONINFO = WM_USER + 63 69 | TB_SETBUTTONINFO = WM_USER + 64 70 | TB_INSERTBUTTON = WM_USER + 67 71 | TB_ADDBUTTONS = WM_USER + 68 72 | TB_HITTEST = WM_USER + 69 73 | TB_SETDRAWTEXTFLAGS = WM_USER + 70 74 | TB_GETHOTITEM = WM_USER + 71 75 | TB_SETHOTITEM = WM_USER + 72 76 | TB_SETANCHORHIGHLIGHT = WM_USER + 73 77 | TB_GETANCHORHIGHLIGHT = WM_USER + 74 78 | TB_GETINSERTMARK = WM_USER + 79 79 | TB_SETINSERTMARK = WM_USER + 80 80 | TB_INSERTMARKHITTEST = WM_USER + 81 81 | TB_MOVEBUTTON = WM_USER + 82 82 | TB_GETMAXSIZE = WM_USER + 83 83 | TB_SETEXTENDEDSTYLE = WM_USER + 84 84 | TB_GETEXTENDEDSTYLE = WM_USER + 85 85 | TB_GETPADDING = WM_USER + 86 86 | TB_SETPADDING = WM_USER + 87 87 | TB_SETINSERTMARKCOLOR = WM_USER + 88 88 | TB_GETINSERTMARKCOLOR = WM_USER + 89 89 | TB_MAPACCELERATOR = WM_USER + 90 90 | TB_GETSTRING = WM_USER + 91 91 | TB_GETIDEALSIZE = WM_USER + 99 92 | TB_GETMETRICS = WM_USER + 101 93 | TB_SETCOLORSCHEME = CCM_SETCOLORSCHEME 94 | TB_GETCOLORSCHEME = CCM_GETCOLORSCHEME 95 | TB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 96 | TB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 97 | ) 98 | 99 | // ToolBar notifications 100 | const ( 101 | TBN_FIRST = -700 102 | TBN_DROPDOWN = TBN_FIRST - 10 103 | ) 104 | 105 | // TBN_DROPDOWN return codes 106 | const ( 107 | TBDDRET_DEFAULT = 0 108 | TBDDRET_NODEFAULT = 1 109 | TBDDRET_TREATPRESSED = 2 110 | ) 111 | 112 | // ToolBar state constants 113 | const ( 114 | TBSTATE_CHECKED = 1 115 | TBSTATE_PRESSED = 2 116 | TBSTATE_ENABLED = 4 117 | TBSTATE_HIDDEN = 8 118 | TBSTATE_INDETERMINATE = 16 119 | TBSTATE_WRAP = 32 120 | TBSTATE_ELLIPSES = 0x40 121 | TBSTATE_MARKED = 0x0080 122 | ) 123 | 124 | // ToolBar style constants 125 | const ( 126 | TBSTYLE_BUTTON = 0 127 | TBSTYLE_SEP = 1 128 | TBSTYLE_CHECK = 2 129 | TBSTYLE_GROUP = 4 130 | TBSTYLE_CHECKGROUP = TBSTYLE_GROUP | TBSTYLE_CHECK 131 | TBSTYLE_DROPDOWN = 8 132 | TBSTYLE_AUTOSIZE = 16 133 | TBSTYLE_NOPREFIX = 32 134 | TBSTYLE_TOOLTIPS = 256 135 | TBSTYLE_WRAPABLE = 512 136 | TBSTYLE_ALTDRAG = 1024 137 | TBSTYLE_FLAT = 2048 138 | TBSTYLE_LIST = 4096 139 | TBSTYLE_CUSTOMERASE = 8192 140 | TBSTYLE_REGISTERDROP = 0x4000 141 | TBSTYLE_TRANSPARENT = 0x8000 142 | ) 143 | 144 | // ToolBar extended style constants 145 | const ( 146 | TBSTYLE_EX_DRAWDDARROWS = 0x00000001 147 | TBSTYLE_EX_MIXEDBUTTONS = 8 148 | TBSTYLE_EX_HIDECLIPPEDBUTTONS = 16 149 | TBSTYLE_EX_DOUBLEBUFFER = 0x80 150 | ) 151 | 152 | // ToolBar button style constants 153 | const ( 154 | BTNS_BUTTON = TBSTYLE_BUTTON 155 | BTNS_SEP = TBSTYLE_SEP 156 | BTNS_CHECK = TBSTYLE_CHECK 157 | BTNS_GROUP = TBSTYLE_GROUP 158 | BTNS_CHECKGROUP = TBSTYLE_CHECKGROUP 159 | BTNS_DROPDOWN = TBSTYLE_DROPDOWN 160 | BTNS_AUTOSIZE = TBSTYLE_AUTOSIZE 161 | BTNS_NOPREFIX = TBSTYLE_NOPREFIX 162 | BTNS_WHOLEDROPDOWN = 0x0080 163 | BTNS_SHOWTEXT = 0x0040 164 | ) 165 | 166 | // TBBUTTONINFO mask flags 167 | const ( 168 | TBIF_IMAGE = 0x00000001 169 | TBIF_TEXT = 0x00000002 170 | TBIF_STATE = 0x00000004 171 | TBIF_STYLE = 0x00000008 172 | TBIF_LPARAM = 0x00000010 173 | TBIF_COMMAND = 0x00000020 174 | TBIF_SIZE = 0x00000040 175 | TBIF_BYINDEX = 0x80000000 176 | ) 177 | 178 | // TBMETRICS mask flags 179 | const ( 180 | TBMF_PAD = 0x00000001 181 | TBMF_BARPAD = 0x00000002 182 | TBMF_BUTTONSPACING = 0x00000004 183 | ) 184 | 185 | type NMMOUSE struct { 186 | Hdr NMHDR 187 | DwItemSpec uintptr 188 | DwItemData uintptr 189 | Pt POINT 190 | DwHitInfo uintptr 191 | } 192 | 193 | type NMTOOLBAR struct { 194 | Hdr NMHDR 195 | IItem int32 196 | TbButton TBBUTTON 197 | CchText int32 198 | PszText *uint16 199 | RcButton RECT 200 | } 201 | 202 | type TBBUTTON struct { 203 | IBitmap int32 204 | IdCommand int32 205 | FsState byte 206 | FsStyle byte 207 | //#ifdef _WIN64 208 | // BYTE bReserved[6] // padding for alignment 209 | //#elif defined(_WIN32) 210 | BReserved [2]byte // padding for alignment 211 | //#endif 212 | DwData uintptr 213 | IString uintptr 214 | } 215 | 216 | type TBBUTTONINFO struct { 217 | CbSize uint32 218 | DwMask uint32 219 | IdCommand int32 220 | IImage int32 221 | FsState byte 222 | FsStyle byte 223 | Cx uint16 224 | LParam uintptr 225 | PszText uintptr 226 | CchText int32 227 | } 228 | 229 | type TBMETRICS struct { 230 | CbSize uint32 231 | DwMask uint32 232 | CxPad int32 233 | CyPad int32 234 | CxBarPad int32 235 | CyBarPad int32 236 | CxButtonSpacing int32 237 | CyButtonSpacing int32 238 | } 239 | -------------------------------------------------------------------------------- /tooltip.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | // ToolTip styles 14 | const ( 15 | TTS_ALWAYSTIP = 0x01 16 | TTS_NOPREFIX = 0x02 17 | TTS_NOANIMATE = 0x10 18 | TTS_NOFADE = 0x20 19 | TTS_BALLOON = 0x40 20 | TTS_CLOSE = 0x80 21 | ) 22 | 23 | // ToolTip messages 24 | const ( 25 | TTM_ACTIVATE = WM_USER + 1 26 | TTM_SETDELAYTIME = WM_USER + 3 27 | TTM_ADDTOOL = WM_USER + 50 28 | TTM_DELTOOL = WM_USER + 51 29 | TTM_NEWTOOLRECT = WM_USER + 52 30 | TTM_RELAYEVENT = WM_USER + 7 31 | TTM_GETTOOLINFO = WM_USER + 53 32 | TTM_SETTOOLINFO = WM_USER + 54 33 | TTM_HITTEST = WM_USER + 55 34 | TTM_GETTEXT = WM_USER + 56 35 | TTM_UPDATETIPTEXT = WM_USER + 57 36 | TTM_GETTOOLCOUNT = WM_USER + 13 37 | TTM_ENUMTOOLS = WM_USER + 58 38 | TTM_GETCURRENTTOOL = WM_USER + 59 39 | TTM_WINDOWFROMPOINT = WM_USER + 16 40 | TTM_TRACKACTIVATE = WM_USER + 17 41 | TTM_TRACKPOSITION = WM_USER + 18 42 | TTM_SETTIPBKCOLOR = WM_USER + 19 43 | TTM_SETTIPTEXTCOLOR = WM_USER + 20 44 | TTM_GETDELAYTIME = WM_USER + 21 45 | TTM_GETTIPBKCOLOR = WM_USER + 22 46 | TTM_GETTIPTEXTCOLOR = WM_USER + 23 47 | TTM_SETMAXTIPWIDTH = WM_USER + 24 48 | TTM_GETMAXTIPWIDTH = WM_USER + 25 49 | TTM_SETMARGIN = WM_USER + 26 50 | TTM_GETMARGIN = WM_USER + 27 51 | TTM_POP = WM_USER + 28 52 | TTM_UPDATE = WM_USER + 29 53 | TTM_GETBUBBLESIZE = WM_USER + 30 54 | TTM_ADJUSTRECT = WM_USER + 31 55 | TTM_SETTITLE = WM_USER + 33 56 | TTM_POPUP = WM_USER + 34 57 | TTM_GETTITLE = WM_USER + 35 58 | ) 59 | 60 | // ToolTip flags 61 | const ( 62 | TTF_IDISHWND = 0x0001 63 | TTF_CENTERTIP = 0x0002 64 | TTF_RTLREADING = 0x0004 65 | TTF_SUBCLASS = 0x0010 66 | TTF_TRACK = 0x0020 67 | TTF_ABSOLUTE = 0x0080 68 | TTF_TRANSPARENT = 0x0100 69 | TTF_DI_SETITEM = 0x8000 70 | ) 71 | 72 | // ToolTip icons 73 | const ( 74 | TTI_NONE = 0 75 | TTI_INFO = 1 76 | TTI_WARNING = 2 77 | TTI_ERROR = 3 78 | ) 79 | 80 | type TOOLINFO struct { 81 | CbSize uint32 82 | UFlags uint32 83 | Hwnd HWND 84 | UId uintptr 85 | Rect RECT 86 | Hinst HINSTANCE 87 | LpszText *uint16 88 | LParam uintptr 89 | LpReserved unsafe.Pointer 90 | } 91 | 92 | type TTGETTITLE struct { 93 | DwSize uint32 94 | UTitleBitmap uint32 95 | Cch uint32 96 | PszTitle *uint16 97 | } 98 | -------------------------------------------------------------------------------- /treeview.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | // TreeView styles 10 | const ( 11 | TVS_HASBUTTONS = 0x0001 12 | TVS_HASLINES = 0x0002 13 | TVS_LINESATROOT = 0x0004 14 | TVS_EDITLABELS = 0x0008 15 | TVS_DISABLEDRAGDROP = 0x0010 16 | TVS_SHOWSELALWAYS = 0x0020 17 | TVS_RTLREADING = 0x0040 18 | TVS_NOTOOLTIPS = 0x0080 19 | TVS_CHECKBOXES = 0x0100 20 | TVS_TRACKSELECT = 0x0200 21 | TVS_SINGLEEXPAND = 0x0400 22 | TVS_INFOTIP = 0x0800 23 | TVS_FULLROWSELECT = 0x1000 24 | TVS_NOSCROLL = 0x2000 25 | TVS_NONEVENHEIGHT = 0x4000 26 | TVS_NOHSCROLL = 0x8000 27 | ) 28 | 29 | const ( 30 | TVS_EX_NOSINGLECOLLAPSE = 0x0001 31 | TVS_EX_MULTISELECT = 0x0002 32 | TVS_EX_DOUBLEBUFFER = 0x0004 33 | TVS_EX_NOINDENTSTATE = 0x0008 34 | TVS_EX_RICHTOOLTIP = 0x0010 35 | TVS_EX_AUTOHSCROLL = 0x0020 36 | TVS_EX_FADEINOUTEXPANDOS = 0x0040 37 | TVS_EX_PARTIALCHECKBOXES = 0x0080 38 | TVS_EX_EXCLUSIONCHECKBOXES = 0x0100 39 | TVS_EX_DIMMEDCHECKBOXES = 0x0200 40 | TVS_EX_DRAWIMAGEASYNC = 0x0400 41 | ) 42 | 43 | const ( 44 | TVIF_TEXT = 0x0001 45 | TVIF_IMAGE = 0x0002 46 | TVIF_PARAM = 0x0004 47 | TVIF_STATE = 0x0008 48 | TVIF_HANDLE = 0x0010 49 | TVIF_SELECTEDIMAGE = 0x0020 50 | TVIF_CHILDREN = 0x0040 51 | TVIF_INTEGRAL = 0x0080 52 | TVIF_STATEEX = 0x0100 53 | TVIF_EXPANDEDIMAGE = 0x0200 54 | ) 55 | 56 | const ( 57 | TVIS_SELECTED = 0x0002 58 | TVIS_CUT = 0x0004 59 | TVIS_DROPHILITED = 0x0008 60 | TVIS_BOLD = 0x0010 61 | TVIS_EXPANDED = 0x0020 62 | TVIS_EXPANDEDONCE = 0x0040 63 | TVIS_EXPANDPARTIAL = 0x0080 64 | TVIS_OVERLAYMASK = 0x0F00 65 | TVIS_STATEIMAGEMASK = 0xF000 66 | TVIS_USERMASK = 0xF000 67 | ) 68 | 69 | const ( 70 | TVIS_EX_FLAT = 0x0001 71 | TVIS_EX_DISABLED = 0x0002 72 | TVIS_EX_ALL = 0x0002 73 | ) 74 | 75 | const ( 76 | TVI_ROOT = ^HTREEITEM(0xffff) 77 | TVI_FIRST = ^HTREEITEM(0xfffe) 78 | TVI_LAST = ^HTREEITEM(0xfffd) 79 | TVI_SORT = ^HTREEITEM(0xfffc) 80 | ) 81 | 82 | // TVM_EXPAND action flags 83 | const ( 84 | TVE_COLLAPSE = 0x0001 85 | TVE_EXPAND = 0x0002 86 | TVE_TOGGLE = 0x0003 87 | TVE_EXPANDPARTIAL = 0x4000 88 | TVE_COLLAPSERESET = 0x8000 89 | ) 90 | 91 | const ( 92 | TVGN_CARET = 9 93 | ) 94 | 95 | // TreeView messages 96 | const ( 97 | TV_FIRST = 0x1100 98 | 99 | TVM_INSERTITEM = TV_FIRST + 50 100 | TVM_DELETEITEM = TV_FIRST + 1 101 | TVM_EXPAND = TV_FIRST + 2 102 | TVM_GETITEMRECT = TV_FIRST + 4 103 | TVM_GETCOUNT = TV_FIRST + 5 104 | TVM_GETINDENT = TV_FIRST + 6 105 | TVM_SETINDENT = TV_FIRST + 7 106 | TVM_GETIMAGELIST = TV_FIRST + 8 107 | TVM_SETIMAGELIST = TV_FIRST + 9 108 | TVM_GETNEXTITEM = TV_FIRST + 10 109 | TVM_SELECTITEM = TV_FIRST + 11 110 | TVM_GETITEM = TV_FIRST + 62 111 | TVM_SETITEM = TV_FIRST + 63 112 | TVM_EDITLABEL = TV_FIRST + 65 113 | TVM_GETEDITCONTROL = TV_FIRST + 15 114 | TVM_GETVISIBLECOUNT = TV_FIRST + 16 115 | TVM_HITTEST = TV_FIRST + 17 116 | TVM_CREATEDRAGIMAGE = TV_FIRST + 18 117 | TVM_SORTCHILDREN = TV_FIRST + 19 118 | TVM_ENSUREVISIBLE = TV_FIRST + 20 119 | TVM_SORTCHILDRENCB = TV_FIRST + 21 120 | TVM_ENDEDITLABELNOW = TV_FIRST + 22 121 | TVM_GETISEARCHSTRING = TV_FIRST + 64 122 | TVM_SETTOOLTIPS = TV_FIRST + 24 123 | TVM_GETTOOLTIPS = TV_FIRST + 25 124 | TVM_SETINSERTMARK = TV_FIRST + 26 125 | TVM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 126 | TVM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 127 | TVM_SETITEMHEIGHT = TV_FIRST + 27 128 | TVM_GETITEMHEIGHT = TV_FIRST + 28 129 | TVM_SETBKCOLOR = TV_FIRST + 29 130 | TVM_SETTEXTCOLOR = TV_FIRST + 30 131 | TVM_GETBKCOLOR = TV_FIRST + 31 132 | TVM_GETTEXTCOLOR = TV_FIRST + 32 133 | TVM_SETSCROLLTIME = TV_FIRST + 33 134 | TVM_GETSCROLLTIME = TV_FIRST + 34 135 | TVM_SETINSERTMARKCOLOR = TV_FIRST + 37 136 | TVM_GETINSERTMARKCOLOR = TV_FIRST + 38 137 | TVM_GETITEMSTATE = TV_FIRST + 39 138 | TVM_SETLINECOLOR = TV_FIRST + 40 139 | TVM_GETLINECOLOR = TV_FIRST + 41 140 | TVM_MAPACCIDTOHTREEITEM = TV_FIRST + 42 141 | TVM_MAPHTREEITEMTOACCID = TV_FIRST + 43 142 | TVM_SETEXTENDEDSTYLE = TV_FIRST + 44 143 | TVM_GETEXTENDEDSTYLE = TV_FIRST + 45 144 | TVM_SETAUTOSCROLLINFO = TV_FIRST + 59 145 | ) 146 | 147 | // TreeView notifications 148 | const ( 149 | TVN_FIRST = ^uint32(399) 150 | 151 | TVN_SELCHANGING = TVN_FIRST - 50 152 | TVN_SELCHANGED = TVN_FIRST - 51 153 | TVN_GETDISPINFO = TVN_FIRST - 52 154 | TVN_ITEMEXPANDING = TVN_FIRST - 54 155 | TVN_ITEMEXPANDED = TVN_FIRST - 55 156 | TVN_BEGINDRAG = TVN_FIRST - 56 157 | TVN_BEGINRDRAG = TVN_FIRST - 57 158 | TVN_DELETEITEM = TVN_FIRST - 58 159 | TVN_BEGINLABELEDIT = TVN_FIRST - 59 160 | TVN_ENDLABELEDIT = TVN_FIRST - 60 161 | TVN_KEYDOWN = TVN_FIRST - 12 162 | TVN_GETINFOTIP = TVN_FIRST - 14 163 | TVN_SINGLEEXPAND = TVN_FIRST - 15 164 | TVN_ITEMCHANGING = TVN_FIRST - 17 165 | TVN_ITEMCHANGED = TVN_FIRST - 19 166 | TVN_ASYNCDRAW = TVN_FIRST - 20 167 | ) 168 | 169 | // TreeView hit test constants 170 | const ( 171 | TVHT_NOWHERE = 1 172 | TVHT_ONITEMICON = 2 173 | TVHT_ONITEMLABEL = 4 174 | TVHT_ONITEM = TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMSTATEICON 175 | TVHT_ONITEMINDENT = 8 176 | TVHT_ONITEMBUTTON = 16 177 | TVHT_ONITEMRIGHT = 32 178 | TVHT_ONITEMSTATEICON = 64 179 | TVHT_ABOVE = 256 180 | TVHT_BELOW = 512 181 | TVHT_TORIGHT = 1024 182 | TVHT_TOLEFT = 2048 183 | ) 184 | 185 | type HTREEITEM HANDLE 186 | 187 | type TVITEM struct { 188 | Mask uint32 189 | HItem HTREEITEM 190 | State uint32 191 | StateMask uint32 192 | PszText uintptr 193 | CchTextMax int32 194 | IImage int32 195 | ISelectedImage int32 196 | CChildren int32 197 | LParam uintptr 198 | } 199 | 200 | /*type TVITEMEX struct { 201 | mask UINT 202 | hItem HTREEITEM 203 | state UINT 204 | stateMask UINT 205 | pszText LPWSTR 206 | cchTextMax int 207 | iImage int 208 | iSelectedImage int 209 | cChildren int 210 | lParam LPARAM 211 | iIntegral int 212 | uStateEx UINT 213 | hwnd HWND 214 | iExpandedImage int 215 | }*/ 216 | 217 | type TVINSERTSTRUCT struct { 218 | HParent HTREEITEM 219 | HInsertAfter HTREEITEM 220 | Item TVITEM 221 | // itemex TVITEMEX 222 | } 223 | 224 | type NMTREEVIEW struct { 225 | Hdr NMHDR 226 | Action uint32 227 | ItemOld TVITEM 228 | ItemNew TVITEM 229 | PtDrag POINT 230 | } 231 | 232 | type NMTVDISPINFO struct { 233 | Hdr NMHDR 234 | Item TVITEM 235 | } 236 | 237 | type NMTVKEYDOWN struct { 238 | Hdr NMHDR 239 | WVKey uint16 240 | Flags uint32 241 | } 242 | 243 | type TVHITTESTINFO struct { 244 | Pt POINT 245 | Flags uint32 246 | HItem HTREEITEM 247 | } 248 | -------------------------------------------------------------------------------- /updown.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | const UDN_FIRST = ^uint32(720) 10 | 11 | const ( 12 | UD_MAXVAL = 0x7fff 13 | UD_MINVAL = ^uintptr(UD_MAXVAL - 1) 14 | ) 15 | 16 | const ( 17 | UDS_WRAP = 0x0001 18 | UDS_SETBUDDYINT = 0x0002 19 | UDS_ALIGNRIGHT = 0x0004 20 | UDS_ALIGNLEFT = 0x0008 21 | UDS_AUTOBUDDY = 0x0010 22 | UDS_ARROWKEYS = 0x0020 23 | UDS_HORZ = 0x0040 24 | UDS_NOTHOUSANDS = 0x0080 25 | UDS_HOTTRACK = 0x0100 26 | ) 27 | 28 | const ( 29 | UDM_SETRANGE = WM_USER + 101 30 | UDM_GETRANGE = WM_USER + 102 31 | UDM_SETPOS = WM_USER + 103 32 | UDM_GETPOS = WM_USER + 104 33 | UDM_SETBUDDY = WM_USER + 105 34 | UDM_GETBUDDY = WM_USER + 106 35 | UDM_SETACCEL = WM_USER + 107 36 | UDM_GETACCEL = WM_USER + 108 37 | UDM_SETBASE = WM_USER + 109 38 | UDM_GETBASE = WM_USER + 110 39 | UDM_SETRANGE32 = WM_USER + 111 40 | UDM_GETRANGE32 = WM_USER + 112 41 | UDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 42 | UDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 43 | UDM_SETPOS32 = WM_USER + 113 44 | UDM_GETPOS32 = WM_USER + 114 45 | ) 46 | 47 | const UDN_DELTAPOS = UDN_FIRST - 1 48 | 49 | type UDACCEL struct { 50 | NSec uint32 51 | NInc uint32 52 | } 53 | 54 | type NMUPDOWN struct { 55 | Hdr NMHDR 56 | IPos int32 57 | IDelta int32 58 | } 59 | -------------------------------------------------------------------------------- /win.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "golang.org/x/sys/windows" 13 | ) 14 | 15 | const ( 16 | S_OK = 0x00000000 17 | S_FALSE = 0x00000001 18 | E_UNEXPECTED = 0x8000FFFF 19 | E_NOTIMPL = 0x80004001 20 | E_OUTOFMEMORY = 0x8007000E 21 | E_INVALIDARG = 0x80070057 22 | E_NOINTERFACE = 0x80004002 23 | E_POINTER = 0x80004003 24 | E_HANDLE = 0x80070006 25 | E_ABORT = 0x80004004 26 | E_FAIL = 0x80004005 27 | E_ACCESSDENIED = 0x80070005 28 | E_PENDING = 0x8000000A 29 | ) 30 | 31 | const ( 32 | FALSE = 0 33 | TRUE = 1 34 | ) 35 | 36 | type ( 37 | BOOL int32 38 | HRESULT int32 39 | ) 40 | 41 | func SUCCEEDED(hr HRESULT) bool { 42 | return hr >= 0 43 | } 44 | 45 | func FAILED(hr HRESULT) bool { 46 | return hr < 0 47 | } 48 | 49 | func MAKEWORD(lo, hi byte) uint16 { 50 | return uint16(uint16(lo) | ((uint16(hi)) << 8)) 51 | } 52 | 53 | func LOBYTE(w uint16) byte { 54 | return byte(w) 55 | } 56 | 57 | func HIBYTE(w uint16) byte { 58 | return byte(w >> 8 & 0xff) 59 | } 60 | 61 | func MAKELONG(lo, hi uint16) uint32 { 62 | return uint32(uint32(lo) | ((uint32(hi)) << 16)) 63 | } 64 | 65 | func LOWORD(dw uint32) uint16 { 66 | return uint16(dw) 67 | } 68 | 69 | func HIWORD(dw uint32) uint16 { 70 | return uint16(dw >> 16 & 0xffff) 71 | } 72 | 73 | func UTF16PtrToString(s *uint16) string { 74 | return windows.UTF16PtrToString(s) 75 | } 76 | 77 | func MAKEINTRESOURCE(id uintptr) *uint16 { 78 | return (*uint16)(unsafe.Pointer(id)) 79 | } 80 | 81 | func BoolToBOOL(value bool) BOOL { 82 | if value { 83 | return 1 84 | } 85 | 86 | return 0 87 | } 88 | -------------------------------------------------------------------------------- /winnls.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | const ( 10 | // Code Page Default Values. 11 | // Please Use Unicode, either UTF-16 (as in WCHAR) or UTF-8 (code page CP_ACP) 12 | CP_ACP = 0 // default to ANSI code page 13 | CP_OEMCP = 1 // default to OEM code page 14 | CP_MACCP = 2 // default to MAC code page 15 | CP_THREAD_ACP = 3 // current thread's ANSI code page 16 | CP_SYMBOL = 42 // SYMBOL translations 17 | 18 | CP_UTF7 = 65000 // UTF-7 translation 19 | CP_UTF8 = 65001 // UTF-8 translation 20 | ) 21 | -------------------------------------------------------------------------------- /winspool.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The win Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package win 8 | 9 | import ( 10 | "golang.org/x/sys/windows" 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // EnumPrinters flags 16 | const ( 17 | PRINTER_ENUM_DEFAULT = 0x00000001 18 | PRINTER_ENUM_LOCAL = 0x00000002 19 | PRINTER_ENUM_CONNECTIONS = 0x00000004 20 | PRINTER_ENUM_FAVORITE = 0x00000004 21 | PRINTER_ENUM_NAME = 0x00000008 22 | PRINTER_ENUM_REMOTE = 0x00000010 23 | PRINTER_ENUM_SHARED = 0x00000020 24 | PRINTER_ENUM_NETWORK = 0x00000040 25 | ) 26 | 27 | type PRINTER_INFO_4 struct { 28 | PPrinterName *uint16 29 | PServerName *uint16 30 | Attributes uint32 31 | } 32 | 33 | var ( 34 | // Library 35 | libwinspool *windows.LazyDLL 36 | 37 | // Functions 38 | deviceCapabilities *windows.LazyProc 39 | documentProperties *windows.LazyProc 40 | enumPrinters *windows.LazyProc 41 | getDefaultPrinter *windows.LazyProc 42 | ) 43 | 44 | func init() { 45 | // Library 46 | libwinspool = windows.NewLazySystemDLL("winspool.drv") 47 | 48 | // Functions 49 | deviceCapabilities = libwinspool.NewProc("DeviceCapabilitiesW") 50 | documentProperties = libwinspool.NewProc("DocumentPropertiesW") 51 | enumPrinters = libwinspool.NewProc("EnumPrintersW") 52 | getDefaultPrinter = libwinspool.NewProc("GetDefaultPrinterW") 53 | } 54 | 55 | func DeviceCapabilities(pDevice, pPort *uint16, fwCapability uint16, pOutput *uint16, pDevMode *DEVMODE) uint32 { 56 | ret, _, _ := syscall.Syscall6(deviceCapabilities.Addr(), 5, 57 | uintptr(unsafe.Pointer(pDevice)), 58 | uintptr(unsafe.Pointer(pPort)), 59 | uintptr(fwCapability), 60 | uintptr(unsafe.Pointer(pOutput)), 61 | uintptr(unsafe.Pointer(pDevMode)), 62 | 0) 63 | 64 | return uint32(ret) 65 | } 66 | 67 | func DocumentProperties(hWnd HWND, hPrinter HANDLE, pDeviceName *uint16, pDevModeOutput, pDevModeInput *DEVMODE, fMode uint32) int32 { 68 | ret, _, _ := syscall.Syscall6(documentProperties.Addr(), 6, 69 | uintptr(hWnd), 70 | uintptr(hPrinter), 71 | uintptr(unsafe.Pointer(pDeviceName)), 72 | uintptr(unsafe.Pointer(pDevModeOutput)), 73 | uintptr(unsafe.Pointer(pDevModeInput)), 74 | uintptr(fMode)) 75 | 76 | return int32(ret) 77 | } 78 | 79 | func EnumPrinters(Flags uint32, Name *uint16, Level uint32, pPrinterEnum *byte, cbBuf uint32, pcbNeeded, pcReturned *uint32) bool { 80 | ret, _, _ := syscall.Syscall9(enumPrinters.Addr(), 7, 81 | uintptr(Flags), 82 | uintptr(unsafe.Pointer(Name)), 83 | uintptr(Level), 84 | uintptr(unsafe.Pointer(pPrinterEnum)), 85 | uintptr(cbBuf), 86 | uintptr(unsafe.Pointer(pcbNeeded)), 87 | uintptr(unsafe.Pointer(pcReturned)), 88 | 0, 89 | 0) 90 | 91 | return ret != 0 92 | } 93 | 94 | func GetDefaultPrinter(pszBuffer *uint16, pcchBuffer *uint32) bool { 95 | ret, _, _ := syscall.Syscall(getDefaultPrinter.Addr(), 2, 96 | uintptr(unsafe.Pointer(pszBuffer)), 97 | uintptr(unsafe.Pointer(pcchBuffer)), 98 | 0) 99 | 100 | return ret != 0 101 | } 102 | --------------------------------------------------------------------------------