
' MinWin
' Windows support
' 12:53 19/06/2011
' ...
' 21:01 14/03/2017
' 09:05 19/03/2018
'
' WinData
' 16:05 10/03/2018
' Charles Pegge


'types
'http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx

  #if sizeof sys = 4
    def GetClassLongPtr   GetClassLong
    def SetClassLongPtr   SetClassLong
    def GetWindowLongPtr  GetWindowLong
    def SetWindowLongPtr  SetWindowLong
    def GetClassLongPtrA  GetClassLongA
    def SetClassLongPtrA  SetClassLongA
    def GetWindowLongPtrA GetWindowLongA
    def SetWindowLongPtrA SetWindowLongA
  #endif

  '================
  'EQUATES / MACROS
  '================

  % STD_INPUT_HANDLE     -10
  % STD_OUTPUT_HANDLE    -11
  % STD_ERROR_HANDLE     -12 
  % HANDLE_FLAG_INHERIT  0x1
  % STARTF_USESTDHANDLES 0x100



  % CS_VREDRAW      1
  % CS_HREDRAW      2
  % CS_DBLCLKS          0x0008
  % CS_OWNDC            0x0020
  % CS_CLASSDC          0x0040
  % CS_PARENTDC         0x0080
  % CS_NOCLOSE          0x0200
  % CS_SAVEBITS         0x0800
  % CS_BYTEALIGNCLIENT  0x1000
  % CS_BYTEALIGNWINDOW  0x2000
  % CS_GLOBALCLASS      0x4000
  % CS_IME              0x00010000
  % CS_DROPSHADOW       0x00020000

  % IDC_ARROW       32512

  'Layered Window Attributes
  % LWA_COLORKEY 0x00000001
  % LWA_ALPHA    0x00000002

  'Common RGB Colors

  % BLACK   0x000000
  % BLUE    0xFF0000
  % GREEN   0x00FF00
  % CYAN    0xFFFF00
  % RED     0x0000FF
  % MAGENTA 0xFF00FF
  % YELLOW  0x00FFFF
  % WHITE   0xFFFFFF
  % GRAY    0x808080
  % LTGRAY  0xC0C0C0

  % TRANSPARENT      1
  % OPAQUE           2

  % WHITE_BRUSH      0
  % LTGRAY_BRUSH     1
  % GRAY_BRUSH       2
  % DKGRAY_BRUSH     3
  % BLACK_BRUSH      4
  % HOLLOW_BRUSH     5
  % NULL_BRUSH       5

  % WHITE_PEN        6
  % BLACK_PEN        7
  % NULL_PEN         8

  % ANSI_FIXED_FONT  11
  % ANSI_VAR_FONT    12



  % SW_HIDE             0
  % SW_SHOWNORMAL       1
  % SW_NORMAL           1
  % SW_SHOWMINIMIZED    2
  % SW_SHOWMAXIMIZED    3
  % SW_MAXIMIZE         3
  % SW_SHOWNOACTIVATE   4
  % SW_SHOW             5
  % SW_MINIMIZE         6
  % SW_SHOWMINNOACTIVE  7
  % SW_SHOWNA           8
  % SW_RESTORE          9
  % SW_SHOWDEFAULT      10
  % SW_FORCEMINIMIZE    11
  % SW_MAX              11

 /*
 * Dialog Box Command IDs
 */

  % IDOK                1
  % IDCANCEL            2
  % IDABORT             3
  % IDRETRY             4
  % IDIGNORE            5
  % IDYES               6
  % IDNO                7

  % MB_OK                       0x00000000
  % MB_OKCANCEL                 0x00000001
  % MB_ABORTRETRYIGNORE         0x00000002
  % MB_YESNOCANCEL              0x00000003
  % MB_YESNO                    0x00000004
  % MB_RETRYCANCEL              0x00000005
  % MB_CANCELTRYCONTINUE        0x00000006
  % MB_ICONHAND                 0x00000010
  % MB_ICONQUESTION             0x00000020
  % MB_ICONEXCLAMATION          0x00000030
  % MB_ICONASTERISK             0x00000040
  % MB_USERICON                 0x00000080
  % MB_ICONWARNING              MB_ICONEXCLAMATION
  % MB_ICONERROR                MB_ICONHAND
  % MB_ICONINFORMATION          MB_ICONASTERISK
  % MB_ICONSTOP                 MB_ICONHAND
  % MB_DEFBUTTON1               0x00000000
  % MB_DEFBUTTON2               0x00000100
  % MB_DEFBUTTON3               0x00000200
  % MB_DEFBUTTON4               0x00000300
  % MB_APPLMODAL                0x00000000
  % MB_SYSTEMMODAL              0x00001000
  % MB_TASKMODAL                0x00002000
  % MB_HELP                     0x00004000 // Help Button
  % MB_NOFOCUS                  0x00008000
  % MB_SETFOREGROUND            0x00010000
  % MB_DEFAULT_DESKTOP_ONLY     0x00020000
  % MB_TOPMOST                  0x00040000
  % MB_RIGHT                    0x00080000
  % MB_RTLREADING               0x00100000
  % MB_SERVICE_NOTIFICATION     0x00200000
  % MB_SERVICE_NOTIFICATION_NT3X 0x00040000
  % MB_TYPEMASK                 0x0000000F
  % MB_ICONMASK                 0x000000F0
  % MB_DEFMASK                  0x00000F00
  % MB_MODEMASK                 0x00003000
  % MB_MISCMASK                 0x0000C000

  % DM_SPECVERSION 0x0320
  '
  % DM_ORIENTATION          0x00000001L
  % DM_PAPERSIZE            0x00000002L
  % DM_PAPERLENGTH          0x00000004L
  % DM_PAPERWIDTH           0x00000008L
  % DM_SCALE                0x00000010L
  % DM_POSITION             0x00000020L
  % DM_NUP                  0x00000040L
  % DM_DISPLAYORIENTATION   0x00000080L
  % DM_COPIES               0x00000100L
  % DM_DEFAULTSOURCE        0x00000200L
  % DM_PRINTQUALITY         0x00000400L
  % DM_COLOR                0x00000800L
  % DM_DUPLEX               0x00001000L
  % DM_YRESOLUTION          0x00002000L
  % DM_TTOPTION             0x00004000L
  % DM_COLLATE              0x00008000L
  % DM_FORMNAME             0x00010000L
  % DM_LOGPIXELS            0x00020000L
  % DM_BITSPERPEL           0x00040000L
  % DM_PELSWIDTH            0x00080000L
  % DM_PELSHEIGHT           0x00100000L
  % DM_DISPLAYFLAGS         0x00200000L
  % DM_DISPLAYFREQUENCY     0x00400000L
  % DM_ICMMETHOD            0x00800000L
  % DM_ICMINTENT            0x01000000L
  % DM_MEDIATYPE            0x02000000L
  % DM_DITHERTYPE           0x04000000L
  % DM_PANNINGWIDTH         0x08000000L
  % DM_PANNINGHEIGHT        0x10000000L
  % DM_DISPLAYFIXEDOUTPUT   0x20000000L

  /* Flags for ChangeDisplaySettings */
  % CDS_UPDATEREGISTRY           0x00000001
  % CDS_TEST                     0x00000002
  % CDS_FULLSCREEN               0x00000004
  % CDS_GLOBAL                   0x00000008
  % CDS_SET_PRIMARY              0x00000010
  % CDS_VIDEOPARAMETERS          0x00000020
  % CDS_ENABLE_UNSAFE_MODES      0x00000100
  % CDS_DISABLE_UNSAFE_MODES     0x00000200
  % CDS_RESET                    0x40000000
  % CDS_NORESET                  0x10000000

  /* Return values for ChangeDisplaySettings */

  % DISP_CHANGE_SUCCESSFUL       0
  % DISP_CHANGE_RESTART          1
  % DISP_CHANGE_FAILED          -1
  % DISP_CHANGE_BADMODE         -2
  % DISP_CHANGE_NOTUPDATED      -3
  % DISP_CHANGE_BADFLAGS        -4
  % DISP_CHANGE_BADPARAM        -5
  % DISP_CHANGE_BADDUALVIEW     -6


  % CW_USEDEFAULT       0x80000000


  % SM_CXSCREEN           0
  % SM_CYSCREEN           1

  % WA_INACTIVE           0
  % WA_ACTIVE             1
  % WA_CLICKACTIVE        2

  % WM_NULL               0
  % WM_CREATE             1
  % WM_DESTROY            2
  % WM_MOVE               3
  % WM_SIZE               5
  % WM_ACTIVATE           6

  % WM_SETFOCUS           7
  % WM_KILLFOCUS          8

  % WM_SETREDRAW          11
  % WM_SETTEXT            12
  % WM_GETTEXT            13
  % WM_GETTEXTLENGTH      14

  % WM_PAINT              15
  % WM_CLOSE              16
  % WM_QUIT               18
  % WM_ERASEBKGND         20

  % WM_SETFONT            0x030

  % WM_NOTIFY             0x04E
  % WM_HELP               0x053

  % WM_INPUT              0x0FF 
  % WM_KEYFIRST           0x100
  % WM_KEYDOWN            0x100
  % WM_KEYUP              0x101
  % WM_CHAR               0x102
  % WM_DEADCHAR           0x103
  % WM_SYSKEYDOWN         0x104
  % WM_SYSKEYUP           0x105
  % WM_SYSCHAR            0x106
  % WM_SYSDEADCHAR        0x107
  % WM_UNICHAR            0x109
  % WM_INITDIALOG         0x110
  % WM_COMMAND            0x111
  % WM_SYSCOMMAND         0x112
  % WM_TIMER              0x113
  % WM_HSCROLL            0x114
  % WM_VSCROLL            0x115

  % WM_CTLCOLORMSGBOX     0x0132
  % WM_CTLCOLOREDIT       0x0133
  % WM_CTLCOLORLISTBOX    0x0134
  % WM_CTLCOLORBTN        0x0135
  % WM_CTLCOLORDLG        0x0136
  % WM_CTLCOLORSCROLLBAR  0x0137
  % WM_CTLCOLORSTATIC     0x0138

  % WM_MOUSEMOVE          0x200
  % WM_LBUTTONDOWN        0x201
  % WM_LBUTTONUP          0x202
  % WM_LBUTTONDBLCLK      0x203
  % WM_RBUTTONDOWN        0x204
  % WM_RBUTTONUP          0x205
  % WM_RBUTTONDBLCLK      0x206
  % WM_MBUTTONDOWN        0x207
  % WM_MBUTTONUP          0x208
  % WM_MBUTTONDBLCLK      0x209
  % WM_MOUSEWHEEL         0x20A

  % WM_DROPFILES          0x0233

  % WM_USER               0x0400

  % 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

