#if !defined(AFX_STYLES_H__46AFC4E3_CC43_4E69_B5D3_2B6D1F501D0E__INCLUDED_)
#define AFX_STYLES_H__46AFC4E3_CC43_4E69_B5D3_2B6D1F501D0E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <richedit.h>
#include "wclassdefines.h"

struct Style
{
	LPCTSTR szStyle; // style name
	DWORD dwStyle; // style value
};

#define STYLE(s) _T(#s), (DWORD)s

static Style ClassStyles[] = 
{
	{ STYLE(CS_VREDRAW) }, //		0x0001
	{ STYLE(CS_HREDRAW) }, //		0x0002
	{ STYLE(CS_DBLCLKS) }, //		0x0008
	{ STYLE(CS_OWNDC) }, //			0x0020
	{ STYLE(CS_CLASSDC) }, //		0x0040
	{ STYLE(CS_PARENTDC) }, //		0x0080
	{ STYLE(CS_NOCLOSE) }, //		0x0200
	{ STYLE(CS_SAVEBITS) }, //		0x0800
	{ STYLE(CS_BYTEALIGNCLIENT) },//0x1000
	{ STYLE(CS_BYTEALIGNWINDOW) },//0x2000
	{ STYLE(CS_GLOBALCLASS) }, //	0x4000
	{ STYLE(CS_IME) }, //			0x00010000
};

///////

static Style WindowStyles[] = 
{
	{ STYLE(WS_OVERLAPPED) }, //	0x00000000L
	{ STYLE(WS_POPUP) }, //			0x80000000L
	{ STYLE(WS_CHILD) }, //			0x40000000L
	{ STYLE(WS_MINIMIZE) }, //		0x20000000L
	{ STYLE(WS_VISIBLE) }, //		0x10000000L
	{ STYLE(WS_DISABLED) }, //		0x08000000L
	{ STYLE(WS_CLIPSIBLINGS) }, //	0x04000000L
	{ STYLE(WS_CLIPCHILDREN) }, //	0x02000000L
	{ STYLE(WS_MAXIMIZE) }, //		0x01000000L
	{ STYLE(WS_CAPTION) }, //		0x00C00000L
	{ STYLE(WS_BORDER) }, //		0x00800000L
	{ STYLE(WS_DLGFRAME) }, //		0x00400000L
	{ STYLE(WS_VSCROLL) }, //		0x00200000L
	{ STYLE(WS_HSCROLL) }, //		0x00100000L
	{ STYLE(WS_SYSMENU) }, //		0x00080000L
	{ STYLE(WS_THICKFRAME) }, //	0x00040000L
	{ STYLE(WS_GROUP) }, //			0x00020000L
	{ STYLE(WS_TABSTOP) }, //		0x00010000L
	{ STYLE(WS_MINIMIZEBOX) },//	0x00020000L
	{ STYLE(WS_MAXIMIZEBOX) },//	0x00010000L
//	{ STYLE(WS_TILED) }, // duplicate
//	{ STYLE(WS_ICONIC) }, // duplicate
//	{ STYLE(WS_SIZEBOX) }, // duplicate
//	{ STYLE(WS_TILEDWINDOW) }, // duplicate
//	{ STYLE(WS_OVERLAPPEDWINDOW) }, // aggregate style
//	{ STYLE(WS_POPUPWINDOW) }, // aggregate style
//	{ STYLE(WS_CHILDWINDOW) }, // duplicate
};

const int NUMWNDSTYLES = sizeof(WindowStyles) / sizeof(Style);

static UINT LookupWndStyle(LPCTSTR szStyle)
{
	int nStyle = NUMWNDSTYLES;

	while (nStyle--)
	{
		if (lstrcmp(szStyle, WindowStyles[nStyle].szStyle) == 0)
			return WindowStyles[nStyle].dwStyle;
	}

	return 0;
}

////////

static Style WindowExStyles[] = 
{
	{ STYLE(WS_EX_DLGMODALFRAME) }, //	0x00000001L
	{ STYLE(WS_EX_NOPARENTNOTIFY) }, //	0x00000004L
	{ STYLE(WS_EX_TOPMOST) }, //		0x00000008L
	{ STYLE(WS_EX_ACCEPTFILES) }, //	0x00000010L
	{ STYLE(WS_EX_TRANSPARENT) }, //	0x00000020L
	{ STYLE(WS_EX_MDICHILD) }, //		0x00000040L
	{ STYLE(WS_EX_TOOLWINDOW) }, //		0x00000080L
	{ STYLE(WS_EX_WINDOWEDGE) }, //		0x00000100L
	{ STYLE(WS_EX_CLIENTEDGE) }, //		0x00000200L
	{ STYLE(WS_EX_CONTEXTHELP) }, //	0x00000400L
	{ STYLE(WS_EX_RIGHT) },	 // 		0x00001000L
	{ STYLE(WS_EX_LEFT) }, //			0x00000000L
	{ STYLE(WS_EX_RTLREADING) }, //		0x00002000L
	{ STYLE(WS_EX_LTRREADING) }, //		0x00000000L
	{ STYLE(WS_EX_LEFTSCROLLBAR) }, //	0x00004000L
	{ STYLE(WS_EX_RIGHTSCROLLBAR) }, // 0x00000000L
	{ STYLE(WS_EX_CONTROLPARENT) }, //	0x00010000L
	{ STYLE(WS_EX_STATICEDGE) }, //		0x00020000L
	{ STYLE(WS_EX_APPWINDOW) }, //		0x00040000L
//	{ STYLE(WS_EX_OVERLAPPEDWINDOW) }, // aggregate style
//	{ STYLE(WS_EX_PALETTEWINDOW) }, // aggregate style
};

const int NUMWNDEXSTYLES = sizeof(WindowExStyles) / sizeof(Style);

static UINT LookupWndExStyle(LPCTSTR szStyle)
{
	int nStyle = NUMWNDEXSTYLES;

	while (nStyle--)
	{
		if (lstrcmp(szStyle, WindowExStyles[nStyle].szStyle) == 0)
			return WindowExStyles[nStyle].dwStyle;
	}

	return 0;
}

//////

