├── AUTHORS ├── LICENSE ├── README.mdown ├── advapi32.go ├── combobox.go ├── comctl32.go ├── comdlg32.go ├── datetimepicker.go ├── edit.go ├── gdi32.go ├── gdiplus.go ├── header.go ├── kernel32.go ├── listbox.go ├── listview.go ├── menu.go ├── ole32.go ├── oleaut32.go ├── oleaut32_386.go ├── oleaut32_amd64.go ├── opengl32.go ├── shdocvw.go ├── shell32.go ├── shobj.go ├── shobj_386.go ├── shobj_amd64.go ├── tab.go ├── toolbar.go ├── tooltip.go ├── treeview.go ├── updown.go ├── user32.go ├── uxtheme.go ├── winapi.go ├── winmm.go └── winspool.go /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of 'go-winapi' 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 | Anton Lahti 14 | Benny Siegert 15 | Cary Cherng 16 | Hill 17 | wsf01 18 | 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 The go-winapi 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 | fork from https://github.com/lxn/go-winapi 2 | -------------------------------------------------------------------------------- /advapi32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | const KEY_READ REGSAM = 0x20019 13 | const KEY_WRITE REGSAM = 0x20006 14 | 15 | const ( 16 | HKEY_CLASSES_ROOT HKEY = 0x80000000 17 | HKEY_CURRENT_USER HKEY = 0x80000001 18 | HKEY_LOCAL_MACHINE HKEY = 0x80000002 19 | HKEY_USERS HKEY = 0x80000003 20 | HKEY_PERFORMANCE_DATA HKEY = 0x80000004 21 | HKEY_CURRENT_CONFIG HKEY = 0x80000005 22 | HKEY_DYN_DATA HKEY = 0x80000006 23 | ) 24 | 25 | const ( 26 | ERROR_NO_MORE_ITEMS = 259 27 | ) 28 | 29 | type ( 30 | ACCESS_MASK uint32 31 | HKEY HANDLE 32 | REGSAM ACCESS_MASK 33 | ) 34 | 35 | const ( 36 | REG_NONE uint64 = 0 // No value type 37 | REG_SZ = 1 // Unicode nul terminated string 38 | REG_EXPAND_SZ = 2 // Unicode nul terminated string 39 | // (with environment variable references) 40 | REG_BINARY = 3 // Free form binary 41 | REG_DWORD = 4 // 32-bit number 42 | REG_DWORD_LITTLE_ENDIAN = 4 // 32-bit number (same as REG_DWORD) 43 | REG_DWORD_BIG_ENDIAN = 5 // 32-bit number 44 | REG_LINK = 6 // Symbolic Link (unicode) 45 | REG_MULTI_SZ = 7 // Multiple Unicode strings 46 | REG_RESOURCE_LIST = 8 // Resource list in the resource map 47 | REG_FULL_RESOURCE_DESCRIPTOR = 9 // Resource list in the hardware description 48 | REG_RESOURCE_REQUIREMENTS_LIST = 10 49 | REG_QWORD = 11 // 64-bit number 50 | REG_QWORD_LITTLE_ENDIAN = 11 // 64-bit number (same as REG_QWORD) 51 | 52 | ) 53 | 54 | var ( 55 | // Library 56 | libadvapi32 uintptr 57 | 58 | // Functions 59 | regCloseKey uintptr 60 | regOpenKeyEx uintptr 61 | regQueryValueEx uintptr 62 | regEnumValue uintptr 63 | regSetValueEx uintptr 64 | ) 65 | 66 | func init() { 67 | // Library 68 | libadvapi32 = MustLoadLibrary("advapi32.dll") 69 | 70 | // Functions 71 | regCloseKey = MustGetProcAddress(libadvapi32, "RegCloseKey") 72 | regOpenKeyEx = MustGetProcAddress(libadvapi32, "RegOpenKeyExW") 73 | regQueryValueEx = MustGetProcAddress(libadvapi32, "RegQueryValueExW") 74 | regEnumValue = MustGetProcAddress(libadvapi32, "RegEnumValueW") 75 | regSetValueEx = MustGetProcAddress(libadvapi32, "RegSetValueExW") 76 | } 77 | 78 | func RegCloseKey(hKey HKEY) int32 { 79 | ret, _, _ := syscall.Syscall(regCloseKey, 1, 80 | uintptr(hKey), 81 | 0, 82 | 0) 83 | 84 | return int32(ret) 85 | } 86 | 87 | func RegOpenKeyEx(hKey HKEY, lpSubKey *uint16, ulOptions uint32, samDesired REGSAM, phkResult *HKEY) int32 { 88 | ret, _, _ := syscall.Syscall6(regOpenKeyEx, 5, 89 | uintptr(hKey), 90 | uintptr(unsafe.Pointer(lpSubKey)), 91 | uintptr(ulOptions), 92 | uintptr(samDesired), 93 | uintptr(unsafe.Pointer(phkResult)), 94 | 0) 95 | 96 | return int32(ret) 97 | } 98 | 99 | func RegQueryValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpType *uint32, lpData *byte, lpcbData *uint32) int32 { 100 | ret, _, _ := syscall.Syscall6(regQueryValueEx, 6, 101 | uintptr(hKey), 102 | uintptr(unsafe.Pointer(lpValueName)), 103 | uintptr(unsafe.Pointer(lpReserved)), 104 | uintptr(unsafe.Pointer(lpType)), 105 | uintptr(unsafe.Pointer(lpData)), 106 | uintptr(unsafe.Pointer(lpcbData))) 107 | 108 | return int32(ret) 109 | } 110 | 111 | func RegEnumValue(hKey HKEY, index uint32, lpValueName *uint16, lpcchValueName *uint32, lpReserved, lpType *uint32, lpData *byte, lpcbData *uint32) int32 { 112 | ret, _, _ := syscall.Syscall9(regEnumValue, 8, 113 | uintptr(hKey), 114 | uintptr(index), 115 | uintptr(unsafe.Pointer(lpValueName)), 116 | uintptr(unsafe.Pointer(lpcchValueName)), 117 | uintptr(unsafe.Pointer(lpReserved)), 118 | uintptr(unsafe.Pointer(lpType)), 119 | uintptr(unsafe.Pointer(lpData)), 120 | uintptr(unsafe.Pointer(lpcbData)), 121 | 0) 122 | return int32(ret) 123 | } 124 | 125 | func RegSetValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpDataType uint64, lpData *byte, cbData uint32) int32 { 126 | ret, _, _ := syscall.Syscall6(regSetValueEx, 6, 127 | uintptr(hKey), 128 | uintptr(unsafe.Pointer(lpValueName)), 129 | uintptr(lpReserved), 130 | uintptr(lpDataType), 131 | uintptr(unsafe.Pointer(lpData)), 132 | uintptr(cbData)) 133 | return int32(ret) 134 | } 135 | -------------------------------------------------------------------------------- /combobox.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | // ComboBox return values 8 | const ( 9 | CB_OKAY = 0 10 | CB_ERR = ^uintptr(0) // -1 11 | CB_ERRSPACE = ^uintptr(1) // -2 12 | ) 13 | 14 | // ComboBox notifications 15 | const ( 16 | CBN_ERRSPACE = -1 17 | CBN_SELCHANGE = 1 18 | CBN_DBLCLK = 2 19 | CBN_SETFOCUS = 3 20 | CBN_KILLFOCUS = 4 21 | CBN_EDITCHANGE = 5 22 | CBN_EDITUPDATE = 6 23 | CBN_DROPDOWN = 7 24 | CBN_CLOSEUP = 8 25 | CBN_SELENDOK = 9 26 | CBN_SELENDCANCEL = 10 27 | ) 28 | 29 | // ComboBox styles 30 | const ( 31 | CBS_SIMPLE = 0x0001 32 | CBS_DROPDOWN = 0x0002 33 | CBS_DROPDOWNLIST = 0x0003 34 | CBS_OWNERDRAWFIXED = 0x0010 35 | CBS_OWNERDRAWVARIABLE = 0x0020 36 | CBS_AUTOHSCROLL = 0x0040 37 | CBS_OEMCONVERT = 0x0080 38 | CBS_SORT = 0x0100 39 | CBS_HASSTRINGS = 0x0200 40 | CBS_NOINTEGRALHEIGHT = 0x0400 41 | CBS_DISABLENOSCROLL = 0x0800 42 | CBS_UPPERCASE = 0x2000 43 | CBS_LOWERCASE = 0x4000 44 | ) 45 | 46 | // ComboBox messages 47 | const ( 48 | CB_GETEDITSEL = 0x0140 49 | CB_LIMITTEXT = 0x0141 50 | CB_SETEDITSEL = 0x0142 51 | CB_ADDSTRING = 0x0143 52 | CB_DELETESTRING = 0x0144 53 | CB_DIR = 0x0145 54 | CB_GETCOUNT = 0x0146 55 | CB_GETCURSEL = 0x0147 56 | CB_GETLBTEXT = 0x0148 57 | CB_GETLBTEXTLEN = 0x0149 58 | CB_INSERTSTRING = 0x014A 59 | CB_RESETCONTENT = 0x014B 60 | CB_FINDSTRING = 0x014C 61 | CB_SELECTSTRING = 0x014D 62 | CB_SETCURSEL = 0x014E 63 | CB_SHOWDROPDOWN = 0x014F 64 | CB_GETITEMDATA = 0x0150 65 | CB_SETITEMDATA = 0x0151 66 | CB_GETDROPPEDCONTROLRECT = 0x0152 67 | CB_SETITEMHEIGHT = 0x0153 68 | CB_GETITEMHEIGHT = 0x0154 69 | CB_SETEXTENDEDUI = 0x0155 70 | CB_GETEXTENDEDUI = 0x0156 71 | CB_GETDROPPEDSTATE = 0x0157 72 | CB_FINDSTRINGEXACT = 0x0158 73 | CB_SETLOCALE = 0x0159 74 | CB_GETLOCALE = 0x015A 75 | CB_GETTOPINDEX = 0x015b 76 | CB_SETTOPINDEX = 0x015c 77 | CB_GETHORIZONTALEXTENT = 0x015d 78 | CB_SETHORIZONTALEXTENT = 0x015e 79 | CB_GETDROPPEDWIDTH = 0x015f 80 | CB_SETDROPPEDWIDTH = 0x0160 81 | CB_INITSTORAGE = 0x0161 82 | CB_MULTIPLEADDSTRING = 0x0163 83 | CB_GETCOMBOBOXINFO = 0x0164 84 | ) 85 | -------------------------------------------------------------------------------- /comctl32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // Button control messages 13 | const ( 14 | BCM_FIRST = 0x1600 15 | BCM_GETIDEALSIZE = BCM_FIRST + 0x0001 16 | BCM_SETIMAGELIST = BCM_FIRST + 0x0002 17 | BCM_GETIMAGELIST = BCM_FIRST + 0x0003 18 | BCM_SETTEXTMARGIN = BCM_FIRST + 0x0004 19 | BCM_GETTEXTMARGIN = BCM_FIRST + 0x0005 20 | BCM_SETDROPDOWNSTATE = BCM_FIRST + 0x0006 21 | BCM_SETSPLITINFO = BCM_FIRST + 0x0007 22 | BCM_GETSPLITINFO = BCM_FIRST + 0x0008 23 | BCM_SETNOTE = BCM_FIRST + 0x0009 24 | BCM_GETNOTE = BCM_FIRST + 0x000A 25 | BCM_GETNOTELENGTH = BCM_FIRST + 0x000B 26 | ) 27 | 28 | const ( 29 | CCM_FIRST = 0x2000 30 | CCM_LAST = CCM_FIRST + 0x200 31 | CCM_SETBKCOLOR = 8193 32 | CCM_SETCOLORSCHEME = 8194 33 | CCM_GETCOLORSCHEME = 8195 34 | CCM_GETDROPTARGET = 8196 35 | CCM_SETUNICODEFORMAT = 8197 36 | CCM_GETUNICODEFORMAT = 8198 37 | CCM_SETVERSION = 0x2007 38 | CCM_GETVERSION = 0x2008 39 | CCM_SETNOTIFYWINDOW = 0x2009 40 | CCM_SETWINDOWTHEME = 0x200b 41 | CCM_DPISCALE = 0x200c 42 | ) 43 | 44 | // Common controls styles 45 | const ( 46 | CCS_TOP = 1 47 | CCS_NOMOVEY = 2 48 | CCS_BOTTOM = 3 49 | CCS_NORESIZE = 4 50 | CCS_NOPARENTALIGN = 8 51 | CCS_ADJUSTABLE = 32 52 | CCS_NODIVIDER = 64 53 | CCS_VERT = 128 54 | CCS_LEFT = 129 55 | CCS_NOMOVEX = 130 56 | CCS_RIGHT = 131 57 | ) 58 | 59 | // InitCommonControlsEx flags 60 | const ( 61 | ICC_LISTVIEW_CLASSES = 1 62 | ICC_TREEVIEW_CLASSES = 2 63 | ICC_BAR_CLASSES = 4 64 | ICC_TAB_CLASSES = 8 65 | ICC_UPDOWN_CLASS = 16 66 | ICC_PROGRESS_CLASS = 32 67 | ICC_HOTKEY_CLASS = 64 68 | ICC_ANIMATE_CLASS = 128 69 | ICC_WIN95_CLASSES = 255 70 | ICC_DATE_CLASSES = 256 71 | ICC_USEREX_CLASSES = 512 72 | ICC_COOL_CLASSES = 1024 73 | ICC_INTERNET_CLASSES = 2048 74 | ICC_PAGESCROLLER_CLASS = 4096 75 | ICC_NATIVEFNTCTL_CLASS = 8192 76 | INFOTIPSIZE = 1024 77 | ICC_STANDARD_CLASSES = 0x00004000 78 | ICC_LINK_CLASS = 0x00008000 79 | ) 80 | 81 | // WM_NOTITY messages 82 | const ( 83 | NM_FIRST = 0 84 | NM_OUTOFMEMORY = NM_FIRST - 1 85 | NM_CLICK = NM_FIRST - 2 86 | NM_DBLCLK = NM_FIRST - 3 87 | NM_RETURN = NM_FIRST - 4 88 | NM_RCLICK = NM_FIRST - 5 89 | NM_RDBLCLK = NM_FIRST - 6 90 | NM_SETFOCUS = NM_FIRST - 7 91 | NM_KILLFOCUS = NM_FIRST - 8 92 | NM_CUSTOMDRAW = NM_FIRST - 12 93 | NM_HOVER = NM_FIRST - 13 94 | NM_NCHITTEST = NM_FIRST - 14 95 | NM_KEYDOWN = NM_FIRST - 15 96 | NM_RELEASEDCAPTURE = NM_FIRST - 16 97 | NM_SETCURSOR = NM_FIRST - 17 98 | NM_CHAR = NM_FIRST - 18 99 | NM_TOOLTIPSCREATED = NM_FIRST - 19 100 | NM_LAST = NM_FIRST - 99 101 | ) 102 | 103 | // ProgressBar messages 104 | const ( 105 | PBM_SETPOS = WM_USER + 2 106 | PBM_DELTAPOS = WM_USER + 3 107 | PBM_SETSTEP = WM_USER + 4 108 | PBM_STEPIT = WM_USER + 5 109 | PBM_SETRANGE32 = 1030 110 | PBM_GETRANGE = 1031 111 | PBM_GETPOS = 1032 112 | PBM_SETBARCOLOR = 1033 113 | PBM_SETBKCOLOR = CCM_SETBKCOLOR 114 | PBS_SMOOTH = 1 115 | PBS_VERTICAL = 4 116 | ) 117 | 118 | // ImageList creation flags 119 | const ( 120 | ILC_MASK = 0x00000001 121 | ILC_COLOR = 0x00000000 122 | ILC_COLORDDB = 0x000000FE 123 | ILC_COLOR4 = 0x00000004 124 | ILC_COLOR8 = 0x00000008 125 | ILC_COLOR16 = 0x00000010 126 | ILC_COLOR24 = 0x00000018 127 | ILC_COLOR32 = 0x00000020 128 | ILC_PALETTE = 0x00000800 129 | ILC_MIRROR = 0x00002000 130 | ILC_PERITEMMIRROR = 0x00008000 131 | ) 132 | 133 | const ( 134 | CDDS_PREPAINT = 0x00000001 135 | CDDS_ITEM = 0x00010000 136 | CDDS_ITEMPREPAINT = CDDS_ITEM | CDDS_PREPAINT 137 | ) 138 | 139 | const ( 140 | CDRF_DODEFAULT = 0x00000000 141 | CDRF_NEWFONT = 0x00000002 142 | CDRF_SKIPDEFAULT = 0x00000004 143 | CDRF_NOTIFYPOSTPAINT = 0x00000010 144 | CDRF_NOTIFYITEMDRAW = 0x00000020 145 | CDRF_NOTIFYSUBITEMDRAW = 0x00000020 146 | CDRF_NOTIFYPOSTERASE = 0x00000040 147 | ) 148 | 149 | const ( 150 | LPSTR_TEXTCALLBACK = ^uintptr(0) 151 | I_CHILDRENCALLBACK = -1 152 | ) 153 | 154 | type HIMAGELIST HANDLE 155 | 156 | type INITCOMMONCONTROLSEX struct { 157 | DwSize, DwICC uint32 158 | } 159 | 160 | type NMCUSTOMDRAW struct { 161 | Hdr NMHDR 162 | DwDrawStage uint32 163 | Hdc HDC 164 | Rc RECT 165 | DwItemSpec uintptr 166 | UItemState uint32 167 | LItemlParam uintptr 168 | } 169 | 170 | var ( 171 | // Library 172 | libcomctl32 uintptr 173 | 174 | // Functions 175 | imageList_Add uintptr 176 | imageList_AddMasked uintptr 177 | imageList_Create uintptr 178 | imageList_Destroy uintptr 179 | imageList_ReplaceIcon uintptr 180 | initCommonControlsEx uintptr 181 | ) 182 | 183 | func init() { 184 | // Library 185 | libcomctl32 = MustLoadLibrary("comctl32.dll") 186 | 187 | // Functions 188 | imageList_Add = MustGetProcAddress(libcomctl32, "ImageList_Add") 189 | imageList_AddMasked = MustGetProcAddress(libcomctl32, "ImageList_AddMasked") 190 | imageList_Create = MustGetProcAddress(libcomctl32, "ImageList_Create") 191 | imageList_Destroy = MustGetProcAddress(libcomctl32, "ImageList_Destroy") 192 | imageList_ReplaceIcon = MustGetProcAddress(libcomctl32, "ImageList_ReplaceIcon") 193 | initCommonControlsEx = MustGetProcAddress(libcomctl32, "InitCommonControlsEx") 194 | 195 | // Initialize the common controls we support 196 | var initCtrls INITCOMMONCONTROLSEX 197 | initCtrls.DwSize = uint32(unsafe.Sizeof(initCtrls)) 198 | initCtrls.DwICC = ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES 199 | 200 | InitCommonControlsEx(&initCtrls) 201 | } 202 | 203 | func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int32 { 204 | ret, _, _ := syscall.Syscall(imageList_Add, 3, 205 | uintptr(himl), 206 | uintptr(hbmImage), 207 | uintptr(hbmMask)) 208 | 209 | return int32(ret) 210 | } 211 | 212 | func ImageList_AddMasked(himl HIMAGELIST, hbmImage HBITMAP, crMask COLORREF) int32 { 213 | ret, _, _ := syscall.Syscall(imageList_AddMasked, 3, 214 | uintptr(himl), 215 | uintptr(hbmImage), 216 | uintptr(crMask)) 217 | 218 | return int32(ret) 219 | } 220 | 221 | func ImageList_Create(cx, cy int32, flags uint32, cInitial, cGrow int32) HIMAGELIST { 222 | ret, _, _ := syscall.Syscall6(imageList_Create, 5, 223 | uintptr(cx), 224 | uintptr(cy), 225 | uintptr(flags), 226 | uintptr(cInitial), 227 | uintptr(cGrow), 228 | 0) 229 | 230 | return HIMAGELIST(ret) 231 | } 232 | 233 | func ImageList_Destroy(hIml HIMAGELIST) bool { 234 | ret, _, _ := syscall.Syscall(imageList_Destroy, 1, 235 | uintptr(hIml), 236 | 0, 237 | 0) 238 | 239 | return ret != 0 240 | } 241 | 242 | func ImageList_ReplaceIcon(himl HIMAGELIST, i int32, hicon HICON) int32 { 243 | ret, _, _ := syscall.Syscall(imageList_ReplaceIcon, 3, 244 | uintptr(himl), 245 | uintptr(i), 246 | uintptr(hicon)) 247 | 248 | return int32(ret) 249 | } 250 | 251 | func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool { 252 | ret, _, _ := syscall.Syscall(initCommonControlsEx, 1, 253 | uintptr(unsafe.Pointer(lpInitCtrls)), 254 | 0, 255 | 0) 256 | 257 | return ret != 0 258 | } 259 | -------------------------------------------------------------------------------- /comdlg32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // Common error codes 13 | const ( 14 | CDERR_DIALOGFAILURE = 0xFFFF 15 | CDERR_FINDRESFAILURE = 0x0006 16 | CDERR_INITIALIZATION = 0x0002 17 | CDERR_LOADRESFAILURE = 0x0007 18 | CDERR_LOADSTRFAILURE = 0x0005 19 | CDERR_LOCKRESFAILURE = 0x0008 20 | CDERR_MEMALLOCFAILURE = 0x0009 21 | CDERR_MEMLOCKFAILURE = 0x000A 22 | CDERR_NOHINSTANCE = 0x0004 23 | CDERR_NOHOOK = 0x000B 24 | CDERR_NOTEMPLATE = 0x0003 25 | CDERR_REGISTERMSGFAIL = 0x000C 26 | CDERR_STRUCTSIZE = 0x0001 27 | ) 28 | 29 | // PrintDlg specific error codes 30 | const ( 31 | PDERR_CREATEICFAILURE = 0x100A 32 | PDERR_DEFAULTDIFFERENT = 0x100C 33 | PDERR_DNDMMISMATCH = 0x1009 34 | PDERR_GETDEVMODEFAIL = 0x1005 35 | PDERR_INITFAILURE = 0x1006 36 | PDERR_LOADDRVFAILURE = 0x1004 37 | PDERR_NODEFAULTPRN = 0x1008 38 | PDERR_NODEVICES = 0x1007 39 | PDERR_PARSEFAILURE = 0x1002 40 | PDERR_PRINTERNOTFOUND = 0x100B 41 | PDERR_RETDEFFAILURE = 0x1003 42 | PDERR_SETUPFAILURE = 0x1001 43 | ) 44 | 45 | // ChooseFont specific error codes 46 | const ( 47 | CFERR_MAXLESSTHANMIN = 0x2002 48 | CFERR_NOFONTS = 0x2001 49 | ) 50 | 51 | // GetOpenFileName and GetSaveFileName specific error codes 52 | const ( 53 | FNERR_BUFFERTOOSMALL = 0x3003 54 | FNERR_INVALIDFILENAME = 0x3002 55 | FNERR_SUBCLASSFAILURE = 0x3001 56 | ) 57 | 58 | // FindText and ReplaceText specific error codes 59 | const ( 60 | FRERR_BUFFERLENGTHZERO = 0x4001 61 | ) 62 | 63 | // GetOpenFileName and GetSaveFileName flags 64 | const ( 65 | OFN_ALLOWMULTISELECT = 0x00000200 66 | OFN_CREATEPROMPT = 0x00002000 67 | OFN_DONTADDTORECENT = 0x02000000 68 | OFN_ENABLEHOOK = 0x00000020 69 | OFN_ENABLEINCLUDENOTIFY = 0x00400000 70 | OFN_ENABLESIZING = 0x00800000 71 | OFN_ENABLETEMPLATE = 0x00000040 72 | OFN_ENABLETEMPLATEHANDLE = 0x00000080 73 | OFN_EXPLORER = 0x00080000 74 | OFN_EXTENSIONDIFFERENT = 0x00000400 75 | OFN_FILEMUSTEXIST = 0x00001000 76 | OFN_FORCESHOWHIDDEN = 0x10000000 77 | OFN_HIDEREADONLY = 0x00000004 78 | OFN_LONGNAMES = 0x00200000 79 | OFN_NOCHANGEDIR = 0x00000008 80 | OFN_NODEREFERENCELINKS = 0x00100000 81 | OFN_NOLONGNAMES = 0x00040000 82 | OFN_NONETWORKBUTTON = 0x00020000 83 | OFN_NOREADONLYRETURN = 0x00008000 84 | OFN_NOTESTFILECREATE = 0x00010000 85 | OFN_NOVALIDATE = 0x00000100 86 | OFN_OVERWRITEPROMPT = 0x00000002 87 | OFN_PATHMUSTEXIST = 0x00000800 88 | OFN_READONLY = 0x00000001 89 | OFN_SHAREAWARE = 0x00004000 90 | OFN_SHOWHELP = 0x00000010 91 | ) 92 | 93 | // GetOpenFileName and GetSaveFileName extended flags 94 | const ( 95 | OFN_EX_NOPLACESBAR = 0x00000001 96 | ) 97 | 98 | // PrintDlg[Ex] result actions 99 | const ( 100 | PD_RESULT_APPLY = 2 101 | PD_RESULT_CANCEL = 0 102 | PD_RESULT_PRINT = 1 103 | ) 104 | 105 | // PrintDlg[Ex] flags 106 | const ( 107 | PD_ALLPAGES = 0x00000000 108 | PD_COLLATE = 0x00000010 109 | PD_CURRENTPAGE = 0x00400000 110 | PD_DISABLEPRINTTOFILE = 0x00080000 111 | PD_ENABLEPRINTTEMPLATE = 0x00004000 112 | PD_ENABLEPRINTTEMPLATEHANDLE = 0x00010000 113 | PD_EXCLUSIONFLAGS = 0x01000000 114 | PD_HIDEPRINTTOFILE = 0x00100000 115 | PD_NOCURRENTPAGE = 0x00800000 116 | PD_NOPAGENUMS = 0x00000008 117 | PD_NOSELECTION = 0x00000004 118 | PD_NOWARNING = 0x00000080 119 | PD_PAGENUMS = 0x00000002 120 | PD_PRINTTOFILE = 0x00000020 121 | PD_RETURNDC = 0x00000100 122 | PD_RETURNDEFAULT = 0x00000400 123 | PD_RETURNIC = 0x00000200 124 | PD_SELECTION = 0x00000001 125 | PD_USEDEVMODECOPIES = 0x00040000 126 | PD_USEDEVMODECOPIESANDCOLLATE = 0x00040000 127 | PD_USELARGETEMPLATE = 0x10000000 128 | ) 129 | 130 | // PrintDlgEx exclusion flags 131 | const ( 132 | PD_EXCL_COPIESANDCOLLATE = DM_COPIES | DM_COLLATE 133 | ) 134 | 135 | const START_PAGE_GENERAL = 0xffffffff 136 | 137 | type ( 138 | LPOFNHOOKPROC uintptr 139 | HPROPSHEETPAGE HANDLE 140 | LPUNKNOWN uintptr 141 | ) 142 | 143 | type OPENFILENAME struct { 144 | LStructSize uint32 145 | HwndOwner HWND 146 | HInstance HINSTANCE 147 | LpstrFilter *uint16 148 | LpstrCustomFilter *uint16 149 | NMaxCustFilter uint32 150 | NFilterIndex uint32 151 | LpstrFile *uint16 152 | NMaxFile uint32 153 | LpstrFileTitle *uint16 154 | NMaxFileTitle uint32 155 | LpstrInitialDir *uint16 156 | LpstrTitle *uint16 157 | Flags uint32 158 | NFileOffset uint16 159 | NFileExtension uint16 160 | LpstrDefExt *uint16 161 | LCustData uintptr 162 | LpfnHook LPOFNHOOKPROC 163 | LpTemplateName *uint16 164 | PvReserved unsafe.Pointer 165 | DwReserved uint32 166 | FlagsEx uint32 167 | } 168 | 169 | type PRINTPAGERANGE struct { 170 | NFromPage uint32 171 | NToPage uint32 172 | } 173 | 174 | type DEVNAMES struct { 175 | WDriverOffset uint16 176 | WDeviceOffset uint16 177 | WOutputOffset uint16 178 | WDefault uint16 179 | } 180 | 181 | type PRINTDLGEX struct { 182 | LStructSize uint32 183 | HwndOwner HWND 184 | HDevMode HGLOBAL 185 | HDevNames HGLOBAL 186 | HDC HDC 187 | Flags uint32 188 | Flags2 uint32 189 | ExclusionFlags uint32 190 | NPageRanges uint32 191 | NMaxPageRanges uint32 192 | LpPageRanges *PRINTPAGERANGE 193 | NMinPage uint32 194 | NMaxPage uint32 195 | NCopies uint32 196 | HInstance HINSTANCE 197 | LpPrintTemplateName *uint16 198 | LpCallback LPUNKNOWN 199 | NPropertyPages uint32 200 | LphPropertyPages *HPROPSHEETPAGE 201 | NStartPage uint32 202 | DwResultAction uint32 203 | } 204 | 205 | var ( 206 | // Library 207 | libcomdlg32 uintptr 208 | 209 | // Functions 210 | commDlgExtendedError uintptr 211 | getOpenFileName uintptr 212 | getSaveFileName uintptr 213 | printDlgEx uintptr 214 | ) 215 | 216 | func init() { 217 | // Library 218 | libcomdlg32 = MustLoadLibrary("comdlg32.dll") 219 | 220 | // Functions 221 | commDlgExtendedError = MustGetProcAddress(libcomdlg32, "CommDlgExtendedError") 222 | getOpenFileName = MustGetProcAddress(libcomdlg32, "GetOpenFileNameW") 223 | getSaveFileName = MustGetProcAddress(libcomdlg32, "GetSaveFileNameW") 224 | printDlgEx = MustGetProcAddress(libcomdlg32, "PrintDlgExW") 225 | } 226 | 227 | func CommDlgExtendedError() uint32 { 228 | ret, _, _ := syscall.Syscall(commDlgExtendedError, 0, 229 | 0, 230 | 0, 231 | 0) 232 | 233 | return uint32(ret) 234 | } 235 | 236 | func GetOpenFileName(lpofn *OPENFILENAME) bool { 237 | ret, _, _ := syscall.Syscall(getOpenFileName, 1, 238 | uintptr(unsafe.Pointer(lpofn)), 239 | 0, 240 | 0) 241 | 242 | return ret != 0 243 | } 244 | 245 | func GetSaveFileName(lpofn *OPENFILENAME) bool { 246 | ret, _, _ := syscall.Syscall(getSaveFileName, 1, 247 | uintptr(unsafe.Pointer(lpofn)), 248 | 0, 249 | 0) 250 | 251 | return ret != 0 252 | } 253 | 254 | func PrintDlgEx(lppd *PRINTDLGEX) HRESULT { 255 | ret, _, _ := syscall.Syscall(printDlgEx, 1, 256 | uintptr(unsafe.Pointer(lppd)), 257 | 0, 258 | 0) 259 | 260 | return HRESULT(ret) 261 | } 262 | -------------------------------------------------------------------------------- /datetimepicker.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The go-winapi 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 | package winapi 6 | 7 | const DTM_FIRST = 0x1000 8 | const DTN_FIRST = ^uint32(739) // -740 9 | const DTN_FIRST2 = ^uint32(752) // -753 10 | 11 | const ( 12 | GDTR_MIN = 0x0001 13 | GDTR_MAX = 0x0002 14 | ) 15 | 16 | const ( 17 | GDT_ERROR = -1 18 | GDT_VALID = 0 19 | GDT_NONE = 1 20 | ) 21 | 22 | // Messages 23 | const ( 24 | DTM_GETSYSTEMTIME = DTM_FIRST + 1 25 | DTM_SETSYSTEMTIME = DTM_FIRST + 2 26 | DTM_GETRANGE = DTM_FIRST + 3 27 | DTM_SETRANGE = DTM_FIRST + 4 28 | DTM_SETFORMAT = DTM_FIRST + 50 29 | DTM_SETMCCOLOR = DTM_FIRST + 6 30 | DTM_GETMCCOLOR = DTM_FIRST + 7 31 | DTM_GETMONTHCAL = DTM_FIRST + 8 32 | DTM_SETMCFONT = DTM_FIRST + 9 33 | DTM_GETMCFONT = DTM_FIRST + 10 34 | ) 35 | 36 | // Styles 37 | const ( 38 | DTS_UPDOWN = 0x0001 39 | DTS_SHOWNONE = 0x0002 40 | DTS_SHORTDATEFORMAT = 0x0000 41 | DTS_LONGDATEFORMAT = 0x0004 42 | DTS_SHORTDATECENTURYFORMAT = 0x000C 43 | DTS_TIMEFORMAT = 0x0009 44 | DTS_APPCANPARSE = 0x0010 45 | DTS_RIGHTALIGN = 0x0020 46 | ) 47 | 48 | // Notifications 49 | const ( 50 | DTN_DATETIMECHANGE = DTN_FIRST2 - 6 51 | DTN_USERSTRING = DTN_FIRST - 5 52 | DTN_WMKEYDOWN = DTN_FIRST - 4 53 | DTN_FORMAT = DTN_FIRST - 3 54 | DTN_FORMATQUERY = DTN_FIRST - 2 55 | DTN_DROPDOWN = DTN_FIRST2 - 1 56 | DTN_CLOSEUP = DTN_FIRST2 57 | ) 58 | 59 | // Structs 60 | type ( 61 | NMDATETIMECHANGE struct { 62 | Nmhdr NMHDR 63 | DwFlags uint32 64 | St SYSTEMTIME 65 | } 66 | 67 | NMDATETIMESTRING struct { 68 | Nmhdr NMHDR 69 | PszUserString *uint16 70 | St SYSTEMTIME 71 | DwFlags uint32 72 | } 73 | 74 | NMDATETIMEWMKEYDOWN struct { 75 | Nmhdr NMHDR 76 | NVirtKey int 77 | PszFormat *uint16 78 | St SYSTEMTIME 79 | } 80 | 81 | NMDATETIMEFORMAT struct { 82 | Nmhdr NMHDR 83 | PszFormat *uint16 84 | St SYSTEMTIME 85 | PszDisplay *uint16 86 | SzDisplay [64]uint16 87 | } 88 | 89 | NMDATETIMEFORMATQUERY struct { 90 | Nmhdr NMHDR 91 | PszFormat *uint16 92 | SzMax SIZE 93 | } 94 | ) 95 | -------------------------------------------------------------------------------- /edit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | // Edit styles 8 | const ( 9 | ES_LEFT = 0x0000 10 | ES_CENTER = 0x0001 11 | ES_RIGHT = 0x0002 12 | ES_MULTILINE = 0x0004 13 | ES_UPPERCASE = 0x0008 14 | ES_LOWERCASE = 0x0010 15 | ES_PASSWORD = 0x0020 16 | ES_AUTOVSCROLL = 0x0040 17 | ES_AUTOHSCROLL = 0x0080 18 | ES_NOHIDESEL = 0x0100 19 | ES_OEMCONVERT = 0x0400 20 | ES_READONLY = 0x0800 21 | ES_WANTRETURN = 0x1000 22 | ES_NUMBER = 0x2000 23 | ) 24 | 25 | // Edit notifications 26 | const ( 27 | EN_SETFOCUS = 0x0100 28 | EN_KILLFOCUS = 0x0200 29 | EN_CHANGE = 0x0300 30 | EN_UPDATE = 0x0400 31 | EN_ERRSPACE = 0x0500 32 | EN_MAXTEXT = 0x0501 33 | EN_HSCROLL = 0x0601 34 | EN_VSCROLL = 0x0602 35 | EN_ALIGN_LTR_EC = 0x0700 36 | EN_ALIGN_RTL_EC = 0x0701 37 | ) 38 | 39 | // Edit messages 40 | const ( 41 | EM_GETSEL = 0x00B0 42 | EM_SETSEL = 0x00B1 43 | EM_GETRECT = 0x00B2 44 | EM_SETRECT = 0x00B3 45 | EM_SETRECTNP = 0x00B4 46 | EM_SCROLL = 0x00B5 47 | EM_LINESCROLL = 0x00B6 48 | EM_SCROLLCARET = 0x00B7 49 | EM_GETMODIFY = 0x00B8 50 | EM_SETMODIFY = 0x00B9 51 | EM_GETLINECOUNT = 0x00BA 52 | EM_LINEINDEX = 0x00BB 53 | EM_SETHANDLE = 0x00BC 54 | EM_GETHANDLE = 0x00BD 55 | EM_GETTHUMB = 0x00BE 56 | EM_LINELENGTH = 0x00C1 57 | EM_REPLACESEL = 0x00C2 58 | EM_GETLINE = 0x00C4 59 | EM_LIMITTEXT = 0x00C5 60 | EM_CANUNDO = 0x00C6 61 | EM_UNDO = 0x00C7 62 | EM_FMTLINES = 0x00C8 63 | EM_LINEFROMCHAR = 0x00C9 64 | EM_SETTABSTOPS = 0x00CB 65 | EM_SETPASSWORDCHAR = 0x00CC 66 | EM_EMPTYUNDOBUFFER = 0x00CD 67 | EM_GETFIRSTVISIBLELINE = 0x00CE 68 | EM_SETREADONLY = 0x00CF 69 | EM_SETWORDBREAKPROC = 0x00D0 70 | EM_GETWORDBREAKPROC = 0x00D1 71 | EM_GETPASSWORDCHAR = 0x00D2 72 | EM_SETMARGINS = 0x00D3 73 | EM_GETMARGINS = 0x00D4 74 | EM_SETLIMITTEXT = EM_LIMITTEXT 75 | EM_GETLIMITTEXT = 0x00D5 76 | EM_POSFROMCHAR = 0x00D6 77 | EM_CHARFROMPOS = 0x00D7 78 | EM_SETIMESTATUS = 0x00D8 79 | EM_GETIMESTATUS = 0x00D9 80 | EM_SETCUEBANNER = 0x1501 81 | EM_GETCUEBANNER = 0x1502 82 | ) 83 | -------------------------------------------------------------------------------- /gdi32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | 13 | // GetDeviceCaps index constants 14 | const ( 15 | TA_NOUPDATECP = 0 16 | TA_UPDATECP = 1 17 | TA_LEFT = 0 18 | TA_RIGHT =2 19 | TA_CENTER =6 20 | TA_TOP = 0 21 | TA_BOTTOM = 8 22 | TA_BASELINE = 24 23 | ) 24 | 25 | // GetDeviceCaps index constants 26 | const ( 27 | DRIVERVERSION = 0 28 | TECHNOLOGY = 2 29 | HORZSIZE = 4 30 | VERTSIZE = 6 31 | HORZRES = 8 32 | VERTRES = 10 33 | LOGPIXELSX = 88 34 | LOGPIXELSY = 90 35 | BITSPIXEL = 12 36 | PLANES = 14 37 | NUMBRUSHES = 16 38 | NUMPENS = 18 39 | NUMFONTS = 22 40 | NUMCOLORS = 24 41 | NUMMARKERS = 20 42 | ASPECTX = 40 43 | ASPECTY = 42 44 | ASPECTXY = 44 45 | PDEVICESIZE = 26 46 | CLIPCAPS = 36 47 | SIZEPALETTE = 104 48 | NUMRESERVED = 106 49 | COLORRES = 108 50 | PHYSICALWIDTH = 110 51 | PHYSICALHEIGHT = 111 52 | PHYSICALOFFSETX = 112 53 | PHYSICALOFFSETY = 113 54 | SCALINGFACTORX = 114 55 | SCALINGFACTORY = 115 56 | VREFRESH = 116 57 | DESKTOPHORZRES = 118 58 | DESKTOPVERTRES = 117 59 | BLTALIGNMENT = 119 60 | SHADEBLENDCAPS = 120 61 | COLORMGMTCAPS = 121 62 | RASTERCAPS = 38 63 | CURVECAPS = 28 64 | LINECAPS = 30 65 | POLYGONALCAPS = 32 66 | TEXTCAPS = 34 67 | ) 68 | 69 | // GetDeviceCaps TECHNOLOGY constants 70 | const ( 71 | DT_PLOTTER = 0 72 | DT_RASDISPLAY = 1 73 | DT_RASPRINTER = 2 74 | DT_RASCAMERA = 3 75 | DT_CHARSTREAM = 4 76 | DT_METAFILE = 5 77 | DT_DISPFILE = 6 78 | ) 79 | 80 | // GetDeviceCaps SHADEBLENDCAPS constants 81 | const ( 82 | SB_NONE = 0x00 83 | SB_CONST_ALPHA = 0x01 84 | SB_PIXEL_ALPHA = 0x02 85 | SB_PREMULT_ALPHA = 0x04 86 | SB_GRAD_RECT = 0x10 87 | SB_GRAD_TRI = 0x20 88 | ) 89 | 90 | // GetDeviceCaps COLORMGMTCAPS constants 91 | const ( 92 | CM_NONE = 0x00 93 | CM_DEVICE_ICM = 0x01 94 | CM_GAMMA_RAMP = 0x02 95 | CM_CMYK_COLOR = 0x04 96 | ) 97 | 98 | // GetDeviceCaps RASTERCAPS constants 99 | const ( 100 | RC_BANDING = 2 101 | RC_BITBLT = 1 102 | RC_BITMAP64 = 8 103 | RC_DI_BITMAP = 128 104 | RC_DIBTODEV = 512 105 | RC_FLOODFILL = 4096 106 | RC_GDI20_OUTPUT = 16 107 | RC_PALETTE = 256 108 | RC_SCALING = 4 109 | RC_STRETCHBLT = 2048 110 | RC_STRETCHDIB = 8192 111 | RC_DEVBITS = 0x8000 112 | RC_OP_DX_OUTPUT = 0x4000 113 | ) 114 | 115 | // GetDeviceCaps CURVECAPS constants 116 | const ( 117 | CC_NONE = 0 118 | CC_CIRCLES = 1 119 | CC_PIE = 2 120 | CC_CHORD = 4 121 | CC_ELLIPSES = 8 122 | CC_WIDE = 16 123 | CC_STYLED = 32 124 | CC_WIDESTYLED = 64 125 | CC_INTERIORS = 128 126 | CC_ROUNDRECT = 256 127 | ) 128 | 129 | // GetDeviceCaps LINECAPS constants 130 | const ( 131 | LC_NONE = 0 132 | LC_POLYLINE = 2 133 | LC_MARKER = 4 134 | LC_POLYMARKER = 8 135 | LC_WIDE = 16 136 | LC_STYLED = 32 137 | LC_WIDESTYLED = 64 138 | LC_INTERIORS = 128 139 | ) 140 | 141 | // GetDeviceCaps POLYGONALCAPS constants 142 | const ( 143 | PC_NONE = 0 144 | PC_POLYGON = 1 145 | PC_POLYPOLYGON = 256 146 | PC_PATHS = 512 147 | PC_RECTANGLE = 2 148 | PC_WINDPOLYGON = 4 149 | PC_SCANLINE = 8 150 | PC_TRAPEZOID = 4 151 | PC_WIDE = 16 152 | PC_STYLED = 32 153 | PC_WIDESTYLED = 64 154 | PC_INTERIORS = 128 155 | ) 156 | 157 | // GetDeviceCaps TEXTCAPS constants 158 | const ( 159 | TC_OP_CHARACTER = 1 160 | TC_OP_STROKE = 2 161 | TC_CP_STROKE = 4 162 | TC_CR_90 = 8 163 | TC_CR_ANY = 16 164 | TC_SF_X_YINDEP = 32 165 | TC_SA_DOUBLE = 64 166 | TC_SA_INTEGER = 128 167 | TC_SA_CONTIN = 256 168 | TC_EA_DOUBLE = 512 169 | TC_IA_ABLE = 1024 170 | TC_UA_ABLE = 2048 171 | TC_SO_ABLE = 4096 172 | TC_RA_ABLE = 8192 173 | TC_VA_ABLE = 16384 174 | TC_RESERVED = 32768 175 | TC_SCROLLBLT = 65536 176 | ) 177 | 178 | // Brush styles 179 | const ( 180 | BS_SOLID = 0 181 | BS_NULL = 1 182 | BS_HOLLOW = BS_NULL 183 | BS_HATCHED = 2 184 | BS_PATTERN = 3 185 | BS_INDEXED = 4 186 | BS_DIBPATTERN = 5 187 | BS_DIBPATTERNPT = 6 188 | BS_PATTERN8X8 = 7 189 | BS_DIBPATTERN8X8 = 8 190 | BS_MONOPATTERN = 9 191 | ) 192 | 193 | // Hatch styles 194 | const ( 195 | HS_HORIZONTAL = 0 196 | HS_VERTICAL = 1 197 | HS_FDIAGONAL = 2 198 | HS_BDIAGONAL = 3 199 | HS_CROSS = 4 200 | HS_DIAGCROSS = 5 201 | ) 202 | 203 | // Pen types 204 | const ( 205 | PS_COSMETIC = 0x00000000 206 | PS_GEOMETRIC = 0x00010000 207 | PS_TYPE_MASK = 0x000F0000 208 | ) 209 | 210 | // Pen styles 211 | const ( 212 | PS_SOLID = 0 213 | PS_DASH = 1 214 | PS_DOT = 2 215 | PS_DASHDOT = 3 216 | PS_DASHDOTDOT = 4 217 | PS_NULL = 5 218 | PS_INSIDEFRAME = 6 219 | PS_USERSTYLE = 7 220 | PS_ALTERNATE = 8 221 | PS_STYLE_MASK = 0x0000000F 222 | ) 223 | 224 | // Pen cap types 225 | const ( 226 | PS_ENDCAP_ROUND = 0x00000000 227 | PS_ENDCAP_SQUARE = 0x00000100 228 | PS_ENDCAP_FLAT = 0x00000200 229 | PS_ENDCAP_MASK = 0x00000F00 230 | ) 231 | 232 | // Pen join types 233 | const ( 234 | PS_JOIN_ROUND = 0x00000000 235 | PS_JOIN_BEVEL = 0x00001000 236 | PS_JOIN_MITER = 0x00002000 237 | PS_JOIN_MASK = 0x0000F000 238 | ) 239 | 240 | // Stock logical objects 241 | const ( 242 | WHITE_BRUSH = 0 243 | LTGRAY_BRUSH = 1 244 | GRAY_BRUSH = 2 245 | DKGRAY_BRUSH = 3 246 | BLACK_BRUSH = 4 247 | NULL_BRUSH = 5 248 | HOLLOW_BRUSH = NULL_BRUSH 249 | WHITE_PEN = 6 250 | BLACK_PEN = 7 251 | NULL_PEN = 8 252 | OEM_FIXED_FONT = 10 253 | ANSI_FIXED_FONT = 11 254 | ANSI_VAR_FONT = 12 255 | SYSTEM_FONT = 13 256 | DEVICE_DEFAULT_FONT = 14 257 | DEFAULT_PALETTE = 15 258 | SYSTEM_FIXED_FONT = 16 259 | DEFAULT_GUI_FONT = 17 260 | DC_BRUSH = 18 261 | DC_PEN = 19 262 | ) 263 | 264 | const LF_FACESIZE = 32 265 | 266 | // Font weight constants 267 | const ( 268 | FW_DONTCARE = 0 269 | FW_THIN = 100 270 | FW_EXTRALIGHT = 200 271 | FW_ULTRALIGHT = FW_EXTRALIGHT 272 | FW_LIGHT = 300 273 | FW_NORMAL = 400 274 | FW_REGULAR = 400 275 | FW_MEDIUM = 500 276 | FW_SEMIBOLD = 600 277 | FW_DEMIBOLD = FW_SEMIBOLD 278 | FW_BOLD = 700 279 | FW_EXTRABOLD = 800 280 | FW_ULTRABOLD = FW_EXTRABOLD 281 | FW_HEAVY = 900 282 | FW_BLACK = FW_HEAVY 283 | ) 284 | 285 | // Charset constants 286 | const ( 287 | ANSI_CHARSET = 0 288 | DEFAULT_CHARSET = 1 289 | SYMBOL_CHARSET = 2 290 | SHIFTJIS_CHARSET = 128 291 | HANGEUL_CHARSET = 129 292 | HANGUL_CHARSET = 129 293 | GB2312_CHARSET = 134 294 | CHINESEBIG5_CHARSET = 136 295 | GREEK_CHARSET = 161 296 | TURKISH_CHARSET = 162 297 | HEBREW_CHARSET = 177 298 | ARABIC_CHARSET = 178 299 | BALTIC_CHARSET = 186 300 | RUSSIAN_CHARSET = 204 301 | THAI_CHARSET = 222 302 | EASTEUROPE_CHARSET = 238 303 | OEM_CHARSET = 255 304 | JOHAB_CHARSET = 130 305 | VIETNAMESE_CHARSET = 163 306 | MAC_CHARSET = 77 307 | ) 308 | 309 | // Font output precision constants 310 | const ( 311 | OUT_DEFAULT_PRECIS = 0 312 | OUT_STRING_PRECIS = 1 313 | OUT_CHARACTER_PRECIS = 2 314 | OUT_STROKE_PRECIS = 3 315 | OUT_TT_PRECIS = 4 316 | OUT_DEVICE_PRECIS = 5 317 | OUT_RASTER_PRECIS = 6 318 | OUT_TT_ONLY_PRECIS = 7 319 | OUT_OUTLINE_PRECIS = 8 320 | OUT_PS_ONLY_PRECIS = 10 321 | ) 322 | 323 | // Font clipping precision constants 324 | const ( 325 | CLIP_DEFAULT_PRECIS = 0 326 | CLIP_CHARACTER_PRECIS = 1 327 | CLIP_STROKE_PRECIS = 2 328 | CLIP_MASK = 15 329 | CLIP_LH_ANGLES = 16 330 | CLIP_TT_ALWAYS = 32 331 | CLIP_EMBEDDED = 128 332 | ) 333 | 334 | // Font output quality constants 335 | const ( 336 | DEFAULT_QUALITY = 0 337 | DRAFT_QUALITY = 1 338 | PROOF_QUALITY = 2 339 | NONANTIALIASED_QUALITY = 3 340 | ANTIALIASED_QUALITY = 4 341 | CLEARTYPE_QUALITY = 5 342 | ) 343 | 344 | // Font pitch constants 345 | const ( 346 | DEFAULT_PITCH = 0 347 | FIXED_PITCH = 1 348 | VARIABLE_PITCH = 2 349 | ) 350 | 351 | // Font family constants 352 | const ( 353 | FF_DECORATIVE = 80 354 | FF_DONTCARE = 0 355 | FF_MODERN = 48 356 | FF_ROMAN = 16 357 | FF_SCRIPT = 64 358 | FF_SWISS = 32 359 | ) 360 | 361 | // DeviceCapabilities capabilities 362 | const ( 363 | DC_FIELDS = 1 364 | DC_PAPERS = 2 365 | DC_PAPERSIZE = 3 366 | DC_MINEXTENT = 4 367 | DC_MAXEXTENT = 5 368 | DC_BINS = 6 369 | DC_DUPLEX = 7 370 | DC_SIZE = 8 371 | DC_EXTRA = 9 372 | DC_VERSION = 10 373 | DC_DRIVER = 11 374 | DC_BINNAMES = 12 375 | DC_ENUMRESOLUTIONS = 13 376 | DC_FILEDEPENDENCIES = 14 377 | DC_TRUETYPE = 15 378 | DC_PAPERNAMES = 16 379 | DC_ORIENTATION = 17 380 | DC_COPIES = 18 381 | DC_BINADJUST = 19 382 | DC_EMF_COMPLIANT = 20 383 | DC_DATATYPE_PRODUCED = 21 384 | DC_COLLATE = 22 385 | DC_MANUFACTURER = 23 386 | DC_MODEL = 24 387 | DC_PERSONALITY = 25 388 | DC_PRINTRATE = 26 389 | DC_PRINTRATEUNIT = 27 390 | DC_PRINTERMEM = 28 391 | DC_MEDIAREADY = 29 392 | DC_STAPLE = 30 393 | DC_PRINTRATEPPM = 31 394 | DC_COLORDEVICE = 32 395 | DC_NUP = 33 396 | DC_MEDIATYPENAMES = 34 397 | DC_MEDIATYPES = 35 398 | ) 399 | 400 | const ( 401 | CCHDEVICENAME = 32 402 | CCHFORMNAME = 32 403 | ) 404 | 405 | const ( 406 | DM_UPDATE = 1 407 | DM_COPY = 2 408 | DM_PROMPT = 4 409 | DM_MODIFY = 8 410 | DM_IN_BUFFER = DM_MODIFY 411 | DM_IN_PROMPT = DM_PROMPT 412 | DM_OUT_BUFFER = DM_COPY 413 | DM_OUT_DEFAULT = DM_UPDATE 414 | ) 415 | 416 | // DEVMODE field selection bits 417 | const ( 418 | DM_ORIENTATION = 0x00000001 419 | DM_PAPERSIZE = 0x00000002 420 | DM_PAPERLENGTH = 0x00000004 421 | DM_PAPERWIDTH = 0x00000008 422 | DM_SCALE = 0x00000010 423 | DM_POSITION = 0x00000020 424 | DM_NUP = 0x00000040 425 | DM_DISPLAYORIENTATION = 0x00000080 426 | DM_COPIES = 0x00000100 427 | DM_DEFAULTSOURCE = 0x00000200 428 | DM_PRINTQUALITY = 0x00000400 429 | DM_COLOR = 0x00000800 430 | DM_DUPLEX = 0x00001000 431 | DM_YRESOLUTION = 0x00002000 432 | DM_TTOPTION = 0x00004000 433 | DM_COLLATE = 0x00008000 434 | DM_FORMNAME = 0x00010000 435 | DM_LOGPIXELS = 0x00020000 436 | DM_BITSPERPEL = 0x00040000 437 | DM_PELSWIDTH = 0x00080000 438 | DM_PELSHEIGHT = 0x00100000 439 | DM_DISPLAYFLAGS = 0x00200000 440 | DM_DISPLAYFREQUENCY = 0x00400000 441 | DM_ICMMETHOD = 0x00800000 442 | DM_ICMINTENT = 0x01000000 443 | DM_MEDIATYPE = 0x02000000 444 | DM_DITHERTYPE = 0x04000000 445 | DM_PANNINGWIDTH = 0x08000000 446 | DM_PANNINGHEIGHT = 0x10000000 447 | DM_DISPLAYFIXEDOUTPUT = 0x20000000 448 | ) 449 | 450 | // Orientation constants 451 | const ( 452 | DMORIENT_PORTRAIT = 1 453 | DMORIENT_LANDSCAPE = 2 454 | ) 455 | 456 | // Paper sizes 457 | const ( 458 | DMPAPER_FIRST = DMPAPER_LETTER 459 | DMPAPER_LETTER = 1 /* Letter 8 1/2 x 11 in */ 460 | DMPAPER_LETTERSMALL = 2 /* Letter Small 8 1/2 x 11 in */ 461 | DMPAPER_TABLOID = 3 /* Tabloid 11 x 17 in */ 462 | DMPAPER_LEDGER = 4 /* Ledger 17 x 11 in */ 463 | DMPAPER_LEGAL = 5 /* Legal 8 1/2 x 14 in */ 464 | DMPAPER_STATEMENT = 6 /* Statement 5 1/2 x 8 1/2 in */ 465 | DMPAPER_EXECUTIVE = 7 /* Executive 7 1/4 x 10 1/2 in */ 466 | DMPAPER_A3 = 8 /* A3 297 x 420 mm */ 467 | DMPAPER_A4 = 9 /* A4 210 x 297 mm */ 468 | DMPAPER_A4SMALL = 10 /* A4 Small 210 x 297 mm */ 469 | DMPAPER_A5 = 11 /* A5 148 x 210 mm */ 470 | DMPAPER_B4 = 12 /* B4 (JIS) 250 x 354 */ 471 | DMPAPER_B5 = 13 /* B5 (JIS) 182 x 257 mm */ 472 | DMPAPER_FOLIO = 14 /* Folio 8 1/2 x 13 in */ 473 | DMPAPER_QUARTO = 15 /* Quarto 215 x 275 mm */ 474 | DMPAPER_10X14 = 16 /* 10x14 in */ 475 | DMPAPER_11X17 = 17 /* 11x17 in */ 476 | DMPAPER_NOTE = 18 /* Note 8 1/2 x 11 in */ 477 | DMPAPER_ENV_9 = 19 /* Envelope #9 3 7/8 x 8 7/8 */ 478 | DMPAPER_ENV_10 = 20 /* Envelope #10 4 1/8 x 9 1/2 */ 479 | DMPAPER_ENV_11 = 21 /* Envelope #11 4 1/2 x 10 3/8 */ 480 | DMPAPER_ENV_12 = 22 /* Envelope #12 4 \276 x 11 */ 481 | DMPAPER_ENV_14 = 23 /* Envelope #14 5 x 11 1/2 */ 482 | DMPAPER_CSHEET = 24 /* C size sheet */ 483 | DMPAPER_DSHEET = 25 /* D size sheet */ 484 | DMPAPER_ESHEET = 26 /* E size sheet */ 485 | DMPAPER_ENV_DL = 27 /* Envelope DL 110 x 220mm */ 486 | DMPAPER_ENV_C5 = 28 /* Envelope C5 162 x 229 mm */ 487 | DMPAPER_ENV_C3 = 29 /* Envelope C3 324 x 458 mm */ 488 | DMPAPER_ENV_C4 = 30 /* Envelope C4 229 x 324 mm */ 489 | DMPAPER_ENV_C6 = 31 /* Envelope C6 114 x 162 mm */ 490 | DMPAPER_ENV_C65 = 32 /* Envelope C65 114 x 229 mm */ 491 | DMPAPER_ENV_B4 = 33 /* Envelope B4 250 x 353 mm */ 492 | DMPAPER_ENV_B5 = 34 /* Envelope B5 176 x 250 mm */ 493 | DMPAPER_ENV_B6 = 35 /* Envelope B6 176 x 125 mm */ 494 | DMPAPER_ENV_ITALY = 36 /* Envelope 110 x 230 mm */ 495 | DMPAPER_ENV_MONARCH = 37 /* Envelope Monarch 3.875 x 7.5 in */ 496 | DMPAPER_ENV_PERSONAL = 38 /* 6 3/4 Envelope 3 5/8 x 6 1/2 in */ 497 | DMPAPER_FANFOLD_US = 39 /* US Std Fanfold 14 7/8 x 11 in */ 498 | DMPAPER_FANFOLD_STD_GERMAN = 40 /* German Std Fanfold 8 1/2 x 12 in */ 499 | DMPAPER_FANFOLD_LGL_GERMAN = 41 /* German Legal Fanfold 8 1/2 x 13 in */ 500 | DMPAPER_ISO_B4 = 42 /* B4 (ISO) 250 x 353 mm */ 501 | DMPAPER_JAPANESE_POSTCARD = 43 /* Japanese Postcard 100 x 148 mm */ 502 | DMPAPER_9X11 = 44 /* 9 x 11 in */ 503 | DMPAPER_10X11 = 45 /* 10 x 11 in */ 504 | DMPAPER_15X11 = 46 /* 15 x 11 in */ 505 | DMPAPER_ENV_INVITE = 47 /* Envelope Invite 220 x 220 mm */ 506 | DMPAPER_RESERVED_48 = 48 /* RESERVED--DO NOT USE */ 507 | DMPAPER_RESERVED_49 = 49 /* RESERVED--DO NOT USE */ 508 | DMPAPER_LETTER_EXTRA = 50 /* Letter Extra 9 \275 x 12 in */ 509 | DMPAPER_LEGAL_EXTRA = 51 /* Legal Extra 9 \275 x 15 in */ 510 | DMPAPER_TABLOID_EXTRA = 52 /* Tabloid Extra 11.69 x 18 in */ 511 | DMPAPER_A4_EXTRA = 53 /* A4 Extra 9.27 x 12.69 in */ 512 | DMPAPER_LETTER_TRANSVERSE = 54 /* Letter Transverse 8 \275 x 11 in */ 513 | DMPAPER_A4_TRANSVERSE = 55 /* A4 Transverse 210 x 297 mm */ 514 | DMPAPER_LETTER_EXTRA_TRANSVERSE = 56 /* Letter Extra Transverse 9\275 x 12 in */ 515 | DMPAPER_A_PLUS = 57 /* SuperA/SuperA/A4 227 x 356 mm */ 516 | DMPAPER_B_PLUS = 58 /* SuperB/SuperB/A3 305 x 487 mm */ 517 | DMPAPER_LETTER_PLUS = 59 /* Letter Plus 8.5 x 12.69 in */ 518 | DMPAPER_A4_PLUS = 60 /* A4 Plus 210 x 330 mm */ 519 | DMPAPER_A5_TRANSVERSE = 61 /* A5 Transverse 148 x 210 mm */ 520 | DMPAPER_B5_TRANSVERSE = 62 /* B5 (JIS) Transverse 182 x 257 mm */ 521 | DMPAPER_A3_EXTRA = 63 /* A3 Extra 322 x 445 mm */ 522 | DMPAPER_A5_EXTRA = 64 /* A5 Extra 174 x 235 mm */ 523 | DMPAPER_B5_EXTRA = 65 /* B5 (ISO) Extra 201 x 276 mm */ 524 | DMPAPER_A2 = 66 /* A2 420 x 594 mm */ 525 | DMPAPER_A3_TRANSVERSE = 67 /* A3 Transverse 297 x 420 mm */ 526 | DMPAPER_A3_EXTRA_TRANSVERSE = 68 /* A3 Extra Transverse 322 x 445 mm */ 527 | DMPAPER_DBL_JAPANESE_POSTCARD = 69 /* Japanese Double Postcard 200 x 148 mm */ 528 | DMPAPER_A6 = 70 /* A6 105 x 148 mm */ 529 | DMPAPER_JENV_KAKU2 = 71 /* Japanese Envelope Kaku #2 */ 530 | DMPAPER_JENV_KAKU3 = 72 /* Japanese Envelope Kaku #3 */ 531 | DMPAPER_JENV_CHOU3 = 73 /* Japanese Envelope Chou #3 */ 532 | DMPAPER_JENV_CHOU4 = 74 /* Japanese Envelope Chou #4 */ 533 | DMPAPER_LETTER_ROTATED = 75 /* Letter Rotated 11 x 8 1/2 11 in */ 534 | DMPAPER_A3_ROTATED = 76 /* A3 Rotated 420 x 297 mm */ 535 | DMPAPER_A4_ROTATED = 77 /* A4 Rotated 297 x 210 mm */ 536 | DMPAPER_A5_ROTATED = 78 /* A5 Rotated 210 x 148 mm */ 537 | DMPAPER_B4_JIS_ROTATED = 79 /* B4 (JIS) Rotated 364 x 257 mm */ 538 | DMPAPER_B5_JIS_ROTATED = 80 /* B5 (JIS) Rotated 257 x 182 mm */ 539 | DMPAPER_JAPANESE_POSTCARD_ROTATED = 81 /* Japanese Postcard Rotated 148 x 100 mm */ 540 | DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED = 82 /* Double Japanese Postcard Rotated 148 x 200 mm */ 541 | DMPAPER_A6_ROTATED = 83 /* A6 Rotated 148 x 105 mm */ 542 | DMPAPER_JENV_KAKU2_ROTATED = 84 /* Japanese Envelope Kaku #2 Rotated */ 543 | DMPAPER_JENV_KAKU3_ROTATED = 85 /* Japanese Envelope Kaku #3 Rotated */ 544 | DMPAPER_JENV_CHOU3_ROTATED = 86 /* Japanese Envelope Chou #3 Rotated */ 545 | DMPAPER_JENV_CHOU4_ROTATED = 87 /* Japanese Envelope Chou #4 Rotated */ 546 | DMPAPER_B6_JIS = 88 /* B6 (JIS) 128 x 182 mm */ 547 | DMPAPER_B6_JIS_ROTATED = 89 /* B6 (JIS) Rotated 182 x 128 mm */ 548 | DMPAPER_12X11 = 90 /* 12 x 11 in */ 549 | DMPAPER_JENV_YOU4 = 91 /* Japanese Envelope You #4 */ 550 | DMPAPER_JENV_YOU4_ROTATED = 92 /* Japanese Envelope You #4 Rotated*/ 551 | DMPAPER_P16K = 93 /* PRC 16K 146 x 215 mm */ 552 | DMPAPER_P32K = 94 /* PRC 32K 97 x 151 mm */ 553 | DMPAPER_P32KBIG = 95 /* PRC 32K(Big) 97 x 151 mm */ 554 | DMPAPER_PENV_1 = 96 /* PRC Envelope #1 102 x 165 mm */ 555 | DMPAPER_PENV_2 = 97 /* PRC Envelope #2 102 x 176 mm */ 556 | DMPAPER_PENV_3 = 98 /* PRC Envelope #3 125 x 176 mm */ 557 | DMPAPER_PENV_4 = 99 /* PRC Envelope #4 110 x 208 mm */ 558 | DMPAPER_PENV_5 = 100 /* PRC Envelope #5 110 x 220 mm */ 559 | DMPAPER_PENV_6 = 101 /* PRC Envelope #6 120 x 230 mm */ 560 | DMPAPER_PENV_7 = 102 /* PRC Envelope #7 160 x 230 mm */ 561 | DMPAPER_PENV_8 = 103 /* PRC Envelope #8 120 x 309 mm */ 562 | DMPAPER_PENV_9 = 104 /* PRC Envelope #9 229 x 324 mm */ 563 | DMPAPER_PENV_10 = 105 /* PRC Envelope #10 324 x 458 mm */ 564 | DMPAPER_P16K_ROTATED = 106 /* PRC 16K Rotated */ 565 | DMPAPER_P32K_ROTATED = 107 /* PRC 32K Rotated */ 566 | DMPAPER_P32KBIG_ROTATED = 108 /* PRC 32K(Big) Rotated */ 567 | DMPAPER_PENV_1_ROTATED = 109 /* PRC Envelope #1 Rotated 165 x 102 mm */ 568 | DMPAPER_PENV_2_ROTATED = 110 /* PRC Envelope #2 Rotated 176 x 102 mm */ 569 | DMPAPER_PENV_3_ROTATED = 111 /* PRC Envelope #3 Rotated 176 x 125 mm */ 570 | DMPAPER_PENV_4_ROTATED = 112 /* PRC Envelope #4 Rotated 208 x 110 mm */ 571 | DMPAPER_PENV_5_ROTATED = 113 /* PRC Envelope #5 Rotated 220 x 110 mm */ 572 | DMPAPER_PENV_6_ROTATED = 114 /* PRC Envelope #6 Rotated 230 x 120 mm */ 573 | DMPAPER_PENV_7_ROTATED = 115 /* PRC Envelope #7 Rotated 230 x 160 mm */ 574 | DMPAPER_PENV_8_ROTATED = 116 /* PRC Envelope #8 Rotated 309 x 120 mm */ 575 | DMPAPER_PENV_9_ROTATED = 117 /* PRC Envelope #9 Rotated 324 x 229 mm */ 576 | DMPAPER_PENV_10_ROTATED = 118 /* PRC Envelope #10 Rotated 458 x 324 mm */ 577 | DMPAPER_LAST = DMPAPER_PENV_10_ROTATED 578 | DMPAPER_USER = 256 579 | ) 580 | 581 | // Bin constants 582 | const ( 583 | DMBIN_FIRST = DMBIN_UPPER 584 | DMBIN_UPPER = 1 585 | DMBIN_ONLYONE = 1 586 | DMBIN_LOWER = 2 587 | DMBIN_MIDDLE = 3 588 | DMBIN_MANUAL = 4 589 | DMBIN_ENVELOPE = 5 590 | DMBIN_ENVMANUAL = 6 591 | DMBIN_AUTO = 7 592 | DMBIN_TRACTOR = 8 593 | DMBIN_SMALLFMT = 9 594 | DMBIN_LARGEFMT = 10 595 | DMBIN_LARGECAPACITY = 11 596 | DMBIN_CASSETTE = 14 597 | DMBIN_FORMSOURCE = 15 598 | DMBIN_LAST = DMBIN_FORMSOURCE 599 | DMBIN_USER = 256 600 | ) 601 | 602 | // Quality constants 603 | const ( 604 | DMRES_DRAFT = -1 605 | DMRES_LOW = -2 606 | DMRES_MEDIUM = -3 607 | DMRES_HIGH = -4 608 | ) 609 | 610 | // Color/monochrome constants 611 | const ( 612 | DMCOLOR_MONOCHROME = 1 613 | DMCOLOR_COLOR = 2 614 | ) 615 | 616 | // Duplex constants 617 | const ( 618 | DMDUP_SIMPLEX = 1 619 | DMDUP_VERTICAL = 2 620 | DMDUP_HORIZONTAL = 3 621 | ) 622 | 623 | // TrueType constants 624 | const ( 625 | DMTT_BITMAP = 1 626 | DMTT_DOWNLOAD = 2 627 | DMTT_SUBDEV = 3 628 | DMTT_DOWNLOAD_OUTLINE = 4 629 | ) 630 | 631 | // Collation constants 632 | const ( 633 | DMCOLLATE_FALSE = 0 634 | DMCOLLATE_TRUE = 1 635 | ) 636 | 637 | // Background modes 638 | const ( 639 | TRANSPARENT = 1 640 | OPAQUE = 2 641 | ) 642 | 643 | // Ternary raster operations 644 | const ( 645 | SRCCOPY = 0x00CC0020 646 | SRCPAINT = 0x00EE0086 647 | SRCAND = 0x008800C6 648 | SRCINVERT = 0x00660046 649 | SRCERASE = 0x00440328 650 | NOTSRCCOPY = 0x00330008 651 | NOTSRCERASE = 0x001100A6 652 | MERGECOPY = 0x00C000CA 653 | MERGEPAINT = 0x00BB0226 654 | PATCOPY = 0x00F00021 655 | PATPAINT = 0x00FB0A09 656 | PATINVERT = 0x005A0049 657 | DSTINVERT = 0x00550009 658 | BLACKNESS = 0x00000042 659 | WHITENESS = 0x00FF0062 660 | NOMIRRORBITMAP = 0x80000000 661 | CAPTUREBLT = 0x40000000 662 | ) 663 | 664 | // StretchBlt modes 665 | const ( 666 | BLACKONWHITE = 1 667 | WHITEONBLACK = 2 668 | COLORONCOLOR = 3 669 | HALFTONE = 4 670 | MAXSTRETCHBLTMODE = 4 671 | STRETCH_ANDSCANS = BLACKONWHITE 672 | STRETCH_ORSCANS = WHITEONBLACK 673 | STRETCH_DELETESCANS = COLORONCOLOR 674 | STRETCH_HALFTONE = HALFTONE 675 | ) 676 | 677 | // Bitmap compression constants 678 | const ( 679 | BI_RGB = 0 680 | BI_RLE8 = 1 681 | BI_RLE4 = 2 682 | BI_BITFIELDS = 3 683 | BI_JPEG = 4 684 | BI_PNG = 5 685 | ) 686 | 687 | // Bitmap color table usage 688 | const ( 689 | DIB_RGB_COLORS = 0 690 | DIB_PAL_COLORS = 1 691 | ) 692 | 693 | const CBM_INIT = 4 694 | 695 | const CLR_INVALID = 0xFFFFFFFF 696 | 697 | const ( 698 | /* pixel types */ 699 | PFD_TYPE_RGBA = 0 700 | PFD_TYPE_COLORINDEX = 1 701 | 702 | /* layer types */ 703 | PFD_MAIN_PLANE = 0 704 | PFD_OVERLAY_PLANE = 1 705 | PFD_UNDERLAY_PLANE = (-1) 706 | 707 | /* PIXELFORMATDESCRIPTOR flags */ 708 | PFD_DOUBLEBUFFER = 0x00000001 709 | PFD_STEREO = 0x00000002 710 | PFD_DRAW_TO_WINDOW = 0x00000004 711 | PFD_DRAW_TO_BITMAP = 0x00000008 712 | PFD_SUPPORT_GDI = 0x00000010 713 | PFD_SUPPORT_OPENGL = 0x00000020 714 | PFD_GENERIC_FORMAT = 0x00000040 715 | PFD_NEED_PALETTE = 0x00000080 716 | PFD_NEED_SYSTEM_PALETTE = 0x00000100 717 | PFD_SWAP_EXCHANGE = 0x00000200 718 | PFD_SWAP_COPY = 0x00000400 719 | PFD_SWAP_LAYER_BUFFERS = 0x00000800 720 | PFD_GENERIC_ACCELERATED = 0x00001000 721 | PFD_SUPPORT_DIRECTDRAW = 0x00002000 722 | 723 | /* PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only */ 724 | PFD_DEPTH_DONTCARE = 0x20000000 725 | PFD_DOUBLEBUFFER_DONTCARE = 0x40000000 726 | PFD_STEREO_DONTCARE = 0x80000000 727 | ) 728 | 729 | type ( 730 | COLORREF uint32 731 | HBITMAP HGDIOBJ 732 | HBRUSH HGDIOBJ 733 | HRGN HGDIOBJ 734 | HDC HANDLE 735 | HFONT HGDIOBJ 736 | HGDIOBJ HANDLE 737 | HENHMETAFILE HANDLE 738 | HPALETTE HGDIOBJ 739 | HPEN HGDIOBJ 740 | HREGION HGDIOBJ 741 | ) 742 | 743 | type PIXELFORMATDESCRIPTOR struct { 744 | NSize uint16 745 | NVersion uint16 746 | DwFlags uint32 747 | IPixelType byte 748 | CColorBits byte 749 | CRedBits byte 750 | CRedShift byte 751 | CGreenBits byte 752 | CGreenShift byte 753 | CBlueBits byte 754 | CBlueShift byte 755 | CAlphaBits byte 756 | CAlphaShift byte 757 | CAccumBits byte 758 | CAccumRedBits byte 759 | CAccumGreenBits byte 760 | CAccumBlueBits byte 761 | CAccumAlphaBits byte 762 | CDepthBits byte 763 | CStencilBits byte 764 | CAuxBuffers byte 765 | ILayerType byte 766 | BReserved byte 767 | DwLayerMask uint32 768 | DwVisibleMask uint32 769 | DwDamageMask uint32 770 | } 771 | 772 | type LOGFONT struct { 773 | LfHeight int32 774 | LfWidth int32 775 | LfEscapement int32 776 | LfOrientation int32 777 | LfWeight int32 778 | LfItalic byte 779 | LfUnderline byte 780 | LfStrikeOut byte 781 | LfCharSet byte 782 | LfOutPrecision byte 783 | LfClipPrecision byte 784 | LfQuality byte 785 | LfPitchAndFamily byte 786 | LfFaceName [LF_FACESIZE]uint16 787 | } 788 | 789 | type TEXTMETRIC struct { 790 | TmHeight int32 791 | TmAscent int32 792 | TmDescent int32 793 | TmInternalLeading int32 794 | TmExternalLeading int32 795 | TmAveCharWidth int32 796 | TmMaxCharWidth int32 797 | TmWeight int32 798 | TmOverhang int32 799 | TmDigitizedAspectX int32 800 | TmDigitizedAspectY int32 801 | TmFirstChar uint16 802 | TmLastChar uint16 803 | TmDefaultChar uint16 804 | TmBreakChar uint16 805 | TmItalic byte 806 | TmUnderlined byte 807 | TmStruckOut byte 808 | TmPitchAndFamily byte 809 | TmCharSet byte 810 | } 811 | 812 | type DEVMODE struct { 813 | DmDeviceName [CCHDEVICENAME]uint16 814 | DmSpecVersion uint16 815 | DmDriverVersion uint16 816 | DmSize uint16 817 | DmDriverExtra uint16 818 | DmFields uint32 819 | DmOrientation int16 820 | DmPaperSize int16 821 | DmPaperLength int16 822 | DmPaperWidth int16 823 | DmScale int16 824 | DmCopies int16 825 | DmDefaultSource int16 826 | DmPrintQuality int16 827 | DmColor int16 828 | DmDuplex int16 829 | DmYResolution int16 830 | DmTTOption int16 831 | DmCollate int16 832 | DmFormName [CCHFORMNAME]uint16 833 | DmLogPixels uint16 834 | DmBitsPerPel uint32 835 | DmPelsWidth uint32 836 | DmPelsHeight uint32 837 | DmDisplayFlags uint32 838 | DmDisplayFrequency uint32 839 | DmICMMethod uint32 840 | DmICMIntent uint32 841 | DmMediaType uint32 842 | DmDitherType uint32 843 | DmReserved1 uint32 844 | DmReserved2 uint32 845 | DmPanningWidth uint32 846 | DmPanningHeight uint32 847 | } 848 | 849 | type POINT struct { 850 | X, Y int32 851 | } 852 | 853 | type RECT struct { 854 | Left, Top, Right, Bottom int32 855 | } 856 | 857 | type SIZE struct { 858 | CX, CY int32 859 | } 860 | 861 | type DOCINFO struct { 862 | CbSize int32 863 | LpszDocName *uint16 864 | LpszOutput *uint16 865 | LpszDatatype *uint16 866 | FwType uint32 867 | } 868 | 869 | type LOGBRUSH struct { 870 | LbStyle uint32 871 | LbColor COLORREF 872 | LbHatch uintptr 873 | } 874 | 875 | type CIEXYZ struct { 876 | CiexyzX, CiexyzY, CiexyzZ int32 // FXPT2DOT30 877 | } 878 | 879 | type CIEXYZTRIPLE struct { 880 | CiexyzRed, CiexyzGreen, CiexyzBlue CIEXYZ 881 | } 882 | 883 | type BITMAPINFOHEADER struct { 884 | BiSize uint32 885 | BiWidth int32 886 | BiHeight int32 887 | BiPlanes uint16 888 | BiBitCount uint16 889 | BiCompression uint32 890 | BiSizeImage uint32 891 | BiXPelsPerMeter int32 892 | BiYPelsPerMeter int32 893 | BiClrUsed uint32 894 | BiClrImportant uint32 895 | } 896 | 897 | type BITMAPV4HEADER struct { 898 | BITMAPINFOHEADER 899 | BV4RedMask uint32 900 | BV4GreenMask uint32 901 | BV4BlueMask uint32 902 | BV4AlphaMask uint32 903 | BV4CSType uint32 904 | BV4Endpoints CIEXYZTRIPLE 905 | BV4GammaRed uint32 906 | BV4GammaGreen uint32 907 | BV4GammaBlue uint32 908 | } 909 | 910 | type BITMAPV5HEADER struct { 911 | BITMAPV4HEADER 912 | BV5Intent uint32 913 | BV5ProfileData uint32 914 | BV5ProfileSize uint32 915 | BV5Reserved uint32 916 | } 917 | 918 | type RGBQUAD struct { 919 | RgbBlue byte 920 | RgbGreen byte 921 | RgbRed byte 922 | RgbReserved byte 923 | } 924 | 925 | type BITMAPINFO struct { 926 | BmiHeader BITMAPINFOHEADER 927 | BmiColors *RGBQUAD 928 | } 929 | 930 | type BITMAP struct { 931 | BmType int32 932 | BmWidth int32 933 | BmHeight int32 934 | BmWidthBytes int32 935 | BmPlanes uint16 936 | BmBitsPixel uint16 937 | BmBits unsafe.Pointer 938 | } 939 | 940 | type DIBSECTION struct { 941 | DsBm BITMAP 942 | DsBmih BITMAPINFOHEADER 943 | DsBitfields [3]uint32 944 | DshSection HANDLE 945 | DsOffset uint32 946 | } 947 | 948 | type ENHMETAHEADER struct { 949 | IType uint32 950 | NSize uint32 951 | RclBounds RECT 952 | RclFrame RECT 953 | DSignature uint32 954 | NVersion uint32 955 | NBytes uint32 956 | NRecords uint32 957 | NHandles uint16 958 | SReserved uint16 959 | NDescription uint32 960 | OffDescription uint32 961 | NPalEntries uint32 962 | SzlDevice SIZE 963 | SzlMillimeters SIZE 964 | CbPixelFormat uint32 965 | OffPixelFormat uint32 966 | BOpenGL uint32 967 | SzlMicrometers SIZE 968 | } 969 | 970 | var ( 971 | // Library 972 | libgdi32 uintptr 973 | 974 | // Functions 975 | abortDoc uintptr 976 | bitBlt uintptr 977 | choosePixelFormat uintptr 978 | closeEnhMetaFile uintptr 979 | copyEnhMetaFile uintptr 980 | createBitmap uintptr 981 | createBrushIndirect uintptr 982 | createCompatibleDC uintptr 983 | createDC uintptr 984 | createDIBSection uintptr 985 | createFontIndirect uintptr 986 | createEnhMetaFile uintptr 987 | createIC uintptr 988 | deleteDC uintptr 989 | deleteEnhMetaFile uintptr 990 | deleteObject uintptr 991 | ellipse uintptr 992 | endDoc uintptr 993 | endPage uintptr 994 | extCreatePen uintptr 995 | getDeviceCaps uintptr 996 | getEnhMetaFile uintptr 997 | getEnhMetaFileHeader uintptr 998 | getObject uintptr 999 | getStockObject uintptr 1000 | getTextExtentExPoint uintptr 1001 | getTextExtentPoint32 uintptr 1002 | getTextMetrics uintptr 1003 | lineTo uintptr 1004 | moveToEx uintptr 1005 | playEnhMetaFile uintptr 1006 | rectangle uintptr 1007 | resetDC uintptr 1008 | restoreDC uintptr 1009 | selectObject uintptr 1010 | setBkMode uintptr 1011 | setBrushOrgEx uintptr 1012 | setPixelFormat uintptr 1013 | setStretchBltMode uintptr 1014 | setTextColor uintptr 1015 | saveDC uintptr 1016 | startDoc uintptr 1017 | startPage uintptr 1018 | stretchBlt uintptr 1019 | swapBuffers uintptr 1020 | textOut uintptr 1021 | ) 1022 | 1023 | func init() { 1024 | // Library 1025 | libgdi32 = MustLoadLibrary("gdi32.dll") 1026 | 1027 | // Functions 1028 | abortDoc = MustGetProcAddress(libgdi32, "AbortDoc") 1029 | bitBlt = MustGetProcAddress(libgdi32, "BitBlt") 1030 | choosePixelFormat = MustGetProcAddress(libgdi32, "ChoosePixelFormat") 1031 | closeEnhMetaFile = MustGetProcAddress(libgdi32, "CloseEnhMetaFile") 1032 | copyEnhMetaFile = MustGetProcAddress(libgdi32, "CopyEnhMetaFileW") 1033 | createBitmap = MustGetProcAddress(libgdi32, "CreateBitmap") 1034 | createBrushIndirect = MustGetProcAddress(libgdi32, "CreateBrushIndirect") 1035 | createCompatibleDC = MustGetProcAddress(libgdi32, "CreateCompatibleDC") 1036 | createDC = MustGetProcAddress(libgdi32, "CreateDCW") 1037 | createDIBSection = MustGetProcAddress(libgdi32, "CreateDIBSection") 1038 | createEnhMetaFile = MustGetProcAddress(libgdi32, "CreateEnhMetaFileW") 1039 | createFontIndirect = MustGetProcAddress(libgdi32, "CreateFontIndirectW") 1040 | createIC = MustGetProcAddress(libgdi32, "CreateICW") 1041 | deleteDC = MustGetProcAddress(libgdi32, "DeleteDC") 1042 | deleteEnhMetaFile = MustGetProcAddress(libgdi32, "DeleteEnhMetaFile") 1043 | deleteObject = MustGetProcAddress(libgdi32, "DeleteObject") 1044 | ellipse = MustGetProcAddress(libgdi32, "Ellipse") 1045 | endDoc = MustGetProcAddress(libgdi32, "EndDoc") 1046 | endPage = MustGetProcAddress(libgdi32, "EndPage") 1047 | extCreatePen = MustGetProcAddress(libgdi32, "ExtCreatePen") 1048 | getDeviceCaps = MustGetProcAddress(libgdi32, "GetDeviceCaps") 1049 | getEnhMetaFile = MustGetProcAddress(libgdi32, "GetEnhMetaFileW") 1050 | getEnhMetaFileHeader = MustGetProcAddress(libgdi32, "GetEnhMetaFileHeader") 1051 | getObject = MustGetProcAddress(libgdi32, "GetObjectW") 1052 | getStockObject = MustGetProcAddress(libgdi32, "GetStockObject") 1053 | getTextExtentExPoint = MustGetProcAddress(libgdi32, "GetTextExtentExPointW") 1054 | getTextExtentPoint32 = MustGetProcAddress(libgdi32, "GetTextExtentPoint32W") 1055 | getTextMetrics = MustGetProcAddress(libgdi32, "GetTextMetricsW") 1056 | lineTo = MustGetProcAddress(libgdi32, "LineTo") 1057 | moveToEx = MustGetProcAddress(libgdi32, "MoveToEx") 1058 | playEnhMetaFile = MustGetProcAddress(libgdi32, "PlayEnhMetaFile") 1059 | rectangle = MustGetProcAddress(libgdi32, "Rectangle") 1060 | resetDC = MustGetProcAddress(libgdi32, "ResetDCW") 1061 | restoreDC = MustGetProcAddress(libgdi32, "RestoreDC") 1062 | saveDC = MustGetProcAddress(libgdi32, "SaveDC") 1063 | selectObject = MustGetProcAddress(libgdi32, "SelectObject") 1064 | setBkMode = MustGetProcAddress(libgdi32, "SetBkMode") 1065 | setBrushOrgEx = MustGetProcAddress(libgdi32, "SetBrushOrgEx") 1066 | setPixelFormat = MustGetProcAddress(libgdi32, "SetPixelFormat") 1067 | setStretchBltMode = MustGetProcAddress(libgdi32, "SetStretchBltMode") 1068 | setTextColor = MustGetProcAddress(libgdi32, "SetTextColor") 1069 | startDoc = MustGetProcAddress(libgdi32, "StartDocW") 1070 | startPage = MustGetProcAddress(libgdi32, "StartPage") 1071 | stretchBlt = MustGetProcAddress(libgdi32, "StretchBlt") 1072 | swapBuffers = MustGetProcAddress(libgdi32, "SwapBuffers") 1073 | textOut = MustGetProcAddress(libgdi32, "TextOutW") 1074 | 1075 | } 1076 | 1077 | func AbortDoc(hdc HDC) int32 { 1078 | ret, _, _ := syscall.Syscall(abortDoc, 1, 1079 | uintptr(hdc), 1080 | 0, 1081 | 0) 1082 | 1083 | return int32(ret) 1084 | } 1085 | 1086 | func BitBlt(hdcDest HDC, nXDest, nYDest, nWidth, nHeight int32, hdcSrc HDC, nXSrc, nYSrc int32, dwRop uint32) bool { 1087 | ret, _, _ := syscall.Syscall9(bitBlt, 9, 1088 | uintptr(hdcDest), 1089 | uintptr(nXDest), 1090 | uintptr(nYDest), 1091 | uintptr(nWidth), 1092 | uintptr(nHeight), 1093 | uintptr(hdcSrc), 1094 | uintptr(nXSrc), 1095 | uintptr(nYSrc), 1096 | uintptr(dwRop)) 1097 | 1098 | return ret != 0 1099 | } 1100 | 1101 | func ChoosePixelFormat(hdc HDC, ppfd *PIXELFORMATDESCRIPTOR) int32 { 1102 | ret, _, _ := syscall.Syscall(choosePixelFormat, 2, 1103 | uintptr(hdc), 1104 | uintptr(unsafe.Pointer(ppfd)), 1105 | 0) 1106 | 1107 | return int32(ret) 1108 | } 1109 | 1110 | func CloseEnhMetaFile(hdc HDC) HENHMETAFILE { 1111 | ret, _, _ := syscall.Syscall(closeEnhMetaFile, 1, 1112 | uintptr(hdc), 1113 | 0, 1114 | 0) 1115 | 1116 | return HENHMETAFILE(ret) 1117 | } 1118 | 1119 | func CopyEnhMetaFile(hemfSrc HENHMETAFILE, lpszFile *uint16) HENHMETAFILE { 1120 | ret, _, _ := syscall.Syscall(copyEnhMetaFile, 2, 1121 | uintptr(hemfSrc), 1122 | uintptr(unsafe.Pointer(lpszFile)), 1123 | 0) 1124 | 1125 | return HENHMETAFILE(ret) 1126 | } 1127 | 1128 | func CreateBitmap(nWidth, nHeight int32, cPlanes, cBitsPerPel uint32, lpvBits unsafe.Pointer) HBITMAP { 1129 | ret, _, _ := syscall.Syscall6(createBitmap, 5, 1130 | uintptr(nWidth), 1131 | uintptr(nHeight), 1132 | uintptr(cPlanes), 1133 | uintptr(cBitsPerPel), 1134 | uintptr(lpvBits), 1135 | 0) 1136 | 1137 | return HBITMAP(ret) 1138 | } 1139 | 1140 | func CreateBrushIndirect(lplb *LOGBRUSH) HBRUSH { 1141 | ret, _, _ := syscall.Syscall(createBrushIndirect, 1, 1142 | uintptr(unsafe.Pointer(lplb)), 1143 | 0, 1144 | 0) 1145 | 1146 | return HBRUSH(ret) 1147 | } 1148 | 1149 | func CreateCompatibleDC(hdc HDC) HDC { 1150 | ret, _, _ := syscall.Syscall(createCompatibleDC, 1, 1151 | uintptr(hdc), 1152 | 0, 1153 | 0) 1154 | 1155 | return HDC(ret) 1156 | } 1157 | 1158 | func CreateDC(lpszDriver, lpszDevice, lpszOutput *uint16, lpInitData *DEVMODE) HDC { 1159 | ret, _, _ := syscall.Syscall6(createDC, 4, 1160 | uintptr(unsafe.Pointer(lpszDriver)), 1161 | uintptr(unsafe.Pointer(lpszDevice)), 1162 | uintptr(unsafe.Pointer(lpszOutput)), 1163 | uintptr(unsafe.Pointer(lpInitData)), 1164 | 0, 1165 | 0) 1166 | 1167 | return HDC(ret) 1168 | } 1169 | 1170 | func CreateDIBSection(hdc HDC, pbmih *BITMAPINFOHEADER, iUsage uint32, ppvBits *unsafe.Pointer, hSection HANDLE, dwOffset uint32) HBITMAP { 1171 | ret, _, _ := syscall.Syscall6(createDIBSection, 6, 1172 | uintptr(hdc), 1173 | uintptr(unsafe.Pointer(pbmih)), 1174 | uintptr(iUsage), 1175 | uintptr(unsafe.Pointer(ppvBits)), 1176 | uintptr(hSection), 1177 | uintptr(dwOffset)) 1178 | 1179 | return HBITMAP(ret) 1180 | } 1181 | 1182 | func CreateEnhMetaFile(hdcRef HDC, lpFilename *uint16, lpRect *RECT, lpDescription *uint16) HDC { 1183 | ret, _, _ := syscall.Syscall6(createEnhMetaFile, 4, 1184 | uintptr(hdcRef), 1185 | uintptr(unsafe.Pointer(lpFilename)), 1186 | uintptr(unsafe.Pointer(lpRect)), 1187 | uintptr(unsafe.Pointer(lpDescription)), 1188 | 0, 1189 | 0) 1190 | 1191 | return HDC(ret) 1192 | } 1193 | 1194 | func CreateFontIndirect(lplf *LOGFONT) HFONT { 1195 | ret, _, _ := syscall.Syscall(createFontIndirect, 1, 1196 | uintptr(unsafe.Pointer(lplf)), 1197 | 0, 1198 | 0) 1199 | 1200 | return HFONT(ret) 1201 | } 1202 | 1203 | func CreateIC(lpszDriver, lpszDevice, lpszOutput *uint16, lpdvmInit *DEVMODE) HDC { 1204 | ret, _, _ := syscall.Syscall6(createIC, 4, 1205 | uintptr(unsafe.Pointer(lpszDriver)), 1206 | uintptr(unsafe.Pointer(lpszDevice)), 1207 | uintptr(unsafe.Pointer(lpszOutput)), 1208 | uintptr(unsafe.Pointer(lpdvmInit)), 1209 | 0, 1210 | 0) 1211 | 1212 | return HDC(ret) 1213 | } 1214 | 1215 | func DeleteDC(hdc HDC) bool { 1216 | ret, _, _ := syscall.Syscall(deleteDC, 1, 1217 | uintptr(hdc), 1218 | 0, 1219 | 0) 1220 | 1221 | return ret != 0 1222 | } 1223 | 1224 | func DeleteEnhMetaFile(hemf HENHMETAFILE) bool { 1225 | ret, _, _ := syscall.Syscall(deleteEnhMetaFile, 1, 1226 | uintptr(hemf), 1227 | 0, 1228 | 0) 1229 | 1230 | return ret != 0 1231 | } 1232 | 1233 | func DeleteObject(hObject HGDIOBJ) bool { 1234 | ret, _, _ := syscall.Syscall(deleteObject, 1, 1235 | uintptr(hObject), 1236 | 0, 1237 | 0) 1238 | 1239 | return ret != 0 1240 | } 1241 | 1242 | func Ellipse(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool { 1243 | ret, _, _ := syscall.Syscall6(ellipse, 5, 1244 | uintptr(hdc), 1245 | uintptr(nLeftRect), 1246 | uintptr(nTopRect), 1247 | uintptr(nRightRect), 1248 | uintptr(nBottomRect), 1249 | 0) 1250 | 1251 | return ret != 0 1252 | } 1253 | 1254 | func EndDoc(hdc HDC) int32 { 1255 | ret, _, _ := syscall.Syscall(endDoc, 1, 1256 | uintptr(hdc), 1257 | 0, 1258 | 0) 1259 | 1260 | return int32(ret) 1261 | } 1262 | 1263 | func EndPage(hdc HDC) int32 { 1264 | ret, _, _ := syscall.Syscall(endPage, 1, 1265 | uintptr(hdc), 1266 | 0, 1267 | 0) 1268 | 1269 | return int32(ret) 1270 | } 1271 | 1272 | func ExtCreatePen(dwPenStyle, dwWidth uint32, lplb *LOGBRUSH, dwStyleCount uint32, lpStyle *uint32) HPEN { 1273 | ret, _, _ := syscall.Syscall6(extCreatePen, 5, 1274 | uintptr(dwPenStyle), 1275 | uintptr(dwWidth), 1276 | uintptr(unsafe.Pointer(lplb)), 1277 | uintptr(dwStyleCount), 1278 | uintptr(unsafe.Pointer(lpStyle)), 1279 | 0) 1280 | 1281 | return HPEN(ret) 1282 | } 1283 | 1284 | func GetDeviceCaps(hdc HDC, nIndex int32) int32 { 1285 | ret, _, _ := syscall.Syscall(getDeviceCaps, 2, 1286 | uintptr(hdc), 1287 | uintptr(nIndex), 1288 | 0) 1289 | 1290 | return int32(ret) 1291 | } 1292 | 1293 | func GetEnhMetaFile(lpszMetaFile *uint16) HENHMETAFILE { 1294 | ret, _, _ := syscall.Syscall(getEnhMetaFile, 1, 1295 | uintptr(unsafe.Pointer(lpszMetaFile)), 1296 | 0, 1297 | 0) 1298 | 1299 | return HENHMETAFILE(ret) 1300 | } 1301 | 1302 | func GetEnhMetaFileHeader(hemf HENHMETAFILE, cbBuffer uint32, lpemh *ENHMETAHEADER) uint32 { 1303 | ret, _, _ := syscall.Syscall(getEnhMetaFileHeader, 3, 1304 | uintptr(hemf), 1305 | uintptr(cbBuffer), 1306 | uintptr(unsafe.Pointer(lpemh))) 1307 | 1308 | return uint32(ret) 1309 | } 1310 | 1311 | func GetObject(hgdiobj HGDIOBJ, cbBuffer uintptr, lpvObject unsafe.Pointer) int32 { 1312 | ret, _, _ := syscall.Syscall(getObject, 3, 1313 | uintptr(hgdiobj), 1314 | uintptr(cbBuffer), 1315 | uintptr(lpvObject)) 1316 | 1317 | return int32(ret) 1318 | } 1319 | 1320 | func GetStockObject(fnObject int32) HGDIOBJ { 1321 | ret, _, _ := syscall.Syscall(getStockObject, 1, 1322 | uintptr(fnObject), 1323 | 0, 1324 | 0) 1325 | 1326 | return HGDIOBJ(ret) 1327 | } 1328 | 1329 | func GetTextExtentExPoint(hdc HDC, lpszStr *uint16, cchString, nMaxExtent int32, lpnFit, alpDx *int32, lpSize *SIZE) bool { 1330 | ret, _, _ := syscall.Syscall9(getTextExtentExPoint, 7, 1331 | uintptr(hdc), 1332 | uintptr(unsafe.Pointer(lpszStr)), 1333 | uintptr(cchString), 1334 | uintptr(nMaxExtent), 1335 | uintptr(unsafe.Pointer(lpnFit)), 1336 | uintptr(unsafe.Pointer(alpDx)), 1337 | uintptr(unsafe.Pointer(lpSize)), 1338 | 0, 1339 | 0) 1340 | 1341 | return ret != 0 1342 | } 1343 | 1344 | func GetTextExtentPoint32(hdc HDC, lpString *uint16, c int32, lpSize *SIZE) bool { 1345 | ret, _, _ := syscall.Syscall6(getTextExtentPoint32, 4, 1346 | uintptr(hdc), 1347 | uintptr(unsafe.Pointer(lpString)), 1348 | uintptr(c), 1349 | uintptr(unsafe.Pointer(lpSize)), 1350 | 0, 1351 | 0) 1352 | 1353 | return ret != 0 1354 | } 1355 | 1356 | func GetTextMetrics(hdc HDC, lptm *TEXTMETRIC) bool { 1357 | ret, _, _ := syscall.Syscall(getTextMetrics, 2, 1358 | uintptr(hdc), 1359 | uintptr(unsafe.Pointer(lptm)), 1360 | 0) 1361 | 1362 | return ret != 0 1363 | } 1364 | 1365 | func LineTo(hdc HDC, nXEnd, nYEnd int32) bool { 1366 | ret, _, _ := syscall.Syscall(lineTo, 3, 1367 | uintptr(hdc), 1368 | uintptr(nXEnd), 1369 | uintptr(nYEnd)) 1370 | 1371 | return ret != 0 1372 | } 1373 | 1374 | func MoveToEx(hdc HDC, x, y int32, lpPoint *POINT) bool { 1375 | ret, _, _ := syscall.Syscall6(moveToEx, 4, 1376 | uintptr(hdc), 1377 | uintptr(x), 1378 | uintptr(y), 1379 | uintptr(unsafe.Pointer(lpPoint)), 1380 | 0, 1381 | 0) 1382 | 1383 | return ret != 0 1384 | } 1385 | 1386 | func PlayEnhMetaFile(hdc HDC, hemf HENHMETAFILE, lpRect *RECT) bool { 1387 | ret, _, _ := syscall.Syscall(playEnhMetaFile, 3, 1388 | uintptr(hdc), 1389 | uintptr(hemf), 1390 | uintptr(unsafe.Pointer(lpRect))) 1391 | 1392 | return ret != 0 1393 | } 1394 | 1395 | func Rectangle_(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool { 1396 | ret, _, _ := syscall.Syscall6(rectangle, 5, 1397 | uintptr(hdc), 1398 | uintptr(nLeftRect), 1399 | uintptr(nTopRect), 1400 | uintptr(nRightRect), 1401 | uintptr(nBottomRect), 1402 | 0) 1403 | 1404 | return ret != 0 1405 | } 1406 | 1407 | func ResetDC(hdc HDC, lpInitData *DEVMODE) HDC { 1408 | ret, _, _ := syscall.Syscall(resetDC, 2, 1409 | uintptr(hdc), 1410 | uintptr(unsafe.Pointer(lpInitData)), 1411 | 0) 1412 | 1413 | return HDC(ret) 1414 | } 1415 | 1416 | func RestoreDC(hdc HDC, nSaveDC int32) bool { 1417 | ret, _, _ := syscall.Syscall(restoreDC, 2, 1418 | uintptr(hdc), 1419 | uintptr(nSaveDC), 1420 | 0) 1421 | return ret != 0 1422 | } 1423 | 1424 | func SaveDC(hdc HDC) int32 { 1425 | ret, _, _ := syscall.Syscall(saveDC, 1, 1426 | uintptr(hdc), 1427 | 0, 1428 | 0) 1429 | return int32(ret) 1430 | } 1431 | 1432 | func SelectObject(hdc HDC, hgdiobj HGDIOBJ) HGDIOBJ { 1433 | ret, _, _ := syscall.Syscall(selectObject, 2, 1434 | uintptr(hdc), 1435 | uintptr(hgdiobj), 1436 | 0) 1437 | 1438 | return HGDIOBJ(ret) 1439 | } 1440 | 1441 | func SetBkMode(hdc HDC, iBkMode int32) int32 { 1442 | ret, _, _ := syscall.Syscall(setBkMode, 2, 1443 | uintptr(hdc), 1444 | uintptr(iBkMode), 1445 | 0) 1446 | 1447 | return int32(ret) 1448 | } 1449 | 1450 | func SetBrushOrgEx(hdc HDC, nXOrg, nYOrg int32, lppt *POINT) bool { 1451 | ret, _, _ := syscall.Syscall6(setBrushOrgEx, 4, 1452 | uintptr(hdc), 1453 | uintptr(nXOrg), 1454 | uintptr(nYOrg), 1455 | uintptr(unsafe.Pointer(lppt)), 1456 | 0, 1457 | 0) 1458 | 1459 | return ret != 0 1460 | } 1461 | 1462 | func SetPixelFormat(hdc HDC, iPixelFormat int32, ppfd *PIXELFORMATDESCRIPTOR) bool { 1463 | ret, _, _ := syscall.Syscall(setPixelFormat, 3, 1464 | uintptr(hdc), 1465 | uintptr(iPixelFormat), 1466 | uintptr(unsafe.Pointer(ppfd))) 1467 | 1468 | return ret != 0 1469 | } 1470 | 1471 | func SetStretchBltMode(hdc HDC, iStretchMode int32) int32 { 1472 | ret, _, _ := syscall.Syscall(setStretchBltMode, 2, 1473 | uintptr(hdc), 1474 | uintptr(iStretchMode), 1475 | 0) 1476 | 1477 | return int32(ret) 1478 | } 1479 | 1480 | func SetTextColor(hdc HDC, crColor COLORREF) COLORREF { 1481 | ret, _, _ := syscall.Syscall(setTextColor, 2, 1482 | uintptr(hdc), 1483 | uintptr(crColor), 1484 | 0) 1485 | 1486 | return COLORREF(ret) 1487 | } 1488 | 1489 | func StartDoc(hdc HDC, lpdi *DOCINFO) int32 { 1490 | ret, _, _ := syscall.Syscall(startDoc, 2, 1491 | uintptr(hdc), 1492 | uintptr(unsafe.Pointer(lpdi)), 1493 | 0) 1494 | 1495 | return int32(ret) 1496 | } 1497 | 1498 | func StartPage(hdc HDC) int32 { 1499 | ret, _, _ := syscall.Syscall(startPage, 1, 1500 | uintptr(hdc), 1501 | 0, 1502 | 0) 1503 | 1504 | return int32(ret) 1505 | } 1506 | 1507 | func StretchBlt(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int32, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int32, dwRop uint32) bool { 1508 | ret, _, _ := syscall.Syscall12(stretchBlt, 11, 1509 | uintptr(hdcDest), 1510 | uintptr(nXOriginDest), 1511 | uintptr(nYOriginDest), 1512 | uintptr(nWidthDest), 1513 | uintptr(nHeightDest), 1514 | uintptr(hdcSrc), 1515 | uintptr(nXOriginSrc), 1516 | uintptr(nYOriginSrc), 1517 | uintptr(nWidthSrc), 1518 | uintptr(nHeightSrc), 1519 | uintptr(dwRop), 1520 | 0) 1521 | 1522 | return ret != 0 1523 | } 1524 | 1525 | func SwapBuffers(hdc HDC) bool { 1526 | ret, _, _ := syscall.Syscall(swapBuffers, 1, 1527 | uintptr(hdc), 1528 | 0, 1529 | 0) 1530 | 1531 | return ret != 0 1532 | } 1533 | 1534 | func TextOut(hdc HDC, nXStart, nYStart int32, lpString *uint16, cchString int32) bool { 1535 | ret, _, _ := syscall.Syscall6(textOut, 5, 1536 | uintptr(hdc), 1537 | uintptr(nXStart), 1538 | uintptr(nYStart), 1539 | uintptr(unsafe.Pointer(lpString)), 1540 | uintptr(cchString), 1541 | 0) 1542 | return ret != 0 1543 | } 1544 | 1545 | func TextOutA(hdc HDC, nXStart, nYStart int32, lpString *uint16, cchString int32) bool { 1546 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "TextOutA"), 5, 1547 | uintptr(hdc), 1548 | uintptr(nXStart), 1549 | uintptr(nYStart), 1550 | uintptr(unsafe.Pointer(lpString)), 1551 | uintptr(cchString), 1552 | 0) 1553 | return ret != 0 1554 | } 1555 | 1556 | func SetTextAlign(hdc HDC, fMode uint32) uint32 { 1557 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "SetTextAlign"), 2, 1558 | uintptr(hdc), 1559 | uintptr(fMode), 1560 | 0) 1561 | return uint32(ret) 1562 | } 1563 | 1564 | func Polyline(hdc HDC, lppt *POINT, cPoints int32) BOOL { 1565 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "Polyline"), 3, 1566 | uintptr(hdc), 1567 | uintptr(unsafe.Pointer(lppt)), 1568 | uintptr(cPoints)) 1569 | return BOOL(ret) 1570 | } 1571 | 1572 | func Rectangle(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) BOOL { 1573 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "Rectangle"), 5, 1574 | uintptr(hdc), 1575 | uintptr(nLeftRect), 1576 | uintptr(nTopRect), 1577 | uintptr(nRightRect), 1578 | uintptr(nBottomRect), 1579 | 0) 1580 | return BOOL(ret) 1581 | } 1582 | 1583 | func RoundRect(hdc HDC, nLeftRect, nTopRect , nRightRect , nBottomRect , nWidth , nHeight int32) BOOL { 1584 | ret, _, _ := syscall.Syscall9(MustGetProcAddress(libgdi32, "RoundRect"), 7, 1585 | uintptr(hdc), 1586 | uintptr(nLeftRect), 1587 | uintptr(nTopRect), 1588 | uintptr(nRightRect), 1589 | uintptr(nBottomRect), 1590 | uintptr(nWidth), 1591 | uintptr(nHeight), 1592 | 0, 1593 | 0) 1594 | 1595 | return BOOL(ret) 1596 | } 1597 | 1598 | func PolyBezier(hdc HDC, lppt *POINT, cPoints int32) BOOL { 1599 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "PolyBezier"), 3, 1600 | uintptr(hdc), 1601 | uintptr(unsafe.Pointer(lppt)), 1602 | uintptr(cPoints)) 1603 | return BOOL(ret) 1604 | } 1605 | 1606 | const ( 1607 | ALTERNATE = 1 1608 | WINDING = 2 1609 | ) 1610 | 1611 | func SetPolyFillMode(hdc HDC, iPolyFillMode int32) int32 { 1612 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "SetPolyFillMode"), 2, 1613 | uintptr(hdc), 1614 | uintptr(iPolyFillMode), 1615 | 0) 1616 | return int32(ret) 1617 | } 1618 | 1619 | func Polygon(hdc HDC, lpPoints *POINT, nCount int32) BOOL{ 1620 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "Polygon"), 3, 1621 | uintptr(hdc), 1622 | uintptr(unsafe.Pointer(lpPoints)), 1623 | uintptr(nCount)) 1624 | return BOOL(ret) 1625 | } 1626 | 1627 | const ( 1628 | MM_TEXT = 1 1629 | MM_LOMETRIC = 2 1630 | MM_HIMETRIC = 3 1631 | MM_LOENGLISH = 4 1632 | MM_HIENGLISH = 5 1633 | MM_TWIPS = 6 1634 | MM_ISOTROPIC = 7 1635 | MM_ANISOTROPIC = 8 1636 | ) 1637 | 1638 | func SetMapMode(hdc HDC, fnMapMode int32) int32{ 1639 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "SetMapMode"), 2, 1640 | uintptr(hdc), 1641 | uintptr(fnMapMode), 1642 | 0) 1643 | return int32(ret) 1644 | } 1645 | 1646 | func SetWindowExtEx(hdc HDC, nXExtent, nYExtent int32, lpSize *SIZE) BOOL{ 1647 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "SetWindowExtEx"), 4, 1648 | uintptr(hdc), 1649 | uintptr(nXExtent), 1650 | uintptr(nYExtent), 1651 | uintptr(unsafe.Pointer(lpSize)), 1652 | 0, 1653 | 0) 1654 | return BOOL(ret) 1655 | } 1656 | 1657 | func SetViewportExtEx(hdc HDC, nXExtent, nYExtent int32, lpSize *SIZE) BOOL{ 1658 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "SetViewportExtEx"), 4, 1659 | uintptr(hdc), 1660 | uintptr(nXExtent), 1661 | uintptr(nYExtent), 1662 | uintptr(unsafe.Pointer(lpSize)), 1663 | 0, 1664 | 0) 1665 | return BOOL(ret) 1666 | } 1667 | 1668 | func DPtoLP(hdc HDC, lpPoints *POINT, nCount int32) BOOL{ 1669 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "DPtoLP"), 3, 1670 | uintptr(hdc), 1671 | uintptr(unsafe.Pointer(lpPoints)), 1672 | uintptr(nCount)) 1673 | return BOOL(ret) 1674 | } 1675 | 1676 | 1677 | func CreateSolidBrush(crColor COLORREF) HBRUSH{ 1678 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "CreateSolidBrush"), 1, 1679 | uintptr(crColor), 1680 | 0, 1681 | 0) 1682 | return HBRUSH(ret) 1683 | } 1684 | 1685 | func CreateEllipticRgn(nLeftRect, nTopRect, nRightRect, nBottomRect int32) HRGN { 1686 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "CreateEllipticRgn"), 4, 1687 | uintptr(nLeftRect), 1688 | uintptr(nTopRect), 1689 | uintptr(nRightRect), 1690 | uintptr(nBottomRect), 1691 | 0, 1692 | 0) 1693 | 1694 | return HRGN(ret) 1695 | } 1696 | 1697 | func CreateRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect int32) HRGN { 1698 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "CreateRectRgn"), 4, 1699 | uintptr(nLeftRect), 1700 | uintptr(nTopRect), 1701 | uintptr(nRightRect), 1702 | uintptr(nBottomRect), 1703 | 0, 1704 | 0) 1705 | 1706 | return HRGN(ret) 1707 | } 1708 | 1709 | /* CombineRgn() Styles */ 1710 | const ( 1711 | RGN_AND = 1 1712 | RGN_OR = 2 1713 | RGN_XOR = 3 1714 | RGN_DIFF = 4 1715 | RGN_COPY = 5 1716 | RGN_MIN = RGN_AND 1717 | RGN_MAX = RGN_COPY 1718 | ) 1719 | 1720 | /* Region Flags */ 1721 | const ( 1722 | ERROR = 0 1723 | NULLREGION = 1 1724 | SIMPLEREGION = 2 1725 | COMPLEXREGION = 3 1726 | RGN_ERROR = ERROR 1727 | ) 1728 | 1729 | func CombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2 HRGN, fnCombineMode int32) int32{ 1730 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "CombineRgn"), 4, 1731 | uintptr(hrgnDest), 1732 | uintptr(hrgnSrc1), 1733 | uintptr(hrgnSrc2), 1734 | uintptr(fnCombineMode), 1735 | 0, 1736 | 0) 1737 | 1738 | return int32(ret) 1739 | } 1740 | 1741 | 1742 | func SelectClipRgn(hdc HDC, hrgn HRGN) int32 { 1743 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "SelectClipRgn"), 1, 1744 | uintptr(hdc), 1745 | uintptr(hrgn), 1746 | 0) 1747 | 1748 | return int32(ret) 1749 | } 1750 | 1751 | func SetViewportOrgEx(hdc HDC, X, Y int32, lpPoint *POINT) BOOL { 1752 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "SetViewportOrgEx"), 4, 1753 | uintptr(hdc), 1754 | uintptr(X), 1755 | uintptr(Y), 1756 | uintptr(unsafe.Pointer(lpPoint)), 1757 | 0, 1758 | 0) 1759 | 1760 | return BOOL(ret) 1761 | } 1762 | 1763 | func GetTextFace(hdc HDC, nCount int32, lpFaceName *uint16) int32{ 1764 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "GetTextFaceW"), 3, 1765 | uintptr(hdc), 1766 | uintptr(nCount), 1767 | uintptr(unsafe.Pointer(lpFaceName))) 1768 | 1769 | return int32(ret) 1770 | } 1771 | 1772 | func GetTextFaceA(hdc HDC, nCount int32, lpFaceName *uint16) int32{ 1773 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "GetTextFaceA"), 3, 1774 | uintptr(hdc), 1775 | uintptr(nCount), 1776 | uintptr(unsafe.Pointer(lpFaceName))) 1777 | 1778 | return int32(ret) 1779 | } 1780 | 1781 | func CreateFont(nHeight, nWidth, nEscapement, nOrientation, fnWeight int32, fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet, fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily uint32, lpszFace *uint16) HFONT{ 1782 | ret, _, _ := syscall.Syscall15(MustGetProcAddress(libgdi32, "CreateFontW"), 14, 1783 | uintptr(nHeight), 1784 | uintptr(nWidth), 1785 | uintptr(nEscapement), 1786 | uintptr(nOrientation), 1787 | uintptr(fnWeight), 1788 | uintptr(fdwItalic), 1789 | uintptr(fdwUnderline), 1790 | uintptr(fdwStrikeOut), 1791 | uintptr(fdwCharSet), 1792 | uintptr(fdwOutputPrecision), 1793 | uintptr(fdwClipPrecision), 1794 | uintptr(fdwQuality), 1795 | uintptr(fdwPitchAndFamily), 1796 | uintptr(unsafe.Pointer(lpszFace)), 1797 | 0) 1798 | 1799 | return HFONT(ret) 1800 | } 1801 | 1802 | func CreateFontA(nHeight, nWidth, nEscapement, nOrientation, fnWeight int32, fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet, fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily uint32, lpszFace *uint16) HFONT{ 1803 | ret, _, _ := syscall.Syscall15(MustGetProcAddress(libgdi32, "CreateFontA"), 14, 1804 | uintptr(nHeight), 1805 | uintptr(nWidth), 1806 | uintptr(nEscapement), 1807 | uintptr(nOrientation), 1808 | uintptr(fnWeight), 1809 | uintptr(fdwItalic), 1810 | uintptr(fdwUnderline), 1811 | uintptr(fdwStrikeOut), 1812 | uintptr(fdwCharSet), 1813 | uintptr(fdwOutputPrecision), 1814 | uintptr(fdwClipPrecision), 1815 | uintptr(fdwQuality), 1816 | uintptr(fdwPitchAndFamily), 1817 | uintptr(unsafe.Pointer(lpszFace)), 1818 | 0) 1819 | 1820 | return HFONT(ret) 1821 | } 1822 | 1823 | func SetPixel(hdc HDC, X, Y int32, crColor COLORREF) COLORREF { 1824 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "SetPixel"), 4, 1825 | uintptr(hdc), 1826 | uintptr(X), 1827 | uintptr(Y), 1828 | uintptr(crColor), 1829 | 0, 1830 | 0) 1831 | 1832 | return COLORREF(ret) 1833 | } 1834 | 1835 | func CreatePen(fnPenStyle, nWidth int32, crColor COLORREF)HPEN{ 1836 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "CreatePen"), 3, 1837 | uintptr(fnPenStyle), 1838 | uintptr(nWidth), 1839 | uintptr(crColor)) 1840 | 1841 | return HPEN(ret) 1842 | } 1843 | 1844 | /* Binary raster ops */ 1845 | const ( 1846 | R2_BLACK = 1 /* 0 */ 1847 | R2_NOTMERGEPEN = 2 /* DPon */ 1848 | R2_MASKNOTPEN = 3 /* DPna */ 1849 | R2_NOTCOPYPEN = 4 /* PN */ 1850 | R2_MASKPENNOT = 5 /* PDna */ 1851 | R2_NOT = 6 /* Dn */ 1852 | R2_XORPEN = 7 /* DPx */ 1853 | R2_NOTMASKPEN = 8 /* DPan */ 1854 | R2_MASKPEN = 9 /* DPa */ 1855 | R2_NOTXORPEN = 10 /* DPxn */ 1856 | R2_NOP = 11 /* D */ 1857 | R2_MERGENOTPEN = 12 /* DPno */ 1858 | R2_COPYPEN = 13 /* P */ 1859 | R2_MERGEPENNOT = 14 /* PDno */ 1860 | R2_MERGEPEN = 15 /* DPo */ 1861 | R2_WHITE = 16 /* 1 */ 1862 | R2_LAST = 16 1863 | ) 1864 | 1865 | func SetROP2(hdc HDC, fnDrawMode int32) int32{ 1866 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "SetROP2"), 2, 1867 | uintptr(hdc), 1868 | uintptr(fnDrawMode), 1869 | 0) 1870 | 1871 | return int32(ret) 1872 | } 1873 | 1874 | func GetROP2(hdc HDC)int32 { 1875 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "GetROP2"), 1, 1876 | uintptr(hdc), 1877 | 0, 1878 | 0) 1879 | 1880 | return int32(ret) 1881 | } 1882 | 1883 | 1884 | func OffsetWindowOrgEx(hdc HDC, nXOffset, nYOffset int32, lpPoint *POINT) BOOL{ 1885 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "OffsetWindowOrgEx"), 4, 1886 | uintptr(hdc), 1887 | uintptr(nXOffset), 1888 | uintptr(nYOffset), 1889 | uintptr(unsafe.Pointer(lpPoint)), 1890 | 0, 1891 | 0) 1892 | 1893 | return BOOL(ret) 1894 | } 1895 | 1896 | func SetWindowOrgEx(hdc HDC, X, Y int32, lpPoint *POINT) BOOL { 1897 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "SetWindowOrgEx"), 4, 1898 | uintptr(hdc), 1899 | uintptr(X), 1900 | uintptr(Y), 1901 | uintptr(unsafe.Pointer(lpPoint)), 1902 | 0, 1903 | 0) 1904 | 1905 | return BOOL(ret) 1906 | } 1907 | 1908 | func GetPixel(hdc HDC, nXPos, nYPos int32) COLORREF { 1909 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libgdi32, "GetPixel"), 3, 1910 | uintptr(hdc), 1911 | uintptr(nXPos), 1912 | uintptr(nYPos), 1913 | 0, 1914 | 0, 1915 | 0) 1916 | 1917 | return COLORREF(ret) 1918 | 1919 | } 1920 | 1921 | func SetBkColor(hdc HDC, crColor COLORREF) COLORREF{ 1922 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libgdi32, "SetBkColor"), 2, 1923 | uintptr(hdc), 1924 | uintptr(crColor), 1925 | 0) 1926 | 1927 | return COLORREF(ret) 1928 | } -------------------------------------------------------------------------------- /gdiplus.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | type GpStatus int32 13 | 14 | const ( 15 | Ok GpStatus = 0 16 | GenericError GpStatus = 1 17 | InvalidParameter GpStatus = 2 18 | OutOfMemory GpStatus = 3 19 | ObjectBusy GpStatus = 4 20 | InsufficientBuffer GpStatus = 5 21 | NotImplemented GpStatus = 6 22 | Win32Error GpStatus = 7 23 | WrongState GpStatus = 8 24 | Aborted GpStatus = 9 25 | FileNotFound GpStatus = 10 26 | ValueOverflow GpStatus = 11 27 | AccessDenied GpStatus = 12 28 | UnknownImageFormat GpStatus = 13 29 | FontFamilyNotFound GpStatus = 14 30 | FontStyleNotFound GpStatus = 15 31 | NotTrueTypeFont GpStatus = 16 32 | UnsupportedGdiplusVersion GpStatus = 17 33 | GdiplusNotInitialized GpStatus = 18 34 | PropertyNotFound GpStatus = 19 35 | PropertyNotSupported GpStatus = 20 36 | ProfileNotFound GpStatus = 21 37 | ) 38 | 39 | func (s GpStatus) String() string { 40 | switch s { 41 | case Ok: 42 | return "Ok" 43 | 44 | case GenericError: 45 | return "GenericError" 46 | 47 | case InvalidParameter: 48 | return "InvalidParameter" 49 | 50 | case OutOfMemory: 51 | return "OutOfMemory" 52 | 53 | case ObjectBusy: 54 | return "ObjectBusy" 55 | 56 | case InsufficientBuffer: 57 | return "InsufficientBuffer" 58 | 59 | case NotImplemented: 60 | return "NotImplemented" 61 | 62 | case Win32Error: 63 | return "Win32Error" 64 | 65 | case WrongState: 66 | return "WrongState" 67 | 68 | case Aborted: 69 | return "Aborted" 70 | 71 | case FileNotFound: 72 | return "FileNotFound" 73 | 74 | case ValueOverflow: 75 | return "ValueOverflow" 76 | 77 | case AccessDenied: 78 | return "AccessDenied" 79 | 80 | case UnknownImageFormat: 81 | return "UnknownImageFormat" 82 | 83 | case FontFamilyNotFound: 84 | return "FontFamilyNotFound" 85 | 86 | case FontStyleNotFound: 87 | return "FontStyleNotFound" 88 | 89 | case NotTrueTypeFont: 90 | return "NotTrueTypeFont" 91 | 92 | case UnsupportedGdiplusVersion: 93 | return "UnsupportedGdiplusVersion" 94 | 95 | case GdiplusNotInitialized: 96 | return "GdiplusNotInitialized" 97 | 98 | case PropertyNotFound: 99 | return "PropertyNotFound" 100 | 101 | case PropertyNotSupported: 102 | return "PropertyNotSupported" 103 | 104 | case ProfileNotFound: 105 | return "ProfileNotFound" 106 | } 107 | 108 | return "Unknown Status Value" 109 | } 110 | 111 | type GdiplusStartupInput struct { 112 | GdiplusVersion uint32 113 | DebugEventCallback uintptr 114 | SuppressBackgroundThread BOOL 115 | SuppressExternalCodecs BOOL 116 | } 117 | 118 | type GdiplusStartupOutput struct { 119 | NotificationHook uintptr 120 | NotificationUnhook uintptr 121 | } 122 | 123 | type GpImage struct{} 124 | 125 | type GpBitmap GpImage 126 | 127 | type ARGB uint32 128 | 129 | var ( 130 | // Library 131 | libgdiplus uintptr 132 | 133 | // Functions 134 | gdipCreateBitmapFromFile uintptr 135 | gdipCreateBitmapFromHBITMAP uintptr 136 | gdipCreateHBITMAPFromBitmap uintptr 137 | gdipDisposeImage uintptr 138 | gdiplusShutdown uintptr 139 | gdiplusStartup uintptr 140 | ) 141 | 142 | var ( 143 | token uintptr 144 | ) 145 | 146 | func init() { 147 | // Library 148 | libgdiplus = MustLoadLibrary("gdiplus.dll") 149 | 150 | // Functions 151 | gdipCreateBitmapFromFile = MustGetProcAddress(libgdiplus, "GdipCreateBitmapFromFile") 152 | gdipCreateBitmapFromHBITMAP = MustGetProcAddress(libgdiplus, "GdipCreateBitmapFromHBITMAP") 153 | gdipCreateHBITMAPFromBitmap = MustGetProcAddress(libgdiplus, "GdipCreateHBITMAPFromBitmap") 154 | gdipDisposeImage = MustGetProcAddress(libgdiplus, "GdipDisposeImage") 155 | gdiplusShutdown = MustGetProcAddress(libgdiplus, "GdiplusShutdown") 156 | gdiplusStartup = MustGetProcAddress(libgdiplus, "GdiplusStartup") 157 | } 158 | 159 | func GdipCreateBitmapFromFile(filename *uint16, bitmap **GpBitmap) GpStatus { 160 | ret, _, _ := syscall.Syscall(gdipCreateBitmapFromFile, 2, 161 | uintptr(unsafe.Pointer(filename)), 162 | uintptr(unsafe.Pointer(bitmap)), 163 | 0) 164 | 165 | return GpStatus(ret) 166 | } 167 | 168 | func GdipCreateBitmapFromHBITMAP(hbm HBITMAP, hpal HPALETTE, bitmap **GpBitmap) GpStatus { 169 | ret, _, _ := syscall.Syscall(gdipCreateBitmapFromHBITMAP, 3, 170 | uintptr(hbm), 171 | uintptr(hpal), 172 | uintptr(unsafe.Pointer(bitmap))) 173 | 174 | return GpStatus(ret) 175 | } 176 | 177 | func GdipCreateHBITMAPFromBitmap(bitmap *GpBitmap, hbmReturn *HBITMAP, background ARGB) GpStatus { 178 | ret, _, _ := syscall.Syscall(gdipCreateHBITMAPFromBitmap, 3, 179 | uintptr(unsafe.Pointer(bitmap)), 180 | uintptr(unsafe.Pointer(hbmReturn)), 181 | uintptr(background)) 182 | 183 | return GpStatus(ret) 184 | } 185 | 186 | func GdipDisposeImage(image *GpImage) GpStatus { 187 | ret, _, _ := syscall.Syscall(gdipDisposeImage, 1, 188 | uintptr(unsafe.Pointer(image)), 189 | 0, 190 | 0) 191 | 192 | return GpStatus(ret) 193 | } 194 | 195 | func GdiplusShutdown() { 196 | syscall.Syscall(gdiplusShutdown, 1, 197 | token, 198 | 0, 199 | 0) 200 | } 201 | 202 | func GdiplusStartup(input *GdiplusStartupInput, output *GdiplusStartupOutput) GpStatus { 203 | ret, _, _ := syscall.Syscall(gdiplusStartup, 3, 204 | uintptr(unsafe.Pointer(&token)), 205 | uintptr(unsafe.Pointer(input)), 206 | uintptr(unsafe.Pointer(output))) 207 | 208 | return GpStatus(ret) 209 | } 210 | 211 | /*GdipSaveImageToFile(image *GpImage, filename *uint16, clsidEncoder *CLSID, encoderParams *EncoderParameters) GpStatus { 212 | ret, _, _ := syscall.Syscall6(gdipSaveImageToFile, 4, 213 | uintptr(unsafe.Pointer(image)), 214 | uintptr(unsafe.Pointer(filename)), 215 | uintptr(unsafe.Pointer(clsidEncoder)), 216 | uintptr(unsafe.Pointer(encoderParams)), 217 | 0, 218 | 0) 219 | 220 | return GpStatus(ret) 221 | }*/ 222 | -------------------------------------------------------------------------------- /header.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The go-winapi 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 | package winapi 6 | 7 | const ( 8 | HDF_SORTDOWN = 0x200 9 | HDF_SORTUP = 0x400 10 | ) 11 | 12 | const ( 13 | HDI_FORMAT = 4 14 | ) 15 | 16 | const ( 17 | HDM_FIRST = 0x1200 18 | HDM_GETITEM = HDM_FIRST + 11 19 | HDM_SETITEM = HDM_FIRST + 12 20 | ) 21 | 22 | const ( 23 | HDS_NOSIZING = 0x0800 24 | ) 25 | 26 | type HDITEM struct { 27 | Mask uint32 28 | Cxy int32 29 | PszText *uint16 30 | Hbm HBITMAP 31 | CchTextMax int32 32 | Fmt int32 33 | LParam uintptr 34 | IImage int32 35 | IOrder int32 36 | Type uint32 37 | PvFilter uintptr 38 | } 39 | -------------------------------------------------------------------------------- /kernel32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | const MAX_PATH = 260 13 | 14 | // Error codes 15 | const ( 16 | ERROR_SUCCESS = 0 17 | ERROR_FILE_NOT_FOUND = 2 18 | ERROR_INVALID_PARAMETER = 87 19 | ERROR_INSUFFICIENT_BUFFER = 122 20 | ERROR_MORE_DATA = 234 21 | ) 22 | 23 | // GlobalAlloc flags 24 | const ( 25 | GHND = 0x0042 26 | GMEM_FIXED = 0x0000 27 | GMEM_MOVEABLE = 0x0002 28 | GMEM_ZEROINIT = 0x0040 29 | GPTR = 0x004 30 | ) 31 | 32 | // Predefined locale ids 33 | const ( 34 | LOCALE_INVARIANT = 0x007f 35 | LOCALE_NOUSEROVERRIDE = 0x80000000 36 | LOCALE_USE_CP_ACP = 0x40000000 37 | LOCALE_RETURN_NUMBER = 0x20000000 38 | LOCALE_ILANGUAGE = 1 39 | LOCALE_SLANGUAGE = 2 40 | LOCALE_SENGLANGUAGE = 0x1001 41 | LOCALE_SABBREVLANGNAME = 3 42 | LOCALE_SNATIVELANGNAME = 4 43 | LOCALE_ICOUNTRY = 5 44 | LOCALE_SCOUNTRY = 6 45 | LOCALE_SENGCOUNTRY = 0x1002 46 | LOCALE_SABBREVCTRYNAME = 7 47 | LOCALE_SNATIVECTRYNAME = 8 48 | LOCALE_IDEFAULTLANGUAGE = 9 49 | LOCALE_IDEFAULTCOUNTRY = 10 50 | LOCALE_IDEFAULTCODEPAGE = 11 51 | LOCALE_IDEFAULTANSICODEPAGE = 0x1004 52 | LOCALE_SLIST = 12 53 | LOCALE_IMEASURE = 13 54 | LOCALE_SDECIMAL = 14 55 | LOCALE_STHOUSAND = 15 56 | LOCALE_SGROUPING = 16 57 | LOCALE_IDIGITS = 17 58 | LOCALE_ILZERO = 18 59 | LOCALE_INEGNUMBER = 0x1010 60 | LOCALE_SNATIVEDIGITS = 19 61 | LOCALE_SCURRENCY = 20 62 | LOCALE_SINTLSYMBOL = 21 63 | LOCALE_SMONDECIMALSEP = 22 64 | LOCALE_SMONTHOUSANDSEP = 23 65 | LOCALE_SMONGROUPING = 24 66 | LOCALE_ICURRDIGITS = 25 67 | LOCALE_IINTLCURRDIGITS = 26 68 | LOCALE_ICURRENCY = 27 69 | LOCALE_INEGCURR = 28 70 | LOCALE_SDATE = 29 71 | LOCALE_STIME = 30 72 | LOCALE_SSHORTDATE = 31 73 | LOCALE_SLONGDATE = 32 74 | LOCALE_STIMEFORMAT = 0x1003 75 | LOCALE_IDATE = 33 76 | LOCALE_ILDATE = 34 77 | LOCALE_ITIME = 35 78 | LOCALE_ITIMEMARKPOSN = 0x1005 79 | LOCALE_ICENTURY = 36 80 | LOCALE_ITLZERO = 37 81 | LOCALE_IDAYLZERO = 38 82 | LOCALE_IMONLZERO = 39 83 | LOCALE_S1159 = 40 84 | LOCALE_S2359 = 41 85 | LOCALE_ICALENDARTYPE = 0x1009 86 | LOCALE_IOPTIONALCALENDAR = 0x100B 87 | LOCALE_IFIRSTDAYOFWEEK = 0x100C 88 | LOCALE_IFIRSTWEEKOFYEAR = 0x100D 89 | LOCALE_SDAYNAME1 = 42 90 | LOCALE_SDAYNAME2 = 43 91 | LOCALE_SDAYNAME3 = 44 92 | LOCALE_SDAYNAME4 = 45 93 | LOCALE_SDAYNAME5 = 46 94 | LOCALE_SDAYNAME6 = 47 95 | LOCALE_SDAYNAME7 = 48 96 | LOCALE_SABBREVDAYNAME1 = 49 97 | LOCALE_SABBREVDAYNAME2 = 50 98 | LOCALE_SABBREVDAYNAME3 = 51 99 | LOCALE_SABBREVDAYNAME4 = 52 100 | LOCALE_SABBREVDAYNAME5 = 53 101 | LOCALE_SABBREVDAYNAME6 = 54 102 | LOCALE_SABBREVDAYNAME7 = 55 103 | LOCALE_SMONTHNAME1 = 56 104 | LOCALE_SMONTHNAME2 = 57 105 | LOCALE_SMONTHNAME3 = 58 106 | LOCALE_SMONTHNAME4 = 59 107 | LOCALE_SMONTHNAME5 = 60 108 | LOCALE_SMONTHNAME6 = 61 109 | LOCALE_SMONTHNAME7 = 62 110 | LOCALE_SMONTHNAME8 = 63 111 | LOCALE_SMONTHNAME9 = 64 112 | LOCALE_SMONTHNAME10 = 65 113 | LOCALE_SMONTHNAME11 = 66 114 | LOCALE_SMONTHNAME12 = 67 115 | LOCALE_SMONTHNAME13 = 0x100E 116 | LOCALE_SABBREVMONTHNAME1 = 68 117 | LOCALE_SABBREVMONTHNAME2 = 69 118 | LOCALE_SABBREVMONTHNAME3 = 70 119 | LOCALE_SABBREVMONTHNAME4 = 71 120 | LOCALE_SABBREVMONTHNAME5 = 72 121 | LOCALE_SABBREVMONTHNAME6 = 73 122 | LOCALE_SABBREVMONTHNAME7 = 74 123 | LOCALE_SABBREVMONTHNAME8 = 75 124 | LOCALE_SABBREVMONTHNAME9 = 76 125 | LOCALE_SABBREVMONTHNAME10 = 77 126 | LOCALE_SABBREVMONTHNAME11 = 78 127 | LOCALE_SABBREVMONTHNAME12 = 79 128 | LOCALE_SABBREVMONTHNAME13 = 0x100F 129 | LOCALE_SPOSITIVESIGN = 80 130 | LOCALE_SNEGATIVESIGN = 81 131 | LOCALE_IPOSSIGNPOSN = 82 132 | LOCALE_INEGSIGNPOSN = 83 133 | LOCALE_IPOSSYMPRECEDES = 84 134 | LOCALE_IPOSSEPBYSPACE = 85 135 | LOCALE_INEGSYMPRECEDES = 86 136 | LOCALE_INEGSEPBYSPACE = 87 137 | LOCALE_FONTSIGNATURE = 88 138 | LOCALE_SISO639LANGNAME = 89 139 | LOCALE_SISO3166CTRYNAME = 90 140 | LOCALE_SYSTEM_DEFAULT = 0x800 141 | LOCALE_USER_DEFAULT = 0x400 142 | ) 143 | 144 | var ( 145 | // Library 146 | libkernel32 uintptr 147 | 148 | // Functions 149 | closeHandle uintptr 150 | fileTimeToSystemTime uintptr 151 | getLastError uintptr 152 | getLogicalDriveStrings uintptr 153 | getModuleHandle uintptr 154 | getNumberFormat uintptr 155 | getThreadLocale uintptr 156 | getVersion uintptr 157 | globalAlloc uintptr 158 | globalFree uintptr 159 | globalLock uintptr 160 | globalUnlock uintptr 161 | moveMemory uintptr 162 | mulDiv uintptr 163 | setLastError uintptr 164 | systemTimeToFileTime uintptr 165 | getProfileString uintptr 166 | ) 167 | 168 | type ( 169 | ATOM uint16 170 | HANDLE uintptr 171 | HGLOBAL HANDLE 172 | HINSTANCE HANDLE 173 | HMODULE HANDLE 174 | HRSRC HANDLE 175 | LCID uint32 176 | LCTYPE uint32 177 | DWORD uint32 178 | DWORD32 uint32 179 | DWORDLONG uint64 180 | DWORD64 uint64 181 | LPTSTR *uint16 182 | LPCTSTR *uint16 183 | INT int32 184 | UINT uint32 185 | UINT_PTR uint32 186 | LPVOID uintptr 187 | ) 188 | 189 | const MAXDWORD DWORD = 4294967295 190 | 191 | type FILETIME struct { 192 | DwLowDateTime uint32 193 | DwHighDateTime uint32 194 | } 195 | 196 | type NUMBERFMT struct { 197 | NumDigits uint32 198 | LeadingZero uint32 199 | Grouping uint32 200 | LpDecimalSep *uint16 201 | LpThousandSep *uint16 202 | NegativeOrder uint32 203 | } 204 | 205 | type SYSTEMTIME struct { 206 | WYear uint16 207 | WMonth uint16 208 | WDayOfWeek uint16 209 | WDay uint16 210 | WHour uint16 211 | WMinute uint16 212 | WSecond uint16 213 | WMilliseconds uint16 214 | } 215 | 216 | func init() { 217 | // Library 218 | libkernel32 = MustLoadLibrary("kernel32.dll") 219 | 220 | // Functions 221 | closeHandle = MustGetProcAddress(libkernel32, "CloseHandle") 222 | fileTimeToSystemTime = MustGetProcAddress(libkernel32, "FileTimeToSystemTime") 223 | getLastError = MustGetProcAddress(libkernel32, "GetLastError") 224 | getLogicalDriveStrings = MustGetProcAddress(libkernel32, "GetLogicalDriveStringsW") 225 | getModuleHandle = MustGetProcAddress(libkernel32, "GetModuleHandleW") 226 | getNumberFormat = MustGetProcAddress(libkernel32, "GetNumberFormatW") 227 | getProfileString = MustGetProcAddress(libkernel32, "GetProfileStringW") 228 | getThreadLocale = MustGetProcAddress(libkernel32, "GetThreadLocale") 229 | getVersion = MustGetProcAddress(libkernel32, "GetVersion") 230 | globalAlloc = MustGetProcAddress(libkernel32, "GlobalAlloc") 231 | globalFree = MustGetProcAddress(libkernel32, "GlobalFree") 232 | globalLock = MustGetProcAddress(libkernel32, "GlobalLock") 233 | globalUnlock = MustGetProcAddress(libkernel32, "GlobalUnlock") 234 | moveMemory = MustGetProcAddress(libkernel32, "RtlMoveMemory") 235 | mulDiv = MustGetProcAddress(libkernel32, "MulDiv") 236 | setLastError = MustGetProcAddress(libkernel32, "SetLastError") 237 | systemTimeToFileTime = MustGetProcAddress(libkernel32, "SystemTimeToFileTime") 238 | 239 | } 240 | 241 | func CloseHandle(hObject HANDLE) bool { 242 | ret, _, _ := syscall.Syscall(closeHandle, 1, 243 | uintptr(hObject), 244 | 0, 245 | 0) 246 | 247 | return ret != 0 248 | } 249 | 250 | func FileTimeToSystemTime(lpFileTime *FILETIME, lpSystemTime *SYSTEMTIME) bool { 251 | ret, _, _ := syscall.Syscall(fileTimeToSystemTime, 2, 252 | uintptr(unsafe.Pointer(lpFileTime)), 253 | uintptr(unsafe.Pointer(lpSystemTime)), 254 | 0) 255 | 256 | return ret != 0 257 | } 258 | 259 | func GetLastError() uint32 { 260 | ret, _, _ := syscall.Syscall(getLastError, 0, 261 | 0, 262 | 0, 263 | 0) 264 | 265 | return uint32(ret) 266 | } 267 | 268 | func GetLogicalDriveStrings(nBufferLength uint32, lpBuffer *uint16) uint32 { 269 | ret, _, _ := syscall.Syscall(getLogicalDriveStrings, 2, 270 | uintptr(nBufferLength), 271 | uintptr(unsafe.Pointer(lpBuffer)), 272 | 0) 273 | 274 | return uint32(ret) 275 | } 276 | 277 | func GetModuleHandle(lpModuleName *uint16) HINSTANCE { 278 | ret, _, _ := syscall.Syscall(getModuleHandle, 1, 279 | uintptr(unsafe.Pointer(lpModuleName)), 280 | 0, 281 | 0) 282 | 283 | return HINSTANCE(ret) 284 | } 285 | 286 | func GetNumberFormat(Locale LCID, dwFlags uint32, lpValue *uint16, lpFormat *NUMBERFMT, lpNumberStr *uint16, cchNumber int32) int32 { 287 | ret, _, _ := syscall.Syscall6(getNumberFormat, 6, 288 | uintptr(Locale), 289 | uintptr(dwFlags), 290 | uintptr(unsafe.Pointer(lpValue)), 291 | uintptr(unsafe.Pointer(lpFormat)), 292 | uintptr(unsafe.Pointer(lpNumberStr)), 293 | uintptr(cchNumber)) 294 | 295 | return int32(ret) 296 | } 297 | 298 | func GetProfileString(lpAppName, lpKeyName, lpDefault *uint16, lpReturnedString uintptr, nSize uint32) bool { 299 | ret, _, _ := syscall.Syscall6(getProfileString, 5, 300 | uintptr(unsafe.Pointer(lpAppName)), 301 | uintptr(unsafe.Pointer(lpKeyName)), 302 | uintptr(unsafe.Pointer(lpDefault)), 303 | lpReturnedString, 304 | uintptr(nSize), 305 | 0) 306 | return ret != 0 307 | } 308 | 309 | func GetThreadLocale() LCID { 310 | ret, _, _ := syscall.Syscall(getThreadLocale, 0, 311 | 0, 312 | 0, 313 | 0) 314 | 315 | return LCID(ret) 316 | } 317 | 318 | func GetVersion() int64 { 319 | ret, _, _ := syscall.Syscall(getVersion, 0, 320 | 0, 321 | 0, 322 | 0) 323 | return int64(ret) 324 | } 325 | 326 | func GlobalAlloc(uFlags uint32, dwBytes uintptr) HGLOBAL { 327 | ret, _, _ := syscall.Syscall(globalAlloc, 2, 328 | uintptr(uFlags), 329 | dwBytes, 330 | 0) 331 | 332 | return HGLOBAL(ret) 333 | } 334 | 335 | func GlobalFree(hMem HGLOBAL) HGLOBAL { 336 | ret, _, _ := syscall.Syscall(globalFree, 1, 337 | uintptr(hMem), 338 | 0, 339 | 0) 340 | 341 | return HGLOBAL(ret) 342 | } 343 | 344 | func GlobalLock(hMem HGLOBAL) unsafe.Pointer { 345 | ret, _, _ := syscall.Syscall(globalLock, 1, 346 | uintptr(hMem), 347 | 0, 348 | 0) 349 | 350 | return unsafe.Pointer(ret) 351 | } 352 | 353 | func GlobalUnlock(hMem HGLOBAL) bool { 354 | ret, _, _ := syscall.Syscall(globalUnlock, 1, 355 | uintptr(hMem), 356 | 0, 357 | 0) 358 | 359 | return ret != 0 360 | } 361 | 362 | func MoveMemory(destination, source unsafe.Pointer, length uintptr) { 363 | syscall.Syscall(moveMemory, 3, 364 | uintptr(unsafe.Pointer(destination)), 365 | uintptr(source), 366 | uintptr(length)) 367 | } 368 | 369 | func MulDiv(nNumber, nNumerator, nDenominator int32) int32 { 370 | ret, _, _ := syscall.Syscall(mulDiv, 3, 371 | uintptr(nNumber), 372 | uintptr(nNumerator), 373 | uintptr(nDenominator)) 374 | 375 | return int32(ret) 376 | } 377 | 378 | func SetLastError(dwErrorCode uint32) { 379 | syscall.Syscall(setLastError, 1, 380 | uintptr(dwErrorCode), 381 | 0, 382 | 0) 383 | } 384 | 385 | func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { 386 | ret, _, _ := syscall.Syscall(systemTimeToFileTime, 2, 387 | uintptr(unsafe.Pointer(lpSystemTime)), 388 | uintptr(unsafe.Pointer(lpFileTime)), 389 | 0) 390 | 391 | return ret != 0 392 | } 393 | 394 | func GetLocalTime(lpSystemTime *SYSTEMTIME){ 395 | syscall.Syscall(MustGetProcAddress(libkernel32, "GetLocalTime"), 1, 396 | uintptr(unsafe.Pointer(lpSystemTime)), 397 | 0, 398 | 0) 399 | } 400 | 401 | func GetLocaleInfo(Locale LCID, LCType LCTYPE, lpLCData *uint16, cchData int32) int32{ 402 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libkernel32, "GetLocaleInfoW"), 4, 403 | uintptr(Locale), 404 | uintptr(LCType), 405 | uintptr(unsafe.Pointer(lpLCData)), 406 | uintptr(cchData), 407 | 0, 408 | 0) 409 | 410 | return int32(ret) 411 | } 412 | 413 | func GetLocaleInfoA(Locale LCID, LCType LCTYPE, lpLCData *uint16, cchData int32) int32{ 414 | ret, _, _ := syscall.Syscall6(MustGetProcAddress(libkernel32, "GetLocaleInfoA"), 4, 415 | uintptr(Locale), 416 | uintptr(LCType), 417 | uintptr(unsafe.Pointer(lpLCData)), 418 | uintptr(cchData), 419 | 0, 420 | 0) 421 | 422 | return int32(ret) 423 | } 424 | 425 | func GetCurrentDirectory(nBufferLength DWORD, lpBuffer uintptr) DWORD{ 426 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libkernel32, "GetCurrentDirectoryW"), 2, 427 | uintptr(nBufferLength), 428 | uintptr(unsafe.Pointer(lpBuffer)), 429 | 0) 430 | 431 | return DWORD(ret) 432 | } 433 | 434 | func SetCurrentDirectory(lpPathName LPCTSTR) BOOL{ 435 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libkernel32, "SetCurrentDirectoryW"), 1, 436 | uintptr(unsafe.Pointer(lpPathName)), 437 | 0, 438 | 0) 439 | 440 | return BOOL(ret) 441 | } 442 | 443 | func FindResource(hModule HMODULE, lpName, lpType LPCTSTR) HRSRC { 444 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libkernel32, "FindResourceW"), 3, 445 | uintptr(hModule), 446 | uintptr(unsafe.Pointer(lpName)), 447 | uintptr(unsafe.Pointer(lpType))) 448 | 449 | return HRSRC(ret) 450 | } 451 | 452 | func LoadResource(hModule HMODULE, hResInfo HRSRC) HGLOBAL { 453 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libkernel32, "LoadResource"), 2, 454 | uintptr(hModule), 455 | uintptr(hResInfo), 456 | 0) 457 | 458 | return HGLOBAL(ret) 459 | } 460 | 461 | func LockResource(hResData HGLOBAL)LPVOID { 462 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libkernel32, "LockResource"), 2, 463 | uintptr(hResData), 464 | 0, 465 | 0) 466 | 467 | return LPVOID(ret) 468 | } 469 | 470 | func SizeofResource(hModule HMODULE, hResInfo HRSRC)DWORD{ 471 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libkernel32, "SizeofResource"), 2, 472 | uintptr(hModule), 473 | uintptr(hResInfo), 474 | 0) 475 | 476 | return DWORD(ret) 477 | } 478 | 479 | func FreeResource(hglbResource HGLOBAL) BOOL{ 480 | ret, _, _ := syscall.Syscall(MustGetProcAddress(libkernel32, "FreeResource"), 1, 481 | uintptr(hglbResource), 482 | 0, 483 | 0) 484 | 485 | return BOOL(ret) 486 | } -------------------------------------------------------------------------------- /listbox.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The go-winapi 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 | package winapi 6 | 7 | // ListBox style 8 | const ( 9 | LBS_NOTIFY = 0x0001 10 | LBS_SORT = 0x0002 11 | LBS_NOREDRAW = 0x0004 12 | LBS_MULTIPLESEL = 0x0008 13 | LBS_OWNERDRAWFIXED = 0x0010 14 | LBS_OWNERDRAWVARIABLE = 0x0020 15 | LBS_HASSTRINGS = 0x0040 16 | LBS_USETABSTOPS = 0x0080 17 | LBS_NOINTEGRALHEIGHT = 0x0100 18 | LBS_MULTICOLUMN = 0x0200 19 | LBS_WANTKEYBOARDINPUT = 0x0400 20 | LBS_EXTENDEDSEL = 0x0800 21 | LBS_DISABLENOSCROLL = 0x1000 22 | LBS_NODATA = 0x2000 23 | LBS_NOSEL = 0x4000 24 | LBS_COMBOBOX = 0x8000 25 | LBS_STANDARD = LBS_NOTIFY | LBS_SORT | WS_BORDER | WS_VSCROLL 26 | ) 27 | 28 | // ListBox messages 29 | const ( 30 | LB_ADDSTRING = 0x0180 31 | LB_INSERTSTRING = 0x0181 32 | LB_DELETESTRING = 0x0182 33 | LB_SELITEMRANGEEX = 0x0183 34 | LB_RESETCONTENT = 0x0184 35 | LB_SETSEL = 0x0185 36 | LB_SETCURSEL = 0x0186 37 | LB_GETSEL = 0x0187 38 | LB_GETCURSEL = 0x0188 39 | LB_GETTEXT = 0x0189 40 | LB_GETTEXTLEN = 0x018A 41 | LB_GETCOUNT = 0x018B 42 | LB_SELECTSTRING = 0x018C 43 | LB_DIR = 0x018D 44 | LB_GETTOPINDEX = 0x018E 45 | LB_FINDSTRING = 0x018F 46 | LB_GETSELCOUNT = 0x0190 47 | LB_GETSELITEMS = 0x0191 48 | LB_SETTABSTOPS = 0x0192 49 | LB_GETHORIZONTALEXTENT = 0x0193 50 | LB_SETHORIZONTALEXTENT = 0x0194 51 | LB_SETCOLUMNWIDTH = 0x0195 52 | LB_ADDFILE = 0x0196 53 | LB_SETTOPINDEX = 0x0197 54 | LB_GETITEMRECT = 0x0198 55 | LB_GETITEMDATA = 0x0199 56 | LB_SETITEMDATA = 0x019A 57 | LB_SELITEMRANGE = 0x019B 58 | LB_SETANCHORINDEX = 0x019C 59 | LB_GETANCHORINDEX = 0x019D 60 | LB_SETCARETINDEX = 0x019E 61 | LB_GETCARETINDEX = 0x019F 62 | LB_SETITEMHEIGHT = 0x01A0 63 | LB_GETITEMHEIGHT = 0x01A1 64 | LB_FINDSTRINGEXACT = 0x01A2 65 | LB_SETLOCALE = 0x01A5 66 | LB_GETLOCALE = 0x01A6 67 | LB_SETCOUNT = 0x01A7 68 | LB_INITSTORAGE = 0x01A8 69 | LB_ITEMFROMPOINT = 0x01A9 70 | LB_MULTIPLEADDSTRING = 0x01B1 71 | ) 72 | 73 | //Listbox Notification Codes 74 | const ( 75 | LBN_ERRSPACE = -2 76 | LBN_SELCHANGE = 1 77 | LBN_DBLCLK = 2 78 | LBN_SELCANCEL = 3 79 | LBN_SETFOCUS = 4 80 | LBN_KILLFOCUS = 5 81 | ) 82 | const ( 83 | LB_ERR = -1 84 | LB_ERRSPACE = -2 85 | ) 86 | -------------------------------------------------------------------------------- /listview.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | const ( 8 | LVSCW_AUTOSIZE = ^uintptr(0) 9 | LVSCW_AUTOSIZE_USEHEADER = ^uintptr(1) 10 | ) 11 | 12 | // ListView messages 13 | const ( 14 | LVM_FIRST = 0x1000 15 | LVM_SETIMAGELIST = LVM_FIRST + 3 16 | LVM_GETITEM = LVM_FIRST + 75 17 | LVM_SETITEM = LVM_FIRST + 76 18 | LVM_INSERTITEM = LVM_FIRST + 77 19 | LVM_DELETEITEM = LVM_FIRST + 8 20 | LVM_DELETEALLITEMS = LVM_FIRST + 9 21 | LVM_GETCALLBACKMASK = LVM_FIRST + 10 22 | LVM_SETCALLBACKMASK = LVM_FIRST + 11 23 | LVM_GETNEXTITEM = LVM_FIRST + 12 24 | LVM_FINDITEM = LVM_FIRST + 83 25 | LVM_GETITEMRECT = LVM_FIRST + 14 26 | LVM_GETSTRINGWIDTH = LVM_FIRST + 87 27 | LVM_HITTEST = LVM_FIRST + 18 28 | LVM_ENSUREVISIBLE = LVM_FIRST + 19 29 | LVM_SCROLL = LVM_FIRST + 20 30 | LVM_REDRAWITEMS = LVM_FIRST + 21 31 | LVM_ARRANGE = LVM_FIRST + 22 32 | LVM_EDITLABEL = LVM_FIRST + 118 33 | LVM_GETEDITCONTROL = LVM_FIRST + 24 34 | LVM_GETCOLUMN = LVM_FIRST + 95 35 | LVM_SETCOLUMN = LVM_FIRST + 96 36 | LVM_INSERTCOLUMN = LVM_FIRST + 97 37 | LVM_DELETECOLUMN = LVM_FIRST + 28 38 | LVM_GETCOLUMNWIDTH = LVM_FIRST + 29 39 | LVM_SETCOLUMNWIDTH = LVM_FIRST + 30 40 | LVM_GETHEADER = LVM_FIRST + 31 41 | LVM_CREATEDRAGIMAGE = LVM_FIRST + 33 42 | LVM_GETVIEWRECT = LVM_FIRST + 34 43 | LVM_GETTEXTCOLOR = LVM_FIRST + 35 44 | LVM_SETTEXTCOLOR = LVM_FIRST + 36 45 | LVM_GETTEXTBKCOLOR = LVM_FIRST + 37 46 | LVM_SETTEXTBKCOLOR = LVM_FIRST + 38 47 | LVM_GETTOPINDEX = LVM_FIRST + 39 48 | LVM_GETCOUNTPERPAGE = LVM_FIRST + 40 49 | LVM_GETORIGIN = LVM_FIRST + 41 50 | LVM_UPDATE = LVM_FIRST + 42 51 | LVM_SETITEMSTATE = LVM_FIRST + 43 52 | LVM_GETITEMSTATE = LVM_FIRST + 44 53 | LVM_GETITEMTEXT = LVM_FIRST + 115 54 | LVM_SETITEMTEXT = LVM_FIRST + 116 55 | LVM_SETITEMCOUNT = LVM_FIRST + 47 56 | LVM_SORTITEMS = LVM_FIRST + 48 57 | LVM_SETITEMPOSITION32 = LVM_FIRST + 49 58 | LVM_GETSELECTEDCOUNT = LVM_FIRST + 50 59 | LVM_GETITEMSPACING = LVM_FIRST + 51 60 | LVM_GETISEARCHSTRING = LVM_FIRST + 117 61 | LVM_SETICONSPACING = LVM_FIRST + 53 62 | LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54 63 | LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55 64 | LVM_GETSUBITEMRECT = LVM_FIRST + 56 65 | LVM_SUBITEMHITTEST = LVM_FIRST + 57 66 | LVM_SETCOLUMNORDERARRAY = LVM_FIRST + 58 67 | LVM_GETCOLUMNORDERARRAY = LVM_FIRST + 59 68 | LVM_SETHOTITEM = LVM_FIRST + 60 69 | LVM_GETHOTITEM = LVM_FIRST + 61 70 | LVM_SETHOTCURSOR = LVM_FIRST + 62 71 | LVM_GETHOTCURSOR = LVM_FIRST + 63 72 | LVM_APPROXIMATEVIEWRECT = LVM_FIRST + 64 73 | LVM_SETWORKAREAS = LVM_FIRST + 65 74 | LVM_GETWORKAREAS = LVM_FIRST + 70 75 | LVM_GETNUMBEROFWORKAREAS = LVM_FIRST + 73 76 | LVM_GETSELECTIONMARK = LVM_FIRST + 66 77 | LVM_SETSELECTIONMARK = LVM_FIRST + 67 78 | LVM_SETHOVERTIME = LVM_FIRST + 71 79 | LVM_GETHOVERTIME = LVM_FIRST + 72 80 | LVM_SETTOOLTIPS = LVM_FIRST + 74 81 | LVM_GETTOOLTIPS = LVM_FIRST + 78 82 | LVM_SORTITEMSEX = LVM_FIRST + 81 83 | LVM_SETBKIMAGE = LVM_FIRST + 138 84 | LVM_GETBKIMAGE = LVM_FIRST + 139 85 | LVM_SETSELECTEDCOLUMN = LVM_FIRST + 140 86 | LVM_SETVIEW = LVM_FIRST + 142 87 | LVM_GETVIEW = LVM_FIRST + 143 88 | LVM_INSERTGROUP = LVM_FIRST + 145 89 | LVM_SETGROUPINFO = LVM_FIRST + 147 90 | LVM_GETGROUPINFO = LVM_FIRST + 149 91 | LVM_REMOVEGROUP = LVM_FIRST + 150 92 | LVM_MOVEGROUP = LVM_FIRST + 151 93 | LVM_GETGROUPCOUNT = LVM_FIRST + 152 94 | LVM_GETGROUPINFOBYINDEX = LVM_FIRST + 153 95 | LVM_MOVEITEMTOGROUP = LVM_FIRST + 154 96 | LVM_GETGROUPRECT = LVM_FIRST + 98 97 | LVM_SETGROUPMETRICS = LVM_FIRST + 155 98 | LVM_GETGROUPMETRICS = LVM_FIRST + 156 99 | LVM_ENABLEGROUPVIEW = LVM_FIRST + 157 100 | LVM_SORTGROUPS = LVM_FIRST + 158 101 | LVM_INSERTGROUPSORTED = LVM_FIRST + 159 102 | LVM_REMOVEALLGROUPS = LVM_FIRST + 160 103 | LVM_HASGROUP = LVM_FIRST + 161 104 | LVM_GETGROUPSTATE = LVM_FIRST + 92 105 | LVM_GETFOCUSEDGROUP = LVM_FIRST + 93 106 | LVM_SETTILEVIEWINFO = LVM_FIRST + 162 107 | LVM_GETTILEVIEWINFO = LVM_FIRST + 163 108 | LVM_SETTILEINFO = LVM_FIRST + 164 109 | LVM_GETTILEINFO = LVM_FIRST + 165 110 | LVM_SETINSERTMARK = LVM_FIRST + 166 111 | LVM_GETINSERTMARK = LVM_FIRST + 167 112 | LVM_INSERTMARKHITTEST = LVM_FIRST + 168 113 | LVM_GETINSERTMARKRECT = LVM_FIRST + 169 114 | LVM_SETINSERTMARKCOLOR = LVM_FIRST + 170 115 | LVM_GETINSERTMARKCOLOR = LVM_FIRST + 171 116 | LVM_SETINFOTIP = LVM_FIRST + 173 117 | LVM_GETSELECTEDCOLUMN = LVM_FIRST + 174 118 | LVM_ISGROUPVIEWENABLED = LVM_FIRST + 175 119 | LVM_GETOUTLINECOLOR = LVM_FIRST + 176 120 | LVM_SETOUTLINECOLOR = LVM_FIRST + 177 121 | LVM_CANCELEDITLABEL = LVM_FIRST + 179 122 | LVM_MAPINDEXTOID = LVM_FIRST + 180 123 | LVM_MAPIDTOINDEX = LVM_FIRST + 181 124 | LVM_ISITEMVISIBLE = LVM_FIRST + 182 125 | LVM_GETNEXTITEMINDEX = LVM_FIRST + 211 126 | ) 127 | 128 | // ListView notifications 129 | const ( 130 | LVN_FIRST = -100 131 | 132 | LVN_ITEMCHANGING = LVN_FIRST - 0 133 | LVN_ITEMCHANGED = LVN_FIRST - 1 134 | LVN_INSERTITEM = LVN_FIRST - 2 135 | LVN_DELETEITEM = LVN_FIRST - 3 136 | LVN_DELETEALLITEMS = LVN_FIRST - 4 137 | LVN_BEGINLABELEDIT = LVN_FIRST - 75 138 | LVN_ENDLABELEDIT = LVN_FIRST - 76 139 | LVN_COLUMNCLICK = LVN_FIRST - 8 140 | LVN_BEGINDRAG = LVN_FIRST - 9 141 | LVN_BEGINRDRAG = LVN_FIRST - 11 142 | LVN_ODCACHEHINT = LVN_FIRST - 13 143 | LVN_ODFINDITEM = LVN_FIRST - 79 144 | LVN_ITEMACTIVATE = LVN_FIRST - 14 145 | LVN_ODSTATECHANGED = LVN_FIRST - 15 146 | LVN_HOTTRACK = LVN_FIRST - 21 147 | LVN_GETDISPINFO = LVN_FIRST - 77 148 | LVN_SETDISPINFO = LVN_FIRST - 78 149 | LVN_KEYDOWN = LVN_FIRST - 55 150 | LVN_MARQUEEBEGIN = LVN_FIRST - 56 151 | LVN_GETINFOTIP = LVN_FIRST - 58 152 | LVN_INCREMENTALSEARCH = LVN_FIRST - 63 153 | LVN_BEGINSCROLL = LVN_FIRST - 80 154 | LVN_ENDSCROLL = LVN_FIRST - 81 155 | ) 156 | 157 | // ListView LVNI constants 158 | const ( 159 | LVNI_ALL = 0 160 | LVNI_FOCUSED = 1 161 | LVNI_SELECTED = 2 162 | LVNI_CUT = 4 163 | LVNI_DROPHILITED = 8 164 | LVNI_ABOVE = 256 165 | LVNI_BELOW = 512 166 | LVNI_TOLEFT = 1024 167 | LVNI_TORIGHT = 2048 168 | ) 169 | 170 | // ListView styles 171 | const ( 172 | LVS_ICON = 0x0000 173 | LVS_REPORT = 0x0001 174 | LVS_SMALLICON = 0x0002 175 | LVS_LIST = 0x0003 176 | LVS_TYPEMASK = 0x0003 177 | LVS_SINGLESEL = 0x0004 178 | LVS_SHOWSELALWAYS = 0x0008 179 | LVS_SORTASCENDING = 0x0010 180 | LVS_SORTDESCENDING = 0x0020 181 | LVS_SHAREIMAGELISTS = 0x0040 182 | LVS_NOLABELWRAP = 0x0080 183 | LVS_AUTOARRANGE = 0x0100 184 | LVS_EDITLABELS = 0x0200 185 | LVS_OWNERDATA = 0x1000 186 | LVS_NOSCROLL = 0x2000 187 | LVS_TYPESTYLEMASK = 0xfc00 188 | LVS_ALIGNTOP = 0x0000 189 | LVS_ALIGNLEFT = 0x0800 190 | LVS_ALIGNMASK = 0x0c00 191 | LVS_OWNERDRAWFIXED = 0x0400 192 | LVS_NOCOLUMNHEADER = 0x4000 193 | LVS_NOSORTHEADER = 0x8000 194 | ) 195 | 196 | // ListView extended styles 197 | const ( 198 | LVS_EX_GRIDLINES = 0x00000001 199 | LVS_EX_SUBITEMIMAGES = 0x00000002 200 | LVS_EX_CHECKBOXES = 0x00000004 201 | LVS_EX_TRACKSELECT = 0x00000008 202 | LVS_EX_HEADERDRAGDROP = 0x00000010 203 | LVS_EX_FULLROWSELECT = 0x00000020 204 | LVS_EX_ONECLICKACTIVATE = 0x00000040 205 | LVS_EX_TWOCLICKACTIVATE = 0x00000080 206 | LVS_EX_FLATSB = 0x00000100 207 | LVS_EX_REGIONAL = 0x00000200 208 | LVS_EX_INFOTIP = 0x00000400 209 | LVS_EX_UNDERLINEHOT = 0x00000800 210 | LVS_EX_UNDERLINECOLD = 0x00001000 211 | LVS_EX_MULTIWORKAREAS = 0x00002000 212 | LVS_EX_LABELTIP = 0x00004000 213 | LVS_EX_BORDERSELECT = 0x00008000 214 | LVS_EX_DOUBLEBUFFER = 0x00010000 215 | LVS_EX_HIDELABELS = 0x00020000 216 | LVS_EX_SINGLEROW = 0x00040000 217 | LVS_EX_SNAPTOGRID = 0x00080000 218 | LVS_EX_SIMPLESELECT = 0x00100000 219 | ) 220 | 221 | // ListView column flags 222 | const ( 223 | LVCF_FMT = 0x0001 224 | LVCF_WIDTH = 0x0002 225 | LVCF_TEXT = 0x0004 226 | LVCF_SUBITEM = 0x0008 227 | LVCF_IMAGE = 0x0010 228 | LVCF_ORDER = 0x0020 229 | ) 230 | 231 | // ListView column format constants 232 | const ( 233 | LVCFMT_LEFT = 0x0000 234 | LVCFMT_RIGHT = 0x0001 235 | LVCFMT_CENTER = 0x0002 236 | LVCFMT_JUSTIFYMASK = 0x0003 237 | LVCFMT_IMAGE = 0x0800 238 | LVCFMT_BITMAP_ON_RIGHT = 0x1000 239 | LVCFMT_COL_HAS_IMAGES = 0x8000 240 | ) 241 | 242 | // ListView item flags 243 | const ( 244 | LVIF_TEXT = 0x00000001 245 | LVIF_IMAGE = 0x00000002 246 | LVIF_PARAM = 0x00000004 247 | LVIF_STATE = 0x00000008 248 | LVIF_INDENT = 0x00000010 249 | LVIF_NORECOMPUTE = 0x00000800 250 | LVIF_GROUPID = 0x00000100 251 | LVIF_COLUMNS = 0x00000200 252 | ) 253 | 254 | // ListView item states 255 | const ( 256 | LVIS_FOCUSED = 1 257 | LVIS_SELECTED = 2 258 | LVIS_CUT = 4 259 | LVIS_DROPHILITED = 8 260 | LVIS_OVERLAYMASK = 0xF00 261 | LVIS_STATEIMAGEMASK = 0xF000 262 | ) 263 | 264 | // ListView hit test constants 265 | const ( 266 | LVHT_NOWHERE = 0x00000001 267 | LVHT_ONITEMICON = 0x00000002 268 | LVHT_ONITEMLABEL = 0x00000004 269 | LVHT_ONITEMSTATEICON = 0x00000008 270 | LVHT_ONITEM = LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON 271 | 272 | LVHT_ABOVE = 0x00000008 273 | LVHT_BELOW = 0x00000010 274 | LVHT_TORIGHT = 0x00000020 275 | LVHT_TOLEFT = 0x00000040 276 | ) 277 | 278 | // ListView image list types 279 | const ( 280 | LVSIL_NORMAL = 0 281 | LVSIL_SMALL = 1 282 | LVSIL_STATE = 2 283 | LVSIL_GROUPHEADER = 3 284 | ) 285 | 286 | type LVCOLUMN struct { 287 | Mask uint32 288 | Fmt int32 289 | Cx int32 290 | PszText *uint16 291 | CchTextMax int32 292 | ISubItem int32 293 | IImage int32 294 | IOrder int32 295 | } 296 | 297 | type LVITEM struct { 298 | Mask uint32 299 | IItem int32 300 | ISubItem int32 301 | State uint32 302 | StateMask uint32 303 | PszText *uint16 304 | CchTextMax int32 305 | IImage int32 306 | LParam uintptr 307 | IIndent int32 308 | IGroupId int32 309 | CColumns uint32 310 | PuColumns uint32 311 | } 312 | 313 | type LVHITTESTINFO struct { 314 | Pt POINT 315 | Flags uint32 316 | IItem int32 317 | ISubItem int32 318 | IGroup int32 319 | } 320 | 321 | type NMITEMACTIVATE struct { 322 | Hdr NMHDR 323 | IItem int32 324 | ISubItem int32 325 | UNewState uint32 326 | UOldState uint32 327 | UChanged uint32 328 | PtAction POINT 329 | LParam uintptr 330 | UKeyFlags uint32 331 | } 332 | 333 | type NMLISTVIEW struct { 334 | Hdr NMHDR 335 | IItem int32 336 | ISubItem int32 337 | UNewState uint32 338 | UOldState uint32 339 | UChanged uint32 340 | PtAction POINT 341 | LParam uintptr 342 | } 343 | 344 | type NMLVCUSTOMDRAW struct { 345 | Nmcd NMCUSTOMDRAW 346 | ClrText COLORREF 347 | ClrTextBk COLORREF 348 | ISubItem int32 349 | DwItemType uint32 350 | ClrFace COLORREF 351 | IIconEffect int32 352 | IIconPhase int32 353 | IPartId int32 354 | IStateId int32 355 | RcText RECT 356 | UAlign uint32 357 | } 358 | 359 | type NMLVDISPINFO struct { 360 | Hdr NMHDR 361 | Item LVITEM 362 | } 363 | -------------------------------------------------------------------------------- /menu.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | // Constants for MENUITEMINFO.fMask 8 | const ( 9 | MIIM_STATE = 1 10 | MIIM_ID = 2 11 | MIIM_SUBMENU = 4 12 | MIIM_CHECKMARKS = 8 13 | MIIM_TYPE = 16 14 | MIIM_DATA = 32 15 | MIIM_STRING = 64 16 | MIIM_BITMAP = 128 17 | MIIM_FTYPE = 256 18 | ) 19 | 20 | // Constants for MENUITEMINFO.fType 21 | const ( 22 | MFT_BITMAP = 4 23 | MFT_MENUBARBREAK = 32 24 | MFT_MENUBREAK = 64 25 | MFT_OWNERDRAW = 256 26 | MFT_RADIOCHECK = 512 27 | MFT_RIGHTJUSTIFY = 0x4000 28 | MFT_SEPARATOR = 0x800 29 | MFT_RIGHTORDER = 0x2000 30 | MFT_STRING = 0 31 | ) 32 | 33 | // Constants for MENUITEMINFO.fState 34 | const ( 35 | MFS_CHECKED = 8 36 | MFS_DEFAULT = 4096 37 | MFS_DISABLED = 3 38 | MFS_ENABLED = 0 39 | MFS_GRAYED = 3 40 | MFS_HILITE = 128 41 | MFS_UNCHECKED = 0 42 | MFS_UNHILITE = 0 43 | ) 44 | 45 | // Constants for MENUITEMINFO.hbmp* 46 | const ( 47 | HBMMENU_CALLBACK = -1 48 | HBMMENU_SYSTEM = 1 49 | HBMMENU_MBAR_RESTORE = 2 50 | HBMMENU_MBAR_MINIMIZE = 3 51 | HBMMENU_MBAR_CLOSE = 5 52 | HBMMENU_MBAR_CLOSE_D = 6 53 | HBMMENU_MBAR_MINIMIZE_D = 7 54 | HBMMENU_POPUP_CLOSE = 8 55 | HBMMENU_POPUP_RESTORE = 9 56 | HBMMENU_POPUP_MAXIMIZE = 10 57 | HBMMENU_POPUP_MINIMIZE = 11 58 | ) 59 | 60 | // MENUINFO mask constants 61 | const ( 62 | MIM_APPLYTOSUBMENUS = 0x80000000 63 | MIM_BACKGROUND = 0x00000002 64 | MIM_HELPID = 0x00000004 65 | MIM_MAXHEIGHT = 0x00000001 66 | MIM_MENUDATA = 0x00000008 67 | MIM_STYLE = 0x00000010 68 | ) 69 | 70 | // MENUINFO style constants 71 | const ( 72 | MNS_AUTODISMISS = 0x10000000 73 | MNS_CHECKORBMP = 0x04000000 74 | MNS_DRAGDROP = 0x20000000 75 | MNS_MODELESS = 0x40000000 76 | MNS_NOCHECK = 0x80000000 77 | MNS_NOTIFYBYPOS = 0x08000000 78 | ) 79 | 80 | const ( 81 | MF_BYCOMMAND = 0x00000000 82 | MF_BYPOSITION = 0x00000400 83 | MF_CHECKED = 0x00000008 84 | MF_UNCHECKED = 0x00000000 85 | MF_GRAYED = 0x00000001 86 | MF_ENABLED = 0x00000000 87 | MF_DISABLED = 0x00000002 88 | MF_STRING = 0x00000000 89 | MF_SEPARATOR = 0x00000800 90 | MF_POPUP = 0x00000010 91 | MF_OWNERDRAW = 0x00000100 92 | MF_MENUBREAK = 0x00000040 93 | MF_MENUBARBREAK = 0x00000020 94 | MF_BITMAP = 0x00000004 95 | ) 96 | 97 | type MENUITEMINFO struct { 98 | CbSize uint32 99 | FMask uint32 100 | FType uint32 101 | FState uint32 102 | WID uint32 103 | HSubMenu HMENU 104 | HbmpChecked HBITMAP 105 | HbmpUnchecked HBITMAP 106 | DwItemData uintptr 107 | DwTypeData *uint16 108 | Cch uint32 109 | HbmpItem HBITMAP 110 | } 111 | 112 | type MENUINFO struct { 113 | CbSize uint32 114 | FMask uint32 115 | DwStyle uint32 116 | CyMax uint32 117 | HbrBack HBRUSH 118 | DwContextHelpID uint32 119 | DwMenuData uintptr 120 | } 121 | -------------------------------------------------------------------------------- /ole32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | const ( 13 | CLSCTX_INPROC_SERVER = 0x1 14 | CLSCTX_INPROC_HANDLER = 0x2 15 | CLSCTX_LOCAL_SERVER = 0x4 16 | CLSCTX_INPROC_SERVER16 = 0x8 17 | CLSCTX_REMOTE_SERVER = 0x10 18 | CLSCTX_INPROC_HANDLER16 = 0x20 19 | CLSCTX_RESERVED1 = 0x40 20 | CLSCTX_RESERVED2 = 0x80 21 | CLSCTX_RESERVED3 = 0x100 22 | CLSCTX_RESERVED4 = 0x200 23 | CLSCTX_NO_CODE_DOWNLOAD = 0x400 24 | CLSCTX_RESERVED5 = 0x800 25 | CLSCTX_NO_CUSTOM_MARSHAL = 0x1000 26 | CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000 27 | CLSCTX_NO_FAILURE_LOG = 0x4000 28 | CLSCTX_DISABLE_AAA = 0x8000 29 | CLSCTX_ENABLE_AAA = 0x10000 30 | CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000 31 | CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000 32 | CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000 33 | CLSCTX_ENABLE_CLOAKING = 0x100000 34 | CLSCTX_PS_DLL = 0x80000000 35 | CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER 36 | ) 37 | 38 | // Verbs for IOleObject.DoVerb 39 | const ( 40 | OLEIVERB_PRIMARY = 0 41 | OLEIVERB_SHOW = -1 42 | OLEIVERB_OPEN = -2 43 | OLEIVERB_HIDE = -3 44 | OLEIVERB_UIACTIVATE = -4 45 | OLEIVERB_INPLACEACTIVATE = -5 46 | OLEIVERB_DISCARDUNDOSTATE = -6 47 | ) 48 | 49 | // OLECLOSE constants 50 | const ( 51 | OLECLOSE_SAVEIFDIRTY = 0 52 | OLECLOSE_NOSAVE = 1 53 | OLECLOSE_PROMPTSAVE = 2 54 | ) 55 | 56 | type IID GUID 57 | type CLSID GUID 58 | type REFIID *IID 59 | type REFCLSID *CLSID 60 | 61 | var ( 62 | IID_IClassFactory = IID{0x00000001, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 63 | IID_IConnectionPointContainer = IID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} 64 | IID_IOleClientSite = IID{0x00000118, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 65 | IID_IOleInPlaceObject = IID{0x00000113, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 66 | IID_IOleInPlaceSite = IID{0x00000119, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 67 | IID_IOleObject = IID{0x00000112, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 68 | IID_IUnknown = IID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 69 | ) 70 | 71 | func EqualREFIID(a, b REFIID) bool { 72 | if a == b { 73 | return true 74 | } 75 | if a == nil || b == nil { 76 | return false 77 | } 78 | 79 | if a.Data1 != b.Data1 || a.Data2 != b.Data2 || a.Data3 != b.Data3 { 80 | return false 81 | } 82 | 83 | for i := 0; i < 8; i++ { 84 | if a.Data4[i] != b.Data4[i] { 85 | return false 86 | } 87 | } 88 | 89 | return true 90 | } 91 | 92 | type IClassFactoryVtbl struct { 93 | QueryInterface uintptr 94 | AddRef uintptr 95 | Release uintptr 96 | CreateInstance uintptr 97 | LockServer uintptr 98 | } 99 | 100 | type IClassFactory struct { 101 | LpVtbl *IClassFactoryVtbl 102 | } 103 | 104 | func (cf *IClassFactory) Release() uint32 { 105 | ret, _, _ := syscall.Syscall(cf.LpVtbl.Release, 1, 106 | uintptr(unsafe.Pointer(cf)), 107 | 0, 108 | 0) 109 | 110 | return uint32(ret) 111 | } 112 | 113 | func (cf *IClassFactory) CreateInstance(pUnkOuter *IUnknown, riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 114 | ret, _, _ := syscall.Syscall6(cf.LpVtbl.CreateInstance, 4, 115 | uintptr(unsafe.Pointer(cf)), 116 | uintptr(unsafe.Pointer(pUnkOuter)), 117 | uintptr(unsafe.Pointer(riid)), 118 | uintptr(unsafe.Pointer(ppvObject)), 119 | 0, 120 | 0) 121 | 122 | return HRESULT(ret) 123 | } 124 | 125 | type IConnectionPointVtbl struct { 126 | QueryInterface uintptr 127 | AddRef uintptr 128 | Release uintptr 129 | GetConnectionInterface uintptr 130 | GetConnectionPointContainer uintptr 131 | Advise uintptr 132 | Unadvise uintptr 133 | EnumConnections uintptr 134 | } 135 | 136 | type IConnectionPoint struct { 137 | LpVtbl *IConnectionPointVtbl 138 | } 139 | 140 | func (cp *IConnectionPoint) Release() uint32 { 141 | ret, _, _ := syscall.Syscall(cp.LpVtbl.Release, 1, 142 | uintptr(unsafe.Pointer(cp)), 143 | 0, 144 | 0) 145 | 146 | return uint32(ret) 147 | } 148 | 149 | func (cp *IConnectionPoint) Advise(pUnkSink unsafe.Pointer, pdwCookie *uint32) HRESULT { 150 | ret, _, _ := syscall.Syscall(cp.LpVtbl.Advise, 3, 151 | uintptr(unsafe.Pointer(cp)), 152 | uintptr(pUnkSink), 153 | uintptr(unsafe.Pointer(pdwCookie))) 154 | 155 | return HRESULT(ret) 156 | } 157 | 158 | type IConnectionPointContainerVtbl struct { 159 | QueryInterface uintptr 160 | AddRef uintptr 161 | Release uintptr 162 | EnumConnectionPoints uintptr 163 | FindConnectionPoint uintptr 164 | } 165 | 166 | type IConnectionPointContainer struct { 167 | LpVtbl *IConnectionPointContainerVtbl 168 | } 169 | 170 | func (cpc *IConnectionPointContainer) Release() uint32 { 171 | ret, _, _ := syscall.Syscall(cpc.LpVtbl.Release, 1, 172 | uintptr(unsafe.Pointer(cpc)), 173 | 0, 174 | 0) 175 | 176 | return uint32(ret) 177 | } 178 | 179 | func (cpc *IConnectionPointContainer) FindConnectionPoint(riid REFIID, ppCP **IConnectionPoint) HRESULT { 180 | ret, _, _ := syscall.Syscall(cpc.LpVtbl.FindConnectionPoint, 3, 181 | uintptr(unsafe.Pointer(cpc)), 182 | uintptr(unsafe.Pointer(riid)), 183 | uintptr(unsafe.Pointer(ppCP))) 184 | 185 | return HRESULT(ret) 186 | } 187 | 188 | type IOleClientSiteVtbl struct { 189 | QueryInterface uintptr 190 | AddRef uintptr 191 | Release uintptr 192 | SaveObject uintptr 193 | GetMoniker uintptr 194 | GetContainer uintptr 195 | ShowObject uintptr 196 | OnShowWindow uintptr 197 | RequestNewObjectLayout uintptr 198 | } 199 | 200 | type IOleClientSite struct { 201 | LpVtbl *IOleClientSiteVtbl 202 | } 203 | 204 | type IOleInPlaceFrameVtbl struct { 205 | QueryInterface uintptr 206 | AddRef uintptr 207 | Release uintptr 208 | GetWindow uintptr 209 | ContextSensitiveHelp uintptr 210 | GetBorder uintptr 211 | RequestBorderSpace uintptr 212 | SetBorderSpace uintptr 213 | SetActiveObject uintptr 214 | InsertMenus uintptr 215 | SetMenu uintptr 216 | RemoveMenus uintptr 217 | SetStatusText uintptr 218 | EnableModeless uintptr 219 | TranslateAccelerator uintptr 220 | } 221 | 222 | type IOleInPlaceFrame struct { 223 | LpVtbl *IOleInPlaceFrameVtbl 224 | } 225 | 226 | type IOleInPlaceObjectVtbl struct { 227 | QueryInterface uintptr 228 | AddRef uintptr 229 | Release uintptr 230 | GetWindow uintptr 231 | ContextSensitiveHelp uintptr 232 | InPlaceDeactivate uintptr 233 | UIDeactivate uintptr 234 | SetObjectRects uintptr 235 | ReactivateAndUndo uintptr 236 | } 237 | 238 | type IOleInPlaceObject struct { 239 | LpVtbl *IOleInPlaceObjectVtbl 240 | } 241 | 242 | func (obj *IOleInPlaceObject) Release() uint32 { 243 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, 244 | uintptr(unsafe.Pointer(obj)), 245 | 0, 246 | 0) 247 | 248 | return uint32(ret) 249 | } 250 | 251 | func (obj *IOleInPlaceObject) SetObjectRects(lprcPosRect, lprcClipRect *RECT) HRESULT { 252 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetObjectRects, 3, 253 | uintptr(unsafe.Pointer(obj)), 254 | uintptr(unsafe.Pointer(lprcPosRect)), 255 | uintptr(unsafe.Pointer(lprcClipRect))) 256 | 257 | return HRESULT(ret) 258 | } 259 | 260 | type IOleInPlaceSiteVtbl struct { 261 | QueryInterface uintptr 262 | AddRef uintptr 263 | Release uintptr 264 | GetWindow uintptr 265 | ContextSensitiveHelp uintptr 266 | CanInPlaceActivate uintptr 267 | OnInPlaceActivate uintptr 268 | OnUIActivate uintptr 269 | GetWindowContext uintptr 270 | Scroll uintptr 271 | OnUIDeactivate uintptr 272 | OnInPlaceDeactivate uintptr 273 | DiscardUndoState uintptr 274 | DeactivateAndUndo uintptr 275 | OnPosRectChange uintptr 276 | } 277 | 278 | type IOleInPlaceSite struct { 279 | LpVtbl *IOleInPlaceSiteVtbl 280 | } 281 | 282 | type IOleObjectVtbl struct { 283 | QueryInterface uintptr 284 | AddRef uintptr 285 | Release uintptr 286 | SetClientSite uintptr 287 | GetClientSite uintptr 288 | SetHostNames uintptr 289 | Close uintptr 290 | SetMoniker uintptr 291 | GetMoniker uintptr 292 | InitFromData uintptr 293 | GetClipboardData uintptr 294 | DoVerb uintptr 295 | EnumVerbs uintptr 296 | Update uintptr 297 | IsUpToDate uintptr 298 | GetUserClassID uintptr 299 | GetUserType uintptr 300 | SetExtent uintptr 301 | GetExtent uintptr 302 | Advise uintptr 303 | Unadvise uintptr 304 | EnumAdvise uintptr 305 | GetMiscStatus uintptr 306 | SetColorScheme uintptr 307 | } 308 | 309 | type IOleObject struct { 310 | LpVtbl *IOleObjectVtbl 311 | } 312 | 313 | func (obj *IOleObject) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 314 | ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, 315 | uintptr(unsafe.Pointer(obj)), 316 | uintptr(unsafe.Pointer(riid)), 317 | uintptr(unsafe.Pointer(ppvObject))) 318 | 319 | return HRESULT(ret) 320 | } 321 | 322 | func (obj *IOleObject) Release() uint32 { 323 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, 324 | uintptr(unsafe.Pointer(obj)), 325 | 0, 326 | 0) 327 | 328 | return uint32(ret) 329 | } 330 | 331 | func (obj *IOleObject) SetClientSite(pClientSite *IOleClientSite) HRESULT { 332 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetClientSite, 2, 333 | uintptr(unsafe.Pointer(obj)), 334 | uintptr(unsafe.Pointer(pClientSite)), 335 | 0) 336 | 337 | return HRESULT(ret) 338 | } 339 | 340 | func (obj *IOleObject) SetHostNames(szContainerApp, szContainerObj *uint16) HRESULT { 341 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetHostNames, 3, 342 | uintptr(unsafe.Pointer(obj)), 343 | uintptr(unsafe.Pointer(szContainerApp)), 344 | uintptr(unsafe.Pointer(szContainerObj))) 345 | 346 | return HRESULT(ret) 347 | } 348 | 349 | func (obj *IOleObject) Close(dwSaveOption uint32) HRESULT { 350 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Close, 2, 351 | uintptr(unsafe.Pointer(obj)), 352 | uintptr(dwSaveOption), 353 | 0) 354 | 355 | return HRESULT(ret) 356 | } 357 | 358 | func (obj *IOleObject) DoVerb(iVerb int32, lpmsg *MSG, pActiveSite *IOleClientSite, lindex int32, hwndParent HWND, lprcPosRect *RECT) HRESULT { 359 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.DoVerb, 7, 360 | uintptr(unsafe.Pointer(obj)), 361 | uintptr(iVerb), 362 | uintptr(unsafe.Pointer(lpmsg)), 363 | uintptr(unsafe.Pointer(pActiveSite)), 364 | uintptr(lindex), 365 | uintptr(hwndParent), 366 | uintptr(unsafe.Pointer(lprcPosRect)), 367 | 0, 368 | 0) 369 | 370 | return HRESULT(ret) 371 | } 372 | 373 | type IUnknownVtbl struct { 374 | QueryInterface uintptr 375 | AddRef uintptr 376 | Release uintptr 377 | } 378 | 379 | type IUnknown struct { 380 | LpVtbl *IUnknownVtbl 381 | } 382 | 383 | type OLEINPLACEFRAMEINFO struct { 384 | Cb uint32 385 | FMDIApp BOOL 386 | HwndFrame HWND 387 | Haccel HACCEL 388 | CAccelEntries uint32 389 | } 390 | 391 | type COAUTHIDENTITY struct { 392 | User *uint16 393 | UserLength uint32 394 | Domain *uint16 395 | DomainLength uint32 396 | Password *uint16 397 | PasswordLength uint32 398 | Flags uint32 399 | } 400 | 401 | type COAUTHINFO struct { 402 | dwAuthnSvc uint32 403 | dwAuthzSvc uint32 404 | pwszServerPrincName *uint16 405 | dwAuthnLevel uint32 406 | dwImpersonationLevel uint32 407 | pAuthIdentityData *COAUTHIDENTITY 408 | dwCapabilities uint32 409 | } 410 | 411 | type COSERVERINFO struct { 412 | dwReserved1 uint32 413 | pwszName *uint16 414 | pAuthInfo *COAUTHINFO 415 | dwReserved2 uint32 416 | } 417 | 418 | var ( 419 | // Library 420 | libole32 uintptr 421 | 422 | // Functions 423 | coCreateInstance uintptr 424 | coGetClassObject uintptr 425 | coTaskMemFree uintptr 426 | oleInitialize uintptr 427 | oleSetContainedObject uintptr 428 | oleUninitialize uintptr 429 | ) 430 | 431 | func init() { 432 | // Library 433 | libole32 = MustLoadLibrary("ole32.dll") 434 | 435 | // Functions 436 | coCreateInstance = MustGetProcAddress(libole32, "CoCreateInstance") 437 | coGetClassObject = MustGetProcAddress(libole32, "CoGetClassObject") 438 | coTaskMemFree = MustGetProcAddress(libole32, "CoTaskMemFree") 439 | oleInitialize = MustGetProcAddress(libole32, "OleInitialize") 440 | oleSetContainedObject = MustGetProcAddress(libole32, "OleSetContainedObject") 441 | oleUninitialize = MustGetProcAddress(libole32, "OleUninitialize") 442 | } 443 | 444 | func CoCreateInstance(rclsid REFCLSID, pUnkOuter *IUnknown, dwClsContext uint32, riid REFIID, ppv *unsafe.Pointer) HRESULT { 445 | ret, _, _ := syscall.Syscall6(coCreateInstance, 5, 446 | uintptr(unsafe.Pointer(rclsid)), 447 | uintptr(unsafe.Pointer(pUnkOuter)), 448 | uintptr(dwClsContext), 449 | uintptr(unsafe.Pointer(riid)), 450 | uintptr(unsafe.Pointer(ppv)), 451 | 0) 452 | 453 | return HRESULT(ret) 454 | } 455 | 456 | func CoGetClassObject(rclsid REFCLSID, dwClsContext uint32, pServerInfo *COSERVERINFO, riid REFIID, ppv *unsafe.Pointer) HRESULT { 457 | ret, _, _ := syscall.Syscall6(coGetClassObject, 5, 458 | uintptr(unsafe.Pointer(rclsid)), 459 | uintptr(dwClsContext), 460 | uintptr(unsafe.Pointer(pServerInfo)), 461 | uintptr(unsafe.Pointer(riid)), 462 | uintptr(unsafe.Pointer(ppv)), 463 | 0) 464 | 465 | return HRESULT(ret) 466 | } 467 | 468 | func CoTaskMemFree(pv uintptr) { 469 | syscall.Syscall(coTaskMemFree, 1, 470 | pv, 471 | 0, 472 | 0) 473 | } 474 | 475 | func OleInitialize() HRESULT { 476 | ret, _, _ := syscall.Syscall(oleInitialize, 1, // WTF, why does 0 not work here? 477 | 0, 478 | 0, 479 | 0) 480 | 481 | return HRESULT(ret) 482 | } 483 | 484 | func OleSetContainedObject(pUnknown *IUnknown, fContained bool) HRESULT { 485 | ret, _, _ := syscall.Syscall(oleSetContainedObject, 2, 486 | uintptr(unsafe.Pointer(pUnknown)), 487 | uintptr(BoolToBOOL(fContained)), 488 | 0) 489 | 490 | return HRESULT(ret) 491 | } 492 | 493 | func OleUninitialize() { 494 | syscall.Syscall(oleUninitialize, 0, 495 | 0, 496 | 0, 497 | 0) 498 | } 499 | -------------------------------------------------------------------------------- /oleaut32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | type DISPID int32 13 | 14 | const ( 15 | DISPID_BEFORENAVIGATE DISPID = 100 16 | DISPID_NAVIGATECOMPLETE DISPID = 101 17 | DISPID_STATUSTEXTCHANGE DISPID = 102 18 | DISPID_QUIT DISPID = 103 19 | DISPID_DOWNLOADCOMPLETE DISPID = 104 20 | DISPID_COMMANDSTATECHANGE DISPID = 105 21 | DISPID_DOWNLOADBEGIN DISPID = 106 22 | DISPID_NEWWINDOW DISPID = 107 23 | DISPID_PROGRESSCHANGE DISPID = 108 24 | DISPID_WINDOWMOVE DISPID = 109 25 | DISPID_WINDOWRESIZE DISPID = 110 26 | DISPID_WINDOWACTIVATE DISPID = 111 27 | DISPID_PROPERTYCHANGE DISPID = 112 28 | DISPID_TITLECHANGE DISPID = 113 29 | DISPID_TITLEICONCHANGE DISPID = 114 30 | DISPID_FRAMEBEFORENAVIGATE DISPID = 200 31 | DISPID_FRAMENAVIGATECOMPLETE DISPID = 201 32 | DISPID_FRAMENEWWINDOW DISPID = 204 33 | DISPID_BEFORENAVIGATE2 DISPID = 250 34 | DISPID_NEWWINDOW2 DISPID = 251 35 | DISPID_NAVIGATECOMPLETE2 DISPID = 252 36 | DISPID_ONQUIT DISPID = 253 37 | DISPID_ONVISIBLE DISPID = 254 38 | DISPID_ONTOOLBAR DISPID = 255 39 | DISPID_ONMENUBAR DISPID = 256 40 | DISPID_ONSTATUSBAR DISPID = 257 41 | DISPID_ONFULLSCREEN DISPID = 258 42 | DISPID_DOCUMENTCOMPLETE DISPID = 259 43 | DISPID_ONTHEATERMODE DISPID = 260 44 | DISPID_ONADDRESSBAR DISPID = 261 45 | DISPID_WINDOWSETRESIZABLE DISPID = 262 46 | DISPID_WINDOWCLOSING DISPID = 263 47 | DISPID_WINDOWSETLEFT DISPID = 264 48 | DISPID_WINDOWSETTOP DISPID = 265 49 | DISPID_WINDOWSETWIDTH DISPID = 266 50 | DISPID_WINDOWSETHEIGHT DISPID = 267 51 | DISPID_CLIENTTOHOSTWINDOW DISPID = 268 52 | DISPID_SETSECURELOCKICON DISPID = 269 53 | DISPID_FILEDOWNLOAD DISPID = 270 54 | DISPID_NAVIGATEERROR DISPID = 271 55 | DISPID_PRIVACYIMPACTEDSTATECHANGE DISPID = 272 56 | ) 57 | 58 | var ( 59 | IID_IDispatch = IID{0x00020400, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 60 | ) 61 | 62 | const ( 63 | DISP_E_MEMBERNOTFOUND = 0x80020003 64 | ) 65 | 66 | type VARTYPE uint16 67 | 68 | const ( 69 | VT_EMPTY VARTYPE = 0 70 | VT_NULL VARTYPE = 1 71 | VT_I2 VARTYPE = 2 72 | VT_I4 VARTYPE = 3 73 | VT_R4 VARTYPE = 4 74 | VT_R8 VARTYPE = 5 75 | VT_CY VARTYPE = 6 76 | VT_DATE VARTYPE = 7 77 | VT_BSTR VARTYPE = 8 78 | VT_DISPATCH VARTYPE = 9 79 | VT_ERROR VARTYPE = 10 80 | VT_BOOL VARTYPE = 11 81 | VT_VARIANT VARTYPE = 12 82 | VT_UNKNOWN VARTYPE = 13 83 | VT_DECIMAL VARTYPE = 14 84 | VT_I1 VARTYPE = 16 85 | VT_UI1 VARTYPE = 17 86 | VT_UI2 VARTYPE = 18 87 | VT_UI4 VARTYPE = 19 88 | VT_I8 VARTYPE = 20 89 | VT_UI8 VARTYPE = 21 90 | VT_INT VARTYPE = 22 91 | VT_UINT VARTYPE = 23 92 | VT_VOID VARTYPE = 24 93 | VT_HRESULT VARTYPE = 25 94 | VT_PTR VARTYPE = 26 95 | VT_SAFEARRAY VARTYPE = 27 96 | VT_CARRAY VARTYPE = 28 97 | VT_USERDEFINED VARTYPE = 29 98 | VT_LPSTR VARTYPE = 30 99 | VT_LPWSTR VARTYPE = 31 100 | VT_RECORD VARTYPE = 36 101 | VT_INT_PTR VARTYPE = 37 102 | VT_UINT_PTR VARTYPE = 38 103 | VT_FILETIME VARTYPE = 64 104 | VT_BLOB VARTYPE = 65 105 | VT_STREAM VARTYPE = 66 106 | VT_STORAGE VARTYPE = 67 107 | VT_STREAMED_OBJECT VARTYPE = 68 108 | VT_STORED_OBJECT VARTYPE = 69 109 | VT_BLOB_OBJECT VARTYPE = 70 110 | VT_CF VARTYPE = 71 111 | VT_CLSID VARTYPE = 72 112 | VT_VERSIONED_STREAM VARTYPE = 73 113 | VT_BSTR_BLOB VARTYPE = 0xfff 114 | VT_VECTOR VARTYPE = 0x1000 115 | VT_ARRAY VARTYPE = 0x2000 116 | VT_BYREF VARTYPE = 0x4000 117 | VT_RESERVED VARTYPE = 0x8000 118 | VT_ILLEGAL VARTYPE = 0xffff 119 | VT_ILLEGALMASKED VARTYPE = 0xfff 120 | VT_TYPEMASK VARTYPE = 0xfff 121 | ) 122 | 123 | type VARIANT struct { 124 | Vt VARTYPE 125 | reserved [14]byte 126 | } 127 | 128 | type VARIANTARG VARIANT 129 | 130 | type VARIANT_BOOL int16 131 | 132 | //type BSTR *uint16 133 | 134 | func StringToBSTR(value string) *uint16 /*BSTR*/ { 135 | // IMPORTANT: Don't forget to free the BSTR value when no longer needed! 136 | return SysAllocString(value) 137 | } 138 | 139 | func BSTRToString(value *uint16 /*BSTR*/) string { 140 | // ISSUE: Is this really ok? 141 | bstrArrPtr := (*[200000000]uint16)(unsafe.Pointer(value)) 142 | 143 | bstrSlice := make([]uint16, SysStringLen(value)) 144 | copy(bstrSlice, bstrArrPtr[:]) 145 | 146 | return syscall.UTF16ToString(bstrSlice) 147 | } 148 | 149 | type VAR_I4 struct { 150 | vt VARTYPE 151 | reserved1 [6]byte 152 | lVal int32 153 | reserved2 [4]byte 154 | } 155 | 156 | func IntToVariantI4(value int32) *VAR_I4 { 157 | return &VAR_I4{vt: VT_I4, lVal: value} 158 | } 159 | 160 | func VariantI4ToInt(value *VAR_I4) int32 { 161 | return value.lVal 162 | } 163 | 164 | type VAR_BOOL struct { 165 | vt VARTYPE 166 | reserved1 [6]byte 167 | boolVal VARIANT_BOOL 168 | reserved2 [6]byte 169 | } 170 | 171 | func BoolToVariantBool(value bool) *VAR_BOOL { 172 | return &VAR_BOOL{vt: VT_BOOL, boolVal: VARIANT_BOOL(BoolToBOOL(value))} 173 | } 174 | 175 | func VariantBoolToBool(value *VAR_BOOL) bool { 176 | return value.boolVal != 0 177 | } 178 | 179 | func StringToVariantBSTR(value string) *VAR_BSTR { 180 | // IMPORTANT: Don't forget to free the BSTR value when no longer needed! 181 | return &VAR_BSTR{vt: VT_BSTR, bstrVal: StringToBSTR(value)} 182 | } 183 | 184 | func VariantBSTRToString(value *VAR_BSTR) string { 185 | return BSTRToString(value.bstrVal) 186 | } 187 | 188 | type DISPPARAMS struct { 189 | Rgvarg *VARIANTARG 190 | RgdispidNamedArgs *DISPID 191 | CArgs int32 192 | CNamedArgs int32 193 | } 194 | 195 | var ( 196 | // Library 197 | liboleaut32 uintptr 198 | 199 | // Functions 200 | sysAllocString uintptr 201 | sysFreeString uintptr 202 | sysStringLen uintptr 203 | ) 204 | 205 | func init() { 206 | // Library 207 | liboleaut32 = MustLoadLibrary("oleaut32.dll") 208 | 209 | // Functions 210 | sysAllocString = MustGetProcAddress(liboleaut32, "SysAllocString") 211 | sysFreeString = MustGetProcAddress(liboleaut32, "SysFreeString") 212 | sysStringLen = MustGetProcAddress(liboleaut32, "SysStringLen") 213 | } 214 | 215 | func SysAllocString(s string) *uint16 /*BSTR*/ { 216 | ret, _, _ := syscall.Syscall(sysAllocString, 1, 217 | uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s))), 218 | 0, 219 | 0) 220 | 221 | return (*uint16) /*BSTR*/ (unsafe.Pointer(ret)) 222 | } 223 | 224 | func SysFreeString(bstr *uint16 /*BSTR*/) { 225 | syscall.Syscall(sysFreeString, 1, 226 | uintptr(unsafe.Pointer(bstr)), 227 | 0, 228 | 0) 229 | } 230 | 231 | func SysStringLen(bstr *uint16 /*BSTR*/) uint32 { 232 | ret, _, _ := syscall.Syscall(sysStringLen, 1, 233 | uintptr(unsafe.Pointer(bstr)), 234 | 0, 235 | 0) 236 | 237 | return uint32(ret) 238 | } 239 | -------------------------------------------------------------------------------- /oleaut32_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The go-winapi 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 | package winapi 6 | 7 | type VAR_BSTR struct { 8 | vt VARTYPE 9 | reserved1 [6]byte 10 | bstrVal *uint16 /*BSTR*/ 11 | reserved2 [4]byte 12 | } 13 | -------------------------------------------------------------------------------- /oleaut32_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The go-winapi 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 | package winapi 6 | 7 | type VAR_BSTR struct { 8 | vt VARTYPE 9 | reserved1 [6]byte 10 | bstrVal *uint16 /*BSTR*/ 11 | } 12 | -------------------------------------------------------------------------------- /opengl32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // for second parameter of WglSwapLayerBuffers 13 | const ( 14 | WGL_SWAP_MAIN_PLANE = (1 << 0) 15 | WGL_SWAP_OVERLAY1 = (1 << 1) 16 | WGL_SWAP_OVERLAY2 = (1 << 2) 17 | WGL_SWAP_OVERLAY3 = (1 << 3) 18 | WGL_SWAP_OVERLAY4 = (1 << 4) 19 | WGL_SWAP_OVERLAY5 = (1 << 5) 20 | WGL_SWAP_OVERLAY6 = (1 << 6) 21 | WGL_SWAP_OVERLAY7 = (1 << 7) 22 | WGL_SWAP_OVERLAY8 = (1 << 8) 23 | WGL_SWAP_OVERLAY9 = (1 << 9) 24 | WGL_SWAP_OVERLAY10 = (1 << 10) 25 | WGL_SWAP_OVERLAY11 = (1 << 11) 26 | WGL_SWAP_OVERLAY12 = (1 << 12) 27 | WGL_SWAP_OVERLAY13 = (1 << 13) 28 | WGL_SWAP_OVERLAY14 = (1 << 14) 29 | WGL_SWAP_OVERLAY15 = (1 << 15) 30 | WGL_SWAP_UNDERLAY1 = (1 << 16) 31 | WGL_SWAP_UNDERLAY2 = (1 << 17) 32 | WGL_SWAP_UNDERLAY3 = (1 << 18) 33 | WGL_SWAP_UNDERLAY4 = (1 << 19) 34 | WGL_SWAP_UNDERLAY5 = (1 << 20) 35 | WGL_SWAP_UNDERLAY6 = (1 << 21) 36 | WGL_SWAP_UNDERLAY7 = (1 << 22) 37 | WGL_SWAP_UNDERLAY8 = (1 << 23) 38 | WGL_SWAP_UNDERLAY9 = (1 << 24) 39 | WGL_SWAP_UNDERLAY10 = (1 << 25) 40 | WGL_SWAP_UNDERLAY11 = (1 << 26) 41 | WGL_SWAP_UNDERLAY12 = (1 << 27) 42 | WGL_SWAP_UNDERLAY13 = (1 << 28) 43 | WGL_SWAP_UNDERLAY14 = (1 << 29) 44 | WGL_SWAP_UNDERLAY15 = (1 << 30) 45 | ) 46 | 47 | type ( 48 | HGLRC HANDLE 49 | ) 50 | 51 | type LAYERPLANEDESCRIPTOR struct { 52 | NSize uint16 53 | NVersion uint16 54 | DwFlags uint32 55 | IPixelType uint8 56 | CColorBits uint8 57 | CRedBits uint8 58 | CRedShift uint8 59 | CGreenBits uint8 60 | CGreenShift uint8 61 | CBlueBits uint8 62 | CBlueShift uint8 63 | CAlphaBits uint8 64 | CAlphaShift uint8 65 | CAccumBits uint8 66 | CAccumRedBits uint8 67 | CAccumGreenBits uint8 68 | CAccumBlueBits uint8 69 | CAccumAlphaBits uint8 70 | CDepthBits uint8 71 | CStencilBits uint8 72 | CAuxBuffers uint8 73 | ILayerType uint8 74 | BReserved uint8 75 | CrTransparent COLORREF 76 | } 77 | 78 | type POINTFLOAT struct { 79 | X, Y float32 80 | } 81 | 82 | type GLYPHMETRICSFLOAT struct { 83 | GmfBlackBoxX float32 84 | GmfBlackBoxY float32 85 | GmfptGlyphOrigin POINTFLOAT 86 | GmfCellIncX float32 87 | GmfCellIncY float32 88 | } 89 | 90 | var ( 91 | // Library 92 | lib uintptr 93 | 94 | // Functions 95 | wglCopyContext uintptr 96 | wglCreateContext uintptr 97 | wglCreateLayerContext uintptr 98 | wglDeleteContext uintptr 99 | wglDescribeLayerPlane uintptr 100 | wglGetCurrentContext uintptr 101 | wglGetCurrentDC uintptr 102 | wglGetLayerPaletteEntries uintptr 103 | wglGetProcAddress uintptr 104 | wglMakeCurrent uintptr 105 | wglRealizeLayerPalette uintptr 106 | wglSetLayerPaletteEntries uintptr 107 | wglShareLists uintptr 108 | wglSwapLayerBuffers uintptr 109 | wglUseFontBitmaps uintptr 110 | wglUseFontOutlines uintptr 111 | ) 112 | 113 | func init() { 114 | // Library 115 | lib = MustLoadLibrary("opengl32.dll") 116 | 117 | // Functions 118 | wglCopyContext = MustGetProcAddress(lib, "wglCopyContext") 119 | wglCreateContext = MustGetProcAddress(lib, "wglCreateContext") 120 | wglCreateLayerContext = MustGetProcAddress(lib, "wglCreateLayerContext") 121 | wglDeleteContext = MustGetProcAddress(lib, "wglDeleteContext") 122 | wglDescribeLayerPlane = MustGetProcAddress(lib, "wglDescribeLayerPlane") 123 | wglGetCurrentContext = MustGetProcAddress(lib, "wglGetCurrentContext") 124 | wglGetCurrentDC = MustGetProcAddress(lib, "wglGetCurrentDC") 125 | wglGetLayerPaletteEntries = MustGetProcAddress(lib, "wglGetLayerPaletteEntries") 126 | wglGetProcAddress = MustGetProcAddress(lib, "wglGetProcAddress") 127 | wglMakeCurrent = MustGetProcAddress(lib, "wglMakeCurrent") 128 | wglRealizeLayerPalette = MustGetProcAddress(lib, "wglRealizeLayerPalette") 129 | wglSetLayerPaletteEntries = MustGetProcAddress(lib, "wglSetLayerPaletteEntries") 130 | wglShareLists = MustGetProcAddress(lib, "wglShareLists") 131 | wglSwapLayerBuffers = MustGetProcAddress(lib, "wglSwapLayerBuffers") 132 | wglUseFontBitmaps = MustGetProcAddress(lib, "wglUseFontBitmapsW") 133 | wglUseFontOutlines = MustGetProcAddress(lib, "wglUseFontOutlinesW") 134 | } 135 | 136 | func WglCopyContext(hglrcSrc, hglrcDst HGLRC, mask uint) bool { 137 | ret, _, _ := syscall.Syscall(wglCopyContext, 3, 138 | uintptr(hglrcSrc), 139 | uintptr(hglrcDst), 140 | uintptr(mask)) 141 | 142 | return ret != 0 143 | } 144 | 145 | func WglCreateContext(hdc HDC) HGLRC { 146 | ret, _, _ := syscall.Syscall(wglCreateContext, 1, 147 | uintptr(hdc), 148 | 0, 149 | 0) 150 | 151 | return HGLRC(ret) 152 | } 153 | 154 | func WglCreateLayerContext(hdc HDC, iLayerPlane int) HGLRC { 155 | ret, _, _ := syscall.Syscall(wglCreateLayerContext, 2, 156 | uintptr(hdc), 157 | uintptr(iLayerPlane), 158 | 0) 159 | 160 | return HGLRC(ret) 161 | } 162 | 163 | func WglDeleteContext(hglrc HGLRC) bool { 164 | ret, _, _ := syscall.Syscall(wglDeleteContext, 1, 165 | uintptr(hglrc), 166 | 0, 167 | 0) 168 | 169 | return ret != 0 170 | } 171 | 172 | func WglDescribeLayerPlane(hdc HDC, iPixelFormat, iLayerPlane int, nBytes uint8, plpd *LAYERPLANEDESCRIPTOR) bool { 173 | ret, _, _ := syscall.Syscall6(wglDescribeLayerPlane, 5, 174 | uintptr(hdc), 175 | uintptr(iPixelFormat), 176 | uintptr(iLayerPlane), 177 | uintptr(nBytes), 178 | uintptr(unsafe.Pointer(plpd)), 179 | 0) 180 | 181 | return ret != 0 182 | } 183 | 184 | func WglGetCurrentContext() HGLRC { 185 | ret, _, _ := syscall.Syscall(wglGetCurrentContext, 0, 186 | 0, 187 | 0, 188 | 0) 189 | 190 | return HGLRC(ret) 191 | } 192 | 193 | func WglGetCurrentDC() HDC { 194 | ret, _, _ := syscall.Syscall(wglGetCurrentDC, 0, 195 | 0, 196 | 0, 197 | 0) 198 | 199 | return HDC(ret) 200 | } 201 | 202 | func WglGetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr *COLORREF) int { 203 | ret, _, _ := syscall.Syscall6(wglGetLayerPaletteEntries, 5, 204 | uintptr(hdc), 205 | uintptr(iLayerPlane), 206 | uintptr(iStart), 207 | uintptr(cEntries), 208 | uintptr(unsafe.Pointer(pcr)), 209 | 0) 210 | 211 | return int(ret) 212 | } 213 | 214 | func WglGetProcAddress(lpszProc *byte) uintptr { 215 | ret, _, _ := syscall.Syscall(wglGetProcAddress, 1, 216 | uintptr(unsafe.Pointer(lpszProc)), 217 | 0, 218 | 0) 219 | 220 | return uintptr(ret) 221 | } 222 | 223 | func WglMakeCurrent(hdc HDC, hglrc HGLRC) bool { 224 | ret, _, _ := syscall.Syscall(wglMakeCurrent, 2, 225 | uintptr(hdc), 226 | uintptr(hglrc), 227 | 0) 228 | 229 | return ret != 0 230 | } 231 | 232 | func WglRealizeLayerPalette(hdc HDC, iLayerPlane int, bRealize bool) bool { 233 | ret, _, _ := syscall.Syscall(wglRealizeLayerPalette, 3, 234 | uintptr(hdc), 235 | uintptr(iLayerPlane), 236 | uintptr(BoolToBOOL(bRealize))) 237 | 238 | return ret != 0 239 | } 240 | 241 | func WglSetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr *COLORREF) int { 242 | ret, _, _ := syscall.Syscall6(wglSetLayerPaletteEntries, 5, 243 | uintptr(hdc), 244 | uintptr(iLayerPlane), 245 | uintptr(iStart), 246 | uintptr(cEntries), 247 | uintptr(unsafe.Pointer(pcr)), 248 | 0) 249 | 250 | return int(ret) 251 | } 252 | 253 | func WglShareLists(hglrc1, hglrc2 HGLRC) bool { 254 | ret, _, _ := syscall.Syscall(wglShareLists, 2, 255 | uintptr(hglrc1), 256 | uintptr(hglrc2), 257 | 0) 258 | 259 | return ret != 0 260 | } 261 | 262 | func WglSwapLayerBuffers(hdc HDC, fuPlanes uint) bool { 263 | ret, _, _ := syscall.Syscall(wglSwapLayerBuffers, 2, 264 | uintptr(hdc), 265 | uintptr(fuPlanes), 266 | 0) 267 | 268 | return ret != 0 269 | } 270 | 271 | func WglUseFontBitmaps(hdc HDC, first, count, listbase uint32) bool { 272 | ret, _, _ := syscall.Syscall6(wglUseFontBitmaps, 4, 273 | uintptr(hdc), 274 | uintptr(first), 275 | uintptr(count), 276 | uintptr(listbase), 277 | 0, 278 | 0) 279 | 280 | return ret != 0 281 | } 282 | 283 | func WglUseFontOutlines(hdc HDC, first, count, listbase uint32, deviation, extrusion float32, format int, pgmf *GLYPHMETRICSFLOAT) bool { 284 | ret, _, _ := syscall.Syscall12(wglUseFontBitmaps, 8, 285 | uintptr(hdc), 286 | uintptr(first), 287 | uintptr(count), 288 | uintptr(listbase), 289 | uintptr(deviation), 290 | uintptr(extrusion), 291 | uintptr(format), 292 | uintptr(unsafe.Pointer(pgmf)), 293 | 0, 294 | 0, 295 | 0, 296 | 0) 297 | 298 | return ret != 0 299 | } 300 | -------------------------------------------------------------------------------- /shdocvw.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | const ( 13 | DOCHOSTUIDBLCLK_DEFAULT = 0 14 | DOCHOSTUIDBLCLK_SHOWPROPERTIES = 1 15 | DOCHOSTUIDBLCLK_SHOWCODE = 2 16 | ) 17 | 18 | const ( 19 | DOCHOSTUIFLAG_DIALOG = 0x1 20 | DOCHOSTUIFLAG_DISABLE_HELP_MENU = 0x2 21 | DOCHOSTUIFLAG_NO3DBORDER = 0x4 22 | DOCHOSTUIFLAG_SCROLL_NO = 0x8 23 | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 0x10 24 | DOCHOSTUIFLAG_OPENNEWWIN = 0x20 25 | DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 0x40 26 | DOCHOSTUIFLAG_FLAT_SCROLLBAR = 0x80 27 | DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 0x100 28 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 0x200 29 | DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY = 0x400 30 | DOCHOSTUIFLAG_CODEPAGELINKEDFONTS = 0x800 31 | DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8 = 0x1000 32 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 = 0x2000 33 | DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE = 0x4000 34 | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION = 0x10000 35 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION = 0x20000 36 | DOCHOSTUIFLAG_THEME = 0x40000 37 | DOCHOSTUIFLAG_NOTHEME = 0x80000 38 | DOCHOSTUIFLAG_NOPICS = 0x100000 39 | DOCHOSTUIFLAG_NO3DOUTERBORDER = 0x200000 40 | DOCHOSTUIFLAG_DISABLE_EDIT_NS_FIXUP = 0x400000 41 | DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK = 0x800000 42 | DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL = 0x1000000 43 | ) 44 | 45 | // BrowserNavConstants 46 | const ( 47 | NavOpenInNewWindow = 0x1 48 | NavNoHistory = 0x2 49 | NavNoReadFromCache = 0x4 50 | NavNoWriteToCache = 0x8 51 | NavAllowAutosearch = 0x10 52 | NavBrowserBar = 0x20 53 | NavHyperlink = 0x40 54 | NavEnforceRestricted = 0x80 55 | NavNewWindowsManaged = 0x0100 56 | NavUntrustedForDownload = 0x0200 57 | NavTrustedForActiveX = 0x0400 58 | NavOpenInNewTab = 0x0800 59 | NavOpenInBackgroundTab = 0x1000 60 | NavKeepWordWheelText = 0x2000 61 | NavVirtualTab = 0x4000 62 | NavBlockRedirectsXDomain = 0x8000 63 | NavOpenNewForegroundTab = 0x10000 64 | ) 65 | 66 | var ( 67 | CLSID_WebBrowser = CLSID{0x8856F961, 0x340A, 0x11D0, [8]byte{0xA9, 0x6B, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2}} 68 | DIID_DWebBrowserEvents2 = IID{0x34A715A0, 0x6587, 0x11D0, [8]byte{0x92, 0x4A, 0x00, 0x20, 0xAF, 0xC7, 0xAC, 0x4D}} 69 | IID_IWebBrowser2 = IID{0xD30C1661, 0xCDAF, 0x11D0, [8]byte{0x8A, 0x3E, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E}} 70 | IID_IDocHostUIHandler = IID{0xBD3F23C0, 0xD43E, 0x11CF, [8]byte{0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A}} 71 | ) 72 | 73 | type DWebBrowserEvents2Vtbl struct { 74 | QueryInterface uintptr 75 | AddRef uintptr 76 | Release uintptr 77 | GetTypeInfoCount uintptr 78 | GetTypeInfo uintptr 79 | GetIDsOfNames uintptr 80 | Invoke uintptr 81 | } 82 | 83 | type DWebBrowserEvents2 struct { 84 | LpVtbl *DWebBrowserEvents2Vtbl 85 | } 86 | 87 | type IWebBrowser2Vtbl struct { 88 | QueryInterface uintptr 89 | AddRef uintptr 90 | Release uintptr 91 | GetTypeInfoCount uintptr 92 | GetTypeInfo uintptr 93 | GetIDsOfNames uintptr 94 | Invoke uintptr 95 | GoBack uintptr 96 | GoForward uintptr 97 | GoHome uintptr 98 | GoSearch uintptr 99 | Navigate uintptr 100 | Refresh uintptr 101 | Refresh2 uintptr 102 | Stop uintptr 103 | Get_Application uintptr 104 | Get_Parent uintptr 105 | Get_Container uintptr 106 | Get_Document uintptr 107 | Get_TopLevelContainer uintptr 108 | Get_Type uintptr 109 | Get_Left uintptr 110 | Put_Left uintptr 111 | Get_Top uintptr 112 | Put_Top uintptr 113 | Get_Width uintptr 114 | Put_Width uintptr 115 | Get_Height uintptr 116 | Put_Height uintptr 117 | Get_LocationName uintptr 118 | Get_LocationURL uintptr 119 | Get_Busy uintptr 120 | Quit uintptr 121 | ClientToWindow uintptr 122 | PutProperty uintptr 123 | GetProperty uintptr 124 | Get_Name uintptr 125 | Get_HWND uintptr 126 | Get_FullName uintptr 127 | Get_Path uintptr 128 | Get_Visible uintptr 129 | Put_Visible uintptr 130 | Get_StatusBar uintptr 131 | Put_StatusBar uintptr 132 | Get_StatusText uintptr 133 | Put_StatusText uintptr 134 | Get_ToolBar uintptr 135 | Put_ToolBar uintptr 136 | Get_MenuBar uintptr 137 | Put_MenuBar uintptr 138 | Get_FullScreen uintptr 139 | Put_FullScreen uintptr 140 | Navigate2 uintptr 141 | QueryStatusWB uintptr 142 | ExecWB uintptr 143 | ShowBrowserBar uintptr 144 | Get_ReadyState uintptr 145 | Get_Offline uintptr 146 | Put_Offline uintptr 147 | Get_Silent uintptr 148 | Put_Silent uintptr 149 | Get_RegisterAsBrowser uintptr 150 | Put_RegisterAsBrowser uintptr 151 | Get_RegisterAsDropTarget uintptr 152 | Put_RegisterAsDropTarget uintptr 153 | Get_TheaterMode uintptr 154 | Put_TheaterMode uintptr 155 | Get_AddressBar uintptr 156 | Put_AddressBar uintptr 157 | Get_Resizable uintptr 158 | Put_Resizable uintptr 159 | } 160 | 161 | type IWebBrowser2 struct { 162 | LpVtbl *IWebBrowser2Vtbl 163 | } 164 | 165 | func (wb2 *IWebBrowser2) Release() HRESULT { 166 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Release, 1, 167 | uintptr(unsafe.Pointer(wb2)), 168 | 0, 169 | 0) 170 | 171 | return HRESULT(ret) 172 | } 173 | 174 | func (wb2 *IWebBrowser2) Refresh() HRESULT { 175 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Refresh, 1, 176 | uintptr(unsafe.Pointer(wb2)), 177 | 0, 178 | 0) 179 | 180 | return HRESULT(ret) 181 | } 182 | 183 | func (wb2 *IWebBrowser2) Put_Left(Left int32) HRESULT { 184 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Left, 2, 185 | uintptr(unsafe.Pointer(wb2)), 186 | uintptr(Left), 187 | 0) 188 | 189 | return HRESULT(ret) 190 | } 191 | 192 | func (wb2 *IWebBrowser2) Put_Top(Top int32) HRESULT { 193 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Top, 2, 194 | uintptr(unsafe.Pointer(wb2)), 195 | uintptr(Top), 196 | 0) 197 | 198 | return HRESULT(ret) 199 | } 200 | 201 | func (wb2 *IWebBrowser2) Put_Width(Width int32) HRESULT { 202 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Width, 2, 203 | uintptr(unsafe.Pointer(wb2)), 204 | uintptr(Width), 205 | 0) 206 | 207 | return HRESULT(ret) 208 | } 209 | 210 | func (wb2 *IWebBrowser2) Put_Height(Height int32) HRESULT { 211 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Height, 2, 212 | uintptr(unsafe.Pointer(wb2)), 213 | uintptr(Height), 214 | 0) 215 | 216 | return HRESULT(ret) 217 | } 218 | 219 | func (wb2 *IWebBrowser2) Get_LocationURL(pbstrLocationURL **uint16 /*BSTR*/) HRESULT { 220 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Get_LocationURL, 2, 221 | uintptr(unsafe.Pointer(wb2)), 222 | uintptr(unsafe.Pointer(pbstrLocationURL)), 223 | 0) 224 | 225 | return HRESULT(ret) 226 | } 227 | 228 | func (wb2 *IWebBrowser2) Navigate2(URL *VAR_BSTR, Flags *VAR_I4, TargetFrameName *VAR_BSTR, PostData unsafe.Pointer, Headers *VAR_BSTR) HRESULT { 229 | ret, _, _ := syscall.Syscall6(wb2.LpVtbl.Navigate2, 6, 230 | uintptr(unsafe.Pointer(wb2)), 231 | uintptr(unsafe.Pointer(URL)), 232 | uintptr(unsafe.Pointer(Flags)), 233 | uintptr(unsafe.Pointer(TargetFrameName)), 234 | uintptr(PostData), 235 | uintptr(unsafe.Pointer(Headers))) 236 | 237 | return HRESULT(ret) 238 | } 239 | 240 | type IDocHostUIHandlerVtbl struct { 241 | QueryInterface uintptr 242 | AddRef uintptr 243 | Release uintptr 244 | ShowContextMenu uintptr 245 | GetHostInfo uintptr 246 | ShowUI uintptr 247 | HideUI uintptr 248 | UpdateUI uintptr 249 | EnableModeless uintptr 250 | OnDocWindowActivate uintptr 251 | OnFrameWindowActivate uintptr 252 | ResizeBorder uintptr 253 | TranslateAccelerator uintptr 254 | GetOptionKeyPath uintptr 255 | GetDropTarget uintptr 256 | GetExternal uintptr 257 | TranslateUrl uintptr 258 | FilterDataObject uintptr 259 | } 260 | 261 | type IDocHostUIHandler struct { 262 | LpVtbl *IDocHostUIHandlerVtbl 263 | } 264 | 265 | type DOCHOSTUIINFO struct { 266 | CbSize uint32 267 | DwFlags uint32 268 | DwDoubleClick uint32 269 | PchHostCss *uint16 270 | PchHostNS *uint16 271 | } 272 | -------------------------------------------------------------------------------- /shell32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | type CSIDL uint32 13 | 14 | const ( 15 | CSIDL_DESKTOP = 0x00 16 | CSIDL_INTERNET = 0x01 17 | CSIDL_PROGRAMS = 0x02 18 | CSIDL_CONTROLS = 0x03 19 | CSIDL_PRINTERS = 0x04 20 | CSIDL_PERSONAL = 0x05 21 | CSIDL_FAVORITES = 0x06 22 | CSIDL_STARTUP = 0x07 23 | CSIDL_RECENT = 0x08 24 | CSIDL_SENDTO = 0x09 25 | CSIDL_BITBUCKET = 0x0A 26 | CSIDL_STARTMENU = 0x0B 27 | CSIDL_MYDOCUMENTS = 0x0C 28 | CSIDL_MYMUSIC = 0x0D 29 | CSIDL_MYVIDEO = 0x0E 30 | CSIDL_DESKTOPDIRECTORY = 0x10 31 | CSIDL_DRIVES = 0x11 32 | CSIDL_NETWORK = 0x12 33 | CSIDL_NETHOOD = 0x13 34 | CSIDL_FONTS = 0x14 35 | CSIDL_TEMPLATES = 0x15 36 | CSIDL_COMMON_STARTMENU = 0x16 37 | CSIDL_COMMON_PROGRAMS = 0x17 38 | CSIDL_COMMON_STARTUP = 0x18 39 | CSIDL_COMMON_DESKTOPDIRECTORY = 0x19 40 | CSIDL_APPDATA = 0x1A 41 | CSIDL_PRINTHOOD = 0x1B 42 | CSIDL_LOCAL_APPDATA = 0x1C 43 | CSIDL_ALTSTARTUP = 0x1D 44 | CSIDL_COMMON_ALTSTARTUP = 0x1E 45 | CSIDL_COMMON_FAVORITES = 0x1F 46 | CSIDL_INTERNET_CACHE = 0x20 47 | CSIDL_COOKIES = 0x21 48 | CSIDL_HISTORY = 0x22 49 | CSIDL_COMMON_APPDATA = 0x23 50 | CSIDL_WINDOWS = 0x24 51 | CSIDL_SYSTEM = 0x25 52 | CSIDL_PROGRAM_FILES = 0x26 53 | CSIDL_MYPICTURES = 0x27 54 | CSIDL_PROFILE = 0x28 55 | CSIDL_SYSTEMX86 = 0x29 56 | CSIDL_PROGRAM_FILESX86 = 0x2A 57 | CSIDL_PROGRAM_FILES_COMMON = 0x2B 58 | CSIDL_PROGRAM_FILES_COMMONX86 = 0x2C 59 | CSIDL_COMMON_TEMPLATES = 0x2D 60 | CSIDL_COMMON_DOCUMENTS = 0x2E 61 | CSIDL_COMMON_ADMINTOOLS = 0x2F 62 | CSIDL_ADMINTOOLS = 0x30 63 | CSIDL_CONNECTIONS = 0x31 64 | CSIDL_COMMON_MUSIC = 0x35 65 | CSIDL_COMMON_PICTURES = 0x36 66 | CSIDL_COMMON_VIDEO = 0x37 67 | CSIDL_RESOURCES = 0x38 68 | CSIDL_RESOURCES_LOCALIZED = 0x39 69 | CSIDL_COMMON_OEM_LINKS = 0x3A 70 | CSIDL_CDBURN_AREA = 0x3B 71 | CSIDL_COMPUTERSNEARME = 0x3D 72 | CSIDL_FLAG_CREATE = 0x8000 73 | CSIDL_FLAG_DONT_VERIFY = 0x4000 74 | CSIDL_FLAG_NO_ALIAS = 0x1000 75 | CSIDL_FLAG_PER_USER_INIT = 0x8000 76 | CSIDL_FLAG_MASK = 0xFF00 77 | ) 78 | 79 | // NotifyIcon flags 80 | const ( 81 | NIF_MESSAGE = 0x00000001 82 | NIF_ICON = 0x00000002 83 | NIF_TIP = 0x00000004 84 | NIF_STATE = 0x00000008 85 | NIF_INFO = 0x00000010 86 | ) 87 | 88 | // NotifyIcon messages 89 | const ( 90 | NIM_ADD = 0x00000000 91 | NIM_MODIFY = 0x00000001 92 | NIM_DELETE = 0x00000002 93 | NIM_SETFOCUS = 0x00000003 94 | NIM_SETVERSION = 0x00000004 95 | ) 96 | 97 | // NotifyIcon states 98 | const ( 99 | NIS_HIDDEN = 0x00000001 100 | NIS_SHAREDICON = 0x00000002 101 | ) 102 | 103 | // NotifyIcon info flags 104 | const ( 105 | NIIF_NONE = 0x00000000 106 | NIIF_INFO = 0x00000001 107 | NIIF_WARNING = 0x00000002 108 | NIIF_ERROR = 0x00000003 109 | NIIF_USER = 0x00000004 110 | NIIF_NOSOUND = 0x00000010 111 | ) 112 | 113 | const NOTIFYICON_VERSION = 3 114 | 115 | // SHGetFileInfo flags 116 | const ( 117 | SHGFI_LARGEICON = 0x000000000 118 | SHGFI_SMALLICON = 0x000000001 119 | SHGFI_OPENICON = 0x000000002 120 | SHGFI_SHELLICONSIZE = 0x000000004 121 | SHGFI_PIDL = 0x000000008 122 | SHGFI_USEFILEATTRIBUTES = 0x000000010 123 | SHGFI_ADDOVERLAYS = 0x000000020 124 | SHGFI_OVERLAYINDEX = 0x000000040 125 | SHGFI_ICON = 0x000000100 126 | SHGFI_DISPLAYNAME = 0x000000200 127 | SHGFI_TYPENAME = 0x000000400 128 | SHGFI_ATTRIBUTES = 0x000000800 129 | SHGFI_ICONLOCATION = 0x000001000 130 | SHGFI_EXETYPE = 0x000002000 131 | SHGFI_SYSICONINDEX = 0x000004000 132 | SHGFI_LINKOVERLAY = 0x000008000 133 | SHGFI_SELECTED = 0x000010000 134 | SHGFI_ATTR_SPECIFIED = 0x000020000 135 | ) 136 | 137 | type NOTIFYICONDATA struct { 138 | CbSize uint32 139 | HWnd HWND 140 | UID uint32 141 | UFlags uint32 142 | UCallbackMessage uint32 143 | HIcon HICON 144 | SzTip [128]uint16 145 | DwState uint32 146 | DwStateMask uint32 147 | SzInfo [256]uint16 148 | UVersion uint32 149 | SzInfoTitle [64]uint16 150 | DwInfoFlags uint32 151 | GuidItem GUID 152 | } 153 | 154 | type SHFILEINFO struct { 155 | HIcon HICON 156 | IIcon int32 157 | DwAttributes uint32 158 | SzDisplayName [MAX_PATH]uint16 159 | SzTypeName [80]uint16 160 | } 161 | 162 | type BROWSEINFO struct { 163 | HwndOwner HWND 164 | PidlRoot uintptr 165 | PszDisplayName *uint16 166 | LpszTitle *uint16 167 | UlFlags uint32 168 | Lpfn uintptr 169 | LParam uintptr 170 | IImage int32 171 | } 172 | 173 | var ( 174 | // Library 175 | libshell32 uintptr 176 | 177 | // Functions 178 | shBrowseForFolder uintptr 179 | shGetFileInfo uintptr 180 | shGetPathFromIDList uintptr 181 | shGetSpecialFolderPath uintptr 182 | shell_NotifyIcon uintptr 183 | ) 184 | 185 | func init() { 186 | // Library 187 | libshell32 = MustLoadLibrary("shell32.dll") 188 | 189 | // Functions 190 | shBrowseForFolder = MustGetProcAddress(libshell32, "SHBrowseForFolderW") 191 | shGetFileInfo = MustGetProcAddress(libshell32, "SHGetFileInfoW") 192 | shGetPathFromIDList = MustGetProcAddress(libshell32, "SHGetPathFromIDListW") 193 | shGetSpecialFolderPath = MustGetProcAddress(libshell32, "SHGetSpecialFolderPathW") 194 | shell_NotifyIcon = MustGetProcAddress(libshell32, "Shell_NotifyIconW") 195 | } 196 | 197 | func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr { 198 | ret, _, _ := syscall.Syscall(shBrowseForFolder, 1, 199 | uintptr(unsafe.Pointer(lpbi)), 200 | 0, 201 | 0) 202 | 203 | return ret 204 | } 205 | 206 | func SHGetFileInfo(pszPath *uint16, dwFileAttributes uint32, psfi *SHFILEINFO, cbFileInfo, uFlags uint32) uintptr { 207 | ret, _, _ := syscall.Syscall6(shGetFileInfo, 5, 208 | uintptr(unsafe.Pointer(pszPath)), 209 | uintptr(dwFileAttributes), 210 | uintptr(unsafe.Pointer(psfi)), 211 | uintptr(cbFileInfo), 212 | uintptr(uFlags), 213 | 0) 214 | 215 | return ret 216 | } 217 | 218 | func SHGetPathFromIDList(pidl uintptr, pszPath *uint16) bool { 219 | ret, _, _ := syscall.Syscall(shGetPathFromIDList, 2, 220 | pidl, 221 | uintptr(unsafe.Pointer(pszPath)), 222 | 0) 223 | 224 | return ret != 0 225 | } 226 | 227 | func SHGetSpecialFolderPath(hwndOwner HWND, lpszPath *uint16, csidl CSIDL, fCreate bool) bool { 228 | ret, _, _ := syscall.Syscall6(shGetSpecialFolderPath, 4, 229 | uintptr(hwndOwner), 230 | uintptr(unsafe.Pointer(lpszPath)), 231 | uintptr(csidl), 232 | uintptr(BoolToBOOL(fCreate)), 233 | 0, 234 | 0) 235 | 236 | return ret != 0 237 | } 238 | 239 | func Shell_NotifyIcon(dwMessage uint32, lpdata *NOTIFYICONDATA) bool { 240 | ret, _, _ := syscall.Syscall(shell_NotifyIcon, 2, 241 | uintptr(dwMessage), 242 | uintptr(unsafe.Pointer(lpdata)), 243 | 0) 244 | 245 | return ret != 0 246 | } 247 | -------------------------------------------------------------------------------- /shobj.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Walk 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | var ( 13 | CLSID_TaskbarList = CLSID{0x56FDF344, 0xFD6D, 0x11d0, [8]byte{0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}} 14 | IID_ITaskbarList3 = IID{0xea1afb91, 0x9e28, 0x4b86, [8]byte{0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf}} 15 | ) 16 | 17 | //TBPFLAG 18 | const ( 19 | TBPF_NOPROGRESS = 0 20 | TBPF_INDETERMINATE = 0x1 21 | TBPF_NORMAL = 0x2 22 | TBPF_ERROR = 0x4 23 | TBPF_PAUSED = 0x8 24 | ) 25 | 26 | type ITaskbarList3Vtbl struct { 27 | QueryInterface uintptr 28 | AddRef uintptr 29 | Release uintptr 30 | HrInit uintptr 31 | AddTab uintptr 32 | DeleteTab uintptr 33 | ActivateTab uintptr 34 | SetActiveAlt uintptr 35 | MarkFullscreenWindow uintptr 36 | SetProgressValue uintptr 37 | SetProgressState uintptr 38 | RegisterTab uintptr 39 | UnregisterTab uintptr 40 | SetTabOrder uintptr 41 | SetTabActive uintptr 42 | ThumbBarAddButtons uintptr 43 | ThumbBarUpdateButtons uintptr 44 | ThumbBarSetImageList uintptr 45 | SetOverlayIcon uintptr 46 | SetThumbnailTooltip uintptr 47 | SetThumbnailClip uintptr 48 | } 49 | 50 | type ITaskbarList3 struct { 51 | LpVtbl *ITaskbarList3Vtbl 52 | } 53 | 54 | func (obj *ITaskbarList3) SetProgressState(hwnd HWND, state int) HRESULT { 55 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetProgressState, 3, 56 | uintptr(unsafe.Pointer(obj)), 57 | uintptr(hwnd), 58 | uintptr(state)) 59 | return HRESULT(ret) 60 | } 61 | -------------------------------------------------------------------------------- /shobj_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Walk 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func (obj *ITaskbarList3) SetProgressValue(hwnd HWND, current uint32, length uint32) HRESULT { 13 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetProgressValue, 6, 14 | uintptr(unsafe.Pointer(obj)), 15 | uintptr(hwnd), 16 | uintptr(current), 17 | 0, 18 | uintptr(length), 19 | 0) 20 | 21 | return HRESULT(ret) 22 | } 23 | -------------------------------------------------------------------------------- /shobj_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Walk 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 | package winapi 6 | 7 | import ( 8 | "unsafe" 9 | "syscall" 10 | ) 11 | 12 | 13 | func (obj *ITaskbarList3) SetProgressValue(hwnd HWND, current uint32, length uint32) HRESULT{ 14 | ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetProgressValue, 4, 15 | uintptr(unsafe.Pointer(obj)), 16 | uintptr(hwnd), 17 | uintptr(current), 18 | uintptr(length), 19 | 0, 20 | 0) 21 | 22 | return HRESULT(ret) 23 | } -------------------------------------------------------------------------------- /tab.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The go-winapi 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 | package winapi 6 | 7 | const TCM_FIRST = 0x1300 8 | const TCN_FIRST = -550 9 | 10 | const ( 11 | TCS_SCROLLOPPOSITE = 0x0001 12 | TCS_BOTTOM = 0x0002 13 | TCS_RIGHT = 0x0002 14 | TCS_MULTISELECT = 0x0004 15 | TCS_FLATBUTTONS = 0x0008 16 | TCS_FORCEICONLEFT = 0x0010 17 | TCS_FORCELABELLEFT = 0x0020 18 | TCS_HOTTRACK = 0x0040 19 | TCS_VERTICAL = 0x0080 20 | TCS_TABS = 0x0000 21 | TCS_BUTTONS = 0x0100 22 | TCS_SINGLELINE = 0x0000 23 | TCS_MULTILINE = 0x0200 24 | TCS_RIGHTJUSTIFY = 0x0000 25 | TCS_FIXEDWIDTH = 0x0400 26 | TCS_RAGGEDRIGHT = 0x0800 27 | TCS_FOCUSONBUTTONDOWN = 0x1000 28 | TCS_OWNERDRAWFIXED = 0x2000 29 | TCS_TOOLTIPS = 0x4000 30 | TCS_FOCUSNEVER = 0x8000 31 | ) 32 | 33 | const ( 34 | TCS_EX_FLATSEPARATORS = 0x00000001 35 | TCS_EX_REGISTERDROP = 0x00000002 36 | ) 37 | 38 | const ( 39 | TCM_GETIMAGELIST = TCM_FIRST + 2 40 | TCM_SETIMAGELIST = TCM_FIRST + 3 41 | TCM_GETITEMCOUNT = TCM_FIRST + 4 42 | TCM_GETITEM = TCM_FIRST + 60 43 | TCM_SETITEM = TCM_FIRST + 61 44 | TCM_INSERTITEM = TCM_FIRST + 62 45 | TCM_DELETEITEM = TCM_FIRST + 8 46 | TCM_DELETEALLITEMS = TCM_FIRST + 9 47 | TCM_GETITEMRECT = TCM_FIRST + 10 48 | TCM_GETCURSEL = TCM_FIRST + 11 49 | TCM_SETCURSEL = TCM_FIRST + 12 50 | TCM_HITTEST = TCM_FIRST + 13 51 | TCM_SETITEMEXTRA = TCM_FIRST + 14 52 | TCM_ADJUSTRECT = TCM_FIRST + 40 53 | TCM_SETITEMSIZE = TCM_FIRST + 41 54 | TCM_REMOVEIMAGE = TCM_FIRST + 42 55 | TCM_SETPADDING = TCM_FIRST + 43 56 | TCM_GETROWCOUNT = TCM_FIRST + 44 57 | TCM_GETTOOLTIPS = TCM_FIRST + 45 58 | TCM_SETTOOLTIPS = TCM_FIRST + 46 59 | TCM_GETCURFOCUS = TCM_FIRST + 47 60 | TCM_SETCURFOCUS = TCM_FIRST + 48 61 | TCM_SETMINTABWIDTH = TCM_FIRST + 49 62 | TCM_DESELECTALL = TCM_FIRST + 50 63 | TCM_HIGHLIGHTITEM = TCM_FIRST + 51 64 | TCM_SETEXTENDEDSTYLE = TCM_FIRST + 52 65 | TCM_GETEXTENDEDSTYLE = TCM_FIRST + 53 66 | TCM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 67 | TCM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 68 | ) 69 | 70 | const ( 71 | TCIF_TEXT = 0x0001 72 | TCIF_IMAGE = 0x0002 73 | TCIF_RTLREADING = 0x0004 74 | TCIF_PARAM = 0x0008 75 | TCIF_STATE = 0x0010 76 | ) 77 | 78 | const ( 79 | TCIS_BUTTONPRESSED = 0x0001 80 | TCIS_HIGHLIGHTED = 0x0002 81 | ) 82 | 83 | const ( 84 | TCHT_NOWHERE = 0x0001 85 | TCHT_ONITEMICON = 0x0002 86 | TCHT_ONITEMLABEL = 0x0004 87 | TCHT_ONITEM = TCHT_ONITEMICON | TCHT_ONITEMLABEL 88 | ) 89 | 90 | const ( 91 | TCN_KEYDOWN = TCN_FIRST - 0 92 | TCN_SELCHANGE = TCN_FIRST - 1 93 | TCN_SELCHANGING = TCN_FIRST - 2 94 | TCN_GETOBJECT = TCN_FIRST - 3 95 | TCN_FOCUSCHANGE = TCN_FIRST - 4 96 | ) 97 | 98 | type TCITEMHEADER struct { 99 | Mask uint32 100 | LpReserved1 uint32 101 | LpReserved2 uint32 102 | PszText *uint16 103 | CchTextMax int32 104 | IImage int32 105 | } 106 | 107 | type TCITEM struct { 108 | Mask uint32 109 | DwState uint32 110 | DwStateMask uint32 111 | PszText *uint16 112 | CchTextMax int32 113 | IImage int32 114 | LParam uintptr 115 | } 116 | 117 | type TCHITTESTINFO struct { 118 | Pt POINT 119 | flags uint32 120 | } 121 | 122 | type NMTCKEYDOWN struct { 123 | Hdr NMHDR 124 | WVKey uint16 125 | Flags uint32 126 | } 127 | -------------------------------------------------------------------------------- /toolbar.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | // ToolBar messages 8 | const ( 9 | TB_ENABLEBUTTON = WM_USER + 1 10 | TB_CHECKBUTTON = WM_USER + 2 11 | TB_PRESSBUTTON = WM_USER + 3 12 | TB_HIDEBUTTON = WM_USER + 4 13 | TB_INDETERMINATE = WM_USER + 5 14 | TB_MARKBUTTON = WM_USER + 6 15 | TB_ISBUTTONENABLED = WM_USER + 9 16 | TB_ISBUTTONCHECKED = WM_USER + 10 17 | TB_ISBUTTONPRESSED = WM_USER + 11 18 | TB_ISBUTTONHIDDEN = WM_USER + 12 19 | TB_ISBUTTONINDETERMINATE = WM_USER + 13 20 | TB_ISBUTTONHIGHLIGHTED = WM_USER + 14 21 | TB_SETSTATE = WM_USER + 17 22 | TB_GETSTATE = WM_USER + 18 23 | TB_ADDBITMAP = WM_USER + 19 24 | TB_DELETEBUTTON = WM_USER + 22 25 | TB_GETBUTTON = WM_USER + 23 26 | TB_BUTTONCOUNT = WM_USER + 24 27 | TB_COMMANDTOINDEX = WM_USER + 25 28 | TB_SAVERESTORE = WM_USER + 76 29 | TB_CUSTOMIZE = WM_USER + 27 30 | TB_ADDSTRING = WM_USER + 77 31 | TB_GETITEMRECT = WM_USER + 29 32 | TB_BUTTONSTRUCTSIZE = WM_USER + 30 33 | TB_SETBUTTONSIZE = WM_USER + 31 34 | TB_SETBITMAPSIZE = WM_USER + 32 35 | TB_AUTOSIZE = WM_USER + 33 36 | TB_GETTOOLTIPS = WM_USER + 35 37 | TB_SETTOOLTIPS = WM_USER + 36 38 | TB_SETPARENT = WM_USER + 37 39 | TB_SETROWS = WM_USER + 39 40 | TB_GETROWS = WM_USER + 40 41 | TB_GETBITMAPFLAGS = WM_USER + 41 42 | TB_SETCMDID = WM_USER + 42 43 | TB_CHANGEBITMAP = WM_USER + 43 44 | TB_GETBITMAP = WM_USER + 44 45 | TB_GETBUTTONTEXT = WM_USER + 75 46 | TB_REPLACEBITMAP = WM_USER + 46 47 | TB_GETBUTTONSIZE = WM_USER + 58 48 | TB_SETBUTTONWIDTH = WM_USER + 59 49 | TB_SETINDENT = WM_USER + 47 50 | TB_SETIMAGELIST = WM_USER + 48 51 | TB_GETIMAGELIST = WM_USER + 49 52 | TB_LOADIMAGES = WM_USER + 50 53 | TB_GETRECT = WM_USER + 51 54 | TB_SETHOTIMAGELIST = WM_USER + 52 55 | TB_GETHOTIMAGELIST = WM_USER + 53 56 | TB_SETDISABLEDIMAGELIST = WM_USER + 54 57 | TB_GETDISABLEDIMAGELIST = WM_USER + 55 58 | TB_SETSTYLE = WM_USER + 56 59 | TB_GETSTYLE = WM_USER + 57 60 | TB_SETMAXTEXTROWS = WM_USER + 60 61 | TB_GETTEXTROWS = WM_USER + 61 62 | TB_GETOBJECT = WM_USER + 62 63 | TB_GETBUTTONINFO = WM_USER + 63 64 | TB_SETBUTTONINFO = WM_USER + 64 65 | TB_INSERTBUTTON = WM_USER + 67 66 | TB_ADDBUTTONS = WM_USER + 68 67 | TB_HITTEST = WM_USER + 69 68 | TB_SETDRAWTEXTFLAGS = WM_USER + 70 69 | TB_GETHOTITEM = WM_USER + 71 70 | TB_SETHOTITEM = WM_USER + 72 71 | TB_SETANCHORHIGHLIGHT = WM_USER + 73 72 | TB_GETANCHORHIGHLIGHT = WM_USER + 74 73 | TB_GETINSERTMARK = WM_USER + 79 74 | TB_SETINSERTMARK = WM_USER + 80 75 | TB_INSERTMARKHITTEST = WM_USER + 81 76 | TB_MOVEBUTTON = WM_USER + 82 77 | TB_GETMAXSIZE = WM_USER + 83 78 | TB_SETEXTENDEDSTYLE = WM_USER + 84 79 | TB_GETEXTENDEDSTYLE = WM_USER + 85 80 | TB_GETPADDING = WM_USER + 86 81 | TB_SETPADDING = WM_USER + 87 82 | TB_SETINSERTMARKCOLOR = WM_USER + 88 83 | TB_GETINSERTMARKCOLOR = WM_USER + 89 84 | TB_MAPACCELERATOR = WM_USER + 90 85 | TB_GETSTRING = WM_USER + 91 86 | TB_SETCOLORSCHEME = CCM_SETCOLORSCHEME 87 | TB_GETCOLORSCHEME = CCM_GETCOLORSCHEME 88 | TB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 89 | TB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 90 | ) 91 | 92 | // ToolBar state constants 93 | const ( 94 | TBSTATE_CHECKED = 1 95 | TBSTATE_PRESSED = 2 96 | TBSTATE_ENABLED = 4 97 | TBSTATE_HIDDEN = 8 98 | TBSTATE_INDETERMINATE = 16 99 | TBSTATE_WRAP = 32 100 | TBSTATE_ELLIPSES = 0x40 101 | TBSTATE_MARKED = 0x0080 102 | ) 103 | 104 | // ToolBar style constants 105 | const ( 106 | TBSTYLE_BUTTON = 0 107 | TBSTYLE_SEP = 1 108 | TBSTYLE_CHECK = 2 109 | TBSTYLE_GROUP = 4 110 | TBSTYLE_CHECKGROUP = TBSTYLE_GROUP | TBSTYLE_CHECK 111 | TBSTYLE_DROPDOWN = 8 112 | TBSTYLE_AUTOSIZE = 16 113 | TBSTYLE_NOPREFIX = 32 114 | TBSTYLE_TOOLTIPS = 256 115 | TBSTYLE_WRAPABLE = 512 116 | TBSTYLE_ALTDRAG = 1024 117 | TBSTYLE_FLAT = 2048 118 | TBSTYLE_LIST = 4096 119 | TBSTYLE_CUSTOMERASE = 8192 120 | TBSTYLE_REGISTERDROP = 0x4000 121 | TBSTYLE_TRANSPARENT = 0x8000 122 | ) 123 | 124 | // ToolBar extended style constants 125 | const ( 126 | TBSTYLE_EX_DRAWDDARROWS = 0x00000001 127 | TBSTYLE_EX_MIXEDBUTTONS = 8 128 | TBSTYLE_EX_HIDECLIPPEDBUTTONS = 16 129 | TBSTYLE_EX_DOUBLEBUFFER = 0x80 130 | ) 131 | 132 | // ToolBar button style constants 133 | const ( 134 | BTNS_BUTTON = TBSTYLE_BUTTON 135 | BTNS_SEP = TBSTYLE_SEP 136 | BTNS_CHECK = TBSTYLE_CHECK 137 | BTNS_GROUP = TBSTYLE_GROUP 138 | BTNS_CHECKGROUP = TBSTYLE_CHECKGROUP 139 | BTNS_DROPDOWN = TBSTYLE_DROPDOWN 140 | BTNS_AUTOSIZE = TBSTYLE_AUTOSIZE 141 | BTNS_NOPREFIX = TBSTYLE_NOPREFIX 142 | BTNS_WHOLEDROPDOWN = 0x0080 143 | BTNS_SHOWTEXT = 0x0040 144 | ) 145 | 146 | // TBBUTTONINFO mask flags 147 | const ( 148 | TBIF_IMAGE = 0x00000001 149 | TBIF_TEXT = 0x00000002 150 | TBIF_STATE = 0x00000004 151 | TBIF_STYLE = 0x00000008 152 | TBIF_LPARAM = 0x00000010 153 | TBIF_COMMAND = 0x00000020 154 | TBIF_SIZE = 0x00000040 155 | TBIF_BYINDEX = 0x80000000 156 | ) 157 | 158 | type NMMOUSE struct { 159 | Hdr NMHDR 160 | DwItemSpec uintptr 161 | DwItemData uintptr 162 | Pt POINT 163 | DwHitInfo uintptr 164 | } 165 | 166 | type TBBUTTON struct { 167 | IBitmap int32 168 | IdCommand int32 169 | FsState byte 170 | FsStyle byte 171 | //#ifdef _WIN64 172 | // BYTE bReserved[6] // padding for alignment 173 | //#elif defined(_WIN32) 174 | BReserved [2]byte // padding for alignment 175 | //#endif 176 | DwData uintptr 177 | IString uintptr 178 | } 179 | 180 | type TBBUTTONINFO struct { 181 | CbSize uint32 182 | DwMask uint32 183 | IdCommand int32 184 | IImage int32 185 | FsState byte 186 | FsStyle byte 187 | Cx uint16 188 | LParam uintptr 189 | PszText uintptr 190 | CchText int32 191 | } 192 | -------------------------------------------------------------------------------- /tooltip.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "unsafe" 9 | ) 10 | 11 | // ToolTip styles 12 | const ( 13 | TTS_ALWAYSTIP = 0x01 14 | TTS_NOPREFIX = 0x02 15 | TTS_NOANIMATE = 0x10 16 | TTS_NOFADE = 0x20 17 | TTS_BALLOON = 0x40 18 | TTS_CLOSE = 0x80 19 | ) 20 | 21 | // ToolTip messages 22 | const ( 23 | TTM_ACTIVATE = WM_USER + 1 24 | TTM_SETDELAYTIME = WM_USER + 3 25 | TTM_ADDTOOL = WM_USER + 50 26 | TTM_DELTOOL = WM_USER + 51 27 | TTM_NEWTOOLRECT = WM_USER + 52 28 | TTM_RELAYEVENT = WM_USER + 7 29 | TTM_GETTOOLINFO = WM_USER + 53 30 | TTM_SETTOOLINFO = WM_USER + 54 31 | TTM_HITTEST = WM_USER + 55 32 | TTM_GETTEXT = WM_USER + 56 33 | TTM_UPDATETIPTEXT = WM_USER + 57 34 | TTM_GETTOOLCOUNT = WM_USER + 13 35 | TTM_ENUMTOOLS = WM_USER + 58 36 | TTM_GETCURRENTTOOL = WM_USER + 59 37 | TTM_WINDOWFROMPOINT = WM_USER + 16 38 | TTM_TRACKACTIVATE = WM_USER + 17 39 | TTM_TRACKPOSITION = WM_USER + 18 40 | TTM_SETTIPBKCOLOR = WM_USER + 19 41 | TTM_SETTIPTEXTCOLOR = WM_USER + 20 42 | TTM_GETDELAYTIME = WM_USER + 21 43 | TTM_GETTIPBKCOLOR = WM_USER + 22 44 | TTM_GETTIPTEXTCOLOR = WM_USER + 23 45 | TTM_SETMAXTIPWIDTH = WM_USER + 24 46 | TTM_GETMAXTIPWIDTH = WM_USER + 25 47 | TTM_SETMARGIN = WM_USER + 26 48 | TTM_GETMARGIN = WM_USER + 27 49 | TTM_POP = WM_USER + 28 50 | TTM_UPDATE = WM_USER + 29 51 | TTM_GETBUBBLESIZE = WM_USER + 30 52 | TTM_ADJUSTRECT = WM_USER + 31 53 | TTM_SETTITLE = WM_USER + 33 54 | TTM_POPUP = WM_USER + 34 55 | TTM_GETTITLE = WM_USER + 35 56 | ) 57 | 58 | // ToolTip flags 59 | const ( 60 | TTF_IDISHWND = 0x0001 61 | TTF_CENTERTIP = 0x0002 62 | TTF_RTLREADING = 0x0004 63 | TTF_SUBCLASS = 0x0010 64 | TTF_TRACK = 0x0020 65 | TTF_ABSOLUTE = 0x0080 66 | TTF_TRANSPARENT = 0x0100 67 | TTF_DI_SETITEM = 0x8000 68 | ) 69 | 70 | // ToolTip icons 71 | const ( 72 | TTI_NONE = 0 73 | TTI_INFO = 1 74 | TTI_WARNING = 2 75 | TTI_ERROR = 3 76 | ) 77 | 78 | type TOOLINFO struct { 79 | CbSize uint32 80 | UFlags uint32 81 | Hwnd HWND 82 | UId uintptr 83 | Rect RECT 84 | Hinst HINSTANCE 85 | LpszText *uint16 86 | LParam uintptr 87 | LpReserved unsafe.Pointer 88 | } 89 | 90 | type TTGETTITLE struct { 91 | DwSize uint32 92 | UTitleBitmap uint32 93 | Cch uint32 94 | PszTitle *uint16 95 | } 96 | -------------------------------------------------------------------------------- /treeview.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | // TreeView styles 8 | const ( 9 | TVS_HASBUTTONS = 0x0001 10 | TVS_HASLINES = 0x0002 11 | TVS_LINESATROOT = 0x0004 12 | TVS_EDITLABELS = 0x0008 13 | TVS_DISABLEDRAGDROP = 0x0010 14 | TVS_SHOWSELALWAYS = 0x0020 15 | TVS_RTLREADING = 0x0040 16 | TVS_NOTOOLTIPS = 0x0080 17 | TVS_CHECKBOXES = 0x0100 18 | TVS_TRACKSELECT = 0x0200 19 | TVS_SINGLEEXPAND = 0x0400 20 | TVS_INFOTIP = 0x0800 21 | TVS_FULLROWSELECT = 0x1000 22 | TVS_NOSCROLL = 0x2000 23 | TVS_NONEVENHEIGHT = 0x4000 24 | TVS_NOHSCROLL = 0x8000 25 | ) 26 | 27 | const ( 28 | TVIF_TEXT = 0x0001 29 | TVIF_IMAGE = 0x0002 30 | TVIF_PARAM = 0x0004 31 | TVIF_STATE = 0x0008 32 | TVIF_HANDLE = 0x0010 33 | TVIF_SELECTEDIMAGE = 0x0020 34 | TVIF_CHILDREN = 0x0040 35 | TVIF_INTEGRAL = 0x0080 36 | TVIF_STATEEX = 0x0100 37 | TVIF_EXPANDEDIMAGE = 0x0200 38 | ) 39 | 40 | const ( 41 | TVIS_SELECTED = 0x0002 42 | TVIS_CUT = 0x0004 43 | TVIS_DROPHILITED = 0x0008 44 | TVIS_BOLD = 0x0010 45 | TVIS_EXPANDED = 0x0020 46 | TVIS_EXPANDEDONCE = 0x0040 47 | TVIS_EXPANDPARTIAL = 0x0080 48 | TVIS_OVERLAYMASK = 0x0F00 49 | TVIS_STATEIMAGEMASK = 0xF000 50 | TVIS_USERMASK = 0xF000 51 | ) 52 | 53 | const ( 54 | TVIS_EX_FLAT = 0x0001 55 | TVIS_EX_DISABLED = 0x0002 56 | TVIS_EX_ALL = 0x0002 57 | ) 58 | 59 | const ( 60 | TVI_ROOT = ^HTREEITEM(0xffff) 61 | TVI_FIRST = ^HTREEITEM(0xfffe) 62 | TVI_LAST = ^HTREEITEM(0xfffd) 63 | TVI_SORT = ^HTREEITEM(0xfffc) 64 | ) 65 | 66 | // TVM_EXPAND action flags 67 | const ( 68 | TVE_COLLAPSE = 0x0001 69 | TVE_EXPAND = 0x0002 70 | TVE_TOGGLE = 0x0003 71 | TVE_EXPANDPARTIAL = 0x4000 72 | TVE_COLLAPSERESET = 0x8000 73 | ) 74 | 75 | const ( 76 | TVGN_CARET = 9 77 | ) 78 | 79 | // TreeView messages 80 | const ( 81 | TV_FIRST = 0x1100 82 | 83 | TVM_INSERTITEM = TV_FIRST + 50 84 | TVM_DELETEITEM = TV_FIRST + 1 85 | TVM_EXPAND = TV_FIRST + 2 86 | TVM_GETITEMRECT = TV_FIRST + 4 87 | TVM_GETCOUNT = TV_FIRST + 5 88 | TVM_GETINDENT = TV_FIRST + 6 89 | TVM_SETINDENT = TV_FIRST + 7 90 | TVM_GETIMAGELIST = TV_FIRST + 8 91 | TVM_SETIMAGELIST = TV_FIRST + 9 92 | TVM_GETNEXTITEM = TV_FIRST + 10 93 | TVM_SELECTITEM = TV_FIRST + 11 94 | TVM_GETITEM = TV_FIRST + 62 95 | TVM_SETITEM = TV_FIRST + 63 96 | TVM_EDITLABEL = TV_FIRST + 65 97 | TVM_GETEDITCONTROL = TV_FIRST + 15 98 | TVM_GETVISIBLECOUNT = TV_FIRST + 16 99 | TVM_HITTEST = TV_FIRST + 17 100 | TVM_CREATEDRAGIMAGE = TV_FIRST + 18 101 | TVM_SORTCHILDREN = TV_FIRST + 19 102 | TVM_ENSUREVISIBLE = TV_FIRST + 20 103 | TVM_SORTCHILDRENCB = TV_FIRST + 21 104 | TVM_ENDEDITLABELNOW = TV_FIRST + 22 105 | TVM_GETISEARCHSTRING = TV_FIRST + 64 106 | TVM_SETTOOLTIPS = TV_FIRST + 24 107 | TVM_GETTOOLTIPS = TV_FIRST + 25 108 | TVM_SETINSERTMARK = TV_FIRST + 26 109 | TVM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 110 | TVM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 111 | TVM_SETITEMHEIGHT = TV_FIRST + 27 112 | TVM_GETITEMHEIGHT = TV_FIRST + 28 113 | TVM_SETBKCOLOR = TV_FIRST + 29 114 | TVM_SETTEXTCOLOR = TV_FIRST + 30 115 | TVM_GETBKCOLOR = TV_FIRST + 31 116 | TVM_GETTEXTCOLOR = TV_FIRST + 32 117 | TVM_SETSCROLLTIME = TV_FIRST + 33 118 | TVM_GETSCROLLTIME = TV_FIRST + 34 119 | TVM_SETINSERTMARKCOLOR = TV_FIRST + 37 120 | TVM_GETINSERTMARKCOLOR = TV_FIRST + 38 121 | TVM_GETITEMSTATE = TV_FIRST + 39 122 | TVM_SETLINECOLOR = TV_FIRST + 40 123 | TVM_GETLINECOLOR = TV_FIRST + 41 124 | TVM_MAPACCIDTOHTREEITEM = TV_FIRST + 42 125 | TVM_MAPHTREEITEMTOACCID = TV_FIRST + 43 126 | TVM_SETEXTENDEDSTYLE = TV_FIRST + 44 127 | TVM_GETEXTENDEDSTYLE = TV_FIRST + 45 128 | TVM_SETAUTOSCROLLINFO = TV_FIRST + 59 129 | ) 130 | 131 | // TreeView notifications 132 | const ( 133 | TVN_FIRST = ^uint32(399) 134 | 135 | TVN_SELCHANGING = TVN_FIRST - 50 136 | TVN_SELCHANGED = TVN_FIRST - 51 137 | TVN_GETDISPINFO = TVN_FIRST - 52 138 | TVN_ITEMEXPANDING = TVN_FIRST - 54 139 | TVN_ITEMEXPANDED = TVN_FIRST - 55 140 | TVN_BEGINDRAG = TVN_FIRST - 56 141 | TVN_BEGINRDRAG = TVN_FIRST - 57 142 | TVN_DELETEITEM = TVN_FIRST - 58 143 | TVN_BEGINLABELEDIT = TVN_FIRST - 59 144 | TVN_ENDLABELEDIT = TVN_FIRST - 60 145 | TVN_KEYDOWN = TVN_FIRST - 12 146 | TVN_GETINFOTIP = TVN_FIRST - 14 147 | TVN_SINGLEEXPAND = TVN_FIRST - 15 148 | TVN_ITEMCHANGING = TVN_FIRST - 17 149 | TVN_ITEMCHANGED = TVN_FIRST - 19 150 | TVN_ASYNCDRAW = TVN_FIRST - 20 151 | ) 152 | 153 | // TreeView hit test constants 154 | const ( 155 | TVHT_NOWHERE = 1 156 | TVHT_ONITEMICON = 2 157 | TVHT_ONITEMLABEL = 4 158 | TVHT_ONITEM = TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMSTATEICON 159 | TVHT_ONITEMINDENT = 8 160 | TVHT_ONITEMBUTTON = 16 161 | TVHT_ONITEMRIGHT = 32 162 | TVHT_ONITEMSTATEICON = 64 163 | TVHT_ABOVE = 256 164 | TVHT_BELOW = 512 165 | TVHT_TORIGHT = 1024 166 | TVHT_TOLEFT = 2048 167 | ) 168 | 169 | type HTREEITEM HANDLE 170 | 171 | type TVITEM struct { 172 | Mask uint32 173 | HItem HTREEITEM 174 | State uint32 175 | StateMask uint32 176 | PszText uintptr 177 | CchTextMax int32 178 | IImage int32 179 | ISelectedImage int32 180 | CChildren int32 181 | LParam uintptr 182 | } 183 | 184 | /*type TVITEMEX struct { 185 | mask UINT 186 | hItem HTREEITEM 187 | state UINT 188 | stateMask UINT 189 | pszText LPWSTR 190 | cchTextMax int 191 | iImage int 192 | iSelectedImage int 193 | cChildren int 194 | lParam LPARAM 195 | iIntegral int 196 | uStateEx UINT 197 | hwnd HWND 198 | iExpandedImage int 199 | }*/ 200 | 201 | type TVINSERTSTRUCT struct { 202 | HParent HTREEITEM 203 | HInsertAfter HTREEITEM 204 | Item TVITEM 205 | // itemex TVITEMEX 206 | } 207 | 208 | type NMTREEVIEW struct { 209 | Hdr NMHDR 210 | Action uint32 211 | ItemOld TVITEM 212 | ItemNew TVITEM 213 | PtDrag POINT 214 | } 215 | 216 | type NMTVDISPINFO struct { 217 | Hdr NMHDR 218 | Item TVITEM 219 | } 220 | 221 | type TVHITTESTINFO struct { 222 | Pt POINT 223 | Flags uint32 224 | HItem HTREEITEM 225 | } 226 | -------------------------------------------------------------------------------- /updown.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The go-winapi 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 | package winapi 6 | 7 | const UDN_FIRST = ^uint32(720) 8 | 9 | const ( 10 | UD_MAXVAL = 0x7fff 11 | UD_MINVAL = ^uintptr(UD_MAXVAL - 1) 12 | ) 13 | 14 | const ( 15 | UDS_WRAP = 0x0001 16 | UDS_SETBUDDYINT = 0x0002 17 | UDS_ALIGNRIGHT = 0x0004 18 | UDS_ALIGNLEFT = 0x0008 19 | UDS_AUTOBUDDY = 0x0010 20 | UDS_ARROWKEYS = 0x0020 21 | UDS_HORZ = 0x0040 22 | UDS_NOTHOUSANDS = 0x0080 23 | UDS_HOTTRACK = 0x0100 24 | ) 25 | 26 | const ( 27 | UDM_SETRANGE = WM_USER + 101 28 | UDM_GETRANGE = WM_USER + 102 29 | UDM_SETPOS = WM_USER + 103 30 | UDM_GETPOS = WM_USER + 104 31 | UDM_SETBUDDY = WM_USER + 105 32 | UDM_GETBUDDY = WM_USER + 106 33 | UDM_SETACCEL = WM_USER + 107 34 | UDM_GETACCEL = WM_USER + 108 35 | UDM_SETBASE = WM_USER + 109 36 | UDM_GETBASE = WM_USER + 110 37 | UDM_SETRANGE32 = WM_USER + 111 38 | UDM_GETRANGE32 = WM_USER + 112 39 | UDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 40 | UDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 41 | UDM_SETPOS32 = WM_USER + 113 42 | UDM_GETPOS32 = WM_USER + 114 43 | ) 44 | 45 | const UDN_DELTAPOS = UDN_FIRST - 1 46 | 47 | type UDACCEL struct { 48 | NSec uint32 49 | NInc uint32 50 | } 51 | 52 | type NMUPDOWN struct { 53 | Hdr NMHDR 54 | IPos int32 55 | IDelta int32 56 | } 57 | -------------------------------------------------------------------------------- /uxtheme.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | var ( 13 | // Library 14 | libuxtheme uintptr 15 | 16 | // Functions 17 | setWindowTheme uintptr 18 | ) 19 | 20 | func init() { 21 | // Library 22 | libuxtheme = MustLoadLibrary("uxtheme.dll") 23 | 24 | // Functions 25 | setWindowTheme = MustGetProcAddress(libuxtheme, "SetWindowTheme") 26 | } 27 | 28 | func SetWindowTheme(hwnd HWND, pszSubAppName, pszSubIdList *uint16) HRESULT { 29 | ret, _, _ := syscall.Syscall(setWindowTheme, 3, 30 | uintptr(hwnd), 31 | uintptr(unsafe.Pointer(pszSubAppName)), 32 | uintptr(unsafe.Pointer(pszSubIdList))) 33 | 34 | return HRESULT(ret) 35 | } 36 | -------------------------------------------------------------------------------- /winapi.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "runtime" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | func init() { 14 | runtime.LockOSThread() 15 | } 16 | 17 | const ( 18 | S_OK = 0x00000000 19 | S_FALSE = 0x00000001 20 | E_UNEXPECTED = 0x8000FFFF 21 | E_NOTIMPL = 0x80004001 22 | E_OUTOFMEMORY = 0x8007000E 23 | E_INVALIDARG = 0x80070057 24 | E_NOINTERFACE = 0x80004002 25 | E_POINTER = 0x80004003 26 | E_HANDLE = 0x80070006 27 | E_ABORT = 0x80004004 28 | E_FAIL = 0x80004005 29 | E_ACCESSDENIED = 0x80070005 30 | E_PENDING = 0x8000000A 31 | ) 32 | 33 | const ( 34 | FALSE = 0 35 | TRUE = 1 36 | ) 37 | 38 | type ( 39 | BOOL int32 40 | HRESULT int32 41 | ) 42 | 43 | type GUID struct { 44 | Data1 uint32 45 | Data2 uint16 46 | Data3 uint16 47 | Data4 [8]byte 48 | } 49 | 50 | func MustLoadLibrary(name string) uintptr { 51 | lib, err := syscall.LoadLibrary(name) 52 | if err != nil { 53 | panic(err) 54 | } 55 | 56 | return uintptr(lib) 57 | } 58 | 59 | func MustGetProcAddress(lib uintptr, name string) uintptr { 60 | addr, err := syscall.GetProcAddress(syscall.Handle(lib), name) 61 | if err != nil { 62 | panic(err) 63 | } 64 | 65 | return uintptr(addr) 66 | } 67 | 68 | func SUCCEEDED(hr HRESULT) bool { 69 | return hr >= 0 70 | } 71 | 72 | func FAILED(hr HRESULT) bool { 73 | return hr < 0 74 | } 75 | 76 | func MAKELONG(lo, hi uint16) uint32 { 77 | return uint32(uint32(lo) | ((uint32(hi)) << 16)) 78 | } 79 | 80 | func LOWORD(dw uint32) uint16 { 81 | return uint16(dw) 82 | } 83 | 84 | func HIWORD(dw uint32) uint16 { 85 | return uint16(dw >> 16 & 0xffff) 86 | } 87 | 88 | func UTF16PtrToString(s *uint16) string { 89 | if s == nil { 90 | return "" 91 | } 92 | return syscall.UTF16ToString((*[1 << 29]uint16)(unsafe.Pointer(s))[0:]) 93 | } 94 | 95 | func MAKEINTRESOURCE(id uintptr) *uint16 { 96 | return (*uint16)(unsafe.Pointer(id)) 97 | } 98 | 99 | func BoolToBOOL(value bool) BOOL { 100 | if value { 101 | return 1 102 | } 103 | 104 | return 0 105 | } 106 | 107 | func RGB(r, g, b int32) COLORREF{ 108 | r = r & 0xff 109 | g = (g & 0xff) <<8 110 | b = (b & 0xff) <<16 111 | return COLORREF( r | g | b ) 112 | } 113 | 114 | func GetRValue(cr COLORREF) uint32{ 115 | return (uint32(cr) & 0xff) 116 | } 117 | 118 | 119 | func GetGValue(cr COLORREF) uint32{ 120 | return ((uint32(cr) >> 4)& 0xff) 121 | } 122 | 123 | 124 | func GetBValue(cr COLORREF) uint32{ 125 | return ((uint32(cr)>>8) & 0xff) 126 | } 127 | -------------------------------------------------------------------------------- /winmm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | var ( 13 | // Library 14 | libwinmm uintptr 15 | 16 | // Functions 17 | playSound uintptr 18 | ) 19 | 20 | func init(){ 21 | // Library 22 | libwinmm = MustLoadLibrary("Winmm.dll") 23 | 24 | // Functions 25 | playSound = MustGetProcAddress(libwinmm, "PlaySoundW") 26 | } 27 | 28 | 29 | const ( 30 | SND_SYNC = 0x0000 /* play synchronously (default) */ 31 | SND_ASYNC = 0x0001 /* play asynchronously */ 32 | SND_NODEFAULT = 0x0002 /* silence (!default) if sound not found */ 33 | SND_MEMORY = 0x0004 /* pszSound points to a memory file */ 34 | SND_LOOP = 0x0008 /* loop the sound until next sndPlaySound */ 35 | SND_NOSTOP = 0x0010 /* don't stop any currently playing sound */ 36 | SND_NOWAIT = 0x00002000 /* don't wait if the driver is busy */ 37 | SND_ALIAS = 0x00010000 /* name is a registry alias */ 38 | SND_ALIAS_ID = 0x00110000 /* alias is a predefined ID */ 39 | SND_FILENAME = 0x00020000 /* name is file name */ 40 | SND_RESOURCE = 0x00040004 /* name is resource name or atom */ 41 | 42 | SND_PURGE = 0x0040 /* purge non-static events for task */ 43 | SND_APPLICATION = 0x0080 /* look for application specific association */ 44 | 45 | SND_SENTRY = 0x00080000 /* Generate a SoundSentry event with this sound */ 46 | SND_RING = 0x00100000 /* Treat this as a "ring" from a communications app - don't duck me */ 47 | SND_SYSTEM = 0x00200000 /* Treat this as a system sound */ 48 | 49 | SND_ALIAS_START = 0 /* alias base */ 50 | ) 51 | 52 | func PlaySound(pszSound *uint16, hmod HWND, fdwSound uint32) BOOL { 53 | 54 | ret, _, _ := syscall.Syscall(playSound, 3, 55 | uintptr(unsafe.Pointer(pszSound)), 56 | uintptr(hmod), 57 | uintptr(fdwSound), 58 | ) 59 | 60 | return BOOL(ret) 61 | } -------------------------------------------------------------------------------- /winspool.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The go-winapi 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 | package winapi 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // EnumPrinters flags 13 | const ( 14 | PRINTER_ENUM_DEFAULT = 0x00000001 15 | PRINTER_ENUM_LOCAL = 0x00000002 16 | PRINTER_ENUM_CONNECTIONS = 0x00000004 17 | PRINTER_ENUM_FAVORITE = 0x00000004 18 | PRINTER_ENUM_NAME = 0x00000008 19 | PRINTER_ENUM_REMOTE = 0x00000010 20 | PRINTER_ENUM_SHARED = 0x00000020 21 | PRINTER_ENUM_NETWORK = 0x00000040 22 | ) 23 | 24 | type PRINTER_INFO_4 struct { 25 | PPrinterName *uint16 26 | PServerName *uint16 27 | Attributes uint32 28 | } 29 | 30 | var ( 31 | // Library 32 | libwinspool uintptr 33 | 34 | // Functions 35 | deviceCapabilities uintptr 36 | documentProperties uintptr 37 | enumPrinters uintptr 38 | getDefaultPrinter uintptr 39 | ) 40 | 41 | func init() { 42 | // Library 43 | libwinspool = MustLoadLibrary("winspool.drv") 44 | 45 | // Functions 46 | deviceCapabilities = MustGetProcAddress(libwinspool, "DeviceCapabilitiesW") 47 | documentProperties = MustGetProcAddress(libwinspool, "DocumentPropertiesW") 48 | enumPrinters = MustGetProcAddress(libwinspool, "EnumPrintersW") 49 | getDefaultPrinter = MustGetProcAddress(libwinspool, "GetDefaultPrinterW") 50 | } 51 | 52 | func DeviceCapabilities(pDevice, pPort *uint16, fwCapability uint16, pOutput *uint16, pDevMode *DEVMODE) uint32 { 53 | ret, _, _ := syscall.Syscall6(deviceCapabilities, 5, 54 | uintptr(unsafe.Pointer(pDevice)), 55 | uintptr(unsafe.Pointer(pPort)), 56 | uintptr(fwCapability), 57 | uintptr(unsafe.Pointer(pOutput)), 58 | uintptr(unsafe.Pointer(pDevMode)), 59 | 0) 60 | 61 | return uint32(ret) 62 | } 63 | 64 | func DocumentProperties(hWnd HWND, hPrinter HANDLE, pDeviceName *uint16, pDevModeOutput, pDevModeInput *DEVMODE, fMode uint32) int32 { 65 | ret, _, _ := syscall.Syscall6(documentProperties, 6, 66 | uintptr(hWnd), 67 | uintptr(hPrinter), 68 | uintptr(unsafe.Pointer(pDeviceName)), 69 | uintptr(unsafe.Pointer(pDevModeOutput)), 70 | uintptr(unsafe.Pointer(pDevModeInput)), 71 | uintptr(fMode)) 72 | 73 | return int32(ret) 74 | } 75 | 76 | func EnumPrinters(Flags uint32, Name *uint16, Level uint32, pPrinterEnum *byte, cbBuf uint32, pcbNeeded, pcReturned *uint32) bool { 77 | ret, _, _ := syscall.Syscall9(enumPrinters, 7, 78 | uintptr(Flags), 79 | uintptr(unsafe.Pointer(Name)), 80 | uintptr(Level), 81 | uintptr(unsafe.Pointer(pPrinterEnum)), 82 | uintptr(cbBuf), 83 | uintptr(unsafe.Pointer(pcbNeeded)), 84 | uintptr(unsafe.Pointer(pcReturned)), 85 | 0, 86 | 0) 87 | 88 | return ret != 0 89 | } 90 | 91 | func GetDefaultPrinter(pszBuffer *uint16, pcchBuffer *uint32) bool { 92 | ret, _, _ := syscall.Syscall(getDefaultPrinter, 2, 93 | uintptr(unsafe.Pointer(pszBuffer)), 94 | uintptr(unsafe.Pointer(pcchBuffer)), 95 | 0) 96 | 97 | return ret != 0 98 | } 99 | --------------------------------------------------------------------------------