/*
 * Edit Control Notification Codes
 */
  % EN_SETFOCUS         0x0100
  % EN_KILLFOCUS        0x0200
  % EN_CHANGE           0x0300
  % EN_UPDATE           0x0400
  % EN_ERRSPACE         0x0500
  % EN_MAXTEXT          0x0501
  % EN_HSCROLL          0x0601
  % EN_VSCROLL          0x0602


  'Window Styles
  ==============
  % WS_OVERLAPPED       0x00000000
  % WS_CHILD            0x40000000
  % WS_OVERLAPPEDWINDOW 0x00cf0000
  % WS_POPUPWINDOW      0x80880000
  % WS_POPUP            0x80000000
  % WS_MINIMIZE         0x20000000
  % WS_VISIBLE          0x10000000
  % WS_DISABLED         0x08000000
  % WS_CLIPSIBLINGS     0x04000000
  % WS_CLIPCHILDREN     0x02000000
  % WS_MAXIMIZE         0x01000000
  % WS_CAPTION          0x00C00000    /* WS_BORDER | WS_DLGFRAME  */
  % WS_BORDER           0x00800000
  % WS_DLGFRAME         0x00400000
  % WS_VSCROLL          0x00200000
  % WS_HSCROLL          0x00100000
  % WS_SYSMENU          0x00080000
  % WS_THICKFRAME       0x00040000
  % WS_GROUP            0x00020000
  % WS_TABSTOP          0x00010000

  % WS_MINIMIZEBOX      0x00020000
  % WS_MAXIMIZEBOX      0x00010000


  % WS_TILED            WS_OVERLAPPED
  % WS_CHILDWINDOW      WS_CHILD
  % WS_ICONIC           WS_MINIMIZE
  % WS_SIZEBOX          WS_THICKFRAME
  % WS_TILEDWINDOW      WS_OVERLAPPEDWINDOA

  'Extended Window Styles
  =======================
  % WS_EX_ACCEPTFILES      0x00000010
  % WS_EX_APPWINDOW        0x00040000
  % WS_EX_CLIENTEDGE       0x00000200
  % WS_EX_COMPOSITED       0x02000000
  % WS_EX_CONTEXTHELP      0x00000400
  % WS_EX_CONTROLPARENT    0x00010000
  % WS_EX_DLGMODALFRAME    0x00000001
  % WS_EX_LAYERED          0x00080000
  % WS_EX_LAYOUTRTL        0x00400000
  % WS_EX_LEFT             0x00000000
  % WS_EX_LEFTSCROLLBAR    0x00004000
  % WS_EX_LTRREADING       0x00000000
  % WS_EX_MDICHILD         0x00000040
  % WS_EX_NOACTIVATE       0x08000000
  % WS_EX_NOINHERITLAYOUT  0x00100000
  % WS_EX_NOPARENTNOTIFY   0x00000004
  % WS_EX_OVERLAPPEDWINDOW WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE
  % WS_EX_PALETTEWINDOW    WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST
  % WS_EX_RIGHT            0x00001000
  % WS_EX_RIGHTSCROLLBAR   0x00000000
  % WS_EX_RTLREADING       0x00002000
  % WS_EX_STATICEDGE       0x00020000
  % WS_EX_TOOLWINDOW       0x00000080
  % WS_EX_TOPMOST          0x00000008
  % WS_EX_TRANSPARENT      0x00000020
  % WS_EX_WINDOWEDGE       0x00000100


  'Edit Control Styles
  ====================
  % 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


 /*
 * Button Control Styles
 */
  % BS_PUSHBUTTON       0x00000000L
  % BS_DEFPUSHBUTTON    0x00000001L
  % BS_CHECKBOX         0x00000002L
  % BS_AUTOCHECKBOX     0x00000003L
  % BS_RADIOBUTTON      0x00000004L
  % BS_3STATE           0x00000005L
  % BS_AUTO3STATE       0x00000006L
  % BS_GROUPBOX         0x00000007L
  % BS_USERBUTTON       0x00000008L
  % BS_AUTORADIOBUTTON  0x00000009L
  % BS_PUSHBOX          0x0000000AL
  % BS_OWNERDRAW        0x0000000BL
  % BS_TYPEMASK         0x0000000FL
  % BS_LEFTTEXT         0x00000020L
  % BS_TEXT             0x00000000L
  % BS_ICON             0x00000040L
  % BS_BITMAP           0x00000080L
  % BS_LEFT             0x00000100L
  % BS_RIGHT            0x00000200L
  % BS_CENTER           0x00000300L
  % BS_TOP              0x00000400L
  % BS_BOTTOM           0x00000800L
  % BS_VCENTER          0x00000C00L
  % BS_PUSHLIKE         0x00001000L
  % BS_MULTILINE        0x00002000L
  % BS_NOTIFY           0x00004000L
  % BS_FLAT             0x00008000L
  % BS_RIGHTBUTTON      BS_LEFTTEXT