static Style HitTests[] = 
{
	{ STYLE(HTERROR) }, //             (-2)
	{ STYLE(HTTRANSPARENT) }, //       (-1)
	{ STYLE(HTNOWHERE) }, //           0
	{ STYLE(HTCLIENT) }, //            1
	{ STYLE(HTCAPTION) }, //           2
	{ STYLE(HTSYSMENU) }, //           3
	{ STYLE(HTGROWBOX) }, //           4
	{ STYLE(HTSIZE) }, //              HTGROWBOX
	{ STYLE(HTMENU) }, //              5
	{ STYLE(HTHSCROLL) }, //           6
	{ STYLE(HTVSCROLL) }, //           7
	{ STYLE(HTMINBUTTON) }, //         8
	{ STYLE(HTMAXBUTTON) }, //         9
	{ STYLE(HTLEFT) }, //              10
	{ STYLE(HTRIGHT) }, //             11
	{ STYLE(HTTOP) }, //               12
	{ STYLE(HTTOPLEFT) }, //           13
	{ STYLE(HTTOPRIGHT) }, //          14
	{ STYLE(HTBOTTOM) }, //            15
	{ STYLE(HTBOTTOMLEFT) }, //        16
	{ STYLE(HTBOTTOMRIGHT) }, //       17
	{ STYLE(HTBORDER) }, //            18
	{ STYLE(HTREDUCE) }, //            HTMINBUTTON
	{ STYLE(HTZOOM) }, //              HTMAXBUTTON
	{ STYLE(HTSIZEFIRST) }, //         HTLEFT
	{ STYLE(HTSIZELAST) }, //          HTBOTTOMRIGHT
	{ STYLE(HTOBJECT) }, //            19
	{ STYLE(HTCLOSE) }, //             20
	{ STYLE(HTHELP) }, //              21
};

// controls
struct Control
{
	LPCTSTR szControlClass; // window class name
	LPCTSTR szBaseClass; // avoids duplicating styles for richedit and comboboxex
	DWORD dwExStyleMsg; // msg to send to control to retrieve Ex styles
};

static Control Controls[] = 
{
	{ WC_BUTTON, _T(""), 0 }, 
	{ WC_STATIC, _T(""), 0 },
	{ WC_EDIT, _T(""), 0 },
	{ WC_COMBOBOX, _T(""), 0 },
	{ WC_COMBOLBOX, WC_LISTBOX, 0 }, // drop list for the combo box
	{ WC_LISTBOX, _T(""), 0 },
	{ WC_SCROLLBAR, _T(""), 0 },
	{ WC_TOOLBAR, _T("CommonControl"), TB_GETEXTENDEDSTYLE }, 
	{ WC_SPIN, _T(""), 0 },
	{ WC_PROGRESS, _T(""), 0 },
	{ WC_SLIDER, _T(""), 0 },
	{ WC_HOTKEY, _T(""), 0 },
	{ WC_LISTVIEW, _T(""), LVM_GETEXTENDEDLISTVIEWSTYLE },
	{ WC_TREEVIEW, _T(""), 0 },
	{ WC_TABCONTROL, _T(""), TCM_GETEXTENDEDSTYLE },
	{ WC_ANIMATE, _T(""), 0 },
	{ WC_RICHEDIT, WC_EDIT, EM_GETEVENTMASK },	// event mask is like extended styles
	{ WC_DATETIMEPICK, _T(""), 0 },
	{ WC_MONTHCAL, _T(""), 0 },
	{ WC_IPADDRESS, _T(""), 0 },
	{ WC_PAGESCROLLER, _T(""), 0 },
	{ WC_COMBOBOXEX, WC_COMBOBOX, CBEM_GETEXTENDEDSTYLE },
	{ WC_STATUSBAR, _T("CommonControl"), 0 },
	{ WC_REBAR, _T(""), 0 },
	{ WC_HEADER, _T(""), 0 },
	{ _T("DialogBox"), _T(""), 0 },
	{ _T("MDIClient"), _T(""), 0 },
	{ WC_TOOLTIPS, _T(""), 0 },
};

struct CtrlStyle
{
	LPCTSTR szControlClass; // window class name
	LPCTSTR szStyle; // style name
	DWORD dwStyle; // style value
	DWORD dwMask; // required masked
	BOOL bExStyle; // is it an _EX_ style
};

#define NOMASK 0x0L

#ifndef HDS_VERT
#define HDS_VERT 0x0001
#endif

////////

