Module:    Win32-controls
Copyright:    Original Code is Copyright (c) 1995-2004 Functional Objects, Inc.
              All rights reserved.
License:      See License.txt in this distribution for details.
Warranty:     Distributed WITHOUT WARRANTY OF ANY KIND

// This file is automatically generated from "commctrl.h"; do not edit.


define inline-only C-function InitCommonControls
  c-name: "InitCommonControls", c-modifiers: "__stdcall";
end;
define inline-only constant $ODT-HEADER                 =  100;
define inline-only constant $ODT-TAB                    =  101;
define inline-only constant $ODT-LISTVIEW               =  102;
define inline-only constant $LVM-FIRST                  = #x1000;
define inline-only constant $TV-FIRST                   = #x1100;
define inline-only constant $HDM-FIRST                  = #x1200;
define inline-only constant $TCM-FIRST                  = #x1300;

define inline-only function HANDLE-WM-NOTIFY (hwnd, wParam, lParam, fn);
   fn( hwnd,  wParam, c-type-cast(<LPNMHDR>, lParam))
end;
define inline-only constant $NM-OUTOFMEMORY             =   -1;
define inline-only constant $NM-CLICK                   =   -2;
define inline-only constant $NM-DBLCLK                  =   -3;
define inline-only constant $NM-RETURN                  =   -4;
define inline-only constant $NM-RCLICK                  =   -5;
define inline-only constant $NM-RDBLCLK                 =   -6;
define inline-only constant $NM-SETFOCUS                =   -7;
define inline-only constant $NM-KILLFOCUS               =   -8;
define inline-only constant $NM-FIRST                   =   -0;
define inline-only constant $NM-LAST                    =  -99;
define inline-only constant $LVN-FIRST                  = -100;
define inline-only constant $LVN-LAST                   = -199;
define inline-only constant $HDN-FIRST                  = -300;
define inline-only constant $HDN-LAST                   = -399;
define inline-only constant $TVN-FIRST                  = -400;
define inline-only constant $TVN-LAST                   = -499;
define inline-only constant $TTN-FIRST                  = -520;
define inline-only constant $TTN-LAST                   = -549;
define inline-only constant $TCN-FIRST                  = -550;
define inline-only constant $TCN-LAST                   = -580;
define inline-only constant $CDN-FIRST                  = -601;
define inline-only constant $CDN-LAST                   = -699;
define inline-only constant $TBN-FIRST                  = -700;
define inline-only constant $TBN-LAST                   = -720;
define inline-only constant $UDN-FIRST                  = -721;
define inline-only constant $UDN-LAST                   = -740;
define inline-only constant $MSGF-COMMCTRL-BEGINDRAG    = #x4200;
define inline-only constant $MSGF-COMMCTRL-SIZEHEADER   = #x4201;
define inline-only constant $MSGF-COMMCTRL-DRAGSELECT   = #x4202;
define inline-only constant $MSGF-COMMCTRL-TOOLBARCUST  = #x4203;
define inline-only constant $CLR-NONE                   = $FFFFFFFF;
define inline-only constant $CLR-DEFAULT                =
	as(<machine-word>, #xFF000000);
define C-subtype <HIMAGELIST> ( <C-void*> ) end;
define inline-only constant $ILC-MASK                   = #x0001;
define inline-only constant $ILC-COLOR                  = #x0000;
define inline-only constant $ILC-COLORDDB               = #x00FE;
define inline-only constant $ILC-COLOR4                 = #x0004;
define inline-only constant $ILC-COLOR8                 = #x0008;
define inline-only constant $ILC-COLOR16                = #x0010;
define inline-only constant $ILC-COLOR24                = #x0018;
define inline-only constant $ILC-COLOR32                = #x0020;
define inline-only constant $ILC-PALETTE                = #x0800;

define inline-only C-function ImageList-Create
  parameter cx         :: <C-int>;
  parameter cy         :: <C-int>;
  parameter flags      :: <UINT>;
  parameter cInitial   :: <C-int>;
  parameter cGrow      :: <C-int>;
  result value :: <HIMAGELIST>;
  c-name: "ImageList_Create", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-Destroy
  parameter himl       :: <HIMAGELIST>;
  result value :: <BOOL>;
  c-name: "ImageList_Destroy", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-GetImageCount
  parameter himl       :: <HIMAGELIST>;
  result value :: <C-int>;
  c-name: "ImageList_GetImageCount", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-Add
  parameter himl       :: <HIMAGELIST>;
  parameter hbmImage   :: <HBITMAP>;
  parameter hbmMask    :: <HBITMAP>;
  result value :: <C-int>;
  c-name: "ImageList_Add", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-ReplaceIcon
  parameter himl       :: <HIMAGELIST>;
  parameter i          :: <C-int>;
  parameter hicon      :: <HICON>;
  result value :: <C-int>;
  c-name: "ImageList_ReplaceIcon", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-SetBkColor
  parameter himl       :: <HIMAGELIST>;
  parameter clrBk      :: <COLORREF>;
  result value :: <COLORREF>;
  c-name: "ImageList_SetBkColor", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-GetBkColor
  parameter himl       :: <HIMAGELIST>;
  result value :: <COLORREF>;
  c-name: "ImageList_GetBkColor", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-SetOverlayImage
  parameter himl       :: <HIMAGELIST>;
  parameter iImage     :: <C-int>;
  parameter iOverlay   :: <C-int>;
  result value :: <BOOL>;
  c-name: "ImageList_SetOverlayImage", c-modifiers: "__stdcall";
end;

define inline-only function ImageList-AddIcon (himl, hicon);
  ImageList-ReplaceIcon(himl, -1, hicon)
end;
define inline-only constant $ILD-NORMAL                 = #x0000;
define inline-only constant $ILD-TRANSPARENT            = #x0001;
define inline-only constant $ILD-MASK                   = #x0010;
define inline-only constant $ILD-IMAGE                  = #x0020;
define inline-only constant $ILD-BLEND25                = #x0002;
define inline-only constant $ILD-BLEND50                = #x0004;
define inline-only constant $ILD-OVERLAYMASK            = #x0F00;

define inline-only function INDEXTOOVERLAYMASK (i);
  (ash(i,8))
end;

define inline-only C-function ImageList-Draw
  parameter himl       :: <HIMAGELIST>;
  parameter i          :: <C-int>;
  parameter hdcDst     :: <HDC>;
  parameter x          :: <C-int>;
  parameter y          :: <C-int>;
  parameter fStyle     :: <UINT>;
  result value :: <BOOL>;
  c-name: "ImageList_Draw", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-Replace
  parameter himl       :: <HIMAGELIST>;
  parameter i          :: <C-int>;
  parameter hbmImage   :: <HBITMAP>;
  parameter hbmMask    :: <HBITMAP>;
  result value :: <BOOL>;
  c-name: "ImageList_Replace", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-AddMasked
  parameter himl       :: <HIMAGELIST>;
  parameter hbmImage   :: <HBITMAP>;
  parameter crMask     :: <COLORREF>;
  result value :: <C-int>;
  c-name: "ImageList_AddMasked", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-DrawEx
  parameter himl       :: <HIMAGELIST>;
  parameter i          :: <C-int>;
  parameter hdcDst     :: <HDC>;
  parameter x          :: <C-int>;
  parameter y          :: <C-int>;
  parameter dx         :: <C-int>;
  parameter dy         :: <C-int>;
  parameter rgbBk      :: <COLORREF>;
  parameter rgbFg      :: <COLORREF>;
  parameter fStyle     :: <UINT>;
  result value :: <BOOL>;
  c-name: "ImageList_DrawEx", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-Remove
  parameter himl       :: <HIMAGELIST>;
  parameter i          :: <C-int>;
  result value :: <BOOL>;
  c-name: "ImageList_Remove", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-GetIcon
  parameter himl       :: <HIMAGELIST>;
  parameter i          :: <C-int>;
  parameter flags      :: <UINT>;
  result value :: <HICON>;
  c-name: "ImageList_GetIcon", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-LoadImage
  parameter hi         :: <HINSTANCE>;
  parameter lpbmp      :: <LPCSTR>;
  parameter cx         :: <C-int>;
  parameter cGrow      :: <C-int>;
  parameter crMask     :: <COLORREF>;
  parameter uType      :: <UINT>;
  parameter uFlags     :: <UINT>;
  result value :: <HIMAGELIST>;
  c-name: "ImageList_LoadImageA", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-BeginDrag
  parameter himlTrack  :: <HIMAGELIST>;
  parameter iTrack     :: <C-int>;
  parameter dxHotspot  :: <C-int>;
  parameter dyHotspot  :: <C-int>;
  result value :: <BOOL>;
  c-name: "ImageList_BeginDrag", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-EndDrag
  c-name: "ImageList_EndDrag", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-DragEnter
  parameter hwndLock   :: <HWND>;
  parameter x          :: <C-int>;
  parameter y          :: <C-int>;
  result value :: <BOOL>;
  c-name: "ImageList_DragEnter", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-DragLeave
  parameter hwndLock   :: <HWND>;
  result value :: <BOOL>;
  c-name: "ImageList_DragLeave", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-DragMove
  parameter x          :: <C-int>;
  parameter y          :: <C-int>;
  result value :: <BOOL>;
  c-name: "ImageList_DragMove", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-SetDragCursorImage
  parameter himlDrag   :: <HIMAGELIST>;
  parameter iDrag      :: <C-int>;
  parameter dxHotspot  :: <C-int>;
  parameter dyHotspot  :: <C-int>;
  result value :: <BOOL>;
  c-name: "ImageList_SetDragCursorImage", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-DragShowNolock
  parameter fShow      :: <BOOL>;
  result value :: <BOOL>;
  c-name: "ImageList_DragShowNolock", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-GetDragImage
  parameter ppt        :: <LPPOINT>;
  parameter pptHotspot :: <LPPOINT>;
  result value :: <HIMAGELIST>;
  c-name: "ImageList_GetDragImage", c-modifiers: "__stdcall";
end;

define inline-only function ImageList-RemoveAll (himl);
  ImageList-Remove(himl, -1)
end;

define inline-only function ImageList-ExtractIcon (hi, himl, i);
  ImageList-GetIcon(himl, i, 0)
end;

define inline-only function ImageList-LoadBitmap (hi, lpbmp, cx, cGrow, crMask);
  ImageList-LoadImage(hi, lpbmp, cx, cGrow, crMask, $IMAGE-BITMAP, 0)
end;

define inline-only C-function ImageList-Read
  parameter pstm       :: <LPSTREAM>;
  result value :: <HIMAGELIST>;
  c-name: "ImageList_Read", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-Write
  parameter himl       :: <HIMAGELIST>;
  parameter pstm       :: <LPSTREAM>;
  result value :: <BOOL>;
  c-name: "ImageList_Write", c-modifiers: "__stdcall";
end;

define C-struct <IMAGEINFO>
  sealed inline-only slot hbmImage-value :: <HBITMAP>;
  sealed inline-only slot hbmMask-value  :: <HBITMAP>;
  sealed inline-only slot Unused1-value  :: <C-int>;
  sealed inline-only slot Unused2-value  :: <C-int>;
  sealed inline-only slot rcImage-value  :: <RECT>;
  pack: 1;
  pointer-type-name: <LPIMAGEINFO>;
  c-name: "struct _IMAGEINFO";
end C-struct <IMAGEINFO>;

define inline-only C-function ImageList-GetIconSize
  parameter himl       :: <HIMAGELIST>;
  output parameter cx  :: <C-int*>;
  output parameter cy  :: <C-int*>;
  result value :: <BOOL>;
  c-name: "ImageList_GetIconSize", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-SetIconSize
  parameter himl       :: <HIMAGELIST>;
  parameter cx         :: <C-int>;
  parameter cy         :: <C-int>;
  result value :: <BOOL>;
  c-name: "ImageList_SetIconSize", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-GetImageInfo
  parameter himl       :: <HIMAGELIST>;
  parameter i          :: <C-int>;
  parameter pImageInfo :: <LPIMAGEINFO>;
  result value :: <BOOL>;
  c-name: "ImageList_GetImageInfo", c-modifiers: "__stdcall";
end;

define inline-only C-function ImageList-Merge
  parameter himl1      :: <HIMAGELIST>;
  parameter i1         :: <C-int>;
  parameter himl2      :: <HIMAGELIST>;
  parameter i2         :: <C-int>;
  parameter dx         :: <C-int>;
  parameter dy         :: <C-int>;
  result value :: <HIMAGELIST>;
  c-name: "ImageList_Merge", c-modifiers: "__stdcall";
end;
define constant $WC-HEADER     = "SysHeader32";
define inline-only constant $HDS-HORZ                   = #x0000;
define inline-only constant $HDS-BUTTONS                = #x0002;
define inline-only constant $HDS-HIDDEN                 = #x0008;
define inline constant <HDITEMA> = <HD-ITEMA>;
define inline constant <HD-ITEM> = <HDITEM>;

define C-struct <HD-ITEMA>
  sealed inline-only slot mask-value     :: <UINT>;
  sealed inline-only slot cxy-value      :: <C-int>;
  sealed inline-only slot pszText-value  :: <LPSTR>;
  sealed inline-only slot hbm-value      :: <HBITMAP>;
  sealed inline-only slot cchTextMax-value :: <C-int>;
  sealed inline-only slot fmt-value      :: <C-int>;
  sealed inline-only slot lParam-value   :: <LPARAM>;
  pack: 1;
  pointer-type-name: <LPHD-ITEMA>;
  c-name: "struct _HD_ITEMA";
end C-struct <HD-ITEMA>;
define inline constant <LPHDITEMA> = <LPHD-ITEMA>;
define inline constant <HDITEM> = <HD-ITEMA>;
define inline constant <LPHDITEM> = <LPHDITEMA>;
define inline-only constant $HDI-WIDTH                  = #x0001;
define inline-only constant $HDI-TEXT                   = #x0002;
define inline-only constant $HDI-FORMAT                 = #x0004;
define inline-only constant $HDI-LPARAM                 = #x0008;
define inline-only constant $HDI-BITMAP                 = #x0010;
define inline-only constant $HDF-LEFT                   =    0;
define inline-only constant $HDF-RIGHT                  =    1;
define inline-only constant $HDF-CENTER                 =    2;
define inline-only constant $HDF-JUSTIFYMASK            = #x0003;
define inline-only constant $HDF-RTLREADING             =    4;
define inline-only constant $HDF-OWNERDRAW              = #x8000;
define inline-only constant $HDF-STRING                 = #x4000;
define inline-only constant $HDF-BITMAP                 = #x2000;
define inline-only constant $HDM-GETITEMCOUNT           = #x1200;

define inline-only function Header-GetItemCount (hwndHD);
   SendMessage( hwndHD, $HDM-GETITEMCOUNT, 0, 0)
end;
define inline-only constant $HDM-INSERTITEM             = #x1201;

define inline-only function Header-InsertItem (hwndHD, i, phdi);
   SendMessage( hwndHD, $HDM-INSERTITEM,  i,
	pointer-address(check-type( phdi, /* const */ <LPHD-ITEM>)))
end;
define inline-only constant $HDM-DELETEITEM             = #x1202;

define inline-only function Header-DeleteItem (hwndHD, i);
   ~ zero?(SendMessage( hwndHD, $HDM-DELETEITEM,  i, 0))
end;
define inline-only constant $HDM-GETITEM                = #x1203;

define inline-only function Header-GetItem (hwndHD, i, phdi);
   ~ zero?(SendMessage( hwndHD, $HDM-GETITEM,  i,
	pointer-address(check-type( phdi, <LPHD-ITEM>))))
end;
define inline-only constant $HDM-SETITEM                = #x1204;

define inline-only function Header-SetItem (hwndHD, i, phdi);
   ~ zero?(SendMessage( hwndHD, $HDM-SETITEM,  i,
	pointer-address(check-type( phdi, /* const */ <LPHD-ITEM>))))
end;
define inline constant <HDLAYOUT> = <HD-LAYOUT>;

define C-struct <HD-LAYOUT>
  sealed inline-only slot prc-value      :: <LPRECT>;
  sealed inline-only slot pwpos-value    :: <LPWINDOWPOS>;
  pack: 1;
  pointer-type-name: <LPHD-LAYOUT>;
  c-name: "struct _HD_LAYOUT";
end C-struct <HD-LAYOUT>;
define inline constant <LPHDLAYOUT> = <LPHD-LAYOUT>;
define inline-only constant $HDM-LAYOUT                 = #x1205;

define inline-only function Header-Layout (hwndHD, playout);
   ~ zero?(SendMessage( hwndHD, $HDM-LAYOUT, 0,
	pointer-address(check-type( playout, <LPHD-LAYOUT>))))
end;
define inline-only constant $HHT-NOWHERE                = #x0001;
define inline-only constant $HHT-ONHEADER               = #x0002;
define inline-only constant $HHT-ONDIVIDER              = #x0004;
define inline-only constant $HHT-ONDIVOPEN              = #x0008;
define inline-only constant $HHT-ABOVE                  = #x0100;
define inline-only constant $HHT-BELOW                  = #x0200;
define inline-only constant $HHT-TORIGHT                = #x0400;
define inline-only constant $HHT-TOLEFT                 = #x0800;
define inline constant <HDHITTESTINFO> = <HD-HITTESTINFO>;

define C-struct <HD-HITTESTINFO>
  sealed inline-only slot pt-value       :: <POINT>;
  sealed inline-only slot flags-value    :: <UINT>;
  sealed inline-only slot iItem-value    :: <C-int>;
  pack: 1;
  pointer-type-name: <LPHD-HITTESTINFO>;
  c-name: "struct _HD_HITTESTINFO";
end C-struct <HD-HITTESTINFO>;
define inline constant <LPHDHITTESTINFO> = <LPHD-HITTESTINFO>;
define inline-only constant $HDM-HITTEST                = #x1206;
define inline-only constant $HDN-ITEMCHANGINGA          = -300;
define inline-only constant $HDN-ITEMCHANGINGW          = -320;
define inline-only constant $HDN-ITEMCHANGEDA           = -301;
define inline-only constant $HDN-ITEMCHANGEDW           = -321;
define inline-only constant $HDN-ITEMCLICKA             = -302;
define inline-only constant $HDN-ITEMCLICKW             = -322;
define inline-only constant $HDN-ITEMDBLCLICKA          = -303;
define inline-only constant $HDN-ITEMDBLCLICKW          = -323;
define inline-only constant $HDN-DIVIDERDBLCLICKA       = -305;
define inline-only constant $HDN-DIVIDERDBLCLICKW       = -325;
define inline-only constant $HDN-BEGINTRACKA            = -306;
define inline-only constant $HDN-BEGINTRACKW            = -326;
define inline-only constant $HDN-ENDTRACKA              = -307;
define inline-only constant $HDN-ENDTRACKW              = -327;
define inline-only constant $HDN-TRACKA                 = -308;
define inline-only constant $HDN-TRACKW                 = -328;
define inline constant $HDN-ITEMCHANGING = $HDN-ITEMCHANGINGA;
define inline constant $HDN-ITEMCHANGED = $HDN-ITEMCHANGEDA;
define inline constant $HDN-ITEMCLICK = $HDN-ITEMCLICKA;
define inline constant $HDN-ITEMDBLCLICK = $HDN-ITEMDBLCLICKA;
define inline constant $HDN-DIVIDERDBLCLICK = $HDN-DIVIDERDBLCLICKA;
define inline constant $HDN-BEGINTRACK = $HDN-BEGINTRACKA;
define inline constant $HDN-ENDTRACK = $HDN-ENDTRACKA;
define inline constant $HDN-TRACK = $HDN-TRACKA;
define inline constant <NMHEADERA> = <HD-NOTIFYA>;
define inline constant <HD-NOTIFY> = <NMHEADER>;

define C-struct <HD-NOTIFYA>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot iItem-value    :: <C-int>;
  sealed inline-only slot iButton-value  :: <C-int>;
  sealed inline-only slot pitem-value    :: <LPHD-ITEMA>;
  pack: 1;
  pointer-type-name: <LPHD-NOTIFYA>;
  c-name: "struct tagNMHEADERA";
end C-struct <HD-NOTIFYA>;
define inline constant <LPNMHEADERA> = <LPHD-NOTIFYA>;
define inline constant <NMHEADER> = <HD-NOTIFYA>;
define inline constant <LPNMHEADER> = <LPNMHEADERA>;

define C-struct <NMHDDISPINFOA>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot iItem-value    :: <C-int>;
  sealed inline-only slot mask-value     :: <UINT>;
  sealed inline-only slot pszText-value  :: <LPSTR>;
  sealed inline-only slot cchTextMax-value :: <C-int>;
  sealed inline-only slot iImage-value   :: <C-int>;
  sealed inline-only slot lParam-value   :: <LPARAM>;
  pack: 1;
  pointer-type-name: <LPNMHDDISPINFOA>;
  c-name: "struct tagNMHDDISPINFOA";
end C-struct <NMHDDISPINFOA>;
define inline constant <NMHDDISPINFO> = <NMHDDISPINFOA>;
define inline constant <LPNMHDDISPINFO> = <LPNMHDDISPINFOA>;
define constant $TOOLBARCLASSNAME = "ToolbarWindow32";

define C-struct <TBBUTTON>
  sealed inline-only slot iBitmap-value  :: <C-int>;
  sealed inline-only slot idCommand-value :: <C-int>;
  sealed inline-only slot fsState-value  :: <C-BYTE>;
  sealed inline-only slot fsStyle-value  :: <C-BYTE>;
  sealed inline-only array slot bReserved-array :: <C-BYTE>,
	length: 2, address-getter: bReserved-value;
  sealed inline-only slot dwData-value   :: <DWORD>;
  sealed inline-only slot iString-value  :: <C-int>;
  pack: 1;
  pointer-type-name: <LPTBBUTTON>;
  c-name: "struct _TBBUTTON";
end C-struct <TBBUTTON>;
define inline constant <PTBBUTTON> = <LPTBBUTTON>;
define inline constant <LPCTBBUTTON> =  /* const */ <LPTBBUTTON>;

define C-struct <COLORMAP>
  sealed inline-only slot from-value     :: <COLORREF>;
  sealed inline-only slot to-value       :: <COLORREF>;
  pack: 1;
  pointer-type-name: <LPCOLORMAP>;
  c-name: "struct _COLORMAP";
end C-struct <COLORMAP>;

define inline-only C-function CreateToolbarEx
  parameter hwnd       :: <HWND>;
  parameter ws         :: <DWORD>;
  parameter wID        :: <UINT>;
  parameter nBitmaps   :: <C-int>;
  parameter hBMInst    :: <HINSTANCE>;
  parameter wBMID      :: <UINT>;
  parameter lpButtons  :: <LPCTBBUTTON>;
  parameter iNumButtons :: <C-int>;
  parameter dxButton   :: <C-int>;
  parameter dyButton   :: <C-int>;
  parameter dxBitmap   :: <C-int>;
  parameter dyBitmap   :: <C-int>;
  parameter uStructSize :: <UINT>;
  result value :: <HWND>;
  c-name: "CreateToolbarEx", c-modifiers: "__stdcall";
end;

define inline-only C-function CreateMappedBitmap
  parameter hInstance  :: <HINSTANCE>;
  parameter idBitmap   :: <C-int>;
  parameter wFlags     :: <UINT>;
  parameter lpColorMap :: <LPCOLORMAP>;
  parameter iNumMaps   :: <C-int>;
  result value :: <HBITMAP>;
  c-name: "CreateMappedBitmap", c-modifiers: "__stdcall";
end;
define inline-only constant $CMB-MASKED                 = #x02;
define inline-only constant $TBSTATE-CHECKED            = #x01;
define inline-only constant $TBSTATE-PRESSED            = #x02;
define inline-only constant $TBSTATE-ENABLED            = #x04;
define inline-only constant $TBSTATE-HIDDEN             = #x08;
define inline-only constant $TBSTATE-INDETERMINATE      = #x10;
define inline-only constant $TBSTATE-WRAP               = #x20;
define inline-only constant $TBSTYLE-BUTTON             = #x0000;
define inline-only constant $TBSTYLE-SEP                = #x0001;
define inline-only constant $TBSTYLE-CHECK              = #x0002;
define inline-only constant $TBSTYLE-GROUP              = #x0004;
define inline-only constant $TBSTYLE-CHECKGROUP         =
	logior($TBSTYLE-GROUP, $TBSTYLE-CHECK);
define inline-only constant $TBSTYLE-TOOLTIPS           = #x0100;
define inline-only constant $TBSTYLE-WRAPABLE           = #x0200;
define inline-only constant $TBSTYLE-ALTDRAG            = #x0400;
define inline-only constant $TB-ENABLEBUTTON            = #x401;
define inline-only constant $TB-CHECKBUTTON             = #x402;
define inline-only constant $TB-PRESSBUTTON             = #x403;
define inline-only constant $TB-HIDEBUTTON              = #x404;
define inline-only constant $TB-INDETERMINATE           = #x405;
define inline-only constant $TB-ISBUTTONENABLED         = #x409;
define inline-only constant $TB-ISBUTTONCHECKED         = #x40A;
define inline-only constant $TB-ISBUTTONPRESSED         = #x40B;
define inline-only constant $TB-ISBUTTONHIDDEN          = #x40C;
define inline-only constant $TB-ISBUTTONINDETERMINATE   = #x40D;
define inline-only constant $TB-SETSTATE                = #x411;
define inline-only constant $TB-GETSTATE                = #x412;
define inline-only constant $TB-ADDBITMAP               = #x413;

define C-struct <TBADDBITMAP>
  sealed inline-only slot hInst-value    :: <HINSTANCE>;
  sealed inline-only slot nID-value      :: <UINT>;
  pack: 1;
  pointer-type-name: <LPTBADDBITMAP>;
  c-name: "struct tagTBADDBITMAP";
end C-struct <TBADDBITMAP>;
define inline-only constant $HINST-COMMCTRL             =
	make(<HINSTANCE>, address: -1);
define inline-only constant $IDB-STD-SMALL-COLOR        =    0;
define inline-only constant $IDB-STD-LARGE-COLOR        =    1;
define inline-only constant $IDB-VIEW-SMALL-COLOR       =    4;
define inline-only constant $IDB-VIEW-LARGE-COLOR       =    5;
define inline-only constant $STD-CUT                    =    0;
define inline-only constant $STD-COPY                   =    1;
define inline-only constant $STD-PASTE                  =    2;
define inline-only constant $STD-UNDO                   =    3;
define inline-only constant $STD-REDOW                  =    4;
define inline-only constant $STD-DELETE                 =    5;
define inline-only constant $STD-FILENEW                =    6;
define inline-only constant $STD-FILEOPEN               =    7;
define inline-only constant $STD-FILESAVE               =    8;
define inline-only constant $STD-PRINTPRE               =    9;
define inline-only constant $STD-PROPERTIES             =   10;
define inline-only constant $STD-HELP                   =   11;
define inline-only constant $STD-FIND                   =   12;
define inline-only constant $STD-REPLACE                =   13;
define inline-only constant $STD-PRINT                  =   14;
define inline-only constant $VIEW-LARGEICONS            =    0;
define inline-only constant $VIEW-SMALLICONS            =    1;
define inline-only constant $VIEW-LIST                  =    2;
define inline-only constant $VIEW-DETAILS               =    3;
define inline-only constant $VIEW-SORTNAME              =    4;
define inline-only constant $VIEW-SORTSIZE              =    5;
define inline-only constant $VIEW-SORTDATE              =    6;
define inline-only constant $VIEW-SORTTYPE              =    7;
define inline-only constant $VIEW-PARENTFOLDER          =    8;
define inline-only constant $VIEW-NETCONNECT            =    9;
define inline-only constant $VIEW-NETDISCONNECT         =   10;
define inline-only constant $VIEW-NEWFOLDER             =   11;
define inline-only constant $TB-ADDBUTTONS              = #x414;
define inline-only constant $TB-INSERTBUTTON            = #x415;
define inline-only constant $TB-DELETEBUTTON            = #x416;
define inline-only constant $TB-GETBUTTON               = #x417;
define inline-only constant $TB-BUTTONCOUNT             = #x418;
define inline-only constant $TB-COMMANDTOINDEX          = #x419;

define C-struct <TBSAVEPARAMSA>
  sealed inline-only slot hkr-value      :: <HKEY>;
  sealed inline-only slot pszSubKey-value :: <LPCSTR>;
  sealed inline-only slot pszValueName-value :: <LPCSTR>;
  pack: 1;
  pointer-type-name: <LPTBSAVEPARAMSA>;
  c-name: "struct tagTBSAVEPARAMSA";
end C-struct <TBSAVEPARAMSA>;
define inline constant <TBSAVEPARAMS> = <TBSAVEPARAMSA>;
define inline constant <LPTBSAVEPARAMS> = <LPTBSAVEPARAMSA>;
define inline-only constant $TB-SAVERESTOREA            = #x41A;
define inline-only constant $TB-SAVERESTOREW            = #x44C;
define inline-only constant $TB-CUSTOMIZE               = #x41B;
define inline-only constant $TB-ADDSTRINGA              = #x41C;
define inline-only constant $TB-ADDSTRINGW              = #x44D;
define inline-only constant $TB-GETITEMRECT             = #x41D;
define inline-only constant $TB-BUTTONSTRUCTSIZE        = #x41E;
define inline-only constant $TB-SETBUTTONSIZE           = #x41F;
define inline-only constant $TB-SETBITMAPSIZE           = #x420;
define inline-only constant $TB-AUTOSIZE                = #x421;
define inline-only constant $TB-GETTOOLTIPS             = #x423;
define inline-only constant $TB-SETTOOLTIPS             = #x424;
define inline-only constant $TB-SETPARENT               = #x425;
define inline-only constant $TB-SETROWS                 = #x427;
define inline-only constant $TB-GETROWS                 = #x428;
define inline-only constant $TB-SETCMDID                = #x42A;
define inline-only constant $TB-CHANGEBITMAP            = #x42B;
define inline-only constant $TB-GETBITMAP               = #x42C;
define inline-only constant $TB-GETBUTTONTEXTA          = #x42D;
define inline-only constant $TB-GETBUTTONTEXTW          = #x44B;
define inline-only constant $TB-REPLACEBITMAP           = #x42E;
define inline constant $TB-GETBUTTONTEXT = $TB-GETBUTTONTEXTA;
define inline constant $TB-SAVERESTORE = $TB-SAVERESTOREA;
define inline constant $TB-ADDSTRING = $TB-ADDSTRINGA;

define C-struct <TBREPLACEBITMAP>
  sealed inline-only slot hInstOld-value :: <HINSTANCE>;
  sealed inline-only slot nIDOld-value   :: <UINT>;
  sealed inline-only slot hInstNew-value :: <HINSTANCE>;
  sealed inline-only slot nIDNew-value   :: <UINT>;
  sealed inline-only slot nButtons-value :: <C-int>;
  pack: 1;
  pointer-type-name: <LPTBREPLACEBITMAP>;
end C-struct <TBREPLACEBITMAP>;
define inline-only constant $TBBF-LARGE                 = #x0001;
define inline-only constant $TB-GETBITMAPFLAGS          = #x429;
define inline-only constant $TBN-GETBUTTONINFOA         = -700;
define inline-only constant $TBN-GETBUTTONINFOW         = -720;
define inline-only constant $TBN-BEGINDRAG              = -701;
define inline-only constant $TBN-ENDDRAG                = -702;
define inline-only constant $TBN-BEGINADJUST            = -703;
define inline-only constant $TBN-ENDADJUST              = -704;
define inline-only constant $TBN-RESET                  = -705;
define inline-only constant $TBN-QUERYINSERT            = -706;
define inline-only constant $TBN-QUERYDELETE            = -707;
define inline-only constant $TBN-TOOLBARCHANGE          = -708;
define inline-only constant $TBN-CUSTHELP               = -709;
define inline constant $TBN-GETBUTTONINFO = $TBN-GETBUTTONINFOA;
define inline constant <NMTOOLBARA> = <TBNOTIFYA>;
define inline constant <LPNMTOOLBARA> = <LPTBNOTIFYA>;
define inline constant <TBNOTIFY> = <NMTOOLBAR>;
define inline constant <LPTBNOTIFY> = <LPNMTOOLBAR>;
define inline constant <NMTOOLBAR> = <TBNOTIFYA>;
define inline constant <LPNMTOOLBAR> = <LPTBNOTIFYA>;
define constant $TOOLTIPS-CLASS = "tooltips_class32";
define inline constant <TTTOOLINFOA> = <TOOLINFOA>;
define inline constant <LPTTTOOLINFOA> = <LPTOOLINFOA>;
define inline constant <LPTOOLINFO> = <LPTTTOOLINFO>;
define inline constant <TOOLINFO> = <TTTOOLINFO>;

define C-struct <TOOLINFOA>
  sealed inline-only slot cbSize-value   :: <UINT>;
  sealed inline-only slot uFlags-value   :: <UINT>;
  sealed inline-only slot hwnd-value     :: <HWND>;
  sealed inline-only slot uId-value      :: <UINT>;
  sealed inline-only slot rect-value     :: <RECT>;
  sealed inline-only slot hinst-value    :: <HINSTANCE>;
  sealed inline-only slot lpszText-value :: <LPSTR>;
  pack: 1;
  pointer-type-name: <LPTOOLINFOA>;
  c-name: "struct tagTOOLINFOA";
end C-struct <TOOLINFOA>;
define C-pointer-type <PTOOLINFOA> => <TOOLINFOA>;
define inline constant <TTTOOLINFO> = <TOOLINFOA>;
define inline constant <LPTTTOOLINFO> = <LPTOOLINFOA>;
define inline-only constant $TTS-ALWAYSTIP              = #x01;
define inline-only constant $TTS-NOPREFIX               = #x02;
define inline-only constant $TTF-IDISHWND               = #x0001;
define inline-only constant $TTF-CENTERTIP              = #x0002;
define inline-only constant $TTF-RTLREADING             = #x0004;
define inline-only constant $TTF-SUBCLASS               = #x0010;
define inline-only constant $TTDT-AUTOMATIC             =    0;
define inline-only constant $TTDT-RESHOW                =    1;
define inline-only constant $TTDT-AUTOPOP               =    2;
define inline-only constant $TTDT-INITIAL               =    3;
define inline-only constant $TTM-ACTIVATE               = #x401;
define inline-only constant $TTM-SETDELAYTIME           = #x403;
define inline-only constant $TTM-ADDTOOLA               = #x404;
define inline-only constant $TTM-ADDTOOLW               = #x432;
define inline-only constant $TTM-DELTOOLA               = #x405;
define inline-only constant $TTM-DELTOOLW               = #x433;
define inline-only constant $TTM-NEWTOOLRECTA           = #x406;
define inline-only constant $TTM-NEWTOOLRECTW           = #x434;
define inline-only constant $TTM-RELAYEVENT             = #x407;
define inline-only constant $TTM-GETTOOLINFOA           = #x408;
define inline-only constant $TTM-GETTOOLINFOW           = #x435;
define inline-only constant $TTM-SETTOOLINFOA           = #x409;
define inline-only constant $TTM-SETTOOLINFOW           = #x436;
define inline-only constant $TTM-HITTESTA               = #x40A;
define inline-only constant $TTM-HITTESTW               = #x437;
define inline-only constant $TTM-GETTEXTA               = #x40B;
define inline-only constant $TTM-GETTEXTW               = #x438;
define inline-only constant $TTM-UPDATETIPTEXTA         = #x40C;
define inline-only constant $TTM-UPDATETIPTEXTW         = #x439;
define inline-only constant $TTM-GETTOOLCOUNT           = #x40D;
define inline-only constant $TTM-ENUMTOOLSA             = #x40E;
define inline-only constant $TTM-ENUMTOOLSW             = #x43A;
define inline-only constant $TTM-GETCURRENTTOOLA        = #x40F;
define inline-only constant $TTM-GETCURRENTTOOLW        = #x43B;
define inline-only constant $TTM-WINDOWFROMPOINT        = #x410;
define inline constant $TTM-ADDTOOL = $TTM-ADDTOOLA;
define inline constant $TTM-DELTOOL = $TTM-DELTOOLA;
define inline constant $TTM-NEWTOOLRECT = $TTM-NEWTOOLRECTA;
define inline constant $TTM-GETTOOLINFO = $TTM-GETTOOLINFOA;
define inline constant $TTM-SETTOOLINFO = $TTM-SETTOOLINFOA;
define inline constant $TTM-HITTEST = $TTM-HITTESTA;
define inline constant $TTM-GETTEXT = $TTM-GETTEXTA;
define inline constant $TTM-UPDATETIPTEXT = $TTM-UPDATETIPTEXTA;
define inline constant $TTM-ENUMTOOLS = $TTM-ENUMTOOLSA;
define inline constant $TTM-GETCURRENTTOOL = $TTM-GETCURRENTTOOLA;
define inline constant <LPTTHITTESTINFOA> = <LPHITTESTINFOA>;
define inline constant <LPHITTESTINFO> = <LPTTHITTESTINFO>;

define C-struct <TTHITTESTINFOA>
  sealed inline-only slot hwnd-value     :: <HWND>;
  sealed inline-only slot pt-value       :: <POINT>;
  sealed inline-only slot ti-value       :: <TTTOOLINFOA>;
  pack: 1;
  pointer-type-name: <LPHITTESTINFOA>;
  c-name: "struct _TT_HITTESTINFOA";
end C-struct <TTHITTESTINFOA>;
define inline constant <TTHITTESTINFO> = <TTHITTESTINFOA>;
define inline constant <LPTTHITTESTINFO> = <LPHITTESTINFOA>;
define inline-only constant $TTN-GETDISPINFOA           = -520;
define inline-only constant $TTN-GETDISPINFOW           = -530;
define inline-only constant $TTN-SHOW                   = -521;
define inline-only constant $TTN-POP                    = -522;
define inline constant $TTN-GETDISPINFO = $TTN-GETDISPINFOA;
define inline constant <NMTTDISPINFOA> = <TOOLTIPTEXTA>;
define inline constant <LPNMTTDISPINFOA> = <LPTOOLTIPTEXTA>;
define inline constant <TOOLTIPTEXT> = <NMTTDISPINFO>;
define inline constant <LPTOOLTIPTEXT> = <LPNMTTDISPINFO>;

define C-struct <TOOLTIPTEXTA>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot lpszText-value :: <LPSTR>;
  sealed inline-only array slot szText-array :: <C-char>, length: 80,
	address-getter: szText-value;
  sealed inline-only slot hinst-value    :: <HINSTANCE>;
  sealed inline-only slot uFlags-value   :: <UINT>;
  pack: 1;
  pointer-type-name: <LPTOOLTIPTEXTA>;
  c-name: "struct tagNMTTDISPIFNOA";
end C-struct <TOOLTIPTEXTA>;
define inline constant <NMTTDISPINFO> = <TOOLTIPTEXTA>;
define inline constant <LPNMTTDISPINFO> = <LPTOOLTIPTEXTA>;
define inline-only constant $SBARS-SIZEGRIP             = #x0100;

define inline-only C-function DrawStatusText
  parameter hDC        :: <HDC>;
  parameter lprc       :: <LPRECT>;
  parameter pszText    :: <LPCSTR>;
  parameter uFlags     :: <UINT>;
  c-name: "DrawStatusTextA", c-modifiers: "__stdcall";
end;

define inline-only C-function CreateStatusWindow
  parameter style      :: <LONG>;
  parameter lpszText   :: <LPCSTR>;
  parameter hwndParent :: <HWND>;
  parameter wID        :: <UINT>;
  result value :: <HWND>;
  c-name: "CreateStatusWindowA", c-modifiers: "__stdcall";
end;
define constant $STATUSCLASSNAME = "msctls_statusbar32";
define inline-only constant $SB-SETTEXTA                = #x401;
define inline-only constant $SB-SETTEXTW                = #x40B;
define inline-only constant $SB-GETTEXTA                = #x402;
define inline-only constant $SB-GETTEXTW                = #x40D;
define inline-only constant $SB-GETTEXTLENGTHA          = #x403;
define inline-only constant $SB-GETTEXTLENGTHW          = #x40C;
define inline constant $SB-GETTEXT = $SB-GETTEXTA;
define inline constant $SB-SETTEXT = $SB-SETTEXTA;
define inline constant $SB-GETTEXTLENGTH = $SB-GETTEXTLENGTHA;
define inline-only constant $SB-SETPARTS                = #x404;
define inline-only constant $SB-GETPARTS                = #x406;
define inline-only constant $SB-GETBORDERS              = #x407;
define inline-only constant $SB-SETMINHEIGHT            = #x408;
define inline-only constant $SB-SIMPLE                  = #x409;
define inline-only constant $SB-GETRECT                 = #x40A;
define inline-only constant $SBT-OWNERDRAW              = #x1000;
define inline-only constant $SBT-NOBORDERS              = #x0100;
define inline-only constant $SBT-POPOUT                 = #x0200;
define inline-only constant $SBT-RTLREADING             = #x0400;

define inline-only C-function MenuHelp
  parameter uMsg       :: <UINT>;
  parameter wParam     :: <WPARAM>;
  parameter lParam     :: <LPARAM>;
  parameter hMainMenu  :: <HMENU>;
  parameter hInst      :: <HINSTANCE>;
  parameter hwndStatus :: <HWND>;
  parameter lpwIDs     :: <LPUINT>;
  c-name: "MenuHelp", c-modifiers: "__stdcall";
end;

define inline-only C-function ShowHideMenuCtl
  parameter hWnd       :: <HWND>;
  parameter uFlags     :: <UINT>;
  output parameter lpInfo :: <LPint>;
  result value :: <BOOL>;
  c-name: "ShowHideMenuCtl", c-modifiers: "__stdcall";
end;

define inline-only C-function GetEffectiveClientRect
  parameter hWnd       :: <HWND>;
  parameter lprc       :: <LPRECT>;
  output parameter lpInfo :: <LPint>;
  c-name: "GetEffectiveClientRect", c-modifiers: "__stdcall";
end;
define constant $TRACKBAR-CLASS = "msctls_trackbar32";
define inline-only constant $TBS-AUTOTICKS              = #x0001;
define inline-only constant $TBS-VERT                   = #x0002;
define inline-only constant $TBS-HORZ                   = #x0000;
define inline-only constant $TBS-TOP                    = #x0004;
define inline-only constant $TBS-BOTTOM                 = #x0000;
define inline-only constant $TBS-LEFT                   = #x0004;
define inline-only constant $TBS-RIGHT                  = #x0000;
define inline-only constant $TBS-BOTH                   = #x0008;
define inline-only constant $TBS-NOTICKS                = #x0010;
define inline-only constant $TBS-ENABLESELRANGE         = #x0020;
define inline-only constant $TBS-FIXEDLENGTH            = #x0040;
define inline-only constant $TBS-NOTHUMB                = #x0080;
define inline-only constant $TBM-GETPOS                 = $WM-USER;
define inline-only constant $TBM-GETRANGEMIN            = #x401;
define inline-only constant $TBM-GETRANGEMAX            = #x402;
define inline-only constant $TBM-GETTIC                 = #x403;
define inline-only constant $TBM-SETTIC                 = #x404;
define inline-only constant $TBM-SETPOS                 = #x405;
define inline-only constant $TBM-SETRANGE               = #x406;
define inline-only constant $TBM-SETRANGEMIN            = #x407;
define inline-only constant $TBM-SETRANGEMAX            = #x408;
define inline-only constant $TBM-CLEARTICS              = #x409;
define inline-only constant $TBM-SETSEL                 = #x40A;
define inline-only constant $TBM-SETSELSTART            = #x40B;
define inline-only constant $TBM-SETSELEND              = #x40C;
define inline-only constant $TBM-GETPTICS               = #x40E;
define inline-only constant $TBM-GETTICPOS              = #x40F;
define inline-only constant $TBM-GETNUMTICS             = #x410;
define inline-only constant $TBM-GETSELSTART            = #x411;
define inline-only constant $TBM-GETSELEND              = #x412;
define inline-only constant $TBM-CLEARSEL               = #x413;
define inline-only constant $TBM-SETTICFREQ             = #x414;
define inline-only constant $TBM-SETPAGESIZE            = #x415;
define inline-only constant $TBM-GETPAGESIZE            = #x416;
define inline-only constant $TBM-SETLINESIZE            = #x417;
define inline-only constant $TBM-GETLINESIZE            = #x418;
define inline-only constant $TBM-GETTHUMBRECT           = #x419;
define inline-only constant $TBM-GETCHANNELRECT         = #x41A;
define inline-only constant $TBM-SETTHUMBLENGTH         = #x41B;
define inline-only constant $TBM-GETTHUMBLENGTH         = #x41C;
define inline-only constant $TB-LINEUP                  =    0;
define inline-only constant $TB-LINEDOWN                =    1;
define inline-only constant $TB-PAGEUP                  =    2;
define inline-only constant $TB-PAGEDOWN                =    3;
define inline-only constant $TB-THUMBPOSITION           =    4;
define inline-only constant $TB-THUMBTRACK              =    5;
define inline-only constant $TB-TOP                     =    6;
define inline-only constant $TB-BOTTOM                  =    7;
define inline-only constant $TB-ENDTRACK                =    8;

define C-struct <DRAGLISTINFO>
  sealed inline-only slot uNotification-value :: <UINT>;
  sealed inline-only slot hwnd-value     :: <HWND>;
  sealed inline-only slot ptCursor-value :: <POINT>;
  pack: 1;
  pointer-type-name: <LPDRAGLISTINFO>;
  c-name: "struct tagDRAGLISTINFO";
end C-struct <DRAGLISTINFO>;
define inline-only constant $DL-BEGINDRAG               = #x485;
define inline-only constant $DL-DRAGGING                = #x486;
define inline-only constant $DL-DROPPED                 = #x487;
define inline-only constant $DL-CANCELDRAG              = #x488;
define inline-only constant $DL-CURSORSET               =    0;
define inline-only constant $DL-STOPCURSOR              =    1;
define inline-only constant $DL-COPYCURSOR              =    2;
define inline-only constant $DL-MOVECURSOR              =    3;

define inline-only C-function MakeDragList
  parameter hLB        :: <HWND>;
  result value :: <BOOL>;
  c-name: "MakeDragList", c-modifiers: "__stdcall";
end;

define inline-only C-function DrawInsert
  parameter handParent :: <HWND>;
  parameter hLB        :: <HWND>;
  parameter nItem      :: <C-int>;
  c-name: "DrawInsert", c-modifiers: "__stdcall";
end;

define inline-only C-function LBItemFromPt
  parameter hLB        :: <HWND>;
  parameter pt         :: <POINT>;
  parameter bAutoScroll :: <BOOL>;
  result value :: <C-int>;
  c-name: "LBItemFromPt", c-modifiers: "__stdcall";
end;
define constant $UPDOWN-CLASS  = "msctls_updown32";

define C-struct <UDACCEL>
  sealed inline-only slot nSec-value     :: <UINT>;
  sealed inline-only slot nInc-value     :: <UINT>;
  pack: 1;
  pointer-type-name: <LPUDACCEL>;
  c-name: "struct _UDACCEL";
end C-struct <UDACCEL>;
define inline-only constant $UD-MAXVAL                  = #x7fff;
define inline-only constant $UD-MINVAL                  =
	-$UD-MAXVAL;
define inline-only constant $UDS-WRAP                   = #x0001;
define inline-only constant $UDS-SETBUDDYINT            = #x0002;
define inline-only constant $UDS-ALIGNRIGHT             = #x0004;
define inline-only constant $UDS-ALIGNLEFT              = #x0008;
define inline-only constant $UDS-AUTOBUDDY              = #x0010;
define inline-only constant $UDS-ARROWKEYS              = #x0020;
define inline-only constant $UDS-HORZ                   = #x0040;
define inline-only constant $UDS-NOTHOUSANDS            = #x0080;
define inline-only constant $UDM-SETRANGE               = #x465;
define inline-only constant $UDM-GETRANGE               = #x466;
define inline-only constant $UDM-SETPOS                 = #x467;
define inline-only constant $UDM-GETPOS                 = #x468;
define inline-only constant $UDM-SETBUDDY               = #x469;
define inline-only constant $UDM-GETBUDDY               = #x46A;
define inline-only constant $UDM-SETACCEL               = #x46B;
define inline-only constant $UDM-GETACCEL               = #x46C;
define inline-only constant $UDM-SETBASE                = #x46D;
define inline-only constant $UDM-GETBASE                = #x46E;

define inline-only C-function CreateUpDownControl
  parameter dwStyle    :: <DWORD>;
  parameter x          :: <C-int>;
  parameter y          :: <C-int>;
  parameter cx         :: <C-int>;
  parameter cy         :: <C-int>;
  parameter hParent    :: <HWND>;
  parameter nID        :: <C-int>;
  parameter hInst      :: <HINSTANCE>;
  parameter hBuddy     :: <HWND>;
  parameter nUpper     :: <C-int>;
  parameter nLower     :: <C-int>;
  parameter nPos       :: <C-int>;
  result value :: <HWND>;
  c-name: "CreateUpDownControl", c-modifiers: "__stdcall";
end;
define inline constant <NMUPDOWN> = <NM-UPDOWN>;
define inline constant <LPNMUPDOWN> = <LPNM-UPDOWN>;

define C-struct <NM-UPDOWN>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot iPos-value     :: <C-int>;
  sealed inline-only slot iDelta-value   :: <C-int>;
  pack: 1;
  pointer-type-name: <LPNM-UPDOWN>;
  c-name: "struct _NM_UPDOWN";
end C-struct <NM-UPDOWN>;
define inline-only constant $UDN-DELTAPOS               = -722;
define constant $PROGRESS-CLASS = "msctls_progress32";
define inline-only constant $PBM-SETRANGE               = #x401;
define inline-only constant $PBM-SETPOS                 = #x402;
define inline-only constant $PBM-DELTAPOS               = #x403;
define inline-only constant $PBM-SETSTEP                = #x404;
define inline-only constant $PBM-STEPIT                 = #x405;
define inline-only constant $HOTKEYF-SHIFT              = #x01;
define inline-only constant $HOTKEYF-CONTROL            = #x02;
define inline-only constant $HOTKEYF-ALT                = #x04;
define inline-only constant $HOTKEYF-EXT                = #x08;
define inline-only constant $HKCOMB-NONE                = #x0001;
define inline-only constant $HKCOMB-S                   = #x0002;
define inline-only constant $HKCOMB-C                   = #x0004;
define inline-only constant $HKCOMB-A                   = #x0008;
define inline-only constant $HKCOMB-SC                  = #x0010;
define inline-only constant $HKCOMB-SA                  = #x0020;
define inline-only constant $HKCOMB-CA                  = #x0040;
define inline-only constant $HKCOMB-SCA                 = #x0080;
define inline-only constant $HKM-SETHOTKEY              = #x401;
define inline-only constant $HKM-GETHOTKEY              = #x402;
define inline-only constant $HKM-SETRULES               = #x403;
define constant $HOTKEY-CLASS  = "msctls_hotkey32";
define inline-only constant $CCS-TOP                    = #x00000001;
define inline-only constant $CCS-NOMOVEY                = #x00000002;
define inline-only constant $CCS-BOTTOM                 = #x00000003;
define inline-only constant $CCS-NORESIZE               = #x00000004;
define inline-only constant $CCS-NOPARENTALIGN          = #x00000008;
define inline-only constant $CCS-ADJUSTABLE             = #x00000020;
define inline-only constant $CCS-NODIVIDER              = #x00000040;
define constant $WC-LISTVIEW   = "SysListView32";
define inline-only constant $LVS-ICON                   = #x0000;
define inline-only constant $LVS-REPORT                 = #x0001;
define inline-only constant $LVS-SMALLICON              = #x0002;
define inline-only constant $LVS-LIST                   = #x0003;
define inline-only constant $LVS-TYPEMASK               = #x0003;
define inline-only constant $LVS-SINGLESEL              = #x0004;
define inline-only constant $LVS-SHOWSELALWAYS          = #x0008;
define inline-only constant $LVS-SORTASCENDING          = #x0010;
define inline-only constant $LVS-SORTDESCENDING         = #x0020;
define inline-only constant $LVS-SHAREIMAGELISTS        = #x0040;
define inline-only constant $LVS-NOLABELWRAP            = #x0080;
define inline-only constant $LVS-AUTOARRANGE            = #x0100;
define inline-only constant $LVS-EDITLABELS             = #x0200;
define inline-only constant $LVS-NOSCROLL               = #x2000;
define inline-only constant $LVS-TYPESTYLEMASK          = #xfc00;
define inline-only constant $LVS-ALIGNTOP               = #x0000;
define inline-only constant $LVS-ALIGNLEFT              = #x0800;
define inline-only constant $LVS-ALIGNMASK              = #x0c00;
define inline-only constant $LVS-OWNERDRAWFIXED         = #x0400;
define inline-only constant $LVS-NOCOLUMNHEADER         = #x4000;
define inline-only constant $LVS-NOSORTHEADER           = #x8000;
define inline-only constant $LVM-GETBKCOLOR             = #x1000;

define inline-only function ListView-GetBkColor (hwnd);
   SendMessage( hwnd, $LVM-GETBKCOLOR, 0, 0)
end;
define inline-only constant $LVM-SETBKCOLOR             = #x1001;

define inline-only function ListView-SetBkColor (hwnd, clrBk);
   ~ zero?(SendMessage( hwnd, $LVM-SETBKCOLOR, 0,  clrBk))
end;
define inline-only constant $LVM-GETIMAGELIST           = #x1002;

define inline-only function ListView-GetImageList (hwnd, iImageList);
   c-type-cast(<HIMAGELIST>, SendMessage( hwnd, $LVM-GETIMAGELIST,  iImageList, 0))
end;
define inline-only constant $LVSIL-NORMAL               =    0;
define inline-only constant $LVSIL-SMALL                =    1;
define inline-only constant $LVSIL-STATE                =    2;
define inline-only constant $LVM-SETIMAGELIST           = #x1003;

define inline-only function ListView-SetImageList (hwnd, himl, iImageList);
   c-type-cast(<HIMAGELIST>, SendMessage( hwnd, $LVM-SETIMAGELIST,  iImageList,
	pointer-address(check-type( himl, <HIMAGELIST>))))
end;
define inline-only constant $LVM-GETITEMCOUNT           = #x1004;

define inline-only function ListView-GetItemCount (hwnd);
   SendMessage( hwnd, $LVM-GETITEMCOUNT, 0, 0)
end;
define inline-only constant $LVIF-TEXT                  = #x0001;
define inline-only constant $LVIF-IMAGE                 = #x0002;
define inline-only constant $LVIF-PARAM                 = #x0004;
define inline-only constant $LVIF-STATE                 = #x0008;
define inline-only constant $LVIS-FOCUSED               = #x0001;
define inline-only constant $LVIS-SELECTED              = #x0002;
define inline-only constant $LVIS-CUT                   = #x0004;
define inline-only constant $LVIS-DROPHILITED           = #x0008;
define inline-only constant $LVIS-ACTIVATING            = #x0020;
define inline-only constant $LVIS-OVERLAYMASK           = #x0F00;
define inline-only constant $LVIS-STATEIMAGEMASK        = #xF000;

define inline-only function INDEXTOSTATEIMAGEMASK (i);
  (ash(i,12))
end;
define inline constant <LVITEMA> = <LV-ITEMA>;
define inline constant <LV-ITEM> = <LVITEM>;

define C-struct <LV-ITEMA>
  sealed inline-only slot mask-value     :: <UINT>;
  sealed inline-only slot iItem-value    :: <C-int>;
  sealed inline-only slot iSubItem-value :: <C-int>;
  sealed inline-only slot state-value    :: <UINT>;
  sealed inline-only slot stateMask-value :: <UINT>;
  sealed inline-only slot pszText-value  :: <LPSTR>;
  sealed inline-only slot cchTextMax-value :: <C-int>;
  sealed inline-only slot iImage-value   :: <C-int>;
  sealed inline-only slot lParam-value   :: <LPARAM>;
  pack: 1;
  pointer-type-name: <LPLV-ITEMA>;
  c-name: "struct tagLVITEMA";
end C-struct <LV-ITEMA>;
define inline constant <LPLVITEMA> = <LPLV-ITEMA>;
define inline constant <LVITEM> = <LV-ITEMA>;
define inline constant <LPLVITEM> = <LPLVITEMA>;
define inline-only constant $LPSTR-TEXTCALLBACKW        =
	make(<LPWSTR>, address: -1);
define inline-only constant $LPSTR-TEXTCALLBACKA        =
	make(<LPSTR>, address: -1);
define inline constant $LPSTR-TEXTCALLBACK = $LPSTR-TEXTCALLBACKA;
define inline-only constant $I-IMAGECALLBACK            =   -1;
define inline-only constant $LVM-GETITEM                = #x1005;

define inline-only function ListView-GetItem (hwnd, pitem);
   ~ zero?(SendMessage( hwnd, $LVM-GETITEM, 0,
	pointer-address(check-type( pitem, <LPLV-ITEM>))))
end;
define inline-only constant $LVM-SETITEM                = #x1006;

define inline-only function ListView-SetItem (hwnd, pitem);
   ~ zero?(SendMessage( hwnd, $LVM-SETITEM, 0,
	pointer-address(check-type( pitem, /* const */ <LPLV-ITEM>))))
end;
define inline-only constant $LVM-INSERTITEM             = #x1007;

define inline-only function ListView-InsertItem (hwnd, pitem);
   SendMessage( hwnd, $LVM-INSERTITEM, 0,
	pointer-address(check-type( pitem, /* const */ <LPLV-ITEM>)))
end;
define inline-only constant $LVM-DELETEITEM             = #x1008;

define inline-only function ListView-DeleteItem (hwnd, i);
   ~ zero?(SendMessage( hwnd, $LVM-DELETEITEM,  i, 0))
end;
define inline-only constant $LVM-DELETEALLITEMS         = #x1009;

define inline-only function ListView-DeleteAllItems (hwnd);
   ~ zero?(SendMessage( hwnd, $LVM-DELETEALLITEMS, 0, 0))
end;
define inline-only constant $LVM-GETCALLBACKMASK        = #x100A;

define inline-only function ListView-GetCallbackMask (hwnd);
   ~ zero?(SendMessage( hwnd, $LVM-GETCALLBACKMASK, 0, 0))
end;
define inline-only constant $LVM-SETCALLBACKMASK        = #x100B;

define inline-only function ListView-SetCallbackMask (hwnd, mask);
   ~ zero?(SendMessage( hwnd, $LVM-SETCALLBACKMASK,  mask, 0))
end;
define inline-only constant $LVNI-ALL                   = #x0000;
define inline-only constant $LVNI-FOCUSED               = #x0001;
define inline-only constant $LVNI-SELECTED              = #x0002;
define inline-only constant $LVNI-CUT                   = #x0004;
define inline-only constant $LVNI-DROPHILITED           = #x0008;
define inline-only constant $LVNI-ABOVE                 = #x0100;
define inline-only constant $LVNI-BELOW                 = #x0200;
define inline-only constant $LVNI-TOLEFT                = #x0400;
define inline-only constant $LVNI-TORIGHT               = #x0800;
define inline-only constant $LVM-GETNEXTITEM            = #x100C;

define inline-only function ListView-GetNextItem (hwnd, i, flags);
   SendMessage( hwnd, $LVM-GETNEXTITEM,  i, MAKELPARAM( flags, 0))
end;
define inline-only constant $LVFI-PARAM                 = #x0001;
define inline-only constant $LVFI-STRING                = #x0002;
define inline-only constant $LVFI-PARTIAL               = #x0008;
define inline-only constant $LVFI-WRAP                  = #x0020;
define inline-only constant $LVFI-NEARESTXY             = #x0040;
define inline constant <LVFINDINFOA> = <LV-FINDINFOA>;
define inline constant <LV-FINDINFO> = <LVFINDINFO>;

define C-struct <LV-FINDINFOA>
  sealed inline-only slot flags-value    :: <UINT>;
  sealed inline-only slot psz-value      :: <LPCSTR>;
  sealed inline-only slot lParam-value   :: <LPARAM>;
  sealed inline-only slot pt-value       :: <POINT>;
  sealed inline-only slot vkDirection-value :: <UINT>;
  pack: 1;
  pointer-type-name: <LPLV-FINDINFOA>;
  c-name: "struct tagLVFINDINFOA";
end C-struct <LV-FINDINFOA>;
define inline constant <LPFINDINFOA> = <LPLV-FINDINFOA>;
define inline constant <LVFINDINFO> = <LV-FINDINFOA>;
define inline-only constant $LVM-FINDITEM               = #x100D;

define inline-only function ListView-FindItem (hwnd, iStart, plvfi);
   SendMessage( hwnd, $LVM-FINDITEM,  iStart,
	pointer-address(check-type( plvfi, /* const */ <LPLV-FINDINFO>)))
end;
define inline-only constant $LVIR-BOUNDS                =    0;
define inline-only constant $LVIR-ICON                  =    1;
define inline-only constant $LVIR-LABEL                 =    2;
define inline-only constant $LVIR-SELECTBOUNDS          =    3;
define inline-only constant $LVM-GETITEMRECT            = #x100E;
define inline-only constant $LVM-SETITEMPOSITION        = #x100F;

define inline-only function ListView-SetItemPosition (hwndLV, i, x, y);
   ~ zero?(SendMessage( hwndLV, $LVM-SETITEMPOSITION,  i, MAKELPARAM( x,  y)))
end;
define inline-only constant $LVM-GETITEMPOSITION        = #x1010;

define inline-only function ListView-GetItemPosition (hwndLV, i, ppt);
   ~ zero?(SendMessage( hwndLV, $LVM-GETITEMPOSITION,  i,
	pointer-address(check-type( ppt, <LPPOINT>))))
end;
define inline-only constant $LVM-GETSTRINGWIDTH         = #x1011;

define inline-only function ListView-GetStringWidth (hwndLV, psz);
   SendMessage( hwndLV, $LVM-GETSTRINGWIDTH, 0,
	pointer-address(check-type( psz, <LPCTSTR>)))
end;
define inline-only constant $LVHT-NOWHERE               = #x0001;
define inline-only constant $LVHT-ONITEMICON            = #x0002;
define inline-only constant $LVHT-ONITEMLABEL           = #x0004;
define inline-only constant $LVHT-ONITEMSTATEICON       = #x0008;
define inline-only constant $LVHT-ONITEM                =
	logior($LVHT-ONITEMICON, $LVHT-ONITEMLABEL, $LVHT-ONITEMSTATEICON);
define inline-only constant $LVHT-ABOVE                 = #x0008;
define inline-only constant $LVHT-BELOW                 = #x0010;
define inline-only constant $LVHT-TORIGHT               = #x0020;
define inline-only constant $LVHT-TOLEFT                = #x0040;
define inline constant <LVHITTESTINFO> = <LV-HITTESTINFO>;

define C-struct <LV-HITTESTINFO>
  sealed inline-only slot pt-value       :: <POINT>;
  sealed inline-only slot flags-value    :: <UINT>;
  sealed inline-only slot iItem-value    :: <C-int>;
  pack: 1;
  pointer-type-name: <LPLV-HITTESTINFO>;
  c-name: "struct tagLVHITTESTINFO";
end C-struct <LV-HITTESTINFO>;
define inline constant <LPLVHITTESTINFO> = <LPLV-HITTESTINFO>;
define inline-only constant $LVM-HITTEST                = #x1012;

define inline-only function ListView-HitTest (hwndLV, pinfo);
   SendMessage( hwndLV, $LVM-HITTEST, 0,
	pointer-address(check-type( pinfo, <LPLV-HITTESTINFO>)))
end;
define inline-only constant $LVM-ENSUREVISIBLE          = #x1013;

define inline-only function ListView-EnsureVisible (hwndLV, i, fPartialOK);
   ~ zero?(SendMessage( hwndLV, $LVM-ENSUREVISIBLE,  i, MAKELPARAM( fPartialOK, 0)))
end;
define inline-only constant $LVM-SCROLL                 = #x1014;

define inline-only function ListView-Scroll (hwndLV, dx, dy);
   ~ zero?(SendMessage( hwndLV, $LVM-SCROLL, dx, dy))
end;
define inline-only constant $LVM-REDRAWITEMS            = #x1015;

define inline-only function ListView-RedrawItems (hwndLV, iFirst, iLast);
   ~ zero?(SendMessage( hwndLV, $LVM-REDRAWITEMS, iFirst, iLast))
end;
define inline-only constant $LVA-DEFAULT                = #x0000;
define inline-only constant $LVA-ALIGNLEFT              = #x0001;
define inline-only constant $LVA-ALIGNTOP               = #x0002;
define inline-only constant $LVA-SNAPTOGRID             = #x0005;
define inline-only constant $LVM-ARRANGE                = #x1016;

define inline-only function ListView-Arrange (hwndLV, code);
   ~ zero?(SendMessage( hwndLV, $LVM-ARRANGE,  code, 0))
end;
define inline-only constant $LVM-EDITLABEL              = #x1017;

define inline-only function ListView-EditLabel (hwndLV, i);
   c-type-cast(<HWND>, SendMessage( hwndLV, $LVM-EDITLABEL,  i, 0))
end;
define inline-only constant $LVM-GETEDITCONTROL         = #x1018;

define inline-only function ListView-GetEditControl (hwndLV);
   c-type-cast(<HWND>, SendMessage( hwndLV, $LVM-GETEDITCONTROL, 0, 0))
end;
define inline constant <LVCOLUMNA> = <LV-COLUMNA>;
define inline constant <LV-COLUMN> = <LVCOLUMN>;

define C-struct <LV-COLUMNA>
  sealed inline-only slot mask-value     :: <UINT>;
  sealed inline-only slot fmt-value      :: <C-int>;
  sealed inline-only slot cx-value       :: <C-int>;
  sealed inline-only slot pszText-value  :: <LPSTR>;
  sealed inline-only slot cchTextMax-value :: <C-int>;
  sealed inline-only slot iSubItem-value :: <C-int>;
  pack: 1;
  pointer-type-name: <LPLV-COLUMNA>;
  c-name: "struct tagLVCOLUMNA";
end C-struct <LV-COLUMNA>;
define inline constant <LPLVCOLUMNA> = <LPLV-COLUMNA>;
define inline constant <LVCOLUMN> = <LV-COLUMNA>;
define inline constant <LPLVCOLUMN> = <LPLVCOLUMNA>;
define inline-only constant $LVCF-FMT                   = #x0001;
define inline-only constant $LVCF-WIDTH                 = #x0002;
define inline-only constant $LVCF-TEXT                  = #x0004;
define inline-only constant $LVCF-SUBITEM               = #x0008;
define inline-only constant $LVCFMT-LEFT                = #x0000;
define inline-only constant $LVCFMT-RIGHT               = #x0001;
define inline-only constant $LVCFMT-CENTER              = #x0002;
define inline-only constant $LVCFMT-JUSTIFYMASK         = #x0003;
define inline-only constant $LVM-GETCOLUMN              = #x1019;

define inline-only function ListView-GetColumn (hwnd, iCol, pcol);
   ~ zero?(SendMessage( hwnd, $LVM-GETCOLUMN,  iCol,
	pointer-address(check-type( pcol, <LPLV-COLUMN>))))
end;
define inline-only constant $LVM-SETCOLUMN              = #x101A;

define inline-only function ListView-SetColumn (hwnd, iCol, pcol);
   ~ zero?(SendMessage( hwnd, $LVM-SETCOLUMN,  iCol,
	pointer-address(check-type( pcol, /* const */ <LPLV-COLUMN>))))
end;
define inline-only constant $LVM-INSERTCOLUMN           = #x101B;

define inline-only function ListView-InsertColumn (hwnd, iCol, pcol);
   SendMessage( hwnd, $LVM-INSERTCOLUMN,  iCol,
	pointer-address(check-type( pcol, /* const */ <LPLV-COLUMN>)))
end;
define inline-only constant $LVM-DELETECOLUMN           = #x101C;

define inline-only function ListView-DeleteColumn (hwnd, iCol);
   ~ zero?(SendMessage( hwnd, $LVM-DELETECOLUMN,  iCol, 0))
end;
define inline-only constant $LVM-GETCOLUMNWIDTH         = #x101D;

define inline-only function ListView-GetColumnWidth (hwnd, iCol);
   SendMessage( hwnd, $LVM-GETCOLUMNWIDTH,  iCol, 0)
end;
define inline-only constant $LVSCW-AUTOSIZE             =   -1;
define inline-only constant $LVSCW-AUTOSIZE-USEHEADER   =   -2;
define inline-only constant $LVM-SETCOLUMNWIDTH         = #x101E;

define inline-only function ListView-SetColumnWidth (hwnd, iCol, cx);
   ~ zero?(SendMessage( hwnd, $LVM-SETCOLUMNWIDTH,  iCol, MAKELPARAM( cx, 0)))
end;
define inline-only constant $LVM-CREATEDRAGIMAGE        = #x1021;

define inline-only function ListView-CreateDragImage (hwnd, i, lpptUpLeft);
   c-type-cast(<HIMAGELIST>, SendMessage( hwnd, $LVM-CREATEDRAGIMAGE,  i,
	pointer-address(check-type( lpptUpLeft, <LPPOINT>))))
end;
define inline-only constant $LVM-GETVIEWRECT            = #x1022;

define inline-only function ListView-GetViewRect (hwnd, prc);
   ~ zero?(SendMessage( hwnd, $LVM-GETVIEWRECT, 0,
	pointer-address(check-type( prc, <LPRECT>))))
end;
define inline-only constant $LVM-GETTEXTCOLOR           = #x1023;

define inline-only function ListView-GetTextColor (hwnd);
   SendMessage( hwnd, $LVM-GETTEXTCOLOR, 0, 0)
end;
define inline-only constant $LVM-SETTEXTCOLOR           = #x1024;

define inline-only function ListView-SetTextColor (hwnd, clrText);
   ~ zero?(SendMessage( hwnd, $LVM-SETTEXTCOLOR, 0,  clrText))
end;
define inline-only constant $LVM-GETTEXTBKCOLOR         = #x1025;

define inline-only function ListView-GetTextBkColor (hwnd);
   SendMessage( hwnd, $LVM-GETTEXTBKCOLOR, 0, 0)
end;
define inline-only constant $LVM-SETTEXTBKCOLOR         = #x1026;

define inline-only function ListView-SetTextBkColor (hwnd, clrTextBk);
   ~ zero?(SendMessage( hwnd, $LVM-SETTEXTBKCOLOR, 0,  clrTextBk))
end;
define inline-only constant $LVM-GETTOPINDEX            = #x1027;

define inline-only function ListView-GetTopIndex (hwndLV);
   SendMessage( hwndLV, $LVM-GETTOPINDEX, 0, 0)
end;
define inline-only constant $LVM-GETCOUNTPERPAGE        = #x1028;

define inline-only function ListView-GetCountPerPage (hwndLV);
   SendMessage( hwndLV, $LVM-GETCOUNTPERPAGE, 0, 0)
end;
define inline-only constant $LVM-GETORIGIN              = #x1029;

define inline-only function ListView-GetOrigin (hwndLV, ppt);
   ~ zero?(SendMessage( hwndLV, $LVM-GETORIGIN, 0,
	pointer-address(check-type( ppt, <LPPOINT>))))
end;
define inline-only constant $LVM-UPDATE                 = #x102A;

define inline-only function ListView-Update (hwndLV, i);
   ~ zero?(SendMessage( hwndLV, $LVM-UPDATE, i, 0))
end;
define inline-only constant $LVM-SETITEMSTATE           = #x102B;

define function ListView-SetItemState (hwndLV, i, data, mask);
   with-stack-structure( ms_lvi :: <LPLV-ITEM> ) 
	ms_lvi.stateMask-value := mask; 
	ms_lvi.state-value := data; 
	SendMessage( hwndLV, $LVM-SETITEMSTATE, i, ms_lvi.pointer-address); 
	end with-stack-structure
end;
define inline-only constant $LVM-GETITEMSTATE           = #x102C;

define inline-only function ListView-GetItemState (hwndLV, i, mask);
   SendMessage( hwndLV, $LVM-GETITEMSTATE, i, mask)
end;
define inline-only constant $LVM-GETITEMTEXT            = #x102D;

define function ListView-GetItemText (hwndLV, i, iSubItem_, pszText_, cchTextMax_);
   with-stack-structure( ms_lvi :: <LPLV-ITEM> ) 
	ms_lvi.iSubItem-value := iSubItem_; 
	ms_lvi.cchTextMax-value := cchTextMax_; 
	ms_lvi.pszText-value := pszText_; 
	SendMessage( hwndLV, $LVM-GETITEMTEXT, i, ms_lvi.pointer-address); 
	end with-stack-structure
end;
define inline-only constant $LVM-SETITEMTEXT            = #x102E;

define function ListView-SetItemText (hwndLV, i, iSubItem_, pszText_);
   with-stack-structure( ms_lvi :: <LPLV-ITEM> ) 
	ms_lvi.iSubItem-value := iSubItem_; 
	ms_lvi.pszText-value := pszText_; 
	SendMessage( hwndLV, $LVM-SETITEMTEXT, i, ms_lvi.pointer-address); 
	end with-stack-structure
end;
define inline-only constant $LVM-SETITEMCOUNT           = #x102F;

define inline-only function ListView-SetItemCount (hwndLV, cItems);
   SendMessage( hwndLV, $LVM-SETITEMCOUNT, cItems, 0)
end;

define C-subtype <PFNLVCOMPARE> ( <C-function-pointer> ) end;
define macro <PFNLVCOMPARE>-callback-wrapper
 { <PFNLVCOMPARE>-callback-wrapper(?new:name,?old:name) } =>
 { define C-callable-wrapper ?new of ?old
  parameter lparam1    :: <LPARAM>;
  parameter lparam2    :: <LPARAM>;
  parameter lparam3    :: <LPARAM>;
  result value :: <C-int>;
  c-modifiers: "__stdcall";
 end C-callable-wrapper }
end;
define inline-only constant $LVM-SORTITEMS              = #x1030;

define inline-only function ListView-SortItems (hwndLV, _pfnCompare, _lPrm);
   ~ zero?(SendMessage( hwndLV, $LVM-SORTITEMS, _lPrm,
	pointer-address(check-type(_pfnCompare, <PFNLVCOMPARE>))))
end;
define inline-only constant $LVM-SETITEMPOSITION32      = #x1031;
define inline-only constant $LVM-GETSELECTEDCOUNT       = #x1032;

define inline-only function ListView-GetSelectedCount (hwndLV);
   SendMessage( hwndLV, $LVM-GETSELECTEDCOUNT, 0, 0)
end;
define inline-only constant $LVM-GETITEMSPACING         = #x1033;

define inline-only function ListView-GetItemSpacing (hwndLV, fSmall);
   SendMessage( hwndLV, $LVM-GETITEMSPACING, fSmall, 0)
end;
define inline-only constant $LVM-GETISEARCHSTRING       = #x1034;

define inline-only function ListView-GetISearchString (hwndLV, lpsz);
   ~ zero?(SendMessage( hwndLV, $LVM-GETISEARCHSTRING, 0,
	pointer-address(check-type(lpsz, <LPTSTR>))))
end;
define inline constant <NMLISTVIEW> = <NM-LISTVIEW>;
define inline constant <LPNMLISTVIEW> = <LPNM-LISTVIEW>;

define C-struct <NM-LISTVIEW>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot iItem-value    :: <C-int>;
  sealed inline-only slot iSubItem-value :: <C-int>;
  sealed inline-only slot uNewState-value :: <UINT>;
  sealed inline-only slot uOldState-value :: <UINT>;
  sealed inline-only slot uChanged-value :: <UINT>;
  sealed inline-only slot ptAction-value :: <POINT>;
  sealed inline-only slot lParam-value   :: <LPARAM>;
  pack: 1;
  pointer-type-name: <LPNM-LISTVIEW>;
  c-name: "struct tagNMLISTVIEW";
end C-struct <NM-LISTVIEW>;
define inline-only constant $LVN-ITEMCHANGING           = -100;
define inline-only constant $LVN-ITEMCHANGED            = -101;
define inline-only constant $LVN-INSERTITEM             = -102;
define inline-only constant $LVN-DELETEITEM             = -103;
define inline-only constant $LVN-DELETEALLITEMS         = -104;
define inline-only constant $LVN-BEGINLABELEDITA        = -105;
define inline-only constant $LVN-BEGINLABELEDITW        = -175;
define inline-only constant $LVN-ENDLABELEDITA          = -106;
define inline-only constant $LVN-ENDLABELEDITW          = -176;
define inline-only constant $LVN-COLUMNCLICK            = -108;
define inline-only constant $LVN-BEGINDRAG              = -109;
define inline-only constant $LVN-BEGINRDRAG             = -111;
define inline-only constant $LVN-GETDISPINFOA           = -150;
define inline-only constant $LVN-GETDISPINFOW           = -177;
define inline-only constant $LVN-SETDISPINFOA           = -151;
define inline-only constant $LVN-SETDISPINFOW           = -178;
define inline constant $LVN-BEGINLABELEDIT = $LVN-BEGINLABELEDITA;
define inline constant $LVN-ENDLABELEDIT = $LVN-ENDLABELEDITA;
define inline constant $LVN-GETDISPINFO = $LVN-GETDISPINFOA;
define inline constant $LVN-SETDISPINFO = $LVN-SETDISPINFOA;
define inline-only constant $LVIF-DI-SETITEM            = #x1000;
define inline constant <NMLVDISPINFOA> = <LV-DISPINFOA>;
define inline constant <LV-DISPINFO> = <NMLVDISPINFO>;

define C-struct <LV-DISPINFOA>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot item-value     :: <LVITEMA>;
  pack: 1;
  pointer-type-name: <LPLV-DISPINFOA>;
  c-name: "struct tagLVDISPINFO";
end C-struct <LV-DISPINFOA>;
define inline constant <LPNMLVDISPINFOA> = <LPLV-DISPINFOA>;
define inline constant <NMLVDISPINFO> = <LV-DISPINFOA>;
define inline-only constant $LVN-KEYDOWN                = -155;
define inline constant <NMLVKEYDOWN> = <LV-KEYDOWN>;

define C-struct <LV-KEYDOWN>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot wVKey-value    :: <WORD>;
  sealed inline-only slot flags-value    :: <UINT>;
  pack: 1;
  pointer-type-name: <LPLV-KEYDOWN>;
  c-name: "struct tagLVKEYDOWN";
end C-struct <LV-KEYDOWN>;
define inline constant <LPNMLVKEYDOWN> = <LPLV-KEYDOWN>;
define constant $WC-TREEVIEW   = "SysTreeView32";
define inline-only constant $TVS-HASBUTTONS             = #x0001;
define inline-only constant $TVS-HASLINES               = #x0002;
define inline-only constant $TVS-LINESATROOT            = #x0004;
define inline-only constant $TVS-EDITLABELS             = #x0008;
define inline-only constant $TVS-DISABLEDRAGDROP        = #x0010;
define inline-only constant $TVS-SHOWSELALWAYS          = #x0020;
define C-subtype <HTREEITEM> ( <C-void*> ) end;
define inline-only constant $TVIF-TEXT                  = #x0001;
define inline-only constant $TVIF-IMAGE                 = #x0002;
define inline-only constant $TVIF-PARAM                 = #x0004;
define inline-only constant $TVIF-STATE                 = #x0008;
define inline-only constant $TVIF-HANDLE                = #x0010;
define inline-only constant $TVIF-SELECTEDIMAGE         = #x0020;
define inline-only constant $TVIF-CHILDREN              = #x0040;
define inline-only constant $TVIS-SELECTED              = #x0002;
define inline-only constant $TVIS-CUT                   = #x0004;
define inline-only constant $TVIS-DROPHILITED           = #x0008;
define inline-only constant $TVIS-BOLD                  = #x0010;
define inline-only constant $TVIS-EXPANDED              = #x0020;
define inline-only constant $TVIS-EXPANDEDONCE          = #x0040;
define inline-only constant $TVIS-OVERLAYMASK           = #x0F00;
define inline-only constant $TVIS-STATEIMAGEMASK        = #xF000;
define inline-only constant $TVIS-USERMASK              = #xF000;
define inline-only constant $I-CHILDRENCALLBACK         =   -1;
define inline constant <TVITEMA> = <TV-ITEMA>;
define inline constant <LPTVITEMA> = <LPTV-ITEMA>;
define inline constant <LPTV-ITEM> = <LPTVITEM>;
define inline constant <TV-ITEM> = <TVITEM>;

define C-struct <TV-ITEMA>
  sealed inline-only slot mask-value     :: <UINT>;
  sealed inline-only slot hItem-value    :: <HTREEITEM>;
  sealed inline-only slot state-value    :: <UINT>;
  sealed inline-only slot stateMask-value :: <UINT>;
  sealed inline-only slot pszText-value  :: <LPSTR>;
  sealed inline-only slot cchTextMax-value :: <C-int>;
  sealed inline-only slot iImage-value   :: <C-int>;
  sealed inline-only slot iSelectedImage-value :: <C-int>;
  sealed inline-only slot cChildren-value :: <C-int>;
  sealed inline-only slot lParam-value   :: <LPARAM>;
  pack: 1;
  pointer-type-name: <LPTV-ITEMA>;
  c-name: "struct tagTVITEMA";
end C-struct <TV-ITEMA>;
define inline constant <TVITEM> = <TV-ITEMA>;
define inline constant <LPTVITEM> = <LPTV-ITEMA>;
define inline-only constant $TVI-ROOT                   =
	make(<HTREEITEM>, address: as(<machine-word>, #xFFFF0000));
define inline-only constant $TVI-FIRST                  =
	make(<HTREEITEM>, address: as(<machine-word>, #xFFFF0001));
define inline-only constant $TVI-LAST                   =
	make(<HTREEITEM>, address: as(<machine-word>, #xFFFF0002));
define inline-only constant $TVI-SORT                   =
	make(<HTREEITEM>, address: as(<machine-word>, #xFFFF0003));
define inline constant <TVINSERTSTRUCTA> = <TV-INSERTSTRUCTA>;
define inline constant <LPTVINSERTSTRUCTA> = <LPTV-INSERTSTRUCTA>;
define inline constant <TV-INSERTSTRUCT> = <TVINSERTSTRUCT>;
define inline constant <LPTV-INSERTSTRUCT> = <LPTVINSERTSTRUCT>;

define C-struct <TV-INSERTSTRUCTA>
  sealed inline-only slot hParent-value  :: <HTREEITEM>;
  sealed inline-only slot hInsertAfter-value :: <HTREEITEM>;
  sealed inline-only slot item-value     :: <TV-ITEMA>;
  pack: 1;
  pointer-type-name: <LPTV-INSERTSTRUCTA>;
  c-name: "struct tagTVINSERTSTRUCTA";
end C-struct <TV-INSERTSTRUCTA>;
define inline constant <TVINSERTSTRUCT> = <TV-INSERTSTRUCTA>;
define inline constant <LPTVINSERTSTRUCT> = <LPTV-INSERTSTRUCTA>;
define inline-only constant $TVM-INSERTITEM             = #x1100;

define inline-only function TreeView-InsertItem (hwnd, lpis);
   c-type-cast(<HTREEITEM>, SendMessage( hwnd, $TVM-INSERTITEM, 0,
	pointer-address(check-type( lpis, <LPTV-INSERTSTRUCT>))))
end;
define inline-only constant $TVM-DELETEITEM             = #x1101;

define inline-only function TreeView-DeleteItem (hwnd, hitem);
   ~ zero?(SendMessage( hwnd, $TVM-DELETEITEM, 0,
	pointer-address(check-type( hitem, <HTREEITEM>))))
end;

define inline-only function TreeView-DeleteAllItems (hwnd);
   ~ zero?(SendMessage( hwnd, $TVM-DELETEITEM, 0, pointer-address($TVI-ROOT)))
end;
define inline-only constant $TVM-EXPAND                 = #x1102;

define inline-only function TreeView-Expand (hwnd, hitem, code);
   ~ zero?(SendMessage( hwnd, $TVM-EXPAND, code,
	pointer-address(check-type( hitem, <HTREEITEM>))))
end;
define inline-only constant $TVE-COLLAPSE               = #x0001;
define inline-only constant $TVE-EXPAND                 = #x0002;
define inline-only constant $TVE-TOGGLE                 = #x0003;
define inline-only constant $TVE-COLLAPSERESET          = #x8000;
define inline-only constant $TVM-GETITEMRECT            = #x1104;
define inline-only constant $TVM-GETCOUNT               = #x1105;

define inline-only function TreeView-GetCount (hwnd);
   SendMessage( hwnd, $TVM-GETCOUNT, 0, 0)
end;
define inline-only constant $TVM-GETINDENT              = #x1106;

define inline-only function TreeView-GetIndent (hwnd);
   SendMessage( hwnd, $TVM-GETINDENT, 0, 0)
end;
define inline-only constant $TVM-SETINDENT              = #x1107;

define inline-only function TreeView-SetIndent (hwnd, indent);
   ~ zero?(SendMessage( hwnd, $TVM-SETINDENT, indent, 0))
end;
define inline-only constant $TVM-GETIMAGELIST           = #x1108;

define inline-only function TreeView-GetImageList (hwnd, iImage);
   c-type-cast(<HIMAGELIST>, SendMessage( hwnd, $TVM-GETIMAGELIST, iImage, 0))
end;
define inline-only constant $TVSIL-NORMAL               =    0;
define inline-only constant $TVSIL-STATE                =    2;
define inline-only constant $TVM-SETIMAGELIST           = #x1109;

define inline-only function TreeView-SetImageList (hwnd, himl, iImage);
   c-type-cast(<HIMAGELIST>, SendMessage( hwnd, $TVM-SETIMAGELIST, iImage,
	pointer-address(check-type( himl, <HIMAGELIST>))))
end;
define inline-only constant $TVM-GETNEXTITEM            = #x110A;

define inline-only function TreeView-GetNextItem (hwnd, hitem, code);
   c-type-cast(<HTREEITEM>, SendMessage( hwnd, $TVM-GETNEXTITEM, code,
	pointer-address(check-type( hitem, <HTREEITEM>))))
end;
define inline-only constant $TVGN-ROOT                  = #x0000;
define inline-only constant $TVGN-NEXT                  = #x0001;
define inline-only constant $TVGN-PREVIOUS              = #x0002;
define inline-only constant $TVGN-PARENT                = #x0003;
define inline-only constant $TVGN-CHILD                 = #x0004;
define inline-only constant $TVGN-FIRSTVISIBLE          = #x0005;
define inline-only constant $TVGN-NEXTVISIBLE           = #x0006;
define inline-only constant $TVGN-PREVIOUSVISIBLE       = #x0007;
define inline-only constant $TVGN-DROPHILITE            = #x0008;
define inline-only constant $TVGN-CARET                 = #x0009;

define inline-only function TreeView-GetChild (hwnd, hitem);
  TreeView-GetNextItem(hwnd, hitem, $TVGN-CHILD)
end;

define inline-only function TreeView-GetNextSibling (hwnd, hitem);
  TreeView-GetNextItem(hwnd, hitem, $TVGN-NEXT)
end;

define inline-only function TreeView-GetPrevSibling (hwnd, hitem);
  TreeView-GetNextItem(hwnd, hitem, $TVGN-PREVIOUS)
end;

define inline-only function TreeView-GetParent (hwnd, hitem);
  TreeView-GetNextItem(hwnd, hitem, $TVGN-PARENT)
end;

define inline-only function TreeView-GetFirstVisible (hwnd);
  TreeView-GetNextItem(hwnd, null-pointer(<HTREEITEM>), $TVGN-FIRSTVISIBLE)
end;

define inline-only function TreeView-GetNextVisible (hwnd, hitem);
  TreeView-GetNextItem(hwnd, hitem, $TVGN-NEXTVISIBLE)
end;

define inline-only function TreeView-GetPrevVisible (hwnd, hitem);
  TreeView-GetNextItem(hwnd, hitem, $TVGN-PREVIOUSVISIBLE)
end;

define inline-only function TreeView-GetSelection (hwnd);
  TreeView-GetNextItem(hwnd, null-pointer(<HTREEITEM>), $TVGN-CARET)
end;

define inline-only function TreeView-GetDropHilight (hwnd);
  TreeView-GetNextItem(hwnd, null-pointer(<HTREEITEM>), $TVGN-DROPHILITE)
end;

define inline-only function TreeView-GetRoot (hwnd);
  TreeView-GetNextItem(hwnd, null-pointer(<HTREEITEM>), $TVGN-ROOT)
end;
define inline-only constant $TVM-SELECTITEM             = #x110B;

define inline-only function TreeView-Select (hwnd, hitem, code);
   ~ zero?(SendMessage( hwnd, $TVM-SELECTITEM, code,
	pointer-address(check-type( hitem, <HTREEITEM>))))
end;

define inline-only function TreeView-SelectItem (hwnd, hitem);
  TreeView-Select(hwnd, hitem, $TVGN-CARET)
end;

define inline-only function TreeView-SelectDropTarget (hwnd, hitem);
  TreeView-Select(hwnd, hitem, $TVGN-DROPHILITE)
end;

define inline-only function TreeView-SelectSetFirstVisible (hwnd, hitem);
  TreeView-Select(hwnd, hitem, $TVGN-FIRSTVISIBLE)
end;
define inline-only constant $TVM-GETITEM                = #x110C;

define inline-only function TreeView-GetItem (hwnd, pitem);
   ~ zero?(SendMessage( hwnd, $TVM-GETITEM, 0,
	pointer-address(check-type( pitem, <LPTV-ITEM>))))
end;
define inline-only constant $TVM-SETITEM                = #x110D;

define inline-only function TreeView-SetItem (hwnd, pitem);
   ~ zero?(SendMessage( hwnd, $TVM-SETITEM, 0,
	pointer-address(check-type( pitem, /* const */ <LPTV-ITEM>))))
end;
define inline-only constant $TVM-EDITLABEL              = #x110E;

define inline-only function TreeView-EditLabel (hwnd, hitem);
   c-type-cast(<HWND>, SendMessage( hwnd, $TVM-EDITLABEL, 0,
	pointer-address(check-type( hitem, <HTREEITEM>))))
end;
define inline-only constant $TVM-GETEDITCONTROL         = #x110F;

define inline-only function TreeView-GetEditControl (hwnd);
   c-type-cast(<HWND>, SendMessage( hwnd, $TVM-GETEDITCONTROL, 0, 0))
end;
define inline-only constant $TVM-GETVISIBLECOUNT        = #x1110;

define inline-only function TreeView-GetVisibleCount (hwnd);
   SendMessage( hwnd, $TVM-GETVISIBLECOUNT, 0, 0)
end;
define inline-only constant $TVM-HITTEST                = #x1111;

define inline-only function TreeView-HitTest (hwnd, lpht);
   c-type-cast(<HTREEITEM>, SendMessage( hwnd, $TVM-HITTEST, 0,
	pointer-address(check-type( lpht, <LPTV-HITTESTINFO>))))
end;
define inline constant <TVHITTESTINFO> = <TV-HITTESTINFO>;
define inline constant <LPTVHITTESTINFO> = <LPTV-HITTESTINFO>;

define C-struct <TV-HITTESTINFO>
  sealed inline-only slot pt-value       :: <POINT>;
  sealed inline-only slot flags-value    :: <UINT>;
  sealed inline-only slot hItem-value    :: <HTREEITEM>;
  pack: 1;
  pointer-type-name: <LPTV-HITTESTINFO>;
  c-name: "struct tagTVHITTESTINFO";
end C-struct <TV-HITTESTINFO>;
define inline-only constant $TVHT-NOWHERE               = #x0001;
define inline-only constant $TVHT-ONITEMICON            = #x0002;
define inline-only constant $TVHT-ONITEMLABEL           = #x0004;
define inline-only constant $TVHT-ONITEM                =
	logior($TVHT-ONITEMICON, $TVHT-ONITEMLABEL, $TVHT-ONITEMSTATEICON);
define inline-only constant $TVHT-ONITEMINDENT          = #x0008;
define inline-only constant $TVHT-ONITEMBUTTON          = #x0010;
define inline-only constant $TVHT-ONITEMRIGHT           = #x0020;
define inline-only constant $TVHT-ONITEMSTATEICON       = #x0040;
define inline-only constant $TVHT-ABOVE                 = #x0100;
define inline-only constant $TVHT-BELOW                 = #x0200;
define inline-only constant $TVHT-TORIGHT               = #x0400;
define inline-only constant $TVHT-TOLEFT                = #x0800;
define inline-only constant $TVM-CREATEDRAGIMAGE        = #x1112;

define inline-only function TreeView-CreateDragImage (hwnd, hitem);
   c-type-cast(<HIMAGELIST>, SendMessage( hwnd, $TVM-CREATEDRAGIMAGE, 0,
	pointer-address(check-type( hitem, <HTREEITEM>))))
end;
define inline-only constant $TVM-SORTCHILDREN           = #x1113;

define inline-only function TreeView-SortChildren (hwnd, hitem, recurse);
   ~ zero?(SendMessage( hwnd, $TVM-SORTCHILDREN, recurse,
	pointer-address(check-type( hitem, <HTREEITEM>))))
end;
define inline-only constant $TVM-ENSUREVISIBLE          = #x1114;

define inline-only function TreeView-EnsureVisible (hwnd, hitem);
   ~ zero?(SendMessage( hwnd, $TVM-ENSUREVISIBLE, 0,
	pointer-address(check-type( hitem, <HTREEITEM>))))
end;
define inline-only constant $TVM-SORTCHILDRENCB         = #x1115;

define inline-only function TreeView-SortChildrenCB (hwnd, psort, recurse);
   ~ zero?(SendMessage( hwnd, $TVM-SORTCHILDRENCB, recurse,
	pointer-address(check-type( psort, <LPTV-SORTCB>))))
end;
define inline-only constant $TVM-ENDEDITLABELNOW        = #x1116;

define inline-only function TreeView-EndEditLabelNow (hwnd, fCancel);
   ~ zero?(SendMessage( hwnd, $TVM-ENDEDITLABELNOW, fCancel, 0))
end;
define inline-only constant $TVM-GETISEARCHSTRING       = #x1117;

define inline-only function TreeView-GetISearchString (hwndTV, lpsz);
   ~ zero?(SendMessage( hwndTV, $TVM-GETISEARCHSTRING, 0,
	pointer-address(check-type(lpsz, <LPTSTR>))))
end;

define C-subtype <PFNTVCOMPARE> ( <C-function-pointer> ) end;
define macro <PFNTVCOMPARE>-callback-wrapper
 { <PFNTVCOMPARE>-callback-wrapper(?new:name,?old:name) } =>
 { define C-callable-wrapper ?new of ?old
  parameter lParam1    :: <LPARAM>;
  parameter lParam2    :: <LPARAM>;
  parameter lParamSort :: <LPARAM>;
  result value :: <C-int>;
  c-modifiers: "__stdcall";
 end C-callable-wrapper }
end;
define inline constant <TVSORTCB> = <TV-SORTCB>;
define inline constant <LPTVSORTCB> = <LPTV-SORTCB>;

define C-struct <TV-SORTCB>
  sealed inline-only slot hParent-value  :: <HTREEITEM>;
  sealed inline-only slot lpfnCompare-value :: <PFNTVCOMPARE>;
  sealed inline-only slot lParam-value   :: <LPARAM>;
  pack: 1;
  pointer-type-name: <LPTV-SORTCB>;
  c-name: "struct tagTVSORTCB";
end C-struct <TV-SORTCB>;
define inline constant <NMTREEVIEWA> = <NM-TREEVIEWA>;
define inline constant <LPNMTREEVIEWA> = <LPNM-TREEVIEWA>;
define inline constant <LPNM-TREEVIEW> = <LPNMTREEVIEW>;
define inline constant <NM-TREEVIEW> = <NMTREEVIEW>;

define C-struct <NM-TREEVIEWA>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot action-value   :: <UINT>;
  sealed inline-only slot itemOld-value  :: <TVITEMA>;
  sealed inline-only slot itemNew-value  :: <TVITEMA>;
  sealed inline-only slot ptDrag-value   :: <POINT>;
  pack: 1;
  pointer-type-name: <LPNM-TREEVIEWA>;
  c-name: "struct tagNMTREEVIEWA";
end C-struct <NM-TREEVIEWA>;
define inline constant <NMTREEVIEW> = <NMTREEVIEWA>;
define inline constant <LPNMTREEVIEW> = <LPNM-TREEVIEWA>;
define inline-only constant $TVN-SELCHANGINGA           = -401;
define inline-only constant $TVN-SELCHANGINGW           = -450;
define inline-only constant $TVN-SELCHANGEDA            = -402;
define inline-only constant $TVN-SELCHANGEDW            = -451;
define inline-only constant $TVC-UNKNOWN                = #x0000;
define inline-only constant $TVC-BYMOUSE                = #x0001;
define inline-only constant $TVC-BYKEYBOARD             = #x0002;
define inline-only constant $TVN-GETDISPINFOA           = -403;
define inline-only constant $TVN-GETDISPINFOW           = -452;
define inline-only constant $TVN-SETDISPINFOA           = -404;
define inline-only constant $TVN-SETDISPINFOW           = -453;
define inline-only constant $TVIF-DI-SETITEM            = #x1000;
define inline constant <NMTVDISPINFOA> = <TV-DISPINFOA>;
define inline constant <TV-DISPINFO> = <NMTVDISPINFO>;

define C-struct <TV-DISPINFOA>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot item-value     :: <TVITEMA>;
  pack: 1;
  pointer-type-name: <LPTV-DISPINFOA>;
  c-name: "struct tagTVDISPINFOA";
end C-struct <TV-DISPINFOA>;
define inline constant <LPNMTVDISPINFOA> = <LPTV-DISPINFOA>;
define inline constant <NMTVDISPINFO> = <TV-DISPINFOA>;
define inline constant <LPNMTVDISPINFO> = <LPNMTVDISPINFOA>;
define inline-only constant $TVN-ITEMEXPANDINGA         = -405;
define inline-only constant $TVN-ITEMEXPANDINGW         = -454;
define inline-only constant $TVN-ITEMEXPANDEDA          = -406;
define inline-only constant $TVN-ITEMEXPANDEDW          = -455;
define inline-only constant $TVN-BEGINDRAGA             = -407;
define inline-only constant $TVN-BEGINDRAGW             = -456;
define inline-only constant $TVN-BEGINRDRAGA            = -408;
define inline-only constant $TVN-BEGINRDRAGW            = -457;
define inline-only constant $TVN-DELETEITEMA            = -409;
define inline-only constant $TVN-DELETEITEMW            = -458;
define inline-only constant $TVN-BEGINLABELEDITA        = -410;
define inline-only constant $TVN-BEGINLABELEDITW        = -459;
define inline-only constant $TVN-ENDLABELEDITA          = -411;
define inline-only constant $TVN-ENDLABELEDITW          = -460;
define inline-only constant $TVN-KEYDOWN                = -412;
define inline constant <NMTVKEYDOWN> = <TV-KEYDOWN>;

define C-struct <TV-KEYDOWN>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot wVKey-value    :: <WORD>;
  sealed inline-only slot flags-value    :: <UINT>;
  pack: 1;
  pointer-type-name: <LPTV-KEYDOWN>;
  c-name: "struct tagTVKEYDOWN";
end C-struct <TV-KEYDOWN>;
define inline constant <LPNMTVKEYDOWN> = <LPTV-KEYDOWN>;
define inline constant $TVN-SELCHANGING = $TVN-SELCHANGINGA;
define inline constant $TVN-SELCHANGED = $TVN-SELCHANGEDA;
define inline constant $TVN-GETDISPINFO = $TVN-GETDISPINFOA;
define inline constant $TVN-SETDISPINFO = $TVN-SETDISPINFOA;
define inline constant $TVN-ITEMEXPANDING = $TVN-ITEMEXPANDINGA;
define inline constant $TVN-ITEMEXPANDED = $TVN-ITEMEXPANDEDA;
define inline constant $TVN-BEGINDRAG = $TVN-BEGINDRAGA;
define inline constant $TVN-BEGINRDRAG = $TVN-BEGINRDRAGA;
define inline constant $TVN-DELETEITEM = $TVN-DELETEITEMA;
define inline constant $TVN-BEGINLABELEDIT = $TVN-BEGINLABELEDITA;
define inline constant $TVN-ENDLABELEDIT = $TVN-ENDLABELEDITA;
define constant $WC-TABCONTROL = "SysTabControl32";
define inline-only constant $TCS-FORCEICONLEFT          = #x0010;
define inline-only constant $TCS-FORCELABELLEFT         = #x0020;
define inline-only constant $TCS-TABS                   = #x0000;
define inline-only constant $TCS-BUTTONS                = #x0100;
define inline-only constant $TCS-SINGLELINE             = #x0000;
define inline-only constant $TCS-MULTILINE              = #x0200;
define inline-only constant $TCS-RIGHTJUSTIFY           = #x0000;
define inline-only constant $TCS-FIXEDWIDTH             = #x0400;
define inline-only constant $TCS-RAGGEDRIGHT            = #x0800;
define inline-only constant $TCS-FOCUSONBUTTONDOWN      = #x1000;
define inline-only constant $TCS-OWNERDRAWFIXED         = #x2000;
define inline-only constant $TCS-TOOLTIPS               = #x4000;
define inline-only constant $TCS-FOCUSNEVER             = #x8000;
define inline-only constant $TCM-GETIMAGELIST           = #x1302;

define inline-only function TabCtrl-GetImageList (hwnd);
   c-type-cast(<HIMAGELIST>, SendMessage( hwnd, $TCM-GETIMAGELIST, 0, 0))
end;
define inline-only constant $TCM-SETIMAGELIST           = #x1303;

define inline-only function TabCtrl-SetImageList (hwnd, himl);
   c-type-cast(<HIMAGELIST>, SendMessage( hwnd, $TCM-SETIMAGELIST, 0,
	pointer-address(check-type( himl, <HIMAGELIST>))))
end;
define inline-only constant $TCM-GETITEMCOUNT           = #x1304;

define inline-only function TabCtrl-GetItemCount (hwnd);
   SendMessage( hwnd, $TCM-GETITEMCOUNT, 0, 0)
end;
define inline-only constant $TCIF-TEXT                  = #x0001;
define inline-only constant $TCIF-IMAGE                 = #x0002;
define inline-only constant $TCIF-RTLREADING            = #x0004;
define inline-only constant $TCIF-PARAM                 = #x0008;
define inline constant <TCITEMHEADERA> = <TC-ITEMHEADERA>;
define inline constant <TC-ITEMHEADER> = <TCITEMHEADER>;

define C-struct <TC-ITEMHEADERA>
  sealed inline-only slot mask-value     :: <UINT>;
  sealed inline-only slot lpReserved1    :: <UINT>;
  sealed inline-only slot lpReserved2    :: <UINT>;
  sealed inline-only slot pszText-value  :: <LPSTR>;
  sealed inline-only slot cchTextMax-value :: <C-int>;
  sealed inline-only slot iImage-value   :: <C-int>;
  pack: 1;
  pointer-type-name: <LPTC-ITEMHEADERA>;
  c-name: "struct tagTCITEMHEADERA";
end C-struct <TC-ITEMHEADERA>;
define inline constant <LPTCITEMHEADERA> = <LPTC-ITEMHEADERA>;
define inline constant <TCITEMHEADER> = <TC-ITEMHEADERA>;
define inline constant <LPTCITEMHEADER> = <LPTCITEMHEADERA>;
define inline constant <TCITEMA> = <TC-ITEMA>;
define inline constant <TC-ITEM> = <TCITEM>;

define C-struct <TC-ITEMA>
  sealed inline-only slot mask-value     :: <UINT>;
  sealed inline-only slot lpReserved1    :: <UINT>;
  sealed inline-only slot lpReserved2    :: <UINT>;
  sealed inline-only slot pszText-value  :: <LPSTR>;
  sealed inline-only slot cchTextMax-value :: <C-int>;
  sealed inline-only slot iImage-value   :: <C-int>;
  sealed inline-only slot lParam-value   :: <LPARAM>;
  pack: 1;
  pointer-type-name: <LPTC-ITEMA>;
  c-name: "struct tagTCITEMA";
end C-struct <TC-ITEMA>;
define inline constant <LPTCITEMA> = <LPTC-ITEMA>;
define inline constant <TCITEM> = <TC-ITEMA>;
define inline constant <LPTCITEM> = <LPTCITEMA>;
define inline-only constant $TCM-GETITEM                = #x1305;

define inline-only function TabCtrl-GetItem (hwnd, iItem, pitem);
   ~ zero?(SendMessage( hwnd, $TCM-GETITEM, iItem,
	pointer-address(check-type( pitem, <LPTC-ITEM>))))
end;
define inline-only constant $TCM-SETITEM                = #x1306;

define inline-only function TabCtrl-SetItem (hwnd, iItem, pitem);
   ~ zero?(SendMessage( hwnd, $TCM-SETITEM, iItem,
	pointer-address(check-type( pitem, <LPTC-ITEM>))))
end;
define inline-only constant $TCM-INSERTITEM             = #x1307;

define inline-only function TabCtrl-InsertItem (hwnd, iItem, pitem);
   SendMessage( hwnd, $TCM-INSERTITEM, iItem,
	pointer-address(check-type( pitem, /* const */ <LPTC-ITEM>)))
end;
define inline-only constant $TCM-DELETEITEM             = #x1308;

define inline-only function TabCtrl-DeleteItem (hwnd, i);
   ~ zero?(SendMessage( hwnd, $TCM-DELETEITEM,  i, 0))
end;
define inline-only constant $TCM-DELETEALLITEMS         = #x1309;

define inline-only function TabCtrl-DeleteAllItems (hwnd);
   ~ zero?(SendMessage( hwnd, $TCM-DELETEALLITEMS, 0, 0))
end;
define inline-only constant $TCM-GETITEMRECT            = #x130A;

define inline-only function TabCtrl-GetItemRect (hwnd, i, prc);
   ~ zero?(SendMessage( hwnd, $TCM-GETITEMRECT,  i,
	pointer-address(check-type( prc, <LPRECT>))))
end;
define inline-only constant $TCM-GETCURSEL              = #x130B;

define inline-only function TabCtrl-GetCurSel (hwnd);
   SendMessage( hwnd, $TCM-GETCURSEL, 0, 0)
end;
define inline-only constant $TCM-SETCURSEL              = #x130C;

define inline-only function TabCtrl-SetCurSel (hwnd, i);
   SendMessage( hwnd, $TCM-SETCURSEL, i, 0)
end;
define inline-only constant $TCHT-NOWHERE               = #x0001;
define inline-only constant $TCHT-ONITEMICON            = #x0002;
define inline-only constant $TCHT-ONITEMLABEL           = #x0004;
define inline-only constant $TCHT-ONITEM                =
	logior($TCHT-ONITEMICON, $TCHT-ONITEMLABEL);
define inline constant <TCHITTESTINFO> = <TC-HITTESTINFO>;
define inline constant <LPTCHITTESTINFO> = <LPTC-HITTESTINFO>;

define C-struct <TC-HITTESTINFO>
  sealed inline-only slot pt-value       :: <POINT>;
  sealed inline-only slot flags-value    :: <UINT>;
  pack: 1;
  pointer-type-name: <LPTC-HITTESTINFO>;
  c-name: "struct tagTCHITTESTINFO";
end C-struct <TC-HITTESTINFO>;
define inline-only constant $TCM-HITTEST                = #x130D;

define inline-only function TabCtrl-HitTest (hwndTC, pinfo);
   SendMessage( hwndTC, $TCM-HITTEST, 0,
	pointer-address(check-type( pinfo, <LPTC-HITTESTINFO>)))
end;
define inline-only constant $TCM-SETITEMEXTRA           = #x130E;

define inline-only function TabCtrl-SetItemExtra (hwndTC, cb);
   ~ zero?(SendMessage( hwndTC, $TCM-SETITEMEXTRA,  cb, 0))
end;
define inline-only constant $TCM-ADJUSTRECT             = #x1328;

define inline-only function TabCtrl-AdjustRect (hwnd, bLarger, prc);
   SendMessage(hwnd, $TCM-ADJUSTRECT,
	select ( bLarger ) #t => 1; #f => 0; end select,
	pointer-address(check-type(prc, <LPRECT>)))
end;
define inline-only constant $TCM-SETITEMSIZE            = #x1329;

define inline-only function TabCtrl-SetItemSize (hwnd, x, y);
   SendMessage( hwnd, $TCM-SETITEMSIZE, 0, MAKELPARAM(x, y))
end;
define inline-only constant $TCM-REMOVEIMAGE            = #x132A;

define inline-only function TabCtrl-RemoveImage (hwnd, i);
   SendMessage( hwnd, $TCM-REMOVEIMAGE, i, 0);
  values()
end;
define inline-only constant $TCM-SETPADDING             = #x132B;

define inline-only function TabCtrl-SetPadding (hwnd,  cx, cy);
   SendMessage( hwnd, $TCM-SETPADDING, 0, MAKELPARAM(cx, cy));
  values()
end;
define inline-only constant $TCM-GETROWCOUNT            = #x132C;

define inline-only function TabCtrl-GetRowCount (hwnd);
   SendMessage( hwnd, $TCM-GETROWCOUNT, 0, 0)
end;
define inline-only constant $TCM-GETTOOLTIPS            = #x132D;

define inline-only function TabCtrl-GetToolTips (hwnd);
   c-type-cast(<HWND>, SendMessage( hwnd, $TCM-GETTOOLTIPS, 0, 0))
end;
define inline-only constant $TCM-SETTOOLTIPS            = #x132E;

define inline-only function TabCtrl-SetToolTips (hwnd, hwndTT);
   SendMessage( hwnd, $TCM-SETTOOLTIPS, hwndTT, 0);
  values()
end;
define inline-only constant $TCM-GETCURFOCUS            = #x132F;

define inline-only function TabCtrl-GetCurFocus (hwnd);
   SendMessage( hwnd, $TCM-GETCURFOCUS, 0, 0)
end;
define inline-only constant $TCM-SETCURFOCUS            = #x1330;

define inline-only function TabCtrl-SetCurFocus (hwnd, i);
   SendMessage( hwnd, $TCM-SETCURFOCUS, i, 0)
end;
define inline-only constant $TCN-KEYDOWN                = -550;
define inline constant <NMTCKEYDOWN> = <TC-KEYDOWN>;

define C-struct <TC-KEYDOWN>
  sealed inline-only slot hdr-value      :: <NMHDR>;
  sealed inline-only slot wVKey-value    :: <WORD>;
  sealed inline-only slot flags-value    :: <UINT>;
  pack: 1;
  pointer-type-name: <LPTC-KEYDOWN>;
  c-name: "struct tagTCKEYDOWN";
end C-struct <TC-KEYDOWN>;
define inline-only constant $TCN-SELCHANGE              = -551;
define inline-only constant $TCN-SELCHANGING            = -552;
define constant $ANIMATE-CLASS = "SysAnimate32";
define inline-only constant $ACS-CENTER                 = #x0001;
define inline-only constant $ACS-TRANSPARENT            = #x0002;
define inline-only constant $ACS-AUTOPLAY               = #x0004;
define inline-only constant $ACM-OPEN                   = #x464;
define inline-only constant $ACM-PLAY                   = #x465;
define inline-only constant $ACM-STOP                   = #x466;
define inline-only constant $ACN-START                  =    1;
define inline-only constant $ACN-STOP                   =    2;

define inline-only function Animate-Create (hwndP, id, dwStyle, hInstance);
   CreateWindow($ANIMATE-CLASS, $NULL-string,
	dwStyle, 0, 0, 0, 0, hwndP, c-type-cast(<HMENU>,  id), hInstance,
	$NULL-VOID)
end;

define inline-only function Animate-Open (hwnd, szName);
  ~ zero?(SendMessage(hwnd, $ACM-OPEN, 0, 
	pointer-address(check-type( szName, <LPTSTR>))))
end;

define inline-only function Animate-OpenEx (hwnd, hInst, szName);
  ~ zero?(SendMessage(hwnd, $ACM-OPEN, hInst,
	pointer-address(check-type( szName, <LPTSTR>))))
end;

define inline-only function Animate-Play (hwnd, from, to, rep);
  ~ zero?(SendMessage(hwnd, $ACM-PLAY,  rep, MAKELONG(from, to)))
end;

define inline-only function Animate-Stop (hwnd);
  ~ zero?(SendMessage(hwnd, $ACM-STOP, 0, 0))
end;

define inline-only function Animate-Close (hwnd);
  Animate-Open(hwnd, $NULL-string)
end;

define inline-only function Animate-Seek (hwnd, frame);
  Animate-Play(hwnd, frame, frame, 1)
end;

define inline-only constant $ILD-SELECTED = $ILD-BLEND50;
define inline-only constant $ILD-FOCUS   = $ILD-BLEND25;
define inline-only constant $ILD-BLEND   = $ILD-BLEND50;
define inline-only constant $CLR-HILIGHT = $CLR-DEFAULT;
define sealed domain make (singleton(<LPIMAGEINFO>));
define sealed domain initialize (<LPIMAGEINFO>);
define sealed domain make (singleton(<LPHD-ITEMA>));
define sealed domain initialize (<LPHD-ITEMA>);
define inline-only constant $HDI-HEIGHT  = $HDI-WIDTH;
define sealed domain make (singleton(<LPHD-LAYOUT>));
define sealed domain initialize (<LPHD-LAYOUT>);
define sealed domain make (singleton(<LPHD-HITTESTINFO>));
define sealed domain initialize (<LPHD-HITTESTINFO>);
define sealed domain make (singleton(<LPHD-NOTIFYA>));
define sealed domain initialize (<LPHD-NOTIFYA>);
define sealed domain make (singleton(<LPNMHDDISPINFOA>));
define sealed domain initialize (<LPNMHDDISPINFOA>);
define sealed domain make (singleton(<LPTBBUTTON>));
define sealed domain initialize (<LPTBBUTTON>);
define sealed domain make (singleton(<LPCOLORMAP>));
define sealed domain initialize (<LPCOLORMAP>);
define sealed domain make (singleton(<LPTBADDBITMAP>));
define sealed domain initialize (<LPTBADDBITMAP>);
define sealed domain make (singleton(<LPTBSAVEPARAMSA>));
define sealed domain initialize (<LPTBSAVEPARAMSA>);
define sealed domain make (singleton(<LPTBREPLACEBITMAP>));
define sealed domain initialize (<LPTBREPLACEBITMAP>);
define sealed domain make (singleton(<LPTOOLINFOA>));
define sealed domain initialize (<LPTOOLINFOA>);
define sealed domain make (singleton(<LPHITTESTINFOA>));
define sealed domain initialize (<LPHITTESTINFOA>);
define inline-only constant $TTN-NEEDTEXT = $TTN-GETDISPINFO;
define inline-only constant $TTN-NEEDTEXTA = $TTN-GETDISPINFOA;
define inline-only constant $TTN-NEEDTEXTW = $TTN-GETDISPINFOW;
define sealed domain make (singleton(<LPTOOLTIPTEXTA>));
define sealed domain initialize (<LPTOOLTIPTEXTA>);
define inline-only constant $MINSYSCOMMAND = $SC-SIZE;
define sealed domain make (singleton(<LPDRAGLISTINFO>));
define sealed domain initialize (<LPDRAGLISTINFO>);
define sealed domain make (singleton(<LPUDACCEL>));
define sealed domain initialize (<LPUDACCEL>);
define sealed domain make (singleton(<LPNM-UPDOWN>));
define sealed domain initialize (<LPNM-UPDOWN>);
define sealed domain make (singleton(<LPLV-ITEMA>));
define sealed domain initialize (<LPLV-ITEMA>);
define sealed domain make (singleton(<LPLV-FINDINFOA>));
define sealed domain initialize (<LPLV-FINDINFOA>);
define sealed domain make (singleton(<LPLV-HITTESTINFO>));
define sealed domain initialize (<LPLV-HITTESTINFO>);
define sealed domain make (singleton(<LPLV-COLUMNA>));
define sealed domain initialize (<LPLV-COLUMNA>);
define sealed domain make (singleton(<LPNM-LISTVIEW>));
define sealed domain initialize (<LPNM-LISTVIEW>);
define sealed domain make (singleton(<LPLV-DISPINFOA>));
define sealed domain initialize (<LPLV-DISPINFOA>);
define sealed domain make (singleton(<LPLV-KEYDOWN>));
define sealed domain initialize (<LPLV-KEYDOWN>);
define sealed domain make (singleton(<LPTV-ITEMA>));
define sealed domain initialize (<LPTV-ITEMA>);
define sealed domain make (singleton(<LPTV-INSERTSTRUCTA>));
define sealed domain initialize (<LPTV-INSERTSTRUCTA>);
define sealed domain make (singleton(<LPTV-HITTESTINFO>));
define sealed domain initialize (<LPTV-HITTESTINFO>);
define sealed domain make (singleton(<LPTV-SORTCB>));
define sealed domain initialize (<LPTV-SORTCB>);
define sealed domain make (singleton(<LPNM-TREEVIEWA>));
define sealed domain initialize (<LPNM-TREEVIEWA>);
define sealed domain make (singleton(<LPTV-DISPINFOA>));
define sealed domain initialize (<LPTV-DISPINFOA>);
define sealed domain make (singleton(<LPTV-KEYDOWN>));
define sealed domain initialize (<LPTV-KEYDOWN>);
define sealed domain make (singleton(<LPTC-ITEMHEADERA>));
define sealed domain initialize (<LPTC-ITEMHEADERA>);
define sealed domain make (singleton(<LPTC-ITEMA>));
define sealed domain initialize (<LPTC-ITEMA>);
define sealed domain make (singleton(<LPTC-HITTESTINFO>));
define sealed domain initialize (<LPTC-HITTESTINFO>);
define sealed domain make (singleton(<LPTC-KEYDOWN>));
define sealed domain initialize (<LPTC-KEYDOWN>);