/*
 * User Button Notification Codes
 */
  % 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 Control Messages
 */
  % 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

  % BST_UNCHECKED      0x0000
  % BST_CHECKED        0x0001
  % BST_INDETERMINATE  0x0002
  % BST_PUSHED         0x0004
  % BST_FOCUS          0x0008

  'LISTBOX

  % LB_ADDSTRING 0X180
  % LB_CTLCODE 0
  % LB_DELETESTRING 0X182
  % LB_DIR 0X18D
  % LB_ERR (-1)
  % LB_ERRSPACE (-2)
  % LB_FINDSTRING 0X18F
  % LB_FINDSTRINGEXACT 0X1A2
  % LB_GETANCHORINDEX 0X19D
  % LB_GETCARETINDEX 0X19F
  % LB_GETCOUNT 0X18B
  % LB_GETCURSEL 0X188
  % LB_GETHORIZONTALEXTENT 0X193
  % LB_GETITEMDATA 0X199
  % LB_GETITEMHEIGHT 0X1A1
  % LB_GETITEMRECT 0X198
  % LB_GETLOCALE 0X1A6
  % LB_GETSEL 0X187
  % LB_GETSELCOUNT 0X190
  % LB_GETSELITEMS 0X191
  % LB_GETTEXT 0X189
  % LB_GETTEXTLEN 0X18A
  % LB_GETTOPINDEX 0X18E
  % LB_INSERTSTRING 0X181
  % LB_MSGMAX 0X1A8
  % LB_OKAY 0
  % LB_RESETCONTENT 0X184
  % LB_SELECTSTRING 0X18C
  % LB_SELITEMRANGE 0X19B
  % LB_SELITEMRANGEEX 0X183
  % LB_SETANCHORINDEX 0X19C
  % LB_SETCARETINDEX 0X19E
  % LB_SETCOLUMNWIDTH 0X195
  % LB_SETCOUNT 0X1A7
  % LB_SETCURSEL 0X186
  % LB_SETHORIZONTALEXTENT 0X194
  % LB_SETITEMDATA 0X19A
  % LB_SETITEMHEIGHT 0X1A0
  % LB_SETLOCALE 0X1A5
  % LB_SETSEL 0X185
  % LB_SETTABSTOPS 0X192
  % LB_SETTOPINDEX 0X197
  % LBN_DBLCLK 2
  % LBN_ERRSPACE (-2)
  % LBN_KILLFOCUS 5
  % LBN_SELCANCEL 3
  % LBN_SELCHANGE 1
  % LBN_SETFOCUS 4
  % LBS_DISABLENOSCROLL 0X1000
  % LBS_EXTENDEDSEL 0X800
  % LBS_HASSTRINGS 0X40
  % LBS_MULTICOLUMN 0X200
  % LBS_MULTIPLESEL 0X8
  % LBS_NODATA 0X2000
  % LBS_NOINTEGRALHEIGHT 0X100
  % LBS_NOREDRAW 0X4
  % LBS_NOTIFY 0X1
  % LBS_OWNERDRAWFIXED 0X10
  % LBS_OWNERDRAWVARIABLE 0X20
  % LBS_SORT 0X2
  % LBS_STANDARD (LBS_NOTIFY Or LBS_SORT Or WS_VSCROLL Or WS_BORDER)
  % LBS_USETABSTOPS 0X80
  % LBS_WANTKEYBOARDINPUT 0X400
  % LBSELCHSTRING "commdlg_LBSelChangedNotify"

  'COMBOBOX

  % CB_ADDSTRING 0X143
  % CB_DELETESTRING 0X144
  % CB_DIR 0X145
  % CB_ERR (-1)
  % CB_ERRSPACE (-2)
  % CB_FINDSTRING 0X14C
  % CB_FINDSTRINGEXACT 0X158
  % CB_GETCOUNT 0X146
  % CB_GETCURSEL 0X147
  % CB_GETDROPPEDCONTROLRECT 0X152
  % CB_GETDROPPEDSTATE 0X157
  % CB_GETEDITSEL 0X140
  % CB_GETEXTENDEDUI 0X156
  % CB_GETITEMDATA 0X150
  % CB_GETITEMHEIGHT 0X154
  % CB_GETLBTEXT 0X148
  % CB_GETLBTEXTLEN 0X149
  % CB_GETLOCALE 0X15A
  % CB_INSERTSTRING 0X14A
  % CB_LIMITTEXT 0X141
  % CB_MSGMAX 0X15B
  % CB_OKAY 0
  % CB_RESETCONTENT 0X14B
  % CB_SELECTSTRING 0X14D
  % CB_SETCURSEL 0X14E
  % CB_SETEDITSEL 0X142
  % CB_SETEXTENDEDUI 0X155
  % CB_SETITEMDATA 0X151
  % CB_SETITEMHEIGHT 0X153
  % CB_SETLOCALE 0X159
  % CB_SHOWDROPDOWN 0X14F
  % CBF_FAIL_ADVISES 0X4000
  % CBF_FAIL_ALLSVRXACTIONS 0X3F000
  % CBF_FAIL_CONNECTIONS 0X2000
  % CBF_FAIL_EXECUTES 0X8000
  % CBF_FAIL_POKES 0X10000
  % CBF_FAIL_REQUESTS 0X20000
  % CBF_FAIL_SELFCONNECTIONS 0X1000
  % CBF_SKIP_ALLNOTIFICATIONS 0X3C0000
  % CBF_SKIP_CONNECT_CONFIRMS 0X40000
  % CBF_SKIP_DISCONNECTS 0X200000
  % CBF_SKIP_REGISTRATIONS 0X80000
  % CBF_SKIP_UNREGISTRATIONS 0X100000
  % CBM_CREATEDIB 0X2 
  % CBM_INIT 0X4 
  % CBN_CLOSEUP 8
  % CBN_DBLCLK 2
  % CBN_DROPDOWN 7
  % CBN_EDITCHANGE 5
  % CBN_EDITUPDATE 6
  % CBN_ERRSPACE (-1)
  % CBN_KILLFOCUS 4
  % CBN_SELCHANGE 1
  % CBN_SELENDCANCEL 10
  % CBN_SELENDOK 9
  % CBN_SETFOCUS 3

  'SCROLLBAR

  % SB_BOTH 3
  % SB_BOTTOM 7
  % SB_CTL 2
  % SB_ENDSCROLL 8
  % SB_HORZ 0
  % SB_LEFT 6
  % SB_LINEDOWN 1
  % SB_LINELEFT 0
  % SB_LINERIGHT 1
  % SB_LINEUP 0
  % SB_PAGEDOWN 3
  % SB_PAGELEFT 2
  % SB_PAGERIGHT 3
  % SB_PAGEUP 2
  % SB_RIGHT 7
  % SB_THUMBPOSITION 4
  % SB_THUMBTRACK 5
  % SB_TOP 6
  % SB_VERT 1
  % SBM_ENABLE_ARROWS 0XE4 
  % SBM_GETPOS 0XE1 
  % SBM_GETRANGE 0XE3 
  % SBM_SETPOS 0XE0 
  % SBM_SETRANGE 0XE2 
  % SBM_SETRANGEREDRAW 0XE6 
  % SBS_BOTTOMALIGN 0X4
  % SBS_HORZ 0X0
  % SBS_LEFTALIGN 0X2
  % SBS_RIGHTALIGN 0X4
  % SBS_SIZEBOX 0X8
  % SBS_SIZEBOXBOTTOMRIGHTALIGN 0X4
  % SBS_SIZEBOXTOPLEFTALIGN 0X2
  % SBS_TOPALIGN 0X2
  % SBS_VERT 0X1

  /*
   * Window field offsets for GetWindowLong()
  */

  % GWL_WNDPROC         -4
  % GWL_HINSTANCE       -6
  % GWL_HWNDPARENT      -8
  % GWL_STYLE           -16
  % GWL_EXSTYLE         -20
  % GWL_USERDATA        -21
  % GWL_ID              -12



  ' PIXELFORMATDESCRIPTOR flags

  % PFD_TYPE_RGBA       = 0
  % PFD_TYPE_COLORINDEX = 1
  % PFD_MAIN_PLANE      = 0
  % PFD_OVERLAY_PLANE   = 1
  % PFD_UNDERLAY_PLANE  =-1
  '
  % PFD_DOUBLEBUFFER          = &H00000001
  % PFD_STEREO                = &H00000002
  % PFD_DRAW_TO_WINDOW        = &H00000004
  % PFD_DRAW_TO_BITMAP        = &H00000008
  % PFD_SUPPORT_GDI           = &H00000010
  % PFD_SUPPORT_OPENGL        = &H00000020
  % PFD_GENERIC_FORMAT        = &H00000040
  % PFD_NEED_PALETTE          = &H00000080
  % PFD_NEED_SYSTEM_PALETTE   = &H00000100
  % PFD_SWAP_EXCHANGE         = &H00000200
  % PFD_SWAP_COPY             = &H00000400
  % PFD_SWAP_LAYER_BUFFERS    = &H00000800
  % PFD_GENERIC_ACCELERATED   = &H00001000
  % PFD_SUPPORT_DIRECTDRAW    = &H00002000

  ' PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only
  % PFD_DEPTH_DONTCARE        = &H20000000
  % PFD_DOUBLEBUFFER_DONTCARE = &H40000000
  % PFD_STEREO_DONTCARE       = &H80000000

  ' Font Weights
  % FW_DONTCARE   = 0
  % FW_THIN       = 100
  % FW_EXTRALIGHT = 200
  % FW_LIGHT      = 300
  % FW_NORMAL     = 400
  % FW_MEDIUM     = 500
  % FW_SEMIBOLD   = 600
  % FW_BOLD       = 700
  % FW_EXTRABOLD  = 800
  % FW_HEAVY      = 900

  % DEFAULT_QUALITY        = 0
  % DRAFT_QUALITY          = 1
  % PROOF_QUALITY          = 2
  % NONANTIALIASED_QUALITY = 3
  % ANTIALIASED_QUALITY    = 4

  % ANSI_CHARSET        = 0
  % DEFAULT_CHARSET     = 1
  % SYMBOL_CHARSET      = 2

  % OUT_TT_PRECIS       = 4
  % CLIP_DEFAULT_PRECIS = 0

  % DEFAULT_PITCH   = 0
  % FIXED_PITCH     = 1
  % VARIABLE_PITCH  = 2
  % MONO_FONT       = 8


  ' Font Families
  '
  % FF_DONTCARE = 0    ' Don't care or don't know.
  % FF_ROMAN    = 16   ' Variable stroke width, serifed.

  ' Times Roman, Century Schoolbook, etc.
  % FF_SWISS    = 32   ' Variable stroke width, sans-serifed.

  ' Helvetica, Swiss, etc.
  % FF_MODERN   = 48   ' Constant stroke width, serifed or sans-serifed.

  ' Pica, Elite, Courier, etc.
  % FF_SCRIPT     = 64 ' Cursive, etc.
  % FF_DECORATIVE = 80 ' Old English, etc.



