New console code based on Win32 windows.

diff --git a/programs/Makefile.in b/programs/Makefile.in
index a0c47c7..5a73a09 100644
--- a/programs/Makefile.in
+++ b/programs/Makefile.in
@@ -17,6 +17,7 @@
 	uninstaller \
 	view \
 	wcmd \
+	wineconsole \
 	winemine \
 	winetest \
 	winhelp \
diff --git a/programs/wineconsole/.cvsignore b/programs/wineconsole/.cvsignore
new file mode 100644
index 0000000..ad904a9
--- /dev/null
+++ b/programs/wineconsole/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+wineconsole.spec.c
+wineconsole_res.res
diff --git a/programs/wineconsole/Makefile.in b/programs/wineconsole/Makefile.in
new file mode 100644
index 0000000..672de8f
--- /dev/null
+++ b/programs/wineconsole/Makefile.in
@@ -0,0 +1,19 @@
+EXTRADEFS = -DSTRICT -DUNICODE
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = wineconsole
+
+C_SRCS = \
+	dialog.c \
+	user.c \
+        wineconsole.c
+
+RC_SRCS = \
+        wineconsole_res.rc
+
+@MAKE_PROG_RULES@
+
+
+### Dependencies:
diff --git a/programs/wineconsole/dialog.c b/programs/wineconsole/dialog.c
new file mode 100644
index 0000000..04220ac
--- /dev/null
+++ b/programs/wineconsole/dialog.c
@@ -0,0 +1,515 @@
+/* dialog management for wineconsole
+ * (c) 2001 Eric Pouech
+ */
+
+#include <stdio.h>
+#include "winecon_private.h"
+#include "commctrl.h"
+#include "prsht.h"
+
+/* FIXME: so far, part of the code is made in ASCII because the Uncode property sheet functions
+ * are not implemented yet
+ */
+struct dialog_info 
+{
+    struct inner_data*	data;		/* pointer to current winecon info */
+    HWND		hDlg;		/* handle to window dialog */
+    int			nFont;		/* number of font size in size LB */
+    struct font_info 
+    {
+	TEXTMETRIC		tm;
+	LOGFONT			lf;
+    } 			*font;		/* array of nFont. index sync'ed with SIZE LB */
+};
+
+/******************************************************************
+ *		WCUSER_OptionDlgProc
+ *
+ * Dialog prop for the option property sheet
+ */
+static BOOL WINAPI WCUSER_OptionDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    struct dialog_info*		di;
+    unsigned 			idc;
+    
+    switch (msg) 
+    {
+    case WM_INITDIALOG:
+	di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam;
+	di->hDlg = hDlg;
+	SetWindowLongA(hDlg, DWL_USER, (DWORD)di);
+	if (di->data->cursor_size < 33)		idc = IDC_OPT_CURSOR_SMALL;
+	else if (di->data->cursor_size < 66)	idc = IDC_OPT_CURSOR_MEDIUM;
+	else					idc = IDC_OPT_CURSOR_LARGE;
+	SendDlgItemMessage(hDlg, idc, BM_SETCHECK, BST_CHECKED, 0L);
+	SetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, WINECON_GetHistorySize(di->data->hConIn),  FALSE);
+	if (WINECON_GetHistoryMode(di->data->hConIn))
+	    SendDlgItemMessage(hDlg, IDC_OPT_HIST_DOUBLE, BM_SETCHECK, BST_CHECKED, 0L);
+	return FALSE; /* because we set the focus */
+    case WM_COMMAND:
+	break;
+    case WM_NOTIFY:
+    {
+	NMHDR*	nmhdr = (NMHDR*)lParam;
+
+	di = (struct dialog_info*)GetWindowLongA(hDlg, DWL_USER);
+	switch (nmhdr->code) 
+	{
+	case PSN_SETACTIVE:
+	    /* needed in propsheet to keep properly the selected radio button
+	     * otherwise, the focus would be set to the first tab stop in the
+	     * propsheet, which would always activate the first radio button
+	     */
+	    if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED) 
+		idc = IDC_OPT_CURSOR_SMALL;
+	    else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED)
+		idc = IDC_OPT_CURSOR_MEDIUM;
+	    else
+		idc = IDC_OPT_CURSOR_LARGE;
+	    PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, idc), TRUE);
+	    break;
+	case PSN_APPLY:
+	{
+	    int		curs_size;
+	    int		hist_size;
+	    BOOL	done;
+
+	    if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED)	curs_size = 33;
+	    else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED) curs_size = 66;
+	    else curs_size = 99;
+	    if (curs_size != di->data->cursor_size)
+	    {
+		CONSOLE_CURSOR_INFO cinfo;
+		cinfo.dwSize = curs_size;
+		cinfo.bVisible = di->data->cursor_visible;
+		SetConsoleCursorInfo(di->data->hConOut, &cinfo);
+	    }
+	    hist_size = GetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, &done, FALSE);
+	    if (done) WINECON_SetHistorySize(di->data->hConIn, hist_size);
+	    SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+	    WINECON_SetHistoryMode(di->data->hConIn, 
+				   IsDlgButtonChecked(hDlg, IDC_OPT_HIST_DOUBLE) & BST_CHECKED);
+	    return TRUE;
+	}
+	default:
+	    return FALSE;
+	}
+	break;
+    }
+    default:
+	return FALSE;
+    }
+    return TRUE;
+}
+
+/******************************************************************
+ *		WCUSER_FontPreviewProc
+ *
+ * Window proc for font previewer in font property sheet
+ */
+static LRESULT WINAPI WCUSER_FontPreviewProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    switch (msg)
+    {
+    case WM_PAINT:
+    {
+	PAINTSTRUCT	ps;
+	int		font_idx;
+	int		size_idx;
+	struct dialog_info*	di;
+
+	di = (struct dialog_info*)GetWindowLong(GetParent(hWnd), DWL_USER);
+	BeginPaint(hWnd, &ps);
+	
+	font_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L);
+	size_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L);
+
+	if (font_idx >= 0 && size_idx >= 0 && size_idx < di->nFont)
+	{
+	    HFONT	hFont, hOldFont;
+	    WCHAR	buf1[256];
+	    WCHAR	buf2[256];
+	    int		len1, len2;
+
+	    hFont = CreateFontIndirect(&di->font[size_idx].lf);
+	    len1 = LoadString(GetModuleHandle(NULL), IDS_FNT_PREVIEW_1, 
+			      buf1, sizeof(buf1) / sizeof(WCHAR));
+	    len2 = LoadString(GetModuleHandle(NULL), IDS_FNT_PREVIEW_2,
+			      buf2, sizeof(buf2) / sizeof(WCHAR));
+	    if (hFont && len1)
+	    {
+		hOldFont = SelectObject(ps.hdc, hFont);
+		SetBkColor(ps.hdc, RGB(0x00, 0x00, 0x00));
+		SetTextColor(ps.hdc, RGB(0xFF, 0xFF, 0xFF));
+		TextOut(ps.hdc, 0, 0, buf1, len1);
+		if (len2)
+		    TextOut(ps.hdc, 0, di->font[size_idx].tm.tmHeight, buf2, len2);
+		SelectObject(ps.hdc, hOldFont);
+		DeleteObject(hFont);
+	    }
+	}
+	EndPaint(hWnd, &ps);
+	break;
+    }
+    default:
+	return DefWindowProc(hWnd, msg, wParam, lParam);
+    }
+    return 0L;
+}
+
+/******************************************************************
+ *		font_enum
+ *
+ *
+ */
+static int CALLBACK font_enum_size2(const LOGFONT* lf, const TEXTMETRIC* tm, 
+				    DWORD FontType, LPARAM lParam)
+{
+    struct dialog_info*	di = (struct dialog_info*)lParam;
+
+    if (WCUSER_ValidateFontMetric(di->data, tm))
+    {
+	di->nFont++;
+    }
+    return 1;
+}
+
+static int CALLBACK font_enum(const LOGFONT* lf, const TEXTMETRIC* tm, 
+			      DWORD FontType, LPARAM lParam)
+{
+    struct dialog_info*	di = (struct dialog_info*)lParam;
+    HDC	hdc;
+
+    if (WCUSER_ValidateFont(di->data, lf) && (hdc = GetDC(di->hDlg)))
+    {
+	di->nFont = 0;
+	EnumFontFamilies(hdc, lf->lfFaceName, font_enum_size2, (LPARAM)di);
+	if (di->nFont)
+	{
+	    int idx;
+	    idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_ADDSTRING, 
+				     0, (LPARAM)lf->lfFaceName);
+	}
+	ReleaseDC(di->hDlg, hdc);
+    }
+    return 1;
+}
+
+/******************************************************************
+ *		font_enum_size
+ *
+ *
+ */
+static int CALLBACK font_enum_size(const LOGFONT* lf, const TEXTMETRIC* tm, 
+				   DWORD FontType, LPARAM lParam)
+{
+    struct dialog_info*	di = (struct dialog_info*)lParam;
+
+    if (WCUSER_ValidateFontMetric(di->data, tm))
+    {
+	WCHAR	buf[32];
+	WCHAR	fmt[] = {'%','l','d',0};
+	int	idx;
+
+	/* we want the string to be sorted with a numeric order, not a lexicographic...
+	 * do the job by hand... get where to insert the new string
+	 */
+	for (idx = 0; idx < di->nFont && tm->tmHeight > di->font[idx].tm.tmHeight; idx++);
+	wsprintfW(buf, fmt, tm->tmHeight);
+	SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_INSERTSTRING, idx, (LPARAM)buf);
+
+	/* now grow our arrays and insert to values at the same index than in the list box */
+	di->font = HeapReAlloc(GetProcessHeap(), 0, di->font, sizeof(*di->font) * (di->nFont + 1));
+	if (idx != di->nFont)
+	    memmove(&di->font[idx + 1], &di->font[idx], (di->nFont - idx) * sizeof(*di->font));
+	di->font[idx].tm = *tm;
+	di->font[idx].lf = *lf;
+	di->nFont++;
+
+    }
+    return 1;
+}
+
+/******************************************************************
+ *		select_font
+ *
+ *
+ */
+static BOOL  select_font(struct dialog_info* di)
+{
+    int		idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L);
+    WCHAR	buf[256];
+    WCHAR	fmt[128];
+
+    if (idx < 0 || idx >= di->nFont)
+	return FALSE;
+
+    LoadString(GetModuleHandle(NULL), IDS_FNT_DISPLAY, fmt, sizeof(fmt) / sizeof(WCHAR));
+    wsprintfW(buf, fmt, di->font[idx].tm.tmMaxCharWidth, di->font[idx].tm.tmHeight);
+
+    SendDlgItemMessage(di->hDlg, IDC_FNT_FONT_INFO, WM_SETTEXT, 0, (LPARAM)buf);
+    InvalidateRect(GetDlgItem(di->hDlg, IDC_FNT_PREVIEW), NULL, TRUE);
+    UpdateWindow(GetDlgItem(di->hDlg, IDC_FNT_PREVIEW));
+    return TRUE;
+}
+
+/******************************************************************
+ *		fill_list_size
+ *
+ * fills the size list box according to selected family in font LB
+ */
+static BOOL  fill_list_size(struct dialog_info* di, BOOL doInit)
+{
+    HDC 	hdc;
+    int		idx;
+    WCHAR	lfFaceName[LF_FACESIZE];
+
+    idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L);
+    if (idx < 0) return FALSE;
+    
+    hdc = GetDC(di->hDlg);
+    if (!hdc) return FALSE;
+
+    SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETTEXT, idx, (LPARAM)lfFaceName);
+    SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_RESETCONTENT, 0L, 0L);
+    if (di->font) HeapFree(GetProcessHeap(), 0, di->font);
+    di->nFont = 0;
+    di->font = NULL;
+
+    EnumFontFamilies(hdc, lfFaceName, font_enum_size, (LPARAM)di);
+    ReleaseDC(di->hDlg, hdc);
+
+    if (doInit)
+    {
+	for (idx = 0; idx < di->nFont; idx++)
+	{
+	    if (memcmp(&di->data->logFont, &di->font[idx].lf, sizeof(LOGFONT)) == 0)
+		break;
+	}
+	if (idx == di->nFont) idx = 0;
+    }
+    else
+	idx = 0;
+    SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_SETCURSEL, idx, 0L);
+    select_font(di);
+    return TRUE;
+}
+
+/******************************************************************
+ *		fill_list_font
+ *
+ * Fills the font LB
+ */
+static BOOL fill_list_font(struct dialog_info* di)
+{
+    HDC hdc;
+
+    hdc = GetDC(di->hDlg);
+    if (!hdc) return FALSE;
+
+    SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_RESETCONTENT, 0L, 0L);
+    EnumFontFamilies(hdc, NULL, font_enum, (LPARAM)di);
+    ReleaseDC(di->hDlg, hdc);
+    if (SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SELECTSTRING, 
+			   (WPARAM)-1, (LPARAM)di->data->logFont.lfFaceName) == LB_ERR)
+	SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SETCURSEL, 0L, 0L);
+    fill_list_size(di, TRUE);
+    return TRUE;
+}
+
+/******************************************************************
+ *		WCUSER_FontDlgProc
+ *
+ * Dialog proc for the Font property sheet
+ */
+static BOOL WINAPI WCUSER_FontDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    struct dialog_info*		di;
+
+    switch (msg) 
+    {
+    case WM_INITDIALOG:
+	di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam;
+	di->hDlg = hDlg;
+	SetWindowLong(hDlg, DWL_USER, (DWORD)di);
+	fill_list_font(di);
+	break;
+    case WM_COMMAND:
+	di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
+	switch (LOWORD(wParam)) 
+	{
+	case IDC_FNT_LIST_FONT:	
+	    if (HIWORD(wParam) == LBN_SELCHANGE)
+	    {
+		fill_list_size(di, FALSE);
+	    }
+	    break;
+	case IDC_FNT_LIST_SIZE:	
+	    if (HIWORD(wParam) == LBN_SELCHANGE)
+	    {
+		select_font(di);
+	    }
+	    break;
+	}
+	break;
+    case WM_NOTIFY:
+    {
+	NMHDR*	nmhdr = (NMHDR*)lParam;
+
+	di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
+	switch (nmhdr->code) 
+	{
+	case PSN_APPLY:
+	{
+	    int idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L);
+
+	    if (idx >= 0 && idx < di->nFont)
+	    {
+		WCUSER_SetFont(di->data, &di->font[idx].lf, &di->font[idx].tm);
+	    }
+	    SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+	    return TRUE;
+	}
+	default:
+	    return FALSE;
+	}
+	break;
+    }
+    default:
+	return FALSE;
+    }
+    return TRUE;
+}
+
+/******************************************************************
+ *		WCUSER_ConfigDlgProc
+ *
+ * Dialog proc for the config property sheet
+ */
+static BOOL WINAPI WCUSER_ConfigDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    struct dialog_info*		di;
+
+    switch (msg) 
+    {
+    case WM_INITDIALOG:
+	di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam;
+	di->hDlg = hDlg;
+	SetWindowLong(hDlg, DWL_USER, (DWORD)di);
+	SetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH,   di->data->sb_width,   FALSE);
+	SetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT,  di->data->sb_height,  FALSE);
+	SetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH,  di->data->win_width,  FALSE);
+	SetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, di->data->win_height, FALSE);
+	break;
+    case WM_COMMAND:
+	di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
+	switch (LOWORD(wParam)) 
+	{
+	}
+	break;
+    case WM_NOTIFY:
+    {
+	NMHDR*	nmhdr = (NMHDR*)lParam;
+
+	di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
+	switch (nmhdr->code) 
+	{
+	case PSN_APPLY:
+	{
+	    COORD	sb;
+	    SMALL_RECT	pos;
+	    BOOL	st_w, st_h;
+
+	    sb.X = GetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH,  &st_w, FALSE);
+	    sb.Y = GetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT, &st_h, FALSE);
+	    if (st_w && st_h && (sb.X != di->data->sb_width || sb.Y != di->data->sb_height))
+	    {
+		SetConsoleScreenBufferSize(di->data->hConOut, sb);
+	    }
+
+	    pos.Right  = GetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH,  &st_w, FALSE);
+	    pos.Bottom = GetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, &st_h, FALSE);
+	    if (st_w && st_h && 
+		(pos.Right != di->data->win_width || pos.Bottom != di->data->win_height))
+	    {
+		pos.Left = pos.Top = 0;
+		pos.Right--; pos.Bottom--;
+		SetConsoleWindowInfo(di->data->hConOut, FALSE, &pos);
+	    }
+
+	    SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+	    return TRUE;
+	}
+	default:
+	    return FALSE;
+	}
+	break;
+    }
+    default:
+	return FALSE;
+    }
+    return TRUE;
+}
+
+/******************************************************************
+ *		WCUSER_GetProperties
+ *
+ * Runs the dialog box to set up the winconsole options
+ */
+BOOL WCUSER_GetProperties(struct inner_data* data)
+{
+    HPROPSHEETPAGE	psPage[3];
+    PROPSHEETPAGEA	psp;
+    PROPSHEETHEADERA	psHead;
+    WNDCLASS		wndclass;
+    static WCHAR	szFntPreview[] = {'W','i','n','e','C','o','n','F','o','n','t','P','r','e','v','i','e','w',0};
+    struct dialog_info	di;
+
+    InitCommonControls();
+
+    di.data = data;
+    di.nFont = 0;
+    di.font = NULL;
+
+    wndclass.style         = 0;
+    wndclass.lpfnWndProc   = WCUSER_FontPreviewProc;
+    wndclass.cbClsExtra    = 0;
+    wndclass.cbWndExtra    = 0;
+    wndclass.hInstance     = GetModuleHandle(NULL);
+    wndclass.hIcon         = 0;
+    wndclass.hCursor       = LoadCursor(0, IDC_ARROW);
+    wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);
+    wndclass.lpszMenuName  = NULL;
+    wndclass.lpszClassName = szFntPreview;
+    RegisterClass(&wndclass);
+
+    memset(&psp, 0, sizeof(psp));
+    psp.dwSize = sizeof(psp);
+    psp.dwFlags = 0;
+    psp.hInstance = wndclass.hInstance;
+    psp.lParam = (LPARAM)&di;
+
+    psp.u.pszTemplate = MAKEINTRESOURCEA(IDD_OPTION);
+    psp.pfnDlgProc = WCUSER_OptionDlgProc;
+    psPage[0] = CreatePropertySheetPageA(&psp);
+
+    psp.u.pszTemplate = MAKEINTRESOURCEA(IDD_FONT);
+    psp.pfnDlgProc = WCUSER_FontDlgProc;
+    psPage[1] = CreatePropertySheetPageA(&psp);
+
+    psp.u.pszTemplate = MAKEINTRESOURCEA(IDD_CONFIG);
+    psp.pfnDlgProc = WCUSER_ConfigDlgProc;
+    psPage[2] = CreatePropertySheetPageA(&psp);
+
+    memset(&psHead, 0, sizeof(psHead));
+    psHead.dwSize = sizeof(psHead);
+    psHead.pszCaption = "Setup";
+    psHead.nPages = 3;
+    psHead.hwndParent = data->hWnd;
+    psHead.u3.phpage = psPage;
+ 
+    PropertySheetA(&psHead);
+
+    return TRUE;
+}
+
diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c
new file mode 100644
index 0000000..2d25c66
--- /dev/null
+++ b/programs/wineconsole/user.c
@@ -0,0 +1,957 @@
+/*
+ * a GUI application for displaying a console
+ *	USER32 back end
+ * Copyright 2001 Eric Pouech
+ */
+
+#include <stdio.h>
+#include "winecon_private.h"
+
+/* mapping console colors to RGB values */
+static	COLORREF	color_map[16] = 
+{
+    RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0x80), RGB(0x00, 0x80, 0x00), RGB(0x00, 0x80, 0x80),
+    RGB(0x80, 0x00, 0x00), RGB(0x80, 0x00, 0x80), RGB(0x80, 0x80, 0x00), RGB(0x80, 0x80, 0x80),
+    RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0xFF), RGB(0x00, 0xFF, 0x00), RGB(0x00, 0xFF, 0xFF),
+    RGB(0xFF, 0x00, 0x00), RGB(0xFF, 0x00, 0xFF), RGB(0xFF, 0xFF, 0x00), RGB(0xFF, 0xFF, 0xFF),
+};
+
+/******************************************************************
+ *		WCUSER_FillMemDC
+ *
+ * Fills the Mem DC with current cells values
+ */
+static void WCUSER_FillMemDC(const struct inner_data* data, int upd_tp, int upd_bm)
+{
+    unsigned		i, j, k;
+    CHAR_INFO*		cell;
+    HFONT		hOldFont;
+    WORD		attr;
+    WCHAR*		line;
+
+    if (!(line = HeapAlloc(GetProcessHeap(), 0, data->sb_width * sizeof(WCHAR))))
+    {Trace(0, "OOM\n"); return;}
+
+    hOldFont = SelectObject(data->hMemDC, data->hFont);
+    for (j = upd_tp; j <= upd_bm; j++)
+    {
+	cell = &data->cells[j * data->sb_width];
+	for (i = 0; i < data->win_width; i++)
+	{
+	    attr = cell[i].Attributes;
+	    SetBkColor(data->hMemDC, color_map[attr & 0x0F]);
+	    SetTextColor(data->hMemDC, color_map[(attr >> 4) & 0x0F]);
+	    for (k = i; k < data->win_width && cell[k].Attributes == attr; k++)
+	    {
+		line[k - i] = cell[k].Char.UnicodeChar;
+	    }
+	    TextOut(data->hMemDC, i * data->cell_width, j * data->cell_height, 
+		    line, k - i);
+	    i = k - 1;
+	}
+    }
+    SelectObject(data->hMemDC, hOldFont);
+    HeapFree(GetProcessHeap(), 0, line);
+}
+
+/******************************************************************
+ *		WCUSER_NewBitmap
+ *
+ * Either the font geometry or the sb geometry has changed. we need to recreate the
+ * bitmap geometry
+ */
+static void WCUSER_NewBitmap(struct inner_data* data, BOOL fill)
+{
+    HBITMAP	hnew, hold;
+
+    if (!data->sb_width || !data->sb_height)
+	return;
+    hnew = CreateCompatibleBitmap(data->hMemDC, 
+				  data->sb_width  * data->cell_width, 
+				  data->sb_height * data->cell_height);
+    hold = SelectObject(data->hMemDC, hnew);
+
+    if (data->hBitmap)
+    {
+	if (hold == data->hBitmap)
+	    DeleteObject(data->hBitmap);
+	else
+	    Trace(0, "leak\n");
+    }
+    data->hBitmap = hnew;
+    if (fill)
+	WCUSER_FillMemDC(data, 0, data->sb_height - 1);
+}
+
+/******************************************************************
+ *		WCUSER_ResizeScreenBuffer
+ *
+ *
+ */
+static void WCUSER_ResizeScreenBuffer(struct inner_data* data)
+{
+    WCUSER_NewBitmap(data, FALSE);
+}
+
+/******************************************************************
+ *		WCUSER_PosCursor
+ *
+ * Set a new position for the cursor
+ */
+static void	WCUSER_PosCursor(const struct inner_data* data)
+{
+    if (data->hWnd != GetFocus() || !data->cursor_visible) return;
+
+    SetCaretPos((data->cursor.X - data->win_pos.X) * data->cell_width, 
+		(data->cursor.Y - data->win_pos.Y) * data->cell_height);
+    ShowCaret(data->hWnd); 
+}
+
+/******************************************************************
+ *		WCUSER_ShapeCursor
+ *
+ * Sets a new shape for the cursor
+ */
+void	WCUSER_ShapeCursor(struct inner_data* data, int size, int vis, BOOL force)
+{
+    if (force || size != data->cursor_size)
+    {
+	if (data->cursor_visible && data->hWnd == GetFocus()) DestroyCaret();
+	if (data->cursor_bitmap) DeleteObject(data->cursor_bitmap);
+	data->cursor_bitmap = (HBITMAP)0;
+	if (size != 100)
+	{
+	    int		w16b; /* number of byets per row, aligned on word size */
+	    BYTE*	ptr;
+	    int		i, j, nbl;
+
+	    w16b = ((data->cell_width + 15) & ~15) / 8;
+	    ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, w16b * data->cell_height);
+	    if (!ptr) {Trace(0, "OOM\n"); return;}
+	    nbl = max((data->cell_height * size) / 100, 1);
+	    for (j = data->cell_height - nbl; j < data->cell_height; j++)
+	    {
+		for (i = 0; i < data->cell_width; i++)
+		{
+		    ptr[w16b * j + (i / 8)] |= 0x80 >> (i & 7);
+		}
+	    }
+	    data->cursor_bitmap = CreateBitmap(data->cell_width, data->cell_height, 1, 1, ptr);
+	    HeapFree(GetProcessHeap(), 0, ptr);
+	}
+	data->cursor_size = size;
+	data->cursor_visible = -1;
+    }
+
+    vis = (vis) ? TRUE : FALSE;
+    if (force || vis != data->cursor_visible)
+    {
+	data->cursor_visible = vis;
+	if (data->hWnd == GetFocus())
+	{
+	    if (vis)
+	    {
+		CreateCaret(data->hWnd, data->cursor_bitmap, data->cell_width, data->cell_height);
+		WCUSER_PosCursor(data);
+	    }
+	    else
+	    {
+		DestroyCaret();
+	    }
+	}
+    }
+}
+
+/******************************************************************
+ *		INECON_ComputePositions
+ *
+ * Recomputes all the components (mainly scroll bars) positions
+ */
+void	WCUSER_ComputePositions(struct inner_data* data)
+{
+    RECT		r;
+    int			dx, dy;
+
+    /* compute window size from desired client size */
+    r.left = r.top = 0;
+    r.right = data->win_width * data->cell_width;
+    r.bottom = data->win_height * data->cell_height;
+
+    if (IsRectEmpty(&r))
+    {
+	ShowWindow(data->hWnd, SW_HIDE);
+	return;
+    }
+
+    AdjustWindowRect(&r, GetWindowLong(data->hWnd, GWL_STYLE), FALSE);
+
+    dx = dy = 0;
+    if (data->sb_width > data->win_width)
+    {
+	dy = GetSystemMetrics(SM_CYHSCROLL);
+	SetScrollRange(data->hWnd, SB_HORZ, 0, data->sb_width - data->win_width, FALSE);
+	SetScrollPos(data->hWnd, SB_HORZ, 0, FALSE); /* FIXME */
+	ShowScrollBar(data->hWnd, SB_HORZ, TRUE);
+    }
+    else
+    {
+	ShowScrollBar(data->hWnd, SB_HORZ, FALSE);
+    }
+
+    if (data->sb_height > data->win_height)
+    {
+	dx = GetSystemMetrics(SM_CXVSCROLL);
+	SetScrollRange(data->hWnd, SB_VERT, 0, data->sb_height - data->win_height, FALSE);
+	SetScrollPos(data->hWnd, SB_VERT, 0, FALSE); /* FIXME */
+	ShowScrollBar(data->hWnd, SB_VERT, TRUE);
+    }	
+    else
+    {
+	ShowScrollBar(data->hWnd, SB_VERT, FALSE);
+    }
+
+    SetWindowPos(data->hWnd, 0, 0, 0, r.right - r.left + dx, r.bottom - r.top + dy,
+		 SWP_NOMOVE|SWP_NOZORDER|SWP_SHOWWINDOW);
+    WCUSER_ShapeCursor(data, data->cursor_size, data->cursor_visible, TRUE);
+    WCUSER_PosCursor(data);
+}
+
+/******************************************************************
+ *		WCUSER_SetTitle
+ *
+ * Sets the title to the wine console
+ */
+static void	WCUSER_SetTitle(const struct inner_data* data)
+{
+    WCHAR	buffer[256];	
+
+    if (WINECON_GetConsoleTitle(data->hConIn, buffer, sizeof(buffer)))
+	SetWindowText(data->hWnd, buffer);
+}
+
+/******************************************************************
+ *		WCUSER_SetFont
+ *
+ *
+ */
+BOOL	WCUSER_SetFont(struct inner_data* data, const LOGFONT* logfont, const TEXTMETRIC* tm)
+{
+    if (!memcmp(logfont, &data->logFont, sizeof(LOGFONT))) return TRUE;
+    if (data->hFont) DeleteObject(data->hFont);
+    data->hFont = CreateFontIndirect(logfont);
+    if (!data->hFont) {Trace(0, "wrong font\n");return FALSE;}
+    data->cell_width = tm->tmMaxCharWidth; /* font is fixed Avg == Max */
+    data->cell_height = tm->tmHeight;
+    data->logFont = *logfont;
+    WCUSER_ComputePositions(data);
+    WCUSER_NewBitmap(data, TRUE);
+    InvalidateRect(data->hWnd, NULL, FALSE);
+    UpdateWindow(data->hWnd);
+    return TRUE;
+}
+
+/******************************************************************
+ *		WCUSER_GetCell
+ *
+ * Get a cell from the a relative coordinate in window (takes into
+ * account the scrolling)
+ */
+static COORD	WCUSER_GetCell(const struct inner_data* data, LPARAM lParam)
+{
+    COORD	c;
+
+    c.X = data->win_pos.X + (short)LOWORD(lParam) / data->cell_width;
+    c.Y = data->win_pos.Y + (short)HIWORD(lParam) / data->cell_height;
+
+    return c;
+}
+
+/******************************************************************
+ *		WCUSER_GetSelectionRect
+ *
+ * Get the selection rectangle
+ */
+static void	WCUSER_GetSelectionRect(const struct inner_data* data, LPRECT r)
+{
+    r->left   = (min(data->selectPt1.X, data->selectPt2.X)    ) * data->cell_width;
+    r->top    = (min(data->selectPt1.Y, data->selectPt2.Y)    ) * data->cell_height;
+    r->right  = (max(data->selectPt1.X, data->selectPt2.X) + 1) * data->cell_width;
+    r->bottom = (max(data->selectPt1.Y, data->selectPt2.Y) + 1) * data->cell_height;
+}
+
+/******************************************************************
+ *		WCUSER_SetSelection
+ *
+ *
+ */
+static void	WCUSER_SetSelection(const struct inner_data* data, HDC hRefDC)
+{
+    HDC		hDC;
+    RECT	r;
+
+    WCUSER_GetSelectionRect(data, &r);
+    hDC = hRefDC ? hRefDC : GetDC(data->hWnd);
+    if (hDC)
+    {
+	if (data->hWnd == GetFocus() && data->cursor_visible)
+	    HideCaret(data->hWnd);
+	InvertRect(hDC, &r);
+	if (hDC != hRefDC)
+	    ReleaseDC(data->hWnd, hDC);
+	if (data->hWnd == GetFocus() && data->cursor_visible)
+	    ShowCaret(data->hWnd);
+    }
+}
+
+/******************************************************************
+ *		WCUSER_MoveSelection
+ *
+ *
+ */
+static void	WCUSER_MoveSelection(struct inner_data* data, COORD dst, BOOL final)
+{
+    RECT	r;
+    HDC		hDC;
+
+    WCUSER_GetSelectionRect(data, &r);
+    hDC = GetDC(data->hWnd);
+    if (hDC)
+    {
+	if (data->hWnd == GetFocus() && data->cursor_visible)
+	    HideCaret(data->hWnd);
+	InvertRect(hDC, &r);
+    }
+    data->selectPt2 = dst;
+    if (hDC)
+    {
+	WCUSER_GetSelectionRect(data, &r);
+	InvertRect(hDC, &r);
+	ReleaseDC(data->hWnd, hDC);
+	if (data->hWnd == GetFocus() && data->cursor_visible)
+	    ShowCaret(data->hWnd);
+    }
+    if (final)
+    {
+	ReleaseCapture();
+	data->hasSelection = TRUE;
+    }
+}
+
+/******************************************************************
+ *		WCUSER_CopySelectionToClipboard
+ *
+ * Copies the current selection into the clipboard
+ */
+static void	WCUSER_CopySelectionToClipboard(const struct inner_data* data)
+{
+    HANDLE	hMem;
+    LPWSTR	p;
+    unsigned	w, h;
+
+    w = abs(data->selectPt1.X - data->selectPt2.X) + 2;
+    h = abs(data->selectPt1.Y - data->selectPt2.Y) + 1;
+
+    if (!OpenClipboard(data->hWnd)) return;
+    EmptyClipboard();
+
+    hMem = GlobalAlloc(GMEM_MOVEABLE, (w * h - 1) * sizeof(WCHAR));
+    if (hMem && (p = GlobalLock(hMem)))
+    {
+	COORD	c;
+	int	y;
+
+	c.X = data->win_pos.X + min(data->selectPt1.X, data->selectPt2.X);
+	c.Y = data->win_pos.Y + min(data->selectPt1.Y, data->selectPt2.Y);
+	
+	for (y = 0; y < h; y++, c.Y++)
+	{
+	    ReadConsoleOutputCharacter(data->hConOut, &p[y * w], w - 1, c, NULL);
+	    if (y < h - 1) p[y * w + w - 1] = '\n';
+	}
+	GlobalUnlock(hMem);
+	SetClipboardData(CF_UNICODETEXT, hMem);
+    }
+    CloseClipboard();
+}
+
+/******************************************************************
+ *		WCUSER_PasteFromClipboard
+ *
+ *
+ */
+static void	WCUSER_PasteFromClipboard(struct inner_data* data)
+{
+    HANDLE	h;
+    WCHAR*	ptr;
+
+    if (!OpenClipboard(data->hWnd)) return;
+    h = GetClipboardData(CF_UNICODETEXT);
+    if (h && (ptr = GlobalLock(h)))
+    {
+	int		i, len = GlobalSize(h) / sizeof(WCHAR);
+	INPUT_RECORD	ir[2];
+	DWORD		n;
+	SHORT		sh;
+
+	ir[0].EventType = KEY_EVENT;
+	ir[0].Event.KeyEvent.wRepeatCount = 0;
+	ir[0].Event.KeyEvent.dwControlKeyState = 0;
+	ir[0].Event.KeyEvent.bKeyDown = TRUE;
+
+	/* generate the corresponding input records */
+	for (i = 0; i < len; i++)
+	{
+	    /* FIXME: the modifying keys are not generated (shift, ctrl...) */
+	    sh = VkKeyScan(ptr[i]);
+	    ir[0].Event.KeyEvent.wVirtualKeyCode = LOBYTE(sh);
+	    ir[0].Event.KeyEvent.wVirtualScanCode = MapVirtualKey(LOBYTE(sh), 0);
+	    ir[0].Event.KeyEvent.uChar.UnicodeChar = ptr[i];
+	    
+	    ir[1] = ir[0];
+	    ir[1].Event.KeyEvent.bKeyDown = FALSE;
+	    
+	    WriteConsoleInput(data->hConIn, ir, 2, &n);
+	}
+	GlobalUnlock(h);
+    }
+    CloseClipboard();
+}
+
+static void WCUSER_Refresh(const struct inner_data* data, int tp, int bm)
+{
+    if (data->win_pos.Y <= bm && data->win_pos.Y + data->win_height >= tp)
+    {
+	RECT	r;
+
+	r.left   = 0;
+	r.right  = data->win_width * data->cell_width;
+	r.top    = (tp - data->win_pos.Y) * data->cell_height;
+	r.bottom = (bm - data->win_pos.Y + 1) * data->cell_height;
+	InvalidateRect(data->hWnd, &r, FALSE);
+	WCUSER_FillMemDC(data, tp, bm);
+	UpdateWindow(data->hWnd);
+    }
+}
+
+/******************************************************************
+ *		WCUSER_Paint
+ *
+ *
+ */
+static void	WCUSER_Paint(const struct inner_data* data)
+{
+    PAINTSTRUCT		ps;
+
+    BeginPaint(data->hWnd, &ps);
+    BitBlt(ps.hdc, 0, 0, data->win_width * data->cell_width, data->win_height * data->cell_height,
+	   data->hMemDC, data->win_pos.X * data->cell_width, data->win_pos.Y * data->cell_height,
+	   SRCCOPY);
+    if (data->hasSelection)
+	WCUSER_SetSelection(data, ps.hdc);
+    EndPaint(data->hWnd, &ps);
+}
+
+/******************************************************************
+ *		WCUSER_Scroll
+ *
+ *
+ */
+static void WCUSER_Scroll(struct inner_data* data, int pos, BOOL horz)
+{
+    if (horz)
+    {
+	SetScrollPos(data->hWnd, SB_HORZ, pos, TRUE);
+	data->win_pos.X = pos;
+	InvalidateRect(data->hWnd, NULL, FALSE);
+    }
+    else
+    {
+	SetScrollPos(data->hWnd, SB_VERT, pos, TRUE);
+	data->win_pos.Y = pos;
+    }
+    InvalidateRect(data->hWnd, NULL, FALSE);
+}
+
+struct font_chooser {
+    struct inner_data*	data;
+    int			done;
+};
+
+/******************************************************************
+ *		WCUSER_ValidateFontMetric
+ *
+ * Returns true if the font described in tm is usable as a font for the renderer
+ */
+BOOL	WCUSER_ValidateFontMetric(const struct inner_data* data, const TEXTMETRIC* tm)
+{
+    return tm->tmMaxCharWidth * data->win_width < GetSystemMetrics(SM_CXSCREEN) &&
+	tm->tmHeight * data->win_height < GetSystemMetrics(SM_CYSCREEN) &&
+	!tm->tmItalic && !tm->tmUnderlined && !tm->tmStruckOut;
+}
+
+/******************************************************************
+ *		WCUSER_ValidateFont
+ *
+ * Returns true if the font family described in lf is usable as a font for the renderer
+ */
+BOOL	WCUSER_ValidateFont(const struct inner_data* data, const LOGFONT* lf)
+{
+    return (lf->lfPitchAndFamily & 3) == FIXED_PITCH && (lf->lfPitchAndFamily & 0xF0) == FF_MODERN;
+}
+
+/******************************************************************
+ *		get_first_font_enum_2
+ *		get_first_font_enum
+ *
+ * Helper functions to get a decent font for the renderer
+ */
+static int CALLBACK get_first_font_enum_2(const LOGFONT* lf, const TEXTMETRIC* tm, 
+					  DWORD FontType, LPARAM lParam)
+{
+    struct font_chooser*	fc = (struct font_chooser*)lParam;
+
+    if (WCUSER_ValidateFontMetric(fc->data, tm))
+    {
+	WCUSER_SetFont(fc->data, lf, tm);
+	fc->done = 1;
+	return 0;
+    }
+    return 1;
+}
+
+static int CALLBACK get_first_font_enum(const LOGFONT* lf, const TEXTMETRIC* tm, 
+					DWORD FontType, LPARAM lParam)
+{
+    struct font_chooser*	fc = (struct font_chooser*)lParam;
+
+    if (WCUSER_ValidateFont(fc->data, lf))
+    {
+	EnumFontFamilies(fc->data->hMemDC, lf->lfFaceName, get_first_font_enum_2, lParam);
+	return !fc->done; /* we just need the first matching one... */
+    }
+    return 1;
+}
+
+/******************************************************************
+ *		WCUSER_Create
+ *
+ * Creates the window for the rendering
+ */
+static LRESULT WCUSER_Create(HWND hWnd, LPCREATESTRUCT lpcs)
+{
+    struct inner_data*	data;
+    HMENU		hMenu;
+    HMENU		hSubMenu;
+    WCHAR		buff[256];
+    HINSTANCE		hInstance = GetModuleHandle(NULL);
+
+    data = lpcs->lpCreateParams;
+    SetWindowLong(hWnd, 0L, (DWORD)data);
+    data->hWnd = hWnd;
+
+    data->cursor_size = 101; /* invalid value, will trigger a complete cleanup */
+    /* FIXME: error handling & memory cleanup */
+    hSubMenu = CreateMenu();
+    if (!hSubMenu) return 0;
+
+    hMenu = GetSystemMenu(hWnd, FALSE);
+    if (!hMenu) return 0;
+
+    LoadString(hInstance, IDS_MARK, buff, sizeof(buff) / sizeof(WCHAR));
+    InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_MARK, buff);
+    LoadString(hInstance, IDS_COPY, buff, sizeof(buff) / sizeof(WCHAR));
+    InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_COPY, buff);
+    LoadString(hInstance, IDS_PASTE, buff, sizeof(buff) / sizeof(WCHAR));
+    InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_PASTE, buff);
+    LoadString(hInstance, IDS_SELECTALL, buff, sizeof(buff) / sizeof(WCHAR));
+    InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SELECTALL, buff);
+    LoadString(hInstance, IDS_SCROLL, buff, sizeof(buff) / sizeof(WCHAR));
+    InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SCROLL, buff);
+    LoadString(hInstance, IDS_SEARCH, buff, sizeof(buff) / sizeof(WCHAR));
+    InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SEARCH, buff);
+
+    InsertMenu(hMenu, -1, MF_BYPOSITION|MF_SEPARATOR, 0, NULL);
+    LoadString(hInstance, IDS_EDIT, buff, sizeof(buff) / sizeof(WCHAR));
+    InsertMenu(hMenu, -1, MF_BYPOSITION|MF_STRING|MF_POPUP, (UINT_PTR)hSubMenu, buff);
+    LoadString(hInstance, IDS_DEFAULT, buff, sizeof(buff) / sizeof(WCHAR));
+    InsertMenu(hMenu, -1, MF_BYPOSITION|MF_STRING, IDS_DEFAULT, buff);
+    LoadString(hInstance, IDS_PROPERTY, buff, sizeof(buff) / sizeof(WCHAR));
+    InsertMenu(hMenu, -1, MF_BYPOSITION|MF_STRING, IDS_PROPERTY, buff);
+
+    data->hMemDC = CreateCompatibleDC(0);
+    if (!data->hMemDC) {Trace(0, "no mem dc\n");return 0;}
+
+    return 0;
+}
+
+/******************************************************************
+ *		WCUSER_SetMenuDetails
+ *
+ * Grays / ungrays the menu items according to their state
+ */
+static void	WCUSER_SetMenuDetails(const struct inner_data* data)
+{
+    HMENU		hMenu = GetSystemMenu(data->hWnd, FALSE);
+
+    if (!hMenu) {Trace(0, "Issue in getting menu bits\n");return;}
+
+    /* FIXME: set the various menu items to their state (if known) */
+    EnableMenuItem(hMenu, IDS_DEFAULT, MF_BYCOMMAND|MF_GRAYED);
+
+    EnableMenuItem(hMenu, IDS_MARK, MF_BYCOMMAND|MF_GRAYED);
+    EnableMenuItem(hMenu, IDS_COPY, MF_BYCOMMAND|(data->hasSelection ? MF_ENABLED : MF_GRAYED));
+    EnableMenuItem(hMenu, IDS_PASTE, 
+		   MF_BYCOMMAND|(IsClipboardFormatAvailable(CF_UNICODETEXT) 
+				 ? MF_ENABLED : MF_GRAYED));
+    /* Select all: always active */
+    EnableMenuItem(hMenu, IDS_SCROLL, MF_BYCOMMAND|MF_GRAYED);
+    EnableMenuItem(hMenu, IDS_SEARCH, MF_BYCOMMAND|MF_GRAYED);
+}
+
+/******************************************************************
+ *		WCUSER_GenerateInputRecord
+ *
+ * generates input_record from windows WM_KEYUP/WM_KEYDOWN messages
+ */
+static void    WCUSER_GenerateInputRecord(struct inner_data* data, BOOL down, 
+					   WPARAM wParam, LPARAM lParam, BOOL sys)
+{
+    INPUT_RECORD	ir;
+    DWORD		n;
+    WCHAR		buf[2];
+    BYTE		keyState[256];
+    static	WCHAR	last; /* keep last char seen as feed for key up message */
+
+    ir.EventType = KEY_EVENT;
+    ir.Event.KeyEvent.bKeyDown = down;
+    ir.Event.KeyEvent.wRepeatCount = LOWORD(lParam);
+    ir.Event.KeyEvent.wVirtualKeyCode = wParam;
+    
+    ir.Event.KeyEvent.wVirtualScanCode = HIWORD(lParam) & 0xFF;
+    GetKeyboardState(keyState);
+    
+    ir.Event.KeyEvent.uChar.UnicodeChar = 0;
+    ir.Event.KeyEvent.dwControlKeyState = 0;
+    if (lParam & (1L << 24))		ir.Event.KeyEvent.dwControlKeyState |= ENHANCED_KEY;
+    if (keyState[VK_SHIFT]    & 0x80)	ir.Event.KeyEvent.dwControlKeyState |= SHIFT_PRESSED;
+    if (keyState[VK_CONTROL]  & 0x80)	ir.Event.KeyEvent.dwControlKeyState |= LEFT_CTRL_PRESSED; /* FIXME: gotta choose one */
+    if (keyState[VK_LCONTROL] & 0x80)	ir.Event.KeyEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
+    if (keyState[VK_RCONTROL] & 0x80)	ir.Event.KeyEvent.dwControlKeyState |= RIGHT_CTRL_PRESSED;
+    if (sys)				ir.Event.KeyEvent.dwControlKeyState |= LEFT_ALT_PRESSED; /* FIXME: gotta choose one */
+    if (keyState[VK_LMENU]    & 0x80)	ir.Event.KeyEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
+    if (keyState[VK_RMENU]    & 0x80)	ir.Event.KeyEvent.dwControlKeyState |= RIGHT_ALT_PRESSED;
+    if (keyState[VK_CAPITAL]  & 0x01)	ir.Event.KeyEvent.dwControlKeyState |= CAPSLOCK_ON;	    
+    if (keyState[VK_NUMLOCK]  & 0x01)	ir.Event.KeyEvent.dwControlKeyState |= NUMLOCK_ON;
+    if (keyState[VK_SCROLL]   & 0x01)	ir.Event.KeyEvent.dwControlKeyState |= SCROLLLOCK_ON;
+
+    if (data->hasSelection && ir.Event.KeyEvent.dwControlKeyState == 0 && 
+	ir.Event.KeyEvent.wVirtualKeyCode == VK_RETURN)
+    {
+	data->hasSelection = FALSE;
+	WCUSER_SetSelection(data, 0);
+	WCUSER_CopySelectionToClipboard(data);
+	return;
+    }
+    
+    if (!(ir.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY))
+    {
+	if (down)
+	{
+	    switch (ToUnicode(wParam, HIWORD(lParam), keyState, buf, 2, 0))
+	    {
+	    case 2:
+		/* FIXME... should generate two events... */
+		/* fall thru */
+	    case 1:	
+		last = buf[0];
+		break;
+	    default:
+		last = 0;
+		break;
+	    }
+	}
+	ir.Event.KeyEvent.uChar.UnicodeChar = last; /* FIXME HACKY... and buggy 'coz it should be a stack, not a single value */
+	if (!down) last = 0;
+    }
+
+    WriteConsoleInput(data->hConIn, &ir, 1, &n);
+}
+
+/******************************************************************
+ *		WCUSER_Proc
+ *
+ *
+ */
+static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    struct inner_data*	data = (struct inner_data*)GetWindowLong(hWnd, 0);
+
+    switch (uMsg)
+    {
+    case WM_CREATE:
+        return WCUSER_Create(hWnd, (LPCREATESTRUCT)lParam);
+    case WM_DESTROY:
+	data->hWnd = 0;
+	PostQuitMessage(0);
+	break;
+    case WM_PAINT:
+	WCUSER_Paint(data);
+	break;
+    case WM_KEYDOWN:
+    case WM_KEYUP:
+	WCUSER_GenerateInputRecord(data, uMsg == WM_KEYDOWN, wParam, lParam, FALSE);
+	break;
+    case WM_SYSKEYDOWN:
+    case WM_SYSKEYUP:
+	WCUSER_GenerateInputRecord(data, uMsg == WM_SYSKEYDOWN, wParam, lParam, TRUE);
+	break;
+    case WM_LBUTTONDOWN:
+	/* EPP if (wParam != MK_LBUTTON) */
+	if (data->hasSelection)
+	{
+	    data->hasSelection = FALSE;
+	}
+	else
+	{
+	    data->selectPt1 = data->selectPt2 = WCUSER_GetCell(data, lParam);
+	    SetCapture(data->hWnd);
+	}
+	WCUSER_SetSelection(data, 0);
+	break;
+    case WM_MOUSEMOVE:
+	/* EPP if (wParam != MK_LBUTTON) */
+        if (GetCapture() == data->hWnd)
+	{
+	    WCUSER_MoveSelection(data, WCUSER_GetCell(data, lParam), FALSE);
+	}
+	break;
+    case WM_LBUTTONUP:
+	/* EPP if (wParam != MK_LBUTTON) */
+        if (GetCapture() == data->hWnd)
+	{
+	    WCUSER_MoveSelection(data, WCUSER_GetCell(data, lParam), TRUE);
+	}
+	break;
+    case WM_SETFOCUS:
+	if (data->cursor_visible)
+	{
+	    CreateCaret(data->hWnd, data->cursor_bitmap, data->cell_width, data->cell_height); 
+	    WCUSER_PosCursor(data);
+	}
+        break; 
+    case WM_KILLFOCUS: 
+	if (data->cursor_visible)
+	    DestroyCaret(); 
+	break;
+    case WM_HSCROLL: 
+        {
+	    int	pos = data->win_pos.X;
+
+	    switch (LOWORD(wParam)) 
+	    { 
+            case SB_PAGEUP: 	pos -= 8; 		break; 
+            case SB_PAGEDOWN: 	pos += 8; 		break; 
+            case SB_LINEUP: 	pos--;			break;
+	    case SB_LINEDOWN: 	pos++;	 		break;
+            case SB_THUMBTRACK: pos = HIWORD(wParam);	break;
+            default: 					break;
+	    } 
+	    if (pos < 0) pos = 0;
+	    if (pos > data->sb_width - data->win_width) pos = data->sb_width - data->win_width;
+	    if (pos != data->win_pos.X)
+	    {
+		ScrollWindow(hWnd, (data->win_pos.X - pos) * data->cell_width, 0, NULL, NULL);
+		data->win_pos.X = pos;
+		SetScrollPos(hWnd, SB_HORZ, pos, TRUE); 
+		UpdateWindow(hWnd); 
+		WCUSER_PosCursor(data);
+		WINECON_NotifyWindowChange(data);
+	    }
+        } 
+	break;
+    case WM_VSCROLL: 
+        {
+	    int	pos = data->win_pos.Y;
+
+	    switch (LOWORD(wParam)) 
+	    { 
+            case SB_PAGEUP: 	pos -= 8; 		break; 
+            case SB_PAGEDOWN: 	pos += 8; 		break; 
+            case SB_LINEUP: 	pos--;			break;
+	    case SB_LINEDOWN: 	pos++;	 		break;
+            case SB_THUMBTRACK: pos = HIWORD(wParam);	break;
+            default: 					break;
+	    } 
+	    if (pos < 0) pos = 0;
+	    if (pos > data->sb_height - data->win_height) pos = data->sb_height - data->win_height;
+	    if (pos != data->win_pos.Y)
+	    {
+		ScrollWindow(hWnd, 0, (data->win_pos.Y - pos) * data->cell_height, NULL, NULL);
+		data->win_pos.Y = pos;
+		SetScrollPos(hWnd, SB_VERT, pos, TRUE); 
+		UpdateWindow(hWnd); 
+		WCUSER_PosCursor(data);
+		WINECON_NotifyWindowChange(data);
+	    }
+        } 
+	break;
+    case WM_SYSCOMMAND:
+	switch (wParam)
+	{
+	case IDS_DEFAULT:
+	    Trace(0, "unhandled yet command: %x\n", wParam);
+	    break;
+	case IDS_PROPERTY:
+	    WCUSER_GetProperties(data);
+	    break;
+	default: 
+	    return DefWindowProc(hWnd, uMsg, wParam, lParam);
+	}
+	break;
+    case WM_RBUTTONDOWN:
+	WCUSER_GetProperties(data);
+	break;    
+    case WM_COMMAND:
+	switch (wParam)
+	{
+	case IDS_MARK:
+	    goto niy;
+	case IDS_COPY:
+	    data->hasSelection = FALSE;
+	    WCUSER_SetSelection(data, 0);
+	    WCUSER_CopySelectionToClipboard(data);
+	    break;
+	case IDS_PASTE:
+	    WCUSER_PasteFromClipboard(data);
+	    break;
+	case IDS_SELECTALL:
+	    data->selectPt1.X = data->selectPt1.Y = 0;
+	    data->selectPt2.X = (data->sb_width - 1) * data->cell_width;
+	    data->selectPt2.Y = (data->sb_height - 1) * data->cell_height;
+	    WCUSER_SetSelection(data, 0);
+	    data->hasSelection = TRUE;
+	    break;
+	case IDS_SCROLL:
+	case IDS_SEARCH:
+	niy:
+	    Trace(0, "unhandled yet command: %x\n", wParam);
+	    break;
+	default: 
+	    return DefWindowProc(hWnd, uMsg, wParam, lParam);
+	}
+	break;
+    case WM_INITMENUPOPUP:
+	if (!HIWORD(lParam))	return DefWindowProc(hWnd, uMsg, wParam, lParam);
+	WCUSER_SetMenuDetails(data);
+	break;
+    default:
+	return DefWindowProc(hWnd, uMsg, wParam, lParam);
+    }
+    return 0;
+}
+
+/******************************************************************
+ *		WCUSER_DeleteBackend
+ *
+ *
+ */
+void WCUSER_DeleteBackend(struct inner_data* data)
+{
+    if (data->hWnd)		DestroyWindow(data->hWnd);
+    if (data->hFont)		DeleteObject(data->hFont);
+    if (data->cursor_bitmap)	DeleteObject(data->cursor_bitmap);
+    if (data->hMemDC)		DeleteDC(data->hMemDC);
+    if (data->hBitmap)		DeleteObject(data->hBitmap);
+}
+
+/******************************************************************
+ *		WCUSER_MainLoop
+ *
+ *
+ */
+static int WCUSER_MainLoop(struct inner_data* data)
+{
+    MSG		msg;
+
+    for (;;) 
+    {
+	switch (MsgWaitForMultipleObjects(1, &data->hSynchro, FALSE, INFINITE, QS_ALLINPUT))
+	{
+	case WAIT_OBJECT_0:
+	    if (!WINECON_GrabChanges(data))
+		PostQuitMessage(0);
+	    break;
+	case WAIT_OBJECT_0+1:
+	    switch (GetMessage(&msg, 0, 0, 0))
+	    {
+	    case -1: /* the event handle became invalid, so exit */
+		return -1;
+	    case 0: /* WM_QUIT has been posted */
+		return 0;
+	    default:
+		DispatchMessage(&msg);
+		break;
+	    }
+	    break;
+	default:
+	    Trace(0, "got pb\n");
+	    /* err */
+	    break;
+	}
+    }	
+}
+
+/******************************************************************
+ *		WCUSER_InitBackend
+ *
+ * Initialisation part II: creation of window.
+ *
+ */
+BOOL WCUSER_InitBackend(struct inner_data* data)
+{
+    static WCHAR wClassName[] = {'W','i','n','e','C','o','n','s','o','l','e','C','l','a','s','s',0};
+
+    WNDCLASS		wndclass;
+    struct font_chooser fc;
+
+    data->fnMainLoop = WCUSER_MainLoop;
+    data->fnPosCursor = WCUSER_PosCursor;
+    data->fnShapeCursor = WCUSER_ShapeCursor;
+    data->fnComputePositions = WCUSER_ComputePositions;
+    data->fnRefresh = WCUSER_Refresh;
+    data->fnResizeScreenBuffer = WCUSER_ResizeScreenBuffer;
+    data->fnSetTitle = WCUSER_SetTitle;
+    data->fnScroll = WCUSER_Scroll;
+    data->fnDeleteBackend = WCUSER_DeleteBackend;
+
+    wndclass.style         = 0;
+    wndclass.lpfnWndProc   = WCUSER_Proc;
+    wndclass.cbClsExtra    = 0;
+    wndclass.cbWndExtra    = sizeof(DWORD);
+    wndclass.hInstance     = GetModuleHandle(NULL);
+    wndclass.hIcon         = LoadIcon(0, IDI_WINLOGO);
+    wndclass.hCursor       = LoadCursor(0, IDC_ARROW);
+    wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);
+    wndclass.lpszMenuName  = NULL;
+    wndclass.lpszClassName = wClassName;
+  
+    RegisterClass(&wndclass);
+
+    CreateWindow(wndclass.lpszClassName, NULL,
+		 WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_HSCROLL|WS_VSCROLL, 
+		 CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0, wndclass.hInstance, data);   
+    if (!data->hWnd) return FALSE;
+
+    /* force update of current data */
+    WINECON_GrabChanges(data);
+
+    /* try to find an acceptable font */
+    fc.data = data;
+    fc.done = 0;
+    EnumFontFamilies(data->hMemDC, NULL, get_first_font_enum, (LPARAM)&fc);
+
+    return fc.done;
+}
+
+
+
diff --git a/programs/wineconsole/winecon_private.h b/programs/wineconsole/winecon_private.h
new file mode 100644
index 0000000..b444164
--- /dev/null
+++ b/programs/wineconsole/winecon_private.h
@@ -0,0 +1,75 @@
+#include <winbase.h>
+#include <wingdi.h>
+#include <winuser.h>
+#include <wincon.h>
+
+#include "wineconsole_res.h"
+
+struct inner_data {
+    unsigned		sb_width;	/* active screen buffer width */
+    unsigned		sb_height;	/* active screen buffer height */
+    CHAR_INFO*		cells;		/* local copy of cells (sb_width * sb_height) */
+    COORD		win_pos;	/* position (in cells) of visible part of screen buffer in window */
+    unsigned		win_width;	/* size (in cells) of visible part of window (width & height) */
+    unsigned		win_height;
+
+    COORD		cursor;		/* position in cells of cursor */
+    int			cursor_visible;
+    int			cursor_size;	/* in % of cell height */
+
+    HANDLE		hConIn;		/* console input handle */
+    HANDLE		hConOut;	/* screen buffer handle: has to be changed when active sb changes */
+    HANDLE		hSynchro;	/* waitable handle signalled by server when something in server has been modified */
+
+    int			(*fnMainLoop)(struct inner_data* data);
+    void		(*fnPosCursor)(const struct inner_data* data);
+    void		(*fnShapeCursor)(struct inner_data* data, int size, int vis, BOOL force);
+    void		(*fnComputePositions)(struct inner_data* data);
+    void		(*fnRefresh)(const struct inner_data* data, int tp, int bm);
+    void		(*fnResizeScreenBuffer)(struct inner_data* data);
+    void		(*fnSetTitle)(const struct inner_data* data);
+    void		(*fnScroll)(struct inner_data* data, int pos, BOOL horz);
+    void		(*fnDeleteBackend)(struct inner_data* data);
+
+    /* the following fields are only user by the USER backend (should be hidden in user) */
+    HWND		hWnd;		/* handle to windows for rendering */
+    HFONT		hFont;		/* font used for rendering, usually fixed */
+    LOGFONT		logFont;	/* logFont dscription for used hFont */
+    unsigned		cell_width;	/* width in pixels of a character */	
+    unsigned		cell_height;	/* height in pixels of a character */
+    HDC			hMemDC;		/* memory DC holding the bitmap below */
+    HBITMAP		hBitmap;	/* bitmap of display window content */
+
+    HBITMAP		cursor_bitmap;  /* bitmap used for the caret */
+    BOOL		hasSelection;	/* a rectangular mouse selection has taken place */
+    COORD		selectPt1;	/* start (and end) point of a mouse selection */
+    COORD		selectPt2;
+};
+
+#  ifdef __GNUC__
+extern void  XTracer(int level, const char* format, ...) __attribute__((format (printf,2,3)));
+#  else
+extern void  XTracer(int level, const char* format, ...);
+#  endif
+#if 0
+/* Trace mode */
+#  define Trace XTracer
+#else
+/* non trace mode */
+#  define Trace (1) ? (void)0 : XTracer
+#endif
+
+extern void WINECON_NotifyWindowChange(struct inner_data* data);
+extern int  WINECON_GetHistorySize(HANDLE hConIn);
+extern BOOL WINECON_SetHistorySize(HANDLE hConIn, int size);
+extern int  WINECON_GetHistoryMode(HANDLE hConIn);
+extern BOOL WINECON_SetHistoryMode(HANDLE hConIn, int mode);
+extern BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len);
+extern void WINECON_FetchCells(struct inner_data* data, int upd_tp, int upd_bm);
+extern int  WINECON_GrabChanges(struct inner_data* data);
+
+extern BOOL WCUSER_GetProperties(struct inner_data*);
+extern BOOL WCUSER_SetFont(struct inner_data* data, const LOGFONT* font, const TEXTMETRIC* tm);
+extern BOOL WCUSER_ValidateFont(const struct inner_data* data, const LOGFONT* lf);
+extern BOOL WCUSER_ValidateFontMetric(const struct inner_data* data, const TEXTMETRIC* tm);
+extern BOOL WCUSER_InitBackend(struct inner_data* data);
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
new file mode 100644
index 0000000..38ba58d
--- /dev/null
+++ b/programs/wineconsole/wineconsole.c
@@ -0,0 +1,479 @@
+/*
+ * an application for displaying Win32 console
+ *
+ * Copyright 2001 Eric Pouech
+ */
+
+#include <stdio.h>
+#include <wine/server.h>
+#include "winecon_private.h"
+
+static int trace_level = 1;
+void      XTracer(int level, const char* format, ...)
+{
+    char        buf[1024];
+    va_list     valist;
+    int         len;
+
+    if (level > trace_level) return;
+
+    va_start(valist, format);
+    len = wvsnprintfA(buf, sizeof(buf), format, valist);
+    va_end(valist);
+ 
+    if (len <= -1) 
+    {
+        len = sizeof(buf) - 1;
+        buf[len] = 0;
+        buf[len - 1] = buf[len - 2] = buf[len - 3] = '.';
+    }
+    fprintf(stderr, buf);
+}
+
+/******************************************************************
+ *		WINECON_FetchCells
+ *
+ * updates the local copy of cells (band to update)
+ */
+void	WINECON_FetchCells(struct inner_data* data, int upd_tp, int upd_bm)
+{
+    int		step;
+    int		j, nr;
+
+    step = REQUEST_MAX_VAR_SIZE / (data->sb_width * 4);
+
+    for (j = upd_tp; j <= upd_bm; j += step)
+    {
+	nr = min(step, upd_bm - j + 1);
+	SERVER_START_VAR_REQ( read_console_output, 4 * nr * data->sb_width )
+	{
+	    req->handle       = (handle_t)data->hConOut;
+	    req->x            = 0;
+	    req->y            = j;
+	    req->w            = data->sb_width;
+	    req->h            = nr;
+	    if (!SERVER_CALL_ERR())
+	    {
+		if (data->sb_width != req->eff_w || nr != req->eff_h) 
+		    Trace(0, "pb here... wrong eff_w %d/%d or eff_h %d/%d\n", 
+			  req->eff_w, data->sb_width, req->eff_h, nr);
+		memcpy(&data->cells[j * data->sb_width], server_data_ptr(req), 
+		       4 * nr * data->sb_width);
+	    }
+	}
+	SERVER_END_VAR_REQ;
+    }
+    data->fnRefresh(data, upd_tp, upd_bm);
+}
+
+/******************************************************************
+ *		WINECON_NotifyWindowChange
+ *
+ * Inform server that visible window on sb has changed
+ */
+void	WINECON_NotifyWindowChange(struct inner_data* data)
+{
+    SERVER_START_REQ( set_console_output_info )
+    {
+	req->handle       = (handle_t)data->hConOut;
+	req->win_left     = data->win_pos.X;
+	req->win_top      = data->win_pos.Y;
+	req->win_right    = data->win_pos.X + data->win_width - 1;
+	req->win_bottom   = data->win_pos.Y + data->win_height - 1;
+	req->mask         = SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW;
+	if (!SERVER_CALL_ERR())
+	{
+	}
+    }
+    SERVER_END_REQ;
+}
+
+/******************************************************************
+ *		WINECON_GetHistorySize
+ *
+ *
+ */
+int	WINECON_GetHistorySize(HANDLE hConIn)
+{
+    int	ret = 0;
+
+    SERVER_START_REQ(get_console_input_info)
+    {
+	req->handle = (handle_t)hConIn;
+	if (!SERVER_CALL_ERR()) ret = req->history_size;
+    }
+    SERVER_END_REQ;
+    return ret;
+}
+
+/******************************************************************
+ *		WINECON_SetHistorySize
+ *
+ *
+ */
+BOOL	WINECON_SetHistorySize(HANDLE hConIn, int size)
+{
+    BOOL	ret;
+
+    SERVER_START_REQ(set_console_input_info)
+    {
+	req->handle = (handle_t)hConIn;
+	req->mask = SET_CONSOLE_INPUT_INFO_HISTORY_SIZE;
+	req->history_size = size;
+	ret = !SERVER_CALL_ERR();
+    }
+    SERVER_END_REQ;
+    return ret;
+}
+
+
+/******************************************************************
+ *		WINECON_GetHistoryMode
+ *
+ *
+ */
+int	WINECON_GetHistoryMode(HANDLE hConIn)
+{
+    int	ret = 0;
+
+    SERVER_START_REQ(get_console_input_info)
+    {
+	req->handle = (handle_t)hConIn;
+	if (!SERVER_CALL_ERR()) ret = req->history_mode;
+    }
+    SERVER_END_REQ;
+    return ret;
+}
+
+/******************************************************************
+ *		WINECON_SetHistoryMode
+ *
+ *
+ */
+BOOL	WINECON_SetHistoryMode(HANDLE hConIn, int mode)
+{
+    BOOL	ret;
+
+    SERVER_START_REQ(set_console_input_info)
+    {
+	req->handle = (handle_t)hConIn;
+	req->mask = SET_CONSOLE_INPUT_INFO_HISTORY_MODE;
+	req->history_mode = mode;
+	ret = !SERVER_CALL_ERR();
+    }
+    SERVER_END_REQ;
+    return ret;
+}
+
+/******************************************************************
+ *		WINECON_GetConsoleTitle
+ *
+ *
+ */
+BOOL	WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len)
+{
+    BOOL	ret;
+    DWORD 	size = 0;
+
+    SERVER_START_VAR_REQ(get_console_input_info, sizeof(buffer))
+    {
+	req->handle = (handle_t)hConIn;
+        if ((ret = !SERVER_CALL_ERR()))
+        {
+            size = min(len - sizeof(WCHAR), server_data_size(req));
+            memcpy(buffer, server_data_ptr(req), size);
+            buffer[size / sizeof(WCHAR)] = 0;
+        }
+    }
+    SERVER_END_VAR_REQ;
+    return ret;
+}
+
+/******************************************************************
+ *		WINECON_GrabChanges
+ *
+ * A change occurs, try to figure out which
+ */
+int	WINECON_GrabChanges(struct inner_data* data)
+{
+    struct console_renderer_event	evts[16];
+    int	i, num;
+    HANDLE h;
+
+    SERVER_START_VAR_REQ( get_console_renderer_events, sizeof(evts) )
+    {
+	req->handle       = (handle_t)data->hSynchro;
+	if (!SERVER_CALL_ERR())
+	{
+	    num = server_data_size(req);
+	    memcpy(evts, server_data_ptr(req), num);
+	    num /= sizeof(evts[0]);
+	}
+	else num = 0;
+    }
+    SERVER_END_VAR_REQ;
+    if (!num) {Trace(0, "hmm renderer signaled but no events available\n"); return 1;}
+    
+    /* FIXME: should do some event compression here (cursor pos, update) */
+    Trace(1, "Change notification:");
+    for (i = 0; i < num; i++)
+    {
+	switch (evts[i].event)
+	{
+	case CONSOLE_RENDERER_TITLE_EVENT:
+	    data->fnSetTitle(data);
+	    break;
+	case CONSOLE_RENDERER_ACTIVE_SB_EVENT:
+	    SERVER_START_REQ( open_console )
+	    {
+		req->from    = (int)data->hConIn;
+		req->access  = GENERIC_READ | GENERIC_WRITE;
+		req->share   = FILE_SHARE_READ | FILE_SHARE_WRITE;
+		req->inherit = FALSE;
+		h = SERVER_CALL_ERR() ? 0 : (HANDLE)req->handle;
+	    }
+	    SERVER_END_REQ;
+	    Trace(1, " active(%d)", (int)h);
+	    if (h)
+	    {
+		CloseHandle(data->hConOut);
+		data->hConOut = h;
+	    }
+	    break;
+	case CONSOLE_RENDERER_SB_RESIZE_EVENT:
+	    if (data->sb_width != evts[i].u.resize.width || 
+		data->sb_height != evts[i].u.resize.height)
+	    {
+		Trace(1, " resize(%d,%d)", evts[i].u.resize.width, evts[i].u.resize.height);
+		data->sb_width  = evts[i].u.resize.width;
+		data->sb_height = evts[i].u.resize.height;
+		
+		data->cells = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, data->cells,
+					  data->sb_width * data->sb_height * sizeof(CHAR_INFO));
+		if (!data->cells) {Trace(0, "OOM\n"); exit(0);}
+		data->fnResizeScreenBuffer(data);
+		data->fnComputePositions(data);
+	    }
+	    break;
+	case CONSOLE_RENDERER_UPDATE_EVENT:
+	    Trace(1, " update(%d,%d)", evts[i].u.update.top, evts[i].u.update.bottom);
+	    WINECON_FetchCells(data, evts[i].u.update.top, evts[i].u.update.bottom);
+	    break;
+	case CONSOLE_RENDERER_CURSOR_POS_EVENT:
+	    if (evts[i].u.cursor_pos.x != data->cursor.X || evts[i].u.cursor_pos.y != data->cursor.Y)
+	    {	
+		data->cursor.X = evts[i].u.cursor_pos.x;
+		data->cursor.Y = evts[i].u.cursor_pos.y;
+		data->fnPosCursor(data);
+		Trace(1, " curs-pos(%d,%d)",evts[i].u.cursor_pos.x, evts[i].u.cursor_pos.y);
+	    }
+	    break;
+	case CONSOLE_RENDERER_CURSOR_GEOM_EVENT:
+	    if (evts[i].u.cursor_geom.size != data->cursor_size || 
+		evts[i].u.cursor_geom.visible != data->cursor_visible)
+	    {
+		data->fnShapeCursor(data, evts[i].u.cursor_geom.size, 
+				    evts[i].u.cursor_geom.visible, FALSE);
+		Trace(1, " curs-geom(%d,%d)", 
+		      evts[i].u.cursor_geom.size, evts[i].u.cursor_geom.visible);
+	    }
+	    break;
+	case CONSOLE_RENDERER_DISPLAY_EVENT:
+	    if (evts[i].u.display.left != data->win_pos.X)
+	    {
+		data->fnScroll(data, evts[i].u.display.left, TRUE);
+		data->fnPosCursor(data);
+		Trace(1, " h-scroll(%d)", evts[i].u.display.left);
+	    }
+	    if (evts[i].u.display.top != data->win_pos.Y)
+	    {
+		data->fnScroll(data, evts[i].u.display.top, FALSE);
+		data->fnPosCursor(data);
+		Trace(1, " v-scroll(%d)", evts[i].u.display.top);
+	    }
+	    if (evts[i].u.display.width != data->win_width || 
+		evts[i].u.display.height != data->win_height)
+	    {
+		Trace(1, " win-size(%d,%d)", evts[i].u.display.width, evts[i].u.display.height);
+		data->win_width = evts[i].u.display.width;
+		data->win_height = evts[i].u.display.height;
+		data->fnComputePositions(data);
+	    }
+	    break;
+	case CONSOLE_RENDERER_EXIT_EVENT:
+	    Trace(1, ". Exit!!\n");
+	    return 0;
+	default:
+	    Trace(0, "Unknown event type (%d)\n", evts[i].event);
+	}
+    }
+
+    Trace(1, ". Done\n");
+    return 1;
+}
+
+/******************************************************************
+ *		WINECON_Delete
+ *
+ * Destroy wineconsole internal data
+ */
+static void WINECON_Delete(struct inner_data* data)
+{
+    if (!data) return;
+
+    if (data->hConIn)		CloseHandle(data->hConIn);
+    if (data->hConOut)		CloseHandle(data->hConOut);
+    if (data->hSynchro)		CloseHandle(data->hSynchro);
+    if (data->cells)		HeapFree(GetProcessHeap(), 0, data->cells);
+    data->fnDeleteBackend(data);
+    HeapFree(GetProcessHeap(), 0, data);
+}
+
+/******************************************************************
+ *		WINECON_Init
+ *
+ * Initialisation part I. Creation of server object (console input and
+ * active screen buffer)
+ */
+static struct inner_data* WINECON_Init(HINSTANCE hInst, void* pid)
+{
+    struct inner_data*	data = NULL;
+    DWORD		ret;
+    WCHAR		szTitle[] = {'W','i','n','e',' ','c','o','n','s','o','l','e',0};
+    size_t		len;
+
+    data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
+    if (!data) return 0;
+
+    /* the handles here are created without the whistles and bells required by console
+     * (mainly because wineconsole doesn't need it)
+     * - there are not inheritable
+     * - hConIn is not synchronizable
+     */
+    SERVER_START_REQ(alloc_console)
+    {
+        req->access  = GENERIC_READ | GENERIC_WRITE;
+        req->inherit = FALSE;
+	req->pid     = pid;
+        ret = !SERVER_CALL_ERR();
+        data->hConIn = (HANDLE)req->handle_in;
+	data->hSynchro = (HANDLE)req->event;
+    }
+    SERVER_END_REQ;
+    if (!ret) goto error;
+
+    len = lstrlenW(szTitle) * sizeof(WCHAR);
+    len = min(len, REQUEST_MAX_VAR_SIZE);
+
+    SERVER_START_VAR_REQ(set_console_input_info, len)
+    {
+	req->handle = (handle_t)data->hConIn;
+        req->mask = SET_CONSOLE_INPUT_INFO_TITLE;
+        memcpy(server_data_ptr(req), szTitle, len);
+        ret = !SERVER_CALL_ERR();
+    }
+    SERVER_END_VAR_REQ;
+
+    if (ret) 
+    {    
+	SERVER_START_REQ(create_console_output)
+	{
+	    req->handle_in = (handle_t)data->hConIn;
+	    req->access    = GENERIC_WRITE|GENERIC_READ;
+	    req->share     = FILE_SHARE_READ|FILE_SHARE_WRITE;
+	    req->inherit   = FALSE;
+	    data->hConOut  = (HANDLE)(SERVER_CALL_ERR() ? 0 : req->handle_out);
+	}
+	SERVER_END_REQ;
+	if (data->hConOut) return data;
+    }
+
+ error:
+    WINECON_Delete(data);
+    return NULL;
+}
+
+/******************************************************************
+ *		WINECON_Spawn
+ *
+ * Spawn the child processus when invoked with wineconsole foo bar
+ */
+static BOOL WINECON_Spawn(struct inner_data* data, LPCSTR lpCmdLine)
+{
+    PROCESS_INFORMATION	info;
+    STARTUPINFO		startup;
+    LPWSTR		ptr = GetCommandLine(); /* we're unicode... */
+    BOOL		done;
+
+    /* we're in the case wineconsole <exe> <options>... spawn the new process */
+    memset(&startup, 0, sizeof(startup));
+    startup.cb          = sizeof(startup);
+    startup.dwFlags     = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
+    startup.wShowWindow = SW_SHOWNORMAL;
+
+    /* the attributes of wineconsole's handles are not adequate for inheritance, so
+     * get them with the correct attributes before process creation
+     */
+    if (!DuplicateHandle(GetCurrentProcess(), data->hConIn,  GetCurrentProcess(),
+			 &startup.hStdInput, GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE, TRUE, 0) ||
+	!DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(), 
+			 &startup.hStdOutput, GENERIC_READ|GENERIC_WRITE, TRUE, 0) ||
+	!DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(), 
+			     &startup.hStdError, GENERIC_READ|GENERIC_WRITE, TRUE, 0))
+    {
+	Trace(0, "can't dup handles\n");
+	/* no need to delete handles, we're exiting the programm anyway */
+	return FALSE;
+    }
+
+    /* we could have several ' ' in process command line... so try first space...
+     * FIXME:
+     * the correct way would be to check the existence of the left part of ptr
+     * (to be a file)
+     */
+    while (*ptr && *ptr++ != ' ');
+
+    done = *ptr && CreateProcess(NULL, ptr, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info);
+    
+    /* we no longer need the handles passed to the child for the console */
+    CloseHandle(startup.hStdInput);
+    CloseHandle(startup.hStdOutput);
+    CloseHandle(startup.hStdError);
+
+    return done;
+}
+
+/******************************************************************
+ *		WINECON_WinMain
+ *
+ * wineconsole can either be started as:
+ *	wineconsole <int>		used when a new console is created (AllocConsole)
+ *	wineconsole <pgm> <arguments>	used to start the program <pgm> from the command line in
+ *					a freshly created console
+ */
+int PASCAL WINECON_WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPCSTR lpCmdLine, UINT nCmdShow)
+{
+    struct inner_data*	data;
+    int			ret = 1;
+    unsigned		evt;
+
+    /* case of wineconsole <evt>, signal process that created us that we're up and running */
+    if (sscanf(lpCmdLine, "%d", &evt) == 1)
+    {
+        if (!(data = WINECON_Init(hInst, 0))) return 0;
+	ret = SetEvent((HANDLE)evt);
+    }
+    else
+    {
+        if (!(data = WINECON_Init(hInst, (void*)GetCurrentProcessId()))) return 0;
+	ret = WINECON_Spawn(data, lpCmdLine);
+    }
+
+    if (ret && WCUSER_InitBackend(data))
+    {
+	ret = data->fnMainLoop(data);
+    }
+    WINECON_Delete(data);
+
+    return ret;
+}
diff --git a/programs/wineconsole/wineconsole.spec b/programs/wineconsole/wineconsole.spec
new file mode 100644
index 0000000..a5c6544
--- /dev/null
+++ b/programs/wineconsole/wineconsole.spec
@@ -0,0 +1,12 @@
+name	wineconsole
+mode	guiexe
+type	win32
+init	WINECON_WinMain
+rsrc    wineconsole_res.res                                                                                                                                                                  
+
+import -delay comctl32
+import  gdi32.dll
+import  user32.dll
+#import	advapi32.dll
+import	kernel32.dll
+import	ntdll.dll
diff --git a/programs/wineconsole/wineconsole_En.rc b/programs/wineconsole/wineconsole_En.rc
new file mode 100644
index 0000000..50b6f6d
--- /dev/null
+++ b/programs/wineconsole/wineconsole_En.rc
@@ -0,0 +1,70 @@
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+STRINGTABLE LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+BEGIN
+IDS_EDIT,		"&Edit"
+IDS_DEFAULT,		"&Default"
+IDS_PROPERTY,		"&Property"
+IDS_MARK,		"&Mark"
+IDS_COPY,		"&Copy"
+IDS_PASTE,		"&Paste"
+IDS_SELECTALL,		"&Select all"
+IDS_SCROLL,		"Sc&roll"
+IDS_SEARCH,		"S&earch"
+IDS_FNT_DISPLAY,	"Each character is %ld pixels wide on %ld pixels high"
+IDS_FNT_PREVIEW_1,	"This is a test"
+IDS_FNT_PREVIEW_2,	""
+END
+
+IDD_OPTION DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 140, 105 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION " Options "
+FONT 8, "Helv"
+{
+	GROUPBOX "Cursor size", -1, 10, 11, 120, 44, BS_GROUPBOX
+	AUTORADIOBUTTON "&Small", IDC_OPT_CURSOR_SMALL, 14, 23, 84, 10, WS_TABSTOP
+	AUTORADIOBUTTON "&Medium", IDC_OPT_CURSOR_MEDIUM, 14, 33, 84, 10, WS_TABSTOP
+	AUTORADIOBUTTON "&Large", IDC_OPT_CURSOR_LARGE, 14, 43, 84, 10, WS_TABSTOP
+
+	GROUPBOX "Command history", -1, 10, 57, 180, 35, BS_GROUPBOX
+	LTEXT "&Numbers of recalled commands :", -1, 14, 67, 78, 18
+	EDITTEXT IDC_OPT_HIST_SIZE, 92, 69, 31, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_OPT_HIST_SIZE_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+	AUTOCHECKBOX "&Remove doubles", IDC_OPT_HIST_DOUBLE, 130, 67, 50, 18, WS_TABSTOP|BS_MULTILINE
+}
+
+IDD_FONT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 140, 105 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION " Font "
+FONT 8, "Helv"
+{
+	LTEXT "&Font", -1, 5, 5, 24, 8
+	LISTBOX IDC_FNT_LIST_FONT, 5,18,109,42, LBS_SORT|WS_VSCROLL
+	LTEXT "&Size", -1, 128, 5, 60, 8
+	LISTBOX IDC_FNT_LIST_SIZE, 128, 18, 50, 60, WS_VSCROLL
+	CONTROL "", IDC_FNT_PREVIEW, "WineConFontPreview", 0L, 5,60,109,40
+	LTEXT "", IDC_FNT_FONT_INFO, 128, 76, 80, 18
+}
+
+IDD_CONFIG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 140, 105 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION " Configuration "
+FONT 8, "Helv"
+{
+	GROUPBOX "Buffer zone", -1, 10, 11, 110, 42, BS_GROUPBOX
+	LTEXT "&Width :", -1, 14, 25, 54, 9
+	EDITTEXT IDC_CNF_SB_WIDTH, 78, 23, 36, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_CNF_SB_WIDTH_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+	LTEXT "&Height :", -1, 14, 39, 54, 9
+	EDITTEXT IDC_CNF_SB_HEIGHT, 78, 37, 36, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_CNF_SB_HEIGHT_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+
+	GROUPBOX "Window size", -1, 10, 55, 110, 42
+	LTEXT "W&idth :", -1, 14, 69, 54, 9
+	EDITTEXT IDC_CNF_WIN_WIDTH, 78, 67, 36, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_CNF_WIN_WIDTH_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+	LTEXT "H&eight :", -1, 14, 83, 54, 9
+	EDITTEXT IDC_CNF_WIN_HEIGHT, 78, 81, 36, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_CNF_WIN_HEIGHT_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+}
+
diff --git a/programs/wineconsole/wineconsole_Fr.rc b/programs/wineconsole/wineconsole_Fr.rc
new file mode 100644
index 0000000..d5a7841
--- /dev/null
+++ b/programs/wineconsole/wineconsole_Fr.rc
@@ -0,0 +1,72 @@
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+STRINGTABLE LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
+BEGIN
+IDS_EDIT,		"&Editer"
+IDS_DEFAULT,		"Par &défaut"
+IDS_PROPERTY,		"&Propriétés"
+IDS_MARK,		"&Marquer"
+IDS_COPY,		"&Copier"
+IDS_PASTE,		"C&oller"
+IDS_SELECTALL,		"&Sélectionner tout"
+IDS_SCROLL,		"&Défiler"
+IDS_SEARCH,		"C&hercher"
+IDS_FNT_DISPLAY,	"Chaque caractère a %ld points en largeur et %ld points en hauteur"
+IDS_FNT_PREVIEW_1,	"Ceci est un test"
+IDS_FNT_PREVIEW_2,	"éèàôë"
+END
+
+IDD_OPTION DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 140, 105 LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION " Options "
+FONT 8, "Helv"
+{
+	GROUPBOX "Taille du curseur", -1, 10, 11, 120, 44, BS_GROUPBOX
+	AUTORADIOBUTTON "&Petit", IDC_OPT_CURSOR_SMALL, 14, 23, 84, 10, WS_TABSTOP
+	AUTORADIOBUTTON "&Moyen", IDC_OPT_CURSOR_MEDIUM, 14, 33, 84, 10, WS_TABSTOP
+	AUTORADIOBUTTON "&Grand", IDC_OPT_CURSOR_LARGE, 14, 43, 84, 10, WS_TABSTOP
+
+	GROUPBOX "Historique des commandes", -1, 10, 57, 180, 35, BS_GROUPBOX
+	LTEXT "&Taille de la mémoire tampon :", -1, 14, 67, 78, 18
+	EDITTEXT IDC_OPT_HIST_SIZE, 92, 69, 31, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_OPT_HIST_SIZE_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+	AUTOCHECKBOX "&Supprimer les doublons", IDC_OPT_HIST_DOUBLE, 130, 67, 50, 18, WS_TABSTOP|BS_MULTILINE
+}
+
+IDD_FONT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 140, 105 LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION " Police "
+FONT 8, "Helv"
+{
+	LTEXT "&Police", -1, 5, 5, 24, 8
+	LISTBOX IDC_FNT_LIST_FONT, 5, 18, 109, 42, LBS_SORT|WS_VSCROLL
+	LTEXT "&Taille", -1, 128, 5, 60, 8
+	LISTBOX IDC_FNT_LIST_SIZE, 128, 18, 50, 60, WS_VSCROLL
+	CONTROL "", IDC_FNT_PREVIEW, "WineConFontPreview", 0L, 5, 60, 109, 40
+	LTEXT "", IDC_FNT_FONT_INFO, 128, 76, 80, 18
+}
+
+IDD_CONFIG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 140, 105 LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION " Configuration "
+FONT 8, "Helv"
+{
+	GROUPBOX "Taille mémoire tampon écran", -1, 10, 11, 110, 42, BS_GROUPBOX
+	LTEXT "&Largeur :", -1, 14, 25, 54, 9
+	EDITTEXT IDC_CNF_SB_WIDTH, 78, 23, 36, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_CNF_SB_WIDTH_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+	LTEXT "Ha&uteur :", -1, 14, 39, 54, 9
+	EDITTEXT IDC_CNF_SB_HEIGHT, 78, 37, 36, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_CNF_SB_HEIGHT_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+
+	GROUPBOX "Taille de la fenêtre", -1, 10, 55, 110, 42
+	LTEXT "La&rgeur :", -1, 14, 69, 54, 9
+	EDITTEXT IDC_CNF_WIN_WIDTH, 78, 67, 36, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_CNF_WIN_WIDTH_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+	LTEXT "Hau&teur :", -1, 14, 83, 54, 9
+	EDITTEXT IDC_CNF_WIN_HEIGHT, 78, 81, 36, 12, WS_TABSTOP|WS_BORDER|ES_NUMBER
+	CONTROL "", IDC_CNF_WIN_HEIGHT_UD, "msctls_updown32", UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_ARROWKEYS|UDS_NOTHOUSANDS, 0, 0, 0, 0
+}
+
+
+
diff --git a/programs/wineconsole/wineconsole_res.h b/programs/wineconsole/wineconsole_res.h
new file mode 100644
index 0000000..17c8cba
--- /dev/null
+++ b/programs/wineconsole/wineconsole_res.h
@@ -0,0 +1,44 @@
+/* wineconsole resource definitions */
+
+/* strings */
+#define IDS_EDIT		0x100
+#define IDS_DEFAULT		0x101
+#define IDS_PROPERTY		0x102
+
+#define IDS_MARK		0x110
+#define IDS_COPY		0x111
+#define IDS_PASTE		0x112
+#define IDS_SELECTALL		0x113
+#define IDS_SCROLL		0x114
+#define IDS_SEARCH		0x115
+
+#define IDS_FNT_DISPLAY		0x200
+#define IDS_FNT_PREVIEW_1	0x201
+#define IDS_FNT_PREVIEW_2	0x202
+
+#define IDD_OPTION		0x0100
+#define IDD_FONT		0x0200
+#define IDD_CONFIG		0x0300
+
+/* dialog boxes */
+#define IDC_OPT_CURSOR_SMALL	0x0101
+#define IDC_OPT_CURSOR_MEDIUM	0x0102
+#define IDC_OPT_CURSOR_LARGE	0x0103
+#define IDC_OPT_HIST_SIZE	0x0104
+#define IDC_OPT_HIST_SIZE_UD	0x0105
+#define IDC_OPT_HIST_DOUBLE	0x0106
+
+#define IDC_FNT_LIST_FONT	0x0201
+#define IDC_FNT_LIST_SIZE	0x0202
+#define IDC_FNT_FONT_INFO	0x0203
+#define IDC_FNT_PREVIEW		0x0204
+
+#define IDC_CNF_SB_WIDTH	0x0301
+#define IDC_CNF_SB_WIDTH_UD	0x0302
+#define IDC_CNF_SB_HEIGHT	0x0303
+#define IDC_CNF_SB_HEIGHT_UD	0x0304
+#define IDC_CNF_WIN_WIDTH	0x0305
+#define IDC_CNF_WIN_WIDTH_UD	0x0306
+#define IDC_CNF_WIN_HEIGHT	0x0307
+#define IDC_CNF_WIN_HEIGHT_UD	0x0308
+
diff --git a/programs/wineconsole/wineconsole_res.rc b/programs/wineconsole/wineconsole_res.rc
new file mode 100644
index 0000000..6ebc40c
--- /dev/null
+++ b/programs/wineconsole/wineconsole_res.rc
@@ -0,0 +1,8 @@
+#include "windef.h"
+#include "winuser.h"
+#include "winnls.h"
+#include "commctrl.h"
+#include "wineconsole_res.h"
+
+#include "wineconsole_En.rc"
+#include "wineconsole_Fr.rc"