├── AUTHORS ├── LICENSE ├── Makefile ├── README.mdown ├── advapi32.go ├── combobox.go ├── comctl32.go ├── comdlg32.go ├── datetimepicker.go ├── edit.go ├── gdi32.go ├── gdiplus.go ├── kernel32.go ├── listview.go ├── menu.go ├── ole32.go ├── oleaut32.go ├── opengl32.go ├── shdocvw.go ├── shell32.go ├── tab.go ├── toolbar.go ├── tooltip.go ├── treeview.go ├── updown.go ├── user32.go ├── uxtheme.go ├── winapi.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include $(GOROOT)/src/Make.inc 2 | 3 | TARG=winapi 4 | GOFILES=\ 5 | advapi32.go\ 6 | combobox.go\ 7 | comctl32.go\ 8 | comdlg32.go\ 9 | datetimepicker.go\ 10 | edit.go\ 11 | gdi32.go\ 12 | gdiplus.go\ 13 | kernel32.go\ 14 | listview.go\ 15 | menu.go\ 16 | ole32.go\ 17 | oleaut32.go\ 18 | opengl32.go\ 19 | shdocvw.go\ 20 | shell32.go\ 21 | tab.go\ 22 | toolbar.go\ 23 | tooltip.go\ 24 | treeview.go\ 25 | updown.go\ 26 | user32.go\ 27 | uxtheme.go\ 28 | winapi.go\ 29 | winspool.go\ 30 | 31 | include $(GOROOT)/src/Make.pkg 32 | -------------------------------------------------------------------------------- /README.mdown: -------------------------------------------------------------------------------- 1 | About go-winapi 2 | =============== 3 | 4 | go-winapi is a Windows API wrapper package for Go. 5 | 6 | Originally part of [walk](https://github.com/lxn/walk), it is now a separate 7 | project. 8 | 9 | Setup 10 | ===== 11 | 12 | 1. Make sure you have a working Go installation. 13 | 14 | The easiest option for building Go programs on Windows is to use a stable 15 | [pre-built Go release](http://code.google.com/p/gomingw/downloads/list). 16 | 17 | Because Go is still changing rapidly, you may prefer to use a weekly Go 18 | snapshot instead. The unofficial [Go Wiki](http://code.google.com/p/go-wiki/) 19 | has some guides for building on Windows and cross-compiling. 20 | 21 | The official [Getting Started](http://golang.org/doc/install.html) guide, 22 | while not focused on Windows, is a recommended read for developers new to Go. 23 | 24 | 2. Either run 25 | `goinstall github.com/lxn/go-winapi` 26 | and import the package like this: 27 | `import "github.com/lxn/go-winapi"` 28 | 29 | Or run 30 | `git clone http://github.com/lxn/go-winapi.git` 31 | and 32 | `cd go-winapi && gomake install` 33 | and import the package like this: 34 | `import "winapi"` 35 | -------------------------------------------------------------------------------- /advapi32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | const KEY_READ REGSAM = 0x20019 13 | 14 | const ( 15 | HKEY_CLASSES_ROOT HKEY = 0x80000000 16 | HKEY_CURRENT_USER HKEY = 0x80000001 17 | HKEY_LOCAL_MACHINE HKEY = 0x80000002 18 | HKEY_USERS HKEY = 0x80000003 19 | HKEY_PERFORMANCE_DATA HKEY = 0x80000004 20 | HKEY_CURRENT_CONFIG HKEY = 0x80000005 21 | HKEY_DYN_DATA HKEY = 0x80000006 22 | ) 23 | 24 | type ( 25 | ACCESS_MASK uint32 26 | HKEY HANDLE 27 | REGSAM ACCESS_MASK 28 | ) 29 | 30 | var ( 31 | // Library 32 | libadvapi32 uintptr 33 | 34 | // Functions 35 | regCloseKey uintptr 36 | regOpenKeyEx uintptr 37 | regQueryValueEx uintptr 38 | ) 39 | 40 | func init() { 41 | // Library 42 | libadvapi32 = MustLoadLibrary("advapi32.dll") 43 | 44 | // Functions 45 | regCloseKey = MustGetProcAddress(libadvapi32, "RegCloseKey") 46 | regOpenKeyEx = MustGetProcAddress(libadvapi32, "RegOpenKeyExW") 47 | regQueryValueEx = MustGetProcAddress(libadvapi32, "RegQueryValueExW") 48 | } 49 | 50 | func RegCloseKey(hKey HKEY) int32 { 51 | ret, _, _ := syscall.Syscall(regCloseKey, 1, 52 | uintptr(hKey), 53 | 0, 54 | 0) 55 | 56 | return int32(ret) 57 | } 58 | 59 | func RegOpenKeyEx(hKey HKEY, lpSubKey *uint16, ulOptions uint32, samDesired REGSAM, phkResult *HKEY) int32 { 60 | ret, _, _ := syscall.Syscall6(regOpenKeyEx, 5, 61 | uintptr(hKey), 62 | uintptr(unsafe.Pointer(lpSubKey)), 63 | uintptr(ulOptions), 64 | uintptr(samDesired), 65 | uintptr(unsafe.Pointer(phkResult)), 66 | 0) 67 | 68 | return int32(ret) 69 | } 70 | 71 | func RegQueryValueEx(hKey HKEY, lpValueName *uint16, lpReserved, lpType *uint32, lpData *byte, lpcbData *uint32) int32 { 72 | ret, _, _ := syscall.Syscall6(regQueryValueEx, 6, 73 | uintptr(hKey), 74 | uintptr(unsafe.Pointer(lpValueName)), 75 | uintptr(unsafe.Pointer(lpReserved)), 76 | uintptr(unsafe.Pointer(lpType)), 77 | uintptr(unsafe.Pointer(lpData)), 78 | uintptr(unsafe.Pointer(lpcbData))) 79 | 80 | return int32(ret) 81 | } 82 | -------------------------------------------------------------------------------- /combobox.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | // 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 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 | // 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 | type HIMAGELIST HANDLE 134 | 135 | type INITCOMMONCONTROLSEX struct { 136 | DwSize, DwICC uint32 137 | } 138 | 139 | var ( 140 | // Library 141 | libcomctl32 uintptr 142 | 143 | // Functions 144 | imageList_Add uintptr 145 | imageList_AddMasked uintptr 146 | imageList_Create uintptr 147 | imageList_Destroy uintptr 148 | initCommonControlsEx uintptr 149 | ) 150 | 151 | func init() { 152 | // Library 153 | libcomctl32 = MustLoadLibrary("comctl32.dll") 154 | 155 | // Functions 156 | imageList_Add = MustGetProcAddress(libcomctl32, "ImageList_Add") 157 | imageList_AddMasked = MustGetProcAddress(libcomctl32, "ImageList_AddMasked") 158 | imageList_Create = MustGetProcAddress(libcomctl32, "ImageList_Create") 159 | imageList_Destroy = MustGetProcAddress(libcomctl32, "ImageList_Destroy") 160 | initCommonControlsEx = MustGetProcAddress(libcomctl32, "InitCommonControlsEx") 161 | 162 | // Initialize the common controls we support 163 | var initCtrls INITCOMMONCONTROLSEX 164 | initCtrls.DwSize = uint32(unsafe.Sizeof(initCtrls)) 165 | initCtrls.DwICC = ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES 166 | 167 | InitCommonControlsEx(&initCtrls) 168 | } 169 | 170 | func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int32 { 171 | ret, _, _ := syscall.Syscall(imageList_Add, 3, 172 | uintptr(himl), 173 | uintptr(hbmImage), 174 | uintptr(hbmMask)) 175 | 176 | return int32(ret) 177 | } 178 | 179 | func ImageList_AddMasked(himl HIMAGELIST, hbmImage HBITMAP, crMask COLORREF) int32 { 180 | ret, _, _ := syscall.Syscall(imageList_AddMasked, 3, 181 | uintptr(himl), 182 | uintptr(hbmImage), 183 | uintptr(crMask)) 184 | 185 | return int32(ret) 186 | } 187 | 188 | func ImageList_Create(cx, cy int32, flags uint32, cInitial, cGrow int32) HIMAGELIST { 189 | ret, _, _ := syscall.Syscall6(imageList_Create, 5, 190 | uintptr(cx), 191 | uintptr(cy), 192 | uintptr(flags), 193 | uintptr(cInitial), 194 | uintptr(cGrow), 195 | 0) 196 | 197 | return HIMAGELIST(ret) 198 | } 199 | 200 | func ImageList_Destroy(hIml HIMAGELIST) bool { 201 | ret, _, _ := syscall.Syscall(imageList_Destroy, 1, 202 | uintptr(hIml), 203 | 0, 204 | 0) 205 | 206 | return ret != 0 207 | } 208 | 209 | func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool { 210 | ret, _, _ := syscall.Syscall(initCommonControlsEx, 1, 211 | uintptr(unsafe.Pointer(lpInitCtrls)), 212 | 0, 213 | 0) 214 | 215 | return ret != 0 216 | } 217 | -------------------------------------------------------------------------------- /comdlg32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | // 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 | 206 | var ( 207 | // Library 208 | libcomdlg32 uintptr 209 | 210 | // Functions 211 | commDlgExtendedError uintptr 212 | getOpenFileName uintptr 213 | getSaveFileName uintptr 214 | printDlgEx uintptr 215 | ) 216 | 217 | func init() { 218 | // Library 219 | libcomdlg32 = MustLoadLibrary("comdlg32.dll") 220 | 221 | // Functions 222 | commDlgExtendedError = MustGetProcAddress(libcomdlg32, "CommDlgExtendedError") 223 | getOpenFileName = MustGetProcAddress(libcomdlg32, "GetOpenFileNameW") 224 | getSaveFileName = MustGetProcAddress(libcomdlg32, "GetSaveFileNameW") 225 | printDlgEx = MustGetProcAddress(libcomdlg32, "PrintDlgExW") 226 | } 227 | 228 | func CommDlgExtendedError() uint32 { 229 | ret, _, _ := syscall.Syscall(commDlgExtendedError, 0, 230 | 0, 231 | 0, 232 | 0) 233 | 234 | return uint32(ret) 235 | } 236 | 237 | func GetOpenFileName(lpofn *OPENFILENAME) bool { 238 | ret, _, _ := syscall.Syscall(getOpenFileName, 1, 239 | uintptr(unsafe.Pointer(lpofn)), 240 | 0, 241 | 0) 242 | 243 | return ret != 0 244 | } 245 | 246 | func GetSaveFileName(lpofn *OPENFILENAME) bool { 247 | ret, _, _ := syscall.Syscall(getSaveFileName, 1, 248 | uintptr(unsafe.Pointer(lpofn)), 249 | 0, 250 | 0) 251 | 252 | return ret != 0 253 | } 254 | 255 | func PrintDlgEx(lppd *PRINTDLGEX) HRESULT { 256 | ret, _, _ := syscall.Syscall(printDlgEx, 1, 257 | uintptr(unsafe.Pointer(lppd)), 258 | 0, 259 | 0) 260 | 261 | return HRESULT(ret) 262 | } 263 | -------------------------------------------------------------------------------- /datetimepicker.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 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 | 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 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 | // 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 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 | // GetDeviceCaps index constants 13 | const ( 14 | DRIVERVERSION = 0 15 | TECHNOLOGY = 2 16 | HORZSIZE = 4 17 | VERTSIZE = 6 18 | HORZRES = 8 19 | VERTRES = 10 20 | LOGPIXELSX = 88 21 | LOGPIXELSY = 90 22 | BITSPIXEL = 12 23 | PLANES = 14 24 | NUMBRUSHES = 16 25 | NUMPENS = 18 26 | NUMFONTS = 22 27 | NUMCOLORS = 24 28 | NUMMARKERS = 20 29 | ASPECTX = 40 30 | ASPECTY = 42 31 | ASPECTXY = 44 32 | PDEVICESIZE = 26 33 | CLIPCAPS = 36 34 | SIZEPALETTE = 104 35 | NUMRESERVED = 106 36 | COLORRES = 108 37 | PHYSICALWIDTH = 110 38 | PHYSICALHEIGHT = 111 39 | PHYSICALOFFSETX = 112 40 | PHYSICALOFFSETY = 113 41 | SCALINGFACTORX = 114 42 | SCALINGFACTORY = 115 43 | VREFRESH = 116 44 | DESKTOPHORZRES = 118 45 | DESKTOPVERTRES = 117 46 | BLTALIGNMENT = 119 47 | SHADEBLENDCAPS = 120 48 | COLORMGMTCAPS = 121 49 | RASTERCAPS = 38 50 | CURVECAPS = 28 51 | LINECAPS = 30 52 | POLYGONALCAPS = 32 53 | TEXTCAPS = 34 54 | ) 55 | 56 | // GetDeviceCaps TECHNOLOGY constants 57 | const ( 58 | DT_PLOTTER = 0 59 | DT_RASDISPLAY = 1 60 | DT_RASPRINTER = 2 61 | DT_RASCAMERA = 3 62 | DT_CHARSTREAM = 4 63 | DT_METAFILE = 5 64 | DT_DISPFILE = 6 65 | ) 66 | 67 | // GetDeviceCaps SHADEBLENDCAPS constants 68 | const ( 69 | SB_NONE = 0x00 70 | SB_CONST_ALPHA = 0x01 71 | SB_PIXEL_ALPHA = 0x02 72 | SB_PREMULT_ALPHA = 0x04 73 | SB_GRAD_RECT = 0x10 74 | SB_GRAD_TRI = 0x20 75 | ) 76 | 77 | // GetDeviceCaps COLORMGMTCAPS constants 78 | const ( 79 | CM_NONE = 0x00 80 | CM_DEVICE_ICM = 0x01 81 | CM_GAMMA_RAMP = 0x02 82 | CM_CMYK_COLOR = 0x04 83 | ) 84 | 85 | // GetDeviceCaps RASTERCAPS constants 86 | const ( 87 | RC_BANDING = 2 88 | RC_BITBLT = 1 89 | RC_BITMAP64 = 8 90 | RC_DI_BITMAP = 128 91 | RC_DIBTODEV = 512 92 | RC_FLOODFILL = 4096 93 | RC_GDI20_OUTPUT = 16 94 | RC_PALETTE = 256 95 | RC_SCALING = 4 96 | RC_STRETCHBLT = 2048 97 | RC_STRETCHDIB = 8192 98 | RC_DEVBITS = 0x8000 99 | RC_OP_DX_OUTPUT = 0x4000 100 | ) 101 | 102 | // GetDeviceCaps CURVECAPS constants 103 | const ( 104 | CC_NONE = 0 105 | CC_CIRCLES = 1 106 | CC_PIE = 2 107 | CC_CHORD = 4 108 | CC_ELLIPSES = 8 109 | CC_WIDE = 16 110 | CC_STYLED = 32 111 | CC_WIDESTYLED = 64 112 | CC_INTERIORS = 128 113 | CC_ROUNDRECT = 256 114 | ) 115 | 116 | // GetDeviceCaps LINECAPS constants 117 | const ( 118 | LC_NONE = 0 119 | LC_POLYLINE = 2 120 | LC_MARKER = 4 121 | LC_POLYMARKER = 8 122 | LC_WIDE = 16 123 | LC_STYLED = 32 124 | LC_WIDESTYLED = 64 125 | LC_INTERIORS = 128 126 | ) 127 | 128 | // GetDeviceCaps POLYGONALCAPS constants 129 | const ( 130 | PC_NONE = 0 131 | PC_POLYGON = 1 132 | PC_POLYPOLYGON = 256 133 | PC_PATHS = 512 134 | PC_RECTANGLE = 2 135 | PC_WINDPOLYGON = 4 136 | PC_SCANLINE = 8 137 | PC_TRAPEZOID = 4 138 | PC_WIDE = 16 139 | PC_STYLED = 32 140 | PC_WIDESTYLED = 64 141 | PC_INTERIORS = 128 142 | ) 143 | 144 | // GetDeviceCaps TEXTCAPS constants 145 | const ( 146 | TC_OP_CHARACTER = 1 147 | TC_OP_STROKE = 2 148 | TC_CP_STROKE = 4 149 | TC_CR_90 = 8 150 | TC_CR_ANY = 16 151 | TC_SF_X_YINDEP = 32 152 | TC_SA_DOUBLE = 64 153 | TC_SA_INTEGER = 128 154 | TC_SA_CONTIN = 256 155 | TC_EA_DOUBLE = 512 156 | TC_IA_ABLE = 1024 157 | TC_UA_ABLE = 2048 158 | TC_SO_ABLE = 4096 159 | TC_RA_ABLE = 8192 160 | TC_VA_ABLE = 16384 161 | TC_RESERVED = 32768 162 | TC_SCROLLBLT = 65536 163 | ) 164 | 165 | // Brush styles 166 | const ( 167 | BS_SOLID = 0 168 | BS_NULL = 1 169 | BS_HOLLOW = BS_NULL 170 | BS_HATCHED = 2 171 | BS_PATTERN = 3 172 | BS_INDEXED = 4 173 | BS_DIBPATTERN = 5 174 | BS_DIBPATTERNPT = 6 175 | BS_PATTERN8X8 = 7 176 | BS_DIBPATTERN8X8 = 8 177 | BS_MONOPATTERN = 9 178 | ) 179 | 180 | // Hatch styles 181 | const ( 182 | HS_HORIZONTAL = 0 183 | HS_VERTICAL = 1 184 | HS_FDIAGONAL = 2 185 | HS_BDIAGONAL = 3 186 | HS_CROSS = 4 187 | HS_DIAGCROSS = 5 188 | ) 189 | 190 | // Pen types 191 | const ( 192 | PS_COSMETIC = 0x00000000 193 | PS_GEOMETRIC = 0x00010000 194 | PS_TYPE_MASK = 0x000F0000 195 | ) 196 | 197 | // Pen styles 198 | const ( 199 | PS_SOLID = 0 200 | PS_DASH = 1 201 | PS_DOT = 2 202 | PS_DASHDOT = 3 203 | PS_DASHDOTDOT = 4 204 | PS_NULL = 5 205 | PS_INSIDEFRAME = 6 206 | PS_USERSTYLE = 7 207 | PS_ALTERNATE = 8 208 | PS_STYLE_MASK = 0x0000000F 209 | ) 210 | 211 | // Pen cap types 212 | const ( 213 | PS_ENDCAP_ROUND = 0x00000000 214 | PS_ENDCAP_SQUARE = 0x00000100 215 | PS_ENDCAP_FLAT = 0x00000200 216 | PS_ENDCAP_MASK = 0x00000F00 217 | ) 218 | 219 | // Pen join types 220 | const ( 221 | PS_JOIN_ROUND = 0x00000000 222 | PS_JOIN_BEVEL = 0x00001000 223 | PS_JOIN_MITER = 0x00002000 224 | PS_JOIN_MASK = 0x0000F000 225 | ) 226 | 227 | // Stock logical objects 228 | const ( 229 | WHITE_BRUSH = 0 230 | LTGRAY_BRUSH = 1 231 | GRAY_BRUSH = 2 232 | DKGRAY_BRUSH = 3 233 | BLACK_BRUSH = 4 234 | NULL_BRUSH = 5 235 | HOLLOW_BRUSH = NULL_BRUSH 236 | WHITE_PEN = 6 237 | BLACK_PEN = 7 238 | NULL_PEN = 8 239 | OEM_FIXED_FONT = 10 240 | ANSI_FIXED_FONT = 11 241 | ANSI_VAR_FONT = 12 242 | SYSTEM_FONT = 13 243 | DEVICE_DEFAULT_FONT = 14 244 | DEFAULT_PALETTE = 15 245 | SYSTEM_FIXED_FONT = 16 246 | DEFAULT_GUI_FONT = 17 247 | DC_BRUSH = 18 248 | DC_PEN = 19 249 | ) 250 | 251 | const LF_FACESIZE = 32 252 | 253 | // Font weight constants 254 | const ( 255 | FW_DONTCARE = 0 256 | FW_THIN = 100 257 | FW_EXTRALIGHT = 200 258 | FW_ULTRALIGHT = FW_EXTRALIGHT 259 | FW_LIGHT = 300 260 | FW_NORMAL = 400 261 | FW_REGULAR = 400 262 | FW_MEDIUM = 500 263 | FW_SEMIBOLD = 600 264 | FW_DEMIBOLD = FW_SEMIBOLD 265 | FW_BOLD = 700 266 | FW_EXTRABOLD = 800 267 | FW_ULTRABOLD = FW_EXTRABOLD 268 | FW_HEAVY = 900 269 | FW_BLACK = FW_HEAVY 270 | ) 271 | 272 | // Charset constants 273 | const ( 274 | ANSI_CHARSET = 0 275 | DEFAULT_CHARSET = 1 276 | SYMBOL_CHARSET = 2 277 | SHIFTJIS_CHARSET = 128 278 | HANGEUL_CHARSET = 129 279 | HANGUL_CHARSET = 129 280 | GB2312_CHARSET = 134 281 | CHINESEBIG5_CHARSET = 136 282 | GREEK_CHARSET = 161 283 | TURKISH_CHARSET = 162 284 | HEBREW_CHARSET = 177 285 | ARABIC_CHARSET = 178 286 | BALTIC_CHARSET = 186 287 | RUSSIAN_CHARSET = 204 288 | THAI_CHARSET = 222 289 | EASTEUROPE_CHARSET = 238 290 | OEM_CHARSET = 255 291 | JOHAB_CHARSET = 130 292 | VIETNAMESE_CHARSET = 163 293 | MAC_CHARSET = 77 294 | ) 295 | 296 | // Font output precision constants 297 | const ( 298 | OUT_DEFAULT_PRECIS = 0 299 | OUT_STRING_PRECIS = 1 300 | OUT_CHARACTER_PRECIS = 2 301 | OUT_STROKE_PRECIS = 3 302 | OUT_TT_PRECIS = 4 303 | OUT_DEVICE_PRECIS = 5 304 | OUT_RASTER_PRECIS = 6 305 | OUT_TT_ONLY_PRECIS = 7 306 | OUT_OUTLINE_PRECIS = 8 307 | OUT_PS_ONLY_PRECIS = 10 308 | ) 309 | 310 | // Font clipping precision constants 311 | const ( 312 | CLIP_DEFAULT_PRECIS = 0 313 | CLIP_CHARACTER_PRECIS = 1 314 | CLIP_STROKE_PRECIS = 2 315 | CLIP_MASK = 15 316 | CLIP_LH_ANGLES = 16 317 | CLIP_TT_ALWAYS = 32 318 | CLIP_EMBEDDED = 128 319 | ) 320 | 321 | // Font output quality constants 322 | const ( 323 | DEFAULT_QUALITY = 0 324 | DRAFT_QUALITY = 1 325 | PROOF_QUALITY = 2 326 | NONANTIALIASED_QUALITY = 3 327 | ANTIALIASED_QUALITY = 4 328 | CLEARTYPE_QUALITY = 5 329 | ) 330 | 331 | // Font pitch constants 332 | const ( 333 | DEFAULT_PITCH = 0 334 | FIXED_PITCH = 1 335 | VARIABLE_PITCH = 2 336 | ) 337 | 338 | // Font family constants 339 | const ( 340 | FF_DECORATIVE = 80 341 | FF_DONTCARE = 0 342 | FF_MODERN = 48 343 | FF_ROMAN = 16 344 | FF_SCRIPT = 64 345 | FF_SWISS = 32 346 | ) 347 | 348 | // DeviceCapabilities capabilities 349 | const ( 350 | DC_FIELDS = 1 351 | DC_PAPERS = 2 352 | DC_PAPERSIZE = 3 353 | DC_MINEXTENT = 4 354 | DC_MAXEXTENT = 5 355 | DC_BINS = 6 356 | DC_DUPLEX = 7 357 | DC_SIZE = 8 358 | DC_EXTRA = 9 359 | DC_VERSION = 10 360 | DC_DRIVER = 11 361 | DC_BINNAMES = 12 362 | DC_ENUMRESOLUTIONS = 13 363 | DC_FILEDEPENDENCIES = 14 364 | DC_TRUETYPE = 15 365 | DC_PAPERNAMES = 16 366 | DC_ORIENTATION = 17 367 | DC_COPIES = 18 368 | DC_BINADJUST = 19 369 | DC_EMF_COMPLIANT = 20 370 | DC_DATATYPE_PRODUCED = 21 371 | DC_COLLATE = 22 372 | DC_MANUFACTURER = 23 373 | DC_MODEL = 24 374 | DC_PERSONALITY = 25 375 | DC_PRINTRATE = 26 376 | DC_PRINTRATEUNIT = 27 377 | DC_PRINTERMEM = 28 378 | DC_MEDIAREADY = 29 379 | DC_STAPLE = 30 380 | DC_PRINTRATEPPM = 31 381 | DC_COLORDEVICE = 32 382 | DC_NUP = 33 383 | DC_MEDIATYPENAMES = 34 384 | DC_MEDIATYPES = 35 385 | ) 386 | 387 | const ( 388 | CCHDEVICENAME = 32 389 | CCHFORMNAME = 32 390 | ) 391 | 392 | const ( 393 | DM_UPDATE = 1 394 | DM_COPY = 2 395 | DM_PROMPT = 4 396 | DM_MODIFY = 8 397 | DM_IN_BUFFER = DM_MODIFY 398 | DM_IN_PROMPT = DM_PROMPT 399 | DM_OUT_BUFFER = DM_COPY 400 | DM_OUT_DEFAULT = DM_UPDATE 401 | ) 402 | 403 | // DEVMODE field selection bits 404 | const ( 405 | DM_ORIENTATION = 0x00000001 406 | DM_PAPERSIZE = 0x00000002 407 | DM_PAPERLENGTH = 0x00000004 408 | DM_PAPERWIDTH = 0x00000008 409 | DM_SCALE = 0x00000010 410 | DM_POSITION = 0x00000020 411 | DM_NUP = 0x00000040 412 | DM_DISPLAYORIENTATION = 0x00000080 413 | DM_COPIES = 0x00000100 414 | DM_DEFAULTSOURCE = 0x00000200 415 | DM_PRINTQUALITY = 0x00000400 416 | DM_COLOR = 0x00000800 417 | DM_DUPLEX = 0x00001000 418 | DM_YRESOLUTION = 0x00002000 419 | DM_TTOPTION = 0x00004000 420 | DM_COLLATE = 0x00008000 421 | DM_FORMNAME = 0x00010000 422 | DM_LOGPIXELS = 0x00020000 423 | DM_BITSPERPEL = 0x00040000 424 | DM_PELSWIDTH = 0x00080000 425 | DM_PELSHEIGHT = 0x00100000 426 | DM_DISPLAYFLAGS = 0x00200000 427 | DM_DISPLAYFREQUENCY = 0x00400000 428 | DM_ICMMETHOD = 0x00800000 429 | DM_ICMINTENT = 0x01000000 430 | DM_MEDIATYPE = 0x02000000 431 | DM_DITHERTYPE = 0x04000000 432 | DM_PANNINGWIDTH = 0x08000000 433 | DM_PANNINGHEIGHT = 0x10000000 434 | DM_DISPLAYFIXEDOUTPUT = 0x20000000 435 | ) 436 | 437 | // Orientation constants 438 | const ( 439 | DMORIENT_PORTRAIT = 1 440 | DMORIENT_LANDSCAPE = 2 441 | ) 442 | 443 | // Paper sizes 444 | const ( 445 | DMPAPER_FIRST = DMPAPER_LETTER 446 | DMPAPER_LETTER = 1 /* Letter 8 1/2 x 11 in */ 447 | DMPAPER_LETTERSMALL = 2 /* Letter Small 8 1/2 x 11 in */ 448 | DMPAPER_TABLOID = 3 /* Tabloid 11 x 17 in */ 449 | DMPAPER_LEDGER = 4 /* Ledger 17 x 11 in */ 450 | DMPAPER_LEGAL = 5 /* Legal 8 1/2 x 14 in */ 451 | DMPAPER_STATEMENT = 6 /* Statement 5 1/2 x 8 1/2 in */ 452 | DMPAPER_EXECUTIVE = 7 /* Executive 7 1/4 x 10 1/2 in */ 453 | DMPAPER_A3 = 8 /* A3 297 x 420 mm */ 454 | DMPAPER_A4 = 9 /* A4 210 x 297 mm */ 455 | DMPAPER_A4SMALL = 10 /* A4 Small 210 x 297 mm */ 456 | DMPAPER_A5 = 11 /* A5 148 x 210 mm */ 457 | DMPAPER_B4 = 12 /* B4 (JIS) 250 x 354 */ 458 | DMPAPER_B5 = 13 /* B5 (JIS) 182 x 257 mm */ 459 | DMPAPER_FOLIO = 14 /* Folio 8 1/2 x 13 in */ 460 | DMPAPER_QUARTO = 15 /* Quarto 215 x 275 mm */ 461 | DMPAPER_10X14 = 16 /* 10x14 in */ 462 | DMPAPER_11X17 = 17 /* 11x17 in */ 463 | DMPAPER_NOTE = 18 /* Note 8 1/2 x 11 in */ 464 | DMPAPER_ENV_9 = 19 /* Envelope #9 3 7/8 x 8 7/8 */ 465 | DMPAPER_ENV_10 = 20 /* Envelope #10 4 1/8 x 9 1/2 */ 466 | DMPAPER_ENV_11 = 21 /* Envelope #11 4 1/2 x 10 3/8 */ 467 | DMPAPER_ENV_12 = 22 /* Envelope #12 4 \276 x 11 */ 468 | DMPAPER_ENV_14 = 23 /* Envelope #14 5 x 11 1/2 */ 469 | DMPAPER_CSHEET = 24 /* C size sheet */ 470 | DMPAPER_DSHEET = 25 /* D size sheet */ 471 | DMPAPER_ESHEET = 26 /* E size sheet */ 472 | DMPAPER_ENV_DL = 27 /* Envelope DL 110 x 220mm */ 473 | DMPAPER_ENV_C5 = 28 /* Envelope C5 162 x 229 mm */ 474 | DMPAPER_ENV_C3 = 29 /* Envelope C3 324 x 458 mm */ 475 | DMPAPER_ENV_C4 = 30 /* Envelope C4 229 x 324 mm */ 476 | DMPAPER_ENV_C6 = 31 /* Envelope C6 114 x 162 mm */ 477 | DMPAPER_ENV_C65 = 32 /* Envelope C65 114 x 229 mm */ 478 | DMPAPER_ENV_B4 = 33 /* Envelope B4 250 x 353 mm */ 479 | DMPAPER_ENV_B5 = 34 /* Envelope B5 176 x 250 mm */ 480 | DMPAPER_ENV_B6 = 35 /* Envelope B6 176 x 125 mm */ 481 | DMPAPER_ENV_ITALY = 36 /* Envelope 110 x 230 mm */ 482 | DMPAPER_ENV_MONARCH = 37 /* Envelope Monarch 3.875 x 7.5 in */ 483 | DMPAPER_ENV_PERSONAL = 38 /* 6 3/4 Envelope 3 5/8 x 6 1/2 in */ 484 | DMPAPER_FANFOLD_US = 39 /* US Std Fanfold 14 7/8 x 11 in */ 485 | DMPAPER_FANFOLD_STD_GERMAN = 40 /* German Std Fanfold 8 1/2 x 12 in */ 486 | DMPAPER_FANFOLD_LGL_GERMAN = 41 /* German Legal Fanfold 8 1/2 x 13 in */ 487 | DMPAPER_ISO_B4 = 42 /* B4 (ISO) 250 x 353 mm */ 488 | DMPAPER_JAPANESE_POSTCARD = 43 /* Japanese Postcard 100 x 148 mm */ 489 | DMPAPER_9X11 = 44 /* 9 x 11 in */ 490 | DMPAPER_10X11 = 45 /* 10 x 11 in */ 491 | DMPAPER_15X11 = 46 /* 15 x 11 in */ 492 | DMPAPER_ENV_INVITE = 47 /* Envelope Invite 220 x 220 mm */ 493 | DMPAPER_RESERVED_48 = 48 /* RESERVED--DO NOT USE */ 494 | DMPAPER_RESERVED_49 = 49 /* RESERVED--DO NOT USE */ 495 | DMPAPER_LETTER_EXTRA = 50 /* Letter Extra 9 \275 x 12 in */ 496 | DMPAPER_LEGAL_EXTRA = 51 /* Legal Extra 9 \275 x 15 in */ 497 | DMPAPER_TABLOID_EXTRA = 52 /* Tabloid Extra 11.69 x 18 in */ 498 | DMPAPER_A4_EXTRA = 53 /* A4 Extra 9.27 x 12.69 in */ 499 | DMPAPER_LETTER_TRANSVERSE = 54 /* Letter Transverse 8 \275 x 11 in */ 500 | DMPAPER_A4_TRANSVERSE = 55 /* A4 Transverse 210 x 297 mm */ 501 | DMPAPER_LETTER_EXTRA_TRANSVERSE = 56 /* Letter Extra Transverse 9\275 x 12 in */ 502 | DMPAPER_A_PLUS = 57 /* SuperA/SuperA/A4 227 x 356 mm */ 503 | DMPAPER_B_PLUS = 58 /* SuperB/SuperB/A3 305 x 487 mm */ 504 | DMPAPER_LETTER_PLUS = 59 /* Letter Plus 8.5 x 12.69 in */ 505 | DMPAPER_A4_PLUS = 60 /* A4 Plus 210 x 330 mm */ 506 | DMPAPER_A5_TRANSVERSE = 61 /* A5 Transverse 148 x 210 mm */ 507 | DMPAPER_B5_TRANSVERSE = 62 /* B5 (JIS) Transverse 182 x 257 mm */ 508 | DMPAPER_A3_EXTRA = 63 /* A3 Extra 322 x 445 mm */ 509 | DMPAPER_A5_EXTRA = 64 /* A5 Extra 174 x 235 mm */ 510 | DMPAPER_B5_EXTRA = 65 /* B5 (ISO) Extra 201 x 276 mm */ 511 | DMPAPER_A2 = 66 /* A2 420 x 594 mm */ 512 | DMPAPER_A3_TRANSVERSE = 67 /* A3 Transverse 297 x 420 mm */ 513 | DMPAPER_A3_EXTRA_TRANSVERSE = 68 /* A3 Extra Transverse 322 x 445 mm */ 514 | DMPAPER_DBL_JAPANESE_POSTCARD = 69 /* Japanese Double Postcard 200 x 148 mm */ 515 | DMPAPER_A6 = 70 /* A6 105 x 148 mm */ 516 | DMPAPER_JENV_KAKU2 = 71 /* Japanese Envelope Kaku #2 */ 517 | DMPAPER_JENV_KAKU3 = 72 /* Japanese Envelope Kaku #3 */ 518 | DMPAPER_JENV_CHOU3 = 73 /* Japanese Envelope Chou #3 */ 519 | DMPAPER_JENV_CHOU4 = 74 /* Japanese Envelope Chou #4 */ 520 | DMPAPER_LETTER_ROTATED = 75 /* Letter Rotated 11 x 8 1/2 11 in */ 521 | DMPAPER_A3_ROTATED = 76 /* A3 Rotated 420 x 297 mm */ 522 | DMPAPER_A4_ROTATED = 77 /* A4 Rotated 297 x 210 mm */ 523 | DMPAPER_A5_ROTATED = 78 /* A5 Rotated 210 x 148 mm */ 524 | DMPAPER_B4_JIS_ROTATED = 79 /* B4 (JIS) Rotated 364 x 257 mm */ 525 | DMPAPER_B5_JIS_ROTATED = 80 /* B5 (JIS) Rotated 257 x 182 mm */ 526 | DMPAPER_JAPANESE_POSTCARD_ROTATED = 81 /* Japanese Postcard Rotated 148 x 100 mm */ 527 | DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED = 82 /* Double Japanese Postcard Rotated 148 x 200 mm */ 528 | DMPAPER_A6_ROTATED = 83 /* A6 Rotated 148 x 105 mm */ 529 | DMPAPER_JENV_KAKU2_ROTATED = 84 /* Japanese Envelope Kaku #2 Rotated */ 530 | DMPAPER_JENV_KAKU3_ROTATED = 85 /* Japanese Envelope Kaku #3 Rotated */ 531 | DMPAPER_JENV_CHOU3_ROTATED = 86 /* Japanese Envelope Chou #3 Rotated */ 532 | DMPAPER_JENV_CHOU4_ROTATED = 87 /* Japanese Envelope Chou #4 Rotated */ 533 | DMPAPER_B6_JIS = 88 /* B6 (JIS) 128 x 182 mm */ 534 | DMPAPER_B6_JIS_ROTATED = 89 /* B6 (JIS) Rotated 182 x 128 mm */ 535 | DMPAPER_12X11 = 90 /* 12 x 11 in */ 536 | DMPAPER_JENV_YOU4 = 91 /* Japanese Envelope You #4 */ 537 | DMPAPER_JENV_YOU4_ROTATED = 92 /* Japanese Envelope You #4 Rotated*/ 538 | DMPAPER_P16K = 93 /* PRC 16K 146 x 215 mm */ 539 | DMPAPER_P32K = 94 /* PRC 32K 97 x 151 mm */ 540 | DMPAPER_P32KBIG = 95 /* PRC 32K(Big) 97 x 151 mm */ 541 | DMPAPER_PENV_1 = 96 /* PRC Envelope #1 102 x 165 mm */ 542 | DMPAPER_PENV_2 = 97 /* PRC Envelope #2 102 x 176 mm */ 543 | DMPAPER_PENV_3 = 98 /* PRC Envelope #3 125 x 176 mm */ 544 | DMPAPER_PENV_4 = 99 /* PRC Envelope #4 110 x 208 mm */ 545 | DMPAPER_PENV_5 = 100 /* PRC Envelope #5 110 x 220 mm */ 546 | DMPAPER_PENV_6 = 101 /* PRC Envelope #6 120 x 230 mm */ 547 | DMPAPER_PENV_7 = 102 /* PRC Envelope #7 160 x 230 mm */ 548 | DMPAPER_PENV_8 = 103 /* PRC Envelope #8 120 x 309 mm */ 549 | DMPAPER_PENV_9 = 104 /* PRC Envelope #9 229 x 324 mm */ 550 | DMPAPER_PENV_10 = 105 /* PRC Envelope #10 324 x 458 mm */ 551 | DMPAPER_P16K_ROTATED = 106 /* PRC 16K Rotated */ 552 | DMPAPER_P32K_ROTATED = 107 /* PRC 32K Rotated */ 553 | DMPAPER_P32KBIG_ROTATED = 108 /* PRC 32K(Big) Rotated */ 554 | DMPAPER_PENV_1_ROTATED = 109 /* PRC Envelope #1 Rotated 165 x 102 mm */ 555 | DMPAPER_PENV_2_ROTATED = 110 /* PRC Envelope #2 Rotated 176 x 102 mm */ 556 | DMPAPER_PENV_3_ROTATED = 111 /* PRC Envelope #3 Rotated 176 x 125 mm */ 557 | DMPAPER_PENV_4_ROTATED = 112 /* PRC Envelope #4 Rotated 208 x 110 mm */ 558 | DMPAPER_PENV_5_ROTATED = 113 /* PRC Envelope #5 Rotated 220 x 110 mm */ 559 | DMPAPER_PENV_6_ROTATED = 114 /* PRC Envelope #6 Rotated 230 x 120 mm */ 560 | DMPAPER_PENV_7_ROTATED = 115 /* PRC Envelope #7 Rotated 230 x 160 mm */ 561 | DMPAPER_PENV_8_ROTATED = 116 /* PRC Envelope #8 Rotated 309 x 120 mm */ 562 | DMPAPER_PENV_9_ROTATED = 117 /* PRC Envelope #9 Rotated 324 x 229 mm */ 563 | DMPAPER_PENV_10_ROTATED = 118 /* PRC Envelope #10 Rotated 458 x 324 mm */ 564 | DMPAPER_LAST = DMPAPER_PENV_10_ROTATED 565 | DMPAPER_USER = 256 566 | ) 567 | 568 | // Bin constants 569 | const ( 570 | DMBIN_FIRST = DMBIN_UPPER 571 | DMBIN_UPPER = 1 572 | DMBIN_ONLYONE = 1 573 | DMBIN_LOWER = 2 574 | DMBIN_MIDDLE = 3 575 | DMBIN_MANUAL = 4 576 | DMBIN_ENVELOPE = 5 577 | DMBIN_ENVMANUAL = 6 578 | DMBIN_AUTO = 7 579 | DMBIN_TRACTOR = 8 580 | DMBIN_SMALLFMT = 9 581 | DMBIN_LARGEFMT = 10 582 | DMBIN_LARGECAPACITY = 11 583 | DMBIN_CASSETTE = 14 584 | DMBIN_FORMSOURCE = 15 585 | DMBIN_LAST = DMBIN_FORMSOURCE 586 | DMBIN_USER = 256 587 | ) 588 | 589 | // Quality constants 590 | const ( 591 | DMRES_DRAFT = -1 592 | DMRES_LOW = -2 593 | DMRES_MEDIUM = -3 594 | DMRES_HIGH = -4 595 | ) 596 | 597 | // Color/monochrome constants 598 | const ( 599 | DMCOLOR_MONOCHROME = 1 600 | DMCOLOR_COLOR = 2 601 | ) 602 | 603 | // Duplex constants 604 | const ( 605 | DMDUP_SIMPLEX = 1 606 | DMDUP_VERTICAL = 2 607 | DMDUP_HORIZONTAL = 3 608 | ) 609 | 610 | // TrueType constants 611 | const ( 612 | DMTT_BITMAP = 1 613 | DMTT_DOWNLOAD = 2 614 | DMTT_SUBDEV = 3 615 | DMTT_DOWNLOAD_OUTLINE = 4 616 | ) 617 | 618 | // Collation constants 619 | const ( 620 | DMCOLLATE_FALSE = 0 621 | DMCOLLATE_TRUE = 1 622 | ) 623 | 624 | // Background modes 625 | const ( 626 | TRANSPARENT = 1 627 | OPAQUE = 2 628 | ) 629 | 630 | // Ternary raster operations 631 | const ( 632 | SRCCOPY = 0x00CC0020 633 | SRCPAINT = 0x00EE0086 634 | SRCAND = 0x008800C6 635 | SRCINVERT = 0x00660046 636 | SRCERASE = 0x00440328 637 | NOTSRCCOPY = 0x00330008 638 | NOTSRCERASE = 0x001100A6 639 | MERGECOPY = 0x00C000CA 640 | MERGEPAINT = 0x00BB0226 641 | PATCOPY = 0x00F00021 642 | PATPAINT = 0x00FB0A09 643 | PATINVERT = 0x005A0049 644 | DSTINVERT = 0x00550009 645 | BLACKNESS = 0x00000042 646 | WHITENESS = 0x00FF0062 647 | NOMIRRORBITMAP = 0x80000000 648 | CAPTUREBLT = 0x40000000 649 | ) 650 | 651 | // StretchBlt modes 652 | const ( 653 | BLACKONWHITE = 1 654 | WHITEONBLACK = 2 655 | COLORONCOLOR = 3 656 | HALFTONE = 4 657 | MAXSTRETCHBLTMODE = 4 658 | STRETCH_ANDSCANS = BLACKONWHITE 659 | STRETCH_ORSCANS = WHITEONBLACK 660 | STRETCH_DELETESCANS = COLORONCOLOR 661 | STRETCH_HALFTONE = HALFTONE 662 | ) 663 | 664 | // Bitmap compression constants 665 | const ( 666 | BI_RGB = 0 667 | BI_RLE8 = 1 668 | BI_RLE4 = 2 669 | BI_BITFIELDS = 3 670 | BI_JPEG = 4 671 | BI_PNG = 5 672 | ) 673 | 674 | // Bitmap color table usage 675 | const ( 676 | DIB_RGB_COLORS = 0 677 | DIB_PAL_COLORS = 1 678 | ) 679 | 680 | const CBM_INIT = 4 681 | 682 | const CLR_INVALID = 0xFFFFFFFF 683 | 684 | const ( 685 | /* pixel types */ 686 | PFD_TYPE_RGBA = 0 687 | PFD_TYPE_COLORINDEX = 1 688 | 689 | /* layer types */ 690 | PFD_MAIN_PLANE = 0 691 | PFD_OVERLAY_PLANE = 1 692 | PFD_UNDERLAY_PLANE = (-1) 693 | 694 | /* PIXELFORMATDESCRIPTOR flags */ 695 | PFD_DOUBLEBUFFER = 0x00000001 696 | PFD_STEREO = 0x00000002 697 | PFD_DRAW_TO_WINDOW = 0x00000004 698 | PFD_DRAW_TO_BITMAP = 0x00000008 699 | PFD_SUPPORT_GDI = 0x00000010 700 | PFD_SUPPORT_OPENGL = 0x00000020 701 | PFD_GENERIC_FORMAT = 0x00000040 702 | PFD_NEED_PALETTE = 0x00000080 703 | PFD_NEED_SYSTEM_PALETTE = 0x00000100 704 | PFD_SWAP_EXCHANGE = 0x00000200 705 | PFD_SWAP_COPY = 0x00000400 706 | PFD_SWAP_LAYER_BUFFERS = 0x00000800 707 | PFD_GENERIC_ACCELERATED = 0x00001000 708 | PFD_SUPPORT_DIRECTDRAW = 0x00002000 709 | 710 | /* PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only */ 711 | PFD_DEPTH_DONTCARE = 0x20000000 712 | PFD_DOUBLEBUFFER_DONTCARE = 0x40000000 713 | PFD_STEREO_DONTCARE = 0x80000000 714 | ) 715 | 716 | type ( 717 | COLORREF uint32 718 | HBITMAP HGDIOBJ 719 | HBRUSH HGDIOBJ 720 | HDC HANDLE 721 | HFONT HGDIOBJ 722 | HGDIOBJ HANDLE 723 | HENHMETAFILE HANDLE 724 | HPALETTE HGDIOBJ 725 | HPEN HGDIOBJ 726 | HREGION HGDIOBJ 727 | ) 728 | 729 | type PIXELFORMATDESCRIPTOR struct { 730 | NSize uint16 731 | NVersion uint16 732 | DwFlags uint32 733 | IPixelType byte 734 | CColorBits byte 735 | CRedBits byte 736 | CRedShift byte 737 | CGreenBits byte 738 | CGreenShift byte 739 | CBlueBits byte 740 | CBlueShift byte 741 | CAlphaBits byte 742 | CAlphaShift byte 743 | CAccumBits byte 744 | CAccumRedBits byte 745 | CAccumGreenBits byte 746 | CAccumBlueBits byte 747 | CAccumAlphaBits byte 748 | CDepthBits byte 749 | CStencilBits byte 750 | CAuxBuffers byte 751 | ILayerType byte 752 | BReserved byte 753 | DwLayerMask uint32 754 | DwVisibleMask uint32 755 | DwDamageMask uint32 756 | } 757 | 758 | type LOGFONT struct { 759 | LfHeight int32 760 | LfWidth int32 761 | LfEscapement int32 762 | LfOrientation int32 763 | LfWeight int32 764 | LfItalic byte 765 | LfUnderline byte 766 | LfStrikeOut byte 767 | LfCharSet byte 768 | LfOutPrecision byte 769 | LfClipPrecision byte 770 | LfQuality byte 771 | LfPitchAndFamily byte 772 | LfFaceName [LF_FACESIZE]uint16 773 | } 774 | 775 | type TEXTMETRIC struct { 776 | TmHeight int32 777 | TmAscent int32 778 | TmDescent int32 779 | TmInternalLeading int32 780 | TmExternalLeading int32 781 | TmAveCharWidth int32 782 | TmMaxCharWidth int32 783 | TmWeight int32 784 | TmOverhang int32 785 | TmDigitizedAspectX int32 786 | TmDigitizedAspectY int32 787 | TmFirstChar uint16 788 | TmLastChar uint16 789 | TmDefaultChar uint16 790 | TmBreakChar uint16 791 | TmItalic byte 792 | TmUnderlined byte 793 | TmStruckOut byte 794 | TmPitchAndFamily byte 795 | TmCharSet byte 796 | } 797 | 798 | type DEVMODE struct { 799 | DmDeviceName [CCHDEVICENAME]uint16 800 | DmSpecVersion uint16 801 | DmDriverVersion uint16 802 | DmSize uint16 803 | DmDriverExtra uint16 804 | DmFields uint32 805 | DmOrientation int16 806 | DmPaperSize int16 807 | DmPaperLength int16 808 | DmPaperWidth int16 809 | DmScale int16 810 | DmCopies int16 811 | DmDefaultSource int16 812 | DmPrintQuality int16 813 | DmColor int16 814 | DmDuplex int16 815 | DmYResolution int16 816 | DmTTOption int16 817 | DmCollate int16 818 | DmFormName [CCHFORMNAME]uint16 819 | DmLogPixels uint16 820 | DmBitsPerPel uint32 821 | DmPelsWidth uint32 822 | DmPelsHeight uint32 823 | DmDisplayFlags uint32 824 | DmDisplayFrequency uint32 825 | DmICMMethod uint32 826 | DmICMIntent uint32 827 | DmMediaType uint32 828 | DmDitherType uint32 829 | DmReserved1 uint32 830 | DmReserved2 uint32 831 | DmPanningWidth uint32 832 | DmPanningHeight uint32 833 | } 834 | 835 | type POINT struct { 836 | X, Y int32 837 | } 838 | 839 | type RECT struct { 840 | Left, Top, Right, Bottom int32 841 | } 842 | 843 | type SIZE struct { 844 | CX, CY int32 845 | } 846 | 847 | type DOCINFO struct { 848 | CbSize int32 849 | LpszDocName *uint16 850 | LpszOutput *uint16 851 | LpszDatatype *uint16 852 | FwType uint32 853 | } 854 | 855 | type LOGBRUSH struct { 856 | LbStyle uint32 857 | LbColor COLORREF 858 | LbHatch uintptr 859 | } 860 | 861 | type BITMAPINFOHEADER struct { 862 | BiSize uint32 863 | BiWidth int32 864 | BiHeight int32 865 | BiPlanes uint16 866 | BiBitCount uint16 867 | BiCompression uint32 868 | BiSizeImage uint32 869 | BiXPelsPerMeter int32 870 | BiYPelsPerMeter int32 871 | BiClrUsed uint32 872 | BiClrImportant uint32 873 | } 874 | 875 | type RGBQUAD struct { 876 | RgbBlue byte 877 | RgbGreen byte 878 | RgbRed byte 879 | RgbReserved byte 880 | } 881 | 882 | type BITMAPINFO struct { 883 | BmiHeader BITMAPINFOHEADER 884 | BmiColors *RGBQUAD 885 | } 886 | 887 | type BITMAP struct { 888 | BmType int32 889 | BmWidth int32 890 | BmHeight int32 891 | BmWidthBytes int32 892 | BmPlanes uint16 893 | BmBitsPixel uint16 894 | BmBits unsafe.Pointer 895 | } 896 | 897 | type DIBSECTION struct { 898 | DsBm BITMAP 899 | DsBmih BITMAPINFOHEADER 900 | DsBitfields [3]uint32 901 | DshSection HANDLE 902 | DsOffset uint32 903 | } 904 | 905 | type ENHMETAHEADER struct { 906 | IType uint32 907 | NSize uint32 908 | RclBounds RECT 909 | RclFrame RECT 910 | DSignature uint32 911 | NVersion uint32 912 | NBytes uint32 913 | NRecords uint32 914 | NHandles uint16 915 | SReserved uint16 916 | NDescription uint32 917 | OffDescription uint32 918 | NPalEntries uint32 919 | SzlDevice SIZE 920 | SzlMillimeters SIZE 921 | CbPixelFormat uint32 922 | OffPixelFormat uint32 923 | BOpenGL uint32 924 | SzlMicrometers SIZE 925 | } 926 | 927 | var ( 928 | // Library 929 | libgdi32 uintptr 930 | 931 | // Functions 932 | abortDoc uintptr 933 | bitBlt uintptr 934 | choosePixelFormat uintptr 935 | closeEnhMetaFile uintptr 936 | copyEnhMetaFile uintptr 937 | createBrushIndirect uintptr 938 | createCompatibleDC uintptr 939 | createDC uintptr 940 | createDIBSection uintptr 941 | createFontIndirect uintptr 942 | createEnhMetaFile uintptr 943 | createIC uintptr 944 | deleteDC uintptr 945 | deleteEnhMetaFile uintptr 946 | deleteObject uintptr 947 | ellipse uintptr 948 | endDoc uintptr 949 | endPage uintptr 950 | extCreatePen uintptr 951 | getDeviceCaps uintptr 952 | getEnhMetaFile uintptr 953 | getEnhMetaFileHeader uintptr 954 | getObject uintptr 955 | getStockObject uintptr 956 | getTextExtentExPoint uintptr 957 | getTextExtentPoint32 uintptr 958 | getTextMetrics uintptr 959 | lineTo uintptr 960 | moveToEx uintptr 961 | playEnhMetaFile uintptr 962 | rectangle uintptr 963 | resetDC uintptr 964 | selectObject uintptr 965 | setBkMode uintptr 966 | setBrushOrgEx uintptr 967 | setPixelFormat uintptr 968 | setStretchBltMode uintptr 969 | setTextColor uintptr 970 | startDoc uintptr 971 | startPage uintptr 972 | stretchBlt uintptr 973 | swapBuffers uintptr 974 | ) 975 | 976 | func init() { 977 | // Library 978 | libgdi32 = MustLoadLibrary("gdi32.dll") 979 | 980 | // Functions 981 | abortDoc = MustGetProcAddress(libgdi32, "AbortDoc") 982 | bitBlt = MustGetProcAddress(libgdi32, "BitBlt") 983 | choosePixelFormat = MustGetProcAddress(libgdi32, "ChoosePixelFormat") 984 | closeEnhMetaFile = MustGetProcAddress(libgdi32, "CloseEnhMetaFile") 985 | copyEnhMetaFile = MustGetProcAddress(libgdi32, "CopyEnhMetaFileW") 986 | createBrushIndirect = MustGetProcAddress(libgdi32, "CreateBrushIndirect") 987 | createCompatibleDC = MustGetProcAddress(libgdi32, "CreateCompatibleDC") 988 | createDC = MustGetProcAddress(libgdi32, "CreateDCW") 989 | createDIBSection = MustGetProcAddress(libgdi32, "CreateDIBSection") 990 | createEnhMetaFile = MustGetProcAddress(libgdi32, "CreateEnhMetaFileW") 991 | createFontIndirect = MustGetProcAddress(libgdi32, "CreateFontIndirectW") 992 | createIC = MustGetProcAddress(libgdi32, "CreateICW") 993 | deleteDC = MustGetProcAddress(libgdi32, "DeleteDC") 994 | deleteEnhMetaFile = MustGetProcAddress(libgdi32, "DeleteEnhMetaFile") 995 | deleteObject = MustGetProcAddress(libgdi32, "DeleteObject") 996 | ellipse = MustGetProcAddress(libgdi32, "Ellipse") 997 | endDoc = MustGetProcAddress(libgdi32, "EndDoc") 998 | endPage = MustGetProcAddress(libgdi32, "EndPage") 999 | extCreatePen = MustGetProcAddress(libgdi32, "ExtCreatePen") 1000 | getDeviceCaps = MustGetProcAddress(libgdi32, "GetDeviceCaps") 1001 | getEnhMetaFile = MustGetProcAddress(libgdi32, "GetEnhMetaFileW") 1002 | getEnhMetaFileHeader = MustGetProcAddress(libgdi32, "GetEnhMetaFileHeader") 1003 | getObject = MustGetProcAddress(libgdi32, "GetObjectW") 1004 | getStockObject = MustGetProcAddress(libgdi32, "GetStockObject") 1005 | getTextExtentExPoint = MustGetProcAddress(libgdi32, "GetTextExtentExPointW") 1006 | getTextExtentPoint32 = MustGetProcAddress(libgdi32, "GetTextExtentPoint32W") 1007 | getTextMetrics = MustGetProcAddress(libgdi32, "GetTextMetricsW") 1008 | lineTo = MustGetProcAddress(libgdi32, "LineTo") 1009 | moveToEx = MustGetProcAddress(libgdi32, "MoveToEx") 1010 | playEnhMetaFile = MustGetProcAddress(libgdi32, "PlayEnhMetaFile") 1011 | rectangle = MustGetProcAddress(libgdi32, "Rectangle") 1012 | resetDC = MustGetProcAddress(libgdi32, "ResetDCW") 1013 | selectObject = MustGetProcAddress(libgdi32, "SelectObject") 1014 | setBkMode = MustGetProcAddress(libgdi32, "SetBkMode") 1015 | setBrushOrgEx = MustGetProcAddress(libgdi32, "SetBrushOrgEx") 1016 | setPixelFormat = MustGetProcAddress(libgdi32, "SetPixelFormat") 1017 | setStretchBltMode = MustGetProcAddress(libgdi32, "SetStretchBltMode") 1018 | setTextColor = MustGetProcAddress(libgdi32, "SetTextColor") 1019 | startDoc = MustGetProcAddress(libgdi32, "StartDocW") 1020 | startPage = MustGetProcAddress(libgdi32, "StartPage") 1021 | stretchBlt = MustGetProcAddress(libgdi32, "StretchBlt") 1022 | swapBuffers = MustGetProcAddress(libgdi32, "SwapBuffers") 1023 | } 1024 | 1025 | func AbortDoc(hdc HDC) int32 { 1026 | ret, _, _ := syscall.Syscall(abortDoc, 1, 1027 | uintptr(hdc), 1028 | 0, 1029 | 0) 1030 | 1031 | return int32(ret) 1032 | } 1033 | 1034 | func BitBlt(hdcDest HDC, nXDest, nYDest, nWidth, nHeight int32, hdcSrc HDC, nXSrc, nYSrc int32, dwRop uint32) bool { 1035 | ret, _, _ := syscall.Syscall9(bitBlt, 9, 1036 | uintptr(hdcDest), 1037 | uintptr(nXDest), 1038 | uintptr(nYDest), 1039 | uintptr(nWidth), 1040 | uintptr(nHeight), 1041 | uintptr(hdcSrc), 1042 | uintptr(nXSrc), 1043 | uintptr(nYSrc), 1044 | uintptr(dwRop)) 1045 | 1046 | return ret != 0 1047 | } 1048 | 1049 | func ChoosePixelFormat(hdc HDC, ppfd *PIXELFORMATDESCRIPTOR) int32 { 1050 | ret, _, _ := syscall.Syscall(choosePixelFormat, 2, 1051 | uintptr(hdc), 1052 | uintptr(unsafe.Pointer(ppfd)), 1053 | 0) 1054 | 1055 | return int32(ret) 1056 | } 1057 | 1058 | func CloseEnhMetaFile(hdc HDC) HENHMETAFILE { 1059 | ret, _, _ := syscall.Syscall(closeEnhMetaFile, 1, 1060 | uintptr(hdc), 1061 | 0, 1062 | 0) 1063 | 1064 | return HENHMETAFILE(ret) 1065 | } 1066 | 1067 | func CopyEnhMetaFile(hemfSrc HENHMETAFILE, lpszFile *uint16) HENHMETAFILE { 1068 | ret, _, _ := syscall.Syscall(copyEnhMetaFile, 2, 1069 | uintptr(hemfSrc), 1070 | uintptr(unsafe.Pointer(lpszFile)), 1071 | 0) 1072 | 1073 | return HENHMETAFILE(ret) 1074 | } 1075 | 1076 | func CreateBrushIndirect(lplb *LOGBRUSH) HBRUSH { 1077 | ret, _, _ := syscall.Syscall(createBrushIndirect, 1, 1078 | uintptr(unsafe.Pointer(lplb)), 1079 | 0, 1080 | 0) 1081 | 1082 | return HBRUSH(ret) 1083 | } 1084 | 1085 | func CreateCompatibleDC(hdc HDC) HDC { 1086 | ret, _, _ := syscall.Syscall(createCompatibleDC, 1, 1087 | uintptr(hdc), 1088 | 0, 1089 | 0) 1090 | 1091 | return HDC(ret) 1092 | } 1093 | 1094 | func CreateDC(lpszDriver, lpszDevice, lpszOutput *uint16, lpInitData *DEVMODE) HDC { 1095 | ret, _, _ := syscall.Syscall6(createDC, 4, 1096 | uintptr(unsafe.Pointer(lpszDriver)), 1097 | uintptr(unsafe.Pointer(lpszDevice)), 1098 | uintptr(unsafe.Pointer(lpszOutput)), 1099 | uintptr(unsafe.Pointer(lpInitData)), 1100 | 0, 1101 | 0) 1102 | 1103 | return HDC(ret) 1104 | } 1105 | 1106 | func CreateDIBSection(hdc HDC, pbmi *BITMAPINFO, iUsage uint32, ppvBits *unsafe.Pointer, hSection HANDLE, dwOffset uint32) HBITMAP { 1107 | ret, _, _ := syscall.Syscall6(createDIBSection, 6, 1108 | uintptr(hdc), 1109 | uintptr(unsafe.Pointer(pbmi)), 1110 | uintptr(iUsage), 1111 | uintptr(unsafe.Pointer(ppvBits)), 1112 | uintptr(hSection), 1113 | uintptr(dwOffset)) 1114 | 1115 | return HBITMAP(ret) 1116 | } 1117 | 1118 | func CreateEnhMetaFile(hdcRef HDC, lpFilename *uint16, lpRect *RECT, lpDescription *uint16) HDC { 1119 | ret, _, _ := syscall.Syscall6(createEnhMetaFile, 4, 1120 | uintptr(hdcRef), 1121 | uintptr(unsafe.Pointer(lpFilename)), 1122 | uintptr(unsafe.Pointer(lpRect)), 1123 | uintptr(unsafe.Pointer(lpDescription)), 1124 | 0, 1125 | 0) 1126 | 1127 | return HDC(ret) 1128 | } 1129 | 1130 | func CreateFontIndirect(lplf *LOGFONT) HFONT { 1131 | ret, _, _ := syscall.Syscall(createFontIndirect, 1, 1132 | uintptr(unsafe.Pointer(lplf)), 1133 | 0, 1134 | 0) 1135 | 1136 | return HFONT(ret) 1137 | } 1138 | 1139 | func CreateIC(lpszDriver, lpszDevice, lpszOutput *uint16, lpdvmInit *DEVMODE) HDC { 1140 | ret, _, _ := syscall.Syscall6(createIC, 4, 1141 | uintptr(unsafe.Pointer(lpszDriver)), 1142 | uintptr(unsafe.Pointer(lpszDevice)), 1143 | uintptr(unsafe.Pointer(lpszOutput)), 1144 | uintptr(unsafe.Pointer(lpdvmInit)), 1145 | 0, 1146 | 0) 1147 | 1148 | return HDC(ret) 1149 | } 1150 | 1151 | func DeleteDC(hdc HDC) bool { 1152 | ret, _, _ := syscall.Syscall(deleteDC, 1, 1153 | uintptr(hdc), 1154 | 0, 1155 | 0) 1156 | 1157 | return ret != 0 1158 | } 1159 | 1160 | func DeleteEnhMetaFile(hemf HENHMETAFILE) bool { 1161 | ret, _, _ := syscall.Syscall(deleteEnhMetaFile, 1, 1162 | uintptr(hemf), 1163 | 0, 1164 | 0) 1165 | 1166 | return ret != 0 1167 | } 1168 | 1169 | func DeleteObject(hObject HGDIOBJ) bool { 1170 | ret, _, _ := syscall.Syscall(deleteObject, 1, 1171 | uintptr(hObject), 1172 | 0, 1173 | 0) 1174 | 1175 | return ret != 0 1176 | } 1177 | 1178 | func Ellipse(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool { 1179 | ret, _, _ := syscall.Syscall6(ellipse, 5, 1180 | uintptr(hdc), 1181 | uintptr(nLeftRect), 1182 | uintptr(nTopRect), 1183 | uintptr(nRightRect), 1184 | uintptr(nBottomRect), 1185 | 0) 1186 | 1187 | return ret != 0 1188 | } 1189 | 1190 | func EndDoc(hdc HDC) int32 { 1191 | ret, _, _ := syscall.Syscall(endDoc, 1, 1192 | uintptr(hdc), 1193 | 0, 1194 | 0) 1195 | 1196 | return int32(ret) 1197 | } 1198 | 1199 | func EndPage(hdc HDC) int32 { 1200 | ret, _, _ := syscall.Syscall(endPage, 1, 1201 | uintptr(hdc), 1202 | 0, 1203 | 0) 1204 | 1205 | return int32(ret) 1206 | } 1207 | 1208 | func ExtCreatePen(dwPenStyle, dwWidth uint32, lplb *LOGBRUSH, dwStyleCount uint32, lpStyle *uint32) HPEN { 1209 | ret, _, _ := syscall.Syscall6(extCreatePen, 5, 1210 | uintptr(dwPenStyle), 1211 | uintptr(dwWidth), 1212 | uintptr(unsafe.Pointer(lplb)), 1213 | uintptr(dwStyleCount), 1214 | uintptr(unsafe.Pointer(lpStyle)), 1215 | 0) 1216 | 1217 | return HPEN(ret) 1218 | } 1219 | 1220 | func GetDeviceCaps(hdc HDC, nIndex int32) int32 { 1221 | ret, _, _ := syscall.Syscall(getDeviceCaps, 2, 1222 | uintptr(hdc), 1223 | uintptr(nIndex), 1224 | 0) 1225 | 1226 | return int32(ret) 1227 | } 1228 | 1229 | func GetEnhMetaFile(lpszMetaFile *uint16) HENHMETAFILE { 1230 | ret, _, _ := syscall.Syscall(getEnhMetaFile, 1, 1231 | uintptr(unsafe.Pointer(lpszMetaFile)), 1232 | 0, 1233 | 0) 1234 | 1235 | return HENHMETAFILE(ret) 1236 | } 1237 | 1238 | func GetEnhMetaFileHeader(hemf HENHMETAFILE, cbBuffer uint32, lpemh *ENHMETAHEADER) uint32 { 1239 | ret, _, _ := syscall.Syscall(getEnhMetaFileHeader, 3, 1240 | uintptr(hemf), 1241 | uintptr(cbBuffer), 1242 | uintptr(unsafe.Pointer(lpemh))) 1243 | 1244 | return uint32(ret) 1245 | } 1246 | 1247 | func GetObject(hgdiobj HGDIOBJ, cbBuffer uintptr, lpvObject unsafe.Pointer) int32 { 1248 | ret, _, _ := syscall.Syscall(getObject, 3, 1249 | uintptr(hgdiobj), 1250 | uintptr(cbBuffer), 1251 | uintptr(lpvObject)) 1252 | 1253 | return int32(ret) 1254 | } 1255 | 1256 | func GetStockObject(fnObject int32) HGDIOBJ { 1257 | ret, _, _ := syscall.Syscall(getDeviceCaps, 1, 1258 | uintptr(fnObject), 1259 | 0, 1260 | 0) 1261 | 1262 | return HGDIOBJ(ret) 1263 | } 1264 | 1265 | func GetTextExtentExPoint(hdc HDC, lpszStr *uint16, cchString, nMaxExtent int32, lpnFit, alpDx *int32, lpSize *SIZE) bool { 1266 | ret, _, _ := syscall.Syscall9(getTextExtentExPoint, 7, 1267 | uintptr(hdc), 1268 | uintptr(unsafe.Pointer(lpszStr)), 1269 | uintptr(cchString), 1270 | uintptr(nMaxExtent), 1271 | uintptr(unsafe.Pointer(lpnFit)), 1272 | uintptr(unsafe.Pointer(alpDx)), 1273 | uintptr(unsafe.Pointer(lpSize)), 1274 | 0, 1275 | 0) 1276 | 1277 | return ret != 0 1278 | } 1279 | 1280 | func GetTextExtentPoint32(hdc HDC, lpString *uint16, c int32, lpSize *SIZE) bool { 1281 | ret, _, _ := syscall.Syscall6(getTextExtentPoint32, 4, 1282 | uintptr(hdc), 1283 | uintptr(unsafe.Pointer(lpString)), 1284 | uintptr(c), 1285 | uintptr(unsafe.Pointer(lpSize)), 1286 | 0, 1287 | 0) 1288 | 1289 | return ret != 0 1290 | } 1291 | 1292 | func GetTextMetrics(hdc HDC, lptm *TEXTMETRIC) bool { 1293 | ret, _, _ := syscall.Syscall(getTextMetrics, 2, 1294 | uintptr(hdc), 1295 | uintptr(unsafe.Pointer(lptm)), 1296 | 0) 1297 | 1298 | return ret != 0 1299 | } 1300 | 1301 | func LineTo(hdc HDC, nXEnd, nYEnd int32) bool { 1302 | ret, _, _ := syscall.Syscall(lineTo, 3, 1303 | uintptr(hdc), 1304 | uintptr(nXEnd), 1305 | uintptr(nYEnd)) 1306 | 1307 | return ret != 0 1308 | } 1309 | 1310 | func MoveToEx(hdc HDC, x, y int, lpPoint *POINT) bool { 1311 | ret, _, _ := syscall.Syscall6(moveToEx, 4, 1312 | uintptr(hdc), 1313 | uintptr(x), 1314 | uintptr(y), 1315 | uintptr(unsafe.Pointer(lpPoint)), 1316 | 0, 1317 | 0) 1318 | 1319 | return ret != 0 1320 | } 1321 | 1322 | func PlayEnhMetaFile(hdc HDC, hemf HENHMETAFILE, lpRect *RECT) bool { 1323 | ret, _, _ := syscall.Syscall(playEnhMetaFile, 3, 1324 | uintptr(hdc), 1325 | uintptr(hemf), 1326 | uintptr(unsafe.Pointer(lpRect))) 1327 | 1328 | return ret != 0 1329 | } 1330 | 1331 | func Rectangle_(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool { 1332 | ret, _, _ := syscall.Syscall6(rectangle, 5, 1333 | uintptr(hdc), 1334 | uintptr(nLeftRect), 1335 | uintptr(nTopRect), 1336 | uintptr(nRightRect), 1337 | uintptr(nBottomRect), 1338 | 0) 1339 | 1340 | return ret != 0 1341 | } 1342 | 1343 | func ResetDC(hdc HDC, lpInitData *DEVMODE) HDC { 1344 | ret, _, _ := syscall.Syscall(resetDC, 2, 1345 | uintptr(hdc), 1346 | uintptr(unsafe.Pointer(lpInitData)), 1347 | 0) 1348 | 1349 | return HDC(ret) 1350 | } 1351 | 1352 | func SelectObject(hdc HDC, hgdiobj HGDIOBJ) HGDIOBJ { 1353 | ret, _, _ := syscall.Syscall(selectObject, 2, 1354 | uintptr(hdc), 1355 | uintptr(hgdiobj), 1356 | 0) 1357 | 1358 | return HGDIOBJ(ret) 1359 | } 1360 | 1361 | func SetBkMode(hdc HDC, iBkMode int32) int32 { 1362 | ret, _, _ := syscall.Syscall(setBkMode, 2, 1363 | uintptr(hdc), 1364 | uintptr(iBkMode), 1365 | 0) 1366 | 1367 | return int32(ret) 1368 | } 1369 | 1370 | func SetBrushOrgEx(hdc HDC, nXOrg, nYOrg int32, lppt *POINT) bool { 1371 | ret, _, _ := syscall.Syscall6(setBrushOrgEx, 4, 1372 | uintptr(hdc), 1373 | uintptr(nXOrg), 1374 | uintptr(nYOrg), 1375 | uintptr(unsafe.Pointer(lppt)), 1376 | 0, 1377 | 0) 1378 | 1379 | return ret != 0 1380 | } 1381 | 1382 | func SetPixelFormat(hdc HDC, iPixelFormat int32, ppfd *PIXELFORMATDESCRIPTOR) bool { 1383 | ret, _, _ := syscall.Syscall(setPixelFormat, 3, 1384 | uintptr(hdc), 1385 | uintptr(iPixelFormat), 1386 | uintptr(unsafe.Pointer(ppfd))) 1387 | 1388 | return ret != 0 1389 | } 1390 | 1391 | func SetStretchBltMode(hdc HDC, iStretchMode int32) int32 { 1392 | ret, _, _ := syscall.Syscall(setStretchBltMode, 2, 1393 | uintptr(hdc), 1394 | uintptr(iStretchMode), 1395 | 0) 1396 | 1397 | return int32(ret) 1398 | } 1399 | 1400 | func SetTextColor(hdc HDC, crColor COLORREF) COLORREF { 1401 | ret, _, _ := syscall.Syscall(setTextColor, 2, 1402 | uintptr(hdc), 1403 | uintptr(crColor), 1404 | 0) 1405 | 1406 | return COLORREF(ret) 1407 | } 1408 | 1409 | func StartDoc(hdc HDC, lpdi *DOCINFO) int32 { 1410 | ret, _, _ := syscall.Syscall(startDoc, 2, 1411 | uintptr(hdc), 1412 | uintptr(unsafe.Pointer(lpdi)), 1413 | 0) 1414 | 1415 | return int32(ret) 1416 | } 1417 | 1418 | func StartPage(hdc HDC) int32 { 1419 | ret, _, _ := syscall.Syscall(startPage, 1, 1420 | uintptr(hdc), 1421 | 0, 1422 | 0) 1423 | 1424 | return int32(ret) 1425 | } 1426 | 1427 | func StretchBlt(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int32, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int32, dwRop uint32) bool { 1428 | ret, _, _ := syscall.Syscall12(stretchBlt, 11, 1429 | uintptr(hdcDest), 1430 | uintptr(nXOriginDest), 1431 | uintptr(nYOriginDest), 1432 | uintptr(nWidthDest), 1433 | uintptr(nHeightDest), 1434 | uintptr(hdcSrc), 1435 | uintptr(nXOriginSrc), 1436 | uintptr(nYOriginSrc), 1437 | uintptr(nWidthSrc), 1438 | uintptr(nHeightSrc), 1439 | uintptr(dwRop), 1440 | 0) 1441 | 1442 | return ret != 0 1443 | } 1444 | 1445 | func SwapBuffers(hdc HDC) bool { 1446 | ret, _, _ := syscall.Syscall(swapBuffers, 1, 1447 | uintptr(hdc), 1448 | 0, 1449 | 0) 1450 | 1451 | return ret != 0 1452 | } 1453 | -------------------------------------------------------------------------------- /gdiplus.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | 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 | // Startup and remember token for shutdown. 159 | var si GdiplusStartupInput 160 | si.GdiplusVersion = 1 161 | if status := GdiplusStartup(&si, nil); status != Ok { 162 | panic("GdiplusStartup failed with status " + status.String()) 163 | } 164 | } 165 | 166 | 167 | func GdipCreateBitmapFromFile(filename *uint16, bitmap **GpBitmap) GpStatus { 168 | ret, _, _ := syscall.Syscall(gdipCreateBitmapFromFile, 2, 169 | uintptr(unsafe.Pointer(filename)), 170 | uintptr(unsafe.Pointer(bitmap)), 171 | 0) 172 | 173 | return GpStatus(ret) 174 | } 175 | 176 | func GdipCreateBitmapFromHBITMAP(hbm HBITMAP, hpal HPALETTE, bitmap **GpBitmap) GpStatus { 177 | ret, _, _ := syscall.Syscall(gdipCreateBitmapFromHBITMAP, 3, 178 | uintptr(hbm), 179 | uintptr(hpal), 180 | uintptr(unsafe.Pointer(bitmap))) 181 | 182 | return GpStatus(ret) 183 | } 184 | 185 | func GdipCreateHBITMAPFromBitmap(bitmap *GpBitmap, hbmReturn *HBITMAP, background ARGB) GpStatus { 186 | ret, _, _ := syscall.Syscall(gdipCreateHBITMAPFromBitmap, 3, 187 | uintptr(unsafe.Pointer(bitmap)), 188 | uintptr(unsafe.Pointer(hbmReturn)), 189 | uintptr(background)) 190 | 191 | return GpStatus(ret) 192 | } 193 | 194 | func GdipDisposeImage(image *GpImage) GpStatus { 195 | ret, _, _ := syscall.Syscall(gdipDisposeImage, 1, 196 | uintptr(unsafe.Pointer(image)), 197 | 0, 198 | 0) 199 | 200 | return GpStatus(ret) 201 | } 202 | 203 | func GdiplusShutdown() { 204 | syscall.Syscall(gdiplusShutdown, 1, 205 | token, 206 | 0, 207 | 0) 208 | } 209 | 210 | func GdiplusStartup(input *GdiplusStartupInput, output *GdiplusStartupOutput) GpStatus { 211 | ret, _, _ := syscall.Syscall(gdiplusStartup, 3, 212 | uintptr(unsafe.Pointer(&token)), 213 | uintptr(unsafe.Pointer(input)), 214 | uintptr(unsafe.Pointer(output))) 215 | 216 | return GpStatus(ret) 217 | } 218 | 219 | /*GdipSaveImageToFile(image *GpImage, filename *uint16, clsidEncoder *CLSID, encoderParams *EncoderParameters) GpStatus { 220 | ret, _, _ := syscall.Syscall6(gdipSaveImageToFile, 4, 221 | uintptr(unsafe.Pointer(image)), 222 | uintptr(unsafe.Pointer(filename)), 223 | uintptr(unsafe.Pointer(clsidEncoder)), 224 | uintptr(unsafe.Pointer(encoderParams)), 225 | 0, 226 | 0) 227 | 228 | return GpStatus(ret) 229 | }*/ 230 | -------------------------------------------------------------------------------- /kernel32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | 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 | var ( 33 | // Library 34 | libkernel32 uintptr 35 | 36 | // Functions 37 | fileTimeToSystemTime uintptr 38 | getLastError uintptr 39 | getLogicalDriveStrings uintptr 40 | getModuleHandle uintptr 41 | getThreadLocale uintptr 42 | globalAlloc uintptr 43 | globalFree uintptr 44 | globalLock uintptr 45 | globalUnlock uintptr 46 | moveMemory uintptr 47 | mulDiv uintptr 48 | setLastError uintptr 49 | systemTimeToFileTime uintptr 50 | ) 51 | 52 | type ( 53 | ATOM uint16 54 | HANDLE uintptr 55 | HGLOBAL HANDLE 56 | HINSTANCE HANDLE 57 | LCID uint32 58 | ) 59 | 60 | type FILETIME struct { 61 | DwLowDateTime uint32 62 | DwHighDateTime uint32 63 | } 64 | 65 | type SYSTEMTIME struct { 66 | WYear uint16 67 | WMonth uint16 68 | WDayOfWeek uint16 69 | WDay uint16 70 | WHour uint16 71 | WMinute uint16 72 | WSecond uint16 73 | WMilliseconds uint16 74 | } 75 | 76 | func init() { 77 | // Library 78 | libkernel32 = MustLoadLibrary("kernel32.dll") 79 | 80 | // Functions 81 | fileTimeToSystemTime = MustGetProcAddress(libkernel32, "FileTimeToSystemTime") 82 | getLastError = MustGetProcAddress(libkernel32, "GetLastError") 83 | getLogicalDriveStrings = MustGetProcAddress(libkernel32, "GetLogicalDriveStringsW") 84 | getModuleHandle = MustGetProcAddress(libkernel32, "GetModuleHandleW") 85 | getThreadLocale = MustGetProcAddress(libkernel32, "GetThreadLocale") 86 | globalAlloc = MustGetProcAddress(libkernel32, "GlobalAlloc") 87 | globalFree = MustGetProcAddress(libkernel32, "GlobalFree") 88 | globalLock = MustGetProcAddress(libkernel32, "GlobalLock") 89 | globalUnlock = MustGetProcAddress(libkernel32, "GlobalUnlock") 90 | moveMemory = MustGetProcAddress(libkernel32, "RtlMoveMemory") 91 | mulDiv = MustGetProcAddress(libkernel32, "MulDiv") 92 | setLastError = MustGetProcAddress(libkernel32, "SetLastError") 93 | systemTimeToFileTime = MustGetProcAddress(libkernel32, "SystemTimeToFileTime") 94 | } 95 | 96 | func FileTimeToSystemTime(lpFileTime *FILETIME, lpSystemTime *SYSTEMTIME) bool { 97 | ret, _, _ := syscall.Syscall(fileTimeToSystemTime, 2, 98 | uintptr(unsafe.Pointer(lpFileTime)), 99 | uintptr(unsafe.Pointer(lpSystemTime)), 100 | 0) 101 | 102 | return ret != 0 103 | } 104 | 105 | func GetLastError() uint32 { 106 | ret, _, _ := syscall.Syscall(getLastError, 0, 107 | 0, 108 | 0, 109 | 0) 110 | 111 | return uint32(ret) 112 | } 113 | 114 | func GetLogicalDriveStrings(nBufferLength uint32, lpBuffer *uint16) uint32 { 115 | ret, _, _ := syscall.Syscall(getLogicalDriveStrings, 2, 116 | uintptr(nBufferLength), 117 | uintptr(unsafe.Pointer(lpBuffer)), 118 | 0) 119 | 120 | return uint32(ret) 121 | } 122 | 123 | func GetModuleHandle(lpModuleName *uint16) HINSTANCE { 124 | ret, _, _ := syscall.Syscall(getModuleHandle, 1, 125 | uintptr(unsafe.Pointer(lpModuleName)), 126 | 0, 127 | 0) 128 | 129 | return HINSTANCE(ret) 130 | } 131 | 132 | func GetThreadLocale() LCID { 133 | ret, _, _ := syscall.Syscall(getThreadLocale, 0, 134 | 0, 135 | 0, 136 | 0) 137 | 138 | return LCID(ret) 139 | } 140 | 141 | func GlobalAlloc(uFlags uint32, dwBytes uintptr) HGLOBAL { 142 | ret, _, _ := syscall.Syscall(globalAlloc, 2, 143 | uintptr(uFlags), 144 | dwBytes, 145 | 0) 146 | 147 | return HGLOBAL(ret) 148 | } 149 | 150 | func GlobalFree(hMem HGLOBAL) HGLOBAL { 151 | ret, _, _ := syscall.Syscall(globalFree, 1, 152 | uintptr(hMem), 153 | 0, 154 | 0) 155 | 156 | return HGLOBAL(ret) 157 | } 158 | 159 | func GlobalLock(hMem HGLOBAL) unsafe.Pointer { 160 | ret, _, _ := syscall.Syscall(globalLock, 1, 161 | uintptr(hMem), 162 | 0, 163 | 0) 164 | 165 | return unsafe.Pointer(ret) 166 | } 167 | 168 | func GlobalUnlock(hMem HGLOBAL) bool { 169 | ret, _, _ := syscall.Syscall(globalUnlock, 1, 170 | uintptr(hMem), 171 | 0, 172 | 0) 173 | 174 | return ret != 0 175 | } 176 | 177 | func MoveMemory(destination, source unsafe.Pointer, length uintptr) { 178 | syscall.Syscall(moveMemory, 3, 179 | uintptr(unsafe.Pointer(destination)), 180 | uintptr(source), 181 | uintptr(length)) 182 | } 183 | 184 | func MulDiv(nNumber, nNumerator, nDenominator int32) int32 { 185 | ret, _, _ := syscall.Syscall(mulDiv, 3, 186 | uintptr(nNumber), 187 | uintptr(nNumerator), 188 | uintptr(nDenominator)) 189 | 190 | return int32(ret) 191 | } 192 | 193 | func SetLastError(dwErrorCode uint32) { 194 | syscall.Syscall(setLastError, 1, 195 | uintptr(dwErrorCode), 196 | 0, 197 | 0) 198 | } 199 | 200 | func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { 201 | ret, _, _ := syscall.Syscall(systemTimeToFileTime, 2, 202 | uintptr(unsafe.Pointer(lpSystemTime)), 203 | uintptr(unsafe.Pointer(lpFileTime)), 204 | 0) 205 | 206 | return ret != 0 207 | } 208 | -------------------------------------------------------------------------------- /listview.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | 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 NMLVDISPINFO struct { 345 | Hdr NMHDR 346 | Item LVITEM 347 | } 348 | -------------------------------------------------------------------------------- /menu.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | // 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 | ) 84 | 85 | type MENUITEMINFO struct { 86 | CbSize uint32 87 | FMask uint32 88 | FType uint32 89 | FState uint32 90 | WID uint32 91 | HSubMenu HMENU 92 | HbmpChecked HBITMAP 93 | HbmpUnchecked HBITMAP 94 | DwItemData uintptr 95 | DwTypeData *uint16 96 | Cch uint32 97 | HbmpItem HBITMAP 98 | } 99 | 100 | type MENUINFO struct { 101 | CbSize uint32 102 | FMask uint32 103 | DwStyle uint32 104 | CyMax uint32 105 | HbrBack HBRUSH 106 | DwContextHelpID uint32 107 | DwMenuData uintptr 108 | } 109 | -------------------------------------------------------------------------------- /ole32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | 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 | ) 36 | 37 | // Verbs for IOleObject.DoVerb 38 | const ( 39 | OLEIVERB_PRIMARY = 0 40 | OLEIVERB_SHOW = -1 41 | OLEIVERB_OPEN = -2 42 | OLEIVERB_HIDE = -3 43 | OLEIVERB_UIACTIVATE = -4 44 | OLEIVERB_INPLACEACTIVATE = -5 45 | OLEIVERB_DISCARDUNDOSTATE = -6 46 | ) 47 | 48 | // OLECLOSE constants 49 | const ( 50 | OLECLOSE_SAVEIFDIRTY = 0 51 | OLECLOSE_NOSAVE = 1 52 | OLECLOSE_PROMPTSAVE = 2 53 | ) 54 | 55 | type IID GUID 56 | type CLSID GUID 57 | type REFIID *IID 58 | type REFCLSID *CLSID 59 | 60 | var ( 61 | IID_IClassFactory = IID{0x00000001, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 62 | IID_IConnectionPointContainer = IID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} 63 | IID_IOleClientSite = IID{0x00000118, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 64 | IID_IOleInPlaceObject = IID{0x00000113, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 65 | IID_IOleInPlaceSite = IID{0x00000119, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 66 | IID_IOleObject = IID{0x00000112, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 67 | IID_IUnknown = IID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} 68 | ) 69 | 70 | func EqualREFIID(a, b REFIID) bool { 71 | if a == b { 72 | return true 73 | } 74 | if a == nil || b == nil { 75 | return false 76 | } 77 | 78 | if a.Data1 != b.Data1 || a.Data2 != b.Data2 || a.Data3 != b.Data3 { 79 | return false 80 | } 81 | 82 | for i := 0; i < 8; i++ { 83 | if a.Data4[i] != b.Data4[i] { 84 | return false 85 | } 86 | } 87 | 88 | return true 89 | } 90 | 91 | type IClassFactoryVtbl struct { 92 | QueryInterface uintptr 93 | AddRef uintptr 94 | Release uintptr 95 | CreateInstance uintptr 96 | LockServer uintptr 97 | } 98 | 99 | type IClassFactory struct { 100 | LpVtbl *IClassFactoryVtbl 101 | } 102 | 103 | func (cf *IClassFactory) Release() uint32 { 104 | ret, _, _ := syscall.Syscall(cf.LpVtbl.Release, 1, 105 | uintptr(unsafe.Pointer(cf)), 106 | 0, 107 | 0) 108 | 109 | return uint32(ret) 110 | } 111 | 112 | func (cf *IClassFactory) CreateInstance(pUnkOuter *IUnknown, riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 113 | ret, _, _ := syscall.Syscall6(cf.LpVtbl.CreateInstance, 4, 114 | uintptr(unsafe.Pointer(cf)), 115 | uintptr(unsafe.Pointer(pUnkOuter)), 116 | uintptr(unsafe.Pointer(riid)), 117 | uintptr(unsafe.Pointer(ppvObject)), 118 | 0, 119 | 0) 120 | 121 | return HRESULT(ret) 122 | } 123 | 124 | type IConnectionPointVtbl struct { 125 | QueryInterface uintptr 126 | AddRef uintptr 127 | Release uintptr 128 | GetConnectionInterface uintptr 129 | GetConnectionPointContainer uintptr 130 | Advise uintptr 131 | Unadvise uintptr 132 | EnumConnections uintptr 133 | } 134 | 135 | type IConnectionPoint struct { 136 | LpVtbl *IConnectionPointVtbl 137 | } 138 | 139 | func (cp *IConnectionPoint) Release() uint32 { 140 | ret, _, _ := syscall.Syscall(cp.LpVtbl.Release, 1, 141 | uintptr(unsafe.Pointer(cp)), 142 | 0, 143 | 0) 144 | 145 | return uint32(ret) 146 | } 147 | 148 | func (cp *IConnectionPoint) Advise(pUnkSink unsafe.Pointer, pdwCookie *uint32) HRESULT { 149 | ret, _, _ := syscall.Syscall(cp.LpVtbl.Advise, 3, 150 | uintptr(unsafe.Pointer(cp)), 151 | uintptr(pUnkSink), 152 | uintptr(unsafe.Pointer(pdwCookie))) 153 | 154 | return HRESULT(ret) 155 | } 156 | 157 | type IConnectionPointContainerVtbl struct { 158 | QueryInterface uintptr 159 | AddRef uintptr 160 | Release uintptr 161 | EnumConnectionPoints uintptr 162 | FindConnectionPoint uintptr 163 | } 164 | 165 | type IConnectionPointContainer struct { 166 | LpVtbl *IConnectionPointContainerVtbl 167 | } 168 | 169 | func (cpc *IConnectionPointContainer) Release() uint32 { 170 | ret, _, _ := syscall.Syscall(cpc.LpVtbl.Release, 1, 171 | uintptr(unsafe.Pointer(cpc)), 172 | 0, 173 | 0) 174 | 175 | return uint32(ret) 176 | } 177 | 178 | func (cpc *IConnectionPointContainer) FindConnectionPoint(riid REFIID, ppCP **IConnectionPoint) HRESULT { 179 | ret, _, _ := syscall.Syscall(cpc.LpVtbl.FindConnectionPoint, 3, 180 | uintptr(unsafe.Pointer(cpc)), 181 | uintptr(unsafe.Pointer(riid)), 182 | uintptr(unsafe.Pointer(ppCP))) 183 | 184 | return HRESULT(ret) 185 | } 186 | 187 | type IOleClientSiteVtbl struct { 188 | QueryInterface uintptr 189 | AddRef uintptr 190 | Release uintptr 191 | SaveObject uintptr 192 | GetMoniker uintptr 193 | GetContainer uintptr 194 | ShowObject uintptr 195 | OnShowWindow uintptr 196 | RequestNewObjectLayout uintptr 197 | } 198 | 199 | type IOleClientSite struct { 200 | LpVtbl *IOleClientSiteVtbl 201 | } 202 | 203 | type IOleInPlaceFrameVtbl struct { 204 | QueryInterface uintptr 205 | AddRef uintptr 206 | Release uintptr 207 | GetWindow uintptr 208 | ContextSensitiveHelp uintptr 209 | GetBorder uintptr 210 | RequestBorderSpace uintptr 211 | SetBorderSpace uintptr 212 | SetActiveObject uintptr 213 | InsertMenus uintptr 214 | SetMenu uintptr 215 | RemoveMenus uintptr 216 | SetStatusText uintptr 217 | EnableModeless uintptr 218 | TranslateAccelerator uintptr 219 | } 220 | 221 | type IOleInPlaceFrame struct { 222 | LpVtbl *IOleInPlaceFrameVtbl 223 | } 224 | 225 | type IOleInPlaceObjectVtbl struct { 226 | QueryInterface uintptr 227 | AddRef uintptr 228 | Release uintptr 229 | GetWindow uintptr 230 | ContextSensitiveHelp uintptr 231 | InPlaceDeactivate uintptr 232 | UIDeactivate uintptr 233 | SetObjectRects uintptr 234 | ReactivateAndUndo uintptr 235 | } 236 | 237 | type IOleInPlaceObject struct { 238 | LpVtbl *IOleInPlaceObjectVtbl 239 | } 240 | 241 | func (obj *IOleInPlaceObject) Release() uint32 { 242 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, 243 | uintptr(unsafe.Pointer(obj)), 244 | 0, 245 | 0) 246 | 247 | return uint32(ret) 248 | } 249 | 250 | func (obj *IOleInPlaceObject) SetObjectRects(lprcPosRect, lprcClipRect *RECT) HRESULT { 251 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetObjectRects, 3, 252 | uintptr(unsafe.Pointer(obj)), 253 | uintptr(unsafe.Pointer(lprcPosRect)), 254 | uintptr(unsafe.Pointer(lprcClipRect))) 255 | 256 | return HRESULT(ret) 257 | } 258 | 259 | type IOleInPlaceSiteVtbl struct { 260 | QueryInterface uintptr 261 | AddRef uintptr 262 | Release uintptr 263 | GetWindow uintptr 264 | ContextSensitiveHelp uintptr 265 | CanInPlaceActivate uintptr 266 | OnInPlaceActivate uintptr 267 | OnUIActivate uintptr 268 | GetWindowContext uintptr 269 | Scroll uintptr 270 | OnUIDeactivate uintptr 271 | OnInPlaceDeactivate uintptr 272 | DiscardUndoState uintptr 273 | DeactivateAndUndo uintptr 274 | OnPosRectChange uintptr 275 | } 276 | 277 | type IOleInPlaceSite struct { 278 | LpVtbl *IOleInPlaceSiteVtbl 279 | } 280 | 281 | type IOleObjectVtbl struct { 282 | QueryInterface uintptr 283 | AddRef uintptr 284 | Release uintptr 285 | SetClientSite uintptr 286 | GetClientSite uintptr 287 | SetHostNames uintptr 288 | Close uintptr 289 | SetMoniker uintptr 290 | GetMoniker uintptr 291 | InitFromData uintptr 292 | GetClipboardData uintptr 293 | DoVerb uintptr 294 | EnumVerbs uintptr 295 | Update uintptr 296 | IsUpToDate uintptr 297 | GetUserClassID uintptr 298 | GetUserType uintptr 299 | SetExtent uintptr 300 | GetExtent uintptr 301 | Advise uintptr 302 | Unadvise uintptr 303 | EnumAdvise uintptr 304 | GetMiscStatus uintptr 305 | SetColorScheme uintptr 306 | } 307 | 308 | type IOleObject struct { 309 | LpVtbl *IOleObjectVtbl 310 | } 311 | 312 | func (obj *IOleObject) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { 313 | ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, 314 | uintptr(unsafe.Pointer(obj)), 315 | uintptr(unsafe.Pointer(riid)), 316 | uintptr(unsafe.Pointer(ppvObject))) 317 | 318 | return HRESULT(ret) 319 | } 320 | 321 | func (obj *IOleObject) Release() uint32 { 322 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, 323 | uintptr(unsafe.Pointer(obj)), 324 | 0, 325 | 0) 326 | 327 | return uint32(ret) 328 | } 329 | 330 | func (obj *IOleObject) SetClientSite(pClientSite *IOleClientSite) HRESULT { 331 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetClientSite, 2, 332 | uintptr(unsafe.Pointer(obj)), 333 | uintptr(unsafe.Pointer(pClientSite)), 334 | 0) 335 | 336 | return HRESULT(ret) 337 | } 338 | 339 | func (obj *IOleObject) SetHostNames(szContainerApp, szContainerObj *uint16) HRESULT { 340 | ret, _, _ := syscall.Syscall(obj.LpVtbl.SetHostNames, 3, 341 | uintptr(unsafe.Pointer(obj)), 342 | uintptr(unsafe.Pointer(szContainerApp)), 343 | uintptr(unsafe.Pointer(szContainerObj))) 344 | 345 | return HRESULT(ret) 346 | } 347 | 348 | func (obj *IOleObject) Close(dwSaveOption uint32) HRESULT { 349 | ret, _, _ := syscall.Syscall(obj.LpVtbl.Close, 2, 350 | uintptr(unsafe.Pointer(obj)), 351 | uintptr(dwSaveOption), 352 | 0) 353 | 354 | return HRESULT(ret) 355 | } 356 | 357 | func (obj *IOleObject) DoVerb(iVerb int32, lpmsg *MSG, pActiveSite *IOleClientSite, lindex int32, hwndParent HWND, lprcPosRect *RECT) HRESULT { 358 | ret, _, _ := syscall.Syscall9(obj.LpVtbl.DoVerb, 7, 359 | uintptr(unsafe.Pointer(obj)), 360 | uintptr(iVerb), 361 | uintptr(unsafe.Pointer(lpmsg)), 362 | uintptr(unsafe.Pointer(pActiveSite)), 363 | uintptr(lindex), 364 | uintptr(hwndParent), 365 | uintptr(unsafe.Pointer(lprcPosRect)), 366 | 0, 367 | 0) 368 | 369 | return HRESULT(ret) 370 | } 371 | 372 | type IUnknownVtbl struct { 373 | QueryInterface uintptr 374 | AddRef uintptr 375 | Release uintptr 376 | } 377 | 378 | type IUnknown struct { 379 | LpVtbl *IUnknownVtbl 380 | } 381 | 382 | type OLEINPLACEFRAMEINFO struct { 383 | Cb uint32 384 | FMDIApp BOOL 385 | HwndFrame HWND 386 | Haccel HACCEL 387 | CAccelEntries uint32 388 | } 389 | 390 | type COAUTHIDENTITY struct { 391 | User *uint16 392 | UserLength uint32 393 | Domain *uint16 394 | DomainLength uint32 395 | Password *uint16 396 | PasswordLength uint32 397 | Flags uint32 398 | } 399 | 400 | type COAUTHINFO struct { 401 | dwAuthnSvc uint32 402 | dwAuthzSvc uint32 403 | pwszServerPrincName *uint16 404 | dwAuthnLevel uint32 405 | dwImpersonationLevel uint32 406 | pAuthIdentityData *COAUTHIDENTITY 407 | dwCapabilities uint32 408 | } 409 | 410 | type COSERVERINFO struct { 411 | dwReserved1 uint32 412 | pwszName *uint16 413 | pAuthInfo *COAUTHINFO 414 | dwReserved2 uint32 415 | } 416 | 417 | var ( 418 | // Library 419 | libole32 uintptr 420 | 421 | // Functions 422 | coGetClassObject uintptr 423 | oleInitialize uintptr 424 | oleSetContainedObject uintptr 425 | oleUninitialize uintptr 426 | ) 427 | 428 | func init() { 429 | // Library 430 | libole32 = MustLoadLibrary("ole32.dll") 431 | 432 | // Functions 433 | coGetClassObject = MustGetProcAddress(libole32, "CoGetClassObject") 434 | oleInitialize = MustGetProcAddress(libole32, "OleInitialize") 435 | oleSetContainedObject = MustGetProcAddress(libole32, "OleSetContainedObject") 436 | oleUninitialize = MustGetProcAddress(libole32, "OleUninitialize") 437 | 438 | // Initialize OLE stuff 439 | // FIXME: Find a way to call OleUninitialize at app shutdown 440 | // Maybe we should require explicit walk.Initialize/walk.Shutdown? 441 | if hr := OleInitialize(); FAILED(hr) { 442 | panic("OleInitialize Error: " + syscall.Errstr(int(hr))) 443 | } 444 | } 445 | 446 | func CoGetClassObject(rclsid REFCLSID, dwClsContext uint32, pServerInfo *COSERVERINFO, riid REFIID, ppv *unsafe.Pointer) HRESULT { 447 | ret, _, _ := syscall.Syscall6(coGetClassObject, 5, 448 | uintptr(unsafe.Pointer(rclsid)), 449 | uintptr(dwClsContext), 450 | uintptr(unsafe.Pointer(pServerInfo)), 451 | uintptr(unsafe.Pointer(riid)), 452 | uintptr(unsafe.Pointer(ppv)), 453 | 0) 454 | 455 | return HRESULT(ret) 456 | } 457 | 458 | func OleInitialize() HRESULT { 459 | ret, _, _ := syscall.Syscall(oleInitialize, 1, // WTF, why does 0 not work here? 460 | 0, 461 | 0, 462 | 0) 463 | 464 | return HRESULT(ret) 465 | } 466 | 467 | func OleSetContainedObject(pUnknown *IUnknown, fContained bool) HRESULT { 468 | ret, _, _ := syscall.Syscall(oleSetContainedObject, 2, 469 | uintptr(unsafe.Pointer(pUnknown)), 470 | uintptr(BoolToBOOL(fContained)), 471 | 0) 472 | 473 | return HRESULT(ret) 474 | } 475 | 476 | func OleUninitialize() { 477 | syscall.Syscall(oleUninitialize, 0, 478 | 0, 479 | 0, 480 | 0) 481 | } 482 | -------------------------------------------------------------------------------- /oleaut32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | 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 | //type BSTR *uint16 132 | 133 | func StringToBSTR(value string) *uint16 /*BSTR*/ { 134 | // IMPORTANT: Don't forget to free the BSTR value when no longer needed! 135 | return SysAllocString(value) 136 | } 137 | 138 | func BSTRToString(value *uint16 /*BSTR*/ ) string { 139 | // ISSUE: Is this really ok? 140 | bstrArrPtr := (*[2000000000]uint16)(unsafe.Pointer(value)) 141 | 142 | bstrSlice := make([]uint16, SysStringLen(value)) 143 | copy(bstrSlice, bstrArrPtr[:]) 144 | 145 | return syscall.UTF16ToString(bstrSlice) 146 | } 147 | 148 | type VAR_I4 struct { 149 | vt VARTYPE 150 | reserved1 [6]byte 151 | lVal int32 152 | reserved2 [4]byte 153 | } 154 | 155 | func IntToVariantI4(value int32) *VAR_I4 { 156 | return &VAR_I4{vt: VT_I4, lVal: value} 157 | } 158 | 159 | func VariantI4ToInt(value *VAR_I4) int32 { 160 | return value.lVal 161 | } 162 | 163 | type VAR_BOOL struct { 164 | vt VARTYPE 165 | reserved1 [6]byte 166 | boolVal VARIANT_BOOL 167 | reserved2 [6]byte 168 | } 169 | 170 | func BoolToVariantBool(value bool) *VAR_BOOL { 171 | return &VAR_BOOL{vt: VT_BOOL, boolVal: VARIANT_BOOL(BoolToBOOL(value))} 172 | } 173 | 174 | func VariantBoolToBool(value *VAR_BOOL) bool { 175 | return value.boolVal != 0 176 | } 177 | 178 | type VAR_BSTR struct { 179 | vt VARTYPE 180 | reserved1 [6]byte 181 | bstrVal *uint16 /*BSTR*/ 182 | reserved2 [4]byte // 32-bit specific 183 | } 184 | 185 | func StringToVariantBSTR(value string) *VAR_BSTR { 186 | // IMPORTANT: Don't forget to free the BSTR value when no longer needed! 187 | return &VAR_BSTR{vt: VT_BSTR, bstrVal: StringToBSTR(value)} 188 | } 189 | 190 | func VariantBSTRToString(value *VAR_BSTR) string { 191 | return BSTRToString(value.bstrVal) 192 | } 193 | 194 | type DISPPARAMS struct { 195 | Rgvarg *VARIANTARG 196 | RgdispidNamedArgs *DISPID 197 | CArgs int32 198 | CNamedArgs int32 199 | } 200 | 201 | var ( 202 | // Library 203 | liboleaut32 uintptr 204 | 205 | // Functions 206 | sysAllocString uintptr 207 | sysFreeString uintptr 208 | sysStringLen uintptr 209 | ) 210 | 211 | func init() { 212 | // Library 213 | liboleaut32 = MustLoadLibrary("oleaut32.dll") 214 | 215 | // Functions 216 | sysAllocString = MustGetProcAddress(liboleaut32, "SysAllocString") 217 | sysFreeString = MustGetProcAddress(liboleaut32, "SysFreeString") 218 | sysStringLen = MustGetProcAddress(liboleaut32, "SysStringLen") 219 | } 220 | 221 | func SysAllocString(s string) *uint16 /*BSTR*/ { 222 | ret, _, _ := syscall.Syscall(sysAllocString, 1, 223 | uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s))), 224 | 0, 225 | 0) 226 | 227 | return (*uint16) /*BSTR*/ (unsafe.Pointer(ret)) 228 | } 229 | 230 | func SysFreeString(bstr *uint16 /*BSTR*/ ) { 231 | syscall.Syscall(sysFreeString, 1, 232 | uintptr(unsafe.Pointer(bstr)), 233 | 0, 234 | 0) 235 | } 236 | 237 | func SysStringLen(bstr *uint16 /*BSTR*/ ) uint32 { 238 | ret, _, _ := syscall.Syscall(sysStringLen, 1, 239 | uintptr(unsafe.Pointer(bstr)), 240 | 0, 241 | 0) 242 | 243 | return uint32(ret) 244 | } 245 | -------------------------------------------------------------------------------- /opengl32.go: -------------------------------------------------------------------------------- 1 | 2 | package winapi 3 | 4 | import ( 5 | "syscall" 6 | "unsafe" 7 | ) 8 | 9 | // for second parameter of WglSwapLayerBuffers 10 | const ( 11 | WGL_SWAP_MAIN_PLANE = (1 << 0) 12 | WGL_SWAP_OVERLAY1 = (1 << 1) 13 | WGL_SWAP_OVERLAY2 = (1 << 2) 14 | WGL_SWAP_OVERLAY3 = (1 << 3) 15 | WGL_SWAP_OVERLAY4 = (1 << 4) 16 | WGL_SWAP_OVERLAY5 = (1 << 5) 17 | WGL_SWAP_OVERLAY6 = (1 << 6) 18 | WGL_SWAP_OVERLAY7 = (1 << 7) 19 | WGL_SWAP_OVERLAY8 = (1 << 8) 20 | WGL_SWAP_OVERLAY9 = (1 << 9) 21 | WGL_SWAP_OVERLAY10 = (1 << 10) 22 | WGL_SWAP_OVERLAY11 = (1 << 11) 23 | WGL_SWAP_OVERLAY12 = (1 << 12) 24 | WGL_SWAP_OVERLAY13 = (1 << 13) 25 | WGL_SWAP_OVERLAY14 = (1 << 14) 26 | WGL_SWAP_OVERLAY15 = (1 << 15) 27 | WGL_SWAP_UNDERLAY1 = (1 << 16) 28 | WGL_SWAP_UNDERLAY2 = (1 << 17) 29 | WGL_SWAP_UNDERLAY3 = (1 << 18) 30 | WGL_SWAP_UNDERLAY4 = (1 << 19) 31 | WGL_SWAP_UNDERLAY5 = (1 << 20) 32 | WGL_SWAP_UNDERLAY6 = (1 << 21) 33 | WGL_SWAP_UNDERLAY7 = (1 << 22) 34 | WGL_SWAP_UNDERLAY8 = (1 << 23) 35 | WGL_SWAP_UNDERLAY9 = (1 << 24) 36 | WGL_SWAP_UNDERLAY10 = (1 << 25) 37 | WGL_SWAP_UNDERLAY11 = (1 << 26) 38 | WGL_SWAP_UNDERLAY12 = (1 << 27) 39 | WGL_SWAP_UNDERLAY13 = (1 << 28) 40 | WGL_SWAP_UNDERLAY14 = (1 << 29) 41 | WGL_SWAP_UNDERLAY15 = (1 << 30) 42 | ) 43 | 44 | type ( 45 | HGLRC HANDLE 46 | ) 47 | 48 | type LAYERPLANEDESCRIPTOR struct { 49 | NSize uint16 50 | NVersion uint16 51 | DwFlags uint32 52 | IPixelType uint8 53 | CColorBits uint8 54 | CRedBits uint8 55 | CRedShift uint8 56 | CGreenBits uint8 57 | CGreenShift uint8 58 | CBlueBits uint8 59 | CBlueShift uint8 60 | CAlphaBits uint8 61 | CAlphaShift uint8 62 | CAccumBits uint8 63 | CAccumRedBits uint8 64 | CAccumGreenBits uint8 65 | CAccumBlueBits uint8 66 | CAccumAlphaBits uint8 67 | CDepthBits uint8 68 | CStencilBits uint8 69 | CAuxBuffers uint8 70 | ILayerType uint8 71 | BReserved uint8 72 | CrTransparent COLORREF 73 | } 74 | 75 | type POINTFLOAT struct { 76 | X, Y float32 77 | } 78 | 79 | type GLYPHMETRICSFLOAT struct { 80 | GmfBlackBoxX float32 81 | GmfBlackBoxY float32 82 | GmfptGlyphOrigin POINTFLOAT 83 | GmfCellIncX float32 84 | GmfCellIncY float32 85 | } 86 | 87 | var ( 88 | // Library 89 | lib uintptr 90 | 91 | // Functions 92 | wglCopyContext uintptr 93 | wglCreateContext uintptr 94 | wglCreateLayerContext uintptr 95 | wglDeleteContext uintptr 96 | wglDescribeLayerPlane uintptr 97 | wglGetCurrentContext uintptr 98 | wglGetCurrentDC uintptr 99 | wglGetLayerPaletteEntries uintptr 100 | wglGetProcAddress uintptr 101 | wglMakeCurrent uintptr 102 | wglRealizeLayerPalette uintptr 103 | wglSetLayerPaletteEntries uintptr 104 | wglShareLists uintptr 105 | wglSwapLayerBuffers uintptr 106 | wglUseFontBitmaps uintptr 107 | wglUseFontOutlines uintptr 108 | ) 109 | 110 | func init() { 111 | // Library 112 | lib = MustLoadLibrary("opengl32.dll") 113 | 114 | // Functions 115 | wglCopyContext = MustGetProcAddress(lib, "wglCopyContext") 116 | wglCreateContext = MustGetProcAddress(lib, "wglCreateContext") 117 | wglCreateLayerContext = MustGetProcAddress(lib, "wglCreateLayerContext") 118 | wglDeleteContext = MustGetProcAddress(lib, "wglDeleteContext") 119 | wglDescribeLayerPlane = MustGetProcAddress(lib, "wglDescribeLayerPlane") 120 | wglGetCurrentContext = MustGetProcAddress(lib, "wglGetCurrentContext") 121 | wglGetCurrentDC = MustGetProcAddress(lib, "wglGetCurrentDC") 122 | wglGetLayerPaletteEntries = MustGetProcAddress(lib, "wglGetLayerPaletteEntries") 123 | wglGetProcAddress = MustGetProcAddress(lib, "wglGetProcAddress") 124 | wglMakeCurrent = MustGetProcAddress(lib, "wglMakeCurrent") 125 | wglRealizeLayerPalette = MustGetProcAddress(lib, "wglRealizeLayerPalette") 126 | wglSetLayerPaletteEntries = MustGetProcAddress(lib, "wglSetLayerPaletteEntries") 127 | wglShareLists = MustGetProcAddress(lib, "wglShareLists") 128 | wglSwapLayerBuffers = MustGetProcAddress(lib, "wglSwapLayerBuffers") 129 | wglUseFontBitmaps = MustGetProcAddress(lib, "wglUseFontBitmapsW") 130 | wglUseFontOutlines = MustGetProcAddress(lib, "wglUseFontOutlinesW") 131 | } 132 | 133 | func WglCopyContext(hglrcSrc, hglrcDst HGLRC, mask uint ) bool { 134 | ret, _, _ := syscall.Syscall(wglCopyContext, 3, 135 | uintptr(hglrcSrc), 136 | uintptr(hglrcDst), 137 | uintptr(mask)) 138 | 139 | return ret != 0 140 | } 141 | 142 | func WglCreateContext(hdc HDC) HGLRC { 143 | ret, _, _ := syscall.Syscall(wglCreateContext, 1, 144 | uintptr(hdc), 145 | 0, 146 | 0) 147 | 148 | return HGLRC(ret) 149 | } 150 | 151 | func WglCreateLayerContext(hdc HDC, iLayerPlane int) HGLRC { 152 | ret, _, _ := syscall.Syscall(wglCreateLayerContext, 2, 153 | uintptr(hdc), 154 | uintptr(iLayerPlane), 155 | 0) 156 | 157 | return HGLRC(ret) 158 | } 159 | 160 | func WglDeleteContext(hglrc HGLRC) bool { 161 | ret, _, _ := syscall.Syscall(wglDeleteContext, 1, 162 | uintptr(hglrc), 163 | 0, 164 | 0) 165 | 166 | return ret != 0 167 | } 168 | 169 | func WglDescribeLayerPlane(hdc HDC, iPixelFormat, iLayerPlane int, nBytes uint8, plpd *LAYERPLANEDESCRIPTOR) bool { 170 | ret, _, _ := syscall.Syscall6(wglDescribeLayerPlane, 5, 171 | uintptr(hdc), 172 | uintptr(iPixelFormat), 173 | uintptr(iLayerPlane), 174 | uintptr(nBytes), 175 | uintptr(unsafe.Pointer(plpd)), 176 | 0) 177 | 178 | return ret != 0 179 | } 180 | 181 | func WglGetCurrentContext() HGLRC { 182 | ret, _, _ := syscall.Syscall(wglGetCurrentContext, 0, 183 | 0, 184 | 0, 185 | 0) 186 | 187 | return HGLRC(ret) 188 | } 189 | 190 | func WglGetCurrentDC() HDC { 191 | ret, _, _ := syscall.Syscall(wglGetCurrentDC, 0, 192 | 0, 193 | 0, 194 | 0) 195 | 196 | return HDC(ret) 197 | } 198 | 199 | func WglGetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr *COLORREF) int { 200 | ret, _, _ := syscall.Syscall6(wglGetLayerPaletteEntries, 5, 201 | uintptr(hdc), 202 | uintptr(iLayerPlane), 203 | uintptr(iStart), 204 | uintptr(cEntries), 205 | uintptr(unsafe.Pointer(pcr)), 206 | 0) 207 | 208 | return int(ret) 209 | } 210 | 211 | func WglGetProcAddress(lpszProc *uint16) uintptr { 212 | ret, _, _ := syscall.Syscall(wglGetProcAddress, 1, 213 | uintptr(unsafe.Pointer(lpszProc)), 214 | 0, 215 | 0) 216 | 217 | return uintptr(ret) 218 | } 219 | 220 | func WglMakeCurrent(hdc HDC, hglrc HGLRC) bool { 221 | ret, _, _ := syscall.Syscall(wglMakeCurrent, 2, 222 | uintptr(hdc), 223 | uintptr(hglrc), 224 | 0) 225 | 226 | return ret != 0 227 | } 228 | 229 | func WglRealizeLayerPalette(hdc HDC, iLayerPlane int, bRealize bool) bool { 230 | ret, _, _ := syscall.Syscall(wglRealizeLayerPalette, 3, 231 | uintptr(hdc), 232 | uintptr(iLayerPlane), 233 | uintptr(BoolToBOOL(bRealize))) 234 | 235 | return ret != 0 236 | } 237 | 238 | func WglSetLayerPaletteEntries(hdc HDC, iLayerPlane, iStart, cEntries int, pcr *COLORREF) int { 239 | ret, _, _ := syscall.Syscall6(wglSetLayerPaletteEntries, 5, 240 | uintptr(hdc), 241 | uintptr(iLayerPlane), 242 | uintptr(iStart), 243 | uintptr(cEntries), 244 | uintptr(unsafe.Pointer(pcr)), 245 | 0) 246 | 247 | return int(ret) 248 | } 249 | 250 | func WglShareLists(hglrc1, hglrc2 HGLRC) bool { 251 | ret, _, _ := syscall.Syscall(wglShareLists, 2, 252 | uintptr(hglrc1), 253 | uintptr(hglrc2), 254 | 0) 255 | 256 | return ret != 0 257 | } 258 | 259 | func WglSwapLayerBuffers(hdc HDC, fuPlanes uint) bool { 260 | ret, _, _ := syscall.Syscall(wglSwapLayerBuffers, 2, 261 | uintptr(hdc), 262 | uintptr(fuPlanes), 263 | 0) 264 | 265 | return ret != 0 266 | } 267 | 268 | func WglUseFontBitmaps(hdc HDC, first, count, listbase uint32) bool { 269 | ret, _, _ := syscall.Syscall6(wglUseFontBitmaps, 4, 270 | uintptr(hdc), 271 | uintptr(first), 272 | uintptr(count), 273 | uintptr(listbase), 274 | 0, 275 | 0) 276 | 277 | return ret != 0 278 | } 279 | 280 | func WglUseFontOutlines(hdc HDC, first, count, listbase uint32, deviation, extrusion float32, format int, pgmf *GLYPHMETRICSFLOAT) bool { 281 | ret, _, _ := syscall.Syscall12(wglUseFontBitmaps, 8, 282 | uintptr(hdc), 283 | uintptr(first), 284 | uintptr(count), 285 | uintptr(listbase), 286 | uintptr(deviation), 287 | uintptr(extrusion), 288 | uintptr(format), 289 | uintptr(unsafe.Pointer(pgmf)), 290 | 0, 291 | 0, 292 | 0, 293 | 0) 294 | 295 | return ret != 0 296 | } 297 | -------------------------------------------------------------------------------- /shdocvw.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | 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 | StatusTextChange uintptr 82 | ProgressChange uintptr 83 | CommandStateChange uintptr 84 | DownloadBegin uintptr 85 | DownloadComplete uintptr 86 | TitleChange uintptr 87 | PropertyChange uintptr 88 | BeforeNavigate2 uintptr 89 | NewWindow2 uintptr 90 | NavigateComplete2 uintptr 91 | DocumentComplete uintptr 92 | OnQuit uintptr 93 | OnVisible uintptr 94 | OnToolBar uintptr 95 | OnMenuBar uintptr 96 | OnStatusBar uintptr 97 | OnFullScreen uintptr 98 | OnTheaterMode uintptr 99 | WindowSetResizable uintptr 100 | WindowSetLeft uintptr 101 | WindowSetTop uintptr 102 | WindowSetWidth uintptr 103 | WindowSetHeight uintptr 104 | WindowClosing uintptr 105 | ClientToHostWindow uintptr 106 | SetSecureLockIcon uintptr 107 | FileDownload uintptr 108 | NavigateError uintptr 109 | PrintTemplateInstantiation uintptr 110 | PrintTemplateTeardown uintptr 111 | UpdatePageStatus uintptr 112 | PrivacyImpactedStateChange uintptr 113 | NewWindow3 uintptr 114 | } 115 | 116 | type DWebBrowserEvents2 struct { 117 | LpVtbl *DWebBrowserEvents2Vtbl 118 | } 119 | 120 | type IWebBrowser2Vtbl struct { 121 | QueryInterface uintptr 122 | AddRef uintptr 123 | Release uintptr 124 | GetTypeInfoCount uintptr 125 | GetTypeInfo uintptr 126 | GetIDsOfNames uintptr 127 | Invoke uintptr 128 | GoBack uintptr 129 | GoForward uintptr 130 | GoHome uintptr 131 | GoSearch uintptr 132 | Navigate uintptr 133 | Refresh uintptr 134 | Refresh2 uintptr 135 | Stop uintptr 136 | Get_Application uintptr 137 | Get_Parent uintptr 138 | Get_Container uintptr 139 | Get_Document uintptr 140 | Get_TopLevelContainer uintptr 141 | Get_Type uintptr 142 | Get_Left uintptr 143 | Put_Left uintptr 144 | Get_Top uintptr 145 | Put_Top uintptr 146 | Get_Width uintptr 147 | Put_Width uintptr 148 | Get_Height uintptr 149 | Put_Height uintptr 150 | Get_LocationName uintptr 151 | Get_LocationURL uintptr 152 | Get_Busy uintptr 153 | Quit uintptr 154 | ClientToWindow uintptr 155 | PutProperty uintptr 156 | GetProperty uintptr 157 | Get_Name uintptr 158 | Get_HWND uintptr 159 | Get_FullName uintptr 160 | Get_Path uintptr 161 | Get_Visible uintptr 162 | Put_Visible uintptr 163 | Get_StatusBar uintptr 164 | Put_StatusBar uintptr 165 | Get_StatusText uintptr 166 | Put_StatusText uintptr 167 | Get_ToolBar uintptr 168 | Put_ToolBar uintptr 169 | Get_MenuBar uintptr 170 | Put_MenuBar uintptr 171 | Get_FullScreen uintptr 172 | Put_FullScreen uintptr 173 | Navigate2 uintptr 174 | QueryStatusWB uintptr 175 | ExecWB uintptr 176 | ShowBrowserBar uintptr 177 | Get_ReadyState uintptr 178 | Get_Offline uintptr 179 | Put_Offline uintptr 180 | Get_Silent uintptr 181 | Put_Silent uintptr 182 | Get_RegisterAsBrowser uintptr 183 | Put_RegisterAsBrowser uintptr 184 | Get_RegisterAsDropTarget uintptr 185 | Put_RegisterAsDropTarget uintptr 186 | Get_TheaterMode uintptr 187 | Put_TheaterMode uintptr 188 | Get_AddressBar uintptr 189 | Put_AddressBar uintptr 190 | Get_Resizable uintptr 191 | Put_Resizable uintptr 192 | } 193 | 194 | type IWebBrowser2 struct { 195 | LpVtbl *IWebBrowser2Vtbl 196 | } 197 | 198 | func (wb2 *IWebBrowser2) Release() HRESULT { 199 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Release, 1, 200 | uintptr(unsafe.Pointer(wb2)), 201 | 0, 202 | 0) 203 | 204 | return HRESULT(ret) 205 | } 206 | 207 | func (wb2 *IWebBrowser2) Put_Left(Left int32) HRESULT { 208 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Left, 2, 209 | uintptr(unsafe.Pointer(wb2)), 210 | uintptr(Left), 211 | 0) 212 | 213 | return HRESULT(ret) 214 | } 215 | 216 | func (wb2 *IWebBrowser2) Put_Top(Top int32) HRESULT { 217 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Top, 2, 218 | uintptr(unsafe.Pointer(wb2)), 219 | uintptr(Top), 220 | 0) 221 | 222 | return HRESULT(ret) 223 | } 224 | 225 | func (wb2 *IWebBrowser2) Put_Width(Width int32) HRESULT { 226 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Width, 2, 227 | uintptr(unsafe.Pointer(wb2)), 228 | uintptr(Width), 229 | 0) 230 | 231 | return HRESULT(ret) 232 | } 233 | 234 | func (wb2 *IWebBrowser2) Put_Height(Height int32) HRESULT { 235 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Height, 2, 236 | uintptr(unsafe.Pointer(wb2)), 237 | uintptr(Height), 238 | 0) 239 | 240 | return HRESULT(ret) 241 | } 242 | 243 | func (wb2 *IWebBrowser2) Get_LocationURL(pbstrLocationURL **uint16 /*BSTR*/ ) HRESULT { 244 | ret, _, _ := syscall.Syscall(wb2.LpVtbl.Get_LocationURL, 2, 245 | uintptr(unsafe.Pointer(wb2)), 246 | uintptr(unsafe.Pointer(pbstrLocationURL)), 247 | 0) 248 | 249 | return HRESULT(ret) 250 | } 251 | 252 | func (wb2 *IWebBrowser2) Navigate2(URL *VAR_BSTR, Flags *VAR_I4, TargetFrameName *VAR_BSTR, PostData unsafe.Pointer, Headers *VAR_BSTR) HRESULT { 253 | ret, _, _ := syscall.Syscall6(wb2.LpVtbl.Navigate2, 6, 254 | uintptr(unsafe.Pointer(wb2)), 255 | uintptr(unsafe.Pointer(URL)), 256 | uintptr(unsafe.Pointer(Flags)), 257 | uintptr(unsafe.Pointer(TargetFrameName)), 258 | uintptr(PostData), 259 | uintptr(unsafe.Pointer(Headers))) 260 | 261 | return HRESULT(ret) 262 | } 263 | 264 | type IDocHostUIHandlerVtbl struct { 265 | QueryInterface uintptr 266 | AddRef uintptr 267 | Release uintptr 268 | ShowContextMenu uintptr 269 | GetHostInfo uintptr 270 | ShowUI uintptr 271 | HideUI uintptr 272 | UpdateUI uintptr 273 | EnableModeless uintptr 274 | OnDocWindowActivate uintptr 275 | OnFrameWindowActivate uintptr 276 | ResizeBorder uintptr 277 | TranslateAccelerator uintptr 278 | GetOptionKeyPath uintptr 279 | GetDropTarget uintptr 280 | GetExternal uintptr 281 | TranslateUrl uintptr 282 | FilterDataObject uintptr 283 | } 284 | 285 | type IDocHostUIHandler struct { 286 | LpVtbl *IDocHostUIHandlerVtbl 287 | } 288 | 289 | type DOCHOSTUIINFO struct { 290 | CbSize uint32 291 | DwFlags uint32 292 | DwDoubleClick uint32 293 | PchHostCss *uint16 294 | PchHostNS *uint16 295 | } 296 | -------------------------------------------------------------------------------- /shell32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | 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 | const NOTIFYICON_VERSION = 3 104 | 105 | type NOTIFYICONDATA struct { 106 | CbSize uint32 107 | HWnd HWND 108 | UID uint32 109 | UFlags uint32 110 | UCallbackMessage uint32 111 | HIcon HICON 112 | SzTip [128]uint16 113 | DwState uint32 114 | DwStateMask uint32 115 | SzInfo [256]uint16 116 | UVersion uint32 117 | SzInfoTitle [64]uint16 118 | DwInfoFlags uint32 119 | GuidItem GUID 120 | } 121 | 122 | var ( 123 | // Library 124 | libshell32 uintptr 125 | 126 | // Functions 127 | shGetSpecialFolderPath uintptr 128 | shell_NotifyIcon uintptr 129 | ) 130 | 131 | func init() { 132 | // Library 133 | libshell32 = MustLoadLibrary("shell32.dll") 134 | 135 | // Functions 136 | shGetSpecialFolderPath = MustGetProcAddress(libshell32, "SHGetSpecialFolderPathW") 137 | shell_NotifyIcon = MustGetProcAddress(libshell32, "Shell_NotifyIconW") 138 | } 139 | 140 | func ShGetSpecialFolderPath(hwndOwner HWND, lpszPath *uint16, csidl CSIDL, fCreate bool) bool { 141 | ret, _, _ := syscall.Syscall6(shGetSpecialFolderPath, 4, 142 | uintptr(hwndOwner), 143 | uintptr(unsafe.Pointer(lpszPath)), 144 | uintptr(csidl), 145 | uintptr(BoolToBOOL(fCreate)), 146 | 0, 147 | 0) 148 | 149 | return ret != 0 150 | } 151 | 152 | func Shell_NotifyIcon(dwMessage uint32, lpdata *NOTIFYICONDATA) bool { 153 | ret, _, _ := syscall.Syscall(shell_NotifyIcon, 2, 154 | uintptr(dwMessage), 155 | uintptr(unsafe.Pointer(lpdata)), 156 | 0) 157 | 158 | return ret != 0 159 | } 160 | -------------------------------------------------------------------------------- /tab.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 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 | 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 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 | // 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 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 | ) 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 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 | // 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 | // TreeView messages 76 | const ( 77 | TV_FIRST = 0x1100 78 | 79 | TVM_INSERTITEM = TV_FIRST + 50 80 | TVM_DELETEITEM = TV_FIRST + 1 81 | TVM_EXPAND = TV_FIRST + 2 82 | TVM_GETITEMRECT = TV_FIRST + 4 83 | TVM_GETCOUNT = TV_FIRST + 5 84 | TVM_GETINDENT = TV_FIRST + 6 85 | TVM_SETINDENT = TV_FIRST + 7 86 | TVM_GETIMAGELIST = TV_FIRST + 8 87 | TVM_SETIMAGELIST = TV_FIRST + 9 88 | TVM_GETNEXTITEM = TV_FIRST + 10 89 | TVM_SELECTITEM = TV_FIRST + 11 90 | TVM_GETITEM = TV_FIRST + 62 91 | TVM_SETITEM = TV_FIRST + 63 92 | TVM_EDITLABEL = TV_FIRST + 65 93 | TVM_GETEDITCONTROL = TV_FIRST + 15 94 | TVM_GETVISIBLECOUNT = TV_FIRST + 16 95 | TVM_HITTEST = TV_FIRST + 17 96 | TVM_CREATEDRAGIMAGE = TV_FIRST + 18 97 | TVM_SORTCHILDREN = TV_FIRST + 19 98 | TVM_ENSUREVISIBLE = TV_FIRST + 20 99 | TVM_SORTCHILDRENCB = TV_FIRST + 21 100 | TVM_ENDEDITLABELNOW = TV_FIRST + 22 101 | TVM_GETISEARCHSTRING = TV_FIRST + 64 102 | TVM_SETTOOLTIPS = TV_FIRST + 24 103 | TVM_GETTOOLTIPS = TV_FIRST + 25 104 | TVM_SETINSERTMARK = TV_FIRST + 26 105 | TVM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT 106 | TVM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT 107 | TVM_SETITEMHEIGHT = TV_FIRST + 27 108 | TVM_GETITEMHEIGHT = TV_FIRST + 28 109 | TVM_SETBKCOLOR = TV_FIRST + 29 110 | TVM_SETTEXTCOLOR = TV_FIRST + 30 111 | TVM_GETBKCOLOR = TV_FIRST + 31 112 | TVM_GETTEXTCOLOR = TV_FIRST + 32 113 | TVM_SETSCROLLTIME = TV_FIRST + 33 114 | TVM_GETSCROLLTIME = TV_FIRST + 34 115 | TVM_SETINSERTMARKCOLOR = TV_FIRST + 37 116 | TVM_GETINSERTMARKCOLOR = TV_FIRST + 38 117 | TVM_GETITEMSTATE = TV_FIRST + 39 118 | TVM_SETLINECOLOR = TV_FIRST + 40 119 | TVM_GETLINECOLOR = TV_FIRST + 41 120 | TVM_MAPACCIDTOHTREEITEM = TV_FIRST + 42 121 | TVM_MAPHTREEITEMTOACCID = TV_FIRST + 43 122 | TVM_SETEXTENDEDSTYLE = TV_FIRST + 44 123 | TVM_GETEXTENDEDSTYLE = TV_FIRST + 45 124 | TVM_SETAUTOSCROLLINFO = TV_FIRST + 59 125 | ) 126 | 127 | // TreeView notifications 128 | const ( 129 | TVN_FIRST = ^uint32(399) 130 | 131 | TVN_SELCHANGING = TVN_FIRST - 50 132 | TVN_SELCHANGED = TVN_FIRST - 51 133 | TVN_ITEMEXPANDING = TVN_FIRST - 54 134 | TVN_ITEMEXPANDED = TVN_FIRST - 55 135 | TVN_BEGINDRAG = TVN_FIRST - 56 136 | TVN_BEGINRDRAG = TVN_FIRST - 57 137 | TVN_DELETEITEM = TVN_FIRST - 58 138 | TVN_BEGINLABELEDIT = TVN_FIRST - 59 139 | TVN_ENDLABELEDIT = TVN_FIRST - 60 140 | TVN_KEYDOWN = TVN_FIRST - 12 141 | TVN_GETINFOTIP = TVN_FIRST - 14 142 | TVN_SINGLEEXPAND = TVN_FIRST - 15 143 | TVN_ITEMCHANGING = TVN_FIRST - 17 144 | TVN_ITEMCHANGED = TVN_FIRST - 19 145 | TVN_ASYNCDRAW = TVN_FIRST - 20 146 | ) 147 | 148 | type HTREEITEM HANDLE 149 | 150 | type TVITEM struct { 151 | Mask uint32 152 | HItem HTREEITEM 153 | State uint32 154 | StateMask uint32 155 | PszText *uint16 156 | CchTextMax int32 157 | IImage int32 158 | ISelectedImage int32 159 | CChildren int32 160 | LParam uintptr 161 | } 162 | 163 | /*type TVITEMEX struct { 164 | mask UINT 165 | hItem HTREEITEM 166 | state UINT 167 | stateMask UINT 168 | pszText LPWSTR 169 | cchTextMax int 170 | iImage int 171 | iSelectedImage int 172 | cChildren int 173 | lParam LPARAM 174 | iIntegral int 175 | uStateEx UINT 176 | hwnd HWND 177 | iExpandedImage int 178 | }*/ 179 | 180 | 181 | type TVINSERTSTRUCT struct { 182 | HParent HTREEITEM 183 | HInsertAfter HTREEITEM 184 | Item TVITEM 185 | // itemex TVITEMEX 186 | } 187 | 188 | type NMTREEVIEW struct { 189 | Hdr NMHDR 190 | Action uint32 191 | ItemOld TVITEM 192 | ItemNew TVITEM 193 | PtDrag POINT 194 | } 195 | -------------------------------------------------------------------------------- /updown.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 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 | 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 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 | // 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 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 | "fmt" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | const ( 14 | S_OK = 0x00000000 15 | S_FALSE = 0x00000001 16 | E_UNEXPECTED = 0x8000FFFF 17 | E_NOTIMPL = 0x80004001 18 | E_OUTOFMEMORY = 0x8007000E 19 | E_INVALIDARG = 0x80070057 20 | E_NOINTERFACE = 0x80004002 21 | E_POINTER = 0x80004003 22 | E_HANDLE = 0x80070006 23 | E_ABORT = 0x80004004 24 | E_FAIL = 0x80004005 25 | E_ACCESSDENIED = 0x80070005 26 | E_PENDING = 0x8000000A 27 | ) 28 | 29 | const ( 30 | FALSE = 0 31 | TRUE = 1 32 | ) 33 | 34 | type ( 35 | BOOL int32 36 | HRESULT uint32 37 | ) 38 | 39 | type GUID struct { 40 | Data1 uint32 41 | Data2 uint16 42 | Data3 uint16 43 | Data4 [8]byte 44 | } 45 | 46 | func MustLoadLibrary(name string) uintptr { 47 | lib, errno := syscall.LoadLibrary(name) 48 | if errno != 0 { 49 | panic(fmt.Sprintf(`syscall.LoadLibrary("%s") failed: %s`, name, syscall.Errstr(errno))) 50 | } 51 | 52 | return uintptr(lib) 53 | } 54 | 55 | func MustGetProcAddress(lib uintptr, name string) uintptr { 56 | addr, errno := syscall.GetProcAddress(syscall.Handle(lib), name) 57 | if errno != 0 { 58 | panic(fmt.Sprintf(`syscall.GetProcAddress(%d, "%s") failed: %s`, lib, name, syscall.Errstr(errno))) 59 | } 60 | 61 | return uintptr(addr) 62 | } 63 | 64 | func SUCCEEDED(hr HRESULT) bool { 65 | return hr >= 0 66 | } 67 | 68 | func FAILED(hr HRESULT) bool { 69 | return hr < 0 70 | } 71 | 72 | func MAKELONG(lo, hi uint16) uint32 { 73 | return uint32(uint32(lo) | ((uint32(hi)) << 16)) 74 | } 75 | 76 | func LOWORD(dw uint32) uint16 { 77 | return uint16(dw) 78 | } 79 | 80 | func HIWORD(dw uint32) uint16 { 81 | return uint16(dw >> 16 & 0xffff) 82 | } 83 | 84 | func UTF16PtrToString(s *uint16) string { 85 | return syscall.UTF16ToString((*[1 << 30]uint16)(unsafe.Pointer(s))[0:]) 86 | } 87 | 88 | func MAKEINTRESOURCE(id uintptr) *uint16 { 89 | return (*uint16)(unsafe.Pointer(id)) 90 | } 91 | 92 | func BoolToBOOL(value bool) BOOL { 93 | if value { 94 | return 1 95 | } 96 | 97 | return 0 98 | } 99 | -------------------------------------------------------------------------------- /winspool.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 | 8 | import ( 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | // EnumPrinters flags 14 | const ( 15 | PRINTER_ENUM_DEFAULT = 0x00000001 16 | PRINTER_ENUM_LOCAL = 0x00000002 17 | PRINTER_ENUM_CONNECTIONS = 0x00000004 18 | PRINTER_ENUM_FAVORITE = 0x00000004 19 | PRINTER_ENUM_NAME = 0x00000008 20 | PRINTER_ENUM_REMOTE = 0x00000010 21 | PRINTER_ENUM_SHARED = 0x00000020 22 | PRINTER_ENUM_NETWORK = 0x00000040 23 | ) 24 | 25 | type PRINTER_INFO_4 struct { 26 | PPrinterName *uint16 27 | PServerName *uint16 28 | Attributes uint32 29 | } 30 | 31 | var ( 32 | // Library 33 | libwinspool uintptr 34 | 35 | // Functions 36 | deviceCapabilities uintptr 37 | documentProperties uintptr 38 | enumPrinters uintptr 39 | getDefaultPrinter uintptr 40 | ) 41 | 42 | func init() { 43 | // Library 44 | libwinspool = MustLoadLibrary("winspool.drv") 45 | 46 | // Functions 47 | deviceCapabilities = MustGetProcAddress(libwinspool, "DeviceCapabilitiesW") 48 | documentProperties = MustGetProcAddress(libwinspool, "DocumentPropertiesW") 49 | enumPrinters = MustGetProcAddress(libwinspool, "EnumPrintersW") 50 | getDefaultPrinter = MustGetProcAddress(libwinspool, "GetDefaultPrinterW") 51 | } 52 | 53 | func DeviceCapabilities(pDevice, pPort *uint16, fwCapability uint16, pOutput *uint16, pDevMode *DEVMODE) uint32 { 54 | ret, _, _ := syscall.Syscall6(deviceCapabilities, 5, 55 | uintptr(unsafe.Pointer(pDevice)), 56 | uintptr(unsafe.Pointer(pPort)), 57 | uintptr(fwCapability), 58 | uintptr(unsafe.Pointer(pOutput)), 59 | uintptr(unsafe.Pointer(pDevMode)), 60 | 0) 61 | 62 | return uint32(ret) 63 | } 64 | 65 | func DocumentProperties(hWnd HWND, hPrinter HANDLE, pDeviceName *uint16, pDevModeOutput, pDevModeInput *DEVMODE, fMode uint32) int32 { 66 | ret, _, _ := syscall.Syscall6(documentProperties, 6, 67 | uintptr(hWnd), 68 | uintptr(hPrinter), 69 | uintptr(unsafe.Pointer(pDeviceName)), 70 | uintptr(unsafe.Pointer(pDevModeOutput)), 71 | uintptr(unsafe.Pointer(pDevModeInput)), 72 | uintptr(fMode)) 73 | 74 | return int32(ret) 75 | } 76 | 77 | func EnumPrinters(Flags uint32, Name *uint16, Level uint32, pPrinterEnum *byte, cbBuf uint32, pcbNeeded, pcReturned *uint32) bool { 78 | ret, _, _ := syscall.Syscall9(enumPrinters, 7, 79 | uintptr(Flags), 80 | uintptr(unsafe.Pointer(Name)), 81 | uintptr(Level), 82 | uintptr(unsafe.Pointer(pPrinterEnum)), 83 | uintptr(cbBuf), 84 | uintptr(unsafe.Pointer(pcbNeeded)), 85 | uintptr(unsafe.Pointer(pcReturned)), 86 | 0, 87 | 0) 88 | 89 | return ret != 0 90 | } 91 | 92 | func GetDefaultPrinter(pszBuffer *uint16, pcchBuffer *uint32) bool { 93 | ret, _, _ := syscall.Syscall(getDefaultPrinter, 2, 94 | uintptr(unsafe.Pointer(pszBuffer)), 95 | uintptr(unsafe.Pointer(pcchBuffer)), 96 | 0) 97 | 98 | return ret != 0 99 | } 100 | --------------------------------------------------------------------------------