/*
 * Virtual Keys, Standard Set
 */


  % VK_LBUTTON     0x01
  % VK_RBUTTON     0x02
  % VK_CANCEL      0x03
  % VK_MBUTTON     0x04    /* NOT contiguous with L & RBUTTON */
  % VK_BACK        0x08
  % VK_TAB         0x09
  % VK_CLEAR       0x0C
  % VK_RETURN      0x0D

  % VK_SHIFT       0x10
  % VK_CONTROL     0x11
  % VK_MENU        0x12
  % VK_PAUSE       0x13
  % VK_CAPITAL     0x14

  % VK_KANA        0x15
  % VK_HANGEUL     0x15  /* old name - should be here for compatibility */
  % VK_HANGUL      0x15
  % VK_JUNJA       0x17
  % VK_FINAL       0x18
  % VK_HANJA       0x19
  % VK_KANJI       0x19

  % VK_ESCAPE      0x1B

  % VK_CONVERT     0x1C
  % VK_NONCONVERT  0x1D
  % VK_ACCEPT      0x1E
  % VK_MODECHANGE  0x1F

  % VK_SPACE       0x20
  % VK_PRIOR       0x21
  % VK_NEXT        0x22
  % VK_END         0x23
  % VK_HOME        0x24
  % VK_LEFT        0x25
  % VK_UP          0x26
  % VK_RIGHT       0x27
  % VK_DOWN        0x28
  % VK_SELECT      0x29
  % VK_PRINT       0x2A
  % VK_EXECUTE     0x2B
  % VK_SNAPSHOT    0x2C
  % VK_INSERT      0x2D
  % VK_DELETE      0x2E
  % VK_HELP        0x2F

