// 9 february 2014 package main import ( // "syscall" // "unsafe" ) // Button styles. const ( // from winuser.h _BS_PUSHBUTTON = 0x00000000 _BS_DEFPUSHBUTTON = 0x00000001 _BS_CHECKBOX = 0x00000002 _BS_AUTOCHECKBOX = 0x00000003 _BS_RADIOBUTTON = 0x00000004 _BS_3STATE = 0x00000005 _BS_AUTO3STATE = 0x00000006 _BS_GROUPBOX = 0x00000007 _BS_USERBUTTON = 0x00000008 _BS_AUTORADIOBUTTON = 0x00000009 _BS_PUSHBOX = 0x0000000A _BS_OWNERDRAW = 0x0000000B _BS_TYPEMASK = 0x0000000F _BS_LEFTTEXT = 0x00000020 _BS_TEXT = 0x00000000 _BS_ICON = 0x00000040 _BS_BITMAP = 0x00000080 _BS_LEFT = 0x00000100 _BS_RIGHT = 0x00000200 _BS_CENTER = 0x00000300 _BS_TOP = 0x00000400 _BS_BOTTOM = 0x00000800 _BS_VCENTER = 0x00000C00 _BS_PUSHLIKE = 0x00001000 _BS_MULTILINE = 0x00002000 _BS_NOTIFY = 0x00004000 _BS_FLAT = 0x00008000 _BS_RIGHTBUTTON = _BS_LEFTTEXT // from commctrl.h // _BS_SPLITBUTTON = 0x0000000C // Windows Vista and newer and(/or?) comctl6 only // _BS_DEFSPLITBUTTON = 0x0000000D // Windows Vista and newer and(/or?) comctl6 only // _BS_COMMANDLINK = 0x0000000E // Windows Vista and newer and(/or?) comctl6 only // _BS_DEFCOMMANDLINK = 0x0000000F // Windows Vista and newer and(/or?) comctl6 only ) // Button messages. // TODO check if any are not defined on Windows 2000 const ( // from winuser.h _BM_GETCHECK = 0x00F0 _BM_SETCHECK = 0x00F1 _BM_GETSTATE = 0x00F2 _BM_SETSTATE = 0x00F3 _BM_SETSTYLE = 0x00F4 _BM_CLICK = 0x00F5 _BM_GETIMAGE = 0x00F6 _BM_SETIMAGE = 0x00F7 _BM_SETDONTCLICK = 0x00F8 ) // Button WM_COMMAND notifications. const ( // from winuser.h _BN_CLICKED = 0 _BN_PAINT = 1 _BN_HILITE = 2 _BN_UNHILITE = 3 _BN_DISABLE = 4 _BN_DOUBLECLICKED = 5 _BN_PUSHED = _BN_HILITE _BN_UNPUSHED = _BN_UNHILITE _BN_DBLCLK = _BN_DOUBLECLICKED _BN_SETFOCUS = 6 _BN_KILLFOCUS = 7 ) // Button check states. const ( // from winuser.h _BST_UNCHECKED = 0x0000 _BST_CHECKED = 0x0001 _BST_INDETERMINATE = 0x0002 ) /* var ( checkDlgButton = user32.NewProc("CheckDlgButton") checkRadioButton = user32.NewProc("CheckRadioButton") isDlgButtonChecked = user32.NewProc("IsDlgButtonChecked") ) func CheckDlgButton(hDlg HWND, nIDButton int, uCheck uint32) (err error) { r1, _, err := checkDlgButton.Call( uintptr(hDlg), uintptr(nIDButton), uintptr(uCheck)) if r1 == 0 { // failure return err } return nil } func CheckRadioButton(hDlg HWND, nIDFirstButton int, nIDLastButton int, nIDCheckButton int) (err error) { r1, _, err := checkRadioButton.Call( uintptr(hDlg), uintptr(nIDFirstButton), uintptr(nIDLastButton), uintptr(nIDCheckButton)) if r1 == 0 { // failure return err } return nil } // TODO handle errors func IsDlgButtonChecked(hDlg HWND, nIDButton int) (state uint32, err error) { r1, _, _ := isDlgButtonChecked.Call( uintptr(hDlg), uintptr(nIDButton)) return uint32(r1), nil } // Combobox styles. const ( // from winuser.h CBS_SIMPLE = 0x0001 CBS_DROPDOWN = 0x0002 CBS_DROPDOWNLIST = 0x0003 CBS_OWNERDRAWFIXED = 0x0010 CBS_OWNERDRAWVARIABLE = 0x0020 CBS_AUTOHSCROLL = 0x0040 CBS_OEMCONVERT = 0x0080 CBS_SORT = 0x0100 CBS_HASSTRINGS = 0x0200 CBS_NOINTEGRALHEIGHT = 0x0400 CBS_DISABLENOSCROLL = 0x0800 CBS_UPPERCASE = 0x2000 CBS_LOWERCASE = 0x4000 ) // Combobox messages. // TODO filter out messages not provided in windows 2000 const ( // from winuser.h CB_GETEDITSEL = 0x0140 CB_LIMITTEXT = 0x0141 CB_SETEDITSEL = 0x0142 CB_ADDSTRING = 0x0143 CB_DELETESTRING = 0x0144 CB_DIR = 0x0145 CB_GETCOUNT = 0x0146 CB_GETCURSEL = 0x0147 CB_GETLBTEXT = 0x0148 CB_GETLBTEXTLEN = 0x0149 CB_INSERTSTRING = 0x014A CB_RESETCONTENT = 0x014B CB_FINDSTRING = 0x014C CB_SELECTSTRING = 0x014D CB_SETCURSEL = 0x014E CB_SHOWDROPDOWN = 0x014F CB_GETITEMDATA = 0x0150 CB_SETITEMDATA = 0x0151 CB_GETDROPPEDCONTROLRECT = 0x0152 CB_SETITEMHEIGHT = 0x0153 CB_GETITEMHEIGHT = 0x0154 CB_SETEXTENDEDUI = 0x0155 CB_GETEXTENDEDUI = 0x0156 CB_GETDROPPEDSTATE = 0x0157 CB_FINDSTRINGEXACT = 0x0158 CB_SETLOCALE = 0x0159 CB_GETLOCALE = 0x015A CB_GETTOPINDEX = 0x015B CB_SETTOPINDEX = 0x015C CB_GETHORIZONTALEXTENT = 0x015D CB_SETHORIZONTALEXTENT = 0x015E CB_GETDROPPEDWIDTH = 0x015F CB_SETDROPPEDWIDTH = 0x0160 CB_INITSTORAGE = 0x0161 CB_MULTIPLEADDSTRING = 0x0163 CB_GETCOMBOBOXINFO = 0x0164 ) // Combobox WM_COMMAND notificaitons. // TODO filter out notifications not provided in windows 2000 const ( // from winuser.h CBN_ERRSPACE = (-1) // TODO this will blow up the Go compiler if it's used CBN_SELCHANGE = 1 CBN_DBLCLK = 2 CBN_SETFOCUS = 3 CBN_KILLFOCUS = 4 CBN_EDITCHANGE = 5 CBN_EDITUPDATE = 6 CBN_DROPDOWN = 7 CBN_CLOSEUP = 8 CBN_SELENDOK = 9 CBN_SELENDCANCEL = 10 ) // Edit control styles. const ( // from winuser.h ES_LEFT = 0x0000 ES_CENTER = 0x0001 ES_RIGHT = 0x0002 ES_MULTILINE = 0x0004 ES_UPPERCASE = 0x0008 ES_LOWERCASE = 0x0010 ES_PASSWORD = 0x0020 ES_AUTOVSCROLL = 0x0040 ES_AUTOHSCROLL = 0x0080 ES_NOHIDESEL = 0x0100 ES_OEMCONVERT = 0x0400 ES_READONLY = 0x0800 ES_WANTRETURN = 0x1000 ES_NUMBER = 0x2000 ) // Edit control messages. // TODO filter out messages not provided in windows 2000 const ( // from winuser.h EM_GETSEL = 0x00B0 EM_SETSEL = 0x00B1 EM_GETRECT = 0x00B2 EM_SETRECT = 0x00B3 EM_SETRECTNP = 0x00B4 EM_SCROLL = 0x00B5 EM_LINESCROLL = 0x00B6 EM_SCROLLCARET = 0x00B7 EM_GETMODIFY = 0x00B8 EM_SETMODIFY = 0x00B9 EM_GETLINECOUNT = 0x00BA EM_LINEINDEX = 0x00BB EM_SETHANDLE = 0x00BC EM_GETHANDLE = 0x00BD EM_GETTHUMB = 0x00BE EM_LINELENGTH = 0x00C1 EM_REPLACESEL = 0x00C2 EM_GETLINE = 0x00C4 EM_LIMITTEXT = 0x00C5 EM_CANUNDO = 0x00C6 EM_UNDO = 0x00C7 EM_FMTLINES = 0x00C8 EM_LINEFROMCHAR = 0x00C9 EM_SETTABSTOPS = 0x00CB EM_SETPASSWORDCHAR = 0x00CC EM_EMPTYUNDOBUFFER = 0x00CD EM_GETFIRSTVISIBLELINE = 0x00CE EM_SETREADONLY = 0x00CF EM_SETWORDBREAKPROC = 0x00D0 EM_GETWORDBREAKPROC = 0x00D1 EM_GETPASSWORDCHAR = 0x00D2 EM_SETMARGINS = 0x00D3 EM_GETMARGINS = 0x00D4 EM_SETLIMITTEXT = EM_LIMITTEXT // [;win40 Name change] EM_GETLIMITTEXT = 0x00D5 EM_POSFROMCHAR = 0x00D6 EM_CHARFROMPOS = 0x00D7 EM_SETIMESTATUS = 0x00D8 EM_GETIMESTATUS = 0x00D9 ) // Edit control WM_COMMAND notifications. // TODO filter out notifications not provided in windows 2000 const ( // from winuser.h EN_SETFOCUS = 0x0100 EN_KILLFOCUS = 0x0200 EN_CHANGE = 0x0300 EN_UPDATE = 0x0400 EN_ERRSPACE = 0x0500 EN_MAXTEXT = 0x0501 EN_HSCROLL = 0x0601 EN_VSCROLL = 0x0602 EN_ALIGN_LTR_EC = 0x0700 EN_ALIGN_RTL_EC = 0x0701 EC_LEFTMARGIN = 0x0001 EC_RIGHTMARGIN = 0x0002 EC_USEFONTINFO = 0xFFFF EMSIS_COMPOSITIONSTRING = 0x0001 EIMES_GETCOMPSTRATONCE = 0x0001 EIMES_CANCELCOMPSTRINFOCUS = 0x0002 EIMES_COMPLETECOMPSTRKILLFOCUS = 0x0004 ) // Listbox styles. const ( // from winuser.h LBS_NOTIFY = 0x0001 LBS_SORT = 0x0002 LBS_NOREDRAW = 0x0004 LBS_MULTIPLESEL = 0x0008 LBS_OWNERDRAWFIXED = 0x0010 LBS_OWNERDRAWVARIABLE = 0x0020 LBS_HASSTRINGS = 0x0040 LBS_USETABSTOPS = 0x0080 LBS_NOINTEGRALHEIGHT = 0x0100 LBS_MULTICOLUMN = 0x0200 LBS_WANTKEYBOARDINPUT = 0x0400 LBS_EXTENDEDSEL = 0x0800 LBS_DISABLENOSCROLL = 0x1000 LBS_NODATA = 0x2000 LBS_NOSEL = 0x4000 LBS_COMBOBOX = 0x8000 LBS_STANDARD = (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER) ) // Listbox messages. // TODO filter out messages not provided in windows 2000 const ( // from winuser.h LB_ADDSTRING = 0x0180 LB_INSERTSTRING = 0x0181 LB_DELETESTRING = 0x0182 LB_SELITEMRANGEEX = 0x0183 LB_RESETCONTENT = 0x0184 LB_SETSEL = 0x0185 LB_SETCURSEL = 0x0186 LB_GETSEL = 0x0187 LB_GETCURSEL = 0x0188 LB_GETTEXT = 0x0189 LB_GETTEXTLEN = 0x018A LB_GETCOUNT = 0x018B LB_SELECTSTRING = 0x018C LB_DIR = 0x018D LB_GETTOPINDEX = 0x018E LB_FINDSTRING = 0x018F LB_GETSELCOUNT = 0x0190 LB_GETSELITEMS = 0x0191 LB_SETTABSTOPS = 0x0192 LB_GETHORIZONTALEXTENT = 0x0193 LB_SETHORIZONTALEXTENT = 0x0194 LB_SETCOLUMNWIDTH = 0x0195 LB_ADDFILE = 0x0196 LB_SETTOPINDEX = 0x0197 LB_GETITEMRECT = 0x0198 LB_GETITEMDATA = 0x0199 LB_SETITEMDATA = 0x019A LB_SELITEMRANGE = 0x019B LB_SETANCHORINDEX = 0x019C LB_GETANCHORINDEX = 0x019D LB_SETCARETINDEX = 0x019E LB_GETCARETINDEX = 0x019F LB_SETITEMHEIGHT = 0x01A0 LB_GETITEMHEIGHT = 0x01A1 LB_FINDSTRINGEXACT = 0x01A2 LB_SETLOCALE = 0x01A5 LB_GETLOCALE = 0x01A6 LB_SETCOUNT = 0x01A7 LB_INITSTORAGE = 0x01A8 LB_ITEMFROMPOINT = 0x01A9 LB_MULTIPLEADDSTRING = 0x01B1 LB_GETLISTBOXINFO = 0x01B2 ) // Listbox WM_COMMAND notifications and message returns. // TODO filter out notifications not provided in windows 2000 const ( // from winuser.h LB_OKAY = 0 LB_ERR = (-1) // TODO this will blow up the Go compiler if it's used LBN_ERRSPACE = (-2) // TODO this will blow up the Go compiler if it's used LBN_SELCHANGE = 1 LBN_DBLCLK = 2 LBN_SELCANCEL = 3 LBN_SETFOCUS = 4 LBN_KILLFOCUS = 5 ) // Static control styles. const ( // from winuser.h SS_LEFT = 0x00000000 SS_CENTER = 0x00000001 SS_RIGHT = 0x00000002 SS_ICON = 0x00000003 SS_BLACKRECT = 0x00000004 SS_GRAYRECT = 0x00000005 SS_WHITERECT = 0x00000006 SS_BLACKFRAME = 0x00000007 SS_GRAYFRAME = 0x00000008 SS_WHITEFRAME = 0x00000009 SS_USERITEM = 0x0000000A SS_SIMPLE = 0x0000000B SS_LEFTNOWORDWRAP = 0x0000000C SS_OWNERDRAW = 0x0000000D SS_BITMAP = 0x0000000E SS_ENHMETAFILE = 0x0000000F SS_ETCHEDHORZ = 0x00000010 SS_ETCHEDVERT = 0x00000011 SS_ETCHEDFRAME = 0x00000012 SS_TYPEMASK = 0x0000001F SS_REALSIZECONTROL = 0x00000040 SS_NOPREFIX = 0x00000080 SS_NOTIFY = 0x00000100 SS_CENTERIMAGE = 0x00000200 SS_RIGHTJUST = 0x00000400 SS_REALSIZEIMAGE = 0x00000800 SS_SUNKEN = 0x00001000 SS_EDITCONTROL = 0x00002000 SS_ENDELLIPSIS = 0x00004000 SS_PATHELLIPSIS = 0x00008000 SS_WORDELLIPSIS = 0x0000C000 SS_ELLIPSISMASK = 0x0000C000 ) // Static control messages and WM_COMMAND notifications. const ( // from winuser.h STM_SETICON = 0x0170 STM_GETICON = 0x0171 STM_SETIMAGE = 0x0172 STM_GETIMAGE = 0x0173 STN_CLICKED = 0 STN_DBLCLK = 1 STN_ENABLE = 2 STN_DISABLE = 3 ) */