static CtrlStyle ControlStyles[] = 
{
	{ WC_BUTTON, STYLE(BS_PUSHBUTTON), 0x0F, 0 },//		0x00000000L
	{ WC_BUTTON, STYLE(BS_DEFPUSHBUTTON), 0x0F, 0 },//	0x00000001L
	{ WC_BUTTON, STYLE(BS_CHECKBOX), 0x0F, 0 },//		0x00000002L
	{ WC_BUTTON, STYLE(BS_AUTOCHECKBOX), 0x0F, 0 },//	0x00000003L
	{ WC_BUTTON, STYLE(BS_RADIOBUTTON), 0x0F, 0 },//		0x00000004L
	{ WC_BUTTON, STYLE(BS_3STATE), 0x0F, 0 },//			0x00000005L
	{ WC_BUTTON, STYLE(BS_AUTO3STATE), 0x0F, 0 },//		0x00000006L
	{ WC_BUTTON, STYLE(BS_GROUPBOX), 0x0F, 0 },//		0x00000007L
	{ WC_BUTTON, STYLE(BS_USERBUTTON), 0x0F, 0 },//		0x00000008L
	{ WC_BUTTON, STYLE(BS_AUTORADIOBUTTON), 0x0F, 0 },//	0x00000009L
	{ WC_BUTTON, STYLE(BS_OWNERDRAW), 0x0F, 0 },//		0x0000000BL
	{ WC_BUTTON, STYLE(BS_LEFTTEXT), NOMASK, 0 },//		0x00000020L
	{ WC_BUTTON, STYLE(BS_TEXT), NOMASK, 0 }, //			0x00000000L
	{ WC_BUTTON, STYLE(BS_ICON), NOMASK, 0 }, //			0x00000040L
	{ WC_BUTTON, STYLE(BS_BITMAP), NOMASK, 0 },//		0x00000080L
	{ WC_BUTTON, STYLE(BS_LEFT), NOMASK, 0 }, //			0x00000100L
	{ WC_BUTTON, STYLE(BS_RIGHT), NOMASK, 0 },//			0x00000200L
	{ WC_BUTTON, STYLE(BS_CENTER), NOMASK, 0 },//		0x00000300L
	{ WC_BUTTON, STYLE(BS_TOP), NOMASK, 0 }, //			0x00000400L
	{ WC_BUTTON, STYLE(BS_BOTTOM), NOMASK, 0 },//		0x00000800L
	{ WC_BUTTON, STYLE(BS_VCENTER), NOMASK, 0 },//		0x00000C00L
	{ WC_BUTTON, STYLE(BS_PUSHLIKE), NOMASK, 0 },//		0x00001000L
	{ WC_BUTTON, STYLE(BS_MULTILINE), NOMASK, 0 },//		0x00002000L
	{ WC_BUTTON, STYLE(BS_NOTIFY), NOMASK, 0 }, //		0x00004000L
	{ WC_BUTTON, STYLE(BS_FLAT), NOMASK, 0 }, //			0x00008000L
	{ WC_BUTTON, STYLE(BS_RIGHTBUTTON), NOMASK, 0 }, //	BS_LEFTTEXT

	{ WC_STATIC, STYLE(SS_LEFT), 0x1FL, 0 },//             0x00000000L
	{ WC_STATIC, STYLE(SS_CENTER), 0x1FL, 0 },//           0x00000001L
	{ WC_STATIC, STYLE(SS_RIGHT), 0x1FL, 0 },//            0x00000002L
	{ WC_STATIC, STYLE(SS_ICON), 0x1FL, 0 },//             0x00000003L
	{ WC_STATIC, STYLE(SS_BLACKRECT), 0x1FL, 0 },//        0x00000004L
	{ WC_STATIC, STYLE(SS_GRAYRECT), 0x1FL, 0 },//         0x00000005L
	{ WC_STATIC, STYLE(SS_WHITERECT), 0x1FL, 0 },//        0x00000006L
	{ WC_STATIC, STYLE(SS_BLACKFRAME), 0x1FL, 0 },//       0x00000007L
	{ WC_STATIC, STYLE(SS_GRAYFRAME), 0x1FL, 0 },//        0x00000008L
	{ WC_STATIC, STYLE(SS_WHITEFRAME), 0x1FL, 0 },//       0x00000009L
	{ WC_STATIC, STYLE(SS_USERITEM), 0x1FL, 0 },//         0x0000000AL
	{ WC_STATIC, STYLE(SS_SIMPLE), 0x1FL, 0 },//           0x0000000BL
	{ WC_STATIC, STYLE(SS_LEFTNOWORDWRAP), 0x1FL, 0 },//   0x0000000CL
	{ WC_STATIC, STYLE(SS_OWNERDRAW), 0x1FL, 0 },//        0x0000000DL
	{ WC_STATIC, STYLE(SS_BITMAP), 0x1FL, 0 },//           0x0000000EL
	{ WC_STATIC, STYLE(SS_ENHMETAFILE), 0x1FL, 0 },//      0x0000000FL
	{ WC_STATIC, STYLE(SS_ETCHEDHORZ), 0x1FL, 0 },//       0x00000010L
	{ WC_STATIC, STYLE(SS_ETCHEDVERT), 0x1FL, 0 },//       0x00000011L
	{ WC_STATIC, STYLE(SS_ETCHEDFRAME), 0x1FL, 0 },//      0x00000012L
	{ WC_STATIC, STYLE(SS_NOPREFIX), NOMASK, 0 },//        0x00000080L
	{ WC_STATIC, STYLE(SS_NOTIFY), NOMASK, 0 },//          0x00000100L
	{ WC_STATIC, STYLE(SS_CENTERIMAGE), NOMASK, 0 },//     0x00000200L
	{ WC_STATIC, STYLE(SS_RIGHTJUST), NOMASK, 0 },//       0x00000400L
	{ WC_STATIC, STYLE(SS_REALSIZEIMAGE), NOMASK, 0 },//   0x00000800L
	{ WC_STATIC, STYLE(SS_SUNKEN), NOMASK, 0 },//          0x00001000L
	{ WC_STATIC, STYLE(SS_ENDELLIPSIS), 0xC000L, 0 },//    0x00004000L
	{ WC_STATIC, STYLE(SS_PATHELLIPSIS), 0xC000L, 0 },//   0x00008000L
	{ WC_STATIC, STYLE(SS_WORDELLIPSIS), 0xC000L, 0 },//   0x0000C000L

	{ WC_EDIT, STYLE(ES_LEFT), 0x2L, 0 },//                0x0000L
	{ WC_EDIT, STYLE(ES_CENTER), 0x2L, 0 },//              0x0001L
	{ WC_EDIT, STYLE(ES_RIGHT), 0x2L, 0 },//               0x0002L
	{ WC_EDIT, STYLE(ES_MULTILINE), NOMASK, 0 },//         0x0004L
	{ WC_EDIT, STYLE(ES_UPPERCASE), NOMASK, 0 },//         0x0008L
	{ WC_EDIT, STYLE(ES_LOWERCASE), NOMASK, 0 },//         0x0010L
	{ WC_EDIT, STYLE(ES_PASSWORD), NOMASK, 0 },//          0x0020L
	{ WC_EDIT, STYLE(ES_AUTOVSCROLL), NOMASK, 0 },//       0x0040L
	{ WC_EDIT, STYLE(ES_AUTOHSCROLL), NOMASK, 0 },//       0x0080L
	{ WC_EDIT, STYLE(ES_NOHIDESEL), NOMASK, 0 },//         0x0100L
	{ WC_EDIT, STYLE(ES_OEMCONVERT), NOMASK, 0 },//        0x0400L
	{ WC_EDIT, STYLE(ES_READONLY), NOMASK, 0 },//          0x0800L
	{ WC_EDIT, STYLE(ES_WANTRETURN), NOMASK, 0 },//        0x1000L
	{ WC_EDIT, STYLE(ES_NUMBER), NOMASK, 0 },//            0x2000L

	{ WC_COMBOBOX, STYLE(CBS_SIMPLE), 0xFL, 0 },//               0x0001L
	{ WC_COMBOBOX, STYLE(CBS_DROPDOWN), 0xFL, 0 },//             0x0002L
	{ WC_COMBOBOX, STYLE(CBS_DROPDOWNLIST), 0xFL, 0 },//         0x0003L
	{ WC_COMBOBOX, STYLE(CBS_OWNERDRAWFIXED), NOMASK, 0 },//     0x0010L
	{ WC_COMBOBOX, STYLE(CBS_OWNERDRAWVARIABLE), NOMASK, 0 },//  0x0020L
	{ WC_COMBOBOX, STYLE(CBS_AUTOHSCROLL), NOMASK, 0 },//        0x0040L
	{ WC_COMBOBOX, STYLE(CBS_OEMCONVERT), NOMASK, 0 },//         0x0080L
	{ WC_COMBOBOX, STYLE(CBS_SORT), NOMASK, 0 },//               0x0100L
	{ WC_COMBOBOX, STYLE(CBS_HASSTRINGS), NOMASK, 0 },//         0x0200L
	{ WC_COMBOBOX, STYLE(CBS_NOINTEGRALHEIGHT), NOMASK, 0 },//   0x0400L
	{ WC_COMBOBOX, STYLE(CBS_DISABLENOSCROLL), NOMASK, 0 },//    0x0800L
	{ WC_COMBOBOX, STYLE(CBS_UPPERCASE), NOMASK, 0 },//          0x2000L
	{ WC_COMBOBOX, STYLE(CBS_LOWERCASE), NOMASK, 0 },//          0x4000L

	{ WC_LISTBOX, STYLE(LBS_NOTIFY), NOMASK, 0 },//             0x0001L
	{ WC_LISTBOX, STYLE(LBS_SORT), NOMASK, 0 },//               0x0002L
	{ WC_LISTBOX, STYLE(LBS_NOREDRAW), NOMASK, 0 },//           0x0004L
	{ WC_LISTBOX, STYLE(LBS_MULTIPLESEL), NOMASK, 0 },//        0x0008L
	{ WC_LISTBOX, STYLE(LBS_OWNERDRAWFIXED), NOMASK, 0 },//     0x0010L
	{ WC_LISTBOX, STYLE(LBS_OWNERDRAWVARIABLE), NOMASK, 0 },//  0x0020L
	{ WC_LISTBOX, STYLE(LBS_HASSTRINGS), NOMASK, 0 },//         0x0040L
	{ WC_LISTBOX, STYLE(LBS_USETABSTOPS), NOMASK, 0 },//        0x0080L
	{ WC_LISTBOX, STYLE(LBS_NOINTEGRALHEIGHT), NOMASK, 0 },//   0x0100L
	{ WC_LISTBOX, STYLE(LBS_MULTICOLUMN), NOMASK, 0 },//        0x0200L
	{ WC_LISTBOX, STYLE(LBS_WANTKEYBOARDINPUT), NOMASK, 0 },//  0x0400L
	{ WC_LISTBOX, STYLE(LBS_EXTENDEDSEL), NOMASK, 0 },//        0x0800L
	{ WC_LISTBOX, STYLE(LBS_DISABLENOSCROLL), NOMASK, 0 },//    0x1000L
	{ WC_LISTBOX, STYLE(LBS_NODATA), NOMASK, 0 },//             0x2000L
	{ WC_LISTBOX, STYLE(LBS_NOSEL), NOMASK, 0 },//              0x4000L
	{ WC_LISTBOX, STYLE(LBS_STANDARD), NOMASK, 0 },//           (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)

	{ WC_SCROLLBAR, STYLE(SBS_HORZ), 0x1L, 0 },//                       0x0000L
	{ WC_SCROLLBAR, STYLE(SBS_VERT), 0x1L, 0 },//                       0x0001L
	{ WC_SCROLLBAR, STYLE(SBS_TOPALIGN), NOMASK, 0 },//                 0x0002L
	{ WC_SCROLLBAR, STYLE(SBS_LEFTALIGN), NOMASK, 0 },//                0x0002L
	{ WC_SCROLLBAR, STYLE(SBS_BOTTOMALIGN), NOMASK, 0 },//              0x0004L
	{ WC_SCROLLBAR, STYLE(SBS_RIGHTALIGN), NOMASK, 0 },//               0x0004L
	{ WC_SCROLLBAR, STYLE(SBS_SIZEBOXTOPLEFTALIGN), NOMASK, 0 },//      0x0002L
	{ WC_SCROLLBAR, STYLE(SBS_SIZEBOXBOTTOMRIGHTALIGN), NOMASK, 0 },//  0x0004L
	{ WC_SCROLLBAR, STYLE(SBS_SIZEBOX), NOMASK, 0 },//                  0x0008L
	{ WC_SCROLLBAR, STYLE(SBS_SIZEGRIP), NOMASK, 0 },//                 0x0010L

/*	{ WC_TOOLBAR, STYLE(TBSTYLE_BUTTON), 0x1L, 0 },//             0x0000
	{ WC_TOOLBAR, STYLE(TBSTYLE_SEP), 0x1L, 0 },//                0x0001
	{ WC_TOOLBAR, STYLE(TBSTYLE_CHECK), NOMASK, 0 },//            0x0002
	{ WC_TOOLBAR, STYLE(TBSTYLE_GROUP), NOMASK, 0 },//            0x0004
	{ WC_TOOLBAR, STYLE(TBSTYLE_CHECKGROUP), NOMASK, 0 },//       (TBSTYLE_GROUP | TBSTYLE_CHECK)
	{ WC_TOOLBAR, STYLE(TBSTYLE_DROPDOWN), NOMASK, 0 },//         0x0008
*/	{ WC_TOOLBAR, STYLE(TBSTYLE_AUTOSIZE), NOMASK, 0 },//         0x0010 // automatically calculate the cx of the button
	{ WC_TOOLBAR, STYLE(TBSTYLE_NOPREFIX), NOMASK, 0 },//         0x0020 // if this button should not have accel prefix
	{ WC_TOOLBAR, STYLE(TBSTYLE_TOOLTIPS), NOMASK, 0 },//         0x0100
	{ WC_TOOLBAR, STYLE(TBSTYLE_WRAPABLE), NOMASK, 0 },//         0x0200
	{ WC_TOOLBAR, STYLE(TBSTYLE_ALTDRAG), NOMASK, 0 },//          0x0400
	{ WC_TOOLBAR, STYLE(TBSTYLE_FLAT), NOMASK, 0 },//             0x0800
	{ WC_TOOLBAR, STYLE(TBSTYLE_LIST), NOMASK, 0 },//             0x1000
	{ WC_TOOLBAR, STYLE(TBSTYLE_CUSTOMERASE), NOMASK, 0 },//      0x2000
	{ WC_TOOLBAR, STYLE(TBSTYLE_REGISTERDROP), NOMASK, 0 },//     0x4000
	{ WC_TOOLBAR, STYLE(TBSTYLE_TRANSPARENT), NOMASK, 0 },//      0x8000
	{ WC_TOOLBAR, STYLE(TBSTYLE_EX_DRAWDDARROWS), NOMASK, 1 },//  0x00000001

	{ _T("CommonControl"), STYLE(CCS_TOP), NOMASK, 0 },//                 0x00000001L
	{ _T("CommonControl"), STYLE(CCS_NOMOVEY), NOMASK, 0 },//             0x00000002L
	{ _T("CommonControl"), STYLE(CCS_BOTTOM), NOMASK, 0 },//              0x00000003L
	{ _T("CommonControl"), STYLE(CCS_NORESIZE), NOMASK, 0 },//            0x00000004L
	{ _T("CommonControl"), STYLE(CCS_NOPARENTALIGN), NOMASK, 0 },//       0x00000008L
	{ _T("CommonControl"), STYLE(CCS_ADJUSTABLE), NOMASK, 0 },//          0x00000020L
	{ _T("CommonControl"), STYLE(CCS_NODIVIDER), NOMASK, 0 },//           0x00000040L
	{ _T("CommonControl"), STYLE(CCS_VERT), NOMASK, 0 },//                0x00000080L

	{ WC_SPIN, STYLE(UDS_WRAP), NOMASK, 0 },//                 0x0001
	{ WC_SPIN, STYLE(UDS_SETBUDDYINT), NOMASK, 0 },//          0x0002
	{ WC_SPIN, STYLE(UDS_ALIGNRIGHT), NOMASK, 0 },//           0x0004
	{ WC_SPIN, STYLE(UDS_ALIGNLEFT), NOMASK, 0 },//            0x0008
	{ WC_SPIN, STYLE(UDS_AUTOBUDDY), NOMASK, 0 },//            0x0010
	{ WC_SPIN, STYLE(UDS_ARROWKEYS), NOMASK, 0 },//            0x0020
	{ WC_SPIN, STYLE(UDS_HORZ), NOMASK, 0 },//                 0x0040
	{ WC_SPIN, STYLE(UDS_NOTHOUSANDS), NOMASK, 0 },//          0x0080
	{ WC_SPIN, STYLE(UDS_HOTTRACK), NOMASK, 0 },//             0x0100

	{ WC_PROGRESS, STYLE(PBS_SMOOTH), NOMASK, 0 },//               0x01
	{ WC_PROGRESS, STYLE(PBS_VERTICAL), NOMASK, 0 },//             0x04

	{ WC_SLIDER, STYLE(TBS_AUTOTICKS), NOMASK, 0 },//            0x0001
	{ WC_SLIDER, STYLE(TBS_VERT), NOMASK, 0 },//                 0x0002
	{ WC_SLIDER, STYLE(TBS_HORZ), NOMASK, 0 },//                 0x0000
	{ WC_SLIDER, STYLE(TBS_TOP), NOMASK, 0 },//                  0x0004
	{ WC_SLIDER, STYLE(TBS_BOTTOM), NOMASK, 0 },//               0x0000
	{ WC_SLIDER, STYLE(TBS_LEFT), NOMASK, 0 },//                 0x0004
	{ WC_SLIDER, STYLE(TBS_RIGHT), NOMASK, 0 },//                0x0000
	{ WC_SLIDER, STYLE(TBS_BOTH), NOMASK, 0 },//                 0x0008
	{ WC_SLIDER, STYLE(TBS_NOTICKS), NOMASK, 0 },//              0x0010
	{ WC_SLIDER, STYLE(TBS_ENABLESELRANGE), NOMASK, 0 },//       0x0020
	{ WC_SLIDER, STYLE(TBS_FIXEDLENGTH), NOMASK, 0 },//          0x0040
	{ WC_SLIDER, STYLE(TBS_NOTHUMB), NOMASK, 0 },//              0x0080
	{ WC_SLIDER, STYLE(TBS_TOOLTIPS), NOMASK, 0 },//             0x0100

//	{ "msctls_hotkey32", // has no styles

	{ WC_LISTVIEW, STYLE(LVS_ICON), LVS_TYPEMASK, 0 },//           0x0000
	{ WC_LISTVIEW, STYLE(LVS_REPORT), LVS_TYPEMASK, 0 },//         0x0001
	{ WC_LISTVIEW, STYLE(LVS_SMALLICON), LVS_TYPEMASK, 0 },//      0x0002
	{ WC_LISTVIEW, STYLE(LVS_LIST), LVS_TYPEMASK, 0 },//           0x0003
//	{ WC_LISTVIEW, STYLE(LVS_TYPEMASK), NOMASK, 0 },//             0x0003
	{ WC_LISTVIEW, STYLE(LVS_SINGLESEL), NOMASK, 0 },//            0x0004
	{ WC_LISTVIEW, STYLE(LVS_SHOWSELALWAYS), NOMASK, 0 },//        0x0008
	{ WC_LISTVIEW, STYLE(LVS_SORTASCENDING), NOMASK, 0 },//        0x0010
	{ WC_LISTVIEW, STYLE(LVS_SORTDESCENDING), NOMASK, 0 },//       0x0020
	{ WC_LISTVIEW, STYLE(LVS_SHAREIMAGELISTS), NOMASK, 0 },//      0x0040
	{ WC_LISTVIEW, STYLE(LVS_NOLABELWRAP), NOMASK, 0 },//          0x0080
	{ WC_LISTVIEW, STYLE(LVS_AUTOARRANGE), NOMASK, 0 },//          0x0100
	{ WC_LISTVIEW, STYLE(LVS_EDITLABELS), NOMASK, 0 },//           0x0200
	{ WC_LISTVIEW, STYLE(LVS_OWNERDATA), NOMASK, 0 },//            0x1000
	{ WC_LISTVIEW, STYLE(LVS_NOSCROLL), NOMASK, 0 },//             0x2000
//	{ WC_LISTVIEW, STYLE(LVS_TYPESTYLEMASK), NOMASK, 0 },//        0xfc00
	{ WC_LISTVIEW, STYLE(LVS_ALIGNTOP), LVS_ALIGNMASK, 0 },//      0x0000
	{ WC_LISTVIEW, STYLE(LVS_ALIGNLEFT), LVS_ALIGNMASK, 0 },//     0x0800
//	{ WC_LISTVIEW, STYLE(LVS_ALIGNMASK), NOMASK, 0 },//            0x0c00
	{ WC_LISTVIEW, STYLE(LVS_OWNERDRAWFIXED), NOMASK, 0 },//       0x0400
	{ WC_LISTVIEW, STYLE(LVS_NOCOLUMNHEADER), NOMASK, 0 },//       0x4000
	{ WC_LISTVIEW, STYLE(LVS_NOSORTHEADER), NOMASK, 0 },//         0x8000
	{ WC_LISTVIEW, STYLE(LVS_EX_GRIDLINES), NOMASK, 1 },//        0x00000001
	{ WC_LISTVIEW, STYLE(LVS_EX_SUBITEMIMAGES), NOMASK, 1 },//    0x00000002
	{ WC_LISTVIEW, STYLE(LVS_EX_CHECKBOXES), NOMASK, 1 },//       0x00000004
	{ WC_LISTVIEW, STYLE(LVS_EX_TRACKSELECT), NOMASK, 1 },//      0x00000008
	{ WC_LISTVIEW, STYLE(LVS_EX_HEADERDRAGDROP), NOMASK, 1 },//   0x00000010
	{ WC_LISTVIEW, STYLE(LVS_EX_FULLROWSELECT), NOMASK, 1 },//    0x00000020 // applies to report mode only
	{ WC_LISTVIEW, STYLE(LVS_EX_ONECLICKACTIVATE), NOMASK, 1 },// 0x00000040
	{ WC_LISTVIEW, STYLE(LVS_EX_TWOCLICKACTIVATE), NOMASK, 1 },// 0x00000080
	{ WC_LISTVIEW, STYLE(LVS_EX_FLATSB), NOMASK, 1 },//           0x00000100
	{ WC_LISTVIEW, STYLE(LVS_EX_REGIONAL), NOMASK, 1 },//         0x00000200
	{ WC_LISTVIEW, STYLE(LVS_EX_INFOTIP), NOMASK, 1 },//          0x00000400 // listview does InfoTips for you
	{ WC_LISTVIEW, STYLE(LVS_EX_UNDERLINEHOT), NOMASK, 1 },//     0x00000800
	{ WC_LISTVIEW, STYLE(LVS_EX_UNDERLINECOLD), NOMASK, 1 },//    0x00001000
	{ WC_LISTVIEW, STYLE(LVS_EX_MULTIWORKAREAS), NOMASK, 1 },//   0x00002000

	{ WC_TREEVIEW, STYLE(TVS_HASBUTTONS), NOMASK, 0 },//           0x0001
	{ WC_TREEVIEW, STYLE(TVS_HASLINES), NOMASK, 0 },//             0x0002
	{ WC_TREEVIEW, STYLE(TVS_LINESATROOT), NOMASK, 0 },//          0x0004
	{ WC_TREEVIEW, STYLE(TVS_EDITLABELS), NOMASK, 0 },//           0x0008
	{ WC_TREEVIEW, STYLE(TVS_DISABLEDRAGDROP), NOMASK, 0 },//      0x0010
	{ WC_TREEVIEW, STYLE(TVS_SHOWSELALWAYS), NOMASK, 0 },//        0x0020
	{ WC_TREEVIEW, STYLE(TVS_RTLREADING), NOMASK, 0 },//           0x0040
	{ WC_TREEVIEW, STYLE(TVS_NOTOOLTIPS), NOMASK, 0 },//           0x0080
	{ WC_TREEVIEW, STYLE(TVS_CHECKBOXES), NOMASK, 0 },//           0x0100
	{ WC_TREEVIEW, STYLE(TVS_TRACKSELECT), NOMASK, 0 },//          0x0200
	{ WC_TREEVIEW, STYLE(TVS_SINGLEEXPAND), NOMASK, 0 },//         0x0400
	{ WC_TREEVIEW, STYLE(TVS_INFOTIP), NOMASK, 0 },//              0x0800
	{ WC_TREEVIEW, STYLE(TVS_FULLROWSELECT), NOMASK, 0 },//        0x1000
	{ WC_TREEVIEW, STYLE(TVS_NOSCROLL), NOMASK, 0 },//             0x2000
	{ WC_TREEVIEW, STYLE(TVS_NONEVENHEIGHT), NOMASK, 0 },//        0x4000

	{ WC_TABCONTROL, STYLE(TCS_SCROLLOPPOSITE), NOMASK, 0 },//       0x0001   // assumes multiline tab
	{ WC_TABCONTROL, STYLE(TCS_BOTTOM), NOMASK, 0 },//               0x0002
	{ WC_TABCONTROL, STYLE(TCS_RIGHT), NOMASK, 0 },//                0x0002
	{ WC_TABCONTROL, STYLE(TCS_MULTISELECT), NOMASK, 0 },//          0x0004  // allow multi-select in button mode
	{ WC_TABCONTROL, STYLE(TCS_FLATBUTTONS), NOMASK, 0 },//          0x0008
	{ WC_TABCONTROL, STYLE(TCS_FORCEICONLEFT), NOMASK, 0 },//        0x0010
	{ WC_TABCONTROL, STYLE(TCS_FORCELABELLEFT), NOMASK, 0 },//       0x0020
	{ WC_TABCONTROL, STYLE(TCS_HOTTRACK), NOMASK, 0 },//             0x0040
	{ WC_TABCONTROL, STYLE(TCS_VERTICAL), NOMASK, 0 },//             0x0080
	{ WC_TABCONTROL, STYLE(TCS_TABS), NOMASK, 0 },//                 0x0000
	{ WC_TABCONTROL, STYLE(TCS_BUTTONS), NOMASK, 0 },//              0x0100
	{ WC_TABCONTROL, STYLE(TCS_SINGLELINE), NOMASK, 0 },//           0x0000
	{ WC_TABCONTROL, STYLE(TCS_MULTILINE), NOMASK, 0 },//            0x0200
	{ WC_TABCONTROL, STYLE(TCS_RIGHTJUSTIFY), NOMASK, 0 },//         0x0000
	{ WC_TABCONTROL, STYLE(TCS_FIXEDWIDTH), NOMASK, 0 },//           0x0400
	{ WC_TABCONTROL, STYLE(TCS_RAGGEDRIGHT), NOMASK, 0 },//          0x0800
	{ WC_TABCONTROL, STYLE(TCS_FOCUSONBUTTONDOWN), NOMASK, 0 },//    0x1000
	{ WC_TABCONTROL, STYLE(TCS_OWNERDRAWFIXED), NOMASK, 0 },//       0x2000
	{ WC_TABCONTROL, STYLE(TCS_TOOLTIPS), NOMASK, 0 },//             0x4000
	{ WC_TABCONTROL, STYLE(TCS_FOCUSNEVER), NOMASK, 0 },//           0x8000
	{ WC_TABCONTROL, STYLE(TCS_EX_FLATSEPARATORS), NOMASK, 1 },//   0x00000001
	{ WC_TABCONTROL, STYLE(TCS_EX_REGISTERDROP), NOMASK, 1 },//     0x00000002

	{ WC_ANIMATE, STYLE(ACS_CENTER), NOMASK, 0 },//               0x0001
	{ WC_ANIMATE, STYLE(ACS_TRANSPARENT), NOMASK, 0 },//          0x0002
	{ WC_ANIMATE, STYLE(ACS_AUTOPLAY), NOMASK, 0 },//             0x0004
	{ WC_ANIMATE, STYLE(ACS_TIMER), NOMASK, 0 },//                0x0008  // don't use threads... use timers

	// uses styles from EDIT control
	{ WC_RICHEDIT, STYLE(ES_SAVESEL), NOMASK, 0 },//				0x00008000
	{ WC_RICHEDIT, STYLE(ES_SUNKEN), NOMASK, 0 },//				0x00004000
	{ WC_RICHEDIT, STYLE(ES_DISABLENOSCROLL), NOMASK, 0 },//		0x00002000
	{ WC_RICHEDIT, STYLE(ES_SELECTIONBAR), NOMASK, 0 },//		0x01000000
	{ WC_RICHEDIT, STYLE(ES_NOOLEDRAGDROP), NOMASK, 0 },//		0x00000008
	// event mask is like extended styles
	{ WC_RICHEDIT, STYLE(ENM_NONE), 0x1L, 1 },//				0x00000000
	{ WC_RICHEDIT, STYLE(ENM_CHANGE), NOMASK, 1 },//				0x00000001
	{ WC_RICHEDIT, STYLE(ENM_UPDATE), NOMASK, 1 },//				0x00000002
	{ WC_RICHEDIT, STYLE(ENM_SCROLL), NOMASK, 1 },//				0x00000004
	{ WC_RICHEDIT, STYLE(ENM_KEYEVENTS), NOMASK, 1 },//			0x00010000
	{ WC_RICHEDIT, STYLE(ENM_MOUSEEVENTS), NOMASK, 1 },//		0x00020000
	{ WC_RICHEDIT, STYLE(ENM_REQUESTRESIZE), NOMASK, 1 },//		0x00040000
	{ WC_RICHEDIT, STYLE(ENM_SELCHANGE), NOMASK, 1 },//			0x00080000
	{ WC_RICHEDIT, STYLE(ENM_DROPFILES), NOMASK, 1 },//			0x00100000
	{ WC_RICHEDIT, STYLE(ENM_PROTECTED), NOMASK, 1 },//			0x00200000
	{ WC_RICHEDIT, STYLE(ENM_CORRECTTEXT), NOMASK, 1 },//		0x00400000		/* PenWin specific */
	{ WC_RICHEDIT, STYLE(ENM_SCROLLEVENTS), NOMASK, 1 },//		0x00000008
	{ WC_RICHEDIT, STYLE(ENM_DRAGDROPDONE), NOMASK, 1 },//		0x00000010
	{ WC_RICHEDIT, STYLE(ENM_IMECHANGE), NOMASK, 1 },//			0x00800000		/* unused by RE2.0 */
	{ WC_RICHEDIT, STYLE(ENM_LANGCHANGE), NOMASK, 1 },//			0x01000000
	{ WC_RICHEDIT, STYLE(ENM_OBJECTPOSITIONS), NOMASK, 1 },//	0x02000000
	{ WC_RICHEDIT, STYLE(ENM_LINK), NOMASK, 1 },//				0x04000000

	{ WC_DATETIMEPICK, STYLE(DTS_UPDOWN), NOMASK, 0 },//           0x0001 // use UPDOWN instead of MONTHCAL
	{ WC_DATETIMEPICK, STYLE(DTS_SHOWNONE), NOMASK, 0 },//         0x0002 // allow a NONE selection
	{ WC_DATETIMEPICK, STYLE(DTS_SHORTDATEFORMAT), 0x4L, 0 },//    0x0000 // use the short date format (app must forward WM_WININICHANGE messages)
	{ WC_DATETIMEPICK, STYLE(DTS_LONGDATEFORMAT), 0x4L, 0 },//     0x0004 // use the long date format (app must forward WM_WININICHANGE messages)
	{ WC_DATETIMEPICK, STYLE(DTS_TIMEFORMAT), NOMASK, 0 },//       0x0009 // use the time format (app must forward WM_WININICHANGE messages)
	{ WC_DATETIMEPICK, STYLE(DTS_APPCANPARSE), NOMASK, 0 },//      0x0010 // allow user entered strings (app MUST respond to DTN_USERSTRING)
	{ WC_DATETIMEPICK, STYLE(DTS_RIGHTALIGN), NOMASK, 0 },//       0x0020 // right-align popup instead of left-align it

	{ WC_MONTHCAL, STYLE(MCS_DAYSTATE), NOMASK, 0 },//         0x0001
	{ WC_MONTHCAL, STYLE(MCS_MULTISELECT), NOMASK, 0 },//      0x0002
	{ WC_MONTHCAL, STYLE(MCS_WEEKNUMBERS), NOMASK, 0 },//      0x0004
	{ WC_MONTHCAL, STYLE(MCS_NOTODAYCIRCLE), NOMASK, 0 },//    0x0008
	{ WC_MONTHCAL, STYLE(MCS_NOTODAY), NOMASK, 0 },//          0x0010

//	{ "SysIPAddress32", // no styles

	{ WC_PAGESCROLLER, STYLE(PGS_VERT), 0x1L, 0 },//                   0x00000000
	{ WC_PAGESCROLLER, STYLE(PGS_HORZ ), 0x1L, 0 },//                  0x00000001
	{ WC_PAGESCROLLER, STYLE(PGS_AUTOSCROLL), NOMASK, 0 },//           0x00000002
	{ WC_PAGESCROLLER, STYLE(PGS_DRAGNDROP), NOMASK, 0 },//            0x00000004

	// uses styles from combo box
	{ WC_COMBOBOXEX, STYLE(CBES_EX_NOEDITIMAGE), NOMASK, 1 },//          0x00000001
	{ WC_COMBOBOXEX, STYLE(CBES_EX_NOEDITIMAGEINDENT), NOMASK, 1 },//    0x00000002
	{ WC_COMBOBOXEX, STYLE(CBES_EX_PATHWORDBREAKPROC), NOMASK, 1 },//    0x00000004
	{ WC_COMBOBOXEX, STYLE(CBES_EX_NOSIZELIMIT), NOMASK, 1 },//          0x00000008
	{ WC_COMBOBOXEX, STYLE(CBES_EX_CASESENSITIVE), NOMASK, 1 },//        0x00000010

	{ WC_STATUSBAR, STYLE(SBARS_SIZEGRIP), NOMASK, 0 },//         0x0100

	{ WC_REBAR, STYLE(RBBS_BREAK), NOMASK, 0 },//           0x00000001  // break to new line
	{ WC_REBAR, STYLE(RBBS_FIXEDSIZE), NOMASK, 0 },//       0x00000002  // band can't be sized
	{ WC_REBAR, STYLE(RBBS_CHILDEDGE), NOMASK, 0 },//       0x00000004  // edge around top & bottom of child window
	{ WC_REBAR, STYLE(RBBS_HIDDEN), NOMASK, 0 },//          0x00000008  // don't show
	{ WC_REBAR, STYLE(RBBS_NOVERT), NOMASK, 0 },//          0x00000010  // don't show when vertical
	{ WC_REBAR, STYLE(RBBS_FIXEDBMP), NOMASK, 0 },//        0x00000020  // bitmap doesn't move during band resize
	{ WC_REBAR, STYLE(RBBS_VARIABLEHEIGHT), NOMASK, 0 },//  0x00000040  // allow autosizing of this child vertically
	{ WC_REBAR, STYLE(RBBS_GRIPPERALWAYS), NOMASK, 0 },//   0x00000080  // always show the gripper
	{ WC_REBAR, STYLE(RBBS_NOGRIPPER), NOMASK, 0 },//       0x00000100  // never show the gripper

	{ WC_HEADER, STYLE(HDS_HORZ), 0x1L, 0 },//                   0x0000
	{ WC_HEADER, STYLE(HDS_VERT), 0x1L, 0 },//                   0x0001
	{ WC_HEADER, STYLE(HDS_BUTTONS), NOMASK, 0 },//              0x0002
	{ WC_HEADER, STYLE(HDS_HOTTRACK), NOMASK, 0 },//             0x0004
	{ WC_HEADER, STYLE(HDS_HIDDEN), NOMASK, 0 },//               0x0008
	{ WC_HEADER, STYLE(HDS_DRAGDROP), NOMASK, 0 },//             0x0040
	{ WC_HEADER, STYLE(HDS_FULLDRAG), NOMASK, 0 },//             0x0080
	{ WC_HEADER, STYLE(HDS_BUTTONS), NOMASK, 0 },//              0x0002

	{ _T("DialogBox"), STYLE(DS_ABSALIGN), NOMASK, 0 },//          0x01L
	{ _T("DialogBox"), STYLE(DS_SYSMODAL), NOMASK, 0 },//          0x02L
	{ _T("DialogBox"), STYLE(DS_LOCALEDIT), NOMASK, 0 },//         0x20L   /* Edit items get Local storage. */
	{ _T("DialogBox"), STYLE(DS_SETFONT), NOMASK, 0 },//           0x40L   /* User specified font for Dlg controls */
	{ _T("DialogBox"), STYLE(DS_MODALFRAME), NOMASK, 0 },//        0x80L   /* Can be combined with WS_CAPTION  */
	{ _T("DialogBox"), STYLE(DS_NOIDLEMSG), NOMASK, 0 },//         0x100L  /* WM_ENTERIDLE message will not be sent */
	{ _T("DialogBox"), STYLE(DS_SETFOREGROUND), NOMASK, 0 },//     0x200L  /* not in win3.1 */
	{ _T("DialogBox"), STYLE(DS_3DLOOK), NOMASK, 0 },//            0x0004L
	{ _T("DialogBox"), STYLE(DS_FIXEDSYS), NOMASK, 0 },//          0x0008L
	{ _T("DialogBox"), STYLE(DS_NOFAILCREATE), NOMASK, 0 },//      0x0010L
	{ _T("DialogBox"), STYLE(DS_CONTROL), NOMASK, 0 },//           0x0400L
	{ _T("DialogBox"), STYLE(DS_CENTER), NOMASK, 0 },//            0x0800L
	{ _T("DialogBox"), STYLE(DS_CENTERMOUSE), NOMASK, 0 },//       0x1000L
	{ _T("DialogBox"), STYLE(DS_CONTEXTHELP), NOMASK, 0 },//       0x2000L

//	{ "MDIClient", // no styles

#ifndef TTS_NOANIMATE

	#define TTS_NOANIMATE           0x10
	#define TTS_NOFADE              0x20
	#define TTS_BALLOON             0x40

#endif

	{ WC_TOOLTIPS, STYLE(TTS_ALWAYSTIP), NOMASK, 0 }, //	0x01
	{ WC_TOOLTIPS, STYLE(TTS_NOPREFIX), NOMASK, 0 }, //	0x02
	{ WC_TOOLTIPS, STYLE(TTS_NOANIMATE), NOMASK, 0 }, //	0x10
	{ WC_TOOLTIPS, STYLE(TTS_NOFADE), NOMASK, 0 }, //	0x20
	{ WC_TOOLTIPS, STYLE(TTS_BALLOON), NOMASK, 0 }, //	0x40

};
#endif

const int NUMCTRLSTYLES = sizeof(ControlStyles) / sizeof(CtrlStyle);

static UINT LookupCtrlStyle(LPCTSTR szStyle)
{
	int nStyle = NUMCTRLSTYLES;

	while (nStyle--)
	{
		if (lstrcmp(szStyle, ControlStyles[nStyle].szStyle) == 0)
			return ControlStyles[nStyle].dwStyle;
	}

	return 0;
}

/////