% VK_0          0x30 
% VK_1          0X31 
% VK_2          0X32 
% VK_3          0X33 
% VK_4          0X34 
% VK_5          0X35
% VK_6          0X36 
% VK_7          0X37 
% VK_8          0X38 
% VK_9          0X39 
% VK_@          0X40
% VK_A          0X41 
% VK_B          0X42 
% VK_C          0X43 
% VK_D          0X44 
% VK_E          0X45 
% VK_F          0X46 
% VK_G          0X47 
% VK_H          0X48 
% VK_I          0X49 
% VK_J          0X4A 
% VK_K          0X4B
% VK_L          0X4C 
% VK_M          0X4D 
% VK_N          0X4E 
% VK_O          0X4F 
% VK_P          0X50 
% VK_Q          0X51 
% VK_R          0X52 
% VK_S          0X53 
% VK_T          0X54 
% VK_U          0X55 
% VK_V          0X56 
% VK_W          0X57 
% VK_X          0X58 
% VK_Y          0X59 
% VK_Z          0X5A 
% VK_F1         0X70 
% VK_F2         0X71 
% VK_F3         0X72 
% VK_F4         0X73 
% VK_F5         0X74 
% VK_F6         0X75 
% VK_F7         0X76 
% VK_F8         0X77 
% VK_F9         0X78 
% VK_F10        0X79 
% VK_F11        0X7A 
% VK_F12        0X7B 
% VK_NUMLOCK    0X90 
% VK_OEM_SCROLL 0X91	 
% VK_LSHIFT     0XA0 
% VK_RSHIFT     0XA1 
% VK_LCONTR     0XA2	 
% VK_RCONTROL   0XA3
	

/*
 * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
 * 0x40 : unassigned
 * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
 */

  % VK_LWIN           0x5B
  % VK_RWIN           0x5C
  % VK_APPS           0x5D

  % VK_SLEEP          0x5F

  % VK_NUMPAD0        0x60
  % VK_NUMPAD1        0x61
  % VK_NUMPAD2        0x62
  % VK_NUMPAD3        0x63
  % VK_NUMPAD4        0x64
  % VK_NUMPAD5        0x65
  % VK_NUMPAD6        0x66
  % VK_NUMPAD7        0x67
  % VK_NUMPAD8        0x68
  % VK_NUMPAD9        0x69
  % VK_MULTIPLY       0x6A
  % VK_ADD            0x6B
  % VK_SEPARATOR      0x6C
  % VK_SUBTRACT       0x6D
  % VK_DECIMAL        0x6E
  % VK_DIVIDE         0x6F
  % VK_F1             0x70
  % VK_F2             0x71
  % VK_F3             0x72
  % VK_F4             0x73
  % VK_F5             0x74
  % VK_F6             0x75
  % VK_F7             0x76
  % VK_F8             0x77
  % VK_F9             0x78
  % VK_F10            0x79
  % VK_F11            0x7A
  % VK_F12            0x7B
  % VK_NUMLOCK        0x90
  % VK_SCROLL         0x91


  /*
  * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
  * Used only as parameters to GetAsyncKeyState() and GetKeyState().
  * No other API or message will distinguish left and right keys in this way.
  */
  % VK_LSHIFT         0xA0
  % VK_RSHIFT         0xA1
  % VK_LCONTROL       0xA2
  % VK_RCONTROL       0xA3
  % VK_LMENU          0xA4
  % VK_RMENU          0xA5


  % FILE_ATTRIBUTE_READONLY             0x00000001  
  % FILE_ATTRIBUTE_HIDDEN               0x00000002  
  % FILE_ATTRIBUTE_SYSTEM               0x00000004  
  % FILE_ATTRIBUTE_DIRECTORY            0x00000010  
  % FILE_ATTRIBUTE_ARCHIVE              0x00000020  
  % FILE_ATTRIBUTE_DEVICE               0x00000040  
  % FILE_ATTRIBUTE_NORMAL               0x00000080  
  % FILE_ATTRIBUTE_TEMPORARY            0x00000100  
  % FILE_ATTRIBUTE_SPARSE_FILE          0x00000200  
  % FILE_ATTRIBUTE_REPARSE_POINT        0x00000400  
  % FILE_ATTRIBUTE_COMPRESSED           0x00000800  
  % FILE_ATTRIBUTE_OFFLINE              0x00001000  
  % FILE_ATTRIBUTE_NOT_CONTENT_INDEXED  0x00002000  
  % FILE_ATTRIBUTE_ENCRYPTED            0x00004000  
  % FILE_ATTRIBUTE_VIRTUAL              0x00010000  


  /* Global Memory Flags */

  % GMEM_FIXED          0x0000
  % GMEM_MOVEABLE       0x0002
  % GMEM_NOCOMPACT      0x0010
  % GMEM_NODISCARD      0x0020
  % GMEM_ZEROINIT       0x0040
  % GMEM_MODIFY         0x0080
  % GMEM_DISCARDABLE    0x0100
  % GMEM_NOT_BANKED     0x1000
  % GMEM_SHARE          0x2000
  % GMEM_DDESHARE       0x2000
  % GMEM_NOTIFY         0x4000
  % GMEM_LOWER          GMEM_NOT_BANKED
  % GMEM_VALID_FLAGS    0x7F72
  % GMEM_INVALID_HANDLE 0x8000


  /*
  * Predefined Clipboard Formats
  */
  % CF_TEXT             1
  % CF_BITMAP           2
  % CF_METAFILEPICT     3
  % CF_SYLK             4
  % CF_DIF              5
  % CF_TIFF             6
  % CF_OEMTEXT          7
  % CF_DIB              8
  % CF_PALETTE          9
  % CF_PENDATA          10
  % CF_RIFF             11
  % CF_WAVE             12
  % CF_UNICODETEXT      13
  % CF_ENHMETAFILE      14

  % IDI_APPLICATION     32512
  % IDI_HAND            32513
  % IDI_QUESTION        32514
  % IDI_EXCLAMATION     32515
  % IDI_ASTERISK        32516
  % IDI_WINLOGO         32517
  % IDI_SHIELD          32518

  /*
  * System Menu Command Values
  */

  % SC_SIZE         0xF000
  % SC_MOVE         0xF010
  % SC_MINIMIZE     0xF020
  % SC_MAXIMIZE     0xF030
  % SC_NEXTWINDOW   0xF040
  % SC_PREVWINDOW   0xF050
  % SC_CLOSE        0xF060
  % SC_VSCROLL      0xF070
  % SC_HSCROLL      0xF080
  % SC_MOUSEMENU    0xF090
  % SC_KEYMENU      0xF100
  % SC_ARRANGE      0xF110
  % SC_RESTORE      0xF120
  % SC_TASKLIST     0xF130
  % SC_SCREENSAVE   0xF140
  % SC_HOTKEY       0xF150
  % SC_DEFAULT      0xF160
  % SC_MONITORPOWER 0xF170
  % SC_CONTEXTHELP  0xF180
  % SC_SEPARATOR    0xF00F

  'MENUS

  % MF_INSERT          0x00000000
  % MF_CHANGE          0x00000080
  % MF_APPEND          0x00000100
  % MF_DELETE          0x00000200
  % MF_REMOVE          0x00001000
  '
  % MF_BYCOMMAND       0x00000000
  % MF_BYPOSITION      0x00000400
  '
  % MF_SEPARATOR       0x00000800
  '
  % MF_ENABLED         0x00000000
  % MF_GRAYED          0x00000001
  % MF_DISABLED        0x00000002
  '
  % MF_UNCHECKED       0x00000000
  % MF_CHECKED         0x00000008
  % MF_USECHECKBITMAPS 0x00000200
  '
  % MF_STRING          0x00000000
  % MF_BITMAP          0x00000004
  % MF_OWNERDRAW       0x00000100
  '
  % MF_POPUP           0x00000010
  % MF_MENUBARBREAK    0x00000020
  % MF_MENUBREAK       0x00000040



  'FILES

  % GENERIC_WRITE    0x40000000
  % GENERIC_READ     0x80000000
  % FILE_SHARE_READ    1
  % FILE_SHARE_WRITE   2
  % OPEN_EXISTING    3
  % OPEN_ALWAYS      4


  'PeekMessage
  '
  % PM_NOREMOVE 0
  % PM_REMOVE   1
  % PM_NOYIELD  2

  '==========
  'STRUCTURES
  '==========


  % MAX_PATH             260
  % ERROR_NO_MORE_FILES  18
  % INVALID_HANDLE_VALUE 0

  typedef bool    BOOL
  typedef byte    BYTE  
  typedef zstring TCHAR
  typedef word    WORD
  typedef dword   DWORD
  typedef long    LONG


  type SECURITY_ATTRIBUTES
  dword  nLength
  sys    lpSecurityDescriptor
  bool   bInheritHandle
  end type

  type STARTUPINFO
  dword  cb
  char*  lpReserved
  char*  lpDesktop
  char*  lpTitle
  dword  dwX
  dword  dwY
  dword  dwXSize
  dword  dwYSize
  dword  dwXCountChars
  dword  dwYCountChars
  dword  dwFillAttribute
  dword  dwFlags
  word   wShowWindow
  word   cbReserved2
  byte*  lpReserved2
  sys    hStdInput
  sys    hStdOutput
  sys    hStdError
  end type

  type PROCESS_INFORMATION
  sys    hProcess
  sys    hThread
  dword  dwProcessId
  dword  dwThreadId
  end type


  typedef struct _FILETIME {
  DWORD dwLowDateTime
  DWORD dwHighDateTime
  } FILETIME, *PFILETIME


  typedef struct _WIN32_FIND_DATA {
  DWORD    dwFileAttributes
  FILETIME ftCreationTime
  FILETIME ftLastAccessTime
  FILETIME ftLastWriteTime
  DWORD    nFileSizeHigh
  DWORD    nFileSizeLow
  DWORD    dwReserved0
  DWORD    dwReserved1
  TCHAR    cFileName[MAX_PATH]
  TCHAR    cAlternateFileName[14]
  } WIN32_FIND_DATA, *PWIN32_FIND_DATA, *LPWIN32_FIND_DATA


  '40 bytes
  type WNDCLASS
  int style 
  sys lpfnwndproc
  int cbClsextra
  int  cbWndExtra
  sys hInstance
  sys hIcon
  sys hCursor
  sys hbrBackground
  sys lpszMenuName
  sys lpszClassName
  end type


  type WNDCLASSEX
  int cbSize
  int Style
  sys lpfnwndproc
  int cbClsextra
  int cbWndExtra
  sys hInstance
  sys hIcon
  sys hCursor
  sys hbrBackground
  sys lpszMenuName
  sys lpszClassName
  sys hIconSm
  end type


  type POINT
  long x
  long y
  end type


  '28 bytes
  type MSG
  sys   hwnd
  uint  message
  sys   wParam
  sys   lParam
  dword time
  POINT pt
  dword lPrivate
  end type


  type NMHDR
  sys    hwndFrom
  sys    idFrom
  uint   code
  end type

  type MSGFILTER 
  NMHDR nmhdr
  uint msg
  sys  wParam 
  sys  lParam
  end type

  type RECT
  long left
  long top
  long right
  long bottom
  end type


  type rgbacolor
  byte red
  byte green
  byte blue
  byte alpha
  =
  dword rgba
  end type

 
  type PAINTSTRUCT
  sys hDC
  bool fErase
  RECT rcPaint
  bool fRestore
  bool fIncUpdate
  byte rgbReserved[32]
  end type


  typedef struct tagPIXELFORMATDESCRIPTOR {
  WORD  nSize
  WORD  nVersion
  DWORD dwFlags
  BYTE  iPixelType
  BYTE  cColorBits
  BYTE  cRedBits
  BYTE  cRedShift
  BYTE  cGreenBits
  BYTE  cGreenShift
  BYTE  cBlueBits
  BYTE  cBlueShift
  BYTE  cAlphaBits
  BYTE  cAlphaShift
  BYTE  cAccumBits
  BYTE  cAccumRedBits
  BYTE  cAccumGreenBits
  BYTE  cAccumBlueBits
  BYTE  cAccumAlphaBits
  BYTE  cDepthBits
  BYTE  cStencilBits
  BYTE  cAuxBuffers
  BYTE  iLayerType
  BYTE  bReserved
  DWORD dwLayerMask
  DWORD dwVisibleMask
  DWORD dwDamageMask
  } PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR



  % LF_FACESIZE   32
  % CCHDEVICENAME 32
  % CCHFORMNAME   32

  typedef struct tagLOGFONT {
  LONG  lfHeight
  LONG  lfWidth
  LONG  lfEscapement
  LONG  lfOrientation
  LONG  lfWeight
  BYTE  lfItalic
  BYTE  lfUnderline
  BYTE  lfStrikeOut
  BYTE  lfCharSet
  BYTE  lfOutPrecision
  BYTE  lfClipPrecision
  BYTE  lfQuality
  BYTE  lfPitchAndFamily
  TCHAR lfFaceName[LF_FACESIZE]
  } LOGFONT, *PLOGFONT

/*
  type iLOGFONT {
  LONG  lfHeight
  LONG  lfWidth
  LONG  lfEscapement
  LONG  lfOrientation
  LONG  lfWeight
  BYTE  lfItalic
  BYTE  lfUnderline
  BYTE  lfStrikeOut
  BYTE  lfCharSet
  BYTE  lfOutPrecision
  BYTE  lfClipPrecision
  BYTE  lfQuality
  BYTE  lfPitchAndFamily
  TCHAR lfFaceName[LF_FACESIZE]
  } 
*/


  typedef struct _POINTL {
  LONG x;
  LONG y;
  } POINTL, *PPOINTL


  typedef struct _devicemode {
  TCHAR dmDeviceName[CCHDEVICENAME]
  WORD  dmSpecVersion
  WORD  dmDriverVersion
  WORD  dmSize
  WORD  dmDriverExtra
  DWORD dmFields
  union {
    struct {
      short dmOrientation
      short dmPaperSize
      short dmPaperLength
      short dmPaperWidth
      short dmScale
      short dmCopies
      short dmDefaultSource
      short dmPrintQuality
    };
    struct {
      POINTL dmPosition
      DWORD  dmDisplayOrientation
      DWORD  dmDisplayFixedOutput
    }
  };
  short dmColor
  short dmDuplex
  short dmYResolution
  short dmTTOption
  short dmCollate
  TCHAR dmFormName[CCHFORMNAME]
  WORD  dmLogPixels
  DWORD dmBitsPerPel
  DWORD dmPelsWidth
  DWORD dmPelsHeight
  union {
    DWORD dmDisplayFlags
    DWORD dmNup;
  };
  DWORD dmDisplayFrequency

   DWORD dmICMMethod
   DWORD dmICMIntent
   DWORD dmMediaType
   DWORD dmDitherType
   DWORD dmReserved1
   DWORD dmReserved2

   DWORD dmPanningWidth
   DWORD dmPanningHeight
 
  } DEVMODE, *PDEVMODE, *LPDEVMODE


  type MINMAXINFO
  POINT ptReserved
  POINT ptMaxSize
  POINT ptMaxPosition
  POINT ptMinTrackSize
  POINT ptMaxTrackSize
  end type

  type INITCOMMONCONTROLSEXt
  DWORD dwSize;
  DWORD dwICC;
  end type

  type CREATESTRUCT
  sys    lpCreateParams;
  sys    hInstance;
  sys    hMenu;
  sys    hwndParent;
  int    cy;
  int    cx;
  int    y;
  int    x;
  LONG   style;
  char*  lpszName;
  char*  lpszClass;
  DWORD  dwExStyle;
  end type


