From 2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d Mon Sep 17 00:00:00 2001
From: =?utf8?q?Karsten=20Ball=C3=BCder?= <ballueder@usa.net>
Date: Wed, 20 May 1998 14:12:05 +0000
Subject: [PATCH] added some wxMSW stuff

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/msw/changes.txt        |  273 ++
 docs/msw/install.txt        |  128 +
 docs/msw/issues.txt         |   67 +
 docs/msw/readme.txt         |    5 +
 docs/msw/todo.txt           |  202 ++
 include/wx/msw/app.h        |  179 ++
 include/wx/msw/bitmap.h     |  201 ++
 include/wx/msw/blank.cur    |  Bin 0 -> 326 bytes
 include/wx/msw/bmpbuttn.h   |   85 +
 include/wx/msw/brush.h      |   84 +
 include/wx/msw/bullseye.cur |  Bin 0 -> 326 bytes
 include/wx/msw/button.h     |   56 +
 include/wx/msw/checkbox.h   |   84 +
 include/wx/msw/checklst.h   |   62 +
 include/wx/msw/choice.h     |   78 +
 include/wx/msw/clipbrd.h    |  111 +
 include/wx/msw/clock.cur    |  Bin 0 -> 326 bytes
 include/wx/msw/colordlg.h   |   44 +
 include/wx/msw/colour.h     |   62 +
 include/wx/msw/combobox.h   |   79 +
 include/wx/msw/control.h    |   86 +
 include/wx/msw/curico.h     |   22 +
 include/wx/msw/curicop.h    |   63 +
 include/wx/msw/cursor.h     |   69 +
 include/wx/msw/dc.h         |  341 +++
 include/wx/msw/dcclient.h   |   65 +
 include/wx/msw/dcmemory.h   |   35 +
 include/wx/msw/dcprint.h    |   38 +
 include/wx/msw/dcscreen.h   |   39 +
 include/wx/msw/dde.h        |  161 ++
 include/wx/msw/dialog.h     |  118 +
 include/wx/msw/dib.h        |   26 +
 include/wx/msw/dibutils.h   |  131 +
 include/wx/msw/dirdlg.h     |   47 +
 include/wx/msw/disable.bmp  |  Bin 0 -> 630 bytes
 include/wx/msw/filedlg.h    |   88 +
 include/wx/msw/font.h       |   98 +
 include/wx/msw/fontdlg.h    |   44 +
 include/wx/msw/frame.h      |  162 ++
 include/wx/msw/gauge.h      |   81 +
 include/wx/msw/gdiobj.h     |   67 +
 include/wx/msw/hand.cur     |  Bin 0 -> 326 bytes
 include/wx/msw/heart.cur    |  Bin 0 -> 326 bytes
 include/wx/msw/helpwin.h    |   54 +
 include/wx/msw/icon.h       |  102 +
 include/wx/msw/imaglist.h   |  226 ++
 include/wx/msw/joystick.h   |   93 +
 include/wx/msw/listbox.h    |  135 +
 include/wx/msw/listctrl.h   |  476 ++++
 include/wx/msw/magnif1.cur  |  Bin 0 -> 326 bytes
 include/wx/msw/mdi.h        |  210 ++
 include/wx/msw/menu.h       |  174 ++
 include/wx/msw/metafile.h   |  104 +
 include/wx/msw/minifram.h   |   46 +
 include/wx/msw/msgdlg.h     |   49 +
 include/wx/msw/noentry.cur  |  Bin 0 -> 326 bytes
 include/wx/msw/palette.h    |   66 +
 include/wx/msw/pbrush.cur   |  Bin 0 -> 326 bytes
 include/wx/msw/pen.h        |   98 +
 include/wx/msw/pencil.cur   |  Bin 0 -> 326 bytes
 include/wx/msw/pnghand.h    |   27 +
 include/wx/msw/pngread.h    |  294 +++
 include/wx/msw/pntleft.cur  |  Bin 0 -> 326 bytes
 include/wx/msw/pntright.cur |  Bin 0 -> 326 bytes
 include/wx/msw/printdlg.h   |   71 +
 include/wx/msw/printwin.h   |   58 +
 include/wx/msw/private.h    |  146 ++
 include/wx/msw/query.cur    |  Bin 0 -> 326 bytes
 include/wx/msw/radiobox.h   |  137 +
 include/wx/msw/radiobut.h   |   92 +
 include/wx/msw/region.h     |  136 +
 include/wx/msw/registry.h   |  184 ++
 include/wx/msw/roller.cur   |  Bin 0 -> 326 bytes
 include/wx/msw/scrolbar.h   |   91 +
 include/wx/msw/settings.h   |  129 +
 include/wx/msw/setup.h      |  324 +++
 include/wx/msw/size.cur     |  Bin 0 -> 326 bytes
 include/wx/msw/slider.h     |  110 +
 include/wx/msw/spinbutt.h   |  107 +
 include/wx/msw/statbmp.h    |   64 +
 include/wx/msw/statbox.h    |   63 +
 include/wx/msw/statbr95.h   |   51 +
 include/wx/msw/stattext.h   |   60 +
 include/wx/msw/tabctrl.h    |  148 ++
 include/wx/msw/taskbar.h    |   66 +
 include/wx/msw/tbar95.h     |  108 +
 include/wx/msw/tbarmsw.h    |  130 +
 include/wx/msw/textctrl.h   |  149 ++
 include/wx/msw/timer.h      |   52 +
 include/wx/msw/treectrl.h   |  228 ++
 include/wx/msw/watch1.cur   |  Bin 0 -> 326 bytes
 include/wx/msw/wave.h       |   43 +
 include/wx/msw/window.h     |  798 ++++++
 include/wx/msw/wx.rc        |  110 +
 src/common/doslex.c         | 1214 +++++++++
 src/common/dosyacc.c        |  517 ++++
 src/cygnus.bat              |   15 +
 src/makeb32.env             |   36 +
 src/makebcc.env             |   37 +
 src/makefile.bcc            |   97 +
 src/makefile.dos            |   51 +
 src/makefile.nt             |   35 +
 src/makeg95.env             |  232 ++
 src/makesc.env              |   20 +
 src/makewat.env             |  159 ++
 src/mingegcs.bat            |   13 +
 src/mingw32.bat             |   16 +
 src/msw/Y_TAB.C             |  521 ++++
 src/msw/app.cpp             | 1001 +++++++
 src/msw/bitmap.cpp          |  808 ++++++
 src/msw/bmpbuttn.cpp        |  265 ++
 src/msw/brush.cpp           |  263 ++
 src/msw/button.cpp          |  208 ++
 src/msw/checkbox.cpp        |  325 +++
 src/msw/checklst.cpp        |  306 +++
 src/msw/choice.cpp          |  350 +++
 src/msw/clipbrd.cpp         |  465 ++++
 src/msw/colordlg.cpp        |  124 +
 src/msw/colour.cpp          |  132 +
 src/msw/combobox.cpp        |  313 +++
 src/msw/control.cpp         |  372 +++
 src/msw/curico.cpp          |  899 +++++++
 src/msw/cursor.cpp          |  279 ++
 src/msw/data.cpp            |  723 +++++
 src/msw/dc.cpp              | 1632 ++++++++++++
 src/msw/dcclient.cpp        |  141 +
 src/msw/dcmemory.cpp        |  116 +
 src/msw/dcprint.cpp         |  208 ++
 src/msw/dcscreen.cpp        |   48 +
 src/msw/dde.cpp             |  785 ++++++
 src/msw/dialog.cpp          |  605 +++++
 src/msw/dib.cpp             |  934 +++++++
 src/msw/dibutils.cpp        |  691 +++++
 src/msw/dirdlg.cpp          |  131 +
 src/msw/dummy.cpp           |   65 +
 src/msw/dummydll.cpp        |   21 +
 src/msw/filedlg.cpp         |  356 +++
 src/msw/font.cpp            |  362 +++
 src/msw/fontdlg.cpp         |  281 ++
 src/msw/frame.cpp           | 1076 ++++++++
 src/msw/gauge.cpp           | 1261 +++++++++
 src/msw/gdiobj.cpp          |   68 +
 src/msw/helpwin.cpp         |  142 +
 src/msw/icon.cpp            |  192 ++
 src/msw/imaglist.cpp        |  200 ++
 src/msw/joystick.cpp        |  541 ++++
 src/msw/listbox.cpp         |  837 ++++++
 src/msw/listctrl.cpp        | 1380 ++++++++++
 src/msw/main.cpp            |   87 +
 src/msw/makefile.b32        |  552 ++++
 src/msw/makefile.bcc        |  407 +++
 src/msw/makefile.dos        | 1143 ++++++++
 src/msw/makefile.g95        |  303 +++
 src/msw/makefile.nt         | 1307 +++++++++
 src/msw/makefile.sc         |  147 ++
 src/msw/makefile.wat        |  159 ++
 src/msw/mdi.cpp             | 1212 +++++++++
 src/msw/menu.cpp            |  901 +++++++
 src/msw/menuitem.cpp        |  145 +
 src/msw/metafile.cpp        |  373 +++
 src/msw/minifram.cpp        | 1592 +++++++++++
 src/msw/msgdlg.cpp          |  138 +
 src/msw/nativdlg.cpp        |  289 ++
 src/msw/ownerdrw.cpp        |  230 ++
 src/msw/palette.cpp         |  137 +
 src/msw/pen.cpp             |  457 ++++
 src/msw/penwin.cpp          |  120 +
 src/msw/pnghand.cpp         |  769 ++++++
 src/msw/printdlg.cpp        |  185 ++
 src/msw/printwin.cpp        |  349 +++
 src/msw/radiobox.cpp        |  763 ++++++
 src/msw/radiobut.cpp        |  246 ++
 src/msw/region.cpp          |  410 +++
 src/msw/registry.cpp        |  670 +++++
 src/msw/scrolbar.cpp        |  349 +++
 src/msw/settings.cpp        |  166 ++
 src/msw/slider.cpp          |  790 ++++++
 src/msw/spinbutt.cpp        |  269 ++
 src/msw/statbmp.cpp         |  202 ++
 src/msw/statbox.cpp         |  223 ++
 src/msw/statbr95.cpp        |  227 ++
 src/msw/stattext.cpp        |  220 ++
 src/msw/tabctrl.cpp         |  481 ++++
 src/msw/taskbar.cpp         |  286 ++
 src/msw/tbar95.cpp          |  558 ++++
 src/msw/tbarmsw.cpp         |  855 ++++++
 src/msw/textctrl.cpp        | 1097 ++++++++
 src/msw/thread.cpp          |  320 +++
 src/msw/timer.cpp           |  115 +
 src/msw/treectrl.cpp        |  927 +++++++
 src/msw/utils.cpp           |  748 ++++++
 src/msw/wave.cpp            |  149 ++
 src/msw/window.cpp          | 4959 +++++++++++++++++++++++++++++++++++
 src/msw/wx.def              |   11 +
 src/ntwxwin.mak             |  171 ++
 utils/nplugin/makefile.nt   |   32 +
 196 files changed, 57505 insertions(+)
 create mode 100644 docs/msw/changes.txt
 create mode 100644 docs/msw/install.txt
 create mode 100644 docs/msw/issues.txt
 create mode 100644 docs/msw/readme.txt
 create mode 100644 docs/msw/todo.txt
 create mode 100644 include/wx/msw/app.h
 create mode 100644 include/wx/msw/bitmap.h
 create mode 100644 include/wx/msw/blank.cur
 create mode 100644 include/wx/msw/bmpbuttn.h
 create mode 100644 include/wx/msw/brush.h
 create mode 100644 include/wx/msw/bullseye.cur
 create mode 100644 include/wx/msw/button.h
 create mode 100644 include/wx/msw/checkbox.h
 create mode 100644 include/wx/msw/checklst.h
 create mode 100644 include/wx/msw/choice.h
 create mode 100644 include/wx/msw/clipbrd.h
 create mode 100644 include/wx/msw/clock.cur
 create mode 100644 include/wx/msw/colordlg.h
 create mode 100644 include/wx/msw/colour.h
 create mode 100644 include/wx/msw/combobox.h
 create mode 100644 include/wx/msw/control.h
 create mode 100644 include/wx/msw/curico.h
 create mode 100644 include/wx/msw/curicop.h
 create mode 100644 include/wx/msw/cursor.h
 create mode 100644 include/wx/msw/dc.h
 create mode 100644 include/wx/msw/dcclient.h
 create mode 100644 include/wx/msw/dcmemory.h
 create mode 100644 include/wx/msw/dcprint.h
 create mode 100644 include/wx/msw/dcscreen.h
 create mode 100644 include/wx/msw/dde.h
 create mode 100644 include/wx/msw/dialog.h
 create mode 100644 include/wx/msw/dib.h
 create mode 100644 include/wx/msw/dibutils.h
 create mode 100644 include/wx/msw/dirdlg.h
 create mode 100644 include/wx/msw/disable.bmp
 create mode 100644 include/wx/msw/filedlg.h
 create mode 100644 include/wx/msw/font.h
 create mode 100644 include/wx/msw/fontdlg.h
 create mode 100644 include/wx/msw/frame.h
 create mode 100644 include/wx/msw/gauge.h
 create mode 100644 include/wx/msw/gdiobj.h
 create mode 100644 include/wx/msw/hand.cur
 create mode 100644 include/wx/msw/heart.cur
 create mode 100644 include/wx/msw/helpwin.h
 create mode 100644 include/wx/msw/icon.h
 create mode 100644 include/wx/msw/imaglist.h
 create mode 100644 include/wx/msw/joystick.h
 create mode 100644 include/wx/msw/listbox.h
 create mode 100644 include/wx/msw/listctrl.h
 create mode 100644 include/wx/msw/magnif1.cur
 create mode 100644 include/wx/msw/mdi.h
 create mode 100644 include/wx/msw/menu.h
 create mode 100644 include/wx/msw/metafile.h
 create mode 100644 include/wx/msw/minifram.h
 create mode 100644 include/wx/msw/msgdlg.h
 create mode 100644 include/wx/msw/noentry.cur
 create mode 100644 include/wx/msw/palette.h
 create mode 100644 include/wx/msw/pbrush.cur
 create mode 100644 include/wx/msw/pen.h
 create mode 100644 include/wx/msw/pencil.cur
 create mode 100644 include/wx/msw/pnghand.h
 create mode 100644 include/wx/msw/pngread.h
 create mode 100644 include/wx/msw/pntleft.cur
 create mode 100644 include/wx/msw/pntright.cur
 create mode 100644 include/wx/msw/printdlg.h
 create mode 100644 include/wx/msw/printwin.h
 create mode 100644 include/wx/msw/private.h
 create mode 100644 include/wx/msw/query.cur
 create mode 100644 include/wx/msw/radiobox.h
 create mode 100644 include/wx/msw/radiobut.h
 create mode 100644 include/wx/msw/region.h
 create mode 100644 include/wx/msw/registry.h
 create mode 100644 include/wx/msw/roller.cur
 create mode 100644 include/wx/msw/scrolbar.h
 create mode 100644 include/wx/msw/settings.h
 create mode 100644 include/wx/msw/setup.h
 create mode 100644 include/wx/msw/size.cur
 create mode 100644 include/wx/msw/slider.h
 create mode 100644 include/wx/msw/spinbutt.h
 create mode 100644 include/wx/msw/statbmp.h
 create mode 100644 include/wx/msw/statbox.h
 create mode 100644 include/wx/msw/statbr95.h
 create mode 100644 include/wx/msw/stattext.h
 create mode 100644 include/wx/msw/tabctrl.h
 create mode 100644 include/wx/msw/taskbar.h
 create mode 100644 include/wx/msw/tbar95.h
 create mode 100644 include/wx/msw/tbarmsw.h
 create mode 100644 include/wx/msw/textctrl.h
 create mode 100644 include/wx/msw/timer.h
 create mode 100644 include/wx/msw/treectrl.h
 create mode 100644 include/wx/msw/watch1.cur
 create mode 100644 include/wx/msw/wave.h
 create mode 100644 include/wx/msw/window.h
 create mode 100644 include/wx/msw/wx.rc
 create mode 100644 src/common/doslex.c
 create mode 100644 src/common/dosyacc.c
 create mode 100644 src/cygnus.bat
 create mode 100644 src/makeb32.env
 create mode 100644 src/makebcc.env
 create mode 100644 src/makefile.bcc
 create mode 100644 src/makefile.dos
 create mode 100644 src/makefile.nt
 create mode 100644 src/makeg95.env
 create mode 100644 src/makesc.env
 create mode 100644 src/makewat.env
 create mode 100644 src/mingegcs.bat
 create mode 100644 src/mingw32.bat
 create mode 100644 src/msw/Y_TAB.C
 create mode 100644 src/msw/app.cpp
 create mode 100644 src/msw/bitmap.cpp
 create mode 100644 src/msw/bmpbuttn.cpp
 create mode 100644 src/msw/brush.cpp
 create mode 100644 src/msw/button.cpp
 create mode 100644 src/msw/checkbox.cpp
 create mode 100644 src/msw/checklst.cpp
 create mode 100644 src/msw/choice.cpp
 create mode 100644 src/msw/clipbrd.cpp
 create mode 100644 src/msw/colordlg.cpp
 create mode 100644 src/msw/colour.cpp
 create mode 100644 src/msw/combobox.cpp
 create mode 100644 src/msw/control.cpp
 create mode 100644 src/msw/curico.cpp
 create mode 100644 src/msw/cursor.cpp
 create mode 100644 src/msw/data.cpp
 create mode 100644 src/msw/dc.cpp
 create mode 100644 src/msw/dcclient.cpp
 create mode 100644 src/msw/dcmemory.cpp
 create mode 100644 src/msw/dcprint.cpp
 create mode 100644 src/msw/dcscreen.cpp
 create mode 100644 src/msw/dde.cpp
 create mode 100644 src/msw/dialog.cpp
 create mode 100644 src/msw/dib.cpp
 create mode 100644 src/msw/dibutils.cpp
 create mode 100644 src/msw/dirdlg.cpp
 create mode 100644 src/msw/dummy.cpp
 create mode 100644 src/msw/dummydll.cpp
 create mode 100644 src/msw/filedlg.cpp
 create mode 100644 src/msw/font.cpp
 create mode 100644 src/msw/fontdlg.cpp
 create mode 100644 src/msw/frame.cpp
 create mode 100644 src/msw/gauge.cpp
 create mode 100644 src/msw/gdiobj.cpp
 create mode 100644 src/msw/helpwin.cpp
 create mode 100644 src/msw/icon.cpp
 create mode 100644 src/msw/imaglist.cpp
 create mode 100644 src/msw/joystick.cpp
 create mode 100644 src/msw/listbox.cpp
 create mode 100644 src/msw/listctrl.cpp
 create mode 100644 src/msw/main.cpp
 create mode 100644 src/msw/makefile.b32
 create mode 100644 src/msw/makefile.bcc
 create mode 100644 src/msw/makefile.dos
 create mode 100644 src/msw/makefile.g95
 create mode 100644 src/msw/makefile.nt
 create mode 100644 src/msw/makefile.sc
 create mode 100644 src/msw/makefile.wat
 create mode 100644 src/msw/mdi.cpp
 create mode 100644 src/msw/menu.cpp
 create mode 100644 src/msw/menuitem.cpp
 create mode 100644 src/msw/metafile.cpp
 create mode 100644 src/msw/minifram.cpp
 create mode 100644 src/msw/msgdlg.cpp
 create mode 100644 src/msw/nativdlg.cpp
 create mode 100644 src/msw/ownerdrw.cpp
 create mode 100644 src/msw/palette.cpp
 create mode 100644 src/msw/pen.cpp
 create mode 100644 src/msw/penwin.cpp
 create mode 100644 src/msw/pnghand.cpp
 create mode 100644 src/msw/printdlg.cpp
 create mode 100644 src/msw/printwin.cpp
 create mode 100644 src/msw/radiobox.cpp
 create mode 100644 src/msw/radiobut.cpp
 create mode 100644 src/msw/region.cpp
 create mode 100644 src/msw/registry.cpp
 create mode 100644 src/msw/scrolbar.cpp
 create mode 100644 src/msw/settings.cpp
 create mode 100644 src/msw/slider.cpp
 create mode 100644 src/msw/spinbutt.cpp
 create mode 100644 src/msw/statbmp.cpp
 create mode 100644 src/msw/statbox.cpp
 create mode 100644 src/msw/statbr95.cpp
 create mode 100644 src/msw/stattext.cpp
 create mode 100644 src/msw/tabctrl.cpp
 create mode 100644 src/msw/taskbar.cpp
 create mode 100644 src/msw/tbar95.cpp
 create mode 100644 src/msw/tbarmsw.cpp
 create mode 100644 src/msw/textctrl.cpp
 create mode 100644 src/msw/thread.cpp
 create mode 100644 src/msw/timer.cpp
 create mode 100644 src/msw/treectrl.cpp
 create mode 100644 src/msw/utils.cpp
 create mode 100644 src/msw/wave.cpp
 create mode 100644 src/msw/window.cpp
 create mode 100644 src/msw/wx.def
 create mode 100644 src/ntwxwin.mak
 create mode 100644 utils/nplugin/makefile.nt

diff --git a/docs/msw/changes.txt b/docs/msw/changes.txt
new file mode 100644
index 0000000000..4a32e27d49
--- /dev/null
+++ b/docs/msw/changes.txt
@@ -0,0 +1,273 @@
+
+wxWindows 2.0 for Windows Change Log
+------------------------------------
+
+Alpha 11, May ??th 1998
+-----------------------
+
+- Added thread.h, thread.cpp.
+- Changed Enabled, Checked to IsEnabled, IsChecked in wxMenu,
+  wxMenuBar.
+- Changed wxMenuItem::SetBackColor to SetBackgroundColour,
+  SetTextColor to SetTextColour, and added or made public several
+  wxMenuItem accessors.
+- Added two overloads to wxRegion::Contains. Added
+  wxRegion::IsEmpty for a more consistent naming convention.
+
+Alpha 10, May 7th 1998
+----------------------
+
+- Added desiredWidth, desiredHeight parameters to wxBitmapHandler
+  and wxIcon functions so that you can specify what size of
+  icon should be loaded. Probably will remain a Windows-specific thing.
+- wxStatusBar95 now works for MDI frames.
+- Toolbars in MDI frames now behave normally. They still
+  require application-supplied positioning code though.
+- Changed installation instructions, makefiles and batch files
+  for compiling with Gnu-Win32/Mingw32/EGCS. Also timercmn.cpp
+  change to support Mingw32/EGCS. Bison now used by default.
+
+Alpha 9, April 27th 1998
+------------------------
+
+- Cured bug in wxStatusBar95 that caused a crash if multiple
+  fields were used.
+- Added Gnu-Win32 b19/Mingw32 support by changing resource
+  compilation and pragmas.
+- Cured wxMenu bug introduced in alpha 8 - didn't respond to
+  commands because VZ changed the id setting in wxMenu::MSWCommand.
+
+Alpha 8, April 17th 1998
+------------------------
+
+- Added IsNull to wxGDIObject to check if the ref data is present or not.
+- Added PNG handler and sample - doesn't work for 16-bit PNGs for
+  some reason :-(
+- Added wxJoystick class and event handling, and simple demo.
+- Added simple wxWave class. Needs Stop() function.
+- Added wxModule (module.h/module.cpp) to allow definition
+  of modules to be initialized and cleaned up on wxWindows
+  startup/exit.
+- Start of Mingw32 compatibility (see minimal and dialogs samples
+  makefile.m95 files, and install.txt).
+- Note: Windows printing has stopped working... will investigate.
+VADIM'S CHANGES:
+- Updated wxString: bug fixes, added wxArrayString, some
+  compatibility functions.
+- Updated log.h/cpp, added wxApp::CreateLogTarget.
+- file.h: new wxTempFile class.
+- defs.h: added wxSB_SIZE_GRIP for wxStatusBar95
+- statbr95: wxStatusBar95 control.
+- registry.h/cpp: wxRegKey class for Win95 registry.
+- listbox.cpp: corrected some bugs with owner-drawn listboxes.
+- wxConfig and wxFileConfig classes.
+
+Alpha 7, March 30th 1998
+------------------------
+
+- Added tab classes, tab sample.
+- Now can return FALSE from OnInit and windows will be
+  cleaned up properly before exit.
+- Improved border handling so panels don't get borders
+  automatically.
+- Debugged MDI activation from Window menu.
+- Changes to memory debug handling, including checking for
+  memory leaks on application exit - but see issues.txt for
+  unresolved issues.
+- Added wxTaskBarIcon (taskbar.cpp/h, plus samples/taskbar)
+  to allow maintenance of an icon in the Windows 95 taskbar
+  tray area.
+- Got MFC sample working (MFC and wxWindows in the same
+  application), partly by tweaking ntwxwin.mak settings.
+- Got DLL compilation working again (VC++).
+- Changed wxProp/Dialog Editor filenames.
+
+Alpha 6, March 10th 1998
+------------------------
+
+- Found stack error bug - stopped unwanted OnIdle recursion.
+- Removed bug in wxTreeCtrl::InsertItem I added in alpha 5.
+- Changed exit behaviour in wxApp/wxFrame/wxDialog. Now will
+  check if the number of top-level windows is zero before
+  exiting. Also, wxApp::GetTopWindow will return either
+  m_topWindow or the first member of wxTopLevelWindows, so you
+  don't have to call wxApp::SetTopWindow.
+- Added dynarray.h/dynarray.cpp (from Vadim).
+- Added first cut at OLE drag and drop (from Vadim). dnd sample
+  added. Drop target only at this stage. See src/msw/ole/*.cpp,
+  wx/include/msw/ole/*.h. WIN32 only because of UUID usage.
+  Doesn't work with GnuWin32 - no appropriate headers e.g. for
+  IUnknown.
+  Doesn't work with BC++ either - crashes on program startup.
+- Added Vadim's owner-draw modifications - will probably remain
+  Windows-only. This enhances wxMenu, wxListBox. See ownerdrw sample.
+- Added wxLB_OWNERDRAW for owner-draw listboxes.
+- Vadim's wxCheckListBox derives from wxListBox. See checklst sample.
+  Doesn't entirely work for WIN16.
+- Vadim has added wxMenuItem as a separate file menuitem.cpp. It
+  can also be used as an argument to wxMenu::Append, not just for
+  internal implementation.
+- Some #ifdefs done for MINGW32 compilation (just alter OPTIONS
+  in makeg95.env, together with mingw32.bat). However, resource
+  binding is not working yet so most apps with dialogs crash.
+
+Alpha 5, 14th February 1998
+---------------------------
+
+- GENERIC AND MSW-SPECIFIC CODE NOW TREATED AS TWO SEPARATE
+  DISTRIBUTIONS. This change log will therefore now refer to
+  the Windows-specific code only. See docs/changes.txt for generic
+  changes.
+- Removed Windows-specific reference counting system (GDI
+  resources were cleaned up in idle time) - minimal
+  advantages now we have a wxWin reference counting system.
+- Added missing WXDLLEXPORT keywords so DLL compilation works
+  again.
+- Removed most warnings for GnuWin32 compilation.
+- Added wxRegion/wxRegionIterator, but haven't yet used it in
+  e.g. wxDC.
+
+Alpha 4, 31st January 1998
+--------------------------
+
+- Changed wxDC functions to take longs instead of floats. GetSize now takes
+  integer pointers, plus a version that returns a wxSize.
+- const keyword added to various wxDC functions.
+- Under Windows, wxDC no longer has any knowledge of whether
+  an associated window is scrolled or not. Instead, the device
+  origin is set by wxScrolledWindow in wxScrolledWindow::PrepareDC.
+- wxScrolledWindow applications can optionally override the virtual OnDraw
+  function instead of using the OnPaint event handler. The wxDC passed to
+  OnDraw will be translated by PrepareDC to reflect scrolling.
+  When drawing outside of OnDraw, must call PrepareDC explicitly.
+- wxToolBarBase/wxToolBarSimple similarly changed to allow for
+  scrolling toolbars.
+- Integrated wxPostScriptDC patches for 1.xx by Chris Breeze,
+  to help printing with multiple pages.
+- IPC classes given base classes (wxConnectionBase etc.) which
+  define the API used by different implementations. DDE
+  implementation updated to use these base classes.
+- wxHelpInstance now separated into wxHelpControllerBase (base
+  for all implementations), wxWinHelpController (uses standard
+  WinHelp), wxXLPHelPController (talks to wxHelp by DDE or
+  TCP/IP). There will be others eventually, such as
+  wxHTMLHelpController for Microsoft (and Netscape?) HTML Help.
+- Added Vadim Zeitlin's wxString class plus
+  internationalization code (gettext simulation, wxLocale, etc.).
+  New files from Vadim:
+  include\wx\string.h
+  include\wx\debug.h
+  include\wx\file.h
+  include\wx\log.h
+  include\wx\intl.h
+  src\common\string.cpp
+  src\common\log.cpp
+  src\common\intl.cpp
+  src\common\file.cpp
+  No longer use GNU wxString files.
+- Split off file-related functions into include\wx\filefn.h and
+  src\common\filefn.cpp.
+- Borland C++ support (WIN32) for main library and
+  samples, using makefile.b32 files.
+- Preparation done for allowing BC++ to compile wxWin as a DLL,
+  including changes to defs.h.
+- wxIntPoint removed, wxPoint is now int, and wxRealPoint
+  introduced.
+- Added wxShowEvent (generated when window is being shown or
+  hidden).
+- Got minimal, docview, mdi samples working for 16-bit VC++ and
+  cured 16-bit problem with wxTextCtrl (removed global memory
+  trick).
+- Updated GnuWin32 makefiles, checked minimal, mdi, docview samples.
+
+Alpha 3, September 1997
+-----------------------
+
+- wxListCtrl, wxTreeCtrl, wxImageList classes done.
+- Instigated new file hierarchy, split files and classes up more logically.
+- PrologIO and some other utils now put into core library.
+- Revamped print/preview classes, added wxPageSetupDialog.
+- Started documentation.
+
+Alpha 2, 30th April 1997
+------------------------
+
+- EVT_... macros now have at least one argument, for conformance
+  with MetroWerks compiler.
+- Added ids to .wxr file format.
+- Got Dialog Editor compiled and running again but need
+  to extend functionality to be in line with new controls.
+  Added dialoged\test app to allow dynamic loading of .wxr files
+  for testing purposes.
+- Rewrote wxBitmap to allow installable file type
+  handlers.
+- Rewrote wxBitmapButton, wxStaticBitmap to not use Fafa.
+- Wrote most of wxTreeCtrl and sample (need wxImageList to implement it
+  fully).
+- Added back wxRadioBox.
+- Tidied up wx_main.cpp, wxApp class, putting PenWin code in
+  a separate file.
+
+Alpha 1, 5th April 1997
+-----------------------
+
+At this point, the following has been achieved:
+
+- A lot, but not all, of the code has been revamped for better
+  naming conventions, protection of data members, and use of
+  wxString instead of char *.
+- Obsolete functionality deleted (e.g. default wxPanel layout,
+  old system event system) and code size reduced.
+- Class hierarchy changed (see design doc) - base classes such
+  as wxbWindow now removed.
+- No longer includes windows.h in wxWin headers, by using stand-in
+  Windows types where needed e.g. WXHWND.
+- PrologIO revised.
+- wxScrolledWindow, wxStatusBar and new MDI classes added.
+  MDI is now achived using separate classes, not window styles.
+- wxSystemSettings added, and made use of to reflect standard
+  Windows settings.
+- SetButtonFont/SetLabelFont replaced by SetFont; font and colour
+  settings mucho rationalised.
+- All windows are now subclassed with the same window proc to make
+  event handling far more consistent. Old internal wxWnd and derived
+  classes removed.
+- API for controls revised, in particular addition of
+  wxValidator parameters and removal of labels for some controls.
+- 1 validator written: see examples/validate.
+- Event table system introduced (see most samples and
+  wx_event.cpp/ProcessEvent, wx_event.h). wxEvtHandler
+  made more flexible, with Push/PopEventHandler allowing a chain
+  of event handlers.
+- wxRadioBox removed - will be added back soon.
+- Toolbar class hierarchy revised:
+  wxToolBarBase
+  wxToolBarSimple (= old wxToolBar)
+  wxToolBar95 (= old wxButtonBar under Win95
+  wxToolBarMSW (= old wxButtonBar under WIN16/WIN32)
+- Constraint system debugged somewhat (sizers now work properly).
+- wxFileDialog, wxDirDialog added; other common dialogs now
+  have class equivalents. Generic colour and font dialogs
+  rewritten to not need obsolete panel layout.
+- .wxr resource system partially reinstated, though needs
+  an integer ID for controls. Hopefully the resource system
+  will be replaced by something better and more efficient
+  in the future.
+- Device contexts no longer stored with window and accessed
+  with GetDC - use wxClientDC, wxPaintDC, wxWindowDC stack
+  variables instead.
+- wxSlider uses trackbar class under Win95, and wxSL_LABELS flag
+  determines whether labels are shown. Other Win95-specific flags
+  introduced, e.g. for showing ticks.
+- Styles introduced for dealing with 3D effects per window, for
+  any window: all Win95 3D effects supported, plus transparent windows.
+- Major change to allow 3D effect support without CTL3D, under
+  Win95.
+- Bitmap versions of button and checkbox separated out into new
+  classes, but unimplemented as yet because I intend to remove
+  the need for Fafa - it apparently causes GPFs in Win95 OSR 2.
+- utils/wxprop classes working (except maybe wxPropertyFormView)
+  in preparation for use in Dialog Editor.
+- GNU-WIN32 compilation verified (a month or so ago).
+
+
diff --git a/docs/msw/install.txt b/docs/msw/install.txt
new file mode 100644
index 0000000000..ddedd6764d
--- /dev/null
+++ b/docs/msw/install.txt
@@ -0,0 +1,128 @@
+
+Installing wxWindows 2.0
+------------------------
+
+Unarchiving
+-----------
+
+If there is a setup program, run the setup program that comes with the Windows version.
+Do not install into a path that contains spaces. The installation program should set the
+WXWIN environment variable, which will be activated when your machine is rebooted.
+
+If there is no setup program, it will come as a series of .zip
+files:
+
+wx200gen.zip            Generic source code and samples (required)
+wx200msw.zip            Windows-specific source code and samples (required)
+wx200doc.zip            Documentation source code (not required)
+wx200hlp.zip            WinHelp documentation
+wx200ps.zip             PostScript documentation (will probably
+                        disappear in favour of PDF)
+wx200pdf.zip            Acrobat PDF documentation
+wx200htm.zip            HTML documentation
+
+Unarchive the required files plus any optional documentation
+files into a suitable directory such as c:\wx. Alter your
+WXWIN environment variable to point to this directory.
+
+Compilation
+-----------
+
+At present, wxWindows compiles with VC++ 1.5, VC++ 4.0, VC++ 5.0,
+BC++ 4.5/5.0, Gnu-Win32 b19, and Mingw32.
+
+Visual C++ 4.0/5.0 compilation
+------------------------------
+
+1. Change directory to wx\src\msw. Type 'nmake -f makefile.nt' to
+   make the wxWindows core library.
+2. Change directory to wx\samples and type 'nmake -f makefile.nt'
+   to make all the samples. You can also make them individually.
+
+Visual C++ 1.5 compilation
+--------------------------
+
+1. Change directory to wx\src\msw. Type 'nmake -f makefile.dos' to
+   make the wxWindows core library.
+2. Change directory to wx\samples and type 'nmake -f makefile.b32'
+   to make all the samples. You can also make them individually.
+   NOTE: only a few samples have up-to-date makefiles, e.g.
+   minimal, docview, mdi. The utils makefile does not yet work.
+
+Borland C++ 4.5/5.0 compilation
+-------------------------------
+
+1. Change directory to wx\src\msw. Type 'make -f makefile.b32' to
+   make the wxWindows core library.
+2. Change directory to wx\samples and type 'make -f makefile.b32'
+   to make all the samples. You can also make them individually.
+   NOTE: only a few samples have up-to-date makefiles, e.g.
+   minimal, docview, mdi. The utils makefile does not yet work.
+
+Gnu-Win32 b19/Mingw32 compilation
+---------------------------------
+
+wxWindows 2.0 supports Gnu-Win32 b19, Mingw32, and Mingw32/EGCS.
+
+Thanks are due to Keith Garry Boyce (garp@opustel.com) and Cygnus for making
+it all possible.
+
+From wxWindows 2.0 beta 9, both Gnu-Win32 b19 and Mingw32 (the minimal
+distribution of Gnu-Win32) can be used with the same makefiles.
+
+Here are the steps required:
+
+- Retrieve and install the latest beta of Gnu-Win32, or Mingw32, as per the
+  instructions with either of these packages.
+
+- If using Mingw32 (including the EGCS variant), you need some
+  extra files to use the wxWindows makefiles. You can find these
+  files in ports/mingw32 on the ftp site or CD-ROM, as extra.zip.
+  These should be extracted to the Mingw32 directory.
+
+- Modify the file wx/src/cygnus.bat (or mingw32.bat or mingegcs.bat)
+  to set up appropriate variables, if necessary mounting drives.
+  Run it before compiling.
+
+- For Gnu-Win32, make sure there's a \tmp directory on your
+  Windows drive or bison will crash.
+
+- Edit wx/src/makeg95.env and search for MINGW32. Take note of
+  the comments for adjusting settings to suit Gnu-Win32 or
+  Mingw32. Basically, this is just a case of adding the __MINGW32__ symbol
+  to OPTIONS for Mingw32, or removing it for Cygnus Gnu-Win32.
+  For Mingw32/EGCS, add both __MINGW32__ and __EGCS__.
+
+- Use the makefile.g95 files for compiling wxWindows and samples,
+  e.g.:
+  > cd c:\wx\src\msw
+  > make -f makefile.g95
+  > cd c:\wx\samples\minimal
+  > make -f makefile.g95
+
+- Use the 'strip' command to reduce executable size.
+
+- With Cygnus Gnu-Win32, you can invoke gdb --nw myfile.exe to
+  debug an executable.
+
+- If using GnuWin32 b18, you will need to copy windres.exe
+  from e.g. the Mingw32 distribution, to a directory in your path.
+
+All targets have 'clean' targets to allow removal of object files
+and other intermediate compiler files.
+
+Gotchas:
+
+- libwx.a is 28 MB or more.
+- install.exe doesn't have built-in decompression because lzexpand.lib
+  isn't available with Gnu-Win32. However, you can use it with external
+  decompression utilities.
+
+References:
+
+ - The GNU-WIN32 site is at
+     http://www.cygnus.com/gnu-win32/
+ - Mingw32 is available at:
+     http://agnes.dida.physik.uni-essen.de/~janjaap/mingw32/index.html
+ - See also http://web.ukonline.co.uk/julian.smart/wxwin/gnuwin32.htm
+
diff --git a/docs/msw/issues.txt b/docs/msw/issues.txt
new file mode 100644
index 0000000000..ac12269303
--- /dev/null
+++ b/docs/msw/issues.txt
@@ -0,0 +1,67 @@
+Current issues and bugs
+-----------------------
+
+Debugging code
+--------------
+
+wxDebugContext and global memory operators doesn't work correctly,
+for different (unresolved) reasons on different compilers.
+
+1) In VC++ 5.0, if you use wxDebugAlloc for new and wxDebugFree
+for delete, you get a crash to do with deallocating the debug
+buffer in wxDebugContext. So although the global operators are
+defined, they are #ifdefed to just call malloc and free to avoid
+the problem. This means that non-object memory checking doesn't work.
+The problem does seem to be something to do with a pointer
+mysteriously changing its address, very similar to 2).
+
+2) In BC++ 4.5, there isn't a crash, but instead the ofstream
+pointer passed to SetStream from SetFile (which is called in
+memcheck.cpp) gets mysteriously changed as it's passed to SetStream.
+This means that when counting the number of outstanding memory
+blocks, we can't compare the allocated block with m_debugStream
+to say 'ignore this block because we can't free it before the
+very end of the application'. Therefore it always looks like
+there's a memory leak of one object, in memory.cpp, unless you
+don't call wxDebugContext::SetFile.
+
+The fact that pointers appear to change in both cases must
+indicate a common problem and solution. If we could use the
+standard global memory operators for ofstream and
+wxDebugStreamBuf it might help, but I don't know how to do that -
+I've redefined 'new' throughout as WXDEBUG_NEW (which is itself
+defined as the 3-argument operator).
+
+Config/registry classes
+-----------------------
+
+Problems with Karsten's/Vadim's existing AppConfig classes:
+
+- use char* a lot instead of wxString
+- rather hard to understand
+- will need fairly substantial rewrite
+- no native .ini functions (?) for guaranteed Windows
+  compatibility
+- new wxWin docs required
+
+Good things:
+
+- exists!
+- FileConfig independent of OS
+- specifying a base class that will meet nearly all needs for
+  derived classes
+- enumerator
+
+Other features we should probably have:
+
+- ability to specify vendor name/app name in constructor
+- under Windows, ability to read/write all areas of registry
+  as an option
+
+Options:
+
+- rewrite AppConfig
+- start from own CRegistry class
+- take elements from both
+- do the Windows stuff, let someone else write/adapt the
+  non-Windows classes
diff --git a/docs/msw/readme.txt b/docs/msw/readme.txt
new file mode 100644
index 0000000000..2ae9f1b797
--- /dev/null
+++ b/docs/msw/readme.txt
@@ -0,0 +1,5 @@
+This is the wxWindows for Windows Preview.
+
+For more information, please see changes.txt, todo.txt, and the
+manuals.
+
diff --git a/docs/msw/todo.txt b/docs/msw/todo.txt
new file mode 100644
index 0000000000..9f52631702
--- /dev/null
+++ b/docs/msw/todo.txt
@@ -0,0 +1,202 @@
+
+Todo on wxWin 2.0, Windows platform
+-----------------------------------
+
+HIGH PRIORITY
+-------------
+
+Integrate Robert's wxGrid enhancements.
+
+Find/add wxThread sample - Arthur T-D?
+
+wxControl dimensions should be optionally based on dialog font
+size for portability (dialog units as per Windows).
+
+Implement wxDC floating point transformations.
+
+Remove transformation from device to logical coordinates from
+events e.g. mouse events.
+
+Add wxDC::DeviceToLogical -> wxPoint etc (convenience accessors).
+
+Revamp Dialog Editor for new controls and properties (e.g.
+window id).
+
+Registry classes (check out wxConfig class - see issues.txt).
+
+Update manual.
+    wxApp changes       DONE
+    wxMenu changes      DONE
+    wxModule            DONE
+    wxRegion            DONE
+    wxFile              DONE
+    wxTempFile
+    wxMask              DONE
+    wxDC:Blit           DONE
+    wxTaskBarIcon       DONE
+    wxMsgCatalog etc.
+    wxLog
+    wxConfig, wxRegKey
+    wxTabCtrl
+    wxWave
+    wxJoystick
+    wxStatusBar95 and wxFrame status bar functions
+    wxListBox changes (for ownerdraw functionality)
+    wxThread
+    wxString
+    wxTString
+    Drag and drop (change API if required, e.g. const).
+    wxCheckListBox
+    wxBaseArray, other arrays
+    (wxOwnerDrawn)
+    Various events
+    Document the include file for each class
+
+Write tutorial.
+
+Other static classes.
+
+Makefiles for other compilers. Generic makefiles?
+Rewrite makefiles to maintain simultaneous debug/release
+objects.
+
+More wxSystemSettings (see comment in settings.cpp).
+
+wxSocket integration.
+
+wxListCtrl, wxTreeCtrl, wxImageList integration with Robert
+Roebling's classes.
+
+Convert OGL, other utilities and samples.
+
+Check TODO entries.
+
+Change #include "wx/xxx.h" to #include <wx/xxx.h>
+
+Tidy code further, e.g. formatting from DevStudio, plus
+standard header.
+
+Shell function to invoke a document with open, print, whatever...
+
+wxTextCtrl (and wxMultiText/wxTextWindow in wxWin 1.xx) - differences between Edit
+and RichEdit controls.
+
+Make use of Vadim's gettext implementation throughout wxWin code.
+Document it.
+
+Change wxUpdateIterator to use wxRegion; or scrap
+wxUpdateIterator? See wxGTK.
+
+Check WXWIN_COMPATIBILITY mode, remove any unnecessary #ifdefs.
+
+Retain callback functions; have semi-compatible callback function prototypes
+for all controls, at least in WXWIN_COMPATIBLE mode, but
+retain (Set)Callback for all compilations. This is following a
+panicky response to losing callbacks.
+
+Merge dib.cpp, dibutils.cpp.
+
+Simplify the toolbar samples.
+
+Add a wxTabCtrl sample.
+
+LOW PRIORITY
+------------
+
+Debug PNG support in wxBitmap (no 4-bit support), and possibly add a convertor from PNG
+to HICON. We could perhaps also support inclusion of PNGs into
+a .res file as a custom resource.
+
+Fonts: ability to enumerate them.
+
+Angled text.
+
+Eliminate Set/GetDefaultBackgroundColour? Just take background
+colour for child control instead.
+
+Think about reimplementing wxBitmapButton, wxStaticBitmap using
+BS_BITMAP, SS_BITMAP - but this may not allow wxBitmap
+argument, so instead just allow controls loaded from native
+resource to deal with this style and call default processing.
+
+Completion of drag and drop support (Vadim).
+
+Better clipboard support.
+
+Toolbars: use event tables not virtual functions.
+
+wxWizard class?
+
+Doc/view - have some standard views/docs e.g. wxTextView.
+
+wxClassWizard for generating files, chunks of code.
+
+Miscellaneous file/system function wrappers.
+
+wxImage or replacement; further wxBitmap/wxIcon etc. functions
+(load animated icos).
+
+Integrate existing multimedia classes.
+
+Rich text class?
+
+Optimize size further.
+
+wxThread integration.
+
+Look at WinCE stuff incl. database classes.
+
+Improve conversion guide, compatibility classes, tools?
+
+Bug database.
+
+ActiveX support?
+
+OpenGL integration.
+
+Menu bitmaps - document Vadim's enhancements.
+
+Enhance Tex2RTF to generate Microsoft HTML help, perhaps Netscape
+HTML help also.
+
+wxCreateDynamicObject is apparently slow: ~ 2000 calls to strcmp. Need to
+use some kind of hash table scheme.
+
+Write wxDisplay class for querying settings and passing
+to wxFrame to mirror the X situation (multiple displays).
+
+Write translator between old and new .wxr formats (including
+substituting static text for obsolete labels).
+
+Improve and expand wxSizer classes.
+
+Write more validators.
+
+Classes for file/OS utility functions.
+
+Add support for more static controls e.g. wxStaticLine.
+
+GDI objects could be optimised further in constructors by
+searching for a matching, pre-existing object, and assigning from
+that, thus sharing the internal handle. A problem with this
+arises if you wish to change the data. But this can be handled by
+un-refing and creating a new handle. So we could reuse many
+Windows GDI objects without troubling the programmer. We might
+wish to switch this off in certain circumstances, e.g.
+
+    wxEnableGDIReuse(FALSE);
+    wxBrush brush(...);
+    wxEnableGDIReuse(TRUE);
+
+or even
+
+    wxGDIReuse reuse(FALSE);
+    wxBrush brush(...);
+
+which lasts until its scope ends. This might be needed e.g. if we
+needed to ensure that the operation was maximally efficient
+(creating a new object rather than searching may or may not be
+more efficient).
+
+Perhaps rewrite wxFile to use FILE* descriptors, so Eof and Flush
+can work.
diff --git a/include/wx/msw/app.h b/include/wx/msw/app.h
new file mode 100644
index 0000000000..8fe8d12248
--- /dev/null
+++ b/include/wx/msw/app.h
@@ -0,0 +1,179 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        app.h
+// Purpose:     wxApp class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __APPH__
+#define __APPH__
+
+#ifdef __GNUG__
+#pragma interface "app.h"
+#endif
+
+#include "wx/defs.h"
+#include "wx/object.h"
+
+class WXDLLEXPORT wxFrame;
+class WXDLLEXPORT wxWindow;
+class WXDLLEXPORT wxApp ;
+class WXDLLEXPORT wxKeyEvent;
+class WXDLLEXPORT wxLog;
+
+#define wxPRINT_WINDOWS         1
+#define wxPRINT_POSTSCRIPT      2
+
+WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
+
+void WXDLLEXPORT wxCleanUp(void);
+void WXDLLEXPORT wxCommonCleanUp(void); // Call this from the platform's wxCleanUp()
+void WXDLLEXPORT wxCommonInit(void);    // Call this from the platform's initialization
+
+// Force an exit from main loop
+void WXDLLEXPORT wxExit(void);
+
+// Yield to other apps/messages
+bool WXDLLEXPORT wxYield(void);
+
+// Represents the application. Derive OnInit and declare
+// a new App object to start application
+class WXDLLEXPORT wxApp: public wxEvtHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxApp)
+  wxApp(void);
+  inline ~wxApp(void) {}
+
+  static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
+  static wxAppInitializerFunction GetInitializerFunction(void) { return m_appInitFn; }
+
+  virtual int MainLoop(void);
+  void ExitMainLoop(void);
+  bool Initialized(void);
+  virtual bool Pending(void) ;
+  virtual void Dispatch(void) ;
+
+  virtual void OnIdle(wxIdleEvent& event);
+
+  // Windows specific. Intercept keyboard input.
+#if WXWIN_COMPATIBILITY == 2
+  virtual bool OldOnCharHook(wxKeyEvent& event);
+#endif
+
+// Generic
+  virtual bool OnInit(void) { return FALSE; };
+
+  // No specific tasks to do here.
+  virtual bool OnInitGui(void) { return TRUE; }
+
+  // Called to set off the main loop
+  virtual int OnRun(void) { return MainLoop(); };
+  virtual int OnExit(void) { return 0; };
+  inline void SetPrintMode(int mode) { m_printMode = mode; }
+  inline int GetPrintMode(void) const { return m_printMode; }
+  
+  inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
+  inline bool GetExitOnFrameDelete(void) const { return m_exitOnFrameDelete; }
+
+/*
+  inline void SetShowFrameOnInit(bool flag) { m_showOnInit = flag; }
+  inline bool GetShowFrameOnInit(void) const { return m_showOnInit; }
+*/
+
+  inline wxString GetAppName(void) const {
+      if (m_appName != "")
+        return m_appName;
+      else return m_className;
+    }
+
+  inline void SetAppName(const wxString& name) { m_appName = name; };
+  inline wxString GetClassName(void) const { return m_className; }
+  inline void SetClassName(const wxString& name) { m_className = name; }
+  wxWindow *GetTopWindow(void) const ;
+  inline void SetTopWindow(wxWindow *win) { m_topWindow = win; }
+
+  inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
+  inline bool GetWantDebugOutput(void) { return m_wantDebugOutput; }
+
+  // Send idle event to all top-level windows.
+  // Returns TRUE if more idle time is requested.
+  bool SendIdleEvents(void);
+
+  // Send idle event to window and all subwindows
+  // Returns TRUE if more idle time is requested.
+  bool SendIdleEvents(wxWindow* win);
+
+  inline void SetAuto3D(const bool flag) { m_auto3D = flag; }
+  inline bool GetAuto3D(void) const { return m_auto3D; }
+
+  // Creates a log object
+  virtual wxLog* CreateLogTarget(void);
+
+public:
+//  void (*work_proc)(wxApp*app); // work procedure;
+  int               argc;
+  char **           argv;
+
+protected:
+  bool              m_wantDebugOutput ;
+  wxString          m_className;
+  wxString          m_appName;
+  wxWindow *        m_topWindow;
+  bool              m_exitOnFrameDelete;
+  bool              m_showOnInit;
+  int               m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
+  bool              m_auto3D ;   // Always use 3D controls, except
+                                 // where overriden
+  static wxAppInitializerFunction	m_appInitFn;
+
+/* Windows-specific wxApp definitions */
+
+public:
+
+  // Implementation
+  static bool Initialize(WXHINSTANCE instance);
+  static void CommonInit(void);
+  static bool RegisterWindowClasses(void);
+  static void CleanUp(void);
+  static void CommonCleanUp(void);
+  virtual bool DoMessage(void);
+  virtual bool ProcessMessage(WXMSG* pMsg);
+  void DeletePendingObjects(void);
+  bool ProcessIdle(void);
+
+/*
+  inline void SetPendingCleanup(bool flag) { m_pendingCleanup = flag; }
+  inline bool GetPendingCleanup(void) { return m_pendingCleanup; }
+
+  bool DoResourceCleanup(void);
+  // Set resource collection scheme on or off.
+  inline void SetResourceCollection(bool flag) { m_resourceCollection = flag; }
+  inline bool GetResourceCollection(void) { return m_resourceCollection; }
+*/
+
+public:
+  static long       sm_lastMessageTime;
+  int               m_nCmdShow;
+
+protected:
+  bool              m_keepGoing ;
+//  bool              m_resourceCollection;
+//  bool              m_pendingCleanup; // TRUE if we need to check the GDI object lists for cleanup
+
+DECLARE_EVENT_TABLE()
+};
+
+#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
+int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine,
+                    int nCmdShow, bool enterLoop = TRUE);
+#else
+int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance);
+#endif
+
+#endif
+    // __APPH__
+
diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h
new file mode 100644
index 0000000000..e7919e482e
--- /dev/null
+++ b/include/wx/msw/bitmap.h
@@ -0,0 +1,201 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        bitmap.h
+// Purpose:     wxBitmap class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __BITMAPH__
+#define __BITMAPH__
+
+#ifdef __GNUG__
+#pragma interface "bitmap.h"
+#endif
+
+#include "wx/gdiobj.h"
+#include "wx/gdicmn.h"
+#include "wx/palette.h"
+
+// Bitmap
+class WXDLLEXPORT wxDC;
+class WXDLLEXPORT wxControl;
+class WXDLLEXPORT wxBitmap;
+class WXDLLEXPORT wxBitmapHandler;
+class WXDLLEXPORT wxIcon;
+class WXDLLEXPORT wxCursor;
+
+// A mask is a mono bitmap used for drawing bitmaps
+// transparently.
+class WXDLLEXPORT wxMask: public wxObject
+{
+  DECLARE_DYNAMIC_CLASS(wxMask)
+
+public:
+  wxMask(void);
+
+  // Construct a mask from a bitmap and a colour indicating
+  // the transparent area
+  wxMask(const wxBitmap& bitmap, const wxColour& colour);
+
+  // Construct a mask from a bitmap and a palette index indicating
+  // the transparent area
+  wxMask(const wxBitmap& bitmap, const int paletteIndex);
+
+  // Construct a mask from a mono bitmap (copies the bitmap).
+  wxMask(const wxBitmap& bitmap);
+
+  ~wxMask(void);
+
+  bool Create(const wxBitmap& bitmap, const wxColour& colour);
+  bool Create(const wxBitmap& bitmap, const int paletteIndex);
+  bool Create(const wxBitmap& bitmap);
+
+  // Implementation
+  inline WXHBITMAP GetMaskBitmap(void) const { return m_maskBitmap; }
+  inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
+protected:
+  WXHBITMAP m_maskBitmap;
+};
+
+class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
+{
+    friend class WXDLLEXPORT wxBitmap;
+    friend class WXDLLEXPORT wxIcon;
+    friend class WXDLLEXPORT wxCursor;
+public:
+    wxBitmapRefData(void);
+    ~wxBitmapRefData(void);
+
+public:
+  int           m_width;
+  int           m_height;
+  int           m_depth;
+  bool          m_ok;
+  int           m_numColors;
+  wxPalette     m_bitmapPalette;
+  int           m_quality;
+
+#ifdef __WINDOWS__
+  WXHBITMAP     m_hBitmap;
+  wxDC *        m_selectedInto; // So bitmap knows whether it's been selected into
+                      // a device context (for error checking)
+  wxMask *      m_bitmapMask; // Option mask
+#endif
+};
+
+#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
+
+class WXDLLEXPORT wxBitmapHandler: public wxObject
+{
+  DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
+public:
+  wxBitmapHandler(void) { m_name = ""; m_extension = ""; m_type = 0; };
+
+  virtual bool Create(wxBitmap *bitmap, void *data, const long flags, const int width, const int height, const int depth = 1);
+  virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+      int desiredWidth, int desiredHeight);
+  virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *palette = NULL);
+
+  inline void SetName(const wxString& name) { m_name = name; }
+  inline void SetExtension(const wxString& ext) { m_extension = ext; }
+  inline void SetType(const long type) { m_type = type; }
+  inline wxString GetName(void) const { return m_name; }
+  inline wxString GetExtension(void) const { return m_extension; }
+  inline long GetType(void) const { return m_type; }
+protected:
+  wxString  m_name;
+  wxString  m_extension;
+  long      m_type;
+};
+#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
+
+class WXDLLEXPORT wxBitmap: public wxGDIObject
+{
+  DECLARE_DYNAMIC_CLASS(wxBitmap)
+
+  friend class WXDLLEXPORT wxBitmapHandler;
+
+public:
+  wxBitmap(void); // Platform-specific
+
+  // Copy constructors
+  inline wxBitmap(const wxBitmap& bitmap)
+  { Ref(bitmap); if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this); }
+  inline wxBitmap(const wxBitmap* bitmap) { if (bitmap) Ref(*bitmap); if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this); }
+
+  // Initialize with raw data
+  wxBitmap(const char bits[], const int width, const int height, const int depth = 1);
+
+#if USE_XPM_IN_MSW
+  // Initialize with XPM data
+  wxBitmap(const char **data, wxItem *anItem = NULL);
+#endif
+
+  // Load a file or resource
+  wxBitmap(const wxString& name, const long type = wxBITMAP_TYPE_BMP_RESOURCE);
+
+  // New constructor for generalised creation from data
+  wxBitmap(void *data, const long type, const int width, const int height, const int depth = 1);
+
+  // If depth is omitted, will create a bitmap compatible with the display
+  wxBitmap(const int width, const int height, const int depth = -1);
+  ~wxBitmap(void);
+
+  virtual bool Create(const int width, const int height, const int depth = -1);
+  virtual bool Create(void *data, const long type, const int width, const int height, const int depth = 1);
+  virtual bool LoadFile(const wxString& name, const long type = wxBITMAP_TYPE_BMP_RESOURCE);
+  virtual bool SaveFile(const wxString& name, const int type, const wxPalette *cmap = NULL);
+
+  inline bool Ok(void) const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); }
+  inline int GetWidth(void) const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); }
+  inline int GetHeight(void) const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); }
+  inline int GetDepth(void) const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); }
+  inline int GetQuality(void) const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); }
+  void SetWidth(int w);
+  void SetHeight(int h);
+  void SetDepth(int d);
+  void SetQuality(int q);
+  void SetOk(bool isOk);
+#if WXWIN_COMPATIBILITY
+  inline wxPalette *GetColourMap(void) const { return GetPalette(); }
+  void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
+#endif
+  inline wxPalette* GetPalette(void) const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : NULL); }
+  void SetPalette(const wxPalette& palette);
+
+  inline wxMask *GetMask(void) const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : NULL); }
+  void SetMask(wxMask *mask) ;
+
+  inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
+  inline bool operator == (const wxBitmap& bitmap) { return m_refData == bitmap.m_refData; }
+  inline bool operator != (const wxBitmap& bitmap) { return m_refData != bitmap.m_refData; }
+
+  // Format handling
+  static inline wxList& GetHandlers(void) { return sm_handlers; }
+  static void AddHandler(wxBitmapHandler *handler);
+  static void InsertHandler(wxBitmapHandler *handler);
+  static bool RemoveHandler(const wxString& name);
+  static wxBitmapHandler *FindHandler(const wxString& name);
+  static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType);
+  static wxBitmapHandler *FindHandler(long bitmapType);
+
+  static void InitStandardHandlers(void);
+  static void CleanUpHandlers(void);
+protected:
+  static wxList sm_handlers;
+
+  // Implementation
+public:
+  void SetHBITMAP(WXHBITMAP bmp);
+  inline WXHBITMAP GetHBITMAP(void) const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hBitmap : 0); }
+  inline void SetSelectedInto(wxDC *dc) { if (M_BITMAPDATA) M_BITMAPDATA->m_selectedInto = dc; }
+  inline wxDC *GetSelectedInto(void) const { return (M_BITMAPDATA ? M_BITMAPDATA->m_selectedInto : NULL); }
+  bool FreeResource(bool force = FALSE);
+
+};
+#endif
+  // __BITMAPH__
diff --git a/include/wx/msw/blank.cur b/include/wx/msw/blank.cur
new file mode 100644
index 0000000000000000000000000000000000000000..048f06b4aefde54e0ff825ccb5a5db4d7001d513
GIT binary patch
literal 326
zcmZQzU}9ioP*7k10|Q0|1~DK@1BexX*a3(cfe;L!6oi8y|NsAw;0zE8=!O9W0CiJ?
AlK=n!

literal 0
HcmV?d00001

diff --git a/include/wx/msw/bmpbuttn.h b/include/wx/msw/bmpbuttn.h
new file mode 100644
index 0000000000..86161a9c84
--- /dev/null
+++ b/include/wx/msw/bmpbuttn.h
@@ -0,0 +1,85 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        bmpbuttn.h
+// Purpose:     wxBitmapButton class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __BMPBUTTNH__
+#define __BMPBUTTNH__
+
+#ifdef __GNUG__
+#pragma interface "bmpbuttn.h"
+#endif
+
+#include "wx/button.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
+
+#define wxDEFAULT_BUTTON_MARGIN 4
+
+class WXDLLEXPORT wxBitmapButton: public wxButton
+{
+  DECLARE_DYNAMIC_CLASS(wxBitmapButton)
+ public:
+  inline wxBitmapButton(void) { m_marginX = wxDEFAULT_BUTTON_MARGIN; m_marginY = wxDEFAULT_BUTTON_MARGIN; }
+  inline wxBitmapButton(wxWindow *parent, const wxWindowID id, const wxBitmap& bitmap,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = wxBU_AUTODRAW,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxButtonNameStr)
+  {
+      Create(parent, id, bitmap, pos, size, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id, const wxBitmap& bitmap,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = wxBU_AUTODRAW,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxButtonNameStr);
+
+  virtual void SetLabel(const wxBitmap& bitmap)
+  {
+    SetBitmapLabel(bitmap);
+  }
+
+  virtual void SetBitmapLabel(const wxBitmap& bitmap);
+
+#if WXWIN_COMPATIBILITY
+  inline wxBitmap *GetBitmap(void) const { return (wxBitmap *) & m_buttonBitmap; }
+#endif
+
+  inline wxBitmap& GetBitmapLabel(void) const { return (wxBitmap&) m_buttonBitmap; }
+  inline wxBitmap& GetBitmapSelected(void) const { return (wxBitmap&) m_buttonBitmapSelected; }
+  inline wxBitmap& GetBitmapFocus(void) const { return (wxBitmap&) m_buttonBitmapFocus; }
+  inline wxBitmap& GetBitmapDisabled(void) const { return (wxBitmap&) m_buttonBitmapDisabled; }
+
+  inline void SetBitmapSelected(const wxBitmap& sel) { m_buttonBitmapSelected = sel; };
+  inline void SetBitmapFocus(const wxBitmap& focus) { m_buttonBitmapFocus = focus; };
+  inline void SetBitmapDisabled(const wxBitmap& disabled) { m_buttonBitmapDisabled = disabled; };
+
+  inline void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
+  inline int GetMarginX(void) { return m_marginX; }
+  inline int GetMarginY(void) { return m_marginY; }
+
+  // Implementation
+  virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
+  virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel );
+  virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel );
+  virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg );
+
+ protected:
+  wxBitmap m_buttonBitmap;
+  wxBitmap m_buttonBitmapSelected;
+  wxBitmap m_buttonBitmapFocus;
+  wxBitmap m_buttonBitmapDisabled;
+  int      m_marginX;
+  int      m_marginY;
+};
+
+#endif
+    // __BMPBUTTNH__
diff --git a/include/wx/msw/brush.h b/include/wx/msw/brush.h
new file mode 100644
index 0000000000..5c568ec04f
--- /dev/null
+++ b/include/wx/msw/brush.h
@@ -0,0 +1,84 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        brush.h
+// Purpose:     wxBrush class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __BRUSHH__
+#define __BRUSHH__
+
+#ifdef __GNUG__
+#pragma interface "brush.h"
+#endif
+
+#include "wx/gdicmn.h"
+#include "wx/gdiobj.h"
+#include "wx/bitmap.h"
+
+class WXDLLEXPORT wxBrush;
+
+class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
+{
+    friend class WXDLLEXPORT wxBrush;
+public:
+    wxBrushRefData(void);
+    ~wxBrushRefData(void);
+
+protected:
+  int           m_style;
+  wxBitmap      m_stipple ;
+  wxColour      m_colour;
+  WXHBRUSH      m_hBrush;
+};
+
+#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
+
+// Brush
+class WXDLLEXPORT wxBrush: public wxGDIObject
+{
+  DECLARE_DYNAMIC_CLASS(wxBrush)
+
+public:
+  wxBrush(void);
+  wxBrush(const wxColour& col, const int style);
+  wxBrush(const wxString& col, const int style);
+  wxBrush(const wxBitmap& stipple);
+  inline wxBrush(const wxBrush& brush) { Ref(brush); }
+  inline wxBrush(const wxBrush* brush) { /* UnRef(); */ if (brush) Ref(*brush); }
+  ~wxBrush(void);
+
+  virtual void SetColour(const wxColour& col)  ;
+  virtual void SetColour(const wxString& col)  ;
+  virtual void SetColour(const unsigned char r, const unsigned char g, const unsigned char b)  ;
+  virtual void SetStyle(const int style)  ;
+  virtual void SetStipple(const wxBitmap& stipple)  ;
+
+  inline wxBrush& operator = (const wxBrush& brush) { if (*this == brush) return (*this); Ref(brush); return *this; }
+  inline bool operator == (const wxBrush& brush) { return m_refData == brush.m_refData; }
+  inline bool operator != (const wxBrush& brush) { return m_refData != brush.m_refData; }
+
+  inline wxColour& GetColour(void) const { return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); };
+  inline int GetStyle(void) const { return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); };
+  inline wxBitmap *GetStipple(void) const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); };
+
+  virtual bool Ok(void) const { return (m_refData != NULL) ; }
+
+  // Internal
+  bool RealizeResource(void);
+  WXHANDLE GetResourceHandle(void) ;
+  bool FreeResource(bool force = FALSE);
+/*
+  bool UseResource(void);
+  bool ReleaseResource(void);
+*/
+
+  bool IsFree(void);
+};
+
+#endif
+    // __BRUSHH__
diff --git a/include/wx/msw/bullseye.cur b/include/wx/msw/bullseye.cur
new file mode 100644
index 0000000000000000000000000000000000000000..308c07d3325a0d7dc7b480cfd402abd7a25830f6
GIT binary patch
literal 326
zcma)0u?@m75Ioa_0*O?#q@-j5Oc5~$5`$y`Bu2<6q+kyU1_+W1u!uPR5+qAdz`fq@
zyT5-M7{Q?^fT_jO0W$y#OOvp+bQV3{WgzJ!naHnO)&P?&kmvTm7})KB%?T*Wp^8ga
zUq1Q&fc@bc*E!i_<l#d4$Y<5DyRWJkY9HIyhx4rtisK`txasQ4C%@)2-|x{r?ft+D
DUkZ17

literal 0
HcmV?d00001

diff --git a/include/wx/msw/button.h b/include/wx/msw/button.h
new file mode 100644
index 0000000000..eae77c0e49
--- /dev/null
+++ b/include/wx/msw/button.h
@@ -0,0 +1,56 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        button.h
+// Purpose:     wxButton class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __BUTTONH__
+#define __BUTTONH__
+
+#ifdef __GNUG__
+#pragma interface "button.h"
+#endif
+
+#include "wx/control.h"
+#include "wx/gdicmn.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
+
+// Pushbutton
+class WXDLLEXPORT wxButton: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxButton)
+ public:
+  inline wxButton(void) {}
+  inline wxButton(wxWindow *parent, const wxWindowID id, const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxButtonNameStr)
+  {
+      Create(parent, id, label, pos, size, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id, const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxButtonNameStr);
+
+  virtual void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+  virtual void SetDefault(void);
+  virtual void SetLabel(const wxString& label);
+  virtual wxString GetLabel(void) const ;
+  virtual void Command(wxCommandEvent& event);
+  virtual bool MSWCommand(const WXUINT param, const WXWORD id);
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+};
+
+#endif
+    // __BUTTONH__
diff --git a/include/wx/msw/checkbox.h b/include/wx/msw/checkbox.h
new file mode 100644
index 0000000000..965da6d7d5
--- /dev/null
+++ b/include/wx/msw/checkbox.h
@@ -0,0 +1,84 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        checkbox.h
+// Purpose:     wxCheckBox class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __CHECKBOXH__
+#define __CHECKBOXH__
+
+#ifdef __GNUG__
+#pragma interface "checkbox.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxCheckBoxNameStr;
+
+// Checkbox item (single checkbox)
+class WXDLLEXPORT wxBitmap;
+class WXDLLEXPORT wxCheckBox: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxCheckBox)
+
+ public:
+  inline wxCheckBox(void) { }
+  inline wxCheckBox(wxWindow *parent, const wxWindowID id, const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxCheckBoxNameStr)
+  {
+      Create(parent, id, label, pos, size, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id, const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxCheckBoxNameStr);
+  virtual void SetValue(const bool);
+  virtual bool GetValue(void) const ;
+  virtual void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+  virtual bool MSWCommand(const WXUINT param, const WXWORD id);
+  virtual void SetLabel(const wxString& label);
+  virtual void Command(wxCommandEvent& event);
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+};
+
+class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox
+{
+  DECLARE_DYNAMIC_CLASS(wxBitmapCheckBox)
+
+ public:
+  int checkWidth ;
+  int checkHeight ;
+
+  inline wxBitmapCheckBox(void) { checkWidth = -1; checkHeight = -1; }
+  inline wxBitmapCheckBox(wxWindow *parent, const wxWindowID id, const wxBitmap *label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxCheckBoxNameStr)
+  {
+      Create(parent, id, label, pos, size, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id, const wxBitmap *bitmap,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxCheckBoxNameStr);
+  virtual void SetValue(const bool);
+  virtual bool GetValue(void) const ;
+  virtual void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+  virtual void SetLabel(const wxBitmap *bitmap);
+};
+#endif
+    // __CHECKBOXH__
diff --git a/include/wx/msw/checklst.h b/include/wx/msw/checklst.h
new file mode 100644
index 0000000000..a525fa9c29
--- /dev/null
+++ b/include/wx/msw/checklst.h
@@ -0,0 +1,62 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        checklst.h
+// Purpose:     wxCheckListBox class - a listbox with checkable items
+// Author:      Vadim Zeitlin
+// Modified by: 
+// Created:     16.11.97
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef   __CHECKLST_H__
+#define   __CHECKLST_H__
+
+typedef   unsigned int  uint;
+
+#if !USE_OWNER_DRAWN
+  #error  "wxCheckListBox class requires owner-drawn functionality."
+#endif
+
+class wxCheckListBoxItem; // fwd decl, define in checklst.cpp
+
+class wxCheckListBox : public wxListBox
+{
+  DECLARE_DYNAMIC_CLASS(wxCheckListBox)
+public:
+  // ctors
+  wxCheckListBox();
+  wxCheckListBox(wxWindow *parent, const wxWindowID id,
+                 const wxPoint& pos = wxDefaultPosition,
+                 const wxSize& size = wxDefaultSize,
+                 const int nStrings = 0, 
+                 const wxString choices[] = NULL,
+                 const long style = 0,
+                 const wxValidator& validator = wxDefaultValidator,
+                 const wxString& name = wxListBoxNameStr);
+//                 const wxFont& font = wxNullFont);
+
+  // items may be checked
+  bool  IsChecked(uint uiIndex) const;
+  void  Check(uint uiIndex, bool bCheck = TRUE);
+
+  // accessors
+  uint  GetItemHeight() const { return m_nItemHeight; }
+
+protected:
+  // we create our items ourselves and they have non-standard size,
+  // so we need to override these functions
+  virtual wxOwnerDrawn *CreateItem(uint n);
+  virtual bool          MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
+
+  // pressing space or clicking the check box toggles the item
+  void OnChar(wxKeyEvent& event);
+  void OnLeftClick(wxMouseEvent& event);
+
+private:
+  uint    m_nItemHeight;  // height of checklistbox items (the same for all)
+
+  DECLARE_EVENT_TABLE()
+};
+
+#endif    //_CHECKLST_H
diff --git a/include/wx/msw/choice.h b/include/wx/msw/choice.h
new file mode 100644
index 0000000000..b25535e142
--- /dev/null
+++ b/include/wx/msw/choice.h
@@ -0,0 +1,78 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        choice.h
+// Purpose:     wxChoice class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __CHOICEH__
+#define __CHOICEH__
+
+#ifdef __GNUG__
+#pragma interface "choice.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxChoiceNameStr;
+
+// Choice item
+class WXDLLEXPORT wxChoice: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxChoice)
+
+ public:
+  int no_strings;
+
+  inline wxChoice(void) { no_strings = 0; }
+
+  inline wxChoice(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const int n = 0, const wxString choices[] = NULL,
+           const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxChoiceNameStr)
+  {
+    Create(parent, id, pos, size, n, choices, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const int n = 0, const wxString choices[] = NULL,
+           const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxChoiceNameStr);
+
+  virtual void Append(const wxString& item);
+  virtual void Delete(const int n);
+  virtual void Clear(void);
+  virtual int GetSelection(void) const ;
+  virtual void SetSelection(const int n);
+  virtual int FindString(const wxString& s) const;
+  virtual wxString GetString(const int n) const ;
+  virtual void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+  virtual wxString GetStringSelection(void) const ;
+  virtual bool SetStringSelection(const wxString& sel);
+
+  virtual inline int Number(void) const { return no_strings; }
+  virtual void Command(wxCommandEvent& event);
+
+  virtual bool MSWCommand(const WXUINT param, const WXWORD id);
+
+  virtual inline void SetColumns(const int WXUNUSED(n) = 1 ) { /* No effect */ } ;
+  virtual inline int GetColumns(void) const { return 1 ; };
+
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+  long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+};
+
+#endif
+	// __CHOICEH__
diff --git a/include/wx/msw/clipbrd.h b/include/wx/msw/clipbrd.h
new file mode 100644
index 0000000000..abdabfb142
--- /dev/null
+++ b/include/wx/msw/clipbrd.h
@@ -0,0 +1,111 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        clipbrd.h
+// Purpose:     Clipboard functionality
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __CLIPBRDH__
+#define __CLIPBRDH__
+
+#ifdef __GNUG__
+#pragma interface "clipbrd.h"
+#endif
+
+#include "wx/defs.h"
+#include "wx/setup.h"
+
+#if USE_CLIPBOARD
+
+#include "wx/list.h"
+
+bool WXDLLEXPORT wxOpenClipboard(void);
+bool WXDLLEXPORT wxClipboardOpen(void);
+bool WXDLLEXPORT wxCloseClipboard(void);
+bool WXDLLEXPORT wxEmptyClipboard(void);
+bool WXDLLEXPORT wxIsClipboardFormatAvailable(int dataFormat);
+bool WXDLLEXPORT wxSetClipboardData(int dataFormat, wxObject *obj, int width = 0, int height = 0);
+wxObject* WXDLLEXPORT wxGetClipboardData(int dataFormat, long *len = NULL);
+int  WXDLLEXPORT wxEnumClipboardFormats(int dataFormat);
+int  WXDLLEXPORT wxRegisterClipboardFormat(char *formatName);
+bool WXDLLEXPORT wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount);
+
+/* The following is Matthew Flatt's implementation of the MSW
+ * side of generic clipboard functionality.
+ */
+
+/* A clipboard client holds data belonging to the clipboard.
+   For plain text, a client is not necessary. */
+class WXDLLEXPORT wxClipboardClient : public wxObject
+{
+  DECLARE_ABSTRACT_CLASS(wxClipboardClient)
+
+ public:
+  /* This list should be filled in with strings indicating the formats
+     this client can provide. Almost all clients will provide "TEXT".
+     Format names should be 4 characters long, so things will work
+     out on the Macintosh */
+  wxStringList formats;
+
+  /* This method is called when the client is losing the selection. */
+  virtual void BeingReplaced(void) = 0;
+
+  /* This method is called when someone wants the data this client is
+     supplying to the clipboard. "format" is a string indicating the
+     format of the data - one of the strings from the "formats"
+     list. "*size" should be filled with the size of the resulting
+     data. In the case of text, "*size" does not count the
+     NULL terminator. */
+  virtual char *GetData(char *format, long *size) = 0;
+};
+
+/* ONE instance of this class: */
+class WXDLLEXPORT wxClipboard : public wxObject
+{
+  DECLARE_DYNAMIC_CLASS(wxClipboard)
+
+ public:
+  wxClipboardClient *clipOwner;
+  char *cbString, *sentString, *receivedString;
+  void *receivedTargets;
+  long receivedLength;
+#ifdef __XVIEW__
+  long sel_owner;
+#endif
+
+  wxClipboard();
+  ~wxClipboard();
+
+  /* Set the clipboard data owner. "time" comes from the event record. */
+  void SetClipboardClient(wxClipboardClient *, long time);
+
+  /* Set the clipboard string; does not require a client. */
+  void SetClipboardString(char *, long time);
+
+  /* Get data from the clipboard in the format "TEXT". */
+  char *GetClipboardString(long time);
+
+  /* Get data from the clipboard */
+  char *GetClipboardData(char *format, long *length, long time);
+
+  /* Get the clipboard client directly. Will be NULL if clipboard data
+     is a string, or if some other application owns the clipboard. 
+     This can be useful for shortcutting data translation, if the
+     clipboard user can check for a specific client. (This is used
+     by the wxMediaEdit class.) */
+  wxClipboardClient *GetClipboardClient(void);
+};
+
+/* Initialize wxTheClipboard. Can be called repeatedly */
+void WXDLLEXPORT wxInitClipboard(void);
+
+/* The clipboard */
+extern wxClipboard* WXDLLEXPORT wxTheClipboard;
+
+#endif // USE_CLIPBOARD
+#endif
+    // __CLIPBRDH__
diff --git a/include/wx/msw/clock.cur b/include/wx/msw/clock.cur
new file mode 100644
index 0000000000000000000000000000000000000000..6693b04d6b52ad5bcce3fb27f77ca16c88ddcb58
GIT binary patch
literal 326
zcmZ{fI}XAy5JV@WpbRv$rljNqgqu+0AfZczI08rD27r_zB_$mRN=ZRnAR;~<cKHZ|
zgjdfiTi!P^(13?-7YL;K9?${M6XXg*!IOHdS9=~lJ4py+WyrBl2k;scaXqNR$~m*!
zo`Tdd$;d2Wo=&)qrkt0CGix{!LfdkSwz<XDoR`)db35H1%E{&wCG$&~<+n`d)uTT3
vs$X+7?~(hP55zSPR)8twYb&6si~;`*^lN{3ztO&W%@*QOpL(z2|IWVyjE#Um

literal 0
HcmV?d00001

diff --git a/include/wx/msw/colordlg.h b/include/wx/msw/colordlg.h
new file mode 100644
index 0000000000..09cd225e90
--- /dev/null
+++ b/include/wx/msw/colordlg.h
@@ -0,0 +1,44 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        colordlg.h
+// Purpose:     wxColourDialog class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __COLORDLGH__
+#define __COLORDLGH__
+
+#ifdef __GNUG__
+#pragma interface "colordlg.h"
+#endif
+
+#include "wx/setup.h"
+#include "wx/dialog.h"
+#include "wx/cmndata.h"
+
+/*
+ * COLOUR DIALOG
+ */
+
+class WXDLLEXPORT wxColourDialog: public wxDialog
+{
+ DECLARE_DYNAMIC_CLASS(wxColourDialog)
+ protected:
+  wxColourData colourData;
+  wxWindow *dialogParent;
+ public:
+  wxColourDialog(void);
+  wxColourDialog(wxWindow *parent, wxColourData *data = NULL);
+
+  bool Create(wxWindow *parent, wxColourData *data = NULL);
+
+  int ShowModal(void);
+  wxColourData& GetColourData(void) { return colourData; }
+};
+
+#endif
+    // __COLORDLGH__
diff --git a/include/wx/msw/colour.h b/include/wx/msw/colour.h
new file mode 100644
index 0000000000..5bf97af25d
--- /dev/null
+++ b/include/wx/msw/colour.h
@@ -0,0 +1,62 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        colour.h
+// Purpose:     wxColour class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __COLOURH__
+#define __COLOURH__
+
+#ifdef __GNUG__
+#pragma interface "colour.h"
+#endif
+
+// Colour
+class WXDLLEXPORT wxColour: public wxObject
+{
+  DECLARE_DYNAMIC_CLASS(wxColour)
+public:
+  wxColour(void);
+  wxColour(const unsigned char r, const unsigned char g, const unsigned char b);
+  wxColour(const wxColour& col);
+  wxColour(const wxString& col);
+  ~wxColour(void) ;
+  wxColour& operator =(const wxColour& src) ;
+  wxColour& operator =(const wxString& src) ;
+  inline int Ok(void) const { return (m_isInit) ; }
+
+  void Set(unsigned char r, unsigned char g, unsigned char b);
+
+  // Let's remove this inelegant function
+#if WXWIN_COMPATIBILITY
+  void Get(unsigned char *r, unsigned char *g, unsigned char *b) const;
+#endif
+
+  inline unsigned char Red(void) const { return m_red; }
+  inline unsigned char Green(void) const { return m_green; }
+  inline unsigned char Blue(void) const { return m_blue; }
+
+  inline bool operator == (const wxColour& colour) { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
+
+  inline bool operator != (const wxColour& colour) { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
+
+  WXCOLORREF GetPixel(void) const { return m_pixel; };
+
+ private:
+  bool 			m_isInit;
+  unsigned char m_red;
+  unsigned char m_blue;
+  unsigned char m_green;
+ public:
+  WXCOLORREF m_pixel ;
+};
+
+#define wxColor wxColour
+
+#endif
+	// __COLOURH__
diff --git a/include/wx/msw/combobox.h b/include/wx/msw/combobox.h
new file mode 100644
index 0000000000..d659f8c372
--- /dev/null
+++ b/include/wx/msw/combobox.h
@@ -0,0 +1,79 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        combobox.h
+// Purpose:     wxComboBox class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __COMBOBOXH__
+#define __COMBOBOXH__
+
+#ifdef __GNUG__
+#pragma interface "combobox.h"
+#endif
+
+#include "wx/choice.h"
+
+#if USE_COMBOBOX
+
+WXDLLEXPORT_DATA(extern const char*) wxComboBoxNameStr;
+WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
+
+// Combobox item
+class WXDLLEXPORT wxComboBox: public wxChoice
+{
+  DECLARE_DYNAMIC_CLASS(wxComboBox)
+
+ public:
+  inline wxComboBox(void) {}
+
+  inline wxComboBox(wxWindow *parent, const wxWindowID id,
+           const wxString& value = wxEmptyString,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const int n = 0, const wxString choices[] = NULL,
+           const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxComboBoxNameStr)
+  {
+    Create(parent, id, value, pos, size, n, choices, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxString& value = wxEmptyString,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const int n = 0, const wxString choices[] = NULL,
+           const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxComboBoxNameStr);
+
+  // List functions: see wxChoice
+  
+  // Text field functions
+  virtual wxString GetValue(void) const ;
+  virtual void SetValue(const wxString& value);
+
+  // Clipboard operations
+  virtual void Copy(void);
+  virtual void Cut(void);
+  virtual void Paste(void);
+  virtual void SetInsertionPoint(const long pos);
+  virtual void SetInsertionPointEnd(void);
+  virtual long GetInsertionPoint(void) const ;
+  virtual long GetLastPosition(void) const ;
+  virtual void Replace(const long from, const long to, const wxString& value);
+  virtual void Remove(const long from, const long to);
+  virtual void SetSelection(const long from, const long to);
+  virtual void SetEditable(const bool editable);
+
+  virtual bool MSWCommand(const WXUINT param, const WXWORD id);
+};
+
+#endif // USE_COMBOBOX
+#endif
+    // __COMBOBOXH__
diff --git a/include/wx/msw/control.h b/include/wx/msw/control.h
new file mode 100644
index 0000000000..3ab4b84829
--- /dev/null
+++ b/include/wx/msw/control.h
@@ -0,0 +1,86 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        control.h
+// Purpose:     wxControl class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __CONTROLH__
+#define __CONTROLH__
+
+#ifdef __GNUG__
+#pragma interface "control.h"
+#endif
+
+#include "wx/window.h"
+#include "wx/list.h"
+#include "wx/validate.h"
+
+// General item class
+class WXDLLEXPORT wxControl: public wxWindow
+{
+  DECLARE_ABSTRACT_CLASS(wxControl)
+public:
+   wxControl(void);
+   ~wxControl(void);
+
+   virtual void Command(wxCommandEvent& WXUNUSED(event)) = 0;        // Simulates an event
+   virtual void ProcessCommand(wxCommandEvent& event); // Calls the callback and
+                                                                 // appropriate event handlers
+   virtual void SetClientSize(const int width, const int height);
+   virtual void SetLabel(const wxString& label);
+   virtual wxString GetLabel(void) const ;
+
+#if WXWIN_COMPATIBILITY
+   inline virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
+   inline wxColour*GetButtonColour(void) const { return NULL; }
+
+   inline virtual void SetLabelFont(const wxFont& font);
+   inline virtual void SetButtonFont(const wxFont& font);
+   inline wxFont  *GetLabelFont(void) const ;
+   inline wxFont  *GetButtonFont(void) const ;
+#endif
+
+   // Places item in centre of panel - so can't be used BEFORE panel->Fit()
+   void Centre(const int direction = wxHORIZONTAL);
+   inline void Callback(const wxFunction function);           // Adds callback
+
+   // MSW-specific
+   
+   // Window procedure
+   virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+   virtual void MSWOnMouseMove(const int x, const int y, const WXUINT flags);
+   virtual bool MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam);
+
+   void OnEraseBackground(wxEraseEvent& event);
+
+   // For ownerdraw items
+   virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
+   virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
+
+   inline wxFunction GetCallback(void) { return m_callback; }
+   inline wxList& GetSubcontrols(void) { return m_subControls; }
+protected:
+   wxFunction       m_callback;     // Callback associated with the window
+ 
+   // MSW implementation
+   wxList           m_subControls; // For controls like radiobuttons which are really composite
+
+DECLARE_EVENT_TABLE()
+};
+
+inline void wxControl::Callback(const wxFunction function) { m_callback = function; };           // Adds callback
+
+#if WXWIN_COMPATIBILITY
+inline wxFont  *wxControl::GetLabelFont(void) const         { return GetFont() ; }
+inline wxFont  *wxControl::GetButtonFont(void) const        { return GetFont() ; }
+inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
+inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
+#endif
+
+#endif
+    // __CONTROLH__
diff --git a/include/wx/msw/curico.h b/include/wx/msw/curico.h
new file mode 100644
index 0000000000..0ea5f02cf6
--- /dev/null
+++ b/include/wx/msw/curico.h
@@ -0,0 +1,22 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        curico.h
+// Purpose:     Icon and cursor functions
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+HICON    ReadIconFile(    char *szFileName, HINSTANCE hInst,
+                          int *W = 0, int *H = 0);
+HCURSOR  ReadCursorFile(  char *szFileName, HINSTANCE hInst,
+                          int *W = 0, int *H = 0, int *XHot = 0, int *YHot = 0);
+HCURSOR  IconToCursor(    char *szFileName, HINSTANCE hInst, int XHot, int YHot,
+                          int *W = 0, int *H = 0);
+HICON    CursorToIcon(    char *szFileName, HINSTANCE hInst,
+                          int *W = 0, int *H = 0);
+
+HCURSOR MakeCursorFromBitmap(HINSTANCE hInst, HBITMAP hBitmap, POINT *pPoint);
+HICON MakeIconFromBitmap(HINSTANCE hInst, HBITMAP hBitmap);
diff --git a/include/wx/msw/curicop.h b/include/wx/msw/curicop.h
new file mode 100644
index 0000000000..1ec5056e90
--- /dev/null
+++ b/include/wx/msw/curicop.h
@@ -0,0 +1,63 @@
+// PRIVATE STUFF FOLLOWS UNTIL END
+
+// Header signatures for various resources
+#define BFT_ICON   0x4349   /* 'IC' */
+#define BFT_BITMAP 0x4d42   /* 'BM' */
+#define BFT_CURSOR 0x5450   /* 'PT' */
+
+// This WIDTHBYTES macro determines the number of BYTES per scan line.
+#define WIDTHBYTES( i)   ((i + 31) / 32 * 4)
+#define IS_WIN30_DIB( lpbi)  ((*(LPDWORD)( lpbi)) == sizeof( BITMAPINFOHEADER))
+
+WORD         DIBNumColors(LPSTR pv);
+WORD         PaletteSize(LPSTR lpbi);
+
+
+struct tagCURFILEHEADER { WORD wReserved;         // Always 0
+                          WORD wResourceType;     // 2 = cursor
+                          WORD wResourceCount;    // Number of icons in the file
+                        };
+
+typedef struct tagCURFILEHEADER CURFILEHEADER;
+
+struct tagCURFILERES {
+    BYTE  bWidth;         // Width of image
+    BYTE  bHeight;        // Height of image
+    BYTE  bColorCount;    // Number of colors in image (2, 8, or 16)
+    BYTE  bReserved1;     // Reserved
+    WORD  wXHotspot;      // x coordinate of hotspot
+    WORD  wYHotspot;      // y coordinate of hotspot
+    DWORD dwDIBSize;      // Size of DIB for this image
+    DWORD dwDIBOffset;    // Offset to DIB for this image
+  };
+
+typedef struct tagCURFILERES CURFILERES;
+
+HANDLE  ReadCur( LPSTR szFileName, LPPOINT lpptHotSpot, int *W = 0, int *H = 0);
+HBITMAP ColorDDBToMonoDDB( HBITMAP hbm);
+HCURSOR MakeCursor( HANDLE hDIB, LPPOINT lpptHotSpot, HINSTANCE hInst);
+
+struct tagICONFILEHEADER {
+  WORD wReserved;         // Always 0
+  WORD wResourceType;     // 1 = icon
+  WORD wResourceCount;    // Number of icons in the file
+  };
+
+typedef struct tagICONFILEHEADER ICONFILEHEADER;
+
+struct tagICONFILERES {
+    BYTE  bWidth;         // Width of image
+    BYTE  bHeight;        // Height of image
+    BYTE  bColorCount;    // Number of colors in image (2, 8, or 16)
+    BYTE  bReserved1;     // Reserved
+    WORD  wReserved2;
+    WORD  wReserved3;
+    DWORD dwDIBSize;      // Size of DIB for this image
+    DWORD dwDIBOffset;    // Offset to DIB for this image
+  };
+
+typedef struct tagICONFILERES ICONFILERES;
+
+HANDLE ReadIcon( char *szFileName, int *W = 0, int *H = 0);
+HICON  MakeIcon( HANDLE hDIB, HINSTANCE hInst);
+
diff --git a/include/wx/msw/cursor.h b/include/wx/msw/cursor.h
new file mode 100644
index 0000000000..d3b4473c82
--- /dev/null
+++ b/include/wx/msw/cursor.h
@@ -0,0 +1,69 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        cursor.h
+// Purpose:     wxCursor class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __CURSORH__
+#define __CURSORH__
+
+#ifdef __GNUG__
+#pragma interface "cursor.h"
+#endif
+
+#include "wx/bitmap.h"
+
+class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
+{
+    friend class WXDLLEXPORT wxBitmap;
+    friend class WXDLLEXPORT wxCursor;
+public:
+    wxCursorRefData(void);
+    ~wxCursorRefData(void);
+
+protected:
+  WXHCURSOR m_hCursor;
+  bool m_destroyCursor;
+};
+
+#define M_CURSORDATA ((wxCursorRefData *)m_refData)
+#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
+
+// Cursor
+class WXDLLEXPORT wxCursor: public wxBitmap
+{
+  DECLARE_DYNAMIC_CLASS(wxCursor)
+
+public:
+  wxCursor(void);
+
+  // Copy constructors
+  inline wxCursor(const wxCursor& cursor) { Ref(cursor); }
+  inline wxCursor(const wxCursor* cursor) { /* UnRef(); */ if (cursor) Ref(*cursor); }
+
+  wxCursor(const char bits[], const int width, const int height, const int hotSpotX = -1, const int hotSpotY = -1,
+    const char maskBits[] = NULL);
+  wxCursor(const wxString& name, const long flags = wxBITMAP_TYPE_CUR_RESOURCE,
+   const int hotSpotX = 0, const int hotSpotY = 0);
+  wxCursor(const int cursor_type);
+  ~wxCursor(void);
+
+  virtual bool Ok(void) const { return (m_refData != NULL && M_CURSORDATA->m_hCursor) ; }
+
+  inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
+  inline bool operator == (const wxCursor& cursor) { return m_refData == cursor.m_refData; }
+  inline bool operator != (const wxCursor& cursor) { return m_refData != cursor.m_refData; }
+
+  void SetHCURSOR(WXHCURSOR cursor);
+  inline WXHCURSOR GetHCURSOR(void) const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); }
+
+  bool FreeResource(bool force = FALSE);
+};
+
+#endif
+    // __CURSORH__
diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h
new file mode 100644
index 0000000000..b0c49d268f
--- /dev/null
+++ b/include/wx/msw/dc.h
@@ -0,0 +1,341 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dc.h
+// Purpose:     wxDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DCH__
+#define __DCH__
+
+#ifdef __GNUG__
+#pragma interface "dc.h"
+#endif
+
+#include "wx/pen.h"
+#include "wx/brush.h"
+#include "wx/icon.h"
+#include "wx/font.h"
+#include "wx/gdicmn.h"
+
+class WXDLLEXPORT wxDC: public wxObject
+{
+  DECLARE_ABSTRACT_CLASS(wxDC)
+ protected:
+public:
+  wxDC(void);
+  ~wxDC(void);
+
+  inline void wxDC::BeginDrawing(void) {}
+  inline void wxDC::EndDrawing(void) {}
+
+  virtual void FloodFill(long x1, long y1, wxColour *col, int style=wxFLOOD_SURFACE) ;
+  virtual bool GetPixel(long x1, long y1, wxColour *col) const ;
+
+  virtual void DrawLine(long x1, long y1, long x2, long y2);
+  virtual void CrossHair(long x, long y) ;
+  virtual void DrawArc(long x1,long y1,long x2,long y2,double xc, double yc);
+  virtual void DrawEllipticArc (long x, long y, long w, long h, double sa, double ea);
+  virtual void DrawPoint(long x, long y);
+
+  virtual void DrawLines(int n, wxPoint points[], long xoffset = 0, long yoffset = 0);
+
+  virtual void DrawPolygon(int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE);
+
+  virtual void DrawRectangle(long x, long y, long width, long height);
+  virtual void DrawRoundedRectangle(long x, long y, long width, long height, double radius = 20.0);
+  virtual void DrawEllipse(long x, long y, long width, long height);
+
+  virtual void DrawIcon(const wxIcon& icon, long x, long y);
+
+  virtual void Clear(void);
+  virtual void SetFont(const wxFont& font);
+  virtual void SetPen(const wxPen& pen);
+  virtual void SetBrush(const wxBrush& brush);
+  virtual void SetLogicalFunction(int function);
+  virtual void SetBackground(const wxBrush& brush);
+  virtual void SetBackgroundMode(int mode);
+  virtual void SetClippingRegion(long x, long y, long width, long height);
+  virtual void SetPalette(const wxPalette& palette);
+#if WXWIN_COMPATIBILITY
+  virtual inline void SetColourMap(const wxPalette& palette) { SetPalette(palette); };
+#endif
+  virtual void DestroyClippingRegion(void);
+  virtual void DrawText(const wxString& text, long x, long y, bool use16bit = FALSE);
+
+  virtual long GetCharHeight(void) const;
+  virtual long GetCharWidth(void) const;
+  virtual void GetTextExtent(const wxString& string, long *x, long *y,
+                     long *descent = NULL, long *externalLeading = NULL,
+                     wxFont *theFont = NULL, bool use16bit = FALSE) const;
+#if WXWIN_COMPATIBILITY
+  void GetTextExtent(const wxString& string, float *x, float *y,
+                     float *descent = NULL, float *externalLeading = NULL,
+                     wxFont *theFont = NULL, bool use16bit = FALSE) const ;
+#endif
+
+  // Size in device units
+  virtual void GetSize(int* width, int* height) const;
+  inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); }
+
+  // Size in mm
+  virtual void GetSizeMM(long* width, long* height) const ;
+
+  // Compatibility
+#if WXWIN_COMPATIBILITY
+  inline void GetSize(float* width, float* height) const { int w, h; GetSize(& w, & h); *width = w; *height = h; }
+  inline void GetSizeMM(float *width, float *height) const { long w, h; GetSizeMM(& w, & h); *width = (float) w; *height = (float) h; }
+#endif
+
+  virtual bool StartDoc(const wxString& message);
+  virtual void EndDoc(void);
+  virtual void StartPage(void);
+  virtual void EndPage(void);
+  virtual void SetMapMode(int mode);
+  virtual void SetUserScale(double x, double y);
+  virtual void SetSystemScale(double x, double y);
+  virtual void SetLogicalOrigin(long x, long y);
+  virtual void SetDeviceOrigin(long x, long y);
+
+  // This group of functions does actual conversion
+  // of the input, as you'd expect.
+
+  long DeviceToLogicalX(long x) const;
+  long DeviceToLogicalY(long y) const;
+  long DeviceToLogicalXRel(long x) const;
+  long DeviceToLogicalYRel(long y) const;
+  long LogicalToDeviceX(long x) const;
+  long LogicalToDeviceY(long y) const;
+  long LogicalToDeviceXRel(long x) const;
+  long LogicalToDeviceYRel(long y) const;
+
+  // This group of functions may not do any conversion
+  // if m_scaleGDI is TRUE, since the HDC does the
+  // conversion automatically.
+  // m_scaleGDI NOW OBSOLETE
+  long ImplDeviceToLogicalX(long x) const;
+  long ImplDeviceToLogicalY(long y) const;
+  long ImplDeviceToLogicalXRel(long x) const;
+  long ImplDeviceToLogicalYRel(long y) const;
+  long ImplLogicalToDeviceX(long x) const;
+  long ImplLogicalToDeviceY(long y) const;
+  long ImplLogicalToDeviceXRel(long x) const;
+  long ImplLogicalToDeviceYRel(long y) const;
+
+  virtual bool Blit(long xdest, long ydest, long width, long height,
+            wxDC *source, long xsrc, long ysrc, int rop = wxCOPY, bool useMask = FALSE);
+
+  virtual bool CanDrawBitmap(void) const;
+  virtual bool CanGetTextExtent(void) const;
+
+  //
+  // This function is intended to improves drawing, by avoiding to
+  // repeatly call ::SetPen/::SetBrush. If set to FALSE, these functions
+  // aren't called when calling ::DrawLine(),...
+  // Please note that this is YOUR responsability to use it, and do it
+  // only when you KNOWN that pen/brush isn't changed between 2 calls to
+  // DrawLine,... !!!
+  // Note also that in X, we don't test m_autoSetting on brushes, because they
+  // modify Foreground, as pens. So, convention is:
+  //   - call your SetBrush(), THEN your SetPen, THEN AutoSetTools(FALSE)
+  //   - call DrawLine,...
+  // [mainly coded for Windows]
+  inline virtual void AutoSetTools(bool auto_setting) { m_autoSetting = auto_setting ; }
+  inline virtual void DrawPoint(wxPoint& point) { DrawPoint(point.x, point.y); }
+  virtual void DrawLines(wxList *list, long xoffset = 0, long yoffset = 0);
+  virtual void DrawPolygon(wxList *list, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE);
+#if USE_SPLINES
+  // Splines
+  // 3-point spline
+  virtual void DrawSpline(long x1, long y1, long x2, long y2, long x3, long y3);
+  // Any number of control points - a list of pointers to wxPoints
+  virtual void DrawSpline(wxList *points);
+  virtual void DrawSpline(int n, wxPoint points[]);
+#endif
+  virtual void SetTextForeground(const wxColour& colour);
+  virtual void SetTextBackground(const wxColour& colour);
+  inline virtual bool Ok(void) const {return m_ok;};
+  inline virtual int  GetMapMode(void) const {return m_mappingMode;};
+
+  inline virtual wxBrush *GetBackground(void) const { return (wxBrush*) &m_backgroundBrush ;}
+  inline virtual wxBrush *GetBrush(void) const { return (wxBrush*) &m_brush ;}
+  inline virtual wxFont  *GetFont(void) const { return (wxFont*) &m_font ;}
+  inline virtual int      GetLogicalFunction(void) const { return m_logicalFunction ;}
+  inline virtual wxPen   *GetPen(void) const { return (wxPen*) &m_pen ;}
+  inline virtual wxColour&GetTextBackground(void) const { return (wxColour&) m_textBackgroundColour ;}
+  inline virtual wxColour&GetTextForeground(void) const { return (wxColour&) m_textForegroundColour ;}
+
+  virtual void SetLogicalScale(double x, double y);
+  virtual inline  void GetUserScale(double* x, double *y) const { *x = m_userScaleX; *y = m_userScaleY; }
+  virtual void CalcBoundingBox(long x, long y);
+  // Get the final bounding box of the PostScript or Metafile picture.
+  virtual inline long MinX(void) const { return m_minX; }
+  virtual inline long MaxX(void) const { return m_maxX; }
+  virtual inline long MinY(void) const { return m_minY; }
+  virtual inline long MaxY(void) const { return m_maxY; }
+  // Sometimes we need to override optimization, e.g.
+  // if other software is drawing onto our surface and we
+  // can't be sure of who's done what.
+  virtual inline void SetOptimization(bool WXUNUSED(opt)) { }
+  virtual inline bool GetOptimization(void) { return FALSE; }
+
+  virtual void GetClippingBox(long *x,long *y,long *w,long *h) const ;
+
+  virtual void SetRop(WXHDC cdc);
+  virtual void DoClipping(WXHDC cdc);
+  virtual void SelectOldObjects(WXHDC dc);
+
+  inline wxWindow *GetWindow(void) const { return m_canvas; }
+  inline void SetWindow(wxWindow *win) { m_canvas = win; }
+  inline WXHDC GetHDC(void) const { return m_hDC; }
+  inline void SetHDC(WXHDC dc, bool bOwnsDC = FALSE) { m_hDC = dc; m_bOwnsDC = bOwnsDC; }
+  inline bool GetAutoSetting(void) const { return m_autoSetting; }
+
+//  inline bool GetScaleGDI(void) const { return m_scaleGDI; }
+//  inline void SetScaleGDI(bool flag) { m_scaleGDI = flag; }
+
+protected:
+  bool              m_colour;
+  bool              m_ok;
+  bool              m_clipping;
+  bool              m_isInteractive;
+
+  // Coordinate system variables
+  long             m_logicalOriginX;
+  long             m_logicalOriginY;
+
+  long             m_deviceOriginX;
+  long             m_deviceOriginY;
+
+  double             m_logicalScaleX;
+  double             m_logicalScaleY;
+
+  double             m_userScaleX;
+  double             m_userScaleY;
+
+  int               m_mappingMode;
+
+  long             m_minX;          // bounding box
+  long             m_minY;
+  long             m_maxX;
+  long             m_maxY;
+
+  int               m_logicalFunction;
+  int               m_backgroundMode;
+
+  wxPen             m_pen;
+  wxBrush           m_brush;
+  wxBrush           m_backgroundBrush;
+  wxColour          m_textForegroundColour;
+  wxColour          m_textBackgroundColour;
+  wxFont            m_font;
+  wxPalette         m_palette;
+  bool              m_autoSetting ;
+  int               m_clipX1;
+  int               m_clipY1;
+  int               m_clipX2;
+  int               m_clipY2;
+//  bool              m_dontDelete;
+  int               m_windowExtX;
+  int               m_windowExtY;
+  double            m_systemScaleX;
+  double            m_systemScaleY;
+
+  wxWindow *        m_canvas;
+  wxBitmap          m_selectedBitmap;
+  wxString          m_filename;
+
+  // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
+  bool              m_bOwnsDC;
+
+  WXHDC             m_hDC;
+  int               m_hDCCount;
+
+  // Store all old GDI objects when do a SelectObject,
+  // so we can select them back in (this unselecting user's
+  // objects) so we can safely delete the DC.
+  WXHBITMAP         m_oldBitmap;
+  WXHPEN            m_oldPen;
+  WXHBRUSH          m_oldBrush;
+  WXHFONT           m_oldFont;
+  WXHPALETTE        m_oldPalette;
+
+  // Stores scaling, translation, rotation
+//  wxTransformMatrix	m_transformMatrix;
+
+  // Do we wish to scale GDI objects too, e.g. pen width?
+//  bool				m_scaleGDI;
+};
+
+// Logical to device
+// Absolute
+#define XLOG2DEV(x) ImplLogicalToDeviceX(x)
+
+#define YLOG2DEV(y) ImplLogicalToDeviceY(y)
+
+// Relative
+#define XLOG2DEVREL(x) ImplLogicalToDeviceXRel(x)
+#define YLOG2DEVREL(y) ImplLogicalToDeviceYRel(y)
+
+// Device to logical
+// Absolute
+#define XDEV2LOG(x) ImplDeviceToLogicalX(x)
+
+#define YDEV2LOG(y) ImplDeviceToLogicalY(y)
+
+// Relative
+#define XDEV2LOGREL(x) ImplDeviceToLogicalXRel(x)
+#define YDEV2LOGREL(y) ImplDeviceToLogicalYRel(y)
+
+/*
+ * Have the same macros as for XView but not for every operation:
+ * just for calculating window/viewport extent (a better way of scaling).
+ */
+
+// Logical to device
+// Absolute
+#define MS_XLOG2DEV(x) LogicalToDevice(x)
+
+#define MS_YLOG2DEV(y) LogicalToDevice(y)
+
+// Relative
+#define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
+#define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
+
+// Device to logical
+// Absolute
+#define MS_XDEV2LOG(x) DeviceToLogicalX(x)
+
+#define MS_YDEV2LOG(y) DeviceToLogicalY(y)
+
+// Relative
+#define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
+#define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
+
+#define MM_POINTS      7
+#define MM_METRIC      8
+
+extern int wxPageNumber;
+
+// Conversion
+#define METRIC_CONVERSION_CONSTANT  0.0393700787
+
+// Scaling factors for various unit conversions
+#define mm2inches (METRIC_CONVERSION_CONSTANT)
+#define inches2mm (1/METRIC_CONVERSION_CONSTANT)
+
+#define mm2twips (METRIC_CONVERSION_CONSTANT*1440)
+#define twips2mm (1/(METRIC_CONVERSION_CONSTANT*1440))
+
+#define mm2pt (METRIC_CONVERSION_CONSTANT*72)
+#define pt2mm (1/(METRIC_CONVERSION_CONSTANT*72))
+
+#define     wx_round(a)    (int)((a)+.5)
+
+
+#endif
+    // __DCH__
diff --git a/include/wx/msw/dcclient.h b/include/wx/msw/dcclient.h
new file mode 100644
index 0000000000..05743e7ec3
--- /dev/null
+++ b/include/wx/msw/dcclient.h
@@ -0,0 +1,65 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dcclient.h
+// Purpose:     wxClientDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DCCLIENTH__
+#define __DCCLIENTH__
+
+#ifdef __GNUG__
+#pragma interface "dcclient.h"
+#endif
+
+#include "wx/dc.h"
+
+class WXDLLEXPORT wxClientDC: public wxDC
+{
+  DECLARE_DYNAMIC_CLASS(wxClientDC)
+
+ public:
+  wxClientDC(void);
+
+  // Create a DC corresponding to a canvas
+  wxClientDC(wxWindow *win);
+
+  ~wxClientDC(void);
+};
+
+class WXDLLEXPORT wxWindowDC: public wxDC
+{
+  DECLARE_DYNAMIC_CLASS(wxWindowDC)
+
+ public:
+  wxWindowDC(void);
+
+  // Create a DC corresponding to a canvas
+  wxWindowDC(wxWindow *win);
+
+  ~wxWindowDC(void);
+};
+
+class WXDLLEXPORT wxPaintDC: public wxDC
+{
+  DECLARE_DYNAMIC_CLASS(wxPaintDC)
+
+ public:
+  wxPaintDC(void);
+
+  // Create a DC corresponding to a canvas
+  wxPaintDC(wxWindow *win);
+
+  ~wxPaintDC(void);
+
+ protected:
+    static WXHDC m_staticPaintHDC ;
+    static int m_staticPaintCount ;
+};
+
+#endif
+    // __DCCLIENTH__
diff --git a/include/wx/msw/dcmemory.h b/include/wx/msw/dcmemory.h
new file mode 100644
index 0000000000..7039c610c1
--- /dev/null
+++ b/include/wx/msw/dcmemory.h
@@ -0,0 +1,35 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dcmemory.h
+// Purpose:     wxMemoryDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DCMEMORYH__
+#define __DCMEMORYH__
+
+#ifdef __GNUG__
+#pragma interface "dcmemory.h"
+#endif
+
+#include "wx/dcclient.h"
+
+class WXDLLEXPORT wxMemoryDC: public wxDC
+{
+  DECLARE_DYNAMIC_CLASS(wxMemoryDC)
+
+ public:
+  wxMemoryDC(void);
+  wxMemoryDC(wxDC *dc); // Create compatible DC
+
+  ~wxMemoryDC(void);
+  virtual void SelectObject(const wxBitmap& bitmap);
+  virtual void GetSize(int* width, int* height) const;
+};
+
+#endif
+    // __DCMEMORYH__
diff --git a/include/wx/msw/dcprint.h b/include/wx/msw/dcprint.h
new file mode 100644
index 0000000000..dc434d0f93
--- /dev/null
+++ b/include/wx/msw/dcprint.h
@@ -0,0 +1,38 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dcprint.h
+// Purpose:     wxPrinterDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DCPRINTH__
+#define __DCPRINTH__
+
+#ifdef __GNUG__
+#pragma interface "dcprint.h"
+#endif
+
+#include "wx/dc.h"
+
+class WXDLLEXPORT wxPrinterDC: public wxDC
+{
+ public:
+  DECLARE_CLASS(wxPrinterDC)
+
+  // Create a printer DC
+  wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, const bool interactive = TRUE, const int orientation = wxPORTRAIT);
+  wxPrinterDC(WXHDC theDC);
+
+  ~wxPrinterDC(void);
+};
+
+// Gets an HDC for the default printer configuration
+WXHDC WXDLLEXPORT wxGetPrinterDC(int orientation);
+
+#endif
+    // __DCPRINTH__
+
diff --git a/include/wx/msw/dcscreen.h b/include/wx/msw/dcscreen.h
new file mode 100644
index 0000000000..16c1528169
--- /dev/null
+++ b/include/wx/msw/dcscreen.h
@@ -0,0 +1,39 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dcscreen.h
+// Purpose:     wxScreenDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DCSCREENH__
+#define __DCSCREENH__
+
+#ifdef __GNUG__
+#pragma interface "dcscreen.h"
+#endif
+
+#include "wx/dc.h"
+
+class WXDLLEXPORT wxScreenDC: public wxDC
+{
+  DECLARE_DYNAMIC_CLASS(wxScreenDC)
+
+ public:
+  // Create a DC representing the whole screen
+  wxScreenDC(void);
+  ~wxScreenDC(void);
+
+  // Compatibility with X's requirements for
+  // drawing on top of all windows
+  static bool StartDrawingOnTop(wxWindow *window) { return TRUE; }
+  static bool StartDrawingOnTop(wxRectangle *rect = NULL) { return TRUE; }
+  static bool EndDrawingOnTop(void) { return TRUE; }
+};
+
+#endif
+    // __DCSCREENH__
+
diff --git a/include/wx/msw/dde.h b/include/wx/msw/dde.h
new file mode 100644
index 0000000000..2fdd0ec99a
--- /dev/null
+++ b/include/wx/msw/dde.h
@@ -0,0 +1,161 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dde.h
+// Purpose:     DDE class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DDEH__
+#define __DDEH__
+
+#ifdef __GNUG__
+#pragma interface "dde.h"
+#endif
+
+#include "wx/ipcbase.h"
+
+/*
+ * Mini-DDE implementation
+
+   Most transactions involve a topic name and an item name (choose these
+   as befits your application).
+
+   A client can:
+
+   - ask the server to execute commands (data) associated with a topic
+   - request data from server by topic and item
+   - poke data into the server
+   - ask the server to start an advice loop on topic/item
+   - ask the server to stop an advice loop
+
+   A server can:
+
+   - respond to execute, request, poke and advice start/stop
+   - send advise data to client
+
+   Note that this limits the server in the ways it can send data to the
+   client, i.e. it can't send unsolicited information.
+ *
+ */
+
+class WXDLLEXPORT wxDDEServer;
+class WXDLLEXPORT wxDDEClient;
+
+class WXDLLEXPORT wxDDEConnection: public wxConnectionBase
+{
+  DECLARE_DYNAMIC_CLASS(wxDDEConnection)
+ public:
+  char *buf_ptr;
+  wxString topic_name;
+  int buf_size;
+  wxDDEServer *server;
+  wxDDEClient *client;
+
+  WXHCONV hConv;
+  char *sending_data;
+  int data_size;
+  int data_type;
+
+  wxDDEConnection(char *buffer, int size);
+  wxDDEConnection(void);
+  ~wxDDEConnection(void);
+
+  // Calls that CLIENT can make
+  virtual bool Execute(char *data, int size = -1, int format = wxCF_TEXT);
+  virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxCF_TEXT); }
+  virtual char *Request(const wxString& item, int *size = NULL, int format = wxCF_TEXT);
+  virtual bool Poke(const wxString& item, char *data, int size = -1, int format = wxCF_TEXT);
+  virtual bool StartAdvise(const wxString& item);
+  virtual bool StopAdvise(const wxString& item);
+
+  // Calls that SERVER can make
+  virtual bool Advise(const wxString& item, char *data, int size = -1, int format = wxCF_TEXT);
+
+  // Calls that both can make
+  virtual bool Disconnect(void);
+
+  // Callbacks to SERVER - override at will
+  virtual bool OnExecute(const wxString& topic, char *data, int size, int format) { return FALSE; };
+  virtual char *OnRequest(const wxString& topic, const wxString& item, int *size, int format) { return NULL; };
+  virtual bool OnPoke(const wxString& topic, const wxString& item, char *data, int size, int format) { return FALSE; };
+  virtual bool OnStartAdvise(const wxString& topic, const wxString& item) { return FALSE; };
+  virtual bool OnStopAdvise(const wxString& topic, const wxString& item) { return FALSE; };
+
+  // Callbacks to CLIENT - override at will
+  virtual bool OnAdvise(const wxString& topic, const wxString& item, char *data, int size, int format) { return FALSE; };
+
+  // Callbacks to BOTH
+
+  // Default behaviour is to delete connection and return TRUE
+  virtual bool OnDisconnect(void);
+};
+
+class WXDLLEXPORT wxDDEServer: public wxServerBase
+{
+  DECLARE_DYNAMIC_CLASS(wxDDEServer)
+ public:
+
+  wxDDEServer(void);
+  ~wxDDEServer(void);
+  bool Create(const wxString& server_name); // Returns FALSE if can't create server (e.g. port
+                                  // number is already in use)
+  virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
+
+  ////////////////////////////////////////////////////////////
+  // Implementation
+
+  // Find/delete wxDDEConnection corresponding to the HCONV
+  wxDDEConnection *FindConnection(WXHCONV conv);
+  bool DeleteConnection(WXHCONV conv);
+  inline wxString& GetServiceName(void) const { return (wxString&) service_name; }
+  inline wxList& GetConnections(void) const { return (wxList&) connections; }
+
+ protected:
+  int lastError;
+  wxString service_name;
+  wxList connections;
+};
+
+class WXDLLEXPORT wxDDEClient: public wxClientBase
+{
+  DECLARE_DYNAMIC_CLASS(wxDDEClient)
+ public:
+  wxDDEClient(void);
+  ~wxDDEClient(void);
+  bool ValidHost(const wxString& host);
+  virtual wxConnectionBase *MakeConnection(const wxString& host, const wxString& server, const wxString& topic);
+                                                // Call this to make a connection.
+                                                // Returns NULL if cannot.
+  virtual wxConnectionBase *OnMakeConnection(void); // Tailor this to return own connection.
+
+  ////////////////////////////////////////////////////////////
+  // Implementation
+
+  // Find/delete wxDDEConnection corresponding to the HCONV
+  wxDDEConnection *FindConnection(WXHCONV conv);
+  bool DeleteConnection(WXHCONV conv);
+  inline wxList& GetConnections(void) const { return (wxList&) connections; }
+
+ protected:
+  int lastError;
+  wxList connections;
+};
+
+void WXDLLEXPORT wxDDEInitialize();
+void WXDLLEXPORT wxDDECleanUp();
+
+// Compatibility
+#if WXWIN_COMPATIBILITY
+#define wxServer wxDDEServer
+#define wxClient wxDDEClient
+#define wxConnection wxDDEConnection
+#define wxIPCInitialize wxDDEInitialize
+#define wxIPCCleanUp wxDDECleanUp
+#endif
+
+#endif
+    // __DDEH__
diff --git a/include/wx/msw/dialog.h b/include/wx/msw/dialog.h
new file mode 100644
index 0000000000..f3e9616d92
--- /dev/null
+++ b/include/wx/msw/dialog.h
@@ -0,0 +1,118 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dialog.h
+// Purpose:     wxDialog class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DIALOGH__
+#define __DIALOGH__
+
+#ifdef __GNUG__
+#pragma interface "dialog.h"
+#endif
+
+#include "wx/panel.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr;
+
+// Dialog boxes
+class WXDLLEXPORT wxDialog: public wxPanel
+{
+  DECLARE_DYNAMIC_CLASS(wxDialog)
+ protected:
+  bool m_modalShowing;
+public:
+
+  wxDialog(void);
+
+  // Constructor with a modal flag, but no window id - the old convention
+  inline wxDialog(wxWindow *parent,
+           const wxString& title, bool modal,
+           const int x = -1, const int y= -1, const int width = 500, const int height = 500,
+           const long style = wxDEFAULT_DIALOG_STYLE,
+           const wxString& name = wxDialogNameStr)
+  {
+      long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ;
+      Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), style|modalStyle, name);
+  }
+
+  // Constructor with no modal flag - the new convention.
+  inline wxDialog(wxWindow *parent, const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxDEFAULT_DIALOG_STYLE,
+           const wxString& name = wxDialogNameStr)
+  {
+      Create(parent, id, title, pos, size, style, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxString& title, // bool modal = FALSE, // TODO make this a window style?
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxDEFAULT_DIALOG_STYLE,
+           const wxString& name = wxDialogNameStr);
+
+  ~wxDialog(void);
+
+  virtual bool Destroy(void);
+  void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+  void SetClientSize(const int width, const int height);
+  void GetPosition(int *x, int *y) const;
+  bool Show(const bool show);
+  bool IsShown(void) const ;
+  void Iconize(const bool iconize);
+
+#if WXWIN_COMPATIBILITY
+  inline bool Iconized(void) const { return IsIconized(); };
+#endif
+
+  virtual bool IsIconized(void) const;
+  void Fit(void);
+
+  void SetTitle(const wxString& title);
+  wxString GetTitle(void) const ;
+
+  bool OnClose(void);
+  void OnCharHook(wxKeyEvent& event);
+  void OnPaint(wxPaintEvent& event);
+  void OnCloseWindow(wxCloseEvent& event);
+
+  void SetModal(const bool flag);
+
+  virtual void Centre(const int direction = wxBOTH);
+  virtual bool IsModal(void) const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
+
+  // For now, same as Show(TRUE) but returns return code
+  virtual int ShowModal(void);
+  virtual void EndModal(int retCode);
+
+  // Standard buttons
+  void OnOK(wxCommandEvent& event);
+  void OnApply(wxCommandEvent& event);
+  void OnCancel(wxCommandEvent& event);
+
+  // Responds to colour changes
+  void OnSysColourChanged(wxSysColourChangedEvent& event);
+
+  // IMPLEMENTATION
+  virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+  virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+  virtual bool MSWProcessMessage(WXMSG* pMsg);
+//  virtual bool MSWOnEraseBkgnd(WXHDC pDC);
+  virtual bool MSWOnClose(void);
+  inline bool IsModalShowing() const { return m_modalShowing ; }
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+  			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+DECLARE_EVENT_TABLE()
+};
+
+#endif
+    // __DIALOGH__
diff --git a/include/wx/msw/dib.h b/include/wx/msw/dib.h
new file mode 100644
index 0000000000..754651fb83
--- /dev/null
+++ b/include/wx/msw/dib.h
@@ -0,0 +1,26 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dib.h
+// Purpose:     Routines for loading and saving DIBs
+// Author:      Various
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+// Save (device dependent) wxBitmap as a DIB
+bool             wxSaveBitmap(char *filename, wxBitmap *bitmap, wxColourMap *colourmap = NULL);
+
+// Load device independent bitmap into device dependent bitmap
+wxBitmap         *wxLoadBitmap(char *filename, wxColourMap **colourmap = NULL);
+
+// Load into existing bitmap;
+bool wxLoadIntoBitmap(char *filename, wxBitmap *bitmap, wxColourMap **pal = NULL);
+
+HANDLE BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal);
+BOOL   ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette);
+HANDLE ReadDIB2(LPSTR lpFileName);
+LPSTR FindDIBBits (LPSTR lpbi);
+HPALETTE MakeDIBPalette(LPBITMAPINFOHEADER lpInfo);
+
diff --git a/include/wx/msw/dibutils.h b/include/wx/msw/dibutils.h
new file mode 100644
index 0000000000..b43d4fab2f
--- /dev/null
+++ b/include/wx/msw/dibutils.h
@@ -0,0 +1,131 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dibutils.h
+// Purpose:     Utilities for DIBs
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Microsoft, Julian Smart
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+/***************************************************************************
+
+    (C) Copyright 1994 Microsoft Corp.  All rights reserved.
+
+    You have a royalty-free right to use, modify, reproduce and 
+    distribute the Sample Files (and/or any modified version) in 
+    any way you find useful, provided that you agree that 
+	 Microsoft has no warranty obligations or liability for any
+    Sample Application Files which are modified. 
+
+ **************************************************************************/
+
+/***************************************************************************
+    Functions for handling Device Independent Bitmaps and clearing the 
+	 System Palette.
+ **************************************************************************/
+
+#ifndef SAMPLES_UTILS_H  
+#define SAMPLES_UTILS_H
+
+#ifdef __GNUG__
+#pragma interface "dibutils.h"
+#endif
+
+typedef     LPBITMAPINFOHEADER PDIB;
+typedef     HANDLE             HDIB;
+
+/***************************************************************************
+   External function declarations
+ **************************************************************************/
+
+void        ClearSystemPalette(void);
+PDIB        DibOpenFile(LPSTR szFile);  
+int 			DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi);
+BOOL        DibSetUsage(PDIB pdib, HPALETTE hpal,UINT wUsage);
+PDIB        DibCreate(int bits, int dx, int dy);
+BOOL        DibMapToPalette(PDIB pdib, HPALETTE hpal);
+HPALETTE MakePalette(const BITMAPINFO FAR* Info, UINT flags);
+
+/****************************************************************************
+   Internal function declarations
+ ***************************************************************************/
+
+PDIB        DibReadBitmapInfo(HFILE fh);
+
+/****************************************************************************
+   DIB macros.
+ ***************************************************************************/
+
+#ifdef  WIN32
+	 #define HandleFromDib(lpbi) GlobalHandle(lpbi)
+#else
+    #define HandleFromDib(lpbi) (HANDLE)GlobalHandle(SELECTOROF(lpbi))
+#endif
+
+#define DibFromHandle(h)        (PDIB)GlobalLock(h)
+
+#define DibFree(pdib)           GlobalFreePtr(pdib)
+
+#define WIDTHBYTES(i)           ((unsigned)((i+31)&(~31))/8)  /* ULONG aligned ! */
+
+#define DibWidth(lpbi)          (UINT)(((LPBITMAPINFOHEADER)(lpbi))->biWidth)
+#define DibHeight(lpbi)         (UINT)(((LPBITMAPINFOHEADER)(lpbi))->biHeight)
+#define DibBitCount(lpbi)       (UINT)(((LPBITMAPINFOHEADER)(lpbi))->biBitCount)
+#define DibCompression(lpbi)    (DWORD)(((LPBITMAPINFOHEADER)(lpbi))->biCompression)
+
+#define DibWidthBytesN(lpbi, n) (UINT)WIDTHBYTES((UINT)(lpbi)->biWidth * (UINT)(n))
+#define DibWidthBytes(lpbi)     DibWidthBytesN(lpbi, (lpbi)->biBitCount)
+
+#define DibSizeImage(lpbi)      ((lpbi)->biSizeImage == 0 \
+                                    ? ((DWORD)(UINT)DibWidthBytes(lpbi) * (DWORD)(UINT)(lpbi)->biHeight) \
+                                    : (lpbi)->biSizeImage)
+
+#define DibSize(lpbi)           ((lpbi)->biSize + (lpbi)->biSizeImage + (int)(lpbi)->biClrUsed * sizeof(RGBQUAD))
+#define DibPaletteSize(lpbi)    (DibNumColors(lpbi) * sizeof(RGBQUAD))
+
+#define DibFlipY(lpbi, y)       ((int)(lpbi)->biHeight-1-(y))
+
+//HACK for NT BI_BITFIELDS DIBs
+#ifdef WIN32
+    #define DibPtr(lpbi)            ((lpbi)->biCompression == BI_BITFIELDS \
+                                       ? (LPVOID)(DibColors(lpbi) + 3) \
+                                       : (LPVOID)(DibColors(lpbi) + (UINT)(lpbi)->biClrUsed))
+#else
+	 #define DibPtr(lpbi)            (LPVOID)(DibColors(lpbi) + (UINT)(lpbi)->biClrUsed)
+#endif
+
+#define DibColors(lpbi)         ((RGBQUAD FAR *)((LPBYTE)(lpbi) + (int)(lpbi)->biSize))
+
+#define DibNumColors(lpbi)      ((lpbi)->biClrUsed == 0 && (lpbi)->biBitCount <= 8 \
+                                    ? (int)(1 << (int)(lpbi)->biBitCount)          \
+                                    : (int)(lpbi)->biClrUsed)
+
+#define DibXYN(lpbi,pb,x,y,n)   (LPVOID)(                                     \
+                                (BYTE _huge *)(pb) +                          \
+                                (UINT)((UINT)(x) * (UINT)(n) / 8u) +          \
+                                ((DWORD)DibWidthBytesN(lpbi,n) * (DWORD)(UINT)(y)))
+
+#define DibXY(lpbi,x,y)         DibXYN(lpbi,DibPtr(lpbi),x,y,(lpbi)->biBitCount)
+
+#define FixBitmapInfo(lpbi)     if ((lpbi)->biSizeImage == 0)                 \
+												(lpbi)->biSizeImage = DibSizeImage(lpbi); \
+                                if ((lpbi)->biClrUsed == 0)                   \
+                                    (lpbi)->biClrUsed = DibNumColors(lpbi);   \
+                                if ((lpbi)->biCompression == BI_BITFIELDS && (lpbi)->biClrUsed == 0) \
+                                    ; // (lpbi)->biClrUsed = 3;                    
+
+#define DibInfo(pDIB)     ((BITMAPINFO FAR *)(pDIB))
+
+/***************************************************************************/
+
+#ifndef BI_BITFIELDS
+  #define BI_BITFIELDS 3
+#endif  
+
+#ifndef HALFTONE
+  #define HALFTONE COLORONCOLOR
+#endif
+
+#endif
diff --git a/include/wx/msw/dirdlg.h b/include/wx/msw/dirdlg.h
new file mode 100644
index 0000000000..bbe29b3de5
--- /dev/null
+++ b/include/wx/msw/dirdlg.h
@@ -0,0 +1,47 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dirdlg.h
+// Purpose:     wxDirDialog class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DIRDLGH__
+#define __DIRDLGH__
+
+#ifdef __GNUG__
+#pragma interface "dirdlg.h"
+#endif
+
+#include "wx/dialog.h"
+
+class WXDLLEXPORT wxDirDialog: public wxDialog
+{
+DECLARE_DYNAMIC_CLASS(wxDirDialog)
+public:
+    wxDirDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr,
+        const wxString& defaultPath = "",
+        long style = 0, const wxPoint& pos = wxDefaultPosition);
+
+    inline void SetMessage(const wxString& message) { m_message = message; }
+    inline void SetPath(const wxString& path) { m_path = path; }
+    inline void SetStyle(long style) { m_dialogStyle = style; }
+
+    inline wxString GetMessage(void) const { return m_message; }
+    inline wxString GetPath(void) const { return m_path; }
+    inline long GetStyle(void) const { return m_dialogStyle; }
+
+    int ShowModal(void);
+
+protected:
+    wxString    m_message;
+    long        m_dialogStyle;
+    wxWindow *  m_parent;
+    wxString    m_path;
+};
+
+#endif
+    // __DIRDLGH__
diff --git a/include/wx/msw/disable.bmp b/include/wx/msw/disable.bmp
new file mode 100644
index 0000000000000000000000000000000000000000..8859e1b9ae0aae4441e0c2322ee0a5e16f855f36
GIT binary patch
literal 630
zcmZ?rEn{K;gEAng0mKSW%*en3WZ?r13=BZT(9i&(fFzK~aNxiJAPtiE4@M0C|ASaS
d41^#dAW?t@*wFx*bOD+)`=~r>2n@CG0RV<jjUNC2

literal 0
HcmV?d00001

diff --git a/include/wx/msw/filedlg.h b/include/wx/msw/filedlg.h
new file mode 100644
index 0000000000..f9c6ecafc2
--- /dev/null
+++ b/include/wx/msw/filedlg.h
@@ -0,0 +1,88 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        filedlg.h
+// Purpose:     wxFileDialog class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __FILEDLGH__
+#define __FILEDLGH__
+
+#ifdef __GNUG__
+#pragma interface "filedlg.h"
+#endif
+
+#include "wx/dialog.h"
+
+/*
+ * File selector
+ */
+
+WXDLLEXPORT_DATA(extern const char*) wxFileSelectorPromptStr;
+WXDLLEXPORT_DATA(extern const char*) wxFileSelectorDefaultWildcardStr;
+
+class WXDLLEXPORT wxFileDialog: public wxDialog
+{
+DECLARE_DYNAMIC_CLASS(wxFileDialog)
+protected:
+    wxString    m_message;
+    long        m_dialogStyle;
+    wxWindow *  m_parent;
+    wxString    m_dir;
+    wxString    m_path; // Full path
+    wxString    m_fileName;
+    wxString    m_wildCard;
+    int         m_filterIndex;
+public:
+    wxFileDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr,
+        const wxString& defaultDir = "", const wxString& defaultFile = "", const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
+        long style = 0, const wxPoint& pos = wxDefaultPosition);
+
+    inline void SetMessage(const wxString& message) { m_message = message; }
+    inline void SetPath(const wxString& path) { m_path = path; }
+    inline void SetDirectory(const wxString& dir) { m_dir = dir; }
+    inline void SetFilename(const wxString& name) { m_fileName = name; }
+    inline void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
+    inline void SetStyle(long style) { m_dialogStyle = style; }
+    inline void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
+
+    inline wxString GetMessage(void) const { return m_message; }
+    inline wxString GetPath(void) const { return m_path; }
+    inline wxString GetDirectory(void) const { return m_dir; }
+    inline wxString GetFilename(void) const { return m_fileName; }
+    inline wxString GetWildcard(void) const { return m_wildCard; }
+    inline long GetStyle(void) const { return m_dialogStyle; }
+    inline int GetFilterIndex(void) const { return m_filterIndex ; }
+
+    int ShowModal(void);
+};
+
+#define wxOPEN 1
+#define wxSAVE 2
+#define wxOVERWRITE_PROMPT 4
+#define wxHIDE_READONLY 8
+
+// File selector - backward compatibility
+char* WXDLLEXPORT wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
+                     const char *default_filename = NULL, const char *default_extension = NULL,
+                     const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
+                     wxWindow *parent = NULL, int x = -1, int y = -1);
+
+// An extended version of wxFileSelector
+char* WXDLLEXPORT wxFileSelectorEx(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
+                     const char *default_filename = NULL, int *indexDefaultExtension = NULL,
+                     const char *wildcard = wxFileSelectorDefaultWildcardStr, const int flags = 0,
+                     wxWindow *parent = NULL, const int x = -1, const int y = -1);
+
+// Generic file load dialog
+char* WXDLLEXPORT wxLoadFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
+
+// Generic file save dialog
+char* WXDLLEXPORT wxSaveFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
+
+#endif
+    // __FILEDLGH__
diff --git a/include/wx/msw/font.h b/include/wx/msw/font.h
new file mode 100644
index 0000000000..2ed2b248f1
--- /dev/null
+++ b/include/wx/msw/font.h
@@ -0,0 +1,98 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        font.h
+// Purpose:     wxFont class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __FONTH__
+#define __FONTH__
+
+#ifdef __GNUG__
+#pragma interface "font.h"
+#endif
+
+#include "wx/gdiobj.h"
+
+class WXDLLEXPORT wxFont;
+
+class WXDLLEXPORT wxFontRefData: public wxGDIRefData
+{
+    friend class WXDLLEXPORT wxFont;
+public:
+    wxFontRefData(void);
+    ~wxFontRefData(void);
+protected:
+  bool          m_temporary;   // If TRUE, the pointer to the actual font
+                               // is temporary and SHOULD NOT BE DELETED by
+                               // destructor
+  int           m_pointSize;
+  int           m_family;
+  int           m_fontId;
+  int           m_style;
+  int           m_weight;
+  bool          m_underlined;
+  wxString      m_faceName;
+  WXHFONT       m_hFont;
+
+};
+
+#define M_FONTDATA ((wxFontRefData *)m_refData)
+
+WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
+
+// Font
+class WXDLLEXPORT wxFont: public wxGDIObject
+{
+  DECLARE_DYNAMIC_CLASS(wxFont)
+public:
+  wxFont(void);
+  wxFont(int PointSize, int Family, int Style, int Weight, bool underlined = FALSE, const wxString& Face = wxEmptyString);
+  inline wxFont(const wxFont& font) { Ref(font); }
+  inline wxFont(const wxFont* font) { /* UnRef(); */ if (font) Ref(*font); }
+
+  ~wxFont(void);
+
+  bool Create(int PointSize, int Family, int Style, int Weight, bool underlined = FALSE, const wxString& Face = wxEmptyString);
+
+  // Internal
+  virtual bool RealizeResource(void);
+  virtual WXHANDLE GetResourceHandle(void) ;
+  virtual bool FreeResource(bool force = FALSE);
+/*
+  virtual bool UseResource(void);
+  virtual bool ReleaseResource(void);
+*/
+
+  virtual bool IsFree(void);
+  virtual bool Ok(void) const { return (m_refData != NULL) ; }
+
+  inline int GetPointSize(void) const { return M_FONTDATA->m_pointSize; }
+  inline int GetFamily(void) const { return M_FONTDATA->m_family; }
+  inline int GetFontId(void) const { return M_FONTDATA->m_fontId; } /* New font system */
+  inline int GetStyle(void) const { return M_FONTDATA->m_style; }
+  inline int GetWeight(void) const { return M_FONTDATA->m_weight; }
+  wxString GetFamilyString(void) const ;
+  wxString GetFaceName(void) const ;
+  wxString GetStyleString(void) const ;
+  wxString GetWeightString(void) const ;
+  inline bool GetUnderlined(void) const { return M_FONTDATA->m_underlined; }
+
+  void SetPointSize(const int pointSize);
+  void SetFamily(const int family);
+  void SetStyle(const int style);
+  void SetWeight(const int weight);
+  void SetFaceName(const wxString& faceName);
+  void SetUnderlined(const bool underlined);
+
+  inline wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; }
+  inline bool operator == (const wxFont& font) { return m_refData == font.m_refData; }
+  inline bool operator != (const wxFont& font) { return m_refData != font.m_refData; }
+};
+
+#endif
+    // __FONTH__
diff --git a/include/wx/msw/fontdlg.h b/include/wx/msw/fontdlg.h
new file mode 100644
index 0000000000..9ef6c77751
--- /dev/null
+++ b/include/wx/msw/fontdlg.h
@@ -0,0 +1,44 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        fontdlg.h
+// Purpose:     wxFontDialog class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __FONTDLGH__
+#define __FONTDLGH__
+
+#ifdef __GNUG__
+#pragma interface "fontdlg.h"
+#endif
+
+#include "wx/dialog.h"
+#include "wx/cmndata.h"
+
+/*
+ * FONT DIALOG
+ */
+ 
+class WXDLLEXPORT wxFontDialog: public wxDialog
+{
+ DECLARE_DYNAMIC_CLASS(wxFontDialog)
+ protected:
+  wxWindow *dialogParent;
+  wxFontData fontData;
+ public:
+  wxFontDialog(void);
+  wxFontDialog(wxWindow *parent, wxFontData *data = NULL);
+
+  bool Create(wxWindow *parent, wxFontData *data = NULL);
+
+  int ShowModal(void);
+  wxFontData& GetFontData(void) { return fontData; }
+};
+
+#endif
+    // __FONTDLGH__
+
diff --git a/include/wx/msw/frame.h b/include/wx/msw/frame.h
new file mode 100644
index 0000000000..652dd1b549
--- /dev/null
+++ b/include/wx/msw/frame.h
@@ -0,0 +1,162 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        frame.h
+// Purpose:     wxFrame class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __FRAMEH__
+#define __FRAMEH__
+
+#ifdef __GNUG__
+#pragma interface "frame.h"
+#endif
+
+#include "wx/window.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr;
+
+class WXDLLEXPORT wxMenuBar;
+class WXDLLEXPORT wxStatusBar;
+
+class WXDLLEXPORT wxFrame: public wxWindow {
+
+  DECLARE_DYNAMIC_CLASS(wxFrame)
+
+public:
+  wxFrame(void);
+  inline wxFrame(wxWindow *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxDEFAULT_FRAME_STYLE,
+           const wxString& name = wxFrameNameStr)
+  {
+      Create(parent, id, title, pos, size, style, name);
+  }
+
+  ~wxFrame(void);
+
+  bool Create(wxWindow *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxDEFAULT_FRAME_STYLE,
+           const wxString& name = wxFrameNameStr);
+
+#if WXWIN_COMPATIBILITY
+  // The default thing is to set the focus for the first child window.
+  // Override for your own behaviour.
+  virtual void OldOnActivate(bool flag);
+
+  // Default behaviour is to display a help string for the menu item.
+  virtual void OldOnMenuSelect(int id);
+
+  inline virtual void OldOnMenuCommand(int WXUNUSED(id)) {};         // Called on frame menu command
+  void OldOnSize(int x, int y);
+#endif
+
+  virtual bool Destroy(void);
+  void SetClientSize(const int width, const int height);
+  void GetClientSize(int *width, int *height) const;
+
+  void GetSize(int *width, int *height) const ;
+  void GetPosition(int *x, int *y) const ;
+  void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+
+  void OnSize(wxSizeEvent& event);
+  void OnMenuHighlight(wxMenuEvent& event);
+  void OnActivate(wxActivateEvent& event);
+  void OnIdle(wxIdleEvent& event);
+  void OnCloseWindow(wxCloseEvent& event);
+
+  bool Show(const bool show);
+
+  // Set menu bar
+  void SetMenuBar(wxMenuBar *menu_bar);
+  virtual wxMenuBar *GetMenuBar(void) const ;
+
+  // Set title
+  void SetTitle(const wxString& title);
+  wxString GetTitle(void) const ;
+
+  void Centre(const int direction = wxBOTH);
+
+  // Call this to simulate a menu command
+  virtual void Command(int id);
+  virtual void ProcessCommand(int id);
+
+  // Set icon
+  virtual void SetIcon(const wxIcon& icon);
+
+  // Create status line
+  virtual bool CreateStatusBar(const int number=1);
+  inline wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
+
+  // Set status line text
+  virtual void SetStatusText(const wxString& text, const int number = 0);
+
+  // Set status line widths
+  virtual void SetStatusWidths(const int n, const int *widths_field);
+
+  // Hint to tell framework which status bar to use
+  // TODO: should this go into a wxFrameworkSettings class perhaps?
+  static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; };
+  static bool UsesNativeStatusBar(void) { return m_useNativeStatusBar; };
+
+  // Fit frame around subwindows
+  virtual void Fit(void);
+
+  // Iconize
+  virtual void Iconize(const bool iconize);
+
+  virtual bool IsIconized(void) const ;
+
+  // Compatibility
+  inline bool Iconized(void) const { return IsIconized(); }
+
+  virtual void Maximize(const bool maximize);
+  virtual bool LoadAccelerators(const wxString& table);
+
+  virtual void PositionStatusBar(void);
+  virtual wxStatusBar *OnCreateStatusBar(const int number);
+
+  // Query app for menu item updates (called from OnIdle)
+  void DoMenuUpdates(void);
+  void DoMenuUpdates(wxMenu* menu);
+
+  WXHMENU GetWinMenu(void) const ;
+
+  // Responds to colour changes
+  void OnSysColourChanged(wxSysColourChangedEvent& event);
+
+  // Handlers
+  bool MSWOnPaint(void);
+  WXHICON MSWOnQueryDragIcon(void);
+  void MSWOnSize(const int x, const int y, const WXUINT flag);
+  bool MSWOnCommand(const WXWORD id, const WXWORD cmd, const WXHWND control);
+  bool MSWOnClose(void);
+  void MSWOnMenuHighlight(const WXWORD item, const WXWORD flags, const WXHMENU sysmenu);
+  bool MSWProcessMessage(WXMSG *msg);
+  void MSWCreate(const int id, wxWindow *parent, const char *WXUNUSED(wclass), wxWindow *wx_win, const char *title,
+                   const int x, const int y, const int width, const int height, const long style);
+
+protected:
+  wxMenuBar *           m_frameMenuBar;
+  wxStatusBar *         m_frameStatusBar;
+  wxIcon                m_icon;
+  bool                  m_iconized;
+  WXHICON               m_defaultIcon;
+  static bool           m_useNativeStatusBar;
+
+  DECLARE_EVENT_TABLE()
+};
+
+#endif
+    // __FRAMEH__
diff --git a/include/wx/msw/gauge.h b/include/wx/msw/gauge.h
new file mode 100644
index 0000000000..070d25ca46
--- /dev/null
+++ b/include/wx/msw/gauge.h
@@ -0,0 +1,81 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        gauge.h
+// Purpose:     wxGauge class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __GAUGEH__
+#define __GAUGEH__
+
+#ifdef __GNUG__
+#pragma interface "gauge.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxGaugeNameStr;
+
+// Group box
+class WXDLLEXPORT wxGauge: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxGauge)
+ public:
+  inline wxGauge(void) { m_rangeMax = 0; m_gaugePos = 0; m_useProgressBar = FALSE; }
+
+  inline wxGauge(wxWindow *parent, const wxWindowID id,
+           const int range,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxGA_HORIZONTAL,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxGaugeNameStr)
+  {
+    Create(parent, id, range, pos, size, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const int range,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxGA_HORIZONTAL,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxGaugeNameStr);
+
+  void SetShadowWidth(const int w);
+  void SetBezelFace(const int w);
+  void SetRange(const int r);
+  void SetValue(const int pos);
+
+  int GetShadowWidth(void) const ;
+  int GetBezelFace(void) const ;
+  int GetRange(void) const ;
+  int GetValue(void) const ;
+
+  void SetForegroundColour(const wxColour& col);
+  void SetBackgroundColour(const wxColour& col);
+
+  // Backward compatibility
+#if WXWIN_COMPATIBILITY
+  inline void SetButtonColour(const wxColour& col) { SetForegroundColour(col); }
+#endif
+
+  void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+
+  // Are we a Win95 progress bar, or a normal gauge?
+  inline bool GetProgressBar(void) const { return m_useProgressBar; }
+
+  virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ;
+
+ protected:
+   int      m_rangeMax;
+   int      m_gaugePos;
+   bool     m_useProgressBar;
+};
+
+#endif
+    // __GAUGEH__
diff --git a/include/wx/msw/gdiobj.h b/include/wx/msw/gdiobj.h
new file mode 100644
index 0000000000..31c3f4ad97
--- /dev/null
+++ b/include/wx/msw/gdiobj.h
@@ -0,0 +1,67 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        gdiobj.h
+// Purpose:     wxGDIObject class: base class for other GDI classes
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __GDIOBJH__
+#define __GDIOBJH__
+
+#include "wx/object.h"
+
+#ifdef __GNUG__
+#pragma interface "gdiobj.h"
+#endif
+
+// wxGDIRefData is the reference-counted data part of a GDI object.
+// It contains another counter, m_usageCount, which counts the number
+// of times this object has been used; e.g. in SetFont, the count
+// is incremented. This is different from reference counting,
+// where only the constructors, destructors and (un)clone operations
+// affect the reference count.
+// THIS IS NOW BEING REMOVED AS REDUNDANT AND ERROR-PRONE
+
+class WXDLLEXPORT wxGDIRefData: public wxObjectRefData {
+public:
+    inline wxGDIRefData(void)
+	{
+ 	}
+};
+
+#define M_GDIDATA ((wxGDIRefData *)m_refData)
+
+class WXDLLEXPORT wxGDIObject: public wxObject
+{
+DECLARE_DYNAMIC_CLASS(wxGDIObject)
+ public:
+  inline wxGDIObject(void) { m_visible = FALSE; };
+  inline ~wxGDIObject(void) {};
+
+  // Creates the resource
+  virtual bool RealizeResource(void) { return FALSE; };
+
+  // Frees the resource
+  virtual bool FreeResource(bool WXUNUSED(force) = FALSE) { return FALSE; };
+
+  virtual bool IsFree(void) { return FALSE; };
+
+  inline bool IsNull(void) const { return (m_refData == 0); }
+
+  // Returns handle.
+  virtual WXHANDLE GetResourceHandle(void) { return 0; }
+
+  virtual bool GetVisible(void) { return m_visible; }
+  virtual void SetVisible(bool v) { m_visible = v; }
+
+protected:
+  bool m_visible; // Can a pointer to this object be safely taken?
+                 // - only if created within FindOrCreate...
+};
+
+#endif
+    // __GDIOBJH__
diff --git a/include/wx/msw/hand.cur b/include/wx/msw/hand.cur
new file mode 100644
index 0000000000000000000000000000000000000000..ce349aa3324a9dee883052b92064b2d63300ede7
GIT binary patch
literal 326
zcmaLRu?@m75QX92Ae4e49YUfYB_$h>Q5b+7V3Vw3i9tw5o01~R%X5enBm!rB_W3ON
z4i*H80@kcJ2G{@xbBWS|*AV0JzD&EM>GCVfYDn@1_AfXkEnH14;bE2Y-DPx!E#F+4
n3(xRBnp{fiOo~hCmIO~8)S0^vy3)0n_&rwA-QRwC&bR3S<|=*2

literal 0
HcmV?d00001

diff --git a/include/wx/msw/heart.cur b/include/wx/msw/heart.cur
new file mode 100644
index 0000000000000000000000000000000000000000..53811dcc55b75b2a6d25cc0915f81e65ef55a465
GIT binary patch
literal 326
zcmc)Dy$!=47=+=MP|$@gEiO}L17|Zc8lx}*r3>WCM@SUO3*^wlzjScHu`Cd|@^Eki
z?#8Zo8fW93&oU3cSrW#wNyo5CJxP0%+7P7brQ)PK*mu~DY3-19t8Wl0_%gX{)hF}K
T5vtFzg_3$|R``u=|J45i+#Y=v

literal 0
HcmV?d00001

diff --git a/include/wx/msw/helpwin.h b/include/wx/msw/helpwin.h
new file mode 100644
index 0000000000..01b2eecf05
--- /dev/null
+++ b/include/wx/msw/helpwin.h
@@ -0,0 +1,54 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        helpwin.h
+// Purpose:     Help system: WinHelp implementation
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __HELPWINH__
+#define __HELPWINH__
+
+#ifdef __GNUG__
+#pragma interface "helpwin.h"
+#endif
+
+#include "wx/wx.h"
+
+#if USE_HELP
+
+#include "wx/helpbase.h"
+
+class WXDLLEXPORT wxWinHelpController: public wxHelpControllerBase
+{
+  DECLARE_CLASS(wxWinHelpController)
+
+ public:
+  wxWinHelpController(void);
+  ~wxWinHelpController(void);
+
+  // Must call this to set the filename and server name
+  virtual bool Initialize(const wxString& file, int server = -1);
+
+  // If file is "", reloads file given  in Initialize
+  virtual bool LoadFile(const wxString& file = "");
+  virtual bool DisplayContents(void);
+  virtual bool DisplaySection(int sectionNo);
+  virtual bool DisplayBlock(long blockNo);
+  virtual bool KeywordSearch(const wxString& k);
+
+  virtual bool Quit(void);
+  virtual void OnQuit(void);
+
+  inline wxString GetHelpFile(void) const { return m_helpFile; }
+
+protected:
+  wxString m_helpFile;
+};
+
+#endif // USE_HELP
+#endif
+    // __HELPWINH__
diff --git a/include/wx/msw/icon.h b/include/wx/msw/icon.h
new file mode 100644
index 0000000000..f7119fa44a
--- /dev/null
+++ b/include/wx/msw/icon.h
@@ -0,0 +1,102 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        icon.h
+// Purpose:     wxIcon class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __ICONH__
+#define __ICONH__
+
+#ifdef __GNUG__
+#pragma interface "icon.h"
+#endif
+
+#include "wx/bitmap.h"
+
+class WXDLLEXPORT wxIconRefData: public wxBitmapRefData
+{
+    friend class WXDLLEXPORT wxBitmap;
+    friend class WXDLLEXPORT wxIcon;
+public:
+    wxIconRefData(void);
+    ~wxIconRefData(void);
+
+public:
+  WXHICON m_hIcon;
+};
+
+#define M_ICONDATA ((wxIconRefData *)m_refData)
+#define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData())
+
+// Icon
+class WXDLLEXPORT wxIcon: public wxBitmap
+{
+  DECLARE_DYNAMIC_CLASS(wxIcon)
+
+public:
+  wxIcon(void);
+
+  // Copy constructors
+  inline wxIcon(const wxIcon& icon) { Ref(icon); }
+  inline wxIcon(const wxIcon* icon) { /* UnRef(); */ if (icon) Ref(*icon); }
+
+  wxIcon(const char bits[], const int width, const int height);
+  wxIcon(const wxString& name, const long flags = wxBITMAP_TYPE_ICO_RESOURCE,
+    int desiredWidth = -1, int desiredHeight = -1);
+  ~wxIcon(void);
+
+  bool LoadFile(const wxString& name, const long flags = wxBITMAP_TYPE_ICO_RESOURCE,
+      int desiredWidth = -1, int desiredHeight = -1);
+
+  inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
+  inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
+  inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
+
+  void SetHICON(WXHICON ico);
+  inline WXHICON GetHICON(void) const { return (M_ICONDATA ? M_ICONDATA->m_hIcon : 0); }
+
+  virtual bool Ok(void) const { return (m_refData != NULL && M_ICONDATA->m_hIcon) ; }
+
+  bool FreeResource(bool force = FALSE);
+};
+
+// TODO: Put these in separate, private header
+
+class WXDLLEXPORT wxICOFileHandler: public wxBitmapHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxICOFileHandler)
+public:
+  inline wxICOFileHandler(void)
+  {
+	m_name = "ICO icon file";
+	m_extension = "ico";
+	m_type = wxBITMAP_TYPE_ICO;
+  };
+
+  virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+      int desiredWidth = -1, int desiredHeight = -1);
+};
+
+class WXDLLEXPORT wxICOResourceHandler: public wxBitmapHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxICOResourceHandler)
+public:
+  inline wxICOResourceHandler(void)
+  {
+	m_name = "ICO resource";
+	m_extension = "ico";
+	m_type = wxBITMAP_TYPE_ICO_RESOURCE;
+  };
+
+  virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+      int desiredWidth = -1, int desiredHeight = -1);
+
+};
+
+#endif
+    // __ICONH__
diff --git a/include/wx/msw/imaglist.h b/include/wx/msw/imaglist.h
new file mode 100644
index 0000000000..0b464abbaa
--- /dev/null
+++ b/include/wx/msw/imaglist.h
@@ -0,0 +1,226 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        imaglist.h
+// Purpose:     wxImageList class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __IMAGLISTH__
+#define __IMAGLISTH__
+
+#ifdef __GNUG__
+#pragma interface "imaglist.h"
+#endif
+
+#include "wx/bitmap.h"
+
+/*
+ * wxImageList is used for wxListCtrl, wxTreeCtrl. These controls refer to
+ * images for their items by an index into an image list.
+ * A wxImageList is capable of creating images with optional masks from
+ * a variety of sources - a single bitmap plus a colour to indicate the mask,
+ * two bitmaps, or an icon.
+ *
+ * Image lists can also create and draw images used for drag and drop functionality.
+ * This is not yet implemented in wxImageList. We need to discuss a generic API
+ * for doing drag and drop and see whether it ties in with the Win95 view of it.
+ * See below for candidate functions and an explanation of how they might be
+ * used.
+ */
+
+// Flags for Draw
+#define wxIMAGELIST_DRAW_NORMAL         0x0001
+#define wxIMAGELIST_DRAW_TRANSPARENT    0x0002
+#define wxIMAGELIST_DRAW_SELECTED       0x0004
+#define wxIMAGELIST_DRAW_FOCUSED        0x0008
+
+// Flag values for Set/GetImageList
+enum {
+    wxIMAGE_LIST_NORMAL, // Normal icons
+    wxIMAGE_LIST_SMALL,  // Small icons
+    wxIMAGE_LIST_STATE   // State icons: unimplemented (see WIN32 documentation)
+};
+
+// Eventually we'll make this a reference-counted wxGDIObject. For
+// now, the app must take care of ownership issues. That is, the
+// image lists must be explicitly deleted after the control(s) that uses them
+// is (are) deleted, or when the app exits.
+class WXDLLEXPORT wxImageList: public wxObject
+{
+  DECLARE_DYNAMIC_CLASS(wxImageList)
+ public:
+  /*
+   * Public interface
+   */
+
+  wxImageList(void);
+
+  // Creates an image list.
+  // Specify the width and height of the images in the list,
+  // whether there are masks associated with them (e.g. if creating images
+  // from icons), and the initial size of the list.
+  inline wxImageList(const int width, const int height, const bool mask = TRUE, const int initialCount = 1)
+  {
+    Create(width, height, mask, initialCount);
+  }
+  ~wxImageList(void);
+
+
+  // Attributes
+  ////////////////////////////////////////////////////////////////////////////
+
+  // Returns the number of images in the image list.
+  int GetImageCount(void) const;
+
+  // Operations
+  ////////////////////////////////////////////////////////////////////////////
+
+  // Creates an image list
+  // width, height specify the size of the images in the list (all the same).
+  // mask specifies whether the images have masks or not.
+  // initialNumber is the initial number of images to reserve.
+  bool Create(const int width, const int height, const bool mask = TRUE, const int initialNumber = 1);
+
+  // Adds a bitmap, and optionally a mask bitmap.
+  // Note that wxImageList creates *new* bitmaps, so you may delete
+  // 'bitmap' and 'mask' after calling Add.
+  int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
+
+  // Adds a bitmap, using the specified colour to create the mask bitmap
+  // Note that wxImageList creates *new* bitmaps, so you may delete
+  // 'bitmap' after calling Add.
+  int Add(const wxBitmap& bitmap, const wxColour& maskColour);
+
+  // Adds a bitmap and mask from an icon.
+  int Add(const wxIcon& icon);
+
+  // Replaces a bitmap, optionally passing a mask bitmap.
+  // Note that wxImageList creates new bitmaps, so you may delete
+  // 'bitmap' and 'mask' after calling Replace.
+  bool Replace(const int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
+
+/* Not supported by Win95
+  // Replacing a bitmap, using the specified colour to create the mask bitmap
+  // Note that wxImageList creates new bitmaps, so you may delete
+  // 'bitmap'.
+  bool Replace(const int index, const wxBitmap& bitmap, const wxColour& maskColour);
+*/
+
+  // Replaces a bitmap and mask from an icon.
+  // You can delete 'icon' after calling Replace.
+  bool Replace(const int index, const wxIcon& icon);
+
+  // Removes the image at the given index.
+  bool Remove(const int index);
+
+  // Remove all images
+  bool RemoveAll(void);
+
+  // Draws the given image on a dc at the specified position.
+  // If 'solidBackground' is TRUE, Draw sets the image list background
+  // colour to the background colour of the wxDC, to speed up
+  // drawing by eliminating masked drawing where possible.
+  bool Draw(const int index, wxDC& dc, const int x, const int y,
+    const int flags = wxIMAGELIST_DRAW_NORMAL, const bool solidBackground = FALSE);
+
+  // TODO: miscellaneous functionality
+/*
+  wxIcon *MakeIcon(const int index);
+  bool SetOverlayImage(const int index, const int overlayMask);
+
+*/
+
+  // TODO: Drag-and-drop related functionality.
+
+#if 0
+  // Creates a new drag image by combining the given image (typically a mouse cursor image)
+  // with the current drag image.
+  bool SetDragCursorImage(const int index, const wxPoint& hotSpot);
+
+  // If successful, returns a pointer to the temporary image list that is used for dragging;
+  // otherwise, NULL.
+  // dragPos: receives the current drag position.
+  // hotSpot: receives the offset of the drag image relative to the drag position.
+  static wxImageList *GetDragImageList(wxPoint& dragPos, wxPoint& hotSpot);
+
+  // Call this function to begin dragging an image. This function creates a temporary image list
+  // that is used for dragging. The image combines the specified image and its mask with the
+  // current cursor. In response to subsequent mouse move messages, you can move the drag image
+  // by using the DragMove member function. To end the drag operation, you can use the EndDrag
+  // member function.
+  bool BeginDrag(const int index, const wxPoint& hotSpot);
+
+  // Ends a drag operation.
+  bool EndDrag(void);
+
+  // Call this function to move the image that is being dragged during a drag-and-drop operation.
+  // This function is typically called in response to a mouse move message. To begin a drag
+  // operation, use the BeginDrag member function.
+  static bool DragMove(const wxPoint& point);
+
+  // During a drag operation, locks updates to the window specified by lockWindow and displays
+  // the drag image at the position specified by point.
+  // The coordinates are relative to the window's upper left corner, so you must compensate
+  // for the widths of window elements, such as the border, title bar, and menu bar, when
+  // specifying the coordinates.
+  // If lockWindow is NULL, this function draws the image in the display context associated
+  // with the desktop window, and coordinates are relative to the upper left corner of the screen.
+  // This function locks all other updates to the given window during the drag operation.
+  // If you need to do any drawing during a drag operation, such as highlighting the target
+  // of a drag-and-drop operation, you can temporarily hide the dragged image by using the
+  // wxImageList::DragLeave function.
+
+  // lockWindow: pointer to the window that owns the drag image.
+  // point:      position at which to display the drag image. Coordinates are relative to the
+  //             upper left corner of the window (not the client area).
+
+  static bool DragEnter( wxWindow *lockWindow, const wxPoint& point );
+
+  // Unlocks the window specified by pWndLock and hides the drag image, allowing the
+  // window to be updated.
+  static bool DragLeave( wxWindow *lockWindow );
+
+  /* Here's roughly how you'd use these functions if implemented in this Win95-like way:
+
+  1) Starting to drag:
+
+  wxImageList *dragImageList = new wxImageList(16, 16, TRUE);
+  dragImageList->Add(myDragImage); // Provide an image to combine with the current cursor
+  dragImageList->BeginDrag(0, wxPoint(0, 0));
+  wxShowCursor(FALSE);        // wxShowCursor not yet implemented in wxWin
+  myWindow->CaptureMouse();
+
+  2) Dragging:
+
+  // Called within mouse move event. Could also use dragImageList instead of assuming
+  // these are static functions.
+  // These two functions could possibly be combined into one, since DragEnter is
+  // a bit obscure.
+  wxImageList::DragMove(wxPoint(x, y));  // x, y are current cursor position
+  wxImageList::DragEnter(NULL, wxPoint(x, y)); // NULL assumes dragging across whole screen
+
+  3) Finishing dragging:
+
+  dragImageList->EndDrag();
+  myWindow->ReleaseMouse();
+  wxShowCursor(TRUE);
+*/
+
+#endif
+
+  // Implementation
+  ////////////////////////////////////////////////////////////////////////////
+
+  // Returns the native image list handle
+  inline WXHIMAGELIST GetHIMAGELIST(void) const { return m_hImageList; }
+
+protected:
+  WXHIMAGELIST m_hImageList;
+};
+
+#endif
+    // __IMAGLISTH__
diff --git a/include/wx/msw/joystick.h b/include/wx/msw/joystick.h
new file mode 100644
index 0000000000..aa97ff1252
--- /dev/null
+++ b/include/wx/msw/joystick.h
@@ -0,0 +1,93 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        joystick.h
+// Purpose:     wxJoystick class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __JOYSTICKH__
+#define __JOYSTICKH__
+
+#ifdef __GNUG__
+#pragma interface "joystick.h"
+#endif
+
+#include "wx/event.h"
+
+class WXDLLEXPORT wxJoystick: public wxObject
+{
+  DECLARE_DYNAMIC_CLASS(wxJoystick)
+ public:
+  /*
+   * Public interface
+   */
+
+  wxJoystick(int joystick = wxJOYSTICK1) { m_joystick = joystick; };
+
+  // Attributes
+  ////////////////////////////////////////////////////////////////////////////
+
+  wxPoint GetPosition(void) const;
+  int GetZPosition(void) const;
+  int GetButtonState(void) const;
+  int GetPOVPosition(void) const;
+  int GetPOVCTSPosition(void) const;
+  int GetRudderPosition(void) const;
+  int GetUPosition(void) const;
+  int GetVPosition(void) const;
+  int GetMovementThreshold(void) const;
+  void SetMovementThreshold(int threshold) ;
+
+  // Capabilities
+  ////////////////////////////////////////////////////////////////////////////
+
+  bool IsOk(void) const; // Checks that the joystick is functioning
+  int GetNumberJoysticks(void) const ;
+  int GetManufacturerId(void) const ;
+  int GetProductId(void) const ;
+  wxString GetProductName(void) const ;
+  int GetXMin(void) const;
+  int GetYMin(void) const;
+  int GetZMin(void) const;
+  int GetXMax(void) const;
+  int GetYMax(void) const;
+  int GetZMax(void) const;
+  int GetNumberButtons(void) const;
+  int GetNumberAxes(void) const;
+  int GetMaxButtons(void) const;
+  int GetMaxAxes(void) const;
+  int GetPollingMin(void) const;
+  int GetPollingMax(void) const;
+  int GetRudderMin(void) const;
+  int GetRudderMax(void) const;
+  int GetUMin(void) const;
+  int GetUMax(void) const;
+  int GetVMin(void) const;
+  int GetVMax(void) const;
+
+  bool HasRudder(void) const;
+  bool HasZ(void) const;
+  bool HasU(void) const;
+  bool HasV(void) const;
+  bool HasPOV(void) const;
+  bool HasPOV4Dir(void) const;
+  bool HasPOVCTS(void) const;
+
+  // Operations
+  ////////////////////////////////////////////////////////////////////////////
+
+  // pollingFreq = 0 means that movement events are sent when above the threshold.
+  // If pollingFreq > 0, events are received every this many milliseconds.
+  bool SetCapture(wxWindow* win, int pollingFreq = 0);
+  bool ReleaseCapture(void);
+
+protected:
+  int       m_joystick;
+};
+
+#endif
+    // __JOYSTICKH__
diff --git a/include/wx/msw/listbox.h b/include/wx/msw/listbox.h
new file mode 100644
index 0000000000..97d0084199
--- /dev/null
+++ b/include/wx/msw/listbox.h
@@ -0,0 +1,135 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        listbox.h
+// Purpose:     wxListBox class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __LISTBOXH__
+#define __LISTBOXH__
+
+#ifdef __GNUG__
+#pragma interface "listbox.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr;
+WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr;
+
+#if USE_OWNER_DRAWN
+  class WXDLLEXPORT wxOwnerDrawn;
+
+  // define the array of list box items
+  #include  <wx/dynarray.h>
+  WX_DEFINE_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
+#endif
+
+WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
+
+// List box item
+class WXDLLEXPORT wxListBox: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxListBox)
+ public:
+
+  wxListBox(void);
+  inline wxListBox(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const int n = 0, const wxString choices[] = NULL,
+           const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxListBoxNameStr)
+  {
+    Create(parent, id, pos, size, n, choices, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const int n = 0, const wxString choices[] = NULL,
+           const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxListBoxNameStr);
+
+  ~wxListBox();
+
+  bool MSWCommand(const WXUINT param, const WXWORD id);
+
+#if USE_OWNER_DRAWN
+  bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
+  bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
+
+  // plug-in for derived classes
+  virtual wxOwnerDrawn *CreateItem(uint n);
+
+  // allows to get the item and use SetXXX functions to set it's appearance
+  wxOwnerDrawn *GetItem(uint n) const { return m_aItems[n]; }
+#endif
+
+  virtual void Append(const wxString& item);
+  virtual void Append(const wxString& item, char *clientData);
+  virtual void Set(const int n, const wxString* choices, char **clientData = NULL);
+  virtual int FindString(const wxString& s) const ;
+  virtual void Clear(void);
+  virtual void SetSelection(const int n, const bool select = TRUE);
+
+  virtual void Deselect(const int n);
+
+  // For single choice list item only
+  virtual int GetSelection(void) const ;
+  virtual void Delete(const int n);
+  virtual char *GetClientData(const int n) const ;
+  virtual void SetClientData(const int n, char *clientData);
+  virtual void SetString(const int n, const wxString& s);
+
+  // For single or multiple choice list item
+  virtual int GetSelections(int **listSelections) const ;
+  virtual bool Selected(const int n) const ;
+  virtual wxString GetString(const int n) const ;
+  virtual void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+
+  // Set the specified item at the first visible item
+  // or scroll to max range.
+  virtual void SetFirstItem(const int n) ;
+  virtual void SetFirstItem(const wxString& s) ;
+
+  virtual void InsertItems(const int nItems, const wxString items[], const int pos);
+
+  virtual wxString GetStringSelection(void) const ;
+  virtual bool SetStringSelection(const wxString& s, const bool flag = TRUE);
+  virtual int Number(void) const ;
+
+  void Command(wxCommandEvent& event);
+
+  // Windows-specific code to set the horizontal extent of
+  // the listbox, if necessary. If s is non-NULL, it's
+  // used to calculate the horizontal extent.
+  // Otherwise, all strings are used.
+  virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
+
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+  virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+  virtual void SetupColours(void);
+
+ protected:
+  int m_noItems;
+  int m_selected;
+  int *m_selections;
+
+#if USE_OWNER_DRAWN
+  // control items
+  wxListBoxItemsArray m_aItems;
+#endif
+
+};
+
+#endif
+    // __LISTBOXH__
diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h
new file mode 100644
index 0000000000..b0ecd50391
--- /dev/null
+++ b/include/wx/msw/listctrl.h
@@ -0,0 +1,476 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        listctrl.h
+// Purpose:     wxListCtrl class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __LISTCTRLH__
+#define __LISTCTRLH__
+
+#ifdef __GNUG__
+#pragma interface "listctrl.h"
+#endif
+
+#include "wx/control.h"
+#include "wx/event.h"
+#include "wx/imaglist.h"
+
+/*
+    The wxListCtrl can show lists of items in four different modes:
+    wxLC_LIST:   multicolumn list view, with optional small icons (icons could be
+                 optional for some platforms). Columns are computed automatically,
+                 i.e. you don't set columns as in wxLC_REPORT. In other words,
+                 the list wraps, unlike a wxListBox.
+    wxLC_REPORT: single or multicolumn report view (with optional header)
+    wxLC_ICON:   large icon view, with optional labels
+    wxLC_SMALL_ICON: small icon view, with optional labels
+
+    You can change the style dynamically, either with SetSingleStyle or
+    SetWindowStyleFlag.
+
+    Further window styles:
+
+    wxLC_ALIGN_TOP          icons align to the top (default)
+    wxLC_ALIGN_LEFT         icons align to the left
+    wxLC_AUTOARRANGE        icons arrange themselves
+    wxLC_USER_TEXT          the app provides label text on demand, except for column headers
+    wxLC_EDIT_LABELS        labels are editable: app will be notified.
+    wxLC_NO_HEADER          no header in report mode
+    wxLC_NO_SORT_HEADER     can't click on header
+    wxLC_SINGLE_SEL         single selection
+    wxLC_SORT_ASCENDING     sort ascending (must still supply a comparison callback in SortItems)
+    wxLC_SORT_DESCENDING    sort descending (ditto)
+
+    Items are referred to by their index (position in the list starting from zero).
+
+    Label text is supplied via insertion/setting functions and is stored by the
+    control, unless the wxLC_USER_TEXT style has been specified, in which case
+    the app will be notified when text is required (see sample).
+
+    Images are dealt with by (optionally) associating 3 image lists with the control.
+    Zero-based indexes into these image lists indicate which image is to be used for
+    which item. Each image in an image list can contain a mask, and can be made out
+    of either a bitmap, two bitmaps or an icon. See ImagList.h for more details.
+
+    Notifications are passed via the wxWindows 2.0 event system, or using virtual
+    functions in wxWindows 1.66.
+
+    See the sample wxListCtrl app for API usage.
+
+    TODO:
+     - addition of further convenience functions
+       to avoid use of wxListItem in some functions
+     - state/overlay images: probably not needed.
+     - in Win95, you can be called back to supply other information
+       besides text, such as state information. This saves no memory
+       and is probably superfluous to requirements.
+     - discover why SetWindowLong doesn't properly change the
+       style, requiring RecreateWindow instead.
+     - testing of whole API, extending current sample.
+
+
+ */
+
+// Mask flags to tell app/GUI what fields of wxListItem are valid
+#define wxLIST_MASK_STATE           0x0001
+#define wxLIST_MASK_TEXT            0x0002
+#define wxLIST_MASK_IMAGE           0x0004
+#define wxLIST_MASK_DATA            0x0008
+#define wxLIST_SET_ITEM             0x0010
+#define wxLIST_MASK_WIDTH           0x0020
+#define wxLIST_MASK_FORMAT          0x0040
+
+// State flags for indicating the state of an item
+#define wxLIST_STATE_DONTCARE       0x0000
+#define wxLIST_STATE_DROPHILITED    0x0001
+#define wxLIST_STATE_FOCUSED        0x0002
+#define wxLIST_STATE_SELECTED       0x0004
+#define wxLIST_STATE_CUT            0x0008
+
+// Hit test flags, used in HitTest
+#define wxLIST_HITTEST_ABOVE            0x0001  // Above the client area.
+#define wxLIST_HITTEST_BELOW            0x0002  // Below the client area.
+#define wxLIST_HITTEST_NOWHERE          0x0004  // In the client area but below the last item.
+#define wxLIST_HITTEST_ONITEMICON       0x0020  // On the bitmap associated with an item.
+#define wxLIST_HITTEST_ONITEMLABEL      0x0080  // On the label (string) associated with an item.
+#define wxLIST_HITTEST_ONITEMRIGHT      0x0100  // In the area to the right of an item.
+#define wxLIST_HITTEST_ONITEMSTATEICON  0x0200  // On the state icon for a tree view item that is in a user-defined state.
+#define wxLIST_HITTEST_TOLEFT           0x0400  // To the left of the client area.
+#define wxLIST_HITTEST_TORIGHT          0x0800  // To the right of the client area.
+
+#define wxLIST_HITTEST_ONITEM (wxLIST_HITTEST_ONITEMICON | wxLIST_HITTEST_ONITEMLABEL wxLIST_HITTEST_ONITEMSTATEICON)
+
+// Flags for GetNextItem
+enum {
+    wxLIST_NEXT_ABOVE,          // Searches for an item above the specified item
+    wxLIST_NEXT_ALL,            // Searches for subsequent item by index
+    wxLIST_NEXT_BELOW,          // Searches for an item below the specified item
+    wxLIST_NEXT_LEFT,           // Searches for an item to the left of the specified item
+    wxLIST_NEXT_RIGHT,          // Searches for an item to the right of the specified item
+};
+
+// Alignment flags for Arrange
+enum {
+    wxLIST_ALIGN_DEFAULT,
+    wxLIST_ALIGN_LEFT,
+    wxLIST_ALIGN_TOP,
+    wxLIST_ALIGN_SNAP_TO_GRID
+};
+
+// Column format
+enum {
+    wxLIST_FORMAT_LEFT,
+    wxLIST_FORMAT_RIGHT,
+    wxLIST_FORMAT_CENTRE,
+    wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE
+};
+
+// Autosize values for SetColumnWidth
+enum {
+    wxLIST_AUTOSIZE = -1,
+    wxLIST_AUTOSIZE_USEHEADER = -2
+};
+
+// Flag values for GetItemRect
+enum {
+    wxLIST_RECT_BOUNDS,
+    wxLIST_RECT_ICON,
+    wxLIST_RECT_LABEL
+};
+
+// Flag values for FindItem
+enum {
+    wxLIST_FIND_UP,
+    wxLIST_FIND_DOWN,
+    wxLIST_FIND_LEFT,
+    wxLIST_FIND_RIGHT
+};
+
+// wxListItem: data representing an item, or report field.
+// It also doubles up to represent entire column information
+// when inserting or setting a column.
+class WXDLLEXPORT wxListItem: public wxObject
+{
+ DECLARE_DYNAMIC_CLASS(wxListItem)
+public:
+    long            m_mask;     // Indicates what fields are valid
+    long            m_itemId;   // The zero-based item position
+    int             m_col;      // Zero-based column, if in report mode
+    long            m_state;    // The state of the item
+    long            m_stateMask; // Which flags of m_state are valid (uses same flags)
+    wxString        m_text;     // The label/header text
+    int             m_image;    // The zero-based index into an image list
+    long            m_data;     // App-defined data
+
+    // For columns only
+    int             m_format;   // left, right, centre
+    int             m_width;    // width of column
+
+    wxListItem(void);
+};
+
+// type of compare function for wxListCtrl sort operation
+typedef int (*wxListCtrlCompare)(const long item1, const long item2, long sortData);
+
+class WXDLLEXPORT wxListCtrl: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxListCtrl)
+ public:
+  /*
+   * Public interface
+   */
+
+  wxListCtrl(void);
+
+  inline wxListCtrl(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+            const long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
+            const wxString& name = "listCtrl")
+  {
+    Create(parent, id, pos, size, style, validator, name);
+  }
+  ~wxListCtrl(void);
+
+  bool Create(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+            const long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = "wxListCtrl");
+
+
+  // Attributes
+  ////////////////////////////////////////////////////////////////////////////
+
+  // Sets the background colour (GetBackgroundColour already implicit in
+  // wxWindow class)
+  void SetBackgroundColour(const wxColour& col);
+
+  // Gets information about this column
+  bool GetColumn(const int col, wxListItem& item) const;
+
+  // Sets information about this column
+  bool SetColumn(const int col, wxListItem& item) ;
+
+  // Gets the column width
+  int GetColumnWidth(const int col) const;
+
+  // Sets the column width
+  bool SetColumnWidth(const int col, const int width) ;
+
+  // Gets the number of items that can fit vertically in the
+  // visible area of the list control (list or report view)
+  // or the total number of items in the list control (icon
+  // or small icon view)
+  int GetCountPerPage(void) const;
+
+  // Gets the edit control for editing labels.
+  wxTextCtrl& GetEditControl(void) const;
+
+  // Gets information about the item
+  bool GetItem(wxListItem& info) const ;
+
+  // Sets information about the item
+  bool SetItem(wxListItem& info) ;
+
+  // Sets a string field at a particular column
+  long SetItem(const long index, const int col, const wxString& label, const int imageId = -1);
+
+  // Gets the item state
+  int  GetItemState(const long item, const long stateMask) const ;
+
+  // Sets the item state
+  bool SetItemState(const long item, const long state, const long stateMask) ;
+
+  // Sets the item image
+  bool SetItemImage(const long item, const int image, const int selImage) ;
+
+  // Gets the item text
+  wxString GetItemText(const long item) const ;
+
+  // Sets the item text
+  void SetItemText(const long item, const wxString& str) ;
+
+  // Gets the item data
+  long GetItemData(const long item) const ;
+
+  // Sets the item data
+  bool SetItemData(const long item, long data) ;
+
+  // Gets the item rectangle
+  bool GetItemRect(const long item, wxRectangle& rect, const int code = wxLIST_RECT_BOUNDS) const ;
+
+  // Gets the item position
+  bool GetItemPosition(const long item, wxPoint& pos) const ;
+
+  // Sets the item position
+  bool SetItemPosition(const long item, const wxPoint& pos) ;
+
+  // Gets the number of items in the list control
+  int GetItemCount(void) const;
+
+  // Gets the number of columns in the list control
+  int GetColumnCount(void) const;
+
+  // Retrieves the spacing between icons in pixels.
+  // If small is TRUE, gets the spacing for the small icon
+  // view, otherwise the large icon view.
+  int GetItemSpacing(bool isSmall) const;
+
+  // Gets the number of selected items in the list control
+  int GetSelectedItemCount(void) const;
+
+  // Gets the text colour of the listview
+  wxColour GetTextColour(void) const;
+
+  // Sets the text colour of the listview
+  void SetTextColour(const wxColour& col);
+
+  // Gets the index of the topmost visible item when in
+  // list or report view
+  long GetTopItem(void) const ;
+
+  // Add or remove a single window style
+  void SetSingleStyle(const long style, const bool add = TRUE) ;
+
+  // Set the whole window style
+  void SetWindowStyleFlag(const long style) ;
+
+  // Searches for an item, starting from 'item'.
+  // item can be -1 to find the first item that matches the
+  // specified flags.
+  // Returns the item or -1 if unsuccessful.
+  long GetNextItem(const long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ;
+
+  // Implementation: converts wxWindows style to MSW style.
+  // Can be a single style flag or a bit list.
+  // oldStyle is 'normalised' so that it doesn't contain
+  // conflicting styles.
+  long ConvertToMSWStyle(long& oldStyle, const long style) const;
+
+  // Gets one of the three image lists
+  wxImageList *GetImageList(const int which) const ;
+
+  // Sets the image list
+  // N.B. There's a quirk in the Win95 list view implementation.
+  // If in wxLC_LIST mode, it'll *still* display images by the labels if
+  // there's a small-icon image list set for the control - even though you
+  // haven't specified wxLIST_MASK_IMAGE when inserting.
+  // So you have to set a NULL small-icon image list to be sure that
+  // the wxLC_LIST mode works without icons. Of course, you may want icons...
+  void SetImageList(wxImageList *imageList, const int which) ;
+
+  // Operations
+  ////////////////////////////////////////////////////////////////////////////
+
+  // Arranges the items
+  bool Arrange(const int flag = wxLIST_ALIGN_DEFAULT);
+
+  // Deletes an item
+  bool DeleteItem(const long item);
+
+  // Deletes all items
+  bool DeleteAllItems(void) ;
+
+  // Deletes a column
+  bool DeleteColumn(const int col);
+
+  // Deletes all columns
+  bool DeleteAllColumns(void);
+
+  // Clears items, and columns if there are any.
+  void ClearAll(void);
+
+  // Edits a label
+  wxTextCtrl& Edit(const long item) ;
+
+  // Ensures this item is visible
+  bool EnsureVisible(const long item) ;
+
+  // Find an item whose label matches this string, starting from the item after 'start'
+  // or the beginning if 'start' is -1.
+  long FindItem(const long start, const wxString& str, const bool partial = FALSE);
+
+  // Find an item whose data matches this data, starting from the item after 'start'
+  // or the beginning if 'start' is -1.
+  long FindItem(const long start, const long data);
+
+  // Find an item nearest this position in the specified direction, starting from
+  // the item after 'start' or the beginning if 'start' is -1.
+  long FindItem(const long start, const wxPoint& pt, const int direction);
+
+  // Determines which item (if any) is at the specified point,
+  // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
+  long HitTest(const wxPoint& point, int& flags);
+
+  // Inserts an item, returning the index of the new item if successful,
+  // -1 otherwise.
+  // TOD: Should also have some further convenience functions
+  // which don't require setting a wxListItem object
+  long InsertItem(wxListItem& info);
+
+  // Insert a string item
+  long InsertItem(const long index, const wxString& label);
+
+  // Insert an image item
+  long InsertItem(const long index, const int imageIndex);
+
+  // Insert an image/string item
+  long InsertItem(const long index, const wxString& label, const int imageIndex);
+
+  // For list view mode (only), inserts a column.
+  long InsertColumn(const long col, wxListItem& info);
+
+  long InsertColumn(const long col, const wxString& heading, const int format = wxLIST_FORMAT_LEFT,
+    const int width = -1);
+
+  // Scrolls the list control. If in icon, small icon or report view mode,
+  // x specifies the number of pixels to scroll. If in list view mode, x
+  // specifies the number of columns to scroll.
+  // If in icon, small icon or list view mode, y specifies the number of pixels
+  // to scroll. If in report view mode, y specifies the number of lines to scroll.
+  bool ScrollList(const int dx, const int dy);
+
+  // Sort items.
+
+  // fn is a function which takes 3 long arguments: item1, item2, data.
+  // item1 is the long data associated with a first item (NOT the index).
+  // item2 is the long data associated with a second item (NOT the index).
+  // data is the same value as passed to SortItems.
+  // The return value is a negative number if the first item should precede the second
+  // item, a positive number of the second item should precede the first,
+  // or zero if the two items are equivalent.
+
+  // data is arbitrary data to be passed to the sort function.
+  bool SortItems(wxListCtrlCompare fn, long data);
+
+/* Why should we need this function? Leave for now.
+ * WE NEED IT because item data may have changed,
+ * but the display needs refreshing (in string callback mode)
+  // Updates an item. If the list control has the wxLI_AUTO_ARRANGE style,
+  // the items will be rearranged.
+  bool Update(const long item);
+*/
+
+  void Command(wxCommandEvent& event) { ProcessCommand(event); };
+
+  // IMPLEMENTATION
+  bool MSWCommand(const WXUINT param, const WXWORD id);
+  bool MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam);
+
+  // Recreate window - seems to be necessary when changing a style.
+  void RecreateWindow(void);
+
+  // Add to pool: necessary because Windows needs to have a string
+  // still exist across 3 callbacks.
+  char *AddPool(const wxString& str);
+
+protected:
+  wxTextCtrl        m_textCtrl;        // The control used for editing a label
+  wxImageList *     m_imageListNormal; // The image list for normal icons
+  wxImageList *     m_imageListSmall;  // The image list for small icons
+  wxImageList *     m_imageListState;  // The image list state icons (not implemented yet)
+
+  long              m_baseStyle;  // Basic Windows style flags, for recreation purposes
+  wxStringList      m_stringPool; // Pool of 3 strings to satisfy Windows callback
+                                  // requirements
+  int               m_colCount;   // Windows doesn't have GetColumnCount so must
+                                  // keep track of inserted/deleted columns
+
+};
+
+class WXDLLEXPORT wxListEvent: public wxCommandEvent
+{
+  DECLARE_DYNAMIC_CLASS(wxListEvent)
+
+ public:
+  wxListEvent(WXTYPE commandType = 0, int id = 0);
+
+  int           m_code;
+  long          m_itemIndex;
+  long          m_oldItemIndex;
+  int           m_col;
+  bool          m_cancelled;
+  wxPoint       m_pointDrag;
+
+  wxListItem    m_item;
+};
+
+typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
+
+#define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn },
+
+#endif
+    // __LISTCTRLH__
diff --git a/include/wx/msw/magnif1.cur b/include/wx/msw/magnif1.cur
new file mode 100644
index 0000000000000000000000000000000000000000..bb4c8978d6ff06cf471120492e33ef0ec3aa5a9b
GIT binary patch
literal 326
zcma)$I}U<C6h#l8C>j%~Y^Ahh2U5B#=yVarEx8MAF<MX%uNTEYr+0E@-tWE)gal+6
z%$bn~umU#5B?=SxywyLSWVj^_$<HYF#LgVNIE65SM?sWS#NMCuq*RRg*5eSOh3&N&
v$$$7$XV2};RC+F@b}c1awUlaV>E4>7bUl^2Og?mRSL=Gs&6db^TgQ3<2@rcN

literal 0
HcmV?d00001

diff --git a/include/wx/msw/mdi.h b/include/wx/msw/mdi.h
new file mode 100644
index 0000000000..6664f219f4
--- /dev/null
+++ b/include/wx/msw/mdi.h
@@ -0,0 +1,210 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        mdi.h
+// Purpose:     MDI (Multiple Document Interface) classes
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __MDIH__
+#define __MDIH__
+
+#ifdef __GNUG__
+#pragma interface "mdi.h"
+#endif
+
+#include "wx/frame.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr;
+WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr;
+
+class WXDLLEXPORT wxMDIClientWindow;
+class WXDLLEXPORT wxMDIChildFrame;
+
+class WXDLLEXPORT wxMDIParentFrame: public wxFrame
+{
+  DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
+
+  friend class WXDLLEXPORT wxMDIChildFrame;
+ public:
+
+  wxMDIParentFrame(void);
+  inline wxMDIParentFrame(wxWindow *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
+           const wxString& name = wxFrameNameStr)
+  {
+      Create(parent, id, title, pos, size, style, name);
+  }
+
+  ~wxMDIParentFrame(void);
+
+  bool Create(wxWindow *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
+           const wxString& name = wxFrameNameStr);
+
+#if WXWIN_COMPATIBILITY
+  virtual void OldOnActivate(bool flag);
+  virtual void OldOnSize(int x, int y);
+#endif
+
+  void OnSize(wxSizeEvent& event);
+  void OnActivate(wxActivateEvent& event);
+
+  // Toolbar (currently, for use by Windows MDI parent frames ONLY)
+  virtual inline void SetToolBar(wxWindow *toolbar) { m_frameToolBar = toolbar; }
+  virtual inline wxWindow *GetToolBar(void) const { return m_frameToolBar; }
+
+  void SetMenuBar(wxMenuBar *menu_bar);
+
+  // Gets the size available for subwindows after menu size, toolbar size
+  // and status bar size have been subtracted. If you want to manage your own
+  // toolbar(s), don't call SetToolBar.
+  void GetClientSize(int *width, int *height) const;
+
+  // Get the active MDI child window (Windows only)
+  wxMDIChildFrame *GetActiveChild(void) const ;
+
+  // Get the client window
+  inline wxMDIClientWindow *GetClientWindow(void) const ;
+
+  // Create the client window class (don't Create the window,
+  // just return a new class)
+  virtual wxMDIClientWindow *OnCreateClient(void) ;
+
+  inline WXHMENU GetWindowMenu(void) const ;
+
+  // MDI operations
+  virtual void Cascade(void);
+  virtual void Tile(void);
+  virtual void ArrangeIcons(void);
+  virtual void ActivateNext(void);
+  virtual void ActivatePrevious(void);
+
+  // Handlers
+  void MSWOnSize(const int x, const int y, const WXUINT flag);
+  bool MSWOnCommand(const WXWORD id, const WXWORD cmd, const WXHWND control);
+  void MSWOnMenuHighlight(const WXWORD item, const WXWORD flags, const WXHMENU sysmenu);
+  bool MSWProcessMessage(WXMSG *msg);
+  void MSWOnCreate(WXLPCREATESTRUCT cs);
+  long MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+  bool MSWOnEraseBkgnd(const WXHDC pDC);
+  bool MSWOnDestroy(void);
+  bool MSWOnActivate(const int state, const bool minimized, const WXHWND activate);
+
+  // Responds to colour changes
+  void OnSysColourChanged(wxSysColourChangedEvent& event);
+
+ protected:
+    wxMDIClientWindow *             m_clientWindow;
+    wxMDIChildFrame *               m_currentChild;
+    WXHMENU                         m_windowMenu;
+    bool                            m_parentFrameActive; // TRUE if MDI Frame is intercepting
+                                                         // commands, not child
+    wxWindow *                      m_frameToolBar ;
+DECLARE_EVENT_TABLE()
+};
+
+// Inlines
+inline wxMDIClientWindow *wxMDIParentFrame::GetClientWindow(void) const { return m_clientWindow; }
+inline WXHMENU wxMDIParentFrame::GetWindowMenu(void) const { return m_windowMenu; }
+
+class WXDLLEXPORT wxMDIChildFrame: public wxFrame
+{
+  DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
+ public:
+
+  wxMDIChildFrame(void);
+  inline wxMDIChildFrame(wxMDIParentFrame *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxDEFAULT_FRAME_STYLE,
+           const wxString& name = wxFrameNameStr)
+  {
+      Create(parent, id, title, pos, size, style, name);
+  }
+
+  ~wxMDIChildFrame(void);
+
+  bool Create(wxMDIParentFrame *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxDEFAULT_FRAME_STYLE,
+           const wxString& name = wxFrameNameStr);
+
+  // Set menu bar
+  void SetMenuBar(wxMenuBar *menu_bar);
+  void SetClientSize(const int width, const int height);
+  void GetPosition(int *x, int *y) const ;
+
+  // MDI operations
+  virtual void Maximize(void);
+  virtual void Restore(void);
+  virtual void Activate(void);
+
+  // Handlers
+
+    long MSWOnMDIActivate(const long bActivate, const WXHWND, const WXHWND);
+    void MSWOnSize(const int x, const int y, const WXUINT);
+    void MSWOnWindowPosChanging(void *lpPos);
+    bool MSWOnCommand(const WXWORD id, const WXWORD cmd, const WXHWND control);
+    long MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+    bool MSWProcessMessage(WXMSG *msg);
+    void MSWDestroyWindow(void);
+
+    // Implementation
+    bool ResetWindowStyle(void *vrect);
+ protected:
+//    bool            m_active;
+};
+
+class WXDLLEXPORT wxMDIClientWindow: public wxWindow
+{
+  DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
+ public:
+
+  wxMDIClientWindow(void) ;
+  inline wxMDIClientWindow(wxMDIParentFrame *parent, const long style = 0)
+  {
+      CreateClient(parent, style);
+  }
+
+  ~wxMDIClientWindow(void);
+
+  // Note: this is virtual, to allow overridden behaviour.
+  virtual bool CreateClient(wxMDIParentFrame *parent, const long style = wxVSCROLL | wxHSCROLL);
+
+  // Explicitly call default scroll behaviour
+  void OnScroll(wxScrollEvent& event);
+
+  // Window procedure
+  virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+
+  // Calls an appropriate default window procedure
+  virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+
+  // Should hand the message to the default proc
+  long MSWOnMDIActivate(const long bActivate, const WXHWND, const WXHWND);
+
+protected:
+    int m_scrollX;
+    int m_scrollY;
+DECLARE_EVENT_TABLE()
+};
+
+#endif
+    // __MDIH__
diff --git a/include/wx/msw/menu.h b/include/wx/msw/menu.h
new file mode 100644
index 0000000000..0a9f3642c7
--- /dev/null
+++ b/include/wx/msw/menu.h
@@ -0,0 +1,174 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        menu.h
+// Purpose:     wxMenu, wxMenuBar classes
+// Author:      Julian Smart
+// Modified by: Vadim Zeitlin (wxMenuItem is now in separate file)
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __MENUH__
+#define __MENUH__
+
+#ifdef __GNUG__
+#pragma interface "menu.h"
+#endif
+
+#include "wx/defs.h"
+#include "wx/event.h"
+
+class wxMenuItem;
+class wxMenuBar;
+class wxMenu;
+
+WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
+
+// ----------------------------------------------------------------------------
+// Menu
+// ----------------------------------------------------------------------------
+class WXDLLEXPORT wxMenu: public wxEvtHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxMenu)
+
+public:
+  // ctor & dtor
+  wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
+  ~wxMenu();
+
+  // construct menu
+    // append items to the menu
+      // separator line
+  void AppendSeparator();
+      // normal item
+  void Append(int id, const wxString& Label, const wxString& helpString = wxEmptyString,
+              bool checkable = FALSE);
+      // a submenu
+  void Append(int id, const wxString& Label, wxMenu *SubMenu, 
+              const wxString& helpString = wxEmptyString);
+      // the most generic form (create wxMenuItem first and use it's functions)
+  void Append(wxMenuItem *pItem);
+    // insert a break in the menu
+  void Break();
+    // delete an item
+  void Delete(int id); /* If it's a submenu, menu is not destroyed. VZ: why? */
+
+  // menu item control
+  void Enable(int id, bool Flag);
+  bool Enabled(int id) const;
+  inline bool IsEnabled(int id) const { return Enabled(id); };
+  void Check(int id, bool Flag);
+  bool Checked(int id) const;
+  inline bool IsChecked(int id) const { return IsChecked(id); };
+
+  // item properties
+    // title
+  void SetTitle(const wxString& label);
+  const wxString& GetTitle() const;
+    // label
+  void SetLabel(int id, const wxString& label);
+  wxString GetLabel(int id) const;
+    // help string
+  virtual void SetHelpString(const int id, const wxString& helpString);
+  virtual wxString GetHelpString(const int id) const ;
+
+  // find item
+    // Finds the item id matching the given string, NOT_FOUND if not found.
+  virtual int FindItem(const wxString& itemString) const ;
+    // Find wxMenuItem by ID, and item's menu too if itemMenu is !NULL.
+  wxMenuItem *FindItemForId(const int itemId, wxMenu **itemMenu = NULL) const;
+
+  void ProcessCommand(wxCommandEvent& event);
+  inline void Callback(const wxFunction func) { m_callback = func; }
+
+  virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
+  inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
+  inline wxEvtHandler *GetEventHandler(void) { return m_eventHandler; }
+
+  // IMPLEMENTATION
+  bool MSWCommand(const WXUINT param, const WXWORD id);
+
+  void      SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; }
+  wxWindow *GetInvokingWindow()         const { return m_pInvokingWindow; }
+
+  // semi-private accessors
+    // get the window which contains this menu
+  wxWindow *GetWindow() const;
+    // get the menu handle
+  WXHMENU GetHMenu() const;
+
+private:
+  bool              m_doBreak ;
+
+public:
+  // This is used when m_hMenu is NULL because we don't want to
+  // delete it in ~wxMenu (it's been added to a parent menu).
+  // But we'll still need the handle for other purposes.
+  // Might be better to have a flag saying whether it's deleteable or not.
+  WXHMENU           m_savehMenu ; // Used for Enable() on popup
+  WXHMENU           m_hMenu;
+  wxFunction        m_callback;
+
+  int               m_noItems;
+  wxString          m_title;
+  wxMenu *          m_topLevelMenu;
+  wxMenuBar *       m_menuBar;
+  wxList            m_menuItems;
+  wxEvtHandler *    m_parent;
+  wxEvtHandler *    m_eventHandler;
+  wxWindow         *m_pInvokingWindow;
+};
+
+// ----------------------------------------------------------------------------
+// Menu Bar (a la Windows)
+// ----------------------------------------------------------------------------
+class wxFrame;
+class WXDLLEXPORT wxMenuBar: public wxEvtHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxMenuBar)
+
+  wxMenuBar(void);
+  wxMenuBar(const int n, wxMenu *menus[], const wxString titles[]);
+  ~wxMenuBar(void);
+
+  void Append(wxMenu *menu, const wxString& title);
+  // Must only be used AFTER menu has been attached to frame,
+  // otherwise use individual menus to enable/disable items
+  void Enable(const int Id, const bool Flag);
+  bool Enabled(const int Id) const ;
+  inline bool IsEnabled(const int Id) const { return Enabled(Id); };
+  void EnableTop(const int pos, const bool Flag);
+  void Check(const int id, const bool Flag);
+  bool Checked(const int id) const ;
+  inline bool IsChecked(const int Id) const { return Checked(Id); };
+  void SetLabel(const int id, const wxString& label) ;
+  wxString GetLabel(const int id) const ;
+  void SetLabelTop(const int pos, const wxString& label) ;
+  wxString GetLabelTop(const int pos) const ;
+  virtual void Delete(wxMenu *menu, const int index = 0); /* Menu not destroyed */
+  virtual bool OnAppend(wxMenu *menu, const char *title);
+  virtual bool OnDelete(wxMenu *menu, const int index);
+
+  virtual void SetHelpString(const int Id, const wxString& helpString);
+  virtual wxString GetHelpString(const int Id) const ;
+
+  virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ;
+
+  // Find wxMenuItem for item ID, and return item's
+  // menu too if itemMenu is non-NULL.
+  wxMenuItem *FindItemForId(const int itemId, wxMenu **menuForItem = NULL) const ;
+
+  inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
+  inline wxEvtHandler *GetEventHandler(void) { return m_eventHandler; }
+
+ public:
+  wxEvtHandler *            m_eventHandler;
+  int                       m_menuCount;
+  wxMenu **                 m_menus;
+  wxString *                m_titles;
+  wxFrame *                 m_menuBarFrame;
+  WXHMENU                   m_hMenu;
+};
+
+#endif // __MENUH__
diff --git a/include/wx/msw/metafile.h b/include/wx/msw/metafile.h
new file mode 100644
index 0000000000..c4c0665ed7
--- /dev/null
+++ b/include/wx/msw/metafile.h
@@ -0,0 +1,104 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        metafile.h
+// Purpose:     wxMetaFile, wxMetaFileDC classes
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+
+#ifndef __METAFIILEH__
+#define __METAFIILEH__
+
+#ifdef __GNUG__
+#pragma interface "metafile.h"
+#endif
+
+#include "wx/setup.h"
+
+#if USE_METAFILE
+#include "wx/dc.h"
+
+/*
+ * Metafile and metafile device context classes - work in Windows 3.1 only
+ *
+ */
+
+class WXDLLEXPORT wxDC;
+class WXDLLEXPORT wxMetaFile: public wxObject
+{
+  DECLARE_DYNAMIC_CLASS(wxMetaFile)
+ public:
+  wxMetaFile(const wxString& file = "");
+  ~wxMetaFile(void);
+
+  // After this is called, the metafile cannot be used for anything
+  // since it is now owned by the clipboard.
+  virtual bool SetClipboard(int width = 0, int height = 0);
+
+  virtual bool Play(wxDC *dc);
+  inline bool Ok(void) { return m_metaFile != 0; };
+
+  // Implementation
+  inline WXHANDLE GetHMETAFILE(void) { return m_metaFile; }
+  inline void SetHMETAFILE(WXHANDLE mf) { m_metaFile = mf; }
+  inline int GetWindowsMappingMode(void) { return m_windowsMappingMode; }
+  inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
+
+protected:
+  WXHANDLE m_metaFile;
+  int m_windowsMappingMode;
+};
+
+class WXDLLEXPORT wxMetaFileDC: public wxDC
+{
+  DECLARE_DYNAMIC_CLASS(wxMetaFileDC)
+
+ public:
+  // Don't supply origin and extent
+  // Supply them to wxMakeMetaFilePlaceable instead.
+  wxMetaFileDC(const wxString& file = "");
+
+  // Supply origin and extent (recommended).
+  // Then don't need to supply them to wxMakeMetaFilePlaceable.
+  wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
+
+  ~wxMetaFileDC(void);
+
+  // Should be called at end of drawing
+  virtual wxMetaFile *Close(void);
+  virtual void SetMapMode(int mode);
+  virtual void GetTextExtent(const wxString& string, float *x, float *y,
+                     float *descent = NULL, float *externalLeading = NULL,
+                     wxFont *theFont = NULL, bool use16bit = FALSE);
+
+  // Implementation
+  inline wxMetaFile *GetMetaFile(void) { return m_metaFile; }
+  inline void SetMetaFile(wxMetaFile *mf) { m_metaFile = mf; }
+  inline int GetWindowsMappingMode(void) { return m_windowsMappingMode; }
+  inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
+
+protected:
+  int m_windowsMappingMode;
+  wxMetaFile *m_metaFile;
+};
+
+/*
+ * Pass filename of existing non-placeable metafile, and bounding box.
+ * Adds a placeable metafile header, sets the mapping mode to anisotropic,
+ * and sets the window origin and extent to mimic the MM_TEXT mapping mode.
+ *
+ */
+
+// No origin or extent
+bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, float scale = 1.0);
+
+// Optional origin and extent
+bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
+
+#endif // USE_METAFILE
+#endif
+    // __METAFIILEH__
diff --git a/include/wx/msw/minifram.h b/include/wx/msw/minifram.h
new file mode 100644
index 0000000000..54d025e255
--- /dev/null
+++ b/include/wx/msw/minifram.h
@@ -0,0 +1,46 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        minifram.h
+// Purpose:     wxMiniFrame class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __MINIFRAMH__
+#define __MINIFRAMH__
+
+#ifdef __GNUG__
+#pragma interface "minifram.h"
+#endif
+
+#include "wx/frame.h"
+
+class WXDLLEXPORT wxMiniFrame: public wxFrame {
+
+  DECLARE_DYNAMIC_CLASS(wxMiniFrame)
+
+public:
+  inline wxMiniFrame(void) {}
+  inline wxMiniFrame(wxWindow *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxDEFAULT_FRAME|wxTINY_CAPTION_HORIZ,
+           const wxString& name = wxFrameNameStr)
+  {
+      Create(parent, id, title, pos, size, style, name);
+  }
+
+  ~wxMiniFrame(void);
+
+  long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+
+protected:
+};
+
+#endif
+    // __MINIFRAMH__
diff --git a/include/wx/msw/msgdlg.h b/include/wx/msw/msgdlg.h
new file mode 100644
index 0000000000..7188bb2f62
--- /dev/null
+++ b/include/wx/msw/msgdlg.h
@@ -0,0 +1,49 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        msgdlg.h
+// Purpose:     wxMessageDialog class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __MSGBOXDLGH__
+#define __MSGBOXDLGH__
+
+#ifdef __GNUG__
+#pragma interface "msgdlg.h"
+#endif
+
+#include "wx/setup.h"
+#include "wx/dialog.h"
+
+/*
+ * Message box dialog
+ */
+
+WXDLLEXPORT_DATA(extern const char*) wxMessageBoxCaptionStr;
+
+class WXDLLEXPORT wxMessageDialog: public wxDialog
+{
+DECLARE_DYNAMIC_CLASS(wxMessageDialog)
+protected:
+    wxString    m_caption;
+    wxString    m_message;
+    long        m_dialogStyle;
+    wxWindow *  m_parent;
+public:
+    wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,
+        long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
+
+    int ShowModal(void);
+};
+
+
+int WXDLLEXPORT wxMessageBox(const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,
+  const long style = wxOK|wxCENTRE,
+  wxWindow *parent = NULL, const int x = -1, const int y = -1);
+
+#endif
+    // __MSGBOXDLGH__
diff --git a/include/wx/msw/noentry.cur b/include/wx/msw/noentry.cur
new file mode 100644
index 0000000000000000000000000000000000000000..b002e96b36dc2bd4664a6b7ef2d08c5a8f25f5a9
GIT binary patch
literal 326
zcmZ{eJqp4=5QX1t0<jRH7Lr29lFBmaEP}g63lAk^vCg4_CkdXwGR2Z{*9ZYIZ<t?r
z9|H&wqy%CYIRRS$dzbD6?UG!4^ljrZRc4-+-zn;VByq41I6r}A4O&S<@?wN+v^Z_F
zs4^`sl@`~#7DcEj3k`(}gQjqv$LRG8&zh0@;lKKnxr><FfY}gp(D4wr^^ls{rcm~{
gRJPnHdnlF7Z_1)q1NHR~ylM{G(c`_I;aM|!19Gr%*Z=?k

literal 0
HcmV?d00001

diff --git a/include/wx/msw/palette.h b/include/wx/msw/palette.h
new file mode 100644
index 0000000000..bddc8a334c
--- /dev/null
+++ b/include/wx/msw/palette.h
@@ -0,0 +1,66 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        palette.h
+// Purpose:     wxPalette class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __PALETTEH__
+#define __PALETTEH__
+
+#ifdef __GNUG__
+#pragma interface "palette.h"
+#endif
+
+#include "wx/gdiobj.h"
+
+class WXDLLEXPORT wxPalette;
+
+class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData
+{
+    friend class WXDLLEXPORT wxPalette;
+public:
+    wxPaletteRefData(void);
+    ~wxPaletteRefData(void);
+protected:
+ WXHPALETTE m_hPalette;
+};
+
+#define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
+
+class WXDLLEXPORT wxPalette: public wxGDIObject
+{
+  DECLARE_DYNAMIC_CLASS(wxPalette)
+
+public:
+  wxPalette(void);
+  inline wxPalette(const wxPalette& palette) { Ref(palette); }
+  inline wxPalette(const wxPalette* palette) { /* UnRef(); */ if (palette) Ref(*palette); }
+
+  wxPalette(const int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
+  ~wxPalette(void);
+  bool Create(const int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
+  int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const;
+  bool GetRGB(const int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
+
+  virtual bool Ok(void) const { return (m_refData != NULL) ; }
+
+  inline wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; }
+  inline bool operator == (const wxPalette& palette) { return m_refData == palette.m_refData; }
+  inline bool operator != (const wxPalette& palette) { return m_refData != palette.m_refData; }
+
+  virtual bool FreeResource(bool force = FALSE);
+
+  inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); }
+  void SetHPALETTE(WXHPALETTE pal);
+};
+
+#define wxColorMap wxPalette
+#define wxColourMap wxPalette
+
+#endif
+    // __PALETTEH__
diff --git a/include/wx/msw/pbrush.cur b/include/wx/msw/pbrush.cur
new file mode 100644
index 0000000000000000000000000000000000000000..97212e3faad4bb1f28892269ee9bdfed99e70a85
GIT binary patch
literal 326
zcmaKmF%m#95Jg{%(HWi5Q7Rq5C7dUY>Ihnm^@EIRz06DYXET|Fg1|69O~(|V1xBeW
zW*M|@-s1`1Zf0Nbs%3_3+#s3Ab-zNTT>hw*hh}g&=`~^V@2WRjG~4x!=b@g%1>swF
A?*IS*

literal 0
HcmV?d00001

diff --git a/include/wx/msw/pen.h b/include/wx/msw/pen.h
new file mode 100644
index 0000000000..9604745a00
--- /dev/null
+++ b/include/wx/msw/pen.h
@@ -0,0 +1,98 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        pen.h
+// Purpose:     wxPen class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __PENH__
+#define __PENH__
+
+#ifdef __GNUG__
+#pragma interface "pen.h"
+#endif
+
+#include "wx/gdiobj.h"
+
+typedef    WXDWORD  wxDash ;
+
+class WXDLLEXPORT wxPen;
+
+class WXDLLEXPORT wxPenRefData: public wxGDIRefData
+{
+    friend class WXDLLEXPORT wxPen;
+public:
+    wxPenRefData(void);
+    ~wxPenRefData(void);
+
+protected:
+  int           m_width;
+  int           m_style;
+  int           m_join ;
+  int           m_cap ;
+  wxBitmap      m_stipple ;
+  int           m_nbDash ;
+  wxDash *      m_dash ;
+  wxColour      m_colour;
+  WXHPEN        m_hPen;
+};
+
+#define M_PENDATA ((wxPenRefData *)m_refData)
+
+// Pen
+class WXDLLEXPORT wxPen: public wxGDIObject
+{
+  DECLARE_DYNAMIC_CLASS(wxPen)
+public:
+  wxPen(void);
+  wxPen(const wxColour& col, const int width, const int style);
+  wxPen(const wxString& col, const int width, const int style);
+  wxPen(const wxBitmap& stipple, const int width);
+  inline wxPen(const wxPen& pen) { Ref(pen); }
+  inline wxPen(const wxPen* pen) { /* UnRef(); */ if (pen) Ref(*pen); }
+  ~wxPen(void);
+
+  inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
+  inline bool operator == (const wxPen& pen) { return m_refData == pen.m_refData; }
+  inline bool operator != (const wxPen& pen) { return m_refData != pen.m_refData; }
+
+  virtual bool Ok(void) const { return (m_refData != NULL) ; }
+
+  // Override in order to recreate the pen
+  void SetColour(const wxColour& col) ;
+  void SetColour(const wxString& col)  ;
+  void SetColour(const unsigned char r, const unsigned char g, const unsigned char b)  ;
+
+  void SetWidth(const int width)  ;
+  void SetStyle(const int style)  ;
+  void SetStipple(const wxBitmap& stipple)  ;
+  void SetDashes(const int nb_dashes, const wxDash *dash)  ;
+  void SetJoin(const int join)  ;
+  void SetCap(const int cap)  ;
+
+  inline wxColour& GetColour(void) const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
+  inline int GetWidth(void) const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
+  inline int GetStyle(void) const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
+  inline int GetJoin(void) const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
+  inline int GetCap(void) const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
+  inline int GetDashes(wxDash **ptr) const {
+     *ptr = (M_PENDATA ? M_PENDATA->m_dash : NULL); return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
+  }
+
+  inline wxBitmap *GetStipple(void) const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : NULL); };
+
+  // Internal
+  bool RealizeResource(void);
+  bool FreeResource(bool force = FALSE);
+  WXHANDLE GetResourceHandle(void) ;
+  bool IsFree(void);
+};
+
+int wx2msPenStyle(int wx_style);
+
+#endif
+    // __PENH__
diff --git a/include/wx/msw/pencil.cur b/include/wx/msw/pencil.cur
new file mode 100644
index 0000000000000000000000000000000000000000..231ed1e79f7bc3c1b4291024697607f58f1c91ba
GIT binary patch
literal 326
zcmbWxAr8Vo5QX8lG@*{707F<=i9liKq44YtxB^G%5jX-8Sy>X&#}92%f$MC(o!QMy
zGSW;zF^X7fAEXskiHHh;^NS(%kMXuWJ|<LYnAwmIIAV)MlJZK*ZtQU9<B2oA4Qmvb
igJ6frab+?`hJb|nVn0rHv$Na6e$&wXHPF=9e%T-W#C(JR

literal 0
HcmV?d00001

diff --git a/include/wx/msw/pnghand.h b/include/wx/msw/pnghand.h
new file mode 100644
index 0000000000..1de5e7f75a
--- /dev/null
+++ b/include/wx/msw/pnghand.h
@@ -0,0 +1,27 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        pnghand.h
+// Purpose:     PNG bitmap handler
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Microsoft, Julian Smart
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxPNGFileHandler)
+public:
+  inline wxPNGFileHandler(void)
+  {
+	m_name = "PNG bitmap file";
+	m_extension = "bmp";
+	m_type = wxBITMAP_TYPE_PNG;
+  };
+
+  virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+      int desiredWidth, int desiredHeight);
+  virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *palette = NULL);
+};
+
diff --git a/include/wx/msw/pngread.h b/include/wx/msw/pngread.h
new file mode 100644
index 0000000000..ed6cc8fa78
--- /dev/null
+++ b/include/wx/msw/pngread.h
@@ -0,0 +1,294 @@
+/*
+ * File:	pngread.h
+ * Purpose:	PNG file reader
+ * Author:	Alejandro Aguilar Sierra/Julian Smart
+ * Created:	1995
+ * Copyright:	(c) 1995, Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ *
+ *
+ */
+
+#ifndef __PNGREAD__
+#define __PNGREAD__
+
+#ifdef __GNUG__
+#pragma interface "pngread.h"
+#endif
+
+#ifndef byte
+typedef unsigned char byte;
+#endif
+
+#define WXIMA_COLORS DIB_PAL_COLORS
+
+#ifdef __WIN32__
+typedef byte* ImagePointerType;
+#else
+typedef byte huge* ImagePointerType;
+#endif
+
+typedef struct
+{
+	byte red;
+	byte green;
+   byte blue;
+} rgb_color_struct;
+
+
+#define COLORTYPE_PALETTE	1
+#define COLORTYPE_COLOR		2
+#define COLORTYPE_ALPHA		4
+
+class wxPNGReader
+{
+protected:
+  int filetype;
+  char filename[255];
+  ImagePointerType RawImage;  		//  Image data
+
+  int Width, Height;   		//  Dimensions
+  int Depth;	 				// (bits x pixel)
+  int ColorType;				// Bit 1 = Palette used
+									// Bit 2 = Color used
+									// Bit 3 = Alpha used
+
+  long EfeWidth;	 			// Efective Width
+
+  LPBITMAPINFOHEADER lpbi;
+  int bgindex;
+  wxPalette* Palette;
+  bool imageOK;
+friend class wxPNGReaderIter;
+public:
+  wxPNGReader(void);
+  wxPNGReader (char* ImageFileName);     // Read an image file
+  ~wxPNGReader ();
+
+  void Create(int width, int height, int deep, int colortype=-1);
+
+  bool ReadFile( char* ImageFileName=0 );
+  bool SaveFile( char* ImageFileName=0 );
+  bool SaveXPM(char *filename, char *name = 0);
+  int  GetWidth( void ) const { return Width; };
+  int  GetHeight( void ) const { return Height; };
+  int  GetDepth( void ) const { return Depth; };
+  int  GetColorType( void ) const { return ColorType; };
+
+  int  GetIndex(int x, int y);
+  bool GetRGB(int x, int y, byte* r, byte* g, byte* b);
+
+  bool SetIndex(int x, int y, int index);
+  bool SetRGB(int x, int y, byte r, byte g, byte b);
+
+  // ColorMap settings
+  bool SetPalette(wxPalette* colourmap);
+  bool SetPalette(int n, rgb_color_struct *rgb_struct);
+  bool SetPalette(int n, byte *r, byte *g=0, byte *b=0);
+  wxPalette* GetPalette() const { return Palette; }
+
+  void NullData();
+  inline int GetBGIndex(void) { return bgindex; }
+
+  inline bool Inside(int x, int y)
+      { return (0<=y && y<Height && 0<=x && x<Width); }
+
+  virtual wxBitmap *GetBitmap(void);
+  virtual bool InstantiateBitmap(wxBitmap *bitmap);
+  wxMask *CreateMask(void);
+
+  inline bool Ok(void) { return imageOK; }
+};
+
+class wxPNGReaderIter
+{
+protected:
+  int Itx, Ity;				// Counters
+  int Stepx, Stepy;
+  ImagePointerType IterImage;  		//  Image pointer
+  wxPNGReader *ima;
+public:
+// Constructors
+  wxPNGReaderIter ( void );
+  wxPNGReaderIter ( wxPNGReader *imax );
+  operator wxPNGReader* ();
+
+// Iterators
+  bool ItOK ();
+  void reset ();
+  void upset ();
+  void SetRow(byte *buf, int n);
+  void GetRow(byte *buf, int n);
+  byte GetByte( ) { return IterImage[Itx]; }
+  void SetByte(byte b) { IterImage[Itx] = b; }
+  ImagePointerType GetRow(void);
+  bool NextRow();
+  bool PrevRow();
+  bool NextByte();
+  bool PrevByte();
+
+  void SetSteps(int x, int y=0) {  Stepx = x; Stepy = y; }
+  void GetSteps(int *x, int *y) {  *x = Stepx; *y = Stepy; }
+  bool NextStep();
+  bool PrevStep();
+
+////////////////////////// AD - for interlace ///////////////////////////////
+  void SetY(int y);
+/////////////////////////////////////////////////////////////////////////////
+};
+
+
+inline
+wxPNGReaderIter::wxPNGReaderIter(void)
+{
+  ima = 0;
+  IterImage = 0;
+  Itx = Ity = 0;
+  Stepx = Stepy = 0;
+}
+
+inline
+wxPNGReaderIter::wxPNGReaderIter(wxPNGReader *imax): ima(imax)
+{
+  if (ima)
+	 IterImage = ima->RawImage;
+  Itx = Ity = 0;
+  Stepx = Stepy = 0;
+}
+
+inline
+wxPNGReaderIter::operator wxPNGReader* ()
+{
+  return ima;
+}
+
+inline
+bool wxPNGReaderIter::ItOK ()
+{
+  if (ima)
+	 return ima->Inside(Itx, Ity);
+  else
+	 return FALSE;
+}
+
+
+inline void wxPNGReaderIter::reset()
+{
+  IterImage = ima->RawImage;
+  Itx = Ity = 0;
+}
+
+inline void wxPNGReaderIter::upset()
+{
+  Itx = 0;
+  Ity = ima->Height-1;
+  IterImage = ima->RawImage + ima->EfeWidth*(ima->Height-1);
+}
+
+inline bool wxPNGReaderIter::NextRow()
+{
+  if (++Ity >= ima->Height) return 0;
+  IterImage += ima->EfeWidth;
+  return 1;
+}
+
+inline bool wxPNGReaderIter::PrevRow()
+{
+  if (--Ity < 0) return 0;
+  IterImage -= ima->EfeWidth;
+  return 1;
+}
+
+////////////////////////// AD - for interlace ///////////////////////////////
+inline void wxPNGReaderIter::SetY(int y)
+{
+  if ((y < 0) || (y > ima->Height)) return;
+  Ity = y;
+  IterImage = ima->RawImage + ima->EfeWidth*y;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+inline void wxPNGReaderIter::SetRow(byte *buf, int n)
+{
+// Here should be bcopy or memcpy
+  //_fmemcpy(IterImage, (void far *)buf, n);
+  if (n<0)
+	 n = ima->GetWidth();
+
+  for (int i=0; i<n; i++) IterImage[i] = buf[i];
+}
+
+inline void wxPNGReaderIter::GetRow(byte *buf, int n)
+{
+  for (int i=0; i<n; i++) buf[i] = IterImage[i];
+}
+
+inline ImagePointerType wxPNGReaderIter::GetRow()
+{
+  return IterImage;
+}
+
+inline bool wxPNGReaderIter::NextByte()
+{
+  if (++Itx < ima->EfeWidth)
+	 return 1;
+  else
+	 if (++Ity < ima->Height)
+	 {
+		IterImage += ima->EfeWidth;
+		Itx = 0;
+		return 1;
+	 } else
+		return 0;
+}
+
+inline bool wxPNGReaderIter::PrevByte()
+{
+  if (--Itx >= 0)
+	 return 1;
+  else
+	 if (--Ity >= 0)
+	 {
+		IterImage -= ima->EfeWidth;
+		Itx = 0;
+		return 1;
+	 } else
+		return 0;
+}
+
+inline bool wxPNGReaderIter::NextStep()
+{
+  Itx += Stepx;
+  if (Itx < ima->EfeWidth)
+	 return 1;
+  else {
+	 Ity += Stepy;
+	 if (Ity < ima->Height)
+	 {
+		IterImage += ima->EfeWidth;
+		Itx = 0;
+		return 1;
+	 } else
+		return 0;
+  }
+}
+
+inline bool wxPNGReaderIter::PrevStep()
+{
+  Itx -= Stepx;
+  if (Itx >= 0)
+	 return 1;
+  else {       
+	 Ity -= Stepy;
+	 if (Ity >= 0 && Ity < ima->Height)
+	 {
+		IterImage -= ima->EfeWidth;
+		Itx = 0;
+		return 1;
+	 } else
+		return 0;
+  }
+}
+
+#endif
+
diff --git a/include/wx/msw/pntleft.cur b/include/wx/msw/pntleft.cur
new file mode 100644
index 0000000000000000000000000000000000000000..222b25b86408566858225dab95d0d8e78a86babc
GIT binary patch
literal 326
zcmaiuyAc905JR<G;D8xIA_9kmbYME+%D9Mg2XsIyY$=pL#zqK@`CMpuo>%f`ZD0jM
z&XCqP7_gPwi!6@9G@8EU6PB6e5_)c<19k;=r;4FCrkmqDJCX=N<wBn?tm*jzO7uFm
hef^=MA^5<^JJ4{|Ds=mYUW1nYk{<&W^wjB1z5x{0Zb|?E

literal 0
HcmV?d00001

diff --git a/include/wx/msw/pntright.cur b/include/wx/msw/pntright.cur
new file mode 100644
index 0000000000000000000000000000000000000000..e9b6b5037eded13660d3ea0154f0de96463479a1
GIT binary patch
literal 326
zcmaivF%H5o3`L)@R0ak%M$(ayk&z>@vd|u_N68HkD=IZVP*JAV(X;&%%ld&8MqNW<
z!_i;|9E7eo3)A_;SiWM)5iyCy?gG~qd!F#V!(V%RxQQ&1bl}lr@fc|Cnba?CECcc|
f8>x$^*vja7#8s^r|EH1u{jyS@T2f@6-CZ8va`9(v

literal 0
HcmV?d00001

diff --git a/include/wx/msw/printdlg.h b/include/wx/msw/printdlg.h
new file mode 100644
index 0000000000..ba5af57c5e
--- /dev/null
+++ b/include/wx/msw/printdlg.h
@@ -0,0 +1,71 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        printdlg.h
+// Purpose:     wxPrintDialog, wxPageSetupDialog classes
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __PRINTDLGH__
+#define __PRINTDLGH__
+
+#ifdef __GNUG__
+#pragma interface "printdlg.h"
+#endif
+
+#include "wx/dialog.h"
+#include "wx/cmndata.h"
+
+/*
+ * wxPrinterDialog
+ * The common dialog for printing.
+ */
+
+class WXDLLEXPORT wxDC;
+class WXDLLEXPORT wxPrintDialog: public wxDialog
+{
+  DECLARE_DYNAMIC_CLASS(wxPrintDialog)
+
+ private:
+  wxPrintData printData;
+  wxDC *printerDC;
+  bool destroyDC;
+  char *deviceName;
+  char *driverName;
+  char *portName;
+  wxWindow *dialogParent;
+ public:
+  wxPrintDialog(void);
+  wxPrintDialog(wxWindow *parent, wxPrintData* data = NULL);
+  ~wxPrintDialog(void);
+
+  bool Create(wxWindow *parent, wxPrintData* data = NULL);
+  virtual int ShowModal(void);
+
+  inline wxPrintData& GetPrintData(void) { return printData; }
+  virtual wxDC *GetPrintDC(void);
+};
+
+class WXDLLEXPORT wxPageSetupDialog: public wxDialog
+{
+  DECLARE_DYNAMIC_CLASS(wxPageSetupDialog)
+
+ private:
+  wxPageSetupData   m_pageSetupData;
+  wxWindow*         m_dialogParent;
+ public:
+  wxPageSetupDialog(void);
+  wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL);
+  ~wxPageSetupDialog(void);
+
+  bool Create(wxWindow *parent, wxPageSetupData *data = NULL);
+  virtual int ShowModal(void);
+
+  inline wxPageSetupData& GetPageSetupData(void) { return m_pageSetupData; }
+};
+
+#endif
+    // __PRINTDLGH__
diff --git a/include/wx/msw/printwin.h b/include/wx/msw/printwin.h
new file mode 100644
index 0000000000..6ba0aa6a72
--- /dev/null
+++ b/include/wx/msw/printwin.h
@@ -0,0 +1,58 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        printwin.h
+// Purpose:     wxWindowsPrinter, wxWindowsPrintPreview classes
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __PRINTWINH__
+#define __PRINTWINH__
+
+#ifdef __GNUG__
+#pragma interface "printwin.h"
+#endif
+
+#include "wx/prntbase.h"
+
+/*
+ * Represents the printer: manages printing a wxPrintout object
+ */
+ 
+class WXDLLEXPORT wxWindowsPrinter: public wxPrinterBase
+{
+  DECLARE_DYNAMIC_CLASS(wxWindowsPrinter)
+
+ private:
+  WXFARPROC lpAbortProc;
+ public:
+  wxWindowsPrinter(wxPrintData *data = NULL);
+  ~wxWindowsPrinter(void);
+
+  virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
+  virtual bool PrintDialog(wxWindow *parent);
+  virtual bool Setup(wxWindow *parent);
+};
+
+/*
+ * wxPrintPreview
+ * Programmer creates an object of this class to preview a wxPrintout.
+ */
+ 
+class WXDLLEXPORT wxWindowsPrintPreview: public wxPrintPreviewBase
+{
+  DECLARE_CLASS(wxWindowsPrintPreview)
+
+ public:
+  wxWindowsPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = NULL, wxPrintData *data = NULL);
+  ~wxWindowsPrintPreview(void);
+
+  virtual bool Print(bool interactive);
+  virtual void DetermineScaling(void);
+};
+
+#endif
+    // __PRINTWINH__
diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h
new file mode 100644
index 0000000000..5a3635e748
--- /dev/null
+++ b/include/wx/msw/private.h
@@ -0,0 +1,146 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        private.h
+// Purpose:     Private declarations
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __PRIVATEH__
+#define __PRIVATEH__
+
+#include "wx/defs.h"
+
+#include <windows.h>
+
+#define VIEWPORT_EXTENT 1000
+
+class WXDLLEXPORT wxFont ;
+
+void WXDLLEXPORT wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
+void WXDLLEXPORT wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
+wxWindow* WXDLLEXPORT wxFindWinFromHandle(WXHWND hWnd);
+void WXDLLEXPORT wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);
+
+WXDLLEXPORT_DATA(extern HICON) wxSTD_FRAME_ICON;
+WXDLLEXPORT_DATA(extern HICON) wxSTD_MDIPARENTFRAME_ICON;
+WXDLLEXPORT_DATA(extern HICON) wxSTD_MDICHILDFRAME_ICON;
+WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_FRAME_ICON;
+WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDIPARENTFRAME_ICON;
+WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDICHILDFRAME_ICON;
+WXDLLEXPORT_DATA(extern HFONT) wxSTATUS_LINE_FONT;
+
+extern HINSTANCE WXDLLEXPORT wxGetInstance();
+void WXDLLEXPORT wxFillLogFont(LOGFONT *logFont, wxFont *font);
+wxFont WXDLLEXPORT wxCreateFontFromLogFont(LOGFONT *logFont); // , bool createNew = TRUE);
+
+#ifdef __GNUWIN32__
+#define CASTWNDPROC (long unsigned)
+#else
+#define CASTWNDPROC
+#endif
+
+#if !defined(APIENTRY)	// NT defines APIENTRY, 3.x not
+#define APIENTRY FAR PASCAL
+#endif
+ 
+#ifdef __WIN32__
+#define _EXPORT /**/
+#else
+#define _EXPORT _export
+typedef signed short int SHORT ;
+#endif
+ 
+#if !defined(__WIN32__)	// 3.x uses FARPROC for dialogs
+#define DLGPROC FARPROC
+#endif
+
+#if USE_PENWIN
+void WXDLLEXPORT wxRegisterPenWin(void);
+void WXDLLEXPORT wxCleanUpPenWin(void);
+void WXDLLEXPORT wxEnablePenAppHooks (bool hook);
+#endif
+
+#if USE_ITSY_BITSY
+#define IBS_HORZCAPTION    0x4000L
+#define IBS_VERTCAPTION    0x8000L
+
+UINT    WINAPI ibGetCaptionSize( HWND hWnd  ) ;
+UINT    WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize ) ;
+LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam ) ;
+VOID    WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
+#endif
+
+/* When implementing a new item, be sure to:
+ *
+ * - add the item to the parent panel
+ * - set window_parent to the parent
+ * - NULL any extra child window pointers not created for this item
+ *   (e.g. label control that wasn't needed)
+ * - delete any extra child windows in the destructor (e.g. label control)
+ * - implement GetSize and SetSize
+ * - to find panel position if coordinates are (-1, -1), use GetPosition
+ * - call AdvanceCursor after creation, for panel layout mechanism.
+ *
+ */
+
+#if CTL3D
+#include <wx/msw/ctl3d/ctl3d.h>
+#endif
+
+/*
+ * Decide what window classes we're going to use
+ * for this combination of CTl3D/FAFA settings
+ */
+ 
+#define STATIC_CLASS     "STATIC"
+#define STATIC_FLAGS     (SS_LEFT|WS_CHILD|WS_VISIBLE)
+#define CHECK_CLASS      "BUTTON"
+#define CHECK_FLAGS      (BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD)
+#define CHECK_IS_FAFA   FALSE
+#define RADIO_CLASS      "BUTTON"
+#define RADIO_FLAGS      (BS_AUTORADIOBUTTON|WS_CHILD|WS_VISIBLE)
+#define RADIO_SIZE       20
+#define RADIO_IS_FAFA   FALSE
+#define PURE_WINDOWS
+#define GROUP_CLASS      "BUTTON"
+#define GROUP_FLAGS      (BS_GROUPBOX|WS_CHILD|WS_VISIBLE)
+
+/*
+#define BITCHECK_FLAGS   (FB_BITMAP|FC_BUTTONDRAW|FC_DEFAULT|WS_VISIBLE)
+#define BITRADIO_FLAGS   (FC_BUTTONDRAW|FB_BITMAP|FC_RADIO|WS_CHILD|WS_VISIBLE)
+*/
+
+#define MEANING_CHARACTER '0'
+#define DEFAULT_ITEM_WIDTH  200
+#define DEFAULT_ITEM_HEIGHT 80
+#define EDIT_CONTROL_FACTOR (15.0/10.0)
+                                        // Scale font to get edit control height
+
+// Generic subclass proc, for panel item moving/sizing and intercept
+// EDIT control VK_RETURN messages
+extern LONG APIENTRY _EXPORT
+  wxSubclassedGenericControlProc(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+// Find maximum size of window/rectangle
+extern void WXDLLEXPORT wxFindMaxSize(WXHWND hwnd, RECT *rect);
+
+// List of scrollbar controls
+WXDLLEXPORT_DATA(extern wxList) wxScrollBarList;
+// The MakeProcInstance version of the function wxSubclassedGenericControlProc
+WXDLLEXPORT_DATA(extern FARPROC) wxGenericControlSubClassProc;
+WXDLLEXPORT_DATA(extern char*) wxBuffer;
+WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance;
+
+wxWindow* WXDLLEXPORT wxFindControlFromHandle(WXHWND hWnd);
+void WXDLLEXPORT wxAddControlHandle(WXHWND hWnd, wxWindow *item);
+
+#if !defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE)
+#define WS_EX_CLIENTEDGE 0
+#endif
+
+#endif
+    // __PRIVATEH__
diff --git a/include/wx/msw/query.cur b/include/wx/msw/query.cur
new file mode 100644
index 0000000000000000000000000000000000000000..3578e90fd956ff8ff5288634e9c7a96505910746
GIT binary patch
literal 326
zcmZY3t#Se}6vgp>Hakt+Mqv|)MAmgtyhc@ZC4%9jHGQm=eGD9SC4%Afrj%iJdNRM9
z+^Yf&j#3(G77k|Cb5l%joSonN)opm(k{-kT6$Xf9s_tq|1AG@;^;PgyEUenZTNBy3
zmfiTlu3b)SZQgtySoaO@rR6n6`j{Xbu|G_6ev!sJWxH!9U86Nwmvr;I$V!HFCpJMm
Yc@doO`~N_0@8k!sa183kPWhbm0~DuU7XSbN

literal 0
HcmV?d00001

diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h
new file mode 100644
index 0000000000..36c1882277
--- /dev/null
+++ b/include/wx/msw/radiobox.h
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        radiobox.h
+// Purpose:     wxRadioBox class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __RADIOBOXH__
+#define __RADIOBOXH__
+
+#ifdef __GNUG__
+#pragma interface "radiobox.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxRadioBoxNameStr;
+
+// List box item
+class WXDLLEXPORT wxBitmap ;
+
+class WXDLLEXPORT wxRadioBox: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxRadioBox)
+public:
+  wxRadioBox(void);
+
+#if WXWIN_COMPATIBILITY
+  wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
+             int x = -1, int y = -1, int width = -1, int height = -1,
+             int n = 0, char **choices = NULL,
+             int majorDim = 0, long style = wxRA_HORIZONTAL, const char *name = wxRadioBoxNameStr);
+
+/*
+  inline wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
+             int x, int y, int width, int height,
+             int n, wxBitmap **choices,
+             int majorDim = 0, long style = wxRA_HORIZONTAL, const char *name = wxRadioBoxNameStr)
+  {
+    Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), n, (const wxBitmap **)choices, majorDim, style,
+        wxDefaultValidator, name);
+    Callback(func);
+  }
+*/
+
+#endif
+
+  inline wxRadioBox(wxWindow *parent, const wxWindowID id, const wxString& title,
+             const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+             const int n = 0, const wxString choices[] = NULL,
+             const int majorDim = 0, const long style = wxRA_HORIZONTAL,
+             const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr)
+  {
+    Create(parent, id, title, pos, size, n, choices, majorDim, style, val, name);
+  }
+
+/*
+  wxRadioBox(wxWindow *parent, const wxWindowID id, const wxString& title,
+             const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+             const int n = 0, const wxBitmap *choices[] = NULL,
+             const int majorDim = 0, const long style = wxRA_HORIZONTAL,
+             const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr)
+  {
+    Create(parent, id, title, pos, size, n, choices, majorDim, style, val, name);
+  }
+*/
+
+  ~wxRadioBox(void);
+
+  bool Create(wxWindow *parent, const wxWindowID id, const wxString& title,
+             const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+             const int n = 0, const wxString choices[] = NULL,
+             const int majorDim = 0, const long style = wxRA_HORIZONTAL,
+             const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr);
+
+/*
+  bool Create(wxWindow *parent, const wxWindowID id, const wxString& title,
+             const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+             const int n = 0, const wxBitmap *choices[] = NULL,
+             const int majorDim = 0, const long style = wxRA_HORIZONTAL,
+             const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr);
+*/
+
+  virtual bool MSWCommand(const WXUINT param, const WXWORD id);
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+  int FindString(const wxString& s) const;
+  void SetSelection(const int N);
+  int GetSelection(void) const;
+  wxString GetString(const int N) const;
+  void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+  void GetSize(int *x, int *y) const;
+  void GetPosition(int *x, int *y) const;
+  wxString GetLabel(void) const;
+  void SetLabel(const wxString& label);
+  void SetLabel(const int item, const wxString& label) ;
+  void SetLabel(const int item, wxBitmap *bitmap) ;
+  wxString GetLabel(const int item) const;
+  bool Show(const bool show);
+  void SetFocus(void);
+  void Enable(const bool enable);
+  void Enable(const int item, const bool enable);
+  void Show(const int item, const bool show) ;
+  inline void SetLabelFont(const wxFont& WXUNUSED(font)) {};
+  inline void SetButtonFont(const wxFont& font) { SetFont(font); }
+
+  virtual wxString GetStringSelection(void) const;
+  virtual bool SetStringSelection(const wxString& s);
+  inline virtual int Number(void) const { return m_noItems; } ;
+  void Command(wxCommandEvent& event);
+  
+  inline int GetNumberOfRowsOrCols(void) const { return m_noRowsOrCols; }
+  inline void SetNumberOfRowsOrCols(const int n) { m_noRowsOrCols = n; }
+
+  // Implementation
+  inline WXHWND *GetRadioButtons(void) const { return m_radioButtons; }
+  bool ContainsHWND(WXHWND hWnd) const ;
+
+protected:
+  WXHWND *          m_radioButtons;
+  int               m_majorDim ;
+  int *             m_radioWidth ;  // for bitmaps
+  int *             m_radioHeight ;
+
+  int               m_noItems;
+  int               m_noRowsOrCols;
+  int               m_selectedButton;
+
+};
+
+#endif
+    // __RADIOBOXH__
diff --git a/include/wx/msw/radiobut.h b/include/wx/msw/radiobut.h
new file mode 100644
index 0000000000..d78fdf1d5d
--- /dev/null
+++ b/include/wx/msw/radiobut.h
@@ -0,0 +1,92 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        radiobut.h
+// Purpose:     wxRadioButton class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __RADIOBUTH__
+#define __RADIOBUTH__
+
+#ifdef __GNUG__
+#pragma interface "radiobut.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxRadioButtonNameStr;
+
+class WXDLLEXPORT wxRadioButton: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxRadioButton)
+ protected:
+ public:
+  inline wxRadioButton(void) {}
+  inline wxRadioButton(wxWindow *parent, const wxWindowID id,
+           const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxRadioButtonNameStr)
+  {
+      Create(parent, id, label, pos, size, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxRadioButtonNameStr);
+
+  virtual void SetLabel(const wxString& label);
+  virtual void SetValue(const bool val);
+  virtual bool GetValue(void) const ;
+
+  void Command(wxCommandEvent& event);
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+};
+
+// Not implemented
+#if 0
+class WXDLLEXPORT wxBitmap ;
+
+WXDLLEXPORT_DATA(extern const char*) wxBitmapRadioButtonNameStr;
+
+class WXDLLEXPORT wxBitmapRadioButton: public wxRadioButton
+{
+  DECLARE_DYNAMIC_CLASS(wxBitmapRadioButton)
+ protected:
+  wxBitmap *theButtonBitmap;
+ public:
+  inline wxBitmapRadioButton(void) { theButtonBitmap = NULL; }
+  inline wxBitmapRadioButton(wxWindow *parent, const wxWindowID id,
+           const wxBitmap *label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxBitmapRadioButtonNameStr)
+  {
+      Create(parent, id, label, pos, size, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxBitmap *label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxBitmapRadioButtonNameStr);
+
+  virtual void SetLabel(const wxBitmap *label);
+  virtual void SetValue(const bool val) ;
+  virtual bool GetValue(void) const ;
+};
+#endif
+
+#endif
+    // __RADIOBUTH__
diff --git a/include/wx/msw/region.h b/include/wx/msw/region.h
new file mode 100644
index 0000000000..c660a62f72
--- /dev/null
+++ b/include/wx/msw/region.h
@@ -0,0 +1,136 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        region.h
+// Purpose:     wxRegion class
+// Author:      Markus Holzem, Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __REGIONH__
+#define __REGIONH__
+
+#ifdef __GNUG__
+#pragma interface "region.h"
+#endif
+
+#include "wx/list.h"
+#include "wx/gdiobj.h"
+
+class WXDLLEXPORT wxRect;
+class WXDLLEXPORT wxPoint;
+
+enum wxRegionContain {
+	wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
+};
+
+// So far, for internal use only
+enum wxRegionOp {
+wxRGN_AND,          // Creates the intersection of the two combined regions.
+wxRGN_COPY,         // Creates a copy of the region identified by hrgnSrc1.
+wxRGN_DIFF,         // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
+wxRGN_OR,           // Creates the union of two combined regions.
+wxRGN_XOR           // Creates the union of two combined regions except for any overlapping areas.
+};
+
+class WXDLLEXPORT wxRegion : public wxGDIObject {
+DECLARE_DYNAMIC_CLASS(wxRegion);
+	friend class WXDLLEXPORT wxRegionIterator;
+public:
+    wxRegion(long x, long y, long w, long h);
+    wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
+    wxRegion(const wxRect& rect);
+
+	wxRegion(void);
+	~wxRegion(void);
+
+	//# Copying
+	inline wxRegion(const wxRegion& r)
+		{ Ref(r); }
+	inline wxRegion& operator = (const wxRegion& r)
+		{ Ref(r); return (*this); }
+
+	//# Modify region
+	// Clear current region
+	void Clear(void);
+
+	// Union rectangle or region with this.
+	inline bool Union(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_OR); }
+	inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
+	inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
+
+	// Intersect rectangle or region with this.
+	inline bool Intersect(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_AND); }
+	inline bool Intersect(const wxRect& rect)  { return Combine(rect, wxRGN_AND); }
+	inline bool Intersect(const wxRegion& region)  { return Combine(region, wxRGN_AND); }
+
+	// Subtract rectangle or region from this:
+    // Combines the parts of 'this' that are not part of the second region.
+	inline bool Subtract(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_DIFF); }
+	inline bool Subtract(const wxRect& rect)  { return Combine(rect, wxRGN_DIFF); }
+	inline bool Subtract(const wxRegion& region)  { return Combine(region, wxRGN_DIFF); }
+
+	// XOR: the union of two combined regions except for any overlapping areas.
+	inline bool Xor(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_XOR); }
+	inline bool Xor(const wxRect& rect)  { return Combine(rect, wxRGN_XOR); }
+	inline bool Xor(const wxRegion& region)  { return Combine(region, wxRGN_XOR); }
+
+	//# Information on region
+	// Outer bounds of region
+	void GetBox(long& x, long& y, long&w, long &h) const;
+	wxRect GetBox(void) const ;
+
+	// Is region empty?
+	bool Empty(void) const;
+    inline bool IsEmpty(void) const { return Empty(); }
+
+	//# Tests
+	// Does the region contain the point (x,y)?
+	wxRegionContain Contains(long x, long y) const;
+	// Does the region contain the point pt?
+	wxRegionContain Contains(const wxPoint& pt) const;
+	// Does the region contain the rectangle (x, y, w, h)?
+	wxRegionContain Contains(long x, long y, long w, long h) const;
+	// Does the region contain the rectangle rect?
+	wxRegionContain Contains(const wxRect& rect) const;
+
+// Internal
+	bool Combine(long x, long y, long width, long height, wxRegionOp op);
+	bool Combine(const wxRegion& region, wxRegionOp op);
+	bool Combine(const wxRect& rect, wxRegionOp op);
+};
+
+class WXDLLEXPORT wxRegionIterator : public wxObject {
+DECLARE_DYNAMIC_CLASS(wxRegionIterator);
+public:
+	wxRegionIterator(void);
+	wxRegionIterator(const wxRegion& region);
+	~wxRegionIterator(void);
+
+	void Reset(void) { m_current = 0; }
+	void Reset(const wxRegion& region);
+
+	operator bool (void) const { return m_current < m_numRects; }
+	bool HaveRects(void) const { return m_current < m_numRects; }
+
+	void operator ++ (void);
+	void operator ++ (int);
+
+	long GetX(void) const;
+	long GetY(void) const;
+	long GetW(void) const;
+	long GetWidth(void) const { return GetW(); }
+	long GetH(void) const;
+	long GetHeight(void) const { return GetH(); }
+
+private:
+	long	 m_current;
+	long	 m_numRects;
+	wxRegion m_region;
+    wxRect*  m_rects;
+};
+
+#endif
+	// __REGIONH__
diff --git a/include/wx/msw/registry.h b/include/wx/msw/registry.h
new file mode 100644
index 0000000000..adacf76944
--- /dev/null
+++ b/include/wx/msw/registry.h
@@ -0,0 +1,184 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        msw/registry.h
+// Purpose:     Registry classes and functions
+// Author:      Vadim Zeitlin
+// Modified by: 
+// Created:     03.04.198
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef   _REGISTRY_H
+#define   _REGISTRY_H
+
+// ----------------------------------------------------------------------------
+// mutable hack (see also registry.cpp)
+// ----------------------------------------------------------------------------
+#if   USE_MUTABLE
+  #define MUTABLE mutable
+#else
+  #define MUTABLE
+#endif
+
+// ----------------------------------------------------------------------------
+// forward decl for handle type
+// ----------------------------------------------------------------------------
+#ifndef   HKEY_DEFINED
+  #define HKEY_DEFINED
+  #define HKEY unsigned long
+#endif
+
+// ----------------------------------------------------------------------------
+// class wxRegKey encapsulates window HKEY handle
+// ----------------------------------------------------------------------------
+class WXDLLEXPORT wxRegKey 
+{
+public:
+  // NB: do _not_ change the values of elements in these enumerations!
+
+  // registry value types (with comments from winnt.h)
+  enum ValueType
+  {
+    Type_None,                       // No value type
+    Type_String,                     // Unicode nul terminated string
+#ifdef  __WIN32__
+    Type_Expand_String,              // Unicode nul terminated string
+                                     // (with environment variable references)
+    Type_Binary,                     // Free form binary
+    Type_Dword,                      // 32-bit number
+    Type_Dword_little_endian,        // 32-bit number (same as Type_DWORD)
+    Type_Dword_big_endian,           // 32-bit number
+    Type_Link,                       // Symbolic Link (unicode)
+    Type_Multi_String,               // Multiple Unicode strings
+    Type_Resource_list,              // Resource list in the resource map
+    Type_Full_resource_descriptor,   // Resource list in the hardware description
+    Type_Resource_requirements_list, // ???
+#endif  //WIN32
+  };
+
+  // predefined registry keys
+  enum StdKey
+  {
+    HKCR,     // classes root
+#ifdef  __WIN32__
+    HKCU,     // current user
+    HKLM,     // local machine
+    HKUSR,    // users
+    HKPD,     // performance data (@@ NT only?)
+#if    WINVER >= 0x0400
+    HKCC,     // current config
+    HKDD,     // dynamic data
+#endif  // Winver
+#endif  // Win32/16
+  };
+
+  // information about standard (predefined) registry keys
+    // number of standard keys
+  static const size_t nStdKeys;
+    // get the name of a standard key
+  static const char *GetStdKeyName(uint key);
+    // get the short name of a standard key
+  static const char *GetStdKeyShortName(uint key);
+    // get StdKey from root HKEY
+  static StdKey GetStdKeyFromHkey(HKEY hkey);
+
+  // extacts the std key prefix from the string (return value) and
+  // leaves only the part after it (i.e. modifies the string passed!)
+  static StdKey ExtractKeyName(wxString& str);
+
+  // ctors
+    // root key is set to HKCR (the only root key under Win16)
+  wxRegKey();
+    // strKey is the full name of the key (i.e. starting with HKEY_xxx...)
+  wxRegKey(const wxString& strKey);
+    // strKey is the name of key under (standard key) keyParent
+  wxRegKey(StdKey          keyParent, const wxString& strKey);
+    // strKey is the name of key under (previously created) keyParent
+  wxRegKey(const wxRegKey& keyParent, const wxString& strKey);
+    //
+ ~wxRegKey();
+
+  // change key (closes the previously opened key if any)
+  void  SetName(const wxString& strKey);
+  void  SetHkey(HKEY  hKey);
+
+  // get infomation about the key
+    // get the (full) key name. Abbreviate std root keys if bShortPrefix.
+  wxString GetName(bool bShortPrefix = TRUE) const;
+    // return TRUE if the key exists
+  bool  Exists()   const;
+    // return TRUE if the key is opened
+  bool  IsOpened() const { return m_hKey != 0;        }
+    // for "if ( !key ) wxLogError(...)" kind of expressions
+  operator bool()  const { return m_dwLastError == 0; }
+
+  // operations on the key itself
+    // explicitly open the key (will be automatically done by all functions
+    // which need the key to be opened if the key is not opened yet)
+  bool  Open();
+    // create the key: will fail if the key already exists and bOkIfExists
+  bool  Create(bool bOkIfExists = TRUE);
+    // close the key (will be automatically done in dtor)
+  bool  Close();
+
+  // deleting keys/values
+    // deletes this key and all of it's subkeys/values
+  bool  DeleteSelf();
+    // deletes the subkey with all of it's subkeys/values recursively
+  bool  DeleteKey(const char *szKey);
+    // deletes the named value (may be NULL to remove the default value)
+  bool  DeleteValue(const char *szValue);
+
+  // access to values and subkeys
+    // get value type
+  ValueType GetValueType(const char *szValue);
+
+    // assignment operators set the default value of the key
+  wxRegKey& operator=(const wxString& strValue)
+    { SetValue(NULL, strValue); return *this; }
+  wxRegKey& operator=(long lValue)
+    { SetValue(NULL, lValue); return *this; }
+
+    // conversion operators query the default value of the key
+  operator wxString() const;
+
+    // set the string value
+  bool  SetValue(const char *szValue, const wxString& strValue);
+    // return the string value
+  bool  QueryValue(const char *szValue, wxString& strValue) const;
+
+#ifdef  __WIN32__
+    // set the numeric value
+  bool  SetValue(const char *szValue, long lValue);
+    // return the numeric value
+  bool  QueryValue(const char *szValue, long *plValue) const;
+#endif  //Win32
+
+    // return TRUE if given subkey exists
+  bool  HasSubKey(const char *szKey) const;
+    // return TRUE if any subkeys exist
+  bool  HasSubkeys() const;
+
+  // enumerate values and subkeys
+#ifdef  __WIN32__
+  bool  GetFirstValue(wxString& strValueName, long& lIndex);
+  bool  GetNextValue (wxString& strValueName, long& lIndex) const;
+#endif  //Win32
+
+  bool  GetFirstKey  (wxString& strKeyName  , long& lIndex);
+  bool  GetNextKey   (wxString& strKeyName  , long& lIndex) const;
+
+private:
+  // no copy ctor/assignment operator
+  wxRegKey(const wxRegKey& key);            // not implemented
+  wxRegKey& operator=(const wxRegKey& key); // not implemented
+
+  HKEY        m_hKey,           // our handle
+              m_hRootKey;       // handle of the top key (i.e. StdKey)
+  wxString    m_strKey;         // key name (relative to m_hRootKey)
+
+  MUTABLE long m_dwLastError;   // last error (0 if none)
+};
+
+#endif  //_REGISTRY_H
diff --git a/include/wx/msw/roller.cur b/include/wx/msw/roller.cur
new file mode 100644
index 0000000000000000000000000000000000000000..bb7f16613384321a0a749dd94a669c8412bff613
GIT binary patch
literal 326
zcmc)Eu?@m75QX7)i4X+^RH-6#B_$=LN1#dXP2v$UN2c%yjKBy?!10G5WdzRpY(MK{
zoz%$WE~?knq>kGKjs#<U>vybS+aqEN+zK*oIOF(~_HU_;mu%^cC^pa4h9U7~#-04&
feWKl^v97-qVuIs@9?NtG?26P>rptuN41cW;gqE8j

literal 0
HcmV?d00001

diff --git a/include/wx/msw/scrolbar.h b/include/wx/msw/scrolbar.h
new file mode 100644
index 0000000000..9edd72a589
--- /dev/null
+++ b/include/wx/msw/scrolbar.h
@@ -0,0 +1,91 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        scrollbar.h
+// Purpose:     wxScrollBar class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SCROLBARH__
+#define __SCROLBARH__
+
+#ifdef __GNUG__
+#pragma interface "scrolbar.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxScrollBarNameStr;
+
+// Scrollbar item
+class WXDLLEXPORT wxScrollBar: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxScrollBar)
+
+public:
+  inline wxScrollBar(void) { m_pageSize = 0; m_viewSize = 0; m_objectSize = 0; }
+  ~wxScrollBar(void);
+
+  inline wxScrollBar(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxSB_HORIZONTAL,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxScrollBarNameStr)
+  {
+      Create(parent, id, pos, size, style, validator, name);
+  }
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxSB_HORIZONTAL,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxScrollBarNameStr);
+
+  int GetPosition(void) const ;
+  inline int GetThumbSize() const { return m_pageSize; }
+  inline int GetPageSize() const { return m_viewSize; }
+  inline int GetRange() const { return m_objectSize; }
+
+  virtual void SetPosition(const int viewStart);
+  virtual void SetScrollbar(const int position, const int thumbSize, const int range, const int pageSize,
+    const bool refresh = TRUE);
+
+#if WXWIN_COMPATIBILITY
+  // Backward compatibility
+  inline int GetValue(void) const { return GetPosition(); }
+  inline void SetValue(const int viewStart) { SetPosition(viewStart); }
+  void GetValues(int *viewStart, int *viewLength, int *objectLength,
+                 int *pageLength) const ;
+  inline int GetViewLength() const { return m_viewSize; }
+  inline int GetObjectLength() const { return m_objectSize; }
+
+  void SetPageSize(const int pageLength);
+  void SetObjectLength(const int objectLength);
+  void SetViewLength(const int viewLength);
+#endif
+
+  void Command(wxCommandEvent& event);
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+  void MSWOnVScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control);
+  void MSWOnHScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control);
+
+#if WXWIN_COMPATIBILITY
+  // Backward compatibility: generate an old-style scroll command
+  void OnScroll(wxScrollEvent& event);
+#endif
+
+protected:
+    int m_pageSize;
+    int m_viewSize;
+    int m_objectSize;
+
+DECLARE_EVENT_TABLE()
+};
+
+#endif
+    // __SCROLBARH__
diff --git a/include/wx/msw/settings.h b/include/wx/msw/settings.h
new file mode 100644
index 0000000000..08f1e64e8e
--- /dev/null
+++ b/include/wx/msw/settings.h
@@ -0,0 +1,129 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        settings.h
+// Purpose:     wxSystemSettings class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SETTINGSH__
+#define __SETTINGSH__
+
+#ifdef __GNUG__
+#pragma interface "settings.h"
+#endif
+
+#include "wx/setup.h"
+
+#define wxSYS_WHITE_BRUSH         0
+#define wxSYS_LTGRAY_BRUSH        1
+#define wxSYS_GRAY_BRUSH          2
+#define wxSYS_DKGRAY_BRUSH        3
+#define wxSYS_BLACK_BRUSH         4
+#define wxSYS_NULL_BRUSH          5
+#define wxSYS_HOLLOW_BRUSH        wxSYS_NULL_BRUSH
+#define wxSYS_WHITE_PEN           6
+#define wxSYS_BLACK_PEN           7
+#define wxSYS_NULL_PEN            8
+#define wxSYS_OEM_FIXED_FONT      10
+#define wxSYS_ANSI_FIXED_FONT     11
+#define wxSYS_ANSI_VAR_FONT       12
+#define wxSYS_SYSTEM_FONT         13
+#define wxSYS_DEVICE_DEFAULT_FONT 14
+#define wxSYS_DEFAULT_PALETTE     15
+#define wxSYS_SYSTEM_FIXED_FONT   16 // Obsolete
+#define wxSYS_DEFAULT_GUI_FONT    17
+
+#define wxSYS_COLOUR_SCROLLBAR         0
+#define wxSYS_COLOUR_BACKGROUND        1
+#define wxSYS_COLOUR_ACTIVECAPTION     2
+#define wxSYS_COLOUR_INACTIVECAPTION   3
+#define wxSYS_COLOUR_MENU              4
+#define wxSYS_COLOUR_WINDOW            5
+#define wxSYS_COLOUR_WINDOWFRAME       6
+#define wxSYS_COLOUR_MENUTEXT          7
+#define wxSYS_COLOUR_WINDOWTEXT        8
+#define wxSYS_COLOUR_CAPTIONTEXT       9
+#define wxSYS_COLOUR_ACTIVEBORDER      10
+#define wxSYS_COLOUR_INACTIVEBORDER    11
+#define wxSYS_COLOUR_APPWORKSPACE      12
+#define wxSYS_COLOUR_HIGHLIGHT         13
+#define wxSYS_COLOUR_HIGHLIGHTTEXT     14
+#define wxSYS_COLOUR_BTNFACE           15
+#define wxSYS_COLOUR_BTNSHADOW         16
+#define wxSYS_COLOUR_GRAYTEXT          17
+#define wxSYS_COLOUR_BTNTEXT           18
+#define wxSYS_COLOUR_INACTIVECAPTIONTEXT 19
+#define wxSYS_COLOUR_BTNHIGHLIGHT      20
+
+#define wxSYS_COLOUR_3DDKSHADOW        21
+#define wxSYS_COLOUR_3DLIGHT           22
+#define wxSYS_COLOUR_INFOTEXT          23
+#define wxSYS_COLOUR_INFOBK            24
+
+#define wxSYS_COLOUR_DESKTOP           wxSYS_COLOUR_BACKGROUND
+#define wxSYS_COLOUR_3DFACE            wxSYS_COLOUR_BTNFACE
+#define wxSYS_COLOUR_3DSHADOW          wxSYS_COLOUR_BTNSHADOW
+#define wxSYS_COLOUR_3DHIGHLIGHT       wxSYS_COLOUR_BTNHIGHLIGHT
+#define wxSYS_COLOUR_3DHILIGHT         wxSYS_COLOUR_BTNHIGHLIGHT
+#define wxSYS_COLOUR_BTNHILIGHT        wxSYS_COLOUR_BTNHIGHLIGHT
+
+// Metrics
+#define wxSYS_MOUSE_BUTTONS           1
+#define wxSYS_BORDER_X                2
+#define wxSYS_BORDER_Y                3
+#define wxSYS_CURSOR_X                4
+#define wxSYS_CURSOR_Y                5
+#define wxSYS_DCLICK_X                6
+#define wxSYS_DCLICK_Y                7
+#define wxSYS_DRAG_X                  8
+#define wxSYS_DRAG_Y                  9
+#define wxSYS_EDGE_X                  10
+#define wxSYS_EDGE_Y                  11
+#define wxSYS_HSCROLL_ARROW_X         12
+#define wxSYS_HSCROLL_ARROW_Y         13
+#define wxSYS_HTHUMB_X                14
+#define wxSYS_ICON_X                  15
+#define wxSYS_ICON_Y                  16
+#define wxSYS_ICONSPACING_X           17
+#define wxSYS_ICONSPACING_Y           18
+#define wxSYS_WINDOWMIN_X             19
+#define wxSYS_WINDOWMIN_Y             20
+#define wxSYS_SCREEN_X                21
+#define wxSYS_SCREEN_Y                22
+#define wxSYS_FRAMESIZE_X             23
+#define wxSYS_FRAMESIZE_Y             24
+#define wxSYS_SMALLICON_X             25
+#define wxSYS_SMALLICON_Y             26
+#define wxSYS_HSCROLL_Y               27
+#define wxSYS_VSCROLL_X               28
+#define wxSYS_VSCROLL_ARROW_X         29
+#define wxSYS_VSCROLL_ARROW_Y         30
+#define wxSYS_VTHUMB_Y                31
+#define wxSYS_CAPTION_Y               32
+#define wxSYS_MENU_Y                  33
+#define wxSYS_NETWORK_PRESENT         34
+#define wxSYS_PENWINDOWS_PRESENT      35
+#define wxSYS_SHOW_SOUNDS             36
+#define wxSYS_SWAP_BUTTONS            37
+
+class WXDLLEXPORT wxSystemSettings: public wxObject
+{
+public:
+    inline wxSystemSettings(void) {}
+
+    // Get a system colour
+    static wxColour    GetSystemColour(int index);
+
+    // Get a system font
+    static wxFont      GetSystemFont(int index);
+
+    // Get a system metric, e.g. scrollbar size
+    static int         GetSystemMetric(int index);
+};
+
+#endif
+    // __SETTINGSH__
diff --git a/include/wx/msw/setup.h b/include/wx/msw/setup.h
new file mode 100644
index 0000000000..2a6145f6c4
--- /dev/null
+++ b/include/wx/msw/setup.h
@@ -0,0 +1,324 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        setup.h
+// Purpose:     Configuration for the library
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SETUPH__
+#define __SETUPH__
+
+/*
+ * General features
+ *
+ */
+
+#define WXWIN_COMPATIBILITY  1
+                                // Compatibility with 1.66 API.
+                                // Level 0: no backward compatibility, all new features
+                                // Level 1: wxDC, OnSize (etc.) compatibility, but
+                                //          some new features such as event tables
+
+#define USE_AUTOTRANS	1
+								// Define wxTString
+#define USE_POSTSCRIPT  1
+                        	// 0 for no PostScript device context
+#define USE_AFM_FOR_POSTSCRIPT 0
+                                // 1 to use font metric files in GetTextExtent
+#define USE_METAFILE    1
+                                // 0 for no Metafile and metafile device context
+#define USE_FORM        0
+                                // 0 for no wxForm
+#define USE_IPC         1
+                                // 0 for no interprocess comms
+// Note: wxHELP uses IPC under X so these are interdependent!
+#define USE_HELP        1
+                                // 0 for no help facility
+#define USE_RESOURCES   1
+                        	// 0 for no wxGetResource/wxWriteResource
+#define USE_CONSTRAINTS 1
+                                // 0 for no window layout constraint system
+                                
+#define USE_TIMEDATE    1
+                                // 0 for no wxTime/wxDate classes
+                                
+#define USE_CLIPBOARD   1
+                        	// 0 for no clipboard functions
+#define USE_SPLINES     1
+                            	// 0 for no splines
+#define USE_XFIG_SPLINE_CODE  1
+                           	// 1 for XFIG spline code, 0 for AIAI spline code.
+// AIAI spline code is slower, but freer of copyright issues.
+
+#define USE_DRAG_AND_DROP 1
+                        	// 0 for no drag and drop
+
+#define USE_TOOLBAR       1
+                                    // Define 1 to use toolbar classes
+#define USE_BUTTONBAR     1
+                                    // Define 1 to use buttonbar classes (enhanced toolbar
+                                    // for MS Windows)
+#define USE_GAUGE         1
+                                    // Define 1 to use Microsoft's gauge (Windows)
+                                    // or Bull's gauge (Motif) library (both in contrib).
+#define USE_COMBOBOX      1
+                                    // Define 1 to use COMBOXBOX control (Windows)
+                                    // or FWW's ComboBox widget (Motif).
+#define USE_RADIOBUTTON   1
+                                    // Define 1 to use radio button control
+
+#define USE_SCROLLBAR   1
+                                    // Define 1 to compile contributed wxScrollBar class
+#define USE_XPM_IN_X    1
+#define USE_XPM_IN_MSW  0
+                                    // Define 1 to support the XPM package in wxBitmap,
+                                    // separated by platform. If 1, you must link in
+                                    // the XPM library to your applications.
+#define USE_IMAGE_LOADING_IN_X          1
+                                  // Use dynamic icon/bitmap loading/saving code in utils/image under X.
+                                  // If this is 1, you will need to link your applications
+                                  // with image_X.lib. where X is motif, ol, or hp.
+
+#define USE_IMAGE_LOADING_IN_MSW        1
+                                  // Use dynamic DIB loading/saving code in utils/dib under MSW.
+#define USE_RESOURCE_LOADING_IN_MSW     0
+                                  // Use dynamic icon/cursor loading/saving code
+                                  // under MSW.
+#define USE_WX_RESOURCES        1
+                                  // Use .wxr resource mechanism (requires PrologIO library)
+
+#define USE_GNU_WXSTRING        0
+                                  // Define 1 to use modified GNU wxString class
+                                  // from (stefan.hammes@urz.uni-heidelberg.de) in contrib\string
+                                  // TODO: why does this give an unresolved 'wxRegex::Search'
+                                  // symbol if 1?
+
+#define HAVE_SOCKET             1
+                                  // Use WinSock if 1                                 
+#define USE_DOC_VIEW_ARCHITECTURE 1
+                                  // Set to 0 to disable document/view architecture
+#define USE_PRINTING_ARCHITECTURE  1
+                                    // Set to 0 to disable print/preview architecture code
+#define USE_POSTSCRIPT_ARCHITECTURE_IN_MSW 1
+                                    // Set to 0 to disable PostScript print/preview architecture code
+                                    // under Windows (just use Windows printing).
+#define USE_DYNAMIC_CLASSES     1
+                                  // If 1, enables provision of run-time type information.
+                                  // NOW MANDATORY: don't change.
+#define USE_MEMORY_TRACING      1
+                                  // If 1, enables debugging versions of wxObject::new and
+                                  // wxObject::delete *IF* DEBUG is also defined.
+                                  // WARNING: this code may not work with all architectures, especially
+                                  // if alignment is an issue.
+#define USE_DEBUG_CONTEXT       1
+                                  // If 1, enables wxDebugContext, for
+                                  // writing error messages to file, etc. 
+                                  // If DEBUG is not defined, will still use
+                                  // normal memory operators.
+                                  // It's recommended to set this to 1,
+                                  // since you may well need to output
+                                  // an error log in a production
+                                  // version (or non-debugging beta)
+#define USE_GLOBAL_MEMORY_OPERATORS 1
+                                  // In debug mode, cause new and delete to be redefined globally.
+                                  // If this causes problems (e.g. link errors), set this to 0.
+
+#define REMOVE_UNUSED_ARG 1
+                                  // Set this to 0 if your compiler can't cope
+                                  // with omission of prototype parameters.
+
+#define USE_C_MAIN 0
+                                  // Set to 1 to use main.c instead of main.cpp (UNIX only)
+
+#define USE_ODBC                   1
+                                    // Define 1 to use ODBC classes
+
+#define USE_ODBC_IN_MSW_ONLY           1
+
+#if USE_ODBC && USE_ODBC_IN_MSW_ONLY
+#undef USE_ODBC
+#define USE_ODBC 0
+#endif
+
+#define USE_IOSTREAMH     1
+                                  // VC++ 4.2 and above allows <iostream> and <iostream.h>
+                                  // but you can't mix them. Set to 1 for <iostream.h>,
+                                  // 0 for <iostream>
+
+/*
+ * Finer detail
+ *
+ */
+
+/*
+ * Motif and XView
+ *
+ */
+
+#define WX_STANDARD_GRAPHICS 0
+                                  // If 1, normalizes X drawing code to behave exactly as
+                                  // as MSW. If 0, is compatible with existing applications.
+                                  // Some Xlib drawing primitives have non-intuitive behaviour!
+
+#define USE_GADGETS                0
+                                    // More efficient to use gadgets for some
+                                    // widgets in Motif. 0 for no gadgets.
+                                    // Please note: there is no reason to not
+                                    // use it except if you intend to modify
+                                    // color of individuals items OR
+                                    // you need to move panel items interactively
+#define USE_BUTTON_GADGET          0
+                                    // On JACS's system, gadget buttons
+                                    // interfere with default button setting.
+#define PIXEL0_DISABLE             0
+                                    // Define as 1 to disallow allocation
+                                    // of pixel #0 (wxXOR problem).
+                                    // JACS - I found this caused problems.
+
+#define MOTIF_MENUBAR_DELETE_FIX   0
+                                    // On some systems (Ultrix, OSF), deleting a frame
+                                    // from within a menu callback causes a crash.
+                                    // Set to 1 to avoid deleting the menubar handle directly,
+                                    // which seems to cure it.
+#define	DEFAULT_FILE_SELECTOR_SIZE 0
+				    // Let Motif defines the size of File
+				    // Selector Box (if 1), or fix it to
+				    // wxFSB_WIDTH x wxFSB_HEIGHT (if 0)
+#define	wxFSB_WIDTH                600
+#define wxFSB_HEIGHT               500
+
+#define	MOTIF_MANAGE               1
+				    // Control default style of Dialogs
+				    // 1: use wxMOTIF_RESIZE as default
+				    // 0: do not use wxMOTIF_RESIZE as default
+
+
+/*
+ * MS Windows/Windows NT
+ *
+ */
+
+#if defined(__WIN95__)
+#define CTL3D                      0
+#else
+#define CTL3D                      1
+                                    // Define 1 to use Microsoft CTL3D library.
+                                    // See note above about using FAFA and CTL3D.
+#endif
+
+#define USE_COMMON_DIALOGS         1
+                                    // On rare occasions (e.g. using DJGPP) may want
+                                    // to omit common dialogs
+                                    // (e.g. file selector, printer dialog).
+                                    // Switching this off also switches off
+                                    // the printing architecture and interactive
+                                    // wxPrinterDC.
+#define USE_GREY_BACKGROUND        1
+                                    // If 1, uses grey (gray!) panels
+                                    // in FAFA and non-FAFA, non-CTL3D modes.
+                                    // I (JACS) think the controls look better
+                                    // this way. CTL3D always uses grey panels.
+#define USE_ITSY_BITSY             1
+                                    // Define 1 to use Microsoft's ItsyBitsy
+                                    // small title bar library
+#define USE_BITMAP_MESSAGE         1
+                                    // Define 1 to use bitmap messages.
+#define USE_PORTABLE_FONTS_IN_MSW  0
+                                    // Define 1 to use new portable font scheme in Windows
+                                    // (used by default under X)
+#define FONT_SIZE_COMPATIBILITY    0
+                                    // Define 1 for font size to be backward compatible
+                                    // to 1.63 and earlier. 1.64 and later define point
+                                    // sizes to be compatible with Windows.
+#define USE_GENERIC_DIALOGS_IN_MSW 1
+                                    // Define 1 to use generic dialogs in Windows, even though
+                                    // they duplicate native common dialog (e.g. wxColourDialog)
+#define USE_PENWINDOWS 0
+                                    // Set to 1 to use PenWindows
+
+#define USE_OWNER_DRAWN             1
+                                    // Owner-drawn menus and listboxes
+
+#define USE_NATIVE_STATUSBAR        1
+                                    // Set to 0 to use cross-platform wxStatusBar
+
+/*
+ * Any platform
+ *
+ */
+
+#define USE_TYPEDEFS               0
+                                    // Use typedefs not classes for wxPoint
+				    // and others, to reduce overhead and avoid
+				    // MS C7 memory bug. Bounds checker
+				    // complains about deallocating
+                                    // arrays of wxPoints if wxPoint is a class.
+
+#if (!defined(WIN32) && !defined(__WIN32__)) || defined(__GNUWIN32__) || defined(__BORLANDC__)
+// Can't use OLE drag and drop in Windows 3.1 because we don't know how
+// to implement UUIDs
+// GnuWin32 doesn't have appropriate headers for e.g. IUnknown.
+#undef USE_DRAG_AND_DROP
+#define USE_DRAG_AND_DROP 0
+#endif
+
+// Only WIN32 supports wxStatusBar95
+#if !defined(__WIN32__) && USE_NATIVE_STATUSBAR
+#undef  USE_NATIVE_STATUSBAR
+#define USE_NATIVE_STATUSBAR 0
+#endif
+
+// Minimal setup e.g. for compiling small utilities
+#define MINIMAL_WXWINDOWS_SETUP 0
+
+#if MINIMAL_WXWINDOWS_SETUP
+#undef USE_POSTSCRIPT
+# define USE_POSTSCRIPT 0
+#undef USE_PRINTING_ARCHITECTURE
+# define USE_PRINTING_ARCHITECTURE 0
+#undef USE_POSTSCRIPT_ARCHITECTURE_IN_MSW
+# define USE_POSTSCRIPT_ARCHITECTURE_IN_MSW 0
+#undef USE_METAFILE
+# define USE_METAFILE 0
+#undef USE_FORM
+# define USE_FORM 0
+#undef USE_SPLINES
+# define USE_SPLINES 0
+#undef USE_SCROLLBAR
+# define USE_SCROLLBAR 0
+#undef USE_COMBOBOX
+# define USE_COMBOBOX 0
+#undef USE_RADIOBUTTON
+# define USE_RADIOBUTTON 0
+#undef USE_XPM_IN_MSW
+# define USE_XPM_IN_MSW 0
+#undef USE_WX_RESOURCES
+# define USE_WX_RESOURCES 0
+#undef USE_DOC_VIEW_ARCHITECTURE
+# define USE_DOC_VIEW_ARCHITECTURE 0
+#undef USE_GNU_WXSTRING
+# define USE_GNU_WXSTRING 0
+#undef USE_ODBC
+# define USE_ODBC 0
+#undef USE_TIMEDATE
+# define USE_TIMEDATE 0
+#undef CTL3D
+# define CTL3D 0
+#undef USE_ITSY_BITSY
+# define USE_ITSY_BITSY 0
+#undef USE_IMAGE_LOADING_IN_MSW
+# define USE_IMAGE_LOADING_IN_MSW 0
+#undef USE_GAUGE
+# define USE_GAUGE 0
+#undef USE_RESOURCE_LOADING_IN_MSW
+# define USE_RESOURCE_LOADING_IN_MSW 0
+#undef USE_DRAG_AND_DROP
+# define USE_DRAG_AND_DROP 0
+#endif
+
+#endif
+    // __SETUPH__
diff --git a/include/wx/msw/size.cur b/include/wx/msw/size.cur
new file mode 100644
index 0000000000000000000000000000000000000000..01a731c1b21b8c373b8f358e7501fd02d9d9ec4b
GIT binary patch
literal 326
zcmZvWF%p763`O6Xf=)VHC@sAK9&4@OXdHzjP*O0)`~?Sf%uY7>KgmzvM51lsOwBF9
z1-OO>#XUU5E4GIX9KX9C;4`xT)d2Mf%>=@`Cp%$gRAxi%KFXDgQ|;YXqGqKbEzSS2
zxZ&H@fJ^T_ckWZOZ-_0yJ@doYoPEi;pP`$!>l)?aR8voxFPFufG^8a>Y5&*@<;HQ&

literal 0
HcmV?d00001

diff --git a/include/wx/msw/slider.h b/include/wx/msw/slider.h
new file mode 100644
index 0000000000..78a5e28fa1
--- /dev/null
+++ b/include/wx/msw/slider.h
@@ -0,0 +1,110 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        slider.h
+// Purpose:     wxSlider class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SLIDERH__
+#define __SLIDERH__
+
+#ifdef __GNUG__
+#pragma interface "slider.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxSliderNameStr;
+
+// Slider
+class WXDLLEXPORT wxSlider: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxSlider)
+
+public:
+  wxSlider(void);
+
+  inline wxSlider(wxWindow *parent, const wxWindowID id,
+           const int value, const int minValue, const int maxValue,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxSL_HORIZONTAL,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxSliderNameStr)
+  {
+      Create(parent, id, value, minValue, maxValue, pos, size, style, validator, name);
+  }
+
+  ~wxSlider(void);
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const int value, const int minValue, const int maxValue,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = wxSL_HORIZONTAL,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxSliderNameStr);
+
+  virtual int GetValue(void) const ;
+  virtual void SetValue(const int);
+  void GetSize(int *x, int *y) const ;
+  void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+  void GetPosition(int *x, int *y) const ;
+  bool Show(const bool show);
+
+  void SetRange(const int minValue, const int maxValue);
+
+  inline int GetMin(void) const { return m_rangeMin; }
+  inline int GetMax(void) const { return m_rangeMax; }
+
+  // For trackbars only
+  void SetTickFreq(const int n, const int pos);
+  inline int GetTickFreq(void) const { return m_tickFreq; }
+  void SetPageSize(const int pageSize);
+  int GetPageSize(void) const ;
+  void ClearSel(void) ;
+  void ClearTicks(void) ;
+  void SetLineSize(const int lineSize);
+  int GetLineSize(void) const ;
+  int GetSelEnd(void) const ;
+  int GetSelStart(void) const ;
+  void SetSelection(const int minPos, const int maxPos);
+  void SetThumbLength(const int len) ;
+  int GetThumbLength(void) const ;
+  void SetTick(const int tickPos) ;
+
+  // IMPLEMENTATION
+  inline WXHWND GetStaticMin() const { return m_staticMin; }
+  inline WXHWND GetStaticMax() const { return m_staticMax; }
+  inline WXHWND GetEditValue() const { return m_staticValue; }
+  virtual bool ContainsHWND(WXHWND hWnd) const;
+
+  // Backward compatibility: translate to familiar wxEVT_COMMAND_SLIDER_UPDATED
+#if WXWIN_COMPATIBILITY
+  void OnScroll(wxScrollEvent& event);
+#endif
+
+  void Command(wxCommandEvent& event);
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+  void MSWOnVScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control);
+  void MSWOnHScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control);
+
+ protected:
+  WXHWND        m_staticMin;
+  WXHWND        m_staticMax;
+  WXHWND        m_staticValue;
+  int           m_rangeMin;
+  int           m_rangeMax;
+  int           m_pageSize;
+  int           m_lineSize;
+  int           m_tickFreq;
+DECLARE_EVENT_TABLE()
+};
+
+#endif
+    // __SLIDERH__
diff --git a/include/wx/msw/spinbutt.h b/include/wx/msw/spinbutt.h
new file mode 100644
index 0000000000..3b76035ae8
--- /dev/null
+++ b/include/wx/msw/spinbutt.h
@@ -0,0 +1,107 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        spinbutt.h
+// Purpose:     wxSpinButton class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SPINBUTTH__
+#define __SPINBUTTH__
+
+#ifdef __GNUG__
+#pragma interface "spinbutt.h"
+#endif
+
+#include "wx/control.h"
+#include "wx/event.h"
+
+#if defined(__WIN95__)
+
+/*
+    The wxSpinButton is like a small scrollbar than is often placed next
+    to a text control.
+
+    wxSP_HORIZONTAL:   horizontal spin button
+    wxSP_VERTICAL:     vertical spin button (the default)
+    wxSP_ARROW_KEYS:   arrow keys increment/decrement value
+    wxSP_WRAP:         value wraps at either end
+ */
+
+class WXDLLEXPORT wxSpinButton: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxSpinButton)
+ public:
+  /*
+   * Public interface
+   */
+
+  wxSpinButton(void);
+
+  inline wxSpinButton(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+            const long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton")
+  {
+    Create(parent, id, pos, size, style, name);
+  }
+  ~wxSpinButton(void);
+
+  bool Create(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+            const long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton");
+
+
+  // Attributes
+  ////////////////////////////////////////////////////////////////////////////
+
+  int GetValue(void) const ;
+  void SetValue(const int val) ;
+  void SetRange(const int minVal, const int maxVal) ;
+  inline int GetMin(void) const { return m_min; }
+  inline int GetMax(void) const { return m_max; }
+
+  // Operations
+  ////////////////////////////////////////////////////////////////////////////
+
+  void Command(wxCommandEvent& event) { ProcessCommand(event); };
+
+  // IMPLEMENTATION
+  bool MSWCommand(const WXUINT param, const WXWORD id);
+  bool MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam);
+  void MSWOnVScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control);
+  void MSWOnHScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control);
+
+protected:
+  int   m_min;
+  int   m_max;
+};
+
+class WXDLLEXPORT wxSpinEvent: public wxScrollEvent
+{
+  DECLARE_DYNAMIC_CLASS(wxSpinEvent)
+
+ public:
+  wxSpinEvent(WXTYPE commandType = 0, int id = 0);
+};
+
+typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
+
+// Spin events
+
+#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
+#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
+
+#define EVT_SPIN(id, func) \
+  { wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
+  { wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
+  { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
+  { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
+  { wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
+  { wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
+  { wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
+
+#endif
+    // __WIN95__
+#endif
+    // __SPINBUTTH__
diff --git a/include/wx/msw/statbmp.h b/include/wx/msw/statbmp.h
new file mode 100644
index 0000000000..d66db9614b
--- /dev/null
+++ b/include/wx/msw/statbmp.h
@@ -0,0 +1,64 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        statbmp.h
+// Purpose:     wxStaticBitmap class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __STATBMPH__
+#define __STATBMPH__
+
+#ifdef __GNUG__
+#pragma interface "statbmp.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxStaticBitmapNameStr;
+
+class WXDLLEXPORT wxStaticBitmap: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
+ public:
+  inline wxStaticBitmap(void) { }
+
+  inline wxStaticBitmap(wxWindow *parent, const wxWindowID id,
+           const wxBitmap& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = 0,
+           const wxString& name = wxStaticBitmapNameStr)
+  {
+    Create(parent, id, label, pos, size, style, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxBitmap& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = 0,
+           const wxString& name = wxStaticBitmapNameStr);
+
+  virtual void SetBitmap(const wxBitmap& bitmap);
+
+  virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
+  virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
+
+  void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+
+  inline wxBitmap& GetBitmap(void) const { return (wxBitmap&) m_messageBitmap; }
+
+  // Implementation
+  virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
+  virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+ protected:
+  wxBitmap m_messageBitmap;
+
+};
+
+#endif
+    // __STATBMPH__
diff --git a/include/wx/msw/statbox.h b/include/wx/msw/statbox.h
new file mode 100644
index 0000000000..fbd5e150c3
--- /dev/null
+++ b/include/wx/msw/statbox.h
@@ -0,0 +1,63 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        statbox.h
+// Purpose:     wxStaticBox class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __STATBOXH__
+#define __STATBOXH__
+
+#ifdef __GNUG__
+#pragma interface "statbox.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxStaticBoxNameStr;
+
+// Group box
+class WXDLLEXPORT wxStaticBox: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxStaticBox)
+
+ public:
+  inline wxStaticBox(void) {}
+  inline wxStaticBox(wxWindow *parent, const wxWindowID id,
+           const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = 0,
+           const wxString& name = wxStaticBoxNameStr)
+  {
+    Create(parent, id, label, pos, size, style, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = 0,
+           const wxString& name = wxStaticBoxNameStr);
+
+  virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
+  virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
+
+  void OnEraseBackground(wxEraseEvent& event);
+
+  virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+
+  void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+  void SetLabel(const wxString& label);
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+DECLARE_EVENT_TABLE()
+};
+
+#endif
+    // __STATBOXH__
diff --git a/include/wx/msw/statbr95.h b/include/wx/msw/statbr95.h
new file mode 100644
index 0000000000..a6a6acb4be
--- /dev/null
+++ b/include/wx/msw/statbr95.h
@@ -0,0 +1,51 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        msw/statbr95.h
+// Purpose:     native implementation of wxStatusBar
+// Author:      Vadim Zeitlin
+// Modified by: 
+// Created:     04.04.98
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef   _STATBR95_H
+#define   _STATBR95_H
+
+#if       USE_NATIVE_STATUSBAR
+
+class WXDLLEXPORT wxStatusBar95 : public wxStatusBar
+{
+  DECLARE_DYNAMIC_CLASS(wxStatusBar95);
+
+public:
+  // ctors
+  wxStatusBar95();
+  wxStatusBar95(wxWindow *parent, wxWindowID id = -1, long style = wxSB_SIZEGRIP);
+
+  // create status line
+  bool Create(wxWindow *parent, wxWindowID id = -1, long style = wxSB_SIZEGRIP);
+
+  // a status line can have several (<256) fields numbered from 0
+  virtual void SetFieldsCount(int number = 1, const int *widths = NULL);
+
+  // each field of status line has it's own text
+  virtual void     SetStatusText(const wxString& text, const int number = 0);
+  virtual wxString GetStatusText(int number = 0) const;
+
+  // set status line fields' widths
+  virtual void SetStatusWidths(int n, const int *widths_field);
+
+  // we're going to process WM_SIZE (of the parent window)
+  void OnSize(wxSizeEvent& event);
+
+  DECLARE_EVENT_TABLE()
+
+protected:
+  void CopyFieldsWidth(const int *widths);
+  void SetFieldsWidth();
+};
+
+#endif  // USE_NATIVE_STATUSBAR
+
+#endif  //_STATBR95_H
\ No newline at end of file
diff --git a/include/wx/msw/stattext.h b/include/wx/msw/stattext.h
new file mode 100644
index 0000000000..4f6e66aa4e
--- /dev/null
+++ b/include/wx/msw/stattext.h
@@ -0,0 +1,60 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        stattext.h
+// Purpose:     wxStaticText class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __STATTEXTH__
+#define __STATTEXTH__
+
+#ifdef __GNUG__
+#pragma interface "stattext.h"
+#endif
+
+#include "wx/control.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxStaticTextNameStr;
+
+class WXDLLEXPORT wxStaticText: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxStaticText)
+ public:
+  inline wxStaticText(void) { }
+
+  inline wxStaticText(wxWindow *parent, const wxWindowID id,
+           const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = 0,
+           const wxString& name = wxStaticTextNameStr)
+  {
+    Create(parent, id, label, pos, size, style, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxString& label,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = 0,
+           const wxString& name = wxStaticTextNameStr);
+
+  virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
+  virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
+
+  void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+
+  void SetLabel(const wxString&);
+
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+  virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+};
+
+#endif
+    // __STATTEXTH__
diff --git a/include/wx/msw/tabctrl.h b/include/wx/msw/tabctrl.h
new file mode 100644
index 0000000000..ff35c3ebcd
--- /dev/null
+++ b/include/wx/msw/tabctrl.h
@@ -0,0 +1,148 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        tabctrl.h
+// Purpose:     wxTabCtrl class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __TABCTRLH__
+#define __TABCTRLH__
+
+#ifdef __GNUG__
+#pragma interface "tabctrl.h"
+#endif
+
+class wxImageList;
+
+// WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr;
+
+/*
+ * Flags returned by HitTest
+ */
+
+#define wxTAB_HITTEST_NOWHERE           1
+#define wxTAB_HITTEST_ONICON            2
+#define wxTAB_HITTEST_ONLABEL           4
+#define wxTAB_HITTEST_ONITEM            6
+
+class WXDLLEXPORT wxTabCtrl: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxTabCtrl)
+ public:
+   /*
+    * Public interface
+    */
+
+    wxTabCtrl(void);
+
+    inline wxTabCtrl(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+            const long style = 0, const wxString& name = "tabCtrl")
+    {
+        Create(parent, id, pos, size, style, name);
+    }
+    ~wxTabCtrl(void);
+
+// Accessors
+
+    // Get the selection
+    int GetSelection(void) const;
+
+    // Get the associated image list
+    wxImageList* GetImageList(void) const;
+
+    // Get the number of items
+    int GetItemCount(void) const;
+
+    // Get the rect corresponding to the tab
+    bool GetItemRect(const int item, wxRect& rect) const;
+
+    // Get the number of rows
+    int GetRowCount(void) const;
+
+    // Get the item text
+    wxString GetItemText(const int item) const ;
+
+    // Get the item image
+    int GetItemImage(const int item) const;
+
+    // Get the item data
+    void* GetItemData(const int item) const;
+
+    // Set the selection
+    int SetSelection(const int item);
+
+    // Set the image list
+    void SetImageList(wxImageList* imageList);
+
+    // Set the text for an item
+    bool SetItemText(const int item, const wxString& text);
+
+    // Set the image for an item
+    bool SetItemImage(const int item, const int image);
+
+    // Set the data for an item
+    bool SetItemData(const int item, void* data);
+
+    // Set the size for a fixed-width tab control
+    void SetItemSize(const wxSize& size);
+
+    // Set the padding between tabs
+    void SetPadding(const wxSize& padding);
+
+// Operations
+
+    bool Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+                const long style = 0, const wxString& name = "tabCtrl");
+
+    // Delete all items
+    bool DeleteAllItems(void);
+
+    // Delete an item
+    bool DeleteItem(const int item);
+
+    // Hit test
+    int HitTest(const wxPoint& pt, long& flags);
+
+    // Insert an item
+    int InsertItem(const int item, const wxString& text, const int imageId = -1, void* data = NULL);
+
+// Implementation
+
+    // Call default behaviour
+    void OnPaint(wxPaintEvent& event) { Default() ; }
+    void OnSize(wxSizeEvent& event) { Default() ; }
+    void OnMouseEvent(wxMouseEvent& event) { Default() ; }
+    void OnKillFocus(wxFocusEvent& event) { Default() ; }
+
+    void Command(wxCommandEvent& event);
+    bool MSWCommand(const WXUINT param, const WXWORD id);
+    bool MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam);
+
+    // Responds to colour changes
+    void OnSysColourChanged(wxSysColourChangedEvent& event);
+
+protected:
+    wxImageList*    m_imageList;
+
+DECLARE_EVENT_TABLE()
+};
+
+class WXDLLEXPORT wxTabEvent: public wxCommandEvent
+{
+  DECLARE_DYNAMIC_CLASS(wxTabEvent)
+
+ public:
+  wxTabEvent(WXTYPE commandType = 0, int id = 0);
+};
+
+typedef void (wxEvtHandler::*wxTabEventFunction)(wxTabEvent&);
+
+#define EVT_TAB_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TAB_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn },
+#define EVT_TAB_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TAB_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn },
+
+#endif
+    // __TABCTRLH__
diff --git a/include/wx/msw/taskbar.h b/include/wx/msw/taskbar.h
new file mode 100644
index 0000000000..36703ce96d
--- /dev/null
+++ b/include/wx/msw/taskbar.h
@@ -0,0 +1,66 @@
+/////////////////////////////////////////////////////////////////////////
+// File:        taskbar.h
+// Purpose:	    Defines wxTaskBarIcon class for manipulating icons on the
+//              Windows task bar.
+// Author:      Julian Smart
+// Modified by:
+// Created:     24/3/98
+// RCS-ID:      $Id$
+// Copyright:   (c)
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////
+
+#ifndef _TASKBAR_H_
+#define _TASKBAR_H_
+
+#ifdef __GNUG__
+#pragma interface "taskbar.h"
+#endif
+
+#include <wx/list.h>
+#include <wx/icon.h>
+
+class wxTaskBarIcon: public wxObject
+{
+public:
+	wxTaskBarIcon(void);
+	virtual ~wxTaskBarIcon(void);
+
+// Accessors
+    inline WXHWND GetHWND() const { return m_hWnd; }
+    inline bool IsOK() const { return (m_hWnd != 0) ; }
+    inline bool IsIconInstalled() const { return m_iconAdded; }
+
+// Operations
+    bool SetIcon(const wxIcon& icon, const wxString& tooltip = "");
+    bool RemoveIcon(void);
+
+// Overridables
+    virtual void OnMouseMove(void);
+    virtual void OnLButtonDown(void);
+    virtual void OnLButtonUp(void);
+    virtual void OnRButtonDown(void);
+    virtual void OnRButtonUp(void);
+    virtual void OnLButtonDClick(void);
+    virtual void OnRButtonDClick(void);
+
+// Implementation
+    static wxTaskBarIcon* FindObjectForHWND(WXHWND hWnd);
+    static void AddObject(wxTaskBarIcon* obj);
+    static void RemoveObject(wxTaskBarIcon* obj);
+    static bool RegisterWindowClass();
+    static WXHWND CreateTaskBarWindow();
+    long WindowProc( WXHWND hWnd, unsigned int msg, unsigned int wParam, long lParam );
+
+// Data members
+protected:
+    WXHWND          m_hWnd;
+    bool            m_iconAdded;
+    static wxList   sm_taskBarIcons;
+    static bool     sm_registeredClass;
+    static unsigned int sm_taskbarMsg;
+};
+
+#endif
+    // _TASKBAR_H_
+
diff --git a/include/wx/msw/tbar95.h b/include/wx/msw/tbar95.h
new file mode 100644
index 0000000000..5a04b68243
--- /dev/null
+++ b/include/wx/msw/tbar95.h
@@ -0,0 +1,108 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        tbar95.h
+// Purpose:     wxToolBar95 (Windows 95 toolbar) class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __TBAR95H__
+#define __TBAR95H__
+
+#ifdef __GNUG__
+#pragma interface "tbar95.h"
+#endif
+
+#if USE_BUTTONBAR && USE_TOOLBAR
+#include "wx/tbarbase.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr;
+
+#define DEFAULTBITMAPX   16
+#define DEFAULTBITMAPY   15
+#define DEFAULTBUTTONX   24
+#define DEFAULTBUTTONY   24
+#define DEFAULTBARHEIGHT 27
+
+class WXDLLEXPORT wxToolBar95: public wxToolBarBase
+{
+  DECLARE_DYNAMIC_CLASS(wxToolBar95)
+ public:
+  /*
+   * Public interface
+   */
+
+  wxToolBar95(void);
+
+#if WXWIN_COMPATIBILITY > 0
+  inline wxToolBar95(wxWindow *parent, int x, int y, int w, int h,
+            long style = wxNO_BORDER, int orientation = wxVERTICAL, int RowsOrColumns = 2,
+            const char *name = wxToolBarNameStr)
+  {
+    Create(parent, -1, wxPoint(x, y), wxSize(w, h), style, orientation, RowsOrColumns, name);
+  }
+#endif
+  inline wxToolBar95(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+            const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
+            const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr)
+  {
+    Create(parent, id, pos, size, style, orientation, RowsOrColumns, name);
+  }
+  ~wxToolBar95(void);
+
+  bool Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+            const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
+            const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
+
+  // Call default behaviour
+  void OnPaint(wxPaintEvent& event) { Default() ; }
+  void OnSize(wxSizeEvent& event) { Default() ; }
+  void OnMouseEvent(wxMouseEvent& event) { Default() ; }
+  void OnKillFocus(wxFocusEvent& event) { Default() ; }
+
+  // Handle wxToolBar95 events
+
+  // If pushedBitmap is NULL, a reversed version of bitmap is
+  // created and used as the pushed/toggled image.
+  // If toggle is TRUE, the button toggles between the two states.
+  wxToolBarTool *AddTool(const int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
+               const bool toggle = FALSE, const long xPos = -1, const long yPos = -1, wxObject *clientData = NULL,
+               const wxString& helpString1 = "", const wxString& helpString2 = "");
+
+  // New members
+  // Set default bitmap size
+  void SetDefaultSize(const wxSize& size);
+  void EnableTool(const int toolIndex, const bool enable); // additional drawing on enabling
+  void ToggleTool(const int toolIndex, const bool toggle); // toggle is TRUE if toggled on
+  void ClearTools(void);
+
+  // The button size is bigger than the bitmap size
+  wxSize GetDefaultButtonSize(void) const;
+
+  wxSize GetMaxSize(void) const;
+  void GetSize(int *w, int *y) const;
+
+  // Add all the buttons: required for Win95.
+  virtual bool CreateTools(void);
+  virtual void SetRows(const int nRows);
+  virtual void Layout(void) {}
+
+  // IMPLEMENTATION
+  bool MSWCommand(const WXUINT param, const WXWORD id);
+  bool MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam);
+
+  // Responds to colour changes
+  void OnSysColourChanged(wxSysColourChangedEvent& event);
+
+protected:
+  WXHBITMAP         m_hBitmap;
+
+DECLARE_EVENT_TABLE()
+};
+
+#endif // USE_TOOL/BUTTONBAR
+#endif
+    // __TBAR95H__
diff --git a/include/wx/msw/tbarmsw.h b/include/wx/msw/tbarmsw.h
new file mode 100644
index 0000000000..320a46a785
--- /dev/null
+++ b/include/wx/msw/tbarmsw.h
@@ -0,0 +1,130 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        tbarmsw.h
+// Purpose:     wxToolBarMSW class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __TBARMSWH__
+#define __TBARMSWH__
+
+#ifdef __GNUG__
+#pragma interface "tbarmsw.h"
+#endif
+
+#if USE_BUTTONBAR && USE_TOOLBAR
+#include "wx/tbarbase.h"
+
+WXDLLEXPORT_DATA(extern const char*) wxButtonBarNameStr;
+
+// Non-Win95 (WIN32, WIN16, UNIX) version
+
+class WXDLLEXPORT wxToolBarMSW: public wxToolBarBase
+{
+  DECLARE_DYNAMIC_CLASS(wxToolBarMSW)
+public:
+  /*
+   * Public interface
+   */
+  wxToolBarMSW(void);
+
+#if WXWIN_COMPATIBILITY > 0
+  inline wxToolBarMSW(wxWindow *parent, int x, int y, int w, int h,
+            long style = wxNO_BORDER, int orientation = wxVERTICAL, int RowsOrColumns = 2,
+            const char *name = wxButtonBarNameStr)
+  {
+    Create(parent, -1, wxPoint(x, y), wxSize(w, h), style, orientation, RowsOrColumns, name);
+  }
+#endif
+  inline wxToolBarMSW(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+            const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
+            const int RowsOrColumns = 2, const wxString& name = wxButtonBarNameStr)
+  {
+    Create(parent, id, pos, size, style, orientation, RowsOrColumns, name);
+  }
+  bool Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+            const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
+            const int RowsOrColumns = 2, const wxString& name = wxButtonBarNameStr);
+
+  ~wxToolBarMSW(void);
+
+  // Handle wxWindows events
+  void OnPaint(wxPaintEvent& event);
+  void OnSize(wxSizeEvent& event);
+  void OnMouseEvent(wxMouseEvent& event);
+
+  // If pushedBitmap is NULL, a reversed version of bitmap is
+  // created and used as the pushed/toggled image.
+  // If toggle is TRUE, the button toggles between the two states.
+  wxToolBarTool *AddTool(const int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
+               const bool toggle = FALSE, const long xPos = -1, const long yPos = -1, wxObject *clientData = NULL,
+               const wxString& helpString1 = "", const wxString& helpString2 = "");
+
+  void DrawTool(wxDC& dc, wxMemoryDC& memDc, wxToolBarTool *tool);
+
+  // New members
+  // Set default bitmap size
+  virtual void SetDefaultSize(const wxSize& size);
+  void EnableTool(const int toolIndex, const bool enable); // additional drawing on enabling
+
+  // The button size is bigger than the bitmap size
+  wxSize GetDefaultButtonSize(void) const;
+ protected:
+  void DrawTool(wxDC& dc, wxToolBarTool *tool, int state);
+
+  void GetSysColors(void);
+  bool InitGlobalObjects(void);
+  void FreeGlobalObjects(void);
+  void PatB(WXHDC hdc,int x,int y,int dx,int dy, long rgb);
+  void CreateMask(WXHDC hDC, int xoffset, int yoffset, int dx, int dy);
+  void DrawBlankButton(WXHDC hdc, int x, int y, int dx, int dy, int state);
+  void DrawButton(WXHDC hdc, int x, int y, int dx, int dy, wxToolBarTool *tool, int state);
+  WXHBITMAP CreateDitherBitmap();
+  bool CreateDitherBrush(void);
+  bool FreeDitherBrush(void);
+  WXHBITMAP CreateMappedBitmap(WXHINSTANCE hInstance, void *lpBitmapInfo);
+  WXHBITMAP CreateMappedBitmap(WXHINSTANCE hInstance, WXHBITMAP hBitmap);
+
+ protected:
+
+  WXHBRUSH          m_hbrDither;
+  WXDWORD           m_rgbFace;
+  WXDWORD           m_rgbShadow;
+  WXDWORD           m_rgbHilight;
+  WXDWORD           m_rgbFrame;
+
+//
+// m_hdcMono is the DC that holds a mono bitmap, m_hbmMono
+// that is used to create highlights
+// of button faces.
+// m_hbmDefault hold the default bitmap if there is one.
+//
+  WXHDC             m_hdcMono;
+  WXHBITMAP         m_hbmMono;
+  WXHBITMAP         m_hbmDefault;
+
+DECLARE_EVENT_TABLE()
+};
+
+#define DEFAULTBITMAPX   16
+#define DEFAULTBITMAPY   15
+#define DEFAULTBUTTONX   24
+#define DEFAULTBUTTONY   22
+#define DEFAULTBARHEIGHT 27
+
+//
+// States (not all of them currently used)
+//
+#define wxTBSTATE_CHECKED         0x01    // radio button is checked
+#define wxTBSTATE_PRESSED         0x02    // button is being depressed (any style)
+#define wxTBSTATE_ENABLED         0x04    // button is enabled
+#define wxTBSTATE_HIDDEN          0x08    // button is hidden
+#define wxTBSTATE_INDETERMINATE   0x10    // button is indeterminate
+
+#endif // USE_TOOL/BUTTONBAR
+#endif
+    // __TBARMSWH__
diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h
new file mode 100644
index 0000000000..43b5ea9ac3
--- /dev/null
+++ b/include/wx/msw/textctrl.h
@@ -0,0 +1,149 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        textctrl.h
+// Purpose:     wxTextCtrl class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __TEXTCTRLH__
+#define __TEXTCTRLH__
+
+#ifdef __GNUG__
+#pragma interface "textctrl.h"
+#endif
+
+#include "wx/control.h"
+
+#if USE_IOSTREAMH
+#include <iostream.h>
+#else
+#include <iostream>
+#endif
+
+WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr;
+WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
+
+// Single-line text item
+class WXDLLEXPORT wxTextCtrl: public wxControl
+
+// 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow and streambuf:
+// it complains about deriving a huge class from the huge class streambuf. !!
+// Also, can't use streambuf if making or using a DLL :-(
+
+#if (defined(__BORLANDC__) && !defined(__WIN32__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
+#define NO_TEXT_WINDOW_STREAM
+#endif
+
+#ifndef NO_TEXT_WINDOW_STREAM
+, public streambuf
+#endif
+
+{
+  DECLARE_DYNAMIC_CLASS(wxTextCtrl)
+
+ protected:
+  wxString fileName;
+ public:
+  wxTextCtrl(void);
+  inline wxTextCtrl(wxWindow *parent, const wxWindowID id,
+           const wxString& value = wxEmptyString,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxTextCtrlNameStr)
+#ifndef NO_TEXT_WINDOW_STREAM
+ :streambuf()
+#endif
+  {
+      Create(parent, id, value, pos, size, style, validator, name);
+  }
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxString& value = wxEmptyString,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize, const long style = 0,
+           const wxValidator& validator = wxDefaultValidator,
+           const wxString& name = wxTextCtrlNameStr);
+
+  virtual wxString GetValue(void) const ;
+  virtual void SetValue(const wxString& value);
+  virtual void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+
+  // Clipboard operations
+  virtual void Copy(void);
+  virtual void Cut(void);
+  virtual void Paste(void);
+
+  virtual void SetInsertionPoint(const long pos);
+  virtual void SetInsertionPointEnd(void);
+  virtual long GetInsertionPoint(void) const ;
+  virtual long GetLastPosition(void) const ;
+  virtual void Replace(const long from, const long to, const wxString& value);
+  virtual void Remove(const long from, const long to);
+  virtual void SetSelection(const long from, const long to);
+
+  virtual void Command(wxCommandEvent& event);
+
+  virtual void SetEditable(const bool editable);
+
+#ifndef NO_TEXT_WINDOW_STREAM
+  int overflow(int i);
+  int sync(void);
+  int underflow(void);
+#endif
+
+  void OnDropFiles(wxDropFilesEvent& event);
+
+  wxTextCtrl& operator<<(const wxString& s);
+  wxTextCtrl& operator<<(const int i);
+  wxTextCtrl& operator<<(const long i);
+  wxTextCtrl& operator<<(const float f);
+  wxTextCtrl& operator<<(const double d);
+  wxTextCtrl& operator<<(const char c);
+
+  virtual bool LoadFile(const wxString& file);
+  virtual bool SaveFile(const wxString& file);
+  virtual void WriteText(const wxString& text);
+  virtual void DiscardEdits(void);
+  virtual bool IsModified(void) const;
+
+#if WXWIN_COMPATIBILITY
+  inline bool Modified(void) const { return IsModified(); }
+#endif
+
+  virtual long XYToPosition(const long x, const long y) const ;
+  virtual void PositionToXY(const long pos, long *x, long *y) const ;
+  virtual void ShowPosition(const long pos);
+  virtual int GetLineLength(const long lineNo) const ;
+  virtual wxString GetLineText(const long lineNo) const ;
+  virtual int GetNumberOfLines(void) const ;
+  virtual void Clear(void);
+
+  // Process special keys e.g. 'enter' and process as if it were a command, if required
+  void OnChar(wxKeyEvent& event);
+
+  void OnEraseBackground(wxEraseEvent& event);
+
+  // Implementation
+  virtual bool MSWCommand(const WXUINT param, const WXWORD id);
+  inline bool IsRich(void) { return m_isRich; }
+  inline void SetRichEdit(const bool isRich) { m_isRich = isRich; }
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+  virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+  virtual void AdoptAttributesFromHWND(void);
+  virtual void SetupColours(void);
+
+protected:
+   bool      m_isRich; // Are we using rich text edit to implement this?
+
+DECLARE_EVENT_TABLE()
+};
+
+#endif
+    // __TEXTCTRLH__
diff --git a/include/wx/msw/timer.h b/include/wx/msw/timer.h
new file mode 100644
index 0000000000..a6e6d4d3f8
--- /dev/null
+++ b/include/wx/msw/timer.h
@@ -0,0 +1,52 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        timer.h
+// Purpose:     wxTimer class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __TIMERH__
+#define __TIMERH_
+
+#ifdef __GNUG__
+#pragma interface "timer.h"
+#endif
+
+#include "wx/object.h"
+
+class WXDLLEXPORT wxTimer: public wxObject
+{
+  DECLARE_DYNAMIC_CLASS(wxTimer)
+
+ public:
+  bool oneShot ;
+  int  milli ;
+  int  lastMilli ;
+
+  long id;
+ public:
+  wxTimer(void);
+  ~wxTimer(void);
+  virtual bool Start(int milliseconds = -1,bool one_shot = FALSE); // Start timer
+  virtual void Stop(void);                   // Stop timer
+  virtual void Notify(void) = 0;             // Override this member
+  inline int Interval(void) { return milli ; }; // Returns the current interval time (0 if stop)
+};
+
+// Timer functions (milliseconds)
+void WXDLLEXPORT wxStartTimer(void);
+// Gets time since last wxStartTimer or wxGetElapsedTime
+long WXDLLEXPORT wxGetElapsedTime(bool resetTimer = TRUE);
+
+// EXPERIMENTAL: comment this out if it doesn't compile.
+bool WXDLLEXPORT wxGetLocalTime(long *timeZone, int *dstObserved);
+
+// Get number of seconds since 00:00:00 GMT, Jan 1st 1970.
+long WXDLLEXPORT wxGetCurrentTime(void);
+
+#endif
+    // __TIMERH_
diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h
new file mode 100644
index 0000000000..978e96622b
--- /dev/null
+++ b/include/wx/msw/treectrl.h
@@ -0,0 +1,228 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        treectrl.h
+// Purpose:     wxTreeCtrl class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __TREECTRLH__
+#define __TREECTRLH__
+
+#ifdef __GNUG__
+#pragma interface "treectrl.h"
+#endif
+
+#include "wx/control.h"
+#include "wx/event.h"
+#include "wx/imaglist.h"
+
+// WXDLLEXPORT_DATA(extern const char*) wxTreeNameStr;
+
+#define wxTREE_MASK_HANDLE          0x0001
+#define wxTREE_MASK_STATE           0x0002
+#define wxTREE_MASK_TEXT            0x0004
+#define wxTREE_MASK_IMAGE           0x0008
+#define wxTREE_MASK_SELECTED_IMAGE  0x0010
+#define wxTREE_MASK_CHILDREN        0x0020
+#define wxTREE_MASK_DATA            0x0040
+
+#define wxTREE_STATE_BOLD           0x0001
+#define wxTREE_STATE_DROPHILITED    0x0002
+#define wxTREE_STATE_EXPANDED       0x0004
+#define wxTREE_STATE_EXPANDEDONCE   0x0008
+#define wxTREE_STATE_FOCUSED        0x0010
+#define wxTREE_STATE_SELECTED       0x0020
+#define wxTREE_STATE_CUT            0x0040
+
+#define wxTREE_HITTEST_ABOVE            0x0001  // Above the client area.
+#define wxTREE_HITTEST_BELOW            0x0002  // Below the client area.
+#define wxTREE_HITTEST_NOWHERE          0x0004  // In the client area but below the last item.
+#define wxTREE_HITTEST_ONITEMBUTTON     0x0010  // On the button associated with an item.
+#define wxTREE_HITTEST_ONITEMICON       0x0020  // On the bitmap associated with an item.
+#define wxTREE_HITTEST_ONITEMINDENT     0x0040  // In the indentation associated with an item.
+#define wxTREE_HITTEST_ONITEMLABEL      0x0080  // On the label (string) associated with an item.
+#define wxTREE_HITTEST_ONITEMRIGHT      0x0100  // In the area to the right of an item.
+#define wxTREE_HITTEST_ONITEMSTATEICON  0x0200  // On the state icon for a tree view item that is in a user-defined state.
+#define wxTREE_HITTEST_TOLEFT           0x0400  // To the right of the client area.
+#define wxTREE_HITTEST_TORIGHT          0x0800  // To the left of the client area.
+
+#define wxTREE_HITTEST_ONITEM (wxTREE_HITTEST_ONITEMICON | wxTREE_HITTEST_ONITEMLABEL wxTREE_HITTEST_ONITEMSTATEICON)
+
+// Flags for GetNextItem
+enum {
+    wxTREE_NEXT_CARET,                 // Retrieves the currently selected item.
+    wxTREE_NEXT_CHILD,                 // Retrieves the first child item. The hItem parameter must be NULL.
+    wxTREE_NEXT_DROPHILITE,            // Retrieves the item that is the target of a drag-and-drop operation.
+    wxTREE_NEXT_FIRSTVISIBLE,          // Retrieves the first visible item.
+    wxTREE_NEXT_NEXT,                 // Retrieves the next sibling item.
+    wxTREE_NEXT_NEXTVISIBLE,           // Retrieves the next visible item that follows the specified item.
+    wxTREE_NEXT_PARENT,                // Retrieves the parent of the specified item.
+    wxTREE_NEXT_PREVIOUS,              // Retrieves the previous sibling item.
+    wxTREE_NEXT_PREVIOUSVISIBLE,       // Retrieves the first visible item that precedes the specified item.
+    wxTREE_NEXT_ROOT                   // Retrieves the first child item of the root item of which the specified item is a part.
+};
+
+// Flags for ExpandItem
+enum {
+    wxTREE_EXPAND_EXPAND,
+    wxTREE_EXPAND_COLLAPSE,
+    wxTREE_EXPAND_COLLAPSE_RESET,
+    wxTREE_EXPAND_TOGGLE
+};
+
+// Flags for InsertItem
+enum {
+    wxTREE_INSERT_LAST = -1,
+    wxTREE_INSERT_FIRST = -2,
+    wxTREE_INSERT_SORT = -3
+};
+
+class WXDLLEXPORT wxTreeItem: public wxObject
+{
+ DECLARE_DYNAMIC_CLASS(wxTreeItem)
+public:
+    long            m_mask;
+    long            m_itemId;
+    long            m_state;
+    long            m_stateMask;
+    wxString        m_text;
+    int             m_image;
+    int             m_selectedImage;
+    int             m_children;
+    long            m_data;
+
+    wxTreeItem(void);
+};
+
+class WXDLLEXPORT wxTreeCtrl: public wxControl
+{
+  DECLARE_DYNAMIC_CLASS(wxTreeCtrl)
+ public:
+  /*
+   * Public interface
+   */
+
+  wxTreeCtrl(void);
+
+  inline wxTreeCtrl(wxWindow *parent, const wxWindowID id = -1,
+            const wxPoint& pos = wxDefaultPosition,
+            const wxSize& size = wxDefaultSize,
+            const long style = wxTR_HAS_BUTTONS,
+            const wxValidator& validator = wxDefaultValidator,
+            const wxString& name = "wxTreeCtrl")
+  {
+    Create(parent, id, pos, size, style, validator, name);
+  }
+  ~wxTreeCtrl(void);
+
+  bool Create(wxWindow *parent, const wxWindowID id = -1,
+            const wxPoint& pos = wxDefaultPosition,
+            const wxSize& size = wxDefaultSize,
+            const long style = wxTR_HAS_BUTTONS,
+            const wxValidator& validator = wxDefaultValidator,
+            const wxString& name = "wxTreeCtrl");
+
+  // Attributes
+  int GetCount(void) const ;
+  int GetIndent(void) const ;
+  void SetIndent(int indent) ;
+  wxImageList *GetImageList(const int which = wxIMAGE_LIST_NORMAL) const ;
+  void SetImageList(wxImageList *imageList, const int which = wxIMAGE_LIST_NORMAL) ;
+  long GetNextItem(const long item, int code) const ;
+  bool ItemHasChildren(const long item) const ;
+  long GetChild(const long item) const ;
+  long GetParent(const long item) const ;
+  long GetFirstVisibleItem(void) const ;
+  long GetNextVisibleItem(const long item) const ;
+  long GetSelection(void) const ;
+  long GetRootItem(void) const ;
+  bool GetItem(wxTreeItem& info) const ;
+  bool SetItem(wxTreeItem& info) ;
+  int  GetItemState(const long item, const long stateMask) const ;
+  bool SetItemState(const long item, const long state, const long stateMask) ;
+  bool SetItemImage(const long item, const int image, const int selImage) ;
+  wxString GetItemText(const long item) const ;
+  void SetItemText(const long item, const wxString& str) ;
+  long GetItemData(const long item) const ;
+  bool SetItemData(const long item, long data) ;
+  bool GetItemRect(const long item, wxRectangle& rect, bool textOnly = FALSE) const;
+  wxTextCtrl& GetEditControl(void) const;
+
+  // Operations
+  bool DeleteItem(const long item);
+  bool ExpandItem(const long item, const int action);
+  long InsertItem(const long parent, wxTreeItem& info, const long insertAfter = wxTREE_INSERT_LAST);
+
+  // If image > -1 and selImage == -1, the same image is used for
+  // both selected and unselected items.
+  long InsertItem(const long parent, const wxString& label, const int image = -1, const int selImage = -1, const long insertAfter = wxTREE_INSERT_LAST);
+  bool SelectItem(const long item);
+  bool ScrollTo(const long item);
+  bool DeleteAllItems(void) ;
+  wxTextCtrl& Edit(const long item) ;
+  long HitTest(const wxPoint& point, int& flags);
+//  wxImageList *CreateDragImage(const long item) ;
+  bool SortChildren(const long item) ;
+  bool EnsureVisible(const long item) ;
+
+  void Command(wxCommandEvent& event) { ProcessCommand(event); };
+
+  // IMPLEMENTATION
+  bool MSWCommand(const WXUINT param, const WXWORD id);
+  bool MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam);
+
+protected:
+  wxTextCtrl m_textCtrl;
+  wxImageList *m_imageListNormal;
+  wxImageList *m_imageListState;
+};
+
+/*
+ wxEVT_COMMAND_TREE_BEGIN_DRAG,
+ wxEVT_COMMAND_TREE_BEGIN_RDRAG,
+ wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT,
+ wxEVT_COMMAND_TREE_END_LABEL_EDIT,
+ wxEVT_COMMAND_TREE_DELETE_ITEM,
+ wxEVT_COMMAND_TREE_GET_INFO,
+ wxEVT_COMMAND_TREE_SET_INFO,
+ wxEVT_COMMAND_TREE_ITEM_EXPANDED,
+ wxEVT_COMMAND_TREE_ITEM_EXPANDING,
+ wxEVT_COMMAND_TREE_SEL_CHANGED,
+ wxEVT_COMMAND_TREE_SEL_CHANGING,
+ wxEVT_COMMAND_TREE_KEY_DOWN
+*/
+
+class WXDLLEXPORT wxTreeEvent: public wxCommandEvent
+{
+  DECLARE_DYNAMIC_CLASS(wxTreeEvent)
+
+ public:
+  wxTreeEvent(WXTYPE commandType = 0, int id = 0);
+
+  int           m_code;
+  wxTreeItem    m_item;
+  long          m_oldItem;
+  wxPoint       m_pointDrag;
+};
+
+typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
+
+#define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_GET_INFO(id, fn) { wxEVT_COMMAND_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_SET_INFO(id, fn) { wxEVT_COMMAND_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+#define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_COMMAND_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn },
+
+#endif
+    // __TREECTRLH__
diff --git a/include/wx/msw/watch1.cur b/include/wx/msw/watch1.cur
new file mode 100644
index 0000000000000000000000000000000000000000..323f01c3e5e7698be6414ef664354d7ea0f22e9d
GIT binary patch
literal 326
zcmaivJraU25QSf)pp2D`1(cRnc8K@U&N5=Sffr&X+<?xpLXHr}h8e*%%a78zJ6|@t
zlYMUj%peekz#I~50W1Kl9Bzc2L%8f>D1Gxgi3q~VR9qe@^c#Y7>X|n8t*m76w1H{s
zr7CaR)|{f(J!4c8mx}1ip7d3bc70DoI%77Z4}m_{fk|pv94%{lCdt{O^Kzc--2m~F
i8VD>PE5OeIk4fEEM(`)bcU<#fzj9iv$=XvdzJCB`+hyqh

literal 0
HcmV?d00001

diff --git a/include/wx/msw/wave.h b/include/wx/msw/wave.h
new file mode 100644
index 0000000000..9ca6d0f33d
--- /dev/null
+++ b/include/wx/msw/wave.h
@@ -0,0 +1,43 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wave.h
+// Purpose:     wxWave class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __WAVEH__
+#define __WAVEH__
+
+#ifdef __GNUG__
+#pragma interface "wave.h"
+#endif
+
+#include <wx/object.h>
+
+class wxWave : public wxObject
+{
+public:
+  wxWave(void);
+  wxWave(const wxString& fileName, bool isResource = FALSE);
+  ~wxWave(void);
+
+public:
+  bool  Create(const wxString& sFileName, bool isResource = FALSE);
+  bool  IsOk(void) const { return (m_waveData ? TRUE : FALSE); };
+  bool  Play(bool async = TRUE, bool looped = FALSE) const;
+
+protected:
+  bool  Free(void);
+
+private:
+  byte* m_waveData;
+  int   m_waveLength;
+  bool  m_isResource;
+};
+
+#endif
+
diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h
new file mode 100644
index 0000000000..73d5971c39
--- /dev/null
+++ b/include/wx/msw/window.h
@@ -0,0 +1,798 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        window.h
+// Purpose:     wxWindow class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __WINDOWH__
+#define __WINDOWH__
+
+#ifdef __GNUG__
+#pragma interface "window.h"
+#endif
+
+#include "wx/gdicmn.h"
+#include "wx/icon.h"
+#include "wx/cursor.h"
+#include "wx/pen.h"
+#include "wx/font.h"
+#include "wx/validate.h"
+#include "wx/event.h"
+#include "wx/string.h"
+#include "wx/list.h"
+
+#define wxKEY_SHIFT     1
+#define wxKEY_CTRL      2
+
+/*
+ * Base class for frame, panel, canvas, panel items, dialog box.
+ *
+ */
+
+/*
+ * Event handler: windows have themselves as their event handlers
+ * by default, but their event handlers could be set to another
+ * object entirely. This separation can reduce the amount of
+ * derivation required, and allow alteration of a window's functionality
+ * (e.g. by a resource editor that temporarily switches event handlers).
+ */
+
+class WXDLLEXPORT wxWindow;
+class WXDLLEXPORT wxEvent;
+class WXDLLEXPORT wxCommandEvent;
+class WXDLLEXPORT wxKeyEvent;
+class WXDLLEXPORT wxControl;
+class WXDLLEXPORT wxCursor;
+class WXDLLEXPORT wxColourMap;
+class WXDLLEXPORT wxFont;
+class WXDLLEXPORT wxMenu;
+class WXDLLEXPORT wxRectangle;
+class WXDLLEXPORT wxBitmap;
+class WXDLLEXPORT wxSizer;
+class WXDLLEXPORT wxList;
+class WXDLLEXPORT wxLayoutConstraints;
+class WXDLLEXPORT wxMouseEvent;
+class WXDLLEXPORT wxButton;
+class WXDLLEXPORT wxColour;
+class WXDLLEXPORT wxBrush;
+class WXDLLEXPORT wxPen;
+class WXDLLEXPORT wxIcon;
+class WXDLLEXPORT wxDC;
+class WXDLLEXPORT wxValidator;
+
+#if USE_DRAG_AND_DROP
+class wxDropTarget;
+#endif
+
+#if USE_WX_RESOURCES
+class WXDLLEXPORT wxResourceTable;
+class WXDLLEXPORT wxItemResource;
+#endif
+
+WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr;
+
+WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
+WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
+
+class WXDLLEXPORT wxWindow: public wxEvtHandler
+{
+  DECLARE_ABSTRACT_CLASS(wxWindow)
+
+  friend class wxUpdateIterator;
+  friend class wxDC;
+  friend class wxPaintDC;
+
+public:
+  wxWindow(void);
+  inline wxWindow(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = 0,
+           const wxString& name = wxPanelNameStr)
+  {
+  	  m_children = new wxList;
+      Create(parent, id, pos, size, style, name);
+  }
+
+  virtual ~wxWindow(void);
+
+  bool Create(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos = wxDefaultPosition,
+           const wxSize& size = wxDefaultSize,
+           const long style = 0,
+           const wxString& name = wxPanelNameStr);
+
+  // Fit the window around the items
+  virtual void Fit(void);
+
+  // Show or hide the window
+  virtual bool Show(const bool show);
+
+  // Is the window shown?
+  virtual bool IsShown(void) const;
+
+  // Raise the window to the top of the Z order
+  virtual void Raise(void);
+
+  // Lower the window to the bottom of the Z order
+  virtual void Lower(void);
+
+  // Is the window enabled?
+  virtual bool IsEnabled(void) const;
+
+  // For compatibility
+  inline bool Enabled(void) const { return IsEnabled(); }
+
+  // Dialog support: override these and call
+  // base class members to add functionality
+  // that can't be done using validators.
+
+  // Transfer values to controls. If returns FALSE,
+  // it's an application error (pops up a dialog)
+  virtual bool TransferDataToWindow(void);
+
+  // Transfer values from controls. If returns FALSE,
+  // transfer failed: don't quit
+  virtual bool TransferDataFromWindow(void);
+
+  // Validate controls. If returns FALSE,
+  // validation failed: don't quit
+  virtual bool Validate(void);
+
+  // Return code for dialogs
+  inline void SetReturnCode(int retCode);
+  inline int GetReturnCode(void);
+
+  // Set the cursor
+  virtual void SetCursor(const wxCursor& cursor);
+  inline virtual wxCursor *GetCursor(void) const { return (wxCursor *)& m_windowCursor; };
+
+  // Get the window with the focus
+  static wxWindow *FindFocus(void);
+
+  // Get character size
+  virtual int GetCharHeight(void) const;
+  virtual int GetCharWidth(void) const;
+
+  // Get overall window size
+  virtual void GetSize(int *width, int *height) const;
+
+  // Get window position, relative to parent (or screen if no parent)
+  virtual void GetPosition(int *x, int *y) const;
+
+  // Get client (application-useable) size
+  virtual void GetClientSize(int *width, int *height) const;
+
+  // Set overall size and position
+  virtual void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
+  inline virtual void SetSize(const int width, const int height) { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); }
+  inline virtual void Move(const int x, const int y) { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING); }
+
+  // Set client size
+  virtual void SetClientSize(const int width, const int size);
+
+  // Convert client to screen coordinates
+  virtual void ClientToScreen(int *x, int *y) const;
+
+  // Convert screen to client coordinates
+  virtual void ScreenToClient(int *x, int *y) const;
+
+  // Set the focus to this window
+  virtual void SetFocus(void);
+
+  // Capture/release mouse
+  virtual void CaptureMouse(void);
+  virtual void ReleaseMouse(void);
+
+  // Enable or disable the window
+  virtual void Enable(const bool enable);
+
+#if USE_DRAG_AND_DROP
+  // Associate a drop target with this window (if the window already had a drop
+  // target, it's deleted!) and return the current drop target (may be NULL).
+  void          SetDropTarget(wxDropTarget *pDropTarget);
+  wxDropTarget *GetDropTarget() const { return m_pDropTarget; }
+#endif
+
+  // Accept files for dragging
+  virtual void DragAcceptFiles(const bool accept);
+
+  // Set/get the window title
+  virtual inline void SetTitle(const wxString& WXUNUSED(title)) {};
+  inline virtual wxString GetTitle(void) const { return wxString(""); };
+  // Most windows have the concept of a label; for frames, this is the
+  // title; for items, this is the label or button text.
+  inline virtual wxString GetLabel(void) const { return GetTitle(); }
+
+  // Set/get the window name (used for resource setting in X)
+  inline virtual wxString GetName(void) const;
+  inline virtual void SetName(const wxString& name);
+
+  // Centre the window
+  virtual void Centre(const int direction) ;
+  inline void Center(const int direction = wxHORIZONTAL) { Centre(direction); }
+
+  // Popup a menu
+  virtual bool PopupMenu(wxMenu *menu, const int x, const int y);
+
+  // Send the window a refresh event
+  virtual void Refresh(const bool eraseBack = TRUE, const wxRectangle *rect = NULL);
+
+#if WXWIN_COMPATIBILITY
+  // Set/get scroll attributes
+  virtual void SetScrollRange(const int orient, const int range, const bool refresh = TRUE);
+  virtual void SetScrollPage(const int orient, const int page, const bool refresh = TRUE);
+  virtual int OldGetScrollRange(const int orient) const;
+  virtual int GetScrollPage(const int orient) const;
+#endif
+
+  // New functions that will replace the above.
+  virtual void SetScrollbar(const int orient, const int pos, const int thumbVisible,
+    const int range, const bool refresh = TRUE);
+
+  virtual void SetScrollPos(const int orient, const int pos, const bool refresh = TRUE);
+  virtual int GetScrollPos(const int orient) const;
+  virtual int GetScrollRange(const int orient) const;
+  virtual int GetScrollThumb(const int orient) const;
+
+  virtual void ScrollWindow(const int dx, const int dy, const wxRectangle *rect = NULL);
+
+  // Caret manipulation
+  virtual void CreateCaret(const int w, const int h);
+  virtual void CreateCaret(const wxBitmap *bitmap);
+  virtual void DestroyCaret(void);
+  virtual void ShowCaret(const bool show);
+  virtual void SetCaretPos(const int x, const int y);
+  virtual void GetCaretPos(int *x, int *y) const;
+
+  // Tell window how much it can be sized
+  virtual void SetSizeHints(const int minW = -1, const int minH = -1, const int maxW = -1, const int maxH = -1, const int incW = -1, const int incH = -1);
+
+  // Set/get the window's identifier
+  inline int GetId() const;
+  inline void SetId(const int id);
+
+  // Make the window modal (all other windows unresponsive)
+  virtual void MakeModal(const bool modal);
+
+  // Get the private handle (platform-dependent)
+  inline void *GetHandle(void) const;
+
+  // Set/get the window's relatives
+  inline wxWindow *GetParent(void) const;
+  inline void SetParent(wxWindow *p) ;
+  inline wxWindow *GetGrandParent(void) const;
+  inline wxList *GetChildren() const;
+
+  // Set/get the window's font
+  virtual void SetFont(const wxFont& f);
+  inline virtual wxFont *GetFont(void) const;
+
+  // Set/get the window's validator
+  void SetValidator(const wxValidator& validator);
+  inline wxValidator *GetValidator(void) const;
+
+  // Set/get the window's style
+  inline void SetWindowStyleFlag(const long flag);
+  inline long GetWindowStyleFlag(void) const;
+
+  // Set/get double-clickability
+  // TODO: we probably wish to get rid of this, and
+  // always allow double clicks.
+  inline void SetDoubleClick(const bool flag);
+  inline bool GetDoubleClick(void) const;
+  inline void AllowDoubleClick(const bool value)  { SetDoubleClick(value); }
+
+  // Old way to handle a control command
+  virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
+
+  // Set/get event handler
+  inline void SetEventHandler(wxEvtHandler *handler);
+  inline wxEvtHandler *GetEventHandler(void) const;
+
+  // Push/pop event handler (i.e. allow a chain of event handlers
+  // be searched)
+  void PushEventHandler(wxEvtHandler *handler) ;
+  wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ;
+  
+  // Close the window by calling OnClose, posting a deletion
+  virtual bool Close(const bool force = FALSE);
+
+  // Destroy the window (delayed, if a managed window)
+  virtual bool Destroy(void) ;
+
+  // Mode for telling default OnSize members to
+  // call Layout(), if not using Sizers, just top-down constraints
+  inline void SetAutoLayout(const bool a);
+  inline bool GetAutoLayout(void) const;
+
+  // Set/get constraints
+  inline wxLayoutConstraints *GetConstraints(void) const;
+  void SetConstraints(wxLayoutConstraints *c);
+
+  // Set/get window background colour
+  inline virtual void SetBackgroundColour(const wxColour& col);
+  inline virtual wxColour GetBackgroundColour(void) const;
+
+  // Set/get window foreground colour
+  inline virtual void SetForegroundColour(const wxColour& col);
+  inline virtual wxColour GetForegroundColour(void) const;
+
+  // TODO: are these really necessary???
+  // Set/get window default background colour (for children to inherit)
+  inline virtual void SetDefaultBackgroundColour(const wxColour& col);
+  inline virtual wxColour GetDefaultBackgroundColour(void) const;
+
+  // Set/get window default foreground colour (for children to inherit)
+  inline virtual void SetDefaultForegroundColour(const wxColour& col);
+  inline virtual wxColour GetDefaultForegroundColour(void) const;
+
+  // For backward compatibility
+  inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
+  inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
+  inline virtual wxFont  *GetLabelFont(void) const { return GetFont(); };
+  inline virtual wxFont  *GetButtonFont(void) const { return GetFont(); };
+
+  // Get the default button, if there is one
+  inline virtual wxButton *GetDefaultItem(void) const;
+  inline virtual void SetDefaultItem(wxButton *but);
+
+  // Override to define new behaviour for default action (e.g. double clicking
+  // on a listbox)
+  virtual void OnDefaultAction(wxControl *initiatingItem);
+
+  // Resource loading
+#if USE_WX_RESOURCES
+  virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL);
+  virtual wxControl *CreateItem(const wxItemResource *childResource, const wxResourceTable *table = NULL);
+#endif
+
+  // Native resource loading
+  virtual bool LoadNativeDialog(wxWindow* parent, const wxWindowID& id);
+  virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
+  virtual wxWindow* GetWindowChild1(const wxWindowID& id);
+  virtual wxWindow* GetWindowChild(const wxWindowID& id);
+
+  virtual void GetTextExtent(const wxString& string, int *x, int *y,
+                             int *descent = NULL,
+                             int *externalLeading = NULL,
+                             const wxFont *theFont = NULL, const bool use16 = FALSE) const;
+#if WXWIN_COMPATIBILITY
+  void GetTextExtent(const wxString& string, float *x, float *y,
+                             float *descent = NULL,
+                             float *externalLeading = NULL,
+                             const wxFont *theFont = NULL, const bool use16 = FALSE) const;
+#endif
+
+  // Gets 'context' member
+  // OBSOLETE
+  // TODO: how to make backward compatible?
+//  inline wxDC *GetDC(void) const;
+
+  // Is the window retained?
+  inline bool IsRetained(void) const;
+
+  // Set the window's colourmap/palette
+  // OBSOLETE
+//  virtual void SetPalette(wxPalette *palette);
+
+  // Warp the pointer the given position
+  virtual void WarpPointer(const int x_pos, const int y_pos) ;
+
+  // Clear the window
+  virtual void Clear(void);
+
+  // Find a window by id or name
+  virtual wxWindow *FindWindow(const long id);
+  virtual wxWindow *FindWindow(const wxString& name);
+
+  // Constraint operations
+  bool Layout(void);
+  void SetSizer(wxSizer *sizer);    // Adds sizer child to this window
+  inline wxSizer *GetSizer(void) const ;
+  inline wxWindow *GetSizerParent(void) const ;
+  inline void SetSizerParent(wxWindow *win);
+
+  // Do Update UI processing for controls
+  void UpdateWindowUI(void);
+
+  void OnSize(wxSizeEvent& event);
+  void OnEraseBackground(wxEraseEvent& event);
+  void OnChar(wxKeyEvent& event);
+  void OnPaint(wxPaintEvent& event);
+  void OnIdle(wxIdleEvent& event);
+
+//  virtual void OnChangeFocus(wxControl *from, wxControl *to);
+//  virtual bool OnFunctionKey(wxKeyEvent &event);
+
+#if WXWIN_COMPATIBILITY
+  virtual void OldOnMenuSelect(int WXUNUSED(cmd));
+  virtual void OldOnInitMenuPopup(int WXUNUSED(pos));
+  virtual void OldOnScroll(wxCommandEvent& WXUNUSED(event));
+  virtual void OldOnPaint(void);                 // Called when needs painting
+  virtual void OldOnSize(int width, int height);           // Called on resize
+  virtual void OldOnMouseEvent(wxMouseEvent& event);  // Called on mouse event
+  virtual void OldOnChar(wxKeyEvent& event);     // Called on character event
+  virtual void OldOnMenuCommand(int cmd); // Dealt with properly in wxFrame
+  inline virtual void OldOnMove(int WXUNUSED(x), int WXUNUSED(y));          // Called on move
+  inline virtual void OldOnActivate(bool WXUNUSED(active));       // Called on window activation (MSW)
+  virtual void OldOnSetFocus(void);              // Called on setting focus
+  virtual void OldOnKillFocus(void);             // Called on killing focus
+#endif
+
+/* THIS IS NOW OBSOLETE - all positions are in device units
+  // Calculates the position of a point on the window
+  // taking into account the position of scrollbars.
+  // Windows doesn't automatically reflect the position of the
+  // scrollbars - (0, 0) is always the top left of the visible window,
+  // whereas in XView, (0, 0) moves according to scrollbar positions.
+  virtual void CalcScrolledPosition(const int x, const int y, int *xx, int *yy) const ;
+
+  // Calculate logical (scroll-bar/scaling aware) position from
+  // device (pixel) position
+  virtual void CalcUnscrolledPosition(const int x, const int y, float *xx, float *yy) const ;
+*/
+
+public:
+  ////////////////////////////////////////////////////////////////////////
+  //// IMPLEMENTATION
+  
+  // Windows subclassing
+  void SubclassWin(WXHWND hWnd);
+  void UnsubclassWin(void);
+  virtual long Default(void);
+  virtual bool MSWCommand(const WXUINT param, const WXWORD id);
+  virtual bool MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam);
+  virtual wxWindow *FindItem(const int id) const;
+  virtual wxWindow *FindItemByHWND(const WXHWND hWnd, bool controlOnly = FALSE) const ;
+  virtual void PreDelete(const WXHDC dc);              // Allows system cleanup
+  // TO DO: how many of these need to be virtual?
+  virtual WXHWND GetHWND(void) const ;
+  virtual void SetHWND(WXHWND hWnd);
+
+  // Make a Windows extended style from the given wxWindows window style
+  virtual WXDWORD MakeExtendedStyle(long style, bool eliminateBorders = TRUE);
+  // Determine whether 3D effects are wanted
+  virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D);
+
+  virtual void AddChild(wxWindow *child);         // Adds reference to the child object
+  virtual void RemoveChild(wxWindow *child);   // Removes reference to child
+                                       // (but doesn't delete the child object)
+  virtual void DestroyChildren(void);  // Removes and destroys all children
+
+  inline bool IsBeingDeleted(void);
+
+  // MSW only: TRUE if this control is part of the main control
+  virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
+
+  // Constraint implementation
+  void UnsetConstraints(wxLayoutConstraints *c);
+  inline wxList *GetConstraintsInvolvedIn(void) const ;
+  // Back-pointer to other windows we're involved with, so if we delete
+  // this window, we must delete any constraints we're involved with.
+  void AddConstraintReference(wxWindow *otherWin);
+  void RemoveConstraintReference(wxWindow *otherWin);
+  void DeleteRelatedConstraints(void);
+
+  virtual void ResetConstraints(void);
+  virtual void SetConstraintSizes(const bool recurse = TRUE);
+  virtual bool LayoutPhase1(int *noChanges);
+  virtual bool LayoutPhase2(int *noChanges);
+  virtual bool DoPhase(const int);
+  // Transforms from sizer coordinate space to actual
+  // parent coordinate space
+  virtual void TransformSizerToActual(int *x, int *y) const ;
+
+  // Set size with transformation to actual coordinates if nec.
+  virtual void SizerSetSize(const int x, const int y, const int w, const int h);
+  virtual void SizerMove(const int x, const int y);
+
+  // Only set/get the size/position of the constraint (if any)
+  virtual void SetSizeConstraint(const int x, const int y, const int w, const int h);
+  virtual void MoveConstraint(const int x, const int y);
+  virtual void GetSizeConstraint(int *w, int *h) const ;
+  virtual void GetClientSizeConstraint(int *w, int *h) const ;
+  virtual void GetPositionConstraint(int *x, int *y) const ;
+
+  wxObject *GetChild(const int number) const ;
+
+  void MSWCreate(const int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title,
+               const int x, const int y, const int width, const int height,
+               const WXDWORD style, const char *dialog_template = NULL,
+               const WXDWORD exendedStyle = 0);
+
+  // Actually defined in wx_canvs.cc since requires wxCanvas declaration
+  virtual void MSWDeviceToLogical(float *x, float *y) const ;
+
+  // Create an appropriate wxWindow from a HWND
+  virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
+
+  // Make sure the window style reflects the HWND style (roughly)
+  virtual void AdoptAttributesFromHWND(void);
+
+  // Setup background and foreground colours correctly
+  virtual void SetupColours(void);
+
+  // Handlers
+  virtual void MSWOnCreate(WXLPCREATESTRUCT cs);
+  virtual bool MSWOnPaint(void);
+  virtual WXHICON MSWOnQueryDragIcon(void) { return 0; }
+  virtual void MSWOnSize(const int x, const int y, const WXUINT flag);
+  virtual void MSWOnWindowPosChanging(void *lpPos);
+  virtual void MSWOnHScroll(const WXWORD nSBCode, const WXWORD pos, const WXHWND control);
+  virtual void MSWOnVScroll(const WXWORD nSBCode, const WXWORD pos, const WXHWND control);
+  virtual bool MSWOnCommand(const WXWORD id, const WXWORD cmd, const WXHWND control);
+  virtual long MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam);
+  virtual bool MSWOnNotify(const WXWPARAM wParam, const WXLPARAM lParam);
+  virtual WXHBRUSH MSWOnCtlColor(const WXHDC dc, const WXHWND pWnd, const WXUINT nCtlColor,
+                              const WXUINT message, const WXWPARAM wParam, const WXLPARAM lParam);
+  virtual bool MSWOnColorChange(const WXHWND hWnd, const WXUINT message, const WXWPARAM wParam, const WXLPARAM lParam);
+  virtual bool MSWOnEraseBkgnd(const WXHDC pDC);
+  virtual void MSWOnMenuHighlight(const WXWORD item, const WXWORD flags, const WXHMENU sysmenu);
+  virtual void MSWOnInitMenuPopup(const WXHMENU menu, const int pos, const bool isSystem);
+  virtual bool MSWOnClose(void);
+  virtual bool MSWOnDestroy(void);
+  virtual bool MSWOnSetFocus(const WXHWND wnd);
+  virtual bool MSWOnKillFocus(const WXHWND wnd);
+  virtual void MSWOnDropFiles(const WXWPARAM wParam);
+  virtual bool MSWOnInitDialog(WXHWND hWndFocus);
+  virtual void MSWOnShow(bool show, int status);
+
+  // TODO: rationalise these functions into 1 or 2 which take the
+  // event type as argument.
+  virtual void MSWOnLButtonDown(const int x, const int y, const WXUINT flags);
+  virtual void MSWOnLButtonUp(const int x, const int y, const WXUINT flags);
+  virtual void MSWOnLButtonDClick(const int x, const int y, const WXUINT flags);
+
+  virtual void MSWOnMButtonDown(const int x, const int y, const WXUINT flags);
+  virtual void MSWOnMButtonUp(const int x, const int y, const WXUINT flags);
+  virtual void MSWOnMButtonDClick(const int x, const int y, const WXUINT flags);
+
+  virtual void MSWOnRButtonDown(const int x, const int y, const WXUINT flags);
+  virtual void MSWOnRButtonUp(const int x, const int y, const WXUINT flags);
+  virtual void MSWOnRButtonDClick(const int x, const int y, const WXUINT flags);
+
+  virtual void MSWOnMouseMove(const int x, const int y, const WXUINT flags);
+  virtual void MSWOnMouseEnter(const int x, const int y, const WXUINT flags);
+  virtual void MSWOnMouseLeave(const int x, const int y, const WXUINT flags);
+
+  virtual void MSWOnChar(const WXWORD wParam, const WXLPARAM lParam, const bool isASCII = FALSE);
+
+  virtual bool MSWOnActivate(const int flag, const bool minimized, const WXHWND activate);
+  virtual long MSWOnMDIActivate(const long flag, const WXHWND activate, const WXHWND deactivate);
+
+  virtual bool MSWOnDrawItem(const int id, WXDRAWITEMSTRUCT *item);
+  virtual bool MSWOnMeasureItem(const int id, WXMEASUREITEMSTRUCT *item);
+
+  virtual void MSWOnJoyDown(const int joystick, const int x, const int y, const WXUINT flags);
+  virtual void MSWOnJoyUp(const int joystick, const int x, const int y, const WXUINT flags);
+  virtual void MSWOnJoyMove(const int joystick, const int x, const int y, const WXUINT flags);
+  virtual void MSWOnJoyZMove(const int joystick, const int z, const WXUINT flags);
+
+  // Window procedure
+  virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+
+  // Calls an appropriate default window procedure
+  virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+  virtual bool MSWProcessMessage(WXMSG* pMsg);
+  virtual void MSWDestroyWindow(void);
+
+  // Detach "Window" menu from menu bar so it doesn't get deleted
+  void MSWDetachWindowMenu(void);
+  
+  inline WXFARPROC MSWGetOldWndProc() const;
+  inline void MSWSetOldWndProc(const WXFARPROC proc);
+
+  // Define for each class of dialog and control
+  virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+  inline void SetShowing(const bool show);
+  inline bool IsUserEnabled(void) const;
+  inline bool GetUseCtl3D(void) const ;
+  inline bool GetTransparentBackground(void) const ;
+
+  // Responds to colour changes: passes event on to children.
+  void OnSysColourChanged(wxSysColourChangedEvent& event);
+
+  // Transfers data to any child controls
+  void OnInitDialog(wxInitDialogEvent& event);
+
+  // Sends an OnInitDialog event, which in turns transfers data to
+  // to the window via validators.
+  virtual void InitDialog(void);
+
+  ////////////////////////////////////////////////////////////////////////
+  //// PROTECTED DATA
+protected:
+  int                   m_windowId;
+  long                  m_windowStyle; 			// Store the window's style
+  wxEvtHandler *        m_windowEventHandler; 	// Usually is 'this'
+  wxLayoutConstraints * m_constraints;           // Constraints for this window
+  wxList *              m_constraintsInvolvedIn; // List of constraints we're involved in
+  wxSizer *             m_windowSizer;                       // Window's top-level sizer (if any)
+  wxWindow *            m_sizerParent;                      // Window's parent sizer (if any)
+  bool                  m_autoLayout;                            // Whether to call Layout() in OnSize
+  wxWindow *            m_windowParent;                     // Each window always knows its parent
+  wxValidator *         m_windowValidator;
+  // Old window proc, for subclassed controls
+  WXFARPROC             m_oldWndProc;
+  bool                  m_useCtl3D;             // Using CTL3D for this control
+
+  bool                  m_inOnSize; 			// Protection against OnSize reentry
+#ifndef __WIN32__
+  // Pointer to global memory, for EDIT controls that need
+  // special treatment to reduce USER area consumption.
+  WXHGLOBAL             m_globalHandle;
+#endif
+
+  bool                  m_winEnabled;
+  int                   m_minSizeX;
+  int                   m_minSizeY;
+  int                   m_maxSizeX;
+  int                   m_maxSizeY;
+
+  // Caret data
+  int                   m_caretWidth;
+  int                   m_caretHeight;
+  bool                  m_caretEnabled;
+  bool                  m_caretShown;
+
+  // Device context being stored whilst drawing is done
+//  WXHDC                 m_tempHDC;
+  // Temporary device context stored during an OnPaint
+//  WXHDC                 m_paintHDC;
+  wxFont                m_windowFont;                               // Window's font
+  bool                  m_isShown;
+  bool                  m_doubleClickAllowed ;
+  wxCursor              m_windowCursor;                        // Window's cursor
+  bool                  m_winCaptured;
+  wxString              m_windowName;                            // Window name
+
+#if USE_EXTENDED_STATICS
+  wxList                m_staticItems;
+#endif
+
+  wxButton *            m_defaultItem;
+
+  wxColour              m_backgroundColour ;
+  wxColour              m_defaultBackgroundColour;
+
+  wxColour              m_foregroundColour ;
+  wxColour              m_defaultForegroundColour;
+
+  bool                  m_backgroundTransparent;
+
+//  wxDC *                m_windowDC;    // The canvas's device context
+
+  int                   m_xThumbSize;
+  int                   m_yThumbSize;
+
+  float                 m_lastXPos;
+  float                 m_lastYPos;
+  int                   m_lastEvent;
+
+  bool                  m_mouseInWindow;
+
+#if USE_DRAG_AND_DROP
+  wxDropTarget         *m_pDropTarget;    // the current drop target or NULL
+#endif  //USE_DRAG_AND_DROP
+
+public:
+  WXHWND                m_hWnd; 			// MS Windows window handle
+  WXUINT                m_lastMsg;
+  WXWPARAM              m_lastWParam;
+  WXLPARAM              m_lastLParam;
+  wxRectangle           m_updateRect;             // Bounding box for screen damage area
+#ifdef __WIN32__
+  WXHRGN                m_updateRgn;                  // NT allows access to the rectangle list
+#endif
+  WXHANDLE              m_acceleratorTable;
+  WXHMENU               m_hMenu; // Menu, if any
+  wxList *              m_children;                           // Window's children
+  int                   m_returnCode;
+  bool                  m_isBeingDeleted; // Fudge because can't access parent
+                        // when being deleted
+
+DECLARE_EVENT_TABLE()
+};
+
+////////////////////////////////////////////////////////////////////////
+//// INLINES
+
+inline void *wxWindow::GetHandle(void) const { return (void *)GetHWND(); }
+inline int wxWindow::GetId() const { return m_windowId; }
+inline void wxWindow::SetId(const int id) { m_windowId = id; }
+inline wxWindow *wxWindow::GetParent(void) const { return m_windowParent; }
+inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; }
+inline wxWindow *wxWindow::GetGrandParent(void) const { return (m_windowParent ? m_windowParent->m_windowParent : NULL); }
+inline wxList *wxWindow::GetChildren() const { return m_children; }
+inline wxFont *wxWindow::GetFont(void) const { return (wxFont *) & m_windowFont; }
+inline wxString wxWindow::GetName(void) const { return m_windowName; }
+inline void wxWindow::SetName(const wxString& name) { m_windowName = name; }
+inline long wxWindow::GetWindowStyleFlag(void) const { return m_windowStyle; }
+inline void wxWindow::SetWindowStyleFlag(const long flag) { m_windowStyle = flag; }
+inline void wxWindow::SetDoubleClick(const bool flag) { m_doubleClickAllowed = flag; }
+inline bool wxWindow::GetDoubleClick(void) const { return m_doubleClickAllowed; }
+inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; }
+inline wxEvtHandler *wxWindow::GetEventHandler(void) const { return m_windowEventHandler; }
+inline void wxWindow::SetAutoLayout(const bool a) { m_autoLayout = a; }
+inline bool wxWindow::GetAutoLayout(void) const { return m_autoLayout; }
+inline wxLayoutConstraints *wxWindow::GetConstraints(void) const { return m_constraints; }
+inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; };
+inline wxColour wxWindow::GetBackgroundColour(void) const { return m_backgroundColour; };
+inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; };
+inline wxColour wxWindow::GetForegroundColour(void) const { return m_foregroundColour; };
+inline void wxWindow::SetDefaultForegroundColour(const wxColour& col) { m_defaultForegroundColour = col; };
+inline wxColour wxWindow::GetDefaultForegroundColour(void) const { return m_defaultForegroundColour; };
+inline void wxWindow::SetDefaultBackgroundColour(const wxColour& col) { m_defaultBackgroundColour = col; };
+inline wxColour wxWindow::GetDefaultBackgroundColour(void) const { return m_defaultBackgroundColour; };
+
+inline wxButton *wxWindow::GetDefaultItem(void) const { return m_defaultItem; }
+inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
+// inline wxDC *wxWindow::GetDC(void) const { return m_windowDC; }
+inline bool wxWindow::IsRetained(void) const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); }
+#if WXWIN_COMPATIBILITY
+inline void wxWindow::OldOnMenuSelect(int WXUNUSED(cmd)) { Default(); };
+inline void wxWindow::OldOnInitMenuPopup(int WXUNUSED(pos)) { Default(); };
+inline void wxWindow::OldOnScroll(wxCommandEvent& WXUNUSED(event)) { Default(); };
+inline void wxWindow::OldOnMenuCommand(int WXUNUSED(cmd)) { Default(); } // Dealt with properly in wxFrame
+inline void wxWindow::OldOnMove(int WXUNUSED(x), int WXUNUSED(y)) { Default(); };          // Called on move
+inline void wxWindow::OldOnActivate(bool WXUNUSED(active)) { Default(); };       // Called on window activation (MSW)
+#endif
+inline void wxWindow::SetShowing(const bool show) { m_isShown = show; }
+inline wxList *wxWindow::GetConstraintsInvolvedIn(void) const { return m_constraintsInvolvedIn; }
+inline wxSizer *wxWindow::GetSizer(void) const { return m_windowSizer; }
+inline wxWindow *wxWindow::GetSizerParent(void) const { return m_sizerParent; }
+inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; }
+inline WXFARPROC wxWindow::MSWGetOldWndProc() const { return m_oldWndProc; }
+inline void wxWindow::MSWSetOldWndProc(const WXFARPROC proc) { m_oldWndProc = proc; }
+inline wxValidator *wxWindow::GetValidator(void) const { return m_windowValidator; }
+inline bool wxWindow::IsUserEnabled(void) const { return m_winEnabled; }
+inline bool wxWindow::GetUseCtl3D(void) const { return m_useCtl3D; }
+inline bool wxWindow::GetTransparentBackground(void) const { return m_backgroundTransparent; }
+inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
+inline int wxWindow::GetReturnCode(void) { return m_returnCode; }
+inline bool wxWindow::IsBeingDeleted(void) { return m_isBeingDeleted; }
+
+// Window specific (so far)
+wxWindow* WXDLLEXPORT wxGetActiveWindow(void);
+
+// Allows iteration through damaged rectangles in OnPaint
+class WXDLLEXPORT wxUpdateIterator
+{
+  int rects;						// How many rects in Update region
+  int current;					        // Current rectangle index
+  void *rp;						// current rectangle
+#ifdef	__WIN32__
+  WXRGNDATA *rlist;					// Storage for regiondata
+#endif
+
+ public:
+  wxUpdateIterator(wxWindow* wnd);
+  ~wxUpdateIterator(void);
+
+  operator int (void);
+  wxUpdateIterator* operator ++(int);
+  void GetRect(wxRectangle *rect);
+  int GetX();
+  int GetY();
+  int GetW();
+  int GetH();
+};
+
+WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows;
+
+int WXDLLEXPORT wxCharCodeMSWToWX(int keySym);
+int WXDLLEXPORT wxCharCodeWXToMSW(int id, bool *IsVirtual);
+
+// Allocates control ids
+int WXDLLEXPORT NewControlId(void);
+
+#endif
+    // __WINDOWH__
diff --git a/include/wx/msw/wx.rc b/include/wx/msw/wx.rc
new file mode 100644
index 0000000000..9bbc41a3ed
--- /dev/null
+++ b/include/wx/msw/wx.rc
@@ -0,0 +1,110 @@
+/////////////////////////////////////////////////////////////////////////////
+// File:     wx.rc
+// Purpose:  wxWindows resource definitions. ALWAYS include
+//           this in your application resource file.
+//
+//                     wxWindows version 1.50
+// Copyright (c) 1993 Artificial Intelligence Applications Institute,
+//                   The University of Edinburgh
+//
+//                     Author: Julian Smart
+//                       Date: 9-4-93
+//
+// Permission to use, copy, modify, and distribute this software and its
+// documentation for any purpose is hereby granted without fee, provided
+// that the above copyright notice, author statement and this permission
+// notice appear in all copies of this software and related documentation.
+//
+// THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
+// IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// IN NO EVENT SHALL THE ARTIFICIAL INTELLIGENCE APPLICATIONS INSTITUTE OR THE
+// UNIVERSITY OF EDINBURGH BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR
+// CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF
+// DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
+// THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/////////////////////////////////////////////////////////////////////////////
+//
+//
+
+#ifdef __GNUWIN32__
+#include <wx/msw/gnuwin32/winresrc.h>
+#else
+#include <windows.h>
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Dummy Dialog for all wxCAPTION Dialog boxes
+//
+
+wxCaptionDialog DIALOG DISCARDABLE  34, 22, 144, 75
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Dummy dialog"
+BEGIN
+	LTEXT "", -1,-2,-2,1,1   //necessary for __WATCOMC__
+END
+
+//
+// Dummy dialog for dialog boxes without caption & with thin frame
+//
+wxNoCaptionDialog DIALOG 34, 22, 144, 75
+STYLE WS_POPUP
+BEGIN
+	LTEXT "", -1,-2,-2,1,1   //necessary for __WATCOMC__
+END
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// This is the MDI Window menu
+//
+
+wxWindowMenu MENU DISCARDABLE
+BEGIN
+    POPUP "&Window"
+    BEGIN
+        MENUITEM "&Cascade",                    4002
+        MENUITEM "&Tile",                       4001
+        MENUITEM "&Arrange icons",              4003
+        MENUITEM "&Next",                       4004
+    END
+END
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Standard wxWindows Cursors
+//
+
+WXCURSOR_HAND           CURSOR  DISCARDABLE     "wx/msw/hand.cur"
+WXCURSOR_BULLSEYE       CURSOR  DISCARDABLE     "wx/msw/bullseye.cur"
+WXCURSOR_PENCIL         CURSOR  DISCARDABLE     "wx/msw/pencil.cur"
+WXCURSOR_MAGNIFIER      CURSOR  DISCARDABLE     "wx/msw/magnif1.cur"
+WXCURSOR_NO_ENTRY       CURSOR  DISCARDABLE     "wx/msw/noentry.cur"
+WXCURSOR_SIZING         CURSOR  DISCARDABLE     "wx/msw/size.cur"
+WXCURSOR_ROLLER         CURSOR  DISCARDABLE     "wx/msw/roller.cur"
+WXCURSOR_WATCH          CURSOR  DISCARDABLE     "wx/msw/watch1.cur"
+WXCURSOR_PBRUSH         CURSOR  DISCARDABLE     "wx/msw/pbrush.cur"
+WXCURSOR_PLEFT          CURSOR  DISCARDABLE     "wx/msw/pntleft.cur"
+WXCURSOR_PRIGHT         CURSOR  DISCARDABLE     "wx/msw/pntright.cur"
+WXCURSOR_QARROW         CURSOR  DISCARDABLE     "wx/msw/query.cur"
+WXCURSOR_BLANK          CURSOR  DISCARDABLE     "wx/msw/blank.cur"
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Default Icons
+//
+
+wxDEFAULT_FRAME               ICON "wx/msw/std.ico"
+wxDEFAULT_MDIPARENTFRAME      ICON "wx/msw/mdi.ico"
+wxDEFAULT_MDICHILDFRAME       ICON "wx/msw/child.ico"
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Bitmaps
+//
+
+wxDISABLE_BUTTON_BITMAP         BITMAP  "wx/msw/disable.bmp"
+
+
diff --git a/src/common/doslex.c b/src/common/doslex.c
new file mode 100644
index 0000000000..67e789afba
--- /dev/null
+++ b/src/common/doslex.c
@@ -0,0 +1,1214 @@
+/* A lexical scanner generated by flex */
+
+/* scanner skeleton version:
+ * $Header$
+	Last change:  JS   13 Jul 97    6:17 pm
+ */
+
+#define FLEX_SCANNER
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#include <osfcn.h>
+
+/* use prototypes in function declarations */
+#define YY_USE_PROTOS
+
+/* the "const" storage-class-modifier is valid */
+#define YY_USE_CONST
+
+#else	/* ! __cplusplus */
+
+#ifdef __STDC__
+
+#ifdef __GNUC__
+#include <stddef.h>
+#else
+#include <stdlib.h>
+#endif	/* __GNUC__ */
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif	/* __STDC__ */
+#endif	/* ! __cplusplus */
+
+
+#ifdef __TURBOC__
+#define YY_USE_CONST
+#endif
+
+
+#ifndef YY_USE_CONST
+#define const
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+/* we can't get here if it's an ANSI C compiler, or a C++ compiler,
+ * so it's got to be a K&R compiler, and therefore there's no standard
+ * place from which to include these definitions
+ */
+/*
+char *malloc();
+int free();
+*/
+
+int read();
+#endif
+
+
+/* amount of stuff to slurp up with each read */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* returned upon end-of-file */
+#define YY_END_TOK 0
+
+/* copy whatever the last rule matched to the standard output */
+
+/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
+/* this used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite()
+ */
+#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
+
+/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#define YY_INPUT(buf,result,max_size) \
+	if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
+	    YY_FATAL_ERROR( "read() in flex scanner failed" );
+#define YY_NULL 0
+
+/* no semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#define yyterminate() return ( YY_NULL )
+
+/* report a fatal error */
+
+/* The funky do-while is used to turn this macro definition into
+ * a single C statement (which needs a semi-colon terminator).
+ * This avoids problems with code like:
+ *
+ * 	if ( something_happens )
+ *		YY_FATAL_ERROR( "oops, the something happened" );
+ *	else
+ *		everything_okay();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the YY_FATAL_ERROR() call.
+ */
+
+#define YY_FATAL_ERROR(msg) \
+	do \
+		{ \
+		(void) fputs( msg, stderr ); \
+		(void) putc( '\n', stderr ); \
+		exit( 1 ); \
+		} \
+	while ( 0 )
+
+/* default yywrap function - always treat EOF as an EOF */
+int yywrap(void) { return 1; }
+
+
+/* enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* action number for EOF rule of a given start state */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* special action meaning "start processing a new file" */
+#define YY_NEW_FILE \
+	do \
+		{ \
+		yy_init_buffer( yy_current_buffer, yyin ); \
+		yy_load_buffer_state(); \
+		} \
+	while ( 0 )
+
+/* default declaration of generated scanner - a define so the user can
+ * easily add parameters
+ */
+#define YY_DECL int yylex YY_PROTO(( void )) 
+
+/* code executed at the end of each rule */
+#define YY_BREAK break;
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
+#endif
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+#define YY_CHAR unsigned char
+# line 1 "lexer.l"
+#define INITIAL 0
+# line 9 "lexer.l"
+/*
+ * File:         lexer.l
+ * Description:  Lexical analyser for PROLOGIO; can be used with
+ *               either lex and flex.
+ */
+#include <string.h>
+
+/* +++steve162e: added, otherwise, PROIO_input will be undefined (at least under LINUX)
+             please check, if this is also TRUE under other UNIXes.
+ */
+
+#if defined(FLEX_SCANNER) && defined(_LINUX)
+#define PROIO_input my_input
+#endif
+/* ---steve162e */
+
+#include "wx/expr.h"
+#ifdef wx_x
+extern char *malloc();
+#endif
+#define Return(x) return x;
+
+#if defined(VMS) && !defined(strdup)
+#define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s));
+#endif
+
+static size_t lex_buffer_length = 0;
+static const char *lex_buffer = NULL;
+static size_t lex_string_ptr = 0;
+static int lex_read_from_string = 0;
+
+static int my_input(void);
+static int my_unput(char);
+
+#ifdef FLEX_SCANNER
+#undef YY_INPUT
+# define YY_INPUT(buf,result,max_size) \
+   if (lex_read_from_string) \
+   {  int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \
+   else \
+	if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
+	    YY_FATAL_ERROR( "read() in flex scanner failed" );
+#else
+# undef unput
+# define unput(_c) my_unput(_c)
+#endif
+
+# line 58 "lexer.l"
+
+/* done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext
+ */
+#define YY_DO_BEFORE_ACTION \
+	yytext = yy_bp; \
+	yyleng = yy_cp - yy_bp; \
+	yy_hold_char = *yy_cp; \
+	*yy_cp = '\0'; \
+	yy_c_buf_p = yy_cp;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* return all but the first 'n' matched characters back to the input stream */
+#define yyless(n) \
+	do \
+		{ \
+		/* undo effects of setting up yytext */ \
+		*yy_cp = yy_hold_char; \
+		yy_c_buf_p = yy_cp = yy_bp + n; \
+		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+		} \
+	while ( 0 )
+
+#undef unput
+#define unput(c) yyunput( c, yytext )
+
+
+struct yy_buffer_state
+    {
+    FILE *yy_input_file;
+
+    YY_CHAR *yy_ch_buf;		/* input buffer */
+    YY_CHAR *yy_buf_pos;	/* current position in input buffer */
+
+    /* size of input buffer in bytes, not including room for EOB characters*/
+    int yy_buf_size;	
+
+    /* number of characters read into yy_ch_buf, not including EOB characters */
+    int yy_n_chars;
+
+    int yy_eof_status;		/* whether we've seen an EOF on this buffer */
+#define EOF_NOT_SEEN 0
+    /* "pending" happens when the EOF has been seen but there's still
+     * some text process
+     */
+#define EOF_PENDING 1
+#define EOF_DONE 2
+    };
+
+static YY_BUFFER_STATE yy_current_buffer;
+
+/* we provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state"
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed */
+static YY_CHAR yy_hold_char;
+
+static int yy_n_chars;		/* number of characters read into yy_ch_buf */
+
+
+
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+#ifndef YY_USER_INIT
+#define YY_USER_INIT
+#endif
+
+extern YY_CHAR *yytext;
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+YY_CHAR *yytext;
+int yyleng;
+
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+
+#define YY_END_OF_BUFFER 18
+typedef int yy_state_type;
+static const short int yy_accept[34] =
+    {   0,
+        0,    0,   18,   16,   13,   14,   16,   16,    6,    7,
+       16,    8,   12,   16,    1,   11,    3,    9,   10,    2,
+        0,    5,    0,    0,    0,    4,    1,   15,    3,    5,
+        0,    0,    0
+    } ;
+
+static const YY_CHAR yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    2,    1,    4,    1,    1,    1,    1,    5,    6,
+        7,    8,    9,   10,    9,   11,   12,   13,   13,   13,
+       13,   13,   13,   13,   13,   13,   13,    1,    1,    1,
+       14,    1,    1,    1,   15,   15,   15,   15,   15,   15,
+       15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
+       15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
+       16,   17,   18,    1,   15,    1,   15,   15,   15,   15,
+
+       19,   15,   15,   15,   15,   15,   15,   15,   15,   15,
+       15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
+       15,   15,    1,   20,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static const YY_CHAR yy_meta[21] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    2,    1,    2,    1,    3,    1,    2,    1
+    } ;
+
+static const short int yy_base[37] =
+    {   0,
+        0,    0,   48,   55,   55,   55,   17,   42,   55,   55,
+       19,   55,   55,   23,   17,   55,    0,   55,   55,    0,
+       18,   55,   19,   23,   21,   55,   12,   55,    0,   24,
+       25,   29,   55,   49,   52,   22
+    } ;
+
+static const short int yy_def[37] =
+    {   0,
+       33,    1,   33,   33,   33,   33,   34,   35,   33,   33,
+       33,   33,   33,   33,   33,   33,   36,   33,   33,   36,
+       34,   33,   34,   34,   35,   33,   33,   33,   36,   34,
+       34,   34,    0,   33,   33,   33
+    } ;
+
+static const short int yy_nxt[76] =
+    {   0,
+        4,    5,    6,    7,    8,    9,   10,    4,   11,   12,
+       13,   14,   15,   16,   17,   18,    4,   19,   20,    4,
+       22,   22,   30,   29,   27,   26,   22,   22,   30,   27,
+       28,   27,   30,   23,   23,   23,   24,   24,   24,   31,
+       23,   32,   24,   24,   24,   23,   26,   33,   24,   21,
+       21,   21,   25,   25,    3,   33,   33,   33,   33,   33,
+       33,   33,   33,   33,   33,   33,   33,   33,   33,   33,
+       33,   33,   33,   33,   33
+    } ;
+
+static const short int yy_chk[76] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        7,   21,   23,   36,   27,   25,   24,   30,   31,   15,
+       14,   11,   32,    7,   21,   23,    7,   21,   23,   24,
+       30,   31,   24,   30,   31,   32,    8,    3,   32,   34,
+       34,   34,   35,   35,   33,   33,   33,   33,   33,   33,
+       33,   33,   33,   33,   33,   33,   33,   33,   33,   33,
+       33,   33,   33,   33,   33
+    } ;
+
+static yy_state_type yy_last_accepting_state;
+static YY_CHAR *yy_last_accepting_cpos;
+
+/* the intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+
+/* these variables are all declared out here so that section 3 code can
+ * manipulate them
+ */
+/* points to current character in buffer */
+static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
+static int yy_init = 1;		/* whether we need to initialize */
+static int yy_start = 0;	/* start state number */
+
+/* flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin.  A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
+void yyrestart YY_PROTO(( FILE *input_file ));
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+
+#define yy_new_buffer yy_create_buffer
+
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+
+YY_DECL
+    {
+    register yy_state_type yy_current_state;
+    register YY_CHAR *yy_cp, *yy_bp;
+    register int yy_act;
+
+
+
+
+    if ( yy_init )
+	{
+	YY_USER_INIT;
+
+	if ( ! yy_start )
+	    yy_start = 1;	/* first start state */
+
+	if ( ! yyin )
+	    yyin = stdin;
+
+	if ( ! yyout )
+	    yyout = stdout;
+
+	if ( yy_current_buffer )
+	    yy_init_buffer( yy_current_buffer, yyin );
+	else
+	    yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+	yy_load_buffer_state();
+
+	yy_init = 0;
+	}
+
+    while ( 1 )		/* loops until end-of-file is reached */
+	{
+	yy_cp = yy_c_buf_p;
+
+	/* support of yytext */
+	*yy_cp = yy_hold_char;
+
+	/* yy_bp points to the position in yy_ch_buf of the start of the
+	 * current run.
+	 */
+	yy_bp = yy_cp;
+
+	yy_current_state = yy_start;
+yy_match:
+	do
+	    {
+	    register YY_CHAR yy_c = yy_ec[*yy_cp];
+	    if ( yy_accept[yy_current_state] )
+		{
+		yy_last_accepting_state = yy_current_state;
+		yy_last_accepting_cpos = yy_cp;
+		}
+	    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+		{
+		yy_current_state = yy_def[yy_current_state];
+		if ( yy_current_state >= 34 )
+		    yy_c = yy_meta[yy_c];
+		}
+	    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+	    ++yy_cp;
+	    }
+	while ( yy_current_state != 33 );
+	yy_cp = yy_last_accepting_cpos;
+	yy_current_state = yy_last_accepting_state;
+
+yy_find_action:
+	yy_act = yy_accept[yy_current_state];
+
+	YY_DO_BEFORE_ACTION;
+	YY_USER_ACTION;
+
+do_action:	/* this label is used only to access EOF actions */
+
+
+	switch ( yy_act )
+	    {
+	    case 0: /* must backtrack */
+	    /* undo the effects of YY_DO_BEFORE_ACTION */
+	    *yy_cp = yy_hold_char;
+	    yy_cp = yy_last_accepting_cpos;
+	    yy_current_state = yy_last_accepting_state;
+	    goto yy_find_action;
+
+case 1:
+# line 60 "lexer.l"
+{yylval.s = strdup(yytext); Return(INTEGER);}
+	YY_BREAK
+case 2:
+# line 62 "lexer.l"
+Return(EXP);
+	YY_BREAK
+case 3:
+# line 64 "lexer.l"
+{yylval.s = strdup(yytext); Return(WORD);}
+	YY_BREAK
+case 4:
+# line 66 "lexer.l"
+{int len = strlen(yytext);
+                                   yytext[len-1] = 0;
+                                   yylval.s = strdup(yytext+1); 
+                                   Return(WORD);}
+	YY_BREAK
+case 5:
+# line 71 "lexer.l"
+{yylval.s = strdup(yytext); Return(STRING);}
+	YY_BREAK
+case 6:
+# line 73 "lexer.l"
+Return(OPEN);
+	YY_BREAK
+case 7:
+# line 75 "lexer.l"
+Return(CLOSE);
+	YY_BREAK
+case 8:
+# line 77 "lexer.l"
+Return(COMMA);
+	YY_BREAK
+case 9:
+# line 79 "lexer.l"
+Return(OPEN_SQUARE);
+	YY_BREAK
+case 10:
+# line 81 "lexer.l"
+Return(CLOSE_SQUARE);
+	YY_BREAK
+case 11:
+# line 83 "lexer.l"
+Return(EQUALS);
+	YY_BREAK
+case 12:
+# line 85 "lexer.l"
+Return(PERIOD);
+	YY_BREAK
+case 13:
+# line 87 "lexer.l"
+;
+	YY_BREAK
+case 14:
+# line 89 "lexer.l"
+;
+	YY_BREAK
+case 15:
+# line 91 "lexer.l"
+{       loop:
+#ifdef __cplusplus
+                          while (yyinput() != '*');
+                          switch (yyinput())
+#else
+                          while (input() != '*');
+                          switch (input())
+#endif
+                                  {
+                                  case '/': break;
+                                  case '*': unput('*');
+                                  default: goto loop;
+                                  }
+                          }
+	YY_BREAK
+case 16:
+# line 106 "lexer.l"
+Return(ERROR);
+	YY_BREAK
+case 17:
+# line 108 "lexer.l"
+ECHO;
+	YY_BREAK
+case YY_STATE_EOF(INITIAL):
+    yyterminate();
+
+	    case YY_END_OF_BUFFER:
+		{
+		/* amount of text matched not including the EOB char */
+		int yy_amount_of_matched_text = yy_cp - yytext - 1;
+
+		/* undo the effects of YY_DO_BEFORE_ACTION */
+		*yy_cp = yy_hold_char;
+
+		/* note that here we test for yy_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since yy_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the end-
+		 * of-buffer state).  Contrast this with the test in yyinput().
+		 */
+		if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+		    /* this was really a NUL */
+		    {
+		    yy_state_type yy_next_state;
+
+		    yy_c_buf_p = yytext + yy_amount_of_matched_text;
+
+		    yy_current_state = yy_get_previous_state();
+
+		    /* okay, we're now positioned to make the
+		     * NUL transition.  We couldn't have
+		     * yy_get_previous_state() go ahead and do it
+		     * for us because it doesn't know how to deal
+		     * with the possibility of jamming (and we
+		     * don't want to build jamming into it because
+		     * then it will run more slowly)
+		     */
+
+		    yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+		    yy_bp = yytext + YY_MORE_ADJ;
+
+		    if ( yy_next_state )
+			{
+			/* consume the NUL */
+			yy_cp = ++yy_c_buf_p;
+			yy_current_state = yy_next_state;
+			goto yy_match;
+			}
+
+		    else
+			{
+			    yy_cp = yy_last_accepting_cpos;
+			    yy_current_state = yy_last_accepting_state;
+			goto yy_find_action;
+			}
+		    }
+
+		else switch ( yy_get_next_buffer() )
+		    {
+		    case EOB_ACT_END_OF_FILE:
+			{
+			yy_did_buffer_switch_on_eof = 0;
+
+			if ( yywrap() )
+			    {
+			    /* note: because we've taken care in
+			     * yy_get_next_buffer() to have set up yytext,
+			     * we can now set up yy_c_buf_p so that if some
+			     * total hoser (like flex itself) wants
+			     * to call the scanner after we return the
+			     * YY_NULL, it'll still work - another YY_NULL
+			     * will get returned.
+			     */
+			    yy_c_buf_p = yytext + YY_MORE_ADJ;
+
+			    yy_act = YY_STATE_EOF((yy_start - 1) / 2);
+			    goto do_action;
+			    }
+
+			else
+			    {
+			    if ( ! yy_did_buffer_switch_on_eof )
+				YY_NEW_FILE;
+			    }
+			}
+			break;
+
+		    case EOB_ACT_CONTINUE_SCAN:
+			yy_c_buf_p = yytext + yy_amount_of_matched_text;
+
+			yy_current_state = yy_get_previous_state();
+
+			yy_cp = yy_c_buf_p;
+			yy_bp = yytext + YY_MORE_ADJ;
+			goto yy_match;
+
+		    case EOB_ACT_LAST_MATCH:
+			yy_c_buf_p =
+			    &yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+			yy_current_state = yy_get_previous_state();
+
+			yy_cp = yy_c_buf_p;
+			yy_bp = yytext + YY_MORE_ADJ;
+			goto yy_find_action;
+		    }
+		break;
+		}
+
+	    default:
+#ifdef FLEX_DEBUG
+		printf( "action # %d\n", yy_act );
+#endif
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	    }
+	}
+    }
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * synopsis
+ *     int yy_get_next_buffer();
+ *     
+ * returns a code representing an action
+ *     EOB_ACT_LAST_MATCH - 
+ *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *     EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+
+    {
+    register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
+    register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
+    register int number_to_move, i;
+    int ret_val;
+
+    if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+	YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+    /* try to read more data */
+
+    /* first move last chars to start of buffer */
+    number_to_move = yy_c_buf_p - yytext;
+
+    for ( i = 0; i < number_to_move; ++i )
+	*(dest++) = *(source++);
+
+    if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
+	/* don't do the read, it's not guaranteed to return an EOF,
+	 * just force an EOF
+	 */
+	yy_n_chars = 0;
+
+    else
+	{
+	int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+	if ( num_to_read > YY_READ_BUF_SIZE )
+	    num_to_read = YY_READ_BUF_SIZE;
+
+	else if ( num_to_read <= 0 )
+	    YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
+
+	/* read in more data */
+	YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+		  yy_n_chars, num_to_read );
+	}
+
+    if ( yy_n_chars == 0 )
+	{
+	if ( number_to_move == 1 )
+	    {
+	    ret_val = EOB_ACT_END_OF_FILE;
+	    yy_current_buffer->yy_eof_status = EOF_DONE;
+	    }
+
+	else
+	    {
+	    ret_val = EOB_ACT_LAST_MATCH;
+	    yy_current_buffer->yy_eof_status = EOF_PENDING;
+	    }
+	}
+
+    else
+	ret_val = EOB_ACT_CONTINUE_SCAN;
+
+    yy_n_chars += number_to_move;
+    yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+    yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+    /* yytext begins at the second character in yy_ch_buf; the first
+     * character is the one which preceded it before reading in the latest
+     * buffer; it needs to be kept around in case it's a newline, so
+     * yy_get_previous_state() will have with '^' rules active
+     */
+
+    yytext = &yy_current_buffer->yy_ch_buf[1];
+
+    return ( ret_val );
+    }
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached
+ *
+ * synopsis
+ *     yy_state_type yy_get_previous_state();
+ */
+
+static yy_state_type yy_get_previous_state()
+
+    {
+    register yy_state_type yy_current_state;
+    register YY_CHAR *yy_cp;
+
+    yy_current_state = yy_start;
+
+    for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+	{
+	register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
+	if ( yy_accept[yy_current_state] )
+	    {
+	    yy_last_accepting_state = yy_current_state;
+	    yy_last_accepting_cpos = yy_cp;
+	    }
+	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+	    {
+	    yy_current_state = yy_def[yy_current_state];
+	    if ( yy_current_state >= 34 )
+		yy_c = yy_meta[yy_c];
+	    }
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+	}
+
+    return ( yy_current_state );
+    }
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *     next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+register yy_state_type yy_current_state;
+#endif
+
+    {
+    register int yy_is_jam;
+    register YY_CHAR *yy_cp = yy_c_buf_p;
+
+    register YY_CHAR yy_c = 1;
+    if ( yy_accept[yy_current_state] )
+	{
+	yy_last_accepting_state = yy_current_state;
+	yy_last_accepting_cpos = yy_cp;
+	}
+    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+	{
+	yy_current_state = yy_def[yy_current_state];
+	if ( yy_current_state >= 34 )
+	    yy_c = yy_meta[yy_c];
+	}
+    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+    yy_is_jam = (yy_current_state == 33);
+
+    return ( yy_is_jam ? 0 : yy_current_state );
+    }
+
+
+#ifdef YY_USE_PROTOS
+static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+YY_CHAR c;
+register YY_CHAR *yy_bp;
+#endif
+
+    {
+    register YY_CHAR *yy_cp = yy_c_buf_p;
+
+    /* undo effects of setting up yytext */
+    *yy_cp = yy_hold_char;
+
+    if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+	{ /* need to shift things up to make room */
+	register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
+	register YY_CHAR *dest =
+	    &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
+	register YY_CHAR *source =
+	    &yy_current_buffer->yy_ch_buf[number_to_move];
+
+	while ( source > yy_current_buffer->yy_ch_buf )
+	    *--dest = *--source;
+
+	yy_cp += dest - source;
+	yy_bp += dest - source;
+	yy_n_chars = yy_current_buffer->yy_buf_size;
+
+	if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+	    YY_FATAL_ERROR( "flex scanner push-back overflow" );
+	}
+
+    if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
+	yy_cp[-2] = '\n';
+
+    *--yy_cp = c;
+
+    /* note: the formal parameter *must* be called "yy_bp" for this
+     *       macro to now work correctly
+     */
+    YY_DO_BEFORE_ACTION; /* set up yytext again */
+    }
+
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+
+    {
+    int c;
+    YY_CHAR *yy_cp = yy_c_buf_p;
+
+    *yy_cp = yy_hold_char;
+
+    if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+	{
+	/* yy_c_buf_p now points to the character we want to return.
+	 * If this occurs *before* the EOB characters, then it's a
+	 * valid NUL; if not, then we've hit the end of the buffer.
+	 */
+	if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+	    /* this was really a NUL */
+	    *yy_c_buf_p = '\0';
+
+	else
+	    { /* need more input */
+	    yytext = yy_c_buf_p;
+	    ++yy_c_buf_p;
+
+	    switch ( yy_get_next_buffer() )
+		{
+		case EOB_ACT_END_OF_FILE:
+		    {
+		    if ( yywrap() )
+			{
+			yy_c_buf_p = yytext + YY_MORE_ADJ;
+			return ( EOF );
+			}
+
+		    YY_NEW_FILE;
+
+#ifdef __cplusplus
+		    return ( yyinput() );
+#else
+		    return ( input() );
+#endif
+		    }
+		    break;
+
+		case EOB_ACT_CONTINUE_SCAN:
+		    yy_c_buf_p = yytext + YY_MORE_ADJ;
+		    break;
+
+		case EOB_ACT_LAST_MATCH:
+#ifdef __cplusplus
+		    YY_FATAL_ERROR( "unexpected last match in yyinput()" );
+#else
+		    YY_FATAL_ERROR( "unexpected last match in input()" );
+#endif
+		}
+	    }
+	}
+
+    c = *yy_c_buf_p;
+    yy_hold_char = *++yy_c_buf_p;
+
+    return ( c );
+    }
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+
+    {
+    yy_init_buffer( yy_current_buffer, input_file );
+    yy_load_buffer_state();
+    }
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+
+    {
+    if ( yy_current_buffer == new_buffer )
+	return;
+
+    if ( yy_current_buffer )
+	{
+	/* flush out information for old buffer */
+	*yy_c_buf_p = yy_hold_char;
+	yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+	yy_current_buffer->yy_n_chars = yy_n_chars;
+	}
+
+    yy_current_buffer = new_buffer;
+    yy_load_buffer_state();
+
+    /* we don't actually know whether we did this switch during
+     * EOF (yywrap()) processing, but the only time this flag
+     * is looked at is after yywrap() is called, so it's safe
+     * to go ahead and always set it.
+     */
+    yy_did_buffer_switch_on_eof = 1;
+    }
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+
+    {
+    yy_n_chars = yy_current_buffer->yy_n_chars;
+    yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+    yyin = yy_current_buffer->yy_input_file;
+    yy_hold_char = *yy_c_buf_p;
+    }
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+
+    {
+    YY_BUFFER_STATE b;
+
+    b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
+
+    if ( ! b )
+	YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+    b->yy_buf_size = size;
+
+    /* yy_ch_buf has to be 2 characters longer than the size given because
+     * we need to put in 2 end-of-buffer characters.
+     */
+    b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
+
+    if ( ! b->yy_ch_buf )
+	YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+    yy_init_buffer( b, file );
+
+    return ( b );
+    }
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+    {
+    if ( b == yy_current_buffer )
+	yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+    free( (char *) b->yy_ch_buf );
+    free( (char *) b );
+    }
+
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+    {
+    b->yy_input_file = file;
+
+    /* we put in the '\n' and start reading from [1] so that an
+     * initial match-at-newline will be true.
+     */
+
+    b->yy_ch_buf[0] = '\n';
+    b->yy_n_chars = 1;
+
+    /* we always need two end-of-buffer characters.  The first causes
+     * a transition to the end-of-buffer state.  The second causes
+     * a jam in that state.
+     */
+    b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+    b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
+
+    b->yy_buf_pos = &b->yy_ch_buf[1];
+
+    b->yy_eof_status = EOF_NOT_SEEN;
+    }
+# line 108 "lexer.l"
+
+
+
+#ifdef FLEX_SCANNER
+static int lex_input() {
+  return input();
+}
+#else	/* BSD/AT&T lex */
+#ifndef input
+# error "Sorry, but need either flex or AT&T lex"
+#endif
+static int lex_input() {
+  return input();
+}
+/* # undef unput
+# define unput(_c) my_unput(_c)
+*/
+
+# undef input
+# define input() my_input()
+static int my_unput(char c)
+{
+  if (lex_read_from_string) {
+    /* Make sure we have something */
+    if (lex_string_ptr) {
+      if (c == '\n') yylineno--;
+      lex_string_ptr--;
+    }
+  } else {
+    yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;
+/*    unput(c); Causes infinite recursion! */
+  }
+  return c;
+}
+
+#endif
+
+/* Public */ 
+void LexFromFile(FILE *fd)
+{
+  lex_read_from_string = 0;
+  yyin = fd;
+  /* Don't know why this is necessary, but otherwise
+   * lex only works _once_!
+   */
+#ifdef FLEX_SCANNER
+  yy_init = 1;
+#endif
+}
+
+void LexFromString(char *buffer)
+{
+  lex_read_from_string = 1;
+  lex_buffer = buffer;
+  lex_buffer_length = strlen(buffer);
+  lex_string_ptr = 0;
+  /* Don't know why this is necessary, but otherwise
+   * lex only works _once_!
+   */
+#ifdef FLEX_SCANNER
+  yy_init = 1;
+#endif
+}
+
+static int my_input( void )
+{
+  if (lex_read_from_string) {
+    if (lex_string_ptr == lex_buffer_length)
+      return 0;
+    else {
+      char c = lex_buffer[lex_string_ptr++];
+#ifndef FLEX_SCANNER
+      if (c == '\n') yylineno++;
+#endif
+      return c;
+    }
+  } else {
+    return lex_input();
+  }
+}
+
+void wxExprCleanUp()
+{
+	if (yy_current_buffer)
+		yy_delete_buffer(yy_current_buffer);
+}
diff --git a/src/common/dosyacc.c b/src/common/dosyacc.c
new file mode 100644
index 0000000000..e2bdecb862
--- /dev/null
+++ b/src/common/dosyacc.c
@@ -0,0 +1,517 @@
+#ifndef lint
+static char yysccsid[] = "@(#)yaccpar     1.7 (Berkeley) 09/09/90";
+#endif
+#define YYBYACC 1
+#line 2 "parser.y"
+#include "string.h"
+#include "wx/expr.h"
+
+#ifndef __EXTERN_C__
+#define __EXTERN_C__ 1
+#endif
+
+#if defined(__cplusplus) || defined(__STDC__)
+#if defined(__cplusplus) && defined(__EXTERN_C__)
+extern "C" {
+#endif
+#endif
+int yylex(void);
+int yylook(void);
+int yywrap(void);
+int yyback(int *, int);
+
+/* You may need to put /DLEX_SCANNER in your makefile
+ * if you're using LEX!
+	Last change:  JS   13 Jul 97    6:12 pm
+ */
+#ifdef LEX_SCANNER
+/* int yyoutput(int); */
+void yyoutput(int);
+#else
+void yyoutput(int);
+#endif
+
+#if defined(__cplusplus) || defined(__STDC__)
+#if defined(__cplusplus) && defined(__EXTERN_C__)
+}
+#endif
+#endif
+#line 36 "parser.y"
+typedef union {
+    char *s;
+/*    struct pexpr *expr; */
+} YYSTYPE;
+#line 44 "y_tab.c"
+#define INTEGER 1
+#define WORD 2
+#define STRING 3
+#define PERIOD 13
+#define OPEN 4
+#define CLOSE 5
+#define COMMA 6
+#define NEWLINE 7
+#define ERROR 8
+#define OPEN_SQUARE 9
+#define CLOSE_SQUARE 10
+#define EQUALS 11
+#define EXP 14
+#define YYERRCODE 256
+short yylhs[] = {                                        -1,
+    0,    0,    1,    1,    1,    2,    2,    2,    3,    3,
+    3,    4,    4,    5,    5,    5,    5,    5,    5,    5,
+};
+short yylen[] = {                                         2,
+    0,    2,    2,    2,    2,    4,    2,    3,    0,    1,
+    3,    3,    1,    1,    1,    1,    3,    3,    5,    1,
+};
+short yydefred[] = {                                      1,
+    0,    0,    0,    0,    2,    0,    5,    3,    0,    0,
+    0,   15,    7,   20,    0,    0,   13,    4,    0,    0,
+    0,    0,    8,    0,    6,    0,   18,    0,   12,   11,
+    0,   19,
+};
+short yydgoto[] = {                                       1,
+    5,   14,   15,   16,   17,
+};
+short yysindex[] = {                                      0,
+   -2,    9,    2,    1,    0,   10,    0,    0,   11,   -5,
+   17,    0,    0,    0,   14,   -1,    0,    0,   33,   38,
+   41,   16,    0,   11,    0,   29,    0,   40,    0,    0,
+   44,    0,
+};
+short yyrindex[] = {                                      0,
+    0,    0,    0,    0,    0,    0,    0,    0,   42,   21,
+   24,    0,    0,    0,    0,   30,    0,    0,    0,    0,
+    0,    0,    0,   31,    0,   27,    0,   24,    0,    0,
+    0,    0,
+};
+short yygindex[] = {                                      0,
+    0,   45,   -8,    0,   26,
+};
+#define YYTABLESIZE 254
+short yytable[] = {                                       3,
+   19,   10,   11,   12,   24,    9,    4,   20,   21,    4,
+   13,   10,   11,   12,    8,   30,   10,   28,   12,    4,
+    9,    7,   18,   23,    4,   16,   16,   22,   14,   14,
+   16,   17,   17,   14,   10,    9,   17,   25,   26,   10,
+    9,   27,   31,    9,   32,    6,    9,   29,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    2,
+};
+short yycheck[] = {                                       2,
+    9,    1,    2,    3,    6,    4,    9,   13,   14,    9,
+   10,    1,    2,    3,   13,   24,    1,    2,    3,    9,
+    4,   13,   13,   10,    9,    5,    6,   11,    5,    6,
+   10,    5,    6,   10,    5,    5,   10,    5,    1,   10,
+   10,    1,   14,    4,    1,    1,    5,   22,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  256,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 14
+#if YYDEBUG
+char *yyname[] = {
+"end-of-file","INTEGER","WORD","STRING","OPEN","CLOSE","COMMA","NEWLINE",
+"ERROR","OPEN_SQUARE","CLOSE_SQUARE","EQUALS",0,"PERIOD","EXP",
+};
+char *yyrule[] = {
+"$accept : commands",
+"commands :",
+"commands : commands command",
+"command : WORD PERIOD",
+"command : expr PERIOD",
+"command : error PERIOD",
+"expr : WORD OPEN arglist CLOSE",
+"expr : OPEN_SQUARE CLOSE_SQUARE",
+"expr : OPEN_SQUARE arglist CLOSE_SQUARE",
+"arglist :",
+"arglist : arg",
+"arglist : arg COMMA arglist",
+"arg : WORD EQUALS arg1",
+"arg : arg1",
+"arg1 : WORD",
+"arg1 : STRING",
+"arg1 : INTEGER",
+"arg1 : INTEGER PERIOD INTEGER",
+"arg1 : INTEGER EXP INTEGER",
+"arg1 : INTEGER PERIOD INTEGER EXP INTEGER",
+"arg1 : expr",
+};
+#endif
+#define yyclearin (yychar=(-1))
+#define yyerrok (yyerrflag=0)
+#ifdef YYSTACKSIZE
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#endif
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 600
+#define YYMAXDEPTH 600
+#endif
+#endif
+int yydebug;
+int yynerrs;
+int yyerrflag;
+int yychar;
+short *yyssp;
+YYSTYPE *yyvsp;
+YYSTYPE yyval;
+YYSTYPE yylval;
+short yyss[YYSTACKSIZE];
+YYSTYPE yyvs[YYSTACKSIZE];
+#define yystacksize YYSTACKSIZE
+#line 118 "parser.y"
+
+#include "../common/lex_yy.c"
+
+/*
+void yyerror(s)
+char *s;
+{
+  syntax_error(s);
+}
+*/
+
+/* Ansi prototype. If this doesn't work for you... uncomment
+   the above instead.
+ */
+
+void yyerror(char *s)
+{
+  syntax_error(s);
+}
+
+/*
+ * Unfortunately, my DOS version of FLEX
+ * requires yywrap to be #def'ed, whereas
+ * the UNIX flex expects a proper function.
+ */
+
+/* Not sure if __SC__ is the appropriate thing
+ * to test
+ */
+
+#ifndef __SC__
+#ifdef USE_DEFINE
+#ifndef yywrap
+#define yywrap() 1
+#endif
+#else
+int yywrap() { return 1; }
+#endif
+#endif
+#line 247 "y_tab.c"
+#define YYABORT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+int
+yyparse()
+{
+    register int yym, yyn, yystate;
+#if YYDEBUG
+    register char *yys;
+    extern char *getenv();
+
+    if (yys = getenv("YYDEBUG"))
+    {
+        yyn = *yys;
+        if (yyn >= '0' && yyn <= '9')
+            yydebug = yyn - '0';
+    }
+#endif
+
+    yynerrs = 0;
+    yyerrflag = 0;
+    yychar = (-1);
+
+    yyssp = yyss;
+    yyvsp = yyvs;
+    *yyssp = yystate = 0;
+
+yyloop:
+    if (yyn = yydefred[yystate]) goto yyreduce;
+    if (yychar < 0)
+    {
+        if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("yydebug: state %d, reading %d (%s)\n", yystate,
+                    yychar, yys);
+        }
+#endif
+    }
+    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("yydebug: state %d, shifting to state %d\n",
+                    yystate, yytable[yyn]);
+#endif
+        if (yyssp >= yyss + yystacksize - 1)
+        {
+            goto yyoverflow;
+        }
+        *++yyssp = yystate = yytable[yyn];
+        *++yyvsp = yylval;
+        yychar = (-1);
+        if (yyerrflag > 0)  --yyerrflag;
+        goto yyloop;
+    }
+    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+        yyn = yytable[yyn];
+        goto yyreduce;
+    }
+    if (yyerrflag) goto yyinrecovery;
+#ifdef lint
+    goto yynewerror;
+#endif
+yynewerror:
+    yyerror("syntax error");
+#ifdef lint
+    goto yyerrlab;
+#endif
+yyerrlab:
+    ++yynerrs;
+yyinrecovery:
+    if (yyerrflag < 3)
+    {
+        yyerrflag = 3;
+        for (;;)
+        {
+            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
+                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("yydebug: state %d, error recovery shifting\
+ to state %d\n", *yyssp, yytable[yyn]);
+#endif
+                if (yyssp >= yyss + yystacksize - 1)
+                {
+                    goto yyoverflow;
+                }
+                *++yyssp = yystate = yytable[yyn];
+                *++yyvsp = yylval;
+                goto yyloop;
+            }
+            else
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("yydebug: error recovery discarding state %d\n",
+                            *yyssp);
+#endif
+                if (yyssp <= yyss) goto yyabort;
+                --yyssp;
+                --yyvsp;
+            }
+        }
+    }
+    else
+    {
+        if (yychar == 0) goto yyabort;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("yydebug: state %d, error recovery discards token %d (%s)\n",
+                    yystate, yychar, yys);
+        }
+#endif
+        yychar = (-1);
+        goto yyloop;
+    }
+yyreduce:
+#if YYDEBUG
+    if (yydebug)
+        printf("yydebug: state %d, reducing by rule %d (%s)\n",
+                yystate, yyn, yyrule[yyn]);
+#endif
+    yym = yylen[yyn];
+    yyval = yyvsp[1-yym];
+    switch (yyn)
+    {
+case 3:
+#line 68 "parser.y"
+{process_command(proio_cons(make_word(yyvsp[-1].s), NULL)); free(yyvsp[-1].s);}
+break;
+case 4:
+#line 70 "parser.y"
+{process_command(yyvsp[-1].s);}
+break;
+case 5:
+#line 72 "parser.y"
+{syntax_error("Unrecognized command.");}
+break;
+case 6:
+#line 76 "parser.y"
+{yyval.s = proio_cons(make_word(yyvsp[-3].s), yyvsp[-1].s); free(yyvsp[-3].s);}
+break;
+case 7:
+#line 78 "parser.y"
+{yyval.s = proio_cons(NULL, NULL);}
+break;
+case 8:
+#line 80 "parser.y"
+{yyval.s = yyvsp[-1].s; }
+break;
+case 9:
+#line 84 "parser.y"
+{yyval.s = NULL;}
+break;
+case 10:
+#line 86 "parser.y"
+{yyval.s = proio_cons(yyvsp[0].s, NULL);}
+break;
+case 11:
+#line 89 "parser.y"
+{yyval.s = proio_cons(yyvsp[-2].s, yyvsp[0].s);}
+break;
+case 12:
+#line 93 "parser.y"
+{yyval.s = proio_cons(make_word("="), proio_cons(make_word(yyvsp[-2].s), proio_cons(yyvsp[0].s, NULL)));
+                         free(yyvsp[-2].s); }
+break;
+case 13:
+#line 96 "parser.y"
+{yyval.s = yyvsp[0].s; }
+break;
+case 14:
+#line 99 "parser.y"
+{yyval.s = make_word(yyvsp[0].s); free(yyvsp[0].s);}
+break;
+case 15:
+#line 101 "parser.y"
+{yyval.s = make_string(yyvsp[0].s); free(yyvsp[0].s);}
+break;
+case 16:
+#line 103 "parser.y"
+{yyval.s = make_integer(yyvsp[0].s); free(yyvsp[0].s);}
+break;
+case 17:
+#line 105 "parser.y"
+{yyval.s = make_real(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); }
+break;
+case 18:
+#line 107 "parser.y"
+{yyval.s = make_exp(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); }
+break;
+case 19:
+#line 110 "parser.y"
+{yyval.s = make_exp2(yyvsp[-4].s, yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-4].s); free(yyvsp[-2].s);
+                                                                  free(yyvsp[0].s); }
+break;
+case 20:
+#line 114 "parser.y"
+{yyval.s = yyvsp[0].s;}
+break;
+#line 461 "y_tab.c"
+    }
+    yyssp -= yym;
+    yystate = *yyssp;
+    yyvsp -= yym;
+    yym = yylhs[yyn];
+    if (yystate == 0 && yym == 0)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("yydebug: after reduction, shifting from state 0 to\
+ state %d\n", YYFINAL);
+#endif
+        yystate = YYFINAL;
+        *++yyssp = YYFINAL;
+        *++yyvsp = yyval;
+        if (yychar < 0)
+        {
+            if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+            if (yydebug)
+            {
+                yys = 0;
+                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+                if (!yys) yys = "illegal-symbol";
+                printf("yydebug: state %d, reading %d (%s)\n",
+                        YYFINAL, yychar, yys);
+            }
+#endif
+        }
+        if (yychar == 0) goto yyaccept;
+        goto yyloop;
+    }
+    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+        yystate = yytable[yyn];
+    else
+        yystate = yydgoto[yym];
+#if YYDEBUG
+    if (yydebug)
+        printf("yydebug: after reduction, shifting from state %d \
+to state %d\n", *yyssp, yystate);
+#endif
+    if (yyssp >= yyss + yystacksize - 1)
+    {
+        goto yyoverflow;
+    }
+    *++yyssp = yystate;
+    *++yyvsp = yyval;
+    goto yyloop;
+yyoverflow:
+    yyerror("yacc stack overflow");
+yyabort:
+    return (1);
+yyaccept:
+    return (0);
+}
diff --git a/src/cygnus.bat b/src/cygnus.bat
new file mode 100644
index 0000000000..4cf2cf09cf
--- /dev/null
+++ b/src/cygnus.bat
@@ -0,0 +1,15 @@
+rem Cygnus Gnu-Win32 environment variables
+rem Assumes that compiler and wxWindows are installed on the g: drive.
+rem
+set WXWIN=d:\wx2
+path C:\WINDOWS;C:\WINDOWS\COMMAND;g:\gnuwin32\b19\H-i386-cygwin32\bin;g:\gnuwin32\b19\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2-970404;c:\bin;g:\gnuwin32\b19\tcl\bin
+set GCC_EXEC_PREFIX=G:\gnuwin32\b19\H-i386-cygwin32\lib\gcc-lib\
+set RCINCLUDE=%WXWIN\include
+set CPLUS_INCLUDE_PATH=/g/gnuwin32/b19/h-i386-cygwin32/i386-cygwin32/include:/g/gnuwin32/b19/include/g++:/g/gnuwin32/b19/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2-970404/include:/d/wx2/include:/g/gnuwin32/b19/include/g++
+set MAKE_MODE=unix
+mount G: /g
+mount D: /d
+
+rem 4DOS users only...
+unalias make
+alias makegnu make -f makefile.g95
diff --git a/src/makeb32.env b/src/makeb32.env
new file mode 100644
index 0000000000..d99981bfac
--- /dev/null
+++ b/src/makeb32.env
@@ -0,0 +1,36 @@
+# Common settings for Borland 32-bit compilation (makefile.b32 files)
+
+WXDIR = $(WXWIN)
+CFG = $(WXDIR)\src\msw\wxwin32.cfg
+WXLIBDIR = $(WXDIR)\lib
+WXINC = $(WXDIR)\include
+WIN95FLAG = -D__WIN95__
+
+!ifndef FINAL
+FINAL=0
+!endif
+
+!ifndef DEBUG
+DEBUG=1
+!endif
+
+!if "$(FINAL)" == "0"
+OPT = -Od
+DEBUG_FLAGS= -v -DDEBUG=$(DEBUG) -DUSE_DEFINE
+!else
+OPT = -O2
+DEBUG_FLAGS = -DDEBUG=$(DEBUG) -DUSE_DEFINE
+!endif
+CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
+
+LIBTARGET= $(WXLIBDIR)\wx32.lib
+DUMMY=dummy
+
+SRCSUFF = cpp
+OBJSUFF = obj
+
+.$(SRCSUFF).obj:
+	bcc32 $(CPPFLAGS) -c {$< }
+
+.c.obj:
+	bcc32 $(CPPFLAGS) -P- -c {$< }
diff --git a/src/makebcc.env b/src/makebcc.env
new file mode 100644
index 0000000000..1c4aa33f12
--- /dev/null
+++ b/src/makebcc.env
@@ -0,0 +1,37 @@
+# Common settings for Borland 16-bit compilation (makefile.bcc files)
+
+WXDIR = $(WXWIN)
+
+CFG = $(WXDIR)\src\wxwin.cfg
+WXLIB = $(WXDIR)\lib
+WXINC = $(WXDIR)\include\msw
+WXBASEINC = $(WXDIR)\include\base
+
+!ifndef FINAL
+FINAL=0
+!endif
+
+!ifndef DEBUG
+DEBUG=0
+!endif
+
+!if "$(FINAL)" == "0"
+LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib
+OPT = -Od
+DEBUG_FLAGS= -v
+!else
+LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib
+OPT = -O2
+DEBUG_FLAGS =
+!endif
+CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
+
+CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
+
+LIBTARGET= $(WXLIB)\wx.lib
+
+SRCSUFF = cpp
+OBJSUFF = obj
+
+.$(SRCSUFF).obj:
+        bcc $(CPPFLAGS) -c {$< }
diff --git a/src/makefile.bcc b/src/makefile.bcc
new file mode 100644
index 0000000000..eec6ab1157
--- /dev/null
+++ b/src/makefile.bcc
@@ -0,0 +1,97 @@
+#
+# File:		makefile.bcc
+# Author:	Julian Smart
+# Created:	1993
+# Updated:	
+# Copyright:	(c) 1993, AIAI, University of Edinburgh
+#
+# "%W% %G%"
+#
+# Makefile : Builds wxWindows library wx.lib for Windows 3.1
+# and Borland C++ 3.1. This makefile calls makefile.bcc in msw and
+# base subdirectories.
+
+!if "$(BCCDIR)" == ""
+!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4
+!endif
+
+!if "$(WXWIN)" == ""
+!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
+!endif
+
+!ifndef DEBUG
+DEBUG=0
+!endif
+
+!ifndef FINAL
+FINAL=0
+!endif
+
+# Change these if needed.
+WXDIR = $(WXWIN)
+
+!include $(WXDIR)\src\makebcc.env
+
+!if "$(FINAL)" == "0"
+OPT = -Od
+DEBUG_FLAGS= -v /DDEBUG=$(DEBUG) # -v # -v for debugging info
+!else
+OPT = -O2
+DEBUG_FLAGS = /DDEBUG=$(DEBUG)
+!endif
+
+BOR_VER = 4
+
+#!if "$(BOR_VER)" == "3.1"
+#BCCDIR = d:\bc3
+#!elif "$(BOR_VER)" == "4"
+#BCCDIR = d:\bc4
+#!endif
+
+WXBASEINC = $(WXDIR)\include\base
+WXINC = $(WXDIR)\include\msw
+PROLOGIOINC = $(WXDIR)\utils\prologio\src
+XPMINC=$(WXDIR)\contrib\wxxpm\libxpm.34b\lib
+
+all:    wxwin.cfg
+	cd $(WXDIR)\src\msw
+	make -f makefile.bcc -DCFG=$(CFG) -DWXDIR=$(WXDIR) DEBUG=$(DEBUG) -DDEBUG_FLAGS=$(DEBUG_FLAGS) -DOPT=$(OPT) -DFINAL=$(FINAL)
+	cd $(WXDIR)\src
+
+clean:
+        erase wxwin.cfg
+	cd $(WXDIR)\src\msw
+	make -f makefile.bcc clean
+	cd $(WXDIR)\src
+
+wxwin.cfg: makefile.bcc
+	copy &&!
+-H=$(WXDIR)\src\borland.pch
+-2
+-P
+-d
+-w-hid
+-w-par
+-w-pia
+-w-aus
+-w-rch
+-ml
+-Od
+-WE
+-Fs-
+-Vf
+-I$(WXBASEINC);$(WXINC);$(PROLOGIOINC);$(XPMINC);$(BCCDIR)\include;$(WXDIR)\contrib\fafa;$(WXDIR)\contrib\itsybits;$(WXDIR)\utils\rcparser\src
+
+-L$(BCCDIR)\lib
+-Dwx_msw
+! wxwin.cfg
+!if "$(BOR_VER)" == "3.1"
+	echo -Ff=4 >>wxwin.cfg
+!elif "$(BOR_VER)" == "4"
+	echo -Ff=512 >>wxwin.cfg
+	echo -dc >>wxwin.cfg
+!endif
+
+
+# -O was: -Oxt
+
diff --git a/src/makefile.dos b/src/makefile.dos
new file mode 100644
index 0000000000..d734f4a817
--- /dev/null
+++ b/src/makefile.dos
@@ -0,0 +1,51 @@
+#
+# File:		makefile.dos
+# Author:	Julian Smart
+# Created:	1993
+# Updated:	
+# Copyright:	(c) 1993, AIAI, University of Edinburgh
+#
+# "%W% %G%"
+#
+# Makefile : Builds wxWindows library wx.lib for Windows 3.1
+# You can invoke the makefile in this directory, wx/src, or
+# equally from wx/src/msw. This makefile was created to be
+# consistent with other makefiles which were appearing this
+# directory.
+
+# Arguments:
+#
+# FINAL=1 argument to nmake to build version with no debugging info.
+# DEBUG=1 argument to nmake to build DEBUG version (memory checking, tracing)
+#
+# Set WXDIR to the wxWindows directory if env. variable WXWIN not set.
+#
+WXDIR = $(WXWIN)
+THISDIR = $(WXDIR)\src\msw
+WXLIB = $(WXDIR)\lib
+WXINC = $(WXDIR)\include\msw
+WXBASESRC = $(WXDIR)\src\base
+WXBASEINC = $(WXDIR)\include\base
+
+!ifndef FINAL
+FINAL=0
+!endif
+
+!ifndef DEBUG
+DEBUG=0
+!endif
+
+all:
+  cd $(WXDIR)\src\msw
+  nmake -f makefile.dos FINAL=$(FINAL) DEBUG=$(DEBUG)
+  cd $(THISDIR)
+
+clean:
+  cd $(WXDIR)\src\msw
+  nmake -f makefile.dos clean
+  cd $(THISDIR)
+
+cleanall:
+  cd $(WXDIR)\src\msw
+  nmake -f makefile.dos cleanall
+  cd $(THISDIR)
diff --git a/src/makefile.nt b/src/makefile.nt
new file mode 100644
index 0000000000..a6681a2230
--- /dev/null
+++ b/src/makefile.nt
@@ -0,0 +1,35 @@
+#
+# File:		makefile.nt
+# Author:	Julian Smart
+# Created:	1997
+# Updated:	
+# Copyright:	(c) 1997, Julian Smart
+#
+# "%W% %G%"
+#
+# Makefile : Builds wxWindows library wx.lib for VC++ (32-bit)
+# Arguments:
+#
+# FINAL=1 argument to nmake to build version with no debugging info.
+# dll builds a library (wxdll.lib) suitable for creating DLLs
+#    * Note that the dll target is experimental - see docs/dll.txt.
+#
+!include <ntwxwin.mak>
+
+THISDIR=$(WXWIN)\src
+
+all:
+    cd msw
+    nmake -f makefile.nt
+    cd $(THISDIR)
+
+clean:
+    cd msw
+    nmake -f makefile.nt clean
+    cd $(THISDIR)
+
+cleanall:
+    cd msw
+    nmake -f makefile.nt cleanall
+    cd $(THISDIR)
+
diff --git a/src/makeg95.env b/src/makeg95.env
new file mode 100644
index 0000000000..3882775246
--- /dev/null
+++ b/src/makeg95.env
@@ -0,0 +1,232 @@
+# makeg95.env
+# Common makefile settings for wxWindows programs
+# This file is included by all the other makefiles, thus changes 
+# made here take effect everywhere (except where overriden).
+#
+# An alternative to editing this file is to create a shell script
+# to export specific variables, and call make with the -e switch
+# to override makefile variables. See wx/install/install.txt.
+# And you can override specific variables on the make command line, e.g.
+#
+# make -f makefile.unix DEBUG=''
+#
+# You may prefer to use the GNU configure script than raw makefiles -
+# see contrib/wxshlib.
+#
+
+########################## Compiler ##################################
+
+# C++ compiler
+# For AIX/CSet++: use CC = xlC
+# For IRIX: use CC = CC
+# CC = gcc-2.6.2
+CC = gcc
+
+# C compiler for pure C programs
+# Typical: CC=g++ , CCC=gcc
+#          CC=cl386 /Tp, CCC=cl386
+#
+# (Used only for XView, file sb_scrol.c)
+#
+CCC = $(CC)
+
+# Compiler used for LEX generated C
+# AIX: use $(CCC)
+CCLEX=$(CC)
+
+MAKE=make
+
+# LEX
+LEX=flex.exe -t -L
+
+# YACC. byacc or bison
+# YACC=byacc.exe
+YACC=bison.exe
+
+# Resource compiler
+RESCOMP=windres.exe
+
+RESFLAGS=--include-dir $(WXDIR)/include --define __WIN32__ --define __WIN95__ --define __GNUWIN32__
+
+########################## Compiler flags #############################
+
+# Miscellaneous compiler options
+# Solaris/GCC: -DSVR4
+# Solaris/GCC, dynamic library: -DSVR4 -fPIC
+# FreeBDS 2.0: does not need -D_BSD - always defined
+# AIX/CSet++: -+ -qsrcmsg -DSYSV
+# AIX/GCC: -DSYSV -DAIX
+# Data General: -DDG
+# HP: -D_HPUX_SOURCE +a1 -Aa +d -z
+# IRIX: -mips2
+OPTIONS= -D__MINGW32__ # -D__EGCS__
+
+# Debugging information
+# AIX: comment out.
+# IRIX: -g3
+DEBUGFLAGS = -ggdb
+
+# Debug/trace mode. 1 or more for debugging.
+DEBUG=0
+
+WIN95=1
+
+ifeq ($(WIN95),0)
+# With 3.50, Win95 will use your existing icons to show smaller ones.
+# With 4.0, you'll have to follow Win95 procedures for icons or you'll get the
+# default Windows icon.
+APPVER=3.50
+WINVERSION=-DWINVER=0x0350 -D__GNUWIN32__ -D__WIN32__ # Generic WIN32
+else
+APPVER=3.50 # 4.0
+# This means 'enable Windows 95 features' (in wxWindows and in VC++ 4.0).
+WINVERSION=-DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -D__WIN32__
+endif
+
+CPU=i386
+
+# Suffixes
+OBJSUFF=o
+SRCSUFF=cpp
+LIBPREFIX=lib
+LIBSUFF=a
+EXESUFF=.exe
+RESSUFF=res
+RSCSUFF=rsc
+
+# Warnings
+# AIX: comment out
+# IRIX: -w -wlint,-fpiv
+# These are for the GNU compiler. We now get the compiler to check for as
+# many things as we can, to catch portability problems sooner.
+WARN = -Wall
+
+# -pedantic -Wpointer-arith -Wtraditional -Wcast-align \
+# -Wenum-clash -Wnested-externs -Woverloaded-virtual \
+# -Winline -Wconversion
+
+# not good with too few 'const' decls in wxWindows
+# -Wcast-qual -Wwrite-strings
+
+# too hard (problems with system header files)
+# -Wstrict-prototypes -Wmissing-prototypes
+# -Wredudant-decs
+
+# Which GUI, -Dwx_xview or -Dwx_motif (don't change this)
+GUI = -D__WINDOWS__
+
+# Optimization
+# OPT = -O
+# FreeBSD 2.0 with i486: OPT = -O2 -m486
+# IRIX: -O2 #-O0 : no, -O1: quick, -O2: global -O3: full(register)
+# Linux: -m486 # -O2 for optimization
+OPT =
+
+# Options for ar archiver
+# AROPTIONS = crs # For IRIX and Solaris (both SYSVR4).
+AROPTIONS = ruv
+RANLIB = ranlib
+# RANLIB = echo # Uncomment this line for IRIX and Solaris
+
+# Compiler libraries: defaults to GCC libraries
+# Solaris: -lgen -ldl -lsocket -lnsl
+#   and/or possibly -lucb, whatever that is... (-lucb CAUSES MOTIF FILE SELECTION PROBLEMS)
+#   or possibly -lgen -lsocket -L/usr/ccs/lib linbnsl.a 
+# GCC > 2.7.1 on Solaris: -lstdc++ -lc -lgen -ldl -lsocket -lnsl -lucb 
+# SGI:     -lPW
+# FreeBSD 2.0: -lg++ -lcompat
+# FreeBSD 1.x: -lcompat doesn`t need, only -lg++ needed
+# AIX: -lCns -lbsd
+# G++ 2.7.0 requires -liostream too.
+# IRIX: -lPW
+#COMPLIBS=-lg++
+#for win95
+#COMPLIBS=-lgcc
+
+# Compiler or system-specific include paths
+# E.g. some SPARCStations need
+# -I/usr/ucbinclude/sys
+#added for win95
+COMPPATHS=
+
+# HP-specific compiler library: an AIAI convenience
+HPCOMPLIBS=
+
+# LDLIBS for specific GUIs
+
+# The following for LINUX and Motif 2.0:
+#MOTIFLDLIBS = -lwx_motif $(COMPLIBS) -lXm -lXmu -lXpm -lXt -lXext -lX11 -lm
+
+#BASICMOTIFLDLIBS = -lwx_motif /aiai/packages/motif1.2.1/motif/sun4/lib/libXm.a /aiai/packages/motif1.2.1/motif/sun4/lib/libXmu.a /aiai/packages/motif1.2.1/motif/sun4/lib/libXt.a /aiai/packages/motif1.2.1/motif/sun4/lib/libX11.a -lm
+# Apparently libg++ (in COMPLIBS) should go before libXm because of a clash of
+# function name: re_create.
+#BASICMOTIFLDLIBS = -lwx_motif $(COMPLIBS) -lXm -lXmu -lXt -lX11 -lm
+
+#MOTIFLDLIBS = $(BASICMOTIFLDLIBS) $(COMPLIBS)
+
+#XVIEWLDLIBS = -lwx_ol -lxview -lolgx -lX11 -lm $(COMPLIBS)
+#HPLDLIBS=-lwx_hp -lXm -lXmu -lXt -lX11 -lm
+#CYGNUSLDLIBS=
+# Default LDLIBS for XView (don't change this)
+#LDLIBS = $(CYGNUSLDLIBS)
+
+# _ol or _motif (don't need to change, the makefiles will take
+# care of it if you use motif/hp/xview targets)
+#GUISUFFIX=_ol
+
+########################## Directories ###############################
+
+
+WINLIBS=-lstdc++ -lgcc \
+	-lwinspool -lwinmm -lshell32 -loldnames \
+	-lcomctl32 -lctl3d32 -lodbc32
+
+# Shouldn't need to change these...
+WXSRC=$(WXDIR)/src/msw
+WXINC=$(WXDIR)/include
+WXBASESRC=$(WXDIR)/src/common
+WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx.$(LIBSUFF)
+INC = -I$(WXINC) $(COMPPATHS)
+RCLFLAGS=-cpp "cpp -lang-c++ -DWIN32 -D_WIN32 -DRCL_INVOKED -I$(WXWIN)\include"
+
+#LIBS = -lctl3d32 $(WXLIB) $(WINLIBS) $(COMPLIBS)
+LIBS = $(WXLIB) $(WINLIBS) $(COMPLIBS)
+
+WINFLAGS=-D_X86_=1 -DWIN32 -D_WIN32 $(WINVERSION)
+
+#for windows 95
+XINCLUDE=$(WINFLAGS)
+XLIB=$(LIBS)
+LDLIBS = $(LIBS)
+
+# Directory for object files (don't change)
+OBJDIR = objects$(GUISUFFIX)
+
+# You shouldn't need to change these...
+CPPFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) $(DEBUGFLAGS) -DDEBUG='$(DEBUG)' $(WARN) $(OPT)
+CFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) $(DEBUGFLAGS) -DDEBUG='$(DEBUG)' $(WARN) $(OPT)
+LDFLAGS =  -Wl,--subsystem,windows -mwindows -L$(WXDIR)/lib
+
+# Extra patch link for XView
+#XVIEW_LINK = $(WXDIR)/src/x/objects_ol/sb_scrol.o # $(WXDIR)/src/x/objects_ol/xvwinlp.o
+
+.SUFFIXES: .rc .$(RESSUFF) .$(RSCSUFF) .cpp .c
+
+# Set these in a batch file instead e.g. install/cygnus.bat
+#	RCINCLUDE="$(WXDIR)/include/msw;$(WXDIR)/contrib/fafa;$(WXDIR)/contrib/itsybits"; \
+#	CPLUS_INCLUDE_PATH=/usr/H-i386-cygwin32/i386-cygwin32/include:/usr/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2-961023/include:$(WXDIR)/include/common:$(WXDIR)/include/msw:$(WXDIR)/contrib/fafa:$(WXDIR)/contrib/itsybits; \
+#	export CPLUS_INCLUDE_PATH RCINCLUDE;  \
+
+.rc.$(RESSUFF):  $< $(WXDIR)/include/msw/wx.rc
+	$(RC) $(RESFLAGS1) $< $(RESFLAGS2) $*.$(RESSUFF) $(RCLFLAGS)
+
+.$(RESSUFF).$(RSCSUFF): $<
+	$(CVTRES) $< $*.$(RSCSUFF)
+
+.$(SRCSUFF).$(OBJSUFF):
+	$(CC) -c $(CPPFLAGS) -o $@ $*.$(SRCSUFF)
+
+.c.o:
+	$(CC) -c $(CPPFLAGS) -o $@ $*.c
+
+
diff --git a/src/makesc.env b/src/makesc.env
new file mode 100644
index 0000000000..c10cc56f39
--- /dev/null
+++ b/src/makesc.env
@@ -0,0 +1,20 @@
+# Common settings for Symantec
+
+WXDIR = $(WXWIN)
+INCDIR = $(WXDIR)\include
+MSWINC = $(INCDIR)\msw
+BASEINC = $(INCDIR)\base
+
+SRCSUFF = cpp
+OBJSUFF = obj
+
+# default values
+
+CC=sc
+RC=rc
+CFLAGS = -o -ml -W -D__WINDOWS__
+LDFLAGS = -ml -W
+
+.$(SRCSUFF).obj:
+	*$(CC) -c $(CFLAGS) -I$(INCLUDE) $(OPTIONS) $<
+
diff --git a/src/makewat.env b/src/makewat.env
new file mode 100644
index 0000000000..c4281cc084
--- /dev/null
+++ b/src/makewat.env
@@ -0,0 +1,159 @@
+# File:         makewat.env
+# Purpose:      Watcom environments for wxWindows makefiles.
+# Author:       Julian Smart and others
+#
+# The main things to change are:
+#
+#   WATCOM:    set to where the compiler is installed
+#   WXDIR:     set to where the wxWindows is installed
+#   MODE:      set to windows [16 bit windows], nt [win32s], or win386 [32-bit non-WIN32]
+
+FINAL=0
+WATCOMDIR=$(%WATCOM)
+#.EXTENSIONS: .exe .obj .c .cc .cpp .res .rc .def
+
+# Set this to win386 if compiling under WIN386 mode, or
+# to windows for normal 16-bit Windows, nt if compiling for WIN32s/NT
+MODE= nt # windows
+
+WXDIR = c:\wx
+WXINC = $(WXDIR)\include\msw
+WXBASEINC = $(WXDIR)\include\base
+
+# Suffixes
+OBJSUFF=obj
+SRCSUFF=cpp
+
+DEBUG=0
+
+!ifneq NOPRECOMP 1
+PRECOMP     = /fh=$(WXDIR)\src\msw\watcom.pch
+!endif
+
+RC = wrc
+
+!ifeq MODE win386
+
+##### WIN386 OPTIONS
+
+# Set LEVEL to 386 if using 32-bit compilation
+LEVEL       = 386
+CCC         = wpp$(LEVEL)
+CC         =  wcc$(LEVEL)
+OS_TARGET   = win386
+MODEL       =
+LINKOPTION  = win386
+BINDCOMMAND = wbind
+WATLIBDIR = $(WATCOMDIR)\lib386\win
+MINDATA     = option mindata=100K
+MAXDATA     = option maxdata=100K
+STACK       = option stack=64k
+EXTRALIBS   = $(WXDIR)\contrib\ctl3d\ctl3d32.obj 
+IFLAGS      = -i=$(WXINC) -i=$(WXBASEINC) -i=$(WXDIR)\contrib\fafa -i=$(%watcom)\h;$(%watcom)\h\win
+RESFLAGS1   = -r -bt=windows /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa
+RESFLAGS2   = -R $(name) /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa
+DEBUGINFO   = debug all
+
+#CPPFLAGS    = /zw /w1 /zq /d2 /d__WIN386__ /zt4 $(MODEL) /d__WINDOWS__
+CPPFLAGS    = /zw /w1 /zq /d1 /d__WIN386__ $(MODEL) $(PRECOMP) /d__WINDOWS__ $(EXTRACPPFLAGS)
+
+!endif
+#### END WIN386 MODE
+
+!ifeq MODE windows
+
+##### 16-BIT WINDOWS OPTIONS
+
+# Set LEVEL to 386 if using 32-bit compilation
+LEVEL       =
+CCC         = wpp$(LEVEL)
+CC          = wcc$(LEVEL)
+OS_TARGET   = windows
+MODEL       =/ml
+LINKOPTION  = windows
+BINDCOMMAND = echo
+WATLIBDIR = $(WATCOMDIR)\lib286\win
+MINDATA     =
+MAXDATA     =
+STACK       =
+EXTRALIBS=$(WATLIBDIR)\shell.lib $(WATLIBDIR)\ddeml.lib $(WATLIBDIR)\ctl3d.lib $(WATLIBDIR)\commdlg.lib $(WATLIBDIR)\mmsystem.lib
+IFLAGS      = -i=$(WXINC) -i=$(WXBASEINC) -i=$(WXDIR)\contrib\fafa 
+RESFLAGS1   = -r -bt=windows -i=$(WXINC) -i=$(WXDIR)\contrib\fafa 
+RESFLAGS2   = -R
+DEBUGINFO   = debug all
+
+#-i=$(WXDIR)\contrib\itsybits
+
+# Note: I've added the data threshold (/zt4) for 16-bit operation,
+# or we get link failure (TEXT segment overflow). Is this OK for
+# 32-bit mode also? -- JACS
+# An alternative might be /zc (put string literals in code segment).
+#CPPFLAGS    = /zw /w1 /zq /d1 /zt4 $(MODEL) /d__WINDOWS__
+CPPFLAGS    = /zw /w2 /zq /d1 $(MODEL) $(PRECOMP) /d__WINDOWS__ $(EXTRACPPFLAGS)
+
+!endif
+#### END WINDOWS MODE
+
+!ifeq MODE nt
+
+##### NT OPTIONS
+
+LEVEL       = 386
+CCC         = wpp$(LEVEL)
+CC         =  wcc$(LEVEL)
+OS_TARGET   = nt_win
+MODEL       =
+# If you use win95, assumptions will be made about Win95 icon format etc.
+# so nt_win is probably better for simultaneous Win32s/Win95/NT operation.
+LINKOPTION  = nt_win # win95
+BINDCOMMAND = wrc
+WATLIBDIR   = $(WATCOMDIR)\lib386\nt
+MINDATA     =
+MAXDATA     =
+STACK       = option stack=64k
+EXTRALIBS   = $(WATLIBDIR)\ctl3d32.lib $(WATLIBDIR)\odbc32.lib
+IFLAGS      = -i=$(WXINC) -i=$(WXBASEINC) -i=$(WXDIR)\contrib\fafa -i=$(%watcom)\h;$(%watcom)\h\nt
+RESFLAGS1   = -r -bt=nt /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa
+RESFLAGS2   = -R $(name) /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa
+DEBUGINFO   = debug all # Linking: comment out if operating in a non-debuggable environment
+
+#-i=$(WXDIR)\contrib\itsybits
+
+# Here are some possible optimization flags:
+# /5r  Pentium timings
+# /fp5 /fpi87 Inline 80x87 instructions optimized for Pentium: coprocessor must be present
+# /ox  Standard optimizations
+# /or  Reordering for Pentium timings (included in /ox)
+# The Watcom-recommended flags for optimum Pentium speed are:
+# /oneatx /zp4 /5 /fpi87 /fp5
+
+OPTFLAGS=/ox /5r # /DDEBUG=1
+
+# /d1 for line numbers only: anything else produces an enormous wx32.lib
+CPPFLAGS    = /bt=nt /w1 /D__WIN32__ /zq $(OPTFLAGS) $(MODEL) $(PRECOMP) /d1 /d__WINDOWS__ $(EXTRACPPFLAGS)
+
+!endif
+#### END NT MODE
+
+.cpp.obj: # $< # .AUTODEPEND
+    *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+
+#    %create tmp.lbc
+#    @%append tmp.lbc $(CPPFLAGS) $(IFLAGS) $<
+#    echo $<
+#    $(CCC) @tmp.lbc
+
+.c.obj: # $< # .AUTODEPEND
+    *$(CC) $(CPPFLAGS) $(IFLAGS) $<
+
+# This doesn't work for wcc
+#    %create tmp.lbc
+#    @%append tmp.lbc $(CPPFLAGS) $(IFLAGS) $<
+#    echo $<
+#    $(CC) @tmp.lbc
+
+dummy:  .SYMBOLIC
+    @echo Please give a target for wxWin makefiles: the usual one is 'all'.
+
+erasepch:   .SYMBOLIC
+    -erase $(WXDIR)\src\msw\watcom.pch
diff --git a/src/mingegcs.bat b/src/mingegcs.bat
new file mode 100644
index 0000000000..2176c2885d
--- /dev/null
+++ b/src/mingegcs.bat
@@ -0,0 +1,13 @@
+REM
+REM replace g:\egcs-mingw32 with whatever your installation root may be.
+REM
+path C:\WINDOWS;C:\WINDOWS\COMMAND;g:\egcs-mingw32\bin;c:\bin
+
+SET GCC_EXEC_PREFIX=g:\egcs-mingw32\lib\gcc-lib\
+set BISON_SIMPLE=g:\egcs-mingw32\share\bison.simple
+set BISON_HAIRY=g:\egcs-mingw32\share\bison.hairy
+
+rem 4DOS users only...
+unalias make
+alias makeming make -f makefile.g95
+
diff --git a/src/mingw32.bat b/src/mingw32.bat
new file mode 100644
index 0000000000..6e3bea5c20
--- /dev/null
+++ b/src/mingw32.bat
@@ -0,0 +1,16 @@
+rem Mingw32 environment variables
+rem
+set WXWIN=d:\wx2
+path C:\WINDOWS;C:\WINDOWS\COMMAND;e:\mingw32\bin;e:\mingw32\lib\gcc-lib\i386-mingw32\2.8.1;c:\bin
+rem set GCC_EXEC_PREFIX=G:\gnuwin32\b18\H-i386-cygwin32\lib\gcc-lib\
+set RCINCLUDE=%WXWIN\include
+rem set CPLUS_INCLUDE_PATH=/g/gnuwin32/b18/h-i386-cygwin32/i386-cygwin32/include:/g/gnuwin32/b18/include/g++:/g/gnuwin32/b18/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2-970404/include:/d/wx2/include:/g/gnuwin32/b18/include/g++
+set CPLUS_INCLUDE_PATH=e:\mingw32\include;e:\mingw32\lib\gcc-lib\i386-mingw32\2.8.1\include;e:\mingw32\include\g++
+set C_INCLUDE_PATH=e:\mingw32\include;e:\mingw32\lib\gcc-lib\i386-mingw32\2.8.1\include;e:\mingw32\include\g++
+set LIBRARY_PATH=e:\mingw32\lib;e:\mingw32\lib\gcc-lib\i386-mingw32\2.8.1
+set BISON_SIMPLE=e:\mingw32\share\bison.simple
+set BISON_HAIRY=e:\mingw32\share\bison.hairy
+
+rem 4DOS users only...
+unalias make
+alias makeming make -f makefile.g95
diff --git a/src/msw/Y_TAB.C b/src/msw/Y_TAB.C
new file mode 100644
index 0000000000..e1e62c59f6
--- /dev/null
+++ b/src/msw/Y_TAB.C
@@ -0,0 +1,521 @@
+#ifndef lint
+static char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
+#endif
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define yyclearin (yychar=(-1))
+#define yyerrok (yyerrflag=0)
+#define YYRECOVERING (yyerrflag!=0)
+#define YYPREFIX "yy"
+#line 2 "../common/parser.y"
+#include <string.h>
+#include "wx/expr.h"
+
+#ifndef __EXTERN_C__
+#define __EXTERN_C__ 1
+#endif
+
+#if defined(__cplusplus) || defined(__STDC__)
+#if defined(__cplusplus) && defined(__EXTERN_C__)
+extern "C" {
+#endif
+#endif
+int yylex(void);
+int yylook(void);
+int yywrap(void);
+int yyback(int *, int);
+void yyerror(char *);
+
+/* You may need to put /DLEX_SCANNER in your makefile
+ * if you're using LEX!
+ */
+#ifdef LEX_SCANNER
+/* int yyoutput(int); */
+void yyoutput(int);
+#else
+void yyoutput(int);
+#endif
+
+#if defined(__cplusplus) || defined(__STDC__)
+#if defined(__cplusplus) && defined(__EXTERN_C__)
+}
+#endif
+#endif
+#line 37 "../common/parser.y"
+typedef union {
+    char *s;
+/*    struct pexpr *expr; */
+} YYSTYPE;
+#line 51 "y_tab.c"
+#define INTEGER 1
+#define WORD 2
+#define STRING 3
+#define PERIOD 13
+#define OPEN 4
+#define CLOSE 5
+#define COMMA 6
+#define NEWLINE 7
+#define ERROR 8
+#define OPEN_SQUARE 9
+#define CLOSE_SQUARE 10
+#define EQUALS 11
+#define EXP 14
+#define YYERRCODE 256
+short yylhs[] = {                                        -1,
+    0,    0,    1,    1,    1,    2,    2,    2,    3,    3,
+    3,    4,    4,    5,    5,    5,    5,    5,    5,    5,
+};
+short yylen[] = {                                         2,
+    0,    2,    2,    2,    2,    4,    2,    3,    0,    1,
+    3,    3,    1,    1,    1,    1,    3,    3,    5,    1,
+};
+short yydefred[] = {                                      1,
+    0,    0,    0,    0,    2,    0,    5,    3,    0,    0,
+    0,   15,    7,   20,    0,    0,   13,    4,    0,    0,
+    0,    0,    8,    0,    6,    0,   18,    0,   12,   11,
+    0,   19,
+};
+short yydgoto[] = {                                       1,
+    5,   14,   15,   16,   17,
+};
+short yysindex[] = {                                      0,
+   -2,    9,    2,    1,    0,   10,    0,    0,   11,   -5,
+   17,    0,    0,    0,   14,   -1,    0,    0,   33,   38,
+   41,   16,    0,   11,    0,   29,    0,   40,    0,    0,
+   44,    0,
+};
+short yyrindex[] = {                                      0,
+    0,    0,    0,    0,    0,    0,    0,    0,   42,   21,
+   24,    0,    0,    0,    0,   30,    0,    0,    0,    0,
+    0,    0,    0,   31,    0,   27,    0,   24,    0,    0,
+    0,    0,
+};
+short yygindex[] = {                                      0,
+    0,   45,   -8,    0,   26,
+};
+#define YYTABLESIZE 254
+short yytable[] = {                                       3,
+   19,   10,   11,   12,   24,    9,    4,   20,   21,    4,
+   13,   10,   11,   12,    8,   30,   10,   28,   12,    4,
+    9,    7,   18,   23,    4,   16,   16,   22,   14,   14,
+   16,   17,   17,   14,   10,    9,   17,   25,   26,   10,
+    9,   27,   31,    9,   32,    6,    9,   29,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    2,
+};
+short yycheck[] = {                                       2,
+    9,    1,    2,    3,    6,    4,    9,   13,   14,    9,
+   10,    1,    2,    3,   13,   24,    1,    2,    3,    9,
+    4,   13,   13,   10,    9,    5,    6,   11,    5,    6,
+   10,    5,    6,   10,    5,    5,   10,    5,    1,   10,
+   10,    1,   14,    4,    1,    1,    5,   22,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  256,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 14
+#if YYDEBUG
+char *yyname[] = {
+"end-of-file","INTEGER","WORD","STRING","OPEN","CLOSE","COMMA","NEWLINE",
+"ERROR","OPEN_SQUARE","CLOSE_SQUARE","EQUALS",0,"PERIOD","EXP",
+};
+char *yyrule[] = {
+"$accept : commands",
+"commands :",
+"commands : commands command",
+"command : WORD PERIOD",
+"command : expr PERIOD",
+"command : error PERIOD",
+"expr : WORD OPEN arglist CLOSE",
+"expr : OPEN_SQUARE CLOSE_SQUARE",
+"expr : OPEN_SQUARE arglist CLOSE_SQUARE",
+"arglist :",
+"arglist : arg",
+"arglist : arg COMMA arglist",
+"arg : WORD EQUALS arg1",
+"arg : arg1",
+"arg1 : WORD",
+"arg1 : STRING",
+"arg1 : INTEGER",
+"arg1 : INTEGER PERIOD INTEGER",
+"arg1 : INTEGER EXP INTEGER",
+"arg1 : INTEGER PERIOD INTEGER EXP INTEGER",
+"arg1 : expr",
+};
+#endif
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+int yydebug;
+int yynerrs;
+int yyerrflag;
+int yychar;
+short *yyssp;
+YYSTYPE *yyvsp;
+YYSTYPE yyval;
+YYSTYPE yylval;
+short yyss[YYSTACKSIZE];
+YYSTYPE yyvs[YYSTACKSIZE];
+#define yystacksize YYSTACKSIZE
+#line 119 "../common/parser.y"
+
+#include "../common/lex_yy.c"
+
+/*
+void yyerror(s)
+char *s;
+{
+  syntax_error(s);
+}
+*/
+
+/* Ansi prototype. If this doesn't work for you... uncomment
+   the above instead.
+ */
+
+void yyerror(char *s)
+{
+  syntax_error(s);
+}
+
+/*
+ * Unfortunately, my DOS version of FLEX
+ * requires yywrap to be #def'ed, whereas
+ * the UNIX flex expects a proper function.
+ */
+
+/* Not sure if __SC__ is the appropriate thing
+ * to test
+ */
+
+#ifndef __SC__
+#ifdef USE_DEFINE
+#ifndef yywrap
+#define yywrap() 1
+#endif
+#else if !defined(__alpha) && !defined(__ultrix)
+int yywrap() { return 1; }
+#endif
+#endif
+#line 251 "y_tab.c"
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+int
+yyparse()
+{
+    register int yym, yyn, yystate;
+#if YYDEBUG
+    register char *yys;
+    extern char *getenv();
+
+    if (yys = getenv("YYDEBUG"))
+    {
+        yyn = *yys;
+        if (yyn >= '0' && yyn <= '9')
+            yydebug = yyn - '0';
+    }
+#endif
+
+    yynerrs = 0;
+    yyerrflag = 0;
+    yychar = (-1);
+
+    yyssp = yyss;
+    yyvsp = yyvs;
+    *yyssp = yystate = 0;
+
+yyloop:
+    if (yyn = yydefred[yystate]) goto yyreduce;
+    if (yychar < 0)
+    {
+        if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, reading %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+    }
+    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: state %d, shifting to state %d\n",
+                    YYPREFIX, yystate, yytable[yyn]);
+#endif
+        if (yyssp >= yyss + yystacksize - 1)
+        {
+            goto yyoverflow;
+        }
+        *++yyssp = yystate = yytable[yyn];
+        *++yyvsp = yylval;
+        yychar = (-1);
+        if (yyerrflag > 0)  --yyerrflag;
+        goto yyloop;
+    }
+    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+        yyn = yytable[yyn];
+        goto yyreduce;
+    }
+    if (yyerrflag) goto yyinrecovery;
+#ifdef lint
+    goto yynewerror;
+#endif
+yynewerror:
+    yyerror("syntax error");
+#ifdef lint
+    goto yyerrlab;
+#endif
+yyerrlab:
+    ++yynerrs;
+yyinrecovery:
+    if (yyerrflag < 3)
+    {
+        yyerrflag = 3;
+        for (;;)
+        {
+            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
+                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
+#endif
+                if (yyssp >= yyss + yystacksize - 1)
+                {
+                    goto yyoverflow;
+                }
+                *++yyssp = yystate = yytable[yyn];
+                *++yyvsp = yylval;
+                goto yyloop;
+            }
+            else
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: error recovery discarding state %d\n",
+                            YYPREFIX, *yyssp);
+#endif
+                if (yyssp <= yyss) goto yyabort;
+                --yyssp;
+                --yyvsp;
+            }
+        }
+    }
+    else
+    {
+        if (yychar == 0) goto yyabort;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+        yychar = (-1);
+        goto yyloop;
+    }
+yyreduce:
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+                YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+    yym = yylen[yyn];
+    yyval = yyvsp[1-yym];
+    switch (yyn)
+    {
+case 3:
+#line 69 "../common/parser.y"
+{process_command(proio_cons(make_word(yyvsp[-1].s), NULL)); free(yyvsp[-1].s);}
+break;
+case 4:
+#line 71 "../common/parser.y"
+{process_command(yyvsp[-1].s);}
+break;
+case 5:
+#line 73 "../common/parser.y"
+{syntax_error("Unrecognized command.");}
+break;
+case 6:
+#line 77 "../common/parser.y"
+{yyval.s = proio_cons(make_word(yyvsp[-3].s), yyvsp[-1].s); free(yyvsp[-3].s);}
+break;
+case 7:
+#line 79 "../common/parser.y"
+{yyval.s = proio_cons(NULL, NULL);}
+break;
+case 8:
+#line 81 "../common/parser.y"
+{yyval.s = yyvsp[-1].s; }
+break;
+case 9:
+#line 85 "../common/parser.y"
+{yyval.s = NULL;}
+break;
+case 10:
+#line 87 "../common/parser.y"
+{yyval.s = proio_cons(yyvsp[0].s, NULL);}
+break;
+case 11:
+#line 90 "../common/parser.y"
+{yyval.s = proio_cons(yyvsp[-2].s, yyvsp[0].s);}
+break;
+case 12:
+#line 94 "../common/parser.y"
+{yyval.s = proio_cons(make_word("="), proio_cons(make_word(yyvsp[-2].s), proio_cons(yyvsp[0].s, NULL)));
+                         free(yyvsp[-2].s); }
+break;
+case 13:
+#line 97 "../common/parser.y"
+{yyval.s = yyvsp[0].s; }
+break;
+case 14:
+#line 100 "../common/parser.y"
+{yyval.s = make_word(yyvsp[0].s); free(yyvsp[0].s);}
+break;
+case 15:
+#line 102 "../common/parser.y"
+{yyval.s = make_string(yyvsp[0].s); free(yyvsp[0].s);}
+break;
+case 16:
+#line 104 "../common/parser.y"
+{yyval.s = make_integer(yyvsp[0].s); free(yyvsp[0].s);}
+break;
+case 17:
+#line 106 "../common/parser.y"
+{yyval.s = make_real(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); }
+break;
+case 18:
+#line 108 "../common/parser.y"
+{yyval.s = make_exp(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); }
+break;
+case 19:
+#line 111 "../common/parser.y"
+{yyval.s = make_exp2(yyvsp[-4].s, yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-4].s); free(yyvsp[-2].s);
+                                                                  free(yyvsp[0].s); }
+break;
+case 20:
+#line 115 "../common/parser.y"
+{yyval.s = yyvsp[0].s;}
+break;
+#line 466 "y_tab.c"
+    }
+    yyssp -= yym;
+    yystate = *yyssp;
+    yyvsp -= yym;
+    yym = yylhs[yyn];
+    if (yystate == 0 && yym == 0)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+        yystate = YYFINAL;
+        *++yyssp = YYFINAL;
+        *++yyvsp = yyval;
+        if (yychar < 0)
+        {
+            if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+            if (yydebug)
+            {
+                yys = 0;
+                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+                if (!yys) yys = "illegal-symbol";
+                printf("%sdebug: state %d, reading %d (%s)\n",
+                        YYPREFIX, YYFINAL, yychar, yys);
+            }
+#endif
+        }
+        if (yychar == 0) goto yyaccept;
+        goto yyloop;
+    }
+    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+        yystate = yytable[yyn];
+    else
+        yystate = yydgoto[yym];
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yyssp, yystate);
+#endif
+    if (yyssp >= yyss + yystacksize - 1)
+    {
+        goto yyoverflow;
+    }
+    *++yyssp = yystate;
+    *++yyvsp = yyval;
+    goto yyloop;
+yyoverflow:
+    yyerror("yacc stack overflow");
+yyabort:
+    return (1);
+yyaccept:
+    return (0);
+}
diff --git a/src/msw/app.cpp b/src/msw/app.cpp
new file mode 100644
index 0000000000..31c1cd1849
--- /dev/null
+++ b/src/msw/app.cpp
@@ -0,0 +1,1001 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        app.cpp
+// Purpose:     wxApp
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "app.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#define IN_WX_MAIN_CPP
+#include "wx/wxprec.h"
+
+#if defined(__BORLANDC__)
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/frame.h"
+#include "wx/app.h"
+#include "wx/utils.h"
+#include "wx/gdicmn.h"
+#include "wx/pen.h"
+#include "wx/brush.h"
+#include "wx/cursor.h"
+#include "wx/icon.h"
+#include "wx/palette.h"
+#include "wx/dc.h"
+#include "wx/dialog.h"
+#include "wx/msgdlg.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "wx/postscrp.h"
+#include "wx/log.h"
+#include "wx/module.h"
+
+#if USE_WX_RESOURCES
+#include "wx/resource.h"
+#endif
+
+
+#include <string.h>
+
+#if defined(__WIN95__) && !defined(__GNUWIN32__)
+#include <commctrl.h>
+#endif
+
+extern char *wxBuffer;
+extern char *wxOsVersion;
+extern wxList *wxWinHandleList;
+extern wxList wxPendingDelete;
+extern void wxSetKeyboardHook(bool doIt);
+extern wxCursor *g_globalCursor;
+
+HANDLE wxhInstance = 0;
+static MSG s_currentMsg;
+wxApp *wxTheApp = NULL;
+
+char wxFrameClassName[]         = "wxFrameClass";
+char wxMDIFrameClassName[]      = "wxMDIFrameClass";
+char wxMDIChildFrameClassName[] = "wxMDIChildFrameClass";
+char wxPanelClassName[]         = "wxPanelClass";
+char wxCanvasClassName[]        = "wxCanvasClass";
+
+HICON wxSTD_FRAME_ICON = NULL;
+HICON wxSTD_MDICHILDFRAME_ICON = NULL;
+HICON wxSTD_MDIPARENTFRAME_ICON = NULL;
+
+HICON wxDEFAULT_FRAME_ICON = NULL;
+HICON wxDEFAULT_MDICHILDFRAME_ICON = NULL;
+HICON wxDEFAULT_MDIPARENTFRAME_ICON = NULL;
+
+HBRUSH wxDisableButtonBrush = 0;
+
+LRESULT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
+BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
+    EVT_IDLE(wxApp::OnIdle)
+END_EVENT_TABLE()
+#endif
+
+long wxApp::sm_lastMessageTime = 0;
+
+#ifdef __WIN95__
+static HINSTANCE gs_hRichEdit = NULL;
+#endif
+
+bool wxApp::Initialize(WXHANDLE instance)
+{
+  HANDLE hInstance = (HANDLE)instance;
+
+  CommonInit();
+
+#if defined(__WIN95__)
+  InitCommonControls();
+  gs_hRichEdit = LoadLibrary("RICHED32.DLL");
+
+  if (gs_hRichEdit == NULL)
+  {
+    wxMessageBox("Could not initialise Rich Edit DLL");
+  }
+#endif
+
+#if     defined(WX_DRAG_DROP)
+  // we need to initialize OLE library
+  if ( FAILED(::OleInitialize(NULL)) )
+    wxFatalError(_("Cannot initialize OLE"));
+#endif
+
+#if CTL3D
+  if (!Ctl3dRegister(hInstance))
+    wxFatalError("Cannot register CTL3D");
+
+  Ctl3dAutoSubclass(hInstance);
+#endif
+
+  wxSTD_FRAME_ICON = LoadIcon(hInstance, "wxSTD_FRAME");
+  wxSTD_MDIPARENTFRAME_ICON = LoadIcon(hInstance, "wxSTD_MDIPARENTFRAME");
+  wxSTD_MDICHILDFRAME_ICON = LoadIcon(hInstance, "wxSTD_MDICHILDFRAME");
+
+  wxDEFAULT_FRAME_ICON = LoadIcon(hInstance, "wxDEFAULT_FRAME");
+  wxDEFAULT_MDIPARENTFRAME_ICON = LoadIcon(hInstance, "wxDEFAULT_MDIPARENTFRAME");
+  wxDEFAULT_MDICHILDFRAME_ICON = LoadIcon(hInstance, "wxDEFAULT_MDICHILDFRAME");
+
+  RegisterWindowClasses();
+
+  // Create the brush for disabling bitmap buttons
+
+  LOGBRUSH lb ;
+  lb.lbStyle = BS_PATTERN;
+  lb.lbHatch = (int)LoadBitmap( hInstance, "wxDISABLE_BUTTON_BITMAP" ) ;
+  wxDisableButtonBrush = ::CreateBrushIndirect( & lb ) ;
+  ::DeleteObject( (HGDIOBJ)lb.lbHatch ) ;
+
+#if USE_PENWINDOWS
+  wxRegisterPenWin();
+#endif
+
+  wxWinHandleList = new wxList(wxKEY_INTEGER);
+
+  // This is to foil optimizations in Visual C++ that
+  // throw out dummy.obj.
+#if (_MSC_VER >= 800) && !defined(WXMAKINGDLL)
+  extern char wxDummyChar;
+  if (wxDummyChar) wxDummyChar++;
+#endif
+  wxSetKeyboardHook(TRUE);
+
+  wxModule::RegisterModules();
+  if (!wxModule::InitializeModules())
+    return FALSE;
+  return TRUE;
+}
+
+bool wxApp::RegisterWindowClasses(void)
+{
+///////////////////////////////////////////////////////////////////////
+// Register the frame window class.
+  WNDCLASS wndclass;   // Structure used to register Windows class.
+
+  wndclass.style         = CS_HREDRAW | CS_VREDRAW;
+  wndclass.lpfnWndProc   = (WNDPROC)wxWndProc;
+  wndclass.cbClsExtra    = 0;
+  wndclass.cbWndExtra    = sizeof( DWORD ); // was 4
+  wndclass.hInstance     = wxhInstance;
+  wndclass.hIcon         = NULL;        // wxSTD_FRAME_ICON;
+  wndclass.hCursor       = LoadCursor( NULL, IDC_ARROW );
+  wndclass.hbrBackground =  (HBRUSH)(COLOR_APPWORKSPACE+1) ;
+//  wndclass.hbrBackground = GetStockObject( WHITE_BRUSH );
+  wndclass.lpszMenuName  = NULL;
+#ifdef _MULTIPLE_INSTANCES
+  sprintf( wxFrameClassName,"wxFrameClass%d", hInstance );
+#endif
+  wndclass.lpszClassName = wxFrameClassName;
+
+  if (!RegisterClass( &wndclass ))
+  {
+    // wxFatalError("Can't register Frame Window class");
+  }
+
+///////////////////////////////////////////////////////////////////////
+// Register the MDI frame window class.
+  WNDCLASS wndclass1;   // Structure used to register Windows class.
+
+  wndclass1.style         = CS_HREDRAW | CS_VREDRAW;
+  wndclass1.lpfnWndProc   = (WNDPROC)wxWndProc;
+  wndclass1.cbClsExtra    = 0;
+  wndclass1.cbWndExtra    = sizeof( DWORD ); // was 4
+  wndclass1.hInstance     = wxhInstance;
+  wndclass1.hIcon         = NULL; // wxSTD_MDIPARENTFRAME_ICON;
+  wndclass1.hCursor       = LoadCursor( NULL, IDC_ARROW );
+//  wndclass1.hbrBackground =  (HBRUSH)(COLOR_APPWORKSPACE+1) ;
+  wndclass1.hbrBackground = NULL;
+  wndclass1.lpszMenuName  = NULL;
+
+  wndclass1.lpszClassName = wxMDIFrameClassName;
+  if (!RegisterClass( &wndclass1 ))
+  {
+//    wxFatalError("Can't register MDI Frame window class");
+//	return FALSE;
+  }
+
+///////////////////////////////////////////////////////////////////////
+// Register the MDI child frame window class.
+  WNDCLASS wndclass4;   // Structure used to register Windows class.
+
+  wndclass4.style         = CS_HREDRAW | CS_VREDRAW;
+  wndclass4.lpfnWndProc   = (WNDPROC)wxWndProc;
+  wndclass4.cbClsExtra    = 0;
+  wndclass4.cbWndExtra    = sizeof( DWORD ); // was 4
+  wndclass4.hInstance     = wxhInstance;
+  wndclass4.hIcon         = NULL;       // wxSTD_MDICHILDFRAME_ICON;
+  wndclass4.hCursor       = LoadCursor( NULL, IDC_ARROW );
+  // TODO: perhaps this should be NULL so that Windows doesn't
+  // paint the background itself (would OnEraseBackground duplicate
+  // this?)
+  wndclass4.hbrBackground =  (HBRUSH)(COLOR_WINDOW+1) ;
+//  wndclass4.hbrBackground = NULL;
+  wndclass4.lpszMenuName  = NULL;
+  wndclass4.lpszClassName = wxMDIChildFrameClassName;
+
+  if (!RegisterClass( &wndclass4 ))
+  {
+//   wxFatalError("Can't register MDI child frame window class");
+//   return FALSE;
+  }
+
+///////////////////////////////////////////////////////////////////////
+// Register the panel window class.
+  WNDCLASS wndclass2;   // Structure used to register Windows class.
+  memset(&wndclass2, 0, sizeof(WNDCLASS));   // start with NULL defaults
+  // Use CS_OWNDC to avoid messing about restoring the context
+  // for every graphic operation.
+  wndclass2.style         = CS_HREDRAW | CS_VREDRAW;
+  wndclass2.lpfnWndProc   = (WNDPROC)wxWndProc;
+  wndclass2.cbClsExtra    = 0;
+  wndclass2.cbWndExtra    = sizeof( DWORD ); // was 4
+  wndclass2.hInstance     = wxhInstance;
+  wndclass2.hIcon         = NULL;
+  wndclass2.hCursor       = NULL;
+//  wndclass2.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1) ;
+  wndclass2.hbrBackground = GetStockObject( LTGRAY_BRUSH );
+  wndclass2.lpszMenuName  = NULL;
+  wndclass2.lpszClassName = wxPanelClassName;
+  if (!RegisterClass( &wndclass2 ))
+  {
+//   wxFatalError("Can't register Panel Window class");
+//   return FALSE;
+  }
+
+///////////////////////////////////////////////////////////////////////
+// Register the canvas and textsubwindow class name
+  WNDCLASS wndclass3;   // Structure used to register Windows class.
+  memset(&wndclass3, 0, sizeof(WNDCLASS));   // start with NULL defaults
+  // Use CS_OWNDC to avoid messing about restoring the context
+  // for every graphic operation.
+//  wndclass3.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS ; 
+  // wxWin 2.0
+  wndclass3.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ; 
+  wndclass3.lpfnWndProc   = (WNDPROC)wxWndProc;
+  wndclass3.cbClsExtra    = 0;
+  wndclass3.cbWndExtra    = sizeof( DWORD ); // was 4
+  wndclass3.hInstance     = wxhInstance;
+  wndclass3.hIcon         = NULL;
+  wndclass3.hCursor       = NULL;
+//  wndclass3.hbrBackground = (HBRUSH)(COLOR_WINDOW+1) ;
+  wndclass3.hbrBackground = NULL;
+  wndclass3.lpszMenuName  = NULL;
+  wndclass3.lpszClassName = wxCanvasClassName;
+  if (!RegisterClass( &wndclass3))
+  {
+//   wxFatalError("Can't register Canvas class");
+//   return FALSE;
+  }
+
+  return TRUE;
+}
+
+// Cleans up any wxWindows internal structures left lying around
+void wxApp::CleanUp(void)
+{
+  wxModule::CleanUpModules();
+
+  CommonCleanUp();
+
+  wxSetKeyboardHook(FALSE);
+
+#ifdef __WIN95__
+  if (gs_hRichEdit != NULL)
+    FreeLibrary(gs_hRichEdit);
+#endif
+
+#if USE_PENWINDOWS
+  wxCleanUpPenWin();
+#endif
+
+  if (wxSTD_FRAME_ICON)
+    DestroyIcon(wxSTD_FRAME_ICON);
+  if (wxSTD_MDICHILDFRAME_ICON)
+    DestroyIcon(wxSTD_MDICHILDFRAME_ICON);
+  if (wxSTD_MDIPARENTFRAME_ICON)
+    DestroyIcon(wxSTD_MDIPARENTFRAME_ICON);
+
+  if (wxDEFAULT_FRAME_ICON)
+    DestroyIcon(wxDEFAULT_FRAME_ICON);
+  if (wxDEFAULT_MDICHILDFRAME_ICON)
+    DestroyIcon(wxDEFAULT_MDICHILDFRAME_ICON);
+  if (wxDEFAULT_MDIPARENTFRAME_ICON)
+    DestroyIcon(wxDEFAULT_MDIPARENTFRAME_ICON);
+
+  if ( wxDisableButtonBrush )
+    ::DeleteObject( wxDisableButtonBrush ) ;
+
+#if     defined(WX_DRAG_DROP)
+  ::OleUninitialize();
+#endif
+
+#if CTL3D
+  Ctl3dUnregister(wxhInstance);
+#endif
+
+  if (wxWinHandleList)
+    delete wxWinHandleList ;
+    
+}
+
+void wxApp::CommonInit(void)
+{
+#ifdef __WINDOWS__
+  wxBuffer = new char[1500];
+#else
+  wxBuffer = new char[BUFSIZ + 512];
+#endif
+
+  wxClassInfo::InitializeClasses();
+
+#ifdef __X__
+  wxTheFontNameDirectory.Initialize();
+#endif
+
+#if defined(__X__) && USE_RESOURCES
+  // Read standard font names from .Xdefaults
+
+  extern char *wxDecorativeFontName;
+  extern char *wxRomanFontName;
+  extern char *wxModernFontName;
+  extern char *wxSwissFontName;
+  extern char *wxScriptFontName;
+  extern char *wxTeletypeFontName;
+  extern char *wxDefaultFontName;
+
+  (void) wxGetResource("wxWindows", "defaultFamily", &wxDefaultFontName);
+  (void) wxGetResource("wxWindows", "decorativeFamily", &wxDecorativeFontName);
+  (void) wxGetResource("wxWindows", "romanFamily", &wxRomanFontName);
+  (void) wxGetResource("wxWindows", "modernFamily", &wxModernFontName);
+  (void) wxGetResource("wxWindows", "swissFamily", &wxSwissFontName);
+  (void) wxGetResource("wxWindows", "scriptFamily", &wxScriptFontName);
+  (void) wxGetResource("wxWindows", "teletypeFamily", &wxTeletypeFontName);
+#endif
+
+#if USE_RESOURCES
+  (void) wxGetResource("wxWindows", "OsVersion", &wxOsVersion);
+#endif
+
+  wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
+  wxTheColourDatabase->Initialize();
+  wxInitializeStockObjects();
+
+#if USE_WX_RESOURCES
+  wxInitializeResourceSystem();
+#endif
+
+  // For PostScript printing
+#if USE_POSTSCRIPT
+  wxInitializePrintSetupData();
+  wxThePrintPaperDatabase = new wxPrintPaperDatabase;
+  wxThePrintPaperDatabase->CreateDatabase();
+#endif
+
+  wxBitmap::InitStandardHandlers();
+
+  g_globalCursor = new wxCursor;
+}
+
+void wxApp::CommonCleanUp(void)
+{
+#if USE_WX_RESOURCES
+  wxCleanUpResourceSystem();
+
+//  wxDefaultResourceTable->ClearTable();
+#endif
+  // Indicate that the cursor can be freed,
+  // so that cursor won't be deleted by deleting
+  // the bitmap list before g_globalCursor goes out
+  // of scope (double deletion of the cursor).
+  wxSetCursor(wxNullCursor);
+  delete g_globalCursor;
+
+  wxDeleteStockObjects() ;
+
+  // Destroy all GDI lists, etc.
+  delete wxTheBrushList;
+  wxTheBrushList = NULL;
+
+  delete wxThePenList;
+  wxThePenList = NULL;
+
+  delete wxTheFontList;
+  wxTheFontList = NULL;
+
+  delete wxTheBitmapList;
+  wxTheBitmapList = NULL;
+
+  delete wxTheColourDatabase;
+  wxTheColourDatabase = NULL;
+
+#if USE_POSTSCRIPT
+  wxInitializePrintSetupData(FALSE);
+  delete wxThePrintPaperDatabase;
+  wxThePrintPaperDatabase = NULL;
+#endif
+
+  wxBitmap::CleanUpHandlers();
+
+  delete[] wxBuffer;
+  wxBuffer = NULL;
+}
+
+#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
+
+// Main wxWindows entry point
+
+int wxEntry(WXHINSTANCE hInstance, WXHINSTANCE WXUNUSED(hPrevInstance), char *m_lpCmdLine,
+                    int nCmdShow, bool enterLoop)
+{
+  wxhInstance = (HINSTANCE) hInstance;
+
+#if (DEBUG && USE_MEMORY_TRACING) || USE_DEBUG_CONTEXT
+
+#if !defined(_WINDLL)
+  streambuf* sBuf = new wxDebugStreamBuf;
+#else
+  streambuf* sBuf = NULL;
+#endif
+  ostream* oStr = new ostream(sBuf) ;
+  wxDebugContext::SetStream(oStr, sBuf);
+
+#endif
+
+  if (!wxApp::Initialize((WXHINSTANCE) wxhInstance))
+    return 0;
+
+  // The app may have declared a global application object, but we recommend
+  // the IMPLEMENT_APP macro is used instead, which sets an initializer function
+  // for delayed, dynamic app object construction.
+  if (!wxTheApp)
+  {
+  	if (!wxApp::GetInitializerFunction())
+  	{
+    	MessageBox(NULL, "No initializer - use IMPLEMENT_APP macro.", "wxWindows Error", MB_APPLMODAL | MB_ICONSTOP | MB_OK);
+		return 0;
+  	}
+
+  	wxTheApp = (* wxApp::GetInitializerFunction()) ();
+  }
+
+  if (!wxTheApp) {
+    MessageBox(NULL, "You have to define an instance of wxApp!", "wxWindows Error", MB_APPLMODAL | MB_ICONSTOP | MB_OK);
+    return 0;
+  }
+
+  // Split command line into tokens, as in usual main(argc, argv)
+  char **command = new char*[50];
+  
+  int count = 0;
+  char *buf = new char[strlen(m_lpCmdLine) + 1];
+  
+  // Hangs around until end of app. in case
+  // user carries pointers to the tokens
+
+  /* Model independent strcpy */
+  int i;
+  for (i = 0; (buf[i] = m_lpCmdLine[i]) != 0; i++)
+  {
+    /* loop */;
+  }
+
+  // Get application name
+  char name[200];
+  ::GetModuleFileName(wxhInstance, name, 199);
+
+  // Is it only 16-bit Borland that already copies the program name
+  // to the first argv index?
+#if !defined(__GNUWIN32__)
+// #if ! (defined(__BORLANDC__) && !defined(__WIN32__))
+  command[count++] = copystring(name);
+// #endif
+#endif
+
+  strcpy(name, wxFileNameFromPath(name));
+  wxStripExtension(name);
+  wxTheApp->SetAppName(name);
+
+  /* Break up string */
+  // Treat strings enclosed in double-quotes as single arguments
+    char* str = buf;
+	while (*str)
+	{
+		while (*str && *str <= ' ') str++;	// skip whitespace
+		if (*str == '"')
+		{
+			str++;
+			command[count++] = str;
+			while (*str && *str != '"') str++;
+		}
+		else if (*str)
+		{
+			command[count++] = str;
+			while (*str && *str > ' ') str++;
+		}
+		if (*str) *str++ = '\0';
+	}
+  command[count] = NULL; /* argv[] is NULL terminated list! */
+
+  wxTheApp->argc = count;
+  wxTheApp->argv = command;
+  wxTheApp->m_nCmdShow = nCmdShow;
+
+  // GUI-specific initialisation. In fact on Windows we don't have any,
+  // but this call is provided for compatibility across platforms.
+  wxTheApp->OnInitGui() ;
+
+  if (!wxTheApp->OnInit())
+  {
+    	wxTheApp->DeletePendingObjects();
+        wxTheApp->OnExit();
+        wxApp::CleanUp();
+
+        delete wxTheApp;
+        wxTheApp = NULL;
+
+        delete [] buf ;
+
+        // TODO: This should really be cleaned up in ~wxApp
+        delete [] command[0] ;
+        delete [] command ;
+   	    return 0;
+  }
+
+  if (!enterLoop)
+	return 0;
+
+  int retValue = 1;
+
+/* New behaviour - leave it to the app to show the top window
+  if (wxTheApp->GetTopWindow()) {
+    // show the toplevel frame, only if we are not iconized (from MS-Windows)
+    if(wxTheApp->GetShowFrameOnInit() && (nCmdShow!=SW_HIDE)) wxTheApp->GetTopWindow()->Show(TRUE);
+  }
+*/
+
+  retValue = wxTheApp->OnRun();
+
+  if (wxTheApp->GetTopWindow())
+  {
+    // Forcibly delete the window.
+	if (wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame)) ||
+	    wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxDialog)))
+	{
+    	wxTheApp->GetTopWindow()->Close(TRUE);
+    	wxTheApp->DeletePendingObjects();
+	}
+	else
+	{
+		delete wxTheApp->GetTopWindow();
+		wxTheApp->SetTopWindow(NULL);
+	}
+  }
+  
+  wxTheApp->OnExit();
+  wxApp::CleanUp();
+
+  delete wxTheApp;
+  wxTheApp = NULL;
+
+  delete [] buf ;
+  delete [] command[0] ;
+  delete [] command ;
+
+#if (DEBUG && USE_MEMORY_TRACING) || USE_DEBUG_CONTEXT
+  // At this point we want to check if there are any memory
+  // blocks that aren't part of the wxDebugContext itself,
+  // as a special case. Then when dumping we need to ignore
+  // wxDebugContext, too.
+  if (wxDebugContext::CountObjectsLeft() > 0)
+  {
+    wxTrace("There were memory leaks.\n");
+    wxDebugContext::Dump();
+    wxDebugContext::PrintStatistics();
+  }
+  wxDebugContext::SetStream(NULL, NULL);
+#endif
+
+  return retValue;
+}
+
+#else /*  _WINDLL  */
+
+int wxEntry(WXHINSTANCE hInstance)
+{
+  wxhInstance = (HINSTANCE) hInstance;
+  wxApp::Initialize((WXHINSTANCE) wxhInstance);
+
+  // The app may have declared a global application object, but we recommend
+  // the IMPLEMENT_APP macro is used instead, which sets an initializer function
+  // for delayed, dynamic app object construction.
+
+  if (!wxTheApp)
+  {
+  	if (!wxApp::GetInitializerFunction())
+  	{
+    	MessageBox(NULL, "No initializer - use IMPLEMENT_APP macro.", "wxWindows Error", MB_APPLMODAL | MB_ICONSTOP | MB_OK);
+		return 0;
+  	}
+
+  	wxTheApp = (* wxApp::GetInitializerFunction()) ();
+  }
+
+  if (!wxTheApp) {
+    MessageBox(NULL, "You have to define an instance of wxApp!", "wxWindows Error", MB_APPLMODAL | MB_ICONSTOP | MB_OK);
+    return 0;
+  }
+
+  wxTheApp->argc = 0;
+  wxTheApp->argv = NULL;
+
+  wxTheApp->OnInitGui();
+
+  wxTheApp->OnInit();
+
+  if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->GetHWND()) {
+    wxTheApp->GetTopWindow()->Show(TRUE);
+  }
+
+  return 1;
+}
+#endif // _WINDLL
+
+// Static member initialization
+wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
+
+wxApp::wxApp(void)
+{
+  m_topWindow = NULL;
+  wxTheApp = this;
+//  work_proc = NULL ;
+  m_className = "";
+//  m_resourceCollection = TRUE;
+//  m_pendingCleanup = FALSE;
+  m_wantDebugOutput = TRUE ;
+  m_appName = "";
+  argc = 0;
+  argv = NULL;
+#ifdef __WINDOWS__
+  m_printMode = wxPRINT_WINDOWS;
+#else
+  m_printMode = wxPRINT_POSTSCRIPT;
+#endif
+//  work_proc = NULL;
+  m_exitOnFrameDelete = TRUE;
+//  m_showOnInit = TRUE;
+  m_auto3D = TRUE;
+}
+
+bool wxApp::Initialized(void)
+{
+#ifndef _WINDLL
+  if (GetTopWindow())
+    return TRUE;
+  else
+    return FALSE;
+#endif
+#ifdef _WINDLL // Assume initialized if DLL (no way of telling)
+  return TRUE;
+#endif
+}
+
+/*
+ * Get and process a message, returning FALSE if WM_QUIT
+ * received.
+ *
+ */
+bool wxApp::DoMessage(void)
+{
+  if (!::GetMessage(&s_currentMsg, (HWND) NULL, 0, 0))
+  {
+    return FALSE;
+  }
+    
+  // Process the message
+  if (!ProcessMessage((WXMSG *)&s_currentMsg))
+  {
+    ::TranslateMessage(&s_currentMsg);
+    wxApp::sm_lastMessageTime = s_currentMsg.time; /* MATTHEW: timeStamp impl. */
+    ::DispatchMessage(&s_currentMsg);
+  }
+  return TRUE;
+}
+
+/*
+ * Keep trying to process messages until WM_QUIT
+ * received.
+ *
+ * If there are messages to be processed, they will all be
+ * processed and OnIdle will not be called.
+ * When there are no more messages, OnIdle is called.
+ * If OnIdle requests more time,
+ * it will be repeatedly called so long as there are no pending messages.
+ * A 'feature' of this is that once OnIdle has decided that no more processing
+ * is required, then it won't get processing time until further messages
+ * are processed (it'll sit in DoMessage).
+ */
+
+int wxApp::MainLoop(void)
+{
+  m_keepGoing = TRUE;
+  while (m_keepGoing)
+  {
+    while (!::PeekMessage(&s_currentMsg, 0, 0, 0, PM_NOREMOVE) &&
+           ProcessIdle()) {}
+    if (!DoMessage())
+      m_keepGoing = FALSE;
+  }
+
+  return s_currentMsg.wParam;
+}
+
+// Returns TRUE if more time is needed.
+bool wxApp::ProcessIdle(void)
+{
+    wxIdleEvent event;
+    event.SetEventObject(this);
+    ProcessEvent(event);
+
+    return event.MoreRequested();
+}
+
+void wxApp::ExitMainLoop(void)
+{
+  m_keepGoing = FALSE;
+}
+
+bool wxApp::Pending(void)
+{
+  return (::PeekMessage(&s_currentMsg, 0, 0, 0, PM_NOREMOVE) != 0) ;
+}
+
+void wxApp::Dispatch(void)
+{
+    if (!DoMessage())
+      m_keepGoing = FALSE;
+}
+
+/*
+ * Give all windows a chance to preprocess
+ * the message. Some may have accelerator tables, or have
+ * MDI complications.
+ */
+bool wxApp::ProcessMessage(WXMSG *Msg)
+{
+  MSG *msg = (MSG *)Msg;
+
+  HWND hWnd;
+
+  // Anyone for a message? Try youngest descendants first.
+  for (hWnd = msg->hwnd; hWnd != NULL; hWnd = ::GetParent(hWnd))
+  {
+    wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
+    if (wnd)
+    {
+       if (wnd->MSWProcessMessage(Msg))
+         return TRUE;
+
+       // STOP if we've reached the top of the hierarchy!
+//       if (m_topWindow && (wnd == m_topWindow))
+//          return FALSE;
+    }
+  }
+
+  // TODO: Is this now obsolete, given that m_topWindow may not be defined?
+  // Does it do anything useful anyway?
+//  if (m_topWindow && m_topWindow->MSWProcessMessage(Msg))
+//     return TRUE;
+    return FALSE;
+}
+
+void wxApp::OnIdle(wxIdleEvent& event)
+{
+  static bool inOnIdle = FALSE;
+
+  // Avoid recursion (via ProcessEvent default case)
+  if (inOnIdle)
+    return;
+
+  inOnIdle = TRUE;
+
+  // 'Garbage' collection of windows deleted with Close().
+  DeletePendingObjects();
+
+  // Send OnIdle events to all windows
+  bool needMore = SendIdleEvents();
+
+  if (needMore)
+    event.RequestMore(TRUE);
+
+  inOnIdle = FALSE;
+}
+
+// Send idle event to all top-level windows
+bool wxApp::SendIdleEvents(void)
+{
+    bool needMore = FALSE;
+	wxNode* node = wxTopLevelWindows.First();
+	while (node)
+	{
+		wxWindow* win = (wxWindow*) node->Data();
+		if (SendIdleEvents(win))
+            needMore = TRUE;
+
+		node = node->Next();
+	}
+    return needMore;
+}
+
+// Send idle event to window and all subwindows
+bool wxApp::SendIdleEvents(wxWindow* win)
+{
+    bool needMore = FALSE;
+
+	wxIdleEvent event;
+	event.SetEventObject(win);
+	win->ProcessEvent(event);
+
+    if (event.MoreRequested())
+        needMore = TRUE;
+
+	wxNode* node = win->GetChildren()->First();
+	while (node)
+	{
+		wxWindow* win = (wxWindow*) node->Data();
+		if (SendIdleEvents(win))
+            needMore = TRUE;
+
+		node = node->Next();
+	}
+    return needMore ;
+}
+
+// Windows specific. Intercept keyboard input: by default,
+// route it to the active frame or dialog box.
+#if WXWIN_COMPATIBILITY == 2
+bool wxApp::OldOnCharHook(wxKeyEvent& event)
+{
+  wxWindow *win = wxGetActiveWindow();
+  if (win)
+    return win->GetEventHandler()->OldOnCharHook(event);
+  else
+    return FALSE;
+}
+#endif
+
+void wxApp::DeletePendingObjects(void)
+{
+  wxNode *node = wxPendingDelete.First();
+  while (node)
+  {
+    wxObject *obj = (wxObject *)node->Data();
+    
+    delete obj;
+
+    if (wxPendingDelete.Member(obj))
+      delete node;
+
+    // Deleting one object may have deleted other pending
+    // objects, so start from beginning of list again.
+    node = wxPendingDelete.First();
+  }
+}
+
+/*
+// Free up font objects that are not being used at present.
+bool wxApp::DoResourceCleanup(void)
+{
+//  wxDebugMsg("ResourceCleanup\n");
+
+  if (wxTheFontList)
+  {
+    wxNode *node = wxTheFontList->First();
+    while (node)
+    {
+      wxGDIObject *obj = (wxGDIObject *)node->Data();
+      if ((obj->GetResourceHandle() != 0) && (obj->GetResourceUsage() == 0))
+      {
+//        wxDebugMsg("Freeing font %ld (GDI object %d)\n", (long)obj, (int)obj->GetResourceHandle());
+        obj->FreeResource();
+      }
+      node = node->Next();
+    }
+  }
+  if (wxThePenList)
+  {
+    wxNode *node = wxThePenList->First();
+    while (node)
+    {
+      wxGDIObject *obj = (wxGDIObject *)node->Data();
+      if ((obj->GetResourceHandle() != 0) && (obj->GetResourceUsage() == 0))
+      {
+//        wxDebugMsg("Freeing pen %ld (GDI object %d)\n", (long)obj, (int)obj->GetResourceHandle());
+        obj->FreeResource();
+      }
+      node = node->Next();
+    }
+  }
+  if (wxTheBrushList)
+  {
+    wxNode *node = wxTheBrushList->First();
+    while (node)
+    {
+      wxGDIObject *obj = (wxGDIObject *)node->Data();
+      if ((obj->GetResourceHandle() != 0) && (obj->GetResourceUsage() == 0))
+      {
+//        wxDebugMsg("Freeing brush %ld (GDI object %d)\n", (long)obj, (int)obj->GetResourceHandle());
+        obj->FreeResource();
+      }
+      node = node->Next();
+    }
+  }
+
+  SetPendingCleanup(FALSE);
+  return FALSE;
+}
+*/
+
+wxLog* wxApp::CreateLogTarget(void)
+{
+    return new wxLogGui;
+}
+
+wxWindow* wxApp::GetTopWindow(void) const
+{
+    if (m_topWindow)
+        return m_topWindow;
+    else if (wxTopLevelWindows.Number() > 0)
+        return (wxWindow*) wxTopLevelWindows.First()->Data();
+    else
+        return NULL;
+}
+
+void wxExit(void)
+{
+  wxApp::CleanUp();
+  FatalAppExit(0, "Fatal error: exiting");
+}
+
+// Yield to incoming messages
+bool wxYield(void)
+{
+  MSG msg;
+  // We want to go back to the main message loop
+  // if we see a WM_QUIT. (?)
+  while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) && msg.message != WM_QUIT)
+  {
+    if (!wxTheApp->DoMessage())
+      break;
+  }
+
+  return TRUE;
+}
+
+HINSTANCE wxGetInstance()
+{
+	return wxhInstance;
+}
+
+// For some reason, with MSVC++ 1.5, WinMain isn't linked in properly
+// if in a separate file. So include it here to ensure it's linked.
+#if (defined(_MSC_VER) && !defined(__WIN32__)) || defined(__GNUWIN32__)
+#include "main.cpp"
+#endif
+
+#undef IN_WX_MAIN_CPP
+
diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp
new file mode 100644
index 0000000000..e535b7c0b3
--- /dev/null
+++ b/src/msw/bitmap.cpp
@@ -0,0 +1,808 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        bitmap.cpp
+// Purpose:     wxBitmap
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "bitmap.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/list.h"
+#include "wx/utils.h"
+#include "wx/app.h"
+#include "wx/palette.h"
+#include "wx/bitmap.h"
+#include "wx/icon.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "assert.h"
+
+#if USE_XPM_IN_MSW
+#define FOR_MSW 1
+#include "..\..\contrib\wxxpm\libxpm.34b\lib\xpm34.h"
+#endif
+
+#include "wx/msw/dib.h"
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
+IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
+#endif
+
+wxBitmapRefData::wxBitmapRefData(void)
+{
+  m_ok = FALSE;
+  m_width = 0;
+  m_height = 0;
+  m_depth = 0;
+  m_quality = 0;
+  m_hBitmap = 0 ;
+  m_selectedInto = NULL;
+  m_numColors = 0;
+  m_bitmapMask = NULL;
+}
+
+wxBitmapRefData::~wxBitmapRefData(void)
+{
+  if (m_selectedInto)
+  {
+    char buf[200];
+    sprintf(buf, "Bitmap was deleted without selecting out of wxMemoryDC %X.", (unsigned int) m_selectedInto);
+    wxFatalError(buf);
+  }
+  if (m_hBitmap)
+  {
+    DeleteObject((HBITMAP) m_hBitmap);
+  }
+  m_hBitmap = 0 ;
+
+  if (m_bitmapMask)
+    delete m_bitmapMask;
+  m_bitmapMask = NULL;
+}
+
+wxList wxBitmap::sm_handlers;
+
+wxBitmap::wxBitmap(void)
+{
+  m_refData = NULL; // new wxBitmapRefData;
+
+  if ( wxTheBitmapList )
+    wxTheBitmapList->AddBitmap(this);
+}
+
+wxBitmap::~wxBitmap(void)
+{
+    if (wxTheBitmapList)
+        wxTheBitmapList->DeleteObject(this);
+}
+
+bool wxBitmap::FreeResource(bool force)
+{
+  if ( !M_BITMAPDATA )
+	return FALSE;
+
+  if (M_BITMAPDATA->m_selectedInto)
+  {
+    char buf[200];
+    sprintf(buf, "Bitmap %X was deleted without selecting out of wxMemoryDC %X.", (unsigned int) this, (unsigned int) M_BITMAPDATA->m_selectedInto);
+    wxFatalError(buf);
+  }
+  if (M_BITMAPDATA->m_hBitmap)
+  {
+    DeleteObject((HBITMAP) M_BITMAPDATA->m_hBitmap);
+  }
+  M_BITMAPDATA->m_hBitmap = 0 ;
+
+/*
+  if (M_BITMAPDATA->m_bitmapPalette)
+    delete M_BITMAPDATA->m_bitmapPalette;
+
+  M_BITMAPDATA->m_bitmapPalette = NULL ;
+*/
+
+  return TRUE;
+}
+
+
+wxBitmap::wxBitmap(const char bits[], const int the_width, const int the_height, const int no_bits)
+{
+  m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_width = the_width ;
+  M_BITMAPDATA->m_height = the_height ;
+  M_BITMAPDATA->m_depth = no_bits ;
+  M_BITMAPDATA->m_numColors = 0;
+
+  M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateBitmap(the_width, the_height, no_bits, 1, bits);
+
+  if (M_BITMAPDATA->m_hBitmap)
+    M_BITMAPDATA->m_ok = TRUE;
+  else
+    M_BITMAPDATA->m_ok = FALSE;
+
+  M_BITMAPDATA->m_selectedInto = NULL;
+
+  if ( wxTheBitmapList )
+    wxTheBitmapList->AddBitmap(this);
+}
+
+wxBitmap::wxBitmap(const int w, const int h, const int d)
+{
+  (void)Create(w, h, d);
+
+  if ( wxTheBitmapList )
+    wxTheBitmapList->AddBitmap(this);
+}
+
+wxBitmap::wxBitmap(void *data, const long type, const int width, const int height, const int depth)
+{
+  (void) Create(data, type, width, height, depth);
+
+  if ( wxTheBitmapList )
+    wxTheBitmapList->AddBitmap(this);
+}
+
+wxBitmap::wxBitmap(const wxString& filename, const long type)
+{
+  LoadFile(filename, (int)type);
+
+  if ( wxTheBitmapList )
+    wxTheBitmapList->AddBitmap(this);
+}
+
+#if USE_XPM_IN_MSW
+// Create from data
+wxBitmap::wxBitmap(const char **data, wxItem *WXUNUSED(anItem))
+{
+	(void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
+}
+#endif
+
+bool wxBitmap::Create(const int w, const int h, const int d)
+{
+  UnRef();
+
+  m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_width = w;
+  M_BITMAPDATA->m_height = h;
+  M_BITMAPDATA->m_depth = d;
+
+  if (d > 0)
+  {
+    M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateBitmap(w, h, d, 1, NULL);
+  }
+  else
+  {
+    HDC dc = GetDC(NULL);
+    M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateCompatibleBitmap(dc, w, h);
+    ReleaseDC(NULL, dc);
+    M_BITMAPDATA->m_depth = wxDisplayDepth();
+  }
+  if (M_BITMAPDATA->m_hBitmap)
+    M_BITMAPDATA->m_ok = TRUE;
+  else
+    M_BITMAPDATA->m_ok = FALSE;
+  return M_BITMAPDATA->m_ok;
+}
+
+bool wxBitmap::LoadFile(const wxString& filename, const long type)
+{
+  UnRef();
+
+  m_refData = new wxBitmapRefData;
+
+  wxBitmapHandler *handler = FindHandler(type);
+
+  if ( handler )
+	return handler->LoadFile(this, filename, type, -1, -1);
+  else
+	return FALSE;
+}
+
+bool wxBitmap::Create(void *data, const long type, const int width, const int height, const int depth)
+{
+  UnRef();
+
+  m_refData = new wxBitmapRefData;
+
+  wxBitmapHandler *handler = FindHandler(type);
+
+  if ( handler )
+	return handler->Create(this, data, type, width, height, depth);
+  else
+	return FALSE;
+}
+
+bool wxBitmap::SaveFile(const wxString& filename, const int type, const wxPalette *palette)
+{
+  wxBitmapHandler *handler = FindHandler(type);
+
+  if ( handler )
+	return handler->SaveFile(this, filename, type, palette);
+  else
+	return FALSE;
+}
+
+void wxBitmap::SetWidth(int w)
+{
+  if (!M_BITMAPDATA)
+	m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_width = w;
+}
+
+void wxBitmap::SetHeight(int h)
+{
+  if (!M_BITMAPDATA)
+	m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_height = h;
+}
+
+void wxBitmap::SetDepth(int d)
+{
+  if (!M_BITMAPDATA)
+	m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_depth = d;
+}
+
+void wxBitmap::SetQuality(int q)
+{
+  if (!M_BITMAPDATA)
+	m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_quality = q;
+}
+
+void wxBitmap::SetOk(bool isOk)
+{
+  if (!M_BITMAPDATA)
+	m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_ok = isOk;
+}
+
+void wxBitmap::SetPalette(const wxPalette& palette)
+{
+  if (!M_BITMAPDATA)
+	m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_bitmapPalette = palette ;
+}
+
+void wxBitmap::SetMask(wxMask *mask)
+{
+  if (!M_BITMAPDATA)
+	m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_bitmapMask = mask ;
+}
+
+void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
+{
+  if (!M_BITMAPDATA)
+	m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_hBitmap = bmp;
+}
+
+void wxBitmap::AddHandler(wxBitmapHandler *handler)
+{
+	sm_handlers.Append(handler);
+}
+
+void wxBitmap::InsertHandler(wxBitmapHandler *handler)
+{
+	sm_handlers.Insert(handler);
+}
+
+bool wxBitmap::RemoveHandler(const wxString& name)
+{
+	wxBitmapHandler *handler = FindHandler(name);
+	if ( handler )
+	{
+		sm_handlers.DeleteObject(handler);
+		return TRUE;
+	}
+	else
+		return FALSE;
+}
+
+wxBitmapHandler *wxBitmap::FindHandler(const wxString& name)
+{
+	wxNode *node = sm_handlers.First();
+	while ( node )
+	{
+		wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
+		if ( handler->GetName() == name )
+			return handler;
+		node = node->Next();
+	}
+	return NULL;
+}
+
+wxBitmapHandler *wxBitmap::FindHandler(const wxString& extension, long bitmapType)
+{
+	wxNode *node = sm_handlers.First();
+	while ( node )
+	{
+		wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
+		if ( handler->GetExtension() == extension &&
+		      (bitmapType == -1 || handler->GetType() == bitmapType) )
+			return handler;
+		node = node->Next();
+	}
+	return NULL;
+}
+
+wxBitmapHandler *wxBitmap::FindHandler(long bitmapType)
+{
+	wxNode *node = sm_handlers.First();
+	while ( node )
+	{
+		wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
+		if (handler->GetType() == bitmapType)
+			return handler;
+		node = node->Next();
+	}
+	return NULL;
+}
+
+/*
+ * wxMask
+ */
+
+wxMask::wxMask(void)
+{
+    m_maskBitmap = 0;
+}
+
+// Construct a mask from a bitmap and a colour indicating
+// the transparent area
+wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
+{
+    m_maskBitmap = 0;
+	Create(bitmap, colour);
+}
+
+// Construct a mask from a bitmap and a palette index indicating
+// the transparent area
+wxMask::wxMask(const wxBitmap& bitmap, const int paletteIndex)
+{
+    m_maskBitmap = 0;
+	Create(bitmap, paletteIndex);
+}
+
+// Construct a mask from a mono bitmap (copies the bitmap).
+wxMask::wxMask(const wxBitmap& bitmap)
+{
+    m_maskBitmap = 0;
+	Create(bitmap);
+}
+
+wxMask::~wxMask(void)
+{
+    if ( m_maskBitmap )
+        ::DeleteObject((HBITMAP) m_maskBitmap);
+}
+
+// Create a mask from a mono bitmap (copies the bitmap).
+bool wxMask::Create(const wxBitmap& bitmap)
+{
+    if ( m_maskBitmap )
+	{
+		::DeleteObject((HBITMAP) m_maskBitmap);
+		m_maskBitmap = 0;
+	}
+	if (!bitmap.Ok() || bitmap.GetDepth() != 1)
+	{
+		return FALSE;
+	}
+	m_maskBitmap = (WXHBITMAP) CreateBitmap(
+					bitmap.GetWidth(),
+					bitmap.GetHeight(),
+					1, 1, 0
+					);
+	HDC srcDC = CreateCompatibleDC(0);
+	SelectObject(srcDC, (HBITMAP) bitmap.GetHBITMAP());
+	HDC destDC = CreateCompatibleDC(0);
+	SelectObject(destDC, (HBITMAP) m_maskBitmap);
+	BitBlt(destDC, 0, 0, bitmap.GetWidth(), bitmap.GetHeight(), srcDC, 0, 0, SRCCOPY);
+	SelectObject(srcDC, 0);
+	DeleteDC(srcDC);
+	SelectObject(destDC, 0);
+	DeleteDC(destDC);
+	return TRUE;
+}
+
+// Create a mask from a bitmap and a palette index indicating
+// the transparent area
+bool wxMask::Create(const wxBitmap& bitmap, const int paletteIndex)
+{
+    if ( m_maskBitmap )
+	{
+		::DeleteObject((HBITMAP) m_maskBitmap);
+		m_maskBitmap = 0;
+	}
+	if (bitmap.Ok() && bitmap.GetPalette()->Ok())
+	{
+		unsigned char red, green, blue;
+		if (bitmap.GetPalette()->GetRGB(paletteIndex, &red, &green, &blue))
+		{
+			wxColour transparentColour(red, green, blue);
+			return Create(bitmap, transparentColour);
+		}
+	}
+	return FALSE;
+}
+
+// Create a mask from a bitmap and a colour indicating
+// the transparent area
+bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
+{
+    if ( m_maskBitmap )
+	{
+		::DeleteObject((HBITMAP) m_maskBitmap);
+		m_maskBitmap = 0;
+	}
+	if (!bitmap.Ok())
+	{
+		return FALSE;
+	}
+
+	// scan the bitmap for the transparent colour and set
+	// the corresponding pixels in the mask to BLACK and
+	// the rest to WHITE
+	COLORREF maskColour = RGB(colour.Red(), colour.Green(), colour.Blue());
+	m_maskBitmap = (WXHBITMAP) ::CreateBitmap(
+					bitmap.GetWidth(),
+					bitmap.GetHeight(),
+					1, 1, 0
+					);
+	HDC srcDC = ::CreateCompatibleDC(0);
+	::SelectObject(srcDC, (HBITMAP) bitmap.GetHBITMAP());
+	HDC destDC = ::CreateCompatibleDC(0);
+	::SelectObject(destDC, (HBITMAP) m_maskBitmap);
+
+	// this is not very efficient, but I can't think
+	// of a better way of doing it
+	for (int w = 0; w < bitmap.GetWidth(); w++)
+	{
+		for (int h = 0; h < bitmap.GetHeight(); h++)
+		{
+			COLORREF col = GetPixel(srcDC, w, h);
+			if (col == maskColour)
+			{
+				::SetPixel(destDC, w, h, RGB(0, 0, 0));
+			}
+			else
+			{
+				::SetPixel(destDC, w, h, RGB(255, 255, 255));
+			}
+		}
+	}
+	::SelectObject(srcDC, 0);
+	::DeleteDC(srcDC);
+	::SelectObject(destDC, 0);
+	::DeleteDC(destDC);
+	return TRUE;
+}
+
+/*
+ * wxBitmapHandler
+ */
+
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
+
+bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, const long type, const int width, const int height, const int depth)
+{
+	return FALSE;
+}
+
+bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const long type,
+    int desiredWidth, int desiredHeight)
+{
+	return FALSE;
+}
+
+bool wxBitmapHandler::SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *palette)
+{
+	return FALSE;
+}
+
+/*
+ * Standard handlers
+ */
+
+class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler)
+public:
+  inline wxBMPResourceHandler(void)
+  {
+	m_name = "Windows bitmap resource";
+	m_extension = "";
+	m_type = wxBITMAP_TYPE_BMP_RESOURCE;
+  };
+
+  virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+      int desiredWidth, int desiredHeight);
+};
+IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler)
+
+bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+    int desiredWidth, int desiredHeight)
+{
+    // TODO: load colourmap.
+    M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ::LoadBitmap(wxGetInstance(), name);
+    if (M_BITMAPHANDLERDATA->m_hBitmap)
+    {
+      M_BITMAPHANDLERDATA->m_ok = TRUE;
+      BITMAP bm;
+      GetObject((HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap, sizeof(BITMAP), (LPSTR) &bm);
+      M_BITMAPHANDLERDATA->m_width = bm.bmWidth;
+      M_BITMAPHANDLERDATA->m_height = bm.bmHeight;
+      M_BITMAPHANDLERDATA->m_depth = bm.bmPlanes;
+      return TRUE;
+    }
+	return FALSE;
+}
+
+class WXDLLEXPORT wxBMPFileHandler: public wxBitmapHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxBMPFileHandler)
+public:
+  inline wxBMPFileHandler(void)
+  {
+	m_name = "Windows bitmap file";
+	m_extension = "bmp";
+	m_type = wxBITMAP_TYPE_BMP;
+  };
+
+  virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+      int desiredWidth, int desiredHeight);
+  virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *palette = NULL);
+};
+IMPLEMENT_DYNAMIC_CLASS(wxBMPFileHandler, wxBitmapHandler)
+
+bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+    int desiredWidth, int desiredHeight)
+{
+#if USE_IMAGE_LOADING_IN_MSW
+    wxPalette *palette = NULL;
+    bool success = FALSE;
+/*
+    if (type & wxBITMAP_DISCARD_COLOURMAP)
+      success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap);
+    else
+*/
+    success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0);
+    if (!success && palette)
+    {
+      delete palette;
+      palette = NULL;
+    }
+    if (palette)
+      M_BITMAPHANDLERDATA->m_bitmapPalette = *palette;
+    return success;
+#else
+	return FALSE;
+#endif
+}
+
+bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *pal)
+{
+#if USE_IMAGE_LOADING_IN_MSW
+    wxPalette *actualPalette = (wxPalette *)pal;
+    if (!actualPalette && (!M_BITMAPHANDLERDATA->m_bitmapPalette.IsNull()))
+      actualPalette = & (M_BITMAPHANDLERDATA->m_bitmapPalette);
+    return (wxSaveBitmap(WXSTRINGCAST name, bitmap, actualPalette) != 0);
+#else
+	return FALSE;
+#endif
+}
+
+class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxXPMFileHandler)
+public:
+  inline wxXPMFileHandler(void)
+  {
+	m_name = "XPM bitmap file";
+	m_extension = "xpm";
+	m_type = wxBITMAP_TYPE_XPM;
+  };
+
+  virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+    int desiredWidth = -1, int desiredHeight = -1);
+  virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *palette = NULL);
+};
+IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler)
+
+bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+    int desiredWidth, int desiredHeight)
+{
+#if USE_XPM_IN_MSW
+    XImage *ximage;
+    XpmAttributes xpmAttr;
+    HDC     dc;
+
+    M_BITMAPHANDLERDATA->m_ok = FALSE;
+    dc = CreateCompatibleDC(NULL);
+    if (dc)
+    {
+      xpmAttr.valuemask = XpmReturnPixels;
+      int errorStatus = XpmReadFileToImage(&dc, WXSTRINGCAST name, &ximage, (XImage **) NULL, &xpmAttr);
+      DeleteDC(dc);
+      if (errorStatus == XpmSuccess)
+      {
+	M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap;
+
+	BITMAP  bm;
+	GetObject((HBITMAP) m_hBitmap, sizeof(bm), (LPSTR) & bm);
+
+	M_BITMAPHANDLERDATA->m_width = (bm.bmWidth);
+	M_BITMAPHANDLERDATA->m_height = (bm.bmHeight);
+	M_BITMAPHANDLERDATA->m_depth = (bm.bmPlanes * bm.bmBitsPixel);
+	M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
+        XpmFreeAttributes(&xpmAttr);
+	XImageFree(ximage);
+	
+	M_BITMAPHANDLERDATA->m_ok = TRUE;
+	return TRUE;
+      }
+      else
+      {
+        M_BITMAPHANDLERDATA->m_ok = FALSE;
+        return FALSE;
+      }
+    }
+#else
+	return FALSE;
+#endif
+}
+
+bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *palette)
+{
+#if USE_XPM_IN_MSW
+      HDC     dc = NULL;
+
+      Visual *visual = NULL;
+      XImage  ximage;
+
+      dc = CreateCompatibleDC(NULL);
+      if (dc)
+      {
+        if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
+        { /* for following SetPixel */
+          /* fill the XImage struct 'by hand' */
+	  ximage.width = M_BITMAPHANDLERDATA->m_width; ximage.height = M_BITMAPHANDLERDATA->m_height;
+	  ximage.depth = M_BITMAPHANDLERDATA->m_depth; ximage.bitmap = M_BITMAPHANDLERDATA->m_hBitmap;
+	  int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name,
+						  &ximage, (XImage *) NULL, (XpmAttributes *) NULL);
+
+          if (dc)
+	    DeleteDC(dc);
+
+	  if (errorStatus == XpmSuccess)
+	    return TRUE;		/* no error */
+	  else
+	    return FALSE;
+        } else return FALSE;
+      } else return FALSE;
+#else
+	return FALSE;
+#endif
+}
+
+class WXDLLEXPORT wxXPMDataHandler: public wxBitmapHandler
+{
+  DECLARE_DYNAMIC_CLASS(wxXPMDataHandler)
+public:
+  inline wxXPMDataHandler(void)
+  {
+	m_name = "XPM bitmap data";
+	m_extension = "xpm";
+	m_type = wxBITMAP_TYPE_XPM_DATA;
+  };
+
+  virtual bool Create(wxBitmap *bitmap, void *data, const long flags, const int width, const int height, const int depth = 1);
+};
+IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler)
+
+bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, const long flags, const int width, const int height, const int depth)
+{
+#if USE_XPM_IN_MSW
+  XImage *ximage;
+  int     ErrorStatus;
+  XpmAttributes xpmAttr;
+  HDC     dc;
+
+  M_BITMAPHANDLERDATA->m_ok = FALSE;
+  M_BITMAPHANDLERDATA->m_numColors = 0;
+
+  dc = CreateCompatibleDC(NULL);	/* memory DC */
+
+  if (dc)
+  {
+    xpmAttr.valuemask = XpmReturnInfos;	/* get infos back */
+    ErrorStatus = XpmCreateImageFromData(&dc, (char **)data,
+         &ximage, (XImage **) NULL, &xpmAttr);
+
+    if (ErrorStatus == XpmSuccess)
+    {
+      /* ximage is malloced and contains bitmap and attributes */
+      M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap;
+
+      BITMAP  bm;
+      GetObject((HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap, sizeof(bm), (LPSTR) & bm);
+
+      M_BITMAPHANDLERDATA->m_width = (bm.bmWidth);
+      M_BITMAPHANDLERDATA->m_height = (bm.bmHeight);
+      M_BITMAPHANDLERDATA->m_depth = (bm.bmPlanes * bm.bmBitsPixel);
+      M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
+      XpmFreeAttributes(&xpmAttr);
+
+      XImageFree(ximage);	// releases the malloc, but does not detroy
+			// the bitmap
+      M_BITMAPHANDLERDATA->m_ok = TRUE;
+      DeleteDC(dc);
+
+    } else
+    {
+      M_BITMAPHANDLERDATA->m_ok = FALSE;
+//    XpmDebugError(ErrorStatus, NULL);
+      DeleteDC(dc);
+	  return FALSE;
+    }
+  }
+#else
+  return FALSE;
+#endif
+}
+
+void wxBitmap::CleanUpHandlers(void)
+{
+	wxNode *node = sm_handlers.First();
+	while ( node )
+	{
+		wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
+		wxNode *next = node->Next();
+		delete handler;
+		delete node;
+		node = next;
+	}
+}
+
+void wxBitmap::InitStandardHandlers(void)
+{
+	AddHandler(new wxBMPResourceHandler);
+	AddHandler(new wxBMPFileHandler);
+	AddHandler(new wxXPMFileHandler);
+	AddHandler(new wxXPMDataHandler);
+	AddHandler(new wxICOResourceHandler);
+	AddHandler(new wxICOFileHandler);
+}
+
+
+
diff --git a/src/msw/bmpbuttn.cpp b/src/msw/bmpbuttn.cpp
new file mode 100644
index 0000000000..7d9c245c29
--- /dev/null
+++ b/src/msw/bmpbuttn.cpp
@@ -0,0 +1,265 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        bmpbuttn.cpp
+// Purpose:     wxBitmapButton
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "bmpbuttn.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/bmpbuttn.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
+#endif
+
+#define BUTTON_HEIGHT_FACTOR (EDIT_CONTROL_FACTOR * 1.1)
+
+bool wxBitmapButton::Create(wxWindow *parent, const wxWindowID id, const wxBitmap& bitmap,
+           const wxPoint& pos,
+           const wxSize& size, const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  m_buttonBitmap = bitmap;
+  SetName(name);
+  SetValidator(validator);
+
+  parent->AddChild(this);
+
+  m_backgroundColour = parent->GetDefaultBackgroundColour() ;
+  m_foregroundColour = parent->GetDefaultForegroundColour() ;
+  m_windowStyle = style;
+  m_marginX = 0;
+  m_marginY = 0;
+
+  if ( style & wxBU_AUTODRAW )
+  {
+	m_marginX = wxDEFAULT_BUTTON_MARGIN;
+	m_marginY = wxDEFAULT_BUTTON_MARGIN;
+  }
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  if (id == -1)
+    m_windowId = NewControlId();
+  else
+    m_windowId = id;
+
+  if ( width == -1 && bitmap.Ok())
+	width = bitmap.GetWidth() + 2*m_marginX;
+
+  if ( height == -1 && bitmap.Ok())
+	height = bitmap.GetHeight() + 2*m_marginY;
+
+  HWND wx_button =
+    CreateWindowEx(0, "BUTTON", "", BS_OWNERDRAW | WS_TABSTOP | WS_CHILD,
+                    0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                    wxGetInstance(), NULL);
+
+  m_hWnd = (WXHWND)wx_button;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND)wx_button);
+
+  // TODO? If in future we have a facility for having a label as well
+  // as a bitmap, set the font.
+//  SetFont(parent->GetFont()) ;
+
+  SetSize(x, y, width, height);
+  ShowWindow(wx_button, SW_SHOW);
+
+  return TRUE;
+}
+
+void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
+{
+  m_buttonBitmap = bitmap;
+}
+
+bool wxBitmapButton::MSWOnDraw(WXDRAWITEMSTRUCT *item)
+{
+	long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE);
+#if defined(__WIN95__)
+	if (style & BS_BITMAP)
+	{
+		// Should we call Default() here?
+//		Default();
+
+		// Let default procedure draw the bitmap, which is defined
+		// in the Windows resource.
+		return FALSE;
+	}
+#endif
+
+    LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) item;
+
+	wxBitmap* bitmap = &m_buttonBitmap;
+
+	UINT state = lpDIS->itemState;
+	if ((state & ODS_SELECTED) && m_buttonBitmapSelected.Ok())
+		bitmap = &m_buttonBitmapSelected;
+	else if ((state & ODS_FOCUS) && m_buttonBitmapFocus.Ok())
+		bitmap = &m_buttonBitmapFocus;
+	else if ((state & ODS_DISABLED) && m_buttonBitmapDisabled.Ok())
+		bitmap = &m_buttonBitmapDisabled;
+
+	if ( !bitmap->Ok() )
+		return FALSE;
+
+	HDC hDC = lpDIS->hDC;
+	HDC memDC = ::CreateCompatibleDC(hDC);
+
+	HBITMAP old = ::SelectObject(memDC, (HBITMAP) bitmap->GetHBITMAP());
+
+	if (!old)
+		return FALSE;
+
+	RECT rect = lpDIS->rcItem;
+
+	int x = lpDIS->rcItem.left;
+	int y = lpDIS->rcItem.top;
+	int width = lpDIS->rcItem.right - x;
+	int height = lpDIS->rcItem.bottom - y;
+
+	// Draw the face, if auto-drawing
+	if ( GetWindowStyleFlag() & wxBU_AUTODRAW )
+		DrawFace((WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom,
+            ((state & ODS_SELECTED) == ODS_SELECTED));
+
+	// Centre the bitmap in the control area
+	int x1 = (int) (x + ((width - bitmap->GetWidth()) / 2));
+	int y1 = (int) (y + ((height - bitmap->GetHeight()) / 2));
+
+	if ( (state & ODS_SELECTED) && (GetWindowStyleFlag() & wxBU_AUTODRAW) )
+	{
+		x1 ++;
+		y1 ++;
+	}
+
+	::BitBlt(hDC, x1, y1, bitmap->GetWidth(), bitmap->GetHeight(), memDC, 0, 0, SRCCOPY);
+
+	if ( (state & ODS_DISABLED) && (GetWindowStyleFlag() & wxBU_AUTODRAW) )
+		DrawButtonDisable( (WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, TRUE ) ;
+	else if ( (state & ODS_FOCUS) && (GetWindowStyleFlag() & wxBU_AUTODRAW) )
+		DrawButtonFocus( (WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, ((state & ODS_SELECTED) == ODS_SELECTED));
+
+	::SelectObject(memDC, old);
+
+    ::DeleteDC(memDC);
+
+    return TRUE;
+}
+
+void wxBitmapButton::DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel )
+{
+  HPEN	oldp;
+  HBRUSH	oldb ;
+
+  HPEN penBorder;
+  HPEN penLight;
+  HPEN penShadow;
+  HBRUSH brushFace;
+  COLORREF ms_color;
+
+	ms_color = GetSysColor(COLOR_WINDOWFRAME) ;
+	penBorder = CreatePen(PS_SOLID,0,ms_color) ;
+
+	ms_color = GetSysColor(COLOR_BTNSHADOW) ;
+	penShadow = CreatePen(PS_SOLID,0,ms_color) ;
+
+	ms_color = GetSysColor(COLOR_BTNHIGHLIGHT) ;
+	penLight = CreatePen(PS_SOLID,0,ms_color) ;
+
+	ms_color = GetSysColor(COLOR_BTNFACE) ;
+	brushFace = CreateSolidBrush(ms_color) ;
+
+	oldp = SelectObject( (HDC) dc, GetStockObject( NULL_PEN ) ) ;
+	oldb = SelectObject( (HDC) dc, brushFace ) ;
+	Rectangle( (HDC) dc, left, top, right, bottom ) ;
+	SelectObject( (HDC) dc, penBorder) ;
+        MoveToEx((HDC) dc,left+1,top,NULL);LineTo((HDC) dc,right-1,top);
+        MoveToEx((HDC) dc,left,top+1,NULL);LineTo((HDC) dc,left,bottom-1);
+        MoveToEx((HDC) dc,left+1,bottom-1,NULL);LineTo((HDC) dc,right-1,bottom-1);
+        MoveToEx((HDC) dc,right-1,top+1,NULL);LineTo((HDC) dc,right-1,bottom-1);
+
+	SelectObject( (HDC) dc, penShadow) ;
+	if (sel)
+	{
+		MoveToEx((HDC) dc,left+1	,bottom-2	,NULL) ;
+		LineTo((HDC) dc,  left+1	,top+1) ;
+		LineTo((HDC) dc,  right-2	,top+1) ;
+	}
+	else
+	{
+		MoveToEx((HDC) dc,left+1	,bottom-2	,NULL) ;
+		LineTo((HDC) dc,  right-2	,bottom-2) ;
+		LineTo((HDC) dc,  right-2	,top) ;
+		MoveToEx((HDC) dc,left+2	,bottom-3	,NULL) ;
+		LineTo((HDC) dc,  right-3	,bottom-3) ;
+		LineTo((HDC) dc,  right-3	,top+1) ;
+
+		SelectObject( (HDC) dc, penLight) ;
+
+		MoveToEx((HDC) dc,left+1	,bottom-2	,NULL) ;
+		LineTo((HDC) dc,  left+1	,top+1) ;
+		LineTo((HDC) dc,  right-2	,top+1) ;
+	}
+	SelectObject((HDC) dc,oldp) ;
+	SelectObject((HDC) dc,oldb) ;
+
+  DeleteObject(penBorder);
+  DeleteObject(penLight);
+  DeleteObject(penShadow);
+  DeleteObject(brushFace);
+}
+
+#define FOCUS_MARGIN 6
+
+void wxBitmapButton::DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel )
+{
+	RECT rect;
+	rect.left = left;
+	rect.top = top;
+	rect.right = right;
+	rect.bottom = bottom;
+	InflateRect( &rect, - FOCUS_MARGIN, - FOCUS_MARGIN ) ;
+	if ( sel )
+		OffsetRect( &rect, 1, 1 ) ;
+	DrawFocusRect( (HDC) dc, &rect ) ;
+}
+
+extern HBRUSH wxDisableButtonBrush;
+void wxBitmapButton::DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg )
+{
+	HBRUSH	old = SelectObject( (HDC) dc, wxDisableButtonBrush ) ;
+
+	if ( with_marg )
+		::PatBlt( (HDC) dc, left + m_marginX, top + m_marginY,
+			right - 2 * m_marginX, bottom - 2 * m_marginY,
+				0xfa0089ul ) ;
+	else	::PatBlt( (HDC) dc, left, top, right, bottom, 0xfa0089ul ) ;
+
+	::SelectObject( (HDC) dc, old ) ;
+}
+
diff --git a/src/msw/brush.cpp b/src/msw/brush.cpp
new file mode 100644
index 0000000000..2b34ed2f23
--- /dev/null
+++ b/src/msw/brush.cpp
@@ -0,0 +1,263 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        brush.cpp
+// Purpose:     wxBrush
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "brush.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/list.h"
+#include "wx/utils.h"
+#include "wx/app.h"
+#include "wx/brush.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#include "assert.h"
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
+#endif
+
+wxBrushRefData::wxBrushRefData(void)
+{
+  m_style = wxSOLID;
+//  m_stipple = NULL ;
+  m_hBrush = 0;
+}
+
+wxBrushRefData::~wxBrushRefData(void)
+{
+	if ( m_hBrush )
+		::DeleteObject((HBRUSH) m_hBrush);
+}
+
+// Brushes
+wxBrush::wxBrush(void)
+{
+  if ( wxTheBrushList )
+    wxTheBrushList->AddBrush(this);
+}
+
+wxBrush::~wxBrush()
+{
+    if (wxTheBrushList)
+        wxTheBrushList->RemoveBrush(this);
+}
+
+wxBrush::wxBrush(const wxColour& col, const int Style)
+{
+  m_refData = new wxBrushRefData;
+
+  M_BRUSHDATA->m_colour = col;
+  M_BRUSHDATA->m_style = Style;
+  M_BRUSHDATA->m_hBrush = 0;
+
+  RealizeResource();
+
+  if ( wxTheBrushList )
+    wxTheBrushList->AddBrush(this);
+}
+
+wxBrush::wxBrush(const wxString& col, const int Style)
+{
+  m_refData = new wxBrushRefData;
+
+  M_BRUSHDATA->m_colour = col;
+  M_BRUSHDATA->m_style = Style;
+  M_BRUSHDATA->m_hBrush = 0;
+
+  RealizeResource();
+
+  if ( wxTheBrushList )
+    wxTheBrushList->AddBrush(this);
+}
+
+wxBrush::wxBrush(const wxBitmap& stipple)
+{
+  m_refData = new wxBrushRefData;
+
+  M_BRUSHDATA->m_style = wxSTIPPLE;
+  M_BRUSHDATA->m_stipple = stipple;
+  M_BRUSHDATA->m_hBrush = 0;
+
+  RealizeResource();
+
+  if ( wxTheBrushList )
+    wxTheBrushList->AddBrush(this);
+}
+
+bool wxBrush::RealizeResource(void) 
+{
+  if (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0))
+  {
+    if (M_BRUSHDATA->m_style==wxTRANSPARENT)
+    {
+      M_BRUSHDATA->m_hBrush = (WXHBRUSH) ::GetStockObject(NULL_BRUSH);
+      return TRUE;
+    }
+    COLORREF ms_colour = 0 ;
+
+    ms_colour = M_BRUSHDATA->m_colour.GetPixel() ;
+
+    switch (M_BRUSHDATA->m_style)
+    {
+/****
+    // Don't reset cbrush, wxTRANSPARENT is handled by wxBrush::SelectBrush()
+    // this could save (many) time if frequently switching from
+    // wxSOLID to wxTRANSPARENT, because Create... is not always called!!
+    //
+    // NB August 95: now create and select a Null brush instead.
+    // This could be optimized as above.
+    case wxTRANSPARENT:
+      M_BRUSHDATA->m_hBrush = NULL;  // Must always select a suitable background brush
+                      // - could choose white always for a quick solution
+      break;
+***/
+      case wxBDIAGONAL_HATCH:
+        M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_BDIAGONAL,ms_colour) ;
+        break ;
+      case wxCROSSDIAG_HATCH:
+        M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_DIAGCROSS,ms_colour) ;
+        break ;
+      case wxFDIAGONAL_HATCH:
+        M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_FDIAGONAL,ms_colour) ;
+        break ;
+      case wxCROSS_HATCH:
+        M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_CROSS,ms_colour) ;
+        break ;
+      case wxHORIZONTAL_HATCH:
+        M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_HORIZONTAL,ms_colour) ;
+        break ;
+      case wxVERTICAL_HATCH:
+        M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_VERTICAL,ms_colour) ;
+        break ;
+      case wxSTIPPLE:
+        if (M_BRUSHDATA->m_stipple.Ok())
+          M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreatePatternBrush((HBITMAP) M_BRUSHDATA->m_stipple.GetHBITMAP()) ;
+        else
+          M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateSolidBrush(ms_colour) ;
+        break ;
+      case wxSOLID:
+      default:
+        M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateSolidBrush(ms_colour) ;
+        break;
+    }
+#ifdef DEBUG_CREATE
+    if (M_BRUSHDATA->m_hBrush==NULL) wxError("Cannot create brush","Internal error") ;
+#endif
+    return TRUE;
+  }
+  else
+    return FALSE;
+}
+
+WXHANDLE wxBrush::GetResourceHandle(void)
+{
+  return (WXHANDLE) M_BRUSHDATA->m_hBrush;
+}
+
+bool wxBrush::FreeResource(bool force)
+{
+  if (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush != 0))
+  {
+    DeleteObject((HBRUSH) M_BRUSHDATA->m_hBrush);
+    M_BRUSHDATA->m_hBrush = 0;
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+/*
+bool wxBrush::UseResource(void)
+{
+  IncrementResourceUsage();
+  return TRUE;
+}
+
+bool wxBrush::ReleaseResource(void)
+{
+  DecrementResourceUsage();
+  return TRUE;
+}
+*/
+
+bool wxBrush::IsFree(void)
+{
+  return (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0));
+}
+
+void wxBrush::SetColour(const wxColour& col)
+{
+  if ( !M_BRUSHDATA )
+	m_refData = new wxBrushRefData;
+
+  M_BRUSHDATA->m_colour = col;
+
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxBrush::SetColour(const wxString& col)
+{
+  if ( !M_BRUSHDATA )
+	m_refData = new wxBrushRefData;
+
+  M_BRUSHDATA->m_colour = col;
+
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxBrush::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
+{
+  if ( !M_BRUSHDATA )
+	m_refData = new wxBrushRefData;
+
+  M_BRUSHDATA->m_colour.Set(r, g, b);
+
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxBrush::SetStyle(const int Style)
+{
+  if ( !M_BRUSHDATA )
+	m_refData = new wxBrushRefData;
+
+  M_BRUSHDATA->m_style = Style;
+
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxBrush::SetStipple(const wxBitmap& Stipple)
+{
+  if ( !M_BRUSHDATA )
+	m_refData = new wxBrushRefData;
+
+  M_BRUSHDATA->m_stipple = Stipple;
+
+  if (FreeResource())
+    RealizeResource();
+}
+
+
diff --git a/src/msw/button.cpp b/src/msw/button.cpp
new file mode 100644
index 0000000000..fbfef488f8
--- /dev/null
+++ b/src/msw/button.cpp
@@ -0,0 +1,208 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        button.cpp
+// Purpose:     wxButton
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "button.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/button.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
+#endif
+
+#define BUTTON_HEIGHT_FACTOR (EDIT_CONTROL_FACTOR * 1.1)
+
+// Buttons
+
+bool wxButton::MSWCommand(const WXUINT param, const WXWORD id)
+{
+  if (param == BN_CLICKED)
+  {
+    wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, id);
+    event.SetEventObject(this);
+    ProcessCommand(event);
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+bool wxButton::Create(wxWindow *parent, const wxWindowID id, const wxString& label,
+           const wxPoint& pos,
+           const wxSize& size, const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  SetName(name);
+  SetValidator(validator);
+
+  parent->AddChild((wxButton *)this);
+  m_backgroundColour = parent->GetDefaultBackgroundColour() ;
+  m_foregroundColour = parent->GetDefaultForegroundColour() ;
+
+  m_windowStyle = (long&)style;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  if (id == -1)
+    m_windowId = NewControlId();
+  else
+    m_windowId = id;
+
+  DWORD exStyle = MakeExtendedStyle(m_windowStyle);
+  HWND wx_button =
+    CreateWindowEx(exStyle, "BUTTON", label, BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD,
+                    0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                    wxGetInstance(), NULL);
+
+#if CTL3D
+//  if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS))
+//    Ctl3dSubclassCtl(wx_button);
+#endif
+
+  m_hWnd = (WXHWND)wx_button;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND)wx_button);
+
+  SetFont(* parent->GetFont());
+
+  SetSize(x, y, width, height);
+  ShowWindow(wx_button, SW_SHOW);
+
+  return TRUE;
+}
+
+void wxButton::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+  int x1 = x;
+  int y1 = y;
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  int actualWidth = width;
+  int actualHeight = height;
+  int ww, hh;
+  GetSize(&ww, &hh);
+
+  float current_width;
+  float cyf;
+  char buf[300];
+  GetWindowText((HWND) GetHWND(), buf, 300);
+  GetTextExtent(buf, &current_width, &cyf,NULL,NULL,GetFont());
+
+  // If we're prepared to use the existing width, then...
+  if (width == -1 && ((sizeFlags & wxSIZE_AUTO_WIDTH) != wxSIZE_AUTO_WIDTH))
+    actualWidth = ww;
+  else if (width == -1)
+  {
+    int cx;
+    int cy;
+    wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
+    actualWidth = (int)(current_width + 3*cx) ;
+  }
+  
+  // If we're prepared to use the existing height, then...
+  if (height == -1 && ((sizeFlags & wxSIZE_AUTO_HEIGHT) != wxSIZE_AUTO_HEIGHT))
+    actualHeight = hh;
+  else if (height == -1)
+  {
+    actualHeight = (int)(cyf*BUTTON_HEIGHT_FACTOR) ;
+  }
+
+  MoveWindow((HWND) GetHWND(), x1, y1, actualWidth, actualHeight, TRUE);
+
+/*
+  if (!((width == -1) && (height == -1)))
+  {
+#if WXWIN_COMPATIBILITY
+    GetEventHandler()->OldOnSize(width, height);
+#else
+    wxSizeEvent event(wxSize(width, height), m_windowId);
+    event.eventObject = this;
+    GetEventHandler()->ProcessEvent(event);
+#endif
+  }
+*/
+}
+
+void wxButton::SetDefault(void)
+{
+  wxWindow *parent = (wxWindow *)GetParent();
+  if (parent)
+    parent->SetDefaultItem(this);
+
+  if (parent)
+  {
+    SendMessage((HWND) parent->GetHWND(), DM_SETDEFID, m_windowId, 0L);
+  }
+}
+
+wxString wxButton::GetLabel(void) const
+{
+    GetWindowText((HWND) GetHWND(), wxBuffer, 300);
+    return wxString(wxBuffer);
+}
+
+void wxButton::SetLabel(const wxString& label)
+{
+  SetWindowText((HWND) GetHWND(), (const char *) label);
+}
+
+WXHBRUSH wxButton::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+/*
+    WXHBRUSH hBrush = (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam);
+//    ::SetTextColor((HDC) pDC, GetSysColor(COLOR_BTNTEXT));
+    ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(),
+        GetForegroundColour().Blue()));
+
+	return hBrush;
+*/
+  // This doesn't in fact seem to make any difference at all - buttons are always
+  // the same colour.
+  ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+
+  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+
+  // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
+  // has a zero usage count.
+  // NOT NOW; CHANGED.
+//  backgroundBrush->RealizeResource();
+  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
+}
+
+void wxButton::Command (wxCommandEvent & event)
+{
+  ProcessCommand (event);
+}
+
+
diff --git a/src/msw/checkbox.cpp b/src/msw/checkbox.cpp
new file mode 100644
index 0000000000..eca9672ea3
--- /dev/null
+++ b/src/msw/checkbox.cpp
@@ -0,0 +1,325 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        checkbox.cpp
+// Purpose:     wxCheckBox
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "checkbox.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/checkbox.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
+#endif
+
+bool wxCheckBox::MSWCommand(const WXUINT WXUNUSED(param), const WXWORD WXUNUSED(id))
+{
+  wxCommandEvent event(wxEVENT_TYPE_CHECKBOX_COMMAND, m_windowId);
+  event.SetInt(GetValue());
+  event.SetEventObject(this);
+  ProcessCommand(event);
+  return TRUE;
+}
+
+// Single check box item
+bool wxCheckBox::Create(wxWindow *parent, const wxWindowID id, const wxString& label,
+           const wxPoint& pos,
+           const wxSize& size, const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  SetName(name);
+  SetValidator(validator);
+  if (parent) parent->AddChild(this);
+
+  SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
+  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+
+  m_windowStyle = style;
+
+  wxString Label = label;
+  if (Label == "")
+    Label = " "; // Apparently needed or checkbox won't show
+
+	if ( id == -1 )
+  		m_windowId = NewControlId();
+	else
+		m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  long msStyle = BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD;
+
+  // We perhaps have different concepts of 3D here - a 3D border,
+  // versus a 3D button.
+  // So we only wish to give a border if this is specified
+  // in the style.
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
+    msStyle |= WS_BORDER;
+
+  HWND wx_button = CreateWindowEx(exStyle, "BUTTON", (const char *)Label,
+                    msStyle,
+                    0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                    wxGetInstance(), NULL);
+
+#if CTL3D
+  if (want3D)
+  {
+    Ctl3dSubclassCtl(wx_button);
+    m_useCtl3D = TRUE;
+  }
+#endif
+
+  m_hWnd = (WXHWND) wx_button;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND) wx_button);
+  
+  SetFont(* parent->GetFont());
+
+  SetSize(x, y, width, height);
+
+  ShowWindow(wx_button, SW_SHOW);
+  return TRUE;
+}
+
+void wxCheckBox::SetLabel(const wxString& label)
+{
+  SetWindowText((HWND) GetHWND(), (const char *)label);
+}
+
+void wxCheckBox::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+  int x1 = x;
+  int y1 = y;
+  int w1 = width;
+  int h1 = height;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  char buf[300];
+
+  float current_width;
+
+  float cyf;
+
+  HWND button = (HWND) GetHWND();
+
+    GetWindowText(button, buf, 300);
+    if (buf[0])
+    {
+      GetTextExtent(buf, &current_width, &cyf, NULL, NULL, GetFont());
+      if (w1 < 0)
+        w1 = (int)(current_width + RADIO_SIZE);
+      if (h1 < 0)
+      {
+        h1 = (int)(cyf);
+        if (h1 < RADIO_SIZE)
+          h1 = RADIO_SIZE;
+      }
+    }
+    else
+    {
+      if (w1 < 0)
+        w1 = RADIO_SIZE;
+      if (h1 < 0)
+        h1 = RADIO_SIZE;
+    }
+
+  MoveWindow(button, x1, y1, w1, h1, TRUE);
+
+/*
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+*/
+
+}
+
+void wxCheckBox::SetValue(const bool val)
+{
+  SendMessage((HWND) GetHWND(), BM_SETCHECK, val, 0);
+}
+
+bool wxCheckBox::GetValue(void) const
+{
+#ifdef __WIN32__
+  return (SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0) == BST_CHECKED);
+#else
+  return ((0x003 & SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0)) == 0x003);
+#endif
+}
+
+WXHBRUSH wxCheckBox::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+#if CTL3D
+  if ( m_useCtl3D )
+  {
+    HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
+      
+      return (WXHBRUSH) hbrush;
+  }
+#endif
+
+  if (GetParent()->GetTransparentBackground())
+    SetBkMode((HDC) pDC, TRANSPARENT);
+  else
+    SetBkMode((HDC) pDC, OPAQUE);
+
+  ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+
+  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+
+  // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
+  // has a zero usage count.
+//  backgroundBrush->RealizeResource();
+  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
+}
+
+void wxCheckBox::Command (wxCommandEvent & event)
+{
+  SetValue ((event.GetInt() != 0));
+  ProcessCommand (event);
+}
+
+bool wxBitmapCheckBox::Create(wxWindow *parent, const wxWindowID id, const wxBitmap *label,
+           const wxPoint& pos,
+           const wxSize& size, const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  SetName(name);
+  SetValidator(validator);
+  if (parent) parent->AddChild(this);
+
+  SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
+  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+  m_windowStyle = style;
+
+	if ( id == -1 )
+  		m_windowId = NewControlId();
+	else
+		m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  checkWidth = -1 ;
+  checkHeight = -1 ;
+  long msStyle = CHECK_FLAGS;
+
+  HWND wx_button = CreateWindowEx(MakeExtendedStyle(m_windowStyle), CHECK_CLASS, "toggle",
+                    msStyle,
+                    0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                    wxGetInstance(), NULL);
+
+#if CTL3D
+  if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS))
+  {
+    Ctl3dSubclassCtl(wx_button);
+  	  m_useCtl3D = TRUE;
+  }
+#endif
+
+  m_hWnd = (WXHWND)wx_button;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND)wx_button);
+
+//  SetFont(parent->GetFont());
+
+  SetSize(x, y, width, height);
+
+  ShowWindow(wx_button, SW_SHOW);
+  return TRUE;
+}
+
+void wxBitmapCheckBox::SetLabel(const wxBitmap *bitmap)
+{
+}
+
+void wxBitmapCheckBox::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+
+  int x1 = x;
+  int y1 = y;
+  int w1 = width;
+  int h1 = height;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  HWND button = (HWND) GetHWND();
+/*
+    if (w1<0)
+      w1 = checkWidth + FB_MARGIN ;
+    if (h1<0)
+      h1 = checkHeight + FB_MARGIN ;
+*/
+  MoveWindow(button, x1, y1, w1, h1, TRUE);
+
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+}
+
+void wxBitmapCheckBox::SetValue(const bool val)
+{
+  SendMessage((HWND) GetHWND(), BM_SETCHECK, val, 0);
+}
+
+bool wxBitmapCheckBox::GetValue(void) const
+{
+  return ((0x003 & SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0)) == 0x003);
+}
+
+
diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp
new file mode 100644
index 0000000000..a04d7689aa
--- /dev/null
+++ b/src/msw/checklst.cpp
@@ -0,0 +1,306 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        msw/checklst.cpp
+// Purpose:     implementation of wxCheckListBox class
+// Author:      Vadim Zeitlin
+// Modified by: 
+// Created:     16.11.97
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// headers & declarations
+// ============================================================================
+
+#ifdef __GNUG__
+#pragma implementation "checklst.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#include <windows.h>
+
+#include "wx/ownerdrw.h"
+#include "wx/msw/checklst.h"
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+#if !USE_SHARED_LIBRARY
+  IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
+#endif
+
+// ----------------------------------------------------------------------------
+// declaration and implementation of wxCheckListBoxItem class
+// ----------------------------------------------------------------------------
+
+class wxCheckListBoxItem : public wxOwnerDrawn
+{
+public:
+  // ctor
+  wxCheckListBoxItem(wxCheckListBox *pParent, uint nIndex);
+
+  // drawing functions
+  virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat);
+
+  // simple accessors
+  bool IsChecked() const  { return m_bChecked;        }
+  void Check(bool bCheck) { m_bChecked = bCheck;      }
+  void Toggle();
+
+private:
+  bool            m_bChecked;
+  wxCheckListBox *m_pParent;
+  uint            m_nIndex;
+};
+
+wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, uint nIndex)
+                  : wxOwnerDrawn("", TRUE)   // checkable
+{
+  m_bChecked = FALSE;
+  m_pParent  = pParent;
+  m_nIndex   = nIndex;
+
+  // we don't initialize m_nCheckHeight/Width vars because it's
+  // done in OnMeasure while they are used only in OnDraw and we
+  // know that there will always be OnMeasure before OnDraw
+
+  // fix appearance
+  SetFont(wxSystemSettings::GetSystemFont(wxSYS_ANSI_VAR_FONT));
+  SetMarginWidth(GetDefaultMarginWidth());
+}
+
+/*
+ * JACS - I've got the owner-draw stuff partially working with WIN16,
+ * with a really horrible-looking cross for wxCheckListBox instead of a
+ * check - could use a bitmap check-mark instead, defined in wx.rc.
+ * Also there's a refresh problem whereby it doesn't always draw the
+ * check until you click to the right of it, which is OK for WIN32.
+ */
+
+bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, 
+                                    wxODAction act, wxODStatus stat)
+{
+  if ( IsChecked() )
+    stat = (wxOwnerDrawn::wxODStatus)(stat | wxOwnerDrawn::wxODChecked);
+
+  if ( wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) ) {
+    // ## using native API for performance and precision
+    uint nCheckWidth  = GetDefaultMarginWidth(),
+         nCheckHeight = m_pParent->GetItemHeight();
+          
+    int x = rc.GetX(), 
+        y = rc.GetY();
+
+    HDC hdc = (HDC)dc.GetHDC();
+
+    // create pens
+    HPEN hpenBack = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_WINDOW)),
+         hpenGray = CreatePen(PS_SOLID, 0, RGB(128, 128, 128)),
+         hpenPrev = SelectObject(hdc, hpenBack);
+
+    // we erase the 1-pixel border
+    Rectangle(hdc, x, y, x + nCheckWidth, y + nCheckHeight);
+
+    // shift check mark 1 pixel to the right (it looks better like this)
+    x++;
+
+    if ( IsChecked() ) {
+      // first create a monochrome bitmap in a memory DC
+      HDC hdcMem = CreateCompatibleDC(hdc);
+      HBITMAP hbmpCheck = CreateBitmap(nCheckWidth, nCheckHeight, 1, 1, 0);
+      HBITMAP hbmpOld = SelectObject(hdcMem, hbmpCheck);
+
+      // then draw a check mark into it
+      RECT rect = { 0, 0, nCheckWidth, nCheckHeight };
+
+#ifdef __WIN32__
+      DrawFrameControl(hdcMem, &rect, DFC_MENU, DFCS_MENUCHECK);
+#else
+      // In WIN16, draw a cross
+      HPEN blackPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
+      HPEN whiteBrush = GetStockObject(WHITE_BRUSH);
+      HPEN hPenOld = ::SelectObject(hdcMem, blackPen);
+      HPEN hBrushOld = ::SelectObject(hdcMem, whiteBrush);
+      ::SetROP2(hdcMem, R2_COPYPEN);
+      Rectangle(hdcMem, 0, 0, nCheckWidth, nCheckHeight);
+      MoveTo(hdcMem, 0, 0);
+      LineTo(hdcMem, nCheckWidth, nCheckHeight);
+      MoveTo(hdcMem, nCheckWidth, 0);
+      LineTo(hdcMem, 0, nCheckHeight);
+      ::SelectObject(hdcMem, hPenOld);
+      ::SelectObject(hdcMem, hBrushOld);
+      ::DeleteObject(blackPen);
+#endif
+
+      // finally copy it to screen DC and clean up
+      BitBlt(hdc, x, y, nCheckWidth - 1, nCheckHeight, 
+             hdcMem, 0, 0, SRCCOPY);
+
+      SelectObject(hdcMem, hbmpOld);
+      DeleteObject(hbmpCheck);
+      DeleteDC(hdcMem);
+    }
+
+    // now we draw the smaller rectangle
+    y++;
+    nCheckWidth  -= 2;
+    nCheckHeight -= 2;
+
+    // draw hollow gray rectangle
+    (void)SelectObject(hdc, hpenGray);
+    HBRUSH hbrPrev  = SelectObject(hdc, GetStockObject(NULL_BRUSH));
+    Rectangle(hdc, x, y, x + nCheckWidth, y + nCheckHeight);
+
+    // clean up
+    (void)SelectObject(hdc, hpenPrev);
+    (void)SelectObject(hdc, hbrPrev);
+
+    DeleteObject(hpenBack);
+    DeleteObject(hpenGray);
+
+    /*
+    dc.DrawRectangle(x, y, nCheckWidth, nCheckHeight);
+
+    if ( IsChecked() ) {
+      dc.DrawLine(x, y, x + nCheckWidth, y + nCheckHeight);
+      dc.DrawLine(x, y + nCheckHeight, x + nCheckWidth, y);
+    }
+    */
+
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+// change the state of the item and redraw it
+void wxCheckListBoxItem::Toggle()
+{ 
+  m_bChecked = !m_bChecked;
+
+  uint nHeight = m_pParent->GetItemHeight();
+  uint y = m_nIndex * nHeight;
+  RECT rcUpdate = { 0, y, GetDefaultMarginWidth(), y + nHeight};
+  InvalidateRect((HWND)m_pParent->GetHWND(), &rcUpdate, FALSE);
+
+  wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, m_pParent->GetId());
+  event.SetInt(m_nIndex);
+  event.SetEventObject(m_pParent);
+  m_pParent->ProcessCommand(event);
+}
+
+// ----------------------------------------------------------------------------
+// implementation of wxCheckListBox class
+// ----------------------------------------------------------------------------
+
+// define event table
+// ------------------
+BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
+  EVT_CHAR(wxCheckListBox::OnChar)
+  EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick)
+END_EVENT_TABLE()
+
+// control creation
+// ----------------
+
+// def ctor: use Create() to really create the control
+wxCheckListBox::wxCheckListBox() : wxListBox()
+{
+}
+
+// ctor which creates the associated control
+wxCheckListBox::wxCheckListBox(wxWindow *parent, const wxWindowID id,
+                               const wxPoint& pos, const wxSize& size,
+                               const int nStrings, const wxString choices[],
+                               const long style, const wxValidator& val,
+                               const wxString& name) // , const wxFont& font)
+                // don't use ctor with arguments! we must call Create()
+                // ourselves from here.
+              : wxListBox()
+//                , m_font(font)
+{
+  Create(parent, id, pos, size, nStrings, choices, style|wxLB_OWNERDRAW, val, name);
+}
+
+// create/retrieve item
+// --------------------
+
+// create a check list box item
+wxOwnerDrawn *wxCheckListBox::CreateItem(uint nIndex)
+{
+  wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this, nIndex);
+  if ( m_windowFont.Ok() )
+    pItem->SetFont(m_windowFont);
+
+  return pItem;
+}
+
+// get item (converted to right type)
+#define GetItem(n)    ((wxCheckListBoxItem *)(GetItem(n)))
+
+// return item size
+// ----------------
+bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
+{
+  if ( wxListBox::MSWOnMeasure(item) ) {
+    MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item;
+
+    // save item height
+    m_nItemHeight = pStruct->itemHeight;
+
+    // add place for the check mark
+    pStruct->itemWidth += wxOwnerDrawn::GetDefaultMarginWidth();
+
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+// check items
+// -----------
+
+bool wxCheckListBox::IsChecked(uint uiIndex) const
+{
+  return GetItem(uiIndex)->IsChecked();
+}
+
+void wxCheckListBox::Check(uint uiIndex, bool bCheck)
+{
+  GetItem(uiIndex)->Check(bCheck);
+}
+
+// process events
+// --------------
+
+void wxCheckListBox::OnChar(wxKeyEvent& event)
+{
+  if ( event.KeyCode() == WXK_SPACE )
+    GetItem(GetSelection())->Toggle();
+  else
+    wxListBox::OnChar(event);
+}
+
+void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
+{
+  // clicking on the item selects it, clicking on the checkmark toggles
+  if ( (uint)event.GetX() <= wxOwnerDrawn::GetDefaultMarginWidth() ) {
+    // # better use LB_ITEMFROMPOINT perhaps?
+    uint nItem = ((uint)event.GetY()) / m_nItemHeight;
+    if ( nItem < (uint)m_noItems )
+      GetItem(nItem)->Toggle();
+    //else: it's not an error, just click outside of client zone
+  }
+  else {
+    // implement default behaviour: clicking on the item selects it
+    event.Skip();
+  }
+}
diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp
new file mode 100644
index 0000000000..850211d0dd
--- /dev/null
+++ b/src/msw/choice.cpp
@@ -0,0 +1,350 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        choice.cpp
+// Purpose:     wxChoice
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "choice.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/choice.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
+#endif
+
+bool wxChoice::MSWCommand(const WXUINT param, const WXWORD WXUNUSED(id))
+{
+  if (param == CBN_SELCHANGE)
+  {
+    wxCommandEvent event(wxEVENT_TYPE_CHOICE_COMMAND, m_windowId);
+    event.SetInt(GetSelection());
+    event.SetEventObject(this);
+    event.SetString(copystring(GetStringSelection()));
+    ProcessCommand(event);
+    delete[] event.GetString();
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+bool wxChoice::Create(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos,
+           const wxSize& size,
+		   const int n, const wxString choices[],
+		   const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  SetName(name);
+  SetValidator(validator);
+  if (parent) parent->AddChild(this);
+  SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
+  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+  no_strings = n;
+
+  m_windowStyle = style;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  long msStyle = WS_CHILD | CBS_DROPDOWNLIST | WS_HSCROLL | WS_VSCROLL
+                   | WS_TABSTOP | WS_VISIBLE;
+  if (m_windowStyle & wxCB_SORT)
+    msStyle |= CBS_SORT;
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+    msStyle |= WS_BORDER;
+
+  HWND wx_combo = CreateWindowEx(exStyle, "COMBOBOX", NULL,
+                   msStyle,
+                   0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                   wxGetInstance(), NULL);
+/*
+#if CTL3D
+  if (want3D)
+  {
+    m_useCtl3D = TRUE;
+    Ctl3dSubclassCtl(wx_combo); // Does CTL3D affect the combobox? I think not.
+  }
+#endif
+*/
+
+  m_hWnd = (WXHWND) wx_combo;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND) wx_combo);
+
+  SetFont(* parent->GetFont());
+
+  int i;
+  for (i = 0; i < n; i++)
+    SendMessage(wx_combo, CB_INSERTSTRING, i, (LONG)(const char *)choices[i]);
+  SendMessage(wx_combo, CB_SETCURSEL, i, 0);
+
+  SetSize(x, y, width, height);
+
+  return TRUE;
+}
+
+void wxChoice::Append(const wxString& item)
+{
+  SendMessage((HWND) GetHWND(), CB_ADDSTRING, 0, (LONG)(const char *)item);
+
+  no_strings ++;
+}
+
+void wxChoice::Delete(const int n)
+{
+  no_strings = (int)SendMessage((HWND) GetHWND(), CB_DELETESTRING, n, 0);
+}
+
+void wxChoice::Clear(void)
+{
+  SendMessage((HWND) GetHWND(), CB_RESETCONTENT, 0, 0);
+
+  no_strings = 0;
+}
+
+
+int wxChoice::GetSelection(void) const
+{
+  return (int)SendMessage((HWND) GetHWND(), CB_GETCURSEL, 0, 0);
+}
+
+void wxChoice::SetSelection(const int n)
+{
+  SendMessage((HWND) GetHWND(), CB_SETCURSEL, n, 0);
+}
+
+int wxChoice::FindString(const wxString& s) const
+{
+#if defined(__WATCOMC__) && defined(__WIN386__)
+  // For some reason, Watcom in WIN386 mode crashes in the CB_FINDSTRINGEXACT message.
+  // Do it the long way instead.
+  char buf[512];
+  for (int i = 0; i < Number(); i++)
+  {
+    int len = (int)SendMessage((HWND) GetHWND(), CB_GETLBTEXT, i, (LPARAM)(LPSTR)buf);
+    buf[len] = 0;
+    if (strcmp(buf, (const char *)s) == 0)
+      return i;
+  }
+  return -1;
+#else
+ int pos = (int)SendMessage((HWND) GetHWND(), CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)(LPSTR)(const char *)s);
+ if (pos == LB_ERR)
+   return -1;
+ else
+   return pos;
+#endif
+}
+
+wxString wxChoice::GetString(const int n) const
+{
+  int len = (int)SendMessage((HWND) GetHWND(), CB_GETLBTEXT, n, (long)wxBuffer);
+  wxBuffer[len] = 0;
+  return wxString(wxBuffer);
+}
+
+void wxChoice::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+
+  int x1 = x;
+  int y1 = y;
+  int w1 = width;
+  int h1 = height;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  // If we're prepared to use the existing size, then...
+  if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
+  {
+    GetSize(&w1, &h1);
+  }
+
+  int cx; // button font dimensions
+  int cy;
+  wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
+
+  float control_width, control_height;
+
+  // Ignore height parameter because height doesn't
+  // mean 'initially displayed' height, it refers to the
+  // drop-down menu as well. The wxWindows interpretation
+  // is different; also, getting the size returns the
+  // _displayed_ size (NOT the drop down menu size)
+  // so setting-getting-setting size would not work.
+  h1 = -1;
+
+  // Deal with default size (using -1 values)
+  if (width <= 0)
+  {
+    // Find the longest string
+    if (no_strings == 0)
+      control_width = (float)100.0;
+    else
+    {
+      float len, ht;
+      float longest = (float)0.0;
+      int i;
+      for (i = 0; i < no_strings; i++)
+      {
+        wxString str(GetString(i));
+        GetTextExtent(str, &len, &ht, NULL, NULL,GetFont());
+        if ( len > longest) longest = len;
+      }
+
+      control_width = (float)(int)(longest + cx*5);
+    }
+  }
+
+  // Choice drop-down list depends on number of items (limited to 10)
+  if (h1 <= 0)
+  {
+    if (no_strings == 0)
+      h1 = (int)(EDIT_CONTROL_FACTOR*cy*10.0);
+    else h1 = (int)(EDIT_CONTROL_FACTOR*cy*(wxMin(10, no_strings) + 1));
+  }
+
+  // If non-default width...
+  if (width >= 0)
+    control_width = (float)width;
+
+  control_height = (float)h1;
+
+  // Calculations may have made text size too small
+  if (control_height <= 0)
+    control_height = (float)(int)(cy*EDIT_CONTROL_FACTOR) ;
+
+  if (control_width <= 0)
+    control_width = (float)100.0;
+
+  MoveWindow((HWND) GetHWND(), x1, y1,
+                              (int)control_width, (int)control_height, TRUE);
+
+/*
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+*/
+}
+
+WXHBRUSH wxChoice::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+	return 0;
+}
+
+long wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+    switch (nMsg)
+    {
+/*
+      case WM_GETDLGCODE:
+      {
+        if (GetWindowStyleFlag() & wxPROCESS_ENTER)
+          return DLGC_WANTALLKEYS;
+        break;
+      }
+*/
+/*
+      case WM_CHAR: // Always an ASCII character
+      {
+        if (wParam == VK_RETURN)
+        {
+          wxCommandEvent event(wxEVENT_TYPE_TEXT_ENTER_COMMAND);
+          event.commandString = ((wxTextCtrl *)item)->GetValue();
+          event.eventObject = item;
+          item->ProcessCommand(event);
+          return FALSE;
+        }
+        break;
+      }
+*/
+      case WM_LBUTTONUP:
+      {
+        int x = (int)LOWORD(lParam);
+        int y = (int)HIWORD(lParam);
+
+       // Ok, this is truly weird, but if a panel with a wxChoice loses the
+       // focus, then you get a *fake* WM_LBUTTONUP message
+       // with x = 65535 and y = 65535.
+       // Filter out this nonsense.
+       if (x == 65535 && y == 65535)
+         return Default();
+       break;
+      }
+    }
+
+  return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
+}
+
+wxString wxChoice::GetStringSelection (void) const
+{
+  int sel = GetSelection ();
+  if (sel > -1)
+    return wxString(this->GetString (sel));
+  else
+    return wxString("");
+}
+
+bool wxChoice::SetStringSelection (const wxString& s)
+{
+  int sel = FindString (s);
+  if (sel > -1)
+    {
+      SetSelection (sel);
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
+
+void wxChoice::Command(wxCommandEvent & event)
+{
+  SetSelection (event.GetInt());
+  ProcessCommand (event);
+}
+
+
+
diff --git a/src/msw/clipbrd.cpp b/src/msw/clipbrd.cpp
new file mode 100644
index 0000000000..af48db1a5a
--- /dev/null
+++ b/src/msw/clipbrd.cpp
@@ -0,0 +1,465 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        clipbrd.cpp
+// Purpose:     Clipboard functionality
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation
+#pragma implementation "clipbrd.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#endif
+
+#if USE_CLIPBOARD
+
+#ifndef WX_PRECOMP
+#include "wx/app.h"
+#include "wx/frame.h"
+#include "wx/bitmap.h"
+#include "wx/utils.h"
+#endif
+
+#include "wx/metafile.h"
+#include "wx/clipbrd.h"
+#include "wx/msw/private.h"
+#include "wx/msw/dib.h"
+
+#include <string.h>
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
+#endif
+
+bool wxClipboardIsOpen = FALSE;
+
+bool wxOpenClipboard(void)
+{
+  if (wxTheApp->GetTopWindow() && !wxClipboardIsOpen)
+  {
+    wxClipboardIsOpen = (::OpenClipboard((HWND) wxTheApp->GetTopWindow()->GetHWND()) != 0);
+    return wxClipboardIsOpen;
+  }
+  else return FALSE;
+}
+
+bool wxCloseClipboard(void)
+{
+  if (wxClipboardIsOpen)
+  {
+    wxClipboardIsOpen = FALSE;
+  }
+  return (::CloseClipboard() != 0);
+}
+
+bool wxEmptyClipboard(void)
+{
+  return (::EmptyClipboard() != 0);
+}
+
+bool wxClipboardOpen(void)
+{
+  return wxClipboardIsOpen;
+}
+
+bool wxIsClipboardFormatAvailable(int dataFormat)
+{
+  return (::IsClipboardFormatAvailable(dataFormat) != 0);
+}
+
+bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
+{
+  switch (dataFormat)
+  {
+    case wxCF_BITMAP:
+    {
+      wxBitmap *wxBM = (wxBitmap *)obj;
+
+      HDC hdcMem = CreateCompatibleDC(NULL);
+      HDC hdcSrc = CreateCompatibleDC(NULL);
+      HBITMAP old = ::SelectObject(hdcSrc, (HBITMAP) wxBM->GetHBITMAP());
+      HBITMAP hBitmap = CreateCompatibleBitmap(hdcSrc,
+                                              wxBM->GetWidth(), wxBM->GetHeight());
+      if (!hBitmap)
+      {
+        SelectObject(hdcSrc, old);
+        DeleteDC(hdcMem);
+        DeleteDC(hdcSrc);
+        return FALSE;
+      }
+      HBITMAP old1 = SelectObject(hdcMem, hBitmap);
+      BitBlt(hdcMem, 0, 0, wxBM->GetWidth(), wxBM->GetHeight(),
+             hdcSrc, 0, 0, SRCCOPY);
+
+      // Select new bitmap out of memory DC
+      SelectObject(hdcMem, old1);
+
+      // Set the data
+      bool success = (bool)(::SetClipboardData(CF_BITMAP, hBitmap) != 0);
+
+      // Clean up
+      SelectObject(hdcSrc, old);
+      DeleteDC(hdcSrc);
+      DeleteDC(hdcMem);      
+      return success;
+      break;
+    }
+    case wxCF_DIB:
+    {
+#if USE_IMAGE_LOADING_IN_MSW
+      HBITMAP hBitmap=(HBITMAP) ((wxBitmap *)obj)->GetHBITMAP();
+      HANDLE hDIB=BitmapToDIB(hBitmap,NULL); // NULL==uses system palette
+      bool success = (::SetClipboardData(CF_DIB,hDIB) != 0);
+#else
+      bool success=FALSE;
+#endif
+      return success;
+      break;
+    }
+#if USE_METAFILE
+    case wxCF_METAFILE:
+    {
+      wxMetaFile *wxMF = (wxMetaFile *)obj;
+      HANDLE data = GlobalAlloc(GHND, sizeof(METAFILEPICT) + 1);
+#ifdef __WINDOWS_386__
+      METAFILEPICT *mf = (METAFILEPICT *)MK_FP32(GlobalLock(data));
+#else
+      METAFILEPICT *mf = (METAFILEPICT *)GlobalLock(data);
+#endif
+
+      mf->mm = wxMF->GetWindowsMappingMode();
+      mf->xExt = width;
+      mf->yExt = height;
+      mf->hMF = (HANDLE) wxMF->GetHMETAFILE();
+      GlobalUnlock(data);
+      wxMF->SetHMETAFILE((WXHANDLE) NULL);
+
+      return (SetClipboardData(CF_METAFILEPICT, data) != 0);
+      break;
+    }
+#endif
+    case CF_SYLK:
+    case CF_DIF:
+    case CF_TIFF:
+    case CF_PALETTE:
+    {
+      return FALSE;
+      break;
+    }
+    case wxCF_OEMTEXT:
+      dataFormat = wxCF_TEXT;
+    case wxCF_TEXT:
+       width = strlen((char *)obj) + 1;
+       height = 1;
+    default:
+    {
+      char *s = (char *)obj;
+      DWORD l;
+
+      l = (width * height);
+      HANDLE hGlobalMemory = GlobalAlloc(GHND, l);
+                if (!hGlobalMemory)
+        return FALSE;
+
+#ifdef __WINDOWS_386__
+      LPSTR lpGlobalMemory = (LPSTR)MK_FP32(GlobalLock(hGlobalMemory));
+#else
+      LPSTR lpGlobalMemory = (LPSTR)GlobalLock(hGlobalMemory);
+#endif
+
+#ifdef __WIN32__
+      memcpy(lpGlobalMemory, s, l);
+#elif defined(__WATCOMC__) && defined(__WINDOWS_386__)
+      memcpy(lpGlobalMemory, s, l);
+#else
+      hmemcpy(lpGlobalMemory, s, l);
+#endif
+
+      GlobalUnlock(hGlobalMemory);
+      HANDLE success = SetClipboardData(dataFormat, hGlobalMemory);
+      return (success != 0);
+      break;
+    }
+  }
+  return FALSE;
+}
+
+wxObject *wxGetClipboardData(int dataFormat, long *len)
+{
+  switch (dataFormat)
+  {
+    case wxCF_BITMAP:
+    {
+      BITMAP bm;
+      HBITMAP hBitmap = GetClipboardData(CF_BITMAP);
+      if (!hBitmap)
+        return NULL;
+
+      HDC hdcMem = CreateCompatibleDC(NULL);
+      HDC hdcSrc = CreateCompatibleDC(NULL);
+
+      HBITMAP old = ::SelectObject(hdcSrc, hBitmap);
+      GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
+
+      HBITMAP hNewBitmap = CreateBitmapIndirect(&bm);
+
+      if (!hNewBitmap)
+      {
+        SelectObject(hdcSrc, old);
+        DeleteDC(hdcMem);
+        DeleteDC(hdcSrc);
+        return NULL;
+      }
+
+      HBITMAP old1 = SelectObject(hdcMem, hNewBitmap);
+      BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight,
+             hdcSrc, 0, 0, SRCCOPY);
+
+      // Select new bitmap out of memory DC
+      SelectObject(hdcMem, old1);
+
+      // Clean up
+      SelectObject(hdcSrc, old);
+      DeleteDC(hdcSrc);
+      DeleteDC(hdcMem);
+
+      // Create and return a new wxBitmap
+      wxBitmap *wxBM = new wxBitmap;
+      wxBM->SetHBITMAP((WXHBITMAP) hNewBitmap);
+      wxBM->SetWidth(bm.bmWidth);
+      wxBM->SetHeight(bm.bmHeight);
+      wxBM->SetDepth(bm.bmPlanes);
+      wxBM->SetOk(TRUE);
+      return (wxObject *)wxBM;
+      break;
+    }
+    case wxCF_METAFILE:
+    case CF_SYLK:
+    case CF_DIF:
+    case CF_TIFF:
+    case CF_PALETTE:
+    case wxCF_DIB:
+    {
+      return FALSE;
+      break;
+    }
+    case wxCF_OEMTEXT:
+      dataFormat = wxCF_TEXT;
+         case wxCF_TEXT:
+    default:
+    {
+      HANDLE hGlobalMemory = GetClipboardData(dataFormat);
+      if (!hGlobalMemory)
+        return NULL;
+
+      int hsize = (int)GlobalSize(hGlobalMemory);
+      if (len)
+        *len = hsize;
+
+      char *s = new char[hsize];
+      if (!s)
+        return NULL;
+
+#ifdef __WINDOWS_386__
+      LPSTR lpGlobalMemory = (LPSTR)MK_FP32(GlobalLock(hGlobalMemory));
+#else
+      LPSTR lpGlobalMemory = (LPSTR)GlobalLock(hGlobalMemory);
+#endif
+
+#ifdef __WIN32__
+      memcpy(s, lpGlobalMemory, GlobalSize(hGlobalMemory));
+#elif __WATCOMC__ && defined(__WINDOWS_386__)
+      memcpy(s, lpGlobalMemory, GlobalSize(hGlobalMemory));
+#else
+      hmemcpy(s, lpGlobalMemory, GlobalSize(hGlobalMemory));
+#endif
+
+      GlobalUnlock(hGlobalMemory);
+
+      return (wxObject *)s;
+      break;
+    }
+  }
+  return NULL;
+}
+
+int  wxEnumClipboardFormats(int dataFormat)
+{
+  return ::EnumClipboardFormats(dataFormat);
+}
+
+int  wxRegisterClipboardFormat(char *formatName)
+{
+  return ::RegisterClipboardFormat(formatName);
+}
+
+bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
+{
+  return (::GetClipboardFormatName(dataFormat, formatName, maxCount) > 0);
+}
+
+/*
+ * Generalized clipboard implementation by Matthew Flatt
+ */
+
+wxClipboard *wxTheClipboard = NULL;
+
+void wxInitClipboard(void)
+{
+  if (!wxTheClipboard)
+    wxTheClipboard = new wxClipboard;
+}
+
+wxClipboard::wxClipboard()
+{
+  clipOwner = NULL;
+  cbString = NULL;
+}
+
+wxClipboard::~wxClipboard()
+{
+  if (clipOwner)
+    clipOwner->BeingReplaced();
+  if (cbString)
+    delete[] cbString;
+}
+
+static int FormatStringToID(char *str)
+{
+  if (!strcmp(str, "TEXT"))
+    return wxCF_TEXT;
+  
+  return wxRegisterClipboardFormat(str);
+}
+
+void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
+{
+  bool got_selection;
+
+  if (clipOwner)
+    clipOwner->BeingReplaced();
+  clipOwner = client;
+  if (cbString) {
+    delete[] cbString;
+    cbString = NULL;
+  }
+
+  if (wxOpenClipboard()) {
+    char **formats, *data;
+         int i;
+    int ftype;
+    long size;
+
+    formats = clipOwner->formats.ListToArray(FALSE);
+    for (i = clipOwner->formats.Number(); i--; ) {
+      ftype = FormatStringToID(formats[i]);
+      data = clipOwner->GetData(formats[i], &size);
+      if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) {
+        got_selection = FALSE;
+        break;
+      }
+    }
+
+    if (i < 0)
+      got_selection = wxCloseClipboard();
+  } else
+    got_selection = FALSE;
+  
+  got_selection = FALSE; // Assume another process takes over
+
+  if (!got_selection) {
+    clipOwner->BeingReplaced();
+         clipOwner = NULL;
+  }
+}
+
+wxClipboardClient *wxClipboard::GetClipboardClient()
+{
+  return clipOwner;
+}
+
+void wxClipboard::SetClipboardString(char *str, long time)
+{
+  bool got_selection;
+
+  if (clipOwner) {
+    clipOwner->BeingReplaced();
+    clipOwner = NULL;
+  }
+  if (cbString)
+    delete[] cbString;
+
+  cbString = str;
+
+  if (wxOpenClipboard()) {
+    if (!wxSetClipboardData(wxCF_TEXT, (wxObject *)str))
+      got_selection = FALSE;
+    else
+                got_selection = wxCloseClipboard();
+  } else
+    got_selection = FALSE;
+
+  got_selection = FALSE; // Assume another process takes over
+
+  if (!got_selection) {
+    delete[] cbString;
+    cbString = NULL;
+  }
+}
+
+char *wxClipboard::GetClipboardString(long time)
+{
+  char *str;
+  long length;
+
+  str = GetClipboardData("TEXT", &length, time);
+  if (!str) {
+    str = new char[1];
+    *str = 0;
+  }
+
+  return str;
+}
+
+char *wxClipboard::GetClipboardData(char *format, long *length, long time)
+{
+  if (clipOwner)  {
+         if (clipOwner->formats.Member(format))
+      return clipOwner->GetData(format, length);
+    else
+      return NULL;
+  } else if (cbString) {
+    if (!strcmp(format, "TEXT"))
+      return copystring(cbString);
+    else
+      return NULL;
+  } else {
+    if (wxOpenClipboard()) {
+      receivedString = (char *)wxGetClipboardData(FormatStringToID(format), 
+                                                  length);
+      wxCloseClipboard();
+    } else
+      receivedString = NULL;
+
+    return receivedString;
+  }
+}
+
+
+#endif // USE_CLIPBOARD
+
diff --git a/src/msw/colordlg.cpp b/src/msw/colordlg.cpp
new file mode 100644
index 0000000000..e18bb2af6b
--- /dev/null
+++ b/src/msw/colordlg.cpp
@@ -0,0 +1,124 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        colordlg.cpp
+// Purpose:     wxColourDialog class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "colordlg.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/defs.h"
+#include "wx/pen.h"
+#include "wx/brush.h"
+#include "wx/gdicmn.h"
+#include "wx/utils.h"
+#include "wx/frame.h"
+#include "wx/dialog.h"
+#include "wx/msgdlg.h"
+#endif
+
+#include <windows.h>
+
+#ifndef __WIN32__
+#include <commdlg.h>
+#endif
+
+#include "wx/msw/private.h"
+#include "wx/colordlg.h"
+#include "wx/cmndata.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define wxDIALOG_DEFAULT_X 300
+#define wxDIALOG_DEFAULT_Y 300
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
+#endif
+
+/*
+ * wxColourDialog
+ */
+
+wxColourDialog::wxColourDialog(void)
+{
+  dialogParent = NULL;
+}
+
+wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
+{
+  Create(parent, data);
+}
+
+bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
+{
+  dialogParent = parent;
+  
+  if (data)
+    colourData = *data;
+  return TRUE;
+}
+
+int wxColourDialog::ShowModal(void)
+{
+    CHOOSECOLOR chooseColorStruct;
+    COLORREF custColours[16];
+    memset(&chooseColorStruct, 0, sizeof(CHOOSECOLOR));
+
+    int i;
+    for (i = 0; i < 16; i++)
+      custColours[i] = RGB(colourData.custColours[i].Red(), colourData.custColours[i].Green(), colourData.custColours[i].Blue());
+
+    chooseColorStruct.lStructSize = sizeof(CHOOSECOLOR);
+    chooseColorStruct.hwndOwner = (HWND) (dialogParent ? (HWND) dialogParent->GetHWND() : NULL);
+    chooseColorStruct.rgbResult = RGB(colourData.dataColour.Red(), colourData.dataColour.Green(), colourData.dataColour.Blue());
+    chooseColorStruct.lpCustColors = custColours;
+
+    chooseColorStruct.Flags = CC_RGBINIT;
+
+    if (!colourData.GetChooseFull())
+      chooseColorStruct.Flags |= CC_PREVENTFULLOPEN;
+
+    // Do the modal dialog
+    bool success = (ChooseColor(&(chooseColorStruct)) != 0);
+
+    // Try to highlight the correct window (the parent)
+    HWND hWndParent = 0;
+    if (GetParent())
+    {
+      hWndParent = (HWND) GetParent()->GetHWND();
+      if (hWndParent)
+        ::BringWindowToTop(hWndParent);
+    }
+
+
+    // Restore values
+    for (i = 0; i < 16; i++)
+    {
+      colourData.custColours[i].Set(GetRValue(custColours[i]), GetGValue(custColours[i]),
+         GetBValue(custColours[i]));
+    }
+
+    colourData.dataColour.Set(GetRValue(chooseColorStruct.rgbResult), GetGValue(chooseColorStruct.rgbResult),
+     GetBValue(chooseColorStruct.rgbResult));
+
+    return success ? wxID_OK : wxID_CANCEL;
+}
+
diff --git a/src/msw/colour.cpp b/src/msw/colour.cpp
new file mode 100644
index 0000000000..bfc43c65a9
--- /dev/null
+++ b/src/msw/colour.cpp
@@ -0,0 +1,132 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        colour.cpp
+// Purpose:     wxColour class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "colour.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#include "wx/gdicmn.h"
+
+#include <string.h>
+#include <windows.h>
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
+#endif
+
+// Colour
+
+wxColour::wxColour (void)
+{
+  m_isInit = FALSE;
+  m_pixel = 0;
+  m_red = m_blue = m_green = 0;
+}
+
+wxColour::wxColour (const unsigned char r, const unsigned char g, const unsigned char b)
+{
+  m_red = r;
+  m_green = g;
+  m_blue = b;
+  m_isInit = TRUE;
+  m_pixel = PALETTERGB (m_red, m_green, m_blue);
+}
+
+wxColour::wxColour (const wxColour& col)
+{
+  m_red = col.m_red;
+  m_green = col.m_green;
+  m_blue = col.m_blue;
+  m_isInit = col.m_isInit;
+  m_pixel = col.m_pixel;
+}
+
+wxColour& wxColour::operator =(const wxColour& col)
+{
+  m_red = col.m_red;
+  m_green = col.m_green;
+  m_blue = col.m_blue;
+  m_isInit = col.m_isInit;
+  m_pixel = col.m_pixel;
+  return *this;
+}
+
+wxColour::wxColour (const wxString& col)
+{
+  wxColour *the_colour = wxTheColourDatabase->FindColour (col);
+  if (the_colour)
+    {
+      m_red = the_colour->Red ();
+      m_green = the_colour->Green ();
+      m_blue = the_colour->Blue ();
+      m_isInit = TRUE;
+    }
+  else
+    {
+      m_red = 0;
+      m_green = 0;
+      m_blue = 0;
+      m_isInit = FALSE;
+    }
+  m_pixel = PALETTERGB (m_red, m_green, m_blue);
+}
+
+wxColour::~wxColour (void)
+{
+}
+
+wxColour& wxColour::operator = (const wxString& col)
+{
+  wxColour *the_colour = wxTheColourDatabase->FindColour (col);
+  if (the_colour)
+    {
+      m_red = the_colour->Red ();
+      m_green = the_colour->Green ();
+      m_blue = the_colour->Blue ();
+      m_isInit = TRUE;
+    }
+  else
+    {
+      m_red = 0;
+      m_green = 0;
+      m_blue = 0;
+      m_isInit = FALSE;
+    }
+  m_pixel = PALETTERGB (m_red, m_green, m_blue);
+  return (*this);
+}
+
+void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
+{
+  m_red = r;
+  m_green = g;
+  m_blue = b;
+  m_isInit = TRUE;
+  m_pixel = PALETTERGB (m_red, m_green, m_blue);
+}
+
+// Obsolete
+#if WXWIN_COMPATIBILITY
+void wxColour::Get (unsigned char *r, unsigned char *g, unsigned char *b) const
+{
+  *r = m_red;
+  *g = m_green;
+  *b = m_blue;
+}
+#endif
+
diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp
new file mode 100644
index 0000000000..5c7888dab5
--- /dev/null
+++ b/src/msw/combobox.cpp
@@ -0,0 +1,313 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        combobox.cpp
+// Purpose:     wxComboBox class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "combobox.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#endif
+
+#if USE_COMBOBOX
+
+#include "wx/combobox.h"
+#include "wx/clipbrd.h"
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
+#endif
+
+bool wxComboBox::MSWCommand(const WXUINT param, const WXWORD WXUNUSED(id))
+{
+  if (param == CBN_SELCHANGE)
+  {
+    wxCommandEvent event(wxEVENT_TYPE_COMBOBOX_COMMAND, m_windowId);
+    event.SetInt(GetSelection());
+    event.SetEventObject(this);
+    event.SetString(copystring(GetStringSelection()));
+    ProcessCommand(event);
+    delete[] event.GetString();
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+bool wxComboBox::Create(wxWindow *parent, const wxWindowID id,
+           const wxString& value,
+           const wxPoint& pos,
+           const wxSize& size,
+		   const int n, const wxString choices[],
+		   const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  SetName(name);
+  SetValidator(validator);
+  if (parent) parent->AddChild(this);
+  SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
+  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+  no_strings = n;
+
+  m_windowStyle = style;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  long msStyle = WS_CHILD | WS_HSCROLL | WS_VSCROLL
+                     | WS_TABSTOP | WS_VISIBLE | CBS_NOINTEGRALHEIGHT;
+  if (m_windowStyle & wxCB_READONLY)
+    msStyle |= CBS_DROPDOWNLIST;
+  else if (m_windowStyle & wxCB_SIMPLE) // A list (shown always) and edit control
+    msStyle |= CBS_SIMPLE;
+  else
+    msStyle |= CBS_DROPDOWN;
+
+  if (m_windowStyle & wxCB_SORT)
+    msStyle |= CBS_SORT;
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+    msStyle |= WS_BORDER;
+
+  HWND wx_combo = CreateWindowEx(exStyle, "COMBOBOX", NULL,
+                   msStyle,
+                   0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                   wxGetInstance(), NULL);
+/*
+#if CTL3D
+  if (want3D)
+  {
+    Ctl3dSubclassCtl(wx_combo);
+    m_useCtl3D = TRUE;
+  }
+#endif
+*/
+
+  m_hWnd = (WXHWND)wx_combo;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND)wx_combo);
+
+  SetFont(* parent->GetFont());
+  int i;
+  for (i = 0; i < n; i++)
+    SendMessage(wx_combo, CB_INSERTSTRING, i, (LONG)(const char *)choices[i]);
+  SendMessage(wx_combo, CB_SETCURSEL, i, 0);
+
+  SetSize(x, y, width, height);
+  if ( value != "" )
+    SetWindowText(wx_combo, (const char *)value);
+
+  return TRUE;
+}
+
+wxString wxComboBox::GetValue(void) const
+{
+  GetWindowText((HWND) GetHWND(), wxBuffer, 500);
+  return wxString(wxBuffer);
+}
+
+void wxComboBox::SetValue(const wxString& value)
+{
+  // If newlines are denoted by just 10, must stick 13 in front.
+  int singletons = 0;
+  int len = value.Length();
+  int i;
+  for (i = 0; i < len; i ++)
+  {
+    if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
+      singletons ++;
+  }
+  if (singletons > 0)
+  {
+    char *tmp = new char[len + singletons + 1];
+    int j = 0;
+    for (i = 0; i < len; i ++)
+    {
+      if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
+      {
+        tmp[j] = 13;
+        j ++;
+      }
+      tmp[j] = value[i];
+      j ++;
+    }
+    tmp[j] = 0;
+    SetWindowText((HWND) GetHWND(), tmp);
+    delete[] tmp;
+  }
+  else
+    SetWindowText((HWND) GetHWND(), (const char *)value);
+}
+
+// Clipboard operations
+void wxComboBox::Copy(void)
+{
+  HWND hWnd = (HWND) GetHWND();
+  SendMessage(hWnd, WM_COPY, 0, 0L);
+}
+
+void wxComboBox::Cut(void)
+{
+  HWND hWnd = (HWND) GetHWND();
+  SendMessage(hWnd, WM_CUT, 0, 0L);
+}
+
+void wxComboBox::Paste(void)
+{
+  HWND hWnd = (HWND) GetHWND();
+  SendMessage(hWnd, WM_PASTE, 0, 0L);
+}
+
+void wxComboBox::SetEditable(const bool editable)
+{
+  // Can't implement in MSW?
+//  HWND hWnd = (HWND) GetHWND();
+//  SendMessage(hWnd, EM_SETREADONLY, (WPARAM)!editable, (LPARAM)0L);
+}
+
+void wxComboBox::SetInsertionPoint(const long pos)
+{
+/*
+  HWND hWnd = (HWND) GetHWND();
+#ifdef __WIN32__
+  SendMessage(hWnd, EM_SETSEL, pos, pos);
+  SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
+#else
+  SendMessage(hWnd, EM_SETSEL, 0, MAKELPARAM(pos, pos));
+#endif
+  char *nothing = "";
+  SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)nothing);
+*/
+}
+
+void wxComboBox::SetInsertionPointEnd(void)
+{
+/*
+  long pos = GetLastPosition();
+  SetInsertionPoint(pos);
+*/
+}
+
+long wxComboBox::GetInsertionPoint(void) const
+{
+/*
+  DWORD Pos=(DWORD)SendMessage((HWND) GetHWND(), EM_GETSEL, 0, 0L);
+  return Pos&0xFFFF;
+*/
+  return 0;
+}
+
+long wxComboBox::GetLastPosition(void) const
+{
+/*
+    HWND hWnd = (HWND) GetHWND();
+
+    // Will always return a number > 0 (according to docs)
+    int noLines = (int)SendMessage(hWnd, EM_GETLINECOUNT, (WPARAM)0, (LPARAM)0L);
+
+    // This gets the char index for the _beginning_ of the last line
+    int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)(noLines-1), (LPARAM)0L);
+    
+    // Get number of characters in the last line. We'll add this to the character
+    // index for the last line, 1st position.
+    int lineLength = (int)SendMessage(hWnd, EM_LINELENGTH, (WPARAM)charIndex, (LPARAM)0L);
+
+    return (long)(charIndex + lineLength);
+*/
+  return 0;
+}
+
+void wxComboBox::Replace(const long from, const long to, const wxString& value)
+{
+#if USE_CLIPBOARD
+    HWND hWnd = (HWND) GetHWND();
+    long fromChar = from;
+    long toChar = to;
+    
+    // Set selection and remove it
+#ifdef __WIN32__
+    SendMessage(hWnd, CB_SETEDITSEL, fromChar, toChar);
+#else
+    SendMessage(hWnd, CB_SETEDITSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar));
+#endif
+    SendMessage(hWnd, WM_CUT, (WPARAM)0, (LPARAM)0);
+
+    // Now replace with 'value', by pasting.
+    wxSetClipboardData(wxCF_TEXT, (wxObject *)(const char *)value, 0, 0);
+
+    // Paste into edit control
+    SendMessage(hWnd, WM_PASTE, (WPARAM)0, (LPARAM)0L);
+#endif
+}
+
+void wxComboBox::Remove(const long from, const long to)
+{
+    HWND hWnd = (HWND) GetHWND();
+    long fromChar = from;
+    long toChar = to;
+    
+    // Cut all selected text
+#ifdef __WIN32__
+    SendMessage(hWnd, CB_SETEDITSEL, fromChar, toChar);
+#else
+    SendMessage(hWnd, CB_SETEDITSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar));
+#endif
+    SendMessage(hWnd, WM_CUT, (WPARAM)0, (LPARAM)0);
+}
+
+void wxComboBox::SetSelection(const long from, const long to)
+{
+    HWND hWnd = (HWND) GetHWND();
+    long fromChar = from;
+    long toChar = to;
+    // if from and to are both -1, it means
+    // (in wxWindows) that all text should be selected.
+    // This translates into Windows convention
+    if ((from == -1) && (to == -1))
+    {
+      fromChar = 0;
+      toChar = -1;
+    }
+    
+#ifdef __WIN32__
+    SendMessage(hWnd, CB_SETEDITSEL, (WPARAM)fromChar, (LPARAM)toChar);
+//    SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
+#else
+    // WPARAM is 0: selection is scrolled into view
+    SendMessage(hWnd, CB_SETEDITSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar));
+#endif
+}
+
+#endif
+ // USE_COMBOBOX
+
diff --git a/src/msw/control.cpp b/src/msw/control.cpp
new file mode 100644
index 0000000000..21c9567042
--- /dev/null
+++ b/src/msw/control.cpp
@@ -0,0 +1,372 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        control.cpp
+// Purpose:     wxControl class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "control.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/app.h"
+#include "wx/dcclient.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#if defined(__WIN95__) && !defined(__GNUWIN32__)
+#include <commctrl.h>
+#endif
+
+#ifdef GetCharWidth
+#undef GetCharWidth
+#undef GetWindowProc
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
+
+BEGIN_EVENT_TABLE(wxControl, wxWindow)
+	EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground)
+END_EVENT_TABLE()
+#endif
+
+// Item members
+wxControl::wxControl(void)
+{
+  m_backgroundColour = *wxWHITE;
+  m_foregroundColour = *wxBLACK;
+  m_callback = 0;
+}
+
+wxControl::~wxControl(void)
+{
+  m_isBeingDeleted = TRUE;
+
+  // If we delete an item, we should initialize the parent panel,
+  // because it could now be invalid.
+  wxWindow *parent = (wxWindow *)GetParent();
+  if (parent)
+  {
+    if (parent->GetDefaultItem() == this)
+        parent->SetDefaultItem(NULL);
+  }
+}
+
+void wxControl::SetLabel(const wxString& label)
+{
+  if (GetHWND())
+    SetWindowText((HWND) GetHWND(), (const char *)label);
+}
+
+wxString wxControl::GetLabel(void) const
+{
+  wxBuffer[0] = 0;
+  if (GetHWND())
+    GetWindowText((HWND)GetHWND(), wxBuffer, 1000);
+
+  return wxString(wxBuffer);
+}
+
+// Call this repeatedly for several wnds to find the overall size
+// of the widget.
+// Call it initially with -1 for all values in rect.
+// Keep calling for other widgets, and rect will be modified
+// to calculate largest bounding rectangle.
+void wxFindMaxSize(WXHWND wnd, RECT *rect)
+{
+  int left = rect->left;
+  int right = rect->right;
+  int top = rect->top;
+  int bottom = rect->bottom;
+
+  GetWindowRect((HWND) wnd, rect);
+
+  if (left < 0)
+    return;
+
+  if (left < rect->left)
+    rect->left = left;
+
+  if (right > rect->right)
+    rect->right = right;
+
+  if (top < rect->top)
+    rect->top = top;
+
+  if (bottom > rect->bottom)
+    rect->bottom = bottom;
+
+}
+
+/*
+// Not currently used
+void wxConvertDialogToPixels(wxWindow *control, int *x, int *y)
+{
+  if (control->m_windowParent && control->m_windowParent->is_dialog)
+  {
+    DWORD word = GetDialogBaseUnits();
+    int xs = LOWORD(word);
+    int ys = HIWORD(word);
+    *x = (int)(*x * xs/4);
+    *y = (int)(*y * ys/8);
+  }
+  else
+  {
+    *x = *x;
+    *y = *y;
+  }
+}
+*/
+
+#if 0
+// We can't rely on Windows giving us events corresponding to the wxWindows Z-ordering.
+// E.g. we can't push a wxGroupBox to the back for editing purposes.
+// Convert the item event to parent coordinates, then search for
+// an item that could receive this event.
+wxControl *wxFakeItemEvent(wxWindow *parent, wxControl *item, wxMouseEvent& event)
+{
+  int x, y;
+  item->GetPosition(&x, &y);
+  event.m_x += x;
+  event.m_y += y;
+
+  wxNode *node = parent->GetChildren()->Last();
+  while (node)
+  {
+    wxControl *newItem = (wxControl *)node->Data();
+    if (newItem->IsSelected() && newItem->SelectionHandleHitTest(event.x, event.GetY()))
+    {
+      // This event belongs to the panel.
+      parent->GetEventHandler()->OldOnMouseEvent(event);
+      return NULL;
+    }
+    else if (newItem->HitTest(event.x, event.GetY()))
+    {
+      int x1, y1;
+      newItem->GetPosition(&x1, &y1);
+      event.x -= x1;
+      event.GetY() -= y1;
+      newItem->OldOnMouseEvent(event);
+      return newItem;
+    }
+    node = node->Previous();
+  }
+  // No takers, so do what we would have done anyway.
+  event.x -= x;
+  event.y -= y;
+  item->OldOnMouseEvent(event);
+  return item;
+}
+#endif
+
+void wxControl::MSWOnMouseMove(const int x, const int y, const WXUINT flags)
+{
+  // 'normal' move event...
+  // Set cursor, but only if we're not in 'busy' mode
+
+/*
+  // Trouble with this is that it sets the cursor for controls too :-(
+  if (m_windowCursor.Ok() && !wxIsBusy())
+    ::SetCursor(m_windowCursor.GetHCURSOR());
+*/
+
+  wxMouseEvent event(wxEVENT_TYPE_MOTION);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime);
+  event.SetEventObject( this );
+
+  // Window gets a click down message followed by a mouse move
+  // message even if position isn't changed!  We want to discard
+  // the trailing move event if x and y are the same.
+  if ((m_lastEvent == wxEVENT_TYPE_RIGHT_DOWN || m_lastEvent == wxEVENT_TYPE_LEFT_DOWN ||
+       m_lastEvent == wxEVENT_TYPE_MIDDLE_DOWN) &&
+      (m_lastXPos == event.GetX() && m_lastYPos == event.GetY()))
+  {
+    m_lastXPos = event.GetX(); m_lastYPos = event.GetY();
+    m_lastEvent = wxEVENT_TYPE_MOTION;
+    return;
+  }
+
+  m_lastEvent = wxEVENT_TYPE_MOTION;
+  m_lastXPos = event.GetX(); m_lastYPos = event.GetY();
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+long wxControl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+  return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
+}
+
+bool wxControl::MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam)
+{
+#if defined(__WIN95__)
+	wxCommandEvent event(0, m_windowId);
+	int eventType = 0;
+	NMHDR *hdr1 = (NMHDR*) lParam;
+	switch ( hdr1->code )
+	{
+		case NM_CLICK:
+		{
+			eventType = wxEVT_COMMAND_LEFT_CLICK;
+			break;
+		}
+		case NM_DBLCLK:
+		{
+			eventType = wxEVT_COMMAND_LEFT_DCLICK;
+			break;
+		}
+		case NM_RCLICK:
+		{
+			eventType = wxEVT_COMMAND_RIGHT_CLICK;
+			break;
+		}
+		case NM_RDBLCLK:
+		{
+			eventType = wxEVT_COMMAND_RIGHT_DCLICK;
+			break;
+		}
+		case NM_SETFOCUS:
+		{
+			eventType = wxEVT_COMMAND_SET_FOCUS;
+			break;
+		}
+		case NM_KILLFOCUS:
+		{
+			eventType = wxEVT_COMMAND_KILL_FOCUS;
+			break;
+		}
+		case NM_RETURN:
+		{
+			eventType = wxEVT_COMMAND_ENTER;
+			break;
+		}
+/* Not implemented
+		case NM_OUTOFMEMORY:
+		{
+			eventType = wxEVT_COMMAND_OUT_OF_MEMORY;
+			break;
+		}
+*/
+		default :
+			return FALSE;
+			break;
+	}
+    event.SetEventType(eventType);
+	event.SetEventObject(this);
+
+	if ( !ProcessEvent(event) )
+		return FALSE;
+	return TRUE;
+#else
+  return FALSE;
+#endif
+}
+
+/*
+ * Allocates control IDs within the appropriate range
+ */
+
+
+int NewControlId(void)
+{
+  static int controlId = 0;
+  controlId ++;
+  return controlId;
+}
+
+void wxControl::ProcessCommand (wxCommandEvent & event)
+{
+  // Tries:
+  // 1) A callback function (to become obsolete)
+  // 2) OnCommand, starting at this window and working up parent hierarchy
+  // 3) OnCommand then calls ProcessEvent to search the event tables.
+  if (m_callback)
+    {
+      (void) (*(m_callback)) (*this, event);
+    }
+    else
+    {
+      GetEventHandler()->OnCommand(*this, event);
+    }
+}
+
+void wxControl::OnEraseBackground(wxEraseEvent& event)
+{
+  // In general, you don't want to erase the background of a control,
+  // or you'll get a flicker.
+  // TODO: move this 'null' function into each control that
+  // might flicker.
+
+  RECT rect;
+  ::GetClientRect((HWND) GetHWND(), &rect);
+
+  HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
+
+  ::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
+  ::DeleteObject(hBrush);
+  ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
+}
+
+void wxControl::SetClientSize (const int width, const int height)
+{
+  SetSize (-1, -1, width, height);
+}
+
+void wxControl::Centre (const int direction)
+{
+  int x, y, width, height, panel_width, panel_height, new_x, new_y;
+
+  wxWindow *parent = (wxWindow *) GetParent ();
+  if (!parent)
+    return;
+
+  parent->GetClientSize (&panel_width, &panel_height);
+  GetSize (&width, &height);
+  GetPosition (&x, &y);
+
+  new_x = x;
+  new_y = y;
+
+  if (direction & wxHORIZONTAL)
+    new_x = (int) ((panel_width - width) / 2);
+
+  if (direction & wxVERTICAL)
+    new_y = (int) ((panel_height - height) / 2);
+
+  SetSize (new_x, new_y, width, height);
+  int temp_x, temp_y;
+  GetPosition (&temp_x, &temp_y);
+  GetPosition (&temp_x, &temp_y);
+}
+
+
diff --git a/src/msw/curico.cpp b/src/msw/curico.cpp
new file mode 100644
index 0000000000..7644dead8a
--- /dev/null
+++ b/src/msw/curico.cpp
@@ -0,0 +1,899 @@
+//* Written by Microsoft Product Support Services, Windows Developer Support. *
+//*****************************************************************************
+//   (C) Copyright Microsoft Corp. 1993.  All rights reserved.
+//   You have a royalty-free right to use, modify, reproduce and
+//   distribute the Sample Files (and/or any modified version) in
+//   any way you find useful, provided that you agree that
+//   Microsoft has no warranty obligations or liability for any
+//   Sample Application Files which are modified.
+
+// Modified by Petr Smilauer, March 1994 for wxWin library purposes!
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#include <io.h>
+#include <windows.h>
+
+#ifdef __GNUWIN32__
+#include "wx/msw/gnuwin32/extra.h"
+#endif
+
+#include "wx/msw/curicop.h"
+#include "wx/msw/curico.h"
+
+//*****************************************************************************
+//* Function : ReadIconFile()                                                 *
+//* Purpose  : Reads an icon resource file and creates an icon based on that  *
+//*            information.                                                   *
+//* Parameters : char *szFileName - The icon resource file.                   *
+//* Returns :  A handle to an icon. The handle will be NULL if an icon cannot *
+//*            be created for any reason.                                     *
+//*****************************************************************************
+
+HICON ReadIconFile( char *szFileName, HINSTANCE hInst, int *W, int *H)
+{ HICON   hIcon;
+  HANDLE  hDIB;
+
+  if( (hDIB = ReadIcon(szFileName, W, H)) == NULL)
+                                          // read the icon DIB from file
+    return NULL;
+  hIcon = MakeIcon( hDIB, hInst);         // create an icon from DIB
+  GlobalFree( hDIB);
+  return hIcon;
+}
+
+//*****************************************************************************
+//* Function : CursorToIcon()                                                 *
+//* Purpose  : Reads a cursor resource file and creates an icon based on that *
+//*            information.                                                   *
+//* Parameters : char *szFileName - The cursor resource file.                 *
+//* Returns :  A handle to an icon. The handle will be NULL if an icon cannot *
+//*            be created for any reason.                                     *
+//* Comments : A cursor is monochrome. So, the resulting icon will also be    *
+//*            monochrome.                                                    *
+//*****************************************************************************
+
+HICON CursorToIcon( char *szFileName, HINSTANCE hInst, int *W, int *H)
+{ HANDLE  hDIB;     // Handle to DIB memory
+  HICON   hIcon;    // Handle to Icon
+
+  if( (hDIB = ReadCur( szFileName, NULL, W, H)) == NULL)
+                                                    // Read cursor DIB
+    return NULL;
+  hIcon = MakeIcon( hDIB, hInst);      // make icon from cursor DIB
+  GlobalFree( hDIB);
+  return hIcon;
+}
+
+//*****************************************************************************
+//* Function : ReadIcon()                                                     *
+//* Purpose  : Reads an icon resource file and extracts the DIB information.  *
+//* Parameters : char *szFileName - The icon resource file.                   *
+//* Returns :  A handle to a DIB. The handle will be NULL if the resource file*
+//*            is corrupt or if memory cannot be allocated for the DIB info.  *
+//*****************************************************************************
+
+HANDLE ReadIcon( char *szFileName, int *W, int *H)
+{ ICONFILEHEADER iconFileHead;   // ICON file header structure
+  ICONFILERES    iconFileRes;    // ICON file resource
+  WORD           cbHead,
+                 cbRes,
+                 cbBits;         // Used for reading in file
+  int            hFile;          // File handle
+  LPBITMAPINFO   lpDIB;          // Pointer to DIB memory
+  HANDLE         hDIB;
+  int            nWidth      = GetSystemMetrics( SM_CXICON),
+                 nHeight     = GetSystemMetrics( SM_CYICON),
+                 nDirEntries = 0;
+
+   // Open and read the .ICO file header and the first ICONFILERES
+  hFile  = _lopen( szFileName, OF_READ);
+  cbHead = _lread( hFile, (LPSTR)&iconFileHead, sizeof(ICONFILEHEADER));
+  cbRes  = _lread( hFile, (LPSTR)&iconFileRes, sizeof(ICONFILERES));
+  ++nDirEntries;
+
+  if((cbHead != sizeof( ICONFILEHEADER)) || (cbRes != sizeof( ICONFILERES)))
+    return NULL;
+
+  // Verify that it's an .ICON file
+  if( iconFileHead.wResourceType != 1)
+    return NULL;
+
+  // inserted by P.S.
+  while( (nDirEntries < iconFileHead.wResourceCount) &&
+         ((iconFileRes.bWidth != nWidth) || (iconFileRes.bHeight != nHeight)))
+  {
+    cbRes = _lread( hFile, (LPSTR )&iconFileRes, sizeof( ICONFILERES));
+    if(cbRes != sizeof( ICONFILERES))
+      return NULL;
+    else
+      ++nDirEntries;
+  }
+
+  if(W != 0)
+    *W = iconFileRes.bWidth;
+  if(H != 0)
+    *H = iconFileRes.bHeight;
+
+  // Allocate and lock memory to read in the DIB
+  hDIB = GlobalAlloc(GHND, iconFileRes.dwDIBSize);
+  if(hDIB == NULL)
+    return NULL;
+#ifdef __WINDOWS_386__
+  lpDIB = (LPBITMAPINFO)MK_FP32(GlobalLock(hDIB));
+#else
+  lpDIB = (LPBITMAPINFO)GlobalLock(hDIB);
+#endif
+
+  // Now read the DIB portion of the file, which follows the
+  // end of icon resource table
+  _llseek( hFile, iconFileRes.dwDIBOffset, 0);
+  cbBits = _lread( hFile, (LPSTR )lpDIB, (WORD )iconFileRes.dwDIBSize);
+
+  // Done reading file
+  _lclose(hFile);
+
+  GlobalUnlock( hDIB);
+
+  if( (DWORD )cbBits != iconFileRes.dwDIBSize)
+  {
+    GlobalFree( hDIB);
+    return NULL;
+  }
+  return hDIB;
+}
+
+//*****************************************************************************
+//* Function : MakeIcon()                                                     *
+//* Purpose  : Creates an icon based on the DIB info. returned by ReadIcon.   *
+//* Parameters : HANDLE hDIB - A handle to the icon's DIB information.        *
+//* Returns :  A handle to an Icon. NULL is returned if an icon cannot be     *
+//*            successfully created.                                          *
+//* Comments : The steps involved in making an icon from a DIB are very       *
+//*            similar to those involved in making a cursor from a DIB.       *
+//* Steps : 1) Obtain a pointer to the Icon's DIB bits.                       *
+//*         2) Divide the DIB'd height with 2 to account for the fact that the*
+//*            DIB stores both the XOR and the AND masks, one after the other.*
+//*         3) Determine the offset to the XOR bits.                          *
+//*         4) Determine the offset to the AND bits.                          *
+//*         5) Create a device dependent bitmap with the XOR bits.            *
+//*         6) Obtain the device dependent XOR bitmask and save in memory.    *
+//*            The AND bitmask is monochrome. Monochrome bits are identical   *
+//*            in both the device dependent bitmaps and device independent    *
+//*            bitmaps. So, no need to convert the AND bitmask.               *
+//*         7) Since a DIB is stored upside down, flip the monochrome AND bits*
+//*            by scanlines.                                                  *
+//*         8) Use the XOR and AND bits and create an icon with CreateIcon.   * 
+//*****************************************************************************
+
+HICON MakeIcon( HANDLE hDIB, HINSTANCE hInst)
+{ LPSTR         lpXORbits,
+                lpANDbits;    // Pointer to XOR and AND bits
+  HBITMAP       hbmXor;       // handle to XOR bitmap
+  BITMAP        bmpXor;       // Used to manipulate XOR bitmap
+  DWORD         dwBmpSize;    // Size of XOR bitmap
+  HANDLE        hXorDDB;
+  LPSTR         lpXorDDB;
+  LONG          szFlip[32];
+  int           j,
+                k;
+  HDC           hDC;
+  HICON         hIcon;
+  LPBITMAPINFO  lpDIB;
+
+  // 1) Obtain a pointer to the Icon's DIB bits.
+#ifdef __WINDOWS_386__
+  lpDIB = (LPBITMAPINFO )MK_FP32(GlobalLock( hDIB));
+#else
+  lpDIB = (LPBITMAPINFO )GlobalLock( hDIB);
+#endif
+
+  // 2) Divide the DIB'd height with 2 to account for the fact that the
+  //    DIB stores both the XOR and the AND masks, one after the other.
+  lpDIB->bmiHeader.biHeight /= 2;
+
+  // 3) Determine the offset to the XOR bits.
+  // To obtain this value, we have to skip the header, and color table
+  lpXORbits = (LPSTR )lpDIB + (int )lpDIB->bmiHeader.biSize +
+              (DIBNumColors( (LPSTR )lpDIB) * sizeof( RGBQUAD));
+
+  // 4) Determine the offset to the AND bits.
+  //    To obtain this value, skip the XOR bits
+  lpANDbits = lpXORbits + (int )(lpDIB->bmiHeader.biHeight *
+              (WIDTHBYTES ( lpDIB->bmiHeader.biWidth *
+                            lpDIB->bmiHeader.biBitCount)));
+
+  // Get a hDC so we can create a bitmap compatible with it
+  hDC = CreateDC( "DISPLAY", NULL, NULL, NULL);
+
+  // 5) Create a device dependent bitmap with the XOR bits.
+  hbmXor = CreateDIBitmap( hDC, (LPBITMAPINFOHEADER)&(lpDIB->bmiHeader),
+                           CBM_INIT, lpXORbits, lpDIB, DIB_RGB_COLORS);
+
+  GetObject( hbmXor, sizeof(BITMAP), (LPSTR)&bmpXor);
+
+  dwBmpSize = (DWORD )(bmpXor.bmWidthBytes * bmpXor.bmHeight * bmpXor.bmPlanes);
+  hXorDDB = GlobalAlloc( GHND, dwBmpSize);
+  if(hXorDDB == NULL)
+  {
+    // clean up before quitting
+    DeleteObject( hbmXor);
+    DeleteDC( hDC);
+    GlobalUnlock( hDIB);
+    return NULL;
+  }
+
+#ifdef __WINDOWS_386__
+  lpXorDDB = (LPSTR)MK_FP32(GlobalLock( hXorDDB));
+#else
+  lpXorDDB = (LPSTR)GlobalLock( hXorDDB);
+#endif
+
+  // 6) Obtain the device dependent XOR bitmask and save in memory.
+  // The AND bitmask is monochrome. Monochrome bits are identical
+  // in both the device dependent bitmaps and device independent
+  // bitmaps. So, no need to convert the AND bitmask.
+  GetBitmapBits( hbmXor, dwBmpSize, lpXorDDB);
+
+  // 7) Since a DIB is stored upside down, flip the monochrome AND bits by scanlines.
+  k = (int )lpDIB->bmiHeader.biHeight;
+  for( j = 0 ; j < k ; j++, lpANDbits += sizeof(DWORD))
+    szFlip[(k - 1) - j] = *(DWORD FAR *)lpANDbits;
+
+  // 8) Use the XOR and AND bits and create an icon with CreateIcon.
+  hIcon = CreateIcon( hInst, bmpXor.bmWidth, bmpXor.bmHeight, bmpXor.bmPlanes,
+                      bmpXor.bmBitsPixel, (const BYTE *)szFlip, (const BYTE *)lpXorDDB);
+
+  // Clean up before exiting.
+  DeleteObject( hbmXor);
+  GlobalUnlock( hXorDDB);
+  GlobalFree( hXorDDB);
+  DeleteDC( hDC);
+  GlobalUnlock( hDIB);
+
+  return hIcon;
+}
+
+// **************************************************************************
+
+//*****************************************************************************
+//* Function : ReadCursorFile()                                               *
+//* Purpose  : Reads a cursor resource file and creates a cursor based on that*
+//*            information.                                                   *
+//* Parameters : char *szFileName - The cursor resource file.                 *
+//* Returns :  A handle to a cursor. The handle will be NULL if a cursor can't*
+//*            be created for any reason.                                     *
+//*****************************************************************************
+
+HCURSOR ReadCursorFile( char *szFileName, HINSTANCE hInst, int *W, int *H,
+                        int *XHot, int *YHot)
+{ HANDLE    hDIB;    // Handle to DIB memory
+  HCURSOR   hCursor;
+  POINT     ptHotSpot;
+
+  // read cur DIB from file
+  if( (hDIB = ReadCur( szFileName, (LPPOINT )&ptHotSpot, W, H)) == NULL)
+    return NULL;
+  hCursor = MakeCursor( hDIB, (LPPOINT )&ptHotSpot, hInst);//create cur from DIB
+  if(XHot != 0)
+    *XHot = ptHotSpot.x;
+  if(YHot != 0)
+    *YHot = ptHotSpot.y;
+  GlobalFree( hDIB);
+  return ( hCursor);
+}
+
+//*****************************************************************************
+//* Function : IconToCursor()                                                 *
+//* Purpose  : Reads an icon resource file and creates a cursor based on that *
+//*            information.                                                   *
+//* Parameters : char *szFileName - The icon resource file.                   *
+//* Returns :  A handle to a cursor. The handle will be NULL if a cursor can't*
+//*            be created for any reason.                                     *
+//* Comments : An icon may be in color. So, the DIB has to be forced to be    *
+//*            monochrome.                                                    *
+//*****************************************************************************
+
+HCURSOR IconToCursor( char *szFileName, HINSTANCE hInst, int XHot, int YHot,
+                      int  *W, int *H)
+{ HCURSOR   hCursor;
+  HANDLE    hDIB;
+  POINT     ptHotSpot;
+
+  if( (hDIB = ReadIcon( szFileName, W, H)) == NULL)
+                                             //read icon file to get icon DIB
+    return NULL;
+  // Set the hot spot of the cursor
+  ptHotSpot.x = XHot;
+  ptHotSpot.y = YHot;
+  hCursor     = MakeCursor( hDIB, (LPPOINT )&ptHotSpot, hInst);
+                              //create cursor from DIB
+  GlobalFree( hDIB);
+  return hCursor;
+}
+
+//*****************************************************************************
+//* Function : ReadCur()                                                      *
+//* Purpose  : Reads a cursor resource file and extracts the DIB information. *
+//* Parameters : LPSTR szFileName - The cursor resource file.                 *
+//* Returns :  A handle to a DIB. The handle will be NULL if the resource file*
+//*            is corrupt or if memory cannot be allocated for the DIB info.  *
+//*****************************************************************************
+
+HANDLE ReadCur( char *szFileName, LPPOINT lpptHotSpot, int *W, int *H)
+{ CURFILEHEADER   curFileHead;  // CURSOR file header structure
+  CURFILERES      curFileRes;   // CURSOR file resource
+  WORD            cbHead,
+                  cbRes,
+                  cbBits;       // Used for reading in file
+  LPBITMAPINFO    lpDIB;        // Pointer to DIB memory
+  int             hFile;        // Handle to File
+  HANDLE          hDIB;
+  int             nWidth      = GetSystemMetrics( SM_CXCURSOR),
+                  nHeight     = GetSystemMetrics( SM_CYCURSOR),
+                  nDirEntries = 0;
+
+  // Open and read the .ICO file header and the first ICONFILERES
+  hFile  = _lopen( szFileName, OF_READ);
+  cbHead = _lread( hFile,  (LPSTR )&curFileHead, sizeof( CURFILEHEADER));
+  cbRes  = _lread( hFile,  (LPSTR )&curFileRes,  sizeof( CURFILERES));
+  ++nDirEntries;
+
+  if((cbHead != sizeof( CURFILEHEADER)) || (cbRes != sizeof( CURFILERES)))
+    return NULL;
+
+   // Verify that it's an .CUR file
+  if ((curFileRes.bReserved1 != 0) || (curFileHead.wResourceType != 2))
+    return NULL;
+
+  // following added by P.S.
+  while( (nDirEntries < curFileHead.wResourceCount) &&
+         ((curFileRes.bWidth != nWidth) || (curFileRes.bHeight != nHeight)))
+  {
+    cbRes = _lread( hFile, (LPSTR )&curFileRes, sizeof( CURFILERES));
+    if(cbRes != sizeof( CURFILERES))
+      return NULL;
+    else
+      ++nDirEntries;
+  }
+  if(W != 0)
+    *W = curFileRes.bWidth;
+  if(H != 0)
+    *H = curFileRes.bHeight;
+
+
+  // Allocate & lock memory to read in the DIB
+  hDIB = GlobalAlloc(GHND, curFileRes.dwDIBSize);
+  if(hDIB == NULL)
+    return NULL;
+
+#ifdef __WINDOWS_386__
+  lpDIB = (LPBITMAPINFO )MK_FP32(GlobalLock(hDIB));
+#else
+  lpDIB = (LPBITMAPINFO )GlobalLock(hDIB);
+#endif
+
+  // Now read the DIB portion of the file, which follows the
+  // end of icon resource table
+  _llseek( hFile, curFileRes.dwDIBOffset, 0);
+  cbBits = _lread( hFile, (LPSTR )lpDIB, (WORD )curFileRes.dwDIBSize);
+
+  // Done reading file
+  _lclose(hFile);
+
+  if((DWORD)cbBits != curFileRes.dwDIBSize)
+  {
+    GlobalUnlock( hDIB);
+    GlobalFree( hDIB);
+    return NULL;
+  }
+  if(lpptHotSpot != NULL)  // If it is necessary to know the hot spot
+  {
+    lpptHotSpot->x = (int )curFileRes.wXHotspot;
+    lpptHotSpot->y = (int )curFileRes.wYHotspot;
+  }
+  GlobalUnlock( hDIB);
+  return( hDIB);
+}
+
+//*****************************************************************************
+//* Function : ColorDDBToMonoDDB()                                            *
+//* Purpose  : Converts a color bitmap to a monochrome bitmap.                *
+//* Parameters : HBITMAP hbm - The color bitmap.                              *
+//* Returns :  A handle to a monochrome bitmap.                               *
+//*****************************************************************************
+HBITMAP ColorDDBToMonoDDB ( HBITMAP hbm)
+{ BITMAP              bm;
+  BITMAPINFOHEADER    bi;
+  LPBITMAPINFOHEADER  lpbi;
+  DWORD               dwLen;
+  HANDLE              hdib;
+  HANDLE              h;
+  HDC                 hdc;
+  HBITMAP             hbmMono;
+
+  GetObject( hbm, sizeof( bm), (LPSTR )&bm);
+
+  bi.biSize           = sizeof( BITMAPINFOHEADER);    // size of this structure
+  bi.biWidth          = bm.bmWidth;                   // bitmap width in pixels
+  bi.biHeight         = bm.bmHeight;                  // bitmap height in pixels
+  bi.biPlanes         = 1;                            // # of planes always 1 for DIBs
+  bi.biBitCount       = bm.bmPlanes * bm.bmBitsPixel; // color bits per pixel
+  bi.biCompression    = BI_RGB;                       // no compression
+  bi.biSizeImage      = 0;                            // 0 means default size
+  bi.biXPelsPerMeter  = 0;                            // not used
+  bi.biYPelsPerMeter  = 0;                            // not used
+  bi.biClrUsed        = 0;                            // 0 means default colors
+  bi.biClrImportant   = 0;                            // 0 means defaults
+
+  dwLen = bi.biSize + PaletteSize((LPSTR)&bi);
+
+  hdc = GetDC( NULL);
+
+  hdib = GlobalAlloc( GHND, dwLen);
+  if (hdib == NULL)
+  {
+    ReleaseDC( NULL, hdc);
+    return NULL;
+  }
+
+#ifdef __WINDOWS_386__
+  lpbi = (LPBITMAPINFOHEADER )MK_FP32(GlobalLock( hdib));
+#else
+  lpbi = (LPBITMAPINFOHEADER )GlobalLock( hdib);
+#endif
+
+  *lpbi = bi;
+
+  // Call GetDIBits with a NULL lpBits parameter; it will calculate
+  // the biSizeImage field.
+  GetDIBits( hdc, hbm, 0, (WORD)bi.biHeight,
+             NULL, (LPBITMAPINFO)lpbi, DIB_RGB_COLORS);
+
+  bi = *lpbi;
+  GlobalUnlock( hdib);
+
+  // If the driver did not fill in the biSizeImage field, make one up.
+  if(bi.biSizeImage == 0)
+    bi.biSizeImage = WIDTHBYTES( (DWORD )bm.bmWidth * bi.biBitCount) * bm.bmHeight;
+
+  // Reallocate the buffer big enough to hold all the bits.
+  dwLen = bi.biSize + PaletteSize((LPSTR)&bi) + bi.biSizeImage;
+  if( (h = GlobalReAlloc( hdib, dwLen, 0)) != 0)
+    hdib = h;
+  else
+  {
+    GlobalFree( hdib);
+    ReleaseDC( NULL, hdc);
+    return NULL;
+  }
+
+  // Call GetDIBits with a NON-NULL lpBits parameter, to actually
+  // get the bits this time.
+
+#ifdef __WINDOWS_386__
+  lpbi = (LPBITMAPINFOHEADER )MK_FP32(GlobalLock( hdib));
+#else
+  lpbi = (LPBITMAPINFOHEADER )GlobalLock( hdib);
+#endif
+
+  if( GetDIBits( hdc, hbm, 0, (WORD)bi.biHeight,
+                 (LPSTR)lpbi + (WORD)lpbi->biSize + PaletteSize((LPSTR)lpbi),
+                 (LPBITMAPINFO)lpbi, DIB_RGB_COLORS) == 0)
+  {
+    GlobalUnlock( hdib);
+    hdib = NULL;
+    ReleaseDC( NULL, hdc);
+    return NULL;
+  }
+
+  // Finally, create a monochrome DDB, and put the DIB into
+  // it. SetDIBits does smart color conversion.
+  hbmMono = CreateBitmap((WORD)lpbi->biWidth, (WORD)lpbi->biHeight, 1, 1, NULL);
+  SetDIBits( hdc, hbmMono, (WORD)0, (WORD)lpbi->biHeight,
+             (LPSTR)lpbi + (int )lpbi->biSize + PaletteSize((LPSTR)lpbi),
+             (LPBITMAPINFO)lpbi, DIB_RGB_COLORS);
+
+  bi = *lpbi;
+  GlobalUnlock( hdib);
+  GlobalFree( hdib);
+
+  ReleaseDC(NULL, hdc);
+  return hbmMono;
+}
+
+//*****************************************************************************
+//* Function : MakeCursor()                                                   *
+//* Purpose  : Creates a cursor based on the DIB info. returned by ReadCursor.*
+//* Parameters : HANDLE hDIB - A handle to the cursor's DIB information.      *
+//*              LPPOINT lppt - A pointer to a point struct. indicating the   *
+//*                             location of the Cursor's hot spot.            *
+//* Returns :  A handle to a cursor. NULL is returned if a cursor cannot be   *
+//*            successfully created.                                          *
+//* Comments : The steps involved in making a cursor from a DIB are very      *
+//*            similar to those involved in making an icon from a DIB.        *
+//* Steps : 1) Obtain a pointer to the Cursor's DIB bits.                     *
+//*         2) Divide the DIB's height with 2 to account for the fact that the*
+//*            DIB stores both the XOR and the AND masks, one after the other.*
+//*         3) Determine the offset to the XOR bits.                          *
+//*         4) Determine the offset to the AND bits.                          *
+//*         5) Create a device dependent bitmap with the XOR bits.            *
+//*         6) Obtain the device dependent XOR bitmask and save in memory.    *
+//*            The AND bitmask is monochrome. Monochrome bits are identical   *
+//*            in both the device dependent bitmaps and device independent    *
+//*            bitmaps. So, no need to convert the AND bitmask.               *
+//*         7) Since a DIB is stored upside down, flip the monochrome AND bits*
+//*            by scanlines.                                                  *
+//*         8) Use the XOR and AND bits and create a cursor with CreateCursor.*
+//*****************************************************************************
+
+HCURSOR MakeCursor( HANDLE hDIB, LPPOINT lpptHotSpot, HINSTANCE hInst)
+{ LPSTR         lpXORbits,
+                lpANDbits;    // Pointer to XOR and AND bits
+  HBITMAP       hbmXor;       // handle to XOR bitmap
+  BITMAP        bmpXor;       // Used to manipulate XOR bitmap
+  DWORD         dwBmpSize;    // Size of XOR bitmap
+  HCURSOR       hCursor;
+  HANDLE        hXorDDB;
+  LPSTR         lpXorDDB;
+  LONG          szFlip[32];
+  int           j,
+                k;
+  HDC           hDC;
+  LPBITMAPINFO  lpDIB;
+
+  // 1) Obtain a pointer to the Cursor's DIB bits.
+#ifdef __WINDOWS_386__
+  lpDIB = (LPBITMAPINFO )MK_FP32(GlobalLock( hDIB));
+#else
+  lpDIB = (LPBITMAPINFO )GlobalLock( hDIB);
+#endif
+
+  // 2) Divide the DIB's height with 2 to account for the fact that the
+  //    DIB stores both the XOR and the AND masks, one after the other.
+  lpDIB->bmiHeader.biHeight /= 2;
+
+  // 3) Determine the offset to the XOR bits.
+  //    To obtain this value, we have to skip the header, and color table
+  lpXORbits = (LPSTR )lpDIB + (int )lpDIB->bmiHeader.biSize +
+              (DIBNumColors((LPSTR)lpDIB) * sizeof(RGBQUAD));
+
+  // 4) Determine the offset to the AND bits
+  //    To obtain this value, skip the XOR bits
+  lpANDbits = lpXORbits + (int )( lpDIB->bmiHeader.biHeight *
+              (WIDTHBYTES( lpDIB->bmiHeader.biWidth *
+                           lpDIB->bmiHeader.biBitCount)));
+
+  // Get a hDC so we can create a bitmap compatible with it
+  hDC = CreateDC( "DISPLAY", NULL, NULL, NULL);
+
+  // 5) Create a device dependent bitmap with the XOR bits.
+  hbmXor = CreateBitmap( (int )lpDIB->bmiHeader.biWidth,
+                         (int )lpDIB->bmiHeader.biHeight, 1, 1, NULL);
+  SetDIBits( hDC, hbmXor, 0, (WORD)lpDIB->bmiHeader.biHeight, lpXORbits,
+             lpDIB, DIB_RGB_COLORS);
+  GetObject( hbmXor, sizeof( BITMAP), (LPSTR )&bmpXor);
+
+  dwBmpSize = (DWORD )(bmpXor.bmWidthBytes * bmpXor.bmHeight * bmpXor.bmPlanes);
+  hXorDDB = GlobalAlloc( GHND, dwBmpSize);
+  if(hXorDDB == NULL)
+  {  // clean up before quitting
+    DeleteObject( hbmXor);
+    DeleteDC( hDC);
+    GlobalUnlock( hDIB);
+    return NULL;
+  }
+#ifdef __WINDOWS_386__
+  lpXorDDB = (LPSTR)MK_FP32(GlobalLock( hXorDDB));
+#else
+  lpXorDDB = (LPSTR)GlobalLock( hXorDDB);
+#endif
+
+  // 6) Obtain the device dependent XOR bitmask and save in memory.
+  //    The AND bitmask is monochrome. Monochrome bits are identical
+  //    in both the device dependent bitmaps and device independent
+  //    bitmaps. So, no need to convert the AND bitmask.
+  GetBitmapBits( hbmXor, dwBmpSize, lpXorDDB);
+
+  // 7) Since a DIB is stored upside down, flip the monochrome AND bits by scanlines.
+  k = (int)lpDIB->bmiHeader.biHeight;
+  for( j = 0 ; j < k; j++, lpANDbits += sizeof( DWORD))
+    szFlip[(k - 1) - j] = *(DWORD FAR *)lpANDbits;
+
+  // 8) Use the XOR and AND bits and create a cursor with CreateCursor.
+  hCursor = CreateCursor( hInst, lpptHotSpot->x, lpptHotSpot->y,
+                          bmpXor.bmWidth, bmpXor.bmHeight, (LPSTR)szFlip, lpXorDDB);
+
+  // Clean up before exiting.
+  DeleteObject( hbmXor);
+  GlobalUnlock( hXorDDB);
+  GlobalFree( hXorDDB);
+  DeleteDC( hDC);
+  GlobalUnlock( hDIB);
+
+  return hCursor;
+}
+
+//*****************************************************************************
+//* Function : PaletteSize()                                                  *
+//* Purpose  : Calculates the palette size in bytes. If the info. block is of *
+//*            the BITMAPCOREHEADER type, the number of colors is multiplied  *
+//*            by sizeof(RGBTRIPLE) to give the palette size, otherwise the   *
+//*            number of colors is multiplied by sizeof(RGBQUAD).             *
+//* Parameters : LPSTR pv - pointer to the BITMAPINFOHEADER                   *
+//* Returns :  The size of the palette.                                       *
+//*****************************************************************************
+
+WORD PaletteSize( LPSTR pv)
+{ LPBITMAPINFOHEADER  lpbi;
+  WORD                NumColors;
+
+  lpbi      = (LPBITMAPINFOHEADER )pv;
+  NumColors = DIBNumColors((LPSTR )lpbi);
+
+  if(lpbi->biSize == sizeof( BITMAPCOREHEADER))  // OS/2 style DIBs
+    return NumColors * sizeof( RGBTRIPLE);
+  else
+    return NumColors * sizeof( RGBQUAD);
+}
+
+//*****************************************************************************
+//* Function : DIBNumColors()                                                 *
+//* Purpose  : This function calculates the number of colors in the DIB's     *
+//*            color table by finding the bits per pixel for the DIB (whether *
+//*            Win3.0 or OS/2-style DIB). If bits per pixel is 1: colors=2,   *
+//*            if 4: colors=16, if 8: colors=256, if 24, no colors in color   *
+//*            table.                                                         *
+//* Parameters : LPSTR lpbi - pointer to packed-DIB memory block.             *
+//* Returns :  The number of colors in the color table.                       *
+//*****************************************************************************
+
+WORD DIBNumColors ( LPSTR pv)
+{ int                 bits;
+  BITMAPINFOHEADER  *lpbi;
+  BITMAPCOREHEADER  *lpbc;
+
+  lpbi = ((BITMAPINFOHEADER* )pv);     // assume win 3.0 style DIBs
+  lpbc = ((BITMAPCOREHEADER* )pv);     // assume OS/2 style DIBs
+
+  // With the BITMAPINFO format headers, the size of the palette
+  // is in biClrUsed, whereas in the BITMAPCORE - style headers, it
+  // is dependent on the bits per pixel ( = 2 raised to the power of
+  // bits/pixel).
+    
+  if(lpbi->biSize != sizeof( BITMAPCOREHEADER))
+  {
+    if(lpbi->biClrUsed != 0)
+      return (WORD)lpbi->biClrUsed;
+    bits = lpbi->biBitCount;
+  }
+  else
+    bits = lpbc->bcBitCount;
+
+  switch( bits)
+  {
+    case 1:
+      return 2;
+    case 4:
+      return 16;
+    case 8:
+      return 256;
+    default:
+      // A 24 bitcount DIB has no color table
+      return 0;
+  }
+}
+
+#if 0
+// ******************************************************************
+BOOL fGetXPixmap( BOOL fIsIcon, char *szFileName, HINSTANCE hInst,
+                  char cData[], int &width, int &height)
+{ HDC       hdc,
+            hdcMemory;
+  HBITMAP   hbmp,
+            holdbmp;
+  int       i,
+            j,
+            w,
+            h;
+  BYTE     *s,
+            cByte,
+            cMask;
+  COLORREF  rgb;
+  HCURSOR   hIconOrCursor = fIsIcon ?
+                      IconToCursor( szFileName, hInst, 0, 0, &w, &h)
+                    : ReadCursorFile( szFileName, hInst, &w, &h, 0, 0);
+  int       sum;
+
+  if(hIconOrCursor == 0)
+    return FALSE;
+
+  hdc       = GetDC( GetDesktopWindow());
+  hdcMemory = CreateCompatibleDC( hdc);
+  hbmp      = CreateCompatibleBitmap( hdc, w, h);
+  holdbmp   = SelectObject( hdcMemory, hbmp);
+  PatBlt( hdcMemory, 0, 0, w, h, BLACKNESS); // or use WHITENESS??
+  DrawIcon( hdcMemory, 0, 0, hIconOrCursor); //using HCURSOR with DrawIcon is OK
+
+  // the data retrieval follows:
+  width  = w;
+  height = h;
+  for( j = 0, s = (BYTE *)cData ; j < h ; ++j)
+    for( i = 0 ; i < w ; ++i, cMask >>= 1)
+    {
+      if( (i % 8) == 0)
+      {
+        cByte = 0;
+        cMask = 0x80;
+      }
+      rgb  = GetPixel( hdcMemory, i, j);
+      sum  = (int )(rgb & 0xFFL);
+      sum += (int )((rgb & 0xFF00L) >> 8);
+      sum += (int )((rgb & 0xFF0000L) >> 16);
+      if(sum > 381)
+        cByte = cByte | cMask;
+      if( (i % 8) == 7)
+      {
+        *s = cByte;
+        ++s;
+      }
+    }
+  SelectObject( hdcMemory, holdbmp);
+  DeleteDC( hdcMemory);
+  ReleaseDC( GetDesktopWindow(), hdc);
+  DestroyCursor( hIconOrCursor);
+  DeleteObject( hbmp);
+  return TRUE;
+}
+#endif
+
+// Added from scavenged internet code, JACS 23/6/95
+HCURSOR MakeCursorFromBitmap(HINSTANCE hInst, HBITMAP hBitmap, POINT *pPoint)
+{
+  HDC hDCColor, hDCMono;
+  HDC hDC;
+  HBITMAP   hBmpOld;
+  HBITMAP   hAndBmp;
+  HBITMAP   hXorBmp;
+  HCURSOR   hNewCursor;
+  BITMAP    bm;
+  DWORD     dwBytes;
+  NPSTR     andBits;
+  NPSTR     xorBits;
+
+  hDC = GetDC(NULL);
+  hDCColor = CreateCompatibleDC(hDC);
+  hDCMono = CreateCompatibleDC(hDC);
+  hAndBmp = CreateCompatibleBitmap(hDCMono, 32, 32);
+  hXorBmp = CreateCompatibleBitmap(hDCMono, 32, 32);
+
+  hBmpOld = SelectObject(hDCColor, hBitmap);
+  SelectObject(hDCMono, hAndBmp);
+  SetBkColor(hDCColor, RGB(191, 191, 191));
+
+  BitBlt(hDCMono, 0, 0, 32, 32, hDCColor, 0, 0, SRCCOPY);
+
+  // Now we have the AND Mask
+
+  GetObject(hAndBmp, sizeof(BITMAP), (LPSTR) &bm);
+  dwBytes = (bm.bmWidthBytes * bm.bmHeight);
+  andBits = (NPSTR) LocalAlloc(LPTR, dwBytes);
+  GetBitmapBits(hAndBmp, dwBytes, andBits);
+
+  SelectObject(hDCMono, hXorBmp);
+  SetBkColor(hDCColor, RGB(0, 0, 0));
+
+  BitBlt(hDCMono, 0, 0, 32, 32, hDCColor, 0, 0, SRCCOPY);
+
+  // Now we have the XOR Mask
+
+  GetObject(hXorBmp, sizeof(BITMAP), (LPSTR) &bm);
+  dwBytes = (bm.bmWidthBytes * bm.bmHeight);
+  xorBits = (NPSTR) LocalAlloc(LPTR, dwBytes);
+  GetBitmapBits(hXorBmp, dwBytes, xorBits);
+
+  if (pPoint->x > 32)
+    pPoint->x = 32;
+  if (pPoint->y > 32)
+    pPoint->y = 32;
+
+  hNewCursor = CreateCursor(hInst,
+                            pPoint->x, pPoint->y, 32, 32, andBits, xorBits);
+
+  SelectObject(hDCColor, hBmpOld);
+  SelectObject(hDCMono, hBmpOld);
+  DeleteDC(hDCColor);
+  DeleteDC(hDCMono);
+  DeleteObject(hAndBmp);
+  DeleteObject(hXorBmp);
+  ReleaseDC(NULL, hDC);
+#ifndef __WIN32__
+  LocalUnlock(LocalHandle((WORD) andBits));
+  LocalUnlock(LocalHandle((WORD) xorBits));
+  LocalFree(LocalHandle((WORD) andBits));
+  LocalFree(LocalHandle((WORD) xorBits));
+#else
+  LocalUnlock(LocalHandle((LPCVOID) andBits));
+  LocalUnlock(LocalHandle((LPCVOID) xorBits));
+  LocalFree(LocalHandle((LPCVOID) andBits));
+  LocalFree(LocalHandle((LPCVOID) xorBits));
+#endif
+  return hNewCursor;
+}
+
+/*
+ * This doesn't work: just gives us a grey square. Ideas, anyone?
+ */
+ 
+HICON MakeIconFromBitmap(HINSTANCE hInst, HBITMAP hBitmap)
+{
+  HDC hDCColor, hDCMono;
+  HDC hDC;
+  HBITMAP   hBmpOld;
+  HBITMAP   hAndBmp;
+  HBITMAP   hXorBmp;
+  HICON     hNewIcon;
+  BITMAP    bm;
+  DWORD     dwBytes;
+  NPSTR     andBits;
+  NPSTR     xorBits;
+
+  hDC = GetDC(NULL);
+  hDCColor = CreateCompatibleDC(hDC);
+  hDCMono = CreateCompatibleDC(hDC);
+  hAndBmp = CreateCompatibleBitmap(hDCMono, 32, 32);
+  hXorBmp = CreateCompatibleBitmap(hDCMono, 32, 32);
+
+  hBmpOld = SelectObject(hDCColor, hBitmap);
+  SelectObject(hDCMono, hAndBmp);
+  SetBkColor(hDCColor, RGB(191, 191, 191));
+
+  BitBlt(hDCMono, 0, 0, 32, 32, hDCColor, 0, 0, SRCCOPY);
+
+  // Now we have the AND Mask
+
+  GetObject(hAndBmp, sizeof(BITMAP), (LPSTR) &bm);
+  dwBytes = (bm.bmWidthBytes * bm.bmHeight);
+  andBits = (NPSTR) LocalAlloc(LPTR, dwBytes);
+  GetBitmapBits(hAndBmp, dwBytes, andBits);
+
+  SelectObject(hDCMono, hXorBmp);
+  SetBkColor(hDCColor, RGB(0, 0, 0));
+
+  BitBlt(hDCMono, 0, 0, 32, 32, hDCColor, 0, 0, SRCCOPY);
+
+  // Now we have the XOR Mask
+
+  GetObject(hXorBmp, sizeof(BITMAP), (LPSTR) &bm);
+  dwBytes = (bm.bmWidthBytes * bm.bmHeight);
+  xorBits = (NPSTR) LocalAlloc(LPTR, dwBytes);
+  GetBitmapBits(hXorBmp, dwBytes, xorBits);
+
+  hNewIcon = CreateIcon(hInst, 1, 4, 32, 32, (unsigned char *)andBits, (unsigned char *)xorBits);
+
+  SelectObject(hDCColor, hBmpOld);
+  SelectObject(hDCMono, hBmpOld);
+  DeleteDC(hDCColor);
+  DeleteDC(hDCMono);
+  DeleteObject(hAndBmp);
+  DeleteObject(hXorBmp);
+  ReleaseDC(NULL, hDC);
+#ifndef __WIN32__
+  LocalUnlock(LocalHandle((WORD) andBits));
+  LocalUnlock(LocalHandle((WORD) xorBits));
+  LocalFree(LocalHandle((WORD) andBits));
+  LocalFree(LocalHandle((WORD) xorBits));
+#else
+  LocalUnlock(LocalHandle((LPCVOID) andBits));
+  LocalUnlock(LocalHandle((LPCVOID) xorBits));
+  LocalFree(LocalHandle((LPCVOID) andBits));
+  LocalFree(LocalHandle((LPCVOID) xorBits));
+#endif
+  return hNewIcon;
+}
+
diff --git a/src/msw/cursor.cpp b/src/msw/cursor.cpp
new file mode 100644
index 0000000000..6ca9e1bc07
--- /dev/null
+++ b/src/msw/cursor.cpp
@@ -0,0 +1,279 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        cursor.cpp
+// Purpose:     wxCursor class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "cursor.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/list.h"
+#include "wx/utils.h"
+#include "wx/app.h"
+#include "wx/cursor.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "wx/msw/dib.h"
+
+#include "assert.h"
+
+#if USE_XPM_IN_MSW
+#define FOR_MSW 1
+#include "..\..\contrib\wxxpm\libxpm.34b\lib\xpm34.h"
+#endif
+
+#if USE_RESOURCE_LOADING_IN_MSW
+#include "wx/msw/curico.h"
+#include "wx/msw/curicop.h"
+#endif
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
+#endif
+
+wxCursorRefData::wxCursorRefData(void)
+{
+  m_width = 32; m_height = 32;
+  m_hCursor = 0 ;
+  m_destroyCursor = FALSE;
+}
+
+wxCursorRefData::~wxCursorRefData(void)
+{
+	if ( m_hCursor && m_destroyCursor)
+		::DestroyCursor((HICON) m_hCursor);
+}
+
+// Cursors
+wxCursor::wxCursor(void)
+{
+}
+
+wxCursor::wxCursor(const char WXUNUSED(bits)[], const int WXUNUSED(width), const int WXUNUSED(height),
+    const int WXUNUSED(hotSpotX), const int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
+{
+}
+
+wxCursor::wxCursor(const wxString& cursor_file, const long flags, const int hotSpotX, const int hotSpotY)
+{
+  m_refData = new wxIconRefData;
+
+  M_CURSORDATA->m_destroyCursor = FALSE;
+  M_CURSORDATA->m_hCursor = 0;
+  M_CURSORDATA->m_ok = FALSE;
+  if (flags & wxBITMAP_TYPE_CUR_RESOURCE)
+  {
+    M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), cursor_file);
+    if (M_CURSORDATA->m_hCursor)
+      M_CURSORDATA->m_ok = TRUE;
+    else
+      M_CURSORDATA->m_ok = FALSE;
+  }
+  else if (flags & wxBITMAP_TYPE_CUR)
+  {
+#if USE_RESOURCE_LOADING_IN_MSW
+    M_CURSORDATA->m_hCursor = (WXHCURSOR) ReadCursorFile((char *)(const char *)cursor_file, wxGetInstance(), &M_CURSORDATA->m_width, &M_CURSORDATA->m_height);
+	M_CURSORDATA->m_destroyCursor = TRUE;
+#endif
+  }
+  else if (flags & wxBITMAP_TYPE_ICO)
+  {
+#if USE_RESOURCE_LOADING_IN_MSW
+    M_CURSORDATA->m_hCursor = (WXHCURSOR) IconToCursor((char *)(const char *)cursor_file, wxGetInstance(), hotSpotX, hotSpotY, &M_CURSORDATA->m_width, &M_CURSORDATA->m_height);
+	M_CURSORDATA->m_destroyCursor = TRUE;
+#endif
+  }
+  else if (flags & wxBITMAP_TYPE_BMP)
+  {
+#if USE_RESOURCE_LOADING_IN_MSW
+    HBITMAP hBitmap = 0;
+    HPALETTE hPalette = 0;
+    bool success = ReadDIB((char *)(const char *)cursor_file, &hBitmap, &hPalette);
+    if (!success)
+      return;
+    if (hPalette)
+      DeleteObject(hPalette);
+    POINT pnt;
+    pnt.x = hotSpotX;
+    pnt.y = hotSpotY;
+    M_CURSORDATA->m_hCursor = (WXHCURSOR) MakeCursorFromBitmap(wxGetInstance(), hBitmap, &pnt);
+	M_CURSORDATA->m_destroyCursor = TRUE;
+    DeleteObject(hBitmap);
+    if (M_CURSORDATA->m_hCursor)
+      M_CURSORDATA->m_ok = TRUE;
+#endif
+  }
+}
+
+// Cursors by stock number
+wxCursor::wxCursor(const int cursor_type)
+{
+  m_refData = new wxIconRefData;
+
+  switch (cursor_type)
+  {
+    case wxCURSOR_WAIT:
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT);
+      break;
+    case wxCURSOR_IBEAM:
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_IBEAM);
+      break;
+    case wxCURSOR_CROSS:
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS);
+      break;
+    case wxCURSOR_SIZENWSE:
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENWSE);
+      break;
+    case wxCURSOR_SIZENESW:
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENESW);
+      break;
+    case wxCURSOR_SIZEWE:
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZEWE);
+      break;
+    case wxCURSOR_SIZENS:
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENS);
+      break;
+    case wxCURSOR_CHAR:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
+      break;
+    }
+    case wxCURSOR_HAND:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_HAND");
+      break;
+    }
+    case wxCURSOR_BULLSEYE:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BULLSEYE");
+      break;
+    }
+    case wxCURSOR_PENCIL:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PENCIL");
+      break;
+    }
+    case wxCURSOR_MAGNIFIER:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_MAGNIFIER");
+      break;
+    }
+    case wxCURSOR_NO_ENTRY:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_NO_ENTRY");
+      break;
+    }
+    case wxCURSOR_LEFT_BUTTON:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
+      break;
+    }
+    case wxCURSOR_RIGHT_BUTTON:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
+      break;
+    }
+    case wxCURSOR_MIDDLE_BUTTON:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
+      break;
+    }
+    case wxCURSOR_SIZING:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_SIZING");
+      break;
+    }
+    case wxCURSOR_WATCH:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_WATCH");
+      break;
+    }
+    case wxCURSOR_SPRAYCAN:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_ROLLER");
+      break;
+    }
+    case wxCURSOR_PAINT_BRUSH:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PBRUSH");
+      break;
+    }
+    case wxCURSOR_POINT_LEFT:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PLEFT");
+      break;
+    }
+    case wxCURSOR_POINT_RIGHT:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PRIGHT");
+      break;
+    }
+    case wxCURSOR_QUESTION_ARROW:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_QARROW");
+      break;
+    }
+    case wxCURSOR_BLANK:
+    {
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK");
+      break;
+    }
+    default:
+    case wxCURSOR_ARROW:
+      M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
+      break;
+  }
+}
+
+wxCursor::~wxCursor(void)
+{
+//	FreeResource(TRUE);
+}
+
+bool wxCursor::FreeResource(bool force)
+{
+  if (M_CURSORDATA && M_CURSORDATA->m_hCursor && M_CURSORDATA->m_destroyCursor)
+  {
+    DestroyCursor((HCURSOR) M_CURSORDATA->m_hCursor);
+	M_CURSORDATA->m_hCursor = 0;
+  }
+  return TRUE;
+}
+
+void wxCursor::SetHCURSOR(WXHCURSOR cursor)
+{
+  if ( !M_CURSORDATA )
+	m_refData = new wxCursorRefData;
+
+  M_CURSORDATA->m_hCursor = cursor;
+}
+
+// Global cursor setting
+void wxSetCursor(const wxCursor& cursor)
+{
+  extern wxCursor *g_globalCursor;
+  if ( g_globalCursor )
+    (*g_globalCursor) = cursor;
+
+  if (cursor.Ok() && cursor.GetHCURSOR())
+    ::SetCursor((HCURSOR) cursor.GetHCURSOR());
+}
+
+
diff --git a/src/msw/data.cpp b/src/msw/data.cpp
new file mode 100644
index 0000000000..dfc8022216
--- /dev/null
+++ b/src/msw/data.cpp
@@ -0,0 +1,723 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        data.cpp
+// Purpose:     Various data
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#define _MAXPATHLEN 500
+
+// Useful buffer, initialized in wxCommonInit
+char *wxBuffer = NULL;
+
+// Windows List
+wxList wxTopLevelWindows;
+
+// List of windows pending deletion
+wxList wxPendingDelete;
+
+// Current cursor, in order to hang on to
+// cursor handle when setting the cursor globally
+wxCursor *g_globalCursor = NULL;
+
+// Message Strings for Internationalization
+char **wx_msg_str = (char**)NULL;
+
+// Custom OS version, as optionally placed in wx.ini/.wxrc
+// Currently this can be Win95, Windows, Win32s, WinNT.
+// For some systems, you can't tell until run-time what services you
+// have. See wxGetOsVersion, which uses this string if present.
+char *wxOsVersion = NULL;
+
+int wxPageNumber;
+
+// GDI Object Lists
+wxBrushList *wxTheBrushList = NULL;
+wxPenList   *wxThePenList = NULL;
+wxFontList   *wxTheFontList = NULL;
+wxBitmapList   *wxTheBitmapList = NULL;
+
+wxColourDatabase *wxTheColourDatabase = NULL;
+
+// Stock objects
+wxFont *wxNORMAL_FONT;
+wxFont *wxSMALL_FONT;
+wxFont *wxITALIC_FONT;
+wxFont *wxSWISS_FONT;
+wxPen *wxRED_PEN;
+
+wxPen *wxCYAN_PEN;
+wxPen *wxGREEN_PEN;
+wxPen *wxBLACK_PEN;
+wxPen *wxWHITE_PEN;
+wxPen *wxTRANSPARENT_PEN;
+wxPen *wxBLACK_DASHED_PEN;
+wxPen *wxGREY_PEN;
+wxPen *wxMEDIUM_GREY_PEN;
+wxPen *wxLIGHT_GREY_PEN;
+
+wxBrush *wxBLUE_BRUSH;
+wxBrush *wxGREEN_BRUSH;
+wxBrush *wxWHITE_BRUSH;
+wxBrush *wxBLACK_BRUSH;
+wxBrush *wxTRANSPARENT_BRUSH;
+wxBrush *wxCYAN_BRUSH;
+wxBrush *wxRED_BRUSH;
+wxBrush *wxGREY_BRUSH;
+wxBrush *wxMEDIUM_GREY_BRUSH;
+wxBrush *wxLIGHT_GREY_BRUSH;
+
+wxColour *wxBLACK;
+wxColour *wxWHITE;
+wxColour *wxRED;
+wxColour *wxBLUE;
+wxColour *wxGREEN;
+wxColour *wxCYAN;
+wxColour *wxLIGHT_GREY;
+
+wxCursor *wxSTANDARD_CURSOR = NULL;
+wxCursor *wxHOURGLASS_CURSOR = NULL;
+wxCursor *wxCROSS_CURSOR = NULL;
+
+// 'Null' objects
+wxBitmap wxNullBitmap;
+wxIcon   wxNullIcon;
+wxCursor wxNullCursor;
+wxPen    wxNullPen;
+wxBrush  wxNullBrush;
+wxPalette wxNullPalette;
+wxFont   wxNullFont;
+wxColour wxNullColour;
+
+// Default window names
+const char *wxButtonNameStr = "button";
+const char *wxCanvasNameStr = "canvas";
+const char *wxCheckBoxNameStr = "check";
+const char *wxChoiceNameStr = "choice";
+const char *wxComboBoxNameStr = "comboBox";
+const char *wxDialogNameStr = "dialog";
+const char *wxFrameNameStr = "frame";
+const char *wxGaugeNameStr = "gauge";
+const char *wxStaticBoxNameStr = "groupBox";
+const char *wxListBoxNameStr = "listBox";
+const char *wxStaticTextNameStr = "message";
+const char *wxStaticBitmapNameStr = "message";
+const char *wxMultiTextNameStr = "multitext";
+const char *wxPanelNameStr = "panel";
+const char *wxRadioBoxNameStr = "radioBox";
+const char *wxRadioButtonNameStr = "radioButton";
+const char *wxBitmapRadioButtonNameStr = "radioButton";
+const char *wxScrollBarNameStr = "scrollBar";
+const char *wxSliderNameStr = "slider";
+const char *wxStaticNameStr = "static";
+const char *wxTextCtrlWindowNameStr = "textWindow";
+const char *wxTextCtrlNameStr = "text";
+const char *wxVirtListBoxNameStr = "virtListBox";
+const char *wxButtonBarNameStr = "buttonbar";
+const char *wxEnhDialogNameStr = "Shell";
+const char *wxToolBarNameStr = "toolbar";
+const char *wxStatusLineNameStr = "status_line";
+const char *wxEmptyString = "";
+const char *wxGetTextFromUserPromptStr = "Input Text";
+const char *wxMessageBoxCaptionStr = "Message";
+const char *wxFileSelectorPromptStr = "Select a file";
+const char *wxFileSelectorDefaultWildcardStr = "*.*";
+const char *wxInternalErrorStr = "wxWindows Internal Error";
+const char *wxFatalErrorStr = "wxWindows Fatal Error";
+
+// See wx/utils.h
+const char *wxFloatToStringStr = "%.2f";
+const char *wxDoubleToStringStr = "%.2f";
+
+#ifdef __WINDOWS__
+const char *wxUserResourceStr = "TEXT";
+#endif
+
+
+#if USE_SHARED_LIBRARY
+/*
+ * For wxWindows to be made into a dynamic library (e.g. Sun),
+ * all IMPLEMENT_... macros must be in one place.
+ * But normally, the definitions are in the appropriate places.
+ */
+
+// Hand-coded IMPLEMENT... macro for wxObject (define static data)
+wxClassInfo wxObject::classwxObject("wxObject", NULL, NULL, sizeof(wxObject), NULL);
+wxClassInfo *wxClassInfo::first = NULL;
+
+#include "wx/button.h"
+#include "wx/bmpbuttn.h"
+IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
+
+#include "wx/checkbox.h"
+IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
+
+#include "wx/choice.h"
+IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
+
+#if USE_CLIPBOARD
+#include "wx/clipbrd.h"
+IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
+#endif
+
+#if USE_COMBOBOX
+#include "wx/combobox.h"
+IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
+#endif
+
+#include "wx/dc.h"
+#include "wx/dcmemory.h"
+#include "wx/dcclient.h"
+#include "wx/dcscreen.h"
+IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxDC)
+IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
+IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxDC)
+IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
+IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
+
+#if defined(__WINDOWS__)
+#include "wx/dcprint.h"
+IMPLEMENT_CLASS(wxPrinterDC, wxDC)
+#endif
+
+#include "wx/dialog.h"
+IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxWindow)
+
+#include "wx/frame.h"
+IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
+
+#include "wx/mdi.h"
+IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
+IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
+IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
+
+#include "wx/cmndata.h"
+IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject)
+
+#include "wx/colordlg.h"
+#include "wx/fontdlg.h"
+
+#if !defined(__WINDOWS__) || USE_GENERIC_DIALOGS_IN_MSW
+#include "wx/generic/colordlg.h"
+#include "wx/generic/fontdlg.h"
+IMPLEMENT_DYNAMIC_CLASS(wxGenericColourDialog, wxDialog)
+IMPLEMENT_DYNAMIC_CLASS(wxGenericFontDialog, wxDialog)
+#endif
+
+// X defines wxColourDialog to be wxGenericColourDialog
+#ifndef __X__
+IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
+IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
+#endif
+
+#include "wx/gdicmn.h"
+#include "wx/pen.h"
+#include "wx/brush.h"
+#include "wx/font.h"
+#include "wx/palette.h"
+#include "wx/icon.h"
+#include "wx/cursor.h"
+
+IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
+IMPLEMENT_CLASS(wxColourDatabase, wxList)
+IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList)
+IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList)
+IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList)
+
+#if (!USE_TYPEDEFS)
+IMPLEMENT_DYNAMIC_CLASS(wxPoint, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxRealPoint, wxObject)
+#endif
+
+#include "wx/hash.h"
+IMPLEMENT_DYNAMIC_CLASS(wxHashTable, wxObject)
+
+#include "wx/helpbase.h"
+IMPLEMENT_CLASS(wxHelpControllerBase, wxObject)
+
+#if USE_HELP
+
+#ifdef __WINDOWS__
+#include "wx/msw/helpwin.h"
+IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
+#endif
+
+// Generic wxHelp controller
+IMPLEMENT_CLASS(wxXLPHelpController, wxHelpControllerBase)
+
+#ifdef __WINDOWS__
+IMPLEMENT_CLASS(wxXLPHelpClient, wxDDEClient)
+IMPLEMENT_CLASS(wxXLPHelpConnection, wxDDEConnection)
+#else
+IMPLEMENT_CLASS(wxXLPHelpClient, wxTCPClient)
+IMPLEMENT_CLASS(wxXLPHelpConnection, wxTCPConnection)
+#endif
+
+#endif
+
+IMPLEMENT_DYNAMIC_CLASS(wxString, wxObject)
+
+#include "wx/list.h"
+IMPLEMENT_DYNAMIC_CLASS(wxNode, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxList, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxStringList, wxList)
+
+#if USE_PRINTING_ARCHITECTURE
+#include "wx/print.h"
+IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
+IMPLEMENT_DYNAMIC_CLASS(wxPrinterBase, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxPostScriptPrinter, wxPrinterBase)
+IMPLEMENT_DYNAMIC_CLASS(wxWindowsPrinter, wxPrinterBase)
+IMPLEMENT_ABSTRACT_CLASS(wxPrintout, wxObject)
+IMPLEMENT_CLASS(wxPreviewCanvas, wxWindow)
+IMPLEMENT_CLASS(wxPreviewControlBar, wxWindow)
+IMPLEMENT_CLASS(wxPreviewFrame, wxFrame)
+IMPLEMENT_CLASS(wxPrintPreviewBase, wxObject)
+IMPLEMENT_CLASS(wxPostScriptPrintPreview, wxPrintPreviewBase)
+IMPLEMENT_CLASS(wxWindowsPrintPreview, wxPrintPreviewBase)
+IMPLEMENT_CLASS(wxGenericPrintDialog, wxDialog)
+IMPLEMENT_CLASS(wxGenericPrintSetupDialog, wxDialog)
+#endif
+
+#if USE_POSTSCRIPT
+#include "wx/postscrp.h"
+IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC)
+IMPLEMENT_DYNAMIC_CLASS(wxPrintSetupData, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxPageSetupData, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList)
+#endif
+
+#if USE_WX_RESOURCES
+#include "wx/resource.h"
+IMPLEMENT_DYNAMIC_CLASS(wxItemResource, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable)
+#endif
+
+#include "wx/event.h"
+IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxShowEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxEvent)
+
+#include "wx/utils.h"
+IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxList)
+
+IMPLEMENT_DYNAMIC_CLASS(wxRect, wxObject)
+
+#if USE_TIMEDATE
+#include "wx/date.h"
+IMPLEMENT_DYNAMIC_CLASS(wxDate, wxObject)
+#endif
+
+#if USE_DOC_VIEW_ARCHITECTURE
+#include "wx/docview.h"
+//IMPLEMENT_ABSTRACT_CLASS(wxDocItem, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxDocument, wxEvtHandler)
+IMPLEMENT_ABSTRACT_CLASS(wxView, wxEvtHandler)
+IMPLEMENT_ABSTRACT_CLASS(wxDocTemplate, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxDocManager, wxEvtHandler)
+IMPLEMENT_CLASS(wxDocChildFrame, wxFrame)
+IMPLEMENT_CLASS(wxDocParentFrame, wxFrame)
+#if USE_PRINTING_ARCHITECTURE
+IMPLEMENT_DYNAMIC_CLASS(wxDocPrintout, wxPrintout)
+#endif
+IMPLEMENT_CLASS(wxCommand, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxCommandProcessor, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxFileHistory, wxObject)
+#endif
+
+#if USE_CONSTRAINTS
+#include "wx/layout.h"
+IMPLEMENT_DYNAMIC_CLASS(wxIndividualLayoutConstraint, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxLayoutConstraints, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxSizer, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxRowColSizer, wxSizer)
+#endif
+
+#if USE_TOOLBAR
+#include "wx/tbarbase.h"
+IMPLEMENT_DYNAMIC_CLASS(wxToolBarTool, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxToolBarBase, wxControl)
+
+#include "wx/tbarsmpl.h"
+IMPLEMENT_DYNAMIC_CLASS(wxToolBarSimple, wxToolBarBase)
+
+#ifdef __WINDOWS__
+#include "wx/tbarmsw.h"
+IMPLEMENT_DYNAMIC_CLASS(wxToolBarMSW, wxToolBarBase)
+
+#include "wx/tbar95.h"
+IMPLEMENT_DYNAMIC_CLASS(wxToolBar95, wxToolBarBase)
+#endif
+
+#endif
+
+#include "wx/statusbr.h"
+
+IMPLEMENT_DYNAMIC_CLASS(wxStatusBar, wxWindow)
+
+BEGIN_EVENT_TABLE(wxStatusBar, wxWindow)
+	EVT_PAINT(wxStatusBar::OnPaint)
+    EVT_SYS_COLOUR_CHANGED(wxStatusBar::OnSysColourChanged)
+END_EVENT_TABLE()
+
+#if USE_TIMEDATE
+#include "wx/time.h"
+IMPLEMENT_DYNAMIC_CLASS(wxTime, wxObject)
+#endif
+
+#if !USE_GNU_WXSTRING
+#include "wx/string.h"
+IMPLEMENT_DYNAMIC_CLASS(wxString, wxObject)
+#endif
+
+#ifdef __MOTIF__
+IMPLEMENT_DYNAMIC_CLASS(wxXColormap, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxXFont, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxXCursor, wxObject)
+#endif
+IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
+IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
+IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
+IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
+IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
+IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
+IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
+
+// This will presumably be implemented on other platforms too
+#ifdef __WINDOWS__
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxBMPFileHandler, wxBitmapHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxICOFileHandler, wxBitmapHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxICOResourceHandler, wxBitmapHandler)
+#endif
+
+#include "wx/statbox.h"
+IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
+
+#if USE_IPC
+#include "wx/dde.h"
+IMPLEMENT_CLASS(wxServerBase, wxObject)
+IMPLEMENT_CLASS(wxClientBase, wxObject)
+IMPLEMENT_CLASS(wxConnectionBase, wxObject)
+
+IMPLEMENT_DYNAMIC_CLASS(wxDDEServer, wxServerBase)
+IMPLEMENT_DYNAMIC_CLASS(wxDDEClient, wxClientBase)
+IMPLEMENT_CLASS(wxDDEConnection, wxConnectionBase)
+#endif
+
+IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
+
+#include "wx/listbox.h"
+IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
+
+#include "wx/checklst.h"
+IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
+
+IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
+
+#include "wx/menu.h"
+IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
+
+#include "wx/stattext.h"
+#include "wx/statbmp.h"
+IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
+
+#if USE_METAFILE
+#include "wx/metafile.h"
+IMPLEMENT_DYNAMIC_CLASS(wxMetaFile, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxMetaFileDC, wxDC)
+#endif
+
+#include "wx/radiobox.h"
+#include "wx/radiobut.h"
+IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
+
+IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
+// IMPLEMENT_DYNAMIC_CLASS(wxBitmapRadioButton, wxRadioButton)
+
+#include "wx/scrolbar.h"
+IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
+
+#if WXWIN_COMPATIBILITY
+BEGIN_EVENT_TABLE(wxScrollBar, wxControl)
+  EVT_SCROLL(wxScrollBar::OnScroll)
+END_EVENT_TABLE()
+#endif
+
+#include "wx/slider.h"
+IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl)
+
+#if WXWIN_COMPATIBILITY
+BEGIN_EVENT_TABLE(wxSlider, wxControl)
+  EVT_SCROLL(wxSlider::OnScroll)
+END_EVENT_TABLE()
+#endif
+
+#include "wx/timer.h"
+IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
+
+#include "wx/textctrl.h"
+IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
+
+#include "wx/window.h"
+IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
+
+#include "wx/scrolwin.h"
+IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxWindow)
+
+#include "wx/panel.h"
+IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow)
+
+#include "wx/msgbxdlg.h"
+#include "wx/textdlg.h"
+#include "wx/filedlg.h"
+#include "wx/dirdlg.h"
+#include "wx/choicdlg.h"
+
+#if !defined(__WINDOWS__) || USE_GENERIC_DIALOGS_IN_MSW
+#include "wx/generic/msgdlgg.h"
+IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog)
+#endif
+
+IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog)
+IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
+IMPLEMENT_CLASS(wxFileDialog, wxDialog)
+IMPLEMENT_CLASS(wxDirDialog, wxDialog)
+
+#ifdef __WINDOWS__
+IMPLEMENT_CLASS(wxMessageDialog)
+#endif
+
+#if USE_GAUGE
+#ifdef __MOTIF__
+#include "../../contrib/xmgauge/gauge.h"
+#endif
+#include "wx_gauge.h"
+IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
+#endif
+
+#include "wx/grid.h"
+IMPLEMENT_DYNAMIC_CLASS(wxGenericGrid, wxPanel)
+
+///// Event tables (also must be in one, statically-linked file for shared libraries)
+
+// This is the base, wxEvtHandler 'bootstrap' code which is expanded manually here
+const wxEventTable *wxEvtHandler::GetEventTable() const { return &wxEvtHandler::sm_eventTable; }
+
+const wxEventTable wxEvtHandler::sm_eventTable =
+	{ NULL, &wxEvtHandler::sm_eventTableEntries[0] };
+
+const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = { { 0, 0, 0, NULL } };
+
+BEGIN_EVENT_TABLE(wxFrame, wxWindow)
+	EVT_ACTIVATE(wxFrame::OnActivate)
+	EVT_SIZE(wxFrame::OnSize)
+	EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
+    EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
+    EVT_IDLE(wxFrame::OnIdle)
+    EVT_CLOSE(wxFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxDialog, wxPanel)
+  EVT_BUTTON(wxID_OK, wxDialog::OnOK)
+  EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
+  EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
+  EVT_CHAR_HOOK(wxDialog::OnCharHook)
+  EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
+  EVT_CLOSE(wxDialog::OnCloseWindow)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
+  EVT_CHAR(wxWindow::OnChar)
+  EVT_SIZE(wxWindow::Size)
+  EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
+  EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
+  EVT_INIT_DIALOG(wxWindow::OnInitDialog)
+  EVT_IDLE(wxWindow::OnIdle)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxScrolledWindow, wxWindow)
+  EVT_SCROLL(wxScrolledWindow::OnScroll)
+  EVT_SIZE(wxScrolledWindow::OnSize)
+  EVT_PAINT(wxScrolledWindow::OnPaint)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxPanel, wxWindow)
+  EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
+	EVT_CHAR(wxTextCtrl::OnChar)
+	EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
+	EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
+END_EVENT_TABLE()
+
+#ifdef __WINDOWS__
+BEGIN_EVENT_TABLE(wxMDIParentWindow, wxFrame)
+  EVT_SIZE(wxMDIParentWindow::OnSize)
+  EVT_ACTIVATE(wxMDIParentWindow::OnActivate)
+  EVT_SYS_COLOUR_CHANGED(wxMDIParentWindow::OnSysColourChanged)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
+  EVT_SCROLL(wxMDIClientWindow::OnScroll)
+END_EVENT_TABLE()
+#endif
+
+BEGIN_EVENT_TABLE(wxToolBarBase, wxControl)
+  EVT_SCROLL(wxToolBarBase::OnScroll)
+  EVT_SIZE(wxToolBarBase::OnSize)
+  EVT_IDLE(wxToolBarBase::OnIdle)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxToolBarSimple, wxToolBarBase)
+	EVT_SIZE(wxToolBarSimple::OnSize)
+	EVT_PAINT(wxToolBarSimple::OnPaint)
+	EVT_KILL_FOCUS(wxToolBarSimple::OnKillFocus)
+	EVT_MOUSE_EVENTS(wxToolBarSimple::OnMouseEvent)
+END_EVENT_TABLE()
+
+#ifdef __WINDOWS__
+BEGIN_EVENT_TABLE(wxToolBarMSW, wxToolBarBase)
+	EVT_SIZE(wxToolBarMSW::OnSize)
+	EVT_PAINT(wxToolBarMSW::OnPaint)
+	EVT_MOUSE_EVENTS(wxToolBarMSW::OnMouseEvent)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxToolBar95, wxToolBarBase)
+	EVT_SIZE(wxToolBar95::OnSize)
+	EVT_PAINT(wxToolBar95::OnPaint)
+	EVT_KILL_FOCUS(wxToolBar95::OnKillFocus)
+	EVT_MOUSE_EVENTS(wxToolBar95::OnMouseEvent)
+    EVT_SYS_COLOUR_CHANGED(wxToolBar95::OnSysColourChanged)
+END_EVENT_TABLE()
+#endif
+
+BEGIN_EVENT_TABLE(wxGenericGrid, wxPanel)
+	EVT_SIZE(wxGenericGrid::OnSize)
+	EVT_PAINT(wxGenericGrid::OnPaint)
+	EVT_MOUSE_EVENTS(wxGenericGrid::OnMouseEvent)
+    EVT_TEXT(wxGRID_TEXT_CTRL, wxGenericGrid::OnText)
+    EVT_COMMAND_SCROLL(wxGRID_HSCROLL, wxGenericGrid::OnGridScroll)
+    EVT_COMMAND_SCROLL(wxGRID_VSCROLL, wxGenericGrid::OnGridScroll)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxControl, wxWindow)
+  EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground)
+END_EVENT_TABLE()
+
+#if !defined(__WINDOWS__) || USE_GENERIC_DIALOGS_IN_MSW
+BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog)
+	EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes)
+	EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo)
+	EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxGenericColourDialog, wxDialog)
+	EVT_BUTTON(wxID_ADD_CUSTOM, wxGenericColourDialog::OnAddCustom)
+	EVT_SLIDER(wxID_RED_SLIDER, wxGenericColourDialog::OnRedSlider)
+	EVT_SLIDER(wxID_GREEN_SLIDER, wxGenericColourDialog::OnGreenSlider)
+	EVT_SLIDER(wxID_BLUE_SLIDER, wxGenericColourDialog::OnBlueSlider)
+	EVT_PAINT(wxGenericColourDialog::OnPaint)
+	EVT_MOUSE_EVENTS(wxGenericColourDialog::OnMouseEvent)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxGenericFontDialog, wxDialog)
+	EVT_CHECKBOX(wxID_FONT_UNDERLINE, wxGenericFontDialog::OnChangeFont)
+	EVT_CHOICE(wxID_FONT_STYLE, wxGenericFontDialog::OnChangeFont)
+	EVT_CHOICE(wxID_FONT_WEIGHT, wxGenericFontDialog::OnChangeFont)
+	EVT_CHOICE(wxID_FONT_FAMILY, wxGenericFontDialog::OnChangeFont)
+	EVT_CHOICE(wxID_FONT_COLOUR, wxGenericFontDialog::OnChangeFont)
+	EVT_CHOICE(wxID_FONT_SIZE, wxGenericFontDialog::OnChangeFont)
+	EVT_PAINT(wxGenericFontDialog::OnPaint)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxGenericPrintDialog, wxDialog)
+    EVT_BUTTON(wxID_OK, wxGenericPrintDialog::OnOK)
+    EVT_BUTTON(wxPRINTID_SETUP, wxGenericPrintDialog::OnSetup)
+    EVT_RADIOBOX(wxPRINTID_RANGE, wxGenericPrintDialog::OnRange)
+END_EVENT_TABLE()
+
+#endif
+
+BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
+	EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog)
+	EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK)
+END_EVENT_TABLE()
+
+#include "wx/prntbase.h"
+
+BEGIN_EVENT_TABLE(wxPrintAbortDialog, wxDialog)
+	EVT_BUTTON(wxID_CANCEL, wxPrintAbortDialog::OnCancel)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxPreviewControlBar, wxWindow)
+	EVT_BUTTON(wxID_PREVIEW_CLOSE, 		wxPreviewControlBar::OnClose)
+	EVT_BUTTON(wxID_PREVIEW_PRINT, 		wxPreviewControlBar::OnPrint)
+	EVT_BUTTON(wxID_PREVIEW_PREVIOUS, 	wxPreviewControlBar::OnPrevious)
+	EVT_BUTTON(wxID_PREVIEW_NEXT, 		wxPreviewControlBar::OnNext)
+	EVT_CHOICE(wxID_PREVIEW_ZOOM, 		wxPreviewControlBar::OnZoom)
+END_EVENT_TABLE()
+
+#endif
+
+
+const wxSize wxDefaultSize(-1, -1);
+const wxPoint wxDefaultPosition(-1, -1);
diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp
new file mode 100644
index 0000000000..9a63615fea
--- /dev/null
+++ b/src/msw/dc.cpp
@@ -0,0 +1,1632 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dc.cpp
+// Purpose:     wxDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "dc.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/frame.h"
+#include "wx/dc.h"
+#include "wx/utils.h"
+#include "wx/dialog.h"
+#include "wx/app.h"
+#endif
+
+#include "wx/dcprint.h"
+#include "wx/msw/private.h"
+
+#include <string.h>
+#include <math.h>
+#include <fstream.h>
+
+#if USE_COMMON_DIALOGS
+#include <commdlg.h>
+#endif
+
+#ifndef __WIN32__
+#include <print.h>
+#endif
+
+#ifdef DrawText
+#undef DrawText
+#endif
+
+#ifdef GetCharWidth
+#undef GetCharWidth
+#endif
+
+#ifdef StartDoc
+#undef StartDoc
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
+#endif
+
+// Declarations local to this file
+
+#define YSCALE(y) (yorigin - (y))
+
+// #define     wx_round(a)    (int)((a)+.5)
+
+// Default constructor
+wxDC::wxDC(void)
+{
+  // Stop internal GDI objects being found and pointers kept
+  // after these objects have been deleted.
+  // No - it's OK; these lists won't return them
+  // because their 'visible' status will be FALSE.
+/*
+  wxTheFontList->RemoveFont(&m_font);
+  wxThePenList->RemovePen(&m_pen);
+  wxTheBrushList->RemoveBrush(&m_brush);
+  wxTheBrushList->RemoveBrush(&m_backgroundBrush);
+*/
+
+  m_minX = 0; m_minY = 0; m_maxX = 0; m_maxY = 0;
+  m_clipping = FALSE;
+  m_autoSetting = TRUE ;
+//  m_scaleGDI = TRUE;
+
+  m_filename = "";
+//  m_selectedBitmap = NULL;
+  m_canvas = NULL;
+/*
+  cur_dc = NULL ;
+  cur_bk = 0 ;
+  cur_cpen = NULL ;
+  cur_cbrush = NULL ;
+*/
+  m_oldBitmap = 0;
+  m_oldPen = 0;
+  m_oldBrush = 0;
+  m_oldFont = 0;
+  m_oldPalette = 0;
+  m_minX = 0; m_minY = 0; m_maxX = 0; m_maxY = 0;
+//  m_font = NULL;
+  m_logicalOriginX = 0;
+  m_logicalOriginY = 0;
+  m_deviceOriginX = 0;
+  m_deviceOriginY = 0;
+  m_logicalScaleX = 1.0;
+  m_logicalScaleY = 1.0;
+  m_userScaleX = 1.0;
+  m_userScaleY = 1.0;
+  m_systemScaleX = 1.0;
+  m_systemScaleY = 1.0;
+  m_mappingMode = MM_TEXT;
+//  m_dontDelete = FALSE;
+  m_bOwnsDC = FALSE;
+  m_hDC = 0;
+  m_clipping = FALSE;
+  m_ok = TRUE;
+  m_windowExtX = VIEWPORT_EXTENT;
+  m_windowExtY = VIEWPORT_EXTENT;
+  m_logicalFunction = -1;
+
+  m_backgroundBrush = *wxWHITE_BRUSH;
+//  m_backgroundBrush.UseResource();
+
+  m_textForegroundColour = *wxBLACK;
+  m_textBackgroundColour = *wxWHITE;
+
+  m_colour = wxColourDisplay();
+
+  m_hDCCount = 0;
+}
+
+
+wxDC::~wxDC(void)
+{
+  if ( m_hDC != 0 ) {
+    SelectOldObjects(m_hDC);
+    if ( m_bOwnsDC ) {
+      if ( m_canvas == NULL )
+        ::DeleteDC((HDC)m_hDC);
+      else
+        ::ReleaseDC((HWND)m_canvas->GetHWND(), (HDC)m_hDC);
+    }
+  }
+
+/*
+  if (m_hDC)
+  {
+    SelectOldObjects(m_hDC);
+    ::DeleteDC((HDC) m_hDC);
+  }
+*/
+}
+
+// This will select current objects out of the DC,
+// which is what you have to do before deleting the
+// DC.
+void wxDC::SelectOldObjects(WXHDC dc)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxDC::SelectOldObjects %X\n", this);
+#endif
+  if (dc)
+  {
+    if (m_oldBitmap)
+    {
+#if DEBUG > 1
+      wxDebugMsg("wxDC::SelectOldObjects: Selecting old HBITMAP %X\n", m_oldBitmap);
+#endif
+      ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap);
+      if (m_selectedBitmap.Ok())
+      {
+        m_selectedBitmap.SetSelectedInto(NULL);
+      }
+    }
+    m_oldBitmap = 0 ;
+    if (m_oldPen)
+    {
+#if DEBUG > 1
+      wxDebugMsg("wxDC::SelectOldObjects: Selecting old HPEN %X\n", m_oldPen);
+#endif
+      ::SelectObject((HDC) dc, (HPEN) m_oldPen);
+    }
+    m_oldPen = 0 ;
+    if (m_oldBrush)
+    {
+#if DEBUG > 1
+      wxDebugMsg("wxDC::SelectOldObjects: Selecting old HBRUSH %X\n", m_oldBrush);
+#endif
+      ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush);
+    }
+    m_oldBrush = 0 ;
+    if (m_oldFont)
+    {
+#if DEBUG > 1
+      wxDebugMsg("wxDC::SelectOldObjects: Selecting old HFONT %X\n", m_oldFont);
+#endif
+      ::SelectObject((HDC) dc, (HFONT) m_oldFont);
+    }
+    m_oldFont = 0 ;
+    if (m_oldPalette)
+    {
+#if DEBUG > 1
+      wxDebugMsg("wxDC::SelectOldObjects: Selecting old HPALETTE %X\n", m_oldPalette);
+#endif
+      ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
+    }
+#if DEBUG > 1
+    wxDebugMsg("wxDC::SelectOldObjects: Done.\n");
+#endif
+    m_oldPalette = 0 ;
+  }
+/*
+  if (m_font.Ok())
+    m_font.ReleaseResource();
+  if (m_pen.Ok())
+    m_pen.ReleaseResource();
+  if (m_brush.Ok())
+    m_brush.ReleaseResource();
+  if (m_backgroundBrush.Ok())
+    m_backgroundBrush.ReleaseResource();
+*/
+
+  m_brush = wxNullBrush ;
+  m_pen = wxNullPen;
+  m_palette = wxNullPalette;
+  m_font = wxNullFont;
+  m_backgroundBrush = wxNullBrush;
+  m_selectedBitmap = wxNullBitmap;
+}
+
+void wxDC::SetClippingRegion(long cx, long cy, long cw, long ch)
+{
+  m_clipping = TRUE;
+  m_clipX1 = (int)cx;
+  m_clipY1 = (int)cy;
+  m_clipX2 = (int)(cx + cw);
+  m_clipY2 = (int)(cy + ch);
+
+  BeginDrawing();
+
+  DoClipping((WXHDC) m_hDC);
+
+  EndDrawing();
+}
+
+void wxDC::DoClipping(WXHDC dc)
+{
+  if (m_clipping && dc)
+  {
+    IntersectClipRect((HDC) dc, XLOG2DEV(m_clipX1), YLOG2DEV(m_clipY1),
+                          XLOG2DEV(m_clipX2), YLOG2DEV(m_clipY2));
+#if 0
+    int x_off = 0;
+    int y_off = 0;
+    if (m_canvas)
+    {
+      m_canvas->CalcScrolledPosition(0, 0, &x_off, &y_off);
+    }
+//    HRGN rgn = CreateRectRgn(XLOG2DEV(m_clipX1 + x_off), YLOG2DEV(m_clipY1 + y_off),
+//                          XLOG2DEV(m_clipX2 + x_off), YLOG2DEV(m_clipY2 + y_off));
+
+//    SelectClipRgn(dc, rgn);
+//    DeleteObject(rgn);
+    IntersectClipRect((HDC) dc, XLOG2DEV(m_clipX1 + x_off), YLOG2DEV(m_clipY1 + y_off),
+                          XLOG2DEV(m_clipX2 + x_off), YLOG2DEV(m_clipY2 + y_off));
+#endif
+  }
+}
+
+void wxDC::DestroyClippingRegion(void)
+{
+  BeginDrawing();
+
+  if (m_clipping && m_hDC)
+  {
+//        SelectClipRgn(dc, NULL);
+    HRGN rgn = CreateRectRgn(0, 0, 32000, 32000);
+#if DEBUG > 1
+    wxDebugMsg("wxDC::DestroyClippingRegion: Selecting HRGN %X\n", rgn);
+#endif
+    SelectClipRgn((HDC) m_hDC, rgn);
+#if DEBUG > 1
+    wxDebugMsg("wxDC::DestroyClippingRegion: Deleting HRGN %X\n", rgn);
+#endif
+    DeleteObject(rgn);
+   }
+   m_clipping = FALSE;
+
+   EndDrawing();
+}
+
+bool wxDC::CanDrawBitmap(void) const
+{
+  return TRUE;
+}
+
+bool wxDC::CanGetTextExtent(void) const
+{
+  // What sort of display is it?
+  int technology = ::GetDeviceCaps((HDC) m_hDC, TECHNOLOGY);
+
+  bool ok;
+
+  if (technology != DT_RASDISPLAY && technology != DT_RASPRINTER)
+    ok = FALSE;
+  else ok = TRUE;
+
+  return ok;
+}
+
+void wxDC::SetPalette(const wxPalette& palette)
+{
+  BeginDrawing();
+
+  m_palette = m_palette;
+
+  if (!m_palette.Ok())
+  {
+    // Setting a NULL colourmap is a way of restoring
+    // the original colourmap
+    if (m_oldPalette)
+    {
+      ::SelectPalette((HDC) m_hDC, (HPALETTE) m_oldPalette, TRUE);
+#if DEBUG > 1
+      wxDebugMsg("wxDC::SetPalette: set old palette %X\n", m_oldPalette);
+#endif
+      m_oldPalette = 0;
+    }
+
+	return;
+  }
+    
+  if (m_palette.Ok() && m_palette.GetHPALETTE())
+  {
+    HPALETTE oldPal = ::SelectPalette((HDC) m_hDC, (HPALETTE) m_palette.GetHPALETTE(), TRUE);
+    if (!m_oldPalette)
+      m_oldPalette = (WXHPALETTE) oldPal;
+
+#if DEBUG > 1
+    wxDebugMsg("wxDC::SetPalette %X: selected palette %X\n", this, m_palette.GetHPALETTE());
+    if (oldPal)
+      wxDebugMsg("wxDC::SetPalette: oldPal was palette %X\n", oldPal);
+    if (m_oldPalette)
+      wxDebugMsg("wxDC::SetPalette: m_oldPalette is palette %X\n", m_oldPalette);
+#endif
+    ::RealizePalette((HDC) m_hDC);
+  }
+
+  EndDrawing();
+}
+
+void wxDC::Clear(void)
+{
+  BeginDrawing();
+
+  RECT rect;
+  if (m_canvas)
+    GetClientRect((HWND) m_canvas->GetHWND(), &rect);
+  else if (m_selectedBitmap.Ok())
+  {
+    rect.left = 0; rect.top = 0;
+    rect.right = m_selectedBitmap.GetWidth();
+    rect.bottom = m_selectedBitmap.GetHeight();
+  }
+  (void) ::SetMapMode((HDC) m_hDC, MM_TEXT);
+
+  DWORD colour = GetBkColor((HDC) m_hDC);
+  HBRUSH brush = CreateSolidBrush(colour);
+  FillRect((HDC) m_hDC, &rect, brush);
+  DeleteObject(brush);
+
+  ::SetMapMode((HDC) m_hDC, MM_ANISOTROPIC);
+  ::SetViewportExtEx((HDC) m_hDC, VIEWPORT_EXTENT, VIEWPORT_EXTENT, NULL);
+  ::SetWindowExtEx((HDC) m_hDC, m_windowExtX, m_windowExtY, NULL);
+  ::SetViewportOrgEx((HDC) m_hDC, (int)m_deviceOriginX, (int)m_deviceOriginY, NULL);
+  ::SetWindowOrgEx((HDC) m_hDC, (int)m_logicalOriginX, (int)m_logicalOriginY, NULL);
+
+  EndDrawing();
+}
+
+void wxDC::FloodFill(long x, long y, wxColour *col, int style)
+{
+//  int xx = (int)x;
+//  int yy = (int)y;
+
+  if (m_brush.Ok() && m_autoSetting)
+    SetBrush(m_brush);
+
+//  if (m_canvas)
+//    m_canvas->CalcScrolledPosition((int)x, (int)y, &xx, &yy);
+
+  BeginDrawing();
+
+  (void)ExtFloodFill((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y),
+                        col->GetPixel(),
+                        style==wxFLOOD_SURFACE?
+                          FLOODFILLSURFACE:FLOODFILLBORDER
+                        );
+
+  EndDrawing();
+
+  CalcBoundingBox(x, y);
+}
+
+bool wxDC::GetPixel(long x, long y, wxColour *col) const
+{
+  // added by steve 29.12.94 (copied from DrawPoint)
+  // returns TRUE for pixels in the color of the current pen
+  // and FALSE for all other pixels colors
+  // if col is non-NULL return the color of the pixel
+/*
+  int xx1 = (int)x;
+  int yy1 = (int)y;
+  if (m_canvas)
+    m_canvas->CalcScrolledPosition((int)x, (int)y, &xx1, &yy1);
+*/
+
+  // get the color of the pixel
+  COLORREF pixelcolor = ::GetPixel((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y));
+  // get the color of the pen
+  COLORREF pencolor = 0x00ffffff;
+  if (m_pen.Ok())
+  {
+    pencolor = m_pen.GetColour().GetPixel() ;
+  }
+  
+  // return the color of the pixel
+  if(col)
+    col->Set(GetRValue(pixelcolor),GetGValue(pixelcolor),GetBValue(pixelcolor));
+  
+  // check, if color of the pixels is the same as the color
+  // of the current pen
+  return(pixelcolor==pencolor);
+}
+
+void wxDC::CrossHair(long x, long y)
+{
+      if (m_pen.Ok() && m_autoSetting)
+        SetPen(m_pen);
+
+      // We suppose that our screen is 2000x2000 max.
+      long x1 = x-2000;
+      long y1 = y-2000;
+      long x2 = x+2000;
+      long y2 = y+2000;
+/*
+      long xx1 = x1 ;
+      long yy1 = y1 ;
+      long xx2 = x2 ;
+      long yy2 = y2 ;
+      long xx  = x ;
+      long yy  = y ;
+
+      if (m_canvas)
+      {
+        m_canvas->CalcScrolledPosition(x1, y1, &xx1, &yy1);
+        m_canvas->CalcScrolledPosition(x2, y2, &xx2, &yy2);
+        m_canvas->CalcScrolledPosition(x, y, &xx, &yy);
+      }
+*/
+
+      BeginDrawing();
+
+      (void)MoveToEx((HDC) m_hDC, XLOG2DEV(x1), YLOG2DEV(y), NULL);
+      (void)LineTo((HDC) m_hDC, XLOG2DEV(x2), YLOG2DEV(y));
+
+      (void)MoveToEx((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y1), NULL);
+      (void)LineTo((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y2));
+
+      EndDrawing();
+
+      CalcBoundingBox(x1, y1);
+      CalcBoundingBox(x2, y2);
+}
+
+void wxDC::DrawLine(long x1, long y1, long x2, long y2)
+{
+// BUGBUG - is this necessary? YES YES YES YEs Yes yes ye....
+  if (m_pen.Ok() && m_autoSetting)
+    SetPen(m_pen);
+/*
+  int xx1 = (int)x1;
+  int yy1 = (int)y1;
+  int xx2 = (int)x2;
+  int yy2 = (int)y2;
+  if (m_canvas)
+  {
+    m_canvas->CalcScrolledPosition((int)x1, (int)y1, &xx1, &yy1);
+    m_canvas->CalcScrolledPosition((int)x2, (int)y2, &xx2, &yy2);
+  }
+*/
+
+  BeginDrawing();
+
+  (void)MoveToEx((HDC) m_hDC, XLOG2DEV(x1), YLOG2DEV(y1), NULL);
+  (void)LineTo((HDC) m_hDC, XLOG2DEV(x2), YLOG2DEV(y2));
+
+  /* MATTHEW: [6] New normalization */
+#if WX_STANDARD_GRAPHICS
+  (void)LineTo((HDC) m_hDC, XLOG2DEV(x2) + 1, YLOG2DEV(y2));
+#endif
+
+  EndDrawing();
+
+  CalcBoundingBox(x1, y1);
+  CalcBoundingBox(x2, y2);
+}
+
+void wxDC::DrawArc(long x1,long y1,long x2,long y2,double xc,double yc)
+{
+/*
+  int xx1 = (int)x1;
+  int yy1 = (int)y1;
+  int xx2 = (int)x2;
+  int yy2 = (int)y2;
+  int xxc = (int)xc ;
+  int yyc = (int)yc;
+*/
+
+  double dx = xc-x1 ;
+  double dy = yc-y1 ;
+  double radius = (double)sqrt(dx*dx+dy*dy) ;;
+  if (x1==x2 && x2==y2)
+  {
+    DrawEllipse(xc,yc,(double)(radius*2.0),(double)(radius*2)) ;
+    return ;
+  }
+
+// BUGBUG - is this necessary?
+  if (m_pen.Ok() && m_autoSetting)
+    SetPen(m_pen) ;
+
+/*
+  if (m_canvas)
+  {
+    m_canvas->CalcScrolledPosition((int)x1, (int)y1, &xx1, &yy1);
+    m_canvas->CalcScrolledPosition((int)x2, (int)y2, &xx2, &yy2);
+    m_canvas->CalcScrolledPosition((int)xc, (int)yc, &xxc, &yyc);
+  }
+*/
+
+  BeginDrawing();
+
+  long xx1 = XLOG2DEV(x1) ;
+  long yy1 = YLOG2DEV(y1) ;
+  long xx2 = XLOG2DEV(x2) ;
+  long yy2 = YLOG2DEV(y2) ;
+  long xxc = XLOG2DEV(xc) ;
+  long yyc = YLOG2DEV(yc) ;
+  long ray = (long) sqrt(double((xxc-xx1)*(xxc-xx1)+(yyc-yy1)*(yyc-yy1))) ;
+
+  (void)MoveToEx((HDC) m_hDC, (int) xx1, (int) yy1, NULL);
+  long xxx1 = (long) (xxc-ray);
+  long yyy1 = (long) (yyc-ray);
+  long xxx2 = (long) (xxc+ray);
+  long yyy2 = (long) (yyc+ray);
+  if (m_brush.Ok() && m_brush.GetStyle() !=wxTRANSPARENT)
+  {
+// BUGBUG - is this necessary?
+    if (m_brush.GetStyle()!=wxTRANSPARENT&&m_autoSetting)
+      SetBrush(m_brush) ;
+    Pie((HDC) m_hDC,xxx1,yyy1,xxx2,yyy2,
+        xx1,yy1,xx2,yy2) ;
+  }
+  else
+    Arc((HDC) m_hDC,xxx1,yyy1,xxx2,yyy2,
+        xx1,yy1,xx2,yy2) ;
+
+  EndDrawing();
+
+  CalcBoundingBox((xc-radius), (yc-radius));
+  CalcBoundingBox((xc+radius), (yc+radius));
+}
+
+void wxDC::DrawEllipticArc(long WXUNUSED(x),long WXUNUSED(y),long WXUNUSED(w),long WXUNUSED(h),double WXUNUSED(sa),double WXUNUSED(ea))
+{
+  // Not implemented
+}
+
+void wxDC::DrawPoint(long x, long y)
+{
+// BUGBUG - is this necessary?
+  if (m_pen.Ok() && m_autoSetting)
+    SetPen(m_pen) ;
+
+/*
+  int xx1 = (int)x;
+  int yy1 = (int)y;
+  if (m_canvas)
+    m_canvas->CalcScrolledPosition((int)x, (int)y, &xx1, &yy1);
+*/
+
+  BeginDrawing();
+
+  COLORREF color = 0x00ffffff;
+  if (m_pen.Ok())
+  {
+//    m_pen.RealizeResource();
+    color = m_pen.GetColour().GetPixel() ;
+  }
+
+/*
+    color = RGB(m_pen->GetColour().Red(),
+                m_pen->GetColour().Green(),
+                m_pen->GetColour().Blue());
+*/
+
+  SetPixel((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), color);
+
+  EndDrawing();
+
+  CalcBoundingBox(x, y);
+}
+
+void wxDC::DrawPolygon(int n, wxPoint points[], long xoffset, long yoffset,int fillStyle)
+{
+// BUGBUG - is this necessary?
+  if (m_pen.Ok() && m_autoSetting)
+    SetPen(m_pen) ;
+/*
+  int xoffset1 = 0;
+  int yoffset1 = 0;
+
+  if (m_canvas)
+    m_canvas->CalcScrolledPosition(0, 0, &xoffset1, &yoffset1);
+
+  xoffset1 += (int)xoffset; yoffset1 += (int)yoffset;
+*/
+
+  BeginDrawing();
+
+  POINT *cpoints = new POINT[n];
+  int i;
+  for (i = 0; i < n; i++)
+  {
+    cpoints[i].x = (int)(XLOG2DEV(points[i].x));
+    cpoints[i].y = (int)(YLOG2DEV(points[i].y));
+
+    CalcBoundingBox(points[i].x, points[i].y);
+  }
+
+  int prev = SetPolyFillMode((HDC) m_hDC,fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING) ;
+  (void)Polygon((HDC) m_hDC, cpoints, n);
+  SetPolyFillMode((HDC) m_hDC,prev) ;
+
+  EndDrawing();
+
+  delete[] cpoints;
+}
+
+void wxDC::DrawLines(int n, wxPoint points[], long xoffset, long yoffset)
+{
+// BUGBUG - is this necessary?
+  if (m_pen.Ok() && m_autoSetting)
+    SetPen(m_pen) ;
+
+/*
+  int xoffset1 = 0;
+  int yoffset1 = 0;
+
+  if (m_canvas)
+  {
+    m_canvas->CalcScrolledPosition(0, 0, &xoffset1, &yoffset1);
+  }
+  xoffset1 += (int)xoffset; yoffset1 += (int)yoffset;
+*/
+
+  BeginDrawing();
+
+  POINT *cpoints = new POINT[n];
+  int i;
+  for (i = 0; i < n; i++)
+  {
+    cpoints[i].x = (int)(XLOG2DEV(points[i].x));
+    cpoints[i].y = (int)(YLOG2DEV(points[i].y));
+
+    CalcBoundingBox(points[i].x, points[i].y);
+  }
+
+ (void)Polyline((HDC) m_hDC, cpoints, n);
+
+  EndDrawing();
+
+  delete[] cpoints;
+}
+
+void wxDC::DrawRectangle(long x, long y, long width, long height)
+{
+// BUGBUG - is this necessary?
+  if (m_pen.Ok() && m_autoSetting)
+    SetPen(m_pen) ;
+
+/*
+  int x1 = (int)x;
+  int y1 = (int)y;
+  int x2 = (int)(x+width);
+  int y2 = (int)(y+height);
+
+  if (m_canvas)
+  {
+    m_canvas->CalcScrolledPosition((int)x, (int)y, &x1, &y1);
+    m_canvas->CalcScrolledPosition((int)(x+width), (int)(y+height), &x2, &y2);
+  }
+*/
+  long x2 = x + width;
+  long y2 = y + height;
+
+  BeginDrawing();
+
+/* MATTHEW: [6] new normalization */
+#if WX_STANDARD_GRAPHICS
+  bool do_brush, do_pen;
+
+  do_brush = m_brush.Ok() && m_brush.GetStyle() != wxTRANSPARENT;
+  do_pen = m_pen.Ok() && m_pen.GetStyle() != wxTRANSPARENT;
+
+  if (do_brush) {
+	 HPEN orig_pen = NULL;
+
+	 if (do_pen || !m_pen.Ok())
+		orig_pen = ::SelectObject((HDC) m_hDC, ::GetStockObject(NULL_PEN));
+
+	 (void)Rectangle((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y),
+		  XLOG2DEV(x2) + 1, YLOG2DEV(y2) + 1);
+
+	 if (do_pen || !m_pen.Ok())
+		::SelectObject((HDC) m_hDC , orig_pen);
+  }
+  if (do_pen) {
+	 HBRUSH orig_brush = NULL;
+
+	 if (do_brush || !m_brush.Ok())
+		orig_brush = ::SelectObject((HDC) m_hDC, ::GetStockObject(NULL_BRUSH));
+
+	 (void)Rectangle((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y),
+		  XLOG2DEV(x2), YLOG2DEV(y2));
+
+	 if (do_brush || !m_brush.Ok())
+		::SelectObject((HDC) m_hDC, orig_brush);
+  }
+#else
+  (void)Rectangle((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2));
+#endif
+
+  CalcBoundingBox(x, y);
+  CalcBoundingBox(x2, y2);
+
+  EndDrawing();
+}
+
+void wxDC::DrawRoundedRectangle(long x, long y, long width, long height, double radius)
+{
+// BUGBUG - is this necessary?
+  if (m_pen.Ok() && m_autoSetting)
+    SetPen(m_pen) ;
+
+  // Now, a negative radius value is interpreted to mean
+  // 'the proportion of the smallest X or Y dimension'
+
+  if (radius < 0.0)
+  {
+    double smallest = 0.0;
+    if (width < height)
+      smallest = width;
+    else
+      smallest = height;
+    radius = (- radius * smallest);
+  }
+
+/*
+  int x1 = (int)x;
+  int y1 = (int)y;
+
+  if (m_canvas)
+  {
+    m_canvas->CalcScrolledPosition((int)x, (int)y, &x1, &y1);
+    m_canvas->CalcScrolledPosition((int)(x+width), (int)(y+height), &x2, &y2);
+  }
+*/
+
+  long x2 = (x+width);
+  long y2 = (y+height);
+
+  BeginDrawing();
+
+  (void)RoundRect((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2),
+                      YLOG2DEV(y2), 2*XLOG2DEV(radius), 2*YLOG2DEV(radius));
+
+  CalcBoundingBox(x, y);
+  CalcBoundingBox(x2, y2);
+
+  EndDrawing();
+}
+
+void wxDC::DrawEllipse(long x, long y, long width, long height)
+{
+// BUGBUG - is this necessary?
+  if (m_pen.Ok() && m_autoSetting)
+    SetPen(m_pen) ;
+
+/*
+  int x1 = (int)x;
+  int y1 = (int)y;
+
+  if (m_canvas)
+  {
+    m_canvas->CalcScrolledPosition((int)x, (int)y, &x1, &y1);
+    m_canvas->CalcScrolledPosition((int)(x+width), (int)(y+height), &x2, &y2);
+  }
+*/
+
+  long x2 = (x+width);
+  long y2 = (y+height);
+
+  BeginDrawing();
+
+  (void)Ellipse((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2));
+
+  EndDrawing();
+
+  CalcBoundingBox(x, y);
+  CalcBoundingBox(x2, y2);
+}
+
+void wxDC::DrawIcon(const wxIcon& icon, long x, long y)
+{
+/*
+  int x1 = (int)x;
+  int y1 = (int)y;
+
+  if (m_canvas)
+    m_canvas->CalcScrolledPosition(int)x, (int)y, &x1, &y1);
+*/
+
+  BeginDrawing();
+
+  ::DrawIcon((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), (HICON) icon.GetHICON());
+  CalcBoundingBox(x, y);
+  CalcBoundingBox(x+icon.GetWidth(), y+icon.GetHeight());
+
+  EndDrawing();
+}
+
+void wxDC::SetFont(const wxFont& the_font)
+{
+  // Release the current font from servitude (decrements the usage count)
+//  if (m_font.Ok())
+//    m_font.ReleaseResource();
+
+  BeginDrawing();
+
+  m_font = the_font;
+
+  if (!the_font.Ok())
+  {
+    if (m_oldFont)
+      ::SelectObject((HDC) m_hDC, (HFONT) m_oldFont);
+    m_oldFont = 0 ;
+  }
+
+  if (m_font.Ok() && m_font.GetResourceHandle())
+  {
+#if DEBUG > 1
+    wxDebugMsg("wxDC::SetFont: Selecting HFONT %X\n", m_font.GetResourceHandle());
+#endif
+    HFONT f = (HFONT) ::SelectObject((HDC) m_hDC, (HFONT) m_font.GetResourceHandle());
+    if (!m_oldFont)
+      m_oldFont = (WXHFONT) f;
+  }
+  EndDrawing();
+}
+
+void wxDC::SetPen(const wxPen& pen)
+{
+  BeginDrawing();
+
+//  if (m_pen.Ok())
+//    m_pen.ReleaseResource();
+
+  m_pen = pen;
+
+  if (!m_pen.Ok())
+  {
+    if (m_oldPen)
+      ::SelectObject((HDC) m_hDC, (HPEN) m_oldPen);
+    m_oldPen = 0 ;
+  }
+
+  if (m_pen.Ok())
+  {
+//    m_pen.UseResource();
+//    m_pen.RealizeResource();
+    if (m_pen.GetResourceHandle())
+    {
+      HPEN p = (HPEN) ::SelectObject((HDC) m_hDC, (HPEN)m_pen.GetResourceHandle()) ;
+      if (!m_oldPen)
+        m_oldPen = (WXHPEN) p;
+    }
+  }
+
+  EndDrawing();
+}
+
+void wxDC::SetBrush(const wxBrush& brush)
+{
+  BeginDrawing();
+
+//  if (m_brush.Ok())
+//    m_brush.ReleaseResource();
+
+  m_brush = brush;
+
+  if (!m_brush.Ok())
+  {
+    if (m_oldBrush)
+      ::SelectObject((HDC) m_hDC, (HBRUSH) m_oldBrush);
+    m_oldBrush = 0 ;
+  }
+
+  if (m_brush.Ok())
+  {
+//    m_brush.UseResource();
+//    m_brush.RealizeResource();
+
+    if (m_brush.GetResourceHandle())
+    {
+      HBRUSH b = 0;
+      b = ::SelectObject((HDC) m_hDC, (HBRUSH)m_brush.GetResourceHandle()) ;
+      if (!m_oldBrush)
+        m_oldBrush = (WXHBRUSH) b;
+    }
+  }
+  EndDrawing();
+}
+
+void wxDC::DrawText(const wxString& text, long x, long y, bool use16bit)
+{
+/*
+  int xx1 = (int)x;
+  int yy1 = (int)y;
+
+  if (m_canvas)
+    m_canvas->CalcScrolledPosition((int)x, (int)y, &xx1, &yy1);
+*/
+
+  BeginDrawing();
+
+  if (m_font.Ok() && m_font.GetResourceHandle())
+  {
+#if DEBUG > 1
+    wxDebugMsg("wxDC::DrawText: Selecting HFONT %X\n", m_font.GetResourceHandle());
+#endif
+    HFONT f = ::SelectObject((HDC) m_hDC, (HFONT) m_font.GetResourceHandle());
+    if (!m_oldFont)
+      m_oldFont = (WXHFONT) f;
+  }
+
+  if (m_textForegroundColour.Ok())
+    SetTextColor((HDC) m_hDC, m_textForegroundColour.GetPixel() ) ;
+
+  DWORD old_background;
+  if (m_textBackgroundColour.Ok())
+  {
+    old_background = SetBkColor((HDC) m_hDC, m_textBackgroundColour.GetPixel() ) ;
+  }
+
+  if (m_backgroundMode == wxTRANSPARENT)
+    SetBkMode((HDC) m_hDC, TRANSPARENT);
+  else
+    SetBkMode((HDC) m_hDC, OPAQUE);
+
+  (void)TextOut((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), (char *) (const char *)text, strlen((const char *)text));
+
+  if (m_textBackgroundColour.Ok())
+    (void)SetBkColor((HDC) m_hDC, old_background);
+
+  CalcBoundingBox(x, y);
+
+  long w, h;
+  GetTextExtent(text, &w, &h);
+  CalcBoundingBox((x + w), (y + h));
+
+  EndDrawing();
+}
+
+void wxDC::SetBackground(const wxBrush& brush)
+{
+//  if (m_backgroundBrush.Ok())
+//    m_backgroundBrush.ReleaseResource();
+
+  m_backgroundBrush = brush;
+
+  if (!m_backgroundBrush.Ok())
+    return;
+
+//  m_backgroundBrush.UseResource();
+//  m_backgroundBrush.RealizeResource() ;
+
+  if (m_canvas)
+  {
+    bool customColours = TRUE;
+    // If we haven't specified wxUSER_COLOURS, don't allow the panel/dialog box to
+    // change background colours from the control-panel specified colours.
+    if (m_canvas->IsKindOf(CLASSINFO(wxWindow)) && ((m_canvas->GetWindowStyleFlag() & wxUSER_COLOURS) != wxUSER_COLOURS))
+      customColours = FALSE;
+      
+    if (customColours)
+    {
+//      HBRUSH br = (m_backgroundBrush.GetStyle()==wxTRANSPARENT) ?
+//                              GetStockObject(NULL_BRUSH) : (HBRUSH) m_backgroundBrush.GetResourceHandle();
+      if (m_backgroundBrush.GetStyle()==wxTRANSPARENT)
+      {
+        m_canvas->m_backgroundTransparent = TRUE;
+      }
+      else
+      {
+        m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
+        m_canvas->m_backgroundTransparent = FALSE;
+      }
+    }
+  }
+  BeginDrawing();
+
+  COLORREF new_color = m_backgroundBrush.GetColour().GetPixel() ;
+  {
+    (void)SetBkColor((HDC) m_hDC, new_color);
+  }
+
+  EndDrawing();
+}
+
+void wxDC::SetBackgroundMode(int mode)
+{
+  m_backgroundMode = mode;
+
+  BeginDrawing();
+
+  if (m_backgroundMode == wxTRANSPARENT)
+    ::SetBkMode((HDC) m_hDC, TRANSPARENT);
+  else
+    ::SetBkMode((HDC) m_hDC, OPAQUE);
+
+  EndDrawing();
+}
+
+void wxDC::SetLogicalFunction(int function)
+{
+  m_logicalFunction = function;
+
+  BeginDrawing();
+
+  SetRop((WXHDC) m_hDC);
+
+  EndDrawing();
+}
+
+void wxDC::SetRop(WXHDC dc)
+{
+  if (!dc || m_logicalFunction < 0)
+    return;
+
+  int c_rop;
+  // These may be wrong
+  switch (m_logicalFunction)
+  {
+//    case wxXOR: c_rop = R2_XORPEN; break;
+    case wxXOR: c_rop = R2_NOTXORPEN; break;
+    case wxINVERT: c_rop = R2_NOT; break;
+    case wxOR_REVERSE: c_rop = R2_MERGEPENNOT; break;
+    case wxAND_REVERSE: c_rop = R2_MASKPENNOT; break;
+    case wxCLEAR: c_rop = R2_WHITE; break;
+    case wxSET: c_rop = R2_BLACK; break;
+    case wxSRC_INVERT: c_rop = R2_NOTCOPYPEN; break;
+    case wxOR_INVERT: c_rop = R2_MERGENOTPEN; break;
+    case wxAND: c_rop = R2_MASKPEN; break;
+    case wxOR: c_rop = R2_MERGEPEN; break;
+    case wxAND_INVERT: c_rop = R2_MASKNOTPEN; break;
+    case wxEQUIV:
+    case wxNAND:
+    case wxCOPY:
+    default:
+      c_rop = R2_COPYPEN; break;
+  }
+  SetROP2((HDC) dc, c_rop);
+}
+
+bool wxDC::StartDoc(const wxString& message)
+{
+  if (!this->IsKindOf(CLASSINFO(wxPrinterDC)))
+    return TRUE;
+    
+  bool flag = FALSE;
+
+  DOCINFO docinfo;
+  docinfo.cbSize = sizeof(DOCINFO);
+  docinfo.lpszDocName = (const char *)message;
+  docinfo.lpszOutput = (const char *)m_filename;
+#if defined(__WIN95__)
+  docinfo.lpszDatatype = NULL;
+  docinfo.fwType = 0;
+#endif
+
+  if (m_hDC) flag = (SP_ERROR !=
+#ifndef __WIN32__
+     ::StartDoc((HDC) m_hDC, &docinfo));
+#else
+#ifdef UNICODE
+     ::StartDocW((HDC) m_hDC, &docinfo));
+#else
+     ::StartDocA((HDC) m_hDC, &docinfo));
+#endif
+#endif
+
+  else flag = FALSE;
+
+  return flag;
+}
+
+void wxDC::EndDoc(void)
+{
+  if (!this->IsKindOf(CLASSINFO(wxPrinterDC)))
+    return;
+  if (m_hDC) ::EndDoc((HDC) m_hDC);
+}
+
+void wxDC::StartPage(void)
+{
+  if (!this->IsKindOf(CLASSINFO(wxPrinterDC)))
+    return;
+  if (m_hDC)
+    ::StartPage((HDC) m_hDC);
+}
+
+void wxDC::EndPage(void)
+{
+  if (!this->IsKindOf(CLASSINFO(wxPrinterDC)))
+    return;
+  if (m_hDC)
+    ::EndPage((HDC) m_hDC);
+}
+
+long wxDC::GetCharHeight(void) const
+{
+  TEXTMETRIC lpTextMetric;
+
+  GetTextMetrics((HDC) m_hDC, &lpTextMetric);
+
+  return YDEV2LOGREL(lpTextMetric.tmHeight);
+}
+
+long wxDC::GetCharWidth(void) const
+{
+  TEXTMETRIC lpTextMetric;
+
+  GetTextMetrics((HDC) m_hDC, &lpTextMetric);
+
+  return XDEV2LOGREL(lpTextMetric.tmAveCharWidth);
+}
+
+void wxDC::GetTextExtent(const wxString& string, long *x, long *y,
+                         long *descent, long *externalLeading, wxFont *theFont, bool use16bit) const
+{
+  wxFont *fontToUse = (wxFont*) theFont;
+  if (!fontToUse)
+    fontToUse = (wxFont*) &m_font;
+
+  SIZE sizeRect;
+  TEXTMETRIC tm;
+
+  GetTextExtentPoint((HDC) m_hDC, (char *)(const char *) string, strlen((char *)(const char *) string), &sizeRect);
+  GetTextMetrics((HDC) m_hDC, &tm);
+
+  *x = XDEV2LOGREL(sizeRect.cx);
+  *y = YDEV2LOGREL(sizeRect.cy);
+  if (descent) *descent = tm.tmDescent;
+  if (externalLeading) *externalLeading = tm.tmExternalLeading;
+}
+
+void wxDC::SetMapMode(int mode)
+{
+  m_mappingMode = mode;
+
+  int pixel_width = 0;
+  int pixel_height = 0;
+  int mm_width = 0;
+  int mm_height = 0;
+
+  BeginDrawing();
+
+  pixel_width = GetDeviceCaps((HDC) m_hDC, HORZRES);
+  pixel_height = GetDeviceCaps((HDC) m_hDC, VERTRES);
+  mm_width = GetDeviceCaps((HDC) m_hDC, HORZSIZE);
+  mm_height = GetDeviceCaps((HDC) m_hDC, VERTSIZE);
+
+  if ((pixel_width == 0) || (pixel_height == 0) || (mm_width == 0) || (mm_height == 0))
+  {
+//    if (!m_hDC && m_canvas)
+//      m_canvas->ReleaseHDC() ;
+    return;
+  }
+
+  double mm2pixelsX = pixel_width/mm_width;
+  double mm2pixelsY = pixel_height/mm_height;
+
+  switch (mode)
+  {
+    case MM_TWIPS:
+    {
+      m_logicalScaleX = (twips2mm * mm2pixelsX);
+      m_logicalScaleY = (twips2mm * mm2pixelsY);
+      break;
+    }
+    case MM_POINTS:
+    {
+      m_logicalScaleX = (pt2mm * mm2pixelsX);
+      m_logicalScaleY = (pt2mm * mm2pixelsY);
+      break;
+    }
+    case MM_METRIC:
+    {
+      m_logicalScaleX = mm2pixelsX;
+      m_logicalScaleY = mm2pixelsY;
+      break;
+    }
+    case MM_LOMETRIC:
+    {
+      m_logicalScaleX = (mm2pixelsX/10.0);
+      m_logicalScaleY = (mm2pixelsY/10.0);
+      break;
+    }
+    default:
+    case MM_TEXT:
+    {
+      m_logicalScaleX = 1.0;
+      m_logicalScaleY = 1.0;
+      break;
+    }
+  }
+
+  if (::GetMapMode((HDC) m_hDC) != MM_ANISOTROPIC)
+    ::SetMapMode((HDC) m_hDC, MM_ANISOTROPIC);
+
+  SetViewportExtEx((HDC) m_hDC, VIEWPORT_EXTENT, VIEWPORT_EXTENT, NULL);
+  m_windowExtX = (int)MS_XDEV2LOGREL(VIEWPORT_EXTENT);
+  m_windowExtY = (int)MS_YDEV2LOGREL(VIEWPORT_EXTENT);
+  ::SetWindowExtEx((HDC) m_hDC, m_windowExtX, m_windowExtY, NULL);
+  ::SetViewportOrgEx((HDC) m_hDC, (int)m_deviceOriginX, (int)m_deviceOriginY, NULL);
+  ::SetWindowOrgEx((HDC) m_hDC, (int)m_logicalOriginX, (int)m_logicalOriginY, NULL);
+
+  EndDrawing();
+}
+
+void wxDC::SetUserScale(double x, double y)
+{
+  m_userScaleX = x;
+  m_userScaleY = y;
+
+  SetMapMode(m_mappingMode);
+}
+
+void wxDC::SetSystemScale(double x, double y)
+{
+  m_systemScaleX = x;
+  m_systemScaleY = y;
+
+  SetMapMode(m_mappingMode);
+}
+
+void wxDC::SetLogicalOrigin(long x, long y)
+{
+  m_logicalOriginX = x;
+  m_logicalOriginY = y;
+
+  BeginDrawing();
+
+  ::SetWindowOrgEx((HDC) m_hDC, (int)m_logicalOriginX, (int)m_logicalOriginY, NULL);
+
+  EndDrawing();
+}
+
+void wxDC::SetDeviceOrigin(long x, long y)
+{
+  m_deviceOriginX = x;
+  m_deviceOriginY = y;
+
+  BeginDrawing();
+
+  ::SetViewportOrgEx((HDC) m_hDC, (int)m_deviceOriginX, (int)m_deviceOriginY, NULL);
+
+  EndDrawing();
+}
+
+long wxDC::DeviceToLogicalX(long x) const
+{
+	return (long) (((x) - m_deviceOriginX)/(m_logicalScaleX*m_userScaleX*m_systemScaleX) - m_logicalOriginX) ;
+}
+
+long wxDC::DeviceToLogicalXRel(long x) const
+{
+	return (long) ((x)/(m_logicalScaleX*m_userScaleX*m_systemScaleX)) ;
+}
+
+long wxDC::DeviceToLogicalY(long y) const
+{
+   	return (long) (((y) - m_deviceOriginY)/(m_logicalScaleY*m_userScaleY*m_systemScaleY) - m_logicalOriginY) ;
+}
+
+long wxDC::DeviceToLogicalYRel(long y) const
+{
+	return (long) ((y)/(m_logicalScaleY*m_userScaleY*m_systemScaleY)) ;
+}
+
+long wxDC::LogicalToDeviceX(long x) const
+{
+	return (long) (floor((x) - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_systemScaleX + m_deviceOriginX) ;
+}
+
+long wxDC::LogicalToDeviceXRel(long x) const
+{
+	return (long) (floor(x)*m_logicalScaleX*m_userScaleX*m_systemScaleX) ;
+}
+
+long wxDC::LogicalToDeviceY(long y) const
+{
+	return (long) (floor((y) - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_systemScaleY + m_deviceOriginY);
+}
+
+long wxDC::LogicalToDeviceYRel(long y) const
+{
+	return (long) (floor(y)*m_logicalScaleY*m_userScaleY*m_systemScaleY) ;
+}
+
+// This group of functions may not do any conversion
+// if m_scaleGDI is TRUE, since the HDC does the
+// conversion automatically.
+
+long wxDC::ImplDeviceToLogicalX(long x) const
+{
+//	return (m_scaleGDI ?  x :  DeviceToLogicalX(x));
+	return x;
+}
+
+long wxDC::ImplDeviceToLogicalY(long y) const
+{
+//	return (m_scaleGDI ?  y :  DeviceToLogicalY(y));
+	return y;
+}
+
+long wxDC::ImplDeviceToLogicalXRel(long x) const
+{
+//	return (m_scaleGDI ?  x :  DeviceToLogicalXRel(x));
+	return x;
+}
+
+long wxDC::ImplDeviceToLogicalYRel(long y) const
+{
+//	return (m_scaleGDI ?  y :  DeviceToLogicalYRel(y));
+	return y;
+}
+
+long wxDC::ImplLogicalToDeviceX(long x) const
+{
+//	return (m_scaleGDI ?  (floor(double(x))) :  LogicalToDeviceX(x));
+	return x;
+}
+
+long wxDC::ImplLogicalToDeviceY(long y) const
+{
+//	return (m_scaleGDI ?  (floor(double(y))) :  LogicalToDeviceY(y));
+	return y;
+}
+
+long wxDC::ImplLogicalToDeviceXRel(long x) const
+{
+//	return (m_scaleGDI ?  (floor(double(x))) :  LogicalToDeviceXRel(x));
+	return x;
+}
+
+long wxDC::ImplLogicalToDeviceYRel(long y) const
+{
+//	return (m_scaleGDI ?  (floor(double(y))) :  LogicalToDeviceYRel(y));
+	return y;
+}
+
+bool wxDC::Blit(long xdest, long ydest, long width, long height,
+                wxDC *source, long xsrc, long ysrc, int rop, bool useMask)
+{
+  BeginDrawing();
+  source->BeginDrawing();
+
+  long xdest1 = xdest;
+  long ydest1 = ydest;
+  long xsrc1 = xsrc;
+  long ysrc1 = ysrc;
+
+  DWORD dwRop = rop == wxCOPY ? SRCCOPY :
+                rop == wxCLEAR ? WHITENESS :
+                rop == wxSET ? BLACKNESS :
+                rop == wxINVERT ? DSTINVERT :
+                rop == wxAND ? MERGECOPY :
+                rop == wxOR ? MERGEPAINT :
+                rop == wxSRC_INVERT ? NOTSRCCOPY :
+                rop == wxXOR ? SRCINVERT :
+                rop == wxOR_REVERSE ? MERGEPAINT :
+                rop == wxAND_REVERSE ? SRCERASE :
+                rop == wxSRC_OR ? SRCPAINT :
+                rop == wxSRC_AND ? SRCAND :
+                SRCCOPY;
+
+  bool success;
+  if (useMask && source->m_selectedBitmap.Ok() && source->m_selectedBitmap.GetMask())
+  {
+
+#if 0 // __WIN32__
+	// Not implemented under Win95 (or maybe a specific device?)
+    if (MaskBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height,
+            (HDC) source->m_hDC, xsrc1, ysrc1, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap(),
+            0, 0, 0xAACC0020))
+    {
+        // Success
+    }
+    else
+#endif
+    {
+        // Old code
+#if 0
+	    HDC dc_mask = CreateCompatibleDC((HDC) source->m_hDC);
+	    ::SelectObject(dc_mask, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap());
+        success = (BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height,
+					 dc_mask, xsrc1, ysrc1, 0x00220326 /* NOTSRCAND */) != 0);
+        success = (BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height,
+					 (HDC) source->m_hDC, xsrc1, ysrc1, SRCPAINT) != 0);
+	    ::SelectObject(dc_mask, 0);
+	    ::DeleteDC(dc_mask);
+#endif
+        // New code from Chris Breeze, 8/5/98
+
+		// create a temp buffer bitmap and DCs to access it and the mask
+		HDC dc_mask = ::CreateCompatibleDC((HDC) source->m_hDC);
+		HDC dc_buffer = ::CreateCompatibleDC((HDC) m_hDC);
+		HBITMAP buffer_bmap = ::CreateCompatibleBitmap((HDC) m_hDC, width, height);
+	    ::SelectObject(dc_mask, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap());
+	    ::SelectObject(dc_buffer, buffer_bmap);
+
+        // copy dest to buffer
+		::BitBlt(dc_buffer, 0, 0, (int)width, (int)height,
+			(HDC) m_hDC, xdest1, ydest1, SRCCOPY);
+
+		// copy src to buffer using selected raster op
+		::BitBlt(dc_buffer, 0, 0, (int)width, (int)height,
+			(HDC) source->m_hDC, xsrc1, ysrc1, dwRop);
+
+		// set masked area in buffer to BLACK (pixel value 0)
+		COLORREF prevBkCol = ::SetBkColor((HDC) m_hDC, RGB(255, 255, 255));
+		COLORREF prevCol = ::SetTextColor((HDC) m_hDC, RGB(0, 0, 0));
+        ::BitBlt(dc_buffer, 0, 0, (int)width, (int)height,
+			dc_mask, xsrc1, ysrc1, SRCAND);
+
+		// set unmasked area in dest to BLACK
+		::SetBkColor((HDC) m_hDC, RGB(0, 0, 0));
+		::SetTextColor((HDC) m_hDC, RGB(255, 255, 255));
+		::BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height,
+			dc_mask, xsrc1, ysrc1, SRCAND);
+		::SetBkColor((HDC) m_hDC, prevBkCol);	// restore colours to original values
+		::SetTextColor((HDC) m_hDC, prevCol);
+
+        // OR buffer to dest
+		success = (::BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height,
+			dc_buffer, 0, 0, SRCPAINT) != 0);
+
+		// tidy up temporary DCs and bitmap
+		::SelectObject(dc_mask, 0);
+	    ::DeleteDC(dc_mask);
+		::SelectObject(dc_buffer, 0);
+	    ::DeleteDC(dc_buffer);
+		::DeleteObject(buffer_bmap);
+    }
+  }
+  else
+  {
+      success = (BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, (HDC) source->m_hDC,
+                            xsrc1, ysrc1, dwRop) != 0);
+  }
+  source->EndDrawing();
+  EndDrawing();
+
+  return success;
+}
+
+void wxDC::GetSize(int* width, int* height) const
+{
+  long w=::GetDeviceCaps((HDC) m_hDC,HORZRES);
+  long h=::GetDeviceCaps((HDC) m_hDC,VERTRES);
+  *width = w;
+  *height = h;
+}
+
+void wxDC::GetSizeMM(long *width, long *height) const
+{
+  long w=::GetDeviceCaps((HDC) m_hDC,HORZSIZE);
+  long h=::GetDeviceCaps((HDC) m_hDC,VERTSIZE);
+  *width = w;
+  *height = h;
+}
+
+#if USE_SPLINES
+# if USE_XFIG_SPLINE_CODE
+#  include "../common/xfspline.inc"
+# else
+#  include "../common/wxspline.inc"
+# endif
+#endif // USE_SPLINES
+
+void wxDC::DrawPolygon(wxList *list, long xoffset, long yoffset,int fillStyle)
+{
+  int n = list->Number();
+  wxPoint *points = new wxPoint[n];
+
+  int i = 0;
+  for(wxNode *node = list->First(); node; node = node->Next()) {
+    wxPoint *point = (wxPoint *)node->Data();
+    points[i].x = point->x;
+    points[i++].y = point->y;
+  }
+  DrawPolygon(n, points, xoffset, yoffset,fillStyle);
+  delete[] points;
+}
+
+void wxDC::DrawLines(wxList *list, long xoffset, long yoffset)
+{
+  int n = list->Number();
+  wxPoint *points = new wxPoint[n];
+
+  int i = 0;
+  for(wxNode *node = list->First(); node; node = node->Next()) {
+    wxPoint *point = (wxPoint *)node->Data();
+    points[i].x = point->x;
+    points[i++].y = point->y;
+  }
+  DrawLines(n, points, xoffset, yoffset);
+  delete []points;
+}
+
+void wxDC::SetTextForeground(const wxColour& colour)
+{
+    m_textForegroundColour = colour;
+}
+
+void wxDC::SetTextBackground(const wxColour& colour)
+{
+    m_textBackgroundColour = colour;
+}
+
+#if USE_SPLINES
+// Make a 3-point spline
+void wxDC::DrawSpline(long x1, long y1, long x2, long y2, long x3, long y3)
+{
+  wxList *point_list = new wxList;
+
+  wxPoint *point1 = new wxPoint;
+  point1->x = x1; point1->y = y1;
+  point_list->Append((wxObject*)point1);
+
+  wxPoint *point2 = new wxPoint;
+  point2->x = x2; point2->y = y2;
+  point_list->Append((wxObject*)point2);
+
+  wxPoint *point3 = new wxPoint;
+  point3->x = x3; point3->y = y3;
+  point_list->Append((wxObject*)point3);
+
+  DrawSpline(point_list);
+
+  for(wxNode *node = point_list->First(); node; node = node->Next()) {
+    wxPoint *p = (wxPoint *)node->Data();
+    delete p;
+  }
+  delete point_list;
+/*
+  wxSpline spline(point_list);
+
+  wx_draw_open_spline(this, &spline);
+  spline.DeletePoints();
+ */
+}
+#endif
+
+// For use by wxWindows only, unless custom units are required.
+void wxDC::SetLogicalScale(double x, double y)
+{
+  m_logicalScaleX = x;
+  m_logicalScaleY = y;
+}
+
+void wxDC::CalcBoundingBox(long x, long y)
+{
+  if (x < m_minX) m_minX = x;
+  if (y < m_minY) m_minY = y;
+  if (x > m_maxX) m_maxX = x;
+  if (y > m_maxY) m_maxY = y;
+}
+
+void wxDC::GetClippingBox(long *x,long *y,long *w,long *h) const
+{
+  if (m_clipping)
+  {
+    *x = m_clipX1 ;
+    *y = m_clipY1 ;
+    *w = (m_clipX2 - m_clipX1) ;
+    *h = (m_clipY2 - m_clipY1) ;
+  }
+  else
+   *x = *y = *w = *h = 0 ;
+}
+
+#if WXWIN_COMPATIBILITY
+void wxDC::GetTextExtent(const wxString& string, float *x, float *y,
+                     float *descent, float *externalLeading,
+                     wxFont *theFont, bool use16bit) const
+{
+    long x1, y1, descent1, externalLeading1;
+	GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit);
+	*x = x1; *y = y1;
+    if (descent)
+        *descent = descent1;
+    if (externalLeading)
+        *externalLeading = externalLeading1;
+}
+#endif
+
diff --git a/src/msw/dcclient.cpp b/src/msw/dcclient.cpp
new file mode 100644
index 0000000000..c406939a28
--- /dev/null
+++ b/src/msw/dcclient.cpp
@@ -0,0 +1,141 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dcclient.cpp
+// Purpose:     wxClientDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "dcclient.h"
+#endif
+
+#ifdef __GNUG__
+#pragma implementation
+#pragma implementation "dcclient.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#endif
+
+#include "wx/dcclient.h"
+
+#include <windows.h>
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxDC)
+IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
+IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxDC)
+#endif
+
+wxClientDC::wxClientDC(void)
+{
+  m_canvas = NULL;
+}
+
+wxClientDC::wxClientDC(wxWindow *the_canvas)
+{
+  m_canvas = the_canvas;
+//  BeginDrawing();
+  m_hDC = (WXHDC) ::GetDC((HWND) the_canvas->GetHWND());
+}
+
+wxClientDC::~wxClientDC(void)
+{
+//  EndDrawing();
+
+  if (m_canvas && (HDC) m_hDC)
+  {
+    SelectOldObjects(m_hDC);
+
+    ::ReleaseDC((HWND) m_canvas->GetHWND(), (HDC) m_hDC);
+	m_hDC = 0;
+  }
+}
+
+wxWindowDC::wxWindowDC(void)
+{
+  m_canvas = NULL;
+}
+
+wxWindowDC::wxWindowDC(wxWindow *the_canvas)
+{
+  m_canvas = the_canvas;
+//  m_hDC = (WXHDC) ::GetDCEx((HWND) the_canvas->GetHWND(), NULL, DCX_WINDOW);
+  m_hDC = (WXHDC) ::GetWindowDC((HWND) the_canvas->GetHWND() );
+  m_hDCCount ++;
+}
+
+wxWindowDC::~wxWindowDC(void)
+{
+  if (m_canvas && m_hDC)
+  {
+    SelectOldObjects(m_hDC);
+
+    ::ReleaseDC((HWND) m_canvas->GetHWND(), (HDC) m_hDC);
+	m_hDC = 0;
+  }
+  m_hDCCount --;
+}
+
+wxPaintDC::wxPaintDC(void)
+{
+  m_canvas = NULL;
+}
+
+static PAINTSTRUCT g_paintStruct;
+
+// Don't call Begin/EndPaint if it's already been called:
+// for example, if calling a base class OnPaint.
+
+WXHDC wxPaintDC::m_staticPaintHDC = 0;
+int wxPaintDC::m_staticPaintCount = 0;
+
+wxPaintDC::wxPaintDC(wxWindow *the_canvas)
+{
+	if ( the_canvas && (m_staticPaintCount == 0))
+	{
+  		m_hDC = (WXHDC) ::BeginPaint((HWND) the_canvas->GetHWND(), &g_paintStruct);
+  		m_hDCCount ++;
+		m_staticPaintCount ++ ;
+		m_staticPaintHDC = m_hDC ;
+	}
+	else
+  		m_hDC = m_staticPaintHDC ;
+
+  m_canvas = the_canvas;
+  RECT updateRect1 = g_paintStruct.rcPaint;
+  m_canvas->m_updateRect.x = updateRect1.left;
+  m_canvas->m_updateRect.y = updateRect1.top;
+  m_canvas->m_updateRect.width = updateRect1.right - updateRect1.left;
+  m_canvas->m_updateRect.height = updateRect1.bottom - updateRect1.top;
+//  m_canvas->m_paintHDC = m_staticPaintHDC ;
+}
+
+wxPaintDC::~wxPaintDC(void)
+{
+	m_staticPaintCount -- ;
+
+	if (m_staticPaintCount == 0)
+	{
+//  		m_canvas->m_paintHDC = 0;
+
+		if ( m_hDC && m_canvas)
+		{
+  			::EndPaint((HWND) m_canvas->GetHWND(), &g_paintStruct);
+  			m_hDCCount --;
+			m_hDC = 0;
+		}
+		m_staticPaintHDC = 0 ;
+	}
+}
diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp
new file mode 100644
index 0000000000..1ff28ae283
--- /dev/null
+++ b/src/msw/dcmemory.cpp
@@ -0,0 +1,116 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dcmemory.cpp
+// Purpose:     wxMemoryDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation
+#pragma implementation "dcmemory.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#endif
+
+#include "wx/dcmemory.h"
+
+#include <windows.h>
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
+#endif
+
+/*
+ * Memory DC
+ *
+ */
+
+wxMemoryDC::wxMemoryDC(void)
+{
+  m_hDC = (WXHDC) ::CreateCompatibleDC(NULL);
+  m_ok = (m_hDC != 0);
+
+  SetBrush(*wxWHITE_BRUSH);
+  SetPen(*wxBLACK_PEN);
+}
+
+wxMemoryDC::wxMemoryDC(wxDC *old_dc)
+{
+  old_dc->BeginDrawing();
+
+  m_hDC = (WXHDC) ::CreateCompatibleDC((HDC) old_dc->GetHDC());
+  m_ok = (m_hDC != 0);
+
+  old_dc->EndDrawing();
+
+  SetBrush(*wxWHITE_BRUSH);
+  SetPen(*wxBLACK_PEN);
+}
+
+wxMemoryDC::~wxMemoryDC(void)
+{
+}
+
+void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
+{
+  // Select old bitmap out of the device context
+  if (m_oldBitmap)
+  {
+    ::SelectObject((HDC) m_hDC, (HBITMAP) m_oldBitmap);
+    if (m_selectedBitmap.Ok())
+    {
+      m_selectedBitmap.SetSelectedInto(NULL);
+      m_selectedBitmap = wxNullBitmap;
+    }
+  }
+
+  // Do own check for whether the bitmap is already selected into
+  // a device context
+  if (bitmap.GetSelectedInto() && (bitmap.GetSelectedInto() != this))
+  {
+    wxFatalError("Error in wxMemoryDC::SelectObject\nBitmap is selected in another wxMemoryDC.\nDelete the first wxMemoryDC or use SelectObject(NULL)");
+    return;
+  }
+  
+  m_selectedBitmap = bitmap;
+
+  if (!m_selectedBitmap.Ok())
+    return;
+
+  m_selectedBitmap.SetSelectedInto(this);
+#if DEBUG > 1
+  wxDebugMsg("wxMemoryDC::SelectObject: Selecting HBITMAP %X\n", m_selectedBitmap.GetHBITMAP());
+#endif
+  HBITMAP bm = ::SelectObject((HDC) m_hDC, (HBITMAP) m_selectedBitmap.GetHBITMAP());
+
+  if (bm == ERROR)
+  {
+    wxFatalError("Error in wxMemoryDC::SelectObject\nBitmap may not be loaded, or may be selected in another wxMemoryDC.\nDelete the first wxMemoryDC to deselect bitmap.");
+  }
+  else if (!m_oldBitmap)
+    m_oldBitmap = (WXHBITMAP) bm;
+}
+
+void wxMemoryDC::GetSize(int *width, int *height) const
+{
+  if (!m_selectedBitmap.Ok())
+  {
+    *width = 0; *height = 0;
+    return;
+  }
+  *width = m_selectedBitmap.GetWidth();
+  *height = m_selectedBitmap.GetHeight();
+}
+
diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp
new file mode 100644
index 0000000000..6802ea9782
--- /dev/null
+++ b/src/msw/dcprint.cpp
@@ -0,0 +1,208 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dcprint.cpp
+// Purpose:     wxPrinterDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation
+#pragma implementation "dcprint.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#endif
+
+#include "wx/dcprint.h"
+#include "math.h"
+#include "fstream.h"
+
+#include <windows.h>
+
+#if USE_COMMON_DIALOGS
+#include <commdlg.h>
+#endif
+
+#ifndef __WIN32__
+#include <print.h>
+#endif
+
+#ifdef DrawText
+#undef DrawText
+#endif
+
+#ifdef GetCharWidth
+#undef GetCharWidth
+#endif
+
+#ifdef StartDoc
+#undef StartDoc
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_CLASS(wxPrinterDC, wxDC)
+#endif
+
+wxPrinterDC::wxPrinterDC(const wxString& driver_name, const wxString& device_name, const wxString& file, const bool interactive, const int orientation)
+{
+  m_isInteractive = interactive;
+
+  if (!file.IsNull() && file != "")
+    m_filename = file;
+
+#if USE_COMMON_DIALOGS
+   if (interactive)
+   {
+     PRINTDLG pd;
+	
+     pd.lStructSize = sizeof( PRINTDLG );
+     pd.hwndOwner=NULL;
+     pd.hDevMode=(HANDLE)NULL;
+     pd.hDevNames=(HANDLE)NULL;
+     pd.Flags=PD_RETURNDC | PD_NOSELECTION | PD_NOPAGENUMS;
+     pd.nFromPage=0;
+     pd.nToPage=0;
+     pd.nMinPage=0;
+     pd.nMaxPage=0;
+     pd.nCopies=1;
+     pd.hInstance=(HINSTANCE)NULL;
+
+     if ( PrintDlg( &pd ) != 0 )
+     {
+       m_hDC = (WXHDC) pd.hDC;
+       m_ok = TRUE;
+     }
+     else
+     {
+       m_ok = FALSE;
+       return;
+     }
+
+//     m_dontDelete = TRUE;
+   }
+   else
+#endif
+   if ((!driver_name.IsNull() && driver_name != "") &&
+       (!device_name.IsNull() && device_name != "") &&
+       (!file.IsNull() && file != ""))
+   {
+     m_hDC = (WXHDC) CreateDC((char *) (const char *) driver_name, (char *) (const char *) device_name, (char *) (const char *) file, NULL);
+     m_ok = m_hDC ? TRUE: FALSE;
+   }
+   else
+   {
+     m_hDC = wxGetPrinterDC(orientation);
+     m_ok = m_hDC ? TRUE: FALSE;
+   }
+   
+   if (m_hDC)
+   {
+//     int width = GetDeviceCaps(m_hDC, VERTRES);
+//     int height = GetDeviceCaps(m_hDC, HORZRES);
+     SetMapMode(MM_TEXT);
+   }
+  SetBrush(*wxBLACK_BRUSH);
+  SetPen(*wxBLACK_PEN);
+}
+
+wxPrinterDC::wxPrinterDC(WXHDC theDC)
+{
+  m_isInteractive = FALSE;
+
+  m_hDC = theDC;
+  m_ok = TRUE;
+  if (m_hDC)
+ {
+//     int width = GetDeviceCaps(m_hDC, VERTRES);
+//     int height = GetDeviceCaps(m_hDC, HORZRES);
+    SetMapMode(MM_TEXT);
+  }
+  SetBrush(*wxBLACK_BRUSH);
+  SetPen(*wxBLACK_PEN);
+}
+
+wxPrinterDC::~wxPrinterDC(void)
+{
+}
+
+WXHDC wxGetPrinterDC(int orientation)
+{
+    HDC         hDC;
+    LPDEVMODE   lpDevMode = NULL;
+    LPDEVNAMES  lpDevNames;
+    LPSTR       lpszDriverName;
+    LPSTR       lpszDeviceName;
+    LPSTR       lpszPortName;
+
+    PRINTDLG    pd;
+    // __GNUWIN32__ has trouble believing PRINTDLG is 66 bytes - thinks it is 68
+    pd.lStructSize    = 66; // sizeof(PRINTDLG);
+    pd.hwndOwner      = (HWND)NULL;
+    pd.hDevMode       = NULL; // Will be created by PrintDlg
+    pd.hDevNames      = NULL; // Ditto
+    pd.Flags          = PD_RETURNDEFAULT;
+    pd.nCopies        = 1;
+
+    if (!PrintDlg((LPPRINTDLG)&pd))
+    {
+        if ( pd.hDevMode )
+            GlobalFree(pd.hDevMode);
+        if (pd.hDevNames)
+            GlobalFree(pd.hDevNames);
+
+        return(0);
+    }
+
+    if (!pd.hDevNames)
+    {
+        if ( pd.hDevMode )
+            GlobalFree(pd.hDevMode);
+    }
+
+    lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
+    lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
+    lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
+    lpszPortName   = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
+    GlobalUnlock(pd.hDevNames);
+
+    if ( pd.hDevMode )
+    {
+        lpDevMode = (DEVMODE*) GlobalLock(pd.hDevMode);
+        lpDevMode->dmOrientation = orientation;
+        lpDevMode->dmFields |= DM_ORIENTATION;
+    }
+
+#ifdef __WIN32__
+    hDC = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName, (DEVMODE *)lpDevMode);
+#else
+    hDC = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName, (LPSTR)lpDevMode);
+#endif
+
+    if (pd.hDevMode && lpDevMode)
+        GlobalUnlock(pd.hDevMode);
+
+    if (pd.hDevNames)
+    {
+	    GlobalFree(pd.hDevNames);
+	    pd.hDevNames=NULL;
+    }
+    if (pd.hDevMode)
+    {
+        GlobalFree(pd.hDevMode);
+        pd.hDevMode=NULL;
+    }
+    return (WXHDC) hDC;
+}
+
+
diff --git a/src/msw/dcscreen.cpp b/src/msw/dcscreen.cpp
new file mode 100644
index 0000000000..71d61dd7d9
--- /dev/null
+++ b/src/msw/dcscreen.cpp
@@ -0,0 +1,48 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dcscreen.cpp
+// Purpose:     wxScreenDC class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "dcscreen.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#endif
+
+#include "wx/dcscreen.h"
+
+#include <windows.h>
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
+#endif
+
+// Create a DC representing the whole screen
+wxScreenDC::wxScreenDC(void)
+{
+  m_hDC = (WXHDC) ::GetDC(NULL);
+  m_hDCCount ++;
+}
+
+wxScreenDC::~wxScreenDC(void)
+{
+  SelectOldObjects(m_hDC);
+  ::ReleaseDC(NULL, (HDC) m_hDC);
+  m_hDC = 0;
+  m_hDCCount --;
+}
+
diff --git a/src/msw/dde.cpp b/src/msw/dde.cpp
new file mode 100644
index 0000000000..e8c8bd1121
--- /dev/null
+++ b/src/msw/dde.cpp
@@ -0,0 +1,785 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dde.cpp
+// Purpose:     DDE classes
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "dde.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/defs.h"
+#endif
+
+#if USE_IPC
+
+#ifndef WX_PRECOMP
+#include "wx/utils.h"
+#include "wx/app.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "wx/dde.h"
+
+#ifdef __GNUWIN32__
+#include "wx/msw/gnuwin32/extra.h"
+#endif
+
+#include <windows.h>
+#include <ddeml.h>
+#include <string.h>
+
+#ifdef __WIN32__
+#define _EXPORT /**/
+#else
+#define _EXPORT _export
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxDDEServer, wxServerBase)
+IMPLEMENT_DYNAMIC_CLASS(wxDDEClient, wxClientBase)
+IMPLEMENT_CLASS(wxDDEConnection, wxConnectionBase)
+#endif
+
+static wxDDEConnection *DDEFindConnection(HCONV hConv);
+static void DDEDeleteConnection(HCONV hConv);
+static wxDDEServer *DDEFindServer(const wxString& s);
+
+extern "C" HDDEDATA EXPENTRY _EXPORT _DDECallback(
+WORD wType,
+WORD wFmt,
+HCONV hConv,
+HSZ hsz1,
+HSZ hsz2,
+HDDEDATA hData,
+DWORD lData1,
+DWORD lData2);
+
+// Add topic name to atom table before using in conversations
+static HSZ DDEAddAtom(const wxString& string);
+static HSZ DDEGetAtom(const wxString& string);
+static void DDEPrintError(void);
+
+static DWORD DDEIdInst = 0L;
+static wxDDEConnection *DDECurrentlyConnecting = NULL;
+
+static wxList wxAtomTable(wxKEY_STRING);
+static wxList wxDDEClientObjects;
+static wxList wxDDEServerObjects;
+
+char *DDEDefaultIPCBuffer = NULL;
+int DDEDefaultIPCBufferSize = 0;
+
+/*
+ * Initialization
+ *
+ */
+
+static bool DDEInitialized = FALSE;
+
+void wxDDEInitialize()
+{
+  if (DDEInitialized)
+    return;
+  DDEInitialized = TRUE;
+
+  // Should insert filter flags
+  DdeInitialize(&DDEIdInst, (PFNCALLBACK)MakeProcInstance(
+               (FARPROC)_DDECallback, wxGetInstance()),
+               APPCLASS_STANDARD,
+               0L);
+}
+
+/*
+ * CleanUp
+ */
+
+void wxDDECleanUp()
+{
+  if (DDEIdInst != 0)
+  {
+    DdeUninitialize(DDEIdInst);
+    DDEIdInst = 0;
+  }
+  if (DDEDefaultIPCBuffer)
+    delete [] DDEDefaultIPCBuffer ;
+}
+
+// Global find connection
+static wxDDEConnection *DDEFindConnection(HCONV hConv)
+{
+  wxNode *node = wxDDEServerObjects.First();
+  wxDDEConnection *found = NULL;
+  while (node && !found)
+  {
+    wxDDEServer *object = (wxDDEServer *)node->Data();
+    found = object->FindConnection((WXHCONV) hConv);
+    node = node->Next();
+  }
+  if (found)
+  	return found;
+
+  node = wxDDEClientObjects.First();
+  while (node && !found)
+  {
+    wxDDEClient *object = (wxDDEClient *)node->Data();
+    found = object->FindConnection((WXHCONV) hConv);
+    node = node->Next();
+  }
+  return found;
+}
+
+// Global delete connection
+static void DDEDeleteConnection(HCONV hConv)
+{
+  wxNode *node = wxDDEServerObjects.First();
+  bool found = FALSE;
+  while (node && !found)
+  {
+    wxDDEServer *object = (wxDDEServer *)node->Data();
+    found = object->DeleteConnection((WXHCONV) hConv);
+    node = node->Next();
+  }
+  if (found)
+	return;
+
+  node = wxDDEServerObjects.First();
+  while (node && !found)
+  {
+    wxDDEClient *object = (wxDDEClient *)node->Data();
+    found = object->DeleteConnection((WXHCONV) hConv);
+    node = node->Next();
+  }
+}
+
+// Find a server from a service name
+static wxDDEServer *DDEFindServer(const wxString& s)
+{
+  wxNode *node = wxDDEServerObjects.First();
+  wxDDEServer *found = NULL;
+  while (node && !found)
+  {
+    wxDDEServer *object = (wxDDEServer *)node->Data();
+    
+    if (object->GetServiceName() == s)
+      found = object;
+    else node = node->Next();
+  }
+  return found;
+}
+
+/*
+ * Server
+ *
+ */
+
+wxDDEServer::wxDDEServer(void)
+{
+  service_name = "";
+  wxDDEServerObjects.Append(this);
+}
+
+bool wxDDEServer::Create(const wxString& server_name)
+{
+  service_name = server_name;
+  HSZ serviceName = DdeCreateStringHandle(DDEIdInst, (char*) (const char *)server_name, CP_WINANSI);
+
+  if (DdeNameService(DDEIdInst, serviceName, NULL, DNS_REGISTER) == 0)
+  {
+    DDEPrintError();
+    return FALSE;
+  }
+  return TRUE;
+}
+
+wxDDEServer::~wxDDEServer(void)
+{
+  if (service_name != "")
+  {
+    HSZ serviceName = DdeCreateStringHandle(DDEIdInst, (char*) (const char *)service_name, CP_WINANSI);
+    if (DdeNameService(DDEIdInst, serviceName, NULL, DNS_UNREGISTER) == 0)
+    {
+      DDEPrintError();
+    }
+  }
+  wxDDEServerObjects.DeleteObject(this);
+
+  wxNode *node = connections.First();
+  while (node)
+  {
+    wxDDEConnection *connection = (wxDDEConnection *)node->Data();
+    wxNode *next = node->Next();
+    connection->OnDisconnect(); // May delete the node implicitly
+    node = next;
+  }
+
+  // If any left after this, delete them
+  node = connections.First();
+  while (node)
+  {
+    wxDDEConnection *connection = (wxDDEConnection *)node->Data();
+    wxNode *next = node->Next();
+    delete connection;
+    node = next;
+  }
+}
+
+wxConnectionBase *wxDDEServer::OnAcceptConnection(const wxString& /* topic */)
+{
+	return new wxDDEConnection;
+}
+
+wxDDEConnection *wxDDEServer::FindConnection(WXHCONV conv)
+{
+  wxNode *node = connections.First();
+  wxDDEConnection *found = NULL;
+  while (node && !found)
+  {
+    wxDDEConnection *connection = (wxDDEConnection *)node->Data();
+    if (connection->hConv == conv)
+      found = connection;
+    else node = node->Next();
+  }
+  return found;
+}
+
+// Only delete the entry in the map, not the actual connection
+bool wxDDEServer::DeleteConnection(WXHCONV conv)
+{
+  wxNode *node = connections.First();
+  bool found = FALSE;
+  while (node && !found)
+  {
+    wxDDEConnection *connection = (wxDDEConnection *)node->Data();
+    if (connection->hConv == conv)
+    {
+      found = TRUE;
+      delete node;
+    }
+    else node = node->Next();
+  }
+  return found;
+}
+
+
+/*
+ * Client
+ *
+ */
+
+
+wxDDEClient::wxDDEClient(void)
+{
+  wxDDEClientObjects.Append(this);
+}
+
+wxDDEClient::~wxDDEClient(void)
+{
+  wxDDEClientObjects.DeleteObject(this);
+  wxNode *node = connections.First();
+  while (node)
+  {
+    wxDDEConnection *connection = (wxDDEConnection *)node->Data();
+    delete connection;  // Deletes the node implicitly (see ~wxDDEConnection)
+    node = connections.First();
+  }
+}
+
+bool wxDDEClient::ValidHost(const wxString& /* host */)
+{
+  return TRUE;
+}
+
+wxConnectionBase *wxDDEClient::MakeConnection(const wxString& /* host */, const wxString& server_name, const wxString& topic)
+{
+  HSZ serviceName = DdeCreateStringHandle(DDEIdInst, (char*) (const char *)server_name, CP_WINANSI);
+  HSZ topic_atom = DdeCreateStringHandle(DDEIdInst, (char*) (const char *)topic, CP_WINANSI);
+
+  HCONV hConv = DdeConnect(DDEIdInst, serviceName, topic_atom, (PCONVCONTEXT)NULL);
+  if (hConv == NULL)
+    return NULL;
+  else
+  {
+    wxDDEConnection *connection = (wxDDEConnection*) OnMakeConnection();
+    if (connection)
+    {
+      connection->hConv = (WXHCONV) hConv;
+      connection->topic_name = topic;
+	  connection->client = this;
+      connections.Append(connection);
+      return connection;
+    }
+    else return NULL;
+  }
+}
+
+wxConnectionBase *wxDDEClient::OnMakeConnection(void)
+{
+	return new wxDDEConnection;
+}
+
+wxDDEConnection *wxDDEClient::FindConnection(WXHCONV conv)
+{
+  wxNode *node = connections.First();
+  wxDDEConnection *found = NULL;
+  while (node && !found)
+  {
+    wxDDEConnection *connection = (wxDDEConnection *)node->Data();
+    if (connection->hConv == conv)
+      found = connection;
+    else node = node->Next();
+  }
+  return found;
+}
+
+// Only delete the entry in the map, not the actual connection
+bool wxDDEClient::DeleteConnection(WXHCONV conv)
+{
+  wxNode *node = connections.First();
+  bool found = FALSE;
+  while (node && !found)
+  {
+    wxDDEConnection *connection = (wxDDEConnection *)node->Data();
+    if (connection->hConv == conv)
+    {
+      found = TRUE;
+      delete node;
+    }
+    else node = node->Next();
+  }
+  return found;
+}
+
+/*
+ * Connection
+ */
+
+wxDDEConnection::wxDDEConnection(char *buffer, int size)
+{
+  if (buffer == NULL)
+  {
+    if (DDEDefaultIPCBuffer == NULL)
+      DDEDefaultIPCBuffer = new char[DDEDefaultIPCBufferSize];
+    buf_ptr = DDEDefaultIPCBuffer;
+    buf_size = DDEDefaultIPCBufferSize;
+  }
+  else
+  {
+    buf_ptr = buffer;
+    buf_size = size;
+  }
+
+  topic_name = "";
+
+  client = NULL;
+  server = NULL;
+
+  hConv = 0;
+  sending_data = NULL;
+}
+
+wxDDEConnection::wxDDEConnection(void)
+{
+  hConv = 0;
+  sending_data = NULL;
+  server = NULL;
+  client = NULL;
+  if (DDEDefaultIPCBuffer == NULL)
+    DDEDefaultIPCBuffer = new char[DDEDefaultIPCBufferSize];
+
+  buf_ptr = DDEDefaultIPCBuffer;
+  buf_size = DDEDefaultIPCBufferSize;
+  topic_name = "";
+}
+
+wxDDEConnection::~wxDDEConnection(void)
+{
+	if (server)
+		server->GetConnections().DeleteObject(this);
+	else
+	    client->GetConnections().DeleteObject(this);
+}
+
+// Calls that CLIENT can make
+bool wxDDEConnection::Disconnect(void)
+{
+  DDEDeleteConnection((HCONV) hConv);
+  return (DdeDisconnect((HCONV) hConv) != 0);
+}
+
+bool wxDDEConnection::Execute(char *data, int size, int format)
+{
+  DWORD result;
+  if (size < 0)
+    size = strlen(data);
+
+  size ++;
+
+  return (DdeClientTransaction((LPBYTE)data, size, (HCONV) hConv,
+    NULL, format, XTYP_EXECUTE, 5000, &result) ? TRUE : FALSE);
+}
+
+char *wxDDEConnection::Request(const wxString& item, int *size, int format)
+{
+  DWORD result;
+  HSZ atom = DDEGetAtom(item);
+
+  HDDEDATA returned_data = DdeClientTransaction(NULL, 0, (HCONV) hConv,
+    atom, format, XTYP_REQUEST, 5000, &result);
+
+  DWORD len = DdeGetData(returned_data, (LPBYTE)(buf_ptr), buf_size, 0);
+
+  DdeFreeDataHandle(returned_data);
+
+  if (size) *size = (int)len;
+  if (len > 0)
+  {
+    return buf_ptr;
+  }
+  else return NULL;
+}
+
+bool wxDDEConnection::Poke(const wxString& item, char *data, int size, int format)
+{
+  DWORD result;
+  if (size < 0)
+    size = strlen(data);
+
+  size ++;
+
+  HSZ item_atom = DDEGetAtom(item);
+  return (DdeClientTransaction((LPBYTE)data, size, (HCONV) hConv,
+    item_atom, format, XTYP_POKE, 5000, &result) ? TRUE : FALSE);
+}
+
+bool wxDDEConnection::StartAdvise(const wxString& item)
+{
+  DWORD result;
+  HSZ atom = DDEGetAtom(item);
+
+  return (DdeClientTransaction(NULL, 0, (HCONV) hConv,
+    atom, CF_TEXT, XTYP_ADVSTART, 5000, &result) ? TRUE : FALSE);
+}
+
+bool wxDDEConnection::StopAdvise(const wxString& item)
+{
+  DWORD result;
+  HSZ atom = DDEGetAtom(item);
+
+  return (DdeClientTransaction(NULL, 0, (HCONV) hConv,
+    atom, CF_TEXT, XTYP_ADVSTOP, 5000, &result) ? TRUE : FALSE);
+}
+
+// Calls that SERVER can make
+bool wxDDEConnection::Advise(const wxString& item, char *data, int size, int format)
+{
+  if (size < 0)
+    size = strlen(data);
+
+  size ++;
+
+  HSZ item_atom = DDEGetAtom(item);
+  HSZ topic_atom = DDEGetAtom(topic_name);
+  sending_data = data;
+  data_size = size;
+  data_type = format;
+  return (DdePostAdvise(DDEIdInst, topic_atom, item_atom) != 0);
+}
+
+bool wxDDEConnection::OnDisconnect(void)
+{
+	delete this;
+	return TRUE;
+}
+
+
+#define DDERETURN HDDEDATA
+
+HDDEDATA EXPENTRY _EXPORT _DDECallback(
+WORD wType,
+WORD wFmt,
+HCONV hConv,
+HSZ hsz1,
+HSZ hsz2,
+HDDEDATA hData,
+DWORD /* lData1 */,
+DWORD /* lData2 */)
+{
+  switch (wType)
+  {
+    case XTYP_CONNECT:
+    {
+      char topic_buf[100];
+      char server_buf[100];
+      DdeQueryString(DDEIdInst, hsz1, (LPSTR)topic_buf, sizeof(topic_buf),
+                     CP_WINANSI);
+      DdeQueryString(DDEIdInst, hsz2, (LPSTR)server_buf, sizeof(topic_buf),
+                     CP_WINANSI);
+      wxDDEServer *server = DDEFindServer(server_buf);
+      if (server)
+      {
+        wxDDEConnection *connection =
+          (wxDDEConnection*) server->OnAcceptConnection(wxString(topic_buf));
+        if (connection)
+        {
+          connection->server = server;
+          server->GetConnections().Append(connection);
+          connection->hConv = 0;
+          connection->topic_name = topic_buf;
+          DDECurrentlyConnecting = connection;
+          return (DDERETURN)TRUE;
+        }
+      }
+      else return (DDERETURN)0;
+      break;
+    }
+
+    case XTYP_CONNECT_CONFIRM:
+    {
+      if (DDECurrentlyConnecting)
+      {
+        DDECurrentlyConnecting->hConv = (WXHCONV) hConv;
+        DDECurrentlyConnecting = NULL;
+        return (DDERETURN)TRUE;
+      }
+      else return 0;
+      break;
+    }
+
+    case XTYP_DISCONNECT:
+    {
+      wxDDEConnection *connection = DDEFindConnection(hConv);
+      if (connection && connection->OnDisconnect())
+      {
+        DDEDeleteConnection(hConv);  // Delete mapping: hConv => connection
+        return (DDERETURN)TRUE;
+      }
+      else return (DDERETURN)0;
+      break;
+    }
+
+    case XTYP_EXECUTE:
+    {
+      wxDDEConnection *connection = DDEFindConnection(hConv);
+
+      if (connection)
+      {
+        DWORD len = DdeGetData(hData, (LPBYTE)(connection->buf_ptr), connection->buf_size, 0);
+        DdeFreeDataHandle(hData);
+        if (connection->OnExecute(connection->topic_name, connection->buf_ptr, (int)len, wFmt))
+          return (DDERETURN)DDE_FACK;
+        else
+          return (DDERETURN)DDE_FNOTPROCESSED;
+      } else return (DDERETURN)DDE_FNOTPROCESSED;
+      break;
+    }
+
+    case XTYP_REQUEST:
+    {
+      wxDDEConnection *connection = DDEFindConnection(hConv);
+
+      if (connection)
+      {
+        char item_name[200];
+        DdeQueryString(DDEIdInst, hsz2, (LPSTR)item_name, sizeof(item_name),
+                     CP_WINANSI);
+
+        int user_size = -1;
+        char *data = connection->OnRequest(connection->topic_name, wxString(item_name), &user_size, wFmt);
+        if (data)
+        {
+          if (user_size < 0) user_size = strlen(data);
+
+          HDDEDATA handle = DdeCreateDataHandle(DDEIdInst,
+                 (LPBYTE)data, user_size + 1, 0, hsz2, wFmt, 0);
+          return (DDERETURN)handle;
+        } else return (DDERETURN)0;
+      } else return (DDERETURN)0;
+      break;
+    }
+
+    case XTYP_POKE:
+    {
+      wxDDEConnection *connection = DDEFindConnection(hConv);
+
+      if (connection)
+      {
+        char item_name[200];
+        DdeQueryString(DDEIdInst, hsz2, (LPSTR)item_name, sizeof(item_name),
+                     CP_WINANSI);
+        DWORD len = DdeGetData(hData, (LPBYTE)(connection->buf_ptr), connection->buf_size, 0);
+        DdeFreeDataHandle(hData);
+        connection->OnPoke(connection->topic_name, wxString(item_name), connection->buf_ptr, (int)len, wFmt);
+        return (DDERETURN)DDE_FACK;
+      } else return (DDERETURN)DDE_FNOTPROCESSED;
+      break;
+    }
+
+    case XTYP_ADVSTART:
+    {
+      wxDDEConnection *connection = DDEFindConnection(hConv);
+
+      if (connection)
+      {
+        char item_name[200];
+        DdeQueryString(DDEIdInst, hsz2, (LPSTR)item_name, sizeof(item_name),
+                     CP_WINANSI);
+
+        return (DDERETURN)connection->OnStartAdvise(connection->topic_name, wxString(item_name));
+      } else return (DDERETURN)0;
+      break;
+    }
+
+    case XTYP_ADVSTOP:
+    {
+      wxDDEConnection *connection = DDEFindConnection(hConv);
+
+      if (connection)
+      {
+        char item_name[200];
+        DdeQueryString(DDEIdInst, hsz2, (LPSTR)item_name, sizeof(item_name),
+                     CP_WINANSI);
+        return (DDERETURN)connection->OnStopAdvise(connection->topic_name, wxString(item_name));
+      } else return (DDERETURN)0;
+      break;
+    }
+
+    case XTYP_ADVREQ:
+    {
+      wxDDEConnection *connection = DDEFindConnection(hConv);
+
+      if (connection && connection->sending_data)
+      {
+        HDDEDATA data = DdeCreateDataHandle(DDEIdInst,
+                          (LPBYTE)connection->sending_data,
+                          connection->data_size, 0, hsz2, connection->data_type, 0);
+        connection->sending_data = NULL;
+        return (DDERETURN)data;
+      } else return (DDERETURN)NULL;
+      break;
+    }
+
+    case XTYP_ADVDATA:
+    {
+      wxDDEConnection *connection = DDEFindConnection(hConv);
+
+      if (connection)
+      {
+        char item_name[200];
+        DdeQueryString(DDEIdInst, hsz2, (LPSTR)item_name, sizeof(item_name),
+                     CP_WINANSI);
+
+        DWORD len = DdeGetData(hData, (LPBYTE)(connection->buf_ptr), connection->buf_size, 0);
+        DdeFreeDataHandle(hData);
+        if (connection->OnAdvise(connection->topic_name, wxString(item_name), connection->buf_ptr, (int)len, wFmt))
+          return (DDERETURN)DDE_FACK;
+        else
+          return (DDERETURN)DDE_FNOTPROCESSED;
+      } else return (DDERETURN)DDE_FNOTPROCESSED;
+      break;
+    }
+  }
+  return 0;
+}
+
+// Atom table stuff
+static HSZ DDEAddAtom(const wxString& string)
+{
+  HSZ atom = DdeCreateStringHandle(DDEIdInst, (char*) (const char *)string, CP_WINANSI);
+  wxAtomTable.Append(string, (wxObject *)atom);
+  return atom;
+}
+
+static HSZ DDEGetAtom(const wxString& string)
+{
+  wxNode *node = wxAtomTable.Find(string);
+  if (node)
+    return (HSZ)node->Data();
+  else
+  {
+    DDEAddAtom(string);
+    return (HSZ)(wxAtomTable.Find(string)->Data());
+  }
+}
+
+void DDEPrintError(void)
+{
+  char *err = NULL;
+  switch (DdeGetLastError(DDEIdInst))
+  {
+    case DMLERR_ADVACKTIMEOUT:
+      err = "A request for a synchronous advise transaction has timed out.";
+      break;
+    case DMLERR_BUSY:
+      err = "The response to the transaction caused the DDE_FBUSY bit to be set.";
+      break;
+    case DMLERR_DATAACKTIMEOUT:
+      err = "A request for a synchronous data transaction has timed out.";
+      break;
+    case DMLERR_DLL_NOT_INITIALIZED:
+      err = "A DDEML function was called without first calling the DdeInitialize function,\n\ror an invalid instance identifier\n\rwas passed to a DDEML function.";
+      break;
+    case DMLERR_DLL_USAGE:
+      err = "An application initialized as APPCLASS_MONITOR has\n\rattempted to perform a DDE transaction,\n\ror an application initialized as APPCMD_CLIENTONLY has \n\rattempted to perform server transactions.";
+      break;
+    case DMLERR_EXECACKTIMEOUT:
+      err = "A request for a synchronous execute transaction has timed out.";
+      break;
+    case DMLERR_INVALIDPARAMETER:
+      err = "A parameter failed to be validated by the DDEML.";
+      break;
+    case DMLERR_LOW_MEMORY:
+      err = "A DDEML application has created a prolonged race condition.";
+      break;
+    case DMLERR_MEMORY_ERROR:
+      err = "A memory allocation failed.";
+      break;
+    case DMLERR_NO_CONV_ESTABLISHED:
+      err = "A client's attempt to establish a conversation has failed.";
+      break;
+    case DMLERR_NOTPROCESSED:
+      err = "A transaction failed.";
+      break;
+    case DMLERR_POKEACKTIMEOUT:
+      err = "A request for a synchronous poke transaction has timed out.";
+      break;
+    case DMLERR_POSTMSG_FAILED:
+      err = "An internal call to the PostMessage function has failed. ";
+      break;
+    case DMLERR_REENTRANCY:
+      err = "Reentrancy problem.";
+      break;
+    case DMLERR_SERVER_DIED:
+      err = "A server-side transaction was attempted on a conversation\n\rthat was terminated by the client, or the server\n\rterminated before completing a transaction.";
+      break;
+    case DMLERR_SYS_ERROR:
+      err = "An internal error has occurred in the DDEML.";
+      break;
+    case DMLERR_UNADVACKTIMEOUT:
+      err = "A request to end an advise transaction has timed out.";
+      break;
+    case DMLERR_UNFOUND_QUEUE_ID:
+      err = "An invalid transaction identifier was passed to a DDEML function.\n\rOnce the application has returned from an XTYP_XACT_COMPLETE callback,\n\rthe transaction identifier for that callback is no longer valid.";
+      break;
+    default:
+      err = "Unrecognised error type.";
+      break;
+  }
+  MessageBox(NULL, (LPCSTR)err, "DDE Error", MB_OK | MB_ICONINFORMATION);
+}
+
+#endif
+  // USE_IPC
diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp
new file mode 100644
index 0000000000..6e5e380c55
--- /dev/null
+++ b/src/msw/dialog.cpp
@@ -0,0 +1,605 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dialog.cpp
+// Purpose:     wxDialog class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "dialog.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/dialog.h"
+#include "wx/utils.h"
+#include "wx/frame.h"
+#include "wx/app.h"
+#include "wx/settings.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#if USE_COMMON_DIALOGS
+#include <commdlg.h>
+#endif
+
+#define wxDIALOG_DEFAULT_X 300
+#define wxDIALOG_DEFAULT_Y 300
+
+// Lists to keep track of windows, so we can disable/enable them
+// for modal dialogs
+wxList wxModalDialogs;
+wxList wxModelessWindows;  // Frames and modeless dialogs
+extern wxList wxPendingDelete;
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
+
+BEGIN_EVENT_TABLE(wxDialog, wxPanel)
+  EVT_BUTTON(wxID_OK, wxDialog::OnOK)
+  EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
+  EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
+  EVT_CHAR_HOOK(wxDialog::OnCharHook)
+  EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
+  EVT_CLOSE(wxDialog::OnCloseWindow)
+END_EVENT_TABLE()
+
+#endif
+
+long wxDialog::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+  return ::CallWindowProc(CASTWNDPROC (FARPROC) m_oldWndProc, (HWND) GetHWND(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
+}
+
+bool wxDialog::MSWProcessMessage(WXMSG* pMsg)
+{
+  return (::IsDialogMessage((HWND) GetHWND(), (MSG*)pMsg) != 0);
+}
+
+bool wxDialog::MSWOnClose(void)
+{
+    return Close();
+}
+
+wxDialog::wxDialog(void)
+{
+  m_isShown = FALSE;
+  m_modalShowing = FALSE;
+
+  SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+  SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+}
+
+bool wxDialog::Create(wxWindow *parent, const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos,
+           const wxSize& size,
+           const long style,
+           const wxString& name)
+{
+  SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+  SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+  SetName(name);
+  
+  if (!parent)
+    wxTopLevelWindows.Append(this);
+
+//  windowFont = wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL);
+
+  if (parent) parent->AddChild(this);
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  if (x < 0) x = wxDIALOG_DEFAULT_X;
+  if (y < 0) y = wxDIALOG_DEFAULT_Y;
+
+  m_windowStyle = style;
+
+  m_isShown = FALSE;
+  m_modalShowing = FALSE;
+
+  if (width < 0)
+    width = 500;
+  if (height < 0)
+    height = 500;
+
+  WXDWORD extendedStyle = MakeExtendedStyle(m_windowStyle);
+  if (m_windowStyle & wxSTAY_ON_TOP)
+    extendedStyle |= WS_EX_TOPMOST;
+
+  // Allows creation of dialogs with & without captions under MSWindows
+  if(style & wxCAPTION){
+    MSWCreate(m_windowId, (wxWindow *)parent, NULL, this, NULL, x, y, width, height, 0, "wxCaptionDialog",
+	  extendedStyle);
+  }
+  else{
+    MSWCreate(m_windowId, (wxWindow *)parent, NULL, this, NULL, x, y, width, height, 0, "wxNoCaptionDialog",
+	  extendedStyle);
+  }
+
+  SubclassWin(GetHWND());
+
+  SetWindowText((HWND) GetHWND(), (const char *)title);
+  SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+
+  return TRUE;
+}
+
+void wxDialog::SetModal(const bool flag)
+{
+	if ( flag )
+		m_windowStyle |= wxDIALOG_MODAL ;
+	else
+		if ( m_windowStyle & wxDIALOG_MODAL )
+  			m_windowStyle -= wxDIALOG_MODAL ;
+  
+  wxModelessWindows.DeleteObject(this);
+  if (!flag)
+    wxModelessWindows.Append(this);
+}
+
+wxDialog::~wxDialog()
+{
+  m_isBeingDeleted = TRUE;
+
+  wxTopLevelWindows.DeleteObject(this);
+
+  if (m_modalShowing)
+  {
+    Show(FALSE);
+    // For some reason, wxWindows can activate another task altogether
+    // when a frame is destroyed after a modal dialog has been invoked.
+    // Try to bring the parent to the top.
+    // dfgg: I moved this following line from end of function -
+    //       must not call if another window is on top!!
+    //       This can often happen with Close() and delayed deleting
+    if (GetParent() && GetParent()->GetHWND())
+      ::BringWindowToTop((HWND) GetParent()->GetHWND());
+  }
+
+  m_modalShowing = FALSE;
+  if ( GetHWND() )
+    ShowWindow((HWND) GetHWND(), SW_HIDE);
+
+  if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
+    wxModelessWindows.DeleteObject(this);
+
+  UnsubclassWin();
+
+  // If this is the last top-level window, exit.
+  if (wxTheApp && (wxTopLevelWindows.Number() == 0))
+  {
+    wxTheApp->SetTopWindow(NULL);
+
+    if (wxTheApp->GetExitOnFrameDelete())
+    {
+       PostQuitMessage(0);
+    }
+  }
+}
+
+// By default, pressing escape cancels the dialog
+void wxDialog::OnCharHook(wxKeyEvent& event)
+{
+  if (GetHWND())
+  {
+    if (event.m_keyCode == WXK_ESCAPE)
+    {
+		// Behaviour changed in 2.0: we'll send a Cancel message
+		// to the dialog instead of Close.
+		wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
+		cancelEvent.SetEventObject( this );
+		GetEventHandler()->ProcessEvent(cancelEvent);
+
+		return;
+    }
+  }
+  // We didn't process this event.
+  event.Skip();
+}
+
+void wxDialog::OnPaint(wxPaintEvent& event)
+{
+	// No: if you call the default procedure, it makes
+	// the following painting code not work.
+//	wxWindow::OnPaint(event);
+}
+
+void wxDialog::Fit(void)
+{
+  wxWindow::Fit();
+}
+
+void wxDialog::Iconize(const bool WXUNUSED(iconize))
+{
+  // Windows dialog boxes can't be iconized
+}
+
+bool wxDialog::IsIconized(void) const
+{
+  return FALSE;
+}
+
+void wxDialog::SetSize(const int x, const int y, const int width, const int height, const int WXUNUSED(sizeFlags))
+{
+  wxWindow::SetSize(x, y, width, height);
+}
+
+void wxDialog::SetClientSize(const int width, const int height)
+{
+  HWND hWnd = (HWND) GetHWND();
+  RECT rect;
+  GetClientRect(hWnd, &rect);
+
+  RECT rect2;
+  GetWindowRect(hWnd, &rect2);
+
+  // Find the difference between the entire window (title bar and all)
+  // and the client area; add this to the new client size to move the
+  // window
+  int actual_width = rect2.right - rect2.left - rect.right + width;
+  int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
+
+  MoveWindow(hWnd, rect2.left, rect2.top, actual_width, actual_height, TRUE);
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(actual_width, actual_height);
+#else
+  wxSizeEvent event(wxSize(actual_width, actual_height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+}
+
+void wxDialog::GetPosition(int *x, int *y) const
+{
+  HWND hWnd = (HWND) GetHWND();
+  RECT rect;
+  GetWindowRect(hWnd, &rect);
+
+  *x = rect.left;
+  *y = rect.top;
+}
+
+bool wxDialog::IsShown(void) const
+{
+  return m_isShown;
+}
+
+bool wxDialog::Show(const bool show)
+{
+  m_isShown = show;
+
+  if (show)
+    InitDialog();
+
+  bool modal =  ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ;
+
+#if WXGARBAGE_COLLECTION_ON /* MATTHEW: GC */
+  if (!modal) {
+    if (show) {
+      if (!wxModelessWindows.Member(this))
+	wxModelessWindows.Append(this);
+    } else
+      wxModelessWindows.DeleteObject(this);
+  }
+  if (show) {
+    if (!wxTopLevelWindows.Member(this))
+      wxTopLevelWindows.Append(this);
+  } else
+    wxTopLevelWindows.DeleteObject(this);
+#endif
+
+  if (modal)
+  {
+    if (show)
+    {
+      wxList DisabledWindows;
+      if (m_modalShowing)
+      {
+        BringWindowToTop((HWND) GetHWND());
+        return TRUE;
+      }
+      
+      m_modalShowing = TRUE;
+      wxNode *node = wxModalDialogs.First();
+      while (node)
+      {
+        wxDialog *box = (wxDialog *)node->Data();
+        if (box != this)
+          ::EnableWindow((HWND) box->GetHWND(), FALSE);
+        node = node->Next();
+      }
+      node = wxModelessWindows.First();
+      while (node)
+      {
+        wxWindow *win = (wxWindow *)node->Data();
+		if (::IsWindowEnabled((HWND) win->GetHWND()))
+		{
+          ::EnableWindow((HWND) win->GetHWND(), FALSE);
+          DisabledWindows.Append(win);
+		}
+        node = node->Next();
+      }
+
+      ShowWindow((HWND) GetHWND(), SW_SHOW);
+      EnableWindow((HWND) GetHWND(), TRUE);
+      BringWindowToTop((HWND) GetHWND());
+
+      if (!wxModalDialogs.Member(this))
+        wxModalDialogs.Append(this);
+
+      MSG msg;
+      // Must test whether this dialog still exists: we may not process
+      // a message before the deletion.
+      while (wxModalDialogs.Member(this) && m_modalShowing && GetMessage(&msg, NULL, 0, 0))
+      {
+        if (!IsDialogMessage((HWND) GetHWND(), &msg))
+        {
+          TranslateMessage(&msg);
+          DispatchMessage(&msg);
+        }
+        if (m_modalShowing && !::PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE))
+				// dfgg: NB MUST test m_modalShowing again as the message loop could have triggered
+				//       a Show(FALSE) in the mean time!!!
+				// Without the test, we might delete the dialog before the end of modal showing.
+        {
+                while (wxTheApp->ProcessIdle() && m_modalShowing)
+                {
+                    // Keep going until we decide we've done enough
+                }
+         }
+      }
+      // dfgg: now must specifically re-enable all other app windows that we disabled earlier
+      node=DisabledWindows.First();
+      while(node) {
+		wxWindow* win = (wxWindow*) node->Data();
+        HWND hWnd = (HWND) win->GetHWND();
+        if (::IsWindow(hWnd) && (wxModalDialogs.Member(win) || wxModelessWindows.Member(win) ))
+          ::EnableWindow(hWnd,TRUE);
+        node=node->Next();
+      }
+    }
+    else
+    {
+      wxModalDialogs.DeleteObject(this);
+
+      wxNode *last = wxModalDialogs.Last();
+
+      // If there's still a modal dialog active, we
+      // enable it, else we enable all modeless windows
+      if (last)
+      {
+        wxDialog *box = (wxDialog *)last->Data();
+        HWND hwnd = (HWND) box->GetHWND();
+        if (box->m_winEnabled)
+          EnableWindow(hwnd, TRUE);
+        BringWindowToTop(hwnd);
+      }
+      else
+      {
+        wxNode *node = wxModelessWindows.First();
+        while (node)
+        {
+          wxWindow *win = (wxWindow *)node->Data();
+          HWND hwnd = (HWND) win->GetHWND();
+          // Only enable again if not user-disabled.
+          if (win->IsUserEnabled())
+            EnableWindow(hwnd, TRUE);
+          node = node->Next();
+        }
+      }
+      // Try to highlight the correct window (the parent)
+      HWND hWndParent = 0;
+      if (GetParent())
+      {
+        hWndParent = (HWND) GetParent()->GetHWND();
+        if (hWndParent)
+          ::BringWindowToTop(hWndParent);
+      }
+      ShowWindow((HWND) GetHWND(), SW_HIDE);
+      m_modalShowing = FALSE;
+    }
+  }
+  else
+  {
+    if (show)
+    {
+      ShowWindow((HWND) GetHWND(), SW_SHOW);
+      BringWindowToTop((HWND) GetHWND());
+    }
+    else
+    {
+      // Try to highlight the correct window (the parent)
+      HWND hWndParent = 0;
+      if (GetParent())
+      {
+        hWndParent = (HWND) GetParent()->GetHWND();
+        if (hWndParent)
+          ::BringWindowToTop(hWndParent);
+      }
+      ShowWindow((HWND) GetHWND(), SW_HIDE);
+    }
+  }
+  return TRUE;
+}
+
+void wxDialog::SetTitle(const wxString& title)
+{
+  SetWindowText((HWND) GetHWND(), (const char *)title);
+}
+
+wxString wxDialog::GetTitle(void) const
+{
+  GetWindowText((HWND) GetHWND(), wxBuffer, 1000);
+  return wxString(wxBuffer);
+}
+
+void wxDialog::Centre(const int direction)
+{
+  int x_offset,y_offset ;
+  int display_width, display_height;
+  int  width, height, x, y;
+  wxFrame *frame ;
+  if (direction & wxCENTER_FRAME)
+  {
+    frame = (wxFrame*)GetParent() ;
+    if (frame)
+    {
+      frame->GetPosition(&x_offset,&y_offset) ;
+      frame->GetSize(&display_width,&display_height) ;
+    }
+  }
+  else
+    frame = NULL ;
+
+  if (frame==NULL)
+  {
+    wxDisplaySize(&display_width, &display_height);
+    x_offset = 0 ;
+    y_offset = 0 ;
+  }
+
+
+  GetSize(&width, &height);
+  GetPosition(&x, &y);
+
+  if (direction & wxHORIZONTAL)
+    x = (int)((display_width - width)/2);
+  if (direction & wxVERTICAL)
+    y = (int)((display_height - height)/2);
+
+  SetSize(x+x_offset, y+y_offset, width, height);
+}
+
+// Replacement for Show(TRUE) for modal dialogs - returns return code
+int wxDialog::ShowModal(void)
+{
+	Show(TRUE);
+	return GetReturnCode();
+}
+
+void wxDialog::EndModal(int retCode)
+{
+	SetReturnCode(retCode);
+	Show(FALSE);
+}
+
+// Define for each class of dialog and control
+WXHBRUSH wxDialog::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+#if CTL3D
+  HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
+  return (WXHBRUSH) hbrush;
+#else
+  return 0;
+#endif
+}
+
+// Standard buttons
+void wxDialog::OnOK(wxCommandEvent& event)
+{
+	if ( Validate() && TransferDataFromWindow() )
+	{
+        if ( IsModal() )
+            EndModal(wxID_OK);
+        else
+        {
+		    SetReturnCode(wxID_OK);
+		    this->Show(FALSE);
+        }
+	}
+}
+
+void wxDialog::OnApply(wxCommandEvent& event)
+{
+	if (Validate())
+		TransferDataFromWindow();
+	// TODO probably need to disable the Apply button until things change again
+}
+
+void wxDialog::OnCancel(wxCommandEvent& event)
+{
+    if ( IsModal() )
+        EndModal(wxID_CANCEL);
+    else
+    {
+        SetReturnCode(wxID_CANCEL);
+		this->Show(FALSE);
+    }
+}
+
+bool wxDialog::OnClose(void)
+{
+	// Behaviour changed in 2.0: we'll send a Cancel message by default,
+    // which may close the dialog.
+    // Check for looping if the Cancel event handler calls Close()
+
+    static wxList closing;
+
+    if ( closing.Member(this) )
+        return FALSE;
+
+    closing.Append(this);
+
+	wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
+	cancelEvent.SetEventObject( this );
+	GetEventHandler()->ProcessEvent(cancelEvent);
+
+    closing.DeleteObject(this);
+
+	return FALSE;
+}
+
+void wxDialog::OnCloseWindow(wxCloseEvent& event)
+{
+    // Compatibility
+    if ( GetEventHandler()->OnClose() || event.GetForce())
+    {
+        this->Destroy();
+    }
+}
+
+// Destroy the window (delayed, if a managed window)
+bool wxDialog::Destroy(void)
+{
+  if (!wxPendingDelete.Member(this))
+    wxPendingDelete.Append(this);
+  return TRUE;
+}
+
+void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
+{
+#if CTL3D
+  Ctl3dColorChange();
+#else
+  SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+  SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+  Refresh();
+#endif
+}
+
+long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+	return wxWindow::MSWWindowProc(message, wParam, lParam);
+}
+
diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp
new file mode 100644
index 0000000000..58d92874cb
--- /dev/null
+++ b/src/msw/dib.cpp
@@ -0,0 +1,934 @@
+/*******************************************************************************
+ *									       *
+ * MODULE	: DIB.CC 						       *
+ *									       *
+ *  DESCRIPTION : Routines for dealing with Device Independent Bitmaps.        *
+ *									       *
+ *  FUNCTIONS	:                                                              *
+ *									       *
+ *                ReadDIB()           - Reads a DIB                            *
+ *									       *
+ *		  WriteDIB()	      - Writes a global handle in CF_DIB format*
+ *					to a file.			       *
+ *									       *
+ *		  PaletteSize()       - Calculates the palette size in bytes   *
+ *					of given DIB			       *
+ *									       *
+ *		  DibNumColors()      - Determines the number of colors in DIB *
+ *									       *
+ *		  DibFromBitmap()     - Creates a DIB repr. the DDB passed in. *
+ *									       *
+ *									       *
+ *		  lread()	      - Private routine to read more than 64k  *
+ *									       *
+ *		  lwrite()	      - Private routine to write more than 64k *
+ *									       *
+ *******************************************************************************/
+
+// For compilers that support precompilation, includes "wx.h".
+#define IN_WX_MAIN_CPP
+#include "wx/wxprec.h"
+
+#if defined(__BORLANDC__)
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#include "wx/defs.h"
+#endif
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+
+#include "wx/msw/dib.h"
+
+#ifdef __GNUWIN32__
+#include "wx/msw/gnuwin32/extra.h"
+#endif
+
+#ifndef SEEK_CUR
+/* flags for _lseek */
+#define	SEEK_CUR 1
+#define	SEEK_END 2
+#define	SEEK_SET 0
+#endif
+
+#define MAXREAD  32768				 /* Number of bytes to be read during */
+						 /* each read operation.			 */
+
+/* Header signatutes for various resources */
+#define BFT_ICON	 0x4349	 /* 'IC' */
+#define BFT_BITMAP 0x4d42	 /* 'BM' */
+#define BFT_CURSOR 0x5450	 /* 'PT' */
+
+/* macro to determine if resource is a DIB */
+#define ISDIB(bft) ((bft) == BFT_BITMAP)
+
+/* Macro to align given value to the closest DWORD (unsigned long ) */
+#define ALIGNULONG(i)	((i+3)/4*4)
+
+/* Macro to determine to round off the given value to the closest byte */
+#define WIDTHBYTES(i)	((i+31)/32*4)
+
+#define PALVERSION		0x300
+#define MAXPALETTE	256	  /* max. # supported palette entries */
+
+DWORD PASCAL lread(int fh, VOID FAR *pv, DWORD ul);
+DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul);
+
+BOOL		 WriteDIB (LPSTR szFile,HANDLE hdib);
+WORD		 PaletteSize (VOID FAR * pv);
+WORD		 DibNumColors (VOID FAR * pv);
+// HANDLE		 DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal);
+BOOL             PASCAL MakeBitmapAndPalette(HDC,HANDLE,HPALETTE *,HBITMAP *);
+HPALETTE MakeDIBPalette(LPBITMAPINFOHEADER);
+BOOL             ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette);
+
+/****************************************************************************
+ *									    *
+ *  FUNCTION   : WriteDIB(LPSTR szFile,HANDLE hdib)			    *
+ *									    *
+ *  PURPOSE    : Write a global handle in CF_DIB format to a file.	    *
+ *									    *
+ *  RETURNS    : TRUE  - if successful. 				    *
+ *		 FALSE - otherwise					    *
+ *									    *
+ ****************************************************************************/
+
+BOOL WriteDIB(LPSTR szFile, HANDLE hdib)
+{
+	BITMAPFILEHEADER	hdr;
+	LPBITMAPINFOHEADER  lpbi;
+	int                 fh;
+	OFSTRUCT            of;
+
+	if (!hdib)
+		return FALSE;
+
+	fh = OpenFile(szFile, &of, OF_CREATE | OF_READWRITE);
+	if (fh == -1)
+		return FALSE;
+
+#ifdef __WINDOWS_386__
+        lpbi = (LPBITMAPINFOHEADER) MK_FP32(GlobalLock(hdib));
+#else
+        lpbi = (LPBITMAPINFOHEADER) GlobalLock(hdib);
+#endif
+    /* Fill in the fields of the file header */
+	hdr.bfType = BFT_BITMAP;
+	hdr.bfSize = GlobalSize(hdib) + sizeof(BITMAPFILEHEADER);
+	hdr.bfReserved1 = 0;
+	hdr.bfReserved2 = 0;
+	hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + lpbi->biSize + 
+		 PaletteSize(lpbi);
+
+    /* Write the file header */
+	_lwrite(fh, (LPSTR) &hdr, sizeof(BITMAPFILEHEADER));
+
+    /* Write the DIB header and the bits */
+	lwrite(fh, (LPSTR) lpbi, GlobalSize(hdib));
+
+	GlobalUnlock(hdib);
+	_lclose(fh);
+	return TRUE;
+}
+
+/****************************************************************************
+ *									    *
+ *  FUNCTION   :  PaletteSize(VOID FAR * pv)				    *
+ *									    *
+ *  PURPOSE    :  Calculates the palette size in bytes. If the info. block  *
+ *		  is of the BITMAPCOREHEADER type, the number of colors is  *
+ *		  multiplied by 3 to give the palette size, otherwise the   *
+ *		  number of colors is multiplied by 4.								*
+ *									    *
+ *  RETURNS    :  Palette size in number of bytes.			    *
+ *									    *
+ ****************************************************************************/
+
+WORD PaletteSize(VOID FAR * pv)
+{
+	LPBITMAPINFOHEADER lpbi;
+	WORD	       NumColors;
+
+	lpbi = (LPBITMAPINFOHEADER) pv;
+	NumColors = DibNumColors(lpbi);
+
+	if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
+		return NumColors * sizeof(RGBTRIPLE);
+	else 
+		return NumColors * sizeof(RGBQUAD);
+}
+
+/****************************************************************************
+ *									    *
+ *  FUNCTION   : DibNumColors(VOID FAR * pv)				    *
+ *									    *
+ *  PURPOSE    : Determines the number of colors in the DIB by looking at   *
+ *		 the BitCount filed in the info block.			    *
+ *									    *
+ *  RETURNS    : The number of colors in the DIB.			    *
+ *									    *
+ ****************************************************************************/
+
+WORD DibNumColors(VOID FAR *pv)
+{
+	int 		bits;
+	BITMAPINFOHEADER	*lpbi;
+	BITMAPCOREHEADER	*lpbc;
+
+	lpbi = ((BITMAPINFOHEADER*) pv);
+	lpbc = ((BITMAPCOREHEADER*) pv);
+
+    /*	With the BITMAPINFO format headers, the size of the palette
+     *	is in biClrUsed, whereas in the BITMAPCORE - style headers, it
+     *	is dependent on the bits per pixel ( = 2 raised to the power of
+     *	bits/pixel).
+     */
+	if (lpbi->biSize != sizeof(BITMAPCOREHEADER)) {
+		if (lpbi->biClrUsed != 0)
+			return (WORD) lpbi->biClrUsed;
+		bits = lpbi->biBitCount;
+		}
+	else 
+		bits = lpbc->bcBitCount;
+
+	switch (bits) {
+  case 1:
+		return 2;
+  case 4:
+		return 16;
+  case 8:
+		return 256;
+  default:
+		/* A 24 bitcount DIB has no color table */
+		return 0;
+		}
+}
+
+/****************************************************************************
+ *									    *
+ *  FUNCTION   : DibFromBitmap()					    *
+ *									    *
+ *  PURPOSE    : Will create a global memory block in DIB format that	    *
+ *		 represents the Device-dependent bitmap (DDB) passed in.    *
+ *									    *
+ *  RETURNS    : A handle to the DIB					    *
+ *									    *
+ ****************************************************************************/
+
+#if NOTHING
+HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal)
+{
+	BITMAP               bm;
+	BITMAPINFOHEADER     bi;
+	BITMAPINFOHEADER FAR *lpbi;
+	DWORD                dwLen;
+	HANDLE               hdib;
+	HANDLE               h;
+	HDC                  hdc;
+
+	if (!hbm)
+		return NULL;
+
+	if (hpal == NULL)
+		hpal = GetStockObject(DEFAULT_PALETTE);
+
+	GetObject(hbm, sizeof (bm), (LPSTR) &bm);
+
+	if (biBits == 0)
+		biBits = bm.bmPlanes * bm.bmBitsPixel;
+
+	bi.biSize = sizeof(BITMAPINFOHEADER);
+	bi.biWidth = bm.bmWidth;
+	bi.biHeight = bm.bmHeight;
+	bi.biPlanes = 1;
+	bi.biBitCount = biBits;
+	bi.biCompression = biStyle;
+	bi.biSizeImage = 0;
+	bi.biXPelsPerMeter = 0;
+	bi.biYPelsPerMeter = 0;
+	bi.biClrUsed = 0;
+	bi.biClrImportant = 0;
+
+	dwLen = bi.biSize + PaletteSize(&bi);
+
+	hdc = GetDC(NULL);
+	hpal = SelectPalette(hdc, hpal, FALSE);
+	RealizePalette(hdc);
+
+	hdib = GlobalAlloc(GHND, dwLen);
+
+	if (!hdib) {
+		SelectPalette(hdc, hpal, FALSE);
+		ReleaseDC(NULL, hdc);
+		return NULL;
+		}
+
+#ifdef __WINDOWS_386__
+	lpbi = (BITMAPINFOHEADER FAR *) MK_FP32(GlobalLock(hdib));
+#else
+	lpbi = (BITMAPINFOHEADER FAR *) GlobalLock(hdib);
+#endif
+
+	*lpbi = bi;
+
+    /*	call GetDIBits with a NULL lpBits param, so it will calculate the
+     *  biSizeImage field for us
+     */
+	GetDIBits(hdc, hbm, 0, (WORD) bi.biHeight,
+		 NULL, (LPBITMAPINFO) lpbi, DIB_RGB_COLORS);
+
+	bi = *lpbi;
+	GlobalUnlock(hdib);
+
+    /* If the driver did not fill in the biSizeImage field, make one up */
+	if (bi.biSizeImage == 0) {
+		bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight;
+
+		if (biStyle != BI_RGB)
+			bi.biSizeImage = (bi.biSizeImage * 3) / 2;
+		}
+
+    /*	realloc the buffer big enough to hold all the bits */
+	dwLen = bi.biSize + PaletteSize(&bi) + bi.biSizeImage;
+	if (h = GlobalReAlloc(hdib, dwLen, 0))
+		hdib = h;
+	else {
+		GlobalFree(hdib);
+		hdib = NULL;
+
+		SelectPalette(hdc, hpal, FALSE);
+		ReleaseDC(NULL, hdc);
+		return hdib;
+		}
+
+    /*	call GetDIBits with a NON-NULL lpBits param, and actualy get the
+     *  bits this time
+     */
+#ifdef __WINDOWS_386__
+	lpbi = (BITMAPINFOHEADER FAR *) MK_FP32(GlobalLock(hdib));
+#else
+	lpbi = (BITMAPINFOHEADER FAR *) GlobalLock(hdib);
+#endif
+
+	if (GetDIBits(hdc,
+		 hbm,
+		 0,
+		 (WORD) bi.biHeight,
+		 (LPSTR) lpbi + (WORD) lpbi->biSize + PaletteSize(lpbi),
+		 (LPBITMAPINFO) lpbi, DIB_RGB_COLORS) == 0) {
+		GlobalUnlock(hdib);
+		hdib = NULL;
+		SelectPalette(hdc, hpal, FALSE);
+		ReleaseDC(NULL, hdc);
+		return NULL;
+		}
+
+	bi = *lpbi;
+	GlobalUnlock(hdib);
+
+	SelectPalette(hdc, hpal, FALSE);
+	ReleaseDC(NULL, hdc);
+	return hdib;
+}
+#endif
+
+ /************* PRIVATE ROUTINES TO READ/WRITE MORE THAN 64K ***************/
+/****************************************************************************
+ *									    *
+ *  FUNCTION   : lread(int fh, VOID FAR *pv, DWORD ul)			    *
+ *									    *
+ *  PURPOSE    : Reads data in steps of 32k till all the data has been read.*
+ *									    *
+ *  RETURNS    : 0 - If read did not proceed correctly. 		    *
+ *		 number of bytes read otherwise.			    *
+ *									    *
+ ****************************************************************************/
+
+DWORD PASCAL lread(int fh, void far *pv, DWORD ul)
+{
+	DWORD     ulT = ul;
+#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__)
+	BYTE *hp = (BYTE *) pv;
+#else
+	BYTE huge *hp = (BYTE huge *) pv;
+#endif
+	while (ul > (DWORD) MAXREAD) {
+		if (_lread(fh, (LPSTR) hp, (WORD) MAXREAD) != MAXREAD)
+			return 0;
+		ul -= MAXREAD;
+		hp += MAXREAD;
+		}
+	if (_lread(fh, (LPSTR) hp, (WORD) ul) != (WORD) ul)
+		return 0;
+	return ulT;
+}
+
+/****************************************************************************
+ *									    *
+ *  FUNCTION   : lwrite(int fh, VOID FAR *pv, DWORD ul) 		    *
+ *									    *
+ *  PURPOSE    : Writes data in steps of 32k till all the data is written.  *
+ *									    *
+ *  RETURNS    : 0 - If write did not proceed correctly.		    *
+ *		 number of bytes written otherwise.			    *
+ *									    *
+ ****************************************************************************/
+
+DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul)
+{
+	DWORD     ulT = ul;
+#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__)
+	BYTE *hp = (BYTE *) pv;
+#else
+	BYTE huge *hp = (BYTE huge *) pv;
+#endif
+	while (ul > MAXREAD) {
+		if (_lwrite(fh, (LPSTR) hp, (WORD) MAXREAD) != MAXREAD)
+			return 0;
+		ul -= MAXREAD;
+		hp += MAXREAD;
+		}
+	if (_lwrite(fh, (LPSTR) hp, (WORD) ul) != (WORD) ul)
+		return 0;
+	return ulT;
+}
+
+/****************************************************************************
+ *
+ *  FUNCTION   : ReadDIB(hWnd)
+ *
+ *  PURPOSE    : Reads a DIB from a file, obtains a handle to its
+ *		 BITMAPINFO struct. and loads the DIB.  Once the DIB
+ *               is loaded, the function also creates a bitmap and
+ *               palette out of the DIB for a device-dependent form.
+ *
+ *  RETURNS    : TRUE  - DIB loaded and bitmap/palette created 
+ *                       The DIBINIT structure pointed to by pInfo is
+ *                       filled with the appropriate handles.
+ *		 FALSE - otherwise
+ *
+ ****************************************************************************/
+BOOL ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
+{
+    int fh;
+    LPBITMAPINFOHEADER lpbi;
+    OFSTRUCT	       of;
+    BITMAPFILEHEADER   bf;
+    WORD		nNumColors;
+    BOOL result = FALSE;
+    char str[128];
+    WORD offBits;
+    HDC hDC;
+    BOOL bCoreHead = FALSE;
+    HANDLE hDIB = 0;
+
+    /* Open the file and get a handle to it's BITMAPINFO */
+
+    fh = OpenFile (lpFileName, &of, OF_READ);
+    if (fh == -1) {
+	wsprintf(str,"Can't open file '%ls'", (LPSTR)lpFileName);
+	MessageBox(NULL, str, "Error", MB_ICONSTOP | MB_OK);
+	return (0);
+    }
+    
+    hDIB = GlobalAlloc(GHND, (DWORD)(sizeof(BITMAPINFOHEADER) + 
+    					256 * sizeof(RGBQUAD)));
+    if (!hDIB)
+	return(0);
+
+#ifdef __WINDOWS_386__
+    lpbi = (LPBITMAPINFOHEADER)MK_FP32(GlobalLock(hDIB));
+#else
+    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
+#endif
+
+    /* read the BITMAPFILEHEADER */
+    if (sizeof (bf) != _lread (fh, (LPSTR)&bf, sizeof (bf)))
+	goto ErrExit;
+
+    if (bf.bfType != 0x4d42)	/* 'BM' */
+	goto ErrExit;
+
+    if (sizeof(BITMAPCOREHEADER) != _lread (fh, (LPSTR)lpbi, sizeof(BITMAPCOREHEADER)))
+	goto ErrExit;
+
+    if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
+    {
+	lpbi->biSize = sizeof(BITMAPINFOHEADER);
+	lpbi->biBitCount = ((LPBITMAPCOREHEADER)lpbi)->bcBitCount;
+	lpbi->biPlanes = ((LPBITMAPCOREHEADER)lpbi)->bcPlanes;
+	lpbi->biHeight = ((LPBITMAPCOREHEADER)lpbi)->bcHeight;
+	lpbi->biWidth = ((LPBITMAPCOREHEADER)lpbi)->bcWidth;
+	bCoreHead = TRUE;
+    }
+    else
+    {
+    	// get to the start of the header and read INFOHEADER
+        _llseek(fh,sizeof(BITMAPFILEHEADER),SEEK_SET);
+	if (sizeof(BITMAPINFOHEADER) != _lread (fh, (LPSTR)lpbi, sizeof(BITMAPINFOHEADER)))
+	    goto ErrExit;
+    }
+
+    if (!(nNumColors = (WORD)lpbi->biClrUsed))
+    {
+	/* no color table for 24-bit, default size otherwise */
+	if (lpbi->biBitCount != 24)
+	    nNumColors = 1 << lpbi->biBitCount;	/* standard size table */
+    }
+
+    /*	fill in some default values if they are zero */
+    if (lpbi->biClrUsed == 0)
+	lpbi->biClrUsed = nNumColors;
+
+    if (lpbi->biSizeImage == 0)
+    {
+	lpbi->biSizeImage = ((((lpbi->biWidth * (DWORD)lpbi->biBitCount) + 31) & ~31) >> 3)
+			 * lpbi->biHeight;
+    }
+
+    /* get a proper-sized buffer for header, color table and bits */ 
+    GlobalUnlock(hDIB);
+    hDIB = GlobalReAlloc(hDIB, lpbi->biSize +
+    					nNumColors * sizeof(RGBQUAD) +
+					lpbi->biSizeImage, 0);
+    if (!hDIB)	/* can't resize buffer for loading */
+	goto ErrExit2;
+
+#ifdef __WINDOWS_386__
+    lpbi = (LPBITMAPINFOHEADER)MK_FP32(GlobalLock(hDIB));
+#else
+    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
+#endif
+
+    /* read the color table */
+    if (!bCoreHead)
+	_lread(fh, (LPSTR)(lpbi) + lpbi->biSize, nNumColors * sizeof(RGBQUAD));
+    else
+    {
+	signed int i;
+	RGBQUAD FAR *pQuad;
+	RGBTRIPLE FAR *pTriple;
+
+	_lread(fh, (LPSTR)(lpbi) + lpbi->biSize, nNumColors * sizeof(RGBTRIPLE));
+
+	pQuad = (RGBQUAD FAR *)((LPSTR)lpbi + lpbi->biSize);
+	pTriple = (RGBTRIPLE FAR *) pQuad;
+	for (i = nNumColors - 1; i >= 0; i--)
+	{
+	    pQuad[i].rgbRed = pTriple[i].rgbtRed;
+	    pQuad[i].rgbBlue = pTriple[i].rgbtBlue;
+	    pQuad[i].rgbGreen = pTriple[i].rgbtGreen;
+	    pQuad[i].rgbReserved = 0;
+	}
+    }
+
+    /* offset to the bits from start of DIB header */
+    offBits = (WORD)lpbi->biSize + nNumColors * sizeof(RGBQUAD);
+
+    if (bf.bfOffBits != 0L)
+    {
+        _llseek(fh,bf.bfOffBits,SEEK_SET);
+    }
+
+    if (lpbi->biSizeImage == lread(fh, (LPSTR)lpbi + offBits, lpbi->biSizeImage))
+    {
+	GlobalUnlock(hDIB);
+
+	hDC = GetDC(NULL);
+	if (!MakeBitmapAndPalette(hDC, hDIB, palette,
+					bitmap))
+	{
+	    ReleaseDC(NULL,hDC);
+	    goto ErrExit2;
+	}
+	else
+	{
+	    ReleaseDC(NULL,hDC);
+            GlobalFree(hDIB);
+	    result = TRUE;
+	}
+    }
+    else
+    {
+ErrExit:
+	GlobalUnlock(hDIB);
+ErrExit2:
+	GlobalFree(hDIB);
+    }
+
+    _lclose(fh);
+    return(result);
+}
+
+/****************************************************************************
+ *
+ *  FUNCTION   : MakeBitmapAndPalette
+ *
+ *  PURPOSE    : Given a DIB, creates a bitmap and corresponding palette
+ *               to be used for a device-dependent representation of
+ *               of the image.
+ *
+ *  RETURNS    : TRUE  --> success. phPal and phBitmap are filled with 
+ *                         appropriate handles.  Caller is responsible
+ *                         for freeing objects.
+ *               FALSE --> unable to create objects.  both pointer are
+ *                         not valid
+ *
+ ****************************************************************************/
+BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB,
+			HPALETTE * phPal, HBITMAP * phBitmap)
+{
+    LPBITMAPINFOHEADER lpInfo;
+    BOOL result = FALSE;
+    HBITMAP hBitmap;
+    HPALETTE hPalette, hOldPal;
+    LPSTR lpBits;
+
+#ifdef __WINDOWS_386__
+    lpInfo = (LPBITMAPINFOHEADER) MK_FP32(GlobalLock(hDIB));
+#else
+    lpInfo = (LPBITMAPINFOHEADER) GlobalLock(hDIB);
+#endif
+
+    if ((hPalette = MakeDIBPalette(lpInfo)))
+    {
+	// Need to realize palette for converting DIB to bitmap.
+	hOldPal = SelectPalette(hDC, hPalette, TRUE);
+	RealizePalette(hDC);
+
+	lpBits = (LPSTR)lpInfo + (WORD)lpInfo->biSize + 
+		(WORD)lpInfo->biClrUsed * sizeof(RGBQUAD);
+	hBitmap = CreateDIBitmap(hDC, lpInfo, CBM_INIT, lpBits, 
+				(LPBITMAPINFO)lpInfo, DIB_RGB_COLORS);
+
+	SelectPalette(hDC, hOldPal, TRUE);
+	RealizePalette(hDC);
+
+	if (!hBitmap)
+	    DeleteObject(hPalette);
+	else
+	{
+	    *phBitmap = hBitmap;
+	    *phPal = hPalette;
+	    result = TRUE;
+	}
+    }
+    return(result);
+}
+
+/****************************************************************************
+ *									    *
+ *  FUNCTION   : MakeDIBPalette(lpInfo)					    *
+ *									    *
+ *  PURPOSE    : Given a BITMAPINFOHEADER, create a palette based on 
+ *		 the color table.
+ *		 
+ *									    *
+ *  RETURNS    : non-zero - handle of a corresponding palette 
+ *		 zero - unable to create palette
+ *									    *
+ ****************************************************************************/
+HPALETTE MakeDIBPalette(LPBITMAPINFOHEADER lpInfo)
+{
+    NPLOGPALETTE npPal;
+    RGBQUAD far *lpRGB;
+    HPALETTE hLogPal; 
+    WORD i;
+
+    /* since biClrUsed field was filled during the loading of the DIB,
+    ** we know it contains the number of colors in the color table.
+    */
+    if (lpInfo->biClrUsed)
+    {
+/*
+	npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) + 
+				(WORD)lpInfo->biClrUsed * sizeof(PALETTEENTRY));
+*/
+	npPal = (NPLOGPALETTE)malloc(sizeof(LOGPALETTE) + 
+				(WORD)lpInfo->biClrUsed * sizeof(PALETTEENTRY));
+
+        if (!npPal)
+	    return(FALSE);
+
+	npPal->palVersion = 0x300;
+	npPal->palNumEntries = (WORD)lpInfo->biClrUsed;
+
+	/* get pointer to the color table */
+	lpRGB = (RGBQUAD FAR *)((LPSTR)lpInfo + lpInfo->biSize);
+
+	/* copy colors from the color table to the LogPalette structure */
+	for (i = 0; i < lpInfo->biClrUsed; i++, lpRGB++)
+	{
+	    npPal->palPalEntry[i].peRed = lpRGB->rgbRed;
+	    npPal->palPalEntry[i].peGreen = lpRGB->rgbGreen;
+	    npPal->palPalEntry[i].peBlue = lpRGB->rgbBlue;
+	    npPal->palPalEntry[i].peFlags = 0;
+	}
+
+	hLogPal = CreatePalette((LPLOGPALETTE)npPal);
+//	LocalFree((HANDLE)npPal);
+        free(npPal);
+        
+	return(hLogPal);
+    }
+
+    /* 24-bit DIB with no color table.  return default palette.  Another
+    ** option would be to create a 256 color "rainbow" palette to provide
+    ** some good color choices.
+    */
+    else
+	return(GetStockObject(DEFAULT_PALETTE));
+}
+
+bool wxLoadIntoBitmap(char *filename, wxBitmap *bitmap, wxColourMap **pal)
+{
+  HBITMAP hBitmap;
+  HPALETTE hPalette;
+
+  bool success = (ReadDIB(filename, &hBitmap, &hPalette) != 0);
+
+  if (!success)
+  {
+    DeleteObject(hPalette);
+    return FALSE;
+  }
+
+  if (hPalette)
+  {
+    if (pal)
+    {
+      *pal = new wxColourMap;
+      (*pal)->SetHPALETTE((WXHPALETTE) hPalette);
+    }
+    else
+      DeleteObject(hPalette);
+  }
+  else if (pal)
+    *pal = NULL;
+
+  if (hBitmap)
+  {
+    BITMAP bm;
+    GetObject(hBitmap, sizeof(bm), (LPSTR)&bm);
+
+    bitmap->SetHBITMAP((WXHBITMAP) hBitmap);
+    bitmap->SetWidth(bm.bmWidth);
+    bitmap->SetHeight(bm.bmHeight);
+    bitmap->SetDepth(bm.bmPlanes * bm.bmBitsPixel);
+    bitmap->SetOk(TRUE);
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+wxBitmap *wxLoadBitmap(char *filename, wxColourMap **pal)
+{
+  wxBitmap *bitmap = new wxBitmap;
+  if (wxLoadIntoBitmap(filename, bitmap, pal))
+    return bitmap;
+  else
+  {
+    delete bitmap;
+    return NULL;
+  }
+}
+
+//---------------------------------------------------------------------
+//
+// Function:   InitBitmapInfoHeader
+//
+// Purpose:    Does a "standard" initialization of a BITMAPINFOHEADER,
+//             given the Width, Height, and Bits per Pixel for the
+//             DIB.
+//
+//             By standard, I mean that all the relevant fields are set
+//             to the specified values.  biSizeImage is computed, the
+//             biCompression field is set to "no compression," and all
+//             other fields are 0.
+//
+//             Note that DIBs only allow BitsPixel values of 1, 4, 8, or
+//             24.  This routine makes sure that one of these values is
+//             used (whichever is most appropriate for the specified
+//             nBPP).
+//
+// Parms:      lpBmInfoHdr == Far pointer to a BITMAPINFOHEADER structure
+//                            to be filled in.
+//             dwWidth     == Width of DIB (not in Win 3.0 & 3.1, high
+//                            word MUST be 0).
+//             dwHeight    == Height of DIB (not in Win 3.0 & 3.1, high
+//                            word MUST be 0).
+//             nBPP        == Bits per Pixel for the DIB.
+//
+// History:   Date      Reason
+//            11/07/91  Created
+//             
+//---------------------------------------------------------------------
+
+void InitBitmapInfoHeader (LPBITMAPINFOHEADER lpBmInfoHdr,
+                                        DWORD dwWidth,
+                                        DWORD dwHeight,
+                                          int nBPP)
+{
+//   _fmemset (lpBmInfoHdr, 0, sizeof (BITMAPINFOHEADER));
+   memset (lpBmInfoHdr, 0, sizeof (BITMAPINFOHEADER));
+
+   lpBmInfoHdr->biSize      = sizeof (BITMAPINFOHEADER);
+   lpBmInfoHdr->biWidth     = dwWidth;
+   lpBmInfoHdr->biHeight    = dwHeight;
+   lpBmInfoHdr->biPlanes    = 1;
+
+   if (nBPP <= 1)
+      nBPP = 1;
+   else if (nBPP <= 4)
+      nBPP = 4;
+   else if (nBPP <= 8)
+      nBPP = 8;
+/* Doesn't work
+   else if (nBPP <= 16)
+      nBPP = 16;
+*/
+   else
+      nBPP = 24;
+
+   lpBmInfoHdr->biBitCount  = nBPP;
+   lpBmInfoHdr->biSizeImage = WIDTHBYTES (dwWidth * nBPP) * dwHeight;
+}
+
+
+
+
+LPSTR FindDIBBits (LPSTR lpbi)
+{
+   return (lpbi + *(LPDWORD)lpbi + PaletteSize (lpbi));
+}
+
+//---------------------------------------------------------------------
+//
+// Function:   BitmapToDIB
+//
+// Purpose:    Given a device dependent bitmap and a palette, returns
+//             a handle to global memory with a DIB spec in it.  The
+//             DIB is rendered using the colors of the palette passed in.
+//
+//             Stolen almost verbatim from ShowDIB.
+//
+// Parms:      hBitmap == Handle to device dependent bitmap compatible
+//                        with default screen display device.
+//             hPal    == Palette to render the DDB with.  If it's NULL,
+//                        use the default palette.
+//
+// History:   Date      Reason
+//             6/01/91  Created
+//             
+//---------------------------------------------------------------------
+
+HANDLE BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal)
+{
+   BITMAP             Bitmap;
+   BITMAPINFOHEADER   bmInfoHdr;
+   LPBITMAPINFOHEADER lpbmInfoHdr;
+   LPSTR              lpBits;
+   HDC                hMemDC;
+   HANDLE             hDIB;
+   HPALETTE           hOldPal = NULL;
+
+      // Do some setup -- make sure the Bitmap passed in is valid,
+      //  get info on the bitmap (like its height, width, etc.),
+      //  then setup a BITMAPINFOHEADER.
+
+   if (!hBitmap)
+      return NULL;
+
+   if (!GetObject (hBitmap, sizeof (Bitmap), (LPSTR) &Bitmap))
+      return NULL;
+
+   InitBitmapInfoHeader (&bmInfoHdr, 
+                         Bitmap.bmWidth, 
+                         Bitmap.bmHeight, 
+                         Bitmap.bmPlanes * Bitmap.bmBitsPixel);
+
+
+      // Now allocate memory for the DIB.  Then, set the BITMAPINFOHEADER
+      //  into this memory, and find out where the bitmap bits go.
+
+   hDIB = GlobalAlloc (GHND, sizeof (BITMAPINFOHEADER) + 
+             PaletteSize ((LPSTR) &bmInfoHdr) + bmInfoHdr.biSizeImage);
+
+   if (!hDIB)
+      return NULL;
+
+#ifdef __WINDOWS_386__
+   lpbmInfoHdr  = (LPBITMAPINFOHEADER) MK_FP32(GlobalLock (hDIB));
+#else
+   lpbmInfoHdr  = (LPBITMAPINFOHEADER) GlobalLock (hDIB);
+#endif
+
+   *lpbmInfoHdr = bmInfoHdr;
+   lpBits       = FindDIBBits ((LPSTR) lpbmInfoHdr);
+
+
+      // Now, we need a DC to hold our bitmap.  If the app passed us
+      //  a palette, it should be selected into the DC.
+
+   hMemDC       = GetDC (NULL);
+
+   if (hPal)
+      {
+      hOldPal = SelectPalette (hMemDC, hPal, FALSE);
+      RealizePalette (hMemDC);
+      }
+
+
+
+      // We're finally ready to get the DIB.  Call the driver and let
+      //  it party on our bitmap.  It will fill in the color table,
+      //  and bitmap bits of our global memory block.
+
+   if (!GetDIBits (hMemDC, 
+                   hBitmap, 
+                   0, 
+                   Bitmap.bmHeight, 
+                   lpBits, 
+                   (LPBITMAPINFO) lpbmInfoHdr, 
+                   DIB_RGB_COLORS))
+      {
+      GlobalUnlock (hDIB);
+      GlobalFree (hDIB);
+      hDIB = NULL;
+      }
+   else
+      GlobalUnlock (hDIB);
+
+
+      // Finally, clean up and return.
+
+   if (hOldPal)
+      SelectPalette (hMemDC, hOldPal, FALSE);
+
+   ReleaseDC (NULL, hMemDC);
+
+   return hDIB;
+}
+
+bool wxSaveBitmap(char *filename, wxBitmap *bitmap, wxColourMap *colourmap)
+{
+  HPALETTE hPalette = 0;
+  if (colourmap)
+    hPalette = (HPALETTE) colourmap->GetHPALETTE();
+
+  HANDLE dibHandle = BitmapToDIB((HBITMAP) bitmap->GetHBITMAP(), hPalette);
+  if (dibHandle)
+  {
+    bool success = (WriteDIB(filename, dibHandle) != 0);
+    GlobalFree(dibHandle);
+    return success;
+  }
+  else return FALSE;
+}
+
+
diff --git a/src/msw/dibutils.cpp b/src/msw/dibutils.cpp
new file mode 100644
index 0000000000..30dca59100
--- /dev/null
+++ b/src/msw/dibutils.cpp
@@ -0,0 +1,691 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dibutils.cpp
+// Purpose:     Utilities for DIBs
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Microsoft, Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "dibutils.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/defs.h"
+#endif
+
+#include <windows.h>
+#include <windowsx.h>
+#include <stdio.h>
+#include <wx/msw/dibutils.h>
+
+#if defined(__WIN32__)
+    #include <memory.h>             // for _fmemcpy()
+	 #define _huge
+#ifndef hmemcpy
+    #define hmemcpy memcpy
+#endif
+#endif
+
+#define BFT_ICON   0x4349   /* 'IC' */
+#define BFT_BITMAP 0x4d42   /* 'BM' */
+#define BFT_CURSOR 0x5450   /* 'PT' */
+
+/* flags for _lseek */
+#define  SEEK_CUR 1
+#define  SEEK_END 2
+#define  SEEK_SET 0
+
+
+/*
+ *  Clear the System Palette so that we can ensure an identity palette 
+ *  mapping for fast performance.
+ */
+
+void ClearSystemPalette(void)
+{
+  //*** A dummy palette setup
+  struct
+  {
+    WORD Version;
+    WORD NumberOfEntries;
+    PALETTEENTRY aEntries[256];
+  } Palette =
+  {
+    0x300,
+    256
+  };
+
+  HPALETTE ScreenPalette = 0;
+  HDC ScreenDC;
+  int Counter;
+  UINT nMapped = 0;
+  BOOL bOK = FALSE;
+  int  nOK = 0;
+  
+  //*** Reset everything in the system palette to black
+  for(Counter = 0; Counter < 256; Counter++)
+  {
+    Palette.aEntries[Counter].peRed = 0;
+	 Palette.aEntries[Counter].peGreen = 0;
+    Palette.aEntries[Counter].peBlue = 0;
+    Palette.aEntries[Counter].peFlags = PC_NOCOLLAPSE;
+  }
+
+  //*** Create, select, realize, deselect, and delete the palette
+  ScreenDC = GetDC(NULL);
+  ScreenPalette = CreatePalette((LOGPALETTE *)&Palette);
+
+  if (ScreenPalette)
+  {
+	 ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE);
+	 nMapped = RealizePalette(ScreenDC);
+    ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE);
+    bOK = DeleteObject(ScreenPalette);
+  }
+
+  nOK = ReleaseDC(NULL, ScreenDC);
+
+  return;
+}
+
+
+/*
+ *   Open a DIB file and return a MEMORY DIB, a memory handle containing..
+ *
+ *   BITMAP INFO    bi
+ *   palette data
+ *   bits....
+ */
+
+int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi)
+{
+	 HFILE               fh;
+	 OFSTRUCT            of;
+
+	 fh = OpenFile(szFile, &of, OF_WRITE | OF_CREATE);
+
+  if (!fh) {
+//	 printf("la regamos0");
+	 return 0;
+  }
+
+  long size = DibSize(lpbi);
+
+  // write file header
+  BITMAPFILEHEADER bmf;
+  bmf.bfType = 'BM';
+  bmf.bfSize = sizeof(bmf) + size;
+  bmf.bfReserved1 = 0;
+  bmf.bfReserved2 = 0;
+  bmf.bfOffBits = sizeof(bmf) + (char far*)(DibPtr(lpbi)) - (char far*)lpbi;
+#if defined( __WATCOMC__) || defined(_MSC_VER)
+  if (_hwrite(fh, (LPCSTR)(&bmf), sizeof(bmf))<0 ||
+	_hwrite(fh, (LPCSTR)lpbi, size)<0) {
+	  _lclose(fh);
+//	 printf("la regamos1");
+	  return 0;
+  }
+#else
+  if (_hwrite(fh, (LPBYTE)(&bmf), sizeof(bmf))<0 ||
+	_hwrite(fh, (LPBYTE)lpbi, size)<0) {
+	  _lclose(fh);
+//	 printf("la regamos1");
+	  return 0;
+  }
+#endif
+
+  _lclose(fh);
+  return 1;
+}
+
+PDIB DibOpenFile(LPSTR szFile)
+{
+	 HFILE               fh;
+	 DWORD               dwLen;
+	 DWORD               dwBits;
+	 PDIB                pdib;
+	 LPVOID              p;
+	 OFSTRUCT            of;
+
+#if defined(WIN32) || defined(_WIN32)
+	 #define GetCurrentInstance()    GetModuleHandle(NULL)
+#else
+	 #define GetCurrentInstance()    (HINSTANCE)SELECTOROF((LPVOID)&of)
+#endif
+
+	 fh = OpenFile(szFile, &of, OF_READ);
+
+	 if (fh == -1)
+	 {
+		  HRSRC h;
+
+          // TODO: Unicode version
+		  h = FindResourceA(GetCurrentInstance(), szFile, RT_BITMAP);
+
+#if defined(WIN32) || defined(_WIN32)
+		  //!!! can we call GlobalFree() on this? is it the right format.
+		  //!!! can we write to this resource?
+		  if (h)
+				return (PDIB)LockResource(LoadResource(GetCurrentInstance(), h));
+#else
+		  if (h)
+				fh = AccessResource(GetCurrentInstance(), h);
+#endif
+	 }
+
+	 if (fh == -1)
+		  return NULL;
+
+	 pdib = DibReadBitmapInfo(fh);
+
+	 if (!pdib)
+		  return NULL;
+
+    /* How much memory do we need to hold the DIB */
+
+    dwBits = pdib->biSizeImage;
+    dwLen  = pdib->biSize + DibPaletteSize(pdib) + dwBits;
+
+    /* Can we get more memory? */
+
+	 p = GlobalReAllocPtr(pdib,dwLen,0);
+
+    if (!p)
+    {
+		  GlobalFreePtr(pdib);
+        pdib = NULL;
+    }
+    else
+    {
+        pdib = (PDIB)p;
+    }
+
+    if (pdib)
+    {
+		  /* read in the bits */
+		  _hread(fh, (LPBYTE)pdib + (UINT)pdib->biSize + DibPaletteSize(pdib), dwBits);
+    }
+
+    _lclose(fh);
+
+    return pdib;
+}
+
+
+/*
+ *  ReadDibBitmapInfo()
+ *
+ *  Will read a file in DIB format and return a global HANDLE to its
+ *  BITMAPINFO.  This function will work with both "old" and "new"
+ *  bitmap formats, but will always return a "new" BITMAPINFO.
+ */
+
+PDIB DibReadBitmapInfo(HFILE fh)
+{
+    DWORD     off;
+    HANDLE    hbi = NULL;
+    int       size;
+    int       i;
+    int       nNumColors;
+
+    RGBQUAD FAR       *pRgb;
+    BITMAPINFOHEADER   bi;
+    BITMAPCOREHEADER   bc;
+    BITMAPFILEHEADER   bf;
+    PDIB               pdib;
+
+    if (fh == -1)
+        return NULL;
+
+    off = _llseek(fh,0L,SEEK_CUR);
+
+    if (sizeof(bf) != _lread(fh,(LPSTR)&bf,sizeof(bf)))
+        return FALSE;
+
+    /*
+     *  do we have a RC HEADER?
+     */
+    if (bf.bfType != BFT_BITMAP)
+    {
+        bf.bfOffBits = 0L;
+        _llseek(fh,off,SEEK_SET);
+    }
+
+    if (sizeof(bi) != _lread(fh,(LPSTR)&bi,sizeof(bi)))
+        return FALSE;
+
+    /*
+     *  what type of bitmap info is this?
+     */
+    switch (size = (int)bi.biSize)
+    {
+        default:
+        case sizeof(BITMAPINFOHEADER):
+            break;
+
+        case sizeof(BITMAPCOREHEADER):
+            bc = *(BITMAPCOREHEADER*)&bi;
+            bi.biSize               = sizeof(BITMAPINFOHEADER);
+            bi.biWidth              = (DWORD)bc.bcWidth;
+            bi.biHeight             = (DWORD)bc.bcHeight;
+            bi.biPlanes             =  (UINT)bc.bcPlanes;
+            bi.biBitCount           =  (UINT)bc.bcBitCount;
+            bi.biCompression        = BI_RGB;
+            bi.biSizeImage          = 0;
+            bi.biXPelsPerMeter      = 0;
+            bi.biYPelsPerMeter      = 0;
+            bi.biClrUsed            = 0;
+            bi.biClrImportant       = 0;
+
+            _llseek(fh,(LONG)sizeof(BITMAPCOREHEADER)-sizeof(BITMAPINFOHEADER),SEEK_CUR);
+
+            break;
+    }
+
+    nNumColors = DibNumColors(&bi);
+
+#if 0
+    if (bi.biSizeImage == 0)
+        bi.biSizeImage = DibSizeImage(&bi);
+
+    if (bi.biClrUsed == 0)
+        bi.biClrUsed = DibNumColors(&bi);
+#else
+    FixBitmapInfo(&bi);
+#endif
+
+    pdib = (PDIB)GlobalAllocPtr(GMEM_MOVEABLE,(LONG)bi.biSize + nNumColors * sizeof(RGBQUAD));
+
+    if (!pdib)
+        return NULL;
+
+    *pdib = bi;
+
+    pRgb = DibColors(pdib);
+
+    if (nNumColors)
+    {
+        if (size == sizeof(BITMAPCOREHEADER))
+        {
+            /*
+             * convert a old color table (3 byte entries) to a new
+             * color table (4 byte entries)
+             */
+            _lread(fh,(LPVOID)pRgb,nNumColors * sizeof(RGBTRIPLE));
+
+            for (i=nNumColors-1; i>=0; i--)
+            {
+                RGBQUAD rgb;
+
+                rgb.rgbRed      = ((RGBTRIPLE FAR *)pRgb)[i].rgbtRed;
+                rgb.rgbBlue     = ((RGBTRIPLE FAR *)pRgb)[i].rgbtBlue;
+                rgb.rgbGreen    = ((RGBTRIPLE FAR *)pRgb)[i].rgbtGreen;
+                rgb.rgbReserved = (BYTE)0;
+
+                pRgb[i] = rgb;
+            }
+        }
+        else
+        {
+            _lread(fh,(LPVOID)pRgb,nNumColors * sizeof(RGBQUAD));
+        }
+    }
+
+    if (bf.bfOffBits != 0L)
+        _llseek(fh,off + bf.bfOffBits,SEEK_SET);
+
+    return pdib;
+}
+
+/*
+ *  DibSetUsage(hdib,hpal,wUsage)
+ *
+ *  Modifies the color table of the passed DIB for use with the wUsage
+ *  parameter specifed.
+ *
+ *  if wUsage is DIB_PAL_COLORS the DIB color table is set to 0-256
+ *  if wUsage is DIB_RGB_COLORS the DIB color table is set to the RGB values
+ *      in the passed palette
+ */
+
+BOOL DibSetUsage(PDIB pdib, HPALETTE hpal,UINT wUsage)
+{
+    PALETTEENTRY       ape[256];
+    RGBQUAD FAR *      pRgb;
+    WORD FAR *         pw;
+    int                nColors;
+    int                n;
+
+    if (hpal == NULL)
+        hpal = (HPALETTE)GetStockObject(DEFAULT_PALETTE);
+
+    if (!pdib)
+        return FALSE;
+
+    nColors = DibNumColors(pdib);
+    
+    if (nColors == 3 && DibCompression(pdib) == BI_BITFIELDS)
+        nColors = 0;
+
+    if (nColors > 0)
+    {
+        pRgb = DibColors(pdib);
+
+        switch (wUsage)
+        {
+            //
+            // Set the DIB color table to palette indexes
+            //
+            case DIB_PAL_COLORS:
+                for (pw = (WORD FAR*)pRgb,n=0; n<nColors; n++,pw++)
+                    *pw = n;
+                break;
+
+            //
+            // Set the DIB color table to RGBQUADS
+            //
+            default:
+            case DIB_RGB_COLORS:
+                nColors =  (nColors < 256) ? nColors: 256;
+
+                GetPaletteEntries(hpal,0,nColors,ape);
+
+                for (n=0; n<nColors; n++)
+                {
+                    pRgb[n].rgbRed      = ape[n].peRed;
+                    pRgb[n].rgbGreen    = ape[n].peGreen;
+                    pRgb[n].rgbBlue     = ape[n].peBlue;
+                    pRgb[n].rgbReserved = 0;
+                }
+                break;
+        }
+    }
+    return TRUE;
+}
+
+/*
+ *  DibCreate(bits, dx, dy)
+ *
+ *  Creates a new packed DIB with the given dimensions and the
+ *  given number of bits per pixel
+ */
+
+PDIB DibCreate(int bits, int dx, int dy)
+{
+    LPBITMAPINFOHEADER lpbi ;
+    DWORD       dwSizeImage;
+    int         i;
+    DWORD FAR  *pdw;
+
+    dwSizeImage = dy*(DWORD)((dx*bits/8+3)&~3);
+
+    lpbi = (PDIB)GlobalAllocPtr(GHND,sizeof(BITMAPINFOHEADER)+dwSizeImage + 1024);
+
+    if (lpbi == NULL)
+        return NULL;
+
+    lpbi->biSize            = sizeof(BITMAPINFOHEADER) ;
+    lpbi->biWidth           = dx;
+    lpbi->biHeight          = dy;
+    lpbi->biPlanes          = 1;
+    lpbi->biBitCount        = bits ;
+    lpbi->biCompression     = BI_RGB ;
+    lpbi->biSizeImage       = dwSizeImage;
+    lpbi->biXPelsPerMeter   = 0 ;
+    lpbi->biYPelsPerMeter   = 0 ;
+    lpbi->biClrUsed         = 0 ;
+    lpbi->biClrImportant    = 0 ;
+
+    if (bits == 4)
+        lpbi->biClrUsed = 16;
+
+    else if (bits == 8)
+        lpbi->biClrUsed = 256;
+
+    pdw = (DWORD FAR *)((LPBYTE)lpbi+(int)lpbi->biSize);
+
+    for (i=0; i<(int)lpbi->biClrUsed/16; i++)
+    {
+        *pdw++ = 0x00000000;    // 0000  black
+        *pdw++ = 0x00800000;    // 0001  dark red
+        *pdw++ = 0x00008000;    // 0010  dark green
+		  *pdw++ = 0x00808000;    // 0011  mustard
+        *pdw++ = 0x00000080;    // 0100  dark blue
+        *pdw++ = 0x00800080;    // 0101  purple
+        *pdw++ = 0x00008080;    // 0110  dark turquoise
+        *pdw++ = 0x00C0C0C0;    // 1000  gray
+        *pdw++ = 0x00808080;    // 0111  dark gray
+        *pdw++ = 0x00FF0000;    // 1001  red
+        *pdw++ = 0x0000FF00;    // 1010  green
+		  *pdw++ = 0x00FFFF00;    // 1011  yellow
+        *pdw++ = 0x000000FF;    // 1100  blue
+        *pdw++ = 0x00FF00FF;    // 1101  pink (magenta)
+        *pdw++ = 0x0000FFFF;    // 1110  cyan
+        *pdw++ = 0x00FFFFFF;    // 1111  white
+    }
+
+    return (PDIB)lpbi;
+}
+
+static void xlatClut8(BYTE FAR *pb, DWORD dwSize, BYTE FAR *xlat)
+{
+    DWORD dw;
+
+#ifdef __cplusplus
+    for (dw = 0; dw < dwSize; dw++, ((BYTE _huge *&)pb)++)
+#else
+    for (dw = 0; dw < dwSize; dw++, ((BYTE _huge *)pb)++)
+#endif
+        *pb = xlat[*pb];
+}
+
+static void xlatClut4(BYTE FAR *pb, DWORD dwSize, BYTE FAR *xlat)
+{
+    DWORD dw;
+
+#ifdef __cplusplus
+    for (dw = 0; dw < dwSize; dw++, ((BYTE _huge *&)pb)++)
+#else
+    for (dw = 0; dw < dwSize; dw++, ((BYTE _huge *)pb)++)
+#endif
+        *pb = (BYTE)(xlat[*pb & 0x0F] | (xlat[(*pb >> 4) & 0x0F] << 4));
+}
+
+#define RLE_ESCAPE  0
+#define RLE_EOL     0
+#define RLE_EOF     1
+#define RLE_JMP     2
+
+static void xlatRle8(BYTE FAR *pb, DWORD dwSize, BYTE FAR *xlat)
+{
+    BYTE    cnt;
+    BYTE    b;
+    BYTE _huge *prle = pb;
+
+    for(;;)
+    {
+        cnt = *prle++;
+        b   = *prle;
+
+        if (cnt == RLE_ESCAPE)
+        {
+            prle++;
+
+            switch (b)
+            {
+                case RLE_EOF:
+                    return;
+
+                case RLE_EOL:
+                    break;
+
+                case RLE_JMP:
+                    prle++;     // skip dX
+                    prle++;     // skip dY
+                    break;
+
+                default:
+                    cnt = b;
+                    for (b=0; b<cnt; b++,prle++)
+                        *prle = xlat[*prle];
+
+                    if (cnt & 1)
+                        prle++;
+
+                    break;
+            }
+        }
+        else
+        {
+            *prle++ = xlat[b];
+        }
+    }
+}
+
+static void xlatRle4(BYTE FAR *pb, DWORD dwSize, BYTE FAR *xlat)
+{
+}
+
+static void hmemmove(BYTE _huge *d, BYTE _huge *s, LONG len)
+{
+    d += len-1;
+    s += len-1;
+
+    while (len--)
+        *d-- = *s--;
+}
+
+/*
+ *  DibMapToPalette(pdib, hpal)
+ *
+ *  Map the colors of the DIB, using GetNearestPaletteIndex, to
+ *  the colors of the given palette.
+ */
+
+BOOL DibMapToPalette(PDIB pdib, HPALETTE hpal)
+{
+	 LPBITMAPINFOHEADER  lpbi;
+	 PALETTEENTRY        pe;
+	 int                 n;
+	 int                 nDibColors;
+	 int                 nPalColors=0;
+	 BYTE FAR *          lpBits;
+	 RGBQUAD FAR *       lpRgb;
+	 BYTE                xlat[256];
+	 DWORD               SizeImage;
+
+	 if (!hpal || !pdib)
+		  return FALSE;
+
+	 lpbi   = (LPBITMAPINFOHEADER)pdib;
+	 lpRgb  = DibColors(pdib);
+
+	 GetObject(hpal,sizeof(int),(LPSTR)&nPalColors);
+	 nDibColors = DibNumColors(pdib);
+
+	 if ((SizeImage = lpbi->biSizeImage) == 0)
+		  SizeImage = DibSizeImage(lpbi);
+
+	 //
+	 //  build a xlat table. from the current DIB colors to the given
+	 //  palette.
+	 //
+	 for (n=0; n<nDibColors; n++)
+		  xlat[n] = (BYTE)GetNearestPaletteIndex(hpal,RGB(lpRgb[n].rgbRed,lpRgb[n].rgbGreen,lpRgb[n].rgbBlue));
+
+	 lpBits = (LPBYTE)DibPtr(lpbi);
+	 lpbi->biClrUsed = nPalColors;
+
+	 //
+	 // re-size the DIB
+	 //
+	 if (nPalColors > nDibColors)
+	 {
+		  GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0);
+		  hmemmove((BYTE _huge *)DibPtr(lpbi), (BYTE _huge *)lpBits, SizeImage);
+		  lpBits = (LPBYTE)DibPtr(lpbi);
+	 }
+	 else if (nPalColors < nDibColors)
+	 {
+		  hmemcpy(DibPtr(lpbi), lpBits, SizeImage);
+		  GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0);
+		  lpBits = (LPBYTE)DibPtr(lpbi);
+	 }
+
+	 //
+	 // translate the DIB bits
+	 //
+	 switch (lpbi->biCompression)
+	 {
+		  case BI_RLE8:
+				xlatRle8(lpBits, SizeImage, xlat);
+				break;
+
+		  case BI_RLE4:
+				xlatRle4(lpBits, SizeImage, xlat);
+				break;
+
+        case BI_RGB:
+				if (lpbi->biBitCount == 8)
+                xlatClut8(lpBits, SizeImage, xlat);
+            else
+                xlatClut4(lpBits, SizeImage, xlat);
+            break;
+    }
+
+    //
+    //  Now copy the RGBs in the logical palette to the dib color table
+    //
+    for (n=0; n<nPalColors; n++)
+    {
+        GetPaletteEntries(hpal,n,1,&pe);
+
+        lpRgb[n].rgbRed      = pe.peRed;
+		  lpRgb[n].rgbGreen    = pe.peGreen;
+		  lpRgb[n].rgbBlue     = pe.peBlue;
+		  lpRgb[n].rgbReserved = (BYTE)0;
+	 }
+
+	 return TRUE;
+}
+
+
+HPALETTE MakePalette(const BITMAPINFO FAR* Info, UINT flags)
+{
+  HPALETTE hPalette;
+  const RGBQUAD far* rgb = Info->bmiColors;
+
+  WORD nColors = Info->bmiHeader.biClrUsed;
+  if (nColors) {
+	 LOGPALETTE* logPal = (LOGPALETTE*)
+		 new BYTE[sizeof(LOGPALETTE) + (nColors-1)*sizeof(PALETTEENTRY)];
+
+	 logPal->palVersion  = 0x300; // Windows 3.0 version
+	 logPal->palNumEntries = nColors;
+	 for (short n = 0; n < nColors; n++) {
+		logPal->palPalEntry[n].peRed   = rgb[n].rgbRed;
+		logPal->palPalEntry[n].peGreen = rgb[n].rgbGreen;
+		logPal->palPalEntry[n].peBlue  = rgb[n].rgbBlue;
+		logPal->palPalEntry[n].peFlags = (BYTE)flags;
+	 }
+	 hPalette = ::CreatePalette(logPal);
+	 delete logPal;
+  } else
+	 hPalette = 0;
+
+  return hPalette;
+}
+
diff --git a/src/msw/dirdlg.cpp b/src/msw/dirdlg.cpp
new file mode 100644
index 0000000000..ecfac092c5
--- /dev/null
+++ b/src/msw/dirdlg.cpp
@@ -0,0 +1,131 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        dirdlg.cpp
+// Purpose:     wxDirDialog
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "dirdlg.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/defs.h"
+#include "wx/utils.h"
+#include "wx/dialog.h"
+#include "wx/dirdlg.h"
+#endif
+
+#if defined(__WIN95__) && !defined(__GNUWIN32__)
+#include "shlobj.h" // Win95 shell
+#endif
+
+#include "wx/msw/private.h"
+#include "wx/cmndata.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define wxDIALOG_DEFAULT_X 300
+#define wxDIALOG_DEFAULT_Y 300
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_CLASS(wxDirDialog, wxDialog)
+#endif
+
+wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
+//		const wxString& caption,
+        const wxString& defaultPath,
+        long style, const wxPoint& pos)
+{
+    m_message = message;
+//    m_caption = caption;
+    m_dialogStyle = style;
+    m_parent = parent;
+	m_path = defaultPath;
+}
+
+int wxDirDialog::ShowModal(void)
+{
+    // Unfortunately Gnu-Win32 doesn't yet have COM support
+#if defined(__WIN95__) && !defined(__GNUWIN32__)
+  HWND hWnd = 0;
+  if (m_parent) hWnd = (HWND) m_parent->GetHWND();
+
+    BROWSEINFO bi;
+    LPSTR lpBuffer; 
+//    LPITEMIDLIST pidlPrograms;  // PIDL for Programs folder 
+    LPITEMIDLIST pidlBrowse;    // PIDL selected by user 
+    LPMALLOC pMalloc = NULL;
+
+    HRESULT result = ::SHGetMalloc(&pMalloc);
+
+    if (result != NOERROR)
+      return wxID_CANCEL;
+    
+    // Allocate a buffer to receive browse information. 
+    if ((lpBuffer = (LPSTR) pMalloc->Alloc(MAX_PATH)) == NULL) 
+    {
+        pMalloc->Release();
+        return wxID_CANCEL;
+    }
+
+/*
+    // Get the PIDL for the Programs folder. 
+    if (!SUCCEEDED(SHGetSpecialFolderLocation( 
+            parent->GetSafeHwnd(), CSIDL_PROGRAMS, &pidlPrograms))) { 
+        pMalloc->Free(lpBuffer);
+        pMalloc->Release();
+        return wxID_CANCEL;
+    } 
+*/
+ 
+    // Fill in the BROWSEINFO structure. 
+    bi.hwndOwner = hWnd;
+    bi.pidlRoot = NULL; // pidlPrograms; 
+    bi.pszDisplayName = lpBuffer; 
+    bi.lpszTitle = (LPCTSTR) (const char *) m_message;
+    bi.ulFlags = 0; 
+    bi.lpfn = NULL; 
+    bi.lParam = 0; 
+ 
+    // Browse for a folder and return its PIDL. 
+    pidlBrowse = SHBrowseForFolder(&bi); 
+
+    int id = wxID_OK;
+    if (pidlBrowse != NULL) {
+ 
+        // Show the display name, title, and file system path. 
+        if (SHGetPathFromIDList(pidlBrowse, lpBuffer))
+          m_path = lpBuffer;
+          
+        // Free the PIDL returned by SHBrowseForFolder. 
+        pMalloc->Free(pidlBrowse);
+    }
+	else
+		id = wxID_CANCEL;
+ 
+    // Clean up. 
+//    pMalloc->Free(pidlPrograms); 
+    pMalloc->Free(lpBuffer); 
+    pMalloc->Release();
+    
+    return id;
+#else
+	return wxID_CANCEL;
+#endif
+}
+
diff --git a/src/msw/dummy.cpp b/src/msw/dummy.cpp
new file mode 100644
index 0000000000..67004e57c8
--- /dev/null
+++ b/src/msw/dummy.cpp
@@ -0,0 +1,65 @@
+/*
+ * File:	dummy.cc
+ * Purpose:	See below
+ * Author:	Julian Smart
+ * Created:	1993
+ * Updated:	
+ * Copyright:   (c) 1993, AIAI, University of Edinburgh
+ */
+
+/* static const char sccsid[] = "@(#)dummy.cc	1.2 5/9/94"; */
+
+/* A dummy file to include wx.h. If precompiling wx.h, I
+ * always start by compiling this and producing the PCH file.
+ * Then subsequent source files use the PCH file.
+ *
+ * If precompiling wx.h for wxWindows and derived apps,
+ * link dummy.obj with your program (the MSC 7 linker complains otherwise).
+ *
+ * This is the only convenient way I found to use precompiled headers
+ * under MSC 7.
+ *
+ * This will produce a big PCH file.
+ */
+
+
+
+#if defined(__BORLANDC__)
+#if !(defined(__WIN32__) || defined(__NT__) || defined(__WIN32__))
+#pragma hdrfile "c:\wx\src\msw\wx.pch"
+#endif
+
+#pragma hdrstart
+#endif
+
+#include "wx/wxprec.h"
+#include "windows.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+// Foils optimizations in Visual C++ (see also wx_main.cc)
+char wxDummyChar=0;
+
+#if defined(WXUSINGDLL)
+
+// NT defines APIENTRY, 3.x not
+#if !defined(APIENTRY)
+#define APIENTRY FAR PASCAL
+#endif
+ 
+#ifdef __WATCOMC__
+int PASCAL
+#else
+int APIENTRY
+#endif
+
+ WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR m_lpCmdLine,
+                    int nCmdShow )
+{
+  return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance, m_lpCmdLine, nCmdShow);
+}
+#endif
+
+
diff --git a/src/msw/dummydll.cpp b/src/msw/dummydll.cpp
new file mode 100644
index 0000000000..16f1b40d8c
--- /dev/null
+++ b/src/msw/dummydll.cpp
@@ -0,0 +1,21 @@
+/*
+ * File:	dummydll.cc
+ * Purpose:	
+ * Author:	Julian Smart
+ * Created:	1993
+ * Updated:	
+ * Copyright:   (c) 1993, AIAI, University of Edinburgh
+ */
+
+/* static const char sccsid[] = "@(#)dummydll.cc	1.2 5/9/94"; */
+
+/*
+ * A dummy file to include wx.h. If precompiling wx.h, I
+ * always start by compiling this and producing the PCH file.
+ * Then subsequent source files use the PCH file.
+ */
+
+#include "wx/wxprec.h"
+
+// Foils optimizations in Visual C++ (see also wx_main.cc)
+char wxDummyChar=0;
diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp
new file mode 100644
index 0000000000..43cf9e9137
--- /dev/null
+++ b/src/msw/filedlg.cpp
@@ -0,0 +1,356 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        filedlg.cpp
+// Purpose:     wxFileDialog
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "filedlg.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/defs.h"
+#include "wx/utils.h"
+#include "wx/dialog.h"
+#include "wx/filedlg.h"
+#endif
+
+#include <windows.h>
+
+#ifndef __WIN32__
+#include <commdlg.h>
+#endif
+
+#include "wx/msw/private.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define wxDIALOG_DEFAULT_X 300
+#define wxDIALOG_DEFAULT_Y 300
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_CLASS(wxFileDialog, wxDialog)
+#endif
+
+char *wxFileSelector(const char *title,
+                     const char *defaultDir, const char *defaultFileName,
+                     const char *defaultExtension, const char *filter, int flags,
+                     wxWindow *parent, int x, int y)
+{
+	// In the original implementation, defaultExtension is passed to the lpstrDefExt member
+	// of OPENFILENAME. This extension, if non-NULL, is appended to the filename if the user
+	// fails to type an extension.
+	// The new implementation (taken from wxFileSelectorEx) appends the extension automatically,
+	// by looking at the filter specification. In fact this should be better than the
+	// native Microsoft implementation because Windows only allows *one* default extension,
+	// whereas here we do the right thing depending on the filter the user has chosen.
+
+	// If there's a default extension specified but no filter, we create a suitable
+	// filter.
+
+	wxString filter2("");
+	if ( defaultExtension && !filter )
+		filter2 = wxString("*.") + wxString(defaultExtension) ;
+	else if ( filter )
+		filter2 = filter;
+
+	wxString defaultDirString;
+	if (defaultDir)
+		defaultDirString = defaultDir;
+	else
+		defaultDirString = "";
+
+	wxString defaultFilenameString;
+	if (defaultFileName)
+		defaultFilenameString = defaultFileName;
+	else
+		defaultFilenameString = "";
+
+	wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
+
+	if ( fileDialog.ShowModal() == wxID_OK )
+	{
+		strcpy(wxBuffer, (const char *)fileDialog.GetPath());
+		return wxBuffer;
+	}
+	else
+		return NULL;
+}
+
+# if __BORLANDC__
+#   include <dir.h>  // for MAXPATH etc. ( Borland 3.1 ) 
+# endif
+
+# ifndef MAXPATH
+# define MAXPATH   400   
+# endif
+
+# ifndef MAXDRIVE
+# define MAXDRIVE  3
+# endif
+
+# ifndef MAXFILE 
+# define MAXFILE   9
+# endif
+
+# ifndef MAXEXT
+# define MAXEXT    5
+# endif
+
+
+char *wxFileSelectorEx( const char *title,
+			const char *defaultDir,
+			const char *defaultFileName,
+			int* defaultFilterIndex,
+			const char *filter,
+            const int       flags,
+            wxWindow* parent,
+            const int       x,
+            const int       y)
+
+{
+	wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "",
+        defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y));
+
+	if ( fileDialog.ShowModal() == wxID_OK )
+	{
+		*defaultFilterIndex = fileDialog.GetFilterIndex();
+		strcpy(wxBuffer, (const char *)fileDialog.GetPath());
+		return wxBuffer;
+	}
+	else
+		return NULL;
+}
+
+wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
+        const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
+        long style, const wxPoint& pos)
+{
+    m_message = message;
+    m_dialogStyle = style;
+    m_parent = parent;
+	m_path = "";
+	m_fileName = defaultFileName;
+	m_dir = defaultDir;
+	m_wildCard = wildCard;
+	m_filterIndex = 1;
+}
+
+int wxFileDialog::ShowModal(void)
+{
+  HWND hWnd = 0;
+  if (m_parent) hWnd = (HWND) m_parent->GetHWND();
+
+	static char  fileNameBuffer [ MAXPATH ];		   // the file-name
+	char         titleBuffer    [ MAXFILE+1+MAXEXT ];  // the file-name, without path
+
+	*fileNameBuffer = '\0';
+    *titleBuffer    = '\0';
+
+	char* filterBuffer = NULL;
+	char* extension    = NULL;
+	char* theFilter    = (char *)(const char *)m_wildCard;
+
+    long msw_flags = 0;
+    if ( (m_dialogStyle & wxHIDE_READONLY) || (m_dialogStyle & wxSAVE) ) { msw_flags |= OFN_HIDEREADONLY; }
+
+
+	OPENFILENAME of;
+	memset(&of, 0, sizeof(OPENFILENAME));
+
+    of.lpstrCustomFilter = NULL;   // system should not save custom filter
+	of.nMaxCustFilter    = 0L;
+
+	of.nFileOffset       = 0;      // 0-based pointer to filname in lpstFile
+	of.nFileExtension    = 0;      // 0-based pointer to extension in lpstrFile
+	of.lpstrDefExt       = NULL;   // no default extension
+
+	of.lStructSize 		 = sizeof(OPENFILENAME);
+	of.hwndOwner 		 = hWnd;
+	of.lpstrTitle        = (char *)(const char *)m_message;
+
+
+	of.lpstrFileTitle    = titleBuffer;
+	of.nMaxFileTitle     = MAXFILE + 1 + MAXEXT;	// Windows 3.0 and 3.1
+
+	of.lpstrInitialDir   = (const char *) m_dir;
+
+	of.Flags 			 = msw_flags;
+
+
+
+    //=== Like Alejandro Sierra's wildcard modification >>===================
+    /*
+        In wxFileSelector you can put, instead of a single wild_card,
+        pairs of strings separated by '|'.
+        The first string is a description, and the
+        second is the wild card. You can put any number of pairs.
+
+        eg.  "description1 (*.ex1)|*.ex1|description2 (*.ex2)|*.ex2"
+
+        If you put a single wild card, it works as before the modification.
+    */
+    //=======================================================================
+
+	if ( !theFilter || (strcmp(theFilter, "") == 0)) theFilter = "*.*";
+
+	int filterBufferLen = 0;
+
+	if ( !strchr( theFilter, '|' ) ) { 			// only one filter ==> default text:
+		char buffText[] = "Files (%s)|%s";
+		filterBufferLen = strlen( theFilter )*2 + strlen( buffText ) -4;
+		filterBuffer    = new char[ filterBufferLen +2 ];
+
+		if ( filterBuffer ) {
+			sprintf( filterBuffer, buffText, theFilter, theFilter );
+		}
+	}
+	else {                  					// more then one filter
+		filterBufferLen = strlen( theFilter );
+		filterBuffer    = new char[ filterBufferLen +2 ];
+
+		if ( filterBuffer ) {
+			strcpy( filterBuffer, theFilter );
+	    }
+	}
+
+    if ( filterBuffer ) {  					    // Substituting '|' with '\0'
+		for ( int i = 0; i < filterBufferLen; i++ ) {
+			if ( filterBuffer[i] == '|' ) { filterBuffer[i] = '\0'; }
+		}
+	}
+
+	filterBuffer[filterBufferLen+1] = '\0';
+
+	of.lpstrFilter  = (LPSTR)filterBuffer;
+	of.nFilterIndex = m_filterIndex;
+
+    //=== Setting defaultFileName >>=========================================
+
+    strncpy( fileNameBuffer, (const char *)m_fileName, MAXPATH-1 );
+    fileNameBuffer[ MAXPATH-1 ] = '\0';
+
+	of.lpstrFile = fileNameBuffer;  // holds returned filename
+	of.nMaxFile  = MAXPATH;
+
+    //== Execute FileDialog >>=================================================
+
+    bool success = (m_dialogStyle & wxSAVE) ? (GetSaveFileName(&of) != 0) : (GetOpenFileName(&of) != 0);
+
+    if ( success )
+    {
+        //=== Adding the correct extension >>=================================
+
+        m_filterIndex = (int)of.nFilterIndex;
+
+	    if ( of.nFileExtension && fileNameBuffer[ of.nFileExtension-1] != '.' )
+        {                                    // user has typed an filename
+                                             // without an extension:
+
+	        int   maxFilter = (int)(of.nFilterIndex*2L-1L);
+	        extension       = filterBuffer;
+
+	        for( int i = 0; i < maxFilter; i++ ) {		    // get extension
+		        extension = extension + strlen( extension ) +1;
+	        }
+
+	        if (  (extension = strrchr( extension, '.' ))   // != "blabla" 
+			      && !strrchr( extension, '*' )             // != "blabla.*"
+			      && !strrchr( extension, '?' )             // != "blabla.?"
+			      && extension[1]                           // != "blabla."
+			      && extension[1] != ' ' )                  // != "blabla. "
+	        {
+                              // now concat extension to the fileName:
+				m_fileName = wxString(fileNameBuffer) + wxString(extension);
+
+                int len = strlen( fileNameBuffer );
+	            strncpy( fileNameBuffer + len, extension, MAXPATH - len );
+                fileNameBuffer[ MAXPATH -1 ] = '\0';
+            }
+	    }
+
+        m_path = fileNameBuffer;
+		m_fileName = wxFileNameFromPath(fileNameBuffer);
+
+
+	    //=== Simulating the wxOVERWRITE_PROMPT >>============================
+
+	    if ( (m_dialogStyle & wxOVERWRITE_PROMPT) && ::wxFileExists( fileNameBuffer ) )
+        {
+		    char  questionText[] = "Replace file\n%s?";
+		    char* messageText    = new char[strlen(questionText)+strlen(fileNameBuffer)-1];
+		    sprintf( messageText, questionText, fileNameBuffer );
+
+		    if ( messageText && ( wxMessageBox( (const char *)messageText, m_message, wxYES_NO ) != wxYES ) )
+            {
+                success = FALSE;
+		    }
+
+		    delete[] messageText;
+	    }
+
+    } // END: if ( success )
+
+
+    delete[] filterBuffer;
+
+	return (success ? wxID_OK : wxID_CANCEL) ;
+
+}
+
+#define wxDIALOG_DEFAULT_X 300
+#define wxDIALOG_DEFAULT_Y 300
+
+// Generic file load/save dialog
+// static inline char * // HP compiler complains
+static char *
+wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
+{
+  char *ext = (char *)extension;
+  
+  char prompt[50];
+  wxString str;
+  if (load)
+	str = (const char*) wxTString("Load %s file");
+  else
+	str = (const char*) wxTString("Save %s file");
+  sprintf(prompt, str, what);
+
+  if (*ext == '.') ext++;
+  char wild[60];
+  sprintf(wild, "*.%s", ext);
+
+  return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
+}
+
+// Generic file load dialog
+char *
+wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
+{
+  return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
+}
+
+
+// Generic file save dialog
+char *
+wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
+{
+  return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
+}
+
+
diff --git a/src/msw/font.cpp b/src/msw/font.cpp
new file mode 100644
index 0000000000..727048a9b8
--- /dev/null
+++ b/src/msw/font.cpp
@@ -0,0 +1,362 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        font.cpp
+// Purpose:     wxFont class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "font.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/list.h"
+#include "wx/utils.h"
+#include "wx/app.h"
+#include "wx/font.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "assert.h"
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
+
+#if USE_PORTABLE_FONTS_IN_MSW
+IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory, wxObject)
+#endif
+
+#endif
+
+wxFontRefData::wxFontRefData(void)
+{
+	m_style = 0;
+  	m_temporary = FALSE;
+  	m_pointSize = 0;
+  	m_family = 0;
+  	m_fontId = 0;
+  	m_style = 0;
+  	m_weight = 0;
+  	m_underlined = 0;
+  	m_faceName = "";
+  	m_hFont = 0;
+}
+
+wxFontRefData::~wxFontRefData(void)
+{
+	if ( m_hFont )
+    	::DeleteObject((HFONT) m_hFont);
+}
+
+wxFont::wxFont(void)
+{
+    if ( wxTheFontList )
+        wxTheFontList->Append(this);
+}
+
+/* Constructor for a font. Note that the real construction is done
+ * in wxDC::SetFont, when information is available about scaling etc.
+ */
+wxFont::wxFont(int PointSize, int Family, int Style, int Weight, bool Underlined, const wxString& Face)
+{
+  Create(PointSize, Family, Style, Weight, Underlined, Face);
+
+    if ( wxTheFontList )
+        wxTheFontList->Append(this);
+}
+
+bool wxFont::Create(int PointSize, int Family, int Style, int Weight, bool Underlined, const wxString& Face)
+{
+  UnRef();
+  m_refData = new wxFontRefData;
+
+  M_FONTDATA->m_family = Family;
+  M_FONTDATA->m_style = Style;
+  M_FONTDATA->m_weight = Weight;
+  M_FONTDATA->m_pointSize = PointSize;
+  M_FONTDATA->m_underlined = Underlined;
+  M_FONTDATA->m_faceName = Face;
+  M_FONTDATA->m_temporary = FALSE;
+  M_FONTDATA->m_hFont = 0;
+
+  RealizeResource();
+
+  return TRUE;
+}
+
+wxFont::~wxFont()
+{
+  if (wxTheFontList)
+    wxTheFontList->DeleteObject(this);
+}
+
+bool wxFont::RealizeResource(void)
+{
+  if (M_FONTDATA && !M_FONTDATA->m_hFont)
+  {
+    BYTE ff_italic;
+    int ff_weight = 0;
+    int ff_family = 0;
+    wxString ff_face("");
+
+    switch (M_FONTDATA->m_family)
+    {
+      case wxSCRIPT:     ff_family = FF_SCRIPT ;
+                         ff_face = "Script" ;
+                         break ;
+      case wxDECORATIVE: ff_family = FF_DECORATIVE;
+                         break;
+      case wxROMAN:      ff_family = FF_ROMAN;
+                         ff_face = "Times New Roman" ;
+                         break;
+      case wxTELETYPE:
+      case wxMODERN:     ff_family = FF_MODERN;
+                         ff_face = "Courier New" ;
+                         break;
+      case wxSWISS:      ff_family = FF_SWISS;
+                         ff_face = "Arial";
+                         break;
+      case wxDEFAULT:
+      default:           ff_family = FF_SWISS;
+                         ff_face = "Arial" ; 
+    }
+
+    if (M_FONTDATA->m_style == wxITALIC || M_FONTDATA->m_style == wxSLANT)
+      ff_italic = 1;
+    else
+      ff_italic = 0;
+
+    if (M_FONTDATA->m_weight == wxNORMAL)
+      ff_weight = FW_NORMAL;
+    else if (M_FONTDATA->m_weight == wxLIGHT)
+      ff_weight = FW_LIGHT;
+    else if (M_FONTDATA->m_weight == wxBOLD)
+      ff_weight = FW_BOLD;
+
+#if defined(__X__) || (defined(__WINDOWS__) && USE_PORTABLE_FONTS_IN_MSW)
+    ff_face = wxTheFontNameDirectory.GetScreenName(M_FONTDATA->m_family, M_FONTDATA->m_weight, M_FONTDATA->m_style);
+#else
+    ff_face = M_FONTDATA->m_faceName;
+	if ( ff_face.IsNull() )
+		ff_face = "";
+#endif
+
+/* Always calculate fonts using the screen DC (is this the best strategy?)
+ * There may be confusion if a font is selected into a printer
+ * DC (say), because the height will be calculated very differently.
+    // What sort of display is it?
+    int technology = ::GetDeviceCaps(dc, TECHNOLOGY);
+
+    int nHeight;
+    
+    if (technology != DT_RASDISPLAY && technology != DT_RASPRINTER)
+    {
+      // Have to get screen DC Caps, because a metafile will return 0.
+      HDC dc2 = ::GetDC(NULL);
+      nHeight = M_FONTDATA->m_pointSize*GetDeviceCaps(dc2, LOGPIXELSY)/72;
+      ::ReleaseDC(NULL, dc2);
+    }
+    else
+    {
+      nHeight = M_FONTDATA->m_pointSize*GetDeviceCaps(dc, LOGPIXELSY)/72;
+    }
+*/
+    // Have to get screen DC Caps, because a metafile will return 0.
+    HDC dc2 = ::GetDC(NULL);
+    int ppInch = ::GetDeviceCaps(dc2, LOGPIXELSY);
+    ::ReleaseDC(NULL, dc2);
+
+    // New behaviour: apparently ppInch varies according to
+    // Large/Small Fonts setting in Windows. This messes
+    // up fonts. So, set ppInch to a constant 96 dpi.
+    ppInch = 96;
+    
+#if FONT_SIZE_COMPATIBILITY
+    // Incorrect, but compatible with old wxWindows behaviour
+    int nHeight = (M_FONTDATA->m_pointSize*ppInch/72);
+#else
+    // Correct for Windows compatibility
+    int nHeight = - (M_FONTDATA->m_pointSize*ppInch/72);
+#endif
+
+    bool ff_underline = M_FONTDATA->m_underlined;
+
+    M_FONTDATA->m_hFont = (WXHFONT) CreateFont(nHeight, 0, 0, 0,ff_weight,ff_italic,(BYTE)ff_underline,
+                0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
+                PROOF_QUALITY, DEFAULT_PITCH | ff_family, (ff_face == "" ? NULL : (const char *)ff_face));
+#ifdef DEBUG_CREATE
+    if (m_hFont==NULL) wxError("Cannot create font","Internal Error") ;
+#endif
+    return (M_FONTDATA->m_hFont != (WXHFONT) NULL);
+  }
+  return FALSE;
+}
+
+bool wxFont::FreeResource(bool force)
+{
+  if (M_FONTDATA && M_FONTDATA->m_hFont)
+  {
+    ::DeleteObject((HFONT) M_FONTDATA->m_hFont);
+    M_FONTDATA->m_hFont = 0;
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/*
+bool wxFont::UseResource(void)
+{
+  IncrementResourceUsage();
+  return TRUE;
+}
+
+bool wxFont::ReleaseResource(void)
+{
+  DecrementResourceUsage();
+  return TRUE;
+}
+*/
+  
+WXHANDLE wxFont::GetResourceHandle(void)
+{
+  if ( !M_FONTDATA )
+	return 0;
+  else
+    return (WXHANDLE)M_FONTDATA->m_hFont ;
+}
+
+bool wxFont::IsFree(void)
+{
+  return (M_FONTDATA && (M_FONTDATA->m_hFont == 0));
+}
+
+void wxFont::SetPointSize(const int pointSize)
+{
+    if ( !m_refData )
+        m_refData = new wxFontRefData;
+    M_FONTDATA->m_pointSize = pointSize;
+}
+
+void wxFont::SetFamily(const int family)
+{
+    if ( !m_refData )
+        m_refData = new wxFontRefData;
+    M_FONTDATA->m_family = family;
+}
+
+void wxFont::SetStyle(const int style)
+{
+    if ( !m_refData )
+        m_refData = new wxFontRefData;
+    M_FONTDATA->m_style = style;
+}
+
+void wxFont::SetWeight(const int weight)
+{
+    if ( !m_refData )
+        m_refData = new wxFontRefData;
+    M_FONTDATA->m_weight = weight;
+}
+
+void wxFont::SetFaceName(const wxString& faceName)
+{
+    if ( !m_refData )
+        m_refData = new wxFontRefData;
+    M_FONTDATA->m_faceName = faceName;
+}
+
+void wxFont::SetUnderlined(const bool underlined)
+{
+    if ( !m_refData )
+        m_refData = new wxFontRefData;
+    M_FONTDATA->m_underlined = underlined;
+}
+
+wxString wxFont::GetFamilyString(void) const
+{
+  wxString fam("");
+  switch (GetFamily())
+  {
+    case wxDECORATIVE:
+      fam = "wxDECORATIVE";
+      break;
+    case wxROMAN:
+      fam = "wxROMAN";
+      break;
+    case wxSCRIPT:
+      fam = "wxSCRIPT";
+      break;
+    case wxSWISS:
+      fam = "wxSWISS";
+      break;
+    case wxMODERN:
+      fam = "wxMODERN";
+      break;
+    case wxTELETYPE:
+      fam = "wxTELETYPE";
+      break;
+    default:
+      fam = "wxDEFAULT";
+      break;
+  }
+  return fam;
+}
+
+/* New font system */
+wxString wxFont::GetFaceName(void) const
+{
+  wxString str("");
+  if (M_FONTDATA)
+	str = M_FONTDATA->m_faceName ;
+  return str;
+}
+
+wxString wxFont::GetStyleString(void) const
+{
+  wxString styl("");
+  switch (GetStyle())
+  {
+    case wxITALIC:
+      styl = "wxITALIC";
+      break;
+    case wxSLANT:
+      styl = "wxSLANT";
+      break;
+    default:
+      styl = "wxNORMAL";
+      break;
+  }
+  return styl;
+}
+
+wxString wxFont::GetWeightString(void) const
+{
+  wxString w("");
+  switch (GetWeight())
+  {
+    case wxBOLD:
+      w = "wxBOLD";
+      break;
+    case wxLIGHT:
+      w = "wxLIGHT";
+      break;
+    default:
+      w = "wxNORMAL";
+      break;
+  }
+  return w;
+}
+
diff --git a/src/msw/fontdlg.cpp b/src/msw/fontdlg.cpp
new file mode 100644
index 0000000000..0e335774d2
--- /dev/null
+++ b/src/msw/fontdlg.cpp
@@ -0,0 +1,281 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        fontdlg.cpp
+// Purpose:     wxFontDialog class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "fontdlg.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/defs.h"
+#include "wx/utils.h"
+#include "wx/dialog.h"
+#endif
+
+#include "wx/fontdlg.h"
+
+#include <windows.h>
+
+#ifndef __WIN32__
+#include <commdlg.h>
+#endif
+
+#include "wx/msw/private.h"
+#include "wx/cmndata.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define wxDIALOG_DEFAULT_X 300
+#define wxDIALOG_DEFAULT_Y 300
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
+#endif
+
+/*
+ * wxFontDialog
+ */
+
+
+wxFontDialog::wxFontDialog(void)
+{
+  dialogParent = NULL;
+}
+
+wxFontDialog::wxFontDialog(wxWindow *parent, wxFontData *data)
+{
+  Create(parent, data);
+}
+
+bool wxFontDialog::Create(wxWindow *parent, wxFontData *data)
+{
+  dialogParent = parent;
+  
+  if (data)
+    fontData = *data;
+  return TRUE;
+}
+
+int wxFontDialog::ShowModal(void)
+{
+    CHOOSEFONT chooseFontStruct;
+    LOGFONT logFont;
+
+    DWORD flags = CF_TTONLY | CF_SCREENFONTS | CF_NOSIMULATIONS;
+
+    memset(&chooseFontStruct, 0, sizeof(CHOOSEFONT));
+
+    chooseFontStruct.lStructSize = sizeof(CHOOSEFONT);
+    chooseFontStruct.hwndOwner = (HWND) (dialogParent ? (HWND) dialogParent->GetHWND() : NULL);
+    chooseFontStruct.lpLogFont = &logFont;
+
+    if (fontData.initialFont.Ok())
+    {
+      flags |= CF_INITTOLOGFONTSTRUCT;
+      wxFillLogFont(&logFont, & fontData.initialFont);
+    }
+
+    chooseFontStruct.iPointSize = 0;
+    chooseFontStruct.rgbColors = RGB((BYTE)fontData.fontColour.Red(), (BYTE)fontData.fontColour.Green(), (BYTE)fontData.fontColour.Blue());
+
+    if (!fontData.GetAllowSymbols())
+      flags |= CF_ANSIONLY;
+    if (fontData.GetEnableEffects())
+      flags |= CF_EFFECTS;
+    if (fontData.GetShowHelp())
+      flags |= CF_SHOWHELP;
+    if (!(fontData.minSize == 0 && fontData.maxSize == 0))
+    {
+      chooseFontStruct.nSizeMin = fontData.minSize;
+      chooseFontStruct.nSizeMax = fontData.maxSize;
+      flags |= CF_LIMITSIZE;
+    }
+
+    chooseFontStruct.Flags = flags;
+    chooseFontStruct.nFontType = SCREEN_FONTTYPE;
+    bool success = (ChooseFont(&(chooseFontStruct)) != 0);
+
+    // Restore values
+    if (success)
+    {
+      fontData.fontColour.Set(GetRValue(chooseFontStruct.rgbColors), GetGValue(chooseFontStruct.rgbColors),
+       GetBValue(chooseFontStruct.rgbColors));
+      fontData.chosenFont = wxCreateFontFromLogFont(&logFont);
+    }
+
+    return success ? wxID_OK : wxID_CANCEL;
+}
+
+void wxFillLogFont(LOGFONT *logFont, wxFont *font)
+{
+    BYTE ff_italic;
+    int ff_weight = 0;
+    int ff_family = 0;
+    wxString ff_face("");
+
+    switch (font->GetFamily())
+    {
+      case wxSCRIPT:     ff_family = FF_SCRIPT ;
+                         ff_face = "Script" ;
+                         break ;
+      case wxDECORATIVE: ff_family = FF_DECORATIVE;
+                         break;
+      case wxROMAN:      ff_family = FF_ROMAN;
+                         ff_face = "Times New Roman" ;
+                         break;
+      case wxTELETYPE:
+      case wxMODERN:     ff_family = FF_MODERN;
+                         ff_face = "Courier New" ;
+                         break;
+      case wxSWISS:      ff_family = FF_SWISS;
+                         ff_face = "Arial";
+                         break;
+      case wxDEFAULT:
+      default:           ff_family = FF_SWISS;
+                         ff_face = "MS Sans Serif" ; 
+    }
+
+    if (font->GetStyle() == wxITALIC || font->GetStyle() == wxSLANT)
+      ff_italic = 1;
+    else
+      ff_italic = 0;
+
+    if (font->GetWeight() == wxNORMAL)
+      ff_weight = FW_NORMAL;
+    else if (font->GetWeight() == wxLIGHT)
+      ff_weight = FW_LIGHT;
+    else if (font->GetWeight() == wxBOLD)
+      ff_weight = FW_BOLD;
+
+    // Have to get screen DC Caps, because a metafile will return 0.
+    HDC dc2 = ::GetDC(NULL);
+    int ppInch = ::GetDeviceCaps(dc2, LOGPIXELSY);
+    ::ReleaseDC(NULL, dc2);
+
+    // New behaviour: apparently ppInch varies according to
+    // Large/Small Fonts setting in Windows. This messes
+    // up fonts. So, set ppInch to a constant 96 dpi.
+    ppInch = 96;
+
+#if FONT_SIZE_COMPATIBILITY
+    // Incorrect, but compatible with old wxWindows behaviour
+    int nHeight = (font->GetPointSize()*ppInch/72);
+#else
+    // Correct for Windows compatibility
+    int nHeight = - (font->GetPointSize()*ppInch/72);
+#endif
+
+    bool ff_underline = font->GetUnderlined();
+
+    ff_face = font->GetFaceName();
+
+    logFont->lfHeight = nHeight;
+    logFont->lfWidth = 0;
+    logFont->lfEscapement = 0;
+    logFont->lfOrientation = 0;
+    logFont->lfWeight = ff_weight;
+    logFont->lfItalic = ff_italic;
+    logFont->lfUnderline = (BYTE)ff_underline;
+    logFont->lfStrikeOut = 0;
+    logFont->lfCharSet = ANSI_CHARSET;
+    logFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
+    logFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
+    logFont->lfQuality = PROOF_QUALITY;
+    logFont->lfPitchAndFamily = DEFAULT_PITCH | ff_family;
+    strcpy(logFont->lfFaceName, ff_face);
+}
+
+wxFont wxCreateFontFromLogFont(LOGFONT *logFont) // , bool createNew)
+{
+  int fontFamily = wxSWISS;
+  int fontStyle = wxNORMAL;
+  int fontWeight = wxNORMAL;
+  int fontPoints = 10;
+  bool fontUnderline = FALSE;
+  char *fontFace = NULL;
+
+//  int lfFamily = logFont->lfPitchAndFamily & 0xF0;
+  int lfFamily = logFont->lfPitchAndFamily;
+  if (lfFamily & FIXED_PITCH)
+    lfFamily -= FIXED_PITCH;
+  if (lfFamily & VARIABLE_PITCH)
+    lfFamily -= VARIABLE_PITCH;
+  
+  switch (lfFamily)
+  {
+    case FF_ROMAN:
+      fontFamily = wxROMAN;
+      break;
+    case FF_SWISS:
+      fontFamily = wxSWISS;
+      break;
+    case FF_SCRIPT:
+      fontFamily = wxSCRIPT;
+      break;
+    case FF_MODERN:
+      fontFamily = wxMODERN;
+      break;
+    case FF_DECORATIVE:
+      fontFamily = wxDECORATIVE;
+      break;
+    default:
+      fontFamily = wxSWISS;
+      break;
+  }
+  switch (logFont->lfWeight)
+  {
+    case FW_LIGHT:
+      fontWeight = wxLIGHT;
+      break;
+    case FW_NORMAL:
+      fontWeight = wxNORMAL;
+      break;
+    case FW_BOLD:
+      fontWeight = wxBOLD;
+      break;
+    default:
+      fontWeight = wxNORMAL;
+      break;
+  }
+  if (logFont->lfItalic)
+    fontStyle = wxITALIC;
+  else
+    fontStyle = wxNORMAL;
+
+  if (logFont->lfUnderline)
+    fontUnderline = TRUE;
+    
+  if  (logFont->lfFaceName)
+    fontFace = logFont->lfFaceName;
+
+  HDC dc2 = ::GetDC(NULL);
+
+  if ( logFont->lfHeight < 0 )
+	logFont->lfHeight = - logFont->lfHeight;
+  fontPoints = abs(72*logFont->lfHeight/GetDeviceCaps(dc2, LOGPIXELSY));
+  ::ReleaseDC(NULL, dc2);
+
+//  if ( createNew )
+  	return wxFont(fontPoints, fontFamily, fontStyle, fontWeight, fontUnderline, fontFace);
+//  else
+//	return wxTheFontList->FindOrCreateFont(fontPoints, fontFamily, fontStyle, fontWeight, fontUnderline, fontFace);
+}
+
+
diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp
new file mode 100644
index 0000000000..55889420fa
--- /dev/null
+++ b/src/msw/frame.cpp
@@ -0,0 +1,1076 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        frame.cpp
+// Purpose:     wxFrame
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "frame.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#include "wx/frame.h"
+#include "wx/menu.h"
+#include "wx/app.h"
+#include "wx/utils.h"
+#include "wx/dialog.h"
+#include "wx/settings.h"
+#include "wx/dcclient.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "wx/statusbr.h"
+#include "wx/menuitem.h"
+
+#ifdef LoadAccelerators
+#undef LoadAccelerators
+#endif
+
+#if USE_NATIVE_STATUSBAR
+#include <wx/msw/statbr95.h>
+#endif
+
+extern wxList wxModelessWindows;
+extern wxList wxPendingDelete;
+extern char wxFrameClassName[];
+
+#if !USE_SHARED_LIBRARY
+BEGIN_EVENT_TABLE(wxFrame, wxWindow)
+  EVT_SIZE(wxFrame::OnSize)
+  EVT_ACTIVATE(wxFrame::OnActivate)
+  EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
+  EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
+  EVT_IDLE(wxFrame::OnIdle)
+  EVT_CLOSE(wxFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
+IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
+#endif
+
+#if USE_NATIVE_STATUSBAR
+bool wxFrame::m_useNativeStatusBar = TRUE;
+#else
+bool wxFrame::m_useNativeStatusBar = FALSE;
+#endif
+
+wxFrame::wxFrame(void)
+{
+  m_frameMenuBar = NULL;
+  m_frameStatusBar = NULL;
+
+  m_windowParent = NULL;
+  m_iconized = FALSE;
+}
+
+bool wxFrame::Create(wxWindow *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos,
+           const wxSize& size,
+           const long style,
+           const wxString& name)
+{
+  if (!parent)
+    wxTopLevelWindows.Append(this);
+
+  SetName(name);
+//  m_modalShowing = FALSE;
+  m_windowStyle = style;
+  m_frameMenuBar = NULL;
+  m_frameStatusBar = NULL;
+
+  SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
+
+//  m_icon = NULL;
+  if ( id > -1 )
+    m_windowId = id;
+  else
+    m_windowId = (int)NewControlId();
+
+  if (parent) parent->AddChild(this);
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_iconized = FALSE;
+  MSWCreate(m_windowId, (wxWindow *)parent, wxFrameClassName, this, (char *)(const char *)title,
+                   x, y, width, height, style);
+
+  wxModelessWindows.Append(this);
+  return TRUE;
+}
+
+wxFrame::~wxFrame(void)
+{
+  m_isBeingDeleted = TRUE;
+  wxTopLevelWindows.DeleteObject(this);
+
+  if (m_frameStatusBar)
+    delete m_frameStatusBar;
+  if (m_frameMenuBar)
+    delete m_frameMenuBar;
+
+/* New behaviour March 1998: check if it's the last top-level window */
+//  if (wxTheApp && (this == wxTheApp->GetTopWindow()))
+
+  if (wxTheApp && (wxTopLevelWindows.Number() == 0))
+  {
+    wxTheApp->SetTopWindow(NULL);
+
+    if (wxTheApp->GetExitOnFrameDelete())
+    {
+       PostQuitMessage(0);
+    }
+  }
+
+  wxModelessWindows.DeleteObject(this);
+
+  // For some reason, wxWindows can activate another task altogether
+  // when a frame is destroyed after a modal dialog has been invoked.
+  // Try to bring the parent to the top.
+  if (GetParent() && GetParent()->GetHWND())
+    ::BringWindowToTop((HWND) GetParent()->GetHWND());
+}
+
+WXHMENU wxFrame::GetWinMenu(void) const
+{
+  return m_hMenu;
+}
+
+// Get size *available for subwindows* i.e. excluding menu bar etc.
+// For XView, this is the same as GetSize
+void wxFrame::GetClientSize(int *x, int *y) const
+{
+  RECT rect;
+  GetClientRect((HWND) GetHWND(), &rect);
+
+  if ( m_frameStatusBar )
+  {
+  int statusX, statusY;
+  m_frameStatusBar->GetClientSize(&statusX, &statusY);
+  rect.bottom -= statusY;
+  }
+  *x = rect.right;
+  *y = rect.bottom;
+}
+
+// Set the client size (i.e. leave the calculation of borders etc.
+// to wxWindows)
+void wxFrame::SetClientSize(const int width, const int height)
+{
+  HWND hWnd = (HWND) GetHWND();
+
+  RECT rect;
+  GetClientRect(hWnd, &rect);
+
+  RECT rect2;
+  GetWindowRect(hWnd, &rect2);
+
+  // Find the difference between the entire window (title bar and all)
+  // and the client area; add this to the new client size to move the
+  // window
+  int actual_width = rect2.right - rect2.left - rect.right + width;
+  int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
+
+  if ( m_frameStatusBar )
+  {
+  int statusX, statusY;
+  m_frameStatusBar->GetClientSize(&statusX, &statusY);
+  actual_height += statusY;
+  }
+
+  POINT point;
+  point.x = rect2.left;
+  point.y = rect2.top;
+
+  MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.SetEventObject( this );
+  GetEventHandler()->ProcessEvent(event);
+#endif
+}
+
+void wxFrame::GetSize(int *width, int *height) const
+{
+  RECT rect;
+  GetWindowRect((HWND) GetHWND(), &rect);
+  *width = rect.right - rect.left;
+  *height = rect.bottom - rect.top;
+}
+
+void wxFrame::GetPosition(int *x, int *y) const
+{
+  RECT rect;
+  GetWindowRect((HWND) GetHWND(), &rect);
+  POINT point;
+  point.x = rect.left;
+  point.y = rect.top;
+
+  *x = point.x;
+  *y = point.y;
+}
+
+void wxFrame::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  int x1 = x;
+  int y1 = y;
+  int w1 = width;
+  int h1 = height;
+
+  GetPosition(&currentX, &currentY);
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  int ww,hh ;
+  GetSize(&ww,&hh) ;
+  if (width == -1) w1 = ww ;
+  if (height==-1) h1 = hh ;
+
+  MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, (BOOL)TRUE);
+
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.SetEventObject( this );
+  GetEventHandler()->ProcessEvent(event);
+#endif
+}
+
+bool wxFrame::Show(const bool show)
+{
+  int cshow;
+  if (show)
+    cshow = SW_SHOW;
+  else
+    cshow = SW_HIDE;
+
+  if (!show)
+  {
+    // Try to highlight the correct window (the parent)
+    HWND hWndParent = 0;
+    if (GetParent())
+    {
+      hWndParent = (HWND) GetParent()->GetHWND();
+      if (hWndParent)
+        ::BringWindowToTop(hWndParent);
+    }
+  }
+
+  ShowWindow((HWND) GetHWND(), (BOOL)cshow);
+  if (show)
+  {
+    BringWindowToTop((HWND) GetHWND());
+
+#if WXWIN_COMPATIBILITY
+    OldOnActivate(TRUE);
+#else
+    wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_windowId);
+    event.SetEventObject( this );
+    GetEventHandler()->ProcessEvent(event);
+#endif
+  }
+  return TRUE;
+}
+
+void wxFrame::Iconize(const bool iconize)
+{
+  if (!iconize)
+    Show(TRUE);
+
+  int cshow;
+  if (iconize)
+    cshow = SW_MINIMIZE;
+  else
+    cshow = SW_RESTORE;
+  ShowWindow((HWND) GetHWND(), (BOOL)cshow);
+  m_iconized = iconize;
+}
+
+// Equivalent to maximize/restore in Windows
+void wxFrame::Maximize(const bool maximize)
+{
+  Show(TRUE);
+  int cshow;
+  if (maximize)
+    cshow = SW_MAXIMIZE;
+  else
+    cshow = SW_RESTORE;
+  ShowWindow((HWND) GetHWND(), cshow);
+  m_iconized = FALSE;
+}
+
+bool wxFrame::IsIconized(void) const
+{
+  ((wxFrame *)this)->m_iconized = (::IsIconic((HWND) GetHWND()) != 0);
+  return m_iconized;
+}
+
+void wxFrame::SetTitle(const wxString& title)
+{
+  SetWindowText((HWND) GetHWND(), (const char *)title);
+}
+
+wxString wxFrame::GetTitle(void) const
+{
+  GetWindowText((HWND) GetHWND(), wxBuffer, 1000);
+  return wxString(wxBuffer);
+}
+
+void wxFrame::SetIcon(const wxIcon& icon)
+{
+  m_icon = icon;
+#if defined(__WIN95__)
+  if ( m_icon.Ok() )
+    SendMessage((HWND) GetHWND(), WM_SETICON,
+                (WPARAM)TRUE, (LPARAM)(HICON) m_icon.GetHICON());
+#endif
+}
+
+wxStatusBar *wxFrame::OnCreateStatusBar(const int number)
+{
+    wxStatusBar *statusBar = NULL;
+
+#if USE_NATIVE_STATUSBAR
+    if (UsesNativeStatusBar())
+    {
+        statusBar = new wxStatusBar95(this);
+    }
+    else
+#endif
+    {
+        statusBar = new wxStatusBar(this, -1, wxPoint(0, 0), wxSize(100, 20));
+
+        // Set the height according to the font and the border size
+        wxClientDC dc(statusBar);
+        dc.SetFont(* statusBar->GetFont());
+
+        long x, y;
+        dc.GetTextExtent("X", &x, &y);
+
+        int height = (int)( (y  * 1.1) + 2* statusBar->GetBorderY());
+
+        statusBar->SetSize(-1, -1, 100, height);
+    }
+
+  statusBar->SetFieldsCount(number);
+  return statusBar;
+}
+
+bool wxFrame::CreateStatusBar(const int number)
+{
+  // VZ: calling CreateStatusBar twice is an error - why anyone would do it?
+  wxCHECK_RET( m_frameStatusBar == NULL, FALSE );
+
+  m_frameStatusBar = OnCreateStatusBar(number);
+  if ( m_frameStatusBar )
+  {
+    PositionStatusBar();
+    return TRUE;
+  }
+  else
+    return FALSE;
+}
+
+void wxFrame::SetStatusText(const wxString& text, const int number)
+{
+  wxCHECK( m_frameStatusBar != NULL );
+
+  m_frameStatusBar->SetStatusText(text, number);
+}
+
+void wxFrame::SetStatusWidths(const int n, const int *widths_field)
+{
+  wxCHECK( m_frameStatusBar != NULL );
+
+  m_frameStatusBar->SetStatusWidths(n, widths_field);
+  PositionStatusBar();
+}
+
+void wxFrame::PositionStatusBar(void)
+{
+  // native status bar positions itself
+  if (m_frameStatusBar
+#if USE_NATIVE_STATUSBAR
+   && !m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95))
+#endif
+    )
+  {
+      int w, h;
+      GetClientSize(&w, &h);
+      int sw, sh;
+      m_frameStatusBar->GetSize(&sw, &sh);
+      m_frameStatusBar->SetSize(0, h, w, sh);
+  }
+}
+
+void wxFrame::SetMenuBar(wxMenuBar *menu_bar)
+{
+  if (!menu_bar)
+  {
+    m_frameMenuBar = NULL;
+    return;
+  }
+  
+  if (menu_bar->m_menuBarFrame)
+   return;
+
+  int i;
+  HMENU menu = CreateMenu();
+
+  for (i = 0; i < menu_bar->m_menuCount; i ++)
+  {
+    HMENU popup = (HMENU)menu_bar->m_menus[i]->m_hMenu;
+    //
+    // After looking Bounds Checker result, it seems that all
+    // menus must be individually destroyed. So, don't reset m_hMenu,
+    // to  allow ~wxMenu to do the job.
+    //
+    menu_bar->m_menus[i]->m_savehMenu = (WXHMENU) popup;
+    // Uncommenting for the moment... JACS
+    menu_bar->m_menus[i]->m_hMenu = 0;
+    AppendMenu(menu, MF_POPUP | MF_STRING, (UINT)popup, menu_bar->m_titles[i]);
+  }
+
+  menu_bar->m_hMenu = (WXHMENU)menu;
+  if (m_frameMenuBar)
+    delete m_frameMenuBar;
+
+  this->m_hMenu = (WXHMENU) menu;
+
+  DWORD err = 0;
+  if (!SetMenu((HWND) GetHWND(), menu))
+  {
+#ifdef __WIN32__
+    err = GetLastError();
+#endif
+  }
+
+  m_frameMenuBar = menu_bar;
+  menu_bar->m_menuBarFrame = this;
+}
+
+bool wxFrame::LoadAccelerators(const wxString& table)
+{
+  m_acceleratorTable = (WXHANDLE)
+#ifdef __WIN32__
+#ifdef UNICODE
+     ::LoadAcceleratorsW(wxGetInstance(), (const char *)table);
+#else
+     ::LoadAcceleratorsA(wxGetInstance(), (const char *)table);
+#endif
+#else
+     ::LoadAccelerators(wxGetInstance(), (const char *)table);
+#endif
+
+  // The above is necessary because LoadAccelerators is a macro
+  // which we have undefed earlier in the file to avoid confusion
+  // with wxFrame::LoadAccelerators. Ugh!
+
+  return (m_acceleratorTable != (WXHANDLE) NULL);
+}
+
+void wxFrame::Fit(void)
+{
+  // Work out max. size
+  wxNode *node = GetChildren()->First();
+  int max_width = 0;
+  int max_height = 0;
+  while (node)
+  {
+    // Find a child that's a subwindow, but not a dialog box.
+    wxWindow *win = (wxWindow *)node->Data();
+
+    if (!win->IsKindOf(CLASSINFO(wxFrame)) &&
+         !win->IsKindOf(CLASSINFO(wxDialog)))
+    {
+      int width, height;
+      int x, y;
+      win->GetSize(&width, &height);
+      win->GetPosition(&x, &y);
+
+      if ((x + width) > max_width)
+        max_width = x + width;
+      if ((y + height) > max_height)
+        max_height = y + height;
+    }
+    node = node->Next();
+  }
+  SetClientSize(max_width, max_height);
+}
+
+// Responds to colour changes, and passes event on to children.
+void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
+{
+    SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
+    Refresh();
+
+    if ( m_frameStatusBar )
+    {
+        wxSysColourChangedEvent event2;
+        event2.SetEventObject( m_frameStatusBar );
+        m_frameStatusBar->ProcessEvent(event2);
+    }
+
+    // Propagate the event to the non-top-level children
+    wxWindow::OnSysColourChanged(event);
+}
+
+/*
+ * Frame window
+ *
+ */
+
+void wxFrame::MSWCreate(const int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title,
+                   const int x, const int y, const int width, const int height, const long style)
+
+{
+  m_defaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON);
+
+  // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
+  // could be the culprit. But without it, you can get a lot of flicker.
+
+//   DWORD msflags = WS_POPUP | WS_CLIPCHILDREN ;
+
+  DWORD msflags = 0;
+  if ((style & wxCAPTION) == wxCAPTION)
+    msflags = WS_OVERLAPPED | WS_CLIPCHILDREN ; // WS_POPUP | WS_CLIPCHILDREN ;
+  else
+    msflags = WS_POPUP | WS_CLIPCHILDREN ;
+
+  if (style & wxMINIMIZE_BOX)
+    msflags |= WS_MINIMIZEBOX;
+  if (style & wxMAXIMIZE_BOX)
+    msflags |= WS_MAXIMIZEBOX;
+  if (style & wxTHICK_FRAME)
+    msflags |= WS_THICKFRAME;
+  if (style & wxSYSTEM_MENU)
+    msflags |= WS_SYSMENU;
+  if ((style & wxMINIMIZE) || (style & wxICONIZE))
+    msflags |= WS_MINIMIZE;
+  if (style & wxMAXIMIZE)
+    msflags |= WS_MAXIMIZE;
+  if (style & wxCAPTION)
+    msflags |= WS_CAPTION;
+
+  // Keep this in wxFrame because it saves recoding this function
+  // in wxTinyFrame
+#if USE_ITSY_BITSY
+  if (style & wxTINY_CAPTION_VERT)
+    msflags |= IBS_VERTCAPTION;
+  if (style & wxTINY_CAPTION_HORIZ)
+    msflags |= IBS_HORZCAPTION;
+#else
+  if (style & wxTINY_CAPTION_VERT)
+    msflags |= WS_CAPTION;
+  if (style & wxTINY_CAPTION_HORIZ)
+    msflags |= WS_CAPTION;
+#endif
+  if ((style & wxTHICK_FRAME) == 0)
+    msflags |= WS_BORDER;
+
+  WXDWORD extendedStyle = MakeExtendedStyle(style);
+
+  if (style & wxSTAY_ON_TOP)
+    extendedStyle |= WS_EX_TOPMOST;
+
+  m_iconized = FALSE;
+  wxWindow::MSWCreate(id, parent, wclass, wx_win, title, x, y, width, height,
+         msflags, NULL, extendedStyle);
+  // Seems to be necessary if we use WS_POPUP
+  // style instead of WS_OVERLAPPED
+  if (width > -1 && height > -1)
+    ::PostMessage((HWND) GetHWND(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(width, height));
+}
+
+bool wxFrame::MSWOnPaint(void)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxFrameWnd::OnPaint %d\n", handle);
+#endif
+  RECT rect;
+  if (GetUpdateRect((HWND) GetHWND(), &rect, FALSE))
+  {
+    if (m_iconized)
+    {
+      HICON the_icon;
+    if (m_icon.Ok())
+      the_icon = (HICON) m_icon.GetHICON();
+      if (the_icon == 0)
+        the_icon = (HICON) m_defaultIcon;
+
+      PAINTSTRUCT ps;
+      // Hold a pointer to the dc so long as the OnPaint() message
+      // is being processed
+      HDC cdc = BeginPaint((HWND) GetHWND(), &ps);
+      
+      // Erase background before painting or we get white background
+      this->MSWDefWindowProc(WM_ICONERASEBKGND,(WORD)ps.hdc,0L);
+      
+      if (the_icon)
+      {
+        RECT rect;
+        GetClientRect((HWND) GetHWND(), &rect);
+        int icon_width = 32;
+        int icon_height = 32;
+        int icon_x = (int)((rect.right - icon_width)/2);
+        int icon_y = (int)((rect.bottom - icon_height)/2);
+        DrawIcon(cdc, icon_x, icon_y, the_icon);
+      }
+
+      EndPaint((HWND) GetHWND(), &ps);
+    }
+
+    if (!m_iconized)
+    {
+//      m_paintHDC = (WXHDC) cdc;
+      GetEventHandler()->OldOnPaint();
+//      m_paintHDC = NULL;
+    }
+    return 0;
+  }
+  return 1;
+}
+
+WXHICON wxFrame::MSWOnQueryDragIcon(void)
+{
+  if (m_icon.Ok() && (m_icon.GetHICON() != 0))
+    return m_icon.GetHICON();
+  else
+    return m_defaultIcon;
+}
+
+void wxFrame::MSWOnSize(const int x, const int y, const WXUINT id)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxFrameWnd::OnSize %d\n", m_hWnd);
+#endif
+  switch (id)
+  {
+    case SIZEFULLSCREEN:
+    case SIZENORMAL:
+      m_iconized = FALSE;
+    break;
+    case SIZEICONIC:
+      m_iconized = TRUE;
+    break;
+  }
+
+ if (!m_iconized)
+ {
+  // forward WM_SIZE to status bar control
+#if USE_NATIVE_STATUSBAR
+  if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
+  {
+    wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId());
+    event.SetEventObject( m_frameStatusBar );
+
+    ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event);
+  }
+#endif
+
+  PositionStatusBar();
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(x, y);
+#else
+  wxSizeEvent event(wxSize(x, y), m_windowId);
+  event.SetEventObject( this );
+  GetEventHandler()->ProcessEvent(event);
+#endif
+ }
+}
+
+bool wxFrame::MSWOnClose(void)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxFrameWnd::OnClose %d\n", handle);
+#endif
+    return Close();
+}
+
+bool wxFrame::MSWOnCommand(const WXWORD id, const WXWORD cmd, const WXHWND control)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxFrameWnd::OnCommand %d\n", handle);
+#endif
+  if (cmd == 0 || cmd == 1 ) // Can be either a menu command or an accelerator.
+  {
+    // In case it's e.g. a toolbar.
+    wxWindow *win = wxFindWinFromHandle(control);
+    if (win)
+      return win->MSWCommand(cmd, id);
+
+    if (GetMenuBar() && GetMenuBar()->FindItemForId(id))
+    {
+      ProcessCommand(id);
+      return TRUE;
+    }
+    else
+      return FALSE;
+  }
+  else
+    return FALSE;
+}
+
+void wxFrame::MSWOnMenuHighlight(const WXWORD nItem, const WXWORD nFlags, const WXHMENU hSysMenu)
+{
+#if WXWIN_COMPATIBILITY
+  if (nFlags == 0xFFFF && hSysMenu == 0)
+    GetEventHandler()->OldOnMenuSelect(-1);
+  else if (nFlags != MF_SEPARATOR)
+    GetEventHandler()->OldOnMenuSelect(nItem);
+#else
+  if (nFlags == 0xFFFF && hSysMenu == 0)
+  {
+    wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, -1);
+    event.SetEventObject( this );
+    GetEventHandler()->ProcessEvent(event);
+  }
+  else if (nFlags != MF_SEPARATOR)
+  {
+    wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, nItem);
+    event.SetEventObject( this );
+    GetEventHandler()->ProcessEvent(event);
+  }
+#endif
+}
+
+bool wxFrame::MSWProcessMessage(WXMSG* pMsg)
+{
+  if (m_acceleratorTable != 0 &&
+          ::TranslateAccelerator((HWND) GetHWND(), (HANDLE) m_acceleratorTable, (MSG *)pMsg))
+    return TRUE;
+  
+  return FALSE;
+}
+
+// Default resizing behaviour - if only ONE subwindow,
+// resize to client rectangle size
+void wxFrame::OnSize(wxSizeEvent& event)
+{
+  // Search for a child which is a subwindow, not another frame.
+  wxWindow *child = NULL;
+  // Count the number of _subwindow_ children
+  int noChildren = 0;
+  for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+  {
+    wxWindow *win = (wxWindow *)node->Data();
+    if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))
+      && (win != GetStatusBar()))
+    {
+      child = win;
+      noChildren ++;
+    }
+  }
+
+  // If not one child, call the Layout function if compiled in
+  if (!child || (noChildren > 1)
+#if USE_CONSTRAINTS
+   || GetAutoLayout()
+#endif
+   )
+  {
+#if USE_CONSTRAINTS
+    if (GetAutoLayout())
+      Layout();
+#endif
+    return;
+  }
+  
+  if (child)
+  {
+    int client_x, client_y;
+
+#if DEBUG > 1
+    wxDebugMsg("wxFrame::OnSize: about to set the child's size.\n");
+#endif
+
+    GetClientSize(&client_x, &client_y);
+    child->SetSize(0, 0, client_x, client_y);
+  }
+
+}
+
+// Default activation behaviour - set the focus for the first child
+// subwindow found.
+void wxFrame::OnActivate(wxActivateEvent& event)
+{
+  for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+  {
+    // Find a child that's a subwindow, but not a dialog box.
+    wxWindow *child = (wxWindow *)node->Data();
+    if (!child->IsKindOf(CLASSINFO(wxFrame)) &&
+         !child->IsKindOf(CLASSINFO(wxDialog)))
+    {
+#if DEBUG > 1
+      wxDebugMsg("wxFrame::OnActivate: about to set the child's focus.\n");
+#endif
+      child->SetFocus();
+      return;
+    }
+  }
+}
+
+// The default implementation for the close window event - calls
+// OnClose for backward compatibility.
+
+void wxFrame::OnCloseWindow(wxCloseEvent& event)
+{
+    // Compatibility
+    if ( GetEventHandler()->OnClose() || event.GetForce())
+    {
+        this->Destroy();
+    }
+}
+
+// Destroy the window (delayed, if a managed window)
+bool wxFrame::Destroy(void)
+{
+  if (!wxPendingDelete.Member(this))
+    wxPendingDelete.Append(this);
+  return TRUE;
+}
+
+// Default menu selection behaviour - display a help string
+void wxFrame::OnMenuHighlight(wxMenuEvent& event)
+{
+  if (GetStatusBar())
+  {
+    if (event.GetMenuId() == -1)
+      SetStatusText("");
+    else
+    {
+      wxMenuBar *menuBar = GetMenuBar();
+      if (menuBar)
+      {
+        wxString helpString(menuBar->GetHelpString(event.GetMenuId()));
+        if (helpString != "")
+          SetStatusText(helpString);
+      }
+    }
+  }
+}
+
+#if WXWIN_COMPATIBILITY
+void wxFrame::OldOnSize(int x, int y)
+{
+#if WXWIN_COMPATIBILITY == 1
+  wxSizeEvent event(wxSize(x, y), m_windowId);
+  event.SetEventObject( this );
+  if (GetEventHandler()->ProcessEvent(event))
+  return;
+#endif
+  // Search for a child which is a subwindow, not another frame.
+  wxWindow *child = NULL;
+  // Count the number of _subwindow_ children
+  int noChildren = 0;
+  for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+  {
+    wxWindow *win = (wxWindow *)node->Data();
+    if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)) && (win != GetStatusBar()))
+    {
+      child = win;
+      noChildren ++;
+    }
+  }
+
+  // If not one child, call the Layout function if compiled in
+  if (!child || (noChildren > 1)
+#if USE_CONSTRAINTS
+   || GetAutoLayout()
+#endif
+   )
+  {
+#if USE_CONSTRAINTS
+    if (GetAutoLayout())
+      Layout();
+#endif
+    return;
+  }
+  
+  if (child)
+  {
+    int client_x, client_y;
+
+#if DEBUG > 1
+    wxDebugMsg("wxFrame::OnSize: about to set the child's size.\n");
+#endif
+
+    GetClientSize(&client_x, &client_y);
+    child->SetSize(0, 0, client_x, client_y);
+  }
+}
+
+// Default activation behaviour - set the focus for the first child
+// subwindow found.
+void wxFrame::OldOnActivate(bool flag)
+{
+#if WXWIN_COMPATIBILITY == 1
+  wxActivateEvent event(wxEVT_ACTIVATE, flag, m_windowId);
+  event.SetEventObject( this );
+  if (GetEventHandler()->ProcessEvent(event))
+  return;
+#endif
+  for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+  {
+    // Find a child that's a subwindow, but not a dialog box.
+    wxWindow *child = (wxWindow *)node->Data();
+    if (!child->IsKindOf(CLASSINFO(wxFrame)) &&
+         !child->IsKindOf(CLASSINFO(wxDialog)))
+    {
+#if DEBUG > 1
+      wxDebugMsg("wxFrame::OnActivate: about to set the child's focus.\n");
+#endif
+      child->SetFocus();
+      return;
+    }
+  }
+}
+
+// Default menu selection behaviour - display a help string
+void wxFrame::OldOnMenuSelect(int id)
+{
+#if WXWIN_COMPATIBILITY == 1
+    wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, id);
+    event.SetEventObject( this );
+  if (GetEventHandler()->ProcessEvent(event))
+    return;
+#endif
+  if (GetStatusBar())
+  {
+    if (id == -1)
+      SetStatusText("");
+    else
+    {
+      wxMenuBar *menuBar = GetMenuBar();
+      if (menuBar)
+      {
+        wxString helpString(menuBar->GetHelpString(id));
+        if (helpString != "")
+          SetStatusText(helpString);
+      }
+    }
+  }
+}
+#endif
+
+wxMenuBar *wxFrame::GetMenuBar(void) const
+{
+  return m_frameMenuBar;
+}
+
+void wxFrame::Centre(const int direction)
+{
+  int display_width, display_height, width, height, x, y;
+  wxDisplaySize(&display_width, &display_height);
+
+  GetSize(&width, &height);
+  GetPosition(&x, &y);
+
+  if (direction & wxHORIZONTAL)
+    x = (int)((display_width - width)/2);
+  if (direction & wxVERTICAL)
+    y = (int)((display_height - height)/2);
+
+  SetSize(x, y, width, height);
+}
+
+// Call this to simulate a menu command
+void wxFrame::Command(int id)
+{
+  ProcessCommand(id);
+}
+
+void wxFrame::ProcessCommand(int id)
+{
+  wxCommandEvent commandEvent(wxEVENT_TYPE_MENU_COMMAND, id);
+  commandEvent.SetInt( id );
+  commandEvent.SetEventObject( this );
+
+  wxMenuBar *bar = GetMenuBar() ;
+  if (!bar)
+    return;
+
+  // Motif does the job by itself!!
+#ifndef __MOTIF__
+  wxMenuItem *item = bar->FindItemForId(id) ;
+  if (item && item->IsCheckable())
+  {
+//wxDebugMsg("Toggling id %d\n",id) ;
+    bar->Check(id,!bar->Checked(id)) ;
+  }
+#endif
+  if (!ProcessEvent(commandEvent))
+    OldOnMenuCommand(id);
+}
+
+void wxFrame::OnIdle(wxIdleEvent& event)
+{
+  DoMenuUpdates();
+}
+
+// Query app for menu item updates (called from OnIdle)
+void wxFrame::DoMenuUpdates(void)
+{
+  wxMenuBar* bar = GetMenuBar();
+  if (!bar)
+    return;
+
+  int i;
+  for (i = 0; i < bar->m_menuCount; i++)
+  {
+    wxMenu* menu = bar->m_menus[i];
+
+    DoMenuUpdates(menu);
+  }
+}
+
+void wxFrame::DoMenuUpdates(wxMenu* menu)
+{
+  wxNode* node = menu->m_menuItems.First();
+  while (node)
+  {
+    wxMenuItem* item = (wxMenuItem*) node->Data();
+    if ( !item->IsSeparator() )
+    {
+        wxWindowID id = item->GetId();
+      wxUpdateUIEvent event(id);
+      event.SetEventObject( this );
+
+      if (GetEventHandler()->ProcessEvent(event))
+      {
+        if (event.GetSetText())
+          menu->SetLabel(id, event.GetText());
+        if (event.GetSetChecked())
+          menu->Check(id, event.GetChecked());
+        if (event.GetSetEnabled())
+          menu->Enable(id, event.GetEnabled());
+      }
+
+      if (item->GetSubMenu())
+        DoMenuUpdates(item->GetSubMenu());
+    }
+    node = node->Next();
+  }
+}
diff --git a/src/msw/gauge.cpp b/src/msw/gauge.cpp
new file mode 100644
index 0000000000..5e5978a9fb
--- /dev/null
+++ b/src/msw/gauge.cpp
@@ -0,0 +1,1261 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        gauge.cpp
+// Purpose:     wxGauge class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "gauge.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/defs.h"
+#endif
+
+#if USE_GAUGE 
+
+#include "wx/gauge.h"
+#include "wx/msw/private.h"
+
+/* gas gauge graph control messages--class "zYzGauge" */
+#define ZYZG_SETRANGE       (WM_USER + 0)
+#define ZYZG_GETRANGE       (WM_USER + 1)
+#define ZYZG_SETPOSITION    (WM_USER + 2)
+#define ZYZG_GETPOSITION    (WM_USER + 3)
+#define ZYZG_SETORIENTATION (WM_USER + 4)
+#define ZYZG_GETORIENTATION (WM_USER + 5)
+#define ZYZG_SETFGCOLOR     (WM_USER + 6)
+#define ZYZG_GETFGCOLOR     (WM_USER + 7)
+#define ZYZG_SETBKCOLOR     (WM_USER + 8)
+#define ZYZG_GETBKCOLOR     (WM_USER + 9)
+#define ZYZG_SETWIDTH3D     (WM_USER + 10)
+#define ZYZG_GETWIDTH3D     (WM_USER + 11)
+#define ZYZG_SETBEZELFACE   (WM_USER + 12)
+#define ZYZG_GETBEZELFACE   (WM_USER + 13)
+#define ZYZG_SETDELTAPOS    (WM_USER + 14)
+
+
+/* orientations for ZYZG_WW_ORIENTATION */
+#define ZYZG_ORIENT_LEFTTORIGHT     0
+#define ZYZG_ORIENT_RIGHTTOLEFT     1
+#define ZYZG_ORIENT_BOTTOMTOTOP     2
+#define ZYZG_ORIENT_TOPTOBOTTOM     3
+
+
+/* gauge styles */
+#define ZYZGS_3D        0x8000L     /* control will be 3D       */
+
+/* public function prototypes */
+BOOL FAR PASCAL gaugeInit(HINSTANCE hInstance);
+
+#define USE_PROGRESS_BAR 1
+
+#if defined(__WIN95__) && !defined(__GNUWIN32__)
+#include <commctrl.h>
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
+#endif
+
+bool wxGauge::Create(wxWindow *parent, const wxWindowID id,
+           const int range,
+           const wxPoint& pos,
+           const wxSize& size,
+           const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  static bool wxGaugeInitialised = FALSE;
+
+  if ( !wxGaugeInitialised )
+  {
+    if (!gaugeInit((HWND) wxGetInstance()))
+    	wxFatalError("Cannot initalize Gauge library");
+	wxGaugeInitialised = TRUE;
+  }
+
+  SetName(name);
+  SetValidator(validator);
+
+  if (parent) parent->AddChild(this);
+  m_rangeMax = range;
+
+  SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
+  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+
+  m_useProgressBar = FALSE;
+  m_windowStyle = style;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  // Use the Win95 progress bar if possible, but not if
+  // we request a vertical gauge.
+#if defined(__WIN95__) && USE_PROGRESS_BAR
+  if ((m_windowStyle & wxGA_PROGRESSBAR) && ((m_windowStyle & wxGA_HORIZONTAL) == wxGA_HORIZONTAL))
+	m_useProgressBar = TRUE;
+#endif
+
+  if (m_useProgressBar)
+  {
+#if defined(__WIN95__) && USE_PROGRESS_BAR
+    long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
+
+    HWND wx_button =
+      CreateWindowEx(MakeExtendedStyle(m_windowStyle), PROGRESS_CLASS, NULL, msFlags,
+                    0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                    wxGetInstance(), NULL);
+
+    m_hWnd = (WXHWND)wx_button;
+
+    // Subclass again for purposes of dialog editing mode
+    SubclassWin((WXHWND) wx_button);
+
+    SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, range));
+#endif
+  }
+  else
+  {
+    long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
+/*  if (m_windowStyle & wxTHREED) */
+    msFlags |= ZYZGS_3D;
+
+    HWND wx_button =
+      CreateWindowEx(MakeExtendedStyle(m_windowStyle), "zYzGauge", NULL, msFlags,
+                    0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                    wxGetInstance(), NULL);
+
+    m_hWnd = (WXHWND)wx_button;
+
+    // Subclass again for purposes of dialog editing mode
+    SubclassWin((WXHWND)wx_button);
+
+    int wOrient = 0;
+
+    if (m_windowStyle & wxGA_HORIZONTAL)
+      wOrient = ZYZG_ORIENT_LEFTTORIGHT;
+    else
+      wOrient = ZYZG_ORIENT_BOTTOMTOTOP;
+  
+    SendMessage(wx_button, ZYZG_SETORIENTATION, wOrient, 0);
+    SendMessage(wx_button, ZYZG_SETRANGE, range, 0);
+
+    SendMessage((HWND) GetHWND(), ZYZG_SETFGCOLOR, 0, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+    SendMessage((HWND) GetHWND(), ZYZG_SETBKCOLOR, 0, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  }
+
+  SetFont(* parent->GetFont());
+
+  if (width == -1)
+    width = 50;
+  if (height == -1)
+    height = 50;
+  SetSize(x, y, width, height);
+
+  ShowWindow((HWND) GetHWND(), SW_SHOW);
+
+  return TRUE;
+}
+
+void wxGauge::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+  int x1 = x;
+  int y1 = y;
+  int w1 = width;
+  int h1 = height;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  float control_width, control_height, control_x, control_y;
+
+  // If we're prepared to use the existing size, then...
+  if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
+  {
+    GetSize(&x1, &y1);
+  }
+
+  // Deal with default size (using -1 values)
+  if (width<=0)
+    w1 = DEFAULT_ITEM_WIDTH;
+
+  if (height<=0)
+    h1 = DEFAULT_ITEM_HEIGHT;
+
+  control_x = (float)x1;
+  control_y = (float)y1;
+  control_width = (float)w1;
+  control_height = (float)h1;
+
+  MoveWindow((HWND) GetHWND(), (int)control_x, (int)control_y, (int)control_width, (int)control_height, TRUE);
+
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+}
+
+void wxGauge::SetShadowWidth(const int w)
+{
+  if (m_useProgressBar)
+  {
+  }
+  else
+    SendMessage((HWND) GetHWND(), ZYZG_SETWIDTH3D, w, 0);
+}
+
+void wxGauge::SetBezelFace(const int w)
+{
+  if (m_useProgressBar)
+  {
+  }
+  else
+    SendMessage((HWND) GetHWND(), ZYZG_SETBEZELFACE, w, 0);
+}
+
+void wxGauge::SetRange(const int r)
+{
+  m_rangeMax = r;
+
+#if defined(__WIN95__) && USE_PROGRESS_BAR
+  if (m_useProgressBar)
+    SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
+  else
+#endif
+    SendMessage((HWND) GetHWND(), ZYZG_SETRANGE, r, 0);
+}
+
+void wxGauge::SetValue(const int pos)
+{
+  m_gaugePos = pos;
+
+#if defined(__WIN95__) && USE_PROGRESS_BAR
+  if (m_useProgressBar)
+    SendMessage((HWND) GetHWND(), PBM_SETPOS, pos, 0);
+  else
+#endif
+    SendMessage((HWND) GetHWND(), ZYZG_SETPOSITION, pos, 0);
+}
+
+int wxGauge::GetShadowWidth(void) const
+{
+  if (m_useProgressBar)
+    return 0;
+  else
+    return (int) SendMessage((HWND) GetHWND(), ZYZG_GETWIDTH3D, 0, 0);
+}
+
+int wxGauge::GetBezelFace(void) const
+{
+  if (m_useProgressBar)
+    return 0;
+  else
+    return (int) SendMessage((HWND) GetHWND(), ZYZG_GETBEZELFACE, 0, 0);
+}
+
+int wxGauge::GetRange(void) const
+{
+  if (m_useProgressBar)
+    return m_rangeMax;
+  else
+    return (int) SendMessage((HWND) GetHWND(), ZYZG_GETRANGE, 0, 0);
+}
+
+int wxGauge::GetValue(void) const
+{
+  if (m_useProgressBar)
+    return m_gaugePos;
+  else
+    return (int) SendMessage((HWND) GetHWND(), ZYZG_GETPOSITION, 0, 0);
+}
+
+void wxGauge::SetForegroundColour(const wxColour& col)
+{
+	m_foregroundColour = col ;
+  if (m_useProgressBar)
+  {
+  }
+  else
+    SendMessage((HWND) GetHWND(), ZYZG_SETFGCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
+}
+
+void wxGauge::SetBackgroundColour(const wxColour& col)
+{
+	m_backgroundColour = col ;
+  if (m_useProgressBar)
+  {
+  }
+  else
+    SendMessage((HWND) GetHWND(), ZYZG_SETBKCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
+}
+
+
+/** zyz3d.c
+ *
+ *  DESCRIPTION: 
+ *      This module contains functions for creating nifty 3D borders
+ *      around controls like zYzGauge.
+ *
+ *  HISTORY:
+ *      3/14/91     cjp     put in this comment
+ *      6/19/92     cjp     touched it a bit
+ *
+ ** cjp */
+// COPYRIGHT:
+//
+//   (C) Copyright Microsoft Corp. 1992.  All rights reserved.
+//
+//   You have a royalty-free right to use, modify, reproduce and
+//   distribute the Sample Files (and/or any modified version) in
+//   any way you find useful, provided that you agree that
+//   Microsoft has no warranty obligations or liability for any
+//   Sample Application Files which are modified.
+//
+
+
+/* get the includes we need */
+#include <windows.h>
+
+/* misc. control flag defines */
+#define DRAW3D_IN           0x0001
+#define DRAW3D_OUT          0x0002
+
+#define DRAW3D_TOPLINE      0x0004
+#define DRAW3D_BOTTOMLINE   0x0008
+#define DRAW3D_LEFTLINE     0x0010
+#define DRAW3D_RIGHTLINE    0x0020
+
+
+/* public function prototypes */
+void FAR PASCAL Draw3DFaceFrame(HDC, LPRECT, WORD);
+void FAR PASCAL Draw3DRect(HDC, LPRECT, WORD, WORD);
+void FAR PASCAL Draw3DLine(HDC, WORD, WORD, WORD, WORD, WORD);
+
+
+/** void FAR PASCAL Draw3DFaceFrame(HDC hdc, LPRECT rc, WORD wWidth)
+ *
+ *  DESCRIPTION: 
+ *      This function draws a flat frame with the current button-face
+ *      color.
+ *
+ *  ARGUMENTS:
+ *      HDC hdc     :   The DC to draw into.
+ *
+ *      LPRECT rc   :   The containing rect for the new frame.
+ *
+ *      WORD wWidth :   The width of the frame to draw.
+ *
+ *  RETURN (void FAR PASCAL):
+ *      The frame will have been drawn into the DC.
+ *
+ *  NOTES:
+ *
+ ** cjp */
+
+void FAR PASCAL Draw3DFaceFrame(HDC hdc, LPRECT rc, WORD wWidth)
+{
+    RECT    rc1;
+    DWORD   rgbOld;
+
+    /* don't go through a bunch of work if we don't have to */
+    if (!wWidth)
+        return;
+
+    /* set up color to be button-face color--so it may not be gray */
+    rgbOld = SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
+
+    /* perform CopyRect w/o bloody windows style overhead */
+    rc1 = *rc;
+
+    /* top */
+    rc1.top = rc->top;
+    rc1.left = rc->left;
+    rc1.bottom = rc->top + wWidth;
+    rc1.right = rc->right;
+
+    /* blast it out */
+    ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
+
+    /* right */
+    rc1.left = rc->right - wWidth;
+    rc1.bottom = rc->bottom;
+
+    /* blast this part now */
+    ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
+
+    /* left */
+    rc1.left = rc->left;
+    rc1.right = rc->left + wWidth;
+
+    /* and another part */
+    ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
+
+    /* bottom */
+    rc1.right = rc->right;
+    rc1.top = rc->bottom - wWidth;
+
+    /* finish it off */
+    ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
+
+    /* restore the old bk color */
+    SetBkColor(hdc, rgbOld);
+} /* Draw3DFaceFrame() */
+
+
+/** void FAR PASCAL Draw3DRect(HDC, LPRECT, WORD, WORD)
+ *
+ *  DESCRIPTION: 
+ *      Draws a 3D rectangle that is shaded.  wFlags can be used to
+ *      control how the rectangle looks.
+ *
+ *  ARGUMENTS:
+ *      HDC hdc             :   Handle to the device context that will be
+ *                              used to display the rectangle.
+ *
+ *      RECT rect           :   A rectangle describing the dimensions of
+ *                              the rectangle in device coordinates.
+ *
+ *      WORD wShadowWidth   :   Width of the shadow in device coordinates.
+ *
+ *      WORD wFlags         :   The following flags may be passed to describe
+ *                              the style of the rectangle:
+ *
+ *                              DRAW3D_IN   :   The shadow is drawn such that
+ *                              the box appears to be sunk in to the screen.
+ *                              This is default if 0 is passed.
+ *
+ *                              DRAW3D_OUT  :   The shadow is drawn such that
+ *                              the box appears to be sticking out of the
+ *                              screen.
+ *
+ *  RETURN (void FAR PASCAL):
+ *      The 3D looking rectangle will have been drawn into the DC.
+ *
+ *  NOTES:
+ *
+ ** cjp */
+
+void FAR PASCAL Draw3DRect(HDC hdc, LPRECT lpRect,
+                               WORD wShadowWidth, WORD wFlags)
+{
+    /* sanity check--don't work if you don't have to! */
+    if (!wShadowWidth || !RectVisible(hdc, lpRect))
+        return;
+
+    /* draw the top line */
+    Draw3DLine(hdc, lpRect->left, lpRect->top,
+                    lpRect->right - lpRect->left,
+                    wShadowWidth, DRAW3D_TOPLINE | wFlags);
+
+    /* right line */
+    Draw3DLine(hdc, lpRect->right, lpRect->top,
+                    lpRect->bottom - lpRect->top,
+                    wShadowWidth, DRAW3D_RIGHTLINE | wFlags);
+
+    /* bottom line */
+    Draw3DLine(hdc, lpRect->left, lpRect->bottom,
+                    lpRect->right - lpRect->left,
+                    wShadowWidth, DRAW3D_BOTTOMLINE | wFlags);
+
+    /* left line */
+    Draw3DLine(hdc, lpRect->left, lpRect->top,
+                    lpRect->bottom - lpRect->top,
+                    wShadowWidth, DRAW3D_LEFTLINE | wFlags);
+} /* Draw3DRect() */
+
+
+/** void FAR PASCAL Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
+ *
+ *  DESCRIPTION: 
+ *      Draws a 3D line that can be used to make a 3D box.
+ *
+ *  ARGUMENTS:
+ *      HDC hdc             :   Handle to the device context that will be
+ *                              used to display the 3D line.
+ *
+ *      WORD x, y           :   Coordinates of the beginning of the line.
+ *                              These coordinates are in device units and
+ *                              represent the _outside_ most point. Horiz-
+ *                              ontal lines are drawn from left to right and
+ *                              vertical lines are drawn from top to bottom.
+ *
+ *      WORD wShadowWidth   :   Width of the shadow in device coordinates.
+ *
+ *      WORD  wFlags        :   The following flags may be passed to
+ *                              describe the style of the 3D line:
+ *
+ *                              DRAW3D_IN   :   The shadow is drawn such that
+ *                              the box appears to be sunk in to the screen.
+ *                              This is default if 0 is passed.
+ *
+ *                              DRAW3D_OUT  :   The shadow is drawn such that
+ *                              the box appears to be sticking out of the
+ *                              screen.
+ *
+ *                              DRAW3D_TOPLINE, _BOTTOMLINE, _LEFTLINE, and
+ *                              _RIGHTLINE  :   Specifies that a "top",
+ *                              "Bottom", "Left", or"Right" line is to be
+ *                              drawn.
+ *
+ *  RETURN (void FAR PASCAL):
+ *      The line will have been drawn into the DC.
+ *
+ *  NOTES:
+ *
+ ** cjp */
+
+void FAR PASCAL Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
+                               WORD wShadowWidth, WORD wFlags) 
+{
+    HBRUSH  hOldBrush;
+    HPEN    hOldPen;
+    BOOL    fDark;
+    POINT   Point[ 4 ];         /* define a polgon with 4 points    */
+
+    /* if width is zero, don't do nothin'! */
+    if (!wShadowWidth)
+        return;
+
+    /* define shape of polygon--origin is always the same */
+    Point[0].x = x;
+    Point[0].y = y;
+
+    /*  To do this we'll simply draw a polygon with four sides, using 
+     *  the appropriate brush.  I dare you to ask me why this isn't a
+     *  switch/case!
+     */
+    if (wFlags & DRAW3D_TOPLINE)
+    {
+        /* across to right */
+        Point[1].x = x + nLen - (wShadowWidth == 1 ? 1 : 0);
+        Point[1].y = y;
+
+        /* down/left */
+        Point[2].x = x + nLen - wShadowWidth;
+        Point[2].y = y + wShadowWidth;
+
+        /* accross to left */
+        Point[3].x = x + wShadowWidth;
+        Point[3].y = y + wShadowWidth;
+
+        /* select 'dark' brush if 'in'--'light' for 'out' */
+        fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE;
+    }
+
+    /* possibly the bottom? */
+    else if (wFlags & DRAW3D_BOTTOMLINE)
+    {
+        /* across to right */
+        Point[1].x = x + nLen;
+        Point[1].y = y;
+
+        /* up/left */
+        Point[2].x = x + nLen - wShadowWidth;
+        Point[2].y = y - wShadowWidth;
+
+        /* accross to left */
+        Point[3].x = x + wShadowWidth;
+        Point[3].y = y - wShadowWidth;
+
+        /* select 'light' brush if 'in' */
+        fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE;
+    }
+
+    /* ok, it's gotta be left? */
+    else if (wFlags & DRAW3D_LEFTLINE)
+    {
+        /* down */
+        Point[1].x = x;
+        Point[1].y = y + nLen - (wShadowWidth == 1 ? 1 : 0);
+
+        /* up/right */
+        Point[2].x = x + wShadowWidth;
+        Point[2].y = y + nLen - wShadowWidth;
+
+        /* down */
+        Point[3].x = x + wShadowWidth;
+        Point[3].y = y + wShadowWidth;
+
+        /* select 'dark' brush if 'in'--'light' for 'out' */
+        fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE;
+    }
+    
+    /* well maybe it's for the right side? */
+    else if (wFlags & DRAW3D_RIGHTLINE)
+    {
+        /* down */
+        Point[1].x = x;
+        Point[1].y = y + nLen;
+
+        /* up/left */
+        Point[2].x = x - wShadowWidth;
+        Point[2].y = y + nLen - wShadowWidth;
+
+        /* up */
+        Point[3].x = x - wShadowWidth;
+        Point[3].y = y + wShadowWidth;
+
+        /* select 'light' brush if 'in' */
+        fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE;
+    }
+
+    /* bad drugs? */
+    else return;
+
+    /* select NULL_PEN for no borders */
+    hOldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
+
+    /* select the appropriate color for the fill */
+    if (fDark)
+        hOldBrush = SelectObject(hdc, GetStockObject(GRAY_BRUSH));
+    else
+        hOldBrush = SelectObject(hdc, GetStockObject(WHITE_BRUSH));
+
+    /* finally, draw the dern thing */
+    Polygon(hdc, (LPPOINT)&Point, 4);
+
+    /* restore what we killed */
+    SelectObject(hdc, hOldBrush);
+    SelectObject(hdc, hOldPen);
+} /* Draw3DLine() */
+
+/** EOF: zyz3d.c **/
+
+/** zyzgauge.c
+ *
+ *  DESCRIPTION: 
+ *      Yet another 'Gas Gauge Custom Control.'  This control gives you
+ *      a 'progress bar' class (named zYzGauge) for use in your applications.
+ *      You can set the range, position, font, color, orientation, and 3d
+ *      effect of the gauge by sending messages to the control.
+ *
+ *      Before you can use this control, you MUST first export the window
+ *      procedure for the control (or define it with the _export keyword):
+ *
+ *          EXPORTS     gaugeWndProc
+ *
+ *      You then need initialize the class before you use it:
+ *
+ *          if (!gaugeInit(hInstance))
+ *              die a horrible death
+ *          else
+ *              you are good to go
+ *
+ *      The colors used by the control default to black and white if you
+ *      are running on a mono-display.  They default to blue and white
+ *      if you are on a color display.  You enable the 3D effect by setting
+ *      the ZYZGS_3D style flag in the styles field of the control (like
+ *      any other control).
+ *
+ *      To select your own colors, you can send the ZYZG_SETFGCOLOR and
+ *      ZYZG_SETBKCOLOR messages to set the foreground (percent done) and
+ *      background (percent not done) colors.  The lParam is the RGB()
+ *      value--wParam is ignored.
+ *
+ *      In all of the following ZYZG_??? messages, the arguments are
+ *      WORDS.  If you are setting parameters, the value is sent as
+ *      the wParam (lParam is ignored).  If you are getting parameters,
+ *      the value is returned as a LONG and should be cast to a *signed*
+ *      integer.
+ *
+ *      To set the depth of the 3D effect (if enabled), you can send the
+ *      ZYZG_SETBEZELFACE and ZYZG_SETWIDTH3D messages.  The bezel face
+ *      is the flat top on the 3D border--its color will be that of the
+ *      button-face.  The 3D width is the width of the bezel itself; inside
+ *      and outside.  The light color is white, the dark color is gray.
+ *      Both widths *can* be zero--both default to 2 which looks to me.
+ *
+ *      The range of the control can be set by sending the ZYZG_SETRANGE
+ *      message to the control.  It can be any integer from 1 to 32767.
+ *      What this specifies is the number of pieces that create a whole.
+ *      The default is 100.  You can get the current range setting by
+ *      sending the ZYZG_GETRANGE message to the control.
+ *
+ *      The position (number of pieces out of the whole have been used) is
+ *      set with the ZYZG_SETPOSITION message.  It can be any integer from
+ *      0 to the current range setting of the control--it will be clipped
+ *      if the position is out of bounds.  The default position is 0.  You
+ *      can get the current position at any time with the ZYZG_GETPOSITION
+ *      message.
+ *
+ *      You can also set the range using a delta from the current range.
+ *      This is done by sending the ZYZG_SETDELTAPOS message with wParam
+ *      set to a _signed_ integer value within the range of the control.
+ *
+ *      The font used for the percentage text can be set using the standard
+ *      WM_SETFONT message.  You can get the current font at any time with
+ *      the WM_GETFONT message.
+ *
+ *      The orientation can be left to right, right to left, bottom to top,
+ *      or top to bottom.  Whatever suits your needs.  You set this by
+ *      sending the ZYZG_ORIENTATION message to the control with one of
+ *      the following values (default is ZYZG_ORIENT_LEFTTORIGHT):
+ *
+ *          ZYZG_ORIENT_LEFTTORIGHT (0)
+ *          ZYZG_ORIENT_RIGHTTOLEFT (1)
+ *          ZYZG_ORIENT_BOTTOMTOTOP (2)
+ *          ZYZG_ORIENT_TOPTOBOTTOM (3)
+ *
+ *  HISTORY:
+ *      3/12/91     cjp     put in this comment
+ *      6/19/92     cjp     touched it a bit
+ *
+ ** cjp */
+// COPYRIGHT:
+//
+//   (C) Copyright Microsoft Corp. 1992.  All rights reserved.
+//
+//   You have a royalty-free right to use, modify, reproduce and
+//   distribute the Sample Files (and/or any modified version) in
+//   any way you find useful, provided that you agree that
+//   Microsoft has no warranty obligations or liability for any
+//   Sample Application Files which are modified.
+//
+
+
+/* get the includes we need */
+#ifndef __GNUWIN32__
+#include <malloc.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+// #include "zyz3d.h"
+// #include "zyzgauge.h"
+
+
+/* static global variables */
+static char gszzYzGaugeClass[] = "zYzGauge";
+    
+
+/* window word position definitions */
+#define ZYZG_WW_PZYZGAUGE   0
+/* #define ZYZG_WW_EXTRABYTES  2 */
+#define ZYZG_WW_EXTRABYTES  4
+
+
+/* control block structure typedef */
+typedef struct tZYZGAUGE
+{
+    WORD    wRange;
+    WORD    wPosition;
+    WORD    wOrientation;
+    WORD    wWidth3D;
+    WORD    wWidthBezelFace;
+    HFONT   hFont;
+    DWORD   rgbTextColor;
+    DWORD   rgbBkColor;
+
+} ZYZGAUGE, *PZYZGAUGE, FAR *LPZYZGAUGE;
+
+
+/* some default values for the control */
+#define ZYZG_DEF_RANGE          100
+#define ZYZG_DEF_POSITION       0
+#define ZYZG_DEF_ORIENTATION    ZYZG_ORIENT_LEFTTORIGHT
+#define ZYZG_DEF_WIDTH3D        2
+#define ZYZG_DEF_BEZELFACE      2
+
+
+
+/* the default settings for drawing colors--display dependent */
+static DWORD    rgbDefTextColor;
+static DWORD    rgbDefBkColor;
+static BOOL     fSupport3D;
+
+#if !defined(APIENTRY)	// NT defines APIENTRY, 3.x not
+#define APIENTRY FAR PASCAL
+#endif
+ 
+#ifdef __WIN32__
+#define _EXPORT /**/
+#else
+#define _EXPORT _export
+typedef signed short int SHORT ;
+#endif
+
+/* internal function prototypes */
+static void PASCAL gaugePaint(HWND, HDC);
+/* LRESULT FAR PASCAL */
+LRESULT APIENTRY _EXPORT gaugeWndProc(HWND, UINT, WPARAM, LPARAM);
+
+
+
+/** BOOL FAR PASCAL gaugeInit(HINSTANCE hInstance)
+ *
+ *  DESCRIPTION: 
+ *      Registers the window class for the zYzGauge control.  Performs
+ *      other initialization for the zYzGauge text control.  This must
+ *      be done before the zYzGauge control is used--or it will fail
+ *      and your dialog box will not open!
+ *
+ *  ARGUMENTS:
+ *      HINSTANCE hInstance :   Instance handle to register class with.
+ *
+ *  RETURN (BOOL FAR):
+ *      The return value is TRUE if the zYzGauge class was successfully
+ *      registered.  It is FALSE if the initialization fails.
+ *
+ *  NOTES:
+ *
+ ** cjp */
+
+//#pragma alloc_text(init, gaugeInit)
+
+BOOL FAR PASCAL gaugeInit(HINSTANCE hInstance)
+{
+    static BOOL fRegistered = FALSE;
+    WNDCLASS    wc;
+    HDC         hdc;
+    
+    /* assume already registered if not first instance */
+    if (fRegistered)
+        return (TRUE);
+
+    /* fill in the class structure for the zyzgauge control */
+    wc.hCursor          = LoadCursor(NULL, IDC_ARROW);
+    wc.hIcon            = NULL;
+    wc.lpszMenuName     = NULL;
+    wc.lpszClassName    = gszzYzGaugeClass;
+    wc.hbrBackground    = (HBRUSH)(COLOR_WINDOW + 1);
+    wc.hInstance        = hInstance;
+
+#ifdef ZYZGAUGE_DLL
+    wc.style            = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW;
+#else
+    wc.style            = CS_HREDRAW | CS_VREDRAW;
+#endif
+
+    wc.lpfnWndProc      = gaugeWndProc;
+    wc.cbClsExtra       = 0;
+    wc.cbWndExtra       = ZYZG_WW_EXTRABYTES;
+
+    /* attempt to register it--return FALSE if fail */
+    if (!RegisterClass(&wc))
+        return (FALSE);
+
+    /*  Get a DC to determine whether device is mono or not, and set
+     *  default foreground/background colors as appropriate.
+     */
+    if ((hdc = CreateIC("DISPLAY", NULL, NULL, 0L)))
+    {
+        /* check for mono-display */
+        if ((GetDeviceCaps(hdc, BITSPIXEL) == 1) &&
+             (GetDeviceCaps(hdc, PLANES) == 1))
+        {
+            /* using a mono DC--white foreground, black background */
+            rgbDefTextColor = RGB(255, 255, 255);
+            rgbDefBkColor = RGB(0, 0, 0);
+        }
+
+        /* good! we have color: blue foreground, white background */
+        else 
+        {
+            rgbDefTextColor = RGB(0, 0, 255);
+            rgbDefBkColor = RGB(255, 255, 255);
+        }
+
+        /* need at _least_ 8 for two shades of gray (>=VGA) */
+        fSupport3D = (GetDeviceCaps(hdc, NUMCOLORS) >= 8) ? TRUE : FALSE;
+
+        /* get rid of the DC (IC) */
+        DeleteDC(hdc);
+    }
+
+    /* uh-oh... can't get DC (IC)... fail */
+    else
+    {
+        /* unregister the class */
+        UnregisterClass(gszzYzGaugeClass, hInstance);
+        return (FALSE);
+    }
+
+    /* return success */
+    return (fRegistered = TRUE);
+} /* gaugeInit() */
+
+
+/** static void PASCAL gaugePaint(HWND hwnd, HDC hdc)
+ *
+ *  DESCRIPTION: 
+ *      This function is responsible for painting the zYzGauge control.
+ *
+ *  ARGUMENTS:
+ *      HWND hwnd   :   The window handle for the gauge.
+ *
+ *      HDC hdc     :   The DC for the gauge's window.
+ *
+ *  RETURN (void):
+ *      The control will have been painted.
+ *
+ *  NOTES:
+ *
+ ** cjp */
+
+static void PASCAL gaugePaint(HWND hwnd, HDC hdc)
+{
+    PZYZGAUGE   pgauge;
+    WORD        iRange, iPos;
+    WORD        Offset = 1;
+    DWORD       dwExtent;
+    RECT        rc1, rc2;
+    HFONT       hFont;
+    char        ach[ 6 ];
+    WORD        dx, dy, wGomerX, wGomerY;
+/* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead,
+ * which needs a SIZE* parameter */
+#if defined(__WIN32__)
+    SIZE size;
+#endif
+
+    /* get pointer to the control's control block */
+//    pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE);
+    pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE);
+
+    /* set the colors into for the gauge into the control */
+    SetTextColor(hdc, pgauge->rgbTextColor);
+    SetBkColor(hdc, pgauge->rgbBkColor);
+
+    /* draw black rectangle for gauge */
+    GetClientRect(hwnd, &rc1);
+
+    /* draw a black border on the _outside_ */
+    FrameRect(hdc, &rc1, GetStockObject(BLACK_BRUSH));
+
+    /* we want to draw _just inside_ the black border */
+    InflateRect(&rc1, -1, -1);
+
+    /* one line thick so far... */
+//    Offset = (WORD) 1;
+
+    /* for 3D stuff, we need to have at least two shades of gray */
+    if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D)
+    {
+        Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_OUT);
+	InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D));
+
+        Draw3DFaceFrame(hdc, &rc1, pgauge->wWidthBezelFace);
+	InflateRect(&rc1, ~(pgauge->wWidthBezelFace), ~(pgauge->wWidthBezelFace));
+
+        Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_IN);
+	InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D));
+
+        /* draw a black border on the _inside_ */
+        FrameRect(hdc, &rc1, GetStockObject(BLACK_BRUSH));
+
+        /* we want to draw _just inside_ the black border */
+        InflateRect(&rc1, -1, -1);
+
+        /* add all the other pixels into the border width */
+        Offset += (2 * pgauge->wWidth3D) + pgauge->wWidthBezelFace + 1;
+    }
+   
+    /* dup--one rc for 'how much filled', one rc for 'how much empty' */
+    rc2 = rc1;
+
+    /* get the range--make sure it's a valid range */
+    if ((iRange = pgauge->wRange) <= 0)
+        iRange = 1;
+
+    /* get the position--greater than 100% would be bad */
+    if ((iPos = pgauge->wPosition) > iRange)
+        iPos = iRange;
+
+    /* compute the actual size of the gauge */
+    dx = rc1.right - rc1.left;
+    dy = rc1.bottom - rc1.top;
+    wGomerX = (WORD)((DWORD)iPos * dx / iRange);
+    wGomerY = (WORD)((DWORD)iPos * dy / iRange);
+
+    /* get the orientation and munge rects accordingly */
+    switch (pgauge->wOrientation)
+    {
+        case ZYZG_ORIENT_RIGHTTOLEFT:
+            rc1.left = rc2.right = rc1.right - wGomerX;
+            break;
+
+        case ZYZG_ORIENT_BOTTOMTOTOP:
+            rc1.top = rc2.bottom = rc1.bottom - wGomerY;
+            break;
+
+        case ZYZG_ORIENT_TOPTOBOTTOM:
+            rc1.bottom = rc2.top += wGomerY;
+            break;
+
+        default:
+            rc1.right = rc2.left += wGomerX;
+            break;
+    } /* switch () */
+
+    /* select the correct font */
+    hFont = SelectObject(hdc, pgauge->hFont);
+
+    /* build up a string to blit out--ie the meaning of life: "42%" */
+    wsprintf(ach, "%3d%%", (WORD)((DWORD)iPos * 100 / iRange));
+/* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead */
+#if defined(__WIN32__)
+    GetTextExtentPoint(hdc, ach, wGomerX = lstrlen(ach), &size);
+    dwExtent = size.cx;
+#else
+    dwExtent = GetTextExtent(hdc, ach, wGomerX = lstrlen(ach));
+#endif  
+
+
+    /*  Draw the finished (ie the percent done) side of box.  If
+     *  ZYZG_WW_POSITION is 42, (in range of 0 to 100) this ExtTextOut
+     *  draws the meaning of life (42%) bar.
+     */
+    ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset,
+                    (dy - HIWORD(dwExtent)) / 2 + Offset,
+                    ETO_OPAQUE | ETO_CLIPPED, &rc2, ach, wGomerX, NULL);
+
+    /*  Reverse fore and back colors for drawing the undone (ie the non-
+     *  finished) side of the box.
+     */
+    SetBkColor(hdc, pgauge->rgbTextColor);
+    SetTextColor(hdc, pgauge->rgbBkColor);
+
+    ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset,
+                    (dy - HIWORD(dwExtent)) / 2 + Offset,
+                    ETO_OPAQUE | ETO_CLIPPED, &rc1, ach, wGomerX, NULL);
+
+    /* unselect the font */
+    SelectObject(hdc, hFont);
+} /* gaugePaint() */
+  
+
+/** LRESULT FAR PASCAL gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+ *
+ *  DESCRIPTION: 
+ *      This is the control's window procedure.  Its purpose is to handle
+ *      special messages for this custom control.
+ *
+ *      The special control messages for the gauge control are:
+ *
+ *          ZYZG_SETRANGE       :   Sets the range of the gauge.  In other
+ *                                  words, the number of parts that make a
+ *                                  whole.
+ *
+ *          ZYZG_GETRANGE       :   Returns the current range of the gauge.
+ *
+ *          ZYZG_SETORIENTATION :   Sets the orientation of the gauge.  This
+ *                                  can be one of the ZYZG_ORIENT_?? msgs.
+ *
+ *          ZYZG_GETORIENTATION :   Gets the current orientation of the 
+ *                                  gauge.
+ *
+ *          ZYZG_SETPOSITION    :   Sets the current position of the gauge.
+ *                                  In other words, how many pieces of the
+ *                                  whole have been used.
+ *
+ *          ZYZG_GETPOSITION    :   Gets the current position of the gauge.
+ *
+ *          ZYZG_SETDELTAPOS    :   Sets the position of the gauge +/- the
+ *                                  specified amount.
+ *
+ *          ZYZG_SETFGCOLOR     :   Sets the foreground (percent done) color.
+ *
+ *          ZYZG_GETFGCOLOR     :   Gets the foreground (percent done) color.
+ *
+ *          ZYZG_SETBKCOLOR     :   Sets the background (percent not done)
+ *                                  color.
+ *
+ *          ZYZG_GETBKCOLOR     :   Gets the background (percent not done)
+ *                                  color.
+ *
+ *          WM_SETFONT          :   Sets the font to use for the percentage
+ *                                  text of the gauge.
+ *
+ *          WM_GETFONT          :   Gets the current font in use by the
+ *                                  gauge.
+ *
+ *  NOTES:
+ *
+ ** cjp */
+
+/* LRESULT FAR PASCAL */
+
+LRESULT APIENTRY _EXPORT gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    HFONT       hFont;
+    PAINTSTRUCT ps;
+    PZYZGAUGE   pgauge;
+    RECT        rc;
+
+//    pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE);
+    pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE);
+
+    /* break to get DefWindowProc() */
+    switch (uMsg)
+    {
+        case WM_CREATE:
+            /* need to allocate a control block */
+//            pgauge = (PZYZGAUGE)LocalAlloc(LPTR, sizeof(ZYZGAUGE));
+            pgauge = (PZYZGAUGE)malloc(sizeof(ZYZGAUGE));
+            if (!pgauge)
+                return (0L);
+
+            /* hang on to this control block */
+//            SetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE, (WORD)pgauge);
+            SetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE, (LONG)pgauge);
+
+            /* fill control block with defaults */
+            pgauge->wRange           = ZYZG_DEF_RANGE;
+            pgauge->wPosition        = ZYZG_DEF_POSITION;
+            pgauge->wOrientation     = ZYZG_DEF_ORIENTATION;
+            pgauge->wWidth3D         = ZYZG_DEF_WIDTH3D;
+            pgauge->wWidthBezelFace  = ZYZG_DEF_BEZELFACE;
+            pgauge->rgbTextColor     = rgbDefTextColor;
+            pgauge->rgbBkColor       = rgbDefBkColor;
+
+            /* use system font */
+            SendMessage(hwnd, WM_SETFONT, (WPARAM)NULL, 0L);
+
+            /* go to DefWindowProc() to finish the job */
+            break;
+
+        case WM_DESTROY:
+            /* get rid of the control's memory */
+            if (pgauge)
+//                LocalFree((HANDLE)pgauge);
+                free(pgauge);
+            break;
+
+        case ZYZG_GETPOSITION:
+            return (pgauge->wPosition);
+
+        case ZYZG_GETRANGE:
+            return (pgauge->wRange);
+
+        case ZYZG_GETORIENTATION:
+            return (pgauge->wOrientation);
+
+        case ZYZG_GETWIDTH3D:
+            return (pgauge->wWidth3D);
+
+        case ZYZG_GETBEZELFACE:
+            return (pgauge->wWidthBezelFace);
+
+        case ZYZG_GETBKCOLOR:
+            return (pgauge->rgbTextColor);
+
+        case ZYZG_GETFGCOLOR:
+            return (pgauge->rgbBkColor);
+
+        case ZYZG_SETBKCOLOR:
+            pgauge->rgbBkColor = lParam;
+            return (0L);
+
+        case ZYZG_SETFGCOLOR:
+            pgauge->rgbTextColor = lParam;
+            return (0L);
+
+
+        case ZYZG_SETPOSITION:
+            pgauge->wPosition = wParam;
+
+zyzgForceRepaint:
+            GetClientRect(hwnd, &rc);
+            if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D)
+            {
+                wParam = (2 * pgauge->wWidth3D) +
+                            pgauge->wWidthBezelFace + 2;
+            }
+
+            else
+                wParam = 1;
+
+	    InflateRect(&rc, ~(wParam), ~(wParam));
+            InvalidateRect(hwnd, &rc, FALSE);
+            UpdateWindow(hwnd);
+            return (0L);
+
+        case ZYZG_SETRANGE:
+            pgauge->wRange = wParam;
+            goto zyzgForceRepaint;
+
+        case ZYZG_SETORIENTATION:
+            pgauge->wOrientation = wParam;
+            goto zyzgForceRepaint;
+
+        case ZYZG_SETWIDTH3D:
+            pgauge->wWidth3D = wParam;
+
+zyzgForceRepaint3D:
+            InvalidateRect(hwnd, NULL, FALSE);
+            UpdateWindow(hwnd);
+            return (0L);
+
+        case ZYZG_SETBEZELFACE:
+            pgauge->wWidthBezelFace = wParam;
+            goto zyzgForceRepaint3D;
+
+        case ZYZG_SETDELTAPOS:
+/* Watcom doesn't like the following line so removing typecasts */
+/*            (int)pgauge->wPosition += (int)wParam; */
+            pgauge->wPosition += wParam;
+            goto zyzgForceRepaint;
+
+        case WM_PAINT:
+            BeginPaint(hwnd, &ps);
+            gaugePaint(hwnd, ps.hdc);
+            EndPaint(hwnd, &ps);
+            return (0L);
+
+        case WM_GETFONT:
+            hFont = pgauge->hFont;
+
+            /* if system font, then return NULL handle */
+            return (long)((hFont == GetStockObject(SYSTEM_FONT)) ? NULL : hFont);
+
+        case WM_SETFONT:
+            /* if NULL hFont, use system font */
+            if (!(hFont = (HFONT)wParam))
+                hFont = GetStockObject(SYSTEM_FONT);
+
+            pgauge->hFont = hFont;
+
+            /* redraw if indicated in message */
+            if ((BOOL)lParam)
+            {
+                InvalidateRect(hwnd, NULL, TRUE);
+                UpdateWindow(hwnd);
+            }
+            return (0L);
+    } /* switch () */
+
+    /* let the dialog mangler take care of this message */
+    return (DefWindowProc(hwnd, uMsg, wParam, lParam));
+} /* gaugeWndProc() */
+
+
+/** EOF: zyzgauge.c **/
+
+#endif // USE_GAUGE
diff --git a/src/msw/gdiobj.cpp b/src/msw/gdiobj.cpp
new file mode 100644
index 0000000000..3a10a3fefe
--- /dev/null
+++ b/src/msw/gdiobj.cpp
@@ -0,0 +1,68 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        gdiobj.cpp
+// Purpose:     wxGDIObject class
+// Author:      Julian Smart
+// Modified by:
+// Created:     01/02/97
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "gdiobj.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/list.h"
+#include "wx/utils.h"
+#include "wx/app.h"
+#endif
+
+#include "wx/gdiobj.h"
+#include "wx/msw/private.h"
+#include "assert.h"
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
+#endif
+
+/*
+void wxGDIObject::IncrementResourceUsage(void)
+{
+	if ( !M_GDIDATA )
+		return;
+
+//  wxDebugMsg("Object %ld about to be incremented: %d\n", (long)this, m_usageCount);
+  M_GDIDATA->m_usageCount ++;
+};
+
+void wxGDIObject::DecrementResourceUsage(void)
+{
+	if ( !M_GDIDATA )
+		return;
+
+  M_GDIDATA->m_usageCount --;
+  if (wxTheApp)
+    wxTheApp->SetPendingCleanup(TRUE);
+//  wxDebugMsg("Object %ld decremented: %d\n", (long)this, M_GDIDATA->m_usageCount);
+  if (M_GDIDATA->m_usageCount < 0)
+  {
+    char buf[80];
+    sprintf(buf, "Object %ld usage count is %d\n", (long)this, M_GDIDATA->m_usageCount);
+    wxDebugMsg(buf);
+  }
+//  assert(M_GDIDATA->m_usageCount >= 0);
+};
+
+*/
+
diff --git a/src/msw/helpwin.cpp b/src/msw/helpwin.cpp
new file mode 100644
index 0000000000..07d27cdf58
--- /dev/null
+++ b/src/msw/helpwin.cpp
@@ -0,0 +1,142 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        helpwin.cpp
+// Purpose:     Help system: WinHelp implementation
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "helpwin.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/defs.h"
+#endif
+
+#include "wx/msw/helpwin.h"
+
+#if USE_HELP
+#include <time.h>
+
+#ifdef __WINDOWS__
+#include <wx/msw/private.h>
+#endif
+
+#include <string.h>
+
+// MAX path length
+#define _MAXPATHLEN 500
+
+// MAX length of Help descriptor
+#define _MAX_HELP_LEN 500
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
+#endif
+
+wxWinHelpController::wxWinHelpController(void)
+{
+  m_helpFile = "";
+}
+
+wxWinHelpController::~wxWinHelpController(void)
+{
+}
+
+bool wxWinHelpController::Initialize(const wxString& filename, int server)
+{
+  m_helpFile = filename;
+  return TRUE;
+}
+
+bool wxWinHelpController::LoadFile(const wxString& file)
+{
+  m_helpFile = file;
+  return TRUE;
+}
+
+bool wxWinHelpController::DisplayContents(void)
+{
+    if (m_helpFile == "") return FALSE;
+
+    char buf[_MAXPATHLEN];
+    strcpy(buf, (const char*) m_helpFile);
+    size_t len = strlen(buf);
+    if (!(buf[len-1] == 'p' && buf[len-2] == 'l' && buf[len-3] == 'h' && buf[len-4] == '.'))
+      strcat(buf, ".hlp");
+    if (wxTheApp->GetTopWindow())
+    {
+#if defined(__WIN95__)
+      WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), buf, HELP_FINDER, 0L);
+#else
+      WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), buf, HELP_CONTENTS, 0L);
+#endif
+     return TRUE;
+    }
+	return FALSE;
+}
+
+bool wxWinHelpController::DisplaySection(int section)
+{
+  // No WinHelp equivalent for this
+  return FALSE;
+}
+
+bool wxWinHelpController::DisplayBlock(long block)
+{
+    // Use context number -- a very rough equivalent to block id!
+    if (!m_helpFile) return FALSE;
+
+    char buf[_MAXPATHLEN];
+    strcpy(buf, m_helpFile);
+    size_t len = strlen(buf);
+    if (!(buf[len-1] == 'p' && buf[len-2] == 'l' && buf[len-3] == 'h' && buf[len-4] == '.'))
+      strcat(buf, ".hlp");
+    if (wxTheApp->GetTopWindow())
+	{
+      WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), buf, HELP_CONTEXT, (DWORD)block);
+      return TRUE;
+	}
+    return FALSE;
+}
+
+bool wxWinHelpController::KeywordSearch(const wxString& k)
+{
+    if (m_helpFile == "") return FALSE;
+
+    char buf[_MAXPATHLEN];
+    strcpy(buf, m_helpFile);
+    size_t len = strlen(buf);
+    if (!(buf[len-1] == 'p' && buf[len-2] == 'l' && buf[len-3] == 'h' && buf[len-4] == '.'))
+      strcat(buf, ".hlp");
+    if (wxTheApp->GetTopWindow())
+    {
+      WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), buf, HELP_PARTIALKEY, (DWORD)(const char*) k);
+      return TRUE;
+    }
+    return FALSE;
+}
+
+// Can't close the help window explicitly in WinHelp
+bool wxWinHelpController::Quit(void)
+{
+  return TRUE;
+}
+
+// Don't get notified of WinHelp quitting
+void wxWinHelpController::OnQuit(void)
+{
+}
+
+#endif // USE_HELP
diff --git a/src/msw/icon.cpp b/src/msw/icon.cpp
new file mode 100644
index 0000000000..f5daa68de4
--- /dev/null
+++ b/src/msw/icon.cpp
@@ -0,0 +1,192 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        icon.cpp
+// Purpose:     wxIcon class
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "icon.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/list.h"
+#include "wx/utils.h"
+#include "wx/app.h"
+#include "wx/icon.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "assert.h"
+
+#if USE_XPM_IN_MSW
+#define FOR_MSW 1
+#include "..\..\contrib\wxxpm\libxpm.34b\lib\xpm34.h"
+#endif
+
+#if USE_RESOURCE_LOADING_IN_MSW
+#include "wx/msw/curico.h"
+#include "wx/msw/curicop.h"
+#endif
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
+IMPLEMENT_DYNAMIC_CLASS(wxICOFileHandler, wxBitmapHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxICOResourceHandler, wxBitmapHandler)
+#endif
+
+/*
+ * Icons
+ */
+
+
+wxIconRefData::wxIconRefData(void)
+{
+  m_hIcon = (WXHICON) NULL ;
+}
+
+wxIconRefData::~wxIconRefData(void)
+{
+	if ( m_hIcon )
+		::DestroyIcon((HICON) m_hIcon);
+}
+
+wxIcon::wxIcon(void)
+{
+}
+
+wxIcon::wxIcon(const char WXUNUSED(bits)[], const int WXUNUSED(width), const int WXUNUSED(height))
+{
+}
+
+wxIcon::wxIcon(const wxString& icon_file, const long flags,
+    int desiredWidth, int desiredHeight)
+
+{
+  LoadFile(icon_file, flags, desiredWidth, desiredHeight);
+}
+
+wxIcon::~wxIcon(void)
+{
+}
+
+bool wxIcon::FreeResource(bool force)
+{
+  if (M_ICONDATA && M_ICONDATA->m_hIcon)
+  {
+    DestroyIcon((HICON) M_ICONDATA->m_hIcon);
+	M_ICONDATA->m_hIcon = (WXHICON) NULL;
+  }
+  return TRUE;
+}
+
+bool wxIcon::LoadFile(const wxString& filename, const long type,
+    int desiredWidth, int desiredHeight)
+{
+  UnRef();
+
+  m_refData = new wxIconRefData;
+
+  wxBitmapHandler *handler = FindHandler(type);
+
+  if ( handler )
+	return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
+  else
+	return FALSE;
+}
+
+void wxIcon::SetHICON(WXHICON ico)
+{
+  if ( !M_ICONDATA )
+	m_refData = new wxIconRefData;
+
+  M_ICONDATA->m_hIcon = ico;
+}
+
+bool wxICOFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+    int desiredWidth, int desiredHeight)
+{
+#if USE_RESOURCE_LOADING_IN_MSW
+	if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
+	{
+		wxIcon *icon = (wxIcon *)bitmap;
+        int width, height;
+        WXHICON hIcon = (WXHICON) ReadIconFile((char *)(const char *)name, wxGetInstance(), &width, &height);
+
+    	((wxIconRefData *)icon->GetRefData())->m_hIcon = hIcon;
+    	((wxIconRefData *)icon->GetRefData())->m_ok = (((wxIconRefData *)icon->GetRefData())->m_hIcon != 0);
+    	return ((wxIconRefData *)icon->GetRefData())->m_ok;
+	}
+	else
+		return FALSE;
+#else
+	return FALSE;
+#endif
+}
+
+bool wxICOResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+    int desiredWidth, int desiredHeight)
+{
+	if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
+	{
+#if defined(__WIN32__)
+    if (desiredWidth > -1 && desiredHeight > -1)
+    {
+        M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadImage(wxGetInstance(), name, IMAGE_ICON, desiredWidth, desiredHeight, LR_DEFAULTCOLOR);
+    }
+    else
+#endif
+    {
+    	M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadIcon(wxGetInstance(), name);
+    }
+
+#ifdef __WIN32__
+/***
+    	DWORD vers = GetVersion() ;
+    	WORD  high = HIWORD(vers) ; // high bit=0 for NT, 1 for Win32s
+    	// Win32s doesn't have GetIconInfo function...
+    	if (M_ICONHANDLERDATA->m_hIcon && (high&0x8000)==0 )
+***/
+    	if (M_ICONHANDLERDATA->m_hIcon && wxGetOsVersion()==wxWINDOWS_NT)
+    	{
+      		ICONINFO info ;
+      		if (::GetIconInfo((HICON) M_ICONHANDLERDATA->m_hIcon, &info))
+      		{
+        		HBITMAP ms_bitmap = info.hbmMask ;
+        		if (ms_bitmap)
+        		{
+          			BITMAP bm;
+          			::GetObject(ms_bitmap, sizeof(BITMAP), (LPSTR) &bm);
+          			M_ICONHANDLERDATA->m_width = bm.bmWidth;
+          			M_ICONHANDLERDATA->m_height = bm.bmHeight;
+        		}
+        		if (info.hbmMask)
+          			::DeleteObject(info.hbmMask) ;
+        		if (info.hbmColor)
+          			::DeleteObject(info.hbmColor) ;
+      		}
+    	}
+#else
+    	M_ICONHANDLERDATA->m_width = 32;
+    	M_ICONHANDLERDATA->m_height = 32;
+#endif
+    	M_ICONHANDLERDATA->m_ok = (M_ICONHANDLERDATA->m_hIcon != 0);
+    	return M_ICONHANDLERDATA->m_ok;
+	}
+	else
+	    return FALSE;
+}
+
diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp
new file mode 100644
index 0000000000..49ce321f41
--- /dev/null
+++ b/src/msw/imaglist.cpp
@@ -0,0 +1,200 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        imaglist.cpp
+// Purpose:     wxImageList
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "imaglist.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#if defined(__WIN95__)
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/window.h"
+#include "wx/dcclient.h"
+#endif
+
+#include "wx/msw/imaglist.h"
+#include "wx/msw/private.h"
+
+#ifndef __GNUWIN32__
+#include <commctrl.h>
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject)
+#endif
+
+wxImageList::wxImageList(void)
+{
+    m_hImageList = 0;
+}
+
+wxImageList::~wxImageList(void)
+{
+	if ( m_hImageList )
+		ImageList_Destroy((HIMAGELIST) m_hImageList);
+	m_hImageList = 0;
+}
+
+
+// Attributes
+////////////////////////////////////////////////////////////////////////////
+
+// Returns the number of images in the image list.
+int wxImageList::GetImageCount(void) const
+{
+	return ImageList_GetImageCount((HIMAGELIST) m_hImageList);
+}
+
+// Operations
+////////////////////////////////////////////////////////////////////////////
+
+// Creates an image list
+bool wxImageList::Create(const int width, const int height, const bool mask, const int initial)
+{
+	UINT flags = 0;
+	if ( mask )
+		flags |= ILC_MASK;
+
+	// Grow by 1, I guess this is reasonable behaviour most of the time
+	m_hImageList = (WXHIMAGELIST) ImageList_Create(width, height, flags, initial, 1);
+	return (m_hImageList != 0);
+}
+
+// Adds a bitmap, and optionally a mask bitmap.
+// Note that wxImageList creates new bitmaps, so you may delete
+// 'bitmap' and 'mask'.
+int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask)
+{
+	HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP();
+	HBITMAP hBitmap2 = 0;
+	if ( mask.Ok() )
+	    hBitmap2 = (HBITMAP) mask.GetHBITMAP();
+	return ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmap2);
+}
+
+// Adds a bitmap, using the specified colour to create the mask bitmap
+// Note that wxImageList creates new bitmaps, so you may delete
+// 'bitmap'.
+int wxImageList::Add(const wxBitmap& bitmap, const wxColour& maskColour)
+{
+	HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP();
+	COLORREF colorRef = PALETTERGB(maskColour.Red(), maskColour.Green(), maskColour.Blue());
+	return ImageList_AddMasked((HIMAGELIST) GetHIMAGELIST(), hBitmap1, colorRef);
+}
+
+// Adds a bitmap and mask from an icon.
+int wxImageList::Add(const wxIcon& icon)
+{
+	HICON hIcon = (HICON) icon.GetHICON();
+	return ImageList_AddIcon((HIMAGELIST) GetHIMAGELIST(), hIcon);
+}
+
+// Replaces a bitmap, optionally passing a mask bitmap.
+// Note that wxImageList creates new bitmaps, so you may delete
+// 'bitmap' and 'mask'.
+bool wxImageList::Replace(const int index, const wxBitmap& bitmap, const wxBitmap& mask)
+{
+	HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP();
+	HBITMAP hBitmap2 = 0;
+	if ( mask.Ok() )
+	    hBitmap2 = (HBITMAP) mask.GetHBITMAP();
+	return (ImageList_Replace((HIMAGELIST) GetHIMAGELIST(), index, hBitmap1, hBitmap2) != 0);
+}
+
+/* Not supported by Win95
+// Replacing a bitmap, using the specified colour to create the mask bitmap
+// Note that wxImageList creates new bitmaps, so you may delete
+// 'bitmap'.
+bool wxImageList::Replace(const int index, const wxBitmap& bitmap, const wxColour& maskColour)
+{
+	HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP();
+	COLORREF colorRef = PALETTERGB(maskColour.Red(), maskColour.Green(), maskColour.Blue());
+	return (bool) ImageList_ReplaceMasked((HIMAGELIST) GetHIMAGELIST(), index, hBitmap1, colorRef);
+}
+*/
+
+// Replaces a bitmap and mask from an icon.
+bool wxImageList::Replace(const int index, const wxIcon& icon)
+{
+	HICON hIcon = (HICON) icon.GetHICON();
+	return (ImageList_ReplaceIcon((HIMAGELIST) GetHIMAGELIST(), index, hIcon) != 0);
+}
+
+// Removes the image at the given index.
+bool wxImageList::Remove(const int index)
+{
+	return (ImageList_Remove((HIMAGELIST) GetHIMAGELIST(), index) != 0);
+}
+
+// Remove all images
+bool wxImageList::RemoveAll(void)
+{
+	// TODO: Is this correct?
+	while ( GetImageCount() > 0 )
+	{
+		Remove(0);
+	}
+	return TRUE;
+}
+
+// Draws the given image on a dc at the specified position.
+// If 'solidBackground' is TRUE, Draw sets the image list background
+// colour to the background colour of the wxDC, to speed up
+// drawing by eliminating masked drawing where possible.
+bool wxImageList::Draw(const int index, wxDC& dc, const int x, const int y,
+    const int flags, const bool solidBackground)
+{
+	HDC hDC = (HDC) dc.GetHDC();
+	if ( !hDC )
+		return FALSE;
+
+	if ( solidBackground )
+	{
+		wxBrush *brush = dc.GetBackground();
+		if ( brush && brush->Ok())
+		{
+			wxColour col(brush->GetColour());
+			ImageList_SetBkColor((HIMAGELIST) GetHIMAGELIST(),
+					PALETTERGB(col.Red(), col.Green(), col.Blue()));
+		}
+		else
+			ImageList_SetBkColor((HIMAGELIST) GetHIMAGELIST(),
+				CLR_NONE);
+	}
+	else
+		ImageList_SetBkColor((HIMAGELIST) GetHIMAGELIST(),
+				CLR_NONE);
+
+    UINT style = 0;
+	if ( flags & wxIMAGELIST_DRAW_NORMAL )
+		style |= ILD_NORMAL;
+	if ( flags & wxIMAGELIST_DRAW_TRANSPARENT )
+		style |= ILD_TRANSPARENT;
+	if ( flags & wxIMAGELIST_DRAW_SELECTED )
+		style |= ILD_SELECTED;
+	if ( flags & wxIMAGELIST_DRAW_FOCUSED )
+		style |= ILD_FOCUS;
+
+	return (ImageList_Draw((HIMAGELIST) GetHIMAGELIST(), index, hDC,
+		x, y, style) != 0);
+}
+
+#endif
+
diff --git a/src/msw/joystick.cpp b/src/msw/joystick.cpp
new file mode 100644
index 0000000000..7911b1338f
--- /dev/null
+++ b/src/msw/joystick.cpp
@@ -0,0 +1,541 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        joystick.cpp
+// Purpose:     wxJoystick class
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "joystick.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if defined(__BORLANDC__)
+#pragma hdrstop
+#endif
+
+#include <windows.h>
+
+#ifndef __GNUWIN32__
+#include <mmsystem.h>
+#endif
+
+#if !defined(__WIN32__) && !defined(_MMRESULT_)
+typedef UINT MMRESULT;
+#endif
+
+#ifdef __GNUWIN32__
+#include <wx/msw/gnuwin32/extra.h>
+#endif
+
+// Why doesn't BC++ have joyGetPosEx?
+#if !defined(__WIN32__) || defined(__BORLANDC__)
+#define NO_JOYGETPOSEX
+#endif
+
+#include <wx/msw/joystick.h>
+
+IMPLEMENT_DYNAMIC_CLASS(wxJoystick, wxObject)
+
+// Attributes
+////////////////////////////////////////////////////////////////////////////
+
+wxPoint wxJoystick::GetPosition(void) const
+{
+    JOYINFO joyInfo;
+    MMRESULT res = joyGetPos(m_joystick, & joyInfo);
+    if (res == JOYERR_NOERROR )
+        return wxPoint(joyInfo.wXpos, joyInfo.wYpos);
+    else
+        return wxPoint(0, 0);
+}
+
+int wxJoystick::GetZPosition(void) const
+{
+    JOYINFO joyInfo;
+    MMRESULT res = joyGetPos(m_joystick, & joyInfo);
+    if (res == JOYERR_NOERROR )
+        return joyInfo.wZpos;
+    else
+        return 0;
+}
+
+int wxJoystick::GetButtonState(void) const
+{
+    JOYINFO joyInfo;
+    MMRESULT res = joyGetPos(m_joystick, & joyInfo);
+    if (res == JOYERR_NOERROR )
+    {
+        int buttons = 0;
+
+        if (joyInfo.wButtons & JOY_BUTTON1)
+            buttons |= wxJOY_BUTTON1;
+        if (joyInfo.wButtons & JOY_BUTTON2)
+            buttons |= wxJOY_BUTTON2;
+        if (joyInfo.wButtons & JOY_BUTTON3)
+            buttons |= wxJOY_BUTTON3;
+        if (joyInfo.wButtons & JOY_BUTTON4)
+            buttons |= wxJOY_BUTTON4;
+        return buttons;
+    }
+    else
+        return 0;
+}
+
+int wxJoystick::GetPOVPosition(void) const
+{
+#ifndef NO_JOYGETPOSEX
+    JOYINFOEX joyInfo;
+    joyInfo.dwFlags = JOY_RETURNPOV;
+    MMRESULT res = joyGetPosEx(m_joystick, & joyInfo);
+    if (res == JOYERR_NOERROR )
+    {
+        return joyInfo.dwPOV;
+    }
+    else
+        return 0;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetPOVCTSPosition(void) const
+{
+#ifndef NO_JOYGETPOSEX
+    JOYINFOEX joyInfo;
+    joyInfo.dwFlags = JOY_RETURNPOVCTS;
+    MMRESULT res = joyGetPosEx(m_joystick, & joyInfo);
+    if (res == JOYERR_NOERROR )
+    {
+        return joyInfo.dwPOV;
+    }
+    else
+        return 0;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetRudderPosition(void) const
+{
+#ifndef NO_JOYGETPOSEX
+    JOYINFOEX joyInfo;
+    joyInfo.dwFlags = JOY_RETURNR;
+    MMRESULT res = joyGetPosEx(m_joystick, & joyInfo);
+    if (res == JOYERR_NOERROR )
+    {
+        return joyInfo.dwRpos;
+    }
+    else
+        return 0;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetUPosition(void) const
+{
+#ifndef NO_JOYGETPOSEX
+    JOYINFOEX joyInfo;
+    joyInfo.dwFlags = JOY_RETURNU;
+    MMRESULT res = joyGetPosEx(m_joystick, & joyInfo);
+    if (res == JOYERR_NOERROR )
+    {
+        return joyInfo.dwUpos;
+    }
+    else
+        return 0;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetVPosition(void) const
+{
+#ifndef NO_JOYGETPOSEX
+    JOYINFOEX joyInfo;
+    joyInfo.dwFlags = JOY_RETURNV;
+    MMRESULT res = joyGetPosEx(m_joystick, & joyInfo);
+    if (res == JOYERR_NOERROR )
+    {
+        return joyInfo.dwVpos;
+    }
+    else
+        return 0;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetMovementThreshold(void) const
+{
+    UINT thresh = 0;
+    MMRESULT res = joyGetThreshold(m_joystick, & thresh);
+    if (res == JOYERR_NOERROR )
+    {
+        return thresh;
+    }
+    else
+        return 0;
+}
+
+void wxJoystick::SetMovementThreshold(int threshold)
+{
+    UINT thresh = threshold;
+    joySetThreshold(m_joystick, thresh);
+}
+
+// Capabilities
+////////////////////////////////////////////////////////////////////////////
+
+bool wxJoystick::IsOk(void) const
+{
+    JOYINFO joyInfo;
+    MMRESULT res = joyGetPos(m_joystick, & joyInfo);
+    return ((joyGetNumDevs() > 0) || (res == JOYERR_NOERROR));
+}
+
+int wxJoystick::GetNumberJoysticks(void) const
+{
+    return joyGetNumDevs();
+}
+
+int wxJoystick::GetManufacturerId(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wMid;
+}
+
+int wxJoystick::GetProductId(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wPid;
+}
+
+wxString wxJoystick::GetProductName(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return wxString("");
+    else
+        return wxString(joyCaps.szPname);
+}
+
+int wxJoystick::GetXMin(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wXmin;
+}
+
+int wxJoystick::GetYMin(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wYmin;
+}
+
+int wxJoystick::GetZMin(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wZmin;
+}
+
+int wxJoystick::GetXMax(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wXmax;
+}
+
+int wxJoystick::GetYMax(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wYmax;
+}
+
+int wxJoystick::GetZMax(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wZmax;
+}
+
+int wxJoystick::GetNumberButtons(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wNumButtons;
+}
+
+int wxJoystick::GetNumberAxes(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wNumAxes;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetMaxButtons(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wMaxButtons;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetMaxAxes(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wMaxAxes;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetPollingMin(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wPeriodMin;
+}
+
+int wxJoystick::GetPollingMax(void) const
+{
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wPeriodMax;
+}
+
+int wxJoystick::GetRudderMin(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wRmin;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetRudderMax(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wRmax;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetUMin(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wUmin;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetUMax(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wUmax;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetVMin(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wVmin;
+#else
+    return 0;
+#endif
+}
+
+int wxJoystick::GetVMax(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return 0;
+    else
+        return joyCaps.wVmax;
+#else
+    return 0;
+#endif
+}
+
+
+bool wxJoystick::HasRudder(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return FALSE;
+    else
+        return ((joyCaps.wCaps & JOYCAPS_HASR) == JOYCAPS_HASR);
+#else
+    return FALSE;
+#endif
+}
+
+bool wxJoystick::HasZ(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return FALSE;
+    else
+        return ((joyCaps.wCaps & JOYCAPS_HASZ) == JOYCAPS_HASZ);
+#else
+    return FALSE;
+#endif
+}
+
+bool wxJoystick::HasU(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return FALSE;
+    else
+        return ((joyCaps.wCaps & JOYCAPS_HASU) == JOYCAPS_HASU);
+#else
+    return FALSE;
+#endif
+}
+
+bool wxJoystick::HasV(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return FALSE;
+    else
+        return ((joyCaps.wCaps & JOYCAPS_HASV) == JOYCAPS_HASV);
+#else
+    return FALSE;
+#endif
+}
+
+bool wxJoystick::HasPOV(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return FALSE;
+    else
+        return ((joyCaps.wCaps & JOYCAPS_HASPOV) == JOYCAPS_HASPOV);
+#else
+    return FALSE;
+#endif
+}
+
+bool wxJoystick::HasPOV4Dir(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return FALSE;
+    else
+        return ((joyCaps.wCaps & JOYCAPS_POV4DIR) == JOYCAPS_POV4DIR);
+#else
+    return FALSE;
+#endif
+}
+
+bool wxJoystick::HasPOVCTS(void) const
+{
+#ifdef __WIN32__
+    JOYCAPS joyCaps;
+    if (joyGetDevCaps(m_joystick, & joyCaps, sizeof(JOYCAPS)) != JOYERR_NOERROR)
+        return FALSE;
+    else
+        return ((joyCaps.wCaps & JOYCAPS_POVCTS) == JOYCAPS_POVCTS);
+#else
+    return FALSE;
+#endif
+}
+
+// Operations
+////////////////////////////////////////////////////////////////////////////
+
+bool wxJoystick::SetCapture(wxWindow* win, int pollingFreq)
+{
+    BOOL changed = (pollingFreq == 0);
+    MMRESULT res = joySetCapture((HWND) win->GetHWND(), m_joystick, pollingFreq, changed);
+    return (res == JOYERR_NOERROR);
+}
+
+bool wxJoystick::ReleaseCapture(void)
+{
+    MMRESULT res = joyReleaseCapture(m_joystick);
+    return (res == JOYERR_NOERROR);
+}
+
diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp
new file mode 100644
index 0000000000..3971e400ee
--- /dev/null
+++ b/src/msw/listbox.cpp
@@ -0,0 +1,837 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        listbox.cpp
+// Purpose:     wxListBox
+// Author:      Julian Smart
+// Modified by: Vadim Zeitlin (owner drawn stuff)
+// Created:     
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "listbox.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/listbox.h"
+#include "wx/settings.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#include <windows.h>
+#include <windowsx.h>
+
+#ifdef __GNUWIN32__
+#include <wx/msw/gnuwin32/extra.h>
+#endif
+
+#ifdef GetCharWidth
+#undef GetCharWidth
+#endif
+
+#if USE_OWNER_DRAWN
+  #include  "wx/ownerdrw.h"
+#endif
+
+#if !USE_SHARED_LIBRARY
+  IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
+#endif
+
+// ============================================================================
+// list box item declaration and implementation
+// ============================================================================
+
+#if USE_OWNER_DRAWN
+
+class wxListBoxItem : public wxOwnerDrawn
+{
+public:
+  wxListBoxItem(const wxString& str = "");
+};
+
+wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE) 
+{
+  // no bitmaps/checkmarks
+  SetMarginWidth(0);
+}
+
+wxOwnerDrawn *wxListBox::CreateItem(uint n)
+{
+  return new wxListBoxItem();
+}
+
+#endif  //USE_OWNER_DRAWN
+
+// ============================================================================
+// list box control implementation
+// ============================================================================
+
+// this macro is dangerous but still better than tons of (HWND)GetHWND()
+#define   hwnd    (HWND)GetHWND()
+
+bool wxListBox::MSWCommand(const WXUINT param, const WXWORD WXUNUSED(id))
+{
+/*
+  if (param == LBN_SELCANCEL)
+  {
+    event.extraLong = FALSE;
+  }
+*/
+  if (param == LBN_SELCHANGE)
+  {
+    wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
+    int *liste = NULL;
+    int count = GetSelections(&liste) ;
+    if (count && liste)
+    {
+      event.m_commandInt = liste[0] ;
+      event.m_clientData = GetClientData(event.m_commandInt);
+      wxString str(GetString(event.m_commandInt));
+      if (str != "")
+        event.m_commandString = copystring((char *)(const char *)str);
+    }
+    else
+    {
+      event.m_commandInt = -1 ;
+      event.m_commandString = copystring("") ;
+    }
+
+    event.SetEventObject( this );
+    ProcessCommand(event);
+    if (event.m_commandString)
+      delete[] event.m_commandString ;
+    return TRUE;
+  }
+  else if (param == LBN_DBLCLK)
+  {
+    wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
+    event.SetEventObject( this );
+    if ( !GetEventHandler()->ProcessEvent(event) )
+    {
+#if WXWIN_COMPATIBILITY
+      wxWindow *parent = (wxWindow *)GetParent();
+      if (parent)
+        parent->GetEventHandler()->OnDefaultAction(this);
+#endif
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
+// Listbox item
+wxListBox::wxListBox(void)
+{
+  m_noItems = 0;
+  m_selected = 0;
+  m_selections = NULL;
+}
+
+bool wxListBox::Create(wxWindow *parent, const wxWindowID id,
+                       const wxPoint& pos,
+                       const wxSize& size,
+                       const int n, const wxString choices[],
+                       const long style,
+                       const wxValidator& validator,
+                       const wxString& name)
+{
+  m_noItems = n;
+  m_hWnd = 0;
+  m_selected = 0;
+  m_selections = NULL;
+
+  SetName(name);
+  SetValidator(validator);
+
+  if (parent) parent->AddChild(this);
+
+  wxSystemSettings settings;
+  SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW));
+  SetForegroundColour(parent->GetDefaultForegroundColour());
+
+  m_windowId = ( id == -1 ) ? (int)NewControlId() : id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+  m_windowStyle = style;
+
+  DWORD wstyle = WS_VSCROLL | WS_TABSTOP | LBS_NOTIFY | LBS_HASSTRINGS;
+  if (m_windowStyle & wxLB_MULTIPLE)
+    wstyle |= LBS_MULTIPLESEL;
+  else if (m_windowStyle & wxLB_EXTENDED)
+    wstyle |= LBS_EXTENDEDSEL;
+
+  if (m_windowStyle & wxLB_ALWAYS_SB)
+    wstyle |= LBS_DISABLENOSCROLL ;
+  if (m_windowStyle & wxLB_HSCROLL)
+    wstyle |= WS_HSCROLL;
+  if (m_windowStyle & wxLB_SORT)
+    wstyle |= LBS_SORT;
+
+#if USE_OWNER_DRAWN
+    if ( m_windowStyle & wxLB_OWNERDRAW ) {
+      // we don't support LBS_OWNERDRAWVARIABLE yet
+      wstyle |= LBS_OWNERDRAWFIXED;
+    }
+#else
+  // Change from previous versions of wxWin: JACS Nov. 1995
+  // Not sure whether to have integral, or no integral
+  // style. With the latter we may get partial items showing.
+  // VZ: also it makes life more difficult for owner-drawn controls
+    wstyle |= LBS_NOINTEGRALHEIGHT;
+#endif
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if ( want3D || (m_windowStyle & wxSIMPLE_BORDER)
+              || (m_windowStyle & wxRAISED_BORDER)
+              || (m_windowStyle & wxSUNKEN_BORDER)
+              || (m_windowStyle & wxDOUBLE_BORDER) ) {
+    wstyle |= WS_BORDER;
+  }
+
+  HWND wx_list = CreateWindowEx(exStyle, "LISTBOX", NULL,
+                                wstyle | WS_CHILD,
+                                0, 0, 0, 0, 
+                                (HWND)parent->GetHWND(), (HMENU)m_windowId,
+                                wxGetInstance(), NULL);
+#if CTL3D
+  if (want3D)
+  {
+    Ctl3dSubclassCtl(wx_list);
+    m_useCtl3D = TRUE;
+  }
+#endif
+
+  uint ui;
+  for (ui = 0; ui < (uint)n; ui++) {
+    SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]);
+  }
+
+  #if USE_OWNER_DRAWN
+    if ( m_windowStyle & wxLB_OWNERDRAW ) {
+      for (ui = 0; ui < (uint)n; ui++) {
+        // create new item which will process WM_{DRAW|MEASURE}ITEM messages
+        wxOwnerDrawn *pNewItem = CreateItem(ui);
+        pNewItem->SetName(choices[ui]);
+        m_aItems.Add(pNewItem);
+        ListBox_SetItemData(wx_list, ui, pNewItem);
+      }
+    }
+  #endif
+
+  if ((m_windowStyle & wxLB_MULTIPLE) == 0)
+    SendMessage(wx_list, LB_SETCURSEL, 0, 0);
+
+  ShowWindow(wx_list, SW_SHOW);
+
+  m_hWnd = (WXHWND)wx_list;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND)wx_list);
+
+  SetFont(* parent->GetFont());
+
+  SetSize(x, y, width, height);
+
+  return TRUE;
+}
+
+wxListBox::~wxListBox(void)
+{
+  #if USE_OWNER_DRAWN
+    uint uiCount = m_aItems.Count();
+    while ( uiCount-- != 0 ) {
+      delete m_aItems[uiCount];
+    }
+  #endif
+
+  DELETEA(m_selections);
+}
+
+void wxListBox::SetupColours(void)
+{
+  SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
+  SetForegroundColour(GetParent()->GetDefaultForegroundColour());
+}
+
+void wxListBox::SetFirstItem(const int N)
+{
+  SendMessage(hwnd,LB_SETTOPINDEX,(WPARAM)N,(LPARAM)0) ;
+}
+
+void wxListBox::SetFirstItem(const wxString& s)
+{
+  int N = FindString(s) ;
+
+  if (N>=0)
+    SetFirstItem(N) ;
+}
+
+void wxListBox::Delete(const int N)
+{
+  SendMessage(hwnd, LB_DELETESTRING, N, 0);
+  m_noItems --;
+  SetHorizontalExtent("");
+}
+
+void wxListBox::Append(const wxString& item)
+{
+  int index = ListBox_AddString(hwnd, item);
+  m_noItems ++;
+
+  #if USE_OWNER_DRAWN
+    if ( m_windowStyle & wxLB_OWNERDRAW ) {
+      wxOwnerDrawn *pNewItem = CreateItem(-1); // dummy argument
+      pNewItem->SetName(item);
+      m_aItems.Add(pNewItem);
+      ListBox_SetItemData(hwnd, index, pNewItem);
+    }
+  #endif
+
+  SetHorizontalExtent(item);
+}
+
+void wxListBox::Append(const wxString& item, char *Client_data)
+{
+  int index = ListBox_AddString(hwnd, item);
+  m_noItems ++;
+
+  #if USE_OWNER_DRAWN
+    if ( m_windowStyle & wxLB_OWNERDRAW ) {
+      // client data must be pointer to wxOwnerDrawn, otherwise we would crash
+      // in OnMeasure/OnDraw.
+      wxFAIL_MSG("Can't use client data with owner-drawn listboxes");
+    }
+    else
+  #endif
+      ListBox_SetItemData(hwnd, index, Client_data);
+
+  SetHorizontalExtent(item);
+}
+
+void wxListBox::Set(const int n, const wxString *choices, char** clientData)
+{
+  ShowWindow(hwnd, SW_HIDE);
+  ListBox_ResetContent(hwnd);
+  int i;
+  for (i = 0; i < n; i++)
+  {
+    ListBox_AddString(hwnd, choices[i]);
+    if ( clientData )
+      ListBox_SetItemData(hwnd, i, clientData[i]);
+  }
+  m_noItems = n;
+
+  #if USE_OWNER_DRAWN
+    if ( m_windowStyle & wxLB_OWNERDRAW ) {
+      // first delete old items
+      uint ui = m_aItems.Count();
+      while ( ui-- != 0 ) {
+        delete m_aItems[ui];
+      }
+      m_aItems.Empty();
+
+      // then create new ones
+      for (ui = 0; ui < (uint)n; ui++) {
+        wxOwnerDrawn *pNewItem = CreateItem(ui);
+        pNewItem->SetName(choices[ui]);
+        m_aItems.Add(pNewItem);
+        ListBox_SetItemData(hwnd, ui, pNewItem);
+
+        wxASSERT_MSG(clientData[ui] == NULL,
+                     "Can't use client data with owner-drawn listboxes");
+      }
+    }
+  #endif
+
+  SetHorizontalExtent("");
+  ShowWindow(hwnd, SW_SHOW);
+}
+
+int wxListBox::FindString(const wxString& s) const
+{
+ int pos = ListBox_FindStringExact(hwnd, (WPARAM)-1, s);
+ if (pos == LB_ERR)
+   return -1;
+ else
+   return pos;
+}
+
+void wxListBox::Clear(void)
+{
+  ListBox_ResetContent(hwnd);
+
+  m_noItems = 0;
+  ListBox_GetHorizontalExtent(hwnd);
+}
+
+void wxListBox::SetSelection(const int N, const bool select)
+{
+  if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED))
+    SendMessage(hwnd, LB_SETSEL, select, N);
+  else
+  {
+    int N1 = N;
+    if (!select)
+        N1 = -1;
+    SendMessage(hwnd, LB_SETCURSEL, N1, 0);
+  }
+}
+
+bool wxListBox::Selected(const int N) const
+{
+  return SendMessage(hwnd, LB_GETSEL, N, 0) == 0 ? FALSE : TRUE;
+}
+
+void wxListBox::Deselect(const int N)
+{
+  if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED))
+    SendMessage(hwnd, LB_SETSEL, FALSE, N);
+}
+
+char *wxListBox::GetClientData(const int N) const
+{
+  return (char *)SendMessage(hwnd, LB_GETITEMDATA, N, 0);
+}
+
+void wxListBox::SetClientData(const int N, char *Client_data)
+{
+  (void)SendMessage(hwnd, LB_SETITEMDATA, N, (LONG)Client_data);
+/*
+  if (result == LB_ERR)
+      return -1;
+  else
+      return 0;
+ */
+}
+
+// Return number of selections and an array of selected integers
+// Use selections field to store data, which will be cleaned up
+// by destructor if necessary.
+int wxListBox::GetSelections(int **list_selections) const
+{
+  wxListBox *nonConst = (wxListBox *)this; // const is a white lie!
+  if (nonConst->m_selections)
+    { delete[] nonConst->m_selections; nonConst->m_selections = NULL; };
+  if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED))
+  {
+    int no_sel = (int)SendMessage(hwnd, LB_GETSELCOUNT, 0, 0);
+    if (no_sel == 0)
+      return 0;
+    nonConst->m_selections = new int[no_sel];
+    SendMessage(hwnd, LB_GETSELITEMS, no_sel, (LONG)m_selections);
+    *list_selections = m_selections;
+    return no_sel;
+  }
+  else
+  {
+    int sel = (int)SendMessage(hwnd, LB_GETCURSEL, 0, 0);
+    if (sel == LB_ERR)
+      return 0;
+    nonConst->m_selections = new int[1];
+    nonConst->m_selections[0] = sel;
+    *list_selections = m_selections;
+    return 1;
+  }
+}
+
+// Get single selection, for single choice list items
+int wxListBox::GetSelection(void) const
+{
+  wxListBox *nonConst = (wxListBox *)this; // const is a white lie!
+  if (nonConst->m_selections)
+    { delete[] nonConst->m_selections; nonConst->m_selections = NULL; };
+  if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED))
+    return -1;
+  else
+  {
+    int sel = (int)SendMessage(hwnd, LB_GETCURSEL, 0, 0);
+    if (sel == LB_ERR)
+      return -1;
+    else
+    {
+      return sel;
+    }
+  }
+}
+
+// Find string for position
+wxString wxListBox::GetString(const int N) const
+{
+  if (N < 0 || N > m_noItems)
+    return wxString("");
+    
+  int len = (int)SendMessage(hwnd, LB_GETTEXT, N, (LONG)wxBuffer);
+  wxBuffer[len] = 0;
+  return wxString(wxBuffer);
+}
+
+void wxListBox::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+
+  int x1 = x;
+  int y1 = y;
+  int w1 = width;
+  int h1 = height;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  // If we're prepared to use the existing size, then...
+  if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
+  {
+    GetSize(&w1, &h1);
+  }
+
+  int cx; // button font dimensions
+  int cy;
+
+  wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
+
+  float control_width, control_height, control_x, control_y;
+
+  // Deal with default size (using -1 values)
+  if (w1<=0)
+    w1 = DEFAULT_ITEM_WIDTH;
+
+  if (h1<=0)
+    h1 = DEFAULT_ITEM_HEIGHT;
+
+  control_x = (float)x1;
+  control_y = (float)y1;
+  control_width = (float)w1;
+  control_height = (float)h1;
+
+  // Calculations may have made size too small
+  if (control_height <= 0)
+    control_height = (float)DEFAULT_ITEM_HEIGHT;
+
+  if (control_width <= 0)
+    control_width = (float)DEFAULT_ITEM_WIDTH;
+
+//  wxDebugMsg("About to set the listbox height to %d", (int)control_height);
+  MoveWindow(hwnd, (int)control_x, (int)control_y,
+                   (int)control_width, (int)control_height, TRUE);
+
+/*
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+*/
+
+}
+
+// Windows-specific code to set the horizontal extent of
+// the listbox, if necessary. If s is non-NULL, it's
+// used to calculate the horizontal extent.
+// Otherwise, all strings are used.
+void wxListBox::SetHorizontalExtent(const wxString& s)
+{
+  // Only necessary if we want a horizontal scrollbar
+  if (!(m_windowStyle & wxHSCROLL))
+    return;
+  TEXTMETRIC lpTextMetric;
+
+  if (s != "")
+  {
+    int existingExtent = (int)SendMessage(hwnd, LB_GETHORIZONTALEXTENT, 0, 0L);
+    HDC dc = GetWindowDC(hwnd);
+    HFONT oldFont = 0;
+    if (GetFont() && GetFont()->GetResourceHandle())
+      oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
+
+    GetTextMetrics(dc, &lpTextMetric);
+    SIZE extentXY;
+    ::GetTextExtentPoint(dc, (LPSTR) (const char *)s, s.Length(), &extentXY);
+    int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
+    
+    if (oldFont)
+      ::SelectObject(dc, oldFont);
+
+    ReleaseDC(hwnd, dc);
+    if (extentX > existingExtent)
+      SendMessage(hwnd, LB_SETHORIZONTALEXTENT, LOWORD(extentX), 0L);
+    return;
+  }
+  else
+  {
+    int largestExtent = 0;
+    HDC dc = GetWindowDC(hwnd);
+    HFONT oldFont = 0;
+    if (GetFont() && GetFont()->GetResourceHandle())
+      oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
+
+    GetTextMetrics(dc, &lpTextMetric);
+    int i;
+    for (i = 0; i < m_noItems; i++)
+    {
+      int len = (int)SendMessage(hwnd, LB_GETTEXT, i, (LONG)wxBuffer);
+      wxBuffer[len] = 0;
+      SIZE extentXY;
+      ::GetTextExtentPoint(dc, (LPSTR)wxBuffer, len, &extentXY);
+      int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
+      if (extentX > largestExtent)
+        largestExtent = extentX;
+    }
+    if (oldFont)
+      ::SelectObject(dc, oldFont);
+
+    ReleaseDC(hwnd, dc);
+    SendMessage(hwnd, LB_SETHORIZONTALEXTENT, LOWORD(largestExtent), 0L);
+  }
+}
+
+void
+wxListBox::InsertItems(const int nItems, const wxString items[], const int pos)
+{
+  int i;
+  for (i = 0; i < nItems; i++)
+    ListBox_InsertString(hwnd, i + pos, items[i]);
+  m_noItems += nItems;
+
+  #if USE_OWNER_DRAWN
+    if ( m_windowStyle & wxLB_OWNERDRAW ) {
+      for ( i = 0; i < nItems; i++ ) {
+        wxOwnerDrawn *pNewItem = CreateItem((uint)(pos + i));
+        pNewItem->SetName(items[i]);
+        m_aItems.Insert(pNewItem, (uint)(pos + i));
+        ListBox_SetItemData(hwnd, i, pNewItem);
+      }
+    }
+  #endif
+
+  SetHorizontalExtent("");
+}
+
+void wxListBox::SetString(const int N, const wxString& s)
+{
+  int sel = GetSelection();
+  
+  char *oldData = (char *)wxListBox::GetClientData(N);
+  
+  SendMessage(hwnd, LB_DELETESTRING, N, 0);
+
+  int newN = N;
+  if (N == (m_noItems - 1))
+    newN = -1;
+    
+  SendMessage(hwnd, LB_INSERTSTRING, newN, (LPARAM) (const char *)s);
+  if (oldData)
+    wxListBox::SetClientData(N, oldData);
+
+  // Selection may have changed
+  if (sel >= 0)
+    SetSelection(sel);
+
+  #if       USE_OWNER_DRAWN
+    // update item's text
+    m_aItems[N]->SetName(s);
+  #endif  //USE_OWNER_DRAWN
+}
+
+int wxListBox::Number (void) const
+{
+  return m_noItems;
+}
+
+// For single selection items only
+wxString wxListBox::GetStringSelection (void) const
+{
+  int sel = GetSelection ();
+  if (sel > -1)
+    return this->GetString (sel);
+  else
+    return wxString("");
+}
+
+bool wxListBox::SetStringSelection (const wxString& s, const bool flag)
+{
+  int sel = FindString (s);
+  if (sel > -1)
+    {
+      SetSelection (sel, flag);
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
+
+// Is this the right thing? Won't setselection generate a command
+// event too? No! It'll just generate a setselection event.
+// But we still can't have this being called whenever a real command
+// is generated, because it sets the selection, which will already
+// have been done! (Unless we have an optional argument for calling
+// by the actual window system, or a separate function, ProcessCommand)
+void wxListBox::Command (wxCommandEvent & event)
+{
+  if (event.m_extraLong)
+    SetSelection (event.m_commandInt);
+  else
+    {
+      Deselect (event.m_commandInt);
+      return;
+    }
+  ProcessCommand (event);
+}
+
+WXHBRUSH wxListBox::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+#if CTL3D
+  if ( m_useCtl3D )
+  {
+    HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
+    return (WXHBRUSH) hbrush;
+  }
+#endif
+
+  if (GetParent()->GetTransparentBackground())
+    SetBkMode((HDC) pDC, TRANSPARENT);
+  else
+    SetBkMode((HDC) pDC, OPAQUE);
+
+  ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+
+  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+
+  // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
+  // has a zero usage count.
+  backgroundBrush->RealizeResource();
+  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
+}
+
+long wxListBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+/*
+  switch (nMsg)
+  {
+        case WM_INITDIALOG:
+        case WM_ACTIVATE:
+        case WM_SETFOCUS:
+        case WM_KILLFOCUS:
+	case WM_CREATE:
+	case WM_PAINT:
+	case WM_QUERYDRAGICON:
+        case WM_SIZE:
+        case WM_RBUTTONDOWN:
+        case WM_RBUTTONUP:
+        case WM_RBUTTONDBLCLK:
+        case WM_MBUTTONDOWN:
+        case WM_MBUTTONUP:
+        case WM_MBUTTONDBLCLK:
+        case WM_LBUTTONDOWN:
+        case WM_LBUTTONUP:
+//        case WM_LBUTTONDBLCLK:
+        case WM_MOUSEMOVE:
+        case WM_DESTROY:
+        case WM_COMMAND:
+        case WM_NOTIFY:
+        case WM_MENUSELECT:
+        case WM_INITMENUPOPUP:
+        case WM_DRAWITEM:
+        case WM_MEASUREITEM:
+        case WM_KEYDOWN:
+        case WM_KEYUP:
+        case WM_CHAR: // Always an ASCII character
+        case WM_HSCROLL:
+        case WM_VSCROLL:
+        case WM_CTLCOLORBTN:
+        case WM_CTLCOLORDLG:
+        case WM_CTLCOLORLISTBOX:
+        case WM_CTLCOLORMSGBOX:
+        case WM_CTLCOLORSCROLLBAR:
+        case WM_CTLCOLORSTATIC:
+        case WM_CTLCOLOREDIT:
+        case WM_SYSCOLORCHANGE:
+        case WM_ERASEBKGND:
+        case WM_MDIACTIVATE:
+        case WM_DROPFILES:
+        case WM_QUERYENDSESSION:
+        case WM_CLOSE:
+        case WM_GETMINMAXINFO:
+		case WM_NCHITTEST:
+            return MSWDefWindowProc(nMsg, wParam, lParam );
+    }
+*/
+  return wxControl::MSWWindowProc(nMsg, wParam, lParam);
+}
+
+#if USE_OWNER_DRAWN
+
+// drawing
+// -------
+
+// space beneath/above each row in pixels
+// "standard" checklistbox use 1 here, some might prefer 2. 0 is ugly.
+#define OWNER_DRAWN_LISTBOX_EXTRA_SPACE    (1)
+
+// the height is the same for all items
+// ## should be changed for LBS_OWNERDRAWVARIABLE style listboxes
+//    NB: can't forward this to wxListBoxItem because LB_SETITEMDATA
+//        message is not yet sent when we get here!
+bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
+{
+  // only owner-drawn control should receive this message
+  wxCHECK_RET( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE );
+
+  MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item;
+
+  wxDC dc;
+  dc.SetHDC((WXHDC)CreateIC("DISPLAY", NULL, NULL, 0));
+  dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_ANSI_VAR_FONT));
+
+  pStruct->itemHeight = dc.GetCharHeight() + 2*OWNER_DRAWN_LISTBOX_EXTRA_SPACE;
+  pStruct->itemWidth  = dc.GetCharWidth();
+
+  return TRUE;
+}
+
+// forward the message to the appropriate item
+bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
+{
+  // only owner-drawn control should receive this message
+  wxCHECK_RET( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE );
+
+  DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item;
+  wxListBoxItem *pItem = (wxListBoxItem *)SendMessage(hwnd, LB_GETITEMDATA, 
+                                                      pStruct->itemID, 0);
+
+  wxCHECK_RET( (int)pItem != LB_ERR, FALSE );
+
+  wxDC dc;
+  dc.SetHDC((WXHDC)pStruct->hDC, FALSE);
+  wxRect rect(pStruct->rcItem.left, pStruct->rcItem.top,
+              pStruct->rcItem.right - pStruct->rcItem.left, 
+              pStruct->rcItem.bottom - pStruct->rcItem.top);
+
+  return pItem->OnDrawItem(dc, rect, 
+                           (wxOwnerDrawn::wxODAction)pStruct->itemAction,
+                           (wxOwnerDrawn::wxODStatus)pStruct->itemState);
+}
+
+#endif
+  // USE_OWNER_DRAWN
diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp
new file mode 100644
index 0000000000..48fe1f2c69
--- /dev/null
+++ b/src/msw/listctrl.cpp
@@ -0,0 +1,1380 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        listctrl.cpp
+// Purpose:     wxListCtrl
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "listctrl.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx.h"
+#endif
+
+#if defined(__WIN95__)
+
+#include "wx/listctrl.h"
+
+#include "wx/msw/private.h"
+
+#ifndef __GNUWIN32__
+#include <commctrl.h>
+#endif
+
+#ifdef __GNUWIN32__
+#include "wx/msw/gnuwin32/extra.h"
+#endif
+
+static void wxConvertToMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& tvItem);
+static void wxConvertFromMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& tvItem, HWND getFullInfo = 0);
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
+
+#endif
+
+wxListCtrl::wxListCtrl(void)
+{
+	m_imageListNormal = NULL;
+	m_imageListSmall = NULL;
+	m_imageListState = NULL;
+	m_baseStyle = 0;
+    m_colCount = 0;
+}
+
+bool wxListCtrl::Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size,
+            const long style, const wxValidator& validator, const wxString& name)
+{
+  m_imageListNormal = NULL;
+  m_imageListSmall = NULL;
+  m_imageListState = NULL;
+  m_colCount = 0;
+
+  wxSystemSettings settings;
+  SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW));
+  SetForegroundColour(parent->GetDefaultForegroundColour());
+
+  SetValidator(validator);
+  SetName(name);
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_windowStyle = style;
+
+  SetParent(parent);
+
+  if (width <= 0)
+    width = 100;
+  if (height <= 0)
+    height = 30;
+  if (x < 0)
+    x = 0;
+  if (y < 0)
+    y = 0;
+
+  m_windowId = (id == -1) ? NewControlId() : id;
+
+  DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
+  
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+    wstyle |= WS_BORDER;
+
+  wstyle |= LVS_SHAREIMAGELISTS;
+  m_baseStyle = wstyle;
+
+  long oldStyle = 0; // Dummy
+  wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle);
+
+  // Create the ListView control.
+  HWND hWndListControl = CreateWindowEx(exStyle,
+    WC_LISTVIEW,
+    "",
+    wstyle,
+    x, y, width, height,
+    (HWND) parent->GetHWND(),
+    (HMENU)m_windowId,
+    wxGetInstance(),
+    NULL );
+
+  m_hWnd = (WXHWND) hWndListControl;
+  if (parent) parent->AddChild(this);
+  
+  SubclassWin((WXHWND) m_hWnd);
+
+  return TRUE;
+}
+
+wxListCtrl::~wxListCtrl(void)
+{
+	m_textCtrl.SetHWND((WXHWND) NULL);
+}
+
+// Add or remove a single window style
+void wxListCtrl::SetSingleStyle(const long style, const bool add)
+{
+	long flag = GetWindowStyleFlag();
+
+	// Get rid of conflicting styles
+	if ( add )
+	{
+		if ( style & wxLC_MASK_TYPE)
+			flag = flag & ~wxLC_MASK_TYPE ;
+		if ( style & wxLC_MASK_ALIGN )
+			flag = flag & ~wxLC_MASK_ALIGN ;
+		if ( style & wxLC_MASK_SORT )
+			flag = flag & ~wxLC_MASK_SORT ;
+    }
+
+	if ( flag & style )
+	{
+		if ( !add )
+			flag -= style;
+	}
+	else
+	{
+		if ( add )
+		{
+			flag |= style;
+		}
+	}
+
+	m_windowStyle = flag;
+
+	RecreateWindow();
+}
+
+// Set the whole window style
+void wxListCtrl::SetWindowStyleFlag(const long flag)
+{
+	m_windowStyle = flag;
+
+	RecreateWindow();
+}
+
+void wxListCtrl::RecreateWindow(void)
+{
+	if ( GetHWND() )
+	{
+	  long oldStyle = 0;
+      long style = ConvertToMSWStyle(oldStyle, m_windowStyle);
+	  style |= m_baseStyle;
+//      ::SetWindowLong((HWND) GetHWND(), GWL_STYLE, style);
+
+      // The following recreation of the window appears to be necessary
+	  // because SetWindowLong doesn't seem to do it.
+
+      int x, y, width, height;
+      GetPosition(&x, &y);
+      GetSize(&width, &height);
+
+      UnsubclassWin();
+      ::DestroyWindow((HWND) GetHWND());
+
+      // Experimental
+      // Recreate the ListView control: unfortunately I can't
+	  // make it work by using SetWindowLong.
+      bool want3D;
+      WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+      HWND hWndListControl = CreateWindowEx(exStyle,
+        WC_LISTVIEW,
+        "",
+        style,
+        x, y, width, height,
+        (HWND) GetParent()->GetHWND(),
+        (HMENU)m_windowId,
+        wxGetInstance(),
+        NULL );
+
+      m_hWnd = (WXHWND) hWndListControl;
+      SubclassWin((WXHWND) m_hWnd);
+
+      if ( m_imageListNormal )
+	    SetImageList(m_imageListNormal, wxIMAGE_LIST_NORMAL);
+      if ( m_imageListSmall )
+	    SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL);
+      if ( m_imageListState )
+	    SetImageList(m_imageListState, wxIMAGE_LIST_STATE);
+	}
+}
+
+// Can be just a single style, or a bitlist
+long wxListCtrl::ConvertToMSWStyle(long& oldStyle, const long style) const
+{
+  long wstyle = 0;
+  if ( style & wxLC_ICON )
+  {
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_SMALLICON )
+		oldStyle -= LVS_SMALLICON;
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_REPORT )
+		oldStyle -= LVS_REPORT;
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_LIST )
+		oldStyle -= LVS_LIST;
+	wstyle |= LVS_ICON;
+  }
+
+  if ( style & wxLC_SMALL_ICON )
+  {
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_ICON )
+		oldStyle -= LVS_ICON;
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_REPORT )
+		oldStyle -= LVS_REPORT;
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_LIST )
+		oldStyle -= LVS_LIST;
+	wstyle |= LVS_SMALLICON;
+  }
+
+  if ( style & wxLC_LIST )
+  {
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_ICON )
+		oldStyle -= LVS_ICON;
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_REPORT )
+		oldStyle -= LVS_REPORT;
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_SMALLICON )
+		oldStyle -= LVS_SMALLICON;
+	wstyle |= LVS_LIST;
+  }
+
+  if ( style & wxLC_REPORT )
+  {
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_ICON )
+		oldStyle -= LVS_ICON;
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_LIST )
+		oldStyle -= LVS_LIST;
+	if ( (oldStyle & LVS_TYPEMASK) == LVS_SMALLICON )
+		oldStyle -= LVS_SMALLICON;
+	wstyle |= LVS_REPORT;
+  }
+
+  if ( style & wxLC_ALIGN_LEFT )
+  {
+	if ( oldStyle & LVS_ALIGNTOP )
+		oldStyle -= LVS_ALIGNTOP;
+	wstyle |= LVS_ALIGNLEFT;
+  }
+
+  if ( style & wxLC_ALIGN_TOP )
+  {
+	if ( oldStyle & LVS_ALIGNLEFT )
+		oldStyle -= LVS_ALIGNLEFT;
+	wstyle |= LVS_ALIGNTOP;
+  }
+
+  if ( style & wxLC_AUTOARRANGE )
+	wstyle |= LVS_AUTOARRANGE;
+
+  // Apparently, no such style (documentation wrong?)
+/*
+  if ( style & wxLC_BUTTON )
+	wstyle |= LVS_BUTTON;
+*/
+
+  if ( style & wxLC_NO_SORT_HEADER )
+	wstyle |= LVS_NOSORTHEADER;
+
+  if ( style & wxLC_NO_HEADER )
+	wstyle |= LVS_NOCOLUMNHEADER;
+
+  if ( style & wxLC_EDIT_LABELS )
+	wstyle |= LVS_EDITLABELS;
+
+  if ( style & wxLC_SINGLE_SEL )
+	wstyle |= LVS_SINGLESEL;
+
+  if ( style & wxLC_SORT_ASCENDING )
+  {
+	if ( oldStyle & LVS_SORTDESCENDING )
+		oldStyle -= LVS_SORTDESCENDING;
+	wstyle |= LVS_SORTASCENDING;
+  }
+
+  if ( style & wxLC_SORT_DESCENDING )
+  {
+	if ( oldStyle & LVS_SORTASCENDING )
+		oldStyle -= LVS_SORTASCENDING;
+	wstyle |= LVS_SORTDESCENDING;
+  }
+
+  return wstyle;
+}
+
+// Sets the background colour (GetBackgroundColour already implicit in
+// wxWindow class)
+void wxListCtrl::SetBackgroundColour(const wxColour& col)
+{
+	wxWindow::SetBackgroundColour(col);
+
+	ListView_SetBkColor((HWND) GetHWND(), PALETTERGB(col.Red(), col.Green(), col.Blue()));
+}
+
+// Gets information about this column
+bool wxListCtrl::GetColumn(const int col, wxListItem& item) const
+{
+	LV_COLUMN lvCol;
+	lvCol.mask = 0;
+	lvCol.fmt = 0;
+	lvCol.pszText = NULL;
+
+   	if ( item.m_mask & wxLIST_MASK_TEXT )
+	{
+		lvCol.mask |= LVCF_TEXT;
+		lvCol.pszText = new char[513];
+		lvCol.cchTextMax = 512;
+	}
+
+	bool success = (ListView_GetColumn((HWND) GetHWND(), col, & lvCol) != 0);
+
+//	item.m_subItem = lvCol.iSubItem;
+	item.m_width = lvCol.cx;
+
+   	if ( (item.m_mask & wxLIST_MASK_TEXT) && lvCol.pszText )
+	{
+		item.m_text = lvCol.pszText;
+		delete[] lvCol.pszText;
+	}
+
+	if ( item.m_mask & wxLIST_MASK_FORMAT )
+	{
+		if (lvCol.fmt == LVCFMT_LEFT)
+			item.m_format = wxLIST_FORMAT_LEFT;
+		else if (lvCol.fmt == LVCFMT_RIGHT)
+			item.m_format = wxLIST_FORMAT_RIGHT;
+		else if (lvCol.fmt == LVCFMT_CENTER)
+			item.m_format = wxLIST_FORMAT_CENTRE;
+    }
+
+	return success;
+}
+
+// Sets information about this column
+bool wxListCtrl::SetColumn(const int col, wxListItem& item)
+{
+	LV_COLUMN lvCol;
+	lvCol.mask = 0;
+	lvCol.fmt = 0;
+	lvCol.pszText = NULL;
+
+   	if ( item.m_mask & wxLIST_MASK_TEXT )
+	{
+		lvCol.mask |= LVCF_TEXT;
+		lvCol.pszText = WXSTRINGCAST item.m_text;
+		lvCol.cchTextMax = 0; // Ignored
+	}
+	if ( item.m_mask & wxLIST_MASK_FORMAT )
+	{
+		lvCol.mask |= LVCF_FMT;
+
+		if ( item.m_format == wxLIST_FORMAT_LEFT )
+			lvCol.fmt = LVCFMT_LEFT;
+		if ( item.m_format == wxLIST_FORMAT_RIGHT )
+			lvCol.fmt = LVCFMT_RIGHT;
+		if ( item.m_format == wxLIST_FORMAT_CENTRE )
+			lvCol.fmt = LVCFMT_CENTER;
+    }
+
+   	if ( item.m_mask & wxLIST_MASK_WIDTH )
+	{
+		lvCol.mask |= LVCF_WIDTH;
+		lvCol.cx = item.m_width;
+
+		if ( lvCol.cx == wxLIST_AUTOSIZE)
+			lvCol.cx = LVSCW_AUTOSIZE;
+		else if ( lvCol.cx == wxLIST_AUTOSIZE_USEHEADER)
+			lvCol.cx = LVSCW_AUTOSIZE_USEHEADER;
+	}
+	lvCol.mask |= LVCF_SUBITEM;
+	lvCol.iSubItem = col;
+	return (ListView_SetColumn((HWND) GetHWND(), col, & lvCol) != 0);
+}
+
+// Gets the column width
+int wxListCtrl::GetColumnWidth(const int col) const
+{
+	return ListView_GetColumnWidth((HWND) GetHWND(), col);
+}
+
+// Sets the column width
+bool wxListCtrl::SetColumnWidth(const int col, const int width)
+{
+	int col2 = col;
+	if ( m_windowStyle & wxLC_LIST )
+		col2 = -1;
+
+	int width2 = width;
+	if ( width2 == wxLIST_AUTOSIZE)
+		width2 = LVSCW_AUTOSIZE;
+	else if ( width2 == wxLIST_AUTOSIZE_USEHEADER)
+		width2 = LVSCW_AUTOSIZE_USEHEADER;
+
+	return (ListView_SetColumnWidth((HWND) GetHWND(), col2, width2) != 0);
+}
+
+// Gets the number of items that can fit vertically in the
+// visible area of the list control (list or report view)
+// or the total number of items in the list control (icon
+// or small icon view)
+int wxListCtrl::GetCountPerPage(void) const
+{
+	return ListView_GetCountPerPage((HWND) GetHWND());
+}
+
+// Gets the edit control for editing labels.
+wxTextCtrl& wxListCtrl::GetEditControl(void) const
+{
+	HWND hWnd = (HWND) ListView_GetEditControl((HWND) GetHWND());
+	((wxListCtrl *)this)->m_textCtrl.SetHWND((WXHWND) hWnd);
+	return (wxTextCtrl&)m_textCtrl;
+}
+
+// Gets information about the item
+bool wxListCtrl::GetItem(wxListItem& info) const
+{
+	LV_ITEM lvItem;
+	lvItem.pszText = NULL;
+	if ( info.m_mask & wxLIST_MASK_TEXT )
+	{
+		lvItem.pszText = new char[513];
+		lvItem.cchTextMax = 512;
+	}
+	bool success = (::SendMessage((HWND) GetHWND(), LVM_GETITEM, 0, (LPARAM)& lvItem) != 0);
+
+	if ( !success )
+	{
+        if (lvItem.pszText)
+			delete[] lvItem.pszText;
+
+		return FALSE;
+	}
+
+    wxConvertFromMSWListItem(this, info, lvItem);
+
+    if (lvItem.pszText)
+		delete[] lvItem.pszText;
+
+	return success;
+}
+
+// Sets information about the item
+bool wxListCtrl::SetItem(wxListItem& info)
+{
+	LV_ITEM item;
+    wxConvertToMSWListItem(this, info, item);
+	item.cchTextMax = 0;
+	return (ListView_SetItem((HWND) GetHWND(), &item) != 0);
+}
+
+long wxListCtrl::SetItem(const long index, const int col, const wxString& label, const int imageId)
+{
+	wxListItem info;
+	info.m_text = label;
+	info.m_mask = wxLIST_MASK_TEXT;
+	info.m_itemId = index;
+	info.m_col = col;
+	if ( imageId > -1 )
+	{
+		info.m_image = imageId;
+		info.m_mask |= wxLIST_MASK_IMAGE;
+	}
+	return SetItem(info);
+}
+
+
+// Gets the item state
+int wxListCtrl::GetItemState(const long item, const long stateMask) const
+{
+	wxListItem info;
+
+	info.m_mask = wxLIST_MASK_STATE ;
+	info.m_stateMask = stateMask;
+	info.m_itemId = item;
+
+	if (!GetItem(info))
+		return 0;
+
+	return info.m_state;
+}
+
+// Sets the item state
+bool wxListCtrl::SetItemState(const long item, const long state, const long stateMask)
+{
+	wxListItem info;
+
+	info.m_mask = wxLIST_MASK_STATE ;
+	info.m_state = state;
+	info.m_stateMask = stateMask;
+	info.m_itemId = item;
+
+	return SetItem(info);
+}
+
+// Sets the item image
+bool wxListCtrl::SetItemImage(const long item, const int image, const int selImage)
+{
+	wxListItem info;
+
+	info.m_mask = wxLIST_MASK_IMAGE ;
+	info.m_image = image;
+	info.m_itemId = item;
+
+	return SetItem(info);
+}
+
+// Gets the item text
+wxString wxListCtrl::GetItemText(const long item) const
+{
+	wxListItem info;
+
+	info.m_mask = wxLIST_MASK_TEXT ;
+	info.m_itemId = item;
+
+	if (!GetItem(info))
+		return wxString("");
+	return info.m_text;
+}
+
+// Sets the item text
+void wxListCtrl::SetItemText(const long item, const wxString& str)
+{
+	wxListItem info;
+
+	info.m_mask = wxLIST_MASK_TEXT ;
+	info.m_itemId = item;
+	info.m_text = str;
+
+	SetItem(info);
+}
+
+// Gets the item data
+long wxListCtrl::GetItemData(const long item) const
+{
+	wxListItem info;
+
+	info.m_mask = wxLIST_MASK_DATA ;
+	info.m_itemId = item;
+
+	if (!GetItem(info))
+		return 0;
+	return info.m_data;
+}
+
+// Sets the item data
+bool wxListCtrl::SetItemData(const long item, long data)
+{
+	wxListItem info;
+
+	info.m_mask = wxLIST_MASK_DATA ;
+	info.m_itemId = item;
+	info.m_data = data;
+
+	return SetItem(info);
+}
+
+// Gets the item rectangle
+bool wxListCtrl::GetItemRect(const long item, wxRectangle& rect, const int code) const
+{
+	RECT rect2;
+
+	int code2 = LVIR_BOUNDS;
+	if ( code == wxLIST_RECT_BOUNDS )
+		code2 = LVIR_BOUNDS;
+	else if ( code == wxLIST_RECT_ICON )
+		code2 = LVIR_ICON;
+	else if ( code == wxLIST_RECT_LABEL )
+		code2 = LVIR_LABEL;
+
+	bool success = (ListView_GetItemRect((HWND) GetHWND(), (int) item, &rect2, code2) != 0);
+
+	rect.x = rect2.left;
+	rect.y = rect2.top;
+	rect.width = rect2.right - rect2.left;
+	rect.height = rect2.bottom - rect2.left;
+	return success;
+}
+
+// Gets the item position
+bool wxListCtrl::GetItemPosition(const long item, wxPoint& pos) const
+{
+	POINT pt;
+
+	bool success = (ListView_GetItemPosition((HWND) GetHWND(), (int) item, &pt) != 0);
+
+	pos.x = pt.x; pos.y = pt.y;
+	return success;
+}
+
+// Sets the item position.
+bool wxListCtrl::SetItemPosition(const long item, const wxPoint& pos)
+{
+	return (ListView_SetItemPosition((HWND) GetHWND(), (int) item, pos.x, pos.y) != 0);
+}
+
+// Gets the number of items in the list control
+int wxListCtrl::GetItemCount(void) const
+{
+	return ListView_GetItemCount((HWND) GetHWND());
+}
+
+// Retrieves the spacing between icons in pixels.
+// If small is TRUE, gets the spacing for the small icon
+// view, otherwise the large icon view.
+int wxListCtrl::GetItemSpacing(bool isSmall) const
+{
+	return ListView_GetItemSpacing((HWND) GetHWND(), (BOOL) isSmall);
+}
+
+// Gets the number of selected items in the list control
+int wxListCtrl::GetSelectedItemCount(void) const
+{
+	return ListView_GetSelectedCount((HWND) GetHWND());
+}
+
+// Gets the text colour of the listview
+wxColour wxListCtrl::GetTextColour(void) const
+{
+	COLORREF ref = ListView_GetTextColor((HWND) GetHWND());
+	wxColour col(GetRValue(ref), GetGValue(ref), GetBValue(ref));
+	return col;
+}
+
+// Sets the text colour of the listview
+void wxListCtrl::SetTextColour(const wxColour& col)
+{
+	ListView_SetTextColor((HWND) GetHWND(), PALETTERGB(col.Red(), col.Blue(), col.Green()));
+}
+
+// Gets the index of the topmost visible item when in
+// list or report view
+long wxListCtrl::GetTopItem(void) const
+{
+	return (long) ListView_GetTopIndex((HWND) GetHWND());
+}
+
+// Searches for an item, starting from 'item'.
+// 'geometry' is one of
+// wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
+// 'state' is a state bit flag, one or more of
+// wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
+// item can be -1 to find the first item that matches the
+// specified flags.
+// Returns the item or -1 if unsuccessful.
+long wxListCtrl::GetNextItem(const long item, int geom, int state) const
+{
+	long flags = 0;
+
+	if ( geom == wxLIST_NEXT_ABOVE )
+		flags |= LVNI_ABOVE;
+	if ( geom == wxLIST_NEXT_ALL )
+		flags |= LVNI_ALL;
+	if ( geom == wxLIST_NEXT_BELOW )
+		flags |= LVNI_BELOW;
+	if ( geom == wxLIST_NEXT_LEFT )
+		flags |= LVNI_TOLEFT;
+	if ( geom == wxLIST_NEXT_RIGHT )
+		flags |= LVNI_TORIGHT;
+
+	if ( state & wxLIST_STATE_CUT )
+		flags |= LVNI_CUT;
+	if ( state & wxLIST_STATE_DROPHILITED )
+		flags |= LVNI_DROPHILITED;
+	if ( state & wxLIST_STATE_FOCUSED )
+		flags |= LVNI_FOCUSED;
+	if ( state & wxLIST_STATE_SELECTED )
+		flags |= LVNI_SELECTED;
+
+	return (long) ListView_GetNextItem((HWND) GetHWND(), item, flags);
+}
+
+
+wxImageList *wxListCtrl::GetImageList(const int which) const
+{
+	if ( which == wxIMAGE_LIST_NORMAL )
+    {
+		return m_imageListNormal;
+	}
+	else if ( which == wxIMAGE_LIST_SMALL )
+    {
+		return m_imageListSmall;
+	}
+	else if ( which == wxIMAGE_LIST_STATE )
+    {
+		return m_imageListState;
+	}
+	return NULL;
+}
+
+void wxListCtrl::SetImageList(wxImageList *imageList, const int which)
+{
+	int flags = 0;
+	if ( which == wxIMAGE_LIST_NORMAL )
+    {
+		flags = LVSIL_NORMAL;
+		m_imageListNormal = imageList;
+	}
+	else if ( which == wxIMAGE_LIST_SMALL )
+    {
+		flags = LVSIL_SMALL;
+		m_imageListSmall = imageList;
+	}
+	else if ( which == wxIMAGE_LIST_STATE )
+    {
+		flags = LVSIL_STATE;
+		m_imageListState = imageList;
+	}
+	ListView_SetImageList((HWND) GetHWND(), (HIMAGELIST) imageList ? imageList->GetHIMAGELIST() : 0, flags);
+}
+
+// Operations
+////////////////////////////////////////////////////////////////////////////
+
+// Arranges the items
+bool wxListCtrl::Arrange(const int flag)
+{
+	UINT code = 0;
+	if ( flag == wxLIST_ALIGN_LEFT )
+		code = LVA_ALIGNLEFT;
+	else if ( flag == wxLIST_ALIGN_TOP )
+		code = LVA_ALIGNTOP;
+	else if ( flag == wxLIST_ALIGN_DEFAULT )
+		code = LVA_DEFAULT;
+	else if ( flag == wxLIST_ALIGN_SNAP_TO_GRID )
+		code = LVA_SNAPTOGRID;
+
+	return (ListView_Arrange((HWND) GetHWND(), code) != 0);
+}
+
+// Deletes an item
+bool wxListCtrl::DeleteItem(const long item)
+{
+	return (ListView_DeleteItem((HWND) GetHWND(), (int) item) != 0);
+}
+
+// Deletes all items
+bool wxListCtrl::DeleteAllItems(void)
+{
+	return (ListView_DeleteAllItems((HWND) GetHWND()) != 0);
+}
+
+// Deletes all items
+bool wxListCtrl::DeleteAllColumns(void)
+{
+	int i;
+    for ( i = 0; i < m_colCount; i++)
+    {
+	  if (ListView_DeleteColumn((HWND) GetHWND(), 0) != 0)
+        m_colCount --;
+    }
+    return (m_colCount == 0);
+}
+
+// Deletes a column
+bool wxListCtrl::DeleteColumn(const int col)
+{
+	bool success = (ListView_DeleteColumn((HWND) GetHWND(), col) != 0);
+
+    if ( success && (m_colCount > 0) )
+        m_colCount --;
+    return success;
+}
+
+// Clears items, and columns if there are any.
+void wxListCtrl::ClearAll(void)
+{
+    DeleteAllItems();
+    if ( m_colCount > 0 )
+        DeleteAllColumns();
+}
+
+// Edits a label
+wxTextCtrl& wxListCtrl::Edit(const long item)
+{
+	HWND hWnd = (HWND) ListView_EditLabel((HWND) GetHWND(), (int) item);
+	m_textCtrl.SetHWND((WXHWND) hWnd);
+	return m_textCtrl;
+}
+
+// Ensures this item is visible
+bool wxListCtrl::EnsureVisible(const long item)
+{
+	return (ListView_EnsureVisible((HWND) GetHWND(), (int) item, FALSE) != 0);
+}
+
+// Find an item whose label matches this string, starting from the item after 'start'
+// or the beginning if 'start' is -1.
+long wxListCtrl::FindItem(const long start, const wxString& str, const bool partial)
+{
+	LV_FINDINFO findInfo;
+
+	findInfo.flags = LVFI_STRING;
+	if ( partial )
+		findInfo.flags |= LVFI_STRING;
+	findInfo.psz = WXSTRINGCAST str;
+
+	return ListView_FindItem((HWND) GetHWND(), (int) start, & findInfo);
+}
+
+// Find an item whose data matches this data, starting from the item after 'start'
+// or the beginning if 'start' is -1.
+long wxListCtrl::FindItem(const long start, const long data)
+{
+	LV_FINDINFO findInfo;
+
+	findInfo.flags = LVFI_PARAM;
+	findInfo.lParam = data;
+
+	return ListView_FindItem((HWND) GetHWND(), (int) start, & findInfo);
+}
+
+// Find an item nearest this position in the specified direction, starting from
+// the item after 'start' or the beginning if 'start' is -1.
+long wxListCtrl::FindItem(const long start, const wxPoint& pt, const int direction)
+{
+	LV_FINDINFO findInfo;
+
+	findInfo.flags = LVFI_NEARESTXY;
+	findInfo.pt.x = pt.x;
+	findInfo.pt.y = pt.y;
+	findInfo.vkDirection = VK_RIGHT;
+
+	if ( direction == wxLIST_FIND_UP )
+		findInfo.vkDirection = VK_UP;
+	else if ( direction == wxLIST_FIND_DOWN )
+		findInfo.vkDirection = VK_DOWN;
+	else if ( direction == wxLIST_FIND_LEFT )
+		findInfo.vkDirection = VK_LEFT;
+	else if ( direction == wxLIST_FIND_RIGHT )
+		findInfo.vkDirection = VK_RIGHT;
+
+	return ListView_FindItem((HWND) GetHWND(), (int) start, & findInfo);
+}
+
+// Determines which item (if any) is at the specified point,
+// giving details in 'flags' (see wxLIST_HITTEST_... flags above)
+long wxListCtrl::HitTest(const wxPoint& point, int& flags)
+{
+    LV_HITTESTINFO hitTestInfo;
+	hitTestInfo.pt.x = (int) point.x;
+	hitTestInfo.pt.y = (int) point.y;
+
+    ListView_HitTest((HWND) GetHWND(), & hitTestInfo);
+
+	flags = 0;
+	if ( hitTestInfo.flags & LVHT_ABOVE )
+		flags |= wxLIST_HITTEST_ABOVE;
+	if ( hitTestInfo.flags & LVHT_BELOW )
+		flags |= wxLIST_HITTEST_BELOW;
+	if ( hitTestInfo.flags & LVHT_NOWHERE )
+		flags |= wxLIST_HITTEST_NOWHERE;
+	if ( hitTestInfo.flags & LVHT_ONITEMICON )
+		flags |= wxLIST_HITTEST_ONITEMICON;
+	if ( hitTestInfo.flags & LVHT_ONITEMLABEL )
+		flags |= wxLIST_HITTEST_ONITEMLABEL;
+	if ( hitTestInfo.flags & LVHT_ONITEMSTATEICON )
+		flags |= wxLIST_HITTEST_ONITEMSTATEICON;
+	if ( hitTestInfo.flags & LVHT_TOLEFT )
+		flags |= wxLIST_HITTEST_TOLEFT;
+	if ( hitTestInfo.flags & LVHT_TORIGHT )
+		flags |= wxLIST_HITTEST_TORIGHT;
+
+	return (long) hitTestInfo.iItem ;
+}
+
+// Inserts an item, returning the index of the new item if successful,
+// -1 otherwise.
+// TOD: Should also have some further convenience functions
+// which don't require setting a wxListItem object
+long wxListCtrl::InsertItem(wxListItem& info)
+{
+	LV_ITEM item;
+	wxConvertToMSWListItem(this, info, item);
+
+	return (long) ListView_InsertItem((HWND) GetHWND(), & item);
+}
+
+long wxListCtrl::InsertItem(const long index, const wxString& label)
+{
+	wxListItem info;
+	info.m_text = label;
+	info.m_mask = wxLIST_MASK_TEXT;
+	info.m_itemId = index;
+	return InsertItem(info);
+}
+
+// Inserts an image item
+long wxListCtrl::InsertItem(const long index, const int imageIndex)
+{
+	wxListItem info;
+	info.m_image = imageIndex;
+	info.m_mask = wxLIST_MASK_IMAGE;
+	info.m_itemId = index;
+	return InsertItem(info);
+}
+
+// Inserts an image/string item
+long wxListCtrl::InsertItem(const long index, const wxString& label, const int imageIndex)
+{
+	wxListItem info;
+	info.m_image = imageIndex;
+	info.m_text = label;
+	info.m_mask = wxLIST_MASK_IMAGE | wxLIST_MASK_TEXT;
+	info.m_itemId = index;
+	return InsertItem(info);
+}
+
+// For list view mode (only), inserts a column.
+long wxListCtrl::InsertColumn(const long col, wxListItem& item)
+{
+	LV_COLUMN lvCol;
+	lvCol.mask = 0;
+	lvCol.fmt = 0;
+	lvCol.pszText = NULL;
+
+   	if ( item.m_mask & wxLIST_MASK_TEXT )
+	{
+		lvCol.mask |= LVCF_TEXT;
+		lvCol.pszText = WXSTRINGCAST item.m_text;
+		lvCol.cchTextMax = 0; // Ignored
+	}
+	if ( item.m_mask & wxLIST_MASK_FORMAT )
+	{
+		lvCol.mask |= LVCF_FMT;
+
+		if ( item.m_format == wxLIST_FORMAT_LEFT )
+			lvCol.fmt = LVCFMT_LEFT;
+		if ( item.m_format == wxLIST_FORMAT_RIGHT )
+			lvCol.fmt = LVCFMT_RIGHT;
+		if ( item.m_format == wxLIST_FORMAT_CENTRE )
+			lvCol.fmt = LVCFMT_CENTER;
+    }
+
+   	if ( item.m_mask & wxLIST_MASK_WIDTH )
+	{
+		lvCol.mask |= LVCF_WIDTH;
+		lvCol.cx = item.m_width;
+
+		if ( lvCol.cx == wxLIST_AUTOSIZE)
+			lvCol.cx = LVSCW_AUTOSIZE;
+		else if ( lvCol.cx == wxLIST_AUTOSIZE_USEHEADER)
+			lvCol.cx = LVSCW_AUTOSIZE_USEHEADER;
+	}
+	lvCol.mask |= LVCF_SUBITEM;
+	lvCol.iSubItem = col;
+
+	bool success = (ListView_InsertColumn((HWND) GetHWND(), col, & lvCol) != 0);
+    if ( success )
+        m_colCount ++;
+    return success;
+}
+
+long wxListCtrl::InsertColumn(const long col, const wxString& heading, const int format,
+    const int width)
+{
+	wxListItem item;
+	item.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_FORMAT;
+	item.m_text = heading;
+	if ( width > -1 )
+	{
+		item.m_mask |= wxLIST_MASK_WIDTH;
+		item.m_width = width;
+	}
+	item.m_format = format;
+
+	return InsertColumn(col, item);
+}
+
+// Scrolls the list control. If in icon, small icon or report view mode,
+// x specifies the number of pixels to scroll. If in list view mode, x
+// specifies the number of columns to scroll.
+// If in icon, small icon or list view mode, y specifies the number of pixels
+// to scroll. If in report view mode, y specifies the number of lines to scroll.
+bool wxListCtrl::ScrollList(const int dx, const int dy)
+{
+	return (ListView_Scroll((HWND) GetHWND(), dx, dy) != 0);
+}
+
+// Sort items.
+
+// fn is a function which takes 3 long arguments: item1, item2, data.
+// item1 is the long data associated with a first item (NOT the index).
+// item2 is the long data associated with a second item (NOT the index).
+// data is the same value as passed to SortItems.
+// The return value is a negative number if the first item should precede the second
+// item, a positive number of the second item should precede the first,
+// or zero if the two items are equivalent.
+
+// data is arbitrary data to be passed to the sort function.
+bool wxListCtrl::SortItems(wxListCtrlCompare fn, long data)
+{
+	return (ListView_SortItems((HWND) GetHWND(), (PFNLVCOMPARE) fn, data) != 0);
+}
+
+bool wxListCtrl::MSWCommand(const WXUINT cmd, const WXWORD id)
+{
+  if (cmd == EN_UPDATE)
+  {
+    wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, id);
+    event.SetEventObject( this );
+    ProcessCommand(event);
+    return TRUE;
+  }
+  else if (cmd == EN_KILLFOCUS)
+  {
+    wxCommandEvent event(wxEVT_KILL_FOCUS, id);
+    event.SetEventObject( this );
+    ProcessCommand(event);
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+bool wxListCtrl::MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam)
+{
+	wxListEvent event(0, m_windowId);
+	int eventType = 0;
+	NMHDR *hdr1 = (NMHDR *) lParam;
+	switch ( hdr1->code )
+	{
+		case LVN_BEGINDRAG:
+		{
+			eventType = wxEVT_COMMAND_LIST_BEGIN_DRAG;
+			NM_LISTVIEW *hdr = (NM_LISTVIEW *)lParam;
+			event.m_itemIndex = hdr->iItem;
+			event.m_pointDrag.x = hdr->ptAction.x;
+			event.m_pointDrag.y = hdr->ptAction.y;
+			break;
+		}
+		case LVN_BEGINLABELEDIT:
+		{
+			eventType = wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
+			LV_DISPINFO *info = (LV_DISPINFO *)lParam;
+			wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND());
+			break;
+		}
+		case LVN_BEGINRDRAG:
+		{
+			eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG;
+			NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
+			event.m_itemIndex = hdr->iItem;
+			event.m_pointDrag.x = hdr->ptAction.x;
+			event.m_pointDrag.y = hdr->ptAction.y;
+			break;
+		}
+		case LVN_COLUMNCLICK:
+		{
+			eventType = wxEVT_COMMAND_LIST_COL_CLICK;
+			NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
+			event.m_itemIndex = -1;
+			event.m_col = hdr->iSubItem;
+			break;
+		}
+		case LVN_DELETEALLITEMS:
+		{
+			eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
+//			NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
+			event.m_itemIndex = -1;
+			break;
+		}
+		case LVN_DELETEITEM:
+		{
+			eventType = wxEVT_COMMAND_LIST_DELETE_ITEM;
+			NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
+			event.m_itemIndex = hdr->iItem;
+			break;
+		}
+		case LVN_ENDLABELEDIT:
+		{
+			eventType = wxEVT_COMMAND_LIST_END_LABEL_EDIT;
+			LV_DISPINFO *info = (LV_DISPINFO *)lParam;
+			wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND());
+			if ( info->item.pszText == NULL || info->item.iItem == -1 )
+				event.m_cancelled = TRUE;
+			break;
+		}
+		case LVN_GETDISPINFO:
+		{
+//			return FALSE;
+			// TODO: some text buffering here, I think
+			// TODO: API for getting Windows to retrieve values
+			// on demand.
+			eventType = wxEVT_COMMAND_LIST_GET_INFO;
+			LV_DISPINFO *info = (LV_DISPINFO *)lParam;
+			wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND());
+			break;
+		}
+		case LVN_INSERTITEM:
+		{
+			eventType = wxEVT_COMMAND_LIST_INSERT_ITEM;
+			NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
+			event.m_itemIndex = hdr->iItem;
+			break;
+		}
+		case LVN_ITEMCHANGED:
+		{
+			// This needs to be sent to wxListCtrl as a rather more
+			// concrete event. For now, just detect a selection
+			// or deselection.
+			NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
+			if ( (hdr->uNewState & LVIS_SELECTED) && !(hdr->uOldState & LVIS_SELECTED) )
+			{
+			  eventType = wxEVT_COMMAND_LIST_ITEM_SELECTED;
+			  event.m_itemIndex = hdr->iItem;
+			}
+			else if ( !(hdr->uNewState & LVIS_SELECTED) && (hdr->uOldState & LVIS_SELECTED) )
+			{
+			  eventType = wxEVT_COMMAND_LIST_ITEM_DESELECTED;
+			  event.m_itemIndex = hdr->iItem;
+			}
+			else
+				return FALSE;
+			break;
+		}
+		case LVN_KEYDOWN:
+		{
+			eventType = wxEVT_COMMAND_LIST_KEY_DOWN;
+			LV_KEYDOWN *info = (LV_KEYDOWN *)lParam;
+			event.m_code = wxCharCodeMSWToWX(info->wVKey);
+			break;
+		}
+		case LVN_SETDISPINFO:
+		{
+			eventType = wxEVT_COMMAND_LIST_SET_INFO;
+			LV_DISPINFO *info = (LV_DISPINFO *)lParam;
+			wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND());
+			break;
+		}
+
+		default :
+			return wxControl::MSWNotify(wParam, lParam);
+			break;
+	}
+
+	event.SetEventObject( this );
+	event.SetEventType(eventType);
+
+	if ( !GetEventHandler()->ProcessEvent(event) )
+		return FALSE;
+
+	if (hdr1->code == LVN_GETDISPINFO)
+	{
+		LV_DISPINFO *info = (LV_DISPINFO *)lParam;
+		if ( info->item.mask & LVIF_TEXT )
+		{
+			if ( !event.m_item.m_text.IsNull() )
+			{
+			  info->item.pszText = AddPool(event.m_item.m_text);
+			  info->item.cchTextMax = strlen(info->item.pszText) + 1;
+			}
+		}
+//		wxConvertToMSWListItem(this, event.m_item, info->item);
+	}
+
+  	return TRUE;
+}
+
+char *wxListCtrl::AddPool(const wxString& str)
+{
+	// Remove the first element if 3 strings exist
+	if ( m_stringPool.Number() == 3 )
+	{
+		wxNode *node = m_stringPool.First();
+		delete[] (char *)node->Data();
+		delete node;
+	}
+	wxNode *node = m_stringPool.Add((char *) (const char *)str);
+	return (char *)node->Data();
+}
+
+// List item structure
+wxListItem::wxListItem(void)
+{
+    m_mask = 0;
+    m_itemId = 0;
+    m_col = 0;
+    m_state = 0;
+    m_stateMask = 0;
+    m_image = 0;
+	m_data = 0;
+
+	m_format = wxLIST_FORMAT_CENTRE;
+	m_width = 0;
+}
+
+static void wxConvertFromMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& lvItem, HWND getFullInfo)
+{
+	info.m_data = lvItem.lParam;
+	info.m_mask = 0;
+	info.m_state = 0;
+	info.m_stateMask = 0;
+	info.m_itemId = lvItem.iItem;
+
+	long oldMask = lvItem.mask;
+
+	bool needText = FALSE;
+	if (getFullInfo != 0)
+	{
+		if ( lvItem.mask & LVIF_TEXT )
+			needText = FALSE;
+		else
+			needText = TRUE;
+
+		if ( needText )
+		{
+			lvItem.pszText = new char[513];
+			lvItem.cchTextMax = 512;
+		}
+//		lvItem.mask |= TVIF_HANDLE | TVIF_STATE | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM ;
+		lvItem.mask |= LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM ;
+		::SendMessage(getFullInfo, LVM_GETITEM, 0, (LPARAM)& lvItem) ;
+	}
+
+	if ( lvItem.mask & LVIF_STATE )
+	{
+		info.m_mask |= wxLIST_MASK_STATE;
+
+    	if ( lvItem.stateMask & LVIS_CUT)
+		{
+			info.m_stateMask |= wxLIST_STATE_CUT ;
+			if ( lvItem.state & LVIS_CUT )
+				info.m_state |= wxLIST_STATE_CUT ;
+		}
+    	if ( lvItem.stateMask & LVIS_DROPHILITED)
+		{
+			info.m_stateMask |= wxLIST_STATE_DROPHILITED ;
+			if ( lvItem.state & LVIS_DROPHILITED )
+				info.m_state |= wxLIST_STATE_DROPHILITED ;
+		}
+    	if ( lvItem.stateMask & LVIS_FOCUSED)
+		{
+			info.m_stateMask |= wxLIST_STATE_FOCUSED ;
+			if ( lvItem.state & LVIS_FOCUSED )
+				info.m_state |= wxLIST_STATE_FOCUSED ;
+		}
+    	if ( lvItem.stateMask & LVIS_SELECTED)
+		{
+			info.m_stateMask |= wxLIST_STATE_SELECTED ;
+			if ( lvItem.state & LVIS_SELECTED )
+				info.m_state |= wxLIST_STATE_SELECTED ;
+		}
+	}
+
+	if ( lvItem.mask & LVIF_TEXT )
+	{
+		info.m_mask |= wxLIST_MASK_TEXT;
+		info.m_text = lvItem.pszText;
+	}
+	if ( lvItem.mask & LVIF_IMAGE )
+	{
+		info.m_mask |= wxLIST_MASK_IMAGE;
+		info.m_image = lvItem.iImage;
+	}
+	if ( lvItem.mask & LVIF_PARAM )
+		info.m_mask |= wxLIST_MASK_DATA;
+	if ( lvItem.mask & LVIF_DI_SETITEM )
+		info.m_mask |= wxLIST_SET_ITEM;
+	info.m_col = lvItem.iSubItem;
+
+	if (needText)
+	{
+       	if (lvItem.pszText)
+			delete[] lvItem.pszText;
+	}
+	lvItem.mask = oldMask ;
+}
+
+static void wxConvertToMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& lvItem)
+{
+	lvItem.iItem = (int) info.m_itemId ;
+
+	lvItem.iImage = info.m_image ;
+	lvItem.lParam = info.m_data;
+	lvItem.stateMask = 0;
+	lvItem.state = 0;
+	lvItem.mask = 0;
+	lvItem.iSubItem = info.m_col;
+
+	if (info.m_mask & wxLIST_MASK_STATE)
+	{
+		lvItem.mask |= LVIF_STATE ;
+		if (info.m_stateMask & wxLIST_STATE_CUT)
+		{
+    		lvItem.stateMask |= LVIS_CUT ;
+			if (info.m_state & wxLIST_STATE_CUT)
+				lvItem.state |= LVIS_CUT;
+		}
+		if (info.m_stateMask & wxLIST_STATE_DROPHILITED)
+		{
+    		lvItem.stateMask |= LVIS_DROPHILITED;
+			if (info.m_state & wxLIST_STATE_DROPHILITED)
+    			lvItem.state |= LVIS_DROPHILITED;
+		}
+		if (info.m_stateMask & wxLIST_STATE_FOCUSED)
+		{
+    		lvItem.stateMask |= LVIS_FOCUSED;
+			if (info.m_state & wxLIST_STATE_FOCUSED)
+    			lvItem.state |= LVIS_FOCUSED;
+		}
+		if (info.m_stateMask & wxLIST_STATE_SELECTED)
+		{
+    		lvItem.stateMask |= LVIS_SELECTED;
+			if (info.m_state & wxLIST_STATE_SELECTED)
+    			lvItem.state |= LVIS_SELECTED;
+		}
+	}
+
+	if (info.m_mask & wxLIST_MASK_TEXT)
+	{
+		lvItem.mask |= LVIF_TEXT ;
+		if ( ctrl->GetWindowStyleFlag() & wxLC_USER_TEXT )
+		{
+			lvItem.pszText = LPSTR_TEXTCALLBACK;
+		}
+		else
+		{
+			lvItem.pszText = (char *) (const char *)info.m_text ;
+			if ( lvItem.pszText )
+				lvItem.cchTextMax = info.m_text.Length();
+			else
+				lvItem.cchTextMax = 0;
+		}
+	}
+	if (info.m_mask & wxLIST_MASK_IMAGE)
+		lvItem.mask |= LVIF_IMAGE ;
+	if (info.m_mask & wxLIST_MASK_DATA)
+		lvItem.mask |= LVIF_PARAM ;
+}
+
+// List event
+IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxCommandEvent)
+
+wxListEvent::wxListEvent(WXTYPE commandType, int id):
+  wxCommandEvent(commandType, id)
+{
+	m_code = 0;
+	m_itemIndex = 0;
+	m_col = 0;
+	m_cancelled = FALSE;
+}
+
+#endif
+
diff --git a/src/msw/main.cpp b/src/msw/main.cpp
new file mode 100644
index 0000000000..e4301f74dc
--- /dev/null
+++ b/src/msw/main.cpp
@@ -0,0 +1,87 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        main.cpp
+// Purpose:     Main/DllMain
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#include "wx/app.h"
+#include <windows.h>
+
+// May wish not to have a DllMain or WinMain, e.g. if we're programming
+// a Netscape plugin.
+#ifndef NOMAIN
+
+// NT defines APIENTRY, 3.x not
+#if !defined(APIENTRY)
+#define APIENTRY FAR PASCAL
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////
+// WinMain
+// Note that WinMain is also defined in dummy.obj, which is linked to
+// an application that is using the DLL version of wxWindows.
+
+#if !defined(_WINDLL)
+
+#ifdef __WATCOMC__
+int PASCAL
+#else
+int APIENTRY
+#endif
+
+ WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR m_lpCmdLine, int nCmdShow )
+{
+  return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance, m_lpCmdLine, nCmdShow);
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////
+// DllMain
+
+#if defined(_WINDLL)
+
+// DLL entry point
+
+extern "C"
+#ifdef __BORLANDC__
+// SCD: I don't know why, but also OWL uses this function
+BOOL WINAPI DllEntryPoint (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
+#else
+BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
+#endif
+{
+    switch (fdwReason)
+	{
+	case DLL_PROCESS_ATTACH:
+        // Only call wxEntry if the application itself is part of the DLL.
+        // If only the wxWindows library is in the DLL, then the initialisation
+        // will be called when the application implicitly calls WinMain.
+
+#if !defined(WXMAKINGDLL)
+        return wxEntry((WXHINSTANCE) hModule);
+#endif
+	    break;
+
+	case DLL_PROCESS_DETACH:
+	default:
+	    break;
+	}
+  return TRUE;
+}
+
+#endif
+
+#endif
+
diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32
new file mode 100644
index 0000000000..2f14f15458
--- /dev/null
+++ b/src/msw/makefile.b32
@@ -0,0 +1,552 @@
+#
+# File:		makefile.b32
+# Author:	Julian Smart
+# Created:	1998
+# Updated:
+# Copyright:
+#
+# "%W% %G%"
+#
+# Makefile : Builds wxWindows library wx.lib for MS Windows,
+# and Borland C++ (32-bit).
+
+!if "$(BCCDIR)" == ""
+!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4
+!endif
+
+!if "$(WXWIN)" == ""
+!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
+!endif
+
+WXDIR = $(WXWIN)
+!include $(WXDIR)\src\makeb32.env
+
+# Please set these according to the settings in wx_setup.h, so we can include
+# the appropriate libraries in wx.lib
+USE_CTL3D=0
+USE_XPM_IN_MSW=0
+
+PERIPH_LIBS=
+PERIPH_TARGET=
+PERIPH_CLEAN_TARGET=
+
+!if "$(USE_CTL3D)" == "1"
+#Use WIN32S/WIN95 32 bit version ctl3d32.dll under win95 (Andre Beltman)
+PERIPH_LIBS=$(WXDIR)\lib\ctl3d32.lib $(PERIPH_LIBS)
+PERIPH_TARGET=ctl3d $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_ctl3d $(PERIPH_CLEAN_TARGET)
+!endif
+
+!if "$(USE_XPM_IN_MSW)" == "1"
+PERIPH_LIBS=$(WXLIB)\xpm.lib $(PERIPH_LIBS)
+PERIPH_TARGET=xpm $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_xpm $(PERIPH_CLEAN_TARGET)
+!endif
+
+LIBTARGET= $(WXLIBDIR)\wx32.lib
+DUMMY=dummy
+
+GENDIR=..\generic
+COMMDIR=..\common
+OLEDIR=.\ole
+MSWDIR=.
+
+DOCDIR = $(WXDIR)\docs
+
+GENERICOBJS= \
+  $(MSWDIR)\choicdgg.obj \
+  $(MSWDIR)\colrdlgg.obj \
+  $(MSWDIR)\fontdlgg.obj \
+  $(MSWDIR)\gridg.obj \
+  $(MSWDIR)\helpxlp.obj \
+  $(MSWDIR)\msgdlgg.obj \
+  $(MSWDIR)\panelg.obj \
+  $(MSWDIR)\printps.obj \
+  $(MSWDIR)\prntdlgg.obj \
+  $(MSWDIR)\scrolwin.obj \
+  $(MSWDIR)\splitter.obj \
+  $(MSWDIR)\statusbr.obj \
+  $(MSWDIR)\tabg.obj \
+  $(MSWDIR)\textdlgg.obj
+
+COMMONOBJS = \
+  $(MSWDIR)\config.obj \
+  $(MSWDIR)\cmndata.obj \
+  $(MSWDIR)\docview.obj \
+  $(MSWDIR)\dynarray.obj \
+  $(MSWDIR)\event.obj \
+  $(MSWDIR)\file.obj \
+  $(MSWDIR)\fileconf.obj \
+  $(MSWDIR)\filefn.obj \
+  $(MSWDIR)\gdicmn.obj \
+  $(MSWDIR)\helpbase.obj \
+  $(MSWDIR)\intl.obj \
+  $(MSWDIR)\ipcbase.obj \
+  $(MSWDIR)\log.obj \
+  $(MSWDIR)\layout.obj \
+  $(MSWDIR)\memory.obj \
+  $(MSWDIR)\module.obj \
+  $(MSWDIR)\object.obj \
+  $(MSWDIR)\odbc.obj \
+  $(MSWDIR)\postscrp.obj \
+  $(MSWDIR)\prntbase.obj \
+  $(MSWDIR)\resource.obj \
+  $(MSWDIR)\tbarbase.obj \
+  $(MSWDIR)\tbarsmpl.obj \
+  $(MSWDIR)\textfile.obj \
+  $(MSWDIR)\timercmn.obj \
+  $(MSWDIR)\utilscmn.obj \
+  $(MSWDIR)\validate.obj \
+  $(MSWDIR)\valtext.obj \
+  $(MSWDIR)\date.obj \
+  $(MSWDIR)\hash.obj \
+  $(MSWDIR)\list.obj \
+  $(MSWDIR)\string.obj \
+  $(MSWDIR)\time.obj \
+  $(MSWDIR)\wxexpr.obj \
+  $(MSWDIR)\y_tab.obj
+
+#  $(MSWDIR)\matrix.obj \
+
+MSWOBJS = \
+  $(MSWDIR)\app.obj \
+  $(MSWDIR)\bitmap.obj \
+  $(MSWDIR)\bmpbuttn.obj \
+  $(MSWDIR)\brush.obj \
+  $(MSWDIR)\button.obj \
+  $(MSWDIR)\checkbox.obj \
+  $(MSWDIR)\checklst.obj \
+  $(MSWDIR)\choice.obj \
+  $(MSWDIR)\clipbrd.obj \
+  $(MSWDIR)\colordlg.obj \
+  $(MSWDIR)\colour.obj \
+  $(MSWDIR)\combobox.obj \
+  $(MSWDIR)\control.obj \
+  $(MSWDIR)\curico.obj \
+  $(MSWDIR)\cursor.obj \
+  $(MSWDIR)\data.obj \
+  $(MSWDIR)\dc.obj \
+  $(MSWDIR)\dcmemory.obj \
+  $(MSWDIR)\dcclient.obj \
+  $(MSWDIR)\dcprint.obj \
+  $(MSWDIR)\dcscreen.obj \
+  $(MSWDIR)\dde.obj \
+  $(MSWDIR)\dialog.obj \
+  $(MSWDIR)\dib.obj \
+  $(MSWDIR)\dirdlg.obj \
+  $(MSWDIR)\filedlg.obj \
+  $(MSWDIR)\font.obj \
+  $(MSWDIR)\fontdlg.obj \
+  $(MSWDIR)\frame.obj \
+  $(MSWDIR)\gauge.obj \
+  $(MSWDIR)\gdiobj.obj \
+  $(MSWDIR)\helpwin.obj \
+  $(MSWDIR)\icon.obj \
+  $(MSWDIR)\imaglist.obj \
+  $(MSWDIR)\joystick.obj \
+  $(MSWDIR)\listbox.obj \
+  $(MSWDIR)\listctrl.obj \
+  $(MSWDIR)\main.obj \
+  $(MSWDIR)\mdi.obj \
+  $(MSWDIR)\menu.obj \
+  $(MSWDIR)\menuitem.obj \
+  $(MSWDIR)\metafile.obj \
+  $(MSWDIR)\minifram.obj \
+  $(MSWDIR)\msgdlg.obj \
+  $(MSWDIR)\nativdlg.obj \
+  $(MSWDIR)\ownerdrw.obj \
+  $(MSWDIR)\palette.obj \
+  $(MSWDIR)\pen.obj \
+  $(MSWDIR)\penwin.obj \
+  $(MSWDIR)\printdlg.obj \
+  $(MSWDIR)\printwin.obj \
+  $(MSWDIR)\radiobox.obj \
+  $(MSWDIR)\radiobut.obj \
+  $(MSWDIR)\region.obj \
+  $(MSWDIR)\registry.obj \
+  $(MSWDIR)\scrolbar.obj \
+  $(MSWDIR)\settings.obj \
+  $(MSWDIR)\slider.obj \
+  $(MSWDIR)\spinbutt.obj \
+  $(MSWDIR)\statbmp.obj \
+  $(MSWDIR)\statbox.obj \
+  $(MSWDIR)\statbr95.obj \
+  $(MSWDIR)\stattext.obj \
+  $(MSWDIR)\tabctrl.obj \
+  $(MSWDIR)\taskbar.obj \
+  $(MSWDIR)\tbar95.obj \
+  $(MSWDIR)\tbarmsw.obj \
+  $(MSWDIR)\textctrl.obj \
+  $(MSWDIR)\thread.obj \
+  $(MSWDIR)\timer.obj \
+  $(MSWDIR)\treectrl.obj \
+  $(MSWDIR)\utils.obj \
+  $(MSWDIR)\wave.obj \
+  $(MSWDIR)\window.obj \
+  $(MSWDIR)\droptgt.obj \
+  $(MSWDIR)\oleutils.obj \
+  $(MSWDIR)\uuid.obj
+
+OBJECTS = $(COMMONOBJS) $(GENERICOBJS) $(MSWOBJS)
+
+default:	wx
+
+wx:    $(CFG) $(DUMMY).obj $(OBJECTS) $(PERIPH_TARGET) $(LIBTARGET)
+
+all:	all_libs all_execs
+
+$(LIBTARGET): $(DUMMY).obj $(OBJECTS) $(BASEOBJECTS)
+	erase $(LIBTARGET)
+	tlib $(LIBTARGET) /P512 @&&!
+-+$(OBJECTS:.obj =.obj -+) -+$(BASEOBJECTS:.obj =.obj -+) -+$(PERIPH_LIBS:.lib =.lib -+)
+!
+
+dummy.obj: dummy.$(SRCSUFF) $(LOCALHEADERS) $(BASEHEADERS) $(WXDIR)\include\wx\wx.h
+dummydll.obj: dummydll.$(SRCSUFF) $(LOCALHEADERS) $(BASEHEADERS) $(WXDIR)\include\wx\wx.h
+
+$(MSWDIR)\y_tab.obj:     $(COMMDIR)\y_tab.c $(COMMDIR)\lex_yy.c
+
+#        cl @<<
+#$(CPPFLAGS2) /c $*.c -DUSE_DEFINE -DYY_USE_PROTOS /Fo$@
+#<<
+
+$(COMMDIR)\y_tab.c:     $(COMMDIR)\dosyacc.c
+        copy $(COMMDIR)\dosyacc.c $(COMMDIR)\y_tab.c
+
+$(COMMDIR)\lex_yy.c:    $(COMMDIR)\doslex.c
+    copy $(COMMDIR)\doslex.c $(COMMDIR)\lex_yy.c
+
+#$(OBJECTS):	$(WXDIR)\include\wx\setup.h
+
+$(MSWDIR)\app.obj:     $(MSWDIR)\app.$(SRCSUFF)
+
+$(MSWDIR)\bitmap.obj:     $(MSWDIR)\bitmap.$(SRCSUFF)
+
+$(MSWDIR)\bmpbuttn.obj:     $(MSWDIR)\bmpbuttn.$(SRCSUFF)
+
+$(MSWDIR)\brush.obj:     $(MSWDIR)\brush.$(SRCSUFF)
+
+$(MSWDIR)\button.obj:     $(MSWDIR)\button.$(SRCSUFF)
+
+$(MSWDIR)\choice.obj:     $(MSWDIR)\choice.$(SRCSUFF)
+
+$(MSWDIR)\checkbox.obj:     $(MSWDIR)\checkbox.$(SRCSUFF)
+
+$(MSWDIR)\checklst.obj:     $(MSWDIR)\checklst.$(SRCSUFF)
+
+$(MSWDIR)\clipbrd.obj:     $(MSWDIR)\clipbrd.$(SRCSUFF)
+
+$(MSWDIR)\colordlg.obj:     $(MSWDIR)\colordlg.$(SRCSUFF)
+
+$(MSWDIR)\colour.obj:     $(MSWDIR)\colour.$(SRCSUFF)
+
+$(MSWDIR)\combobox.obj:     $(MSWDIR)\combobox.$(SRCSUFF)
+
+$(MSWDIR)\control.obj:     $(MSWDIR)\control.$(SRCSUFF)
+
+$(MSWDIR)\curico.obj:     $(MSWDIR)\curico.$(SRCSUFF)
+
+$(MSWDIR)\cursor.obj:     $(MSWDIR)\cursor.$(SRCSUFF)
+
+$(MSWDIR)\data.obj:     $(MSWDIR)\data.$(SRCSUFF)
+
+$(MSWDIR)\dde.obj:     $(MSWDIR)\dde.$(SRCSUFF)
+
+$(MSWDIR)\dc.obj:     $(MSWDIR)\dc.$(SRCSUFF)
+
+$(MSWDIR)\dcmemory.obj:     $(MSWDIR)\dcmemory.$(SRCSUFF)
+
+$(MSWDIR)\dcclient.obj:     $(MSWDIR)\dcclient.$(SRCSUFF)
+
+$(MSWDIR)\dcprint.obj:     $(MSWDIR)\dcprint.$(SRCSUFF)
+
+$(MSWDIR)\dcscreen.obj:     $(MSWDIR)\dcscreen.$(SRCSUFF)
+
+$(MSWDIR)\dialog.obj:     $(MSWDIR)\dialog.$(SRCSUFF)
+
+$(MSWDIR)\dib.obj:     $(MSWDIR)\dib.$(SRCSUFF)
+
+$(MSWDIR)\dirdlg.obj:     $(MSWDIR)\dirdlg.$(SRCSUFF)
+
+$(MSWDIR)\filedlg.obj:     $(MSWDIR)\filedlg.$(SRCSUFF)
+
+$(MSWDIR)\font.obj:     $(MSWDIR)\font.$(SRCSUFF)
+
+$(MSWDIR)\fontdlg.obj:     $(MSWDIR)\fontdlg.$(SRCSUFF)
+
+$(MSWDIR)\frame.obj:     $(MSWDIR)\frame.$(SRCSUFF)
+
+$(MSWDIR)\gauge.obj:     $(MSWDIR)\gauge.$(SRCSUFF)
+
+$(MSWDIR)\gdiobj.obj:     $(MSWDIR)\gdiobj.$(SRCSUFF)
+
+$(MSWDIR)\icon.obj:     $(MSWDIR)\icon.$(SRCSUFF)
+
+$(MSWDIR)\imaglist.obj:     $(MSWDIR)\imaglist.$(SRCSUFF)
+
+$(MSWDIR)\joystick.obj:     $(MSWDIR)\joystick.$(SRCSUFF)
+
+$(MSWDIR)\listbox.obj:     $(MSWDIR)\listbox.$(SRCSUFF)
+
+$(MSWDIR)\listctrl.obj:     $(MSWDIR)\listctrl.$(SRCSUFF)
+
+$(MSWDIR)\main.obj:     $(MSWDIR)\main.$(SRCSUFF)
+
+$(MSWDIR)\mdi.obj:     $(MSWDIR)\mdi.$(SRCSUFF)
+
+$(MSWDIR)\menu.obj:     $(MSWDIR)\menu.$(SRCSUFF)
+
+$(MSWDIR)\menuitem.obj:     $(MSWDIR)\menu.$(SRCSUFF)
+
+$(MSWDIR)\metafile.obj:     $(MSWDIR)\metafile.$(SRCSUFF)
+
+$(MSWDIR)\minifram.obj:     $(MSWDIR)\minifram.$(SRCSUFF)
+
+$(MSWDIR)\msgdlg.obj:     $(MSWDIR)\msgdlg.$(SRCSUFF)
+
+$(MSWDIR)\nativdlg.obj:     $(MSWDIR)\nativdlg.$(SRCSUFF)
+
+$(MSWDIR)\ownerdrw.obj:     $(MSWDIR)\ownerdrw.$(SRCSUFF)
+
+$(MSWDIR)\palette.obj:     $(MSWDIR)\palette.$(SRCSUFF)
+
+$(MSWDIR)\pen.obj:     $(MSWDIR)\pen.$(SRCSUFF)
+
+$(MSWDIR)\penwin.obj:     $(MSWDIR)\penwin.$(SRCSUFF)
+
+$(MSWDIR)\printdlg.obj:     $(MSWDIR)\printdlg.$(SRCSUFF)
+
+$(MSWDIR)\printwin.obj:     $(MSWDIR)\printwin.$(SRCSUFF)
+
+$(MSWDIR)\radiobox.obj:     $(MSWDIR)\radiobox.$(SRCSUFF)
+
+$(MSWDIR)\radiobut.obj:     $(MSWDIR)\radiobut.$(SRCSUFF)
+
+$(MSWDIR)\region.obj:     $(MSWDIR)\region.$(SRCSUFF)
+
+$(MSWDIR)\registry.obj:     $(MSWDIR)\registry.$(SRCSUFF)
+
+$(MSWDIR)\scrolbar.obj:     $(MSWDIR)\scrolbar.$(SRCSUFF)
+
+$(MSWDIR)\settings.obj:     $(MSWDIR)\settings.$(SRCSUFF)
+
+$(MSWDIR)\slider.obj:     $(MSWDIR)\slider.$(SRCSUFF)
+
+$(MSWDIR)\spinbutt.obj:     $(MSWDIR)\spinbutt.$(SRCSUFF)
+
+$(MSWDIR)\statbmp.obj:     $(MSWDIR)\statbmp.$(SRCSUFF)
+
+$(MSWDIR)\statbox.obj:     $(MSWDIR)\statbox.$(SRCSUFF)
+
+$(MSWDIR)\statbr95.obj:     $(MSWDIR)\statbr95.$(SRCSUFF)
+
+$(MSWDIR)\stattext.obj:     $(MSWDIR)\stattext.$(SRCSUFF)
+
+$(MSWDIR)\tabctrl.obj:     $(MSWDIR)\tabctrl.$(SRCSUFF)
+
+$(MSWDIR)\taskbar.obj:     $(MSWDIR)\taskbar.$(SRCSUFF)
+
+$(MSWDIR)\tbar95.obj:     $(MSWDIR)\tbar95.$(SRCSUFF)
+
+$(MSWDIR)\tbarmsw.obj:     $(MSWDIR)\tbarmsw.$(SRCSUFF)
+
+$(MSWDIR)\textctrl.obj:     $(MSWDIR)\textctrl.$(SRCSUFF)
+
+$(MSWDIR)\thread.obj:     $(MSWDIR)\thread.$(SRCSUFF)
+
+$(MSWDIR)\timer.obj:     $(MSWDIR)\timer.$(SRCSUFF)
+
+$(MSWDIR)\treectrl.obj:     $(MSWDIR)\treectrl.$(SRCSUFF)
+
+$(MSWDIR)\utils.obj:     $(MSWDIR)\utils.$(SRCSUFF)
+
+$(MSWDIR)\wave.obj:     $(MSWDIR)\wave.$(SRCSUFF)
+
+$(MSWDIR)\window.obj:     $(MSWDIR)\window.$(SRCSUFF)
+
+$(MSWDIR)\droptgt.obj:     $(OLEDIR)\droptgt.$(SRCSUFF)
+
+$(MSWDIR)\oleutils.obj:     $(OLEDIR)\oleutils.$(SRCSUFF)
+
+$(MSWDIR)\uuid.obj:     $(OLEDIR)\uuid.$(SRCSUFF)
+
+########################################################
+# Common objects (always compiled)
+
+$(MSWDIR)\config.obj:     $(COMMDIR)\config.$(SRCSUFF)
+
+$(MSWDIR)\cmndata.obj:     $(COMMDIR)\cmndata.$(SRCSUFF)
+
+$(MSWDIR)\docview.obj:     $(COMMDIR)\docview.$(SRCSUFF)
+
+$(MSWDIR)\dynarray.obj:     $(COMMDIR)\dynarray.$(SRCSUFF)
+
+$(MSWDIR)\event.obj:     $(COMMDIR)\event.$(SRCSUFF)
+
+$(MSWDIR)\file.obj:     $(COMMDIR)\file.$(SRCSUFF)
+
+$(MSWDIR)\fileconf.obj:     $(COMMDIR)\fileconf.$(SRCSUFF)
+
+$(MSWDIR)\filefn.obj:     $(COMMDIR)\filefn.$(SRCSUFF)
+
+$(MSWDIR)\gdicmn.obj:     $(COMMDIR)\gdicmn.$(SRCSUFF)
+
+$(MSWDIR)\intl.obj:     $(COMMDIR)\intl.$(SRCSUFF)
+
+$(MSWDIR)\ipcbase.obj:     $(COMMDIR)\ipcbase.$(SRCSUFF)
+
+$(MSWDIR)\helpbase.obj:     $(COMMDIR)\helpbase.$(SRCSUFF)
+
+$(MSWDIR)\layout.obj:     $(COMMDIR)\layout.$(SRCSUFF)
+
+$(MSWDIR)\log.obj:     $(COMMDIR)\log.$(SRCSUFF)
+
+$(MSWDIR)\memory.obj:     $(COMMDIR)\memory.$(SRCSUFF)
+
+$(MSWDIR)\module.obj:     $(COMMDIR)\module.$(SRCSUFF)
+
+$(MSWDIR)\object.obj:     $(COMMDIR)\object.$(SRCSUFF)
+
+$(MSWDIR)\odbc.obj:     $(COMMDIR)\odbc.$(SRCSUFF)
+
+$(MSWDIR)\postscrp.obj:     $(COMMDIR)\postscrp.$(SRCSUFF)
+
+$(MSWDIR)\prntbase.obj:     $(COMMDIR)\prntbase.$(SRCSUFF)
+
+$(MSWDIR)\resource.obj:     $(COMMDIR)\resource.$(SRCSUFF)
+
+$(MSWDIR)\tbarbase.obj:     $(COMMDIR)\tbarbase.$(SRCSUFF)
+
+$(MSWDIR)\tbarsmpl.obj:     $(COMMDIR)\tbarsmpl.$(SRCSUFF)
+
+$(MSWDIR)\textfile.obj:     $(COMMDIR)\textfile.$(SRCSUFF)
+
+$(MSWDIR)\timercmn.obj:     $(COMMDIR)\timercmn.$(SRCSUFF)
+
+$(MSWDIR)\utilscmn.obj:     $(COMMDIR)\utilscmn.$(SRCSUFF)
+
+$(MSWDIR)\validate.obj:     $(COMMDIR)\validate.$(SRCSUFF)
+
+$(MSWDIR)\valtext.obj:     $(COMMDIR)\valtext.$(SRCSUFF)
+
+$(MSWDIR)\date.obj:     $(COMMDIR)\date.$(SRCSUFF)
+
+$(MSWDIR)\wxexpr.obj:     $(COMMDIR)\wxexpr.$(SRCSUFF)
+
+$(MSWDIR)\hash.obj:     $(COMMDIR)\hash.$(SRCSUFF)
+
+$(MSWDIR)\list.obj:     $(COMMDIR)\list.$(SRCSUFF)
+
+$(MSWDIR)\string.obj:     $(COMMDIR)\string.$(SRCSUFF)
+
+$(MSWDIR)\matrix.obj:     $(COMMDIR)\matrix.$(SRCSUFF)
+
+$(MSWDIR)\time.obj:     $(COMMDIR)\time.$(SRCSUFF)
+
+########################################################
+# Generic objects (not always compiled, depending on
+# whether platforms have native implementations)
+
+$(MSWDIR)\choicdgg.obj:     $(GENDIR)\choicdgg.$(SRCSUFF)
+
+$(MSWDIR)\colrdlgg.obj:     $(GENDIR)\colrdlgg.$(SRCSUFF)
+
+$(MSWDIR)\fontdlgg.obj:     $(GENDIR)\fontdlgg.$(SRCSUFF)
+
+$(MSWDIR)\gridg.obj:     $(GENDIR)\gridg.$(SRCSUFF)
+
+$(MSWDIR)\helpxlp.obj:     $(GENDIR)\helpxlp.$(SRCSUFF)
+
+$(MSWDIR)\msgdlgg.obj:     $(GENDIR)\msgdlgg.$(SRCSUFF)
+
+$(MSWDIR)\panelg.obj:     $(GENDIR)\panelg.$(SRCSUFF)
+
+$(MSWDIR)\printps.obj:     $(GENDIR)\printps.$(SRCSUFF)
+
+$(MSWDIR)\prntdlgg.obj:     $(GENDIR)\prntdlgg.$(SRCSUFF)
+
+$(MSWDIR)\scrolwin.obj:     $(GENDIR)\scrolwin.$(SRCSUFF)
+
+$(MSWDIR)\splitter.obj:     $(GENDIR)\splitter.$(SRCSUFF)
+
+$(MSWDIR)\statusbr.obj:     $(GENDIR)\statusbr.$(SRCSUFF)
+
+$(MSWDIR)\textdlgg.obj:     $(GENDIR)\textdlgg.$(SRCSUFF)
+
+$(MSWDIR)\tabg.obj:     $(GENDIR)\tabg.$(SRCSUFF)
+
+all_utils:
+    cd $(WXDIR)\utils
+    make -f makefile.b32
+    cd $(WXDIR)\src\msw
+
+all_samples:
+    cd $(WXDIR)\samples
+    make -f makefile.b32
+    cd $(WXDIR)\src\msw
+
+all_execs:
+    cd $(WXDIR)\utils
+    make -f makefile.b32 all_execs
+    cd $(WXDIR)\src\msw
+
+all_libs:
+    cd $(WXDIR)\src\msw
+    make -f makefile.b32 ctl3d dib fafa gauge hytext itsy prologio rcparser wx wxgraph\
+          wxstring wxtree mfutils # wxxpm
+
+all_contribs:
+    cd $(WXDIR)\src\msw
+    make -f makefile.b32 ctl3d fafa wxstring itsy gauge # wxxpm
+
+# CONTRIB
+ctl3d:  $(CFG)
+        cd $(WXDIR)\src\msw\ctl3d\borland
+        make -f makefile.b32 -DCFG=$(CFG)
+        cd $(WXDIR)\src\msw
+
+wxxpm:	$(CFG)
+	cd $(WXDIR)\src\common\wxxpm
+	make -f makefile.b32 -DCFG=$(CFG) -DFINAL=$(FINAL) -DWXWIN=$(WXDIR) -DDEBUG=$(DEBUG)
+	cd $(WXDIR)\src\msw
+
+$(CFG): makefile.b32
+	copy &&!
+-H=$(WXDIR)\src\msw\wx32.csm
+-3
+-P
+-d
+-w-hid
+-w-par
+-w-pia
+-w-aus
+-w-rch
+-Oxt
+-WE
+
+-I$(WXINC);$(BCCDIR)\include
+-I$(WXDIR)\include\msw\gnuwin32
+
+-L$(BCCDIR)\lib
+-D__WXWIN__
+-D__WINDOWS__
+-DWIN32
+$(OPT)
+$(DEBUG_FLAGS)
+$(WIN95FLAG)
+! $(CFG)
+
+#-I$(WXDIR)\src\common\wxxpm\libxpm.34b\lib
+
+clean: $(PERIPH_CLEAN_TARGET)
+    erase $(LIBTARGET)
+    erase *.obj
+    erase *.pch
+    erase *.csm
+    erase *.cfg
+	erase ..\common\y_tab.c
+    erase ..\common\lex_yy.c
+
+cleanall: clean
+
+
diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc
new file mode 100644
index 0000000000..8270dc47cc
--- /dev/null
+++ b/src/msw/makefile.bcc
@@ -0,0 +1,407 @@
+#
+# File:		makefile.bcc
+# Author:	Julian Smart
+# Created:	1993
+# Updated:	
+# Copyright:	(c) 1993, AIAI, University of Edinburgh
+#
+# "%W% %G%"
+#
+# Makefile : Builds wxWindows library wx.lib for Windows 3.1
+# and Borland C++ 3.1
+
+!if "$(BCCDIR)" == ""
+!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4
+!endif
+
+!if "$(WXWIN)" == ""
+!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
+!endif
+
+!if "$(CFG)" == ""
+#!error You must start compiling from wx\src, not wx\src\msw.
+!endif
+
+!ifndef DEBUG
+DEBUG=0
+!endif
+
+WXDIR = $(WXWIN)
+
+!include $(WXDIR)\src\makebcc.env
+
+THISDIR = $(WXDIR)\src\msw
+WXLIB = $(WXDIR)\lib
+WXINC = $(WXDIR)\include\msw
+WXBASESRC = $(WXDIR)\src\base
+WXBASEINC = $(WXDIR)\include\base
+
+# Please set these according to the settings in wx_setup.h, so we can include
+# the appropriate libraries in wx.lib
+USE_CTL3D=1
+USE_ITSYBITS=1
+USE_GAUGE=1
+USE_IMAGE_LOADING_IN_MSW=1
+USE_XPM_IN_MSW=0
+USE_WX_RESOURCES=1
+USE_RESOURCE_LOADING_IN_MSW=1
+USE_GNU_WXSTRING=1
+
+PERIPH_LIBS=
+PERIPH_TARGET=
+PERIPH_CLEAN_TARGET=
+
+!if "$(USE_CTL3D)" == "1"
+PERIPH_LIBS=$(WXDIR)\lib\ctl3dv2.lib $(PERIPH_LIBS)
+PERIPH_TARGET=ctl3d $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_ctl3d $(PERIPH_CLEAN_TARGET)
+!endif
+
+!if "$(USE_ITSYBITS)" == "1"
+PERIPH_LIBS=$(WXDIR)\contrib\itsybits\itsy.lib $(PERIPH_LIBS)
+PERIPH_TARGET=itsy $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_itsy $(PERIPH_CLEAN_TARGET)
+!endif
+
+!if "$(USE_GAUGE)" == "1"
+PERIPH_LIBS=$(WXDIR)\contrib\gauge\gauge.lib $(PERIPH_LIBS)
+PERIPH_TARGET=gauge $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_gauge $(PERIPH_CLEAN_TARGET)
+!endif
+
+!if "$(USE_XPM_IN_MSW)" == "1"
+PERIPH_LIBS=$(WXDIR)\contrib\wxxpm\xpm.lib $(PERIPH_LIBS)
+PERIPH_TARGET=xpm $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_xpm $(PERIPH_CLEAN_TARGET)
+!endif
+
+!if "$(USE_IMAGE_LOADING_IN_MSW)" == "1"
+PERIPH_LIBS=$(WXDIR)\utils\dib\dib.lib $(PERIPH_LIBS)
+PERIPH_TARGET=dib $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_dib $(PERIPH_CLEAN_TARGET)
+!endif
+
+!if "$(USE_WX_RESOURCES)" == "1"
+PERIPH_LIBS=$(WXDIR)\utils\prologio\lib\prologio.lib $(PERIPH_LIBS)
+PERIPH_TARGET=prologio $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_proio $(PERIPH_CLEAN_TARGET)
+!endif
+
+!if "$(USE_RESOURCE_LOADING_IN_MSW)" == "1"
+PERIPH_LIBS=$(WXDIR)\utils\rcparser\lib\rcparser.lib $(PERIPH_LIBS)
+PERIPH_TARGET=rcparser $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_rcp $(PERIPH_CLEAN_TARGET)
+!endif
+
+WXSTRINGOBJ=..\base\wxstring.obj
+
+!if "$(USE_GNU_WXSTRING)" == "1"
+PERIPH_LIBS=$(WXDIR)\contrib\wxstring\wxstring.lib $(PERIPH_LIBS)
+PERIPH_TARGET=wxstring $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_wxstring $(PERIPH_CLEAN_TARGET)
+WXSTRINGOBJ=
+!endif
+
+CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
+
+LIBTARGET= $(WXLIB)\wx.lib
+DUMMY=dummy
+
+BASEHEADERS = $(WXBASEINC)\wx_defs.h \
+  $(WXBASEINC)\wb_buttn.h \
+  $(WXBASEINC)\wb_canvs.h \
+  $(WXBASEINC)\wb_check.h \
+  $(WXBASEINC)\wb_choic.h \
+  $(WXBASEINC)\wb_dc.h \
+  $(WXBASEINC)\wb_dccan.h \
+  $(WXBASEINC)\wb_dcmem.h \
+  $(WXBASEINC)\wb_dialg.h \
+  $(WXBASEINC)\wb_frame.h \
+  $(WXBASEINC)\wb_gdi.h \
+  $(WXBASEINC)\wb_ipc.h \
+  $(WXBASEINC)\wb_ipcob.h \
+  $(WXBASEINC)\wb_item.h \
+  $(WXBASEINC)\wb_lbox.h \
+  $(WXBASEINC)\wb_main.h \
+  $(WXBASEINC)\wb_menu.h \
+  $(WXBASEINC)\wb_messg.h \
+  $(WXBASEINC)\wb_mf.h \
+  $(WXBASEINC)\wb_mnuit.h \
+  $(WXBASEINC)\wb_mtxt.h \
+  $(WXBASEINC)\wb_panel.h \
+  $(WXBASEINC)\wb_slidr.h \
+  $(WXBASEINC)\wb_text.h \
+  $(WXBASEINC)\wb_timer.h \
+  $(WXBASEINC)\wb_txt.h \
+  $(WXBASEINC)\wb_win.h \
+  $(WXBASEINC)\wx_dcps.h \
+  $(WXBASEINC)\wx_form.h \
+  $(WXBASEINC)\wx_hash.h \
+  $(WXBASEINC)\wx_help.h \
+  $(WXBASEINC)\wx_list.h \
+  $(WXBASEINC)\wxstring.h \
+  $(WXBASEINC)\wx_mgstr.h \
+  $(WXBASEINC)\wx_obj.h \
+  $(WXBASEINC)\wx_stdev.h \
+  $(WXBASEINC)\wx_sysev.h \
+  $(WXBASEINC)\wx_types.h \
+  $(WXBASEINC)\wx_utils.h
+
+LOCALHEADERS = \
+  $(WXINC)\wx_buttn.h \
+  $(WXINC)\wx_canvs.h \
+  $(WXINC)\wx_check.h \
+  $(WXINC)\wx_choic.h \
+  $(WXINC)\wx_combo.h \
+  $(WXINC)\wx_dc.h \
+  $(WXINC)\wx_dccan.h \
+  $(WXINC)\wx_dcmem.h \
+  $(WXINC)\wx_dialg.h \
+  $(WXINC)\wx_frame.h \
+  $(WXINC)\wx_gdi.h \
+  $(WXINC)\wx_ipc.h \
+  $(WXINC)\wx_ipcob.h \
+  $(WXINC)\wx_item.h \
+  $(WXINC)\wx_lbox.h \
+  $(WXINC)\wx_main.h \
+  $(WXINC)\wx_menu.h \
+  $(WXINC)\wx_messg.h \
+  $(WXINC)\wx_mf.h \
+  $(WXINC)\wx_mnuit.h \
+  $(WXINC)\wx_mtxt.h \
+  $(WXINC)\wx_panel.h \
+  $(WXINC)\wx_privt.h \
+  $(WXINC)\wx_slidr.h \
+  $(WXINC)\wx_text.h \
+  $(WXINC)\wx_timer.h \
+  $(WXINC)\wx_txt.h \
+  $(WXINC)\wx_win.h
+
+OBJECTS1 = wx_win.obj wx_frame.obj wx_panel.obj wx_utils.obj wx_main.obj\
+  wx_item.obj
+
+OBJECTS2 = wx_text.obj wx_gdi.obj wx_dialg.obj wx_canvs.obj wx_dc.obj wx_mf.obj
+
+OBJECTS3 = wx_ipc.obj wx_timer.obj wx_clipb.obj wx_stat.obj wx_scrol.obj wx_vlbox.obj
+
+OBJECTS4 = wx_buttn.obj wx_messg.obj wx_check.obj wx_choic.obj wx_rbox.obj wx_lbox.obj \
+ wx_group.obj wx_gauge.obj wx_txt.obj wx_mtxt.obj wx_slidr.obj wx_menu.obj wx_db.obj\
+ wx_cmdlg.obj wx_combo.obj
+
+OBJECTS = $(OBJECTS1) $(OBJECTS2) $(OBJECTS3) $(OBJECTS4)
+
+BASEOBJECTS1 = ..\base\wb_data.obj ..\base\wb_win.obj ..\base\wb_frame.obj ..\base\wb_panel.obj\
+  ..\base\wb_utils.obj ..\base\wb_main.obj ..\base\wb_res.obj
+
+BASEOBJECTS2 = ..\base\wb_item.obj ..\base\wb_list.obj ..\base\wb_obj.obj\
+  ..\base\wb_ps.obj ..\base\wx_doc.obj ..\base\wx_tbar.obj ..\base\wx_bbar.obj
+
+BASEOBJECTS3 = ..\base\wb_text.obj ..\base\wb_gdi.obj ..\base\wb_dialg.obj\
+  ..\base\wb_canvs.obj ..\base\wx_date.obj ..\base\wx_time.obj ..\base\wx_frac.obj
+
+BASEOBJECTS4 = ..\base\wb_dc.obj ..\base\wb_mf.obj ..\base\wb_hash.obj\
+  ..\base\wb_ipc.obj ..\base\wx_lay.obj ..\base\wx_mem.obj ..\base\wb_cmdlg.obj
+
+BASEOBJECTS5 = ..\base\wb_form.obj ..\base\wb_timer.obj ..\base\wb_help.obj\
+  ..\base\wb_vlbox.obj ..\base\wb_scrol.obj ..\base\wb_stat.obj
+
+BASEOBJECTS6 = ..\base\wb_sysev.obj ..\base\wb_stdev.obj ..\base\wb_types.obj\
+  ..\base\wb_mgstr.obj ..\base\wb_print.obj $(WXSTRINGOBJ)
+
+BASEOBJECTS = $(BASEOBJECTS1) $(BASEOBJECTS2) $(BASEOBJECTS3)\
+  $(BASEOBJECTS4) $(BASEOBJECTS5) $(BASEOBJECTS6)
+
+
+all:    $(CFG) $(DUMMY).obj base $(OBJECTS) $(PERIPH_TARGET) $(LIBTARGET)
+
+base:
+	cd $(WXBASESRC)
+	make -f makefile.bcc -DCFG=$(CFG) -DWXDIR=$(WXDIR) DEBUG=$(DEBUG) -DDEBUG_FLAGS=$(DEBUG_FLAGS) -DOPT=$(OPT) -DFINAL=$(FINAL)
+	cd $(THISDIR)
+
+$(LIBTARGET): $(DUMMY).obj $(OBJECTS) $(BASEOBJECTS) $(PERIPH_LIBS)
+	erase $(LIBTARGET)
+	tlib $(WXLIB)\wx.lib /P512 @&&!
++$(OBJECTS:.obj =.obj +) +$(BASEOBJECTS:.obj =.obj +) +$(PERIPH_LIBS:.lib =.lib +)
+!
+
+dummy.obj: dummy.$(SRCSUFF) $(LOCALHEADERS) $(BASEHEADERS) $(WXDIR)\include\base\wx.h
+	
+
+dummydll.obj: dummydll.$(SRCSUFF) $(LOCALHEADERS) $(BASEHEADERS) $(WXDIR)\include\base\wx.h
+
+wx_obj.obj:     $(WXBASEINC)\wx_obj.h
+
+wx_win.obj:     $(WXBASEINC)\wx_defs.h $(WXINC)\wx_win.h $(WXBASEINC)\wx_obj.h \
+  $(WXBASEINC)\wx_utils.h wx_win.$(SRCSUFF) $(WXINC)\wx_gdi.h $(WXINC)\wx_privt.h
+
+wx_main.obj:   $(WXBASEINC)\wx_defs.h $(WXBASEINC)\wx_obj.h $(WXINC)\wx_frame.h $(WXBASEINC)\wx_utils.h \
+  $(WXINC)\wx_main.h wx_main.$(SRCSUFF) $(WXINC)\wx_privt.h
+
+wx_frame.obj:   $(WXBASEINC)\wx_defs.h $(WXINC)\wx_win.h $(WXBASEINC)\wx_obj.h $(WXBASEINC)\wx_utils.h $(WXINC)\wx_frame.h wx_frame.$(SRCSUFF)\
+		$(WXBASEINC)\wx_stdev.h $(WXINC)\wx_privt.h
+
+wx_panel.obj:   $(WXBASEINC)\wx_defs.h $(WXINC)\wx_win.h $(WXBASEINC)\wx_obj.h $(WXBASEINC)\wx_utils.h $(WXINC)\wx_frame.h $(WXINC)\wx_panel.h\
+		wx_panel.$(SRCSUFF) $(WXBASEINC)\wx_stdev.h $(WXINC)\wx_privt.h
+
+wx_text.obj:    $(WXBASEINC)\wx_defs.h $(WXINC)\wx_win.h $(WXBASEINC)\wx_obj.h $(WXBASEINC)\wx_utils.h $(WXINC)\wx_frame.h $(WXINC)\wx_text.h\
+		wx_text.$(SRCSUFF) $(WXBASEINC)\wx_stdev.h $(WXINC)\wx_privt.h
+
+wx_canvs.obj:    $(WXBASEINC)\wx_defs.h $(WXINC)\wx_win.h $(WXBASEINC)\wx_obj.h $(WXBASEINC)\wx_utils.h $(WXINC)\wx_frame.h $(WXINC)\wx_canvs.h\
+		 wx_canvs.$(SRCSUFF) $(WXBASEINC)\wx_stdev.h $(WXINC)\wx_gdi.h\
+		 $(WXINC)\wx_dc.h $(WXINC)\wx_privt.h
+
+wx_dc.obj:    $(WXBASEINC)\wx_defs.h $(WXINC)\wx_win.h $(WXBASEINC)\wx_obj.h $(WXBASEINC)\wx_utils.h $(WXINC)\wx_frame.h $(WXINC)\wx_canvs.h\
+		 wx_dc.$(SRCSUFF) $(WXBASEINC)\wx_stdev.h $(WXINC)\wx_gdi.h $(WXINC)\wx_dc.h\
+	$(WXINC)\wx_dccan.h $(WXINC)\wx_dcmem.h
+
+wx_mf.obj:    $(WXBASEINC)\wx_defs.h $(WXINC)\wx_win.h $(WXBASEINC)\wx_obj.h\
+		 wx_mf.$(SRCSUFF) $(WXBASEINC)\wx_stdev.h $(WXINC)\wx_gdi.h $(WXINC)\wx_mf.h
+	
+wx_item.obj:    $(WXBASEINC)\wx_defs.h $(WXINC)\wx_win.h $(WXBASEINC)\wx_obj.h $(WXBASEINC)\wx_utils.h $(WXINC)\wx_frame.h $(WXINC)\wx_item.h\
+		wx_item.$(SRCSUFF) $(WXBASEINC)\wx_stdev.h $(WXINC)\wx_privt.h
+	
+wx_utils.obj:   $(WXBASEINC)\wx_defs.h $(WXBASEINC)\wx_obj.h $(WXBASEINC)\wx_utils.h wx_utils.$(SRCSUFF)
+	
+wx_ipc.obj:   $(WXBASEINC)\wx_defs.h $(WXBASEINC)\wx_obj.h $(WXBASEINC)\wx_utils.h $(WXINC)\wx_ipc.h wx_ipc.$(SRCSUFF)
+	
+wx_gdi.obj:   $(WXBASEINC)\wx_defs.h $(WXINC)\wx_gdi.h $(WXBASEINC)\wx_utils.h wx_gdi.$(SRCSUFF)
+	
+wx_dialg.obj:   $(WXBASEINC)\wx_defs.h wx_dialg.$(SRCSUFF) $(WXINC)\wx_dialg.h $(WXINC)\wx_win.h\
+  $(WXBASEINC)\wx_utils.h $(WXINC)\wx_panel.h $(WXINC)\wx_privt.h
+	
+wx_timer.obj:   $(WXBASEINC)\wx_defs.h wx_timer.$(SRCSUFF) $(WXINC)\wx_timer.h
+	
+wx_clipb.obj:   $(WXBASEINC)\wx_defs.h wx_clipb.$(SRCSUFF) $(WXINC)\wx_clipb.h
+
+wx_stat.obj:   $(WXBASEINC)\wx_defs.h wx_stat.$(SRCSUFF)
+wx_vlbox.obj:   $(WXBASEINC)\wx_defs.h wx_vlbox.$(SRCSUFF)
+wx_messg.obj:   $(WXBASEINC)\wx_defs.h wx_messg.$(SRCSUFF) $(WXINC)\wx_messg.h
+wx_buttn.obj:   $(WXBASEINC)\wx_defs.h wx_buttn.$(SRCSUFF) $(WXINC)\wx_buttn.h
+wx_check.obj:   $(WXBASEINC)\wx_defs.h wx_check.$(SRCSUFF) $(WXINC)\wx_check.h
+wx_choic.obj:   $(WXBASEINC)\wx_defs.h wx_choic.$(SRCSUFF) $(WXINC)\wx_choic.h
+wx_combo.obj:   $(WXBASEINC)\wx_defs.h wx_combo.$(SRCSUFF) $(WXINC)\wx_combo.h
+wx_group.obj:   $(WXBASEINC)\wx_defs.h wx_group.$(SRCSUFF) $(WXINC)\wx_group.h
+wx_gauge.obj:   $(WXBASEINC)\wx_defs.h wx_gauge.$(SRCSUFF) $(WXINC)\wx_gauge.h
+wx_lbox.obj:   $(WXBASEINC)\wx_defs.h wx_lbox.$(SRCSUFF) $(WXINC)\wx_lbox.h
+wx_rbox.obj:   $(WXBASEINC)\wx_defs.h wx_rbox.$(SRCSUFF) $(WXINC)\wx_rbox.h
+wx_menu.obj:   $(WXBASEINC)\wx_defs.h wx_menu.$(SRCSUFF) $(WXINC)\wx_menu.h
+wx_txt.obj:   $(WXBASEINC)\wx_defs.h wx_txt.$(SRCSUFF) $(WXINC)\wx_txt.h
+wx_mtxt.obj:   $(WXBASEINC)\wx_defs.h wx_mtxt.$(SRCSUFF) $(WXINC)\wx_mtxt.h
+wx_slidr.obj:   $(WXBASEINC)\wx_defs.h wx_slidr.$(SRCSUFF) $(WXINC)\wx_slidr.h
+wx_db.obj:   $(WXBASEINC)\wx_defs.h wx_db.$(SRCSUFF) $(WXINC)\wx_db.h
+wx_cmdlg.obj:   $(WXBASEINC)\wx_defs.h wx_cmdlg.$(SRCSUFF) $(WXINC)\wx_cmdlg.h
+
+$(WXINC)\wx_win.h:  $(WXBASEINC)\wb_win.h
+$(WXINC)\wx_main.h:  $(WXBASEINC)\wb_main.h
+$(WXINC)\wx_frame.h:  $(WXBASEINC)\wb_frame.h
+$(WXINC)\wx_panel.h:  $(WXBASEINC)\wb_panel.h
+$(WXINC)\wx_text.h:  $(WXBASEINC)\wb_text.h
+$(WXINC)\wx_dialg.h:  $(WXBASEINC)\wb_dialg.h
+$(WXINC)\wx_ipc.h:  $(WXBASEINC)\wb_ipc.h
+$(WXINC)\wx_gdi.h:  $(WXBASEINC)\wb_gdi.h
+$(WXINC)\wx_event.h:  $(WXBASEINC)\wb_event.h
+$(WXINC)\wx_canvs.h:  $(WXBASEINC)\wb_canvs.h
+$(WXINC)\wx_mf.h:  $(WXBASEINC)\wb_mf.h
+$(WXINC)\wx_item.h:  $(WXBASEINC)\wb_item.h
+$(WXINC)\wx_buttn.h:  $(WXBASEINC)\wb_buttn.h
+$(WXINC)\wx_messg.h:  $(WXBASEINC)\wb_messg.h
+$(WXINC)\wx_choic.h:  $(WXBASEINC)\wb_choic.h
+$(WXINC)\wx_combo.h:  $(WXBASEINC)\wb_combo.h
+$(WXINC)\wx_check.h:  $(WXBASEINC)\wb_check.h
+$(WXINC)\wx_lbox.h:  $(WXBASEINC)\wb_lbox.h
+$(WXINC)\wx_txt.h:  $(WXBASEINC)\wb_txt.h
+$(WXINC)\wx_mtxt.h:  $(WXBASEINC)\wb_mtxt.h
+$(WXINC)\wx_slidr.h:  $(WXBASEINC)\wb_slidr.h
+$(WXINC)\wx_menu.h:  $(WXBASEINC)\wb_menu.h
+
+# Peripheral components
+
+ctl3d:
+    cd $(WXDIR)\contrib\ctl3d\borland
+    make -f makefile.bcc DEBUG=$(DEBUG) 
+    cd $(WXDIR)\src\msw
+
+clean_ctl3d:
+    cd $(WXDIR)\contrib\ctl3d\borland
+    make -f makefile.bcc clean
+    cd $(WXDIR)\src\msw
+
+itsy:
+    cd $(WXDIR)\contrib\itsybits
+    make -f makefile.bcc DEBUG=$(DEBUG) 
+    cd $(WXDIR)\src\msw
+
+clean_itsy:
+    cd $(WXDIR)\contrib\itsybits
+    make -f makefile.bcc clean
+    cd $(WXDIR)\src\msw
+
+gauge:
+    cd $(WXDIR)\contrib\gauge
+    make -f makefile.bcc DEBUG=$(DEBUG) 
+    cd $(WXDIR)\src\msw
+
+clean_gauge:
+    cd $(WXDIR)\contrib\gauge
+    make -f makefile.bcc clean
+    cd $(WXDIR)\src\msw
+
+xpm:
+    cd $(WXDIR)\contrib\wxxpm
+    make -f makefile.bcc DEBUG=$(DEBUG) 
+    cd $(WXDIR)\src\msw
+
+clean_xpm:
+    cd $(WXDIR)\contrib\wxxpm
+    make -f makefile.bcc clean
+    cd $(WXDIR)\src\msw
+
+dib:
+    cd $(WXDIR)\utils\dib
+    make -f makefile.bcc DEBUG=$(DEBUG) 
+    cd $(WXDIR)\src\msw
+
+clean_dib:
+    cd $(WXDIR)\utils\dib
+    make -f makefile.bcc clean
+    cd $(WXDIR)\src\msw
+
+prologio:
+    cd $(WXDIR)\utils\prologio\src
+    make -f makefile.bcc DEBUG=$(DEBUG) 
+    cd $(WXDIR)\src\msw
+
+clean_proio:
+    cd $(WXDIR)\utils\prologio\src
+    make -f makefile.bcc clean
+    cd $(WXDIR)\src\msw
+
+rcparser:
+    cd $(WXDIR)\utils\rcparser\src
+    make -f makefile.bcc DEBUG=$(DEBUG) 
+    cd $(WXDIR)\src\msw
+
+wxstring:
+    cd $(WXDIR)\contrib\wxstring
+    make -f makefile.bcc OPTIONS="$(OPTIONS)" DEBUG="$(DEBUG)"
+    cd $(WXDIR)\src\msw
+
+clean_wxstring:
+    cd $(WXDIR)\contrib\wxstring
+    make -f makefile.bcc clean
+    cd $(WXDIR)\src\msw
+
+clean_rcp:
+    cd $(WXDIR)\utils\rcparser\src
+    make -f makefile.bcc clean
+    cd $(WXDIR)\src\msw
+
+clean: $(PERIPH_CLEAN_TARGET)
+    erase $(LIBTARGET)
+    cd $(WXDIR)\src\base
+    erase *.obj
+    cd $(WXDIR)\src\msw
+    erase *.obj
+
+cleanall: clean
diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos
new file mode 100644
index 0000000000..2116473922
--- /dev/null
+++ b/src/msw/makefile.dos
@@ -0,0 +1,1143 @@
+#
+# File:		makefile.dos
+# Author:	Julian Smart
+# Created:	1997
+# Updated:	
+# Copyright:	(c) 1997, Julian Smart
+#
+# "%W% %G%"
+#
+# Makefile : Builds wxWindows library wx.lib for VC++ (16-bit)
+# Arguments:
+#
+# FINAL=1 argument to nmake to build version with no debugging info.
+#
+!include <..\makemsc.env>
+
+LIBTARGET=$(WXLIB)
+DUMMYOBJ=dummy.obj
+
+# Please set these according to the settings in wx_setup.h, so we can include
+# the appropriate libraries in wx.lib
+
+# This one overrides the others, to be consistent with the settings in wx_setup.h
+MINIMAL_WXWINDOWS_SETUP=0
+
+USE_CTL3D=1
+USE_XPM_IN_MSW=0
+
+!if "$(MINIMAL_WXWINDOWS_SETUP)" == "1"
+USE_CTL3D=0
+USE_IMAGE_LOADING_IN_MSW=0
+USE_XPM_IN_MSW=0
+USE_GNU_WXSTRING=0
+!endif
+
+PERIPH_LIBS=
+PERIPH_TARGET=
+PERIPH_CLEAN_TARGET=
+
+# !if "$(USE_CTL3D)" == "1"
+# PERIPH_LIBS=d:\msdev\lib\ctl3d32.lib $(PERIPH_LIBS)
+# !endif
+
+!if "$(USE_XPM_IN_MSW)" == "1"
+PERIPH_LIBS=$(WXDIR)\contrib\wxxpm\xpm.lib $(PERIPH_LIBS)
+PERIPH_TARGET=xpm $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_xpm $(PERIPH_CLEAN_TARGET)
+!endif
+
+GENDIR=..\generic
+COMMDIR=..\common
+OLEDIR=.\ole
+MSWDIR=.
+
+DOCDIR = $(WXDIR)\docs
+
+GENERICOBJS= \
+  $(GENDIR)\choicdgg.obj \
+  $(GENDIR)\colrdlgg.obj \
+  $(GENDIR)\fontdlgg.obj \
+  $(GENDIR)\gridg.obj \
+  $(GENDIR)\helpxlp.obj \
+  $(GENDIR)\msgdlgg.obj \
+  $(GENDIR)\panelg.obj \
+  $(GENDIR)\printps.obj \
+  $(GENDIR)\prntdlgg.obj \
+  $(GENDIR)\scrolwin.obj \
+  $(GENDIR)\splitter.obj \
+  $(GENDIR)\statusbr.obj \
+  $(GENDIR)\tabg.obj \
+  $(GENDIR)\textdlgg.obj
+
+COMMONOBJS = \
+  $(COMMDIR)\config.obj \
+  $(COMMDIR)\cmndata.obj \
+  $(COMMDIR)\docview.obj \
+  $(COMMDIR)\dynarray.obj \
+  $(COMMDIR)\event.obj \
+  $(COMMDIR)\file.obj \
+  $(COMMDIR)\filefn.obj \
+  $(COMMDIR)\gdicmn.obj \
+  $(COMMDIR)\intl.obj \
+  $(COMMDIR)\helpbase.obj \
+  $(COMMDIR)\ipcbase.obj \
+  $(COMMDIR)\layout.obj \
+  $(COMMDIR)\log.obj \
+  $(COMMDIR)\memory.obj \
+  $(COMMDIR)\module.obj \
+  $(COMMDIR)\object.obj \
+  $(COMMDIR)\odbc.obj \
+  $(COMMDIR)\postscrp.obj \
+  $(COMMDIR)\prntbase.obj \
+  $(COMMDIR)\resource.obj \
+  $(COMMDIR)\tbarbase.obj \
+  $(COMMDIR)\tbarsmpl.obj \
+  $(COMMDIR)\textfile.obj \
+  $(COMMDIR)\timercmn.obj \
+  $(COMMDIR)\utilscmn.obj \
+  $(COMMDIR)\validate.obj \
+  $(COMMDIR)\valtext.obj \
+  $(COMMDIR)\date.obj \
+  $(COMMDIR)\wxexpr.obj \
+  $(COMMDIR)\hash.obj \
+  $(COMMDIR)\list.obj \
+  $(COMMDIR)\string.obj \
+  $(COMMDIR)\time.obj \
+  $(COMMDIR)\y_tab.obj
+
+# Nested classes: won't comple
+#  $(COMMDIR)\fileconf.obj \
+
+MSWOBJS = \
+  $(MSWDIR)\app.obj \
+  $(MSWDIR)\bitmap.obj \
+  $(MSWDIR)\bmpbuttn.obj \
+  $(MSWDIR)\brush.obj \
+  $(MSWDIR)\button.obj \
+  $(MSWDIR)\checkbox.obj \
+  $(MSWDIR)\checklst.obj \
+  $(MSWDIR)\choice.obj \
+  $(MSWDIR)\clipbrd.obj \
+  $(MSWDIR)\colordlg.obj \
+  $(MSWDIR)\colour.obj \
+  $(MSWDIR)\combobox.obj \
+  $(MSWDIR)\control.obj \
+  $(MSWDIR)\curico.obj \
+  $(MSWDIR)\cursor.obj \
+  $(MSWDIR)\data.obj \
+  $(MSWDIR)\dc.obj \
+  $(MSWDIR)\dcmemory.obj \
+  $(MSWDIR)\dcclient.obj \
+  $(MSWDIR)\dcprint.obj \
+  $(MSWDIR)\dcscreen.obj \
+  $(MSWDIR)\dde.obj \
+  $(MSWDIR)\dialog.obj \
+  $(MSWDIR)\dib.obj \
+  $(MSWDIR)\dirdlg.obj \
+  $(MSWDIR)\filedlg.obj \
+  $(MSWDIR)\font.obj \
+  $(MSWDIR)\fontdlg.obj \
+  $(MSWDIR)\frame.obj \
+  $(MSWDIR)\gauge.obj \
+  $(MSWDIR)\gdiobj.obj \
+  $(MSWDIR)\helpwin.obj \
+  $(MSWDIR)\icon.obj \
+  $(MSWDIR)\imaglist.obj \
+  $(MSWDIR)\joystick.obj \
+  $(MSWDIR)\listbox.obj \
+  $(MSWDIR)\listctrl.obj \
+  $(MSWDIR)\main.obj \
+  $(MSWDIR)\mdi.obj \
+  $(MSWDIR)\menu.obj \
+  $(MSWDIR)\menuitem.obj \
+  $(MSWDIR)\metafile.obj \
+  $(MSWDIR)\minifram.obj \
+  $(MSWDIR)\msgdlg.obj \
+  $(MSWDIR)\nativdlg.obj \
+  $(MSWDIR)\ownerdrw.obj \
+  $(MSWDIR)\palette.obj \
+  $(MSWDIR)\pen.obj \
+  $(MSWDIR)\penwin.obj \
+  $(MSWDIR)\printdlg.obj \
+  $(MSWDIR)\printwin.obj \
+  $(MSWDIR)\radiobox.obj \
+  $(MSWDIR)\radiobut.obj \
+  $(MSWDIR)\region.obj \
+  $(MSWDIR)\scrolbar.obj \
+  $(MSWDIR)\settings.obj \
+  $(MSWDIR)\slider.obj \
+  $(MSWDIR)\spinbutt.obj \
+  $(MSWDIR)\statbmp.obj \
+  $(MSWDIR)\statbox.obj \
+  $(MSWDIR)\stattext.obj \
+  $(MSWDIR)\tbar95.obj \
+  $(MSWDIR)\tbarmsw.obj \
+  $(MSWDIR)\textctrl.obj \
+  $(MSWDIR)\timer.obj \
+  $(MSWDIR)\treectrl.obj \
+  $(MSWDIR)\utils.obj \
+  $(MSWDIR)\wave.obj \
+  $(MSWDIR)\window.obj \
+  $(OLEDIR)\droptgt.obj \
+  $(OLEDIR)\oleutils.obj \
+  $(OLEDIR)\uuid.obj
+
+#  $(MSWDIR)\registry.obj \
+
+OBJECTS = $(COMMONOBJS) $(GENERICOBJS) $(MSWOBJS)
+
+# Normal, static library
+all:    $(DUMMYOBJ) $(WXDIR)\lib\wx1.lib $(WXDIR)\lib\wx2.lib $(WXDIR)\lib\wx3.lib
+
+
+#$(WXDIR)\lib\wx.lib:      dummy.obj $(OBJECTS) $(PERIPH_LIBS)
+#	-erase $(LIBTARGET)
+#	lib /PAGESIZE:128 @<<
+#$(LIBTARGET)
+#y
+#$(OBJECTS) $(PERIPH_LIBS)
+#nul
+#;
+#<<
+
+$(WXDIR)\lib\wx1.lib:      $(COMMONOBJS) $(PERIPH_LIBS)
+	-erase $(WXDIR)\lib\wx1.lib
+	lib /PAGESIZE:128 @<<
+$(WXDIR)\lib\wx1.lib
+y
+$(COMMONOBJS) $(PERIPH_LIBS)
+nul
+;
+<<
+
+$(WXDIR)\lib\wx2.lib:      $(GENERICOBJS)
+	-erase $(WXDIR)\lib\wx2.lib
+	lib /PAGESIZE:128 @<<
+$(WXDIR)\lib\wx2.lib
+y
+$(GENERICOBJS)
+nul
+;
+<<
+
+$(WXDIR)\lib\wx3.lib:      $(MSWOBJS)
+	-erase $(WXDIR)\lib\wx3.lib
+	lib /PAGESIZE:128 @<<
+$(WXDIR)\lib\wx3.lib
+y
+$(MSWOBJS)
+nul
+;
+<<
+
+########################################################
+# Windows-specific objects
+
+dummy.obj: dummy.$(SRCSUFF) $(WXDIR)\include\wx\wx.h
+        cl @<<
+        cl $(CPPFLAGS) /YcWX/WXPREC.H $(DEBUG_FLAGS) /c /Tp $*.$(SRCSUFF)
+<<
+
+#dummy.obj: dummy.$(SRCSUFF) $(WXDIR)\include\wx\wx.h
+#        cl $(CPPFLAGS) /YcWX/WXPREC.H $(DEBUG_FLAGS) /c /Tp $*.$(SRCSUFF)
+
+dummydll.obj: dummydll.$(SRCSUFF) $(WXDIR)\include\wx\wx.h
+        cl @<<
+$(CPPFLAGS) /YcWX/WXPREC.H /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/app.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/bitmap.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/bmpbuttn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/brush.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/button.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/choice.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/checkbox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/checklst.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/clipbrd.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/colordlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/colour.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/combobox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/control.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/curico.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/cursor.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/data.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dc.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dde.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dcmemory.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dcclient.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dcprint.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dcscreen.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dialog.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dib.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dirdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/filedlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/font.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/fontdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/frame.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/gauge.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/gdiobj.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/helpwin.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/icon.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/imaglist.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/joystick.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/listbox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/listctrl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/main.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/mdi.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/menu.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/menuitem.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/metafile.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/minifram.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/msgdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/nativdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/ownerdrw.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/palette.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/pen.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/penwin.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/printdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/printwin.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/radiobox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/radiobut.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/region.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/registry.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/scrolbar.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/settings.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/slider.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/spinbutt.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/statbmp.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/statbox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/stattext.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/tbar95.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/tbarmsw.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/textctrl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/timer.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/treectrl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/utils.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/wave.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/window.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(OLEDIR)/droptgt.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(OLEDIR)/oleutils.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(OLEDIR)/uuid.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+########################################################
+# Common objects (always compiled)
+
+$(COMMDIR)/config.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/cmndata.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/docview.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/dynarray.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/event.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/file.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/fileconf.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/filefn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/gdicmn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/helpbase.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/intl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/ipcbase.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/layout.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/log.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/memory.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/module.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/object.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/odbc.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/postscrp.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/prntbase.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/resource.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/tbarbase.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/tbarsmpl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/textfile.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/timercmn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/utilscmn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/validate.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/valtext.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/date.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/wxexpr.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/hash.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/list.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/string.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/matrix.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/wxstrgnu/wxstrgnu.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS2) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/wxstrgnu/wxregex.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS2) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/time.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(COMMDIR)/y_tab.obj:     $*.c $(COMMDIR)/lex_yy.c
+        cl @<<
+$(CPPFLAGS2) -DUSE_DEFINE -DYY_USE_PROTOS /Fo$@ /I ..\common /c $*.c
+<<
+
+$(COMMDIR)/y_tab.c:     $(COMMDIR)/dosyacc.c
+        copy $(COMMDIR)\dosyacc.c $(COMMDIR)\y_tab.c
+
+$(COMMDIR)/lex_yy.c:    $(COMMDIR)/doslex.c
+    copy $(COMMDIR)\doslex.c $(COMMDIR)\lex_yy.c
+
+########################################################
+# Generic objects (not always compiled, depending on
+# whether platforms have native implementations)
+
+$(GENDIR)/choicdgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/colrdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/fontdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/gridg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/helpxlp.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/msgdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/panelg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/printps.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/prntdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/scrolwin.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/splitter.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/statusbr.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/tabg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(GENDIR)/textdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(OBJECTS):	$(WXDIR)/include/wx/setup.h
+
+# Peripheral components
+
+xpm:
+    cd $(WXDIR)\contrib\wxxpm
+    nmake -f makefile.dos FINAL=$(FINAL)
+    cd $(WXDIR)\src\msw
+
+clean_xpm:
+    cd $(WXDIR)\contrib\wxxpm
+    nmake -f makefile.dos clean
+    cd $(WXDIR)\src\msw
+
+clean: $(PERIPH_CLEAN_TARGET)
+        -erase *.obj
+        -erase ..\lib\*.lib
+        -erase *.pdb
+        -erase *.sbr
+        -erase *.pch
+        cd $(WXDIR)\src\generic
+        -erase *.pdb
+        -erase *.sbr
+        -erase *.obj
+        cd $(WXDIR)\src\common
+        -erase *.pdb
+        -erase *.sbr
+        -erase *.obj
+        cd $(WXDIR)\src\msw\ole
+        -erase *.pdb
+        -erase *.sbr
+        -erase *.obj
+        cd $(WXDIR)\src\msw
+
+cleanall: clean
+
+# Making documents
+docs:   hlp
+hlp:    wxhlp faqhlp refhlp
+wxhlp:  $(DOCDIR)/winhelp/wx.hlp
+faqhlp: $(DOCDIR)/winhelp/faq.hlp
+refhlp: $(DOCDIR)/winhelp/techref.hlp
+rtf:    $(DOCDIR)/winhelp/wx.rtf
+faqrtf: $(DOCDIR)/winhelp/faq.rtf
+html:	wxhtml faqhtml
+wxhtml:	$(DOCDIR)\html\wx\wx.htm
+faqhtml: $(DOCDIR)\html\faq\faq.htm
+ps:     faqps wxps referencps
+wxps:	$(WXDIR)\docs\ps\wx.ps
+faqps:	$(WXDIR)\docs\ps\faq.ps
+referencps:	$(WXDIR)\docs\ps\referenc.ps
+
+alldocs: allhlp allhtml allps
+
+allhlp: wxhlp faqhlp
+        nmake -f makefile.dos hlp
+        cd $(WXDIR)\utils\wxprop\src
+        nmake -f makefile.dos hlp
+        cd $(WXDIR)\utils\dialoged\src
+        nmake -f makefile.dos hlp
+        cd $(THISDIR)
+
+#        cd $(WXDIR)\utils\wxhelp\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\wxhelp2\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\prologio\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\tex2rtf\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\wxgraph\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\wxchart\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\wxtree\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\wxbuild\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\wxgrid\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\wxtab\src
+#        nmake -f makefile.dos hlp
+
+#        cd $(WXDIR)\utils\wxclips\src
+#        nmake -f makefile.dos hlp
+#        cd $(WXDIR)\utils\clips2c\src
+#        nmake -f makefile.dos hlp
+
+allhtml: wxhtml faqhtml
+        nmake -f makefile.dos html
+        cd $(WXDIR)\utils\wxprop\src
+        cd $(THISDIR)
+
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\dialoged\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\hytext\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\wxhelp\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\wxhelp2\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\prologio\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\tex2rtf\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\wxgraph\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\wxchart\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\wxtree\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\wxtab\src
+#        nmake -f makefile.dos html
+
+#        cd $(WXDIR)\utils\wxclips\src
+#        nmake -f makefile.dos html
+#        cd $(WXDIR)\utils\clips2c\src
+#        nmake -f makefile.dos html
+
+allps: wxps faqps
+        nmake -f makefile.dos ps
+        cd $(WXDIR)\utils\wxhelp\src
+        nmake -f makefile.dos ps
+        cd $(WXDIR)\utils\wxhelp2\src
+        nmake -f makefile.dos ps
+        cd $(WXDIR)\utils\tex2rtf\src
+        nmake -f makefile.dos ps
+        cd $(WXDIR)\utils\wxgraph\src
+        nmake -f makefile.dos ps
+        cd $(WXDIR)\utils\wxchart\src
+        nmake -f makefile.dos ps
+        cd $(WXDIR)\utils\wxtree\src
+        nmake -f makefile.dos ps
+        cd $(WXDIR)\utils\wxprop\src
+        nmake -f makefile.dos ps
+        cd $(WXDIR)\utils\dialoged\src
+        nmake -f makefile.dos ps
+        cd $(THISDIR)
+
+#        cd $(WXDIR)\utils\wxtab\src
+#        nmake -f makefile.dos ps
+#        cd $(WXDIR)\utils\prologio\src
+#        nmake -f makefile.dos ps
+#        cd $(WXDIR)\utils\wxclips\src
+#        nmake -f makefile.dos ps
+#        cd $(WXDIR)\utils\clips2c\src
+#        nmake -f makefile.dos ps
+
+$(DOCDIR)/winhelp/wx.hlp:         $(DOCDIR)/latex/wx/wx.rtf $(DOCDIR)/latex/wx/wx.hpj
+        cd $(DOCDIR)/latex/wx
+        -erase wx.ph
+        hc wx
+        move wx.hlp $(DOCDIR)\winhelp\wx.hlp
+        move wx.cnt $(DOCDIR)\winhelp\wx.cnt
+        cd $(THISDIR)
+
+$(DOCDIR)/winhelp/faq.hlp:         $(DOCDIR)/latex/faq/faq.rtf $(DOCDIR)/latex/faq/faq.hpj
+        cd $(DOCDIR)/latex/faq
+        -erase faq.ph
+        hc faq
+        move faq.hlp $(DOCDIR)\winhelp\faq.hlp
+        move faq.cnt $(DOCDIR)\winhelp\faq.cnt
+        cd $(THISDIR)
+
+$(DOCDIR)/winhelp/techref.hlp:         $(DOCDIR)/latex/techref/techref.rtf $(DOCDIR)/latex/techref/techref.hpj
+        cd $(DOCDIR)/latex/techref
+        -erase techref.ph
+        hc techref
+        move techref.hlp $(DOCDIR)\winhelp\techref.hlp
+        move techref.cnt $(DOCDIR)\winhelp\techref.cnt
+        cd $(THISDIR)
+
+$(DOCDIR)/latex/wx/wx.rtf:         $(DOCDIR)/latex/wx/classes.tex $(DOCDIR)/latex/wx/body.tex $(DOCDIR)/latex/wx/topics.tex $(DOCDIR)/latex/wx/manual.tex
+        cd $(DOCDIR)\latex\wx
+        -start /w tex2rtf $(DOCDIR)/latex/wx/manual.tex $(DOCDIR)/latex/wx/wx.rtf -twice -winhelp
+        cd $(THISDIR)
+
+$(DOCDIR)/latex/faq/faq.rtf:         $(DOCDIR)/latex/faq/faq.tex
+        cd $(DOCDIR)\latex\faq
+        -start /w tex2rtf $(DOCDIR)/latex/faq/faq.tex $(DOCDIR)/latex/faq/faq.rtf -twice -winhelp
+        cd $(THISDIR)
+
+$(DOCDIR)/latex/techref/techref.rtf:         $(DOCDIR)/latex/techref/techref.tex
+        cd $(DOCDIR)\latex\techref
+        -start /w tex2rtf $(DOCDIR)/latex/techref/techref.tex $(DOCDIR)/latex/techref/techref.rtf -twice -winhelp
+        cd $(THISDIR)
+
+$(DOCDIR)\html\wx\wx.htm:         $(DOCDIR)\latex\wx\classes.tex $(DOCDIR)\latex\wx\body.tex $(DOCDIR)/latex/wx/topics.tex $(DOCDIR)\latex\wx\manual.tex
+        cd $(DOCDIR)\latex\wx
+        -mkdir $(DOCDIR)\html\wx
+        -start /w tex2rtf $(DOCDIR)\latex\wx\manual.tex $(DOCDIR)\html\wx\wx.htm -twice -html -macros $(DOCDIR)\tex2rtf.ini
+        -erase $(DOCDIR)\html\wx\*.con
+        -erase $(DOCDIR)\html\wx\*.ref
+        -erase $(DOCDIR)\latex\wx\*.con
+        -erase $(DOCDIR)\latex\wx\*.ref
+        cd $(THISDIR)
+
+$(DOCDIR)\html\faq\faq.htm:         $(DOCDIR)\latex\faq\faq.tex
+        cd $(DOCDIR)\latex\faq
+        -mkdir $(DOCDIR)\html\faq
+        -start /w tex2rtf $(DOCDIR)\latex\faq\faq.tex $(DOCDIR)\html\faq\faq.htm -twice -html -macros $(DOCDIR)\tex2rtf.ini
+        -erase $(DOCDIR)\html\faq\*.con
+        -erase $(DOCDIR)\html\faq\*.ref
+        -erase $(DOCDIR)\latex\faq\*.con
+        -erase $(DOCDIR)\latexfaq\*.ref
+        cd $(THISDIR)
+
+$(WXDIR)\docs\latex\wx\manual.dvi:	$(DOCDIR)/latex/wx/body.tex $(DOCDIR)/latex/wx/manual.tex
+	cd $(WXDIR)\docs\latex\wx
+        -latex manual
+        -latex manual
+        -makeindx manual
+        -bibtex manual
+        -latex manual
+        -latex manual
+        cd $(THISDIR)
+
+$(WXDIR)\docs\ps\wx.ps:	$(WXDIR)\docs\latex\wx\manual.dvi
+	cd $(WXDIR)\docs\latex\wx
+        -dvips32 -o wx.ps manual
+        move wx.ps $(WXDIR)\docs\ps\wx.ps
+        cd $(THISDIR)
+
+$(WXDIR)\docs\latex\wx\referenc.dvi:	$(DOCDIR)/latex/wx/classes.tex $(DOCDIR)/latex/wx/topics.tex $(DOCDIR)/latex/wx/referenc.tex
+	cd $(WXDIR)\docs\latex\wx
+        -latex referenc
+        -latex referenc
+        -makeindx referenc
+        -bibtex referenc
+        -latex referenc
+        -latex referenc
+        cd $(THISDIR)
+
+$(WXDIR)\docs\ps\referenc.ps:	$(WXDIR)\docs\latex\wx\referenc.dvi
+	cd $(WXDIR)\docs\latex\wx
+        -dvips32 -o referenc.ps referenc
+        move referenc.ps $(WXDIR)\docs\ps\referenc.ps
+        cd $(THISDIR)
+
+$(WXDIR)\docs\latex\faq\faq.dvi:	$(DOCDIR)/latex/faq/faq.tex
+	cd $(WXDIR)\docs\latex\faq
+        -latex faq
+        -latex faq
+        -makeindx faq
+        -latex faq
+        -latex faq
+        cd $(THISDIR)
+
+$(WXDIR)\docs\ps\faq.ps:	$(WXDIR)\docs\latex\faq\faq.dvi
+	cd $(WXDIR)\docs\latex\faq
+        -dvips32 -o faq.ps faq
+        move faq.ps $(WXDIR)\docs\ps\faq.ps
+        cd $(THISDIR)
+
+
diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95
new file mode 100644
index 0000000000..e5748cdd8a
--- /dev/null
+++ b/src/msw/makefile.g95
@@ -0,0 +1,303 @@
+#
+# File:		makefile.unx
+# Author:	Julian Smart
+# Created:	1993
+# Updated:	
+# Copyright:	(c) 1993, AIAI, University of Edinburgh
+#
+# "@(#)makefile.unx	1.2 5/9/94"
+#
+# Makefile for libwx.a
+
+# Replace this with your own path if necessary
+WXDIR = ../..
+
+# All common UNIX compiler flags and options are now in
+# this central makefile.
+include $(WXDIR)/src/makeg95.env
+
+# IMPORTANT: if you want to link in subsidiary libraries,
+# required for some optional parts of wxWindows, you must
+# set EXTRATARGETS and EXTRAOBJS to match the settings in wx_setup.h.
+# Having done this, you won't have to worry about linking them
+# into each application.
+#
+# Here's the full list.
+#   prologio: Required if using the wxWindows resource facility
+#               USE_WX_RESOURCES should be 1
+#   xmgauge:  Gauge class (required for Motif only)
+#               USE_GAUGE should be 1
+#   xpm:      XPM pixmap support
+#               USE_XPM_IN_X should be 1
+#   image:    GIF, BMP image reading
+#               USE_IMAGE_LOADING_IN_X should be 1
+#   wxstring: string class
+#               USE_GNU_WXSTRING should be 1
+#
+# Unfortunately, 'ar' doesn't like combining objects and libraries,
+# so we must identify all the objects from the subordinate libraries. Yuck!
+XPMSRC=../../contrib/wxxpm/objects$(GUISUFFIX)
+XPMOBJS=$(XPMSRC)/crbuffri.$(OBJSUFF) $(XPMSRC)/crbuffrp.$(OBJSUFF) $(XPMSRC)/crdatfri.$(OBJSUFF) $(XPMSRC)/crdatfrp.$(OBJSUFF)\
+  $(XPMSRC)/create.$(OBJSUFF) $(XPMSRC)/crifrbuf.$(OBJSUFF) $(XPMSRC)/crifrdat.$(OBJSUFF) $(XPMSRC)/crpfrbuf.$(OBJSUFF) $(XPMSRC)/crpfrdat.$(OBJSUFF)\
+  $(XPMSRC)/data.$(OBJSUFF) $(XPMSRC)/hashtab.$(OBJSUFF) $(XPMSRC)/misc.$(OBJSUFF) $(XPMSRC)/parse.$(OBJSUFF) $(XPMSRC)/rdftodat.$(OBJSUFF)\
+  $(XPMSRC)/rdftoi.$(OBJSUFF) $(XPMSRC)/rdftop.$(OBJSUFF) $(XPMSRC)/rgb.$(OBJSUFF) $(XPMSRC)/scan.$(OBJSUFF) $(XPMSRC)/simx.$(OBJSUFF)\
+  $(XPMSRC)/wrffrdat.$(OBJSUFF) $(XPMSRC)/wrffri.$(OBJSUFF) $(XPMSRC)/wrffrp.$(OBJSUFF)
+
+# Subordinate library possibilities
+
+EXTRAOBJS=
+
+GENDIR=../generic
+COMMDIR=../common
+OLEDIR=ole
+MSWDIR=.
+
+GENERICOBJDIR=../generic/$(OBJDIR)
+COMMOBJDIR=../common/$(OBJDIR)
+OLEOBJDIR=ole/$(OBJDIR)
+MSWDIR=$(OBJDIR)
+
+DOCDIR = $(WXDIR)\docs
+
+GENERICOBJS= \
+  $(GENDIR)/choicdgg.$(OBJSUFF) \
+  $(GENDIR)/colrdlgg.$(OBJSUFF) \
+  $(GENDIR)/fontdlgg.$(OBJSUFF) \
+  $(GENDIR)/gridg.$(OBJSUFF) \
+  $(GENDIR)/helpxlp.$(OBJSUFF) \
+  $(GENDIR)/msgdlgg.$(OBJSUFF) \
+  $(GENDIR)/panelg.$(OBJSUFF) \
+  $(GENDIR)/printps.$(OBJSUFF) \
+  $(GENDIR)/prntdlgg.$(OBJSUFF) \
+  $(GENDIR)/scrolwin.$(OBJSUFF) \
+  $(GENDIR)/splitter.$(OBJSUFF) \
+  $(GENDIR)/statusbr.$(OBJSUFF) \
+  $(GENDIR)/tabg.$(OBJSUFF) \
+  $(GENDIR)/textdlgg.$(OBJSUFF)
+
+COMMONOBJS = \
+  $(COMMDIR)/config.$(OBJSUFF) \
+  $(COMMDIR)/cmndata.$(OBJSUFF) \
+  $(COMMDIR)/docview.$(OBJSUFF) \
+  $(COMMDIR)/dynarray.$(OBJSUFF) \
+  $(COMMDIR)/event.$(OBJSUFF) \
+  $(COMMDIR)/file.$(OBJSUFF) \
+  $(COMMDIR)/fileconf.$(OBJSUFF) \
+  $(COMMDIR)/filefn.$(OBJSUFF) \
+  $(COMMDIR)/gdicmn.$(OBJSUFF) \
+  $(COMMDIR)/helpbase.$(OBJSUFF) \
+  $(COMMDIR)/intl.$(OBJSUFF) \
+  $(COMMDIR)/layout.$(OBJSUFF) \
+  $(COMMDIR)/log.$(OBJSUFF) \
+  $(COMMDIR)/memory.$(OBJSUFF) \
+  $(COMMDIR)/module.$(OBJSUFF) \
+  $(COMMDIR)/object.$(OBJSUFF) \
+  $(COMMDIR)/odbc.$(OBJSUFF) \
+  $(COMMDIR)/postscrp.$(OBJSUFF) \
+  $(COMMDIR)/prntbase.$(OBJSUFF) \
+  $(COMMDIR)/resource.$(OBJSUFF) \
+  $(COMMDIR)/tbarbase.$(OBJSUFF) \
+  $(COMMDIR)/tbarsmpl.$(OBJSUFF) \
+  $(COMMDIR)/textfile.$(OBJSUFF) \
+  $(COMMDIR)/timercmn.$(OBJSUFF) \
+  $(COMMDIR)/utilscmn.$(OBJSUFF) \
+  $(COMMDIR)/validate.$(OBJSUFF) \
+  $(COMMDIR)/valtext.$(OBJSUFF) \
+  $(COMMDIR)/date.$(OBJSUFF) \
+  $(COMMDIR)/wxexpr.$(OBJSUFF) \
+  $(COMMDIR)/hash.$(OBJSUFF) \
+  $(COMMDIR)/list.$(OBJSUFF) \
+  $(COMMDIR)/string.$(OBJSUFF) \
+  $(COMMDIR)/time.$(OBJSUFF) \
+  $(COMMDIR)/y_tab.$(OBJSUFF)
+
+#  $(COMMDIR)/wxstrgnu/wxstrgnu.$(OBJSUFF) \
+#  $(COMMDIR)/wxstrgnu/wxregex.$(OBJSUFF)
+
+MSWOBJS = \
+  app.$(OBJSUFF) \
+  bitmap.$(OBJSUFF) \
+  bmpbuttn.$(OBJSUFF) \
+  brush.$(OBJSUFF) \
+  button.$(OBJSUFF) \
+  checkbox.$(OBJSUFF) \
+  checklst.$(OBJSUFF) \
+  choice.$(OBJSUFF) \
+  clipbrd.$(OBJSUFF) \
+  colordlg.$(OBJSUFF) \
+  colour.$(OBJSUFF) \
+  combobox.$(OBJSUFF) \
+  control.$(OBJSUFF) \
+  curico.$(OBJSUFF) \
+  cursor.$(OBJSUFF) \
+  data.$(OBJSUFF) \
+  dc.$(OBJSUFF) \
+  dcmemory.$(OBJSUFF) \
+  dcclient.$(OBJSUFF) \
+  dcprint.$(OBJSUFF) \
+  dcscreen.$(OBJSUFF) \
+  dde.$(OBJSUFF) \
+  dialog.$(OBJSUFF) \
+  dib.$(OBJSUFF) \
+  dirdlg.$(OBJSUFF) \
+  filedlg.$(OBJSUFF) \
+  font.$(OBJSUFF) \
+  fontdlg.$(OBJSUFF) \
+  frame.$(OBJSUFF) \
+  gauge.$(OBJSUFF) \
+  gdiobj.$(OBJSUFF) \
+  helpwin.$(OBJSUFF) \
+  icon.$(OBJSUFF) \
+  imaglist.$(OBJSUFF) \
+  joystick.$(OBJSUFF) \
+  listbox.$(OBJSUFF) \
+  listctrl.$(OBJSUFF) \
+  main.$(OBJSUFF) \
+  mdi.$(OBJSUFF) \
+  menu.$(OBJSUFF) \
+  menuitem.$(OBJSUFF) \
+  metafile.$(OBJSUFF) \
+  minifram.$(OBJSUFF) \
+  msgdlg.$(OBJSUFF) \
+  nativdlg.$(OBJSUFF) \
+  ownerdrw.$(OBJSUFF) \
+  palette.$(OBJSUFF) \
+  pen.$(OBJSUFF) \
+  penwin.$(OBJSUFF) \
+  printdlg.$(OBJSUFF) \
+  printwin.$(OBJSUFF) \
+  radiobox.$(OBJSUFF) \
+  radiobut.$(OBJSUFF) \
+  region.$(OBJSUFF) \
+  registry.$(OBJSUFF) \
+  scrolbar.$(OBJSUFF) \
+  settings.$(OBJSUFF) \
+  slider.$(OBJSUFF) \
+  spinbutt.$(OBJSUFF) \
+  statbmp.$(OBJSUFF) \
+  statbox.$(OBJSUFF) \
+  statbr95.$(OBJSUFF) \
+  stattext.$(OBJSUFF) \
+  tabctrl.$(OBJSUFF) \
+  taskbar.$(OBJSUFF) \
+  tbar95.$(OBJSUFF) \
+  tbarmsw.$(OBJSUFF) \
+  textctrl.$(OBJSUFF) \
+  thread.$(OBJSUFF) \
+  timer.$(OBJSUFF) \
+  treectrl.$(OBJSUFF) \
+  utils.$(OBJSUFF) \
+  wave.$(OBJSUFF) \
+  window.$(OBJSUFF) \
+  $(OLEDIR)/droptgt.$(OBJSUFF) \
+  $(OLEDIR)/oleutils.$(OBJSUFF) \
+  $(OLEDIR)/uuid.$(OBJSUFF)
+
+OBJECTS = $(MSWOBJS) $(COMMONOBJS) $(GENERICOBJS)
+
+all:    $(OBJECTS) $(WXLIB)
+
+base:
+	cd $(WXDIR)/src/common; $(MAKE) -f makefile.g95 GUI=$(GUI) GUISUFFIX=$(GUISUFFIX) CC=$(CC)\
+ OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' DEBUGFLAGS='$(DEBUGFLAGS)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)'
+
+
+$(WXLIB): $(OBJECTS) $(EXTRAOBJS)
+	ar $(AROPTIONS) $@ $(EXTRAOBJS) $(OBJECTS)
+	$(RANLIB) $@
+
+#$(MSWOBJDIR):
+#	mkdir $(OBJDIR)
+
+#$(COMMOBJDIR):
+#	mkdir $(COMMDIR)/$(OBJDIR)
+
+#$(GENERICOBJDIR):
+#	mkdir $(GENDIR)/$(OBJDIR)
+
+$(OBJECTS):	$(WXINC)/wx/defs.h $(WXINC)/wx/object.h $(WXINC)/wx/setup.h
+
+$(COMMDIR)/y_tab.$(OBJSUFF):    $(COMMDIR)/y_tab.c $(COMMDIR)/lex_yy.c
+	$(CCLEX) -c $(CPPFLAGS) -o $@ $(COMMDIR)/y_tab.c
+
+# Replace lex with flex if you run into compilation
+# problems with lex_yy.c. See also note about LEX_SCANNER
+# above.
+$(COMMDIR)/lex_yy.c:	$(COMMDIR)/lexer.l
+	$(LEX) $(COMMDIR)/lexer.l > $(COMMDIR)/lex_yy.c
+
+#	sed -e "s/BUFSIZ/5000/g" < lex.yy.c | \
+#	sed -e "s/yyoutput(c)/void yyoutput(c)/g" | \
+#       sed -e "s/YYLMAX 200/YYLMAX 5000/g" > lex_yy.c
+#	rm -f lex.yy.c
+
+# Replace yacc with bison if you run into compilation
+# problems with y_tab.c.
+$(COMMDIR)/y_tab.c:	$(COMMDIR)/parser.y
+	$(YACC) -o $(COMMDIR)/y_tab.c $(COMMDIR)/parser.y
+
+#	mv y.tab.c $(COMMDIR)/y_tab.c
+
+
+# Extra targets
+prologio:
+	cd $(WXDIR)/utils/prologio/src ; $(MAKE) -f makefile.g95
+	cd $(WXDIR)/src/msw
+
+clean_proio:
+	cd $(WXDIR)/utils/prologio/src; $(MAKE) -f makefile.g95 clean
+	cd $(WXDIR)/src/msw
+
+makedib:
+	cd $(WXDIR)/src/msw/dib ; $(MAKE) -f makefile.g95
+	cd $(WXDIR)/src/msw
+
+clean_dib:
+	cd $(WXDIR)/src/msw/dib; $(MAKE) -f makefile.g95 clean
+	cd $(WXDIR)/src/msw
+
+gauge:
+	cd $(WXDIR)/src/msw/gauge; $(MAKE) -f makefile.g95
+	cd $(WXDIR)/src/msw
+
+clean_gauge:
+	cd $(WXDIR)/src/msw/gauge; $(MAKE) -f makefile.g95 clean
+	cd $(WXDIR)/src/msw
+
+wxstring:
+	cd $(WXDIR)/contrib/wxstring; $(MAKE) -f makefile.g95 OPTIONS="$(OPTIONS)" DEBUG="$(DEBUG)"
+	cd $(WXDIR)/src/msw
+
+clean_wxstring:
+	cd $(WXDIR)/contrib/wxstring; $(MAKE) -f makefile.g95 clean
+	cd $(WXDIR)/src/msw
+
+itsy:
+	cd $(WXDIR)/src/msw/itsybits; $(MAKE) -f makefile.g95
+	cd $(WXDIR)/src/msw
+
+clean_itsy:
+	cd $(WXDIR)/contrib/itsybits; $(MAKE) -f makefile.g95 clean
+	cd $(WXDIR)/src/msw
+
+rcparser:
+	cd $(WXDIR)/utils/rcparser/src; $(MAKE)  -f makefile.g95
+	cd $(WXDIR)/src/msw
+
+clean_rcp:
+	cd $(WXDIR)/utils/rcparser/src; $(MAKE) -f makefile.g95 clean
+	cd $(WXDIR)/src/msw
+
+# +++start steve161(09.04.1995): added for wxString in \contrib\wxstring
+wxstring_ol:
+	cd ../../contrib/wxstring; $(MAKE) -f makefile.unx xview
+wxstring_motif:
+	cd ../../contrib/wxstring; $(MAKE) -f makefile.unx motif
+wxstring_hp:
+	cd ../../contrib/wxstring; $(MAKE) -f makefile.unx hp
+
+clean:
+	rm -f $(OBJECTS) $(EXTRAOBJS) ../common/y_tab.c ../common/lex_yy.c $(WXDIR)/lib/libwx$(GUISUFFIX).a core
+
+cleanall: clean
+
diff --git a/src/msw/makefile.nt b/src/msw/makefile.nt
new file mode 100644
index 0000000000..5462b49788
--- /dev/null
+++ b/src/msw/makefile.nt
@@ -0,0 +1,1307 @@
+#
+# File:		makefile.nt
+# Author:	Julian Smart
+# Created:	1997
+# Updated:	
+# Copyright:	(c) 1997, Julian Smart
+#
+# "%W% %G%"
+#
+# Makefile : Builds wxWindows library wx.lib for VC++ (32-bit)
+# Arguments:
+#
+# FINAL=1 argument to nmake to build version with no debugging info.
+# dll builds a library (wxdll.lib) suitable for creating DLLs
+#    * Note that the dll target is experimental - see docs/dll.txt.
+#
+!include <..\ntwxwin.mak>
+
+THISDIR=$(WXWIN)\src\msw
+
+!if "$(WXMAKINGDLL)" == "1"
+LIBTARGET=$(WXDIR)\lib\wx200.dll
+DUMMYOBJ=dummydll.obj
+!else
+LIBTARGET=$(WXLIB)
+DUMMYOBJ=dummy.obj
+!endif
+
+# Please set these according to the settings in wx_setup.h, so we can include
+# the appropriate libraries in wx.lib
+
+# This one overrides the others, to be consistent with the settings in wx_setup.h
+MINIMAL_WXWINDOWS_SETUP=0
+
+USE_XPM_IN_MSW=0
+
+!if "$(MINIMAL_WXWINDOWS_SETUP)" == "1"
+USE_XPM_IN_MSW=0
+!endif
+
+PERIPH_LIBS=
+PERIPH_TARGET=
+PERIPH_CLEAN_TARGET=
+
+!if "$(USE_XPM_IN_MSW)" == "1"
+PERIPH_LIBS=$(WXDIR)\contrib\wxxpm\xpm.lib $(PERIPH_LIBS)
+PERIPH_TARGET=xpm $(PERIPH_TARGET)
+PERIPH_CLEAN_TARGET=clean_xpm $(PERIPH_CLEAN_TARGET)
+!endif
+
+GENDIR=..\generic
+COMMDIR=..\common
+OLEDIR=ole
+MSWDIR=.
+
+DOCDIR = $(WXDIR)\docs
+
+GENERICOBJS= \
+  $(GENDIR)\choicdgg.obj \
+  $(GENDIR)\colrdlgg.obj \
+  $(GENDIR)\fontdlgg.obj \
+  $(GENDIR)\gridg.obj \
+  $(GENDIR)\helpxlp.obj \
+  $(GENDIR)\msgdlgg.obj \
+  $(GENDIR)\panelg.obj \
+  $(GENDIR)\printps.obj \
+  $(GENDIR)\prntdlgg.obj \
+  $(GENDIR)\scrolwin.obj \
+  $(GENDIR)\splitter.obj \
+  $(GENDIR)\statusbr.obj \
+  $(GENDIR)\tabg.obj \
+  $(GENDIR)\textdlgg.obj
+
+COMMONOBJS = \
+  $(COMMDIR)\cmndata.obj \
+  $(COMMDIR)\config.obj \
+  $(COMMDIR)\docview.obj \
+  $(COMMDIR)\dynarray.obj \
+  $(COMMDIR)\event.obj \
+  $(COMMDIR)\file.obj \
+  $(COMMDIR)\fileconf.obj \
+  $(COMMDIR)\filefn.obj \
+  $(COMMDIR)\gdicmn.obj \
+  $(COMMDIR)\intl.obj \
+  $(COMMDIR)\ipcbase.obj \
+  $(COMMDIR)\helpbase.obj \
+  $(COMMDIR)\layout.obj \
+  $(COMMDIR)\log.obj \
+  $(COMMDIR)\memory.obj \
+  $(COMMDIR)\module.obj \
+  $(COMMDIR)\object.obj \
+  $(COMMDIR)\odbc.obj \
+  $(COMMDIR)\postscrp.obj \
+  $(COMMDIR)\prntbase.obj \
+  $(COMMDIR)\resource.obj \
+  $(COMMDIR)\tbarbase.obj \
+  $(COMMDIR)\tbarsmpl.obj \
+  $(COMMDIR)\textfile.obj \
+  $(COMMDIR)\timercmn.obj \
+  $(COMMDIR)\utilscmn.obj \
+  $(COMMDIR)\validate.obj \
+  $(COMMDIR)\valtext.obj \
+  $(COMMDIR)\date.obj \
+  $(COMMDIR)\hash.obj \
+  $(COMMDIR)\list.obj \
+  $(COMMDIR)\string.obj \
+  $(COMMDIR)\time.obj \
+  $(COMMDIR)\wxexpr.obj \
+  $(COMMDIR)\y_tab.obj
+
+#  $(COMMDIR)\wxstrgnu\wxstrgnu.obj \
+#  $(COMMDIR)\wxstrgnu\wxregex.obj \
+#  $(COMMDIR)\matrix.obj \
+
+MSWOBJS = \
+  $(MSWDIR)\app.obj \
+  $(MSWDIR)\bitmap.obj \
+  $(MSWDIR)\bmpbuttn.obj \
+  $(MSWDIR)\brush.obj \
+  $(MSWDIR)\button.obj \
+  $(MSWDIR)\checkbox.obj \
+  $(MSWDIR)\checklst.obj \
+  $(MSWDIR)\choice.obj \
+  $(MSWDIR)\clipbrd.obj \
+  $(MSWDIR)\colordlg.obj \
+  $(MSWDIR)\colour.obj \
+  $(MSWDIR)\combobox.obj \
+  $(MSWDIR)\control.obj \
+  $(MSWDIR)\curico.obj \
+  $(MSWDIR)\cursor.obj \
+  $(MSWDIR)\data.obj \
+  $(MSWDIR)\dc.obj \
+  $(MSWDIR)\dcmemory.obj \
+  $(MSWDIR)\dcclient.obj \
+  $(MSWDIR)\dcprint.obj \
+  $(MSWDIR)\dcscreen.obj \
+  $(MSWDIR)\dde.obj \
+  $(MSWDIR)\dialog.obj \
+  $(MSWDIR)\dib.obj \
+  $(MSWDIR)\dibutils.obj \
+  $(MSWDIR)\dirdlg.obj \
+  $(MSWDIR)\filedlg.obj \
+  $(MSWDIR)\font.obj \
+  $(MSWDIR)\fontdlg.obj \
+  $(MSWDIR)\frame.obj \
+  $(MSWDIR)\gauge.obj \
+  $(MSWDIR)\gdiobj.obj \
+  $(MSWDIR)\helpwin.obj \
+  $(MSWDIR)\icon.obj \
+  $(MSWDIR)\imaglist.obj \
+  $(MSWDIR)\joystick.obj \
+  $(MSWDIR)\listbox.obj \
+  $(MSWDIR)\listctrl.obj \
+  $(MSWDIR)\main.obj \
+  $(MSWDIR)\mdi.obj \
+  $(MSWDIR)\menu.obj \
+  $(MSWDIR)\menuitem.obj \
+  $(MSWDIR)\metafile.obj \
+  $(MSWDIR)\minifram.obj \
+  $(MSWDIR)\msgdlg.obj \
+  $(MSWDIR)\nativdlg.obj \
+  $(MSWDIR)\ownerdrw.obj \
+  $(MSWDIR)\palette.obj \
+  $(MSWDIR)\pen.obj \
+  $(MSWDIR)\penwin.obj \
+  $(MSWDIR)\pnghand.obj \
+  $(MSWDIR)\printdlg.obj \
+  $(MSWDIR)\printwin.obj \
+  $(MSWDIR)\radiobox.obj \
+  $(MSWDIR)\radiobut.obj \
+  $(MSWDIR)\region.obj \
+  $(MSWDIR)\registry.obj \
+  $(MSWDIR)\scrolbar.obj \
+  $(MSWDIR)\settings.obj \
+  $(MSWDIR)\slider.obj \
+  $(MSWDIR)\spinbutt.obj \
+  $(MSWDIR)\statbmp.obj \
+  $(MSWDIR)\statbox.obj \
+  $(MSWDIR)\statbr95.obj \
+  $(MSWDIR)\stattext.obj \
+  $(MSWDIR)\tabctrl.obj \
+  $(MSWDIR)\taskbar.obj \
+  $(MSWDIR)\tbar95.obj \
+  $(MSWDIR)\tbarmsw.obj \
+  $(MSWDIR)\textctrl.obj \
+  $(MSWDIR)\thread.obj \
+  $(MSWDIR)\timer.obj \
+  $(MSWDIR)\treectrl.obj \
+  $(MSWDIR)\utils.obj \
+  $(MSWDIR)\wave.obj \
+  $(MSWDIR)\window.obj \
+  $(OLEDIR)\droptgt.obj \
+  $(OLEDIR)\oleutils.obj \
+  $(OLEDIR)\uuid.obj
+
+OBJECTS = $(COMMONOBJS) $(GENERICOBJS) $(MSWOBJS)
+
+# Normal, static library
+all:    $(DUMMYOBJ) $(OBJECTS) $(PERIPH_TARGET) $(LIBTARGET)
+
+# wxWindows library as DLL
+dll:
+        nmake -f makefile.nt all FINAL=$(FINAL) DLL=1 WXMAKINGDLL=1
+
+# wxWindows + app as DLL. Only affects main.cpp.
+dllapp:
+        nmake -f makefile.nt all FINAL=$(FINAL) DLL=1
+
+# wxWindows + app as DLL, for Netscape plugin - remove DllMain.
+dllnp:
+        nmake -f makefile.nt all NOMAIN=1 FINAL=$(FINAL) DLL=1
+
+# Use this to make dummy.obj and generate a PCH.
+# You might use the dll target, then the pch target, in order to
+# generate a DLL, then a PCH/dummy.obj for compiling your applications with.
+#
+# Explanation: Normally, when compiling a static version of wx.lib, your dummy.obj/PCH
+# are associated with wx.lib. When using a DLL version of wxWindows, however,
+# the DLL is compiled without a PCH, so you only need it for compiling the app.
+# In fact headers are compiled differently depending on whether a DLL is being made
+# or an app is calling the DLL exported functionality (WXDLLEXPORT is different
+# in each case) so you couldn't use the same PCH.
+pch:
+        nmake -f makefile.nt pch1 WXUSINGDLL=1
+
+pch1:   $(DUMMYOBJ)
+
+$(WXDIR)\lib\wx.lib:      dummy.obj $(OBJECTS) $(PERIPH_LIBS)
+	-erase $(LIBTARGET)
+	$(implib) @<<
+-out:$@
+-machine:$(CPU)
+$(OBJECTS) $(PERIPH_LIBS)
+<<
+
+# Update the import library
+$(WXDIR)\lib\wx200.lib: $(DUMMYOBJ) $(OBJECTS)
+    $(implib) @<<
+    -machine:$(CPU)
+    -def:wx.def
+    $(DUMMYOBJ) $(OBJECTS)
+    -out:$(WXDIR)\lib\wx200.lib
+<<
+
+# Update the dynamic link library
+$(WXDIR)\lib\wx200.dll: $(DUMMYOBJ) $(OBJECTS) $(WXDIR)\lib\wx200.lib
+    $(link) @<<
+    $(LINKFLAGS)
+    -out:$(WXDIR)\lib\wx200.dll
+    $(DUMMYOBJ) $(OBJECTS) $(guilibsdll) shell32.lib comctl32.lib ctl3d32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib
+<<
+
+########################################################
+# Windows-specific objects
+
+dummy.obj: dummy.$(SRCSUFF) $(WXDIR)\include\wx\wx.h
+        cl $(CPPFLAGS) $(MAKEPRECOMP) /c /Tp $*.$(SRCSUFF)
+
+dummydll.obj: dummydll.$(SRCSUFF) $(WXDIR)\include\wx\wx.h
+        cl @<<
+$(CPPFLAGS) $(MAKEPRECOMP) /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/app.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/bitmap.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/bmpbuttn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/brush.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/button.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/choice.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/checkbox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/checklst.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/clipbrd.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/colordlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/colour.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/combobox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/control.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/curico.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/cursor.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/data.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/dde.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/dc.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/dcmemory.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/dcclient.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/dcprint.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/dcscreen.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/dialog.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/dib.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/dibutils.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/dirdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/filedlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/font.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/fontdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/frame.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/gauge.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/gdiobj.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/icon.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/imaglist.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/joystick.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/listbox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/listctrl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
+$(MSWDIR)/main.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/mdi.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/menu.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/menuitem.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/metafile.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/minifram.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/msgdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/nativdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/ownerdrw.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/palette.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/pen.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/penwin.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/pnghand.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/printdlg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/printwin.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/radiobox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/radiobut.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/region.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/registry.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/scrolbar.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/settings.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/slider.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/spinbutt.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/statbmp.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/statbox.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/statbr95.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/stattext.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/tabctrl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/taskbar.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/tbar95.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/tbarmsw.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/textctrl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/thread.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/timer.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/treectrl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/utils.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/wave.obj:     $*.$(SRCSUFF)
+        echo $(CPPFLAGS)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(MSWDIR)/window.obj:     $*.$(SRCSUFF)
+        echo $(CPPFLAGS)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(OLEDIR)/droptgt.obj:     $*.$(SRCSUFF)
+        echo $(CPPFLAGS)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(OLEDIR)/oleutils.obj:     $*.$(SRCSUFF)
+        echo $(CPPFLAGS)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(OLEDIR)/uuid.obj:     $*.$(SRCSUFF)
+        echo $(CPPFLAGS)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+########################################################
+# Common objects (always compiled)
+
+$(COMMDIR)/cmndata.obj:     $*.$(SRCSUFF)
+        echo $(CPPFLAGS)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/config.obj:     $*.$(SRCSUFF)
+        echo $(CPPFLAGS)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/docview.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/dynarray.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/event.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/file.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/fileconf.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/filefn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/gdicmn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/intl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/ipcbase.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/helpbase.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/layout.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/log.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/memory.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/module.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/object.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/odbc.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/postscrp.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/prntbase.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/resource.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/tbarbase.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/tbarsmpl.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/textfile.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/timercmn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/utilscmn.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/validate.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/valtext.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/date.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/wxexpr.obj:     $*.$(SRCSUFF)
+        echo $(CPPFLAGS)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/hash.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/list.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/string.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/matrix.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+#$(COMMDIR)/wxstrgnu/wxstrgnu.obj:     $*.$(SRCSUFF)
+#        cl @<<
+#$(CPPFLAGS2) /c /Tp $*.$(SRCSUFF) /Fo$@
+#<<
+
+#$(COMMDIR)/wxstrgnu/wxregex.obj:     $*.$(SRCSUFF)
+#        cl @<<
+#$(CPPFLAGS2) /c /Tp $*.$(SRCSUFF) /Fo$@
+#<<
+
+$(COMMDIR)/time.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)/y_tab.obj:     $*.c $(COMMDIR)/lex_yy.c
+        cl @<<
+$(CPPFLAGS2) /c $*.c -DUSE_DEFINE -DYY_USE_PROTOS /Fo$@
+<<
+
+$(COMMDIR)/y_tab.c:     $(COMMDIR)/dosyacc.c
+        copy $(COMMDIR)\dosyacc.c $(COMMDIR)\y_tab.c
+
+$(COMMDIR)/lex_yy.c:    $(COMMDIR)/doslex.c
+    copy $(COMMDIR)\doslex.c $(COMMDIR)\lex_yy.c
+
+########################################################
+# Generic objects (not always compiled, depending on
+# whether platforms have native implementations)
+
+$(GENDIR)/choicdgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/colrdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/fontdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/gridg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/helpxlp.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/msgdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/panelg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/printps.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/prntdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/scrolwin.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/splitter.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/statusbr.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/tabg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(GENDIR)/textdlgg.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+#test: $(DUMMYOBJ) $(COMMDIR)/string.obj
+
+
+$(OBJECTS):	$(WXDIR)/include/wx/setup.h
+
+# Peripheral components
+
+xpm:
+    cd $(WXDIR)\contrib\wxxpm
+    nmake -f makefile.nt FINAL=$(FINAL)
+    cd $(WXDIR)\src\msw
+
+clean_xpm:
+    cd $(WXDIR)\contrib\wxxpm
+    nmake -f makefile.nt clean
+    cd $(WXDIR)\src\msw
+
+rcparser:
+    cd $(WXDIR)\utils\rcparser\src
+    nmake -f makefile.nt FINAL=$(FINAL)
+    cd $(WXDIR)\src\msw
+
+wxstring:
+    cd $(WXDIR)\contrib\wxstring
+    nmake -f makefile.nt OPTIONS="$(OPTIONS)" DEBUG="$(DEBUG)" FINAL=$(FINAL)
+    cd $(WXDIR)\src\msw
+
+clean_wxstring:
+    cd $(WXDIR)\contrib\wxstring
+    nmake -f makefile.nt clean
+    cd $(WXDIR)\src\msw
+
+clean_rcp:
+    cd $(WXDIR)\utils\rcparser\src
+    nmake -f makefile.nt clean
+    cd $(WXDIR)\src\msw
+
+clean: $(PERIPH_CLEAN_TARGET)
+        -erase *.obj
+        -erase $(LIBTARGET)
+        -erase ..\..\lib\wx200.dll
+        -erase ..\..\lib\wx200.lib
+        -erase ..\..\lib\wx200.exp
+        -erase ..\..\lib\wx200.pdb
+        -erase ..\..\lib\wx200.ilk
+        -erase *.pdb
+        -erase *.sbr
+        -erase *.pch
+        cd $(WXDIR)\src\msw
+        cd $(GENDIR)
+        -erase *.pdb
+        -erase *.sbr
+        -erase *.obj
+        cd $(WXDIR)\src\msw
+        cd $(COMMDIR)
+        -erase *.pdb
+        -erase *.sbr
+        -erase *.obj
+        -erase y_tab.c
+        -erase lex_yy.c
+        cd $(WXDIR)\src\msw
+        cd $(OLEDIR)
+        -erase *.pdb
+        -erase *.sbr
+        -erase *.obj
+        cd $(WXDIR)\src\msw
+#        -erase ..\common\wxstrgnu\*.obj
+#        -erase ..\common\lex_yy.c
+#        -erase ..\common\y_tab.c
+
+cleanall: clean
+
+# Making documents
+docs:   hlp
+hlp:    wxhlp refhlp portinghlp # faqhlp
+wxhlp:  $(DOCDIR)/winhelp/wx.hlp
+faqhlp: $(DOCDIR)/winhelp/faq.hlp
+refhlp: $(DOCDIR)/winhelp/techref.hlp
+rtf:    $(DOCDIR)/winhelp/wx.rtf
+faqrtf: $(DOCDIR)/winhelp/faq.rtf
+pdfrtf:    $(DOCDIR)/pdf/wx.rtf
+faqpdfrtf: $(DOCDIR)/pdf/faq.rtf
+refpdfrtf: $(DOCDIR)/pdf/techref.rtf
+html:	wxhtml # faqhtml
+wxhtml:	$(DOCDIR)\html\wx\wx.htm
+faqhtml: $(DOCDIR)\html\faq\faq.htm
+ps:     wxps referencps # faqps
+wxps:	$(WXDIR)\docs\ps\wx.ps
+faqps:	$(WXDIR)\docs\ps\faq.ps
+referencps:	$(WXDIR)\docs\ps\referenc.ps
+
+portinghtml: $(DOCDIR)\html\porting\port.htm
+portingrtf: $(DOCDIR)/winhelp/porting.rtf
+portinghlp: $(DOCDIR)/winhelp/porting.hlp
+portingpdfrtf: $(DOCDIR)/pdf/porting.rtf
+portingps:	$(WXDIR)\docs\ps\porting.ps
+
+alldocs: allhlp allhtml allpdfrtf # allps # TeX can't cope with references!
+
+allhlp: wxhlp portinghlp # faqhlp
+        cd $(WXDIR)\utils\wxprop\src
+        nmake -f makefile.nt hlp
+        cd $(WXDIR)\utils\dialoged\src
+        nmake -f makefile.nt hlp
+        cd $(THISDIR)
+
+#        cd $(WXDIR)\utils\wxhelp\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\wxhelp2\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\prologio\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\tex2rtf\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\wxgraph\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\wxchart\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\wxtree\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\wxbuild\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\wxgrid\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\wxtab\src
+#        nmake -f makefile.nt hlp
+
+#        cd $(WXDIR)\utils\wxclips\src
+#        nmake -f makefile.nt hlp
+#        cd $(WXDIR)\utils\clips2c\src
+#        nmake -f makefile.nt hlp
+
+allhtml: wxhtml portinghtml # faqhtml
+        cd $(WXDIR)\utils\wxprop\src
+        nmake -f makefile.nt html
+        cd $(WXDIR)\utils\dialoged\src
+        nmake -f makefile.nt html
+        cd $(THISDIR)
+
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\dialoged\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\hytext\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\wxhelp\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\wxhelp2\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\prologio\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\tex2rtf\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\wxgraph\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\wxchart\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\wxtree\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\wxtab\src
+#        nmake -f makefile.nt html
+
+#        cd $(WXDIR)\utils\wxclips\src
+#        nmake -f makefile.nt html
+#        cd $(WXDIR)\utils\clips2c\src
+#        nmake -f makefile.nt html
+
+allps: wxps referencps portingps # faqps
+        cd $(WXDIR)\utils\wxprop\src
+        nmake -f makefile.nt ps
+        cd $(WXDIR)\utils\dialoged\src
+        nmake -f makefile.nt ps
+        cd $(THISDIR)
+
+allpdfrtf: pdfrtf portingpdfrtf # faqpdfrtf
+        cd $(WXDIR)\utils\wxprop\src
+        nmake -f makefile.nt pdfrtf
+        cd $(WXDIR)\utils\dialoged\src
+        nmake -f makefile.nt pdfrtf
+        cd $(THISDIR)
+
+#        cd $(WXDIR)\utils\wxhelp\src
+#        nmake -f makefile.nt ps
+#        cd $(WXDIR)\utils\wxhelp2\src
+#        nmake -f makefile.nt ps
+#        cd $(WXDIR)\utils\tex2rtf\src
+#        nmake -f makefile.nt ps
+#        cd $(WXDIR)\utils\wxgraph\src
+#        nmake -f makefile.nt ps
+#        cd $(WXDIR)\utils\wxchart\src
+#        nmake -f makefile.nt ps
+#        cd $(WXDIR)\utils\wxtree\src
+#        nmake -f makefile.nt ps
+#        cd $(THISDIR)
+
+#        cd $(WXDIR)\utils\wxtab\src
+#        nmake -f makefile.nt ps
+#        cd $(WXDIR)\utils\prologio\src
+#        nmake -f makefile.nt ps
+#        cd $(WXDIR)\utils\wxclips\src
+#        nmake -f makefile.nt ps
+#        cd $(WXDIR)\utils\clips2c\src
+#        nmake -f makefile.nt ps
+
+$(DOCDIR)/winhelp/wx.hlp:         $(DOCDIR)/latex/wx/wx.rtf $(DOCDIR)/latex/wx/wx.hpj
+        cd $(DOCDIR)/latex/wx
+        -erase wx.ph
+        hc wx
+        move wx.hlp $(DOCDIR)\winhelp\wx.hlp
+        move wx.cnt $(DOCDIR)\winhelp\wx.cnt
+        cd $(THISDIR)
+
+$(DOCDIR)/winhelp/porting.hlp:         $(DOCDIR)/latex/porting/porting.rtf $(DOCDIR)/latex/porting/porting.hpj
+        cd $(DOCDIR)/latex/porting
+        -erase porting.ph
+        hc porting
+        move porting.hlp $(DOCDIR)\winhelp\porting.hlp
+        move porting.cnt $(DOCDIR)\winhelp\porting.cnt
+        cd $(THISDIR)
+
+$(DOCDIR)/winhelp/faq.hlp:         $(DOCDIR)/latex/faq/faq.rtf $(DOCDIR)/latex/faq/faq.hpj
+        cd $(DOCDIR)/latex/faq
+        -erase faq.ph
+        hc faq
+        move faq.hlp $(DOCDIR)\winhelp\faq.hlp
+        move faq.cnt $(DOCDIR)\winhelp\faq.cnt
+        cd $(THISDIR)
+
+$(DOCDIR)/winhelp/techref.hlp:         $(DOCDIR)/latex/techref/techref.rtf $(DOCDIR)/latex/techref/techref.hpj
+        cd $(DOCDIR)/latex/techref
+        -erase techref.ph
+        hc techref
+        move techref.hlp $(DOCDIR)\winhelp\techref.hlp
+        move techref.cnt $(DOCDIR)\winhelp\techref.cnt
+        cd $(THISDIR)
+
+$(DOCDIR)/latex/wx/wx.rtf:         $(DOCDIR)/latex/wx/classes.tex $(DOCDIR)/latex/wx/body.tex $(DOCDIR)/latex/wx/topics.tex $(DOCDIR)/latex/wx/manual.tex
+        cd $(DOCDIR)\latex\wx
+        -start /w tex2rtf $(DOCDIR)/latex/wx/manual.tex $(DOCDIR)/latex/wx/wx.rtf -twice -winhelp
+        cd $(THISDIR)
+
+$(DOCDIR)/latex/porting/porting.rtf:         $(DOCDIR)/latex/porting/porting.tex
+        cd $(DOCDIR)\latex\porting
+        -start /w tex2rtf $(DOCDIR)/latex/porting/porting.tex $(DOCDIR)/latex/porting/porting.rtf -twice -winhelp
+        cd $(THISDIR)
+
+$(DOCDIR)/latex/faq/faq.rtf:         $(DOCDIR)/latex/faq/faq.tex
+        cd $(DOCDIR)\latex\faq
+        -start /w tex2rtf $(DOCDIR)/latex/faq/faq.tex $(DOCDIR)/latex/faq/faq.rtf -twice -winhelp
+        cd $(THISDIR)
+
+$(DOCDIR)/latex/techref/techref.rtf:         $(DOCDIR)/latex/techref/techref.tex
+        cd $(DOCDIR)\latex\techref
+        -start /w tex2rtf $(DOCDIR)/latex/techref/techref.tex $(DOCDIR)/latex/techref/techref.rtf -twice -winhelp
+        cd $(THISDIR)
+
+$(DOCDIR)/pdf/wx.rtf:         $(DOCDIR)/latex/wx/classes.tex $(DOCDIR)/latex/wx/body.tex $(DOCDIR)/latex/wx/topics.tex $(DOCDIR)/latex/wx/manual.tex
+        cd $(DOCDIR)\latex\wx
+        -copy *.bmp *.wmf $(DOCDIR)\pdf
+        -start /w tex2rtf $(DOCDIR)/latex/wx/manual.tex $(DOCDIR)/pdf/wx.rtf -twice -rtf
+        cd $(THISDIR)
+
+$(DOCDIR)/pdf/porting.rtf:         $(DOCDIR)/latex/porting/porting.tex
+        cd $(DOCDIR)\latex\porting
+        -copy *.bmp *.wmf $(DOCDIR)\pdf
+        -start /w tex2rtf $(DOCDIR)/latex/porting/porting.tex $(DOCDIR)/pdf/porting.rtf -twice -rtf
+        cd $(THISDIR)
+
+$(DOCDIR)/pdf/faq.rtf:         $(DOCDIR)/latex/faq/faq.tex
+        cd $(DOCDIR)\latex\faq
+        -copy *.bmp *.wmf $(DOCDIR)\pdf
+        -start /w tex2rtf $(DOCDIR)/latex/faq/faq.tex $(DOCDIR)/pdf/faq.rtf -twice -rtf
+        cd $(THISDIR)
+
+$(DOCDIR)/pdf/techref.rtf:         $(DOCDIR)/latex/techref/techref.tex
+        cd $(DOCDIR)\latex\techref
+        -copy *.bmp *.wmf $(DOCDIR)\pdf
+        -start /w tex2rtf $(DOCDIR)/latex/techref/techref.tex $(DOCDIR)/pdf/techref.rtf -twice -rtf
+        cd $(THISDIR)
+
+$(DOCDIR)\html\wx\wx.htm:         $(DOCDIR)\latex\wx\classes.tex $(DOCDIR)\latex\wx\body.tex $(DOCDIR)/latex/wx/topics.tex $(DOCDIR)\latex\wx\manual.tex
+        cd $(DOCDIR)\latex\wx
+        -mkdir $(DOCDIR)\html\wx
+        -start /w tex2rtf $(DOCDIR)\latex\wx\manual.tex $(DOCDIR)\html\wx\wx.htm -twice -html
+        -erase $(DOCDIR)\html\wx\*.con
+        -erase $(DOCDIR)\html\wx\*.ref
+        -erase $(DOCDIR)\latex\wx\*.con
+        -erase $(DOCDIR)\latex\wx\*.ref
+        cd $(THISDIR)
+
+$(DOCDIR)\html\porting\port.htm:         $(DOCDIR)\latex\porting\porting.tex
+        cd $(DOCDIR)\latex\porting
+        -mkdir $(DOCDIR)\html\porting
+        -start /w tex2rtf $(DOCDIR)\latex\porting\porting.tex $(DOCDIR)\html\porting\port.htm -twice -html
+        -erase $(DOCDIR)\html\porting\*.con
+        -erase $(DOCDIR)\html\porting\*.ref
+        -erase $(DOCDIR)\latex\porting\*.con
+        -erase $(DOCDIR)\latex\porting\*.ref
+        cd $(THISDIR)
+
+$(DOCDIR)\html\faq\faq.htm:         $(DOCDIR)\latex\faq\faq.tex
+        cd $(DOCDIR)\latex\faq
+        -mkdir $(DOCDIR)\html\faq
+        -start /w tex2rtf $(DOCDIR)\latex\faq\faq.tex $(DOCDIR)\html\faq\faq.htm -twice -html
+        -erase $(DOCDIR)\html\faq\*.con
+        -erase $(DOCDIR)\html\faq\*.ref
+        -erase $(DOCDIR)\latex\faq\*.con
+        -erase $(DOCDIR)\latexfaq\*.ref
+        cd $(THISDIR)
+
+$(WXDIR)\docs\latex\wx\manual.dvi:	$(DOCDIR)/latex/wx/body.tex $(DOCDIR)/latex/wx/manual.tex
+	cd $(WXDIR)\docs\latex\wx
+        -latex manual
+        -latex manual
+        -makeindx manual
+        -bibtex manual
+        -latex manual
+        -latex manual
+        cd $(THISDIR)
+
+$(WXDIR)\docs\latex\porting\porting.dvi:	$(DOCDIR)/latex/porting/porting.tex
+	cd $(WXDIR)\docs\latex\porting
+        -latex porting
+        -latex porting
+        -makeindx porting
+        -bibtex porting
+        -latex porting
+        -latex porting
+        cd $(THISDIR)
+
+$(WXDIR)\docs\ps\wx.ps:	$(WXDIR)\docs\latex\wx\manual.dvi
+	cd $(WXDIR)\docs\latex\wx
+        -dvips32 -o wx.ps manual
+        move wx.ps $(WXDIR)\docs\ps\wx.ps
+        cd $(THISDIR)
+
+$(WXDIR)\docs\ps\porting.ps:	$(WXDIR)\docs\latex\porting\porting.dvi
+	cd $(WXDIR)\docs\latex\porting
+        -dvips32 -o porting.ps porting
+        move porting.ps $(WXDIR)\docs\ps\porting.ps
+        cd $(THISDIR)
+
+$(WXDIR)\docs\latex\wx\referenc.dvi:	$(DOCDIR)/latex/wx/classes.tex $(DOCDIR)/latex/wx/topics.tex $(DOCDIR)/latex/wx/referenc.tex
+	cd $(WXDIR)\docs\latex\wx
+        -latex referenc
+        -latex referenc
+        -makeindx referenc
+        -bibtex referenc
+        -latex referenc
+        -latex referenc
+        cd $(THISDIR)
+
+$(WXDIR)\docs\ps\referenc.ps:	$(WXDIR)\docs\latex\wx\referenc.dvi
+	cd $(WXDIR)\docs\latex\wx
+        -dvips32 -o referenc.ps referenc
+        move referenc.ps $(WXDIR)\docs\ps\referenc.ps
+        cd $(THISDIR)
+
+$(WXDIR)\docs\latex\faq\faq.dvi:	$(DOCDIR)/latex/faq/faq.tex
+	cd $(WXDIR)\docs\latex\faq
+        -latex faq
+        -latex faq
+        -makeindx faq
+        -latex faq
+        -latex faq
+        cd $(THISDIR)
+
+$(WXDIR)\docs\ps\faq.ps:	$(WXDIR)\docs\latex\faq\faq.dvi
+	cd $(WXDIR)\docs\latex\faq
+        -dvips32 -o faq.ps faq
+        move faq.ps $(WXDIR)\docs\ps\faq.ps
+        cd $(THISDIR)
+
+
diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc
new file mode 100644
index 0000000000..ee780f6f1c
--- /dev/null
+++ b/src/msw/makefile.sc
@@ -0,0 +1,147 @@
+# Symantec C++ makefile for the msw objects
+# called from src\makefile.sc
+
+# configuration section (see src\makefile.sc) ###########################
+
+WXDIR = $(WXWIN)
+
+!include $(WXDIR)\src\makesc.env
+
+INCDIR = $(WXDIR)\include
+MSWINC = $(INCDIR)\msw
+BASEINC = $(INCDIR)\base
+
+# default values overridden by src\makefile.sc
+
+CC=sc
+CFLAGS = -o -ml -W -Dwx_msw
+
+INCLUDE=$(BASEINC);$(MSWINC);$(WXDIR)\contrib\fafa;$(WXDIR)\contrib\itsybits
+
+OPTIONS=
+
+# end of configuration section ##########################################
+
+OBJS = wx_win.obj wx_frame.obj wx_panel.obj wx_utils.obj wx_main.obj \
+wx_item.obj wx_text.obj wx_gdi.obj wx_dialg.obj wx_canvs.obj wx_dc.obj \
+wx_mf.obj wx_ipc.obj wx_timer.obj wx_clipb.obj wx_scrol.obj wx_vlbox.obj \
+wx_stat.obj wx_buttn.obj wx_messg.obj wx_check.obj wx_choic.obj wx_rbox.obj wx_lbox.obj \
+wx_group.obj wx_gauge.obj wx_txt.obj wx_mtxt.obj wx_slidr.obj wx_menu.obj wx_db.obj\
+wx_cmdlg.obj
+
+all: $(OBJS)
+
+wx_obj.obj: $(BASEINC)\wx_obj.h
+
+wx_win.obj: $(BASEINC)\wx_defs.h $(MSWINC)\wx_win.h \
+$(BASEINC)\wx_obj.h $(BASEINC)\wx_utils.h wx_win.$(SRCSUFF) \
+$(MSWINC)\wx_gdi.h $(MSWINC)\wx_privt.h
+
+wx_main.obj: $(BASEINC)\wx_defs.h $(BASEINC)\wx_obj.h \
+$(MSWINC)\wx_frame.h $(BASEINC)\wx_utils.h
+
+wx_frame.obj: $(BASEINC)\wx_defs.h $(MSWINC)\wx_win.h $(BASEINC)\wx_obj.h \
+$(BASEINC)\wx_utils.h $(MSWINC)\wx_frame.h wx_frame.$(SRCSUFF) \
+$(BASEINC)\wx_stdev.h $(MSWINC)\wx_privt.h
+
+wx_panel.obj: $(BASEINC)\wx_defs.h $(MSWINC)\wx_win.h $(BASEINC)\wx_obj.h \
+$(BASEINC)\wx_utils.h $(MSWINC)\wx_frame.h $(MSWINC)\wx_panel.h \
+wx_panel.$(SRCSUFF) $(BASEINC)\wx_stdev.h $(MSWINC)\wx_privt.h
+
+wx_text.obj: $(BASEINC)\wx_defs.h $(MSWINC)\wx_win.h $(BASEINC)\wx_obj.h \
+$(BASEINC)\wx_utils.h $(MSWINC)\wx_frame.h $(MSWINC)\wx_text.h \
+wx_text.$(SRCSUFF) $(BASEINC)\wx_stdev.h $(MSWINC)\wx_privt.h
+
+wx_canvs.obj: $(BASEINC)\wx_defs.h $(MSWINC)\wx_win.h $(BASEINC)\wx_obj.h \
+$(BASEINC)\wx_utils.h $(MSWINC)\wx_frame.h $(MSWINC)\wx_canvs.h \
+wx_canvs.$(SRCSUFF) $(BASEINC)\wx_stdev.h $(MSWINC)\wx_gdi.h $(MSWINC)\wx_dc.h \
+$(MSWINC)\wx_privt.h
+
+wx_dc.obj: $(BASEINC)\wx_defs.h $(MSWINC)\wx_win.h $(BASEINC)\wx_obj.h \
+$(BASEINC)\wx_utils.h $(MSWINC)\wx_frame.h $(MSWINC)\wx_canvs.h wx_dc.$(SRCSUFF) \
+$(BASEINC)\wx_stdev.h $(MSWINC)\wx_gdi.h $(MSWINC)\wx_dc.h \
+$(MSWINC)/wx_dccan.h $(MSWINC)/wx_dcmem.h
+
+wx_mf.obj: $(BASEINC)\wx_defs.h $(MSWINC)\wx_win.h $(BASEINC)\wx_obj.h \
+wx_mf.$(SRCSUFF) $(BASEINC)\wx_stdev.h $(MSWINC)\wx_gdi.h $(MSWINC)\wx_mf.h
+
+wx_item.obj: $(BASEINC)\wx_defs.h $(MSWINC)\wx_win.h $(BASEINC)\wx_obj.h \
+$(BASEINC)\wx_utils.h $(MSWINC)\wx_frame.h $(MSWINC)\wx_item.h \
+wx_item.$(SRCSUFF) $(BASEINC)\wx_stdev.h $(MSWINC)\wx_privt.h
+
+wx_utils.obj: $(BASEINC)\wx_defs.h $(BASEINC)\wx_obj.h \
+$(BASEINC)\wx_utils.h wx_utils.$(SRCSUFF)
+
+wx_ipc.obj: $(BASEINC)\wx_defs.h $(BASEINC)\wx_obj.h \
+$(BASEINC)\wx_utils.h $(MSWINC)\wx_ipc.h wx_ipc.$(SRCSUFF)
+
+wx_gdi.obj: $(BASEINC)\wx_defs.h $(MSWINC)\wx_gdi.h $(BASEINC)\wx_utils.h \
+wx_gdi.$(SRCSUFF)
+
+wx_dialg.obj: $(BASEINC)\wx_defs.h wx_dialg.$(SRCSUFF) $(MSWINC)\wx_dialg.h \
+$(MSWINC)\wx_win.h $(BASEINC)\wx_utils.h $(MSWINC)\wx_panel.h \
+$(MSWINC)\wx_privt.h
+
+wx_timer.obj: $(BASEINC)\wx_defs.h wx_timer.$(SRCSUFF) $(MSWINC)\wx_timer.h
+
+wx_clipb.obj: $(BASEINC)\wx_defs.h wx_clipb.$(SRCSUFF) $(MSWINC)\wx_clipb.h
+
+wx_stat.obj: wx_stat.$(SRCSUFF) $(MSWINC)\wx_stat.h
+
+wx_scrol.obj: wx_scrol.$(SRCSUFF) $(MSWINC)\wx_scrol.h
+
+wx_vlbox.obj: wx_vlbox.$(SRCSUFF) $(MSWINC)\wx_vlbox.h
+
+wx_buttn.obj: wx_buttn.$(SRCSUFF) $(MSWINC)\wx_buttn.h
+
+wx_messg.obj: wx_messg.$(SRCSUFF) $(MSWINC)\wx_messg.h
+
+wx_check.obj: wx_check.$(SRCSUFF) $(MSWINC)\wx_check.h
+
+wx_choic.obj: wx_choic.$(SRCSUFF) $(MSWINC)\wx_choic.h
+
+wx_rbox.obj: wx_rbox.$(SRCSUFF) $(MSWINC)\wx_rbox.h
+
+wx_lbox.obj: wx_lbox.$(SRCSUFF) $(MSWINC)\wx_lbox.h
+
+wx_group.obj: wx_group.$(SRCSUFF) $(MSWINC)\wx_group.h
+
+wx_gauge.obj: wx_gauge.$(SRCSUFF) $(MSWINC)\wx_gauge.h
+
+wx_txt.obj: wx_txt.$(SRCSUFF) $(MSWINC)\wx_txt.h
+
+wx_mtxt.obj: wx_mtxt.$(SRCSUFF) $(MSWINC)\wx_mtxt.h
+
+wx_slidr.obj: wx_slidr.$(SRCSUFF) $(MSWINC)\wx_slidr.h
+
+wx_menu.obj: wx_menu.$(SRCSUFF) $(MSWINC)\wx_menu.h
+
+wx_db.obj: wx_db.$(SRCSUFF) $(MSWINC)\wx_db.h
+
+wx_cmdlg.obj: wx_cmdlg.$(SRCSUFF) $(MSWINC)\wx_cmdlg.h
+
+$(MSWINC)/wx_win.h:  $(BASEINC)/wb_win.h
+$(MSWINC)/wx_main.h:  $(BASEINC)/wb_main.h
+$(MSWINC)/wx_frame.h:  $(BASEINC)/wb_frame.h
+$(MSWINC)/wx_panel.h:  $(BASEINC)/wb_panel.h
+$(MSWINC)/wx_text.h:  $(BASEINC)/wb_text.h
+$(MSWINC)/wx_dialg.h:  $(BASEINC)/wb_dialg.h
+$(MSWINC)/wx_ipc.h:  $(BASEINC)/wb_ipc.h
+$(MSWINC)/wx_gdi.h:  $(BASEINC)/wb_gdi.h
+$(MSWINC)/wx_event.h:  $(BASEINC)/wb_event.h
+$(MSWINC)/wx_canvs.h:  $(BASEINC)/wb_canvs.h
+$(MSWINC)/wx_mf.h:  $(BASEINC)/wb_mf.h
+$(MSWINC)/wx_item.h:  $(BASEINC)/wb_item.h
+$(MSWINC)/wx_buttn.h:  $(BASEINC)/wb_buttn.h
+$(MSWINC)/wx_messg.h:  $(BASEINC)/wb_messg.h
+$(MSWINC)/wx_choic.h:  $(BASEINC)/wb_choic.h
+$(MSWINC)/wx_check.h:  $(BASEINC)/wb_check.h
+$(MSWINC)/wx_lbox.h:  $(BASEINC)/wb_lbox.h
+$(MSWINC)/wx_txt.h:  $(BASEINC)/wb_txt.h
+$(MSWINC)/wx_mtxt.h:  $(BASEINC)/wb_mtxt.h
+$(MSWINC)/wx_slidr.h:  $(BASEINC)/wb_slidr.h
+$(MSWINC)/wx_menu.h:  $(BASEINC)/wb_menu.h
+
+
+clean:
+	-del *.obj
diff --git a/src/msw/makefile.wat b/src/msw/makefile.wat
new file mode 100644
index 0000000000..1dc75e669b
--- /dev/null
+++ b/src/msw/makefile.wat
@@ -0,0 +1,159 @@
+#!/binb/wmake.exe
+#
+# File:		makefile.wat
+# Author:	Edward C. Zimmermann <edz@crg.net>
+# Created:	1994
+# Updated:	Dmitri Chubraev, Nov.1994 <chubraev@iem.ee.ethz.ch>
+# RCS_ID        $Id$
+#
+# Makefile : Builds wxWindows library for Windows 3.1
+# and Watcom C++ 
+
+WXDIR = ..\..
+
+!include $(WXDIR)\src\makewat.env
+
+WXLIB = $(WXDIR)\lib
+
+LIBTARGET   = $(WXLIB)\wx$(LEVEL).lib
+DUMMY=dummydll
+#CTL3DOBJ    = ..\..\contrib\ctl3d\ctl3d32.obj
+#CTL3DLIB    = ..\..\contrib\ctl3d\win32s\ctl3d32.lib
+FAFALIB     = ..\..\contrib\fafa\fafa.lib
+#ODBCLIB     = ..\..\contrib\odbc\odbc32.lib
+GAUGELIB    = ..\..\contrib\gauge\gauge.lib
+ITSYLIB     = ..\..\contrib\itsybits\itsy.lib
+WXSTRINGLIB = ..\..\contrib\wxstring\wxstring.lib
+WXXPMLIB    = ..\..\contrib\wxxpm\wxxpm.lib
+PROIOLIB    = ..\..\utils\prologio\lib\prologio.lib
+DIBLIB      = ..\..\utils\dib\dib.lib
+RCPARSERLIB = ..\..\utils\rcparser\lib\rcparser.lib
+
+EXTRAMODULES = $(GAUGELIB) $(ITSYLIB) $(PROIOLIB) $(DIBLIB) $(WXSTRINGLIB) $(RCPARSERLIB) $(FAFALIB) # $(WXXPMLIB)
+EXTRATARGETS = fafa gauge itsy prologio dib rcparser wxstring # wxxpm
+EXTRATARGETSCLEAN = clean_fafa clean_gauge clean_itsy clean_proio clean_dib clean_rcp clean_wxstring # clean_wxxpm
+
+OBJECTS = wx_win.obj wx_frame.obj wx_panel.obj wx_utils.obj &
+  wx_item.obj wx_text.obj wx_gdi.obj wx_dialg.obj wx_canvs.obj wx_dc.obj &
+  wx_mf.obj wx_ipc.obj wx_timer.obj wx_clipb.obj wx_vlbox.obj &
+  wx_stat.obj wx_scrol.obj wx_buttn.obj wx_messg.obj wx_check.obj wx_choic.obj &
+  wx_rbox.obj wx_lbox.obj wx_group.obj wx_gauge.obj wx_txt.obj wx_mtxt.obj &
+  wx_slidr.obj wx_menu.obj wx_db.obj wx_cmdlg.obj wx_main.obj wx_combo.obj
+
+BASEOBJECTS = ..\base\wb_win.obj ..\base\wb_frame.obj ..\base\wb_panel.obj &
+	..\base\wb_utils.obj ..\base\wx_lay.obj ..\base\wx_doc.obj ..\base\wb_res.obj &
+        ..\base\wb_main.obj ..\base\wb_item.obj ..\base\wb_list.obj ..\base\wb_obj.obj &
+        ..\base\wb_text.obj ..\base\wb_gdi.obj ..\base\wb_dialg.obj ..\base\wb_canvs.obj &
+        ..\base\wb_dc.obj ..\base\wb_mf.obj ..\base\wb_ps.obj ..\base\wx_enhdg.obj &
+        ..\base\wb_hash.obj ..\base\wb_ipc.obj ..\base\wb_form.obj ..\base\wb_timer.obj &
+        ..\base\wb_help.obj ..\base\wb_sysev.obj ..\base\wb_stdev.obj ..\base\wb_types.obj &
+        ..\base\wb_mgstr.obj ..\base\wb_data.obj ..\base\wb_stat.obj &
+        ..\base\wb_scrol.obj ..\base\wb_vlbox.obj ..\base\wb_print.obj ..\base\wx_tbar.obj &
+        ..\base\wx_bbar.obj ..\base\wx_mem.obj ..\base\wx_date.obj ..\base\wb_cmdlg.obj &
+        ..\base\wx_time.obj ..\base\wx_frac.obj
+
+# This now replaced by contrib\wxstring
+#..\base\wxstring.obj 
+
+all:        base $(EXTRATARGETS) erasepch $(LIBTARGET)
+
+base:   .SYMBOLIC
+    cd ..\base
+    wmake -f makefile.wat all OPTIONS="$(OPTIONS)" DEBUG="$(DEBUG)" LEVEL=$(LEVEL)
+    cd ..\msw
+
+$(LIBTARGET) : $(OBJECTS) $(BASEOBJECTS) $(EXTRAMODULES) 
+    %create tmp.lbc
+    @for %i in ( $(OBJECTS) ) do @%append tmp.lbc +%i
+    @for %i in ( $(BASEOBJECTS) ) do @%append tmp.lbc +%i
+    @for %i in ( $(EXTRAMODULES) ) do @%append tmp.lbc +%i
+    wlib /b /c /n /p=512 $^@ @tmp.lbc
+	
+clean:   .SYMBOLIC
+    -erase *.obj *.bak *.err *.pch
+     cd ..\base
+     wmake -f makefile.wat clean
+    -erase $(LIBTARGET)
+     cd ..\msw
+
+cleanall:   clean $(EXTRATARGETSCLEAN)
+
+fafa:   .SYMBOLIC
+    cd $(WXDIR)\contrib\fafa
+    wmake -f makefile.wat all
+    cd $(WXDIR)\src\msw
+
+clean_fafa:   .SYMBOLIC
+    cd $(WXDIR)\contrib\fafa
+    wmake -f makefile.wat clean
+    cd $(WXDIR)\src\msw
+
+itsy:   .SYMBOLIC
+    cd $(WXDIR)\contrib\itsybits
+    wmake -f makefile.wat all
+    cd $(WXDIR)\src\msw
+
+clean_itsy:   .SYMBOLIC
+    cd $(WXDIR)\contrib\itsybits
+    wmake -f makefile.wat clean
+    cd $(WXDIR)\src\msw
+
+gauge:   .SYMBOLIC
+    cd $(WXDIR)\contrib\gauge
+    wmake -f makefile.wat all
+    cd $(WXDIR)\src\msw
+
+clean_gauge:   .SYMBOLIC
+    cd $(WXDIR)\contrib\gauge
+    wmake -f makefile.wat clean
+    cd $(WXDIR)\src\msw
+
+wxxpm:   .SYMBOLIC
+    cd $(WXDIR)\contrib\wxxpm
+    wmake -f makefile.wat all
+    cd $(WXDIR)\src\msw
+
+clean_wxxpm:   .SYMBOLIC
+    cd $(WXDIR)\contrib\wxxpm
+    wmake -f makefile.wat clean
+    cd $(WXDIR)\src\msw
+
+dib:   .SYMBOLIC
+    cd $(WXDIR)\utils\dib
+    wmake -f makefile.wat all
+    cd $(WXDIR)\src\msw
+
+clean_dib:   .SYMBOLIC
+    cd $(WXDIR)\utils\dib
+    wmake -f makefile.wat clean
+    cd $(WXDIR)\src\msw
+
+prologio:   .SYMBOLIC
+    cd $(WXDIR)\utils\prologio\src
+    wmake -f makefile.wat all
+    cd $(WXDIR)\src\msw
+
+clean_proio:   .SYMBOLIC
+    cd $(WXDIR)\utils\prologio\src
+    wmake -f makefile.wat clean
+    cd $(WXDIR)\src\msw
+
+rcparser:   .SYMBOLIC
+    cd $(WXDIR)\utils\rcparser\src
+    wmake -f makefile.wat all
+    cd $(WXDIR)\src\msw
+
+wxstring:   .SYMBOLIC
+    cd $(WXDIR)\contrib\wxstring
+    wmake -f makefile.wat all OPTIONS="$(OPTIONS)" DEBUG="$(DEBUG)"
+    cd $(WXDIR)\src\msw
+
+clean_wxstring:   .SYMBOLIC
+    cd $(WXDIR)\contrib\wxstring
+    wmake -f makefile.wat clean
+    cd $(WXDIR)\src\msw
+
+clean_rcp:   .SYMBOLIC
+    cd $(WXDIR)\utils\rcparser\src
+    wmake -f makefile.wat clean
+    cd $(WXDIR)\src\msw
diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp
new file mode 100644
index 0000000000..ff101f9e68
--- /dev/null
+++ b/src/msw/mdi.cpp
@@ -0,0 +1,1212 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        mdi.cpp
+// Purpose:     MDI classes
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "mdi.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#include "wx/frame.h"
+#include "wx/menu.h"
+#include "wx/app.h"
+#include "wx/utils.h"
+#include "wx/dialog.h"
+#include "wx/statusbr.h"
+#include "wx/settings.h"
+#endif
+
+#include "wx/mdi.h"
+#include "wx/msw/private.h"
+
+#if USE_NATIVE_STATUSBAR
+#include <wx/msw/statbr95.h>
+#endif
+
+#include <string.h>
+
+extern wxList wxModelessWindows;
+
+#define IDM_WINDOWTILE  4001
+#define IDM_WINDOWCASCADE 4002
+#define IDM_WINDOWICONS 4003
+#define IDM_WINDOWNEXT 4004
+// This range gives a maximum of 500
+// MDI children. Should be enough :-)
+#define wxFIRST_MDI_CHILD 4100
+#define wxLAST_MDI_CHILD 4600
+
+// Status border dimensions
+#define         wxTHICK_LINE_BORDER 3
+#define         wxTHICK_LINE_WIDTH  1
+
+extern char wxMDIFrameClassName[];
+extern char wxMDIChildFrameClassName[];
+extern wxWindow *wxWndHook;
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
+IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
+IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
+
+BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
+  EVT_SIZE(wxMDIParentFrame::OnSize)
+  EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
+  EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
+  EVT_SCROLL(wxMDIClientWindow::OnScroll)
+END_EVENT_TABLE()
+
+#endif
+
+wxMDIParentFrame::wxMDIParentFrame(void)
+{
+    m_clientWindow = NULL;
+    m_currentChild = NULL;
+    m_windowMenu = 0;
+    m_parentFrameActive = TRUE;
+  	m_frameToolBar = NULL ;
+}
+
+bool wxMDIParentFrame::Create(wxWindow *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos,
+           const wxSize& size,
+           const long style,
+           const wxString& name)
+{
+  m_defaultIcon = (WXHICON) (wxSTD_MDIPARENTFRAME_ICON ? wxSTD_MDIPARENTFRAME_ICON : wxDEFAULT_MDIPARENTFRAME_ICON);
+
+  m_frameToolBar = NULL ;
+  m_clientWindow = NULL;
+  m_currentChild = NULL;
+  m_windowMenu = 0;
+  m_parentFrameActive = TRUE;
+
+  if (!parent)
+    wxTopLevelWindows.Append(this);
+
+  SetName(name);
+  m_windowStyle = style;
+
+  if (parent) parent->AddChild(this);
+
+  if ( id > -1 )
+    m_windowId = id;
+  else
+    m_windowId = (int)NewControlId();
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_windowMenu = (WXHMENU) ::LoadMenu(wxGetInstance(), "wxWindowMenu");
+
+#if DEBUG > 1
+  wxDebugMsg("Loaded m_windowMenu %d\n", m_windowMenu);
+#endif
+
+  // Adding WS_CLIPCHILDREN causes children not to be properly
+  // drawn when first displaying them.
+  DWORD msflags = WS_OVERLAPPED ; // | WS_CLIPCHILDREN ;
+  if (style & wxMINIMIZE_BOX)
+    msflags |= WS_MINIMIZEBOX;
+  if (style & wxMAXIMIZE_BOX)
+    msflags |= WS_MAXIMIZEBOX;
+  if (style & wxTHICK_FRAME)
+    msflags |= WS_THICKFRAME;
+  if (style & wxSYSTEM_MENU)
+    msflags |= WS_SYSMENU;
+  if ((style & wxMINIMIZE) || (style & wxICONIZE))
+    msflags |= WS_MINIMIZE;
+  if (style & wxMAXIMIZE)
+    msflags |= WS_MAXIMIZE;
+  if (style & wxCAPTION)
+    msflags |= WS_CAPTION;
+
+  wxWindow::MSWCreate(m_windowId, parent, wxMDIFrameClassName, this, title, x, y, width, height,
+         msflags);
+
+  wxModelessWindows.Append(this);
+
+  return TRUE;
+}
+
+wxMDIParentFrame::~wxMDIParentFrame(void)
+{
+  DestroyChildren();
+
+  DestroyMenu((HMENU) m_windowMenu); // Destroy dummy "Window" menu
+  m_windowMenu = 0;
+
+  if (m_clientWindow->MSWGetOldWndProc())
+  	m_clientWindow->UnsubclassWin();
+
+  m_clientWindow->m_hWnd = 0;
+  delete m_clientWindow;
+}
+
+// Get size *available for subwindows* i.e. excluding menu bar.
+void wxMDIParentFrame::GetClientSize(int *x, int *y) const
+{
+  RECT rect;
+  GetClientRect((HWND) GetHWND(), &rect);
+
+  int cwidth = rect.right;
+  int cheight = rect.bottom;
+/*
+  if (m_frameToolBar)
+  {
+    int tw, th;
+    m_frameToolBar->GetSize(&tw, &th);
+    cheight -= th;
+  }
+*/
+  if ( GetStatusBar() )
+  {
+	int sw, sh;
+	GetStatusBar()->GetSize(&sw, &sh);
+	cheight -= sh;
+  }
+
+  *x = cwidth;
+  *y = cheight;
+}
+
+void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
+{
+  if (!menu_bar)
+  {
+    m_frameMenuBar = NULL;
+    return;
+  }
+  
+  if (menu_bar->m_menuBarFrame)
+	 return;
+
+  int i;
+  HMENU menu = CreateMenu();
+
+  for (i = 0; i < menu_bar->m_menuCount; i ++)
+  {
+    HMENU popup = (HMENU)menu_bar->m_menus[i]->m_hMenu;
+    //
+    // After looking Bounds Checker result, it seems that all
+    // menus must be individually destroyed. So, don't reset m_hMenu,
+    // to  allow ~wxMenu to do the job.
+    //
+    menu_bar->m_menus[i]->m_savehMenu = (WXHMENU) popup;
+    // Uncommenting for the moment... JACS
+    menu_bar->m_menus[i]->m_hMenu = (WXHMENU) NULL;
+    AppendMenu(menu, MF_POPUP | MF_STRING, (UINT)popup, menu_bar->m_titles[i]);
+  }
+
+  menu_bar->m_hMenu = (WXHMENU)menu;
+  if (m_frameMenuBar)
+    delete m_frameMenuBar;
+
+  this->m_hMenu = (WXHMENU) menu;
+
+  // MDI parent-specific code follows
+
+  HMENU subMenu = GetSubMenu((HMENU) m_windowMenu, 0);
+
+  // Try to insert Window menu in front of Help, otherwise append it.
+  int N = GetMenuItemCount(menu);
+  bool success = FALSE;
+  for (i = 0; i < N; i++)
+  {
+        char buf[100];
+        int chars = GetMenuString(menu, i, buf, 100, MF_BYPOSITION);
+        if ((chars > 0) && (strcmp(buf, "&Help") == 0 ||
+                            strcmp(buf, "Help") == 0))
+        {
+           success = TRUE;
+           InsertMenu(menu, i, MF_BYPOSITION | MF_POPUP | MF_STRING,
+                      (UINT)subMenu, "&Window");
+           break;
+        }
+  }
+  if (!success)
+    AppendMenu(menu, MF_POPUP,
+                         (UINT)subMenu,
+                         "&Window");
+  m_parentFrameActive = TRUE;
+#ifdef __WIN32__
+  SendMessage((HWND) GetClientWindow()->GetHWND(), WM_MDISETMENU,
+                (WPARAM)menu,
+                  (LPARAM)subMenu);
+#else
+  SendMessage((HWND) GetClientWindow()->GetHWND(), WM_MDISETMENU, 0,
+              MAKELPARAM(menu, subMenu));
+#endif
+  DrawMenuBar((HWND) GetHWND());
+
+  m_frameMenuBar = menu_bar;
+  menu_bar->m_menuBarFrame = this;
+}
+
+void wxMDIParentFrame::OnSize(wxSizeEvent& event)
+{
+#if USE_CONSTRAINTS
+    if (GetAutoLayout())
+      Layout();
+#endif
+    int x = 0;
+    int y = 0;
+    int width, height;
+    GetClientSize(&width, &height);
+    if ( GetToolBar() )
+    {
+        int wt, ht;
+        GetToolBar()->GetSize(&wt, &ht);
+        height -= ht;
+        y += ht;
+        GetToolBar()->SetSize(0, 0, width, ht);
+    }
+
+    if ( GetClientWindow() )
+        GetClientWindow()->SetSize(x, y, width, height);
+
+  // forward WM_SIZE to status bar control
+#if USE_NATIVE_STATUSBAR
+  if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
+    ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event);
+#endif
+}
+
+void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
+{
+	// Do nothing
+}
+
+#if WXWIN_COMPATIBILITY
+void wxMDIParentFrame::OldOnSize(int x, int y)
+{
+#if WXWIN_COMPATIBILITY == 1
+  wxSizeEvent event(wxSize(x, y), m_windowId);
+  event.SetEventObject( this );
+  GetEventHandler()->ProcessEvent(event);
+#else
+
+#if USE_CONSTRAINTS
+  if (GetAutoLayout())
+    Layout();
+#endif
+  int x = 0;
+  int y = 0;
+  int width, height;
+  GetClientSize(&width, &height);
+  if ( GetToolBar() )
+  {
+      int wt, ht;
+      GetToolBar()->GetSize(&wt, &ht);
+      height -= ht;
+      y += ht;
+  }
+
+  if ( GetClientWindow() )
+      GetClientWindow()->SetSize(x, y, width, height);
+
+#endif
+}
+
+// Default activation behaviour - nothing.
+// Default activation behaviour - override dedault wxFrame behaviour
+void wxMDIParentFrame::OldOnActivate(bool flag)
+{
+#if WXWIN_COMPATIBILITY == 1
+  wxActivateEvent event(wxEVT_ACTIVATE, flag, m_windowId);
+  event.SetEventObject( this );
+  GetEventHandler()->ProcessEvent(event);
+#else
+#endif
+}
+
+#endif
+
+// Returns the active MDI child window
+wxMDIChildFrame *wxMDIParentFrame::GetActiveChild(void) const
+{
+//  HWND hWnd = (HWND)LOWORD(SendMessage((HWND) GetClientWindow()->GetHWND(), WM_MDIGETACTIVE, 0, 0L));
+  HWND hWnd = (HWND)SendMessage((HWND) GetClientWindow()->GetHWND(), WM_MDIGETACTIVE, 0, 0L);
+  if (hWnd == 0)
+    return NULL;
+  else
+    return (wxMDIChildFrame *)wxFindWinFromHandle((WXHWND) hWnd);
+}
+
+// Create the client window class (don't Create the window,
+// just return a new class)
+wxMDIClientWindow *wxMDIParentFrame::OnCreateClient(void)
+{
+	return new wxMDIClientWindow ;
+}
+
+// Responds to colour changes, and passes event on to children.
+void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
+{
+    if ( m_clientWindow )
+    {
+        m_clientWindow->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
+        m_clientWindow->Refresh();
+    }
+/*
+    if ( m_frameToolBar )
+    {
+        wxSysColourChangedEvent event2;
+        event2.eventObject = m_frameToolBar;
+        m_frameToolBar->GetEventHandler()->ProcessEvent(event2);
+    }
+*/
+
+    // Propagate the event to the non-top-level children
+    wxFrame::OnSysColourChanged(event);
+}
+
+// MDI operations
+void wxMDIParentFrame::Cascade(void)
+{
+    ::SendMessage( (HWND) GetClientWindow()->GetHWND(), WM_MDICASCADE, 0, 0);
+}
+
+void wxMDIParentFrame::Tile(void)
+{
+    ::SendMessage( (HWND) GetClientWindow()->GetHWND(), WM_MDITILE, MDITILE_HORIZONTAL, 0);
+}
+
+void wxMDIParentFrame::ArrangeIcons(void)
+{
+    ::SendMessage( (HWND) GetClientWindow()->GetHWND(), WM_MDIICONARRANGE, 0, 0);
+}
+
+void wxMDIParentFrame::ActivateNext(void)
+{
+    ::SendMessage( (HWND) GetClientWindow()->GetHWND(), WM_MDINEXT, 0, 0);
+}
+
+void wxMDIParentFrame::ActivatePrevious(void)
+{
+    ::SendMessage( (HWND) GetClientWindow()->GetHWND(), WM_MDINEXT, 0, 1);
+}
+
+
+/*
+// Returns a style for the client window - usually 0
+// or, for example, wxHSCROLL | wxVSCROLL
+long wxMDIParentFrame::GetClientStyle(void) const
+{
+	return wxHSCROLL | wxVSCROLL ;
+}
+*/
+
+bool wxMDIParentFrame::MSWOnDestroy(void)
+{
+  return FALSE;
+}
+
+void wxMDIParentFrame::MSWOnCreate(WXLPCREATESTRUCT WXUNUSED(cs))
+{
+	m_clientWindow = new wxMDIClientWindow;
+	// Uses own style for client style
+	m_clientWindow->CreateClient(this, GetWindowStyleFlag());
+}
+
+void wxMDIParentFrame::MSWOnSize(const int x, const int y, const WXUINT id)
+{
+  switch (id)
+  {
+    case SIZEFULLSCREEN:
+    case SIZENORMAL:
+      m_iconized = FALSE;
+    break;
+    case SIZEICONIC:
+      m_iconized = TRUE;
+    break;
+  }
+
+ if (!m_iconized)
+ {
+  // forward WM_SIZE to status bar control
+#if USE_NATIVE_STATUSBAR
+  if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
+  {
+    wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId());
+    event.SetEventObject( m_frameStatusBar );
+
+    ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event);
+  }
+#endif
+
+	PositionStatusBar();
+
+    GetEventHandler()->OldOnSize(x, y);
+  }
+}
+
+bool wxMDIParentFrame::MSWOnActivate(const int state, const bool minimized, const WXHWND activate)
+{
+	wxWindow::MSWOnActivate(state, minimized, activate);
+
+    // If this window is an MDI parent, we must also send an OnActivate message
+    // to the current child.
+    if ((m_currentChild != NULL) && ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)))
+	{
+#if WXWIN_COMPATIBILITY
+      m_currentChild->GetEventHandler()->OldOnActivate(TRUE);
+#else
+      wxActivateEvent event(wxEVT_ACTIVATE, TRUE,
+	    m_currentChild.m_windowId);
+      event.eventObject = m_currentChild;
+      m_currentChild->GetEventHandler()->ProcessEvent(event);
+#endif
+    }
+    return 0;
+}
+
+bool wxMDIParentFrame::MSWOnCommand(const WXWORD id, const WXWORD cmd, const WXHWND control)
+{
+  if (cmd == 0)
+  {
+    // In case it's e.g. a toolbar.
+    wxWindow *win = wxFindWinFromHandle(control);
+    if (win)
+      return win->MSWCommand(cmd, id);
+
+    switch (id)
+    {
+      case IDM_WINDOWCASCADE:
+        SendMessage((HWND) GetClientWindow()->GetHWND(), WM_MDICASCADE, MDITILE_SKIPDISABLED, 0);
+        return TRUE;
+      case IDM_WINDOWTILE:
+        SendMessage((HWND) GetClientWindow()->GetHWND(), WM_MDITILE, MDITILE_HORIZONTAL, 0);
+        return TRUE;
+      case IDM_WINDOWICONS:
+        SendMessage((HWND) GetClientWindow()->GetHWND(), WM_MDIICONARRANGE, 0, 0);
+        return TRUE;
+      case IDM_WINDOWNEXT:
+        SendMessage((HWND) GetClientWindow()->GetHWND(), WM_MDINEXT, 0, 0);
+        return TRUE;
+      default:
+        break;
+     }
+    if (id >= 0xF000)
+    {
+#if DEBUG > 1
+      wxDebugMsg("wxMDIFrame::OnCommand %d: system command: calling default window proc\n", GetHWND());
+#endif
+      return FALSE; // Get WndProc to call default proc
+    }
+    
+    if (m_parentFrameActive && (id < wxFIRST_MDI_CHILD || id > wxLAST_MDI_CHILD))
+    {
+      ProcessCommand(id);
+      return TRUE;
+    }
+    else if (m_currentChild && (id < wxFIRST_MDI_CHILD || id > wxLAST_MDI_CHILD))
+    {
+#if DEBUG > 1
+      wxDebugMsg("wxMDIFrame::MSWOnCommand %d: calling child OnCommand\n", GetHWND());
+#endif
+      return m_currentChild->MSWOnCommand(id, cmd, control);
+    }
+  }
+  if (id >= wxFIRST_MDI_CHILD && id <= wxLAST_MDI_CHILD)
+  {
+    wxNode* node = GetChildren()->First();
+    while (node)
+    {
+        wxWindow* child = (wxWindow*) node->Data();
+        if (child->GetHWND())
+        {
+#ifdef __WIN32__
+            long childId = GetWindowLong((HWND) child->GetHWND(), GWL_ID);
+#else
+            long childId = GetWindowWord((HWND) child->GetHWND(), GWW_ID);
+#endif
+            if (childId == id)
+            {
+                ::SendMessage( (HWND) GetClientWindow()->GetHWND(), WM_MDIACTIVATE, (WPARAM) (HWND) child->GetHWND(), 0);
+                return TRUE;
+            }
+        }
+        node = node->Next();
+    }
+/*
+    wxWindow* child = FindItem(id);
+    if (child)
+    {
+        ::SendMessage( (HWND) GetClientWindow()->GetHWND(), WM_MDIACTIVATE, (WPARAM) (HWND) child->GetHWND(), 0);
+        return TRUE;
+    }
+*/
+  }
+
+  return FALSE;
+}
+
+void wxMDIParentFrame::MSWOnMenuHighlight(const WXWORD nItem, const WXWORD nFlags, const WXHMENU hSysMenu)
+{
+  if (m_parentFrameActive)
+  {
+	// TODO
+    if (nFlags == 0xFFFF && hSysMenu == (WXHMENU) NULL)
+      GetEventHandler()->OldOnMenuSelect(-1);
+    else if (nFlags != MF_SEPARATOR)
+      GetEventHandler()->OldOnMenuSelect(nItem);
+  }
+  else if (m_currentChild)
+  {
+    m_currentChild->MSWOnMenuHighlight(nItem, nFlags, hSysMenu);
+  }
+}
+
+long wxMDIParentFrame::MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+	WXHWND clientWnd;
+	if ( GetClientWindow() )
+	    clientWnd = GetClientWindow()->GetHWND();
+	else
+		clientWnd = 0;
+
+  return DefFrameProc((HWND) GetHWND(), (HWND) clientWnd, message, wParam, lParam);
+}
+
+bool wxMDIParentFrame::MSWProcessMessage(WXMSG* msg)
+{
+  MSG *pMsg = (MSG *)msg;
+
+  if ((m_currentChild != (wxWindow *)NULL) && (m_currentChild->GetHWND() != (WXHWND) NULL) && m_currentChild->MSWProcessMessage(msg))
+     return TRUE;
+	
+  if (m_acceleratorTable != (WXHANDLE) NULL &&
+          ::TranslateAccelerator((HWND) GetHWND(), (HANDLE) m_acceleratorTable, pMsg))
+    return TRUE;
+
+  if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN)
+  {
+    if (::TranslateMDISysAccel((HWND) GetClientWindow()->GetHWND(), pMsg))
+      return TRUE;
+  }
+
+  return FALSE;
+}
+
+bool wxMDIParentFrame::MSWOnEraseBkgnd(const WXHDC WXUNUSED(pDC))
+{
+  return TRUE;
+}
+
+extern wxWindow *wxWndHook;
+extern wxList *wxWinHandleList;
+
+wxMDIChildFrame::wxMDIChildFrame(void)
+{
+//	m_active = FALSE;
+}
+
+bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
+           const wxWindowID id,
+           const wxString& title,
+           const wxPoint& pos,
+           const wxSize& size,
+           const long style,
+           const wxString& name)
+{
+  m_defaultIcon = (WXHICON) (wxSTD_MDICHILDFRAME_ICON ? wxSTD_MDICHILDFRAME_ICON : wxDEFAULT_MDICHILDFRAME_ICON);
+
+  SetName(name);
+
+  if ( id > -1 )
+    m_windowId = id;
+  else
+    m_windowId = (int)NewControlId();
+
+  if (parent) parent->AddChild(this);
+
+  wxWndHook = this;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  MDICREATESTRUCT mcs;
+	
+  mcs.szClass = wxMDIChildFrameClassName;
+  mcs.szTitle = title;
+  mcs.hOwner = wxGetInstance();
+  if (x > -1) mcs.x = x;
+  else mcs.x = CW_USEDEFAULT;
+
+  if (y > -1) mcs.y = y;
+  else mcs.y = CW_USEDEFAULT;
+
+  if (width > -1) mcs.cx = width;
+  else mcs.cx = CW_USEDEFAULT;
+
+  if (height > -1) mcs.cy = height;
+  else mcs.cy = CW_USEDEFAULT;
+
+  DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN ;
+  if (style & wxMINIMIZE_BOX)
+    msflags |= WS_MINIMIZEBOX;
+  if (style & wxMAXIMIZE_BOX)
+    msflags |= WS_MAXIMIZEBOX;
+  if (style & wxTHICK_FRAME)
+    msflags |= WS_THICKFRAME;
+  if (style & wxSYSTEM_MENU)
+    msflags |= WS_SYSMENU;
+  if ((style & wxMINIMIZE) || (style & wxICONIZE))
+    msflags |= WS_MINIMIZE;
+  if (style & wxMAXIMIZE)
+    msflags |= WS_MAXIMIZE;
+  if (style & wxCAPTION)
+    msflags |= WS_CAPTION;
+
+  mcs.style = msflags;
+
+  mcs.lParam = 0;
+
+  DWORD Return = SendMessage((HWND) parent->GetClientWindow()->GetHWND(),
+		WM_MDICREATE, 0, (LONG)(LPSTR)&mcs);
+
+  //handle = (HWND)LOWORD(Return);
+  // Must be the DWORRD for WIN32. And in 16 bits, HIWORD=0 (says Microsoft)
+  m_hWnd = (WXHWND)Return;
+
+  // This gets reassigned so can't be stored
+//  m_windowId = GetWindowLong((HWND) m_hWnd, GWL_ID);
+
+  wxWndHook = NULL;
+  wxWinHandleList->Append((long)GetHWND(), this);
+
+  SetWindowLong((HWND) GetHWND(), 0, (long)this);
+
+  wxModelessWindows.Append(this);
+  return TRUE;
+}
+
+wxMDIChildFrame::~wxMDIChildFrame(void)
+{
+	MSWDestroyWindow();
+
+    ResetWindowStyle(NULL);
+}
+
+// Set the client size (i.e. leave the calculation of borders etc.
+// to wxWindows)
+void wxMDIChildFrame::SetClientSize(const int width, const int height)
+{
+  HWND hWnd = (HWND) GetHWND();
+
+  RECT rect;
+  GetClientRect(hWnd, &rect);
+
+  RECT rect2;
+  GetWindowRect(hWnd, &rect2);
+
+  // Find the difference between the entire window (title bar and all)
+  // and the client area; add this to the new client size to move the
+  // window
+  int actual_width = rect2.right - rect2.left - rect.right + width;
+  int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
+
+  if (GetStatusBar())
+  {
+	int sx, sy;
+	GetStatusBar()->GetSize(&sx, &sy);
+    actual_height += sy;
+  }
+
+  POINT point;
+  point.x = rect2.left;
+  point.y = rect2.top;
+
+  // If there's an MDI parent, must subtract the parent's top left corner
+  // since MoveWindow moves relative to the parent
+  wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
+  ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
+
+  MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+}
+
+void wxMDIChildFrame::GetPosition(int *x, int *y) const
+{
+  RECT rect;
+  GetWindowRect((HWND) GetHWND(), &rect);
+  POINT point;
+  point.x = rect.left;
+  point.y = rect.top;
+
+  // Since we now have the absolute screen coords,
+  // if there's a parent we must subtract its top left corner
+  wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
+  ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
+
+  *x = point.x;
+  *y = point.y;
+}
+
+void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
+{
+  if (!menu_bar)
+  {
+    m_frameMenuBar = NULL;
+    return;
+  }
+  
+  if (menu_bar->m_menuBarFrame)
+	 return;
+
+  int i;
+  HMENU menu = CreateMenu();
+
+  for (i = 0; i < menu_bar->m_menuCount; i ++)
+  {
+    HMENU popup = (HMENU)menu_bar->m_menus[i]->m_hMenu;
+    //
+    // After looking Bounds Checker result, it seems that all
+    // menus must be individually destroyed. So, don't reset m_hMenu,
+    // to  allow ~wxMenu to do the job.
+    //
+    menu_bar->m_menus[i]->m_savehMenu = (WXHMENU) popup;
+    // Uncommenting for the moment... JACS
+    menu_bar->m_menus[i]->m_hMenu = 0;
+    ::AppendMenu((HMENU) menu, MF_POPUP | MF_STRING, (UINT)popup, menu_bar->m_titles[i]);
+  }
+
+  menu_bar->m_hMenu = (WXHMENU)menu;
+  if (m_frameMenuBar)
+    delete m_frameMenuBar;
+
+  this->m_hMenu = (WXHMENU) menu;
+
+   wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
+
+   parent->m_parentFrameActive = FALSE;
+   HMENU subMenu = GetSubMenu((HWND) parent->GetWindowMenu(), 0);
+
+   // Try to insert Window menu in front of Help, otherwise append it.
+   int N = GetMenuItemCount(menu);
+   bool success = FALSE;
+   for (i = 0; i < N; i++)
+   {
+        char buf[100];
+        int chars = GetMenuString(menu, i, buf, 100, MF_BYPOSITION);
+        if ((chars > 0) && (strcmp(buf, "&Help") == 0 ||
+                            strcmp(buf, "Help") == 0))
+        {
+           success = TRUE;
+           InsertMenu(menu, i, MF_BYPOSITION | MF_POPUP | MF_STRING,
+                      (UINT)subMenu, "&Window");
+           break;
+        }
+      }
+  if (!success)
+    AppendMenu(menu, MF_POPUP,
+                         (UINT)subMenu,
+                         "&Window");
+#ifdef __WIN32__
+  SendMessage((HWND) parent->GetClientWindow()->GetHWND(), WM_MDISETMENU,
+                  (WPARAM)menu,
+                  (LPARAM)subMenu);
+#else
+  SendMessage((HWND) parent->GetClientWindow()->GetHWND(), WM_MDISETMENU, 0,
+                  MAKELPARAM(menu, subMenu));
+#endif
+
+  DrawMenuBar((HWND) parent->GetHWND());
+  m_frameMenuBar = menu_bar;
+  menu_bar->m_menuBarFrame = this;
+}
+
+// MDI operations
+void wxMDIChildFrame::Maximize(void)
+{
+    wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
+    if ( parent && parent->GetClientWindow() )
+        ::SendMessage( (HWND) parent->GetClientWindow()->GetHWND(), WM_MDIMAXIMIZE, (WPARAM) (HWND) GetHWND(), 0);
+}
+
+void wxMDIChildFrame::Restore(void)
+{
+    wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
+    if ( parent && parent->GetClientWindow() )
+        ::SendMessage( (HWND) parent->GetClientWindow()->GetHWND(), WM_MDIRESTORE, (WPARAM) (HWND) GetHWND(), 0);
+}
+
+void wxMDIChildFrame::Activate(void)
+{
+    wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
+    if ( parent && parent->GetClientWindow() )
+        ::SendMessage( (HWND) parent->GetClientWindow()->GetHWND(), WM_MDIACTIVATE, (WPARAM) (HWND) GetHWND(), 0);
+}
+
+static HWND invalidHandle = 0;
+void wxMDIChildFrame::MSWOnSize(const int x, const int y, const WXUINT id)
+{
+  if (!GetHWND()) return;
+
+  if (invalidHandle == (HWND) GetHWND())
+  {
+#if DEBUG > 1
+  wxDebugMsg("wxMDIChildFrame::OnSize %d: invalid, so returning.\n", GetHWND());
+#endif
+    return;
+  }
+  
+  (void)MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
+
+  switch (id)
+  {
+    case SIZEFULLSCREEN:
+    case SIZENORMAL:
+      m_iconized = FALSE;
+    break;
+    case SIZEICONIC:
+      m_iconized = TRUE;
+    break;
+  }
+
+  if (!m_iconized)
+  {
+    // forward WM_SIZE to status bar control
+#if USE_NATIVE_STATUSBAR
+    if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
+    {
+      wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId());
+      event.SetEventObject( m_frameStatusBar );
+
+      ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event);
+    }
+#endif
+
+    PositionStatusBar();
+
+    wxWindow::MSWOnSize(x, y, id);
+  }
+}
+
+bool wxMDIChildFrame::MSWOnCommand(const WXWORD id, const WXWORD cmd, const WXHWND control)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxMDIChildFrame::MSWOnCommand %d\n", GetHWND());
+#endif
+  if ((cmd == 0) && GetHWND())
+  {
+    // In case it's e.g. a toolbar.
+    wxWindow *win = wxFindWinFromHandle(control);
+    if (win)
+      return win->MSWCommand(cmd, id);
+
+    if (GetMenuBar() && GetMenuBar()->FindItemForId(id))
+    {
+      ProcessCommand(id);
+      return TRUE;
+    }
+    else
+      return FALSE;
+    return TRUE;
+  }
+  else
+    return FALSE;
+}
+
+long wxMDIChildFrame::MSWDefWindowProc(WXUINT message, WXUINT wParam, WXLPARAM lParam)
+{
+  if (GetHWND())
+    return DefMDIChildProc((HWND) GetHWND(), (UINT) message, (WPARAM) wParam, (LPARAM) lParam);
+  else return 0;
+}
+
+bool wxMDIChildFrame::MSWProcessMessage(WXMSG *msg)
+{
+  MSG *pMsg = (MSG *)msg;
+  if (m_acceleratorTable && GetHWND())
+  {
+    wxFrame *parent = (wxFrame *)GetParent();
+    HWND parent_hwnd = (HWND) parent->GetHWND();
+    return (::TranslateAccelerator(parent_hwnd, (HANDLE) m_acceleratorTable, pMsg) != 0);
+  }
+  return FALSE;
+}
+
+long wxMDIChildFrame::MSWOnMDIActivate(const long activate, const WXHWND WXUNUSED(one), const WXHWND WXUNUSED(two))
+{
+  wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
+  HMENU parent_menu = (HMENU) parent->GetWinMenu();
+#if DEBUG > 1
+  wxDebugMsg("Parent menu is %d\n", parent_menu);
+#endif
+  HMENU child_menu = (HMENU) GetWinMenu();
+#if DEBUG > 1
+  wxDebugMsg("Child menu is %d\n", child_menu);
+#endif
+
+  if (activate)
+  {
+//    m_active = TRUE;
+    parent->m_currentChild = this;
+    if (child_menu)
+    {
+      parent->m_parentFrameActive = FALSE;
+      HMENU subMenu = GetSubMenu((HMENU) parent->GetWindowMenu(), 0);
+#if DEBUG > 1
+      wxDebugMsg("Window submenu is %d\n", subMenu);
+#endif
+//      HMENU subMenu = 0;
+#ifdef __WIN32__
+      ::SendMessage((HWND) parent->GetClientWindow()->GetHWND(), WM_MDISETMENU,
+                    (WPARAM)child_menu,
+                    (LPARAM)subMenu);
+#else
+      ::SendMessage((HWND) parent->GetClientWindow()->GetHWND(), WM_MDISETMENU, 0,
+                  MAKELONG(child_menu, subMenu));
+#endif
+
+      ::DrawMenuBar((HWND) parent->GetHWND());
+    }
+    GetEventHandler()->OldOnActivate(TRUE);
+  }
+  else
+  {
+    if (parent->m_currentChild == this)
+      parent->m_currentChild = NULL;
+    GetEventHandler()->OldOnActivate(FALSE);
+
+//    m_active = FALSE;
+    if (parent_menu)
+    {
+      parent->m_parentFrameActive = TRUE;
+      HMENU subMenu = GetSubMenu((HMENU) parent->GetWindowMenu(), 0);
+#if DEBUG > 1
+      wxDebugMsg("Window submenu is %d\n", subMenu);
+#endif
+//      HMENU subMenu = 0;
+#ifdef __WIN32__
+      ::SendMessage((HWND) parent->GetClientWindow()->GetHWND(), WM_MDISETMENU,
+                    (WPARAM)parent_menu,
+                    (LPARAM)subMenu);
+#else
+      ::SendMessage((HWND) parent->GetClientWindow()->GetHWND(), WM_MDISETMENU, 0,
+                  MAKELONG(parent_menu, subMenu));
+#endif
+
+      ::DrawMenuBar((HWND) parent->GetHWND());
+    }
+  }
+  // TODO
+  bool flag = (activate != 0);
+  GetEventHandler()->OldOnActivate(flag);
+#if DEBUG > 1
+  wxDebugMsg("Finished (de)activating\n");
+#endif
+  return 0;
+}
+
+void wxMDIChildFrame::MSWDestroyWindow(void)
+{
+  MSWDetachWindowMenu();
+  invalidHandle = (HWND) GetHWND();
+
+  wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
+
+  // Must make sure this handle is invalidated (set to NULL)
+  // since all sorts of things could happen after the
+  // child client is destroyed, but before the wxFrame is
+  // destroyed.
+
+  HWND oldHandle = (HWND)GetHWND();
+#if DEBUG > 1
+  wxDebugMsg("*** About to DestroyWindow MDI child %d\n", oldHandle);
+#endif
+#ifdef __WIN32__
+  SendMessage((HWND) parent->GetClientWindow()->GetHWND(), WM_MDIDESTROY, (WPARAM)oldHandle, (LPARAM)0);
+#else
+  SendMessage((HWND) parent->GetClientWindow()->GetHWND(), WM_MDIDESTROY, (HWND)oldHandle, 0);
+#endif
+#if DEBUG > 1
+  wxDebugMsg("*** Finished DestroyWindow MDI child %d\n", oldHandle);
+#endif
+  invalidHandle = 0;
+
+  if (m_hMenu)
+  {
+    ::DestroyMenu((HMENU) m_hMenu);
+    m_hMenu = 0;
+  }
+  m_hWnd = 0;
+}
+
+// Change the client window's extended style so we don't
+// get a client edge style when a child is maximised (a double
+// border looks silly.)
+bool wxMDIChildFrame::ResetWindowStyle(void *vrect)
+{
+#if defined(__WIN95__)
+    RECT *rect = (RECT *)vrect;
+	wxMDIParentFrame* pFrameWnd = (wxMDIParentFrame *)GetParent();
+	wxMDIChildFrame* pChild = pFrameWnd->GetActiveChild();
+	if (!pChild || (pChild == this))
+	{
+		DWORD dwStyle = ::GetWindowLong((HWND) pFrameWnd->GetClientWindow()->GetHWND(), GWL_EXSTYLE);
+        DWORD dwThisStyle = ::GetWindowLong((HWND) GetHWND(), GWL_STYLE);
+		DWORD dwNewStyle = dwStyle;
+		if (pChild != NULL && (dwThisStyle & WS_MAXIMIZE))
+			dwNewStyle &= ~(WS_EX_CLIENTEDGE);
+		else
+			dwNewStyle |= WS_EX_CLIENTEDGE;
+
+		if (dwStyle != dwNewStyle)
+		{
+			::RedrawWindow((HWND) pFrameWnd->GetClientWindow()->GetHWND(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
+			::SetWindowLong((HWND) pFrameWnd->GetClientWindow()->GetHWND(), GWL_EXSTYLE, dwNewStyle);
+			::SetWindowPos((HWND) pFrameWnd->GetClientWindow()->GetHWND(), NULL, 0, 0, 0, 0,
+				SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOCOPYBITS);
+			if (rect)
+				::GetClientRect((HWND) pFrameWnd->GetClientWindow()->GetHWND(), rect);
+			return TRUE;
+		}
+	}
+	return FALSE;
+#else
+    return FALSE;
+#endif
+}
+
+void wxMDIChildFrame::MSWOnWindowPosChanging(void *pos)
+{
+    WINDOWPOS *lpPos = (WINDOWPOS *)pos;
+#if defined(__WIN95__)
+    if (!(lpPos->flags & SWP_NOSIZE))
+	{
+		RECT rectClient;
+		DWORD dwExStyle = ::GetWindowLong((HWND) GetHWND(), GWL_EXSTYLE);
+        DWORD dwStyle = ::GetWindowLong((HWND) GetHWND(), GWL_STYLE);
+		if (ResetWindowStyle((void *) & rectClient) && (dwStyle & WS_MAXIMIZE))
+		{
+			::AdjustWindowRectEx(&rectClient, dwStyle, FALSE, dwExStyle);
+			lpPos->x = rectClient.left;
+            lpPos->y = rectClient.top;
+			lpPos->cx = rectClient.right - rectClient.left;
+            lpPos->cy = rectClient.bottom - rectClient.top;
+		}
+	    wxMDIParentFrame* pFrameWnd = (wxMDIParentFrame *)GetParent();
+        if (pFrameWnd && pFrameWnd->GetToolBar())
+        {
+            pFrameWnd->GetToolBar()->Refresh();
+        }
+	}
+#endif
+    Default();
+}
+
+// Client window
+wxMDIClientWindow::wxMDIClientWindow(void)
+{
+    m_scrollX = 0;
+    m_scrollY = 0;
+}
+
+wxMDIClientWindow::~wxMDIClientWindow(void)
+{
+}
+
+bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, const long style)
+{
+  m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
+
+  CLIENTCREATESTRUCT ccs;
+  m_windowStyle = style;
+  m_windowParent = parent;
+	
+  ccs.hWindowMenu = (HMENU) parent->GetWindowMenu();
+  ccs.idFirstChild = wxFIRST_MDI_CHILD;
+
+  DWORD msStyle = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN ;
+  if ( parent->GetWindowStyleFlag() & wxHSCROLL )
+	msStyle |= WS_HSCROLL;
+  if ( parent->GetWindowStyleFlag() & wxVSCROLL )
+	msStyle |= WS_VSCROLL ;
+
+#if defined(__WIN95__)
+  DWORD exStyle = WS_EX_CLIENTEDGE;
+#else
+  DWORD exStyle = 0;
+#endif
+
+  wxWndHook = this;
+  m_hWnd = (WXHWND) ::CreateWindowEx(exStyle, "mdiclient", NULL,
+                msStyle, 0, 0, 0, 0, (HWND) parent->GetHWND(), NULL,
+                wxGetInstance(), (LPSTR)(LPCLIENTCREATESTRUCT)&ccs);
+  SubclassWin(m_hWnd);
+  wxWndHook = NULL;
+
+  return (m_hWnd != 0) ;
+}
+
+// Window procedure: here for debugging purposes
+long wxMDIClientWindow::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+    return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
+//    return MSWDefWindowProc(nMsg, wParam, lParam);
+}
+
+long wxMDIClientWindow::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+	if ( MSWGetOldWndProc() != 0)
+  		return ::CallWindowProc(CASTWNDPROC (FARPROC) MSWGetOldWndProc(), (HWND) GetHWND(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
+	else
+		return ::DefWindowProc((HWND) m_hWnd, (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
+}
+
+// Explicitly call default scroll behaviour
+void wxMDIClientWindow::OnScroll(wxScrollEvent& event)
+{
+    // Note: for client windows, the scroll position is not set in
+    // WM_HSCROLL, WM_VSCROLL, so we can't easily determine what
+    // scroll position we're at.
+    // This makes it hard to paint patterns or bitmaps in the background,
+    // and have the client area scrollable as well.
+
+    if ( event.GetOrientation() == wxHORIZONTAL )
+        m_scrollX = event.GetPosition(); // Always returns zero!
+    else
+        m_scrollY = event.GetPosition(); // Always returns zero!
+
+	Default();
+}
+
+// Should hand the message to the default proc
+long wxMDIClientWindow::MSWOnMDIActivate(const long bActivate, const WXHWND, const WXHWND)
+{
+    return Default();
+}
+
diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp
new file mode 100644
index 0000000000..1004cd16e8
--- /dev/null
+++ b/src/msw/menu.cpp
@@ -0,0 +1,901 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        menu.cpp
+// Purpose:     wxMenu, wxMenuBar, wxMenuItem
+// Author:      Julian Smart
+// Modified by: Vadim Zeitlin
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+
+// ============================================================================
+// headers & declarations
+// ============================================================================
+
+// wxWindows headers
+// -----------------
+
+#ifdef __GNUG__
+#pragma implementation "menu.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/frame.h"
+#include "wx/menu.h"
+#include "wx/utils.h"
+#endif
+
+#if USE_OWNER_DRAWN
+#include "wx/ownerdrw.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "wx/msw/menu.h"
+#include "wx/menuitem.h"
+#include "wx/log.h"
+
+// other standard headers
+// ----------------------
+#include <string.h>
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxWindow)
+IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxWindow)
+#endif
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// Menus
+
+// Construct a menu with optional title (then use append)
+wxMenu::wxMenu(const wxString& Title, const wxFunction func)
+{
+  m_title = Title;
+  m_parent = NULL;
+  m_eventHandler = this;
+  m_pInvokingWindow = NULL;
+  m_doBreak = FALSE ;
+  m_noItems = 0;
+  m_menuBar = NULL;
+  m_hMenu = (WXHMENU) CreatePopupMenu();
+  m_savehMenu = 0 ;
+  m_topLevelMenu = this;
+  if (m_title != "")
+  {
+    Append(-2, m_title) ;
+    AppendSeparator() ;
+  }
+
+  Callback(func);
+}
+
+// The wxWindow destructor will take care of deleting the submenus.
+wxMenu::~wxMenu(void)
+{
+  if (m_hMenu)
+    DestroyMenu((HMENU) m_hMenu);
+  m_hMenu = 0;
+
+  // Windows seems really bad on Menu de-allocation...
+  // After many try, here is what I do: RemoveMenu() will ensure
+  // that popup are "disconnected" from their parent; then call
+  // delete method on each child (which in turn do a recursive job),
+  // and finally, DestroyMenu()
+  //
+  // With that, BoundCheckers is happy, and no complaints...
+/*
+  int N = 0 ;
+  if (m_hMenu)
+    N = GetMenuItemCount(m_hMenu);
+  int i;
+  for (i = N-1; i >= 0; i--)
+    RemoveMenu(m_hMenu, i, MF_BYPOSITION);
+*/
+
+  // How is deleting submenus in this loop any different from deleting
+  // the submenus in the children list, via ~wxWindow ?
+  // I'll reinstate this deletion for now and remove addition
+  // from children list (which doesn't exist now)
+  // Julian 1/3/97
+  wxNode *node = m_menuItems.First();
+  while (node)
+  {
+    wxMenuItem *item = (wxMenuItem *)node->Data();
+
+    // Delete child menus.
+    // Beware: they must not be appended to children list!!!
+    // (because order of delete is significant)
+    if (item->GetSubMenu())
+      item->DeleteSubMenu();
+
+    wxNode *next = node->Next();
+    delete item;
+    delete node;
+    node = next;
+  }
+/*
+  if (m_hMenu)
+    DestroyMenu(m_hMenu);
+  m_hMenu = 0;
+*/
+}
+
+void wxMenu::Break(void)
+{
+  m_doBreak = TRUE ;
+}
+
+// function appends a new item or submenu to the menu
+void wxMenu::Append(wxMenuItem *pItem)
+{
+  wxCHECK( pItem != NULL );
+
+  m_menuItems.Append(pItem);
+
+  UINT  flags = 0;
+  
+  if ( m_doBreak ) {
+    flags |= MF_MENUBREAK;
+    m_doBreak = FALSE;
+  }
+
+  if ( pItem->IsSeparator() ) {
+    flags |= MF_SEPARATOR;
+  }
+
+  // id is the numeric id for normal menu items and HMENU for submenus
+  UINT id;
+  wxMenu *SubMenu = pItem->GetSubMenu();
+  if ( SubMenu != NULL ) {
+    wxASSERT( SubMenu->m_hMenu != NULL );
+
+    id = (UINT)SubMenu->m_hMenu;
+
+    SubMenu->m_topLevelMenu = m_topLevelMenu;
+    SubMenu->m_parent       = this;
+    SubMenu->m_savehMenu    = (WXHMENU)id;
+    SubMenu->m_hMenu        = 0;
+
+    flags |= MF_POPUP;
+  }
+  else {
+    id = pItem->GetId();
+  }
+
+  LPCSTR pData;
+  wxString name("");
+
+#if USE_OWNER_DRAWN
+  if ( pItem->IsOwnerDrawn() ) {  // want to get {Measure|Draw}Item messages?
+    // item draws itself, pass pointer to it in data parameter
+    flags |= MF_OWNERDRAW;
+    pData = (LPCSTR)pItem;
+  }
+  else
+#endif
+  {
+    // menu is just a normal string (passed in data parameter)
+    flags |= MF_STRING;
+    name = pItem->GetName();
+    pData = (const char*) name;
+  }
+
+  // VZ: what does this magic -2 mean? I just copied the code but have no idea
+  //     about what it does... ###
+  if ( pItem->GetId() == -2 ) {
+    flags |= MF_DISABLED | MF_GRAYED;
+  }
+
+  HMENU hMenu = (HMENU)((m_hMenu == 0) ? m_savehMenu : m_hMenu);
+
+  if ( !AppendMenu(hMenu, flags, id, pData) )
+  {
+    // wxLogLastError("AppendMenu");
+  }
+
+  m_noItems++;
+}
+
+void wxMenu::AppendSeparator(void)
+{
+  Append(new wxMenuItem(this, ID_SEPARATOR));
+}
+
+// Pullright item
+void wxMenu::Append(int Id, const wxString& label, wxMenu *SubMenu, 
+                    const wxString& helpString)
+{
+  Append(new wxMenuItem(this, Id, label, helpString, FALSE, SubMenu));
+}
+
+// Ordinary menu item
+void wxMenu::Append(int Id, const wxString& label, 
+                    const wxString& helpString, bool checkable)
+{
+  // 'checkable' parameter is useless for Windows.
+  Append(new wxMenuItem(this, Id, label, helpString, checkable));
+}
+
+void wxMenu::Delete(int id)
+{
+  wxNode *node;
+  wxMenuItem *item;
+  int pos;
+  HMENU menu;
+
+  for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) {
+	 item = (wxMenuItem *)node->Data();
+	 if (item->GetId() == id)
+		break;
+  }
+
+  if (!node)
+	return;
+
+  menu = (HMENU)(m_hMenu ? m_hMenu : m_savehMenu);
+
+  wxMenu *pSubMenu = item->GetSubMenu();
+  if ( pSubMenu != NULL ) {
+    RemoveMenu(menu, (UINT)pos, MF_BYPOSITION);
+    pSubMenu->m_hMenu = pSubMenu->m_savehMenu;
+    pSubMenu->m_savehMenu = 0;
+    pSubMenu->m_parent = NULL;
+    //     RemoveChild(item->subMenu);
+    pSubMenu->m_topLevelMenu = NULL;
+    // TODO: Why isn't subMenu deleted here???
+    // Will put this in for now. Assuming this is supposed
+    // to delete the menu, not just remove it.
+    item->DeleteSubMenu();
+  }
+  else {
+    DeleteMenu(menu, (UINT)pos, MF_BYPOSITION);
+  }
+
+  m_menuItems.DeleteNode(node);
+  delete item;
+}
+
+void wxMenu::Enable(int Id, bool Flag)
+{
+  wxMenuItem *item = FindItemForId(Id);
+  wxCHECK( item != NULL );
+
+  item->Enable(Flag);
+}
+
+bool wxMenu::Enabled(int Id) const
+{
+  wxMenuItem *item = FindItemForId(Id);
+  wxCHECK_RET( item != NULL, FALSE );
+
+  return item->IsEnabled();
+}
+
+void wxMenu::Check(int Id, bool Flag)
+{
+  wxMenuItem *item = FindItemForId(Id);
+  wxCHECK( item != NULL );
+
+  item->Check(Flag);
+}
+
+bool wxMenu::Checked(int Id) const
+{
+  wxMenuItem *item = FindItemForId(Id);
+  wxCHECK_RET( item != NULL, FALSE );
+
+  return item->IsChecked();
+}
+
+void wxMenu::SetTitle(const wxString& label)
+{
+  m_title = label ;
+  if (m_hMenu)
+    ModifyMenu((HMENU)m_hMenu, 0,
+             MF_BYPOSITION | MF_STRING | MF_DISABLED,
+             (UINT)-2, (const char *)m_title);
+  else if (m_savehMenu)
+    ModifyMenu((HMENU)m_savehMenu, 0,
+             MF_BYPOSITION | MF_STRING | MF_DISABLED,
+             (UINT)-2, (const char *)m_title);
+}
+
+const wxString& wxMenu::GetTitle() const
+{
+   return m_title;
+}
+
+void wxMenu::SetLabel(int Id, const wxString& label)
+{
+  wxMenuItem *item = FindItemForId(Id) ;
+  if (item==NULL)
+    return;
+
+  if (item->GetSubMenu()==NULL)
+  {
+    if (m_hMenu)
+    {
+      UINT was_flag = GetMenuState((HMENU)m_hMenu,Id,MF_BYCOMMAND) ;
+      ModifyMenu((HMENU)m_hMenu,Id,MF_BYCOMMAND|MF_STRING|was_flag,Id,(const char *)label) ;
+    }
+    else if (m_savehMenu)
+    {
+      UINT was_flag = GetMenuState((HMENU)m_savehMenu,Id,MF_BYCOMMAND) ;
+      ModifyMenu((HMENU)m_savehMenu,Id,MF_BYCOMMAND|MF_STRING|was_flag,Id,(const char *)label) ;
+    }
+  }
+  else
+  {
+    wxMenu *father = item->GetSubMenu()->m_topLevelMenu ;
+    wxNode *node = father->m_menuItems.First() ;
+    int i = 0 ;
+    while (node)
+    {
+      wxMenuItem *matched = (wxMenuItem*)node->Data() ;
+      if (matched==item)
+        break ;
+      i++ ;
+      node = node->Next() ;
+    }
+    // Here, we have the position.
+    ModifyMenu((HMENU)father->m_savehMenu,i,
+               MF_BYPOSITION|MF_STRING|MF_POPUP,
+               (UINT)item->GetSubMenu()->m_savehMenu,(const char *)label) ;
+  }
+  item->SetName(label);
+}
+
+wxString wxMenu::GetLabel(int Id) const
+{
+  static char tmp[128] ;
+  int len;
+  if (m_hMenu)
+    len = GetMenuString((HMENU)m_hMenu,Id,tmp,WXSIZEOF(tmp) - 1,MF_BYCOMMAND);
+  else if (m_savehMenu)
+    len = GetMenuString((HMENU)m_savehMenu,Id,tmp,WXSIZEOF(tmp) - 1,MF_BYCOMMAND);
+  else
+    len = 0 ;
+  tmp[len] = '\0' ;
+  return wxString(tmp) ;
+}
+
+bool wxMenu::MSWCommand(const WXUINT WXUNUSED(param), const WXWORD id)
+{
+  wxCommandEvent event(wxEVENT_TYPE_MENU_COMMAND);
+  event.SetEventObject( this );
+  event.SetId( id );
+  event.SetInt( id );
+  ProcessCommand(event);
+  return TRUE;
+}
+
+// Finds the item id matching the given string, -1 if not found.
+int wxMenu::FindItem (const wxString& itemString) const
+{
+  char buf1[200];
+  char buf2[200];
+  wxStripMenuCodes ((char *)(const char *)itemString, buf1);
+
+  for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
+    {
+      wxMenuItem *item = (wxMenuItem *) node->Data ();
+      if (item->GetSubMenu())
+      {
+        int ans = item->GetSubMenu()->FindItem(itemString);
+        if (ans > -1)
+          return ans;
+      }
+      if ( !item->IsSeparator() )
+      {
+        wxStripMenuCodes((char *)item->GetName().c_str(), buf2);
+        if (strcmp(buf1, buf2) == 0)
+          return item->GetId();
+      }
+    }
+
+  return -1;
+}
+
+wxMenuItem *wxMenu::FindItemForId(const int itemId, wxMenu ** itemMenu) const
+{
+  if (itemMenu)
+    *itemMenu = NULL;
+  for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
+  {
+    wxMenuItem *item = (wxMenuItem *) node->Data ();
+
+    if (item->GetId() == itemId)
+    {
+      if (itemMenu)
+        *itemMenu = (wxMenu *) this;
+      return item;
+    }
+
+    if (item->GetSubMenu())
+    {
+      wxMenuItem *ans = item->GetSubMenu()->FindItemForId (itemId, itemMenu);
+      if (ans)
+        return ans;
+    }
+  }
+
+  if (itemMenu)
+    *itemMenu = NULL;
+  return NULL;
+}
+
+void wxMenu::SetHelpString(const int itemId, const wxString& helpString)
+{
+  wxMenuItem *item = FindItemForId (itemId);
+  if (item)
+    item->SetHelp(helpString);
+}
+
+wxString wxMenu::GetHelpString (const int itemId) const
+{
+  wxMenuItem *item = FindItemForId (itemId);
+  wxString str("");
+  return (item == NULL) ? str : item->GetHelp();
+}
+
+void wxMenu::ProcessCommand(wxCommandEvent & event)
+{
+  bool processed = FALSE;
+
+  // Try a callback
+  if (m_callback)
+  {
+      (void) (*(m_callback)) (*this, event);
+      processed = TRUE;
+  }
+
+  // Try the menu's event handler
+  if ( !processed && GetEventHandler())
+  {
+      processed = GetEventHandler()->ProcessEvent(event);
+  }
+
+  // Try the window the menu was popped up from (and up
+  // through the hierarchy)
+  if ( !processed && GetInvokingWindow())
+    processed = GetInvokingWindow()->ProcessEvent(event);
+}
+
+extern wxMenu *wxCurrentPopupMenu;
+bool wxWindow::PopupMenu(wxMenu *menu, const int x, const int y)
+{
+  menu->SetInvokingWindow(this);
+
+  HWND hWnd = (HWND) GetHWND();
+  HMENU hMenu = (HMENU)menu->m_hMenu;
+  POINT point;
+  point.x = x;
+  point.y = y;
+  ::ClientToScreen(hWnd, &point);
+  wxCurrentPopupMenu = menu;
+  ::TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, point.x, point.y, 0, hWnd, NULL);
+  wxYield();
+  wxCurrentPopupMenu = NULL;
+
+  menu->SetInvokingWindow(NULL);
+
+  return TRUE;
+}
+
+// Menu Bar
+wxMenuBar::wxMenuBar(void)
+{
+  m_eventHandler = this;
+
+  m_menuCount = 0;
+  m_menus = NULL;
+  m_titles = NULL;
+  m_menuBarFrame = NULL;
+  m_hMenu = 0;
+}
+
+wxMenuBar::wxMenuBar(const int N, wxMenu *Menus[], const wxString Titles[])
+{
+  m_eventHandler = this;
+  m_menuCount = N;
+  m_menus = Menus;
+  m_titles = new wxString[N];
+  int i;
+  for ( i = 0; i < N; i++ )
+	m_titles[i] = Titles[i];
+  m_menuBarFrame = NULL;
+  for (i = 0; i < N; i++)
+    m_menus[i]->m_menuBar = (wxMenuBar *) this;
+
+  m_hMenu = 0;
+}
+
+wxMenuBar::~wxMenuBar(void)
+{
+  // In fact, don't want menu to be destroyed before MDI
+  // shuffling has taken place. Let it be destroyed
+  // automatically when the window is destroyed.
+
+//  DestroyMenu(menu);
+//  m_hMenu = NULL;
+
+  int i;
+/*
+  // See remarks in ::~wxMenu() method
+  // BEWARE - this may interfere with MDI fixes, so
+  // may need to remove
+  int N = 0 ;
+
+  if (m_menuBarFrame && ((m_menuBarFrame->GetWindowStyleFlag() & wxSDI) == wxSDI))
+  {
+    if (menu)
+      N = GetMenuItemCount(menu) ;
+    for (i = N-1; i >= 0; i--)
+      RemoveMenu(menu, i, MF_BYPOSITION);
+  }
+*/
+  for (i = 0; i < m_menuCount; i++)
+  {
+    delete m_menus[i];
+  }
+  delete[] m_menus;
+  delete[] m_titles;
+
+/* Don't destroy menu here, in case we're MDI and
+   need to do some shuffling with VALID menu handles.
+  if (menu)
+    DestroyMenu(menu);
+  m_hMenu = 0;
+*/
+}
+
+// Must only be used AFTER menu has been attached to frame,
+// otherwise use individual menus to enable/disable items
+void wxMenuBar::Enable(const int Id, const bool Flag)
+{
+  int ms_flag;
+  if (Flag)
+    ms_flag = MF_ENABLED;
+  else
+    ms_flag = MF_GRAYED;
+
+  wxMenu *itemMenu = NULL;
+  wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
+  if (!item)
+    return;
+
+  if (itemMenu->m_hMenu)
+    EnableMenuItem((HMENU)itemMenu->m_hMenu, Id, MF_BYCOMMAND | ms_flag);
+  else if (itemMenu->m_savehMenu)
+    EnableMenuItem((HMENU)itemMenu->m_savehMenu, Id, MF_BYCOMMAND | ms_flag);
+
+}
+
+void wxMenuBar::EnableTop(const int pos, const bool flag)
+{
+  int ms_flag;
+  if (flag)
+    ms_flag = MF_ENABLED;
+  else
+    ms_flag = MF_GRAYED;
+
+  EnableMenuItem((HMENU)m_hMenu, pos, MF_BYPOSITION | ms_flag);
+  DrawMenuBar((HWND) m_menuBarFrame->GetHWND()) ;
+}
+
+// Must only be used AFTER menu has been attached to frame,
+// otherwise use individual menus
+void wxMenuBar::Check(const int Id, const bool Flag)
+{
+  wxMenu *itemMenu = NULL;
+  wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
+  if (!item)
+    return;
+    
+  if (!item->IsCheckable())
+    return ;
+  int ms_flag;
+  if (Flag)
+    ms_flag = MF_CHECKED;
+  else
+    ms_flag = MF_UNCHECKED;
+
+  if (itemMenu->m_hMenu)
+    CheckMenuItem((HMENU)itemMenu->m_hMenu, Id, MF_BYCOMMAND | ms_flag);
+  else if (itemMenu->m_savehMenu)
+    CheckMenuItem((HMENU)itemMenu->m_savehMenu, Id, MF_BYCOMMAND | ms_flag);
+
+//  CheckMenuItem((HMENU)m_hMenu, Id, MF_BYCOMMAND | ms_flag);
+}
+
+bool wxMenuBar::Checked(const int Id) const
+{
+  wxMenu *itemMenu = NULL;
+  wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
+  if (!item)
+    return FALSE;
+
+  int Flag ;
+
+  if (itemMenu->m_hMenu)
+    Flag=GetMenuState((HMENU)itemMenu->m_hMenu, Id, MF_BYCOMMAND) ;
+  else if (itemMenu->m_savehMenu)
+    Flag=GetMenuState((HMENU)itemMenu->m_savehMenu, Id, MF_BYCOMMAND) ;
+
+//  Flag=GetMenuState((HMENU)m_hMenu, Id, MF_BYCOMMAND) ;
+
+  if (Flag&MF_CHECKED)
+    return TRUE ;
+  else
+    return FALSE ;
+}
+
+bool wxMenuBar::Enabled(const int Id) const
+{
+  wxMenu *itemMenu = NULL;
+  wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
+  if (!item)
+    return FALSE;
+
+  int Flag ;
+
+  if (itemMenu->m_hMenu)
+    Flag=GetMenuState((HMENU)itemMenu->m_hMenu, Id, MF_BYCOMMAND) ;
+  else if (itemMenu->m_savehMenu)
+    Flag=GetMenuState((HMENU)itemMenu->m_savehMenu, Id, MF_BYCOMMAND) ;
+
+  if (Flag&MF_ENABLED)
+    return TRUE ;
+  else
+    return FALSE ;
+}
+
+
+void wxMenuBar::SetLabel(const int Id, const wxString& label)
+{
+  wxMenu *itemMenu = NULL;
+  wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
+
+  if (!item)
+    return;
+
+  if (itemMenu->m_hMenu)
+  {
+    UINT was_flag = GetMenuState((HMENU)itemMenu->m_hMenu,Id,MF_BYCOMMAND) ;
+    ModifyMenu((HMENU)itemMenu->m_hMenu,Id,MF_BYCOMMAND|MF_STRING|was_flag,Id,(const char *)label) ;
+  }
+  else if (itemMenu->m_savehMenu)
+  {
+    UINT was_flag = GetMenuState((HMENU)itemMenu->m_savehMenu,Id,MF_BYCOMMAND) ;
+    ModifyMenu((HMENU)itemMenu->m_savehMenu,Id,MF_BYCOMMAND|MF_STRING|was_flag,Id,(const char *)label) ;
+  }
+}
+
+wxString wxMenuBar::GetLabel(const int Id) const
+{
+  wxMenu *itemMenu = NULL;
+  wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
+
+  if (!item)
+    return wxString("");
+
+  static char tmp[128] ;
+  int len = 0;
+  if (itemMenu->m_hMenu)
+  {
+    len = GetMenuString((HMENU)itemMenu->m_hMenu,Id,tmp,127,MF_BYCOMMAND) ;
+  }
+  else if (itemMenu->m_savehMenu)
+  {
+    len = GetMenuString((HMENU)itemMenu->m_savehMenu,Id,tmp,127,MF_BYCOMMAND) ;
+  }
+
+//  int len = GetMenuString((HMENU)m_hMenu,Id,tmp,127,MF_BYCOMMAND) ;
+  tmp[len] = '\0' ;
+  return wxString(tmp) ;
+}
+
+void wxMenuBar::SetLabelTop(const int pos, const wxString& label)
+{
+  UINT was_flag = GetMenuState((HMENU)m_hMenu,pos,MF_BYPOSITION) ;
+  if (was_flag&MF_POPUP)
+  {
+    was_flag &= 0xff ;
+    HMENU popup = GetSubMenu((HMENU)m_hMenu,pos) ;
+    ModifyMenu((HMENU)m_hMenu,pos,MF_BYPOSITION|MF_STRING|was_flag,(UINT)popup,(const char *)label) ;
+  }
+  else
+    ModifyMenu((HMENU)m_hMenu,pos,MF_BYPOSITION|MF_STRING|was_flag,pos,(const char *)label) ;
+}
+
+wxString wxMenuBar::GetLabelTop(const int pos) const
+{
+  static char tmp[128] ;
+  int len = GetMenuString((HMENU)m_hMenu,pos,tmp,127,MF_BYPOSITION) ;
+  tmp[len] = '\0' ;
+  return wxString(tmp);
+}
+
+bool wxMenuBar::OnDelete(wxMenu *a_menu, const int pos)
+{
+  if (!m_menuBarFrame)
+	 return TRUE;
+
+  if (RemoveMenu((HMENU)m_hMenu, (UINT)pos, MF_BYPOSITION)) {
+	 m_menus[pos]->m_hMenu = m_menus[pos]->m_savehMenu;
+	 m_menus[pos]->m_savehMenu = 0;
+
+	 if (m_menuBarFrame) {
+		DrawMenuBar((HWND) m_menuBarFrame->GetHWND()) ;
+	 }
+
+	 return TRUE;
+  }
+
+  return FALSE;
+}
+
+bool wxMenuBar::OnAppend(wxMenu *a_menu, const char *title)
+{
+  if (!a_menu->m_hMenu)
+	 return FALSE;
+
+  if (!m_menuBarFrame)
+	 return TRUE;
+
+  a_menu->m_savehMenu = a_menu->m_hMenu;
+  a_menu->m_hMenu = 0;
+
+  AppendMenu((HMENU)m_hMenu, MF_POPUP | MF_STRING, (UINT)a_menu->m_savehMenu, title);
+
+  DrawMenuBar((HWND) m_menuBarFrame->GetHWND());
+
+  return TRUE;
+}
+
+void wxMenuBar::Append (wxMenu * menu, const wxString& title)
+{
+  if (!OnAppend(menu, title))
+	 return;
+
+  m_menuCount ++;
+  wxMenu **new_menus = new wxMenu *[m_menuCount];
+  wxString *new_titles = new wxString[m_menuCount];
+  int i;
+
+  for (i = 0; i < m_menuCount - 1; i++)
+	 {
+		new_menus[i] = m_menus[i];
+		m_menus[i] = NULL;
+		new_titles[i] = m_titles[i];
+		m_titles[i] = "";
+	 }
+  if (m_menus)
+	 {
+		delete[]m_menus;
+		delete[]m_titles;
+	 }
+  m_menus = new_menus;
+  m_titles = new_titles;
+
+  m_menus[m_menuCount - 1] = (wxMenu *)menu;
+  m_titles[m_menuCount - 1] = title;
+
+  ((wxMenu *)menu)->m_menuBar = (wxMenuBar *) this;
+  ((wxMenu *)menu)->SetParent(this);
+}
+
+void wxMenuBar::Delete(wxMenu * menu, const int i)
+{
+  int j;
+  int ii = (int) i;
+
+  if (menu != 0) {
+	 for (ii = 0; ii < m_menuCount; ii++) {
+		if (m_menus[ii] == menu)
+	break;
+	 }
+	 if (ii >= m_menuCount)
+		return;
+  } else {
+	 if (ii < 0 || ii >= m_menuCount)
+		return;
+	 menu = m_menus[ii];
+  }
+
+  if (!OnDelete(menu, ii))
+	 return;
+
+  menu->SetParent(NULL);
+
+  -- m_menuCount;
+  for (j = ii; j < m_menuCount; j++) {
+	 m_menus[j] = m_menus[j + 1];
+	 m_titles[j] = m_titles[j + 1];
+  }
+}
+
+// Find the menu menuString, item itemString, and return the item id.
+// Returns -1 if none found.
+int wxMenuBar::FindMenuItem (const wxString& menuString, const wxString& itemString) const
+{
+  char buf1[200];
+  char buf2[200];
+  wxStripMenuCodes ((char *)(const char *)menuString, buf1);
+  int i;
+  for (i = 0; i < m_menuCount; i++)
+    {
+      wxStripMenuCodes ((char *)(const char *)m_titles[i], buf2);
+      if (strcmp (buf1, buf2) == 0)
+	return m_menus[i]->FindItem (itemString);
+    }
+  return -1;
+}
+
+wxMenuItem *wxMenuBar::FindItemForId (const int Id, wxMenu ** itemMenu) const
+{
+  if (itemMenu)
+    *itemMenu = NULL;
+
+  wxMenuItem *item = NULL;
+  int i;
+  for (i = 0; i < m_menuCount; i++)
+    if ((item = m_menus[i]->FindItemForId (Id, itemMenu)))
+      return item;
+  return NULL;
+}
+
+void wxMenuBar::SetHelpString (const int Id, const wxString& helpString)
+{
+  int i;
+  for (i = 0; i < m_menuCount; i++)
+    {
+      if (m_menus[i]->FindItemForId (Id))
+	{
+	  m_menus[i]->SetHelpString (Id, helpString);
+	  return;
+	}
+    }
+}
+
+wxString wxMenuBar::GetHelpString (const int Id) const
+{
+  int i;
+  for (i = 0; i < m_menuCount; i++)
+    {
+      if (m_menus[i]->FindItemForId (Id))
+	    return wxString(m_menus[i]->GetHelpString (Id));
+    }
+  return wxString("");
+}
+
+wxWindow *wxMenu::GetWindow() const
+{ 
+  if ( m_pInvokingWindow != NULL )
+    return m_pInvokingWindow;
+  if ( m_menuBar != NULL)       
+    return m_menuBar->m_menuBarFrame;
+  return NULL;
+}
+
+WXHMENU wxMenu::GetHMenu() const
+{
+  if ( m_hMenu != 0 )
+    return m_hMenu;
+  else if ( m_savehMenu != 0 )
+    return m_savehMenu;
+
+  return 0;
+}
+
diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp
new file mode 100644
index 0000000000..8d7d27379b
--- /dev/null
+++ b/src/msw/menuitem.cpp
@@ -0,0 +1,145 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        menuitem.cpp
+// Purpose:     wxMenuItem implementation
+// Author:      Vadim Zeitlin
+// Modified by: 
+// Created:     11.11.97
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// headers & declarations
+// ============================================================================
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/menu.h"
+#endif
+
+#include "wx/ownerdrw.h"
+#include "wx/menuitem.h"
+
+#include <windows.h>
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// dynamic classes implementation
+// ----------------------------------------------------------------------------
+
+#if     !defined(USE_SHARED_LIBRARY) || !USE_SHARED_LIBRARY
+#if USE_OWNER_DRAWN
+  IMPLEMENT_DYNAMIC_CLASS2(wxMenuItem, wxObject, wxOwnerDrawn)
+#else   //!USE_OWNER_DRAWN
+  IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
+#endif  //USE_OWNER_DRAWN
+
+#endif  //USE_SHARED_LIBRARY
+
+// ----------------------------------------------------------------------------
+// wxMenuItem
+// ----------------------------------------------------------------------------
+
+// ctor & dtor
+// -----------
+
+wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
+                       const wxTString& strName, const wxTString& strHelp,
+                       bool bCheckable,
+                       wxMenu *pSubMenu) :
+#if USE_OWNER_DRAWN
+                        wxOwnerDrawn(strName, bCheckable),
+#else   //no owner drawn support
+                        m_bCheckable(bCheckable),
+                        m_strName(strName),
+#endif  //owner drawn
+                        m_strHelp(strHelp)
+{
+  wxASSERT( pParentMenu != NULL );
+
+#ifdef  USE_OWNER_DRAWN
+    // set default menu colors
+    #define SYS_COLOR(c) (wxSystemSettings::GetSystemColour(wxSYS_COLOUR_##c))
+    
+    SetTextColour(SYS_COLOR(MENUTEXT));
+    SetBackgroundColour(SYS_COLOR(MENU));
+
+    // we don't want normal items be owner-drawn
+    ResetOwnerDrawn();
+
+    #undef  SYS_COLOR
+#endif
+
+  m_pParentMenu = pParentMenu;
+  m_pSubMenu    = pSubMenu;
+  m_idItem      = id;
+  m_bEnabled    = TRUE;
+}
+
+wxMenuItem::~wxMenuItem() 
+{
+}
+
+// misc
+// ----
+
+// delete the sub menu
+void wxMenuItem::DeleteSubMenu()
+{
+  wxASSERT( m_pSubMenu != NULL );
+
+  delete m_pSubMenu;
+  m_pSubMenu = NULL;
+}
+
+// change item state
+// -----------------
+
+void wxMenuItem::Enable(bool bDoEnable)
+{
+  if ( m_bEnabled != bDoEnable ) {
+    if ( m_pSubMenu == NULL ) {     // normal menu item
+      EnableMenuItem((HMENU)m_pParentMenu->GetHMenu(), m_idItem, 
+                     MF_BYCOMMAND | (bDoEnable ? MF_ENABLED: MF_GRAYED));
+    }
+    else                            // submenu
+    {
+      wxMenu *father = m_pSubMenu->m_topLevelMenu ;
+      wxNode *node = father->m_menuItems.First() ;
+      int i = 0 ;
+      while (node) {
+        wxMenuItem *matched = (wxMenuItem*)node->Data();
+        if ( matched == this)
+          break;
+        i++;
+        node = node->Next();
+      }
+      EnableMenuItem((HMENU)father->m_savehMenu, i, 
+                     MF_BYPOSITION | (bDoEnable ? MF_ENABLED: MF_GRAYED));
+    }
+
+    m_bEnabled = bDoEnable;
+  }
+}
+
+void wxMenuItem::Check(bool bDoCheck)
+{
+  wxCHECK ( IsCheckable() );
+
+  if ( m_bChecked != bDoCheck ) {
+    CheckMenuItem((HMENU)m_pParentMenu->GetHMenu(), m_idItem, 
+                  MF_BYCOMMAND | (bDoCheck ? MF_CHECKED : MF_UNCHECKED));
+
+    m_bChecked = bDoCheck;
+  }
+}
\ No newline at end of file
diff --git a/src/msw/metafile.cpp b/src/msw/metafile.cpp
new file mode 100644
index 0000000000..fe52d2438b
--- /dev/null
+++ b/src/msw/metafile.cpp
@@ -0,0 +1,373 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        metafile.cpp
+// Purpose:     wxMetaFileDC etc.
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "metafile.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#endif
+
+#if USE_METAFILE
+
+#ifndef WX_PRECOMP
+#include "wx/utils.h"
+#include "wx/app.h"
+#endif
+
+#include "wx/metafile.h"
+#include "wx/clipbrd.h"
+#include "wx/msw/private.h"
+
+#include <stdio.h>
+#include <string.h>
+
+extern bool wxClipboardIsOpen;
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxMetaFile, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxMetaFileDC, wxDC)
+#endif
+
+/*
+ * Metafiles - Windows 3.1 only
+ * Currently, the only purpose for making a metafile is to put
+ * it on the clipboard.
+ */
+
+wxMetaFile::wxMetaFile(const wxString& file)
+{
+  m_windowsMappingMode = MM_ANISOTROPIC;
+  m_metaFile = 0;
+  if (!file.IsNull() && file == "")
+    m_metaFile = (WXHANDLE) GetMetaFile(file);
+}
+
+wxMetaFile::~wxMetaFile(void)
+{
+  if (m_metaFile)
+    { DeleteMetaFile((HANDLE) m_metaFile); m_metaFile = 0; }
+}
+
+bool wxMetaFile::SetClipboard(int width, int height)
+{
+  bool alreadyOpen=wxClipboardOpen();
+  if (!alreadyOpen)
+  {
+    wxOpenClipboard();
+    if (!wxEmptyClipboard()) return FALSE;
+  }
+  bool success = wxSetClipboardData(wxCF_METAFILE,this, width,height);
+  if (!alreadyOpen) wxCloseClipboard();
+  return (bool) success;
+}
+
+bool wxMetaFile::Play(wxDC *dc)
+{
+  dc->BeginDrawing();
+
+  if (dc->GetHDC() && m_metaFile)
+    PlayMetaFile((HDC) dc->GetHDC(), (HANDLE) m_metaFile);
+
+  dc->EndDrawing();
+
+  return TRUE;
+}
+
+/*
+ * Metafile device context
+ *
+ */
+
+// Original constructor that does not takes origin and extent. If you use this,
+// *DO* give origin/extent arguments to wxMakeMetaFilePlaceable.
+wxMetaFileDC::wxMetaFileDC(const wxString& file)
+{
+  m_metaFile = NULL;
+  m_minX = 10000;
+  m_minY = 10000;
+  m_maxX = -10000;
+  m_maxY = -10000;
+//  m_title = NULL;
+
+  if (!file.IsNull() && wxFileExists(file))
+    wxRemoveFile(file);
+  m_hDC = (WXHDC) CreateMetaFile(file);
+
+  m_ok = TRUE;
+
+  // Actual Windows mapping mode, for future reference.
+  m_windowsMappingMode = MM_TEXT;
+  
+  SetMapMode(MM_TEXT); // NOTE: does not set HDC mapmode (this is correct)
+}
+
+// New constructor that takes origin and extent. If you use this, don't
+// give origin/extent arguments to wxMakeMetaFilePlaceable.
+wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
+{
+  m_minX = 10000;
+  m_minY = 10000;
+  m_maxX = -10000;
+  m_maxY = -10000;
+  if (file != "" && wxFileExists(file)) wxRemoveFile(file);
+  m_hDC = (WXHDC) CreateMetaFile(file);
+
+  m_ok = TRUE;
+
+  ::SetWindowOrgEx((HDC) m_hDC,xorg,yorg, NULL);
+  ::SetWindowExtEx((HDC) m_hDC,xext,yext, NULL);
+
+  // Actual Windows mapping mode, for future reference.
+  m_windowsMappingMode = MM_ANISOTROPIC;
+  
+  SetMapMode(MM_TEXT); // NOTE: does not set HDC mapmode (this is correct)
+}
+
+wxMetaFileDC::~wxMetaFileDC(void)
+{
+  m_hDC = 0;
+}
+
+void wxMetaFileDC::GetTextExtent(const wxString& string, float *x, float *y,
+                                 float *descent, float *externalLeading, wxFont *theFont, bool use16bit)
+{
+  wxFont *fontToUse = theFont;
+  if (!fontToUse)
+    fontToUse = &m_font;
+
+  HDC dc = GetDC(NULL);
+
+  SIZE sizeRect;
+  TEXTMETRIC tm;
+  GetTextExtentPoint(dc, (char *)(const char *) string, strlen((char *)(const char *) string), &sizeRect);
+  GetTextMetrics(dc, &tm);
+
+  ReleaseDC(NULL, dc);
+
+  *x = (float)XDEV2LOGREL(sizeRect.cx);
+  *y = (float)YDEV2LOGREL(sizeRect.cy);
+  if (descent) *descent = (float)tm.tmDescent;
+  if (externalLeading) *externalLeading = (float)tm.tmExternalLeading;
+}
+
+wxMetaFile *wxMetaFileDC::Close(void)
+{
+  SelectOldObjects(m_hDC);
+  HANDLE mf = CloseMetaFile((HDC) m_hDC);
+  m_hDC = 0;
+  if (mf)
+  {
+    wxMetaFile *wx_mf = new wxMetaFile;
+    wx_mf->SetHMETAFILE((WXHANDLE) mf);
+    wx_mf->SetWindowsMappingMode(m_windowsMappingMode);
+    return wx_mf;
+  }
+  return NULL;
+}
+
+void wxMetaFileDC::SetMapMode(int mode)
+{
+  m_mappingMode = mode;
+
+//  int pixel_width = 0;
+//  int pixel_height = 0;
+//  int mm_width = 0;
+//  int mm_height = 0;
+
+  float mm2pixelsX = 10.0;
+  float mm2pixelsY = 10.0;
+
+  switch (mode)
+  {
+    case MM_TWIPS:
+    {
+      m_logicalScaleX = (float)(twips2mm * mm2pixelsX);
+      m_logicalScaleY = (float)(twips2mm * mm2pixelsY);
+      break;
+    }
+    case MM_POINTS:
+    {
+      m_logicalScaleX = (float)(pt2mm * mm2pixelsX);
+      m_logicalScaleY = (float)(pt2mm * mm2pixelsY);
+      break;
+    }
+    case MM_METRIC:
+    {
+      m_logicalScaleX = mm2pixelsX;
+      m_logicalScaleY = mm2pixelsY;
+      break;
+    }
+    case MM_LOMETRIC:
+    {
+      m_logicalScaleX = (float)(mm2pixelsX/10.0);
+      m_logicalScaleY = (float)(mm2pixelsY/10.0);
+      break;
+    }
+    default:
+    case MM_TEXT:
+    {
+      m_logicalScaleX = 1.0;
+      m_logicalScaleY = 1.0;
+      break;
+    }
+  }
+  m_windowExtX = 100;
+  m_windowExtY = 100;
+}
+
+#ifdef __WIN32__
+struct RECT32
+{
+  short left;
+  short top;
+  short right;
+  short bottom;
+};
+
+struct mfPLACEABLEHEADER {
+	DWORD	key;
+	short	hmf;
+	RECT32	bbox;
+	WORD	inch;
+	DWORD	reserved;
+	WORD	checksum;
+};
+#else
+struct mfPLACEABLEHEADER {
+	DWORD	key;
+	HANDLE	hmf;
+	RECT	bbox;
+	WORD	inch;
+	DWORD	reserved;
+	WORD	checksum;
+};
+#endif
+
+/*
+ * Pass filename of existing non-placeable metafile, and bounding box.
+ * Adds a placeable metafile header, sets the mapping mode to anisotropic,
+ * and sets the window origin and extent to mimic the MM_TEXT mapping mode.
+ *
+ */
+ 
+bool wxMakeMetaFilePlaceable(const wxString& filename, float scale)
+{
+  return wxMakeMetaFilePlaceable(filename, 0, 0, 0, 0, scale, FALSE);
+}
+
+bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale, bool useOriginAndExtent)
+{
+  // I'm not sure if this is the correct way of suggesting a scale
+  // to the client application, but it's the only way I can find.
+  int unitsPerInch = (int)(576/scale);
+  
+  mfPLACEABLEHEADER header;
+  header.key = 0x9AC6CDD7L;
+  header.hmf = 0;
+  header.bbox.left = (int)(x1);
+  header.bbox.top = (int)(y1);
+  header.bbox.right = (int)(x2);
+  header.bbox.bottom = (int)(y2);
+  header.inch = unitsPerInch;
+  header.reserved = 0;
+
+  // Calculate checksum  
+  WORD *p;
+  mfPLACEABLEHEADER *pMFHead = &header;
+  for (p =(WORD *)pMFHead,pMFHead -> checksum = 0;
+	p < (WORD *)&pMFHead ->checksum; ++p)
+       pMFHead ->checksum ^= *p;
+
+  FILE *fd = fopen((char *)(const char *)filename, "rb");
+  if (!fd) return FALSE;
+  
+  char tempFileBuf[256];
+  wxGetTempFileName("mf", tempFileBuf);
+  FILE *fHandle = fopen(tempFileBuf, "wb");
+  if (!fHandle)
+    return FALSE;
+  fwrite((void *)&header, sizeof(unsigned char), sizeof(mfPLACEABLEHEADER), fHandle);
+
+  // Calculate origin and extent
+  int originX = x1;
+  int originY = y1;
+  int extentX = x2 - x1;
+  int extentY = (y2 - y1);
+
+  // Read metafile header and write
+  METAHEADER metaHeader;
+  fread((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fd);
+  
+  if (useOriginAndExtent)
+    metaHeader.mtSize += 15;
+  else
+    metaHeader.mtSize += 5;
+    
+  fwrite((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fHandle);
+
+  // Write SetMapMode, SetWindowOrigin and SetWindowExt records
+  char modeBuffer[8];
+  char originBuffer[10];
+  char extentBuffer[10];
+  METARECORD *modeRecord = (METARECORD *)&modeBuffer;
+
+  METARECORD *originRecord = (METARECORD *)&originBuffer;
+  METARECORD *extentRecord = (METARECORD *)&extentBuffer;
+
+  modeRecord->rdSize = 4;
+  modeRecord->rdFunction = META_SETMAPMODE;
+  modeRecord->rdParm[0] = MM_ANISOTROPIC;
+
+  originRecord->rdSize = 5;
+  originRecord->rdFunction = META_SETWINDOWORG;
+  originRecord->rdParm[0] = originY;
+  originRecord->rdParm[1] = originX;
+
+  extentRecord->rdSize = 5;
+  extentRecord->rdFunction = META_SETWINDOWEXT;
+  extentRecord->rdParm[0] = extentY;
+  extentRecord->rdParm[1] = extentX;
+
+  fwrite((void *)modeBuffer, sizeof(char), 8, fHandle);
+  
+  if (useOriginAndExtent)
+  {
+    fwrite((void *)originBuffer, sizeof(char), 10, fHandle);
+    fwrite((void *)extentBuffer, sizeof(char), 10, fHandle);
+  }
+
+  int ch = -2;
+  while (ch != EOF)
+  {
+    ch = getc(fd);
+    if (ch != EOF)
+    {
+      putc(ch, fHandle);
+    }
+  }
+  fclose(fHandle);
+  fclose(fd);
+  wxRemoveFile(filename);
+  wxCopyFile(tempFileBuf, filename);
+  wxRemoveFile(tempFileBuf);
+  return TRUE;
+}
+
+#endif // USE_METAFILE
diff --git a/src/msw/minifram.cpp b/src/msw/minifram.cpp
new file mode 100644
index 0000000000..ca7b86bea6
--- /dev/null
+++ b/src/msw/minifram.cpp
@@ -0,0 +1,1592 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        minifram.cpp
+// Purpose:     wxMiniFrame
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "minifram.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#include "wx/app.h"
+#include "wx/utils.h"
+#endif
+
+#if USE_ITSY_BITSY
+
+#include "wx/minifram.h"
+#include "wx/msw/private.h"
+
+#ifdef __GNUWIN32__
+#include "wx/msw/gnuwin32/extra.h"
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame)
+#endif
+
+long wxMiniFrame::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+  if ((GetWindowStyleFlag() & wxTINY_CAPTION_HORIZ) ||
+      (GetWindowStyleFlag() & wxTINY_CAPTION_VERT))
+    return ::ibDefWindowProc((HWND) GetHWND(), nMsg, wParam, lParam);
+  else if ( m_oldWndProc )
+  	return ::CallWindowProc(CASTWNDPROC (FARPROC) m_oldWndProc, (HWND) GetHWND(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
+  else
+  	return ::DefWindowProc((HWND) GetHWND(), nMsg, wParam, lParam);
+}
+
+wxMiniFrame::~wxMiniFrame(void)
+{
+}
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Project:     ItsyBitsy window support module
+// Module:      itsybits.c
+//
+//
+//    ItsyBitsy is a support module that allows you to create windows
+//    that look and act very much like a popup window witha system
+//    menu and caption bar, except everything is scaled to about 2/3
+//    scale.
+//
+//    For documentation on how to use ItsyBits, read the document
+//    ITSYBITS.DOC.
+//
+//   Revisions:
+//      9/27/91     Charlie Kindel (cek/ckindel)
+//                          Wrote and documented it.
+//
+//      1/14/93     cek         
+//      2/23/93     cek     Added minimize/maximize buttons.
+//      3/18/93     cek     Fixed system menu bug where system menu 
+//                          popped back up if you clicked on the 
+//                          icon again while it was up.
+//      3/24/93     cek     More comments.  Fixed DS_MODALDIALOG style
+//                          problem.  Use auto precompiled headers
+//                          in MSVC.
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include <windows.h>
+#include <windowsx.h>
+
+#include <string.h>
+
+#ifndef __WATCOMC__
+#include <memory.h>
+#endif
+
+#include <stdlib.h>
+
+#ifndef _RGB_H_
+#define _RGB_H_
+         
+   // Some mildly useful macros for the standard 16 colors
+   #define RGBBLACK     RGB(0,0,0)
+   #define RGBRED       RGB(128,0,0)
+   #define RGBGREEN     RGB(0,128,0)
+   #define RGBBLUE      RGB(0,0,128)
+   
+   #define RGBBROWN     RGB(128,128,0)
+   #define RGBMAGENTA   RGB(128,0,128)
+   #define RGBCYAN      RGB(0,128,128)
+   #define RGBLTGRAY    RGB(192,192,192)
+   
+   #define RGBGRAY      RGB(128,128,128)
+   #define RGBLTRED     RGB(255,0,0)
+   #define RGBLTGREEN   RGB(0,255,0)
+   #define RGBLTBLUE    RGB(0,0,255)
+   
+   #define RGBYELLOW    RGB(255,255,0)
+   #define RGBLTMAGENTA RGB(255,0,255)
+   #define RGBLTCYAN    RGB(0,255,255)
+   #define RGBWHITE     RGB(255,255,255)
+#endif
+
+#ifndef GlobalAllocPtr
+#define     GlobalPtrHandle(lp)         \
+                ((HGLOBAL)GlobalHandle(lp))
+
+#define     GlobalLockPtr(lp)                \
+                ((BOOL)GlobalLock(GlobalPtrHandle(lp)))
+#define     GlobalUnlockPtr(lp)      \
+                GlobalUnlock(GlobalPtrHandle(lp))
+
+#define     GlobalAllocPtr(flags, cb)        \
+                (GlobalLock(GlobalAlloc((flags), (cb))))
+#define     GlobalReAllocPtr(lp, cbNew, flags)       \
+                (GlobalUnlockPtr(lp), GlobalLock(GlobalReAlloc(GlobalPtrHandle(lp) , (cbNew), (flags))))
+#define     GlobalFreePtr(lp)                \
+                (GlobalUnlockPtr(lp), (BOOL)GlobalFree(GlobalPtrHandle(lp)))
+#endif
+
+#if defined(__BORLANDC__) || defined(__WATCOMC__)
+#define max(a,b)            (((a) > (b)) ? (a) : (b))
+#define min(a,b)            (((a) < (b)) ? (a) : (b))
+#endif
+
+// CAPTIONXY is the default size of the system menu icon.  This
+// determines the height/width of the caption.
+//
+// The value that results from the following formula works out
+// nicely for the veritcal caption on VGA, 8514 (Large Fonts),
+// 8514 (Small Fonts), XGA (Small Fonts), XGA (Large Fonts),
+// and TIGA (Small Fonts).  It may not be good on other displays.
+//
+// The problem is that TT fonts turn into bitmap fonts when they
+// are sized below a certain threshold.  The idea is to make the
+// size of the caption just big enough to get the smallest TT
+// (scalable) font to fit.
+//
+#define CAPTIONXY (GetSystemMetrics( SM_CYCAPTION ) / 2 + 1)
+
+#define TestWinStyle( hWnd, dwStyleBit ) \
+        (((DWORD)GetWindowLong( hWnd, GWL_STYLE ) & (DWORD)dwStyleBit) ? TRUE : FALSE )
+#define HASCAPTION( hwnd )    (TestWinStyle( hwnd, IBS_VERTCAPTION ) ||\
+                               TestWinStyle( hwnd, IBS_HORZCAPTION ))
+                               
+#define SETCAPTIONSIZE(h,i)   (UINT)SetProp(h,"ibSize",(HANDLE)i)
+#define GETCAPTIONSIZE(h)     (UINT)GetProp(h,"ibSize")
+#define FREECAPTIONSIZE(h)    RemoveProp(h,"ibSize")
+
+#define SETMENUWASUPFLAG(h,i) (UINT)SetProp(h,"ibFlag",(HANDLE)i)
+#define GETMENUWASUPFLAG(h)   (UINT)GetProp(h,"ibFlag")
+#define FREEMENUWASUPFLAG(h)  RemoveProp(h,"ibFlag")
+
+/////////////////////////////////////////////////////////////////////
+// Little known fact:
+//    ExtTextOut() is the fastest way to draw a filled rectangle
+//    in Windows (if you don't want dithered colors or borders).
+//
+//    Unfortunately there is a bug in the Windows 3.0 8514 driver
+//    in using ExtTextOut() to a memory DC.  If you are drawing
+//    to an off screen bitmap, then blitting that bitmap to the
+//    display, do not #define USE_EXTTEXTOUT below.
+//
+//    The following macro (DRAWFASTRECT) draws a filled rectangle
+//    with no border and a solid color.  It uses the current back-
+//    ground color as the fill color.
+//////////////////////////////////////////////////////////////////////
+#define USE_EXTTEXTOUT
+#ifdef USE_EXTTEXTOUT
+   #define DRAWFASTRECT(hdc,lprc) ExtTextOut(hdc,0,0,ETO_OPAQUE,lprc,NULL,0,NULL)
+#else
+   #define DRAWFASTRECT(hdc,lprc) {\
+   HBRUSH hbr = CreateSolidBrush( GetBkColor( hdc ) ) ;\
+   hbr = SelectObject(hdc, hbr) ;\
+   PatBlt(hdc,(lprc)->left,(lprc)->top,(lprc)->right-(lprc)->left,(lprc)->bottom-(lprc)->top,PATCOPY) ;\
+   hbr = SelectObject(hdc, hbr) ;\
+   DeleteObject( hbr ) ;\
+   }
+#endif
+
+// The DrawArrow function takes the following to indicate what
+// kind of arrow to draw.
+//
+#define ARROW_UP        0
+#define ARROW_DOWN      1
+#define ARROW_RESTORE   2
+
+BOOL PASCAL DepressMinMaxButton( HWND hWnd, UINT uiHT, LPRECT ) ;
+BOOL PASCAL DoMenu( HWND hWnd ) ;
+void PASCAL SetupSystemMenu( HWND hWnd, HMENU hMenu ) ;
+BOOL PASCAL GetCaptionRect( HWND hWnd, LPRECT lprc ) ;
+BOOL PASCAL GetIconRect( HWND hWnd, LPRECT lprc ) ;
+BOOL PASCAL GetButtonRect( HWND hWnd, UINT nPos, LPRECT lprc ) ;
+BOOL PASCAL GetMinButtonRect( HWND hWnd, LPRECT lprc ) ;
+BOOL PASCAL GetMaxButtonRect( HWND hWnd, LPRECT lprc ) ;
+BOOL PASCAL DrawCaption( HDC hDC, HWND hWnd, LPRECT lprc,
+                              BOOL fVert, BOOL fSysMenu,
+                              BOOL fMin, BOOL fMax, BOOL fActive ) ;
+void PASCAL DrawSysMenu( HDC hDC, HWND hWnd, BOOL fInvert ) ;
+void PASCAL DrawButton( HDC hDC, HWND hWnd, BOOL fMin, BOOL fDepressed ) ;
+void PASCAL DrawArrow( HDC hdc, LPRECT lprc, UINT uiStyle ) ;
+
+// Global vars
+//
+static BOOL fWin31 ;
+
+///////////////////////////////////////////////////////////////////////
+// External/Public functions
+///////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////
+//  UINT WINAPI ibGetCaptionSize( HWND hWnd )
+//
+//  Description: 
+//
+//    Gets the size of the caption (height if horz, width if
+//    vertical).
+//
+//  Comments:
+//
+///////////////////////////////////////////////////////////////
+UINT WINAPI ibGetCaptionSize( HWND hWnd  )
+{
+    return GETCAPTIONSIZE( hWnd ) + 1 ;
+} // ibSetCaptionSize()
+
+/////////////////////////////////////////////////////////////////
+//  UINT WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize )
+//
+//  Description: 
+//
+//    Changes the size of the caption (height if horz, width if
+//    vertical).
+//
+//  Comments:
+//
+//////////////////////////////////////////////////////////////////
+UINT WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize )
+{
+    UINT ui ;
+
+    if (nSize <= 0)
+        return 0 ;
+
+    nSize-- ;
+    ui = SETCAPTIONSIZE( hWnd, nSize ) ;
+
+    // Once we change the window style, we need a WM_NCCALCRECT
+    // to be generated.
+    //
+    // SWP_FRAMECHANGED is not documented in the 3.1 SDK docs,
+    // but *is* in WINDOWS.H.
+    //
+    SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | 
+                        SWP_NOSIZE | SWP_NOMOVE | 
+                        SWP_NOACTIVATE | SWP_NOZORDER) ;
+
+    return ui ;
+
+} // ibSetCaptionSize()
+
+/////////////////////////////////////////////////////////////////
+//  LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam )
+//
+//  Description: 
+//
+//    This function should be called instead of DefWindowProc() for
+//    windows that want to have itsybitsy captions.
+//
+//  Comments:
+//
+//////////////////////////////////////////////////////////////////
+LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam )
+{
+    LRESULT lRet ;
+    UINT  nCapSize ;
+
+    switch( uiMsg )
+    {
+        case WM_SYSCHAR:
+            // If ALT-SPACE 
+            // was hit then pop up the menu
+            // 
+            if (HASCAPTION( hWnd ) && (wParam == VK_SPACE))
+            {
+                DoMenu( hWnd ) ;
+                break ;
+            }
+
+            // FALL THROUGH!!!!
+            // 
+
+        case WM_SYSKEYDOWN:
+        case WM_SYSKEYUP:
+        case WM_KEYDOWN:
+        case WM_KEYUP:
+        {
+            DWORD dw = GetWindowLong( hWnd, GWL_STYLE ) ;
+
+            // Fool DefWindowProc into thinking we do not have
+            // a system menu.  Otherwise it will try to
+            // pop up its own.
+            // 
+            SetWindowLong( hWnd, GWL_STYLE, dw &~WS_SYSMENU ) ;
+            lRet = DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+            SetWindowLong( hWnd, GWL_STYLE, dw ) ;
+            return lRet ;
+        }
+        break ;
+        
+        case WM_COMMAND:
+            // The menu that is poped up for the system menu with
+            // TrackPopupMenu() sends it's notifications as WM_COMMAND
+            // messages.  We need to translate these into
+            // WM_SYSCOMMAND messages.  All standard WM_SYSCOMMAND
+            // ids are greater than 0xF000.
+            //
+            // This could be a possible cause of confusion if the
+            // itsybitsy window had children that used SC_MOVE or SC_CLOSE
+            // as their IDs.  Take note and be careful.
+            //
+            // Also, because ibDefWindowProc looks at WM_COMMAND messages,
+            // you will need to be careful to call ibDefWindowProc() for
+            // any wm_command messages that you would normally ignore.
+            // Otherwise the system menu won't work.
+            //
+            if (wParam >= 0xF000)
+                // Call PostMessage() here instead of SendMessage!
+                // Here's why:
+                //      Our menu was created by TrackPopupMenu().  TPM() does
+                //      not return until after the menu has been destroyed 
+                //      (and thus the command associated with the menu selection
+                //      sent).  Therefore when we get here, we are still
+                //      *inside* TPM().  If we Send WM_SYSCOMMAND, SC_CLOSE
+                //      to the window, the window will be destroyed before
+                //      TPM() returns to our code within DoMenu() below.  Wel...
+                //      We do stuff with the window handle after DoMenu()
+                //      returns (namely GetProp()).  Since the window has
+                //      been destroyed,this is bad.  
+                PostMessage( hWnd, WM_SYSCOMMAND, wParam, lParam ) ;
+
+        return DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+
+        case WM_GETMINMAXINFO:
+        {
+            nCapSize = GETCAPTIONSIZE( hWnd ) ;
+            if (HASCAPTION( hWnd ) && TestWinStyle( hWnd, WS_THICKFRAME ))
+            {
+                LPPOINT lppt = (LPPOINT)lParam ;
+                RECT    rcMenu ;
+                RECT    rcMin ;
+                RECT    rcMax ;
+                int     nX ;
+                int     cx, cy ;    // window frame/border width
+
+                if (TestWinStyle( hWnd, WS_THICKFRAME ))
+                {
+                    cx = GetSystemMetrics( SM_CXFRAME ) ;
+                    cy = GetSystemMetrics( SM_CYFRAME ) ;
+                }
+                else
+                    if (TestWinStyle(hWnd, WS_BORDER ))
+                    {
+                        cx = GetSystemMetrics( SM_CXBORDER ) ;
+                        cy = GetSystemMetrics( SM_CYBORDER ) ;
+                    }
+                                
+                GetIconRect( hWnd, &rcMenu ) ;
+                GetMinButtonRect( hWnd, &rcMin ) ;
+                GetMaxButtonRect( hWnd, &rcMax ) ;
+                nX = (rcMenu.right-rcMenu.left) + 
+                    (rcMin.right-rcMin.left) +
+                    (rcMin.right-rcMin.left) ;
+
+
+                if (TestWinStyle( hWnd, IBS_VERTCAPTION ) )
+                {
+                    lppt[3].x = nCapSize + cx * 2 - 1 ;
+                    lppt[3].y = nX + (2* nCapSize) ;
+                }
+                else
+                {
+                    lppt[3].x = nX + (2* nCapSize) ;
+                    lppt[3].y = nCapSize + cy * 2 - 1 ;
+                }
+            }
+            return DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+        }
+        break ;
+
+        /////////////////////////////////////////////////////////////////////
+        // Non-client area messages.  These are used to allow the
+        // minature caption bar to be handled correctly.
+        //
+        case WM_NCCREATE:
+        {
+            DWORD dwStyle ;
+            
+            // We have two things that we need to store somewhere:
+            //     1) The caption height (width).
+            // and 2) A flag indicating whether the sysmenu was
+            //        just up or not.
+            // 
+            // CAPTIONXY is a macro that calls GetSystemMetrics.
+            //
+            SETCAPTIONSIZE( hWnd, CAPTIONXY ) ;
+
+            // Set our flag that tells us whether the system menu was
+            // 'just up'. 
+            //
+            SETMENUWASUPFLAG( hWnd, FALSE ) ;
+
+            // Are we in 3.1?  If so we have some neat features
+            // we can use like rotated TrueType fonts.
+            //
+            fWin31 = (BOOL)(LOWORD( GetVersion() ) >= 0x030A) ;
+
+            // If IBS_????CAPTION was specified and the WS_DLGFRAME (or
+            // WS_DLGFRAME 'cause it == WS_CAPTION | WS_BORDER)
+            // was specified the creator made a mistake.  Things get really
+            // ugly if DefWindowProc sees WS_DLGFRAME, so we strip
+            // the WS_DLGFRAME part off!
+            //
+            dwStyle = GetWindowLong( hWnd, GWL_STYLE ) ;
+            if ((dwStyle & IBS_VERTCAPTION || dwStyle & IBS_HORZCAPTION) &&
+                 dwStyle & WS_DLGFRAME)
+            {
+                dwStyle &= (DWORD)~WS_DLGFRAME ;
+                SetWindowLong( hWnd, GWL_STYLE, dwStyle ) ;
+            }
+        }
+        return DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+
+        case WM_NCDESTROY:
+            // We store the caption size in a window prop. so we
+            // must remove props.
+            //
+            FREECAPTIONSIZE( hWnd ) ;
+            FREEMENUWASUPFLAG( hWnd ) ;
+        return DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+
+        case WM_NCCALCSIZE:
+            // This is sent when the window manager wants to find out
+            // how big our client area is to be.  If we have a mini-caption
+            // then we trap this message and calculate the cleint area rect,
+            // which is the client area rect calculated by DefWindowProc()
+            // minus the width/height of the mini-caption bar
+            //
+            lRet = DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+            if (!IsIconic( hWnd ) && HASCAPTION( hWnd ))
+            {
+                nCapSize = GETCAPTIONSIZE( hWnd ) ;
+
+                if (TestWinStyle( hWnd, IBS_VERTCAPTION ) )
+                    ((LPRECT)lParam)->left += nCapSize ;
+                else
+                    ((LPRECT)lParam)->top += nCapSize ;
+            }
+        return lRet ;
+
+        case WM_NCHITTEST:
+            // This message is sent whenever the mouse moves over us.
+            // We will depend on DefWindowProc for everything unless
+            // there is a mini-caption, in which case we will
+            // return HTCAPTION or HTSYSMENU.  When the user clicks
+            // or double clicks, NC_LBUTTON/ message are sent with
+            // wParam equal to what we return here.
+            // This means that this is an ideal place to figure out
+            // where we are!
+            //
+            // let defwindowproc handle the standard borders etc...
+            //
+            lRet = DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+            if (!IsIconic( hWnd ) && HASCAPTION( hWnd ) && lRet == HTNOWHERE)
+            {
+                RECT  rc ;
+                RECT  rcMenu ;
+                RECT  rcMinButton ;
+                RECT  rcMaxButton ;
+                POINT pt ;
+
+                nCapSize = GETCAPTIONSIZE( hWnd ) ;
+
+                // if DefWindowProc returned HTCAPTION then we have to
+                // refine the area and return HTSYSMENU if appropriate
+                //
+                pt.x = LOWORD( lParam ) ;
+                pt.y = HIWORD( lParam ) ;
+
+                GetCaptionRect( hWnd, &rc ) ;  // window coords
+                if (PtInRect( &rc, pt ))
+                {
+                     lRet = HTCAPTION ;
+
+                     // rely on the fact that Get???Rect() return an invalid 
+                     // (empty) rectangle if the menu/buttons don't exist
+                     //
+                     GetIconRect( hWnd, &rcMenu ) ;
+                     GetMinButtonRect( hWnd, &rcMinButton ) ;
+                     GetMaxButtonRect( hWnd, &rcMaxButton ) ;
+     
+                     if (PtInRect( &rcMenu, pt ))
+                          lRet = HTSYSMENU ;
+
+                     if (PtInRect( &rcMinButton, pt ))
+                          lRet = HTMINBUTTON ;
+                     else
+                          if (PtInRect( &rcMaxButton, pt ))
+                                lRet = HTMAXBUTTON ;
+                }
+            }
+            if (lRet != HTSYSMENU)
+                SETMENUWASUPFLAG( hWnd, FALSE ) ;
+        return lRet ;
+
+        case WM_NCLBUTTONDBLCLK:
+            // Windows recieve WM_NC?BUTTONDBLCLK messages whether they
+            // have CS_DBLCLKS or not.  We watch for one of these
+            // to see if the user double clicked on the system menu (to
+            // close the window) or on the caption (to maximize the window).
+            //
+            if (!IsIconic( hWnd ) && HASCAPTION( hWnd ) && wParam == HTSYSMENU)
+            {
+                SendMessage( hWnd, WM_CLOSE, 0, 0L ) ;
+                break ;
+            }
+        return DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+
+        case WM_NCLBUTTONDOWN:
+        {
+            RECT rc ;
+
+            // If we're iconic or we don't have a caption then 
+            // DefWindowProc will do the job just fine.
+            //            
+            if (IsIconic( hWnd ) || !HASCAPTION( hWnd ))
+                 return DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+
+            // Here's were we handle the system menu, the min and max buttons.
+            // If you wanted to change the behavior of the min/max buttons
+            // do something like swap tool palettes or something, you 
+            // would change the SendMessage() calls below.
+            //
+            switch (wParam)
+            {
+                case HTSYSMENU:
+                    if (GETMENUWASUPFLAG( hWnd ) == FALSE && DoMenu( hWnd ))
+                        SETMENUWASUPFLAG( hWnd, TRUE ) ;
+                    else
+                        SETMENUWASUPFLAG( hWnd, FALSE ) ;
+                break ;
+                
+                case HTMINBUTTON:
+                    GetMinButtonRect( hWnd, &rc ) ;
+                    // Note that DepressMinMaxButton() goes into
+                    // a PeekMessage() loop waiting for the mouse
+                    // to come back up.
+                    //
+                    if (DepressMinMaxButton( hWnd, wParam, &rc ))
+                        SendMessage( hWnd, WM_SYSCOMMAND, SC_MINIMIZE, lParam ) ;
+                break ;
+                
+                case HTMAXBUTTON:
+                    GetMaxButtonRect( hWnd, &rc ) ;
+                    // Note that DepressMinMaxButton() goes into
+                    // a PeekMessage() loop waiting for the mouse
+                    // to come back up.
+                    //
+                    if (DepressMinMaxButton( hWnd, wParam, &rc ))
+                    {
+                        if (IsZoomed(hWnd))
+                            SendMessage( hWnd, WM_SYSCOMMAND, SC_RESTORE, lParam ) ;
+                        else
+                            SendMessage( hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, lParam ) ;
+                    }
+                break ;
+                
+                default:
+                    // Well, it appears as though the user clicked somewhere other
+                    // than the buttons.  We let DefWindowProc do it's magic.
+                    // This is where things like dragging and sizing the
+                    // window happen.
+                    //
+                    return DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+            }
+        }
+        break ;
+
+        case WM_NCPAINT:
+        case WM_NCACTIVATE:
+            if (IsIconic( hWnd ))
+                return DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+
+            // Paint the non-client area here.  We will call DefWindowProc
+            // after we are done so it can paint the borders and so
+            // forth...
+            //
+            lRet = DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+            if (HASCAPTION( hWnd ))
+            {
+                RECT  rcCap ;
+                RECT  rc ;
+                HDC    hDC = GetWindowDC( hWnd ) ;
+                BOOL  fActive ;
+
+                GetCaptionRect( hWnd, &rcCap ) ;    // Convert to window coords
+                GetWindowRect( hWnd, &rc ) ;
+                OffsetRect( &rcCap, -rc.left, -rc.top ) ;
+
+                if (uiMsg == WM_NCPAINT)
+                    fActive = (hWnd == GetActiveWindow()) ;
+                else
+                    fActive = wParam ;
+
+                DrawCaption( hDC, hWnd, &rcCap,
+                                        TestWinStyle(hWnd, IBS_VERTCAPTION),
+                                        TestWinStyle(hWnd, WS_SYSMENU),
+                                        TestWinStyle(hWnd, WS_MINIMIZEBOX),
+                                        TestWinStyle(hWnd, WS_MAXIMIZEBOX),
+                                        fActive ) ;
+
+                ReleaseDC( hWnd, hDC ) ;
+            }
+            return lRet;
+        break;
+
+        default:
+            return DefWindowProc( hWnd, uiMsg, wParam, lParam ) ;
+    }
+
+    return 0L ;
+
+} // ibDefWindowProc()
+
+//  ibAdjustWindowRect( HWND hWnd, LPRECT lprc )
+//
+//    Does the same thing as the USER function AdjustWindowRect(),
+//    but knows about itsybitsy windows.  AdjustWindowRect() is
+//    bogus for stuff like this.
+//
+void WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc )
+{
+    short    cx = 0, cy = 0 ;
+    UINT     nCapSize ;
+    
+    nCapSize = GETCAPTIONSIZE( hWnd ) ;
+    
+    // First check Windows's styles, then our own.
+    //
+    if (TestWinStyle( hWnd, WS_THICKFRAME ))
+    {
+        cx = GetSystemMetrics( SM_CXFRAME ) ;
+        cy = GetSystemMetrics( SM_CYFRAME ) ;
+    }
+    else
+        if (TestWinStyle(hWnd, DS_MODALFRAME ))
+        {
+            cx = GetSystemMetrics( SM_CXDLGFRAME ) + GetSystemMetrics( SM_CXBORDER ) ;
+            cy = GetSystemMetrics( SM_CYDLGFRAME ) + GetSystemMetrics( SM_CYBORDER ) ;
+        }
+        else
+            if (TestWinStyle(hWnd, WS_BORDER ))
+            {
+                cx = GetSystemMetrics( SM_CXBORDER ) ;
+                cy = GetSystemMetrics( SM_CYBORDER ) ;
+            }
+    
+    InflateRect( lprc, cx, cy ) ;
+    
+    if (TestWinStyle( hWnd, IBS_VERTCAPTION ))
+        lprc->left -= nCapSize ;
+    else
+        if (TestWinStyle( hWnd, IBS_HORZCAPTION ))
+            lprc->top -= nCapSize ;
+
+} // ibAdjustWindowRect() 
+
+
+///////////////////////////////////////////////////////////////////////
+// Internal functions
+///////////////////////////////////////////////////////////////////////
+
+// DepressMinMaxButton()
+//
+// This function is called when the user has pressed either the min or
+// max button (i.e. WM_NCLBUTTONDOWN).  We go into a Peekmessage() loop,
+// waiting for the mouse to come back up.  This allows us to make the
+// button change up/down state like a real button does.
+//
+// lprc points to the rectangle that describes the button the
+// user has clicked on.
+//
+BOOL PASCAL DepressMinMaxButton( HWND hWnd, UINT uiHT, LPRECT lprc )
+{
+    BOOL    fDepressed = TRUE ;
+    MSG     msg ;
+                      
+    // Draw button in down state
+    DrawButton( NULL, hWnd, uiHT == HTMINBUTTON, fDepressed ) ;
+    SetCapture( hWnd ) ;
+    
+    while (TRUE)
+    {
+        if (PeekMessage((LPMSG)&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE))
+        {
+            switch (msg.message)
+            {
+                case WM_LBUTTONUP:
+                    if (fDepressed)
+                        DrawButton( NULL, hWnd, uiHT == HTMINBUTTON, !fDepressed ) ;
+                    ReleaseCapture();
+                return PtInRect( lprc, msg.pt ) ;
+                
+                case WM_MOUSEMOVE:
+                    if (PtInRect( lprc, msg.pt ))
+                    {
+                        if (!fDepressed)
+                            DrawButton( NULL, hWnd, uiHT == HTMINBUTTON, fDepressed = TRUE ) ;
+                    }
+                    else
+                    {
+                        if (fDepressed)
+                            DrawButton( NULL, hWnd, uiHT == HTMINBUTTON, fDepressed = FALSE ) ;
+                    }
+                break;
+            }
+        }
+    }
+    
+} // DepressMinMaxButton()  
+
+// DrawCaption( HDC hDC, HWND hWnd, LPRECT lprc,
+//                   BOOL fVert, BOOL fSysMenu, BOOL fActive )
+//
+//    This function draws an itsy bitsy caption bar with or
+//    without system menu to the dc specified by hDC.  The
+//    caption is drawn to fit within the lprc RECT and is
+//    drawn//withOut/ borders.
+//
+BOOL PASCAL DrawCaption( HDC hDC, HWND hWnd, LPRECT lprc,
+                              BOOL fVert, BOOL fSysMenu, BOOL fMin,
+                              BOOL fMax, BOOL fActive )
+{
+    RECT        rc ;
+    RECT        rcCap ;
+    COLORREF    rgbCaptionBG ;
+    COLORREF    rgbText ;
+    COLORREF    rgbWindowFrame ;
+    HBRUSH      hbrCaption ;
+    UINT        ui ;
+    UINT        nCapSize ;
+    
+    nCapSize = GETCAPTIONSIZE( hWnd ) ;
+    
+    // Get the colors.
+    //
+    rgbWindowFrame = GetSysColor( COLOR_WINDOWFRAME ) ;
+    
+    // if we have focus use the active caption color
+    // otherwise use the inactive caption color
+    //
+    if (fActive)
+    {
+        rgbText = GetSysColor( COLOR_CAPTIONTEXT ) ;
+        rgbCaptionBG = GetSysColor( COLOR_ACTIVECAPTION ) ;
+    }
+    else
+    {
+        if (fWin31)
+            rgbText = GetSysColor( COLOR_INACTIVECAPTIONTEXT ) ;
+        else
+            rgbText = GetSysColor( COLOR_CAPTIONTEXT ) ;
+
+        rgbCaptionBG = GetSysColor( COLOR_INACTIVECAPTION )  ;
+    }
+
+    SetBkMode( hDC, TRANSPARENT ) ;
+    SelectObject( hDC, GetStockObject( NULL_BRUSH ) ) ;
+    SelectObject( hDC, GetStockObject( NULL_PEN ) ) ;
+    
+    rcCap = *lprc ;
+    
+    if (fSysMenu)
+    {
+        if (fVert)
+            rcCap.top += nCapSize ;
+        else
+            rcCap.left += nCapSize ;
+    }
+    
+    if (fMax)
+    {
+        if (fVert)
+            rcCap.bottom -= nCapSize ;
+        else
+            rcCap.right -= nCapSize ;
+    }
+    
+    if (fMin)
+    {
+        if (fVert)
+            rcCap.bottom -= nCapSize ;
+        else
+            rcCap.right -= nCapSize ;
+    }
+    
+    if (fVert)
+    {
+        rc.left = lprc->right - 1 ;
+        rc.right = lprc->right ;
+        rc.top = lprc->top ;
+        rc.bottom = lprc->bottom ;
+    }
+    else
+    {
+        rc.left = lprc->left ;
+        rc.right = lprc->right ;
+        rc.bottom = lprc->bottom ;
+        rc.top = rc.bottom - 1 ;
+    }
+    
+    SetBkColor( hDC, rgbWindowFrame ) ;
+    DRAWFASTRECT( hDC, &rc ) ;
+
+    hbrCaption = CreateSolidBrush( rgbCaptionBG ) ;
+    hbrCaption = SelectObject( hDC, hbrCaption ) ;
+    SelectObject( hDC, GetStockObject( NULL_PEN ) ) ;
+    if (fVert)
+        Rectangle( hDC, rcCap.left, rcCap.top, rcCap.right, rcCap.bottom + 1 ) ;
+    else
+        Rectangle( hDC, rcCap.left, rcCap.top, rcCap.right+1, rcCap.bottom ) ;
+    hbrCaption = SelectObject( hDC, hbrCaption ) ;
+    DeleteObject( hbrCaption ) ;
+
+    
+    // Draw caption text here.  Only do it in 3.1 'cause 3.1 gives
+    // us 'small fonts'.
+    //
+    ui = GetWindowTextLength( hWnd ) ;
+    if (fWin31)
+    {
+        HFONT          hFont ;
+        LPSTR          lpsz ;
+        LOGFONT        lf ;
+        TEXTMETRIC     tm ;
+        int            cx ;
+        int            cy ;
+        SIZE           Size ;
+        
+        if ((lpsz = (char*)GlobalAllocPtr( GHND, ui + 2 )))
+        {
+            UINT    nBkMode ;
+
+            GetWindowText( hWnd, lpsz, ui + 1 ) ;
+            nBkMode = SetBkMode( hDC, TRANSPARENT ) ;
+            rgbText = SetTextColor( hDC, rgbText ) ;
+            
+            memset( &lf, '\0', sizeof(LOGFONT) ) ;
+
+            lf.lfHeight = -(int)(nCapSize - 3) ;
+            lf.lfCharSet = ANSI_CHARSET ;
+            lf.lfQuality = DEFAULT_QUALITY ;
+            lf.lfClipPrecision = CLIP_LH_ANGLES | CLIP_STROKE_PRECIS ;
+            if (nCapSize >= 20)
+            {
+                lf.lfWeight = FW_BOLD ;
+            }
+            
+            if (fVert)
+            {
+                // Can only rotate true type fonts (well, ok, we could
+                // try and use "modern").
+                strcpy( lf.lfFaceName, "Arial" ) ;
+                lf.lfPitchAndFamily = FF_SWISS | 0x04;
+                lf.lfEscapement = 900 ;
+
+                // Note:  The Win 3.1 documentation for CreateFont() say's
+                // that the lfOrientation member is ignored.  It appears,
+                // that on Windows 16 3.1 this is true, but when running
+                // as a 16 bit WinApp on WindowsNT 3.1 the lfOrientation
+                // must be set or the text does not rotate!
+                //
+                lf.lfOrientation = 900 ;
+                
+                hFont = CreateFontIndirect( &lf ) ;
+                hFont = SelectObject( hDC, hFont ) ;
+                
+                GetTextExtentPoint( hDC, lpsz, ui, &Size ) ;
+                cx = rcCap.bottom - ((rcCap.bottom - rcCap.top - Size.cx) / 2) ;
+                cy = rcCap.left - 1 + ((rcCap.right - rcCap.left - Size.cy) / 2) ;
+
+                // Make sure we got a rotatable font back.
+                //
+                GetTextMetrics( hDC, &tm ) ;
+                if (tm.tmPitchAndFamily & TMPF_VECTOR     ||
+                    tm.tmPitchAndFamily & TMPF_TRUETYPE)
+                {
+                    ExtTextOut( hDC,
+                               cy,
+                               min( (long)cx, rcCap.bottom),
+                               ETO_CLIPPED, &rcCap,
+                               lpsz, ui, NULL ) ;
+                }
+                
+                hFont = SelectObject( hDC, hFont ) ;
+                DeleteObject( hFont ) ;
+            }
+            else
+            {
+                // Use small fonts always for the horizontal. Cause it looks
+                // more like "System" than Arial.
+                //
+                lf.lfPitchAndFamily = FF_SWISS ;
+                
+                hFont = CreateFontIndirect( &lf ) ;
+                hFont = SelectObject( hDC, hFont ) ;
+                
+                GetTextExtentPoint( hDC, lpsz, ui, &Size ) ;
+                cx = rcCap.left + ((rcCap.right - rcCap.left - Size.cx) / 2) ;
+                cy = rcCap.top + ((rcCap.bottom - rcCap.top - Size.cy) / 2) ;
+                
+                // Figger out how big the string is
+                //
+                ExtTextOut( hDC,
+                            max( (long)cx, rcCap.left ),
+                            cy,
+                            ETO_CLIPPED, &rcCap,
+                            lpsz, ui, NULL ) ;
+                
+                hFont = SelectObject( hDC, hFont ) ;
+                DeleteObject( hFont ) ;
+            }
+
+            // Unsetup the DC
+            //
+            rgbText = SetTextColor( hDC, rgbText ) ;
+            SetBkMode( hDC, nBkMode ) ;
+            
+            GlobalFreePtr( lpsz ) ;
+        }
+    }
+    
+    if (fSysMenu)
+        DrawSysMenu( hDC, hWnd, FALSE ) ;
+    
+    if (fMin)
+        DrawButton( hDC, hWnd, TRUE, FALSE ) ;
+
+    if (fMax)
+        DrawButton( hDC, hWnd, FALSE, FALSE ) ;
+    
+    return TRUE ;
+    
+} // DrawCaption()
+
+
+// DrawSysMenu( HDC hDC, hWnd, BOOL fInvert )
+//
+// Draws the little system menu icon.
+//
+void PASCAL DrawSysMenu( HDC hDC, HWND hWnd, BOOL fInvert )
+{
+    RECT         rcIcon ;
+    RECT         rcTemp ;
+    RECT         rc ;
+    COLORREF     rgbIconFace ;
+    COLORREF     rgbWindowFrame ;
+    BOOL         fDC ;
+    UINT         nCapSize ;
+        
+    nCapSize = GETCAPTIONSIZE( hWnd ) ;
+    
+    if (!hDC)
+    {
+        fDC = TRUE ;
+        hDC = GetWindowDC( hWnd ) ;
+    }
+    else
+        fDC = FALSE ;
+    
+    if (hDC)
+    {
+        rgbIconFace    = GetNearestColor( hDC, RGBLTGRAY ) ;
+        rgbWindowFrame = GetSysColor( COLOR_WINDOWFRAME ) ;
+        
+        GetIconRect( hWnd, &rcIcon ) ;
+        GetWindowRect( hWnd, &rc ) ;
+           
+        OffsetRect( &rcIcon, -rc.left, -rc.top ) ;
+        
+        rcTemp = rcIcon ;
+        
+        if (TestWinStyle( hWnd, IBS_VERTCAPTION ))
+        {
+            rc = rcIcon ;      // separator line
+            rc.top = ++rc.bottom - 1 ;
+        }
+        else
+        {
+            rc = rcIcon ;      // separator line
+            rc.left = ++rc.right - 1 ;
+        }
+        
+        // Fill
+        SetBkColor( hDC, rgbIconFace ) ;
+        DRAWFASTRECT( hDC, &rcTemp ) ;
+        
+        // Draw separator line
+        SetBkColor( hDC, rgbWindowFrame ) ;
+        DRAWFASTRECT( hDC, &rc ) ;
+        
+        if (nCapSize > 4)
+        {
+            // Draw the little horizontal doo-hickey
+            //
+            rcTemp.top = rcIcon.top + ((nCapSize-1) / 2) ;
+            rcTemp.bottom = rcTemp.top + 3 ;
+            rcTemp.left  = rcTemp.left + 3 ; 
+            rcTemp.right = rcTemp.right - 1 ;
+                
+            SetBkColor( hDC, RGBGRAY ) ;
+            DRAWFASTRECT( hDC, &rcTemp ) ;
+                
+            rc = rcTemp ;
+            OffsetRect( &rc, -1, -1 ) ;
+            SetBkColor( hDC, RGBBLACK ) ;
+            DRAWFASTRECT( hDC, &rc ) ;
+                
+            InflateRect( &rc, -1, -1 ) ;
+            SetBkColor( hDC, RGBWHITE ) ;
+            DRAWFASTRECT( hDC, &rc ) ;
+        }
+        
+        if (fInvert)
+            InvertRect( hDC, &rcIcon ) ;
+    
+        if (fDC)
+            ReleaseDC( hWnd, hDC ) ;
+    }
+
+} // DrawSysMenu()
+
+// DoMenu( HWND hWnd )
+//
+//    Pops up the system menu.
+//
+BOOL PASCAL DoMenu( HWND hWnd )
+{
+    HDC    hDC ;
+    RECT   rcIcon ;
+    RECT   rc ;
+    POINT  pt ;
+    HMENU  hMenu ;
+    DWORD  dw ;
+
+    if (!TestWinStyle(hWnd, WS_SYSMENU))
+        return FALSE ;
+    
+    if ((hDC = GetWindowDC( hWnd )))
+    {
+        // Invert the icon
+        //
+        DrawSysMenu( hDC, hWnd, TRUE ) ;
+        
+        // Pop up the menu
+        //
+        if (TestWinStyle( hWnd, IBS_VERTCAPTION ))
+        {
+            pt.x = -1 ;
+            pt.y = 0 ;
+        }
+        else
+        {
+            pt.x = 0 ;
+            pt.y = -1 ;
+        }
+        
+        GetIconRect( hWnd, &rcIcon ) ;
+        GetWindowRect( hWnd, &rc ) ;
+        OffsetRect( &rcIcon, -rc.left, -rc.top ) ;
+        
+        ClientToScreen( hWnd, &pt ) ;
+        ClientToScreen( hWnd, (LPPOINT)&rc.right ) ;
+        
+        dw = GetWindowLong( hWnd, GWL_STYLE ) ;
+        SetWindowLong( hWnd, GWL_STYLE, dw | WS_SYSMENU ) ;
+        
+        hMenu = GetSystemMenu( hWnd, FALSE ) ;
+        SetupSystemMenu( hWnd, hMenu ) ;
+        
+        SetWindowLong( hWnd, GWL_STYLE, dw ) ;
+
+        TrackPopupMenu( hMenu, 0, //TPM_LEFTALIGN,
+                    pt.x,
+                    pt.y,
+                    0,
+                    hWnd,
+                    &rc ) ;
+    
+        DrawSysMenu( hDC, hWnd, FALSE ) ;
+        ReleaseDC( hWnd, hDC ) ;
+    }
+    return TRUE ;
+
+} // DoMenu()
+
+// SetupSystemMenu( HWND hWnd, HMENU hMenu )
+//
+//    Enables/Disables the appropriate menu items on the
+//    menu passed for the window passed.
+//
+void PASCAL SetupSystemMenu( HWND hWnd, HMENU hMenu )
+{
+    UINT     wMove ;        
+    UINT     wSize ;
+    UINT     wMinBox ;
+    UINT     wMaxBox ;
+    UINT     wRestore ;
+    
+    // Assume all should be grayed.
+    //
+    wSize = wMove = wMinBox = wMaxBox = wRestore = MF_GRAYED ;
+    
+    if (TestWinStyle( hWnd, WS_MAXIMIZEBOX ) || IsIconic( hWnd ))
+        wMaxBox = MF_ENABLED ;
+    
+    if (TestWinStyle( hWnd, WS_MINIMIZEBOX ))
+        wMinBox = MF_ENABLED ;
+    
+    if (IsZoomed( hWnd ))
+        wRestore = MF_ENABLED ;
+    
+    if (TestWinStyle( hWnd, WS_THICKFRAME ) &&
+        !(IsIconic( hWnd ) || IsZoomed( hWnd )))
+        wSize = MF_ENABLED ;
+    
+    if (!IsZoomed( hWnd ) &&
+        !IsIconic( hWnd ) &&
+        TestWinStyle( hWnd, WS_CAPTION ) )
+        wMove = MF_ENABLED ;
+    
+    EnableMenuItem( hMenu, SC_MOVE,     wMove ) ;
+    EnableMenuItem( hMenu, SC_SIZE,     wSize ) ;
+    EnableMenuItem( hMenu, SC_MINIMIZE, wMinBox ) ;
+    EnableMenuItem( hMenu, SC_MAXIMIZE, wMaxBox ) ;
+    EnableMenuItem( hMenu, SC_RESTORE,  wRestore ) ;
+                        
+} // SetupSystemMenu()
+
+// GetCaptionRect( HWND hWnd, LPRECT lprc )
+//
+//    calcluales the rectangle of the mini-caption in screen coords.
+//
+BOOL PASCAL GetCaptionRect( HWND hWnd, LPRECT lprc )
+{
+    UINT     nCapSize ;
+    
+    nCapSize = GETCAPTIONSIZE( hWnd ) ;
+    
+    if (!HASCAPTION( hWnd ))
+    {
+        SetRectEmpty( lprc ) ;
+        return FALSE ;
+    }
+    
+    GetWindowRect( hWnd, lprc ) ;
+    
+    // the window might have other non-client components like
+    // borders 
+    //
+    if (TestWinStyle( hWnd, WS_THICKFRAME ))
+    {
+        lprc->left += GetSystemMetrics( SM_CXFRAME ) ;
+        lprc->top  += GetSystemMetrics( SM_CYFRAME ) ;
+        lprc->right -= GetSystemMetrics( SM_CXFRAME ) ;
+        lprc->bottom -= GetSystemMetrics( SM_CYFRAME ) ;
+    }
+    else
+        if (TestWinStyle( hWnd, DS_MODALFRAME ))  // if it's a dialog box
+        {   
+            lprc->left += GetSystemMetrics( SM_CXDLGFRAME ) + GetSystemMetrics( SM_CXBORDER ) ;
+            lprc->top  += GetSystemMetrics( SM_CYDLGFRAME ) + GetSystemMetrics( SM_CYBORDER ) ;
+            lprc->right -= GetSystemMetrics( SM_CXDLGFRAME ) + GetSystemMetrics( SM_CXBORDER ) ;
+            lprc->bottom -= GetSystemMetrics( SM_CYDLGFRAME ) + GetSystemMetrics( SM_CYBORDER ) ;
+        }
+        else
+            if (TestWinStyle( hWnd, WS_BORDER ))
+            {   
+                lprc->left += GetSystemMetrics( SM_CXBORDER ) ;
+                lprc->top  += GetSystemMetrics( SM_CYBORDER ) ;
+                lprc->right -= GetSystemMetrics( SM_CXBORDER ) ;
+                lprc->bottom -= GetSystemMetrics( SM_CYBORDER ) ;
+            }
+    
+    if (TestWinStyle( hWnd, IBS_VERTCAPTION ))
+        lprc->right = lprc->left + nCapSize ;
+    else
+        lprc->bottom = lprc->top + nCapSize ;
+    
+    return TRUE ;
+} // GetCaptionRect()
+
+// GetIconRect( HWND hWnd, LPRECT lprc )
+//
+//    Calculates the rect of the icon in screen coordinates.
+//
+BOOL PASCAL GetIconRect( HWND hWnd, LPRECT lprc )
+{
+    UINT    nCapSize ;
+    BOOL    fMenu, fVert ;
+
+    fMenu= TestWinStyle( hWnd, WS_SYSMENU ) ;
+    fVert = TestWinStyle( hWnd, IBS_VERTCAPTION ) ;
+
+    if (!GetCaptionRect( hWnd, lprc ))   // window coords
+      return FALSE ;
+
+    if (!fMenu)
+    {
+        SetRectEmpty( lprc ) ;
+        return FALSE ;
+    }
+
+    nCapSize = GETCAPTIONSIZE( hWnd ) ;
+
+    if (fVert)
+        lprc->bottom = lprc->top + nCapSize ;
+    else
+        lprc->right = lprc->left + nCapSize ;
+    
+    lprc->bottom-- ;
+    lprc->right-- ;
+    
+    return TRUE ;
+
+} // GetIconRect()
+
+// GetMinButtonRect()
+//
+// Calculates the rect of the minimize button in screen
+// coordinates.
+//
+// For horizontal captions, we have the following situation ('Y' is minimize
+// and '^' is maximize or restore):
+//
+//   +---------------------------------+
+//   | - |                     | Y | ^ |
+//   +---------------------------------+
+//   |                         |.......| <-- This is the width (nSize)
+//
+// For vertical captions, we have the following:
+//
+//   |  |
+//   |  |
+//   |  |
+//   |  |
+//   |  |
+//   |  |
+//   |--|--
+//   | Y| .
+//   |--| . <-- This is the height of the rectangle (nSize)
+//   | ^| .
+//   +--+--
+//
+// In order to figure out where the minimize button goes, we first need
+// to know if there is a maximize button.  If so, use GetMaxButtonRect()
+// to place...
+//
+BOOL PASCAL GetMinButtonRect( HWND hWnd, LPRECT lprc )
+{
+    if (!TestWinStyle( hWnd, WS_MINIMIZEBOX )) 
+    {
+        SetRectEmpty( lprc ) ;
+        return FALSE ;
+    }
+
+    // The minimize button can be in either position 1 or 2.  If there
+    // is a maximize button, it's in position 2.
+    //
+    if (TestWinStyle( hWnd, WS_MAXIMIZEBOX ))
+        return GetButtonRect( hWnd, 2, lprc ) ;
+    else
+        return GetButtonRect( hWnd, 1, lprc ) ;
+}
+
+// GetMaxButtonRect()
+//
+// Calculates the rect of the maximize button in screen
+// coordinates.
+//
+// The maximize button, if present, is always to the far right
+// or bottom.
+//
+BOOL PASCAL GetMaxButtonRect( HWND hWnd, LPRECT lprc )
+{
+    //The maximize button can only be in position 1.
+    //
+    if (TestWinStyle( hWnd, WS_MAXIMIZEBOX ))
+        return GetButtonRect( hWnd, 1, lprc ) ;
+    else
+    {
+        SetRectEmpty( lprc ) ;
+        return FALSE ;
+    }
+}
+
+// Get the rect where a button would go. 
+// 
+// This function does not care if it's a min or max, just whether
+// it is the first from the right/bottom or second from the right/bottom
+// and so on..
+//
+BOOL PASCAL GetButtonRect( HWND hWnd, UINT nPos, LPRECT lprc )
+{
+    UINT    nSize = 0 ;
+
+    if (!GetCaptionRect( hWnd, lprc ))   //window coords
+      return FALSE ;
+
+    nSize = GETCAPTIONSIZE( hWnd ) ;
+
+    if (TestWinStyle( hWnd, IBS_VERTCAPTION ))
+    {
+        lprc->bottom -= nSize * (nPos-1) ;
+        lprc->top = lprc->bottom - nSize + 1 ;
+    }
+    else
+    {
+        lprc->right -= nSize * (nPos-1) ;
+        lprc->left = lprc->right - nSize + 1 ;
+    }
+
+    return TRUE ;
+} // GetButtonRect()
+
+// DrawButton( HDC hDC, HWND hWnd, BOOL fMin, BOOL fDepressed )
+// 
+// Draws either the min, max, or restore buttons. If fMin is FALSE then it
+// will draw either the Max or Restore button.  If fDepressed is TRUE it will
+// draw the button in a down state.
+//
+void PASCAL DrawButton( HDC hDC, HWND hWnd, BOOL fMin, BOOL fDepressed)
+{
+    RECT            rcButton ;
+    RECT            rc ;
+    COLORREF        rgbWindowFrame ;
+    BOOL            fDC ;
+    UINT            nCapSize ;
+    UINT            nOffset ;
+    int             n ;
+
+    nCapSize = GETCAPTIONSIZE( hWnd ) ;
+
+    // If you look at the standard Windows' min/max buttons, you will notice
+    // that they have two pixels of 'shadow' to the bottom and right.  Since
+    // our buttons can be really, really small, we only want one pixel of 
+    // shadow when they are small.  I arbitrarily decided that if the 
+    // caption size is greater than or equal to 20 we will use two
+    // pixels.  That's what this THREASHOLD stuff does.
+    //
+    #define THRESHOLD   20
+    nOffset = (nCapSize >= THRESHOLD) ? 2 : 1 ;    
+
+    if (!hDC)
+    {
+        fDC = TRUE ;
+        hDC = GetWindowDC( hWnd ) ;
+    }
+    else
+        fDC = FALSE ;
+    
+    if (hDC)
+    {
+        rgbWindowFrame = GetSysColor( COLOR_WINDOWFRAME ) ;
+        
+        if (fMin)
+            GetMinButtonRect( hWnd, &rcButton ) ;
+        else
+            GetMaxButtonRect( hWnd, &rcButton ) ;
+        
+        GetWindowRect( hWnd, &rc ) ;
+        OffsetRect( &rcButton, -rc.left, -rc.top ) ;
+        
+        rc = rcButton ;
+        if (TestWinStyle( hWnd, IBS_VERTCAPTION ))
+        {
+            rc = rcButton ;     //separator line
+            rc.bottom = --rc.top + 1 ;
+            rcButton.right-- ;
+        }
+        else
+        {
+            rc = rcButton ;     //separator line
+            rc.right = --rc.left + 1 ;
+            rcButton.bottom-- ;
+        }
+        
+        //Draw separator line
+        SetBkColor( hDC, rgbWindowFrame ) ;
+        DRAWFASTRECT( hDC, &rc ) ;
+        
+        //Fill
+        SetBkColor( hDC, RGBLTGRAY ) ;
+        DRAWFASTRECT( hDC, &rcButton ) ;
+        
+        if (!fDepressed)
+        {
+            //The normal min/max buttons have one pixel on the top and left
+            //sides for the highlight, and two pixels on the bottom and
+            //right side for the shadow.
+            //
+            //When our caption is 'small' we only use one pixel on all
+            //sides.
+            //
+            SetBkColor( hDC, RGBWHITE ) ;
+            //Draw left side
+            rc = rcButton ;
+            rc.right = rc.left + 1 ;
+            DRAWFASTRECT( hDC, &rc ) ;
+
+            //Draw Top
+            rc = rcButton ;
+            rc.bottom = rc.top + 1 ;
+            DRAWFASTRECT( hDC, &rc ) ;
+
+            SetBkColor( hDC, RGBGRAY ) ;
+            //Draw right side
+            rc = rcButton ;
+            rc.left = rc.right - 1 ;
+            DRAWFASTRECT( hDC, &rc ) ;
+            if (nCapSize > THRESHOLD)
+            {
+                rc.left-- ;
+                rc.top++ ;
+                DRAWFASTRECT( hDC, &rc ) ;
+            }
+
+            //Draw bottom
+            rc = rcButton ;
+            rc.top = rc.bottom - 1 ;
+            DRAWFASTRECT( hDC, &rc ) ;
+            if (nCapSize > THRESHOLD)
+            {
+                rc.top-- ;
+                rc.left++ ;
+                DRAWFASTRECT( hDC, &rc ) ;
+            }
+
+            rcButton.left++ ;
+            rcButton.top++ ;
+            rcButton.right -= nOffset ;
+            rcButton.bottom -= nOffset ;
+        }
+        else
+        {
+            //Draw depressed state
+
+            SetBkColor( hDC, RGBGRAY ) ;
+            //Draw left side
+            rc = rcButton ;
+            rc.right = rc.left + nOffset ;
+            DRAWFASTRECT( hDC, &rc ) ;
+
+            //Draw Top
+            rc = rcButton ;
+            rc.bottom = rc.top + nOffset ;
+            DRAWFASTRECT( hDC, &rc ) ;
+
+            rcButton.left += 2 * nOffset ;
+            rcButton.top += 2 * nOffset ;
+        }
+
+        // Now draw the arrows.  We do not want the
+        // arrows to grow too large when we have a bigger than
+        // normal caption, so we restrict their size.
+        //
+        // rcButton now represents where we can place our
+        // arrows.  
+        //
+        // The maximum size of our arrows (i.e. the width of rcButton)
+        // has been empirically determined to be SM_CYCAPTION / 2
+        //
+        n = ((GetSystemMetrics( SM_CYCAPTION )) / 2) - 
+            (rcButton.right - rcButton.left) ;
+        if (n < 1)
+            InflateRect( &rcButton, n/2-1, n/2-1 ) ;
+
+        if (fMin)
+            DrawArrow( hDC, &rcButton, ARROW_DOWN ) ;
+        else 
+            if (IsZoomed( hWnd ))
+            {
+                DrawArrow( hDC, &rcButton, ARROW_RESTORE ) ;
+            }
+            else
+                DrawArrow( hDC, &rcButton, ARROW_UP ) ;
+        
+        if (fDC)
+            ReleaseDC( hWnd, hDC ) ;
+    }
+
+} // DrawButton()
+
+
+// DrawArrow
+//
+// Draws either a up or down arrow.  The arrow is bound by the rectangle
+//
+void PASCAL DrawArrow( HDC hdc, LPRECT lprc, UINT uiStyle )
+{
+    int     row ;
+    int     xTip ;
+    int     yTip ;
+    RECT    rc ;
+    int     nMax = (lprc->bottom - lprc->top) >> 1 ;
+
+    SetBkColor( hdc, RGBBLACK ) ;
+
+    // We draw the arrow by drawing a series of horizontal lines
+    //
+    xTip = lprc->left + ((lprc->right - lprc->left+1) >> 1) ;
+    switch (uiStyle)
+    {
+        case ARROW_UP:
+            yTip = lprc->top + ((lprc->bottom - lprc->top-1) >> 2) ;
+            for (row = 1 ; row <= nMax ; row++ )
+            {
+                rc.left = xTip - row ;
+                rc.right = xTip + row - 1 ;
+                rc.top = yTip + row ;
+                rc.bottom = rc.top + 1 ;
+                DRAWFASTRECT( hdc, &rc ) ;
+            }
+        break ;
+
+        case ARROW_DOWN:
+            yTip = lprc->bottom - ((lprc->bottom - lprc->top-1) >> 2) ;
+            for ( row = nMax ; row > 0 ; row-- )
+            {
+                rc.left = xTip - row ;
+                rc.right = xTip + row - 1 ;
+                rc.top = yTip - row ;
+                rc.bottom = rc.top + 1 ;
+                DRAWFASTRECT( hdc, &rc ) ;
+            }
+        break ;
+
+        case ARROW_RESTORE:
+        default:
+            yTip = lprc->top + ((lprc->bottom - lprc->top-1) >> 3) - 2;
+            for (row = 1 ; row <= nMax ; row++ )
+            {
+                rc.left = xTip - row ;
+                rc.right = xTip + row - 1 ;
+                rc.top = yTip + row ;
+                rc.bottom = rc.top + 1 ;
+                DRAWFASTRECT( hdc, &rc ) ;
+            }
+
+            yTip += (nMax+1) * 2 ;
+            for ( row = nMax ; row > 0 ; row-- )
+            {
+                rc.left = xTip - row ;
+                rc.right = xTip + row - 1 ;
+                rc.top = yTip - row ;
+                rc.bottom = rc.top + 1 ;
+                DRAWFASTRECT( hdc, &rc ) ;
+            }
+        break ;
+    }
+
+}  // DrawArrow()   
+
+#endif // USE_ITSY_BITSY
diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp
new file mode 100644
index 0000000000..a3f4628ae1
--- /dev/null
+++ b/src/msw/msgdlg.cpp
@@ -0,0 +1,138 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        msgdlg.cpp
+// Purpose:     wxMessageDialog
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "msgdlg.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/defs.h"
+#include "wx/utils.h"
+#include "wx/dialog.h"
+#include "wx/msgdlg.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define wxDIALOG_DEFAULT_X 300
+#define wxDIALOG_DEFAULT_Y 300
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
+#endif
+
+wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
+        long style, const wxPoint& pos)
+{
+    m_caption = caption;
+    m_message = message;
+    m_dialogStyle = style;
+    m_parent = parent;
+}
+
+int wxMessageDialog::ShowModal(void)
+{
+  HWND hWnd = 0;
+  if (m_parent) hWnd = (HWND) m_parent->GetHWND();
+  unsigned int msStyle = MB_OK;
+  if (m_dialogStyle & wxYES_NO)
+  {
+    if (m_dialogStyle & wxCANCEL)
+      msStyle = MB_YESNOCANCEL;
+    else
+      msStyle = MB_YESNO;
+  }
+  if (m_dialogStyle & wxOK)
+  {
+    if (m_dialogStyle & wxCANCEL)
+      msStyle = MB_OKCANCEL;
+    else
+      msStyle = MB_OK;
+  }
+  if (m_dialogStyle & wxICON_EXCLAMATION)
+    msStyle |= MB_ICONEXCLAMATION;
+  else if (m_dialogStyle & wxICON_HAND)
+    msStyle |= MB_ICONHAND;
+  else if (m_dialogStyle & wxICON_INFORMATION)
+    msStyle |= MB_ICONINFORMATION;
+  else if (m_dialogStyle & wxICON_QUESTION)
+    msStyle |= MB_ICONQUESTION;
+
+  if (hWnd)
+    msStyle |= MB_APPLMODAL;
+  else
+    msStyle |= MB_TASKMODAL;
+    
+  int msAns = MessageBox(hWnd, (LPCSTR)(const char *)m_message, (LPCSTR)(const char *)m_caption, msStyle);
+  int ans = wxOK;
+  switch (msAns)
+  {
+    case IDCANCEL:
+      ans = wxID_CANCEL;
+      break;
+    case IDOK:
+      ans = wxID_OK;
+      break;
+    case IDYES:
+      ans = wxID_YES;
+      break;
+    case IDNO:
+      ans = wxID_NO;
+      break;
+  }
+  return ans;
+}
+
+/*
+ * Common dialogs
+ *
+ */
+ 
+// Pop up a message box
+int wxMessageBox(const wxString& message, const wxString& caption, const long style,
+                 wxWindow *parent, const int x, const int y)
+{
+	wxMessageDialog dialog(parent, message, caption, style);
+
+	int ans = dialog.ShowModal();
+	switch ( ans )
+	{
+		case wxID_OK:
+			return wxOK;
+			break;
+		case wxID_YES:
+			return wxYES;
+			break;
+		case wxID_NO:
+			return wxNO;
+			break;
+		default:
+		case wxID_CANCEL:
+			return wxCANCEL;
+			break;
+	}
+
+	return ans;
+}
+
+
diff --git a/src/msw/nativdlg.cpp b/src/msw/nativdlg.cpp
new file mode 100644
index 0000000000..886418996f
--- /dev/null
+++ b/src/msw/nativdlg.cpp
@@ -0,0 +1,289 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        nativdlg.cpp
+// Purpose:     Native dialog loading code (part of wxWindow)
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/wx.h"
+#endif
+
+#include "wx/spinbutt.h"
+#include "wx/msw/private.h"
+
+extern wxWindow *wxWndHook;
+extern LONG APIENTRY _EXPORT wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+bool wxWindow::LoadNativeDialog(wxWindow* parent, const wxWindowID& id)
+{
+	m_windowId = id;
+    wxWndHook = this;
+	m_hWnd = (WXHWND) ::CreateDialog((HINSTANCE) wxGetInstance(), MAKEINTRESOURCE(id),
+		(HWND) (parent ? parent->GetHWND() : (WXHWND) NULL), (DLGPROC) wxDlgProc);
+    wxWndHook = NULL;
+
+	if ( !m_hWnd )
+		return FALSE;
+
+  	SubclassWin(GetHWND());
+
+    if (!parent)
+      wxTopLevelWindows.Append(this);
+
+	if ( parent )
+		parent->AddChild(this);
+
+	// Enumerate all children
+    HWND hWndNext;
+    hWndNext = ::GetWindow((HWND) m_hWnd, GW_CHILD);
+
+	wxWindow* child = NULL;
+	if (hWndNext)
+	  child = CreateWindowFromHWND(this, (WXHWND) hWndNext);
+
+    while (hWndNext != NULL)
+    {
+       hWndNext = ::GetWindow(hWndNext, GW_HWNDNEXT);
+	   if (hWndNext)
+	     child = CreateWindowFromHWND(this, (WXHWND) hWndNext);
+    }
+
+	return TRUE;
+}
+
+bool wxWindow::LoadNativeDialog(wxWindow* parent, const wxString& name)
+{
+	SetName(name);
+
+    wxWndHook = this;
+	m_hWnd = (WXHWND) ::CreateDialog((HINSTANCE) wxGetInstance(), (const char *) name,
+		(HWND) (parent ? parent->GetHWND() : (WXHWND) NULL), (DLGPROC) wxDlgProc);
+    wxWndHook = NULL;
+
+	if ( !m_hWnd )
+		return FALSE;
+
+  	SubclassWin(GetHWND());
+
+    if (!parent)
+      wxTopLevelWindows.Append(this);
+
+	if ( parent )
+		parent->AddChild(this);
+
+	return TRUE;
+}
+
+wxWindow* wxWindow::GetWindowChild1(const wxWindowID& id)
+{
+	if ( m_windowId == id )
+		return this;
+
+	wxNode *node = GetChildren()->First();
+	while ( node )
+	{
+		wxWindow* child = (wxWindow*) node->Data();
+		wxWindow* win = child->GetWindowChild1(id);
+		if ( win )
+			return win;
+		node = node->Next();
+	}
+
+	return NULL;
+}
+
+wxWindow* wxWindow::GetWindowChild(const wxWindowID& id)
+{
+	wxWindow* win = GetWindowChild1(id);
+	if ( !win )
+	{
+		HWND hWnd =	::GetDlgItem((HWND) GetHWND(), id);
+
+		if (hWnd)
+		{
+			wxWindow* child = CreateWindowFromHWND(this, (WXHWND) hWnd);
+			if (child)
+			{
+				child->AddChild(this);
+				return child;
+			}
+		}
+	}
+	return NULL;
+}
+
+
+wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd)
+{
+	char buf[256];
+
+#ifndef __WIN32__
+	GetClassName((HWND) hWnd, buf, 256);
+#else
+#ifdef UNICODE
+	GetClassNameW((HWND) hWnd, buf, 256);
+#else
+	GetClassNameA((HWND) hWnd, buf, 256);
+#endif
+#endif
+
+	wxString str(buf);
+	str.UpperCase();
+
+#ifndef __WIN32__
+	long id = (long) GetWindowWord((HWND) hWnd, GWW_ID);
+#else
+	long id = GetWindowLong((HWND) hWnd, GWL_ID);
+#endif
+
+	long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
+
+	wxWindow* win = NULL;
+
+	if (str == "BUTTON")
+	{
+		int style1 = (style & 0xFF);
+		if ((style1 == BS_3STATE) || (style1 == BS_AUTO3STATE) || (style1 == BS_AUTOCHECKBOX) ||
+			(style1 == BS_CHECKBOX))
+		{
+			win = new wxCheckBox;
+		}
+		else if ((style1 == BS_AUTORADIOBUTTON) || (style1 == BS_RADIOBUTTON))
+		{
+			win = new wxRadioButton;
+		}
+#ifdef __WIN32__
+		else if (style & BS_BITMAP)
+		{
+			// TODO: how to find the bitmap?
+			win = new wxBitmapButton;
+			wxMessageBox("Have not yet implemented bitmap button as BS_BITMAP button.");
+		}
+#endif
+		else if (style1 == BS_OWNERDRAW)
+		{
+			// TODO: how to find the bitmap?
+			// TODO: can't distinguish between bitmap button and bitmap static.
+			// Change implementation of wxStaticBitmap to SS_BITMAP.
+			// PROBLEM: this assumes that we're using resource-based bitmaps.
+			// So maybe need 2 implementations of bitmap buttons/static controls,
+			// with a switch in the drawing code. Call default proc if BS_BITMAP.
+			win = new wxBitmapButton;
+		}
+		else if ((style1 == BS_PUSHBUTTON) || (style1 == BS_DEFPUSHBUTTON))
+		{
+			win = new wxButton;
+		}
+		else if (style1 == BS_GROUPBOX)
+		{
+			win = new wxStaticBox;
+		}
+		else
+		{
+			char buf[256];
+			sprintf(buf, "Don't know what kind of button this is: id = %d", (int) id);
+			wxMessageBox(buf);
+		}
+	}
+	else if (str == "COMBOBOX")
+	{
+		win = new wxComboBox;
+	}
+	// TODO: Problem if the user creates a multiline - but not rich text - text control,
+	// since wxWin assumes RichEdit control for this. Should have m_isRichText in
+	// wxTextCtrl. Also, convert as much of the window style as is necessary
+	// for correct functioning.
+	// Could have wxWindow::AdoptAttributesFromHWND(WXHWND)
+	// to be overridden by each control class.
+	else if (str == "EDIT")
+	{
+		win = new wxTextCtrl;
+	}
+	else if (str == "LISTBOX")
+	{
+		win = new wxListBox;
+	}
+	else if (str == "SCROLLBAR")
+	{
+		win = new wxScrollBar;
+	}
+#if defined(__WIN95__)
+	else if (str == "MSCTLS_UPDOWN32")
+	{
+		win == new wxSpinButton;
+	}
+#endif
+	else if (str == "MSCTLS_TRACKBAR32")
+	{
+		// Need to ascertain if it's horiz or vert
+		win = new wxSlider;
+	}
+	else if (str == "STATIC")
+	{
+		int style1 = (style & 0xFF);
+
+		if ((style1 == SS_LEFT) || (style1 == SS_RIGHT) || (style1 == SS_SIMPLE))
+			win = new wxStaticText;
+#ifdef __WIN32__
+		else if (style1 == SS_BITMAP)
+		{
+			win = new wxStaticBitmap;
+
+			// Help! this doesn't correspond with the wxWin implementation.
+			wxMessageBox("Please make SS_BITMAP statics into owner-draw buttons.");
+		}
+#endif
+	}
+	else
+	{
+		wxString msg("Don't know how to convert from Windows class ");
+		msg += str;
+		wxMessageBox(msg);
+	}
+
+	if (win)
+	{
+	    parent->AddChild(win);
+		win->SetEventHandler(win);
+		win->SetHWND(hWnd);
+		win->SetId(id);
+		win->SubclassWin(hWnd);
+		win->AdoptAttributesFromHWND();
+		win->SetupColours();
+
+		return win;
+	}
+	else
+		return NULL;
+}
+
+// Make sure the window style (etc.) reflects the HWND style (roughly)
+void wxWindow::AdoptAttributesFromHWND(void)
+{
+	HWND hWnd = (HWND) GetHWND();
+	long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
+
+	if (style & WS_VSCROLL)
+		m_windowStyle |= wxVSCROLL;
+	if (style & WS_HSCROLL)
+		m_windowStyle |= wxHSCROLL;
+}
+
+
diff --git a/src/msw/ownerdrw.cpp b/src/msw/ownerdrw.cpp
new file mode 100644
index 0000000000..22c152f23d
--- /dev/null
+++ b/src/msw/ownerdrw.cpp
@@ -0,0 +1,230 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        msw/ownerdrw.cpp
+// Purpose:     implementation of wxOwnerDrawn class
+// Author:      Vadim Zeitlin
+// Modified by: 
+// Created:     13.11.97
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// headers & declarations
+// ============================================================================
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+  #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+  #include "wx/menu.h"
+#endif
+
+#include "wx/ownerdrw.h"
+#include "wx/menuitem.h"
+
+#include <windows.h>
+
+// ============================================================================
+// implementation of wxOwnerDrawn class
+// ============================================================================
+
+// ctor
+// ----
+wxOwnerDrawn::wxOwnerDrawn(const wxTString& str, 
+                           bool bCheckable, bool bMenuItem)
+            : m_strName(str)
+{
+  m_bCheckable   = bCheckable;
+  m_bOwnerDrawn  = FALSE;
+  m_nHeight      = 0;
+  m_nMarginWidth = ms_nLastMarginWidth;
+}
+
+#if defined(__WINDOWS__) && defined(__WIN32__)
+  uint wxOwnerDrawn::ms_nDefaultMarginWidth = GetSystemMetrics(SM_CXMENUCHECK);
+#else   // # what is the reasonable default?
+  uint wxOwnerDrawn::ms_nDefaultMarginWidth = 15;
+#endif
+
+uint wxOwnerDrawn::ms_nLastMarginWidth = ms_nDefaultMarginWidth;
+
+// drawing
+// -------
+
+// get size of the item
+bool wxOwnerDrawn::OnMeasureItem(uint *pwidth, uint *pheight)
+{
+  wxMemoryDC dc;
+  dc.SetFont(GetFont());
+
+  // ## ugly...
+  char *szStripped = new char[m_strName.Len()];
+  wxStripMenuCodes((char *)m_strName.c_str(), szStripped);
+  wxString str = szStripped;
+  delete [] szStripped;
+
+  // # without this menu items look too tightly packed (at least under Windows)
+  str += 'W'; // 'W' is typically the widest letter
+
+  dc.GetTextExtent(str, (long *)pwidth, (long *)pheight);
+  m_nHeight = *pheight;                // remember height for use in OnDrawItem
+
+  return TRUE;
+}
+
+// searching for this macro you'll find all the code where I'm using the native
+// Win32 GDI functions and not wxWindows ones. Might help to whoever decides to
+// port this code to X. (VZ)
+
+#ifdef __WIN32__
+#define   O_DRAW_NATIVE_API     // comments below explain why I use it
+#endif
+
+// draw the item
+bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus st)
+{
+  // we do nothing on focus change
+  if ( act == wxODFocusChanged )
+    return TRUE;
+
+  // wxColor <-> RGB
+  #define   ToRGB(col)  RGB(col.Red(), col.Green(), col.Blue())
+  #define   UnRGB(col)  GetRValue(col), GetGValue(col), GetBValue(col)
+
+  // set the colors
+  // --------------
+  DWORD colBack, colText;
+  if ( st & wxODSelected ) {
+    colBack = GetSysColor(COLOR_HIGHLIGHT);
+    colText = GetSysColor(COLOR_HIGHLIGHTTEXT);
+  }
+  else {
+    // fall back to default colors if none explicitly specified
+    colBack = m_colBack.Ok() ? ToRGB(m_colBack) : GetSysColor(COLOR_WINDOW);
+    colText = m_colText.Ok() ? ToRGB(m_colText) : GetSysColor(COLOR_WINDOWTEXT);
+  }
+        
+  #ifdef  O_DRAW_NATIVE_API
+    #define  hdc           (HDC)dc.GetHDC()
+    COLORREF colOldText = ::SetTextColor(hdc, colText),
+             colOldBack = ::SetBkColor(hdc, colBack);
+  #else
+    dc.SetTextForeground(wxColor(UnRGB(colText)));
+    dc.SetTextBackground(wxColor(UnRGB(colBack)));
+  #endif
+
+  // select the font and draw the text
+  // ---------------------------------
+
+  // determine where to draw and leave space for a check-mark. 
+  int x = rc.x + GetMarginWidth();
+
+  // using native API because it reckognizes '&' 
+  #ifdef  O_DRAW_NATIVE_API
+    int nPrevMode = SetBkMode(hdc, TRANSPARENT);
+    HBRUSH  hbr = CreateSolidBrush(colBack),
+            hPrevBrush = SelectObject(hdc, hbr);
+
+    RECT rectAll = { rc.GetLeft(), rc.GetTop(), rc.GetRight(), rc.GetBottom() };
+    FillRect(hdc, &rectAll, hbr);
+
+    // use default font if no font set
+    HFONT hfont;
+    if ( m_font.Ok() ) {
+      m_font.RealizeResource();
+      hfont = (HFONT)m_font.GetResourceHandle();
+    }
+    else {
+      hfont = (HFONT)::GetStockObject(SYSTEM_FONT);
+    }
+
+    HFONT hPrevFont = ::SelectObject(hdc, hfont);
+    DrawState(hdc, NULL, NULL, 
+              (LPARAM)(const char *)m_strName, m_strName.Length(), 
+              x, rc.y, rc.GetWidth(), rc.GetHeight(),
+              DST_PREFIXTEXT | ( st & wxODDisabled ? DSS_DISABLED : 0) );
+
+    (void)SelectObject(hdc, hPrevBrush);
+    (void)SelectObject(hdc, hPrevFont);
+    (void)SetBkMode(hdc, nPrevMode);
+  #else
+    dc.SetFont(GetFont());
+    dc.DrawText(m_strName, x, rc.y);
+  #endif  //O_DRAW_NATIVE_API
+
+  // draw the bitmap
+  // ---------------
+  if ( IsCheckable() && !m_bmpChecked.Ok() ) {
+    if ( st & wxODChecked ) {
+      // using native APIs for performance and simplicity
+      #ifdef  O_DRAW_NATIVE_API
+      // what goes on: DrawFrameControl creates a b/w mask, 
+      // then we copy it to screen to have right colors
+
+        // first create a monochrome bitmap in a memory DC
+      HDC hdcMem = CreateCompatibleDC(hdc);
+      HBITMAP hbmpCheck = CreateBitmap(GetMarginWidth(), m_nHeight, 1, 1, 0);
+      SelectObject(hdcMem, hbmpCheck);
+
+        // then draw a check mark into it
+      RECT rect = { 0, 0, GetMarginWidth(), m_nHeight };
+      DrawFrameControl(hdcMem, &rect, DFC_MENU, DFCS_MENUCHECK);
+
+        // finally copy it to screen DC and clean up
+      BitBlt(hdc, rc.x, rc.y, GetMarginWidth(), m_nHeight, 
+             hdcMem, 0, 0, SRCCOPY);
+      DeleteDC(hdcMem);
+      #else
+        // #### to do: perhaps using Marlett font (create equiv. font under X)
+        wxFAIL("not implemented");
+      #endif  //O_DRAW_NATIVE_API
+    }
+  }
+  else {
+    // for uncheckable item we use only the 'checked' bitmap
+    wxBitmap bmp(GetBitmap(IsCheckable() ? ((st & wxODChecked) != 0) : TRUE));
+    if ( bmp.Ok() ) {
+      wxMemoryDC dcMem(&dc);
+      dcMem.SelectObject(bmp);
+
+      // center bitmap
+      int nBmpWidth = bmp.GetWidth(),
+          nBmpHeight = bmp.GetHeight();
+
+      // there should be enough place!
+      wxASSERT((nBmpWidth <= rc.GetWidth()) && (nBmpHeight <= rc.GetHeight()));
+
+      dc.Blit(rc.x + (GetMarginWidth() - nBmpWidth) / 2, 
+              rc.y + (m_nHeight - nBmpHeight) /2, 
+              nBmpWidth, nBmpHeight, 
+              &dcMem, 0, 0, wxCOPY);
+
+      if ( st & wxODSelected ) {
+        #ifdef  O_DRAW_NATIVE_API
+          RECT rectBmp = { rc.GetLeft(), rc.GetTop(), 
+                           rc.GetLeft() + GetMarginWidth(), 
+                           rc.GetTop() + m_nHeight };
+          SetBkColor(hdc, colBack);
+          DrawEdge(hdc, &rectBmp, EDGE_RAISED, BF_SOFT | BF_RECT);
+        #else
+          // ## to write portable DrawEdge
+        #endif  //O_DRAW_NATIVE_API
+      }
+    }
+  }
+
+  #ifdef  O_DRAW_NATIVE_API
+    ::SetTextColor(hdc, colOldText);
+    ::SetBkColor(hdc, colOldBack);
+
+    #undef  hdc
+  #endif  //O_DRAW_NATIVE_API
+
+  return TRUE;
+}
+
diff --git a/src/msw/palette.cpp b/src/msw/palette.cpp
new file mode 100644
index 0000000000..1eaaa5e074
--- /dev/null
+++ b/src/msw/palette.cpp
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        palette.cpp
+// Purpose:     wxPalette
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "palette.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/palette.h"
+#endif
+
+#include <windows.h>
+
+#include "assert.h"
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
+#endif
+
+/*
+ * Palette
+ *
+ */
+
+wxPaletteRefData::wxPaletteRefData(void)
+{
+  m_hPalette = 0;
+}
+
+wxPaletteRefData::~wxPaletteRefData(void)
+{
+	if ( m_hPalette )
+		::DeleteObject((HPALETTE) m_hPalette);
+}
+
+wxPalette::wxPalette(void)
+{
+}
+
+wxPalette::wxPalette(const int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
+{
+  Create(n, red, green, blue);
+}
+
+wxPalette::~wxPalette(void)
+{
+//	FreeResource(TRUE);
+}
+
+bool wxPalette::FreeResource(bool force)
+{
+	if ( M_PALETTEDATA && M_PALETTEDATA->m_hPalette)
+	{
+      DeleteObject((HPALETTE)M_PALETTEDATA->m_hPalette);
+	}
+	return TRUE;
+}
+
+bool wxPalette::Create(const int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
+{
+  UnRef();
+
+  m_refData = new wxPaletteRefData;
+
+  NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
+                        (WORD)n * sizeof(PALETTEENTRY));
+  if (!npPal)
+    return(FALSE);
+
+  npPal->palVersion = 0x300;
+  npPal->palNumEntries = n;
+
+  int i;
+  for (i = 0; i < n; i ++)
+  {
+    npPal->palPalEntry[i].peRed = red[i];
+    npPal->palPalEntry[i].peGreen = green[i];
+    npPal->palPalEntry[i].peBlue = blue[i];
+    npPal->palPalEntry[i].peFlags = 0;
+  }
+  M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal);
+  LocalFree((HANDLE)npPal);
+  return TRUE;
+}
+
+int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
+{
+  if ( !m_refData )
+	return FALSE;
+
+  return ::GetNearestPaletteIndex((HPALETTE) M_PALETTEDATA->m_hPalette, PALETTERGB(red, green, blue));
+}
+
+bool wxPalette::GetRGB(const int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
+{
+  if ( !m_refData )
+	return FALSE;
+
+  if (index < 0 || index > 255)
+         return FALSE;
+
+  PALETTEENTRY entry;
+  if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry))
+  {
+         *red = entry.peRed;
+         *green = entry.peGreen;
+         *blue = entry.peBlue;
+         return TRUE;
+  } else
+         return FALSE;
+}
+
+void wxPalette::SetHPALETTE(WXHPALETTE pal)
+{
+	if ( !m_refData )
+		m_refData = new wxPaletteRefData;
+
+    M_PALETTEDATA->m_hPalette = pal;
+}
+
diff --git a/src/msw/pen.cpp b/src/msw/pen.cpp
new file mode 100644
index 0000000000..12dd825ec7
--- /dev/null
+++ b/src/msw/pen.cpp
@@ -0,0 +1,457 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        pen.cpp
+// Purpose:     wxPen
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "pen.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/list.h"
+#include "wx/utils.h"
+#include "wx/app.h"
+#include "wx/pen.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "assert.h"
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
+#endif
+
+wxPenRefData::wxPenRefData(void)
+{
+//  m_stipple = NULL ;
+  m_style = wxSOLID;
+  m_width = 1;
+  m_join = wxJOIN_ROUND ;
+  m_cap = wxCAP_ROUND ;
+  m_nbDash = 0 ;
+  m_dash = 0 ;
+  m_hPen = 0;
+}
+
+wxPenRefData::~wxPenRefData(void)
+{
+	if ( m_hPen )
+		::DeleteObject((HPEN) m_hPen);
+}
+
+// Pens
+
+wxPen::wxPen(void)
+{
+  if ( wxThePenList )
+    wxThePenList->AddPen(this);
+}
+
+wxPen::~wxPen()
+{
+    if (wxThePenList)
+        wxThePenList->RemovePen(this);
+}
+
+// Should implement Create
+wxPen::wxPen(const wxColour& col, const int Width, const int Style)
+{
+  m_refData = new wxPenRefData;
+
+  M_PENDATA->m_colour = col;
+//  M_PENDATA->m_stipple = NULL;
+  M_PENDATA->m_width = Width;
+  M_PENDATA->m_style = Style;
+  M_PENDATA->m_join = wxJOIN_ROUND ;
+  M_PENDATA->m_cap = wxCAP_ROUND ;
+  M_PENDATA->m_nbDash = 0 ;
+  M_PENDATA->m_dash = 0 ;
+  M_PENDATA->m_hPen = 0 ;
+
+#ifndef __WIN32__
+  // In Windows, only a pen of width = 1 can be dotted or dashed!
+  if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
+      (Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
+      (Style == wxUSER_DASH))
+    M_PENDATA->m_width = 1;
+#else
+/***
+  DWORD vers = GetVersion() ;
+  WORD  high = HIWORD(vers) ; // high bit=0 for NT, 1 for Win32s
+  // Win32s doesn't support wide dashed pens
+
+  if ((high&0x8000)!=0)
+***/
+  if (wxGetOsVersion()==wxWIN32S)
+  {
+    // In Windows, only a pen of width = 1 can be dotted or dashed!
+    if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
+        (Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
+        (Style == wxUSER_DASH))
+      M_PENDATA->m_width = 1;
+  }
+#endif 
+  RealizeResource();
+
+  if ( wxThePenList )
+    wxThePenList->AddPen(this);
+}
+
+wxPen::wxPen(const wxBitmap& stipple, const int Width)
+{
+  m_refData = new wxPenRefData;
+
+//  M_PENDATA->m_colour = col;
+  M_PENDATA->m_stipple = stipple;
+  M_PENDATA->m_width = Width;
+  M_PENDATA->m_style = wxSTIPPLE;
+  M_PENDATA->m_join = wxJOIN_ROUND ;
+  M_PENDATA->m_cap = wxCAP_ROUND ;
+  M_PENDATA->m_nbDash = 0 ;
+  M_PENDATA->m_dash = 0 ;
+  M_PENDATA->m_hPen = 0 ;
+
+  RealizeResource();
+
+  if ( wxThePenList )
+    wxThePenList->AddPen(this);
+}
+
+wxPen::wxPen(const wxString& col, const int Width, const int Style)
+{
+  m_refData = new wxPenRefData;
+
+  M_PENDATA->m_colour = col;
+//  M_PENDATA->m_stipple = NULL ;
+  M_PENDATA->m_width = Width;
+  M_PENDATA->m_style = Style;
+  M_PENDATA->m_join = wxJOIN_ROUND ;
+  M_PENDATA->m_cap = wxCAP_ROUND ;
+  M_PENDATA->m_nbDash = 0 ;
+  M_PENDATA->m_dash = 0 ;
+  M_PENDATA->m_hPen = 0 ;
+
+  // In Windows, only a pen of width = 1 can be dotted or dashed!
+  if ((Style == wxDOT) || (Style == wxLONG_DASH) || (Style == wxSHORT_DASH) || (Style == wxDOT_DASH))
+    M_PENDATA->m_width = 1;
+    
+  RealizeResource();
+
+  if ( wxThePenList )
+    wxThePenList->AddPen(this);
+}
+
+bool wxPen::RealizeResource(void)
+{
+  if (M_PENDATA && (M_PENDATA->m_hPen == 0))
+  {
+    if (M_PENDATA->m_style==wxTRANSPARENT)
+    {
+      M_PENDATA->m_hPen = (WXHPEN) ::GetStockObject(NULL_PEN);
+      return TRUE;
+    }
+
+    COLORREF ms_colour = 0 ;
+    ms_colour = M_PENDATA->m_colour.GetPixel() ;
+
+    // Join style, Cap style, Pen Stippling only on Win32.
+    // Currently no time to find equivalent on Win3.1, sorry
+    // [if such equiv exist!!]
+#ifdef __WIN32__
+    if (M_PENDATA->m_join==wxJOIN_ROUND        &&
+        M_PENDATA->m_cap==wxCAP_ROUND          &&
+        M_PENDATA->m_style!=wxUSER_DASH        &&
+        M_PENDATA->m_style!=wxSTIPPLE
+       )
+      M_PENDATA->m_hPen = (WXHPEN) CreatePen(wx2msPenStyle(M_PENDATA->m_style), M_PENDATA->m_width, ms_colour);
+    else
+    {
+      DWORD ms_style = PS_GEOMETRIC|wx2msPenStyle(M_PENDATA->m_style) ;
+
+      LOGBRUSH logb ;
+
+      switch(M_PENDATA->m_join)
+      {
+        case wxJOIN_BEVEL: ms_style |= PS_JOIN_BEVEL ; break ;
+        case wxJOIN_MITER: ms_style |= PS_JOIN_MITER ; break ;
+        default:
+        case wxJOIN_ROUND: ms_style |= PS_JOIN_ROUND ; break ;
+      }
+
+      switch(M_PENDATA->m_cap)
+      {
+        case wxCAP_PROJECTING: ms_style |= PS_ENDCAP_SQUARE ; break ;
+        case wxCAP_BUTT:       ms_style |= PS_ENDCAP_FLAT ;   break ;
+        default:
+        case wxCAP_ROUND:      ms_style |= PS_ENDCAP_ROUND ;  break ;
+      }
+
+      switch(M_PENDATA->m_style)
+      {
+        case wxSTIPPLE:
+          logb.lbStyle = BS_PATTERN ;
+          if (M_PENDATA->m_stipple.Ok())
+            logb.lbHatch = (LONG)M_PENDATA->m_stipple.GetHBITMAP() ;
+          else
+            logb.lbHatch = (LONG)0 ;
+        break ;
+        case wxBDIAGONAL_HATCH:
+          logb.lbStyle = BS_HATCHED ;
+          logb.lbHatch = HS_BDIAGONAL ;
+        break ;
+        case wxCROSSDIAG_HATCH:
+          logb.lbStyle = BS_HATCHED ;
+          logb.lbHatch = HS_DIAGCROSS ;
+        break ;
+        case wxFDIAGONAL_HATCH:
+          logb.lbStyle = BS_HATCHED ;
+          logb.lbHatch = HS_FDIAGONAL ;
+        break ;
+        case wxCROSS_HATCH:
+          logb.lbStyle = BS_HATCHED ;
+          logb.lbHatch = HS_CROSS ;
+        break ;
+        case wxHORIZONTAL_HATCH:
+          logb.lbStyle = BS_HATCHED ;
+          logb.lbHatch = HS_HORIZONTAL ;
+        break ;
+        case wxVERTICAL_HATCH:
+          logb.lbStyle = BS_HATCHED ;
+          logb.lbHatch = HS_VERTICAL ;
+        break ;
+        default:
+          logb.lbStyle = BS_SOLID ;
+        break ;
+      }
+      logb.lbColor = ms_colour ;
+      wxDash *real_dash ;
+      if (M_PENDATA->m_style==wxUSER_DASH && M_PENDATA->m_nbDash && M_PENDATA->m_dash)
+      {
+        real_dash = new wxDash[M_PENDATA->m_nbDash] ;
+        int i;
+        for (i=0;i<M_PENDATA->m_nbDash;i++)
+          real_dash[i] = M_PENDATA->m_dash[i] * M_PENDATA->m_width ;
+      }
+      else
+        real_dash = 0 ;
+
+      // Win32s doesn't have ExtCreatePen function...
+      if (wxGetOsVersion()==wxWINDOWS_NT || wxGetOsVersion()==wxWIN95)
+        M_PENDATA->m_hPen = (WXHPEN) ExtCreatePen(ms_style,M_PENDATA->m_width,&logb,
+                            M_PENDATA->m_style==wxUSER_DASH ? M_PENDATA->m_nbDash:0, (const DWORD *)real_dash);
+      else
+        M_PENDATA->m_hPen = (WXHPEN) CreatePen(wx2msPenStyle(M_PENDATA->m_style), M_PENDATA->m_width, ms_colour);
+
+      if (real_dash)
+        delete [] real_dash ;
+    }
+#else
+    M_PENDATA->m_hPen = (WXHPEN) CreatePen(wx2msPenStyle(M_PENDATA->m_style), M_PENDATA->m_width, ms_colour);
+#endif
+#ifdef DEBUG_CREATE
+    if (M_PENDATA->m_hPen==0)
+      wxError("Cannot create pen","Internal error") ;
+#endif
+    return TRUE;
+  }
+  return FALSE;
+}
+
+WXHANDLE wxPen::GetResourceHandle(void)
+{
+	if ( !M_PENDATA )
+		return 0;
+	else
+  		return (WXHANDLE)M_PENDATA->m_hPen;
+}
+
+bool wxPen::FreeResource(bool force)
+{
+  if (M_PENDATA && (M_PENDATA->m_hPen != 0))
+  {
+    DeleteObject((HPEN) M_PENDATA->m_hPen);
+    M_PENDATA->m_hPen = 0;
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+/*
+bool wxPen::UseResource(void)
+{
+  IncrementResourceUsage();
+  return TRUE;
+}
+
+bool wxPen::ReleaseResource(void)
+{
+  DecrementResourceUsage();
+  return TRUE;
+}
+*/
+
+bool wxPen::IsFree(void)
+{
+  return (M_PENDATA && M_PENDATA->m_hPen == 0);
+}
+
+void wxPen::SetColour(const wxColour& col)
+{
+  if ( !M_PENDATA )
+	m_refData = new wxPenRefData;
+
+  M_PENDATA->m_colour = col;
+  
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxPen::SetColour(const wxString& col)
+{
+  if ( !M_PENDATA )
+	m_refData = new wxPenRefData;
+
+  M_PENDATA->m_colour = col;
+  
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxPen::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
+{
+  if ( !M_PENDATA )
+	m_refData = new wxPenRefData;
+
+  M_PENDATA->m_colour.Set(r, g, b);
+  
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxPen::SetWidth(const int Width)
+{
+  if ( !M_PENDATA )
+	m_refData = new wxPenRefData;
+
+  M_PENDATA->m_width = Width;
+
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxPen::SetStyle(const int Style)
+{
+  if ( !M_PENDATA )
+	m_refData = new wxPenRefData;
+
+  M_PENDATA->m_style = Style;
+
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxPen::SetStipple(const wxBitmap& Stipple)
+{
+  if ( !M_PENDATA )
+	m_refData = new wxPenRefData;
+
+  M_PENDATA->m_stipple = Stipple;
+  M_PENDATA->m_style = wxSTIPPLE;
+  
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxPen::SetDashes(const int nb_dashes, const wxDash *Dash)
+{
+  if ( !M_PENDATA )
+	m_refData = new wxPenRefData;
+
+  M_PENDATA->m_nbDash = nb_dashes;
+  M_PENDATA->m_dash = (wxDash *)Dash;
+  
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxPen::SetJoin(const int Join)
+{
+  if ( !M_PENDATA )
+	m_refData = new wxPenRefData;
+
+  M_PENDATA->m_join = Join;
+
+  if (FreeResource())
+    RealizeResource();
+}
+
+void wxPen::SetCap(const int Cap)
+{
+  if ( !M_PENDATA )
+	m_refData = new wxPenRefData;
+
+  M_PENDATA->m_cap = Cap;
+
+  if (FreeResource())
+    RealizeResource();
+}
+
+int wx2msPenStyle(int wx_style)
+{
+  int cstyle;
+/***
+#ifdef __WIN32__
+  DWORD vers = GetVersion() ;
+  WORD  high = HIWORD(vers) ; // high bit=0 for NT, 1 for Win32s
+#endif
+***/
+  switch (wx_style)
+  {
+    case wxDOT:
+      cstyle = PS_DOT;
+      break;
+    case wxSHORT_DASH:
+    case wxLONG_DASH:
+      cstyle = PS_DASH;
+      break;
+    case wxTRANSPARENT:
+      cstyle = PS_NULL;
+      break;
+    case wxUSER_DASH:
+      // User dash style not supported on Win3.1, sorry...
+#ifdef __WIN32__
+      // Win32s doesn't have PS_USERSTYLE
+/***
+      if ((high&0x8000)==0)
+***/
+      if (wxGetOsVersion()==wxWINDOWS_NT)
+        cstyle = PS_USERSTYLE ;
+      else
+        cstyle = PS_DOT ; // We must make a choice... This is mine!
+#else
+      cstyle = PS_DASH ;
+#endif
+      break ;
+    case wxSOLID:
+    default:
+      cstyle = PS_SOLID;
+      break;
+  }
+  return cstyle;
+}
+
diff --git a/src/msw/penwin.cpp b/src/msw/penwin.cpp
new file mode 100644
index 0000000000..6fca0c5cda
--- /dev/null
+++ b/src/msw/penwin.cpp
@@ -0,0 +1,120 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        penwin.cpp
+// Purpose:     PenWindows code
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#define IN_WX_MAIN_CPP
+#include "wx/wxprec.h"
+
+#if defined(__BORLANDC__)
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#if USE_PENWINDOWS
+
+#ifdef __BORLANDC__
+#define RPA_DEFAULT 1
+#else
+#include <penwin.h>
+#endif
+
+HANDLE s_hPenWin = (HANDLE)NULL;
+typedef void (CALLBACK * PENREGPROC)(WORD,BOOL);
+
+// The routine below allows Windows applications (binaries) to
+// support Pen input when running under Microsoft Windows for
+// Pen Computing 1.0 without need of the PenPalete.
+//
+// Should masked edit functions be added to wxWindows we would
+// be a new class of functions to support BEDIT controls.
+//
+// (The function is a NOOP for native Windows-NT)
+#ifndef __WIN32__
+static  void (CALLBACK * RegPenApp) (WORD, BOOL) = NULL;
+#endif
+
+// Where is this called??
+void wxEnablePenAppHooks (bool hook)
+{
+#ifndef __WIN32__
+  if (hook)
+    {
+      if (s_hPenWin)
+	return;
+
+      ///////////////////////////////////////////////////////////////////////
+      // If running on a Pen Windows system, register this app so all
+      // EDIT controls in dialogs are replaced by HEDIT controls.
+      if ((s_hPenWin = (HANDLE)GetSystemMetrics (SM_PENWINDOWS)) != (HANDLE) NULL)
+	{
+	  // We do this fancy GetProcAddress simply because we don't
+	  // know if we're running Pen Windows.
+	  if ((RegPenApp = (PENREGPROC)GetProcAddress (s_hPenWin, "RegisterPenApp")) != NULL)
+	    (*RegPenApp) (RPA_DEFAULT, TRUE);
+	}
+    }
+  else
+    {
+      ///////////////////////////////////////////////////////////////////////
+      // If running on a Pen Windows system, unregister
+      if (s_hPenWin)
+	{
+	  // Unregister this app 
+	  if (RegPenApp != NULL)
+	    (*RegPenApp) (RPA_DEFAULT, FALSE);
+	  s_hPenWin = (HANDLE) NULL;
+	}
+    }
+#endif	/* ! Windows-NT */
+}
+
+#endif
+  // End USE_PENWINDOWS
+
+void wxRegisterPenWin(void)
+{
+#if USE_PENWINDOWS
+///////////////////////////////////////////////////////////////////////
+// If running on a Pen Windows system, register this app so all
+// EDIT controls in dialogs are replaced by HEDIT controls.
+// (Notice the CONTROL statement in the RC file is "EDIT",
+// RegisterPenApp will automatically change that control to
+// an HEDIT.
+  if ((s_hPenWin = (HANDLE)GetSystemMetrics(SM_PENWINDOWS)) != (HANDLE)NULL) {
+    // We do this fancy GetProcAddress simply because we don't
+    // know if we're running Pen Windows.
+   if ( (RegPenApp = (void (CALLBACK *)(WORD, BOOL))GetProcAddress(s_hPenWin, "RegisterPenApp"))!= NULL)
+     (*RegPenApp)(RPA_DEFAULT, TRUE);
+  }
+///////////////////////////////////////////////////////////////////////
+#endif
+}
+
+void wxCleanUpPenWin(void)
+{
+#if USE_PENWINDOWS
+  if (s_hPenWin) {
+    // Unregister this app 
+    if (RegPenApp != NULL)
+	(*RegPenApp)(RPA_DEFAULT, FALSE);
+  }
+#endif
+}
+
diff --git a/src/msw/pnghand.cpp b/src/msw/pnghand.cpp
new file mode 100644
index 0000000000..554e1cca16
--- /dev/null
+++ b/src/msw/pnghand.cpp
@@ -0,0 +1,769 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        pnghand.cpp
+// Purpose:     Implements a PNG reader class + handler
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "pngread.h"
+#pragma implementation "pnghand.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fstream.h>
+#include <windows.h>
+#include <wx/msw/pngread.h>
+#include <wx/msw/dibutils.h>
+
+extern "C" {
+#include "png.h"
+}
+
+extern "C" void png_read_init PNGARG((png_structp png_ptr));
+extern "C" void png_write_init PNGARG((png_structp png_ptr));
+
+#ifndef GlobalAllocPtr
+#define     GlobalPtrHandle(lp)         \
+                ((HGLOBAL)GlobalHandle(lp))
+
+#define     GlobalLockPtr(lp)                \
+                ((BOOL)GlobalLock(GlobalPtrHandle(lp)))
+#define     GlobalUnlockPtr(lp)      \
+                GlobalUnlock(GlobalPtrHandle(lp))
+
+#define     GlobalAllocPtr(flags, cb)        \
+                (GlobalLock(GlobalAlloc((flags), (cb))))
+#define     GlobalReAllocPtr(lp, cbNew, flags)       \
+                (GlobalUnlockPtr(lp), GlobalLock(GlobalReAlloc(GlobalPtrHandle(lp) , (cbNew), (flags))))
+#define     GlobalFreePtr(lp)                \
+                (GlobalUnlockPtr(lp), (BOOL)GlobalFree(GlobalPtrHandle(lp)))
+#endif
+
+
+void
+ima_png_error(png_struct *png_ptr, char *message)
+{
+//        wxMessageBox(message, "PNG error");
+
+	longjmp(png_ptr->jmpbuf, 1);
+}
+
+
+// static wxGifReaderIter* iter;
+wxPalette *wxCopyPalette(const wxPalette *cmap);
+
+wxPNGReader::wxPNGReader(void)
+{
+  filetype = 0;
+  RawImage = NULL;  		//  Image data
+
+  Width = 0; Height = 0;   		//  Dimensions
+  Depth = 0;	 				// (bits x pixel)
+  ColorType = 0;				// Bit 1 = Palette used
+									// Bit 2 = Color used
+									// Bit 3 = Alpha used
+
+  EfeWidth = 0;	 			// Efective Width
+
+  lpbi = NULL;
+  bgindex = -1;
+  Palette = 0;
+  imageOK = FALSE;
+}
+
+wxPNGReader::wxPNGReader ( char* ImageFileName )
+{
+  imageOK = FALSE;
+  filetype = 0;
+  RawImage = NULL;  		//  Image data
+
+  Width = 0; Height = 0;   		//  Dimensions
+  Depth = 0;	 				// (bits x pixel)
+  ColorType = 0;				// Bit 1 = Palette used
+									// Bit 2 = Color used
+									// Bit 3 = Alpha used
+
+  EfeWidth = 0;	 			// Efective Width
+
+  lpbi = NULL;
+  bgindex = -1;
+  Palette = 0;
+
+  imageOK = ReadFile (ImageFileName);
+}
+
+void
+wxPNGReader::Create(int width, int height, int depth, int colortype)
+{
+  Width = width; Height = height; Depth = depth;
+  ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0);
+
+  if (lpbi)  {
+	 GlobalFreePtr(lpbi);
+//	 delete Palette;
+  }
+  RawImage = 0;
+  Palette = 0;
+  if (lpbi = DibCreate(Depth, Width, Height))  {
+		RawImage = (ImagePointerType)DibPtr(lpbi);
+		EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
+        imageOK = TRUE;
+  }
+}
+
+wxPNGReader::~wxPNGReader ( )
+{
+  if (lpbi)  {
+	 GlobalFreePtr(lpbi);
+	 delete Palette;
+  }
+}
+
+
+int wxPNGReader::GetIndex(int x, int y)
+{
+  if (!Inside(x, y) || (Depth>8)) return -1;
+
+  ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+  int index = (int)(*ImagePointer);
+  return index;
+}
+
+bool wxPNGReader::GetRGB(int x, int y, byte* r, byte* g, byte* b)
+{
+  if (!Inside(x, y)) return FALSE;
+
+  if (Palette) {
+	 return Palette->GetRGB(GetIndex(x, y), r, g, b);
+/*	 PALETTEENTRY entry;
+	 ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry);
+	 *r = entry.peRed;
+	 *g = entry.peGreen;
+	 *b = entry.peBlue;  */
+  } else {
+	 ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+	 *b = ImagePointer[0];
+	 *g = ImagePointer[1];
+	 *r = ImagePointer[2];
+  }
+  return TRUE;
+}
+
+
+bool wxPNGReader::SetIndex(int x, int y, int index)
+{
+  if (!Inside(x, y) || (Depth>8)) return FALSE;
+
+  ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+  *ImagePointer = index;
+
+  return TRUE;
+}
+
+bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b)
+{
+  if (!Inside(x, y)) return FALSE;
+
+  if (ColorType & COLORTYPE_PALETTE)
+  {
+	 if (!Palette) return FALSE;
+	 SetIndex(x, y, Palette->GetPixel(r, g, b));
+
+  } else {
+	 ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
+	 ImagePointer[0] = b;
+	 ImagePointer[1] = g;
+	 ImagePointer[2] = r;
+  }
+
+  return TRUE;
+}
+
+bool wxPNGReader::SetPalette(wxPalette* colourmap)
+{
+  if (!colourmap)
+	 return FALSE;
+  ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
+  Palette = colourmap;
+  return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
+}
+
+bool
+wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
+{
+  Palette = new wxPalette();
+  if (!Palette)
+	 return FALSE;
+
+  if (!g) g = r;
+  if (!b) b = g;
+  Palette->Create(n, r, g, b);
+  ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
+  return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
+}
+
+bool
+wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
+{
+  Palette = new wxPalette();
+  if (!Palette)
+	 return FALSE;
+
+  byte r[256], g[256], b[256];
+
+  for(int i=0; i<n; i++)
+  {
+	 r[i] = rgb_struct[i].red;
+	 g[i] = rgb_struct[i].green;
+	 b[i] = rgb_struct[i].blue;
+  }
+  // Added by JACS copying from Andrew Davison's additions
+  // to GIF-reading code
+  // Make transparency colour black...
+  if (bgindex != -1)
+    r[bgindex] = g[bgindex] = b[bgindex] = 0;
+
+  Palette->Create(n, r, g, b);
+  ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
+  return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
+}
+
+void wxPNGReader::NullData()
+{
+  lpbi = NULL;
+  Palette = NULL;
+}
+
+wxBitmap* wxPNGReader::GetBitmap(void)
+{
+    wxBitmap *bitmap = new wxBitmap;
+    if ( InstantiateBitmap(bitmap) )
+        return bitmap;
+    else
+    {
+        delete bitmap;
+        return NULL;
+    }
+}
+
+bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap)
+{
+	HDC dc = ::CreateCompatibleDC(NULL);
+
+	if (dc)
+	{
+        // tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it
+        // is a memory dc that must have a bitmap selected into it)
+        HDC dc2 = GetDC(NULL);
+        HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight());
+        ReleaseDC(NULL, dc2);
+        HBITMAP oldBitmap = ::SelectObject(dc, tmpBitmap);
+
+        if ( Palette )
+        {
+            HPALETTE oldPal = ::SelectPalette(dc, (HPALETTE) Palette->GetHPALETTE(), FALSE);
+		    ::RealizePalette(dc);
+        }
+
+		HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi,
+		    CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS);
+
+        ::SelectPalette(dc, NULL, TRUE);
+        ::SelectObject(dc, oldBitmap);
+        ::DeleteObject(tmpBitmap);
+        ::DeleteDC(dc);
+
+        if ( hBitmap )
+        {
+          bitmap->SetHBITMAP((WXHBITMAP) hBitmap);
+          bitmap->SetWidth(GetWidth());
+          bitmap->SetHeight(GetHeight());
+          bitmap->SetDepth(GetDepth());
+          if ( GetDepth() > 1 && Palette )
+            bitmap->SetPalette(*Palette);
+          bitmap->SetOk(TRUE);
+
+
+          // Make a mask if appropriate
+          if ( bgindex > -1 )
+          {
+            wxMask *mask = CreateMask();
+            bitmap->SetMask(mask);
+          }
+		  return TRUE;
+        }
+        else
+        {
+          return FALSE;
+        }
+	}
+	else
+    {
+		return FALSE;
+    }
+}
+
+wxPalette *wxCopyPalette(const wxPalette *cmap)
+{
+  // To get number of entries...
+  WORD count = 0;
+  ::GetObject((HPALETTE) cmap->GetHPALETTE(), sizeof(WORD), &count);
+  
+  LOGPALETTE* logPal = (LOGPALETTE*)
+		 new BYTE[sizeof(LOGPALETTE) + count*sizeof(PALETTEENTRY)];
+  logPal->palVersion = 0x300;
+  logPal->palNumEntries = count;
+  ::GetPaletteEntries((HPALETTE) cmap->GetHPALETTE(), 0, count, logPal->palPalEntry);
+  
+  HPALETTE hPalette = ::CreatePalette(logPal);
+  delete[] logPal;
+
+  wxPalette *newCmap = new wxPalette;
+  newCmap->SetHPALETTE((WXHPALETTE) hPalette);
+  return newCmap;
+}
+
+wxMask *wxPNGReader::CreateMask(void)
+{
+    HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL);
+
+	HDC dc = ::CreateCompatibleDC(NULL);
+    HBITMAP oldBitmap = ::SelectObject(dc, hBitmap);
+
+    int bgIndex = GetBGIndex();
+
+    int x,y;
+
+    for (x=0; x<GetWidth(); x++)
+    {
+        for (y=0; y<GetHeight(); y++)
+        {
+            int index = GetIndex(x, y);
+            if ( index == bgIndex )
+                ::SetPixel(dc, x, GetHeight() - y - 1, RGB(0, 0, 0));
+            else
+                ::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255));
+
+	    }
+    }
+    ::SelectObject(dc, oldBitmap);
+    wxMask *mask = new wxMask;
+    mask->SetMaskBitmap((WXHBITMAP) hBitmap);
+    return mask;
+}
+
+bool wxPNGReader::ReadFile(char * ImageFileName)
+{
+  int number_passes;
+
+  if (ImageFileName)
+	 strcpy(filename, ImageFileName);
+
+	FILE *fp;
+	png_struct *png_ptr;
+   png_info *info_ptr;
+	wxPNGReaderIter iter(this);
+
+	/* open the file */
+	fp = fopen(filename, "rb");
+	if (!fp)
+		return FALSE;
+
+	/* allocate the necessary structures */
+	png_ptr = new (png_struct);
+	if (!png_ptr)
+	{
+		fclose(fp);
+		return FALSE;
+	}
+
+	info_ptr = new (png_info);
+	if (!info_ptr)
+	{
+		fclose(fp);
+		delete(png_ptr);
+		return FALSE;
+	}
+	/* set error handling */
+	if (setjmp(png_ptr->jmpbuf))
+	{
+		png_read_destroy(png_ptr, info_ptr, (png_info *)0);
+		fclose(fp);
+		delete(png_ptr);
+		delete(info_ptr);
+
+		/* If we get here, we had a problem reading the file */
+		return FALSE;
+	}
+        //png_set_error(ima_png_error, NULL);
+
+	/* initialize the structures, info first for error handling */
+	png_info_init(info_ptr);
+	png_read_init(png_ptr);
+
+	/* set up the input control */
+	png_init_io(png_ptr, fp);
+
+	/* read the file information */
+	png_read_info(png_ptr, info_ptr);
+
+	/* allocate the memory to hold the image using the fields
+		of png_info. */
+	png_color_16 my_background={ 0, 31, 127, 255, 0 };
+
+	if (info_ptr->valid & PNG_INFO_bKGD)
+    {
+		png_set_background(png_ptr, &(info_ptr->background),
+			PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
+        if ( info_ptr->num_palette > 0 )
+            bgindex = info_ptr->background.index;
+    }
+	else   {
+		png_set_background(png_ptr, &my_background,
+			PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+
+        // Added by JACS: guesswork!
+        if ( info_ptr->num_trans != 0 )
+            bgindex = info_ptr->num_trans - 1 ;
+	 }
+
+	/* tell libpng to strip 16 bit depth files down to 8 bits */
+	if (info_ptr->bit_depth == 16)
+		png_set_strip_16(png_ptr);
+
+	int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24;
+	Create(info_ptr->width, info_ptr->height, pixel_depth,
+		info_ptr->color_type);
+
+	if (info_ptr->num_palette>0)
+    {
+	    SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette);
+    }
+
+	int row_stride = info_ptr->width * ((pixel_depth+7)>>3);
+ //	printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride);
+//	printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth);
+
+	byte *row_pointers = new byte[row_stride];
+
+	/* turn on interlace handling */
+	if (info_ptr->interlace_type)
+		number_passes = png_set_interlace_handling(png_ptr);
+	else
+		number_passes = 1;
+//	printf("NP = %d ", number_passes);
+
+	for (int pass=0; pass< number_passes; pass++) {
+	iter.upset();
+	int y=0;
+	do	{
+//	  (unsigned char *)iter.GetRow();
+	  if (info_ptr->interlace_type)  {
+		 if (pass>0)
+			iter.GetRow(row_pointers, row_stride);
+		 png_read_row(png_ptr, row_pointers, NULL);
+	  }
+	  else
+		 png_read_row(png_ptr, row_pointers, NULL);
+
+	  iter.SetRow(row_pointers, row_stride);
+	  y++;
+	} while(iter.PrevRow());
+//	printf("Y=%d ",y);
+	}
+	delete[] row_pointers;
+
+	/* read the rest of the file, getting any additional chunks
+		in info_ptr */
+	png_read_end(png_ptr, info_ptr);
+
+	/* clean up after the read, and free any memory allocated */
+	png_read_destroy(png_ptr, info_ptr, (png_info *)0);
+
+	/* free the structures */
+	delete(png_ptr);
+	delete(info_ptr);
+
+	/* close the file */
+	fclose(fp);
+
+	/* that's it */
+	return TRUE;
+}
+
+
+/* write a png file */
+
+bool wxPNGReader::SaveFile(char * ImageFileName)
+{
+  if (ImageFileName)
+	 strcpy(filename, ImageFileName);
+
+  wxPNGReaderIter iter(this);
+  FILE *fp;
+   png_struct *png_ptr;
+	png_info *info_ptr;
+
+   /* open the file */
+	fp = fopen(filename, "wb");
+	if (!fp)
+		return FALSE;
+
+	/* allocate the necessary structures */
+	png_ptr = new (png_struct);
+	if (!png_ptr)
+	{
+		fclose(fp);
+		return FALSE;
+	}
+
+	info_ptr = new (png_info);
+	if (!info_ptr)
+	{
+		fclose(fp);
+		delete(png_ptr);
+		return FALSE;
+	}
+
+	/* set error handling */
+	if (setjmp(png_ptr->jmpbuf))
+	{
+		png_write_destroy(png_ptr);
+		fclose(fp);
+		delete(png_ptr);
+		delete(info_ptr);
+
+		/* If we get here, we had a problem reading the file */
+		return FALSE;
+	}
+        //png_set_error(ima_png_error, NULL);
+
+//	printf("writig pg %s ", filename);
+   /* initialize the structures */
+	png_info_init(info_ptr);
+	png_write_init(png_ptr);
+            
+	int row_stride = GetWidth() * ((GetDepth()+7)>>3);
+	/* set up the output control */
+   png_init_io(png_ptr, fp);
+
+	/* set the file information here */
+	info_ptr->width = GetWidth();
+	info_ptr->height = GetHeight();
+	info_ptr->pixel_depth = GetDepth();
+	info_ptr->channels = (GetDepth()>8) ? 3: 1;
+	info_ptr->bit_depth = GetDepth()/info_ptr->channels;
+	info_ptr->color_type = GetColorType();
+	info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0;
+	info_ptr->valid = 0;
+	info_ptr->rowbytes = row_stride;
+
+
+// printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels);
+	/* set the palette if there is one */
+	if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette())
+	{
+//	  printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
+	  info_ptr->valid |= PNG_INFO_PLTE;
+	  info_ptr->palette = new png_color[256];
+	  info_ptr->num_palette = 256;
+	  for (int i=0; i<256; i++)
+		 GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
+	}
+//	  printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
+
+
+   /* optional significant bit chunk */
+//   info_ptr->valid |= PNG_INFO_sBIT;
+//   info_ptr->sig_bit = true_bit_depth;
+
+	/* optional gamma chunk */
+//   info_ptr->valid |= PNG_INFO_gAMA;
+//   info_ptr->gamma = gamma;
+
+	/* other optional chunks */
+
+   /* write the file information */
+   png_write_info(png_ptr, info_ptr);
+
+   /* set up the transformations you want.  Note that these are
+      all optional.  Only call them if you want them */
+
+	/* shift the pixels up to a legal bit depth and fill in
+      as appropriate to correctly scale the image */
+//   png_set_shift(png_ptr, &(info_ptr->sig_bit));
+
+	/* pack pixels into bytes */
+//   png_set_packing(png_ptr);
+
+	/* flip bgr pixels to rgb */
+//   png_set_bgr(png_ptr);
+
+   /* swap bytes of 16 bit files to most significant bit first */
+//   png_set_swap(png_ptr);
+
+   /* get rid of filler bytes, pack rgb into 3 bytes */
+//   png_set_rgbx(png_ptr);
+
+/* If you are only writing one row at a time, this works */
+
+	byte *row_pointers = new byte[row_stride];
+  	iter.upset();
+	do	{
+//	  (unsigned char *)iter.GetRow();
+	  iter.GetRow(row_pointers, row_stride);
+	  png_write_row(png_ptr, row_pointers);
+	} while(iter.PrevRow());
+        
+        delete[] row_pointers;
+
+/* write the rest of the file */
+   png_write_end(png_ptr, info_ptr);
+
+	/* clean up after the write, and free any memory allocated */
+   png_write_destroy(png_ptr);
+
+   /* if you malloced the palette, free it here */
+   if (info_ptr->palette)
+		delete[] (info_ptr->palette);
+
+	/* free the structures */
+	delete(png_ptr);
+	delete(info_ptr);
+
+	/* close the file */
+	fclose(fp);
+
+	/* that's it */
+	return TRUE;
+}
+
+static int Power(int x, int y)
+{
+    int z = 1;
+    int i;
+    for ( i = 0; i < y; i++)
+    {
+        z *= x;
+    }
+    return z;
+}
+
+static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
+  'C', 'D', 'E', 'F' };
+
+static void DecToHex(int dec, char *buf)
+{
+  int firstDigit = (int)(dec/16.0);
+  int secondDigit = (int)(dec - (firstDigit*16.0));
+  buf[0] = hexArray[firstDigit];
+  buf[1] = hexArray[secondDigit];
+  buf[2] = 0;
+}
+ 
+
+bool wxPNGReader::SaveXPM(char *filename, char *name)
+{
+    char nameStr[256];
+    if ( name )
+        strcpy(nameStr, name);
+    else
+    {
+        strcpy(nameStr, filename);
+        wxStripExtension(nameStr);
+    }
+
+    if ( GetDepth() > 4 )
+    {
+        // Only a depth of 4 and below allowed
+        return FALSE;
+    }
+
+    if ( !GetPalette() )
+        return FALSE;
+
+    ofstream str(filename);
+    if ( str.bad() )
+        return FALSE;
+
+    int noColours = Power(2, GetDepth());
+
+    // Output header
+    str << "/* XPM */\n";
+    str << "static char * " << nameStr << "_xpm[] = {\n";
+    str << "\"" << GetWidth() << " " << GetHeight() << " " << noColours << " 1\",\n";
+
+    // Output colourmap
+    int base = 97 ; // start from 'a'
+
+    unsigned char red, green, blue;
+    char hexBuf[4];
+    int i;
+    for ( i = 0; i < noColours; i ++)
+    {
+        str << "\"" << (char)(base + i) << "      c #";
+        GetPalette()->GetRGB(i, &red, &green, &blue);
+        DecToHex(red, hexBuf);
+        str << hexBuf;
+        DecToHex(green, hexBuf);
+        str << hexBuf;
+        DecToHex(blue, hexBuf);
+        str << hexBuf;
+        str << "\",\n";
+    }
+
+    // Output the data
+    int x, y;
+    for ( y = 0; y < GetHeight(); y++)
+    {
+        str << "\"";
+        for ( x = 0; x < GetWidth(); x++)
+        {
+            int index = GetIndex(x, y);
+            str << (char)(base + index) ;
+        }
+        str << "\",\n";
+    }
+
+    str << "};\n";
+    str.flush();
+
+    return TRUE;
+}
+
+#include <wx/msw/pnghand.h>
+
+IMPLEMENT_DYNAMIC_CLASS(wxPNGFileHandler, wxBitmapHandler)
+
+bool wxPNGFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+    int desiredWidth, int desiredHeight)
+{
+    wxPNGReader reader;
+    if (reader.ReadFile((char*) (const char*) name))
+    {
+        return reader.InstantiateBitmap(bitmap);
+    }
+    else
+        return FALSE;
+}
+
+bool wxPNGFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *pal)
+{
+    return FALSE;
+}
+
+
diff --git a/src/msw/printdlg.cpp b/src/msw/printdlg.cpp
new file mode 100644
index 0000000000..0bc12eff29
--- /dev/null
+++ b/src/msw/printdlg.cpp
@@ -0,0 +1,185 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        printdlg.cpp
+// Purpose:     wxPrintDialog, wxPageSetupDialog
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "printdlg.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#define IN_WX_MAIN_CPP
+#include "wx/wxprec.h"
+
+#if defined(__BORLANDC__)
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#endif
+
+#include "wx/printdlg.h"
+#include "wx/dcprint.h"
+
+// Have to emulate page setup dialog for Win16
+#if !defined(__WIN95__)
+#include "wx/generic/prntdlgg.h"
+#endif
+
+#include <stdlib.h>
+#include <windows.h>
+#include <commdlg.h>
+
+#ifndef __WIN32__
+#include <print.h>
+#endif
+
+// Clash with Windows header files
+#ifdef StartDoc
+#undef StartDoc
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
+IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
+#endif
+
+wxPrintDialog::wxPrintDialog(void):
+ wxDialog()
+{
+  dialogParent = NULL;
+  printerDC = NULL;
+  destroyDC = TRUE;
+  deviceName = NULL;
+  driverName = NULL;
+  portName = NULL;
+}
+
+wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data):
+ wxDialog()
+{
+  Create(p, data);
+}
+
+bool wxPrintDialog::Create(wxWindow *p, wxPrintData* data)
+{
+  dialogParent = p;
+  printerDC = NULL;
+  destroyDC = TRUE;
+  deviceName = NULL;
+  driverName = NULL;
+  portName = NULL;
+
+  if ( data )
+    printData = *data;
+
+#ifdef __WINDOWS__
+  printData.SetOwnerWindow(p);
+#endif
+
+  return TRUE;
+}
+
+wxPrintDialog::~wxPrintDialog(void)
+{
+  if (destroyDC && printerDC)
+    delete printerDC;
+  if (deviceName) delete[] deviceName;
+  if (driverName) delete[] driverName;
+  if (portName) delete[] portName;
+}
+
+int wxPrintDialog::ShowModal(void)
+{
+  printData.ConvertToNative();
+
+  bool ret = (PrintDlg( (PRINTDLG *)printData.printData ) != 0);
+  if ( ret != FALSE && ((PRINTDLG *)printData.printData)->hDC)
+  {
+    wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)printData.printData)->hDC);
+    printerDC = pdc;
+    printData.ConvertFromNative();
+    return wxID_OK;
+  }
+  else
+  {
+/*
+      char buf[256];
+      DWORD exError = CommDlgExtendedError();
+      sprintf(buf, "ret = %d, ex error = %d", (int) ret, (int) exError);
+      wxMessageBox(buf);
+*/
+      return wxID_CANCEL;
+  }
+}
+
+wxDC *wxPrintDialog::GetPrintDC(void)
+{
+  if (printerDC)
+  {
+    destroyDC = FALSE;
+    return printerDC;
+  }
+  else
+    return NULL;
+}
+
+/*
+ * wxPageSetupDialog
+ */
+
+wxPageSetupDialog::wxPageSetupDialog(void):
+ wxDialog()
+{
+  m_dialogParent = NULL;
+}
+
+wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
+ wxDialog()
+{
+  Create(p, data);
+}
+
+bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
+{
+  m_dialogParent = p;
+
+  if (data)
+    m_pageSetupData = (*data);
+
+#if defined(__WIN95__)
+  m_pageSetupData.SetOwnerWindow(p);
+#endif
+  return TRUE;
+}
+
+wxPageSetupDialog::~wxPageSetupDialog(void)
+{
+}
+
+int wxPageSetupDialog::ShowModal(void)
+{
+#ifdef __WIN95__
+    m_pageSetupData.ConvertToNative();
+    if (PageSetupDlg( (PAGESETUPDLG *)m_pageSetupData.GetNativeData() ))
+    {
+      m_pageSetupData.ConvertFromNative();
+      return wxID_OK;
+    }
+    else
+      return wxID_CANCEL;
+#else
+    wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData);
+    int ret = genericPageSetupDialog->ShowModal();
+    m_pageSetupData = genericPageSetupDialog->GetPageSetupData();
+    genericPageSetupDialog->Close(TRUE);
+    return ret;
+#endif
+}
+
diff --git a/src/msw/printwin.cpp b/src/msw/printwin.cpp
new file mode 100644
index 0000000000..a124a83685
--- /dev/null
+++ b/src/msw/printwin.cpp
@@ -0,0 +1,349 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        printwin.cpp
+// Purpose:     wxWindowsPrinter framework
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "printwin.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#include "wx/defs.h"
+
+#define WINDOWS_PRINTING    (wxTheApp->GetPrintMode() == wxPRINT_WINDOWS)
+
+#ifndef WX_PRECOMP
+#include "wx/utils.h"
+#include "wx/dc.h"
+#include "wx/app.h"
+#include "wx/msgdlg.h"
+#endif
+
+#include "wx/msw/printwin.h"
+#include "wx/dcprint.h"
+#include "wx/printdlg.h"
+#include "wx/msw/private.h"
+
+#include <stdlib.h>
+#include <windows.h>
+#include <commdlg.h>
+
+// Clash with Windows header files
+#ifdef StartDoc
+#undef StartDoc
+#endif
+
+#ifndef __WIN32__
+#include <print.h>
+#endif
+
+LONG APIENTRY _EXPORT wxAbortProc(HDC hPr, int Code);
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxWindowsPrinter, wxPrinterBase)
+IMPLEMENT_CLASS(wxWindowsPrintPreview, wxPrintPreviewBase)
+#endif
+
+/*
+ * Printer
+ */
+ 
+wxWindowsPrinter::wxWindowsPrinter(wxPrintData *data):
+  wxPrinterBase(data)
+{
+  lpAbortProc = (WXFARPROC) MakeProcInstance((FARPROC) wxAbortProc, wxGetInstance());
+}
+
+wxWindowsPrinter::~wxWindowsPrinter(void)
+{
+  FreeProcInstance((FARPROC) lpAbortProc);
+}
+
+bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
+{
+  abortIt = FALSE;
+  abortWindow = NULL;
+
+  if (!printout)
+    return FALSE;
+    
+  printout->SetIsPreview(FALSE);
+  printout->OnPreparePrinting();
+
+  // Get some parameters from the printout, if defined
+  int fromPage, toPage;
+  int minPage, maxPage;
+  printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
+
+  if (maxPage == 0)
+    return FALSE;
+
+  printData.SetMinPage(minPage);
+  printData.SetMaxPage(maxPage);
+  if (fromPage != 0)
+    printData.SetFromPage(fromPage);
+  if (toPage != 0)
+    printData.SetToPage(toPage);
+
+  if (minPage != 0)
+  {
+    printData.EnablePageNumbers(TRUE);
+    if (printData.GetFromPage() < printData.GetMinPage())
+      printData.SetFromPage(printData.GetMinPage());
+    else if (printData.GetFromPage() > printData.GetMaxPage())
+      printData.SetFromPage(printData.GetMaxPage());
+    if (printData.GetToPage() > printData.GetMaxPage())
+      printData.SetToPage(printData.GetMaxPage());
+    else if (printData.GetToPage() < printData.GetMinPage())
+      printData.SetToPage(printData.GetMinPage());
+  }
+  else
+    printData.EnablePageNumbers(FALSE);
+  
+  // Create a suitable device context  
+  wxDC *dc = NULL;
+  if (prompt)
+  {
+        wxPrintDialog dialog(parent, & printData);
+        if (dialog.ShowModal() == wxID_OK)
+        {
+          dc = dialog.GetPrintDC();
+          printData = dialog.GetPrintData();
+        }
+  }
+  else
+  {
+      dc = new wxPrinterDC("", "", "", FALSE, printData.GetOrientation());
+  }
+
+  // May have pressed cancel.
+  if (!dc || !dc->Ok())
+  {
+    if (dc) delete dc;
+    return FALSE;
+  }
+  
+  int logPPIScreenX = 0;
+  int logPPIScreenY = 0;
+  int logPPIPrinterX = 0;
+  int logPPIPrinterY = 0;
+
+  HDC hdc = ::GetDC(NULL);
+  logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX);
+  logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY);
+  ::ReleaseDC(NULL, hdc);
+
+  logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX);
+  logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY);
+  if (logPPIPrinterX == 0 || logPPIPrinterY == 0)
+  {
+    delete dc;
+    return FALSE;
+  }
+
+  printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
+  printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
+
+  // Set printout parameters  
+  printout->SetDC(dc);
+
+  int w, h;
+  long ww, hh;
+  dc->GetSize(&w, &h);
+  printout->SetPageSizePixels((int)w, (int)h);
+  dc->GetSizeMM(&ww, &hh);
+  printout->SetPageSizeMM((int)ww, (int)hh);
+
+  // Create an abort window
+  wxBeginBusyCursor();
+
+  wxWindow *win = CreateAbortWindow(parent, printout);
+  wxYield();
+  ::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) lpAbortProc);
+
+  if (!win)
+  {
+    wxEndBusyCursor();
+    wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent);
+    delete dc;
+  }
+  abortWindow = win;
+  abortWindow->Show(TRUE);
+  wxYield();
+
+  printout->OnBeginPrinting();
+  
+  bool keepGoing = TRUE;
+
+  int copyCount;
+  for (copyCount = 1; copyCount <= printData.GetNoCopies(); copyCount ++)
+  {
+    if (!printout->OnBeginDocument(printData.GetFromPage(), printData.GetToPage()))
+    {
+      wxEndBusyCursor();
+      wxMessageBox("Could not start printing.", "Print Error", wxOK, parent);
+      break;
+    }
+    if (abortIt)
+      break;
+
+    int pn;
+    for (pn = printData.GetFromPage(); keepGoing && (pn <= printData.GetToPage()) && printout->HasPage(pn);
+         pn++)
+    {
+      if (abortIt)
+      {
+        keepGoing = FALSE;
+        break;
+      }
+      else
+      {
+//        int dcID = ::SaveDC(dc->GetHDC());
+        dc->StartPage();
+        printout->OnPrintPage(pn);
+        dc->EndPage();
+//        ::RestoreDC(dc->GetHDC(), dcID);
+      }
+    }
+    printout->OnEndDocument();
+  }
+
+  printout->OnEndPrinting();
+
+  if (abortWindow)
+  {
+    abortWindow->Show(FALSE);
+    delete abortWindow;
+    abortWindow = NULL;
+  }
+
+  wxEndBusyCursor();
+
+  delete dc;
+  
+  return TRUE;
+}
+
+bool wxWindowsPrinter::PrintDialog(wxWindow *parent)
+{
+  wxPrintDialog dialog(parent, & printData);
+  return (dialog.ShowModal() == wxID_OK);
+}
+
+bool wxWindowsPrinter::Setup(wxWindow *parent)
+{
+  wxPrintDialog dialog(parent, & printData);
+  dialog.GetPrintData().SetSetupDialog(TRUE);
+  return (dialog.ShowModal() == wxID_OK);
+}
+
+/*
+ * Print preview
+ */
+
+wxWindowsPrintPreview::wxWindowsPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data):
+  wxPrintPreviewBase(printout, printoutForPrinting, data)
+{
+  DetermineScaling();
+}
+
+wxWindowsPrintPreview::~wxWindowsPrintPreview(void)
+{
+}
+
+bool wxWindowsPrintPreview::Print(bool interactive)
+{
+  if (!printPrintout)
+    return FALSE;
+  wxWindowsPrinter printer(&printData);
+  return printer.Print(previewFrame, printPrintout, interactive);
+}
+
+void wxWindowsPrintPreview::DetermineScaling(void)
+{
+    HDC dc = ::GetDC(NULL);
+    int screenWidth = ::GetDeviceCaps(dc, HORZSIZE);
+//    int screenHeight = ::GetDeviceCaps(dc, VERTSIZE);
+    int screenXRes = ::GetDeviceCaps(dc, HORZRES);
+//    int screenYRes = ::GetDeviceCaps(dc, VERTRES);
+    int logPPIScreenX = ::GetDeviceCaps(dc, LOGPIXELSX);
+    int logPPIScreenY = ::GetDeviceCaps(dc, LOGPIXELSY);
+    previewPrintout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
+
+    ::ReleaseDC(NULL, dc);
+
+    // Get a device context for the currently selected printer
+    wxPrinterDC printerDC("", "", "", FALSE, printData.GetOrientation());
+
+    int printerWidth = 150;
+    int printerHeight = 250;
+    int printerXRes = 1500;
+    int printerYRes = 2500;
+
+    if (printerDC.GetHDC())
+    {
+      printerWidth = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZSIZE);
+      printerHeight = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTSIZE);
+      printerXRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZRES);
+      printerYRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTRES);
+
+      int logPPIPrinterX = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSX);
+      int logPPIPrinterY = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSY);
+
+      previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
+      previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
+      
+      if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
+        isOk = FALSE;
+    }
+    else
+      isOk = FALSE;
+
+    pageWidth = printerXRes;
+    pageHeight = printerYRes;
+
+    // At 100%, the page should look about page-size on the screen.
+    previewScale = (float)((float)screenWidth/(float)printerWidth);
+    previewScale = previewScale * (float)((float)screenXRes/(float)printerYRes);
+}
+
+/****************************************************************************
+
+    FUNCTION: wxAbortProc()
+
+    PURPOSE:  Processes messages for the Abort Dialog box
+
+****************************************************************************/
+
+LONG APIENTRY _EXPORT wxAbortProc(HDC WXUNUSED(hPr), int WXUNUSED(Code))
+{
+    MSG msg;
+
+    if (!wxPrinterBase::abortWindow)              /* If the abort dialog isn't up yet */
+        return(TRUE);
+
+    /* Process messages intended for the abort dialog box */
+
+    while (!wxPrinterBase::abortIt && PeekMessage(&msg, 0, 0, 0, TRUE))
+        if (!IsDialogMessage((HWND) wxPrinterBase::abortWindow->GetHWND(), &msg)) {
+            TranslateMessage(&msg);
+            DispatchMessage(&msg);
+        }
+
+    /* bAbort is TRUE (return is FALSE) if the user has aborted */
+
+    return (!wxPrinterBase::abortIt);
+}
+
diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp
new file mode 100644
index 0000000000..c4fe0dc4b8
--- /dev/null
+++ b/src/msw/radiobox.cpp
@@ -0,0 +1,763 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        radiobox.cpp
+// Purpose:     wxRadioBox
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "radiobox.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/radiobox.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
+#endif
+
+bool wxRadioBox::MSWCommand(const WXUINT param, const WXWORD id)
+{
+  if (param == BN_CLICKED)
+  {
+#ifdef __WIN32__
+    int i;
+    for (i = 0; i < m_noItems; i++)
+      if (id == GetWindowLong((HWND) m_radioButtons[i], GWL_ID))
+        m_selectedButton = i;
+#else
+    int i;
+    for (i = 0; i < m_noItems; i++)
+      if (id == GetWindowWord((HWND) m_radioButtons[i], GWW_ID))
+        m_selectedButton = i;
+#endif
+
+    wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId);
+    event.SetInt( m_selectedButton );
+    event.SetEventObject( this );
+    ProcessCommand(event);
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+#if WXWIN_COMPATIBILITY
+wxRadioBox::wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
+             int x, int y, int width, int height,
+             int n, char **choices,
+             int majorDim, long style, const char *name)
+{
+    wxString *choices2 = new wxString[n];
+    for ( int i = 0; i < n; i ++) choices2[i] = choices[i];
+    Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), n, choices2, majorDim, style,
+        wxDefaultValidator, name);
+    Callback(func);
+    delete choices2;
+}
+
+#endif
+
+// Radio box item
+wxRadioBox::wxRadioBox(void)
+{
+  m_selectedButton = -1;
+  m_noItems = 0;
+  m_noRowsOrCols = 0;
+  m_radioButtons = NULL;
+  m_majorDim = 0 ;
+  m_radioWidth = NULL ;
+  m_radioHeight = NULL ;
+}
+
+bool wxRadioBox::Create(wxWindow *parent, const wxWindowID id, const wxString& title,
+             const wxPoint& pos, const wxSize& size,
+             const int n, const wxString choices[],
+             const int majorDim, const long style,
+             const wxValidator& val, const wxString& name)
+{
+  m_selectedButton = -1;
+  m_noItems = n;
+
+  SetName(name);
+  SetValidator(val);
+
+  parent->AddChild(this);
+  m_backgroundColour = parent->GetDefaultBackgroundColour() ;
+  m_foregroundColour = parent->GetDefaultForegroundColour() ;
+
+  m_windowStyle = (long&)style;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  if (id == -1)
+    m_windowId = NewControlId();
+  else
+    m_windowId = id;
+
+  m_noRowsOrCols = majorDim;
+  if (majorDim==0)
+    m_majorDim = n ;
+  m_majorDim = majorDim ;
+
+  long msStyle = GROUP_FLAGS;
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
+    msStyle |= WS_BORDER;
+
+
+  m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title),
+                           msStyle,
+                           0,0,0,0,
+                           (HWND) parent->GetHWND(), (HMENU) m_windowId, wxGetInstance(), NULL) ;
+
+  HWND the_handle = (HWND) parent->GetHWND() ;
+
+#if CTL3D
+  if (want3D)
+  {
+    Ctl3dSubclassCtl((HWND) m_hWnd);
+ 	m_useCtl3D = TRUE;
+  }
+#endif
+
+  SetFont(* parent->GetFont());
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND)m_hWnd);
+
+/* Label will be the same as button font now.
+  if (labelFont)
+  {
+    labelFont->RealizeResource();
+    if (labelFont->GetResourceHandle())
+      SendMessage(ms_handle,WM_SETFONT,
+                (WPARAM)labelFont->GetResourceHandle(),0L);
+  }
+*/
+
+  // Some radio boxes test consecutive id.
+  (void)NewControlId() ;
+  m_radioButtons = new WXHWND[n];
+  m_radioWidth = new int[n] ;
+  m_radioHeight = new int[n] ;
+  int i;
+  for (i = 0; i < n; i++)
+  {
+    m_radioWidth[i] = m_radioHeight[i] = -1 ;
+    long groupStyle = 0;
+    if (i == 0 && style==0)
+      groupStyle = WS_GROUP;
+    long newId = NewControlId();
+    long msStyle = groupStyle | RADIO_FLAGS;
+
+    m_radioButtons[i] = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, choices[i],
+                          msStyle,0,0,0,0,
+                          the_handle, (HMENU)newId, wxGetInstance(), NULL);
+#if CTL3D
+  if (want3D)
+  {
+    Ctl3dSubclassCtl((HWND) m_hWnd);
+ 	m_useCtl3D = TRUE;
+  }
+#endif
+    if (GetFont())
+    {
+       SendMessage((HWND)m_radioButtons[i],WM_SETFONT,
+                    (WPARAM)GetFont()->GetResourceHandle(),0L);
+    }
+    m_subControls.Append((wxObject *)newId);
+  }
+
+  // Create a dummy radio control to end the group.
+  (void)CreateWindowEx(0, RADIO_CLASS, "", WS_GROUP|RADIO_FLAGS, 0,0,0,0, the_handle, (HMENU)NewControlId(), wxGetInstance(), NULL);
+
+  SetSelection(0);
+
+  SetSize(x, y, width, height);
+
+  return TRUE;
+}
+
+#if 0
+bool wxRadioBox::Create(wxWindow *parent, const wxWindowID id, const wxString& title,
+             const wxPoint& pos, const wxSize& size,
+             const int n, const wxBitmap *choices[],
+             const int majorDim, const long style,
+             const wxValidator& val, const wxString& name)
+{
+  m_selectedButton = -1;
+  m_noRowsOrCols = 0;
+  m_noItems = n;
+
+  SetName(name);
+  SetValidator(val);
+
+  parent->AddChild(this);
+  m_backgroundColour = parent->GetDefaultBackgroundColour() ;
+  m_foregroundColour = parent->GetDefaultForegroundColour() ;
+
+  m_windowStyle = (long&)style;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  if (id == -1)
+    m_windowId = NewControlId();
+  else
+    m_windowId = id;
+
+
+  m_noRowsOrCols = majorDim;
+  if (majorDim==0)
+    m_majorDim = n ;
+  m_majorDim = majorDim ;
+  HWND the_handle ;
+
+  long msStyle = GROUP_FLAGS;
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
+    msStyle |= WS_BORDER;
+
+  m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title),
+                           msStyle,
+                           0,0,0,0,
+                           (HWND) parent->GetHWND(), (HMENU) m_windowId, wxGetInstance(), NULL) ;
+
+/*
+  if (labelFont)
+  {
+    labelFont->RealizeResource();
+    if (labelFont->GetResourceHandle())
+      SendMessage(ms_handle,WM_SETFONT,
+                (WPARAM)labelFont->GetResourceHandle(),0L);
+  }
+*/
+  the_handle = (HWND) parent->GetHWND();
+
+#if CTL3D
+  if (want3D)
+  {
+    Ctl3dSubclassCtl((HWND) m_hWnd);
+ 	m_useCtl3D = TRUE;
+  }
+#endif
+
+  SetFont(* parent->GetFont());
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND)m_hWnd);
+
+  (void)NewControlId() ;
+  m_radioButtons = new WXHWND[n];
+  m_radioWidth = new int[n] ;
+  m_radioHeight = new int[n] ;
+
+  int i;
+  for (i = 0; i < n; i++)
+  {
+    long groupStyle = 0;
+    if (i == 0 && style==0)
+      groupStyle = WS_GROUP;
+    long newId = NewControlId();
+    m_radioWidth[i]  = ((wxBitmap *)choices[i])->GetWidth();
+    m_radioHeight[i] = ((wxBitmap *)choices[i])->GetHeight();
+    char tmp[32] ;
+    sprintf(tmp,"Toggle%d",i) ;
+    long msStyle = groupStyle | RADIO_FLAGS;
+    m_radioButtons[i] = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, tmp,
+                          msStyle,0,0,0,0,
+                          the_handle, (HMENU)newId, wxhInstance, NULL);
+#if CTL3D
+  if (want3D)
+  {
+    Ctl3dSubclassCtl((HWND) m_hWnd);
+ 	m_useCtl3D = TRUE;
+  }
+#endif
+    m_subControls.Append((wxObject *)newId);
+  }
+  // Create a dummy radio control to end the group.
+  (void)CreateWindowEx(0, RADIO_CLASS, "", WS_GROUP|RADIO_FLAGS, 0,0,0,0, the_handle, (HMENU)NewControlId(), wxGetInstance(), NULL);
+
+  SetSelection(0);
+
+  SetSize(x, y, width, height);
+
+  return TRUE;
+}
+#endif
+
+wxRadioBox::~wxRadioBox(void)
+{
+  m_isBeingDeleted = TRUE;
+  
+  if (m_radioButtons)
+  {
+    int i;
+    for (i = 0; i < m_noItems; i++)
+      DestroyWindow((HWND) m_radioButtons[i]);
+    delete[] m_radioButtons;
+  }
+  if (m_radioWidth)
+    delete[] m_radioWidth ;
+  if (m_radioHeight)
+    delete[] m_radioHeight ;
+  if (m_hWnd)
+    ::DestroyWindow((HWND) m_hWnd) ;
+  m_hWnd = 0 ;
+
+}
+
+wxString wxRadioBox::GetLabel(const int item) const
+{
+  GetWindowText((HWND)m_radioButtons[item], wxBuffer, 300);
+  return wxString(wxBuffer);
+}
+
+void wxRadioBox::SetLabel(const int item, const wxString& label)
+{
+  m_radioWidth[item] = m_radioHeight[item] = -1 ;
+  SetWindowText((HWND)m_radioButtons[item], (const char *)label);
+}
+
+void wxRadioBox::SetLabel(const int item, wxBitmap *bitmap)
+{
+/*
+    m_radioWidth[item] = bitmap->GetWidth() + FB_MARGIN ;
+    m_radioHeight[item] = bitmap->GetHeight() + FB_MARGIN ;
+*/
+}
+
+int wxRadioBox::FindString(const wxString& s) const
+{
+ int i;
+ for (i = 0; i < m_noItems; i++)
+ {
+  GetWindowText((HWND) m_radioButtons[i], wxBuffer, 1000);
+  if (s == wxBuffer)
+    return i;
+ }
+ return -1;
+}
+
+void wxRadioBox::SetSelection(const int N)
+{
+  if ((N < 0) || (N >= m_noItems))
+    return;
+
+// Following necessary for Win32s, because Win32s translate BM_SETCHECK
+  if (m_selectedButton >= 0 && m_selectedButton < m_noItems)
+    SendMessage((HWND) m_radioButtons[m_selectedButton], BM_SETCHECK, 0, 0L);
+
+  SendMessage((HWND) m_radioButtons[N], BM_SETCHECK, 1, 0L);
+  m_selectedButton = N;
+}
+
+// Get single selection, for single choice list items
+int wxRadioBox::GetSelection(void) const
+{
+  return m_selectedButton;
+}
+
+// Find string for position
+wxString wxRadioBox::GetString(const int N) const
+{
+  GetWindowText((HWND) m_radioButtons[N], wxBuffer, 1000);
+  return wxString(wxBuffer);
+}
+
+void wxRadioBox::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+  int xx = x;
+  int yy = y;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    xx = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    yy = currentY;
+
+  char buf[400];
+
+  int y_offset = yy;
+  int x_offset = xx;
+  float current_width;
+
+  float cyf;
+
+  int cx1,cy1 ;
+  wxGetCharSize(m_hWnd, &cx1, &cy1, GetFont());
+  // Attempt to have a look coherent with other platforms:
+  // We compute the biggest toggle dim, then we align all
+  // items according this value.
+  int maxWidth =  -1;
+  int maxHeight = -1 ;
+
+  int i;
+  for (i = 0 ; i < m_noItems; i++)
+  {
+    int eachWidth;
+    int eachHeight ;
+    if (m_radioWidth[i]<0)
+    {
+      // It's a labelled toggle
+      GetWindowText((HWND) m_radioButtons[i], buf, 300);
+      GetTextExtent(buf, &current_width, &cyf,NULL,NULL, GetFont());
+      eachWidth = (int)(current_width + RADIO_SIZE);
+      eachHeight = (int)((3*cyf)/2);
+    }
+    else
+    {
+      eachWidth = m_radioWidth[i] ;
+      eachHeight = m_radioHeight[i] ;
+    }
+    if (maxWidth<eachWidth) maxWidth = eachWidth ;
+    if (maxHeight<eachHeight) maxHeight = eachHeight ;
+  }
+
+  if (m_hWnd)
+  {
+    int totWidth ;
+    int totHeight;
+
+    int nbHor,nbVer;
+
+    if (m_windowStyle & wxRA_VERTICAL)
+    {
+      nbVer = m_majorDim ;
+      nbHor = (m_noItems+m_majorDim-1)/m_majorDim ;
+    }
+    else
+    {
+      nbHor = m_majorDim ;
+      nbVer = (m_noItems+m_majorDim-1)/m_majorDim ;
+    }
+
+    // this formula works, but I don't know why.
+    // Please, be sure what you do if you modify it!!
+    if (m_radioWidth[0]<0)
+      totHeight = (nbVer * maxHeight) + cy1/2 ;
+    else
+      totHeight = nbVer * (maxHeight+cy1/2) ;
+    totWidth  = nbHor * (maxWidth+cx1) ;
+
+#if (!CTL3D)
+    // Requires a bigger group box in plain Windows
+    MoveWindow((HWND) m_hWnd,x_offset,y_offset,totWidth+cx1,totHeight+(3*cy1)/2,TRUE) ;
+#else
+    MoveWindow((HWND) m_hWnd,x_offset,y_offset,totWidth+cx1,totHeight+cy1,TRUE) ;
+#endif
+    x_offset += cx1;
+    y_offset += cy1;
+  }
+
+#if (!CTL3D)
+  y_offset += (int)(cy1/2); // Fudge factor since buttons overlapped label
+                            // JACS 2/12/93. CTL3D draws group label quite high.
+#endif
+  int startX = x_offset ;
+  int startY = y_offset ;
+
+  for ( i = 0 ; i < m_noItems; i++)
+  {
+    // Bidimensional radio adjustment
+    if (i&&((i%m_majorDim)==0)) // Why is this omitted for i = 0?
+    {
+      if (m_windowStyle & wxRA_VERTICAL)
+      {
+        y_offset = startY;
+        x_offset += maxWidth + cx1 ;
+      }
+      else
+      {
+        x_offset = startX ;
+        y_offset += maxHeight ;
+        if (m_radioWidth[0]>0)
+          y_offset += cy1/2 ;
+      }
+    }
+    int eachWidth ;
+    int eachHeight ;
+    if (m_radioWidth[i]<0)
+    {
+      // It's a labeled item
+      GetWindowText((HWND) m_radioButtons[i], buf, 300);
+      GetTextExtent(buf, &current_width, &cyf,NULL,NULL,GetFont());
+
+      // How do we find out radio button bitmap size!!
+      // By adjusting them carefully, manually :-)
+      eachWidth = (int)(current_width + RADIO_SIZE);
+      eachHeight = (int)((3*cyf)/2);
+    }
+    else
+    {
+      eachWidth = m_radioWidth[i] ;
+      eachHeight = m_radioHeight[i] ;
+    }
+
+    MoveWindow((HWND) m_radioButtons[i],x_offset,y_offset,eachWidth,eachHeight,TRUE);
+    if (m_windowStyle & wxRA_VERTICAL)
+    {
+      y_offset += maxHeight;
+      if (m_radioWidth[0]>0)
+        y_offset += cy1/2 ;
+    }
+    else
+      x_offset += maxWidth + cx1;
+  }
+}
+
+void wxRadioBox::GetSize(int *width, int *height) const
+{
+  RECT rect;
+  rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
+
+  if (m_hWnd)
+    wxFindMaxSize(m_hWnd, &rect);
+
+  int i;
+  for (i = 0; i < m_noItems; i++)
+    wxFindMaxSize(m_radioButtons[i], &rect);
+
+  *width = rect.right - rect.left;
+  *height = rect.bottom - rect.top;
+}
+
+void wxRadioBox::GetPosition(int *x, int *y) const
+{
+  wxWindow *parent = GetParent();
+  RECT rect;
+  rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
+
+  int i;
+  for (i = 0; i < m_noItems; i++)
+    wxFindMaxSize(m_radioButtons[i], &rect);
+
+  if (m_hWnd)
+    wxFindMaxSize(m_hWnd, &rect);
+
+  // Since we now have the absolute screen coords,
+  // if there's a parent we must subtract its top left corner
+  POINT point;
+  point.x = rect.left;
+  point.y = rect.top;
+  if (parent)
+  {
+    ::ScreenToClient((HWND) parent->GetHWND(), &point);
+  }
+
+  *x = point.x;
+  *y = point.y;
+}
+
+wxString wxRadioBox::GetLabel(void) const
+{
+  if (m_hWnd)
+  {
+    GetWindowText((HWND) m_hWnd, wxBuffer, 300);
+    return wxString(wxBuffer);
+  }
+  else return wxString("");
+}
+
+void wxRadioBox::SetLabel(const wxString& label)
+{
+  if (m_hWnd && label)
+    SetWindowText((HWND) m_hWnd, label);
+}
+
+void wxRadioBox::SetFocus(void)
+{
+/*
+  if (m_noItems > 0)
+   ::SetFocus((HWND) m_radioButtons[0]);
+*/
+/* Begin Alberts Patch 26. 5. 1997*/
+  if (m_noItems > 0)
+  {
+    if (m_selectedButton == -1)
+      ::SetFocus((HWND) m_radioButtons[0]);
+    else
+      ::SetFocus((HWND) m_radioButtons[m_selectedButton]);
+  }
+/* Ende Alberts Patch*/
+
+}
+
+bool wxRadioBox::Show(const bool show)
+{
+  int cshow;
+  if (show)
+    cshow = SW_SHOW;
+  else
+    cshow = SW_HIDE;
+  if (m_hWnd)
+    ShowWindow((HWND) m_hWnd, cshow);
+  int i;
+  for (i = 0; i < m_noItems; i++)
+    ShowWindow((HWND) m_radioButtons[i], cshow);
+  return TRUE;
+}
+
+// Enable a specific button
+void wxRadioBox::Enable(const int item, const bool enable)
+{
+  if (item<0)
+    wxWindow::Enable(enable) ;
+  else if (item < m_noItems)
+    ::EnableWindow((HWND) m_radioButtons[item], enable);
+}
+
+// Enable all controls
+void wxRadioBox::Enable(const bool enable)
+{
+  wxControl::Enable(enable);
+  
+  int i;
+  for (i = 0; i < m_noItems; i++)
+    ::EnableWindow((HWND) m_radioButtons[i], enable);
+}
+
+// Show a specific button
+void wxRadioBox::Show(const int item, const bool show)
+{
+  if (item<0)
+    wxRadioBox::Show(show) ;
+  else if (item < m_noItems)
+  {
+    int cshow;
+    if (show)
+      cshow = SW_SHOW;
+    else
+      cshow = SW_HIDE;
+    ShowWindow((HWND) m_radioButtons[item], cshow);
+  }
+}
+
+WXHBRUSH wxRadioBox::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+#if CTL3D
+  if ( m_useCtl3D )
+  {
+    HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
+    return (WXHBRUSH) hbrush;
+  }
+#endif
+
+  if (GetParent()->GetTransparentBackground())
+    SetBkMode((HDC) pDC, TRANSPARENT);
+  else
+    SetBkMode((HDC) pDC, OPAQUE);
+
+  ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+
+  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+
+  // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
+  // has a zero usage count.
+//  backgroundBrush->RealizeResource();
+  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
+}
+
+// For single selection items only
+wxString wxRadioBox::GetStringSelection (void) const
+{
+  int sel = GetSelection ();
+  if (sel > -1)
+    return this->GetString (sel);
+  else
+    return wxString("");
+}
+
+bool wxRadioBox::SetStringSelection (const wxString& s)
+{
+  int sel = FindString (s);
+  if (sel > -1)
+    {
+      SetSelection (sel);
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
+
+/*
+void wxRadioBox::SetLabelFont(wxFont *font)
+{
+  // Decrement the usage count of the old label font
+  // (we may be able to free it up)
+  if (labelFont)
+    labelFont->ReleaseResource();
+
+  labelFont = font;
+
+  // Increment usage count
+  if (font)
+    font->UseResource();
+
+  HWND hWnd = GetHWND();
+  if (hWnd != 0)
+  {
+    if (font)
+    {
+      font->RealizeResource();
+      
+      if (font->GetResourceHandle())
+        SendMessage(hWnd, WM_SETFONT,
+                  (WPARAM)font->GetResourceHandle(),TRUE);
+    }
+  }
+}
+
+*/
+
+bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
+{
+	int i;
+    for (i = 0; i < Number(); i++)
+       if (GetRadioButtons()[i] == hWnd)
+          return TRUE;
+	return FALSE;
+}
+
+void wxRadioBox::Command (wxCommandEvent & event)
+{
+  SetSelection (event.m_commandInt);
+  ProcessCommand (event);
+}
+
+
diff --git a/src/msw/radiobut.cpp b/src/msw/radiobut.cpp
new file mode 100644
index 0000000000..f3a4b655d8
--- /dev/null
+++ b/src/msw/radiobut.cpp
@@ -0,0 +1,246 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        radiobut.cpp
+// Purpose:     wxRadioButton
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "radiobut.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/radiobut.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
+// IMPLEMENT_DYNAMIC_CLASS(wxBitmapRadioButton, wxRadioButton)
+#endif
+
+bool wxRadioButton::Create(wxWindow *parent, const wxWindowID id,
+		   const wxString& label,
+           const wxPoint& pos,
+           const wxSize& size, const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  SetName(name);
+  SetValidator(validator);
+
+  if (parent) parent->AddChild(this);
+
+  SetBackgroundColour(parent->GetDefaultBackgroundColour());
+  SetForegroundColour(parent->GetDefaultForegroundColour());
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_windowStyle = style ;
+
+  long groupStyle = 0;
+  if (m_windowStyle & wxRB_GROUP)
+    groupStyle = WS_GROUP;
+
+//  long msStyle = groupStyle | RADIO_FLAGS;
+  long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ;
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
+    msStyle |= WS_BORDER;
+
+  m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const char *)label,
+                          msStyle,0,0,0,0,
+                          (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
+#if CTL3D
+  if (want3D)
+  {
+    Ctl3dSubclassCtl((HWND) m_hWnd);
+ 	m_useCtl3D = TRUE;
+  }
+#endif
+
+  SetFont(* parent->GetFont());
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND)m_hWnd);
+
+//  SetValue(value);
+
+  // start GRW fix
+  if (label != "")
+  {
+    float label_width, label_height;
+    GetTextExtent(label, &label_width, &label_height, NULL, NULL, GetFont());
+    if (width < 0)
+      width = (int)(label_width + RADIO_SIZE);
+    if (height<0)
+    {
+      height = (int)(label_height);
+      if (height < RADIO_SIZE)
+        height = RADIO_SIZE;
+    }
+  }
+  else
+  {
+    if (width < 0)
+      width = RADIO_SIZE;
+    if (height < 0)
+      height = RADIO_SIZE;
+  }
+  // end GRW fix
+
+  SetSize(x, y, width, height);
+
+  return TRUE;
+}
+
+
+void wxRadioButton::SetLabel(const wxString& label)
+{
+  SetWindowText((HWND) GetHWND(), (const char *)label);
+}
+
+void wxRadioButton::SetValue(const bool value)
+{
+// Following necessary for Win32s, because Win32s translate BM_SETCHECK
+  SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L);
+}
+
+// Get single selection, for single choice list items
+bool wxRadioButton::GetValue(void) const
+{
+  return (SendMessage((HWND) GetHWND(), BM_SETCHECK, 0, 0L) != 0);
+}
+
+WXHBRUSH wxRadioButton::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+#if CTL3D
+  if ( m_useCtl3D )
+  {
+    HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
+    return (WXHBRUSH) hbrush;
+  }
+#endif
+
+  if (GetParent()->GetTransparentBackground())
+    SetBkMode((HDC) pDC, TRANSPARENT);
+  else
+    SetBkMode((HDC) pDC, OPAQUE);
+
+  ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+
+  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+
+  // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
+  // has a zero usage count.
+//  backgroundBrush->RealizeResource();
+  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
+}
+
+void wxRadioButton::Command (wxCommandEvent & event)
+{
+  SetValue ( (event.m_commandInt != 0) );
+  ProcessCommand (event);
+}
+
+
+// Not implemented
+#if 0
+bool wxBitmapRadioButton::Create(wxWindow *parent, const wxWindowID id,
+		   const wxBitmap *bitmap,
+           const wxPoint& pos,
+           const wxSize& size, const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  SetName(name);
+  SetValidator(validator);
+
+  if (parent) parent->AddChild(this);
+  SetBackgroundColour(parent->GetDefaultBackgroundColour());
+  SetForegroundColour(parent->GetDefaultForegroundColour());
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+  m_windowStyle = style ;
+
+  long groupStyle = 0;
+  if (m_windowStyle & wxRB_GROUP)
+    groupStyle = WS_GROUP;
+
+//  long msStyle = groupStyle | RADIO_FLAGS;
+  long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ;
+
+  m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle",
+                          msStyle,0,0,0,0,
+                          (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
+#if CTL3D
+  if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS))
+  {
+    Ctl3dSubclassCtl((HWND) GetHWND());
+	  m_useCtl3D = TRUE;
+  }
+#endif
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin(GetHWND());
+
+  SetSize(x, y, width, height);
+
+  return TRUE;
+}
+
+void wxBitmapRadioButton::SetLabel(const wxBitmap *bitmap)
+{
+}
+
+void wxBitmapRadioButton::SetValue(const bool value)
+{
+// Following necessary for Win32s, because Win32s translate BM_SETCHECK
+  SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L);
+}
+
+// Get single selection, for single choice list items
+bool wxBitmapRadioButton::GetValue(void) const
+{
+  return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L);
+}
+
+#endif
diff --git a/src/msw/region.cpp b/src/msw/region.cpp
new file mode 100644
index 0000000000..b5e7227e1a
--- /dev/null
+++ b/src/msw/region.cpp
@@ -0,0 +1,410 @@
+/////////////////////////////////////////////////////////////////////////////
+// File:      region.cpp
+// Purpose:   Region handling for wxWindows/X11
+// Author:    Markus Holzem
+// Created:   Fri Oct 24 10:46:34 MET 1997
+// RCS-ID:	  $Id$
+// Copyright: (c) 1997 Julian Smart and Markus Holzem
+// Licence:   wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "region.h"
+#endif
+
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#include "wx/msw/region.h"
+#include "wx/gdicmn.h"
+
+#include <windows.h>
+
+#if !USE_SHARED_LIBRARY
+	IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
+	IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
+#endif
+
+//-----------------------------------------------------------------------------
+// wxRegionRefData implementation
+//-----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxRegionRefData : public wxGDIRefData {
+public:
+	wxRegionRefData(void)
+	{
+	}
+
+	wxRegionRefData(const wxRegionRefData& data)
+	{
+#if defined(__WIN32__)
+        DWORD noBytes = ::GetRegionData(data.m_region, 0, NULL);
+        RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
+		::GetRegionData(data.m_region, noBytes, rgnData);
+        m_region = ::ExtCreateRegion(NULL, noBytes, rgnData);
+        delete[] (char*) rgnData;
+#else
+        RECT rect;
+        ::GetRgnBox(data.m_region, &rect);
+        m_region = ::CreateRectRgnIndirect(&rect);
+#endif
+	}
+
+	~wxRegionRefData(void)
+	{
+		::DeleteObject(m_region);
+        m_region = 0;
+	}
+
+	HRGN m_region;
+};
+
+#define M_REGION (((wxRegionRefData*)m_refData)->m_region)
+
+//-----------------------------------------------------------------------------
+// wxRegion
+//-----------------------------------------------------------------------------
+
+/*!
+ * Create an empty region.
+ */
+wxRegion::wxRegion(void)
+{
+    m_refData = new wxRegionRefData;
+    M_REGION = ::CreateRectRgn(0, 0, 0, 0);
+}
+
+wxRegion::wxRegion(long x, long y, long w, long h)
+{
+    m_refData = new wxRegionRefData;
+    M_REGION = ::CreateRectRgn(x, y, x + w, y + h);
+}
+
+wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
+{
+    m_refData = new wxRegionRefData;
+    M_REGION = ::CreateRectRgn(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
+}
+
+wxRegion::wxRegion(const wxRect& rect)
+{
+    m_refData = new wxRegionRefData;
+    M_REGION = ::CreateRectRgn(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom());
+}
+
+/*!
+ * Destroy the region.
+ */
+wxRegion::~wxRegion(void)
+{
+    // m_refData unrefed in ~wxObject
+}
+
+//-----------------------------------------------------------------------------
+//# Modify region
+//-----------------------------------------------------------------------------
+
+//! Clear current region
+void wxRegion::Clear(void)
+{
+	UnRef();
+}
+
+//! Combine rectangle (x, y, w, h) with this.
+bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op)
+{
+	// Don't change shared data
+	if (!m_refData) {
+		m_refData = new wxRegionRefData();
+	} else if (m_refData->GetRefCount() > 1) {
+		wxRegionRefData* ref = (wxRegionRefData*)m_refData;
+		UnRef();
+		m_refData = new wxRegionRefData(*ref);
+	}
+    // If ref count is 1, that means it's 'ours' anyway so no action.
+
+    HRGN rectRegion = ::CreateRectRgn(x, y, x + width, y + height);
+
+    int mode = 0;
+    switch (op)
+    {
+        case wxRGN_AND: mode = RGN_AND; break ;
+        case wxRGN_OR: mode = RGN_OR; break ;
+        case wxRGN_XOR: mode = RGN_XOR; break ;
+        case wxRGN_DIFF: mode = RGN_DIFF; break ;
+        case wxRGN_COPY:
+        default:
+            mode = RGN_COPY; break ;
+    }
+
+	bool success = (ERROR != ::CombineRgn(M_REGION, M_REGION, rectRegion, mode));
+
+    ::DeleteObject(rectRegion);
+
+    return success;
+}
+
+//! Union /e region with this.
+bool wxRegion::Combine(const wxRegion& region, wxRegionOp op)
+{
+	if (region.Empty())
+		return FALSE;
+
+	// Don't change shared data
+	if (!m_refData) {
+		m_refData = new wxRegionRefData();
+	} else	if (m_refData->GetRefCount() > 1) {
+		wxRegionRefData* ref = (wxRegionRefData*)m_refData;
+		UnRef();
+		m_refData = new wxRegionRefData(*ref);
+	}
+
+    int mode = 0;
+    switch (op)
+    {
+        case wxRGN_AND: mode = RGN_AND; break ;
+        case wxRGN_OR: mode = RGN_OR; break ;
+        case wxRGN_XOR: mode = RGN_XOR; break ;
+        case wxRGN_DIFF: mode = RGN_DIFF; break ;
+        case wxRGN_COPY:
+        default:
+            mode = RGN_COPY; break ;
+    }
+
+	return (ERROR != ::CombineRgn(M_REGION, M_REGION, ((wxRegionRefData*)region.m_refData)->m_region, mode));
+}
+
+bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
+{
+    return Combine(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight(), op);
+}
+
+//-----------------------------------------------------------------------------
+//# Information on region
+//-----------------------------------------------------------------------------
+
+// Outer bounds of region
+void wxRegion::GetBox(long& x, long& y, long&w, long &h) const
+{
+	if (m_refData) {
+        RECT rect;
+        ::GetRgnBox(M_REGION, & rect);
+		x = rect.left;
+		y = rect.top;
+		w = rect.right - rect.left;
+		h = rect.bottom - rect.top;
+	} else {
+		x = y = w = h = 0;
+	}
+}
+
+wxRect wxRegion::GetBox(void) const
+{
+    long x, y, w, h;
+    GetBox(x, y, w, h);
+    return wxRect(x, y, w, h);
+}
+
+// Is region empty?
+bool wxRegion::Empty(void) const
+{
+    if (M_REGION == 0)
+        return TRUE;
+    long x, y, w, h;
+    GetBox(x, y, w, h);
+
+    return ((w == 0) && (h == 0));
+}
+
+//-----------------------------------------------------------------------------
+//# Tests
+//-----------------------------------------------------------------------------
+
+// Does the region contain the point (x,y)?
+wxRegionContain wxRegion::Contains(long x, long y) const
+{
+	if (!m_refData)
+		return wxOutRegion;
+
+    if (::PtInRegion(M_REGION, (int) x, (int) y))
+        return wxInRegion;
+    else
+        return wxOutRegion;
+}
+
+// Does the region contain the point pt?
+wxRegionContain wxRegion::Contains(const wxPoint& pt) const
+{
+	if (!m_refData)
+		return wxOutRegion;
+
+    if (::PtInRegion(M_REGION, (int) pt.x, (int) pt.y))
+        return wxInRegion;
+    else
+        return wxOutRegion;
+}
+
+// Does the region contain the rectangle (x, y, w, h)?
+wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const
+{
+	if (!m_refData)
+		return wxOutRegion;
+
+    RECT rect;
+    rect.left = x;
+    rect.top = y;
+    rect.right = x + w;
+    rect.bottom = y + h;
+
+    if (::RectInRegion(M_REGION, & rect))
+        return wxInRegion;
+    else
+        return wxOutRegion;
+}
+
+// Does the region contain the rectangle rect
+wxRegionContain wxRegion::Contains(const wxRect& rect) const
+{
+	if (!m_refData)
+		return wxOutRegion;
+
+    long x, y, w, h;
+    x = rect.x;
+    y = rect.y;
+    w = rect.GetWidth();
+    h = rect.GetHeight();
+    return Contains(x, y, w, h);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//																			 //
+//							   wxRegionIterator								 //
+//																			 //
+///////////////////////////////////////////////////////////////////////////////
+
+/*!
+ * Initialize empty iterator
+ */
+wxRegionIterator::wxRegionIterator(void) : m_current(0), m_numRects(0), m_rects(NULL)
+{
+}
+
+wxRegionIterator::~wxRegionIterator(void)
+{
+    if (m_rects)
+        delete[] m_rects;
+}
+
+/*!
+ * Initialize iterator for region
+ */
+wxRegionIterator::wxRegionIterator(const wxRegion& region)
+{
+    m_rects = NULL;
+
+	Reset(region);
+}
+
+/*!
+ * Reset iterator for a new /e region.
+ */
+void wxRegionIterator::Reset(const wxRegion& region)
+{
+	m_current = 0;
+	m_region = region;
+
+    if (m_rects)
+        delete[] m_rects;
+
+    m_rects = NULL;
+
+	if (m_region.Empty())
+		m_numRects = 0;
+	else
+    {
+#if defined(__WIN32__)
+        DWORD noBytes = ::GetRegionData(((wxRegionRefData*)region.m_refData)->m_region, 0, NULL);
+        RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
+		::GetRegionData(((wxRegionRefData*)region.m_refData)->m_region, noBytes, rgnData);
+
+        RGNDATAHEADER* header = (RGNDATAHEADER*) rgnData;
+
+        m_rects = new wxRect[header->nCount];
+
+        RECT* rect = (RECT*) (rgnData + sizeof(RGNDATAHEADER)) ;
+        uint i;
+        for (i = 0; i < header->nCount; i++)
+        {
+            m_rects[i] = wxRect(rect->left, rect->top,
+                                 rect->right - rect->left, rect->bottom - rect->top);
+            rect += sizeof(RECT);
+        }
+
+        m_numRects = header->nCount;
+
+        delete[] (char*) rgnData;
+#else
+        RECT rect;
+        ::GetRgnBox(((wxRegionRefData*)region.m_refData)->m_region, &rect);
+        m_rects = new wxRect[1];
+        m_rects[0].x = rect.left;
+        m_rects[0].y = rect.top;
+        m_rects[0].width = rect.right - rect.left;
+        m_rects[0].height = rect.bottom - rect.top;
+
+        m_numRects = 1;
+#endif
+    }
+}
+
+/*!
+ * Increment iterator. The rectangle returned is the one after the
+ * incrementation.
+ */
+void wxRegionIterator::operator ++ (void)
+{
+	if (m_current < m_numRects)
+		++m_current;
+}
+
+/*!
+ * Increment iterator. The rectangle returned is the one before the
+ * incrementation.
+ */
+void wxRegionIterator::operator ++ (int)
+{
+	if (m_current < m_numRects)
+		++m_current;
+}
+
+long wxRegionIterator::GetX(void) const
+{
+	if (m_current < m_numRects)
+		return m_rects[m_current].x;
+	return 0;
+}
+
+long wxRegionIterator::GetY(void) const
+{
+	if (m_current < m_numRects)
+		return m_rects[m_current].y;
+	return 0;
+}
+
+long wxRegionIterator::GetW(void) const
+{
+	if (m_current < m_numRects)
+		return m_rects[m_current].width ;
+	return 0;
+}
+
+long wxRegionIterator::GetH(void) const
+{
+	if (m_current < m_numRects)
+		return m_rects[m_current].height;
+	return 0;
+}
+
diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp
new file mode 100644
index 0000000000..480206990e
--- /dev/null
+++ b/src/msw/registry.cpp
@@ -0,0 +1,670 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        msw/registry.cpp
+// Purpose:     implementation of registry classes and functions
+// Author:      Vadim Zeitlin
+// Modified by: 
+// Created:     03.04.98
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+// TODO:        - parsing of registry key names
+//              - support of other (than REG_SZ/REG_DWORD) registry types
+//              - add high level functions (RegisterOleServer, ...)
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include  "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+// other wxWindows headers
+#include  "wx/string.h"
+#include  "wx/intl.h"
+#include  "wx/log.h"
+
+// Windows headers
+#define   STRICT
+#define   WIN32_LEAN_AND_MEAN
+#include  <windows.h>
+
+// other std headers
+#include  <stdlib.h>      // for _MAX_PATH
+
+#ifndef _MAX_PATH
+#define _MAX_PATH 256
+#endif
+
+// our header
+#define   HKEY_DEFINED    // already defined in windows.h
+#include  "wx/msw/registry.h"
+
+// some registry functions don't like signed chars
+typedef unsigned char *RegString;
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// the standard key names, short names and handles all bundled together for
+// convenient access
+static struct
+{
+  HKEY        hkey;
+  const char *szName;
+  const char *szShortName;
+}
+aStdKeys[] = 
+{ 
+  { HKEY_CLASSES_ROOT,      "HKEY_CLASSES_ROOT",      "HKCR" },
+#ifdef  __WIN32__
+  { HKEY_CURRENT_USER,      "HKEY_CURRENT_USER",      "HKCU" },
+  { HKEY_LOCAL_MACHINE,     "HKEY_LOCAL_MACHINE",     "HKLM" },
+  { HKEY_USERS,             "HKEY_USERS",             "HKU"  }, // short name?
+  { HKEY_PERFORMANCE_DATA,  "HKEY_PERFORMANCE_DATA",  "HKPD" },
+#if     WINVER >= 0x0400
+  { HKEY_CURRENT_CONFIG,    "HKEY_CURRENT_CONFIG",    "HKCC" },
+#ifndef __GNUWIN32__
+  { HKEY_DYN_DATA,          "HKEY_DYN_DATA",          "HKDD" }, // short name?
+#endif  //_GNUWIN32__
+#endif  //WINVER >= 4.0
+#endif  //WIN32
+};
+
+// the registry name separator (perhaps one day MS will change it to '/' ;-)
+#define   REG_SEPARATOR     '\\'
+
+// ----------------------------------------------------------------------------
+// macros
+// ----------------------------------------------------------------------------
+// @ const_cast<> is not yet supported by all compilers
+#define CONST_CAST    ((wxRegKey *)this)->
+
+#if   !USE_MUTABLE
+  #define m_dwLastError   CONST_CAST m_dwLastError
+#endif
+
+// ----------------------------------------------------------------------------
+// non member functions
+// ----------------------------------------------------------------------------
+
+// returns TRUE if given registry key exists
+static bool KeyExists(HKEY hRootKey, const char *szKey);
+
+// combines value and key name (uses static buffer!)
+static const char *GetFullName(const wxRegKey *pKey, 
+                               const char *szValue = NULL);
+
+// ============================================================================
+// implementation of wxRegKey class
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// static functions and variables
+// ----------------------------------------------------------------------------
+
+const size_t wxRegKey::nStdKeys = WXSIZEOF(aStdKeys);
+
+// @@ should take a `StdKey key', but as it's often going to be used in loops
+//    it would require casts in user code.  
+const char *wxRegKey::GetStdKeyName(uint key)
+{
+  // return empty string if key is invalid
+  wxCHECK_RET( key < nStdKeys, "" );
+
+  return aStdKeys[key].szName;
+}
+
+const char *wxRegKey::GetStdKeyShortName(uint key)
+{
+  // return empty string if key is invalid
+  wxCHECK_RET( key < nStdKeys, "" );
+
+  return aStdKeys[key].szShortName;
+}
+
+wxRegKey::StdKey wxRegKey::ExtractKeyName(wxString& strKey)
+{
+  wxString strRoot = strKey.Left(REG_SEPARATOR);
+
+  HKEY hRootKey;
+  uint ui;
+  for ( ui = 0; ui < nStdKeys; ui++ ) {
+    if ( strRoot.CmpNoCase(aStdKeys[ui].szName) == 0 || 
+         strRoot.CmpNoCase(aStdKeys[ui].szShortName) == 0 ) {
+      hRootKey = aStdKeys[ui].hkey;
+      break;
+    }
+  }
+
+  if ( ui == nStdKeys ) {
+    wxFAIL_MSG("invalid key prefix in wxRegKey::ExtractKeyName.");
+
+    hRootKey = HKEY_CLASSES_ROOT;
+  }
+  else {
+    strKey = strKey.After(REG_SEPARATOR);
+    if ( !strKey.IsEmpty() && strKey.Last() == REG_SEPARATOR )
+      strKey.Truncate(strKey.Len() - 1);
+  }
+
+  return (wxRegKey::StdKey)(int)hRootKey;
+}
+
+wxRegKey::StdKey wxRegKey::GetStdKeyFromHkey(HKEY hkey)
+{
+  for ( uint ui = 0; ui < nStdKeys; ui++ ) {
+    if ( aStdKeys[ui].hkey == hkey )
+      return (StdKey)ui;
+  }
+  
+  wxFAIL_MSG("non root hkey passed to wxRegKey::GetStdKeyFromHkey.");
+
+  return HKCR;
+}
+
+// ----------------------------------------------------------------------------
+// ctors and dtor
+// ----------------------------------------------------------------------------
+
+wxRegKey::wxRegKey()
+{
+  m_hKey = 0;
+  m_hRootKey = aStdKeys[HKCR].hkey;
+  m_dwLastError = 0;
+}
+
+wxRegKey::wxRegKey(const wxString& strKey) : m_strKey(strKey)
+{
+  m_hRootKey  = aStdKeys[ExtractKeyName(m_strKey)].hkey;
+  m_hKey      = NULL;
+  m_dwLastError = 0;
+}
+
+// parent is a predefined (and preopened) key
+wxRegKey::wxRegKey(StdKey keyParent, const wxString& strKey) : m_strKey(strKey)
+{
+  if ( !m_strKey.IsEmpty() && m_strKey.Last() == REG_SEPARATOR )
+    m_strKey.Truncate(m_strKey.Len() - 1);
+
+  m_hRootKey  = aStdKeys[keyParent].hkey;
+  m_hKey      = NULL;
+  m_dwLastError = 0;
+}
+
+// parent is a normal regkey
+wxRegKey::wxRegKey(const wxRegKey& keyParent, const wxString& strKey)
+        : m_strKey(keyParent.m_strKey)
+{
+  // combine our name with parent's to get the full name
+  if ( !m_strKey.IsEmpty() )
+      m_strKey  += REG_SEPARATOR;
+
+  m_strKey += strKey;
+  if ( !m_strKey.IsEmpty() && m_strKey.Last() == REG_SEPARATOR )
+    m_strKey.Truncate(m_strKey.Len() - 1);
+
+  m_hRootKey  = keyParent.m_hRootKey;
+  m_hKey      = NULL;
+  m_dwLastError = 0;
+}
+
+// dtor closes the key releasing system resource
+wxRegKey::~wxRegKey()
+{
+  Close();
+}
+
+// ----------------------------------------------------------------------------
+// info about the key
+// ----------------------------------------------------------------------------
+
+// returns TRUE if the key exists
+bool wxRegKey::Exists() const
+{
+  // opened key has to exist, try to open it if not done yet
+  return IsOpened() ? TRUE : KeyExists(m_hRootKey, m_strKey);
+}
+
+// returns the full name of the key (prefix is abbreviated if bShortPrefix)
+wxString wxRegKey::GetName(bool bShortPrefix) const
+{
+  StdKey key = GetStdKeyFromHkey(m_hRootKey);
+  wxString str = bShortPrefix ? aStdKeys[key].szShortName 
+                              : aStdKeys[key].szName;
+  if ( !m_strKey.IsEmpty() )
+    str << "\\" << m_strKey;
+
+  return str;
+}
+
+// ----------------------------------------------------------------------------
+// operations
+// ----------------------------------------------------------------------------
+
+// opens key (it's not an error to call Open() on an already opened key)
+bool wxRegKey::Open()
+{
+  if ( IsOpened() )
+    return TRUE;
+
+  m_dwLastError = RegOpenKey(m_hRootKey, m_strKey, &m_hKey);
+  if ( m_dwLastError != ERROR_SUCCESS ) {
+    wxLogSysError(m_dwLastError, "can't open registry key '%s'", 
+                  GetName().c_str());
+    return FALSE;
+  }
+  else
+    return TRUE;
+}
+
+// creates key, failing if it exists and !bOkIfExists
+bool wxRegKey::Create(bool bOkIfExists)
+{
+  // check for existence only if asked (i.e. order is important!)
+  if ( !bOkIfExists && Exists() ) {
+    return FALSE;
+  }
+
+  if ( IsOpened() )
+    return TRUE;
+
+  m_dwLastError = RegCreateKey(m_hRootKey, m_strKey, &m_hKey);
+  if ( m_dwLastError != ERROR_SUCCESS ) {
+    wxLogSysError(m_dwLastError, "can't create registry key '%s'", 
+                  GetName().c_str());
+    return FALSE;
+  }
+  else
+    return TRUE;
+}
+
+bool wxRegKey::DeleteSelf()
+{
+  if ( !Open() )
+    return FALSE;
+
+  wxString strKey;
+  long lIndex;
+  bool bCont = GetFirstKey(strKey, lIndex);
+  while ( bCont ) {
+    wxRegKey key(*this, strKey);
+    if ( !key.DeleteSelf() )
+      return FALSE;
+
+    bCont = GetNextKey(strKey, lIndex);
+  }
+
+  Close();
+
+  m_dwLastError = RegDeleteKey(m_hRootKey, m_strKey);
+  if ( m_dwLastError != ERROR_SUCCESS ) {
+    wxLogSysError(m_dwLastError, "can't delete key '%s'", GetName().c_str());
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+bool wxRegKey::DeleteKey(const char *szKey)
+{
+  if ( !Open() )
+    return FALSE;
+
+  wxRegKey key(*this, szKey);
+  return key.DeleteSelf();
+}
+
+bool wxRegKey::DeleteValue(const char *szValue)
+{
+  if ( !Open() )
+    return FALSE;
+
+  #ifdef  __WIN32__
+    m_dwLastError = RegDeleteValue(m_hKey, szValue);
+    if ( m_dwLastError != ERROR_SUCCESS ) {
+      wxLogSysError(m_dwLastError, "can't delete value '%s' from key '%s'",
+                    szValue, GetName().c_str());
+      return FALSE;
+    }
+  #else   //WIN16
+    // named registry values don't exist in Win16 world
+    wxASSERT( IsEmpty(szValue) );
+
+    // just set the (default and unique) value of the key to ""
+    m_dwLastError = RegSetValue(m_hKey, NULL, REG_SZ, "", RESERVED);
+    if ( m_dwLastError != ERROR_SUCCESS ) {
+      wxLogSysError(m_dwLastError, "can't delete value of key '%s'", 
+                    GetName().c_str());
+      return FALSE;
+    }
+  #endif  //WIN16/32
+
+  return TRUE;
+}
+
+// close the key, it's not an error to call it when not opened
+bool wxRegKey::Close()
+{
+  if ( IsOpened() ) {
+    m_dwLastError = RegCloseKey(m_hKey);
+    if ( m_dwLastError != ERROR_SUCCESS ) {
+      wxLogSysError(m_dwLastError, "can't close registry key '%s'", 
+                    GetName().c_str());
+
+      m_hKey = 0;
+      return FALSE;
+    }
+    else {
+      m_hKey = 0;
+    }
+  }
+
+  return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// access to values and subkeys
+// ----------------------------------------------------------------------------
+
+// returns TRUE if this key has any subkeys
+bool wxRegKey::HasSubkeys() const
+{
+  // just call GetFirstKey with dummy parameters
+  wxString str;
+  long     l;
+  return CONST_CAST GetFirstKey(str, l);
+}
+
+// returns TRUE if given subkey exists
+bool wxRegKey::HasSubKey(const char *szKey) const
+{
+  if ( CONST_CAST Open() )
+    return KeyExists(m_hKey, szKey);
+  else
+    return FALSE;
+}
+
+wxRegKey::ValueType wxRegKey::GetValueType(const char *szValue)
+{
+  #ifdef  __WIN32__
+    if ( !Open() )
+      return Type_None;
+
+    DWORD dwType;
+    m_dwLastError = RegQueryValueEx(m_hKey, szValue, RESERVED,
+                                    &dwType, NULL, NULL);
+    if ( m_dwLastError != ERROR_SUCCESS ) {
+      wxLogSysError(m_dwLastError, "can't read value of key '%s'", 
+                    GetName().c_str());
+      return Type_None;
+    }
+
+    return (ValueType)dwType;
+  #else   //WIN16
+    return IsEmpty(szValue) ? Type_String : Type_None;
+  #endif  //WIN16/32
+}
+
+#ifdef  __WIN32__
+bool wxRegKey::SetValue(const char *szValue, long lValue)
+{
+  if ( CONST_CAST Open() ) {
+    m_dwLastError = RegSetValueEx(m_hKey, szValue, RESERVED, REG_DWORD, 
+                                  (RegString)&lValue, sizeof(lValue));
+    if ( m_dwLastError == ERROR_SUCCESS )
+      return TRUE;
+  }
+
+  wxLogSysError(m_dwLastError, "can't set value of '%s'", 
+                GetFullName(this, szValue));
+  return FALSE;
+}
+
+bool wxRegKey::QueryValue(const char *szValue, long *plValue) const
+{
+  if ( CONST_CAST Open() ) {
+    DWORD dwType, dwSize = sizeof(DWORD);
+    RegString pBuf = (RegString)plValue;
+    m_dwLastError = RegQueryValueEx(m_hKey, szValue, RESERVED, 
+                                    &dwType, pBuf, &dwSize);
+    if ( m_dwLastError != ERROR_SUCCESS ) {
+      wxLogSysError(m_dwLastError, "can't read value of key '%s'", 
+                    GetName().c_str());
+      return FALSE;
+    }
+    else {
+      // check that we read the value of right type
+      wxASSERT_MSG( dwType == REG_DWORD, 
+                    "Type mismatch in wxRegKey::QueryValue()."  );
+
+      return TRUE;
+    }
+  }
+  else
+    return FALSE;
+}
+
+#endif  //Win32
+
+bool wxRegKey::QueryValue(const char *szValue, wxString& strValue) const
+{
+  if ( CONST_CAST Open() ) {
+    #ifdef  __WIN32__
+      // first get the type and size of the data
+      DWORD dwType, dwSize;
+      m_dwLastError = RegQueryValueEx(m_hKey, szValue, RESERVED, 
+                                      &dwType, NULL, &dwSize);
+      if ( m_dwLastError == ERROR_SUCCESS ) {
+        RegString pBuf = (RegString)strValue.GetWriteBuf(dwSize);
+        m_dwLastError = RegQueryValueEx(m_hKey, szValue, RESERVED, 
+                                        &dwType, pBuf, &dwSize);
+        if ( m_dwLastError == ERROR_SUCCESS ) {
+          // check that it was the right type
+          wxASSERT_MSG( dwType == REG_SZ, 
+                        "Type mismatch in wxRegKey::QueryValue()." );
+
+          return TRUE;
+        }
+      }
+    #else   //WIN16
+      // named registry values don't exist in Win16
+      wxASSERT( IsEmpty(szValue) );
+
+      m_dwLastError = RegQueryValue(m_hKey, 0, strValue.GetWriteBuf(256), &l);
+      if ( m_dwLastError == ERROR_SUCCESS )
+        return TRUE;
+    #endif  //WIN16/32
+  }
+
+  wxLogSysError(m_dwLastError, "can't read value of '%s'", 
+                GetFullName(this, szValue));
+  return FALSE;
+}
+
+bool wxRegKey::SetValue(const char *szValue, const wxString& strValue)
+{
+  if ( CONST_CAST Open() ) {
+    #ifdef  __WIN32__
+      m_dwLastError = RegSetValueEx(m_hKey, szValue, RESERVED, REG_SZ, 
+                                    (RegString)strValue.c_str(), 
+                                    strValue.Len() + 1);
+      if ( m_dwLastError == ERROR_SUCCESS )
+        return TRUE;
+    #else   //WIN16
+      // named registry values don't exist in Win16
+      wxASSERT( IsEmpty(szValue) );
+
+      m_dwLastError = RegSetValue(m_hKey, NULL, REG_SZ, strValue, NULL);
+      if ( m_dwLastError == ERROR_SUCCESS )
+        return TRUE;
+    #endif  //WIN16/32
+  }
+
+  wxLogSysError(m_dwLastError, "can't set value of '%s'", 
+                GetFullName(this, szValue));
+  return FALSE;
+}
+
+wxRegKey::operator wxString() const
+{
+  wxString str;
+  QueryValue(NULL, str);
+  return str;
+}
+
+// ----------------------------------------------------------------------------
+// enumeration
+// NB: all these functions require an index variable which allows to have
+//     several concurrently running indexations on the same key
+// ----------------------------------------------------------------------------
+
+#ifdef  __WIN32__
+bool wxRegKey::GetFirstValue(wxString& strValueName, long& lIndex)
+{
+  if ( !Open() )
+    return FALSE;
+
+  char  szValueName[1024];                  // @@ use RegQueryInfoKey...
+  DWORD dwValueLen = WXSIZEOF(szValueName);
+
+  lIndex = 0;
+  m_dwLastError = RegEnumValue(m_hKey, lIndex, 
+                               szValueName, &dwValueLen,
+                               RESERVED, 
+                               NULL,            // [out] type 
+                               NULL,            // [out] buffer for value
+                               NULL);           // [i/o]  it's length
+
+  if ( m_dwLastError != ERROR_SUCCESS ) {
+    if ( m_dwLastError == ERROR_NO_MORE_ITEMS )
+      lIndex = -1;
+    else {
+      wxLogSysError(m_dwLastError, "can't enumerate values of key '%s'", 
+                    GetName().c_str());
+    }
+
+    return FALSE;
+  }
+
+  strValueName = szValueName;
+  return TRUE;
+}
+
+bool wxRegKey::GetNextValue(wxString& strValueName, long& lIndex) const
+{
+  wxASSERT( IsOpened() );
+  wxASSERT( lIndex != -1 );
+
+  char  szValueName[1024];                  // @@ use RegQueryInfoKey...
+  DWORD dwValueLen = WXSIZEOF(szValueName);
+
+  lIndex++;
+  m_dwLastError = RegEnumValue(m_hKey, lIndex, 
+                               szValueName, &dwValueLen,
+                               RESERVED, 
+                               NULL,           // buffer for type 
+                               NULL, NULL);    // buffer for value and length
+
+  if ( m_dwLastError != ERROR_SUCCESS ) {
+    if ( m_dwLastError == ERROR_NO_MORE_ITEMS ) {
+      m_dwLastError = ERROR_SUCCESS;
+      lIndex = -1;
+    }
+    else {
+      wxLogSysError(m_dwLastError, "can't enumerate values of key '%s'", 
+                    GetName().c_str());
+    }
+
+    return FALSE;
+  }
+
+  strValueName = szValueName;
+  return TRUE;
+}
+#endif  //Win32
+
+bool wxRegKey::GetFirstKey(wxString& strKeyName, long& lIndex)
+{
+  if ( !Open() )
+    return FALSE;
+
+  char szKeyName[_MAX_PATH + 1];
+  lIndex = 0;
+  m_dwLastError = RegEnumKey(m_hKey, lIndex, szKeyName, WXSIZEOF(szKeyName));
+
+  if ( m_dwLastError != ERROR_SUCCESS ) {
+    if ( m_dwLastError == ERROR_NO_MORE_ITEMS ) {
+      m_dwLastError = ERROR_SUCCESS;
+      lIndex = -1;
+    }
+    else {
+      wxLogSysError(m_dwLastError, "can't enumerate subkeys of key '%s'", 
+                    GetName().c_str());
+    }
+
+    return FALSE;
+  }
+
+  strKeyName = szKeyName;
+  return TRUE;
+}
+
+bool wxRegKey::GetNextKey(wxString& strKeyName, long& lIndex) const
+{
+  wxASSERT( IsOpened() );
+  wxASSERT( lIndex != -1 );
+
+  char szKeyName[_MAX_PATH + 1];
+  lIndex++;
+  m_dwLastError = RegEnumKey(m_hKey, lIndex, szKeyName, WXSIZEOF(szKeyName));
+
+  if ( m_dwLastError != ERROR_SUCCESS ) {
+    if ( m_dwLastError == ERROR_NO_MORE_ITEMS ) {
+      m_dwLastError = ERROR_SUCCESS;
+      lIndex = -1;
+    }
+    else {
+      wxLogSysError(m_dwLastError, "can't enumerate subkeys of key '%s'", 
+                    GetName().c_str());
+    }
+
+    return FALSE;
+  }
+
+  strKeyName = szKeyName;
+  return TRUE;
+}
+
+// ============================================================================
+// implementation of global functions
+// ============================================================================
+bool KeyExists(HKEY hRootKey, const char *szKey)
+{
+  HKEY hkeyDummy;
+  if ( RegOpenKey(hRootKey, szKey, &hkeyDummy) == ERROR_SUCCESS ) {
+    RegCloseKey(hkeyDummy);
+    return TRUE;
+  }
+  else
+    return FALSE;
+}
+
+const char *GetFullName(const wxRegKey *pKey, const char *szValue)
+{
+  static wxString s_str;
+  s_str = pKey->GetName();
+  if ( !IsEmpty(szValue) )
+    s_str << "\\" << szValue;
+
+  return s_str.c_str();
+}
\ No newline at end of file
diff --git a/src/msw/scrolbar.cpp b/src/msw/scrolbar.cpp
new file mode 100644
index 0000000000..e61cd8e178
--- /dev/null
+++ b/src/msw/scrolbar.cpp
@@ -0,0 +1,349 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        scrolbar.cpp
+// Purpose:     wxScrollBar
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "scrolbar.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/defs.h"
+#include "wx/utils.h"
+#endif
+
+#include "wx/scrolbar.h"
+#include "wx/msw/private.h"
+
+// extern wxList wxScrollBarList;
+extern void wxFindMaxSize(HWND hwnd, RECT *rect);
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
+
+#if WXWIN_COMPATIBILITY
+BEGIN_EVENT_TABLE(wxScrollBar, wxControl)
+  EVT_SCROLL(wxScrollBar::OnScroll)
+END_EVENT_TABLE()
+#endif
+
+#endif
+
+// Scrollbar
+bool wxScrollBar::Create(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos,
+           const wxSize& size, const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+    if (!parent)
+        return FALSE;
+    parent->AddChild(this);
+    SetName(name);
+	SetValidator(validator);
+    
+    SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
+    SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+    m_windowStyle = style;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+    if (width == -1)
+    {
+      if (style & wxHORIZONTAL)
+        width = 140;
+      else
+        width = 14;
+    }
+    if (height == -1)
+    {
+      if (style & wxVERTICAL)
+        height = 140;
+      else
+        height = 14;
+    }
+
+    // Now create scrollbar
+    DWORD _direction = (style & wxHORIZONTAL) ?
+                        SBS_HORZ: SBS_VERT;
+    HWND scroll_bar = CreateWindowEx(MakeExtendedStyle(style), "SCROLLBAR", "scrollbar",
+                         _direction | WS_CHILD | WS_VISIBLE,
+                         0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                         wxGetInstance(), NULL);
+
+    m_pageSize = 1;
+    m_viewSize = 1;
+    m_objectSize = 1;
+
+    ::SetScrollRange(scroll_bar, SB_CTL, 0, 1, FALSE);
+    ::SetScrollPos(scroll_bar, SB_CTL, 0, FALSE);
+    ShowWindow(scroll_bar, SW_SHOW);
+
+    m_hWnd = (WXHWND)scroll_bar;
+
+    // Subclass again for purposes of dialog editing mode
+    SubclassWin((WXHWND) scroll_bar);
+
+    SetSize(x, y, width, height);
+
+    return TRUE;
+}
+
+wxScrollBar::~wxScrollBar(void)
+{
+}
+
+void wxScrollBar::MSWOnVScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control)
+{
+    int position = ::GetScrollPos((HWND) control, SB_CTL);
+    int minPos, maxPos;
+    ::GetScrollRange((HWND) control, SB_CTL, &minPos, &maxPos);
+#if defined(__WIN95__)
+    // A page size greater than one has the effect of reducing the
+	// effective range, therefore the range has already been
+	// boosted artificially - so reduce it again.
+	if ( m_pageSize > 1 )
+		maxPos -= (m_pageSize - 1);
+#endif
+
+    int scrollEvent = 0;
+
+    int nScrollInc;
+    switch ( wParam )
+    {
+            case SB_TOP:
+                    nScrollInc = maxPos - position;
+                    scrollEvent = wxEVT_SCROLL_TOP;
+                    break;
+
+            case SB_BOTTOM:
+                    nScrollInc = - position;
+                    scrollEvent = wxEVT_SCROLL_BOTTOM;
+                    break;
+
+            case SB_LINEUP:
+                    nScrollInc = -1;
+                    scrollEvent = wxEVT_SCROLL_LINEUP;
+                    break;
+
+            case SB_LINEDOWN:
+                    nScrollInc = 1;
+                    scrollEvent = wxEVT_SCROLL_LINEDOWN;
+                    break;
+
+            case SB_PAGEUP:
+                    nScrollInc = -GetPageSize();
+                    scrollEvent = wxEVT_SCROLL_PAGEUP;
+                    break;
+
+            case SB_PAGEDOWN:
+                    nScrollInc = GetPageSize();
+                    scrollEvent = wxEVT_SCROLL_PAGEDOWN;
+                    break;
+
+            case SB_THUMBTRACK:
+            case SB_THUMBPOSITION:
+                    nScrollInc = pos - position;
+                    scrollEvent = wxEVT_SCROLL_THUMBTRACK;
+                    break;
+
+            default:
+                    nScrollInc = 0;
+    }
+
+    if (nScrollInc != 0)
+    {
+        int new_pos = position + nScrollInc;
+
+        if (new_pos < 0)
+            new_pos = 0;
+        if (new_pos > maxPos)
+            new_pos = maxPos;
+
+        SetValue(new_pos);
+        wxScrollEvent event(scrollEvent, m_windowId);
+        event.SetPosition(new_pos);
+        event.SetEventObject( this );
+        GetEventHandler()->ProcessEvent(event);
+    }
+}
+
+void wxScrollBar::MSWOnHScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control)
+{
+	MSWOnVScroll(wParam, pos, control);
+}
+
+void wxScrollBar::SetPosition(const int viewStart)
+{
+#if defined(__WIN95__)
+  SCROLLINFO info;
+  info.cbSize = sizeof(SCROLLINFO);
+  info.nPage = 0;
+  info.nMin = 0;
+  info.nPos = viewStart;
+  info.fMask = SIF_POS ;
+
+  ::SetScrollInfo((HWND) GetHWND(), SB_CTL, &info, TRUE);
+#else
+  ::SetScrollPos((HWND) GetHWND(), SB_CTL, viewStart, TRUE);
+#endif
+}
+
+int wxScrollBar::GetPosition(void) const
+{
+    return ::GetScrollPos((HWND)m_hWnd, SB_CTL);
+}
+
+void wxScrollBar::SetScrollbar(const int position, const int thumbSize, const int range, const int pageSize,
+    const bool refresh)
+{
+  m_viewSize = pageSize;
+  m_pageSize = thumbSize;
+  m_objectSize = range;
+
+  // The range (number of scroll steps) is the
+  // object length minus the page size.
+  int range1 = wxMax((m_objectSize - m_pageSize), 0) ;
+
+#if defined(__WIN95__)
+  // Try to adjust the range to cope with page size > 1
+  // (see comment for SetPageLength)
+  if ( m_pageSize > 1 )
+  {
+	range1 += (m_pageSize - 1);
+  }
+
+  SCROLLINFO info;
+  info.cbSize = sizeof(SCROLLINFO);
+  info.nPage = m_pageSize;
+  info.nMin = 0;
+  info.nMax = range1;
+  info.nPos = position;
+
+  info.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
+
+  ::SetScrollInfo((HWND) GetHWND(), SB_CTL, &info, refresh);
+#else
+  ::SetScrollPos((HWND)m_hWnd, SB_CTL, position, TRUE);
+  ::SetScrollRange((HWND)m_hWnd, SB_CTL, 0, range1, TRUE);
+#endif
+}
+
+
+/* From the WIN32 documentation:
+In version 4.0 or later, the maximum value that a scroll bar can report
+(that is, the maximum scrolling position) depends on the page size.
+If the scroll bar has a page size greater than one, the maximum scrolling position
+is less than the maximum range value. You can use the following formula to calculate
+the maximum scrolling position:
+  
+MaxScrollPos = MaxRangeValue - (PageSize - 1) 
+*/
+
+#if WXWIN_COMPATIBILITY
+void wxScrollBar::SetPageSize(const int pageLength)
+{
+  m_pageSize = pageLength;
+
+#if defined(__WIN95__)
+  SCROLLINFO info;
+  info.cbSize = sizeof(SCROLLINFO);
+  info.nPage = pageLength;
+  info.fMask = SIF_PAGE ;
+
+  ::SetScrollInfo((HWND) GetHWND(), SB_CTL, &info, TRUE);
+#endif
+}
+
+void wxScrollBar::SetObjectLength(const int objectLength)
+{
+  m_objectSize = objectLength;
+
+  // The range (number of scroll steps) is the
+  // object length minus the view size.
+  int range = wxMax((objectLength - m_viewSize), 0) ;
+
+#if defined(__WIN95__)
+  // Try to adjust the range to cope with page size > 1
+  // (see comment for SetPageLength)
+  if ( m_pageSize > 1 )
+  {
+	range += (m_pageSize - 1);
+  }
+
+  SCROLLINFO info;
+  info.cbSize = sizeof(SCROLLINFO);
+  info.nPage = 0;
+  info.nMin = 0;
+  info.nMax = range;
+  info.nPos = 0;
+  info.fMask = SIF_RANGE ;
+
+  ::SetScrollInfo((HWND) GetHWND(), SB_CTL, &info, TRUE);
+#else
+  ::SetScrollRange((HWND)m_hWnd, SB_CTL, 0, range, TRUE);
+#endif
+}
+
+void wxScrollBar::SetViewLength(const int viewLength)
+{
+    m_viewSize = viewLength;
+}
+
+void wxScrollBar::GetValues(int *viewStart, int *viewLength, int *objectLength,
+           int *pageLength) const
+{
+    *viewStart = ::GetScrollPos((HWND)m_hWnd, SB_CTL);
+    *viewLength = m_viewSize;
+    *objectLength = m_objectSize;
+    *pageLength = m_pageSize;
+}
+#endif
+
+WXHBRUSH wxScrollBar::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+  return 0;
+}
+
+void wxScrollBar::Command(wxCommandEvent& event)
+{
+    SetValue(event.m_commandInt);
+    ProcessCommand(event);
+}
+
+#if WXWIN_COMPATIBILITY
+// Backward compatibility
+void wxScrollBar::OnScroll(wxScrollEvent& event)
+{
+    int oldEvent = event.GetEventType();
+    event.SetEventType( wxEVT_COMMAND_SCROLLBAR_UPDATED );
+    if ( !GetEventHandler()->ProcessEvent(event) )
+    {
+        event.SetEventType( oldEvent );
+        if (!GetParent()->GetEventHandler()->ProcessEvent(event))
+            event.Skip();
+    }
+}
+#endif
diff --git a/src/msw/settings.cpp b/src/msw/settings.cpp
new file mode 100644
index 0000000000..1de9962cee
--- /dev/null
+++ b/src/msw/settings.cpp
@@ -0,0 +1,166 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        settings.cpp
+// Purpose:     wxSettings
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "settings.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/defs.h"
+#include "wx/pen.h"
+#include "wx/brush.h"
+#include "wx/gdicmn.h"
+#endif
+
+#include "wx/settings.h"
+#include "wx/window.h"
+#include "wx/msw/private.h"
+
+// TODO: see ::SystemParametersInfo for all sorts of Windows settings.
+// Different args are required depending on the id. How does this differ
+// from GetSystemMetric, and should it? Perhaps call it GetSystemParameter
+// and pass an optional void* arg to get further info.
+// Should also have SetSystemParameter.
+// Also implement WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95)
+
+wxColour wxSystemSettings::GetSystemColour(int index)
+{
+	COLORREF ref = ::GetSysColor(index);
+	wxColour col(GetRValue(ref), GetGValue(ref), GetBValue(ref));
+	return col;
+}
+
+wxFont wxSystemSettings::GetSystemFont(int index)
+{
+	HFONT hFont = (HFONT) ::GetStockObject(index);
+	if ( hFont != NULL )
+	{
+		LOGFONT lf;
+		if ( ::GetObject(hFont, sizeof(LOGFONT), &lf) != 0 )
+		{
+		    // In fontdlg.cpp
+			return wxCreateFontFromLogFont(&lf);
+		}
+		else
+		{
+			return wxNullFont;
+		}
+	}
+	else
+	{
+		return wxNullFont;
+	}
+}
+
+// Get a system metric, e.g. scrollbar size
+int wxSystemSettings::GetSystemMetric(int index)
+{
+	switch ( index)
+	{
+#ifdef __WIN32__
+        case wxSYS_MOUSE_BUTTONS:
+			return ::GetSystemMetrics(SM_CMOUSEBUTTONS);
+#endif
+
+        case wxSYS_BORDER_X:
+			return ::GetSystemMetrics(SM_CXBORDER);
+        case wxSYS_BORDER_Y:
+			return ::GetSystemMetrics(SM_CYBORDER);
+        case wxSYS_CURSOR_X:
+			return ::GetSystemMetrics(SM_CXCURSOR);
+        case wxSYS_CURSOR_Y:
+			return ::GetSystemMetrics(SM_CYCURSOR);
+        case wxSYS_DCLICK_X:
+			return ::GetSystemMetrics(SM_CXDOUBLECLK);
+        case wxSYS_DCLICK_Y:
+			return ::GetSystemMetrics(SM_CYDOUBLECLK);
+#ifdef __WIN32__
+        case wxSYS_DRAG_X:
+			return ::GetSystemMetrics(SM_CXDRAG);
+        case wxSYS_DRAG_Y:
+			return ::GetSystemMetrics(SM_CYDRAG);
+        case wxSYS_EDGE_X:
+			return ::GetSystemMetrics(SM_CXEDGE);
+        case wxSYS_EDGE_Y:
+			return ::GetSystemMetrics(SM_CYEDGE);
+#endif
+        case wxSYS_HSCROLL_ARROW_X:
+			return ::GetSystemMetrics(SM_CXHSCROLL);
+        case wxSYS_HSCROLL_ARROW_Y:
+			return ::GetSystemMetrics(SM_CYHSCROLL);
+        case wxSYS_HTHUMB_X:
+			return ::GetSystemMetrics(SM_CXHTHUMB);
+        case wxSYS_ICON_X:
+			return ::GetSystemMetrics(SM_CXICON);
+        case wxSYS_ICON_Y:
+			return ::GetSystemMetrics(SM_CYICON);
+        case wxSYS_ICONSPACING_X:
+			return ::GetSystemMetrics(SM_CXICONSPACING);
+        case wxSYS_ICONSPACING_Y:
+			return ::GetSystemMetrics(SM_CYICONSPACING);
+        case wxSYS_WINDOWMIN_X:
+			return ::GetSystemMetrics(SM_CXMIN);
+        case wxSYS_WINDOWMIN_Y:
+			return ::GetSystemMetrics(SM_CYMIN);
+        case wxSYS_SCREEN_X:
+			return ::GetSystemMetrics(SM_CXSCREEN);
+        case wxSYS_SCREEN_Y:
+			return ::GetSystemMetrics(SM_CYSCREEN);
+#ifdef __WIN32__
+        case wxSYS_FRAMESIZE_X:
+			return ::GetSystemMetrics(SM_CXSIZEFRAME);
+        case wxSYS_FRAMESIZE_Y:
+			return ::GetSystemMetrics(SM_CYSIZEFRAME);
+        case wxSYS_SMALLICON_X:
+			return ::GetSystemMetrics(SM_CXSMICON);
+        case wxSYS_SMALLICON_Y:
+			return ::GetSystemMetrics(SM_CYSMICON);
+#endif
+        case wxSYS_HSCROLL_Y:
+			return ::GetSystemMetrics(SM_CYHSCROLL);
+        case wxSYS_VSCROLL_X:
+			return ::GetSystemMetrics(SM_CXVSCROLL);
+        case wxSYS_VSCROLL_ARROW_X:
+			return ::GetSystemMetrics(SM_CXVSCROLL);
+        case wxSYS_VSCROLL_ARROW_Y:
+			return ::GetSystemMetrics(SM_CYVSCROLL);
+        case wxSYS_VTHUMB_Y:
+			return ::GetSystemMetrics(SM_CYVTHUMB);
+        case wxSYS_CAPTION_Y:
+			return ::GetSystemMetrics(SM_CYCAPTION);
+        case wxSYS_MENU_Y:
+			return ::GetSystemMetrics(SM_CYMENU);
+#ifdef __WIN32__
+        case wxSYS_NETWORK_PRESENT:
+			return ::GetSystemMetrics(SM_NETWORK) & 0x0001;
+#endif
+        case wxSYS_PENWINDOWS_PRESENT:
+			return ::GetSystemMetrics(SM_PENWINDOWS);
+#ifdef __WIN32__
+        case wxSYS_SHOW_SOUNDS:
+			return ::GetSystemMetrics(SM_SHOWSOUNDS);
+#endif
+        case wxSYS_SWAP_BUTTONS:
+			return ::GetSystemMetrics(SM_SWAPBUTTON);
+		default:
+			return 0;
+	}
+	return 0;
+}
+
diff --git a/src/msw/slider.cpp b/src/msw/slider.cpp
new file mode 100644
index 0000000000..275e19e3d6
--- /dev/null
+++ b/src/msw/slider.cpp
@@ -0,0 +1,790 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        slider.cpp
+// Purpose:     wxSlider
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "slider.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/slider.h"
+#endif
+
+#include "wx/msw/private.h"
+
+// Can opt to not use track bar under Win95 if you prefer it - set to 0
+#define USE_TRACK_BAR 1
+
+#if defined(__WIN95__) && !defined(__GNUWIN32__)
+#include <commctrl.h>
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl)
+
+#if WXWIN_COMPATIBILITY
+BEGIN_EVENT_TABLE(wxSlider, wxControl)
+  EVT_SCROLL(wxSlider::OnScroll)
+END_EVENT_TABLE()
+#endif
+
+#endif
+
+// Slider
+wxSlider::wxSlider(void)
+{
+  m_staticValue = 0;
+  m_staticMin = 0;
+  m_staticMax = 0;
+  m_pageSize = 1;
+  m_lineSize = 1;
+  m_rangeMax = 0;
+  m_rangeMin = 0;
+  m_tickFreq = 0;
+}
+
+bool wxSlider::Create(wxWindow *parent, const wxWindowID id,
+           const int value, const int minValue, const int maxValue,
+           const wxPoint& pos,
+           const wxSize& size, const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  SetName(name);
+  SetValidator(validator);
+
+  if (parent) parent->AddChild(this);
+  SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
+  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+
+  m_staticValue = 0;
+  m_staticMin = 0;
+  m_staticMax = 0;
+  m_pageSize = 1;
+  m_lineSize = 1;
+  m_windowStyle = style;
+  m_tickFreq = 0;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+#if defined(__WIN95__) && USE_TRACK_BAR
+  long msStyle ;
+
+  if ( m_windowStyle & wxSL_LABELS )
+  {
+      msStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER;
+
+      bool want3D;
+      WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+      m_staticValue = (WXHWND) CreateWindowEx(exStyle, "STATIC", NULL,
+                               msStyle,
+                               0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
+                               wxGetInstance(), NULL);
+
+      // Now create min static control
+      sprintf(wxBuffer, "%d", minValue);
+      m_staticMin = (WXHWND) CreateWindowEx(0, "STATIC", wxBuffer,
+                             STATIC_FLAGS,
+                             0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
+                             wxGetInstance(), NULL);
+  }
+
+  msStyle = 0;
+  if (m_windowStyle & wxSL_VERTICAL)
+    msStyle = TBS_VERT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ;
+  else
+    msStyle = TBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP ;
+
+  if ( m_windowStyle & wxSL_AUTOTICKS )
+	msStyle |= TBS_AUTOTICKS ;
+
+  if ( m_windowStyle & wxSL_LEFT )
+	msStyle |= TBS_LEFT;
+  else if ( m_windowStyle & wxSL_RIGHT )
+  	msStyle |= TBS_RIGHT;
+  else if ( m_windowStyle & wxSL_TOP )
+	msStyle |= TBS_TOP;
+  else if ( m_windowStyle & wxSL_BOTTOM )
+	msStyle |= TBS_BOTTOM;
+  else if ( m_windowStyle & wxSL_BOTH )
+	msStyle |= TBS_BOTH;
+  else if ( ! (m_windowStyle & wxSL_AUTOTICKS) )
+	msStyle |= TBS_NOTICKS;
+
+  if ( m_windowStyle & wxSL_SELRANGE )
+	msStyle |= TBS_ENABLESELRANGE ;
+
+  HWND scroll_bar = CreateWindowEx(MakeExtendedStyle(m_windowStyle), TRACKBAR_CLASS, wxBuffer,
+                         msStyle,
+                         0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                         wxGetInstance(), NULL);
+
+  m_rangeMax = maxValue;
+  m_rangeMin = minValue;
+
+  m_pageSize = (int)((maxValue-minValue)/10);
+
+  ::SendMessage(scroll_bar, TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue));
+  ::SendMessage(scroll_bar, TBM_SETPOS, TRUE, (LPARAM)value);
+  ::SendMessage(scroll_bar, TBM_SETPAGESIZE, 0, (LPARAM)m_pageSize);
+
+  m_hWnd = (WXHWND)scroll_bar;
+
+  SubclassWin(GetHWND());
+
+  if ( m_windowStyle & wxSL_LABELS )
+  {
+      // Finally, create max value static item
+      sprintf(wxBuffer, "%d", maxValue);
+      m_staticMax = (WXHWND) CreateWindowEx(0, "STATIC", wxBuffer,
+                             STATIC_FLAGS,
+                             0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
+                             wxGetInstance(), NULL);
+
+      SetFont(parent->GetFont());
+
+      if (GetFont())
+      {
+//        GetFont()->RealizeResource();
+        if (GetFont()->GetResourceHandle())
+        {
+		    if ( m_staticMin )
+      		    SendMessage((HWND)m_staticMin,WM_SETFONT,
+                  	    (WPARAM)GetFont()->GetResourceHandle(),0L);
+		    if ( m_staticMax )
+      		    SendMessage((HWND)m_staticMax,WM_SETFONT,
+                      (WPARAM)GetFont()->GetResourceHandle(),0L);
+      	    if (m_staticValue)
+        	    SendMessage((HWND)m_staticValue,WM_SETFONT,
+                        (WPARAM)GetFont()->GetResourceHandle(),0L);
+        }
+      }
+  }
+#else
+  // non-Win95 implementation
+  
+  long msStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER;
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+  m_staticValue = (WXHWND) CreateWindowEx(exStyle, "STATIC", NULL,
+                           msStyle,
+                           0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
+                           wxGetInstance(), NULL);
+
+  // Now create min static control
+  sprintf(wxBuffer, "%d", minValue);
+  m_staticMin = (WXHWND) CreateWindowEx(0, "STATIC", wxBuffer,
+                         STATIC_FLAGS,
+                         0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
+                         wxGetInstance(), NULL);
+
+  // Now create slider
+  m_windowId = (int)NewControlId();
+
+  msStyle = 0;
+  if (m_windowStyle & wxSL_VERTICAL)
+    msStyle = SBS_VERT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ;
+  else
+    msStyle = SBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP ;
+
+  HWND scroll_bar = CreateWindowEx(MakeExtendedStyle(m_windowStyle), "SCROLLBAR", wxBuffer,
+                         msStyle,
+                         0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                         wxGetInstance(), NULL);
+
+  m_pageSize = (int)((maxValue-minValue)/10);
+  m_rangeMax = maxValue;
+  m_rangeMin = minValue;
+
+  ::SetScrollRange(scroll_bar, SB_CTL, minValue, maxValue, FALSE);
+  ::SetScrollPos(scroll_bar, SB_CTL, value, FALSE);
+  ShowWindow(scroll_bar, SW_SHOW);
+
+  m_hWnd = (WXHWND)scroll_bar;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin(GetHWND());
+
+  // Finally, create max value static item
+  sprintf(wxBuffer, "%d", maxValue);
+  m_staticMax = (WXHWND) CreateWindowEx(0, "STATIC", wxBuffer,
+                         STATIC_FLAGS,
+                         0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
+                         wxGetInstance(), NULL);
+
+  SetFont(* parent->GetFont());
+
+  if (GetFont())
+  {
+//    GetFont()->RealizeResource();
+    if (GetFont()->GetResourceHandle())
+    {
+		if ( m_staticMin )
+      		SendMessage((HWND)m_staticMin,WM_SETFONT,
+                  	(WPARAM)GetFont()->GetResourceHandle(),0L);
+		if ( m_staticMax )
+      		SendMessage((HWND)m_staticMax,WM_SETFONT,
+                  (WPARAM)GetFont()->GetResourceHandle(),0L);
+      	if (m_staticValue)
+        	SendMessage((HWND)m_staticValue,WM_SETFONT,
+                    (WPARAM)GetFont()->GetResourceHandle(),0L);
+    }
+  }
+#endif
+
+  SetSize(x, y, width, height);
+  SetValue(value);
+
+  return TRUE;
+}
+
+void wxSlider::MSWOnVScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control)
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+    int position = 0; // Dummy - not used in this mode
+#else
+    int position = ::GetScrollPos((HWND)control, SB_CTL);
+#endif
+
+    int nScrollInc;
+    int scrollEvent = 0;
+    switch ( wParam )
+    {
+            case SB_TOP:
+                    nScrollInc = m_rangeMax - position;
+                    scrollEvent = wxEVT_SCROLL_TOP;
+                    break;
+
+            case SB_BOTTOM:
+                    nScrollInc = - position;
+                    scrollEvent = wxEVT_SCROLL_BOTTOM;
+                    break;
+
+            case SB_LINEUP:
+                    nScrollInc = - GetLineSize();
+                    scrollEvent = wxEVT_SCROLL_LINEUP;
+                    break;
+
+            case SB_LINEDOWN:
+                    nScrollInc = GetLineSize();
+                    scrollEvent = wxEVT_SCROLL_LINEDOWN;
+                    break;
+
+            case SB_PAGEUP:
+                    nScrollInc = -GetPageSize();
+                    scrollEvent = wxEVT_SCROLL_PAGEUP;
+                    break;
+
+            case SB_PAGEDOWN:
+                    nScrollInc = GetPageSize();
+                    scrollEvent = wxEVT_SCROLL_PAGEDOWN;
+                    break;
+
+            case SB_THUMBTRACK:
+            case SB_THUMBPOSITION:
+#ifdef __WIN32__
+                    nScrollInc = (signed short)pos - position;
+#else
+                    nScrollInc = pos - position;
+#endif
+                    scrollEvent = wxEVT_SCROLL_THUMBTRACK;
+                    break;
+
+            default:
+                    nScrollInc = 0;
+                    return;
+    }
+
+#if !(WIN95 && USE_TRACK_BAR)
+    if (nScrollInc != 0)
+#endif
+    {
+
+#if defined(__WIN95__) && USE_TRACK_BAR
+      int newPos = (int)::SendMessage((HWND) control, TBM_GETPOS, 0, 0);
+#else
+      int newPos = position + nScrollInc;
+#endif
+      if (!(newPos < GetMin() || newPos > GetMax()))
+      {
+        SetValue(newPos);
+
+        wxScrollEvent event(scrollEvent, m_windowId);
+        event.SetPosition(newPos);
+        event.SetEventObject( this );
+        GetEventHandler()->ProcessEvent(event);
+      }
+    }
+}
+
+void wxSlider::MSWOnHScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control)
+{
+	MSWOnVScroll(wParam, pos, control);
+}
+
+wxSlider::~wxSlider(void)
+{
+    if (m_staticMin)
+      DestroyWindow((HWND) m_staticMin);
+    if (m_staticMax)
+      DestroyWindow((HWND) m_staticMax);
+    if (m_staticValue)
+      DestroyWindow((HWND) m_staticValue);
+}
+
+int wxSlider::GetValue(void) const
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  return ::SendMessage((HWND) GetHWND(), TBM_GETPOS, 0, 0);
+#else
+  return ::GetScrollPos((HWND) GetHWND(), SB_CTL);
+#endif
+}
+
+void wxSlider::SetValue(const int value)
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  ::SendMessage((HWND) GetHWND(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value);
+#else
+  ::SetScrollPos((HWND) GetHWND(), SB_CTL, value, TRUE);
+#endif
+  if (m_staticValue)
+  {
+    sprintf(wxBuffer, "%d", value);
+    SetWindowText((HWND) m_staticValue, wxBuffer);
+  }
+}
+
+void wxSlider::GetSize(int *width, int *height) const
+{
+  RECT rect;
+  rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
+
+  wxFindMaxSize(GetHWND(), &rect);
+
+  if (m_staticMin)
+    wxFindMaxSize(m_staticMin, &rect);
+  if (m_staticMax)
+    wxFindMaxSize(m_staticMax, &rect);
+  if (m_staticValue)
+    wxFindMaxSize(m_staticValue, &rect);
+
+  *width = rect.right - rect.left;
+  *height = rect.bottom - rect.top;
+}
+
+void wxSlider::GetPosition(int *x, int *y) const
+{
+  wxWindow *parent = GetParent();
+  RECT rect;
+  rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
+
+  wxFindMaxSize(GetHWND(), &rect);
+
+  if (m_staticMin)
+    wxFindMaxSize(m_staticMin, &rect);
+  if (m_staticMax)
+    wxFindMaxSize(m_staticMax, &rect);
+  if (m_staticValue)
+    wxFindMaxSize(m_staticValue, &rect);
+
+  // Since we now have the absolute screen coords,
+  // if there's a parent we must subtract its top left corner
+  POINT point;
+  point.x = rect.left;
+  point.y = rect.top;
+  if (parent)
+    ::ScreenToClient((HWND) parent->GetHWND(), &point);
+
+  *x = point.x;
+  *y = point.y;
+}
+
+void wxSlider::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int x1 = x;
+  int y1 = y;
+  int w1 = width;
+  int h1 = height;
+
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  char buf[300];
+
+  int x_offset = x;
+  int y_offset = y;
+
+  int cx;     // slider,min,max sizes
+  int cy;
+  float cyf;
+
+  wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
+
+  if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
+  {
+	if ( m_windowStyle & wxSL_LABELS )
+	{
+    float min_len = 0.0;
+
+    GetWindowText((HWND) m_staticMin, buf, 300);
+    GetTextExtent(buf, &min_len, &cyf,NULL,NULL, GetFont());
+
+    float max_len = 0.0;
+
+    GetWindowText((HWND) m_staticMax, buf, 300);
+    GetTextExtent(buf, &max_len, &cyf,NULL,NULL, GetFont());
+    if (m_staticValue)
+    {
+      int new_width = (int)(wxMax(min_len, max_len));
+	  int valueHeight = (int)cyf;
+#ifdef __WIN32__
+      // For some reason, under Win95, the text edit control has
+      // a lot of space before the first character
+      new_width += 3*cx;
+#endif
+#if defined(__WIN95__)
+      // The height needs to be a bit bigger under Win95 if using native
+	  // 3D effects.
+	  valueHeight = (int) (valueHeight * 1.5) ;
+#endif
+      MoveWindow((HWND) m_staticValue, x_offset, y_offset, new_width, valueHeight, TRUE);
+      x_offset += new_width + cx;
+    }
+
+    MoveWindow((HWND) m_staticMin, x_offset, y_offset, (int)min_len, cy, TRUE);
+    x_offset += (int)(min_len + cx);
+
+    int slider_length = (int)(w1 - x_offset - max_len - cx);
+
+#if defined(__WIN95__) && USE_TRACK_BAR
+    int slider_height = h1;
+	if (slider_height < 0 )
+		slider_height = 20;
+#else
+    int slider_height = cy;
+#endif
+
+    // Slider must have a minimum/default length/height
+    if (slider_length < 100)
+      slider_length = 100;
+
+    MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_length, slider_height, TRUE);
+    x_offset += slider_length + cx;
+
+    MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE);
+    }
+	else
+	{
+		// No labels
+		if ( w1 < 0 )
+			w1 = 200;
+		if ( h1 < 0 )
+			h1 = 20;
+    	MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
+	}
+  }
+  else
+  {
+	if ( m_windowStyle & wxSL_LABELS )
+	{
+    float min_len;
+    GetWindowText((HWND) m_staticMin, buf, 300);
+    GetTextExtent(buf, &min_len, &cyf,NULL,NULL,GetFont());
+
+    float max_len;
+    GetWindowText((HWND) m_staticMax, buf, 300);
+    GetTextExtent(buf, &max_len, &cyf,NULL,NULL, GetFont());
+
+    if (m_staticValue)
+    {
+      int new_width = (int)(wxMax(min_len, max_len));
+	  int valueHeight = (int)cyf;
+/*** Suggested change by George Tasker - remove this block...
+#ifdef __WIN32__
+      // For some reason, under Win95, the text edit control has
+      // a lot of space before the first character
+      new_width += 3*cx;
+#endif
+ ... and replace with following line: */
+      new_width += cx;
+
+#if defined(__WIN95__)
+      // The height needs to be a bit bigger under Win95 if using native
+	  // 3D effects.
+	  valueHeight = (int) (valueHeight * 1.5) ;
+#endif
+
+      MoveWindow((HWND) m_staticValue, x_offset, y_offset, new_width, valueHeight, TRUE);
+      y_offset += valueHeight;
+    }
+
+    MoveWindow((HWND) m_staticMin, x_offset, y_offset, (int)min_len, cy, TRUE);
+    y_offset += cy;
+
+    int slider_length = (int)(h1 - y_offset - cy - cy);
+#if defined(__WIN95__) && USE_TRACK_BAR
+    int slider_width = w1;
+	if (slider_width < 0 )
+		slider_width = 20;
+#else
+    // Use character height as an estimate of slider width (yes, width)
+    int slider_width = cy;
+#endif
+
+    // Slider must have a minimum/default length
+    if (slider_length < 100)
+      slider_length = 100;
+
+    MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_width, slider_length, TRUE);
+    y_offset += slider_length;
+
+    MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE);
+    }
+	else
+	{
+		// No labels
+		if ( w1 < 0 )
+			w1 = 20;
+		if ( h1 < 0 )
+			h1 = 200;
+    	MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
+	}
+  }
+
+/*
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+*/
+
+}
+
+void wxSlider::SetRange(const int minValue, const int maxValue)
+{
+  m_rangeMin = minValue;
+  m_rangeMax = maxValue;
+
+#if defined(__WIN95__) && USE_TRACK_BAR
+  ::SendMessage((HWND) GetHWND(), TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue));
+#else
+  ::SetScrollRange((HWND) GetHWND(), SB_CTL, m_rangeMin, m_rangeMax, TRUE);
+#endif
+  char buf[40];
+  if ( m_staticMin )
+  {
+  	sprintf(buf, "%d", m_rangeMin);
+  	SetWindowText((HWND) m_staticMin, buf);
+  }
+
+  if ( m_staticMax )
+  {
+    sprintf(buf, "%d", m_rangeMax);
+    SetWindowText((HWND) m_staticMax, buf);
+  }
+}
+
+WXHBRUSH wxSlider::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+  if ( nCtlColor == CTLCOLOR_SCROLLBAR )
+	return 0;
+
+  // Otherwise, it's a static
+  if (GetParent()->GetTransparentBackground())
+    SetBkMode((HDC) pDC, TRANSPARENT);
+  else
+    SetBkMode((HDC) pDC, OPAQUE);
+
+  ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+
+  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+
+  // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
+  // has a zero usage count.
+//  backgroundBrush->RealizeResource();
+  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
+}
+
+// For trackbars only
+void wxSlider::SetTickFreq(const int n, const int pos)
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  m_tickFreq = n;
+  ::SendMessage( (HWND) GetHWND(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos );
+#endif
+}
+
+void wxSlider::SetPageSize(const int pageSize)
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  ::SendMessage( (HWND) GetHWND(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize );
+#endif
+  m_pageSize = pageSize;
+}
+
+int wxSlider::GetPageSize(void) const
+{
+  return m_pageSize;
+}
+
+void wxSlider::ClearSel(void)
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  ::SendMessage( (HWND) GetHWND(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 );
+#endif
+}
+
+void wxSlider::ClearTicks(void)
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  ::SendMessage( (HWND) GetHWND(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 );
+#endif
+}
+
+void wxSlider::SetLineSize(const int lineSize)
+{
+  m_lineSize = lineSize;
+#if defined(__WIN95__) && USE_TRACK_BAR
+  ::SendMessage( (HWND) GetHWND(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize );
+#endif
+}
+
+int wxSlider::GetLineSize(void) const
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETLINESIZE, (WPARAM) 0, (LPARAM) 0 );
+#else
+  return m_lineSize;
+#endif
+}
+
+int wxSlider::GetSelEnd(void) const
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  return (int) ::SendMessage( (HWND) GetHWND(), TBM_SETSELEND, (WPARAM) 0, (LPARAM) 0 );
+#else
+  return 0;
+#endif
+}
+
+int wxSlider::GetSelStart(void) const
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETSELSTART, (WPARAM) 0, (LPARAM) 0 );
+#else
+  return 0;
+#endif
+}
+
+void wxSlider::SetSelection(const int minPos, const int maxPos)
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  ::SendMessage( (HWND) GetHWND(), TBM_SETSEL, (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) );
+#endif
+}
+
+void wxSlider::SetThumbLength(const int len)
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  ::SendMessage( (HWND) GetHWND(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 );
+#endif
+}
+
+int wxSlider::GetThumbLength(void) const
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETTHUMBLENGTH, (WPARAM) 0, (LPARAM) 0 );
+#else
+  return 0;
+#endif
+}
+
+void wxSlider::SetTick(const int tickPos)
+{
+#if defined(__WIN95__) && USE_TRACK_BAR
+  ::SendMessage( (HWND) GetHWND(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos );
+#endif
+}
+
+bool wxSlider::ContainsHWND(WXHWND hWnd) const
+{
+	return ( hWnd == GetStaticMin() || hWnd == GetStaticMax() || hWnd == GetEditValue() );
+}
+
+#if WXWIN_COMPATIBILITY
+// Backward compatibility
+void wxSlider::OnScroll(wxScrollEvent& event)
+{
+    int oldEvent = event.GetEventType();
+    event.SetEventType( wxEVT_COMMAND_SLIDER_UPDATED );
+    if ( !GetEventHandler()->ProcessEvent(event) )
+    {
+        event.SetEventType( oldEvent );
+        if (!GetParent()->GetEventHandler()->ProcessEvent(event))
+            event.Skip();
+    }
+}
+#endif
+
+void wxSlider::Command (wxCommandEvent & event)
+{
+  SetValue (event.GetInt());
+  ProcessCommand (event);
+}
+
+bool wxSlider::Show(const bool show)
+{
+	wxWindow::Show(show);
+
+    int cshow;
+    if (show)
+        cshow = SW_SHOW;
+    else
+        cshow = SW_HIDE;
+
+    if(m_staticValue)
+		ShowWindow((HWND) m_staticValue, (BOOL)cshow);
+    if(m_staticMin)
+	    ShowWindow((HWND) m_staticMin, (BOOL)cshow);
+    if(m_staticMax)
+		ShowWindow((HWND) m_staticMax, (BOOL)cshow);
+    return TRUE;
+}
+
+
diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp
new file mode 100644
index 0000000000..931add7bc9
--- /dev/null
+++ b/src/msw/spinbutt.cpp
@@ -0,0 +1,269 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        spinbutt.cpp
+// Purpose:     wxSpinButton
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "spinbutt.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx.h"
+#endif
+
+#if defined(__WIN95__)
+
+#include "wx/spinbutt.h"
+#include "wx/msw/private.h"
+
+#ifndef __GNUWIN32__
+#include <commctrl.h>
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
+#endif
+
+wxSpinButton::wxSpinButton(void)
+{
+	m_min = 0;
+	m_max = 100;
+}
+
+bool wxSpinButton::Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size,
+            const long style, const wxString& name)
+{
+  wxSystemSettings settings;
+  m_backgroundColour = parent->GetDefaultBackgroundColour() ;
+  m_foregroundColour = parent->GetDefaultForegroundColour() ;
+
+  SetName(name);
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_windowStyle = style;
+
+  SetParent(parent);
+
+  if (width <= 0)
+    width = 100;
+  if (height <= 0)
+    height = 30;
+  if (x < 0)
+    x = 0;
+  if (y < 0)
+    y = 0;
+
+  m_min = 0;
+  m_max = 100;
+
+  m_windowId = (id == -1) ? NewControlId() : id;
+
+  DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
+  
+  if ( m_windowStyle & wxSP_HORIZONTAL )
+	wstyle |= UDS_HORZ;
+  if ( m_windowStyle & wxSP_ARROW_KEYS )
+	wstyle |= UDS_ARROWKEYS;
+  if ( m_windowStyle & wxSP_WRAP )
+	wstyle |= UDS_WRAP;
+
+  // Create the ListView control.
+  HWND hWndListControl = CreateUpDownControl(wstyle,
+    x, y, width, height,
+    (HWND) parent->GetHWND(),
+    m_windowId,
+    wxGetInstance(),
+    0,
+	m_min, m_max, 0);
+
+  m_hWnd = (WXHWND) hWndListControl;
+  if (parent) parent->AddChild(this);
+
+  // TODO: have this for all controls.
+  if ( !m_hWnd )
+	return FALSE;
+  
+  SubclassWin((WXHWND) m_hWnd);
+
+  return TRUE;
+}
+
+wxSpinButton::~wxSpinButton(void)
+{
+}
+
+// Attributes
+////////////////////////////////////////////////////////////////////////////
+
+int wxSpinButton::GetValue(void) const
+{
+	return (int) ::SendMessage((HWND) GetHWND(), UDM_GETPOS, 0, 0);
+}
+
+void wxSpinButton::SetValue(const int val)
+{
+	::SendMessage((HWND) GetHWND(), UDM_SETPOS, 0, (LPARAM) MAKELONG((short) val, 0));
+}
+
+void wxSpinButton::SetRange(const int minVal, const int maxVal)
+{
+	m_min = minVal;
+	m_max = maxVal;
+	::SendMessage((HWND) GetHWND(), UDM_SETRANGE, 0, (LPARAM) MAKELONG((short) minVal, (short) maxVal));
+}
+
+void wxSpinButton::MSWOnVScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control)
+{
+  if (control)
+  {
+    wxSpinEvent event(0, m_windowId);
+    event.SetPosition(pos);
+    event.SetOrientation(wxVERTICAL);
+    event.SetEventObject( this );
+
+	switch ( wParam )
+	{
+		case SB_TOP:
+			event.m_eventType = wxEVT_SCROLL_TOP;
+			break;
+
+		case SB_BOTTOM:
+			event.m_eventType = wxEVT_SCROLL_BOTTOM;
+			break;
+
+		case SB_LINEUP:
+			event.m_eventType = wxEVT_SCROLL_LINEUP;
+			break;
+
+		case SB_LINEDOWN:
+		        event.m_eventType = wxEVT_SCROLL_LINEDOWN;
+			break;
+
+		case SB_PAGEUP:
+                        event.m_eventType = wxEVT_SCROLL_PAGEUP;
+			break;
+
+		case SB_PAGEDOWN:
+                        event.m_eventType = wxEVT_SCROLL_PAGEDOWN;
+			break;
+
+        case SB_THUMBTRACK:
+        case SB_THUMBPOSITION:
+                        event.m_eventType = wxEVT_SCROLL_THUMBTRACK;
+			break;
+
+		default:
+                        return;
+                        break;
+	}
+    if (!GetEventHandler()->ProcessEvent(event))
+      Default();
+  }
+}
+
+void wxSpinButton::MSWOnHScroll( const WXWORD wParam, const WXWORD pos, const WXHWND control)
+{
+  if (control)
+  {
+    wxSpinEvent event(0, m_windowId);
+    event.SetPosition(pos);
+    event.SetOrientation(wxHORIZONTAL);
+    event.SetEventObject( this );
+
+	switch ( wParam )
+	{
+		case SB_TOP:
+			event.m_eventType = wxEVT_SCROLL_TOP;
+			break;
+
+		case SB_BOTTOM:
+			event.m_eventType = wxEVT_SCROLL_BOTTOM;
+			break;
+
+		case SB_LINEUP:
+			event.m_eventType = wxEVT_SCROLL_LINEUP;
+			break;
+
+		case SB_LINEDOWN:
+	        event.m_eventType = wxEVT_SCROLL_LINEDOWN;
+			break;
+
+		case SB_PAGEUP:
+                        event.m_eventType = wxEVT_SCROLL_PAGEUP;
+			break;
+
+		case SB_PAGEDOWN:
+                        event.m_eventType = wxEVT_SCROLL_PAGEDOWN;
+			break;
+
+        case SB_THUMBTRACK:
+        case SB_THUMBPOSITION:
+                        event.m_eventType = wxEVT_SCROLL_THUMBTRACK;
+			break;
+
+		default:
+                        return;
+                        break;
+	}
+    if (!GetEventHandler()->ProcessEvent(event))
+    	Default();
+  }
+}
+
+bool wxSpinButton::MSWCommand(const WXUINT cmd, const WXWORD id)
+{
+  // No command messages
+  return FALSE;
+}
+
+bool wxSpinButton::MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam)
+{
+	NMHDR* hdr1 = (NMHDR*) lParam;
+	switch ( hdr1->code )
+	{
+/* We don't process this message, currently */
+		case UDN_DELTAPOS:
+		{
+			return wxControl::MSWNotify(wParam, lParam);
+			break;
+		}
+		default :
+			return wxControl::MSWNotify(wParam, lParam);
+			break;
+	}
+/*
+	event.eventObject = this;
+	event.SetEventType(eventType);
+
+	if ( !ProcessEvent(event) )
+		return FALSE;
+*/
+  	return TRUE;
+}
+
+// Spin event
+IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
+
+wxSpinEvent::wxSpinEvent(WXTYPE commandType, int id):
+  wxScrollEvent(commandType, id)
+{
+}
+
+#endif
diff --git a/src/msw/statbmp.cpp b/src/msw/statbmp.cpp
new file mode 100644
index 0000000000..dfdaec3496
--- /dev/null
+++ b/src/msw/statbmp.cpp
@@ -0,0 +1,202 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        statbmp.cpp
+// Purpose:     wxStaticBitmap
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "statbmp.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/statbmp.h"
+#endif
+
+#include <stdio.h>
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
+#endif
+
+/*
+ * wxStaticBitmap
+ */
+
+bool wxStaticBitmap::Create(wxWindow *parent, const wxWindowID id,
+           const wxBitmap& bitmap,
+           const wxPoint& pos,
+           const wxSize& size,
+           const long style,
+           const wxString& name)
+{
+  m_messageBitmap = bitmap;
+  SetName(name);
+  if (parent) parent->AddChild(this);
+
+  m_backgroundColour = parent->GetDefaultBackgroundColour() ;
+  m_foregroundColour = parent->GetDefaultForegroundColour() ;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  if ( width < 0 && bitmap.Ok() )
+	width = bitmap.GetWidth();
+  if ( height < 0 && bitmap.Ok() )
+	height = bitmap.GetHeight();
+
+  m_windowStyle = style;
+
+  // Use an ownerdraw button to produce a static bitmap, since there's
+  // no ownerdraw static.
+  // TODO: perhaps this should be a static item, with style SS_BITMAP.
+  HWND static_item =
+    CreateWindowEx(0, "BUTTON", "", BS_OWNERDRAW | WS_TABSTOP | WS_CHILD,
+                    0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                    wxGetInstance(), NULL);
+  m_hWnd = (WXHWND) static_item;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin((WXHWND) static_item);
+  SetSize(x, y, width, height);
+  return TRUE;
+}
+
+void wxStaticBitmap::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+  int x1 = x;
+  int y1 = y;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  int actualWidth = width;
+  int actualHeight = height;
+
+  int ww, hh;
+  GetSize(&ww, &hh);
+
+  // If we're prepared to use the existing width, then...
+  if (width == -1 && ((sizeFlags & wxSIZE_AUTO_WIDTH) != wxSIZE_AUTO_WIDTH))
+    actualWidth = ww;
+  else actualWidth = width;
+
+  // If we're prepared to use the existing height, then...
+  if (height == -1 && ((sizeFlags & wxSIZE_AUTO_HEIGHT) != wxSIZE_AUTO_HEIGHT))
+    actualHeight = hh;
+  else actualHeight = height;
+
+  MoveWindow((HWND) GetHWND(), x1, y1, actualWidth, actualHeight, TRUE);
+
+  if (!((width == -1) && (height == -1)))
+  {
+#if WXWIN_COMPATIBILITY
+    GetEventHandler()->OldOnSize(actualWidth, actualHeight);
+#else
+    wxSizeEvent event(wxSize(actualWidth, actualHeight), m_windowId);
+    event.eventObject = this;
+    GetEventHandler()->ProcessEvent(event);
+#endif
+  }
+}
+
+void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
+{
+  m_messageBitmap = bitmap;
+
+  int x, y;
+  int w, h;
+  GetPosition(&x, &y);
+  GetSize(&w, &h);
+  RECT rect;
+  rect.left = x; rect.top = y; rect.right = x + w; rect.bottom = y + h;
+
+  if ( bitmap.Ok() )
+  	MoveWindow((HWND) GetHWND(), x, y, bitmap.GetWidth(), bitmap.GetHeight(),
+             FALSE);
+  
+  InvalidateRect((HWND) GetParent()->GetHWND(), &rect, TRUE);
+}
+
+bool wxStaticBitmap::MSWOnDraw(WXDRAWITEMSTRUCT *item)
+{
+	long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE);
+#ifdef __WIN32__
+	if ((style & 0xFF) == SS_BITMAP)
+	{
+		// Should we call Default() here?
+//		Default();
+
+		// Let default procedure draw the bitmap, which is defined
+		// in the Windows resource.
+		return FALSE;
+	}
+#endif
+
+    LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) item;
+
+	wxBitmap* bitmap = &m_messageBitmap;
+	if ( !bitmap->Ok() )
+		return FALSE;
+
+	HDC hDC = lpDIS->hDC;
+	HDC memDC = ::CreateCompatibleDC(hDC);
+
+	HBITMAP old = ::SelectObject(memDC, (HBITMAP) bitmap->GetHBITMAP());
+
+	if (!old)
+		return FALSE;
+
+	RECT rect = lpDIS->rcItem;
+
+	int x = lpDIS->rcItem.left;
+	int y = lpDIS->rcItem.top;
+	int width = lpDIS->rcItem.right - x;
+	int height = lpDIS->rcItem.bottom - y;
+
+	// Centre the bitmap in the control area
+	int x1 = (int) (x + ((width - bitmap->GetWidth()) / 2));
+	int y1 = (int) (y + ((height - bitmap->GetHeight()) / 2));
+
+	::BitBlt(hDC, x1, y1, bitmap->GetWidth(), bitmap->GetHeight(), memDC, 0, 0, SRCCOPY);
+
+	::SelectObject(memDC, old);
+
+    ::DeleteDC(memDC);
+
+    return TRUE;
+}
+
+long wxStaticBitmap::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+  // Ensure that static items get messages. Some controls don't like this
+  // message to be intercepted (e.g. RichEdit), hence the tests.
+  if (nMsg == WM_NCHITTEST)
+    return (long)HTCLIENT;
+
+  return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
+}
+
diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp
new file mode 100644
index 0000000000..b943131324
--- /dev/null
+++ b/src/msw/statbox.cpp
@@ -0,0 +1,223 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        statbox.cpp
+// Purpose:     wxStaticBox
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "statbox.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/dcclient.h"
+#include "wx/app.h"
+#endif
+
+#include "wx/statbox.h"
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
+
+BEGIN_EVENT_TABLE(wxStaticBox, wxControl)
+	EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
+END_EVENT_TABLE()
+
+#endif
+
+/*
+ * Group box
+ */
+ 
+bool wxStaticBox::Create(wxWindow *parent, const wxWindowID id,
+           const wxString& label,
+           const wxPoint& pos,
+           const wxSize& size,
+           const long style,
+           const wxString& name)
+{
+  SetName(name);
+
+  if (parent) parent->AddChild(this);
+
+  SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
+  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_windowStyle = style;
+
+  long msStyle = BS_GROUPBOX | WS_CHILD | WS_VISIBLE ; // GROUP_FLAGS;
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
+
+  HWND wx_button =
+    CreateWindowEx(exStyle, "BUTTON", (const char *)label, msStyle,
+                    0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                    wxGetInstance(), NULL);
+#if CTL3D
+  if (want3D)
+  {
+    Ctl3dSubclassCtl(wx_button);
+	  m_useCtl3D = TRUE;
+  }
+#endif
+
+  m_hWnd = (WXHWND)wx_button;
+
+  // Subclass again for purposes of dialog editing mode
+  SubclassWin(GetHWND());
+
+  SetFont(* parent->GetFont());
+
+  SetSize(x, y, width, height);
+  ShowWindow(wx_button, SW_SHOW);
+
+  return TRUE;
+}
+
+void wxStaticBox::SetLabel(const wxString& label)
+{
+  SetWindowText((HWND)m_hWnd, (const char *)label);
+}
+
+void wxStaticBox::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+
+  int x1 = x;
+  int y1 = y;
+  int w1 = width;
+  int h1 = height;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  // If we're prepared to use the existing size, then...
+  if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
+  {
+    GetSize(&w1, &h1);
+  }
+
+  char buf[300];
+
+  float current_width;
+
+  int cx;
+  int cy;
+  float cyf;
+
+  HWND button = (HWND)m_hWnd;
+  wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
+
+  GetWindowText(button, buf, 300);
+  GetTextExtent(buf, &current_width, &cyf,NULL,NULL,GetFont());
+  if (w1 < 0)
+   w1 = (int)(current_width + 3*cx) ;
+  if (h1<0)
+    h1 = (int)(cyf*EDIT_CONTROL_FACTOR) ;
+  MoveWindow(button, x1, y1, w1, h1, TRUE);
+
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+}
+
+WXHBRUSH wxStaticBox::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+#if CTL3D
+  if ( m_useCtl3D )
+  {
+    HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
+    return (WXHBRUSH) hbrush;
+  }
+#endif
+
+  if (GetParent()->GetTransparentBackground())
+    SetBkMode((HDC) pDC, TRANSPARENT);
+  else
+    SetBkMode((HDC) pDC, OPAQUE);
+
+  ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+
+  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+
+  // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
+  // has a zero usage count.
+//  backgroundBrush->RealizeResource();
+  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
+}
+
+// Shouldn't erase the whole window, since the static box must only paint its
+// outline.
+void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
+{
+  wxWindow *parent = GetParent();
+  if ( parent && parent->GetHWND() && (::GetWindowLong((HWND) parent->GetHWND(), GWL_STYLE) & WS_CLIPCHILDREN) )
+  {
+        // TODO: May in fact need to generate a paint event for inside this
+        // control's rectangle, otherwise all controls are going to be clipped -
+        // ugh.
+        HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+        int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
+
+        RECT rect;
+
+        ::GetClientRect((HWND) GetHWND(), &rect);
+        ::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
+        ::DeleteObject(hBrush);
+        ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
+  }
+  else
+	Default();
+}
+
+long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+	// TODO: somehow, this has to accept mouse clicks in user interface edit mode,
+	// but not otherwise. Only there is no longer a UI edit mode...
+
+	// It worked before because the message could be processed if not in UI
+	// edit mode. We have to find some way of distinguishing this.
+	// Maybe this class can have an AcceptMouseEvents(bool) function; a sort of
+	// kludge... or, we can search for an active event table entry that will
+	// intercept mouse events, and if one exists (that isn't the default),
+	// skip the code below. Too time consuming though.
+	// Perhaps it's ok to do the default thing *anyway* because the title or edge
+	// of the window may still be active!
+	if (nMsg == WM_NCHITTEST)
+            return Default();
+
+	return wxControl::MSWWindowProc(nMsg, wParam, lParam);
+}
+
diff --git a/src/msw/statbr95.cpp b/src/msw/statbr95.cpp
new file mode 100644
index 0000000000..581d1db266
--- /dev/null
+++ b/src/msw/statbr95.cpp
@@ -0,0 +1,227 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        msw/statbr95.cpp
+// Purpose:     native implementation of wxStatusBar
+// Author:      Vadim Zeitlin
+// Modified by: 
+// Created:     04.04.98
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+  #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+  #include "wx/setup.h"
+  #include "wx/frame.h"
+  #include "wx/settings.h"
+  #include "wx/dcclient.h"
+#endif
+
+#include "wx/log.h"
+
+#include "wx/generic/statusbr.h"
+#include "wx/msw/statbr95.h"
+
+#include  <windows.h>
+#include  <windowsx.h>
+
+#ifndef __GNUWIN32__
+#include  <commctrl.h>
+#endif
+
+#if     USE_NATIVE_STATUSBAR
+
+#if     !USE_SHARED_LIBRARY
+  IMPLEMENT_DYNAMIC_CLASS(wxStatusBar95, wxStatusBar);
+
+  BEGIN_EVENT_TABLE(wxStatusBar95, wxStatusBar)
+    EVT_PAINT(wxWindow::OnPaint)
+    EVT_SIZE(wxStatusBar95::OnSize)
+  END_EVENT_TABLE()
+#endif  //USE_SHARED_LIBRARY
+
+
+// ----------------------------------------------------------------------------
+// macros
+// ----------------------------------------------------------------------------
+
+// windowsx.h and commctrl.h don't define those, so we do it here
+#define StatusBar_SetParts(h, n, w) SendMessage(h, SB_SETPARTS, (WPARAM)n, (LPARAM)w)
+#define StatusBar_SetText(h, n, t)  SendMessage(h, SB_SETTEXT, (WPARAM)n, (LPARAM)(LPCSTR)t)
+#define StatusBar_GetTextLen(h, n)  LOWORD(SendMessage(h, SB_GETTEXTLENGTH, (WPARAM)n, 0))
+#define StatusBar_GetText(h, n, s)  LOWORD(SendMessage(h, SB_GETTEXT, (WPARAM)n, (LPARAM)(LPSTR)s))
+
+#define hwnd      ((HWND)m_hWnd)
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxStatusBar95 class
+// ----------------------------------------------------------------------------
+
+wxStatusBar95::wxStatusBar95()
+{
+  SetParent(NULL);
+  m_hWnd = 0;
+  m_windowId = 0;
+}
+
+wxStatusBar95::wxStatusBar95(wxWindow *parent, wxWindowID id, long style)
+{
+  Create(parent, id, style);
+}
+
+bool wxStatusBar95::Create(wxWindow *parent, wxWindowID id, long style)
+{
+  SetParent(parent);
+
+  m_windowId = id == -1 ? NewControlId() : id;
+
+  DWORD wstyle = WS_CHILD | WS_VISIBLE;
+  if ( style & wxSB_SIZEGRIP )
+    wstyle |= SBARS_SIZEGRIP;
+
+  m_hWnd = (WXHWND)CreateStatusWindow(wstyle,
+                                      "",
+                                      (HWND)parent->GetHWND(),
+                                      m_windowId);
+  if ( m_hWnd == 0 ) {
+    wxLogSysError("can't create status bar window");
+    return FALSE;
+  }
+
+  // this doesn't work: display problems (white 1-2 pixel borders...)
+  //  SubclassWin(m_hWnd);
+
+  return TRUE;
+}
+
+void wxStatusBar95::CopyFieldsWidth(const int *widths)
+{
+  if (widths && !m_statusWidths)
+    m_statusWidths = new int[m_nFields];
+
+  if ( widths != NULL ) {
+    for ( int i = 0; i < m_nFields; i++ )
+      m_statusWidths[i] = widths[i];
+  }
+  else {
+    delete [] m_statusWidths;
+    m_statusWidths = NULL;
+  }
+}
+
+void wxStatusBar95::SetFieldsCount(int nFields, const int *widths)
+{
+  wxASSERT( (nFields > 0) && (nFields < 255) );
+
+  m_nFields = nFields;
+
+  CopyFieldsWidth(widths);
+  SetFieldsWidth();
+}
+
+void wxStatusBar95::SetStatusWidths(int n, const int *widths)
+{
+  // @@ I don't understand what this function is for...
+  wxASSERT( n == m_nFields );
+
+  CopyFieldsWidth(widths);
+  SetFieldsWidth();
+}
+
+void wxStatusBar95::SetFieldsWidth()
+{
+  int *pWidths = new int[m_nFields];
+
+  int nWindowWidth, y;
+  GetClientSize(&nWindowWidth, &y);
+
+  if ( m_statusWidths == NULL ) {
+    // default: all fields have the same width
+    int nWidth = nWindowWidth / m_nFields;
+    for ( int i = 0; i < m_nFields; i++ )
+      pWidths[i] = (i + 1) * nWindowWidth;
+  }
+  else {
+    // -1 doesn't mean the same thing for wxWindows and Win32, recalc
+    int nTotalWidth = 0, 
+        nVarCount = 0, 
+        i;
+    for ( i = 0; i < m_nFields; i++ ) {
+      if ( m_statusWidths[i] == -1 )
+        nVarCount++;
+      else
+        nTotalWidth += m_statusWidths[i];
+    }
+
+    if ( nVarCount == 0 ) {
+      // wrong! at least one field must be of variable width
+      wxFAIL;
+
+      nVarCount++;
+    }
+
+    int nVarWidth = (nWindowWidth - nTotalWidth) / nVarCount;
+
+    // do fill the array
+    int nCurPos = 0;
+    for ( i = 0; i < m_nFields; i++ ) {
+      if ( m_statusWidths[i] == -1 )
+        nCurPos += nVarWidth;
+      else
+        nCurPos += m_statusWidths[i];
+      pWidths[i] = nCurPos;
+    }
+  }
+
+  if ( !StatusBar_SetParts(hwnd, m_nFields, pWidths) ) {
+    wxLogDebug("StatusBar_SetParts failed.");
+  }
+
+  delete [] pWidths;
+}
+
+void wxStatusBar95::SetStatusText(const wxString& strText, const int nField)
+{
+  if ( !StatusBar_SetText(hwnd, nField, strText) ) {
+    wxLogDebug("StatusBar_SetText failed");
+  }
+}
+
+wxString wxStatusBar95::GetStatusText(int nField) const
+{
+  wxASSERT( (nField > 0) && (nField < m_nFields) );
+
+  wxString str;
+  StatusBar_GetText(hwnd, nField, 
+                    str.GetWriteBuf(StatusBar_GetTextLen(hwnd, nField)));
+  return str;
+}
+
+void wxStatusBar95::OnSize(wxSizeEvent& event)
+{
+  FORWARD_WM_SIZE(hwnd, SIZE_RESTORED, event.GetSize().x, event.GetSize().y,
+                  SendMessage);
+
+  // adjust fields widths to the new size
+  SetFieldsWidth();
+}
+
+#endif  //USE_NATIVE_STATUSBAR
\ No newline at end of file
diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp
new file mode 100644
index 0000000000..10a2141417
--- /dev/null
+++ b/src/msw/stattext.cpp
@@ -0,0 +1,220 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        stattext.cpp
+// Purpose:     wxStaticText
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "stattext.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/app.h"
+#endif
+
+#include "wx/stattext.h"
+#include "wx/msw/private.h"
+#include <stdio.h>
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
+#endif
+
+bool wxStaticText::Create(wxWindow *parent, const wxWindowID id,
+           const wxString& label,
+           const wxPoint& pos,
+           const wxSize& size,
+           const long style,
+           const wxString& name)
+{
+  SetName(name);
+  if (parent) parent->AddChild(this);
+
+  SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
+  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_windowStyle = style;
+
+  long msStyle = WS_CHILD|WS_VISIBLE;
+  if (m_windowStyle & wxALIGN_CENTRE)
+    msStyle |= SS_CENTER;
+  else if (m_windowStyle & wxALIGN_RIGHT)
+    msStyle |= SS_RIGHT;
+  else
+    msStyle |= SS_LEFT;
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+    msStyle |= WS_BORDER;
+
+  HWND static_item = CreateWindowEx(MakeExtendedStyle(m_windowStyle), "STATIC", (const char *)label,
+                         msStyle,
+                         0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
+                         wxGetInstance(), NULL);
+
+#if CTL3D
+/*
+  if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS))
+    Ctl3dSubclassCtl(static_item);
+*/
+#endif
+
+  m_hWnd = (WXHWND)static_item;
+
+  SubclassWin((WXHWND)static_item);
+
+  SetFont(* parent->GetFont());
+  SetSize(x, y, width, height);
+  return TRUE;
+}
+
+void wxStaticText::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+  int x1 = x;
+  int y1 = y;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  int actualWidth = width;
+  int actualHeight = height;
+
+  char buf[300];
+  int current_width;
+  int cyf;
+
+  ::GetWindowText((HWND) GetHWND(), buf, 300);
+  GetTextExtent(buf, &current_width, &cyf, NULL, NULL,GetFont());
+
+  int ww, hh;
+  GetSize(&ww, &hh);
+
+  // If we're prepared to use the existing width, then...
+  if (width == -1 && ((sizeFlags & wxSIZE_AUTO_WIDTH) != wxSIZE_AUTO_WIDTH))
+    actualWidth = ww;
+  else if (width == -1)
+  {
+    int cx;
+    int cy;
+    wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
+    actualWidth = (int)(current_width + cx) ;
+  }
+
+  // If we're prepared to use the existing height, then...
+  if (height == -1 && ((sizeFlags & wxSIZE_AUTO_HEIGHT) != wxSIZE_AUTO_HEIGHT))
+    actualHeight = hh;
+  else if (height == -1)
+  {
+    actualHeight = (int)(cyf) ;
+  }
+
+  MoveWindow((HWND) GetHWND(), x1, y1, actualWidth, actualHeight, TRUE);
+
+  if (!((width == -1) && (height == -1)))
+  {
+#if WXWIN_COMPATIBILITY
+    GetEventHandler()->OldOnSize(actualWidth, actualHeight);
+#else
+    wxSizeEvent event(wxSize(actualWidth, actualHeight), m_windowId);
+    event.eventObject = this;
+    GetEventHandler()->ProcessEvent(event);
+#endif
+  }
+}
+
+void wxStaticText::SetLabel(const wxString& label)
+{
+  float w, h;
+  RECT rect;
+
+  wxWindow *parent = GetParent();
+  GetWindowRect((HWND) GetHWND(), &rect);
+
+  // Since we now have the absolute screen coords,
+  // if there's a parent we must subtract its top left corner
+  POINT point;
+  point.x = rect.left;
+  point.y = rect.top;
+  if (parent)
+  {
+    ::ScreenToClient((HWND) parent->GetHWND(), &point);
+  }
+
+  GetTextExtent(label, &w, &h, NULL, NULL, GetFont());
+  MoveWindow((HWND) GetHWND(), point.x, point.y, (int)(w + 10), (int)h,
+             TRUE);
+  SetWindowText((HWND) GetHWND(), (const char *)label);
+}
+
+WXHBRUSH wxStaticText::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+/*
+#if CTL3D
+  if ( m_useCtl3D )
+  {
+    HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
+      
+    if (hbrush != (HBRUSH) 0)
+      return hbrush;
+    else
+      return (HBRUSH)MSWDefWindowProc(message, wParam, lParam);
+  }
+#endif
+*/
+
+  if (GetParent()->GetTransparentBackground())
+    SetBkMode((HDC) pDC, TRANSPARENT);
+  else
+    SetBkMode((HDC) pDC, OPAQUE);
+
+  ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+
+  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+
+  // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
+  // has a zero usage count.
+//  backgroundBrush->RealizeResource();
+  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
+}
+
+long wxStaticText::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+  // Ensure that static items get messages. Some controls don't like this
+  // message to be intercepted (e.g. RichEdit), hence the tests.
+  if (nMsg == WM_NCHITTEST)
+    return (long)HTCLIENT;
+
+  return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
+}
+
+
diff --git a/src/msw/tabctrl.cpp b/src/msw/tabctrl.cpp
new file mode 100644
index 0000000000..49b924ccbf
--- /dev/null
+++ b/src/msw/tabctrl.cpp
@@ -0,0 +1,481 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        tabctrl.cpp
+// Purpose:     wxTabCtrl
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "tabctrl.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx.h"
+#endif
+
+#if defined(__WIN95__)
+
+#ifndef __GNUWIN32__
+#include "malloc.h"
+#endif
+
+#include <windows.h>
+
+#ifndef __GNUWIN32__
+#include <commctrl.h>
+#endif
+
+#ifdef __GNUWIN32__
+#include "wx/msw/gnuwin32/extra.h"
+#endif
+
+#include "wx/msw/dib.h"
+#include "wx/msw/tabctrl.h"
+#include "wx/app.h"
+#include "wx/msw/private.h"
+#include "wx/msw/imaglist.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
+
+BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
+	EVT_SIZE(wxTabCtrl::OnSize)
+	EVT_PAINT(wxTabCtrl::OnPaint)
+	EVT_KILL_FOCUS(wxTabCtrl::OnKillFocus)
+	EVT_MOUSE_EVENTS(wxTabCtrl::OnMouseEvent)
+    EVT_SYS_COLOUR_CHANGED(wxTabCtrl::OnSysColourChanged)
+END_EVENT_TABLE()
+#endif
+
+wxTabCtrl::wxTabCtrl(void)
+{
+    m_imageList = NULL;
+}
+
+bool wxTabCtrl::Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size,
+            const long style, const wxString& name)
+{
+  m_imageList = NULL;
+
+  m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
+  	GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+  m_foregroundColour = *wxBLACK ;
+
+  m_defaultForegroundColour = *wxBLACK ;
+  m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
+  	GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+
+  SetName(name);
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_windowStyle = style;
+
+  SetFont(* (wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL)));
+
+  SetParent(parent);
+
+  DWORD msflags = 0;
+  if (style & wxBORDER)
+    msflags |= WS_BORDER;
+  msflags |= WS_CHILD | WS_VISIBLE;
+  
+  if (width <= 0)
+    width = 100;
+  if (height <= 0)
+    height = 30;
+  if (x < 0)
+    x = 0;
+  if (y < 0)
+    y = 0;
+
+  m_windowId = (id < 0 ? NewControlId() : id);
+
+  long tabStyle = 0;
+  if (m_windowStyle & wxTC_MULTILINE)
+    tabStyle |= TCS_MULTILINE;
+  if (m_windowStyle & wxTC_RIGHTJUSTIFY)
+    tabStyle |= TCS_RIGHTJUSTIFY;
+  if (m_windowStyle & wxTC_FIXEDWIDTH)
+    tabStyle |= TCS_FIXEDWIDTH;
+  if (m_windowStyle & wxTC_OWNERDRAW)
+    tabStyle |= TCS_OWNERDRAWFIXED;
+
+  tabStyle |= TCS_TOOLTIPS;
+
+  // Create the toolbar control.
+  HWND hWndTabCtrl = CreateWindowEx(0L,     // No extended styles.
+    WC_TABCONTROL,                          // Class name for the tab control
+    "",                                     // No default text.
+    WS_CHILD | WS_BORDER | WS_VISIBLE | tabStyle,    // Styles and defaults.
+    x, y, width, height,                    // Standard size and position.
+    (HWND) parent->GetHWND(),               // Parent window
+    (HMENU)m_windowId,                      // ID.
+    wxGetInstance(),                        // Current instance.
+    NULL );                                 // No class data.
+
+  m_hWnd = (WXHWND) hWndTabCtrl;
+  if (parent) parent->AddChild(this);
+  
+  SubclassWin((WXHWND) hWndTabCtrl);
+
+  return TRUE;
+}
+
+wxTabCtrl::~wxTabCtrl(void)
+{
+  UnsubclassWin();
+}
+
+void wxTabCtrl::Command(wxCommandEvent& event)
+{
+}
+
+bool wxTabCtrl::MSWCommand(const WXUINT cmd, const WXWORD id)
+{
+  return FALSE;
+}
+
+bool wxTabCtrl::MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam)
+{
+	wxTabEvent event(0, m_windowId);
+	int eventType = 0;
+	NMHDR* hdr1 = (NMHDR*) lParam;
+	switch ( hdr1->code )
+	{
+		case TCN_SELCHANGE:
+		{
+			eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
+			event.SetInt( (int) LOWORD(wParam) ) ;
+			break;
+		}
+		case TCN_SELCHANGING:
+		{
+			eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
+			event.SetInt( (int) LOWORD(wParam) ) ;
+			break;
+		}
+        case TTN_NEEDTEXT:
+        {
+            // TODO
+//            if (tool->m_shortHelpString != "")
+//                ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
+			return wxControl::MSWNotify(wParam, lParam);
+            break;
+        }
+
+		default :
+			return wxControl::MSWNotify(wParam, lParam);
+			break;
+	}
+
+	event.SetEventObject( this );
+	event.SetEventType(eventType);
+
+	if ( !ProcessEvent(event) )
+		return FALSE;
+  	return TRUE;
+}
+
+// Responds to colour changes, and passes event on to children.
+void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent& event)
+{
+    m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
+  	    GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+    m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
+  	    GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+
+    // Remap the buttons
+//    CreateTools();
+
+    Default();
+
+    Refresh();
+
+    // Propagate the event to the non-top-level children
+    wxWindow::OnSysColourChanged(event);
+}
+
+// Delete all items
+bool wxTabCtrl::DeleteAllItems(void)
+{
+    return ( TabCtrl_DeleteAllItems( (HWND) GetHWND() ) != FALSE );
+}
+
+// Delete an item
+bool wxTabCtrl::DeleteItem(const int item)
+{
+    return ( TabCtrl_DeleteItem( (HWND) GetHWND(), item) != FALSE );
+}
+
+// Get the selection
+int wxTabCtrl::GetSelection(void) const
+{
+    return (int) TabCtrl_GetCurSel( (HWND) GetHWND() );
+}
+
+// Get the associated image list
+wxImageList* wxTabCtrl::GetImageList(void) const
+{
+    return m_imageList;
+}
+
+// Get the number of items
+int wxTabCtrl::GetItemCount(void) const
+{
+    return (int) TabCtrl_GetItemCount( (HWND) GetHWND() );
+}
+
+// Get the rect corresponding to the tab
+bool wxTabCtrl::GetItemRect(const int item, wxRect& wxrect) const
+{
+    RECT rect;
+    if ( !TabCtrl_GetItemRect( (HWND) GetHWND(), item, & rect) )
+        return FALSE;
+    else
+    {
+        wxrect.x = rect.left; wxrect.y = rect.top;
+        wxrect.width = rect.right - rect.left;
+        wxrect.height = rect.bottom - rect.top;
+        return TRUE;
+    }
+}
+
+// Get the number of rows
+int wxTabCtrl::GetRowCount(void) const
+{
+    return (int) TabCtrl_GetRowCount( (HWND) GetHWND() );
+}
+
+// Get the item text
+wxString wxTabCtrl::GetItemText(const int item) const
+{
+    char buf[256];
+    wxString str("");
+    TC_ITEM tcItem;
+    tcItem.mask = TCIF_TEXT;
+    tcItem.pszText = buf;
+    tcItem.cchTextMax = 256;
+
+    if (TabCtrl_GetItem( (HWND) GetHWND(), item, & tcItem) )
+        str = tcItem.pszText;
+
+    return str;
+}
+
+// Get the item image
+int wxTabCtrl::GetItemImage(const int item) const
+{
+    TC_ITEM tcItem;
+    tcItem.mask = TCIF_IMAGE;
+
+    if (TabCtrl_GetItem( (HWND) GetHWND(), item, & tcItem) )
+        return tcItem.iImage;
+    else
+        return -1;
+}
+
+// Get the item data
+void* wxTabCtrl::GetItemData(const int item) const
+{
+    TC_ITEM tcItem;
+    tcItem.mask = TCIF_PARAM;
+
+    if (TabCtrl_GetItem( (HWND) GetHWND(), item, & tcItem) )
+        return (void*) tcItem.lParam;
+    else
+        return 0;
+}
+
+// Hit test
+int wxTabCtrl::HitTest(const wxPoint& pt, long& flags)
+{
+    TC_HITTESTINFO hitTestInfo;
+    hitTestInfo.pt.x = pt.x;
+    hitTestInfo.pt.y = pt.y;
+    int item = TabCtrl_HitTest( (HWND) GetHWND(), & hitTestInfo ) ;
+    flags = 0;
+
+    if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE)
+        flags |= wxTAB_HITTEST_NOWHERE;
+    if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON)
+        flags |= wxTAB_HITTEST_ONICON;
+    if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL)
+        flags |= wxTAB_HITTEST_ONLABEL;
+
+    return item;
+}
+
+// Insert an item
+int wxTabCtrl::InsertItem(const int item, const wxString& text, const int imageId, void* data)
+{
+    char buf[256];
+    TC_ITEM tcItem;
+    tcItem.mask = TCIF_PARAM;
+    tcItem.lParam = (long) data;
+    if (text != "")
+    {
+        tcItem.mask |= TCIF_TEXT;
+        strcpy(buf, (const char*) text);
+        tcItem.pszText = buf;
+        tcItem.cchTextMax = 256;
+    }
+    if (imageId != -1)
+    {
+        tcItem.mask |= TCIF_IMAGE;
+        tcItem.iImage = imageId;
+    }
+
+    return (int) TabCtrl_InsertItem( (HWND) GetHWND(), item, & tcItem);
+}
+
+// Set the selection
+int wxTabCtrl::SetSelection(const int item)
+{
+    return (int) TabCtrl_SetCurSel( (HWND) GetHWND(), item );
+}
+
+// Set the image list
+void wxTabCtrl::SetImageList(wxImageList* imageList)
+{
+    m_imageList = imageList;
+    TabCtrl_SetImageList( (HWND) GetHWND(), (HIMAGELIST) imageList->GetHIMAGELIST() );
+}
+
+// Set the text for an item
+bool wxTabCtrl::SetItemText(const int item, const wxString& text)
+{
+    char buf[256];
+    TC_ITEM tcItem;
+    tcItem.mask = TCIF_TEXT;
+    strcpy(buf, (const char*) text);
+    tcItem.pszText = buf;
+    tcItem.cchTextMax = 256;
+
+    return ( TabCtrl_SetItem( (HWND) GetHWND(), item, & tcItem) != 0 );
+}
+
+// Set the image for an item
+bool wxTabCtrl::SetItemImage(const int item, const int image)
+{
+    TC_ITEM tcItem;
+    tcItem.mask = TCIF_IMAGE;
+    tcItem.iImage = image;
+
+    return ( TabCtrl_SetItem( (HWND) GetHWND(), item, & tcItem) != 0 );
+}
+
+// Set the data for an item
+bool wxTabCtrl::SetItemData(const int item, void* data)
+{
+    TC_ITEM tcItem;
+    tcItem.mask = TCIF_PARAM;
+    tcItem.lParam = (long) data;
+
+    return ( TabCtrl_SetItem( (HWND) GetHWND(), item, & tcItem) != 0 );
+}
+
+// Set the size for a fixed-width tab control
+void wxTabCtrl::SetItemSize(const wxSize& size)
+{
+    TabCtrl_SetItemSize( (HWND) GetHWND(), size.x, size.y );
+}
+
+// Set the padding between tabs
+void wxTabCtrl::SetPadding(const wxSize& padding)
+{
+    TabCtrl_SetPadding( (HWND) GetHWND(), padding.x, padding.y );
+}
+
+#if 0
+// These are the default colors used to map the bitmap colors
+// to the current system colors
+
+#define BGR_BUTTONTEXT      (RGB(000,000,000))  // black
+#define BGR_BUTTONSHADOW    (RGB(128,128,128))  // dark grey
+#define BGR_BUTTONFACE      (RGB(192,192,192))  // bright grey
+#define BGR_BUTTONHILIGHT   (RGB(255,255,255))  // white
+#define BGR_BACKGROUNDSEL   (RGB(255,000,000))  // blue
+#define BGR_BACKGROUND      (RGB(255,000,255))  // magenta
+
+void wxMapBitmap(HBITMAP hBitmap, int width, int height)
+{
+  COLORMAP ColorMap[] = {
+    {BGR_BUTTONTEXT,    COLOR_BTNTEXT},     // black
+    {BGR_BUTTONSHADOW,  COLOR_BTNSHADOW},   // dark grey
+    {BGR_BUTTONFACE,    COLOR_BTNFACE},     // bright grey
+    {BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
+    {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT},   // blue
+    {BGR_BACKGROUND,    COLOR_WINDOW}       // magenta
+  };
+
+  int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
+  int n;
+  for ( n = 0; n < NUM_MAPS; n++)
+  {
+    ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
+  }
+
+  HBITMAP hbmOld;
+  HDC hdcMem = CreateCompatibleDC(NULL);
+
+  if (hdcMem)
+  {
+    hbmOld = SelectObject(hdcMem, hBitmap);
+
+    int i, j, k;
+    for ( i = 0; i < width; i++)
+    {
+        for ( j = 0; j < height; j++)
+        {
+            COLORREF pixel = ::GetPixel(hdcMem, i, j);
+/*
+            BYTE red = GetRValue(pixel);
+            BYTE green = GetGValue(pixel);
+            BYTE blue = GetBValue(pixel);
+*/
+
+            for ( k = 0; k < NUM_MAPS; k ++)
+            {
+                if ( ColorMap[k].from == pixel )
+                {
+                    /* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
+                    break;
+                }
+            }
+        }
+    }
+
+
+    SelectObject(hdcMem, hbmOld);
+    DeleteObject(hdcMem);
+  }
+
+}
+#endif
+
+// Tab event
+IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
+
+wxTabEvent::wxTabEvent(WXTYPE commandType, int id):
+  wxCommandEvent(commandType, id)
+{
+}
+
+
+#endif
+    // __WIN95__
diff --git a/src/msw/taskbar.cpp b/src/msw/taskbar.cpp
new file mode 100644
index 0000000000..be8f8cd3c7
--- /dev/null
+++ b/src/msw/taskbar.cpp
@@ -0,0 +1,286 @@
+/////////////////////////////////////////////////////////////////////////
+// File:        taskbar.cpp
+// Purpose:	    Implements wxTaskBarIcon class for manipulating icons on
+//              the Windows task bar.
+// Author:      Julian Smart
+// Modified by:
+// Created:     24/3/98
+// RCS-ID:      $Id$
+// Copyright:   (c)
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "taskbar.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/defs.h"
+#endif
+
+#ifdef __WIN95__
+
+#include <wx/msw/taskbar.h>
+#include <string.h>
+#include <windows.h>
+#include <wx/msw/private.h>
+
+#ifdef __GNUWIN32__
+#include <wx/msw/gnuwin32/extra.h>
+#endif
+
+LRESULT APIENTRY _EXPORT wxTaskBarIconWindowProc( HWND hWnd, unsigned msg,
+				     UINT wParam, LONG lParam );
+
+char *wxTaskBarWindowClass = "wxTaskBarWindowClass";
+
+wxList wxTaskBarIcon::sm_taskBarIcons;
+bool   wxTaskBarIcon::sm_registeredClass = FALSE;
+UINT   wxTaskBarIcon::sm_taskbarMsg = 0;
+
+wxTaskBarIcon::wxTaskBarIcon(void)
+{
+    m_hWnd = 0;
+    m_iconAdded = FALSE;
+
+    AddObject(this);
+
+    if (RegisterWindowClass())
+        m_hWnd = CreateTaskBarWindow();
+}
+
+wxTaskBarIcon::~wxTaskBarIcon(void)
+{
+    RemoveObject(this);
+
+    if (m_iconAdded)
+    {
+        RemoveIcon();
+    }
+
+    if (m_hWnd)
+    {
+        ::DestroyWindow((HWND) m_hWnd);
+        m_hWnd = 0;
+    }
+}
+
+// Operations
+bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
+{
+    if (!IsOK())
+        return FALSE;
+
+    NOTIFYICONDATA notifyData;
+
+    memset(&notifyData, 0, sizeof(notifyData));
+	notifyData.cbSize = sizeof(notifyData);
+	notifyData.hWnd = (HWND) m_hWnd;
+	notifyData.uCallbackMessage = sm_taskbarMsg;
+	notifyData.uFlags = NIF_MESSAGE ;
+	if (icon.Ok())
+    {
+		notifyData.uFlags |= NIF_ICON;
+	    notifyData.hIcon = (HICON) icon.GetHICON();
+    }
+
+    if (((const char*) tooltip != NULL) && (tooltip != ""))
+    {
+        notifyData.uFlags |= NIF_TIP ;
+		lstrcpyn(notifyData.szTip, (char*) (const char*) tooltip, sizeof(notifyData.szTip));
+    }
+
+    notifyData.uID = 99;
+
+    if (m_iconAdded)
+        return (Shell_NotifyIcon(NIM_MODIFY, & notifyData) != 0);
+    else
+    {
+        m_iconAdded = (Shell_NotifyIcon(NIM_ADD, & notifyData) != 0);
+        return m_iconAdded;
+    }
+}
+
+bool wxTaskBarIcon::RemoveIcon(void)
+{
+    if (!m_iconAdded)
+        return FALSE;
+
+    NOTIFYICONDATA notifyData;
+
+    memset(&notifyData, 0, sizeof(notifyData));
+	notifyData.cbSize = sizeof(notifyData);
+	notifyData.hWnd = (HWND) m_hWnd;
+	notifyData.uCallbackMessage = sm_taskbarMsg;
+	notifyData.uFlags = NIF_MESSAGE;
+	notifyData.hIcon = 0 ; // hIcon;
+    notifyData.uID = 99;
+    m_iconAdded = FALSE;
+
+    return (Shell_NotifyIcon(NIM_DELETE, & notifyData) != 0);
+}
+
+// Overridables
+void wxTaskBarIcon::OnMouseMove(void)
+{
+}
+
+void wxTaskBarIcon::OnLButtonDown(void)
+{
+}
+
+void wxTaskBarIcon::OnLButtonUp(void)
+{
+}
+
+void wxTaskBarIcon::OnRButtonDown(void)
+{
+}
+
+void wxTaskBarIcon::OnRButtonUp(void)
+{
+}
+
+void wxTaskBarIcon::OnLButtonDClick(void)
+{
+}
+
+void wxTaskBarIcon::OnRButtonDClick(void)
+{
+}
+
+wxTaskBarIcon* wxTaskBarIcon::FindObjectForHWND(WXHWND hWnd)
+{
+    wxNode*node = sm_taskBarIcons.First();
+    while (node)
+    {
+        wxTaskBarIcon* obj = (wxTaskBarIcon*) node->Data();
+        if (obj->GetHWND() == hWnd)
+            return obj;
+        node = node->Next();
+    }
+    return NULL;
+}
+
+void wxTaskBarIcon::AddObject(wxTaskBarIcon* obj)
+{
+    sm_taskBarIcons.Append(obj);
+}
+
+void wxTaskBarIcon::RemoveObject(wxTaskBarIcon* obj)
+{
+    sm_taskBarIcons.DeleteObject(obj);
+}
+
+bool wxTaskBarIcon::RegisterWindowClass()
+{
+    if (sm_registeredClass)
+        return TRUE;
+
+    // Also register the taskbar message here
+    sm_taskbarMsg = ::RegisterWindowMessage("wxTaskBarIconMessage");
+
+    WNDCLASS	wc;
+    bool	rc;
+
+    HINSTANCE hInstance = GetModuleHandle(NULL);
+
+    /*
+     * set up and register window class
+     */
+    wc.style = CS_HREDRAW | CS_VREDRAW;
+    wc.lpfnWndProc = (WNDPROC) wxTaskBarIconWindowProc;
+    wc.cbClsExtra = 0;
+    wc.cbWndExtra = 0;
+    wc.hInstance = hInstance;
+    wc.hIcon = 0;
+    wc.hCursor = 0;
+    wc.hbrBackground = 0;
+    wc.lpszMenuName = NULL;
+    wc.lpszClassName = wxTaskBarWindowClass ;
+    rc = (::RegisterClass( &wc ) != 0);
+
+    sm_registeredClass = (rc != 0);
+
+    return( (rc != 0) );
+}
+
+WXHWND wxTaskBarIcon::CreateTaskBarWindow()
+{
+    HINSTANCE hInstance = GetModuleHandle(NULL);
+
+    HWND hWnd = CreateWindowEx (0, wxTaskBarWindowClass,
+            "wxTaskBarWindow",
+            WS_OVERLAPPED,
+            0,
+            0,
+            10,
+            10,
+            NULL,
+            (HMENU) 0,
+            hInstance,
+            NULL);
+
+    return (WXHWND) hWnd;
+}
+
+long wxTaskBarIcon::WindowProc( WXHWND hWnd, unsigned int msg, unsigned int wParam, long lParam )
+{
+    if (msg != sm_taskbarMsg)
+        return DefWindowProc((HWND) hWnd, msg, wParam, lParam);
+
+    switch (lParam)
+    {
+	case WM_LBUTTONDOWN:
+		OnLButtonDown();
+		break;
+
+	case WM_LBUTTONUP:
+		OnLButtonUp();
+		break;
+
+	case WM_RBUTTONDOWN:
+		OnRButtonDown();
+		break;
+
+	case WM_RBUTTONUP:
+		OnRButtonUp();
+		break;
+
+	case WM_LBUTTONDBLCLK:
+		OnLButtonDClick();
+		break;
+
+	case WM_RBUTTONDBLCLK:
+		OnRButtonDClick();
+		break;
+
+	case WM_MOUSEMOVE:
+		OnMouseMove();
+		break;
+
+	default:
+        break;
+	}
+    return 0;
+}
+
+LRESULT APIENTRY _EXPORT wxTaskBarIconWindowProc( HWND hWnd, unsigned msg,
+				     UINT wParam, LONG lParam )
+{
+    wxTaskBarIcon* obj = wxTaskBarIcon::FindObjectForHWND((WXHWND) hWnd);
+    if (obj)
+        return obj->WindowProc((WXHWND) hWnd, msg, wParam, lParam);
+    else
+        return DefWindowProc(hWnd, msg, wParam, lParam);
+}
+
+#endif
+    // __WIN95__
diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp
new file mode 100644
index 0000000000..ea86d42cec
--- /dev/null
+++ b/src/msw/tbar95.cpp
@@ -0,0 +1,558 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        tbar95.cpp
+// Purpose:     wxToolBar95
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "tbar95.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx.h"
+#endif
+
+#if USE_BUTTONBAR && USE_TOOLBAR && defined(__WIN95__)
+
+#ifndef __GNUWIN32__
+#include "malloc.h"
+#endif
+
+#include <windows.h>
+
+#ifndef __GNUWIN32__
+#include <commctrl.h>
+#endif
+
+#ifdef __GNUWIN32__
+#include "wx/msw/gnuwin32/extra.h"
+#endif
+
+#include "wx/msw/dib.h"
+#include "wx/tbar95.h"
+#include "wx/app.h"
+#include "wx/msw/private.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxToolBar95, wxToolBarBase)
+
+BEGIN_EVENT_TABLE(wxToolBar95, wxToolBarBase)
+	EVT_SIZE(wxToolBar95::OnSize)
+	EVT_PAINT(wxToolBar95::OnPaint)
+	EVT_KILL_FOCUS(wxToolBar95::OnKillFocus)
+	EVT_MOUSE_EVENTS(wxToolBar95::OnMouseEvent)
+    EVT_SYS_COLOUR_CHANGED(wxToolBar95::OnSysColourChanged)
+END_EVENT_TABLE()
+#endif
+
+void wxMapBitmap(HBITMAP hBitmap, int width, int height);
+
+wxToolBar95::wxToolBar95(void)
+{
+  m_tilingDirection = wxVERTICAL ;
+  m_rowsOrColumns = 0;
+  m_currentRowsOrColumns = 0;
+  m_maxWidth = -1;
+  m_maxHeight = -1;
+  m_hBitmap = 0;
+  m_defaultWidth = DEFAULTBITMAPX;
+  m_defaultHeight = DEFAULTBITMAPY;
+}
+
+bool wxToolBar95::Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size,
+            const long style, const int orientation,
+            const int RowsOrColumns, const wxString& name)
+{
+  m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
+  	GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+  m_foregroundColour = *wxBLACK ;
+
+  m_defaultForegroundColour = *wxBLACK ;
+  m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
+  	GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+
+  m_tilingDirection = orientation;
+  if (m_tilingDirection == wxHORIZONTAL)
+    wxMessageBox("Sorry, wxToolBar95 under Windows 95 only supports vertical tiling.\nPass the number of rows.", "wxToolBar95 usage", wxOK);
+  m_rowsOrColumns = RowsOrColumns;
+  m_currentRowsOrColumns = 0;
+  m_maxWidth = -1;
+  m_maxHeight = -1;
+  
+  m_hBitmap = 0;
+
+  m_defaultWidth = DEFAULTBITMAPX;
+  m_defaultHeight = DEFAULTBITMAPY;
+  SetName(name);
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_windowStyle = style;
+
+  SetFont(wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL));
+
+  SetParent(parent);
+
+  DWORD msflags = 0;
+  if (style & wxBORDER)
+    msflags |= WS_BORDER;
+  msflags |= WS_CHILD | WS_VISIBLE;
+  
+  if (width <= 0)
+    width = 100;
+  if (height <= 0)
+    height = 30;
+  if (x < 0)
+    x = 0;
+  if (y < 0)
+    y = 0;
+
+  m_windowId = (id < 0 ? NewControlId() : id);
+
+  // Create the toolbar control.
+  HWND hWndToolbar = CreateWindowEx(0L,   // No extended styles.
+    TOOLBARCLASSNAME,                 // Class name for the toolbar.
+    "",                               // No default text.
+    WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS,    // Styles and defaults.
+    x, y, width, height,                    // Standard toolbar size and position.
+    (HWND) parent->GetHWND(),                       // Parent window of the toolbar.
+    (HMENU)m_windowId,                // Toolbar ID.
+    wxGetInstance(),                            // Current instance.
+    NULL );                           // No class data.
+
+  // Toolbar-specific initialisation
+  ::SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), (LPARAM)0);
+
+  m_hWnd = (WXHWND) hWndToolbar;
+  if (parent) parent->AddChild(this);
+  
+  SubclassWin((WXHWND) hWndToolbar);
+
+  return TRUE;
+}
+
+wxToolBar95::~wxToolBar95(void)
+{
+  UnsubclassWin();
+
+  if (m_hBitmap)
+  {
+    ::DeleteObject((HBITMAP) m_hBitmap);
+    m_hBitmap = 0;
+  }
+}
+
+bool wxToolBar95::CreateTools(void)
+{
+  if (m_tools.Number() == 0)
+    return FALSE;
+
+  HBITMAP oldToolBarBitmap = (HBITMAP) m_hBitmap;
+    
+  int totalBitmapWidth = (int)(m_defaultWidth * m_tools.Number());
+  int totalBitmapHeight = (int)m_defaultHeight;
+
+  // Create a bitmap for all the tool bitmaps
+  HDC dc = ::GetDC(NULL);
+  m_hBitmap = (WXHBITMAP) ::CreateCompatibleBitmap(dc, totalBitmapWidth, totalBitmapHeight);
+  ::ReleaseDC(NULL, dc);
+  
+  // Now blit all the tools onto this bitmap
+  HDC memoryDC = ::CreateCompatibleDC(NULL);
+  HBITMAP oldBitmap = ::SelectObject(memoryDC, (HBITMAP) m_hBitmap);
+
+  HDC memoryDC2 = ::CreateCompatibleDC(NULL);
+  int x = 0;
+  wxNode *node = m_tools.First();
+  int noButtons = 0;
+  while (node)
+  {
+    wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+    if ((tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR) && tool->m_bitmap1.Ok() && tool->m_bitmap1.GetHBITMAP())
+    {
+//      wxPalette *palette = tool->m_bitmap1->GetPalette();
+
+      HBITMAP oldBitmap2 = ::SelectObject(memoryDC2, (HBITMAP) tool->m_bitmap1.GetHBITMAP());
+      /* int bltResult = */
+	  BitBlt(memoryDC, x, 0, (int) m_defaultWidth, (int) m_defaultHeight, memoryDC2,
+                        0, 0, SRCCOPY);
+      ::SelectObject(memoryDC2, oldBitmap2);
+      x += (int)m_defaultWidth;
+      noButtons ++;
+    }
+    node = node->Next();
+  }
+  ::SelectObject(memoryDC, oldBitmap);
+  ::DeleteDC(memoryDC);
+  ::DeleteDC(memoryDC2);
+
+  // Map to system colours
+  wxMapBitmap((HBITMAP) m_hBitmap, totalBitmapWidth, totalBitmapHeight);
+
+  if ( oldToolBarBitmap )
+  {
+    TBREPLACEBITMAP replaceBitmap;
+    replaceBitmap.hInstOld = NULL;
+    replaceBitmap.hInstNew = NULL;
+    replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
+    replaceBitmap.nIDNew = (UINT) (HBITMAP) m_hBitmap;
+    replaceBitmap.nButtons = noButtons;
+    if (::SendMessage((HWND) GetHWND(), TB_REPLACEBITMAP, (WPARAM) 0, (LPARAM) &replaceBitmap) == -1)
+      wxMessageBox("Could not add bitmap to toolbar");
+
+    ::DeleteObject((HBITMAP) oldToolBarBitmap);
+
+    // Now delete all the buttons
+    int i = 0;
+    while ( TRUE )
+    {
+        // TODO: What about separators???? They don't have an id!
+        if ( ! ::SendMessage( (HWND) GetHWND(), TB_DELETEBUTTON, i, 0 ) )
+            break;
+    }
+  }
+  else
+  {
+    TBADDBITMAP addBitmap;
+    addBitmap.hInst = 0;
+    addBitmap.nID = (UINT)m_hBitmap;
+    if (::SendMessage((HWND) GetHWND(), TB_ADDBITMAP, (WPARAM) noButtons, (LPARAM) &addBitmap) == -1)
+      wxMessageBox("Could not add bitmap to toolbar");
+  }
+
+  // Now add the buttons.
+  TBBUTTON buttons[50];
+
+  node = m_tools.First();
+  int i = 0;
+  int bitmapId = 0;
+  while (node)
+  {
+    wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+    if (tool->m_toolStyle == wxTOOL_STYLE_SEPARATOR)
+    {
+      buttons[i].iBitmap = 0;
+      buttons[i].idCommand = 0;
+
+      buttons[i].fsState = TBSTATE_ENABLED;
+      buttons[i].fsStyle = TBSTYLE_SEP;
+      buttons[i].dwData = 0L;
+      buttons[i].iString = 0;
+    }
+    else
+    {
+      buttons[i].iBitmap = bitmapId;
+      buttons[i].idCommand = tool->m_index;
+
+      buttons[i].fsState = 0;
+      if (tool->m_enabled)
+        buttons[i].fsState |= TBSTATE_ENABLED;
+      if (tool->m_toggleState)
+        buttons[i].fsState |= TBSTATE_CHECKED;
+      buttons[i].fsStyle = tool->m_isToggle ? TBSTYLE_CHECK : TBSTYLE_BUTTON;
+      buttons[i].dwData = 0L;
+      buttons[i].iString = 0;
+
+      bitmapId ++;
+    }
+        
+    i ++;
+    node = node->Next();
+  }
+
+  int ans = (int)::SendMessage((HWND) GetHWND(), TB_ADDBUTTONS, (WPARAM)i, (LPARAM)& buttons);
+  ans = (int)::SendMessage((HWND) GetHWND(), TB_AUTOSIZE, (WPARAM)0, (LPARAM) 0);
+
+  RECT rect;
+  ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_rowsOrColumns, TRUE), (LPARAM) & rect);
+  m_maxWidth = (rect.right - rect.left + 2);
+  m_maxHeight = (rect.bottom - rect.top + 2);
+
+  return TRUE;
+}
+
+bool wxToolBar95::MSWCommand(const WXUINT cmd, const WXWORD id)
+{
+  wxNode *node = m_tools.Find((long)id);
+  if (!node)
+    return FALSE;
+  wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+  if (tool->m_isToggle)
+    tool->m_toggleState = (1 == (1 & (int)::SendMessage((HWND) GetHWND(), TB_GETSTATE, (WPARAM) id, (LPARAM) 0)));
+
+  BOOL ret = OnLeftClick((int)id, tool->m_toggleState);
+  if (ret == FALSE && tool->m_isToggle)
+  {
+    tool->m_toggleState = !tool->m_toggleState;
+    ::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)id, (LPARAM)MAKELONG(tool->m_toggleState, 0));
+  }
+  return TRUE;
+}
+
+bool wxToolBar95::MSWNotify(const WXWPARAM WXUNUSED(wParam), const WXLPARAM lParam)
+{
+	// First check if this applies to us
+    NMHDR *hdr = (NMHDR *)lParam;
+    if (hdr->code != TTN_NEEDTEXT)
+		return FALSE;
+
+ 	HWND toolTipWnd = (HWND) ::SendMessage((HWND) GetHWND(), TB_GETTOOLTIPS, 0, 0);
+	if ( toolTipWnd != hdr->hwndFrom )
+		return FALSE;
+
+  LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT) lParam;
+  int id = (int)ttText->hdr.idFrom;
+  wxNode *node = m_tools.Find((long)id);
+  if (!node)
+    return FALSE;
+  
+  wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+
+  switch (ttText->hdr.code)
+  {
+    case TTN_NEEDTEXT:
+    {
+      if (tool->m_shortHelpString != "")
+        ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
+
+      // For backward compatibility...
+      OnMouseEnter(tool->m_index);
+      break;
+    }
+    default:
+      return FALSE;
+      break;
+  }
+  
+  return TRUE;
+}
+
+void wxToolBar95::SetDefaultSize(const wxSize& size)
+{
+  m_defaultWidth = size.x; m_defaultHeight = size.y;
+  ::SendMessage((HWND) GetHWND(), TB_SETBITMAPSIZE, 0, (LPARAM) MAKELONG ((int)size.x, (int)size.y));
+}
+
+void wxToolBar95::SetRows(const int nRows)
+{
+  RECT rect;
+  ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(nRows, TRUE), (LPARAM) & rect);
+  m_maxWidth = (rect.right - rect.left + 2);
+  m_maxHeight = (rect.bottom - rect.top + 2);
+}
+
+wxSize wxToolBar95::GetMaxSize(void) const
+{
+  if (m_maxWidth == -1 | m_maxHeight == -1)
+  {
+    RECT rect;
+    ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_rowsOrColumns, TRUE), (LPARAM) & rect);
+    ((wxToolBar95 *)this)->m_maxWidth = (rect.right - rect.left + 2); // ???
+    ((wxToolBar95 *)this)->m_maxHeight = (rect.bottom - rect.top + 2); // ???
+  }
+  return wxSize(m_maxWidth, m_maxHeight);
+}
+
+void wxToolBar95::GetSize(int *w, int *h) const
+{
+  wxWindow::GetSize(w, h);
+  // For some reason, the returned height is several pixels bigger than that
+  // displayed!
+  *h -= 2;
+}
+
+// The button size is bigger than the bitmap size
+wxSize wxToolBar95::GetDefaultButtonSize(void) const
+{
+  return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
+}
+
+void wxToolBar95::EnableTool(const int toolIndex, const bool enable)
+{
+  wxNode *node = m_tools.Find((long)toolIndex);
+  if (node)
+  {
+    wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+    tool->m_enabled = enable;
+    ::SendMessage((HWND) GetHWND(), TB_ENABLEBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(enable, 0));
+  }
+}
+
+void wxToolBar95::ToggleTool(const int toolIndex, const bool toggle)
+{
+  wxNode *node = m_tools.Find((long)toolIndex);
+  if (node)
+  {
+    wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+    if (tool->m_isToggle)
+    {
+      tool->m_toggleState = toggle;
+      ::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(toggle, 0));
+    }
+  }
+}
+
+void wxToolBar95::ClearTools(void)
+{
+  // TODO: Don't know how to reset the toolbar bitmap, as yet.
+  // But adding tools and calling CreateTools should probably
+  // recreate a buttonbar OK.
+  wxToolBarBase::ClearTools();
+}
+
+// If pushedBitmap is NULL, a reversed version of bitmap is
+// created and used as the pushed/toggled image.
+// If toggle is TRUE, the button toggles between the two states.
+wxToolBarTool *wxToolBar95::AddTool(const int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap,
+             const bool toggle, const long xPos, const long yPos, wxObject *clientData, const wxString& helpString1, const wxString& helpString2)
+{
+  wxToolBarTool *tool = new wxToolBarTool(index, bitmap, (wxBitmap *)NULL, toggle, xPos, yPos, helpString1, helpString2);
+  tool->m_clientData = clientData;
+
+  if (xPos > -1)
+    tool->m_x = xPos;
+  else
+    tool->m_x = m_xMargin;
+
+  if (yPos > -1)
+    tool->m_y = yPos;
+  else
+    tool->m_y = m_yMargin;
+
+  tool->SetSize(GetDefaultButtonWidth(), GetDefaultButtonHeight());
+
+  m_tools.Append((long)index, tool);
+  return tool;
+}
+
+// Responds to colour changes, and passes event on to children.
+void wxToolBar95::OnSysColourChanged(wxSysColourChangedEvent& event)
+{
+    m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
+  	    GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+    m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
+  	    GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+
+    // Remap the buttons
+    CreateTools();
+
+    Default();
+
+    Refresh();
+
+    // Propagate the event to the non-top-level children
+    wxWindow::OnSysColourChanged(event);
+}
+
+// These are the default colors used to map the bitmap colors
+// to the current system colors
+
+#define BGR_BUTTONTEXT      (RGB(000,000,000))  // black
+#define BGR_BUTTONSHADOW    (RGB(128,128,128))  // dark grey
+#define BGR_BUTTONFACE      (RGB(192,192,192))  // bright grey
+#define BGR_BUTTONHILIGHT   (RGB(255,255,255))  // white
+#define BGR_BACKGROUNDSEL   (RGB(255,000,000))  // blue
+#define BGR_BACKGROUND      (RGB(255,000,255))  // magenta
+
+void wxMapBitmap(HBITMAP hBitmap, int width, int height)
+{
+  COLORMAP ColorMap[] = {
+    {BGR_BUTTONTEXT,    COLOR_BTNTEXT},     // black
+    {BGR_BUTTONSHADOW,  COLOR_BTNSHADOW},   // dark grey
+    {BGR_BUTTONFACE,    COLOR_BTNFACE},     // bright grey
+    {BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
+    {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT},   // blue
+    {BGR_BACKGROUND,    COLOR_WINDOW}       // magenta
+  };
+
+  int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
+  int n;
+  for ( n = 0; n < NUM_MAPS; n++)
+  {
+    ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
+  }
+
+  HBITMAP hbmOld;
+  HDC hdcMem = CreateCompatibleDC(NULL);
+
+  if (hdcMem)
+  {
+    hbmOld = SelectObject(hdcMem, hBitmap);
+
+    int i, j, k;
+    for ( i = 0; i < width; i++)
+    {
+        for ( j = 0; j < height; j++)
+        {
+            COLORREF pixel = ::GetPixel(hdcMem, i, j);
+/*
+            BYTE red = GetRValue(pixel);
+            BYTE green = GetGValue(pixel);
+            BYTE blue = GetBValue(pixel);
+*/
+
+            for ( k = 0; k < NUM_MAPS; k ++)
+            {
+                if ( ColorMap[k].from == pixel )
+                {
+                    /* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
+                    break;
+                }
+            }
+        }
+    }
+
+
+    SelectObject(hdcMem, hbmOld);
+    DeleteObject(hdcMem);
+  }
+
+}
+
+// Some experiments...
+#if 0
+  // What we want to do is create another bitmap which has a depth of 4,
+  // and set the bits. So probably we want to convert this HBITMAP into a
+  // DIB, then call SetDIBits.
+  // AAAGH. The stupid thing is that if newBitmap has a depth of 4 (less than that of
+  // the screen), then SetDIBits fails.
+  HBITMAP newBitmap = ::CreateBitmap(totalBitmapWidth, totalBitmapHeight, 1, 4, NULL);
+  HANDLE newDIB = ::BitmapToDIB((HBITMAP) m_hBitmap, NULL);
+  LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) GlobalLock(newDIB);
+
+  dc = ::GetDC(NULL);
+//  LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) newDIB;
+
+  int result = ::SetDIBits(dc, newBitmap, 0, lpbmi->biHeight, FindDIBBits((LPSTR)lpbmi), (LPBITMAPINFO)lpbmi,
+    DIB_PAL_COLORS);
+  DWORD err = GetLastError();
+
+  ::ReleaseDC(NULL, dc);
+
+  // Delete the DIB
+  GlobalUnlock (newDIB);
+  GlobalFree (newDIB);
+
+//  WXHBITMAP hBitmap2 = wxCreateMappedBitmap((WXHINSTANCE) wxGetInstance(), (WXHBITMAP) m_hBitmap);
+  // Substitute our new bitmap for the old one
+  ::DeleteObject((HBITMAP) m_hBitmap);
+  m_hBitmap = (WXHBITMAP) newBitmap;
+#endif
+
+
+#endif
diff --git a/src/msw/tbarmsw.cpp b/src/msw/tbarmsw.cpp
new file mode 100644
index 0000000000..86b2d33e9f
--- /dev/null
+++ b/src/msw/tbarmsw.cpp
@@ -0,0 +1,855 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        tbarmsw.cpp
+// Purpose:     wxToolBarMSW
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "tbarmsw.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx.h"
+#endif
+
+#if USE_BUTTONBAR && USE_TOOLBAR
+
+#ifndef __GNUWIN32__
+#include "malloc.h"
+#endif
+
+#include <memory.h>
+#include <stdlib.h>
+
+#include "wx/tbarmsw.h"
+#include "wx/app.h"
+#include "wx/msw/private.h"
+#include "wx/msw/dib.h"
+
+/////// Non-Windows 95 implementation
+
+#if !USE_IMAGE_LOADING_IN_MSW
+#error If USE_IMAGE_LOADING_IN_MSW is set to 0, then USE_BUTTONBAR must be set to 0 too.
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxToolBarMSW, wxToolBarBase)
+
+BEGIN_EVENT_TABLE(wxToolBarMSW, wxToolBarBase)
+	EVT_SIZE(wxToolBarMSW::OnSize)
+	EVT_PAINT(wxToolBarMSW::OnPaint)
+	EVT_MOUSE_EVENTS(wxToolBarMSW::OnMouseEvent)
+END_EVENT_TABLE()
+#endif
+
+wxToolBarMSW::wxToolBarMSW(void)
+{
+  m_hbrDither = 0;
+  m_rgbFace = 0;
+  m_rgbShadow = 0;
+  m_rgbHilight = 0;
+  m_rgbFrame = 0;
+  m_hdcMono = 0;
+  m_hbmMono = 0;
+  m_hbmDefault = 0;
+  m_defaultWidth = DEFAULTBITMAPX;
+  m_defaultHeight = DEFAULTBITMAPY;
+}
+
+bool wxToolBarMSW::Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size,
+            const long style, const int orientation,
+            const int RowsOrColumns, const wxString& name)
+{
+	if ( ! wxWindow::Create(parent, id, pos, size, style, name) )
+		return FALSE;
+
+  m_tilingDirection = orientation;
+  m_rowsOrColumns = RowsOrColumns;
+  if ( m_tilingDirection == wxVERTICAL )
+    { m_lastX = 3; m_lastY = 7; }
+  else
+    { m_lastX = 7; m_lastY = 3; }
+  m_maxWidth = m_maxHeight = 0;
+  m_pressedTool = m_currentTool = -1;
+  m_xMargin = 0;
+  m_yMargin = 0;
+  m_toolPacking = 1;
+  m_toolSeparation = 5;
+
+  // Set it to grey
+  SetBackgroundColour(wxColour(192, 192, 192));
+
+  m_hbrDither = 0;
+  m_rgbFace = 0;
+  m_rgbShadow = 0;
+  m_rgbHilight = 0;
+  m_rgbFrame = 0;
+  m_hdcMono = 0;
+  m_hbmMono = 0;
+  m_hbmDefault = 0;
+  m_defaultWidth = DEFAULTBITMAPX;
+  m_defaultHeight = DEFAULTBITMAPY;
+
+  InitGlobalObjects();
+
+  return TRUE;
+}
+
+wxToolBarMSW::~wxToolBarMSW(void)
+{
+  FreeGlobalObjects();
+}
+
+void wxToolBarMSW::SetDefaultSize(const wxSize& size)
+{
+  m_defaultWidth = size.x; m_defaultHeight = size.y;
+  FreeGlobalObjects();
+  InitGlobalObjects();
+}
+
+// The button size is bigger than the bitmap size
+wxSize wxToolBarMSW::GetDefaultButtonSize(void) const
+{
+  return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
+}
+
+void wxToolBarMSW::OnPaint(wxPaintEvent& event)
+{
+  wxPaintDC dc(this);
+
+  static int wxOnPaintCount = 0;
+
+  // Prevent reentry of OnPaint which would cause
+  // wxMemoryDC errors.
+  if (wxOnPaintCount > 0)
+    return;
+  wxOnPaintCount ++;
+
+  wxNode *node = m_tools.First();
+  while (node)
+  {
+    wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+    if (tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR)
+    {
+      int state = wxTBSTATE_ENABLED;
+      if (!tool->m_enabled)
+        state = 0;
+      if (tool->m_isToggle && tool->m_toggleState)
+        state |= wxTBSTATE_CHECKED;
+      DrawTool(dc, tool, state);
+    }
+    node = node->Next();
+  }
+  wxOnPaintCount --;
+}
+
+void wxToolBarMSW::OnSize(wxSizeEvent& event)
+{
+  wxToolBarBase::OnSize(event);
+}
+
+// If a Button is disabled, then NO function (besides leaving
+// or entering) should be carried out. Therefore the additions
+// of 'enabled' testing (Stefan Hammes).
+void wxToolBarMSW::OnMouseEvent(wxMouseEvent& event)
+{
+  static wxToolBarTool *eventCurrentTool = NULL;
+  wxClientDC dc(this);
+
+  if (event.Leaving())
+  {
+    m_currentTool = -1;
+    if (eventCurrentTool && eventCurrentTool->m_enabled)
+    {
+      ::ReleaseCapture();
+      int state = wxTBSTATE_ENABLED;
+      if (eventCurrentTool->m_toggleState)
+        state |= wxTBSTATE_CHECKED;
+      DrawTool(dc, eventCurrentTool, state);
+      eventCurrentTool = NULL;
+    }
+    OnMouseEnter(-1);
+    return;
+  }
+
+  long x, y;
+  event.Position(&x, &y);
+  wxToolBarTool *tool = FindToolForPosition(x, y);
+
+  if (!tool)
+  {
+    if (eventCurrentTool && eventCurrentTool->m_enabled)
+    {
+      ::ReleaseCapture();
+      
+      int state = wxTBSTATE_ENABLED;
+      if (eventCurrentTool->m_toggleState)
+        state |= wxTBSTATE_CHECKED;
+      DrawTool(dc, eventCurrentTool, state);
+      eventCurrentTool = NULL;
+    }
+    if (m_currentTool > -1)
+    {
+      m_currentTool = -1;
+      OnMouseEnter(-1);
+    }
+    return;
+  }
+  
+  if (!event.Dragging() && !event.IsButton())
+  {
+    if (tool->m_index != m_currentTool)
+    {
+      OnMouseEnter(tool->m_index);
+      m_currentTool = tool->m_index;
+      return;
+    }
+  }
+  if (event.Dragging() && tool->m_enabled)
+  {
+    if (eventCurrentTool)
+    {
+      // Might have dragged outside tool
+      if (eventCurrentTool != tool)
+      {
+        int state = wxTBSTATE_ENABLED;
+        if (tool->m_toggleState)
+          state |= wxTBSTATE_CHECKED;
+        DrawTool(dc, tool, state);
+        eventCurrentTool = NULL;
+        return;
+      }
+    }
+    else
+    {
+      if (tool && event.LeftIsDown() && tool->m_enabled)
+      {
+        eventCurrentTool = tool;
+        ::SetCapture((HWND) GetHWND());
+        int state = wxTBSTATE_ENABLED|wxTBSTATE_PRESSED;
+        if (tool->m_toggleState)
+          state |= wxTBSTATE_CHECKED;
+        DrawTool(dc, tool, state);
+      }
+    }
+  }
+  if (event.LeftDown() && tool->m_enabled)
+  {
+    eventCurrentTool = tool;
+    ::SetCapture((HWND) GetHWND());
+    int state = wxTBSTATE_ENABLED|wxTBSTATE_PRESSED;
+    if (tool->m_toggleState)
+      state |= wxTBSTATE_CHECKED;
+    DrawTool(dc, tool, state);
+  }
+  else if (event.LeftUp() && tool->m_enabled)
+  {
+    if (eventCurrentTool)
+      ::ReleaseCapture();
+    if (eventCurrentTool == tool)
+    {
+      if (tool->m_isToggle)
+      {
+        tool->m_toggleState = !tool->m_toggleState;
+        if (!OnLeftClick(tool->m_index, tool->m_toggleState))
+        {
+          tool->m_toggleState = !tool->m_toggleState;
+        }
+        int state = wxTBSTATE_ENABLED;
+        if (tool->m_toggleState)
+          state |= wxTBSTATE_CHECKED;
+        DrawTool(dc, tool, state);
+      }
+      else
+      {
+        int state = wxTBSTATE_ENABLED;
+        if (tool->m_toggleState)
+          state |= wxTBSTATE_CHECKED;
+        DrawTool(dc, tool, state);
+        OnLeftClick(tool->m_index, tool->m_toggleState);
+      }
+    }
+    eventCurrentTool = NULL;
+  }
+  else if (event.RightDown() && tool->m_enabled)
+  {
+    OnRightClick(tool->m_index, x, y);
+  }
+}
+
+// This function enables/disables a toolbar tool and redraws it.
+// If that would not be done, the enabling/disabling wouldn't be
+// visible on the screen.
+void wxToolBarMSW::EnableTool(const int toolIndex, const bool enable)
+{
+  wxNode *node = m_tools.Find((long)toolIndex);
+  if (node)
+  {
+	wxClientDC dc(this);
+
+    // at first do the enabling/disabling in the base class
+    wxToolBarBase::EnableTool(toolIndex,enable);
+    // then calculate the state of the tool and draw it
+    wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+    int state = 0;
+    if(tool->m_toggleState) state |= wxTBSTATE_CHECKED;
+    if(tool->m_enabled) state |= wxTBSTATE_ENABLED;
+    // how can i access the PRESSED state???
+    DrawTool(dc, tool,state);
+  }
+}
+
+void wxToolBarMSW::DrawTool(wxDC& dc, wxToolBarTool *tool, int state)
+{
+  DrawButton(dc.GetHDC(), (int)tool->m_x, (int)tool->m_y, (int)tool->GetWidth(), (int)tool->GetHeight(), tool, state);
+}
+
+void wxToolBarMSW::DrawTool(wxDC& dc, wxMemoryDC& , wxToolBarTool *tool)
+{
+  int state = wxTBSTATE_ENABLED;
+  if (!tool->m_enabled)
+    state = 0;
+  if (tool->m_toggleState)
+    state |= wxTBSTATE_CHECKED;
+  DrawTool(dc, tool, state);
+}
+
+// If pushedBitmap is NULL, a reversed version of bitmap is
+// created and used as the pushed/toggled image.
+// If toggle is TRUE, the button toggles between the two states.
+wxToolBarTool *wxToolBarMSW::AddTool(const int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap,
+             const bool toggle, const long xPos, const long yPos, wxObject *clientData, const wxString& helpString1, const wxString& helpString2)
+{
+  // Using bitmap2 can cause problems (don't know why!)
+
+  // TODO: use the mapping code from wxToolBar95 to get it right in this class
+#if !defined(__WIN32__) && !defined(__WIN386__)
+  wxBitmap *bitmap2 = NULL;
+  if (toggle)
+  {
+    bitmap2 = new wxBitmap;
+    bitmap2->SetHBITMAP( (WXHBITMAP) CreateMappedBitmap(wxGetInstance(), (HBITMAP) ((wxBitmap& )bitmap).GetHBITMAP()));
+  }
+
+  wxToolBarTool *tool = new wxToolBarTool(index, bitmap, *bitmap2, toggle, xPos, yPos, helpString1, helpString2);
+#else
+  wxToolBarTool *tool = new wxToolBarTool(index, bitmap, (wxBitmap *)NULL, toggle, xPos, yPos, helpString1, helpString2);
+#endif
+
+  tool->m_clientData = clientData;
+
+  if (xPos > -1)
+    tool->m_x = xPos;
+  else
+    tool->m_x = m_xMargin;
+
+  if (yPos > -1)
+    tool->m_y = yPos;
+  else
+    tool->m_y = m_yMargin;
+
+  tool->m_deleteSecondBitmap = TRUE;
+  tool->SetSize(GetDefaultButtonWidth(), GetDefaultButtonHeight());
+  
+  // Calculate reasonable max size in case Layout() not called
+  if ((tool->m_x + bitmap.GetWidth() + m_xMargin) > m_maxWidth)
+    m_maxWidth = (tool->m_x + tool->GetWidth() + m_xMargin);
+
+  if ((tool->m_y + bitmap.GetHeight() + m_yMargin) > m_maxHeight)
+    m_maxHeight = (tool->m_y + tool->GetHeight() + m_yMargin);
+
+  m_tools.Append((long)index, tool);
+  return tool;
+}
+
+bool wxToolBarMSW::InitGlobalObjects(void)
+{
+  GetSysColors();      
+  if (!CreateDitherBrush())
+    return FALSE;
+
+  m_hdcMono = (WXHDC) CreateCompatibleDC(NULL);
+  if (!m_hdcMono)
+      return FALSE;
+
+  m_hbmMono = (WXHBITMAP) CreateBitmap((int)GetDefaultButtonWidth(), (int)GetDefaultButtonHeight(), 1, 1, NULL);
+  if (!m_hbmMono)
+      return FALSE;
+
+  m_hbmDefault = (WXHBITMAP) SelectObject((HDC) m_hdcMono, (HBITMAP) m_hbmMono);
+  return TRUE;
+}
+
+void wxToolBarMSW::FreeGlobalObjects(void)
+{
+    FreeDitherBrush();
+
+    if (m_hdcMono) {
+	if (m_hbmDefault)
+	{
+	    SelectObject((HDC) m_hdcMono, (HBITMAP) m_hbmDefault);
+	    m_hbmDefault = 0;
+	}
+	DeleteDC((HDC) m_hdcMono);		// toast the DCs
+    }
+    m_hdcMono = 0;
+
+    if (m_hbmMono)
+		DeleteObject((HBITMAP) m_hbmMono);
+    m_hbmMono = 0;
+}
+
+
+void wxToolBarMSW::PatB(WXHDC hdc,int x,int y,int dx,int dy, long rgb)
+{
+    RECT    rc;
+
+    rc.left   = x;
+    rc.top    = y;
+    rc.right  = x + dx;
+    rc.bottom = y + dy;
+
+    SetBkColor((HDC) hdc,rgb);
+    ExtTextOut((HDC) hdc,0,0,ETO_OPAQUE,&rc,NULL,0,NULL);
+}
+
+
+// create a mono bitmap mask:
+//   1's where color == COLOR_BTNFACE || COLOR_HILIGHT
+//   0's everywhere else
+
+void wxToolBarMSW::CreateMask(WXHDC hdc, int xoffset, int yoffset, int dx, int dy)
+{
+    HDC globalDC = ::GetDC(NULL);
+    HDC hdcGlyphs = CreateCompatibleDC((HDC) globalDC);
+    ReleaseDC(NULL, (HDC) globalDC);
+
+    // krj - create a new bitmap and copy the image from hdc.
+    //HBITMAP bitmapOld = SelectObject(hdcGlyphs, hBitmap);
+    HBITMAP hBitmap = CreateCompatibleBitmap((HDC) hdc, dx, dy);
+    HBITMAP bitmapOld = SelectObject(hdcGlyphs, hBitmap);
+    BitBlt(hdcGlyphs, 0,0, dx, dy, (HDC) hdc, 0, 0, SRCCOPY);
+
+    // initalize whole area with 1's
+    PatBlt((HDC) m_hdcMono, 0, 0, dx, dy, WHITENESS);
+
+    // create mask based on color bitmap
+    // convert this to 1's
+    SetBkColor(hdcGlyphs, m_rgbFace);
+    BitBlt((HDC) m_hdcMono, xoffset, yoffset, (int)GetDefaultWidth(), (int)GetDefaultHeight(),
+        hdcGlyphs, 0, 0, SRCCOPY);
+    // convert this to 1's
+    SetBkColor(hdcGlyphs, m_rgbHilight);
+    // OR in the new 1's
+    BitBlt((HDC) m_hdcMono, xoffset, yoffset, (int)GetDefaultWidth(), (int)GetDefaultHeight(),
+        hdcGlyphs, 0, 0, SRCPAINT);
+
+    SelectObject(hdcGlyphs, bitmapOld);
+    DeleteObject(hBitmap);
+    DeleteDC(hdcGlyphs);
+}
+
+void wxToolBarMSW::DrawBlankButton(WXHDC hdc, int x, int y, int dx, int dy, int state)
+{
+    // face color
+    PatB(hdc, x, y, dx, dy, m_rgbFace);
+
+    if (state & wxTBSTATE_PRESSED) {
+	PatB(hdc, x + 1, y, dx - 2, 1, m_rgbFrame);
+	PatB(hdc, x + 1, y + dy - 1, dx - 2, 1, m_rgbFrame);
+	PatB(hdc, x, y + 1, 1, dy - 2, m_rgbFrame);
+	PatB(hdc, x + dx - 1, y +1, 1, dy - 2, m_rgbFrame);
+	PatB(hdc, x + 1, y + 1, 1, dy-2, m_rgbShadow);
+	PatB(hdc, x + 1, y + 1, dx-2, 1, m_rgbShadow);
+    }
+    else {
+	PatB(hdc, x + 1, y, dx - 2, 1, m_rgbFrame);
+	PatB(hdc, x + 1, y + dy - 1, dx - 2, 1, m_rgbFrame);
+	PatB(hdc, x, y + 1, 1, dy - 2, m_rgbFrame);
+	PatB(hdc, x + dx - 1, y + 1, 1, dy - 2, m_rgbFrame);
+	dx -= 2;
+	dy -= 2;
+	PatB(hdc, x + 1, y + 1, 1, dy - 1, m_rgbHilight);
+	PatB(hdc, x + 1, y + 1, dx - 1, 1, m_rgbHilight);
+	PatB(hdc, x + dx, y + 1, 1, dy, m_rgbShadow);
+	PatB(hdc, x + 1, y + dy, dx, 1,   m_rgbShadow);
+	PatB(hdc, x + dx - 1, y + 2, 1, dy - 2, m_rgbShadow);
+	PatB(hdc, x + 2, y + dy - 1, dx - 2, 1,   m_rgbShadow);
+    }
+}
+
+void wxToolBarMSW::DrawButton(WXHDC hdc, int x, int y, int dx, int dy, wxToolBarTool *tool, int state)
+{
+    int yOffset;
+    HBRUSH hbrOld, hbr;
+    BOOL bMaskCreated = FALSE;
+    int xButton = 0;		// assume button is down
+    int dxFace, dyFace;
+    int xCenterOffset;
+
+    dxFace = dx;
+    dyFace = dy;
+
+//    HBITMAP hBitmap = (HBITMAP) tool->m_bitmap1.GetHBITMAP();
+    HDC globalDC = ::GetDC(NULL);
+    HDC hdcGlyphs = CreateCompatibleDC(globalDC);
+    ReleaseDC(NULL, globalDC);
+
+    // get the proper button look - up or down.
+    if (!(state & (wxTBSTATE_PRESSED | wxTBSTATE_CHECKED))) {
+	xButton = dx;	// use 'up' version of button
+	dxFace -= 2;	
+	dyFace -= 2;	// extents to ignore button highlight
+    }
+
+    DrawBlankButton(hdc, x, y, dx, dy, state);
+
+
+    // move coordinates inside border and away from upper left highlight.
+    // the extents change accordingly.
+    x += 2;
+    y += 2;
+    dxFace -= 3;		
+    dyFace -= 3;
+
+    // Using bitmap2 can cause problems (don't know why!)
+#if !defined(__WIN32__) && !defined(__WIN386__)
+    HBITMAP bitmapOld;
+    if (tool->m_bitmap2.Ok())
+      bitmapOld = SelectObject(hdcGlyphs, (HBITMAP) tool->m_bitmap2.GetHBITMAP());
+    else
+      bitmapOld = SelectObject(hdcGlyphs, (HBITMAP) tool->m_bitmap1.GetHBITMAP());
+#else
+    HBITMAP bitmapOld = SelectObject(hdcGlyphs, (HBITMAP) tool->m_bitmap1.GetHBITMAP());
+#endif    
+
+    // calculate offset of face from (x,y).  y is always from the top,
+    // so the offset is easy.  x needs to be centered in face.
+    yOffset = 1;
+    xCenterOffset = (dxFace - (int)GetDefaultWidth())/2;
+    if (state & (wxTBSTATE_PRESSED | wxTBSTATE_CHECKED))
+    {
+	// pressed state moves down and to the right
+	// (x moves automatically as face size grows)
+        yOffset++;
+    }
+
+    // now put on the face
+    if (state & wxTBSTATE_ENABLED) {
+        // regular version
+        BitBlt((HDC) hdc, x+xCenterOffset, y + yOffset, (int)GetDefaultWidth(), (int)GetDefaultHeight(),
+            hdcGlyphs, 0, 0, SRCCOPY);
+    } else {
+        // disabled version (or indeterminate)
+	bMaskCreated = TRUE;
+        CreateMask((WXHDC) hdcGlyphs, xCenterOffset, yOffset, dxFace, dyFace);
+//        CreateMask(hBitmap, xCenterOffset, yOffset, dxFace, dyFace);
+
+	SetTextColor((HDC) hdc, 0L);	 // 0's in mono -> 0 (for ROP)
+	SetBkColor((HDC) hdc, 0x00FFFFFF); // 1's in mono -> 1
+
+	// draw glyph's white understrike
+	if (!(state & wxTBSTATE_INDETERMINATE)) {
+	    hbr = CreateSolidBrush(m_rgbHilight);
+	    if (hbr) {
+	        hbrOld = SelectObject((HDC) hdc, hbr);
+	        if (hbrOld) {
+	            // draw hilight color where we have 0's in the mask
+                    BitBlt((HDC) hdc, x + 1, y + 1, dxFace, dyFace, (HDC) m_hdcMono, 0, 0, 0x00B8074A);
+	            SelectObject((HDC) hdc, hbrOld);
+	        }
+	        DeleteObject(hbr);
+	    }
+	}
+
+	// gray out glyph
+	hbr = CreateSolidBrush(m_rgbShadow);
+	if (hbr) {
+	    hbrOld = SelectObject((HDC) hdc, hbr);
+	    if (hbrOld) {
+	        // draw the shadow color where we have 0's in the mask
+                BitBlt((HDC) hdc, x, y, dxFace, dyFace, (HDC) m_hdcMono, 0, 0, 0x00B8074A);
+	        SelectObject((HDC) hdc, hbrOld);
+	    }
+	    DeleteObject(hbr);
+	}
+
+	if (state & wxTBSTATE_CHECKED) {
+	    BitBlt((HDC) m_hdcMono, 1, 1, dxFace - 1, dyFace - 1, (HDC) m_hdcMono, 0, 0, SRCAND);
+	}
+    }
+
+    if (state & (wxTBSTATE_CHECKED | wxTBSTATE_INDETERMINATE)) {
+
+        hbrOld = SelectObject((HDC) hdc, (HBRUSH) m_hbrDither);
+	if (hbrOld) {
+
+	    if (!bMaskCreated)
+                CreateMask((WXHDC) hdcGlyphs, xCenterOffset, yOffset, dxFace, dyFace);
+//                CreateMask(hBitmap, xCenterOffset, yOffset, dxFace, dyFace);
+
+	    SetTextColor((HDC) hdc, 0L);		// 0 -> 0
+	    SetBkColor((HDC) hdc, 0x00FFFFFF);	// 1 -> 1
+
+	    // only draw the dither brush where the mask is 1's
+            BitBlt((HDC) hdc, x, y, dxFace, dyFace, (HDC) m_hdcMono, 0, 0, 0x00E20746);
+
+	    SelectObject((HDC) hdc, hbrOld);
+	}
+    }
+    SelectObject(hdcGlyphs, bitmapOld);
+    DeleteDC(hdcGlyphs);
+}
+
+void wxToolBarMSW::GetSysColors(void)
+{
+	static COLORREF rgbSaveFace    = 0xffffffffL,
+	                rgbSaveShadow  = 0xffffffffL,
+	                rgbSaveHilight = 0xffffffffL,
+	                rgbSaveFrame   = 0xffffffffL;
+
+    // For now, override these because the colour replacement isn't working,
+    // and we get inconsistent colours. Assume all buttons are grey for the moment.
+
+//	m_rgbFace    = GetSysColor(COLOR_BTNFACE);
+        m_rgbFace = RGB(192,192,192);
+//	m_rgbShadow  = GetSysColor(COLOR_BTNSHADOW);
+        m_rgbShadow = RGB(128,128,128);
+//	m_rgbHilight = GetSysColor(COLOR_BTNHIGHLIGHT);
+	m_rgbHilight = RGB(255, 255, 255);
+
+	m_rgbFrame   = GetSysColor(COLOR_WINDOWFRAME);
+
+	if (rgbSaveFace!=m_rgbFace || rgbSaveShadow!=m_rgbShadow
+		|| rgbSaveHilight!=m_rgbHilight || rgbSaveFrame!=m_rgbFrame)
+	{
+		rgbSaveFace    = m_rgbFace;
+		rgbSaveShadow  = m_rgbShadow;
+		rgbSaveHilight = m_rgbHilight;
+        rgbSaveFrame   = m_rgbFrame;
+
+		// Update the brush for pushed-in buttons
+		CreateDitherBrush();
+	}
+}
+
+WXHBITMAP wxToolBarMSW::CreateDitherBitmap()
+{
+    BITMAPINFO* pbmi;
+    HBITMAP hbm;
+    HDC hdc;
+    int i;
+    long patGray[8];
+    DWORD rgb;
+
+    pbmi = (BITMAPINFO *)malloc(sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD));
+    memset(pbmi, 0, (sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD)));
+
+    pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    pbmi->bmiHeader.biWidth = 8;
+    pbmi->bmiHeader.biHeight = 8;
+    pbmi->bmiHeader.biPlanes = 1;
+    pbmi->bmiHeader.biBitCount = 1;
+    pbmi->bmiHeader.biCompression = BI_RGB;
+
+//    rgb = GetSysColor(COLOR_BTNFACE);
+    rgb = RGB(192,192,192);
+
+    pbmi->bmiColors[0].rgbBlue  = GetBValue(rgb);
+    pbmi->bmiColors[0].rgbGreen = GetGValue(rgb);
+    pbmi->bmiColors[0].rgbRed   = GetRValue(rgb);
+    pbmi->bmiColors[0].rgbReserved = 0;
+
+//    rgb = GetSysColor(COLOR_BTNHIGHLIGHT);
+    rgb = RGB(255, 255, 255);
+
+    pbmi->bmiColors[1].rgbBlue  = GetBValue(rgb);
+    pbmi->bmiColors[1].rgbGreen = GetGValue(rgb);
+    pbmi->bmiColors[1].rgbRed   = GetRValue(rgb);
+    pbmi->bmiColors[1].rgbReserved = 0;
+
+    /* initialize the brushes */
+
+    for (i = 0; i < 8; i++)
+       if (i & 1)
+           patGray[i] = 0xAAAA5555L;   //  0x11114444L; // lighter gray
+       else
+           patGray[i] = 0x5555AAAAL;   //  0x11114444L; // lighter gray
+
+    hdc = ::GetDC(NULL);
+
+    hbm = CreateDIBitmap(hdc, &pbmi->bmiHeader, CBM_INIT, patGray, pbmi, DIB_RGB_COLORS);
+
+    ReleaseDC(NULL, hdc);
+    free(pbmi);
+
+    return (WXHBITMAP)hbm;
+}
+
+bool wxToolBarMSW::CreateDitherBrush(void)
+{
+	HBITMAP hbmGray;
+	HBRUSH hbrSave;
+	if (m_hbrDither)
+	  return TRUE;
+	hbmGray = (HBITMAP) CreateDitherBitmap();
+
+	if (hbmGray)
+	{
+		hbrSave = (HBRUSH) m_hbrDither;
+		m_hbrDither = (WXHBRUSH) CreatePatternBrush(hbmGray);
+		DeleteObject(hbmGray);
+		if (m_hbrDither)
+		{
+			if (hbrSave)
+			{
+				DeleteObject(hbrSave);
+			}
+			return TRUE;
+		}
+		else
+		{
+			m_hbrDither = (WXHBRUSH) hbrSave;
+		}
+	}
+
+	return FALSE;
+}
+
+bool wxToolBarMSW::FreeDitherBrush(void)
+{
+    if (m_hbrDither)
+      DeleteObject((HBRUSH) m_hbrDither);
+    m_hbrDither = 0;
+    return TRUE;
+}
+
+typedef struct tagCOLORMAP2
+{
+    COLORREF bgrfrom;
+    COLORREF bgrto;
+    COLORREF sysColor;
+} COLORMAP2;
+
+// these are the default colors used to map the dib colors
+// to the current system colors
+
+#define BGR_BUTTONTEXT      (RGB(000,000,000))  // black
+#define BGR_BUTTONSHADOW    (RGB(128,128,128))  // dark grey
+#define BGR_BUTTONFACE      (RGB(192,192,192))  // bright grey
+#define BGR_BUTTONHILIGHT   (RGB(255,255,255))  // white
+#define BGR_BACKGROUNDSEL   (RGB(255,000,000))  // blue
+#define BGR_BACKGROUND      (RGB(255,000,255))  // magenta
+#define FlipColor(rgb)      (RGB(GetBValue(rgb), GetGValue(rgb), GetRValue(rgb)))
+
+WXHBITMAP wxToolBarMSW::CreateMappedBitmap(WXHINSTANCE WXUNUSED(hInstance), void *info)
+{
+  LPBITMAPINFOHEADER lpBitmapInfo = (LPBITMAPINFOHEADER)info;
+  HDC			hdc, hdcMem = NULL;
+
+  DWORD FAR		*p;
+  LPSTR 		lpBits;
+  HBITMAP		hbm = NULL, hbmOld;
+  int numcolors, i;
+  int wid, hgt;
+  static COLORMAP2 ColorMap[] = {
+    {BGR_BUTTONTEXT,    BGR_BUTTONTEXT,    COLOR_BTNTEXT},     // black
+    {BGR_BUTTONSHADOW,  BGR_BUTTONSHADOW,  COLOR_BTNSHADOW},   // dark grey
+    {BGR_BUTTONFACE,    BGR_BUTTONFACE,    COLOR_BTNFACE},     // bright grey
+    {BGR_BUTTONHILIGHT, BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
+    {BGR_BACKGROUNDSEL, BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT},   // blue
+    {BGR_BACKGROUND,    BGR_BACKGROUND,    COLOR_WINDOW}       // magenta
+  };
+
+  #define NUM_MAPS (sizeof(ColorMap)/sizeof(COLORMAP2))
+
+  if (!lpBitmapInfo)
+  	return 0;
+
+  //
+  // So what are the new colors anyway ?
+  //
+  for (i=0; i < (int) NUM_MAPS; i++) {
+     ColorMap[i].bgrto = (long unsigned int) FlipColor(GetSysColor((int)ColorMap[i].sysColor));
+  }
+
+  p = (DWORD FAR *)(((LPSTR)lpBitmapInfo) + lpBitmapInfo->biSize);
+
+  /* Replace button-face and button-shadow colors with the current values
+   */
+  numcolors = 16;
+
+  while (numcolors-- > 0) {
+      for (i = 0; i < (int) NUM_MAPS; i++) {
+          if (*p == ColorMap[i].bgrfrom) {
+          *p = ColorMap[i].bgrto;
+	      break;
+	  }
+      }
+      p++;
+  }
+
+  /* First skip over the header structure */
+  lpBits = (LPSTR)(lpBitmapInfo + 1);
+
+  /* Skip the color table entries, if any */
+  lpBits += (1 << (lpBitmapInfo->biBitCount)) * sizeof(RGBQUAD);
+
+  /* Create a color bitmap compatible with the display device */
+  i = wid = (int)lpBitmapInfo->biWidth;
+  hgt = (int)lpBitmapInfo->biHeight;
+  hdc = ::GetDC(NULL);
+
+  hdcMem = CreateCompatibleDC(hdc);
+  if (hdcMem) {
+//    hbm = CreateDiscardableBitmap(hdc, i, hgt);
+    hbm = CreateCompatibleBitmap(hdc, i, hgt);
+    if (hbm) {
+        hbmOld = SelectObject(hdcMem, hbm);
+
+        // set the main image
+        StretchDIBits(hdcMem, 0, 0, wid, hgt, 0, 0, wid, hgt, lpBits,
+                   (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS, SRCCOPY);
+
+        SelectObject(hdcMem, hbmOld);
+    }
+
+    DeleteObject(hdcMem);
+  }
+
+  ReleaseDC(NULL, hdc);
+
+  return (WXHBITMAP) hbm;
+}
+
+WXHBITMAP wxToolBarMSW::CreateMappedBitmap(WXHINSTANCE hInstance, WXHBITMAP hBitmap)
+{
+  HANDLE hDIB = BitmapToDIB((HBITMAP) hBitmap, 0);
+  if (hDIB)
+  {
+#ifdef __WINDOWS_386__
+    LPBITMAPINFOHEADER lpbmInfoHdr = (LPBITMAPINFOHEADER)MK_FP32(GlobalLock(hDIB));
+#else
+    LPBITMAPINFOHEADER lpbmInfoHdr = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
+#endif
+    HBITMAP newBitmap = (HBITMAP) CreateMappedBitmap((WXHINSTANCE) wxGetInstance(), lpbmInfoHdr);
+    GlobalUnlock(hDIB);
+    GlobalFree(hDIB);
+    return (WXHBITMAP) newBitmap;
+  }
+  return 0;
+}
+
+#endif
diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp
new file mode 100644
index 0000000000..1bf2931792
--- /dev/null
+++ b/src/msw/textctrl.cpp
@@ -0,0 +1,1097 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        textctrl.cpp
+// Purpose:     wxTextCtrl
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "textctrl.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/textctrl.h"
+#include "wx/settings.h"
+#endif
+
+#if USE_CLIPBOARD
+#include "wx/app.h"
+#include "wx/clipbrd.h"
+#endif
+
+#include "wx/msw/private.h"
+
+#include <windows.h>
+#include <stdlib.h>
+#include "fstream.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#if defined(__BORLANDC__) && !defined(__WIN32__)
+#include <alloc.h>
+#else
+#ifndef __GNUWIN32__
+#include <malloc.h>
+#endif
+#define farmalloc malloc
+#define farfree free
+#endif
+#include <windowsx.h>
+
+#include <string.h>
+
+#if defined(__WIN95__) && !defined(__GNUWIN32__)
+#include <richedit.h>
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
+
+BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
+	EVT_CHAR(wxTextCtrl::OnChar)
+	EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
+	EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
+END_EVENT_TABLE()
+
+#endif
+
+// Text item
+wxTextCtrl::wxTextCtrl(void)
+#ifndef NO_TEXT_WINDOW_STREAM
+ :streambuf()
+#endif
+{
+  fileName = "";
+  m_isRich = FALSE;
+}
+
+bool wxTextCtrl::Create(wxWindow *parent, const wxWindowID id,
+		   const wxString& value,
+           const wxPoint& pos,
+           const wxSize& size, const long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+  fileName = "";
+  SetName(name);
+  SetValidator(validator);
+  if (parent) parent->AddChild(this);
+
+  m_windowStyle = style;
+
+  // Should this be taken from the system colours?
+//  SetBackgroundColour(wxColour(255, 255, 255));
+
+  SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
+
+  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+#ifdef __WIN32__
+  WXHGLOBAL m_globalHandle = 0;
+#else
+  // Obscure method from the MS Developer's Network Disk for
+  // using global memory instead of the local heap, which
+  // runs out far too soon. Solves the problem with
+  // failing to appear.
+
+  // Doesn't seem to work for Win95, so removing.
+  m_globalHandle=0;
+//  if ((wxGetOsVersion() != wxWINDOWS_NT) && (wxGetOsVersion() != wxWIN95))
+//    m_globalHandle = (WXHGLOBAL) GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,
+//                         256L);
+#endif
+  long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
+  if (m_windowStyle & wxTE_MULTILINE)
+	msStyle |= ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL ; // WS_BORDER
+  else
+    msStyle |= ES_AUTOHSCROLL ;
+
+  if (m_windowStyle & wxTE_READONLY)
+    msStyle |= ES_READONLY;
+
+  if (m_windowStyle & wxHSCROLL)
+    msStyle |= (WS_HSCROLL | ES_AUTOHSCROLL) ;
+  if (m_windowStyle & wxTE_PASSWORD) // hidden input
+    msStyle |= ES_PASSWORD;
+
+  char *windowClass = "EDIT";
+#if defined(__WIN95__)
+  if ( m_windowStyle & wxTE_MULTILINE )
+#else
+  if ( FALSE )
+#endif
+  {
+      msStyle |= ES_AUTOVSCROLL;
+	  m_isRich = TRUE;
+	  windowClass = "RichEdit" ;
+  }
+  else
+	  m_isRich = FALSE;
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+  // If we're in Win95, and we want a simple 2D border,
+  // then make it an EDIT control instead.
+#if defined(__WIN95__)
+  if (m_windowStyle & wxSIMPLE_BORDER)
+  {
+    windowClass = "EDIT";
+	m_isRich = FALSE;
+  }
+#endif
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+    msStyle |= WS_BORDER;
+
+  HWND edit = CreateWindowEx(exStyle, windowClass, NULL,
+                        msStyle,
+                        0, 0, 0, 0, (HWND) ((wxWindow*)parent)->GetHWND(), (HMENU)m_windowId,
+                        m_globalHandle ? (HANDLE) m_globalHandle : wxGetInstance(), NULL);
+
+#if CTL3D
+  if ( want3D )
+  {
+    Ctl3dSubclassCtl(edit);
+	m_useCtl3D = TRUE;
+  }
+#endif
+
+  m_hWnd = (WXHWND)edit;
+
+#if defined(__WIN95__)
+  if (m_isRich)
+  {
+	// Have to enable events
+	::SendMessage(edit, EM_SETEVENTMASK, 0, ENM_CHANGE | ENM_DROPFILES | ENM_SELCHANGE | ENM_UPDATE);
+  }
+#endif
+
+  SubclassWin(GetHWND());
+
+  if ( parent->GetFont() && parent->GetFont()->Ok() )
+  {
+	SetFont(* parent->GetFont());
+  }
+  else
+  {
+  	SetFont(wxSystemSettings::GetSystemFont(wxSYS_SYSTEM_FONT));
+  }
+
+  SetSize(x, y, width, height);
+
+  // Causes a crash for Symantec C++ and WIN32 for some reason
+#if !(defined(__SC__) && defined(__WIN32__))
+  if (value != "")
+    SetWindowText(edit, (const char *)value);
+#endif
+
+  return TRUE;
+}
+
+// Make sure the window style (etc.) reflects the HWND style (roughly)
+void wxTextCtrl::AdoptAttributesFromHWND(void)
+{
+	wxWindow::AdoptAttributesFromHWND();
+
+	HWND hWnd = (HWND) GetHWND();
+	long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
+
+    char buf[256];
+
+#ifndef __WIN32__
+	GetClassName((HWND) hWnd, buf, 256);
+#else
+#ifdef UNICODE
+	GetClassNameW((HWND) hWnd, buf, 256);
+#else
+	GetClassNameA((HWND) hWnd, buf, 256);
+#endif
+#endif
+
+	wxString str(buf);
+	str.UpperCase();
+
+	if (str == "EDIT")
+		m_isRich = FALSE;
+	else
+		m_isRich = TRUE;
+
+	if (style & ES_MULTILINE)
+		m_windowStyle |= wxTE_MULTILINE;
+	if (style & ES_PASSWORD)
+		m_windowStyle |= wxTE_PASSWORD;
+	if (style & ES_READONLY)
+		m_windowStyle |= wxTE_READONLY;
+	if (style & ES_WANTRETURN)
+		m_windowStyle |= wxTE_PROCESS_ENTER;
+}
+
+void wxTextCtrl::SetupColours(void)
+{
+  SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
+  SetForegroundColour(GetParent()->GetDefaultForegroundColour());
+}
+
+wxString wxTextCtrl::GetValue(void) const
+{
+    int length = GetWindowTextLength((HWND) GetHWND());
+    char *s = new char[length+1];
+    GetWindowText((HWND) GetHWND(), s, length+1);
+    wxString str(s);
+    delete[] s;
+	return str;
+}
+
+void wxTextCtrl::SetValue(const wxString& value)
+{
+  // If newlines are denoted by just 10, must stick 13 in front.
+  int singletons = 0;
+  int len = value.Length();
+  int i;
+  for (i = 0; i < len; i ++)
+  {
+    if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
+      singletons ++;
+  }
+  if (singletons > 0)
+  {
+    char *tmp = new char[len + singletons + 1];
+    int j = 0;
+    for (i = 0; i < len; i ++)
+    {
+      if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
+      {
+        tmp[j] = 13;
+        j ++;
+      }
+      tmp[j] = value[i];
+      j ++;
+    }
+    tmp[j] = 0;
+    SetWindowText((HWND) GetHWND(), tmp);
+    delete[] tmp;
+  }
+  else
+    SetWindowText((HWND) GetHWND(), (const char *)value);
+}
+
+void wxTextCtrl::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+  int x1 = x;
+  int y1 = y;
+  int w1 = width;
+  int h1 = height;
+
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    x1 = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    y1 = currentY;
+
+  int cx; // button font dimensions
+  int cy;
+
+  wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
+
+  float control_width, control_height, control_x, control_y;
+
+  // If we're prepared to use the existing size, then...
+  if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
+  {
+    GetSize(&w1, &h1);
+  }
+
+  // Deal with default size (using -1 values)
+  if (w1<=0)
+    w1 = DEFAULT_ITEM_WIDTH;
+
+  control_x = (float)x1;
+  control_y = (float)y1;
+  control_width = (float)w1;
+  control_height = (float)h1;
+
+  // Calculations may have made text size too small
+  if (control_height <= 0)
+    control_height = (float)(int)(cy*EDIT_CONTROL_FACTOR) ;
+
+  if (control_width <= 0)
+    control_width = (float)DEFAULT_ITEM_WIDTH;
+
+  MoveWindow((HWND) GetHWND(), (int)control_x, (int)control_y,
+                              (int)control_width, (int)control_height, TRUE);
+/*
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+*/
+}
+
+// Clipboard operations
+void wxTextCtrl::Copy(void)
+{
+  HWND hWnd = (HWND) GetHWND();
+  SendMessage(hWnd, WM_COPY, 0, 0L);
+}
+
+void wxTextCtrl::Cut(void)
+{
+  HWND hWnd = (HWND) GetHWND();
+  SendMessage(hWnd, WM_CUT, 0, 0L);
+}
+
+void wxTextCtrl::Paste(void)
+{
+  HWND hWnd = (HWND) GetHWND();
+  SendMessage(hWnd, WM_PASTE, 0, 0L);
+}
+
+void wxTextCtrl::SetEditable(const bool editable)
+{
+  HWND hWnd = (HWND) GetHWND();
+  SendMessage(hWnd, EM_SETREADONLY, (WPARAM)!editable, (LPARAM)0L);
+}
+
+void wxTextCtrl::SetInsertionPoint(const long pos)
+{
+  HWND hWnd = (HWND) GetHWND();
+#ifdef __WIN32__
+#if defined(__WIN95__)
+  if ( m_isRich)
+  {
+    CHARRANGE range;
+    range.cpMin = pos;
+    range.cpMax = pos;
+    SendMessage(hWnd, EM_EXSETSEL, 0, (LPARAM) &range);
+    SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
+  }
+  else
+#endif
+  {
+    SendMessage(hWnd, EM_SETSEL, pos, pos);
+    SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
+  }
+#else
+  SendMessage(hWnd, EM_SETSEL, 0, MAKELPARAM(pos, pos));
+#endif
+  char *nothing = "";
+  SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)nothing);
+}
+
+void wxTextCtrl::SetInsertionPointEnd(void)
+{
+  long pos = GetLastPosition();
+  SetInsertionPoint(pos);
+}
+
+long wxTextCtrl::GetInsertionPoint(void) const
+{
+#if defined(__WIN95__)
+  if (m_isRich)
+  {
+    CHARRANGE range;
+    range.cpMin = 0;
+    range.cpMax = 0;
+    SendMessage((HWND) GetHWND(), EM_EXGETSEL, 0, (LPARAM) &range);
+    return range.cpMin;
+  }
+#endif
+
+  DWORD Pos=(DWORD)SendMessage((HWND) GetHWND(), EM_GETSEL, 0, 0L);
+  return Pos&0xFFFF;
+}
+
+long wxTextCtrl::GetLastPosition(void) const
+{
+    HWND hWnd = (HWND) GetHWND();
+
+    // Will always return a number > 0 (according to docs)
+    int noLines = (int)SendMessage(hWnd, EM_GETLINECOUNT, (WPARAM)0, (LPARAM)0L);
+
+    // This gets the char index for the _beginning_ of the last line
+    int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)(noLines-1), (LPARAM)0L);
+    
+    // Get number of characters in the last line. We'll add this to the character
+    // index for the last line, 1st position.
+    int lineLength = (int)SendMessage(hWnd, EM_LINELENGTH, (WPARAM)charIndex, (LPARAM)0L);
+
+    return (long)(charIndex + lineLength);
+}
+
+void wxTextCtrl::Replace(const long from, const long to, const wxString& value)
+{
+    HWND hWnd = (HWND) GetHWND();
+    long fromChar = from;
+    long toChar = to;
+    
+    // Set selection and remove it
+#ifdef __WIN32__
+    SendMessage(hWnd, EM_SETSEL, fromChar, toChar);
+#else
+    SendMessage(hWnd, EM_SETSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar));
+#endif
+    SendMessage(hWnd, WM_CUT, (WPARAM)0, (LPARAM)0);
+
+    // Now replace with 'value', by pasting.
+    wxSetClipboardData(wxCF_TEXT, (wxObject *) (const char *)value, 0, 0);
+
+    // Paste into edit control
+    SendMessage(hWnd, WM_PASTE, (WPARAM)0, (LPARAM)0L);
+}
+
+void wxTextCtrl::Remove(const long from, const long to)
+{
+    HWND hWnd = (HWND) GetHWND();
+    long fromChar = from;
+    long toChar = to;
+    
+    // Cut all selected text
+#ifdef __WIN32__
+    SendMessage(hWnd, EM_SETSEL, fromChar, toChar);
+#else
+    SendMessage(hWnd, EM_SETSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar));
+#endif
+    SendMessage(hWnd, WM_CUT, (WPARAM)0, (LPARAM)0);
+}
+
+void wxTextCtrl::SetSelection(const long from, const long to)
+{
+    HWND hWnd = (HWND) GetHWND();
+    long fromChar = from;
+    long toChar = to;
+    // if from and to are both -1, it means
+    // (in wxWindows) that all text should be selected.
+    // This translates into Windows convention
+    if ((from == -1) && (to == -1))
+    {
+      fromChar = 0;
+      toChar = -1;
+    }
+    
+#ifdef __WIN32__
+    SendMessage(hWnd, EM_SETSEL, (WPARAM)fromChar, (LPARAM)toChar);
+    SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
+#else
+    // WPARAM is 0: selection is scrolled into view
+    SendMessage(hWnd, EM_SETSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar));
+#endif
+}
+
+bool wxTextCtrl::LoadFile(const wxString& file)
+{
+  if (!FileExists(WXSTRINGCAST file))
+    return FALSE;
+
+  fileName = file;
+
+  Clear();
+
+  ifstream input(WXSTRINGCAST file, ios::nocreate | ios::in);
+
+  if (!input.bad())
+  {
+      // Previously a SETSEL/REPLACESEL call-pair were done to insert
+      // line by line into the control. Apart from being very slow this
+      // was limited to 32K of text by the external interface presenting
+      // positions as signed shorts. Now load in one chunk...
+      // Note use of 'farmalloc' as in Borland 3.1 'size_t' is 16-bits...
+
+      struct stat stat_buf;
+      if (stat(file, &stat_buf) < 0)
+        return FALSE;
+//      char *tmp_buffer = (char*)farmalloc(stat_buf.st_size+1);
+      // This may need to be a bigger buffer than the file size suggests,
+      // if it's a UNIX file. Give it an extra 1000 just in case.
+      char *tmp_buffer = (char*)farmalloc((size_t)(stat_buf.st_size+1+1000));
+      long no_lines = 0;
+      long pos = 0;
+      while (!input.eof() && input.peek() != EOF)
+      {
+        input.getline(wxBuffer, 500);
+	int len = strlen(wxBuffer);
+	wxBuffer[len] = 13;
+	wxBuffer[len+1] = 10;
+	wxBuffer[len+2] = 0;
+	strcpy(tmp_buffer+pos, wxBuffer);
+	pos += strlen(wxBuffer);
+	no_lines++;
+      }
+
+//      SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)tmp_buffer);
+      SetWindowText((HWND) GetHWND(), tmp_buffer);
+      SendMessage((HWND) GetHWND(), EM_SETMODIFY, FALSE, 0L);
+      farfree(tmp_buffer);
+
+      return TRUE;
+  }
+  return FALSE;
+}
+
+// If file is null, try saved file name first
+// Returns TRUE if succeeds.
+bool wxTextCtrl::SaveFile(const wxString& file)
+{
+  wxString theFile;
+  if (file == "")
+    theFile = fileName;
+  if (file == "")
+    return FALSE;
+  fileName = theFile;
+
+  ofstream output(WXSTRINGCAST file);
+  if (output.bad())
+	return FALSE;
+
+    // This will only save 64K max
+    unsigned long nbytes = SendMessage((HWND) GetHWND(), WM_GETTEXTLENGTH, 0, 0);
+    char *tmp_buffer = (char*)farmalloc((size_t)(nbytes+1));
+    SendMessage((HWND) GetHWND(), WM_GETTEXT, (WPARAM)(nbytes+1), (LPARAM)tmp_buffer);
+    char *pstr = tmp_buffer;
+
+	// Convert \r\n to just \n
+	while (*pstr)
+	{
+		if (*pstr != '\r')
+			output << *pstr;
+		pstr++;
+	}
+
+    farfree(tmp_buffer);
+    SendMessage((HWND) GetHWND(), EM_SETMODIFY, FALSE, 0L);
+
+    return TRUE;
+}
+
+void wxTextCtrl::WriteText(const wxString& text)
+{
+    // Covert \n to \r\n
+    int len = text.Length();
+    char *newtext = new char[(len*2)+1];
+    int i = 0;
+    int j = 0;
+    while (i < len)
+    {
+      if (text[i] == '\n')
+      {
+        newtext[j] = '\r';
+        j ++;
+      }
+      newtext[j] = text[i];
+      i ++;
+      j ++;
+    }
+    newtext[j] = 0;
+    SendMessage((HWND) GetHWND(), EM_REPLACESEL, 0, (LPARAM)newtext);
+    delete[] newtext;
+}
+
+void wxTextCtrl::Clear(void)
+{
+//    SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)"");
+    SetWindowText((HWND) GetHWND(), "");
+}
+
+bool wxTextCtrl::IsModified(void) const
+{
+    return (SendMessage((HWND) GetHWND(), EM_GETMODIFY, 0, 0) != 0);
+}
+
+// Makes 'unmodified'
+void wxTextCtrl::DiscardEdits(void)
+{
+  SendMessage((HWND) GetHWND(), EM_SETMODIFY, FALSE, 0L);
+}
+
+/*
+ * Some of the following functions are yet to be implemented
+ *
+ */
+ 
+int wxTextCtrl::GetNumberOfLines(void) const
+{
+    return (int)SendMessage((HWND) GetHWND(), EM_GETLINECOUNT, (WPARAM)0, (LPARAM)0);
+}
+
+long wxTextCtrl::XYToPosition(const long x, const long y) const
+{
+    HWND hWnd = (HWND) GetHWND();
+
+    // This gets the char index for the _beginning_ of this line
+    int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)y, (LPARAM)0);
+    return (long)(x + charIndex);
+}
+
+void wxTextCtrl::PositionToXY(const long pos, long *x, long *y) const
+{
+    HWND hWnd = (HWND) GetHWND();
+
+    // This gets the line number containing the character
+    int lineNo = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)pos, (LPARAM)0);
+    // This gets the char index for the _beginning_ of this line
+    int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)lineNo, (LPARAM)0);
+    // The X position must therefore be the different between pos and charIndex
+    *x = (long)(pos - charIndex);
+    *y = (long)lineNo;
+}
+
+void wxTextCtrl::ShowPosition(const long pos)
+{
+    HWND hWnd = (HWND) GetHWND();
+
+    // To scroll to a position, we pass the number of lines and characters
+    // to scroll *by*. This means that we need to:
+    // (1) Find the line position of the current line.
+    // (2) Find the line position of pos.
+    // (3) Scroll by (pos - current).
+    // For now, ignore the horizontal scrolling.
+
+    // Is this where scrolling is relative to - the line containing the caret?
+    // Or is the first visible line??? Try first visible line.
+//    int currentLineLineNo1 = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)-1, (LPARAM)0L);
+
+    int currentLineLineNo = (int)SendMessage(hWnd, EM_GETFIRSTVISIBLELINE, (WPARAM)0, (LPARAM)0L);
+
+    int specifiedLineLineNo = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)pos, (LPARAM)0L);
+    
+    int linesToScroll = specifiedLineLineNo - currentLineLineNo;
+
+/*
+    wxDebugMsg("Caret line: %d; Current visible line: %d; Specified line: %d; lines to scroll: %d\n",
+      currentLineLineNo1, currentLineLineNo, specifiedLineLineNo, linesToScroll);
+*/
+
+    if (linesToScroll != 0)
+      (void)SendMessage(hWnd, EM_LINESCROLL, (WPARAM)0, (LPARAM)MAKELPARAM(linesToScroll, 0));
+}
+
+int wxTextCtrl::GetLineLength(const long lineNo) const
+{
+    long charIndex = XYToPosition(0, lineNo);
+    HWND hWnd = (HWND) GetHWND();
+    int len = (int)SendMessage(hWnd, EM_LINELENGTH, (WPARAM)charIndex, (LPARAM)0);
+    return len;
+}
+
+wxString wxTextCtrl::GetLineText(const long lineNo) const
+{
+    HWND hWnd = (HWND) GetHWND();
+    *(WORD *)wxBuffer = 512;
+    int noChars = (int)SendMessage(hWnd, EM_GETLINE, (WPARAM)lineNo, (LPARAM)wxBuffer);
+    wxBuffer[noChars] = 0;
+	return wxString(wxBuffer);
+}
+
+/*
+ * Text item
+ */
+ 
+void wxTextCtrl::Command(wxCommandEvent & event)
+{
+  SetValue (event.GetString());
+  ProcessCommand (event);
+}
+
+void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
+{
+  // By default, load the first file into the text window.
+  if (event.GetNumberOfFiles() > 0)
+  {
+    LoadFile(event.GetFiles()[0]);
+  }
+}
+
+// The streambuf code was partly taken from chapter 3 by Jerry Schwarz of
+// AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers
+
+//=========================================================================
+// Called then the buffer is full (gcc 2.6.3) 
+// or when "endl" is output (Borland 4.5)
+//=========================================================================
+// Class declaration using multiple inheritance doesn't work properly for
+// Borland. See note in wb_text.h.
+#ifndef NO_TEXT_WINDOW_STREAM
+int wxTextCtrl::overflow(int c)
+{
+  // Make sure there is a holding area
+  if ( allocate()==EOF )
+  {
+    wxError("Streambuf allocation failed","Internal error");
+    return EOF;
+  }
+  
+  // Verify that there are no characters in get area
+  if ( gptr() && gptr() < egptr() )
+  {
+     wxError("Who's trespassing my get area?","Internal error");
+     return EOF;
+  }
+
+  // Reset get area
+  setg(0,0,0);
+
+  // Make sure there is a put area
+  if ( ! pptr() )
+  {
+/* This doesn't seem to be fatal so comment out error message */
+//    wxError("Put area not opened","Internal error");
+    setp( base(), base() );
+  }
+
+  // Determine how many characters have been inserted but no consumed
+  int plen = pptr() - pbase();
+
+  // Now Jerry relies on the fact that the buffer is at least 2 chars
+  // long, but the holding area "may be as small as 1" ???
+  // And we need an additional \0, so let's keep this inefficient but
+  // safe copy.
+
+  // If c!=EOF, it is a character that must also be comsumed
+  int xtra = c==EOF? 0 : 1;
+
+  // Write temporary C-string to wxTextWindow
+  {
+  char *txt = new char[plen+xtra+1];
+  memcpy(txt, pbase(), plen);
+  txt[plen] = (char)c;     // append c
+  txt[plen+xtra] = '\0';   // append '\0' or overwrite c
+    // If the put area already contained \0, output will be truncated there
+  WriteText(txt);
+    delete[] txt;
+  }
+
+  // Reset put area
+  setp(pbase(), epptr());
+
+#if defined(__WATCOMC__)
+  return __NOT_EOF;
+#elif defined(zapeof)     // HP-UX (all cfront based?)
+  return zapeof(c);
+#else
+  return c!=EOF ? c : 0;  // this should make everybody happy
+#endif
+
+/* OLD CODE
+  int len = pptr() - pbase();
+  char *txt = new char[len+1];
+  strncpy(txt, pbase(), len);
+  txt[len] = '\0';
+  (*this) << txt;
+  setp(pbase(), epptr());
+  delete[] txt;
+  return EOF;
+*/
+}
+
+//=========================================================================
+// called then "endl" is output (gcc) or then explicit sync is done (Borland)
+//=========================================================================
+int wxTextCtrl::sync(void)
+{
+  // Verify that there are no characters in get area
+  if ( gptr() && gptr() < egptr() )
+  {
+     wxError("Who's trespassing my get area?","Internal error");
+     return EOF;
+  }
+
+  if ( pptr() && pptr() > pbase() ) return overflow(EOF);
+
+  return 0;
+/* OLD CODE
+  int len = pptr() - pbase();
+  char *txt = new char[len+1];
+  strncpy(txt, pbase(), len);
+  txt[len] = '\0';
+  (*this) << txt;
+  setp(pbase(), epptr());
+  delete[] txt;
+  return 0;
+*/
+}
+
+//=========================================================================
+// Should not be called by a "ostream". Used by a "istream"
+//=========================================================================
+int wxTextCtrl::underflow(void)
+{
+  return EOF;
+}
+#endif
+
+wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
+{
+  WriteText(s);
+  return *this;
+}
+
+wxTextCtrl& wxTextCtrl::operator<<(const float f)
+{
+  static char buf[100];
+  sprintf(buf, "%.2f", f);
+  WriteText(buf);
+  return *this;
+}
+
+wxTextCtrl& wxTextCtrl::operator<<(const double d)
+{
+  static char buf[100];
+  sprintf(buf, "%.2f", d);
+  WriteText(buf);
+  return *this;
+}
+
+wxTextCtrl& wxTextCtrl::operator<<(const int i)
+{
+  static char buf[100];
+  sprintf(buf, "%i", i);
+  WriteText(buf);
+  return *this;
+}
+
+wxTextCtrl& wxTextCtrl::operator<<(const long i)
+{
+  static char buf[100];
+  sprintf(buf, "%ld", i);
+  WriteText(buf);
+  return *this;
+}
+
+wxTextCtrl& wxTextCtrl::operator<<(const char c)
+{
+  char buf[2];
+
+  buf[0] = c;
+  buf[1] = 0;
+  WriteText(buf);
+  return *this;
+}
+
+
+WXHBRUSH wxTextCtrl::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+#if CTL3D
+  if ( m_useCtl3D )
+  {
+    HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
+    return (WXHBRUSH) hbrush;
+  }
+#endif
+
+  if (GetParent()->GetTransparentBackground())
+    SetBkMode((HDC) pDC, TRANSPARENT);
+  else
+    SetBkMode((HDC) pDC, OPAQUE);
+
+  ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+
+  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+
+  // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
+  // has a zero usage count.
+  // NOT NOW - will be cleaned up at end of app.
+//  backgroundBrush->RealizeResource();
+  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
+}
+
+void wxTextCtrl::OnChar(wxKeyEvent& event)
+{
+	if ( (event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER))
+	{
+		wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
+		event.SetEventObject( this );
+		if ( !GetEventHandler()->ProcessEvent(event) )
+			event.Skip();
+	}
+	else
+		event.Skip();
+}
+
+long wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+    switch (nMsg)
+    {
+/*
+      case WM_GETDLGCODE:
+      {
+        if (GetWindowStyleFlag() & wxPROCESS_ENTER)
+          return DLGC_WANTALLKEYS;
+        break;
+      }
+*/
+/*
+      case WM_CHAR: // Always an ASCII character
+      {
+        if (wParam == VK_RETURN)
+        {
+          wxCommandEvent event(wxEVENT_TYPE_TEXT_ENTER_COMMAND);
+          event.commandString = ((wxTextCtrl *)item)->GetValue();
+          event.eventObject = item;
+          item->ProcessCommand(event);
+          return FALSE;
+        }
+        break;
+      }
+*/
+    default:
+        break;
+    }
+
+  return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
+}
+
+void wxTextCtrl::OnEraseBackground(wxEraseEvent& event)
+{
+    if ( m_windowStyle & wxTE_MULTILINE )
+    {
+        // No flicker - only problem is we probably can't change the background
+        Default();
+/*
+        RECT rect;
+        ::GetClientRect((HWND) GetHWND(), &rect);
+
+        HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+        int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
+
+        ::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
+        ::DeleteObject(hBrush);
+        ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
+*/
+    }
+//        wxWindow::OnEraseBackground(event);
+}
+
+bool wxTextCtrl::MSWCommand(const WXUINT param, const WXWORD WXUNUSED(id))
+{
+/*
+  // Debugging
+  wxDebugMsg("Edit control %d: ", (int)id);
+  switch (param)
+  {
+    case EN_SETFOCUS:
+      wxDebugMsg("EN_SETFOCUS\n");
+      break;
+    case EN_KILLFOCUS:
+      wxDebugMsg("EN_KILLFOCUS\n");
+      break;
+    case EN_CHANGE:
+      wxDebugMsg("EN_CHANGE\n");
+      break;
+    case EN_UPDATE:
+      wxDebugMsg("EN_UPDATE\n");
+      break;
+    case EN_ERRSPACE:
+      wxDebugMsg("EN_ERRSPACE\n");
+      break;
+    case EN_MAXTEXT:
+      wxDebugMsg("EN_MAXTEXT\n");
+      break;
+    case EN_HSCROLL:
+      wxDebugMsg("EN_HSCROLL\n");
+      break;
+    case EN_VSCROLL:
+      wxDebugMsg("EN_VSCROLL\n");
+      break;
+    default:
+      wxDebugMsg("Unknown EDIT notification\n");
+      break;
+  }
+*/
+  WXTYPE eventTyp = 0;
+  switch (param)
+  {
+    case EN_SETFOCUS:
+      eventTyp = wxEVENT_TYPE_SET_FOCUS;
+      break;
+    case EN_KILLFOCUS:
+      eventTyp = wxEVENT_TYPE_KILL_FOCUS;
+      break;
+    case EN_UPDATE:
+	  break;
+    case EN_CHANGE:
+      eventTyp = wxEVENT_TYPE_TEXT_COMMAND;
+      break;
+    case EN_ERRSPACE:
+      break;
+    case EN_MAXTEXT:
+      break;
+    case EN_HSCROLL:
+       break;
+    case EN_VSCROLL:
+      break;
+    default:
+      break;
+  }
+  if (eventTyp != 0)
+  {
+    wxCommandEvent event(eventTyp, m_windowId);
+	wxString val(GetValue());
+	if ( !val.IsNull() )
+      event.m_commandString = WXSTRINGCAST val;
+    event.SetEventObject( this );
+    ProcessCommand(event);
+
+    return TRUE;
+  }
+  else
+    return FALSE;
+}
+
+
+// For Rich Edit controls. Do we need it?
+#if 0
+#if defined(__WIN95__)
+bool wxTextCtrl::MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam)
+{
+	wxCommandEvent event(0, m_windowId);
+	int eventType = 0;
+	NMHDR *hdr1 = (NMHDR *) lParam;
+	switch ( hdr1->code )
+	{
+		// Insert case code here
+		default :
+			return wxControl::MSWNotify(wParam, lParam);
+			break;
+	}
+
+	event.SetEventObject( this );
+	event.SetEventType(eventType);
+
+	if ( !ProcessEvent(event) )
+		return FALSE;
+
+  	return TRUE;
+}
+#endif
+#endif
+
diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp
new file mode 100644
index 0000000000..f6b625878f
--- /dev/null
+++ b/src/msw/thread.cpp
@@ -0,0 +1,320 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        thread.cpp
+// Purpose:     wxThread Implementation
+// Author:      Original from Wolfram Gloger/Guilhem Lavaux
+// Modified by:
+// Created:     04/22/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "thread.h"
+#endif
+
+#include "wx/wxprec.h"
+
+#if defined(__BORLANDC__)
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#include <stdio.h>
+
+#include <windows.h>
+#include "wx/module.h"
+#include "wx/thread.h"
+
+enum thread_state {
+  STATE_IDLE = 0,
+  STATE_RUNNING,
+  STATE_CANCELED,
+  STATE_EXITED
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Static variables
+/////////////////////////////////////////////////////////////////////////////
+
+static HANDLE p_mainid;
+wxMutex wxMainMutex; // controls access to all GUI functions
+
+/////////////////////////////////////////////////////////////////////////////
+// Windows implementation
+/////////////////////////////////////////////////////////////////////////////
+
+class wxMutexInternal {
+public:
+  HANDLE p_mutex;
+};
+
+wxMutex::wxMutex(void)
+{
+  p_internal = new wxMutexInternal;
+  p_internal->p_mutex = CreateMutex(NULL, FALSE, NULL);
+  m_locked = 0;
+}
+
+wxMutex::~wxMutex(void)
+{
+  CloseHandle(p_internal->p_mutex);
+}
+
+wxMutexError wxMutex::Lock(void)
+{
+  DWORD ret;
+
+  ret = WaitForSingleObject(p_internal->p_mutex, INFINITE);
+  if (ret == WAIT_ABANDONED)
+    return MUTEX_BUSY;
+
+  m_locked++;
+  return MUTEX_NO_ERROR;
+}
+
+wxMutexError wxMutex::TryLock(void)
+{
+  DWORD ret;
+
+  ret = WaitForSingleObject(p_internal->p_mutex, 0);
+  if (ret == WAIT_TIMEOUT || ret == WAIT_ABANDONED)
+    return MUTEX_BUSY;
+
+  m_locked++;
+  return MUTEX_NO_ERROR;
+}
+
+wxMutexError wxMutex::Unlock(void)
+{
+  BOOL ret;
+
+  if (m_locked > 0)
+    m_locked--;
+
+    // Why does this have 3 args? The redundant ones removed by JACS
+//  ret = ReleaseMutex(p_internal->p_mutex, 1, NULL);
+  ret = ReleaseMutex(p_internal->p_mutex);
+  return MUTEX_NO_ERROR;
+}
+
+class wxConditionInternal {
+public:
+  HANDLE event;
+  int waiters;
+};
+
+wxCondition::wxCondition(void)
+{
+  p_internal = new wxConditionInternal;
+  p_internal->event = CreateEvent(NULL, FALSE, FALSE, NULL);
+  p_internal->waiters = 0;
+}
+
+wxCondition::~wxCondition(void)
+{
+  CloseHandle(p_internal->event);
+}
+
+void wxCondition::Wait(wxMutex& mutex)
+{
+  mutex.Unlock();
+  p_internal->waiters++;
+  WaitForSingleObject(p_internal->event, INFINITE);
+  p_internal->waiters--;
+  mutex.Lock();
+}
+
+bool wxCondition::Wait(wxMutex& mutex, unsigned long sec,
+                       unsigned long nsec)
+{
+  DWORD ret;
+
+  mutex.Unlock();
+  p_internal->waiters++;
+  ret = WaitForSingleObject(p_internal->event, (sec*1000)+(nsec/1000000));
+  p_internal->waiters--;
+  mutex.Lock();
+
+  return (ret != WAIT_TIMEOUT);
+}
+
+void wxCondition::Signal(void)
+{
+  SetEvent(p_internal->event);
+}
+
+void wxCondition::Broadcast(void)
+{
+  int i;
+
+  for (i=0;i<p_internal->waiters;i++)
+    SetEvent(p_internal->event);
+}
+
+class wxThreadInternal {
+public:
+  static DWORD WinThreadStart(LPVOID arg);
+
+  HANDLE thread_id;
+  int state;
+  int prio, defer;
+  DWORD tid;
+};
+
+DWORD wxThreadInternal::WinThreadStart(LPVOID arg)
+{
+  wxThread *ptr = (wxThread *)arg;
+  DWORD ret;
+
+  ret = (DWORD)ptr->Entry();
+  ptr->p_internal->state = STATE_EXITED;
+
+  return ret;
+}
+
+wxThreadError wxThread::Create(void)
+{
+  int win_prio, prio = p_internal->prio;
+
+  p_internal->thread_id = CreateThread(NULL, 0,
+                   (LPTHREAD_START_ROUTINE)wxThreadInternal::WinThreadStart,
+                   (void *)this, CREATE_SUSPENDED, &p_internal->tid);
+  if (p_internal->thread_id == NULL) {
+    printf("Error = %d\n", GetLastError());
+    return THREAD_NO_RESOURCE;
+  }
+
+  if (prio <= 20)
+    win_prio = THREAD_PRIORITY_LOWEST;
+  else if (prio <= 40)
+    win_prio = THREAD_PRIORITY_BELOW_NORMAL;
+  else if (prio <= 60)
+    win_prio = THREAD_PRIORITY_NORMAL;
+  else if (prio <= 80)
+    win_prio = THREAD_PRIORITY_ABOVE_NORMAL;
+  else if (prio <= 100)
+    win_prio = THREAD_PRIORITY_HIGHEST;
+
+  SetThreadPriority(p_internal->thread_id, win_prio);
+
+  ResumeThread(p_internal->thread_id);
+  p_internal->state = STATE_RUNNING;
+ 
+  return THREAD_NO_ERROR;
+}
+
+wxThreadError wxThread::Destroy()
+{
+  if (p_internal->state != STATE_RUNNING)
+    return THREAD_NOT_RUNNING;
+
+  if (p_internal->defer == FALSE)
+    TerminateThread(p_internal->thread_id, 0);
+  else
+    p_internal->state = STATE_CANCELED;
+
+  return THREAD_NO_ERROR;
+}
+
+void wxThread::Exit(void *status)
+{
+  p_internal->state = STATE_EXITED;
+  ExitThread((DWORD)status);
+}
+
+void wxThread::SetPriority(int prio)
+{
+  p_internal->prio = prio;
+}
+
+int wxThread::GetPriority(void)
+{
+  return p_internal->prio;
+}
+
+void wxThread::DeferDestroy(bool on)
+{
+  p_internal->defer = on;
+}
+
+void wxThread::TestDestroy()
+{
+  if (p_internal->state == STATE_CANCELED)
+    ExitThread(0);
+}
+
+void *wxThread::Join()
+{
+  DWORD exit_code;
+
+  if (p_internal->state == STATE_IDLE)
+    return NULL;
+
+  if (wxThread::IsMain())
+    wxMainMutex.Unlock();
+  WaitForSingleObject(p_internal->thread_id, INFINITE);
+  if (wxThread::IsMain())
+    wxMainMutex.Lock();
+
+  GetExitCodeThread(p_internal->thread_id, &exit_code);
+  CloseHandle(p_internal->thread_id);
+
+  p_internal->state = STATE_IDLE;
+
+  return (void *)exit_code;
+}
+
+unsigned long wxThread::GetID()
+{
+  return (unsigned long)p_internal->tid;
+}
+
+bool wxThread::IsMain()
+{
+  return (GetCurrentThread() == p_mainid);
+}
+
+wxThread::wxThread()
+{
+  p_internal = new wxThreadInternal();
+
+  p_internal->defer = FALSE;
+  p_internal->prio  = WXTHREAD_DEFAULT_PRIORITY;
+  p_internal->state = STATE_IDLE;
+}
+
+wxThread::~wxThread()
+{
+  Destroy();
+  Join();
+  delete p_internal;
+}
+
+// The default callback just joins the thread and throws away the result.
+void wxThread::OnExit()
+{
+  Join();
+}
+
+// Automatic initialization
+class wxThreadModule : public wxModule {
+  DECLARE_DYNAMIC_CLASS(wxThreadModule)
+public:
+  virtual bool OnInit(void) {
+    p_mainid = GetCurrentThread();
+    wxMainMutex.Lock();
+    return TRUE;
+  }
+
+  // Global cleanup
+  virtual void OnExit(void) {
+    wxMainMutex.Unlock();
+  }
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
+
diff --git a/src/msw/timer.cpp b/src/msw/timer.cpp
new file mode 100644
index 0000000000..0896d3648d
--- /dev/null
+++ b/src/msw/timer.cpp
@@ -0,0 +1,115 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        timer.cpp
+// Purpose:     wxTimer implementation
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "timer.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#include "wx/list.h"
+#include "wx/app.h"
+#endif
+
+#include "wx/timer.h"
+#include "wx/msw/private.h"
+
+#include <time.h>
+#include <sys/types.h>
+
+#if !defined(__SC__) && !defined(__GNUWIN32__)
+#include <sys/timeb.h>
+#endif
+#ifdef __WIN32__
+#define _EXPORT /**/
+#else
+#define _EXPORT _export
+#endif
+
+#include <windows.h>
+
+wxList wxTimerList(wxKEY_INTEGER);
+UINT WINAPI _EXPORT wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD);
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
+#endif
+
+wxTimer::wxTimer(void)
+{
+  milli = 0 ;
+  lastMilli = -1 ;
+  id = 0;
+}
+
+wxTimer::~wxTimer(void)
+{
+  Stop();
+
+  wxTimerList.DeleteObject(this);
+}
+
+bool wxTimer::Start(int milliseconds,bool mode)
+{
+  oneShot = mode ;
+  if (milliseconds < 0)
+    milliseconds = lastMilli;
+
+  if (milliseconds <= 0)
+    return FALSE;
+
+  lastMilli = milli = milliseconds;
+
+  wxTimerList.DeleteObject(this);
+  TIMERPROC wxTimerProcInst = (TIMERPROC) MakeProcInstance((FARPROC)wxTimerProc,
+                                          wxGetInstance());
+
+  id = SetTimer(NULL, (UINT)(id ? id : 1), (UINT)milliseconds, wxTimerProcInst);
+  if (id > 0)
+  {
+    wxTimerList.Append(id, this);
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+void wxTimer::Stop(void)
+{
+  if (id) {
+    KillTimer(NULL, (UINT)id);
+    wxTimerList.DeleteObject(this); /* @@@@ */
+  }
+  id = 0 ;
+  milli = 0 ;
+}
+
+UINT WINAPI _EXPORT wxTimerProc(HWND WXUNUSED(hwnd), WORD, int idTimer, DWORD)
+{
+  wxNode *node = wxTimerList.Find((long)idTimer);
+  if (node)
+  {
+    wxTimer *timer = (wxTimer *)node->Data();
+    if (timer->id==0)
+      return(0) ; // Avoid to process spurious timer events
+    if (timer->oneShot)
+      timer->Stop() ;
+    timer->Notify();
+  }
+  return 0;
+}
+
diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp
new file mode 100644
index 0000000000..647180b317
--- /dev/null
+++ b/src/msw/treectrl.cpp
@@ -0,0 +1,927 @@
+/*
+ * File:  TreeCtrl.cpp
+ * Purpose: Tree control
+ * Author:  Julian Smart
+ * Created: 1997
+ * Updated: 
+ * Copyright:
+ */
+
+/* static const char sccsid[] = "%W% %G%"; */
+
+#ifdef __GNUG__
+#pragma implementation "treectrl.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx.h"
+#endif
+
+#include "wx/log.h"
+
+#if defined(__WIN95__)
+
+#include "wx/treectrl.h"
+#include "wx/msw/private.h"
+
+#ifndef __GNUWIN32__
+#include <commctrl.h>
+#endif
+
+// Bug in headers, sometimes
+#ifndef TVIS_FOCUSED
+#define TVIS_FOCUSED            0x0001
+#endif
+
+static void wxConvertToMSWTreeItem(wxTreeItem& info, TV_ITEM& tvItem);
+static void wxConvertFromMSWTreeItem(wxTreeItem& info, TV_ITEM& tvItem, HWND getFullInfo = 0);
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
+
+#endif
+
+wxTreeCtrl::wxTreeCtrl(void)
+{
+  m_imageListNormal = NULL;
+  m_imageListState = NULL;
+}
+
+bool wxTreeCtrl::Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size,
+            const long style, const wxValidator& validator, const wxString& name)
+{
+  wxSystemSettings settings;
+  SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW));
+  SetForegroundColour(parent->GetDefaultForegroundColour());
+
+  SetName(name);
+  SetValidator(validator);
+
+  m_imageListNormal = NULL;
+  m_imageListState = NULL;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  m_windowStyle = style;
+
+//  SetFont(wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL));
+
+  SetParent(parent);
+
+  if (width <= 0)
+    width = 100;
+  if (height <= 0)
+    height = 30;
+  if (x < 0)
+    x = 0;
+  if (y < 0)
+    y = 0;
+
+  m_windowId = (id == -1) ? NewControlId() : id;
+
+  DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_LINESATROOT;
+  
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+    wstyle |= WS_BORDER;
+
+  if ( m_windowStyle & wxTR_HAS_BUTTONS )
+  wstyle |= TVS_HASBUTTONS;
+
+  if ( m_windowStyle & wxTR_EDIT_LABELS )
+  wstyle |= TVS_EDITLABELS;
+
+  // Create the toolbar control.
+  HWND hWndTreeControl = CreateWindowEx(exStyle,
+    WC_TREEVIEW,
+    "",
+    wstyle,
+    x, y, width, height,
+    (HWND) parent->GetHWND(),
+    (HMENU)m_windowId,
+    wxGetInstance(),
+    NULL );
+
+  m_hWnd = (WXHWND) hWndTreeControl;
+  if (parent) parent->AddChild(this);
+  
+  SubclassWin((WXHWND) m_hWnd);
+
+  return TRUE;
+}
+
+wxTreeCtrl::~wxTreeCtrl(void)
+{
+  m_textCtrl.SetHWND((WXHWND) NULL);
+}
+
+// Attributes
+int wxTreeCtrl::GetCount(void) const
+{
+  return (int) TreeView_GetCount((HWND) GetHWND());
+}
+
+int wxTreeCtrl::GetIndent(void) const
+{
+  return (int) TreeView_GetIndent((HWND) GetHWND());
+}
+
+void wxTreeCtrl::SetIndent(int indent)
+{
+  TreeView_SetIndent((HWND) GetHWND(), indent);
+}
+
+wxImageList *wxTreeCtrl::GetImageList(const int which) const
+{
+  if ( which == wxIMAGE_LIST_NORMAL )
+    {
+    return m_imageListNormal;
+  }
+  else if ( which == wxIMAGE_LIST_STATE )
+    {
+    return m_imageListState;
+  }
+  return NULL;
+}
+
+void wxTreeCtrl::SetImageList(wxImageList *imageList, const int which)
+{
+  int flags = 0;
+  if ( which == wxIMAGE_LIST_NORMAL )
+    {
+    flags = TVSIL_NORMAL;
+    m_imageListNormal = imageList;
+  }
+  else if ( which == wxIMAGE_LIST_STATE )
+    {
+    flags = TVSIL_STATE;
+    m_imageListState = imageList;
+  }
+  TreeView_SetImageList((HWND) GetHWND(), (HIMAGELIST) imageList ? imageList->GetHIMAGELIST() : 0, flags);
+}
+
+long wxTreeCtrl::GetNextItem(const long item, int code) const
+{
+  UINT flag = 0;
+  switch ( code )
+  {
+    case wxTREE_NEXT_CARET:
+      flag = TVGN_CARET;
+      break;
+    case wxTREE_NEXT_CHILD:
+      flag = TVGN_CHILD;
+      break;
+    case wxTREE_NEXT_DROPHILITE:
+      flag = TVGN_DROPHILITE;
+      break;
+    case wxTREE_NEXT_FIRSTVISIBLE:
+      flag = TVGN_FIRSTVISIBLE;
+      break;
+    case wxTREE_NEXT_NEXT:
+      flag = TVGN_NEXT;
+      break;
+    case wxTREE_NEXT_NEXTVISIBLE:
+      flag = TVGN_NEXTVISIBLE;
+      break;
+    case wxTREE_NEXT_PARENT:
+      flag = TVGN_PARENT;
+      break;
+    case wxTREE_NEXT_PREVIOUS:
+      flag = TVGN_PREVIOUS;
+      break;
+    case wxTREE_NEXT_PREVIOUSVISIBLE:
+      flag = TVGN_PREVIOUSVISIBLE;
+      break;
+    case wxTREE_NEXT_ROOT:
+      flag = TVGN_ROOT;
+      break;
+
+    default :
+      break;
+  }
+  return (long) TreeView_GetNextItem( (HWND) GetHWND(), (HTREEITEM) item, flag);
+}
+
+bool wxTreeCtrl::ItemHasChildren(const long item) const
+{
+  TV_ITEM item2;
+  item2.hItem = (HTREEITEM) item;
+  item2.mask = TVIF_CHILDREN;
+  TreeView_GetItem((HWND) GetHWND(), &item2);
+  return (item2.cChildren != 0);
+}
+
+long wxTreeCtrl::GetChild(const long item) const
+{
+  return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)item);
+}
+
+long wxTreeCtrl::GetParent(const long item) const
+{
+  return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)item);
+}
+
+long wxTreeCtrl::GetFirstVisibleItem(void) const
+{
+  return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0);
+}
+
+long wxTreeCtrl::GetNextVisibleItem(const long item) const
+{
+  return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)item);
+}
+
+long wxTreeCtrl::GetSelection(void) const
+{
+  return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_CARET, 0);
+}
+
+long wxTreeCtrl::GetRootItem(void) const
+{
+  return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_ROOT, 0);
+}
+
+// TODO: convert mask
+bool wxTreeCtrl::GetItem(wxTreeItem& info) const
+{
+  TV_ITEM tvItem;
+  tvItem.hItem   = (HTREEITEM)info.m_itemId;
+  tvItem.pszText = NULL;
+  tvItem.mask    = 0;
+  if ( info.m_mask & wxTREE_MASK_TEXT )
+  {
+    tvItem.mask |= TVIF_TEXT;
+    tvItem.pszText = new char[513];
+    tvItem.cchTextMax = 512;
+  }
+  if ( info.m_mask & wxTREE_MASK_DATA )
+    tvItem.mask |= TVIF_PARAM;
+
+  bool success = TreeView_GetItem((HWND)GetHWND(), &tvItem) != 0;
+
+  if ( !success )
+  {
+    wxLogSysError("TreeView_GetItem failed");
+
+    if (tvItem.pszText)
+      delete[] tvItem.pszText;
+
+    return FALSE;
+  }
+
+  wxConvertFromMSWTreeItem(info, tvItem);
+
+  if (tvItem.pszText)
+    delete[] tvItem.pszText;
+
+  return success;
+}
+
+bool wxTreeCtrl::SetItem(wxTreeItem& info)
+{
+  TV_ITEM item;
+    wxConvertToMSWTreeItem(info, item);
+  return (::SendMessage((HWND) GetHWND(), TVM_SETITEM, 0, (LPARAM)&item) != 0);
+}
+
+int  wxTreeCtrl::GetItemState(const long item, const long stateMask) const
+{
+  wxTreeItem info;
+
+  info.m_mask = wxTREE_MASK_STATE ;
+  info.m_stateMask = stateMask;
+  info.m_itemId = item;
+
+  if (!GetItem(info))
+    return 0;
+
+  return info.m_state;
+}
+
+bool wxTreeCtrl::SetItemState(const long item, const long state, const long stateMask)
+{
+  wxTreeItem info;
+
+  info.m_mask = wxTREE_MASK_STATE ;
+  info.m_state = state;
+  info.m_stateMask = stateMask;
+  info.m_itemId = item;
+
+  return SetItem(info);
+}
+
+bool wxTreeCtrl::SetItemImage(const long item, const int image, const int selImage)
+{
+  wxTreeItem info;
+
+  info.m_mask = wxTREE_MASK_IMAGE ;
+  info.m_image = image;
+  if ( selImage > -1)
+  {
+    info.m_selectedImage = selImage;
+    info.m_mask |= wxTREE_MASK_SELECTED_IMAGE;
+  }
+  info.m_itemId = item;
+
+  return SetItem(info);
+}
+
+wxString wxTreeCtrl::GetItemText(const long item) const
+{
+  wxTreeItem info;
+
+  info.m_mask = wxTREE_MASK_TEXT ;
+  info.m_itemId = item;
+
+  if (!GetItem(info))
+    return wxString("");
+  return info.m_text;
+}
+
+void wxTreeCtrl::SetItemText(const long item, const wxString& str)
+{
+  wxTreeItem info;
+
+  info.m_mask = wxTREE_MASK_TEXT ;
+  info.m_itemId = item;
+  info.m_text = str;
+
+  SetItem(info);
+}
+
+long wxTreeCtrl::GetItemData(const long item) const
+{
+  wxTreeItem info;
+
+  info.m_mask = wxTREE_MASK_DATA ;
+  info.m_itemId = item;
+
+  if (!GetItem(info))
+    return 0;
+  return info.m_data;
+}
+
+bool wxTreeCtrl::SetItemData(const long item, long data)
+{
+  wxTreeItem info;
+
+  info.m_mask = wxTREE_MASK_DATA ;
+  info.m_itemId = item;
+  info.m_data = data;
+
+  return SetItem(info);
+}
+
+bool wxTreeCtrl::GetItemRect(const long item, wxRectangle& rect, bool textOnly) const
+{
+  RECT rect2;
+
+  *(HTREEITEM*)& rect2 = (HTREEITEM) item;
+  bool success = (::SendMessage((HWND) GetHWND(), TVM_GETITEMRECT, (WPARAM)textOnly,
+    (LPARAM)&rect2) != 0);
+
+  rect.x = rect2.left;
+  rect.y = rect2.top;
+  rect.width = rect2.right - rect2.left;
+  rect.height = rect2.bottom - rect2.left;
+  return success;
+}
+
+wxTextCtrl& wxTreeCtrl::GetEditControl(void) const
+{
+  HWND hWnd = (HWND) TreeView_GetEditControl((HWND) GetHWND());
+  ((wxTreeCtrl *)this)->m_textCtrl.SetHWND((WXHWND) hWnd);
+  return (wxTextCtrl&) m_textCtrl;
+}
+
+// Operations
+bool wxTreeCtrl::DeleteItem(const long item)
+{
+  return (TreeView_DeleteItem((HWND) GetHWND(), (HTREEITEM) item) != 0);
+}
+
+bool wxTreeCtrl::ExpandItem(const long item, const int action)
+{
+  UINT mswAction = TVE_EXPAND;
+  switch ( action )
+  {
+    case wxTREE_EXPAND_EXPAND:
+      mswAction = TVE_EXPAND;
+      break;
+    case wxTREE_EXPAND_COLLAPSE:
+      mswAction = TVE_COLLAPSE;
+    case wxTREE_EXPAND_COLLAPSE_RESET:
+      mswAction = TVE_COLLAPSERESET;
+    case wxTREE_EXPAND_TOGGLE:
+      mswAction = TVE_TOGGLE;
+      break;
+    default :
+      break;
+  }
+  return (TreeView_Expand((HWND) GetHWND(), (HTREEITEM) item, mswAction) != 0);
+}
+
+long wxTreeCtrl::InsertItem(const long parent, wxTreeItem& info, const long insertAfter)
+{
+  TV_INSERTSTRUCT tvInsertStruct;
+  tvInsertStruct.hParent = (HTREEITEM) parent ;
+  tvInsertStruct.hInsertAfter = (HTREEITEM) insertAfter ;
+
+  wxConvertToMSWTreeItem(info, tvInsertStruct.item);
+
+  return (long) TreeView_InsertItem((HWND) GetHWND(), & tvInsertStruct);
+}
+
+long wxTreeCtrl::InsertItem(const long parent, const wxString& label, const int image, const int selImage,
+  const long insertAfter)
+{
+  wxTreeItem info;
+  info.m_text = label;
+  info.m_mask = wxTREE_MASK_TEXT;
+  if ( image > -1 )
+  {
+    info.m_mask |= wxTREE_MASK_IMAGE | wxTREE_MASK_SELECTED_IMAGE;
+    info.m_image = image;
+    if ( selImage == -1 )
+      info.m_selectedImage = image;
+    else
+      info.m_selectedImage = selImage;
+  }
+
+  return InsertItem(parent, info, insertAfter);
+}
+
+bool wxTreeCtrl::SelectItem(const long item)
+{
+  return (TreeView_SelectItem((HWND) GetHWND(), (HTREEITEM) item) != 0);
+}
+
+bool wxTreeCtrl::ScrollTo(const long item)
+{
+  return (TreeView_SelectSetFirstVisible((HWND) GetHWND(), (HTREEITEM) item) != 0);
+}
+
+bool wxTreeCtrl::DeleteAllItems(void)
+{
+  return (TreeView_DeleteAllItems((HWND) GetHWND()) != 0);
+}
+
+wxTextCtrl& wxTreeCtrl::Edit(const long item)
+{
+  HWND hWnd = (HWND) TreeView_EditLabel((HWND) GetHWND(), item);
+  m_textCtrl.SetHWND((WXHWND) hWnd);
+  return m_textCtrl;
+}
+
+long wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
+{
+    TV_HITTESTINFO hitTestInfo;
+  hitTestInfo.pt.x = (int) point.x;
+  hitTestInfo.pt.y = (int) point.y;
+
+    TreeView_HitTest((HWND) GetHWND(), & hitTestInfo);
+
+  flags = 0;
+  if ( hitTestInfo.flags & TVHT_ABOVE )
+    flags |= wxTREE_HITTEST_ABOVE;
+  if ( hitTestInfo.flags & TVHT_BELOW )
+    flags |= wxTREE_HITTEST_BELOW;
+  if ( hitTestInfo.flags & TVHT_NOWHERE )
+    flags |= wxTREE_HITTEST_NOWHERE;
+  if ( hitTestInfo.flags & TVHT_ONITEMBUTTON )
+    flags |= wxTREE_HITTEST_ONITEMBUTTON;
+  if ( hitTestInfo.flags & TVHT_ONITEMICON )
+    flags |= wxTREE_HITTEST_ONITEMICON;
+  if ( hitTestInfo.flags & TVHT_ONITEMINDENT )
+    flags |= wxTREE_HITTEST_ONITEMINDENT;
+  if ( hitTestInfo.flags & TVHT_ONITEMLABEL )
+    flags |= wxTREE_HITTEST_ONITEMLABEL;
+  if ( hitTestInfo.flags & TVHT_ONITEMRIGHT )
+    flags |= wxTREE_HITTEST_ONITEMRIGHT;
+  if ( hitTestInfo.flags & TVHT_ONITEMSTATEICON )
+    flags |= wxTREE_HITTEST_ONITEMSTATEICON;
+  if ( hitTestInfo.flags & TVHT_TOLEFT )
+    flags |= wxTREE_HITTEST_TOLEFT;
+  if ( hitTestInfo.flags & TVHT_TORIGHT )
+    flags |= wxTREE_HITTEST_TORIGHT;
+
+  return (long) hitTestInfo.hItem ;
+}
+
+/*
+wxImageList *wxTreeCtrl::CreateDragImage(const long item)
+{
+}
+*/
+
+bool wxTreeCtrl::SortChildren(const long item)
+{
+  return (TreeView_SortChildren((HWND) GetHWND(), (HTREEITEM) item, 0) != 0);
+}
+
+bool wxTreeCtrl::EnsureVisible(const long item)
+{
+  return (TreeView_EnsureVisible((HWND) GetHWND(), (HTREEITEM) item) != 0);
+}
+
+bool wxTreeCtrl::MSWCommand(const WXUINT cmd, const WXWORD id)
+{
+  if (cmd == EN_UPDATE)
+  {
+    wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, id);
+    event.SetEventObject( this );
+    ProcessCommand(event);
+    return TRUE;
+  }
+  else if (cmd == EN_KILLFOCUS)
+  {
+    wxCommandEvent event(wxEVT_KILL_FOCUS, id);
+    event.SetEventObject( this );
+    ProcessCommand(event);
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+bool wxTreeCtrl::MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam)
+{
+  wxTreeEvent event(0, m_windowId);
+  int eventType = 0;
+  NMHDR* hdr1 = (NMHDR*) lParam;
+  switch ( hdr1->code )
+  {
+    case TVN_BEGINDRAG:
+    {
+      eventType = wxEVT_COMMAND_TREE_BEGIN_DRAG;
+      NM_TREEVIEW* hdr = (NM_TREEVIEW*)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, hdr->itemNew, (HWND) GetHWND());
+      event.m_pointDrag.x = hdr->ptDrag.x;
+      event.m_pointDrag.y = hdr->ptDrag.y;
+      break;
+    }
+    case TVN_BEGINLABELEDIT:
+    {
+      eventType = wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT;
+      TV_DISPINFO *info = (TV_DISPINFO *)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, info->item, (HWND) GetHWND());
+      break;
+    }
+    case TVN_BEGINRDRAG:
+    {
+      eventType = wxEVT_COMMAND_TREE_BEGIN_RDRAG;
+      NM_TREEVIEW* hdr = (NM_TREEVIEW*)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, hdr->itemNew, (HWND) GetHWND());
+      event.m_pointDrag.x = hdr->ptDrag.x;
+      event.m_pointDrag.y = hdr->ptDrag.y;
+      break;
+    }
+    case TVN_DELETEITEM:
+    {
+      eventType = wxEVT_COMMAND_TREE_DELETE_ITEM;
+      NM_TREEVIEW* hdr = (NM_TREEVIEW*)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, hdr->itemOld, (HWND) GetHWND());
+      event.m_pointDrag.x = hdr->ptDrag.x;
+      event.m_pointDrag.y = hdr->ptDrag.y;
+      break;
+    }
+    case TVN_ENDLABELEDIT:
+    {
+      eventType = wxEVT_COMMAND_TREE_END_LABEL_EDIT;
+      TV_DISPINFO *info = (TV_DISPINFO *)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, info->item, (HWND) GetHWND());
+      break;
+    }
+    case TVN_GETDISPINFO:
+    {
+      eventType = wxEVT_COMMAND_TREE_GET_INFO;
+      TV_DISPINFO *info = (TV_DISPINFO *)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, info->item, (HWND) GetHWND());
+      break;
+    }
+    case TVN_ITEMEXPANDING:
+    {
+      eventType = wxEVT_COMMAND_TREE_ITEM_EXPANDING;
+      NM_TREEVIEW* hdr = (NM_TREEVIEW*)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, hdr->itemNew, (HWND) GetHWND());
+
+      switch ( hdr->action )
+      {
+        case TVE_EXPAND:
+          event.m_code = wxTREE_EXPAND_EXPAND;
+          break;
+        case TVE_COLLAPSE:
+          event.m_code = wxTREE_EXPAND_COLLAPSE;
+        case TVE_COLLAPSERESET:
+          event.m_code = wxTREE_EXPAND_COLLAPSE_RESET;
+        case TVE_TOGGLE:
+          event.m_code = wxTREE_EXPAND_TOGGLE;
+          break;
+        default :
+          break;
+      }
+      break;
+    }
+    case TVN_ITEMEXPANDED:
+    {
+      eventType = wxEVT_COMMAND_TREE_ITEM_EXPANDED;
+      NM_TREEVIEW* hdr = (NM_TREEVIEW*)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, hdr->itemNew, (HWND) GetHWND());
+      switch ( hdr->action )
+      {
+        case TVE_EXPAND:
+          event.m_code = wxTREE_EXPAND_EXPAND;
+          break;
+        case TVE_COLLAPSE:
+          event.m_code = wxTREE_EXPAND_COLLAPSE;
+        case TVE_COLLAPSERESET:
+          event.m_code = wxTREE_EXPAND_COLLAPSE_RESET;
+        case TVE_TOGGLE:
+          event.m_code = wxTREE_EXPAND_TOGGLE;
+          break;
+        default :
+          break;
+      }
+      break;
+    }
+    case TVN_KEYDOWN:
+    {
+      eventType = wxEVT_COMMAND_TREE_KEY_DOWN;
+      TV_KEYDOWN *info = (TV_KEYDOWN *)lParam;
+      event.m_code = wxCharCodeMSWToWX(info->wVKey);
+      break;
+    }
+    case TVN_SELCHANGED:
+    {
+      eventType = wxEVT_COMMAND_TREE_SEL_CHANGED;
+      NM_TREEVIEW* hdr = (NM_TREEVIEW*)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, hdr->itemNew, (HWND) GetHWND());
+      event.m_oldItem = (long) hdr->itemNew.hItem;
+
+      break;
+    }
+    case TVN_SELCHANGING:
+    {
+      eventType = wxEVT_COMMAND_TREE_SEL_CHANGING;
+      NM_TREEVIEW* hdr = (NM_TREEVIEW*)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, hdr->itemNew, (HWND) GetHWND());
+      event.m_oldItem = (long) hdr->itemNew.hItem;
+      break;
+    }
+    case TVN_SETDISPINFO:
+    {
+      eventType = wxEVT_COMMAND_TREE_SET_INFO;
+      TV_DISPINFO *info = (TV_DISPINFO *)lParam;
+      wxConvertFromMSWTreeItem(event.m_item, info->item, (HWND) GetHWND());
+      break;
+    }
+
+    default :
+      return wxControl::MSWNotify(wParam, lParam);
+      break;
+  }
+
+  event.SetEventObject( this );
+  event.SetEventType(eventType);
+
+  if ( !GetEventHandler()->ProcessEvent(event) )
+    return FALSE;
+
+  if (hdr1->code == TVN_GETDISPINFO)
+  {
+    TV_DISPINFO *info = (TV_DISPINFO *)lParam;
+    wxConvertToMSWTreeItem(event.m_item, info->item);
+  }
+
+    return TRUE;
+}
+
+// Tree item structure
+wxTreeItem::wxTreeItem(void)
+{
+    m_mask = 0;
+    m_itemId = 0;
+    m_state = 0;
+    m_stateMask = 0;
+    m_image = -1;
+    m_selectedImage = -1;
+    m_children = 0;
+  m_data = 0;
+}
+
+// If getFullInfo is TRUE, we explicitly query for more info if we haven't got it all.
+static void wxConvertFromMSWTreeItem(wxTreeItem& info, TV_ITEM& tvItem, HWND getFullInfo)
+{
+  info.m_data = tvItem.lParam;
+  info.m_mask = 0;
+  info.m_state = 0;
+  info.m_stateMask = 0;
+
+  long oldMask = tvItem.mask;
+
+  bool needText = FALSE;
+  if (getFullInfo != 0)
+  {
+    if ( tvItem.mask & TVIF_TEXT )
+      needText = FALSE;
+    else
+      needText = TRUE;
+
+    if ( needText )
+    {
+      tvItem.pszText = new char[513];
+      tvItem.cchTextMax = 512;
+    }
+    tvItem.mask |= TVIF_HANDLE | TVIF_STATE | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM ;
+    ::SendMessage(getFullInfo, TVM_GETITEM, 0, (LPARAM)& tvItem) ;
+  }
+
+  if ( tvItem.mask & TVIF_HANDLE )
+  {
+    info.m_mask |= wxTREE_MASK_HANDLE;
+    info.m_itemId = (long) tvItem.hItem;
+  }
+  if ( tvItem.mask & TVIF_STATE )
+  {
+    info.m_mask |= wxTREE_MASK_STATE;
+      if ( tvItem.stateMask & TVIS_BOLD)
+    {
+      info.m_stateMask |= wxTREE_STATE_BOLD ;
+      if ( tvItem.state & TVIS_BOLD )
+        info.m_state |= wxTREE_STATE_BOLD ;
+    }
+
+      if ( tvItem.stateMask & TVIS_CUT)
+    {
+      info.m_stateMask |= wxTREE_STATE_CUT ;
+      if ( tvItem.state & TVIS_CUT )
+        info.m_state |= wxTREE_STATE_CUT ;
+    }
+
+      if ( tvItem.stateMask & TVIS_DROPHILITED)
+    {
+      info.m_stateMask |= wxTREE_STATE_DROPHILITED ;
+      if ( tvItem.state & TVIS_DROPHILITED )
+        info.m_state |= wxTREE_STATE_DROPHILITED ;
+    }
+      if ( tvItem.stateMask & TVIS_EXPANDED)
+    {
+      info.m_stateMask |= wxTREE_STATE_EXPANDED ;
+      if ( tvItem.state & TVIS_EXPANDED )
+        info.m_state |= wxTREE_STATE_EXPANDED ;
+    }
+      if ( tvItem.stateMask & TVIS_EXPANDEDONCE)
+    {
+      info.m_stateMask |= wxTREE_STATE_EXPANDEDONCE ;
+      if ( tvItem.state & TVIS_EXPANDEDONCE )
+        info.m_state |= wxTREE_STATE_EXPANDEDONCE ;
+    }
+      if ( tvItem.stateMask & TVIS_FOCUSED)
+    {
+      info.m_stateMask |= wxTREE_STATE_FOCUSED ;
+      if ( tvItem.state & TVIS_FOCUSED )
+        info.m_state |= wxTREE_STATE_FOCUSED ;
+    }
+      if ( tvItem.stateMask & TVIS_SELECTED)
+    {
+      info.m_stateMask |= wxTREE_STATE_SELECTED ;
+      if ( tvItem.state & TVIS_SELECTED )
+        info.m_state |= wxTREE_STATE_SELECTED ;
+    }
+  }
+
+  if ( tvItem.mask & TVIF_TEXT )
+  {
+    info.m_mask |= wxTREE_MASK_TEXT;
+    info.m_text = tvItem.pszText;
+  }
+  if ( tvItem.mask & TVIF_IMAGE )
+  {
+    info.m_mask |= wxTREE_MASK_IMAGE;
+    info.m_image = tvItem.iImage;
+  }
+  if ( tvItem.mask & TVIF_SELECTEDIMAGE )
+  {
+    info.m_mask |= wxTREE_MASK_SELECTED_IMAGE;
+    info.m_selectedImage = tvItem.iSelectedImage;
+  }
+  if ( tvItem.mask & TVIF_CHILDREN )
+  {
+    info.m_mask |= wxTREE_MASK_CHILDREN;
+    info.m_children = tvItem.cChildren;
+  }
+  if ( tvItem.mask & TVIF_PARAM )
+    info.m_mask |= wxTREE_MASK_DATA;
+
+  if (needText)
+  {
+        if (tvItem.pszText)
+      delete[] tvItem.pszText;
+  }
+  tvItem.mask = oldMask ;
+}
+
+static void wxConvertToMSWTreeItem(wxTreeItem& info, TV_ITEM& tvItem)
+{
+  tvItem.hItem = (HTREEITEM) info.m_itemId ;
+
+  tvItem.iImage = info.m_image ;
+  tvItem.iSelectedImage = info.m_selectedImage;
+  tvItem.cChildren = info.m_children;
+  tvItem.lParam = info.m_data;
+  tvItem.mask = 0;
+  tvItem.stateMask = 0;
+  tvItem.state = 0;
+
+  if (info.m_mask & wxTREE_MASK_HANDLE)
+    tvItem.mask |= TVIF_HANDLE ;
+  if (info.m_mask & wxTREE_MASK_STATE)
+    tvItem.mask |= TVIF_STATE ;
+  if (info.m_mask & wxTREE_MASK_TEXT)
+  {
+    tvItem.mask |= TVIF_TEXT ;
+    tvItem.pszText = (char *) (const char *)info.m_text ;
+    if ( tvItem.pszText )
+      tvItem.cchTextMax = info.m_text.Length();
+    else
+      tvItem.cchTextMax = 0;
+  }
+  if (info.m_mask & wxTREE_MASK_IMAGE)
+    tvItem.mask |= TVIF_IMAGE ;
+  if (info.m_mask & wxTREE_MASK_SELECTED_IMAGE)
+    tvItem.mask |= TVIF_SELECTEDIMAGE ;
+  if (info.m_mask & wxTREE_MASK_CHILDREN)
+    tvItem.mask |= TVIF_CHILDREN ;
+  if (info.m_mask & wxTREE_MASK_DATA)
+    tvItem.mask |= TVIF_PARAM ;
+
+  if (info.m_stateMask & wxTREE_STATE_BOLD)
+  {
+      tvItem.stateMask |= TVIS_BOLD ;
+    tvItem.state |= TVIS_BOLD;
+  }
+  if (info.m_stateMask & wxTREE_STATE_CUT)
+  {
+      tvItem.stateMask |= TVIS_CUT ;
+    if ( info.m_state & wxTREE_STATE_CUT )
+      tvItem.state |= TVIS_CUT;
+  }
+  if (info.m_stateMask & wxTREE_STATE_DROPHILITED)
+  {
+      tvItem.stateMask |= TVIS_DROPHILITED;
+    if ( info.m_state & wxTREE_STATE_DROPHILITED )
+        tvItem.state |= TVIS_DROPHILITED;
+  }
+  if (info.m_stateMask & wxTREE_STATE_EXPANDED)
+  {
+      tvItem.stateMask |= TVIS_EXPANDED;
+    if ( info.m_state & wxTREE_STATE_EXPANDED )
+        tvItem.state |= TVIS_EXPANDED;
+  }
+  if (info.m_stateMask & wxTREE_STATE_EXPANDEDONCE)
+  {
+      tvItem.stateMask |= TVIS_EXPANDEDONCE;
+    if ( info.m_state & wxTREE_STATE_EXPANDEDONCE )
+        tvItem.state |= TVIS_EXPANDEDONCE;
+  }
+  if (info.m_stateMask & wxTREE_STATE_FOCUSED)
+  {
+      tvItem.stateMask |= TVIS_FOCUSED;
+    if ( info.m_state & wxTREE_STATE_FOCUSED )
+        tvItem.state |= TVIS_FOCUSED;
+  }
+  if (info.m_stateMask & wxTREE_STATE_SELECTED)
+  {
+      tvItem.stateMask |= TVIS_SELECTED;
+    if ( info.m_state & wxTREE_STATE_SELECTED )
+        tvItem.state |= TVIS_SELECTED;
+  }
+}
+
+// Tree event
+IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent)
+
+wxTreeEvent::wxTreeEvent(WXTYPE commandType, int id):
+  wxCommandEvent(commandType, id)
+{
+  m_code = 0;
+  m_oldItem = 0;
+}
+
+#endif
+
diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp
new file mode 100644
index 0000000000..361bd94e31
--- /dev/null
+++ b/src/msw/utils.cpp
@@ -0,0 +1,748 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        utils.cpp
+// Purpose:     Various utilities
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation
+#pragma implementation "utils.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/setup.h"
+#include "wx/utils.h"
+#include "wx/app.h"
+#include "wx/cursor.h"
+#endif
+
+#include "wx/msw/private.h"
+#include "wx/timer.h"
+
+#include <ctype.h>
+
+#ifndef __GNUWIN32__
+#include <direct.h>
+#include <dos.h>
+#endif
+
+#ifdef __GNUWIN32__
+#include <sys/unistd.h>
+#include <sys/stat.h>
+#ifndef __MINGW32__
+#include <std.h>
+#endif
+
+#define stricmp strcasecmp
+#endif
+
+#ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
+                    // this (3.1 I believe) and how to test for it.
+                    // If this works for Borland 4.0 as well, then no worries.
+#include <dir.h>
+#endif
+
+#ifdef __WIN32__
+#include <io.h>
+
+#ifndef __GNUWIN32__
+#include <shellapi.h>
+#endif
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifndef __WATCOMC__
+#if !(defined(_MSC_VER) && (_MSC_VER > 800))
+#include <errno.h>
+#endif
+#endif
+#include <stdarg.h>
+
+// In the WIN.INI file
+static const char WX_SECTION[] = "wxWindows";
+static const char eHOSTNAME[]  = "HostName";
+static const char eUSERID[]    = "UserId";
+static const char eUSERNAME[]  = "UserName";
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxList)
+#endif
+
+// For the following functions we SHOULD fill in support
+// for Windows-NT (which I don't know) as I assume it begin
+// a POSIX Unix (so claims MS) that it has some special
+// functions beyond those provided by WinSock
+
+// Get full hostname (eg. DoDo.BSn-Germany.crg.de)
+bool wxGetHostName(char *buf, int maxSize)
+{
+#ifdef __WIN32__
+  DWORD nSize = maxSize;
+  return (::GetComputerName(buf, &nSize) != 0);
+#else
+  char *sysname;
+  const char *default_host = "noname";
+
+  if ((sysname = getenv("SYSTEM_NAME")) == NULL) {
+     GetProfileString(WX_SECTION, eHOSTNAME, default_host, buf, maxSize - 1);
+  } else
+    strncpy(buf, sysname, maxSize - 1);
+  buf[maxSize] = '\0';
+  return *buf ? TRUE : FALSE;
+#endif
+}
+
+// Get user ID e.g. jacs
+bool wxGetUserId(char *buf, int maxSize)
+{
+#if defined(__WIN32__) && !defined(__win32s__) && 0
+  // Gets the current user's full name according to the MS article PSS ID
+  // Number: Q119670
+  // Seems to be the same as the login name for me?
+  char *UserName = new char[256];
+  char *Domain = new char[256];
+  DWORD maxCharacters = 255;
+  GetUserName( UserName, &maxCharacters );
+  GetComputerName( Domain, &maxCharacters );
+
+  WCHAR  wszUserName[256];           // Unicode user name
+  WCHAR  wszDomain[256];
+  LPBYTE ComputerName;
+ 
+  struct _SERVER_INFO_100 *si100;   // Server structure
+  struct _USER_INFO_2 *ui;          // User structure
+ 
+  // Convert ASCII user name and domain to Unicode.
+ 
+  MultiByteToWideChar( CP_ACP, 0, UserName,
+     strlen(UserName)+1, wszUserName, sizeof(wszUserName) );
+  MultiByteToWideChar( CP_ACP, 0, Domain,
+     strlen(Domain)+1, wszDomain, sizeof(wszDomain) );
+
+  // Get the computer name of a DC for the specified domain.
+  // >If you get a link error on this, include netapi32.lib<
+ 
+  NetGetDCName( NULL, wszDomain, &ComputerName );
+ 
+  // Look up the user on the DC.
+ 
+  if(NetUserGetInfo( (LPWSTR) ComputerName,
+     (LPWSTR) &wszUserName, 2, (LPBYTE *) &ui))
+  {
+     printf( "Error getting user information.\n" );
+     return( FALSE );
+  }
+ 
+  // Convert the Unicode full name to ASCII.
+ 
+  WideCharToMultiByte( CP_ACP, 0, ui->usri2_full_name,
+     -1, buf, 256, NULL, NULL );
+  }
+  return( TRUE );
+/*
+  DWORD nSize = maxSize;
+  return ::GetUserName(buf, &nSize);
+*/
+#else
+  char *user;
+  const char *default_id = "anonymous";
+
+  // Can't assume we have NIS (PC-NFS) or some other ID daemon
+  // So we ...
+  if (	(user = getenv("USER")) == NULL &&
+	(user = getenv("LOGNAME")) == NULL ) {
+     // Use wxWindows configuration data (comming soon)
+     GetProfileString(WX_SECTION, eUSERID, default_id, buf, maxSize - 1);
+  } else
+    strncpy(buf, user, maxSize - 1);
+  return *buf ? TRUE : FALSE;
+#endif
+}
+
+// Get user name e.g. Julian Smart
+bool wxGetUserName(char *buf, int maxSize)
+{
+  const char *default_name = "Unknown User"; 
+#if defined(__WIN32__)
+/*
+  DWORD nSize = maxSize;
+  In VC++ 4.0, results in unresolved symbol __imp__GetUserNameA
+  if (GetUserName(buf, &nSize))
+    return TRUE;
+  else
+*/
+    // Could use NIS, MS-Mail or other site specific programs
+    // Use wxWindows configuration data 
+    GetProfileString(WX_SECTION, eUSERNAME, default_name, buf, maxSize - 1);
+    return *buf ? TRUE : FALSE;
+//  }
+#else
+#if !defined(__WATCOMC__) && !defined(__GNUWIN32__) && USE_PENWINDOWS
+  extern HANDLE hPenWin; // PenWindows Running?
+  if (hPenWin)
+  {
+    // PenWindows Does have a user concept!
+    // Get the current owner of the recognizer
+    GetPrivateProfileString("Current", "User", default_name, wxBuffer, maxSize - 1, "PENWIN.INI");
+    strncpy(buf, wxBuffer, maxSize - 1);
+  }
+  else
+#endif
+  {
+    // Could use NIS, MS-Mail or other site specific programs
+    // Use wxWindows configuration data 
+    GetProfileString(WX_SECTION, eUSERNAME, default_name, buf, maxSize - 1);
+  }
+  return *buf ? TRUE : FALSE;
+#endif
+}
+
+// Execute a command (e.g. another program) in a
+// system-independent manner.
+
+long wxExecute(char **argv, bool sync)
+{
+  if (*argv == NULL)
+    return 0;
+
+  char command[1024];
+  command[0] = '\0';
+
+  int argc;
+  for (argc = 0; argv[argc]; argc++)
+   {
+    if (argc)
+      strcat(command, " ");
+    strcat(command, argv[argc]);
+   }
+
+  return wxExecute((char *)command, sync);
+}
+
+long wxExecute(const wxString& command, bool sync)
+{
+  if (command == "")
+    return 0;
+
+#ifdef __WIN32__
+  char * cl;
+  char * argp;
+  int clen;
+  HINSTANCE result;
+  DWORD dresult;
+
+  // copy the command line
+  clen = command.Length();
+  if (!clen) return -1;
+  cl = (char *) calloc( 1, 256);
+  if (!cl) return -1;
+  strcpy( cl, WXSTRINGCAST command);
+
+  // isolate command and arguments
+  argp = strchr( cl, ' ');
+  if (argp)
+    *argp++ = '\0';
+
+  // execute the command
+#ifdef __GNUWIN32__
+  result = ShellExecute( (HWND) (wxTheApp->GetTopWindow() ? (HWND) wxTheApp->GetTopWindow()->GetHWND() : NULL),
+     (const wchar_t) "open", (const wchar_t) cl, (const wchar_t) argp, (const wchar_t) NULL, SW_SHOWNORMAL);
+#else
+  result = ShellExecute( (HWND) (wxTheApp->GetTopWindow() ? wxTheApp->GetTopWindow()->GetHWND() : NULL),
+     "open", cl, argp, NULL, SW_SHOWNORMAL);
+#endif
+
+  if (((long)result) <= 32) {
+   free(cl);
+   return 0;
+  }
+  
+  if (!sync)
+  {
+    free(cl);
+    return dresult;
+  }
+
+  // waiting until command executed
+  do {
+    wxYield();
+    dresult = GetModuleFileName( result, cl, 256);
+  } while( dresult);
+  
+  /* long lastError = GetLastError(); */
+
+  free(cl);
+  return 0;
+#else
+  long instanceID = WinExec((LPCSTR) WXSTRINGCAST command, SW_SHOW);
+  if (instanceID < 32) return(0);
+
+  if (sync) {
+    int running;
+    do {
+      wxYield();
+      running = GetModuleUsage((HANDLE)instanceID);
+    } while (running);
+  }
+  return(instanceID);
+#endif
+}
+
+int wxKill(long pid, int sig)
+{
+  return 0;
+}
+
+//
+// Execute a program in an Interactive Shell
+//
+bool
+wxShell(const wxString& command)
+{
+  char *shell;
+  if ((shell = getenv("COMSPEC")) == NULL)
+    shell = "\\COMMAND.COM";
+
+  char tmp[255];
+  if (command != "")
+    sprintf(tmp, "%s /c %s", shell, WXSTRINGCAST command);
+  else
+    strcpy(tmp, shell);
+
+  return (wxExecute((char *)tmp, FALSE) != 0);
+}
+
+// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
+long wxGetFreeMemory(void)
+{
+#if defined(__WIN32__) && !defined(__BORLANDC__)
+  MEMORYSTATUS memStatus;
+  memStatus.dwLength = sizeof(MEMORYSTATUS);
+  GlobalMemoryStatus(&memStatus);
+  return memStatus.dwAvailPhys;
+#else
+  return (long)GetFreeSpace(0);
+#endif
+}
+
+// Sleep for nSecs seconds. Attempt a Windows implementation using timers.
+static bool inTimer = FALSE;
+class wxSleepTimer: public wxTimer
+{
+ public:
+  inline void Notify(void)
+  {
+    inTimer = FALSE;
+    Stop();
+  }
+};
+
+static wxTimer *wxTheSleepTimer = NULL;
+
+void wxSleep(int nSecs)
+{
+#if 0 // WIN32 hangs app
+  Sleep( 1000*nSecs );
+#else
+  if (inTimer)
+    return;
+
+  wxTheSleepTimer = new wxSleepTimer;
+  inTimer = TRUE;
+  wxTheSleepTimer->Start(nSecs*1000);
+  while (inTimer)
+  {
+    if (wxTheApp->Pending())
+      wxTheApp->Dispatch();
+  }
+  delete wxTheSleepTimer;
+  wxTheSleepTimer = NULL;
+#endif
+}
+
+// Consume all events until no more left
+void wxFlushEvents(void)
+{
+//  wxYield();
+}
+
+// Output a debug mess., in a system dependent fashion.
+void wxDebugMsg(const char *fmt ...)
+{
+  va_list ap;
+  static char buffer[512];
+
+  if (!wxTheApp->GetWantDebugOutput())
+    return ;
+
+  va_start(ap, fmt);
+
+  wvsprintf(buffer,fmt,ap) ;
+  OutputDebugString((LPCSTR)buffer) ;
+
+  va_end(ap);
+}
+
+// Non-fatal error: pop up message box and (possibly) continue
+void wxError(const wxString& msg, const wxString& title)
+{
+  sprintf(wxBuffer, "%s\nContinue?", WXSTRINGCAST msg);
+  if (MessageBox(NULL, (LPCSTR)wxBuffer, (LPCSTR)WXSTRINGCAST title,
+             MB_ICONSTOP | MB_YESNO) == IDNO)
+    wxExit();
+}
+
+// Fatal error: pop up message box and abort
+void wxFatalError(const wxString& msg, const wxString& title)
+{
+  sprintf(wxBuffer, "%s: %s", WXSTRINGCAST title, WXSTRINGCAST msg);
+  FatalAppExit(0, (LPCSTR)wxBuffer);
+}
+
+// Emit a beeeeeep
+void wxBell(void)
+{
+#ifdef __WIN32__
+  Beep(1000,1000) ;	// 1kHz during 1 sec.
+#else
+  MessageBeep(-1) ;
+#endif
+}
+
+int wxGetOsVersion(int *majorVsn, int *minorVsn)
+{
+  extern char *wxOsVersion;
+  if (majorVsn)
+    *majorVsn = 0;
+  if (minorVsn)
+    *minorVsn = 0;
+    
+  int retValue ;
+#ifndef __WIN32__
+#ifdef __WINDOWS_386__
+  retValue = wxWIN386;
+#else
+
+#if !defined(__WATCOMC__) && !defined(__GNUWIN32__) && USE_PENWINDOWS
+  extern HANDLE hPenWin;
+  retValue = hPenWin ? wxPENWINDOWS : wxWINDOWS ;
+#endif
+
+#endif
+#else
+  DWORD Version = GetVersion() ;
+  WORD  lowWord  = LOWORD(Version) ;
+  
+  if (wxOsVersion)
+  {
+    if (strcmp(wxOsVersion, "Win95") == 0)
+      return wxWIN95;
+    else if (strcmp(wxOsVersion, "Win32s") == 0)
+      return wxWIN32S;
+    else if (strcmp(wxOsVersion, "Windows") == 0)
+      return wxWINDOWS;
+    else if (strcmp(wxOsVersion, "WinNT") == 0)
+      return wxWINDOWS_NT;
+  }
+  bool  Win32s  = (( Version & 0x80000000 ) != 0);
+  bool  Win95   = (( Version & 0xFF ) >= 4);
+  bool  WinNT   = Version < 0x80000000;
+
+  // Get the version number
+  if (majorVsn)
+	  *majorVsn = LOBYTE( lowWord );
+  if (minorVsn)
+	  *minorVsn = HIBYTE( lowWord );
+
+  if (Win95)
+    return wxWIN95;
+  else if (Win32s)
+    return wxWIN32S;
+  else if (WinNT)
+    return wxWINDOWS_NT;
+  else
+    return wxWINDOWS;
+    
+//  retValue = ((high & 0x8000)==0) ? wxWINDOWS_NT : wxWIN32S ;
+#endif
+  // @@@@ To be completed. I don't have the manual here...
+  if (majorVsn) *majorVsn = 3 ;
+  if (minorVsn) *minorVsn = 1 ;
+  return retValue ;
+}
+
+// Reading and writing resources (eg WIN.INI, .Xdefaults)
+#if USE_RESOURCES
+bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
+{
+  if (file != "")
+    return (WritePrivateProfileString((LPCSTR)WXSTRINGCAST section, (LPCSTR)WXSTRINGCAST entry, (LPCSTR)value, (LPCSTR)WXSTRINGCAST file) != 0);
+  else
+    return (WriteProfileString((LPCSTR)WXSTRINGCAST section, (LPCSTR)WXSTRINGCAST entry, (LPCSTR)WXSTRINGCAST value) != 0);
+}
+
+bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
+{
+  char buf[50];
+  sprintf(buf, "%.4f", value);
+  return wxWriteResource(section, entry, buf, file);
+}
+
+bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
+{
+  char buf[50];
+  sprintf(buf, "%ld", value);
+  return wxWriteResource(section, entry, buf, file);
+}
+
+bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
+{
+  char buf[50];
+  sprintf(buf, "%d", value);
+  return wxWriteResource(section, entry, buf, file);
+}
+
+bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
+{
+  static const char defunkt[] = "$$default";
+  if (file != "")
+  {
+    int n = GetPrivateProfileString((LPCSTR)WXSTRINGCAST section, (LPCSTR)WXSTRINGCAST entry, (LPCSTR)defunkt,
+                                    (LPSTR)wxBuffer, 1000, (LPCSTR)WXSTRINGCAST file);
+    if (n == 0 || strcmp(wxBuffer, defunkt) == 0)
+     return FALSE;
+  }
+  else
+  {
+    int n = GetProfileString((LPCSTR)WXSTRINGCAST section, (LPCSTR)WXSTRINGCAST entry, (LPCSTR)defunkt,
+                                    (LPSTR)wxBuffer, 1000);
+    if (n == 0 || strcmp(wxBuffer, defunkt) == 0)
+      return FALSE;
+  }
+  if (*value) delete[] (*value);
+      *value = copystring(wxBuffer);
+      return TRUE;
+    }
+
+bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
+{
+  char *s = NULL;
+  bool succ = wxGetResource(section, entry, (char **)&s, file);
+  if (succ)
+  {
+    *value = (float)strtod(s, NULL);
+    delete[] s;
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
+{
+  char *s = NULL;
+  bool succ = wxGetResource(section, entry, (char **)&s, file);
+  if (succ)
+  {
+    *value = strtol(s, NULL, 10);
+    delete[] s;
+    return TRUE;
+  }
+  else return FALSE;
+}
+
+bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
+{
+  char *s = NULL;
+  bool succ = wxGetResource(section, entry, (char **)&s, file);
+  if (succ)
+  {
+    *value = (int)strtol(s, NULL, 10);
+    delete[] s; 
+    return TRUE;
+  }
+  else return FALSE;
+}
+#endif // USE_RESOURCES
+
+// Old cursor
+static HCURSOR wxBusyCursorOld = 0;
+static int wxBusyCursorCount = 0;
+
+// Set the cursor to the busy cursor for all windows
+void wxBeginBusyCursor(wxCursor *cursor)
+{
+  wxBusyCursorCount ++;
+  if (wxBusyCursorCount == 1)
+  {
+    wxBusyCursorOld = ::SetCursor((HCURSOR) cursor->GetHCURSOR());
+  }
+  else
+  {
+    (void)::SetCursor((HCURSOR) cursor->GetHCURSOR());
+  }
+}
+
+// Restore cursor to normal
+void wxEndBusyCursor(void)
+{
+  if (wxBusyCursorCount == 0)
+    return;
+    
+  wxBusyCursorCount --;
+  if (wxBusyCursorCount == 0)
+  {
+    ::SetCursor(wxBusyCursorOld);
+    wxBusyCursorOld = 0;
+  }
+}
+
+// TRUE if we're between the above two calls
+bool wxIsBusy(void)
+{
+  return (wxBusyCursorCount > 0);
+}    
+
+// Hack for MS-DOS
+char *wxGetUserHome (const wxString& user)
+{
+  char *home;
+  wxString user1(user);
+
+  if (user1 != "") {
+    char tmp[64];
+    if (wxGetUserId(tmp, sizeof(tmp)/sizeof(char))) {
+      // Guests belong in the temp dir
+      if (stricmp(tmp, "annonymous") == 0) {
+	if ((home = getenv("TMP")) != NULL ||
+	    (home = getenv("TMPDIR")) != NULL ||
+	    (home = getenv("TEMP")) != NULL)
+	  return *home ? home : "\\";
+      }
+      if (stricmp(tmp, WXSTRINGCAST user1) == 0)
+	    user1 = "";
+    }
+  }
+  if (user1 == "")
+    if ((home = getenv("HOME")) != NULL)
+    {
+      strcpy(wxBuffer, home);
+      Unix2DosFilename(wxBuffer);
+      return wxBuffer;
+    }
+  return NULL; // No home known!
+}
+
+// Check whether this window wants to process messages, e.g. Stop button
+// in long calculations.
+bool wxCheckForInterrupt(wxWindow *wnd)
+{
+	if(wnd){
+		MSG msg;
+		HWND win= (HWND) wnd->GetHWND();
+		while(PeekMessage(&msg,win,0,0,PM_REMOVE)){
+			TranslateMessage(&msg);
+			DispatchMessage(&msg);
+		}
+		return TRUE;//*** temporary?
+	}
+	else{
+		wxError("wnd==NULL !!!");
+		return FALSE;//*** temporary?
+	}
+}
+
+// MSW only: get user-defined resource from the .res file.
+// Returns NULL or newly-allocated memory, so use delete[] to clean up.
+
+#ifdef __WINDOWS__
+char *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType)
+{
+  char *s = NULL;
+#ifndef __WIN32__
+  HRSRC hResource = ::FindResource(wxGetInstance(), WXSTRINGCAST resourceName, WXSTRINGCAST resourceType);
+#else
+#ifdef UNICODE
+  HRSRC hResource = ::FindResourceW(wxGetInstance(), WXSTRINGCAST resourceName, WXSTRINGCAST resourceType);
+#else
+  HRSRC hResource = ::FindResourceA(wxGetInstance(), WXSTRINGCAST resourceName, WXSTRINGCAST resourceType);
+#endif
+#endif
+
+  if (hResource == 0)
+    return NULL;
+  HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource);
+  if (hData == 0)
+    return NULL;
+  char *theText = (char *)LockResource(hData);
+  if (!theText)
+    return NULL;
+    
+  s = copystring(theText);
+
+  // Obsolete in WIN32
+#ifndef __WIN32__
+  UnlockResource(hData);
+#endif
+
+  // No need??
+//  GlobalFree(hData);
+
+  return s;
+}
+#endif
+
+void wxGetMousePosition( int* x, int* y )
+{
+  POINT pt;
+  GetCursorPos( & pt );
+  *x = pt.x;
+  *y = pt.y;
+};
+
+// Return TRUE if we have a colour display
+bool wxColourDisplay(void)
+{
+  HDC dc = ::GetDC(NULL);
+  bool flag;
+  int noCols = GetDeviceCaps(dc, NUMCOLORS);
+  if ((noCols == -1) || (noCols > 2))
+    flag = TRUE;
+  else
+    flag = FALSE;
+  ReleaseDC(NULL, dc);
+  return flag;
+}
+
+// Returns depth of screen
+int wxDisplayDepth(void)
+{
+  HDC dc = ::GetDC(NULL);
+  int planes = GetDeviceCaps(dc, PLANES);
+  int bitsPerPixel = GetDeviceCaps(dc, BITSPIXEL);
+  int depth = planes*bitsPerPixel;
+  ReleaseDC(NULL, dc);
+  return depth;
+}
+
+// Get size of display
+void wxDisplaySize(int *width, int *height)
+{
+  HDC dc = ::GetDC(NULL);
+  *width = GetDeviceCaps(dc, HORZRES); *height = GetDeviceCaps(dc, VERTRES);
+  ReleaseDC(NULL, dc);
+}
+
diff --git a/src/msw/wave.cpp b/src/msw/wave.cpp
new file mode 100644
index 0000000000..8f54200b7b
--- /dev/null
+++ b/src/msw/wave.cpp
@@ -0,0 +1,149 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wave.cpp
+// Purpose:     wxWave
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "wave.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if defined(__BORLANDC__)
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
+#include <wx/file.h>
+#include <wx/msw/wave.h>
+#include <wx/msw/private.h>
+
+#include <windows.h>
+#include <windowsx.h>
+
+#ifndef __GNUWIN32__
+#include <mmsystem.h>
+#endif
+
+#ifdef __GNUWIN32__
+#include <wx/msw/gnuwin32/extra.h>
+#endif
+
+wxWave::wxWave(void)
+  : m_waveLength(0), m_isResource(FALSE), m_waveData(NULL)
+{
+}
+
+wxWave::wxWave(const wxString& sFileName, bool isResource)
+  : m_waveLength(0), m_isResource(isResource), m_waveData(NULL)
+{
+  Create(sFileName, isResource);
+}
+
+
+wxWave::~wxWave(void)
+{
+  Free();
+}
+
+bool wxWave::Create(const wxString& fileName, bool isResource)
+{
+  Free();
+
+  if (isResource)
+  {
+    m_isResource = TRUE;
+
+    HRSRC hresInfo;
+#ifdef __WIN32__
+    hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, "WAVE");
+#else
+    hresInfo = ::FindResource((HMODULE) wxhInstance, fileName, "WAVE");
+#endif
+    if (!hresInfo)
+        return FALSE;
+
+    HGLOBAL waveData = ::LoadResource((HMODULE) wxhInstance, hresInfo);
+
+    if (waveData)
+    {
+      m_waveData= (byte*)::LockResource(waveData);
+      m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo);
+    }
+
+    return (m_waveData ? TRUE : FALSE);
+  }
+  else
+  {
+    m_isResource = FALSE;
+
+    wxFile fileWave;
+    if (!fileWave.Open(fileName, wxFile::read))
+        return FALSE;
+
+    m_waveLength = (int) fileWave.Length();
+
+    m_waveData = (byte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
+    if (!m_waveData)
+        return FALSE;
+
+    fileWave.Read(m_waveData, m_waveLength);
+
+    return TRUE;
+  }
+}
+
+bool wxWave::Play(bool async, bool looped) const
+{
+  if (!IsOk())
+    return FALSE;
+
+#ifdef __WIN32__
+  return ( ::PlaySound((LPCSTR)m_waveData, NULL, SND_MEMORY |
+    SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 );
+#else
+  return ( ::sndPlaySound((LPCSTR)m_waveData, SND_MEMORY |
+    SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 );
+#endif
+}
+
+bool
+wxWave::Free(void)
+{
+  if (m_waveData)
+  {
+#ifdef __WIN32__
+    HGLOBAL waveData = ::GlobalHandle(m_waveData);
+#else
+    HGLOBAL waveData = GlobalPtrHandle(m_waveData);
+#endif
+
+    if (waveData)
+    {
+      if (m_isResource)
+        ::FreeResource(waveData);
+      else
+      {
+        ::GlobalUnlock(waveData);
+        ::GlobalFree(waveData);
+      }
+
+      m_waveData = NULL;
+      m_waveLength = 0;
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
+
diff --git a/src/msw/window.cpp b/src/msw/window.cpp
new file mode 100644
index 0000000000..3c3728462a
--- /dev/null
+++ b/src/msw/window.cpp
@@ -0,0 +1,4959 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        windows.cpp
+// Purpose:     wxWindow
+// Author:      Julian Smart
+// Modified by:
+// Created:     04/01/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart and Markus Holzem
+// Licence:   	wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "window.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <stdio.h>
+#include "wx/setup.h"
+#include "wx/menu.h"
+#include "wx/dc.h"
+#include "wx/dcclient.h"
+#include "wx/utils.h"
+#include "wx/app.h"
+#include "wx/panel.h"
+#include "wx/layout.h"
+#include "wx/dialog.h"
+#include "wx/listbox.h"
+#include "wx/button.h"
+#include "wx/settings.h"
+#include "wx/msgdlg.h"
+#endif
+
+#if     USE_OWNER_DRAWN
+#include "wx/ownerdrw.h"
+#endif
+
+#if     USE_DRAG_AND_DROP
+#include "wx/msw/ole/droptgt.h"
+#endif
+
+#include "wx/menuitem.h"
+#include "wx/msw/private.h"
+
+#include <string.h>
+
+#ifndef __GNUWIN32__
+#include <shellapi.h>
+#include <mmsystem.h>
+#endif
+
+#ifdef __WIN32__
+#include <windowsx.h>
+#endif
+
+#ifdef __GNUWIN32__
+#include <wx/msw/gnuwin32/extra.h>
+#endif
+
+#ifdef GetCharWidth
+#undef GetCharWidth
+#endif
+
+#ifdef FindWindow
+#undef FindWindow
+#endif
+
+#ifdef GetClassName
+#undef GetClassName
+#endif
+
+#ifdef GetClassInfo
+#undef GetClassInfo
+#endif
+
+#define WINDOW_MARGIN 3	// This defines sensitivity of Leave events
+
+wxMenu *wxCurrentPopupMenu = NULL;
+extern wxList wxPendingDelete;
+
+void wxRemoveHandleAssociation(wxWindow *win);
+void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win);
+wxWindow *wxFindWinFromHandle(WXHWND hWnd);
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
+
+BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
+  EVT_CHAR(wxWindow::OnChar)
+  EVT_SIZE(wxWindow::OnSize)
+  EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
+  EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
+  EVT_INIT_DIALOG(wxWindow::OnInitDialog)
+  EVT_IDLE(wxWindow::OnIdle)
+END_EVENT_TABLE()
+
+#endif
+
+// Find an item given the MS Windows id
+wxWindow *wxWindow::FindItem(const int id) const
+{
+  if (!GetChildren())
+    return NULL;
+  wxNode *current = GetChildren()->First();
+  while (current)
+  {
+    wxWindow *childWin = (wxWindow *)current->Data();
+
+    wxWindow *wnd = childWin->FindItem(id) ;
+    if (wnd)
+      return wnd ;
+
+    if (childWin->IsKindOf(CLASSINFO(wxControl)))
+    {
+      wxControl *item = (wxControl *)childWin;
+      if (item->m_windowId == id)
+        return item;
+      else
+      {
+        // In case it's a 'virtual' control (e.g. radiobox)
+        if (item->GetSubcontrols().Member((wxObject *)id))
+          return item;
+      }
+    }
+    current = current->Next();
+  }
+  return NULL;
+}
+
+// Find an item given the MS Windows handle
+wxWindow *wxWindow::FindItemByHWND(const WXHWND hWnd, bool controlOnly) const
+{
+  if (!GetChildren())
+    return NULL;
+  wxNode *current = GetChildren()->First();
+  while (current)
+  {
+    wxObject *obj = (wxObject *)current->Data() ;
+    // Do a recursive search.
+    wxWindow *parent = (wxWindow *)obj ;
+    wxWindow *wnd = parent->FindItemByHWND(hWnd) ;
+    if (wnd)
+      return wnd ;
+
+    if ((!controlOnly) || obj->IsKindOf(CLASSINFO(wxControl)))
+    {
+      wxWindow *item = (wxWindow *)current->Data();
+      if ((HWND)(item->GetHWND()) == (HWND) hWnd)
+        return item;
+      else
+      {
+		if ( item->ContainsHWND(hWnd) )
+			return item;
+      }
+    }
+    current = current->Next();
+  }
+  return NULL;
+}
+
+// Default command handler
+bool wxWindow::MSWCommand(const WXUINT WXUNUSED(param), const WXWORD WXUNUSED(id))
+{
+  return FALSE;
+}
+
+bool wxWindow::MSWNotify(const WXWPARAM WXUNUSED(wParam), const WXLPARAM WXUNUSED(lParam))
+{
+  return FALSE;
+}
+
+void wxWindow::PreDelete(const WXHDC WXUNUSED(dc))
+{
+}
+
+WXHWND wxWindow::GetHWND(void) const
+{
+  return (WXHWND) m_hWnd;
+}
+
+void wxWindow::SetHWND(WXHWND hWnd)
+{
+	m_hWnd = hWnd;
+}
+
+// Constructor
+wxWindow::wxWindow(void)
+{
+  // Generic
+  m_windowId = 0;
+  m_isShown = TRUE;
+  m_windowStyle = 0;
+  m_windowParent = NULL;
+  m_windowEventHandler = this;
+  m_windowName = "";
+  m_windowCursor = *wxSTANDARD_CURSOR;
+  m_children = new wxList;
+  m_doubleClickAllowed = 0 ;
+  m_winCaptured = FALSE;
+  m_constraints = NULL;
+  m_constraintsInvolvedIn = NULL;
+  m_windowSizer = NULL;
+  m_sizerParent = NULL;
+  m_autoLayout = FALSE;
+  m_windowValidator = NULL;
+
+  // MSW-specific
+  m_hWnd = 0;
+  m_winEnabled = TRUE;
+  m_caretWidth = 0; m_caretHeight = 0;
+  m_caretEnabled = FALSE;
+  m_caretShown = FALSE;
+  m_inOnSize = FALSE;
+  m_minSizeX = -1;
+  m_minSizeY = -1;
+  m_maxSizeX = -1;
+  m_maxSizeY = -1;
+//  m_paintHDC = 0;
+//  m_tempHDC = 0;
+  m_isBeingDeleted = FALSE;
+  m_oldWndProc = 0;
+#ifndef __WIN32__
+  m_globalHandle = 0;
+#endif
+  m_useCtl3D = FALSE;
+
+  m_defaultItem = NULL;
+
+  wxSystemSettings settings;
+
+  m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ;
+  m_foregroundColour = *wxBLACK;
+  m_defaultForegroundColour = *wxBLACK ;
+  m_defaultBackgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ;
+
+/*
+    wxColour(GetRValue(GetSysColor(COLOR_WINDOW)),
+  	GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+*/
+
+  // wxWnd
+  m_lastMsg = 0;
+  m_lastWParam = 0;
+  m_lastLParam = 0;
+  m_acceleratorTable = 0;
+  m_hMenu = 0;
+
+  m_xThumbSize = 0;
+  m_yThumbSize = 0;
+  m_backgroundTransparent = FALSE;
+
+  m_lastXPos = (float)-1.0;
+  m_lastYPos = (float)-1.0;
+  m_lastEvent = -1;
+  m_returnCode = 0;
+
+#if  USE_DRAG_AND_DROP
+  m_pDropTarget = NULL;
+#endif
+}
+
+// Destructor
+wxWindow::~wxWindow(void)
+{
+  m_isBeingDeleted = TRUE;
+
+  // JACS - if behaviour is odd, restore this
+  // to the start of ~wxWindow. Vadim has changed
+  // it to nearer the end. Unsure of side-effects
+  // e.g. when deleting associated global data.
+  // Restore old Window proc, if required
+//  UnsubclassWin();
+
+	// Have to delete constraints/sizer FIRST otherwise
+	// sizers may try to look at deleted windows as they
+	// delete themselves.
+#if USE_CONSTRAINTS
+  DeleteRelatedConstraints();
+  if (m_constraints)
+  {
+    // This removes any dangling pointers to this window
+    // in other windows' constraintsInvolvedIn lists.
+    UnsetConstraints(m_constraints);
+    delete m_constraints;
+    m_constraints = NULL;
+  }
+  if (m_windowSizer)
+  {
+    delete m_windowSizer;
+    m_windowSizer = NULL;
+  }
+  // If this is a child of a sizer, remove self from parent
+  if (m_sizerParent)
+    m_sizerParent->RemoveChild((wxWindow *)this);
+#endif
+
+  // wxWnd
+  MSWDetachWindowMenu();
+
+  wxRemoveHandleAssociation(this);
+
+  // TODO for backward compatibility
+#if 0
+  // WX_CANVAS
+  if (m_windowDC)
+  {
+    HWND hWnd = (HWND) GetHWND();
+    HDC dc = ::GetDC(hWnd);
+    m_windowDC->SelectOldObjects (dc);
+    ReleaseDC(hWnd, dc);
+    delete m_windowDC;
+  }
+#endif
+
+  if (m_windowParent)
+    m_windowParent->RemoveChild(this);
+
+  DestroyChildren();
+
+  if (m_hWnd)
+    ::DestroyWindow((HWND)m_hWnd);
+  m_hWnd = 0;
+#ifndef __WIN32__
+  if (m_globalHandle)
+  {
+    GlobalFree((HGLOBAL) m_globalHandle);
+    m_globalHandle = 0;
+  }
+#endif
+
+  delete m_children;
+  m_children = NULL;
+
+  // Just in case the window has been Closed, but
+  // we're then deleting immediately: don't leave
+  // dangling pointers.
+  wxPendingDelete.DeleteObject(this);
+
+  // Just in case we've loaded a top-level window via
+  // wxWindow::LoadNativeDialog but we weren't a dialog
+  // class
+  wxTopLevelWindows.DeleteObject(this);
+
+//  if (GetFont() && GetFont()->Ok())
+//    GetFont()->ReleaseResource();
+
+  if ( m_windowValidator )
+	delete m_windowValidator;
+
+  // Restore old Window proc, if required 
+  // and remove hWnd <-> wxWindow association
+  UnsubclassWin();
+}
+
+// Destroy the window (delayed, if a managed window)
+bool wxWindow::Destroy(void)
+{
+    delete this;
+    return TRUE;
+}
+
+extern char wxCanvasClassName[];
+
+// Constructor
+bool wxWindow::Create(wxWindow *parent, const wxWindowID id,
+           const wxPoint& pos,
+           const wxSize& size,
+           const long style,
+           const wxString& name)
+{
+  // Generic
+  m_isBeingDeleted = FALSE;
+  m_windowId = 0;
+  m_isShown = TRUE;
+  m_windowStyle = 0;
+  m_windowParent = NULL;
+  m_windowEventHandler = this;
+//  m_windowFont = NULL;
+  // We don't wish internal (potentially transient) fonts to be found
+  // by FindOrCreate
+//  wxTheFontList->RemoveFont(& m_windowFont);
+  m_windowName = "";
+  m_windowCursor = *wxSTANDARD_CURSOR;
+  m_doubleClickAllowed = 0 ;
+  m_winCaptured = FALSE;
+  m_constraints = NULL;
+  m_constraintsInvolvedIn = NULL;
+  m_windowSizer = NULL;
+  m_sizerParent = NULL;
+  m_autoLayout = FALSE;
+  m_windowValidator = NULL;
+#if  USE_DRAG_AND_DROP
+  m_pDropTarget = NULL;
+#endif
+
+  // MSW-specific
+  m_hWnd = 0;
+  m_winEnabled = TRUE;
+  m_caretWidth = 0; m_caretHeight = 0;
+  m_caretEnabled = FALSE;
+  m_caretShown = FALSE;
+  m_inOnSize = FALSE;
+  m_minSizeX = -1;
+  m_minSizeY = -1;
+  m_maxSizeX = -1;
+  m_maxSizeY = -1;
+//  m_paintHDC = 0;
+//  m_tempHDC = 0;
+  m_oldWndProc = 0;
+#ifndef __WIN32__
+  m_globalHandle = 0;
+#endif
+  m_useCtl3D = FALSE;
+  m_defaultItem = NULL;
+  m_windowParent = NULL;
+//  m_windowDC = NULL;
+  m_mouseInWindow = FALSE;
+  if (!parent)
+    return FALSE;
+
+  if (parent) parent->AddChild(this);
+
+  // wxWnd
+  m_lastMsg = 0;
+  m_lastWParam = 0;
+  m_lastLParam = 0;
+  m_acceleratorTable = 0;
+  m_hMenu = 0;
+
+  m_xThumbSize = 0;
+  m_yThumbSize = 0;
+  m_backgroundTransparent = FALSE;
+
+  m_lastXPos = (float)-1.0;
+  m_lastYPos = (float)-1.0;
+  m_lastEvent = -1;
+  m_returnCode = 0;
+
+  SetName(name);
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  int x = pos.x;
+  int y = pos.y;
+  int width = size.x;
+  int height = size.y;
+
+  wxSystemSettings settings;
+
+  m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ;
+  m_foregroundColour = *wxBLACK;
+  m_defaultForegroundColour = *wxBLACK ;
+  m_defaultBackgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ;
+/*
+  m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
+  	GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
+*/
+
+  m_windowStyle = style;
+
+  DWORD msflags = 0;
+  if (style & wxBORDER)
+    msflags |= WS_BORDER;
+  if (style & wxTHICK_FRAME)
+    msflags |= WS_THICKFRAME;
+  // TODO: probably make WS_CLIPCHILDREN this a setting in wx/setup.h,
+  // to reduce flicker with the trade-off that groupboxes must paint in a solid
+  // colour (so your control order must be correct, and you can't easily draw a
+  // transparent group).
+  msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN;
+
+  bool want3D;
+  WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+  // Even with extended styles, need to combine with WS_BORDER
+  // for them to look right.
+  if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+    msflags |= WS_BORDER;
+
+  m_mouseInWindow = FALSE ;
+
+  if ( id == -1 )
+  	m_windowId = (int)NewControlId();
+  else
+	m_windowId = id;
+
+  MSWCreate(m_windowId, (wxWindow *)parent, wxCanvasClassName, this, NULL, x, y, width, height, msflags,
+    NULL, exStyle);
+
+  return TRUE;
+}
+
+void wxWindow::SetFocus(void)
+{
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    ::SetFocus(hWnd);
+}
+
+void wxWindow::Enable(const bool enable)
+{
+  m_winEnabled = enable;
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    ::EnableWindow(hWnd, (BOOL)enable);
+}
+
+void wxWindow::CaptureMouse(void)
+{
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd && !m_winCaptured)
+  {
+    SetCapture(hWnd);
+    m_winCaptured = TRUE;
+  }
+}
+
+void wxWindow::ReleaseMouse(void)
+{
+  if (m_winCaptured)
+  {
+    ReleaseCapture();
+    m_winCaptured = FALSE;
+  }
+}
+
+// Push/pop event handler (i.e. allow a chain of event handlers
+// be searched)
+void wxWindow::PushEventHandler(wxEvtHandler *handler)
+{
+	handler->SetNextHandler(GetEventHandler());
+	SetEventHandler(handler);
+}
+
+wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
+{
+	if ( GetEventHandler() )
+	{
+		wxEvtHandler *handlerA = GetEventHandler();
+		wxEvtHandler *handlerB = handlerA->GetNextHandler();
+		handlerA->SetNextHandler(NULL);
+		SetEventHandler(handlerB);
+		if ( deleteHandler )
+		{
+			delete handlerA;
+			return NULL;
+		}
+		else
+			return handlerA;
+	}
+	else
+		return NULL;
+}
+
+#if    USE_DRAG_AND_DROP
+
+void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
+{
+  DELETEP(m_pDropTarget);
+  m_pDropTarget = pDropTarget;
+  if ( m_pDropTarget != 0 )
+    m_pDropTarget->Register(m_hWnd);
+}
+
+#endif
+
+//old style file-manager drag&drop support
+// I think we should retain the old-style
+// DragAcceptFiles in parallel with SetDropTarget.
+// JACS
+void wxWindow::DragAcceptFiles(const bool accept)
+{
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    ::DragAcceptFiles(hWnd, (BOOL)accept);
+}
+
+// Get total size
+void wxWindow::GetSize(int *x, int *y) const
+{
+  HWND hWnd = (HWND) GetHWND();
+  RECT rect;
+  GetWindowRect(hWnd, &rect);
+  *x = rect.right - rect.left;
+  *y = rect.bottom - rect.top;
+}
+
+void wxWindow::GetPosition(int *x, int *y) const
+{
+  HWND hWnd = (HWND) GetHWND();
+  HWND hParentWnd = 0;
+  if (GetParent())
+    hParentWnd = (HWND) GetParent()->GetHWND();
+  
+  RECT rect;
+  GetWindowRect(hWnd, &rect);
+
+  // Since we now have the absolute screen coords,
+  // if there's a parent we must subtract its top left corner
+  POINT point;
+  point.x = rect.left;
+  point.y = rect.top;
+  if (hParentWnd)
+  {
+    ::ScreenToClient(hParentWnd, &point);
+  }
+  *x = point.x;
+  *y = point.y;
+}
+
+void wxWindow::ScreenToClient(int *x, int *y) const
+{
+  HWND hWnd = (HWND) GetHWND();
+  POINT pt;
+  pt.x = *x;
+  pt.y = *y;
+  ::ScreenToClient(hWnd, &pt);
+
+  *x = pt.x;
+  *y = pt.y;
+}
+
+void wxWindow::ClientToScreen(int *x, int *y) const
+{
+  HWND hWnd = (HWND) GetHWND();
+  POINT pt;
+  pt.x = *x;
+  pt.y = *y;
+  ::ClientToScreen(hWnd, &pt);
+
+  *x = pt.x;
+  *y = pt.y;
+}
+
+void wxWindow::SetCursor(const wxCursor& cursor)
+{
+  m_windowCursor = cursor;
+  if (m_windowCursor.Ok())
+  {
+    HWND hWnd = (HWND) GetHWND();
+
+    // Change the cursor NOW if we're within the correct window
+    POINT point;
+    ::GetCursorPos(&point);
+
+    RECT rect;
+    ::GetWindowRect(hWnd, &rect);
+
+    if (::PtInRect(&rect, point) && !wxIsBusy())
+      ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR());
+  }
+
+  // This will cause big reentrancy problems if wxFlushEvents is implemented.
+//  wxFlushEvents();
+//  return old_cursor;
+}
+
+
+// Get size *available for subwindows* i.e. excluding menu bar etc.
+// For XView, this is the same as GetSize
+void wxWindow::GetClientSize(int *x, int *y) const
+{
+  HWND hWnd = (HWND) GetHWND();
+  RECT rect;
+  GetClientRect(hWnd, &rect);
+  *x = rect.right;
+  *y = rect.bottom;
+}
+
+void wxWindow::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+{
+  int currentX, currentY;
+  GetPosition(&currentX, &currentY);
+  int actualWidth = width;
+  int actualHeight = height;
+  int actualX = x;
+  int actualY = y;
+  if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    actualX = currentX;
+  if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    actualY = currentY;
+
+  int currentW,currentH;
+  GetSize(&currentW, &currentH);
+  if (width == -1)
+    actualWidth = currentW ;
+  if (height == -1)
+    actualHeight = currentH ;
+
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    MoveWindow(hWnd, actualX, actualY, actualWidth, actualHeight, (BOOL)TRUE);
+
+/* Not needed? should be called anyway via MoveWindow
+  if (!(width == -1) && (height == -1))
+  {
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+  }
+*/
+}
+
+void wxWindow::SetClientSize(const int width, const int height)
+{
+  wxWindow *parent = GetParent();
+  HWND hWnd = (HWND) GetHWND();
+  HWND hParentWnd = (HWND) (HWND) parent->GetHWND();
+
+  RECT rect;
+  GetClientRect(hWnd, &rect);
+
+  RECT rect2;
+  GetWindowRect(hWnd, &rect2);
+
+  // Find the difference between the entire window (title bar and all)
+  // and the client area; add this to the new client size to move the
+  // window
+  int actual_width = rect2.right - rect2.left - rect.right + width;
+  int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
+
+  // If there's a parent, must subtract the parent's top left corner
+  // since MoveWindow moves relative to the parent
+
+  POINT point;
+  point.x = rect2.left;
+  point.y = rect2.top;
+  if (parent)
+  {
+    ::ScreenToClient(hParentWnd, &point);
+  }
+
+  MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(width, height);
+#else
+  wxSizeEvent event(wxSize(width, height), m_windowId);
+  event.m_eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+}
+
+bool wxWindow::Show(const bool show)
+{
+  HWND hWnd = (HWND) GetHWND();
+  int cshow;
+  if (show)
+    cshow = SW_SHOW;
+  else
+    cshow = SW_HIDE;
+  ShowWindow(hWnd, (BOOL)cshow);
+  if (show)
+  {
+    BringWindowToTop(hWnd);
+    // Next line causes a crash on NT, apparently.
+//    UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
+  }
+  return TRUE;
+}
+
+bool wxWindow::IsShown(void) const
+{
+  return (::IsWindowVisible((HWND) GetHWND()) != 0);
+}
+
+int wxWindow::GetCharHeight(void) const
+{
+  TEXTMETRIC lpTextMetric;
+  HWND hWnd = (HWND) GetHWND();
+  HDC dc = ::GetDC(hWnd);
+
+  GetTextMetrics(dc, &lpTextMetric);
+  ::ReleaseDC(hWnd, dc);
+
+  return lpTextMetric.tmHeight;
+}
+
+int wxWindow::GetCharWidth(void) const
+{
+  TEXTMETRIC lpTextMetric;
+  HWND hWnd = (HWND) GetHWND();
+  HDC dc = ::GetDC(hWnd);
+
+  GetTextMetrics(dc, &lpTextMetric);
+  ::ReleaseDC(hWnd, dc);
+
+  return lpTextMetric.tmAveCharWidth;
+}
+
+void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
+                           int *descent, int *externalLeading, const wxFont *theFont, const bool) const
+{
+  wxFont *fontToUse = (wxFont *)theFont;
+  if (!fontToUse)
+    fontToUse = (wxFont *) & m_windowFont;
+
+  HWND hWnd = (HWND) GetHWND();
+  HDC dc = ::GetDC(hWnd);
+
+  HFONT fnt = 0; 
+  HFONT was = 0;
+  if (fontToUse && fontToUse->Ok())
+  {
+//    fontToUse->UseResource();
+    
+//    fontToUse->RealizeResource();
+    if ((fnt=(HFONT) fontToUse->GetResourceHandle()))
+      was = SelectObject(dc,fnt) ;
+  }
+
+  SIZE sizeRect;
+  TEXTMETRIC tm;
+  GetTextExtentPoint(dc, (const char *)string, (int)string.Length(), &sizeRect);
+  GetTextMetrics(dc, &tm);
+
+  if (fontToUse && fnt && was) 
+    SelectObject(dc,was) ; 
+
+  ReleaseDC(hWnd, dc);
+
+  *x = sizeRect.cx;
+  *y = sizeRect.cy;
+  if (descent) *descent = tm.tmDescent;
+  if (externalLeading) *externalLeading = tm.tmExternalLeading;
+
+//  if (fontToUse)
+//    fontToUse->ReleaseResource();
+}
+
+#if WXWIN_COMPATIBILITY
+void wxWindow::GetTextExtent(const wxString& string, float *x, float *y,
+                             float *descent,
+                             float *externalLeading,
+                             const wxFont *theFont, const bool use16) const
+  {
+    int x1, y1, descent1, externalLeading1;
+    GetTextExtent(string, &x1, &y1, &descent1, &externalLeading1, theFont, use16);
+    *x = x1; *y = y1;
+    if ( descent )
+        *descent = descent1;
+    if ( externalLeading )
+        *externalLeading = externalLeading1;
+  }
+#endif
+
+void wxWindow::Refresh(const bool eraseBack, const wxRectangle *rect)
+{
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+  {
+    if (rect)
+    {
+      RECT mswRect;
+      mswRect.left = rect->x;
+      mswRect.top = rect->y;
+      mswRect.right = rect->x + rect->width;
+      mswRect.bottom = rect->y + rect->height;
+      
+      ::InvalidateRect(hWnd, &mswRect, eraseBack);
+    }
+    else
+      ::InvalidateRect(hWnd, NULL, eraseBack);
+  }
+}
+
+// TODO: Are these really necessary now?
+/*
+WXHDC wxWindow::GetHDC(void) const
+{
+  wxWindow *nonConst = (wxWindow *)this;
+  if (m_paintHDC)
+    return(m_paintHDC) ;
+  nonConst->m_tempHDC = (WXHDC) ::GetDC((HWND) GetHWND()) ;
+  return(m_tempHDC) ;
+}
+
+void wxWindow::ReleaseHDC(void)
+{
+  // We're within an OnPaint: it'll be released.
+  if (m_paintHDC)
+    return ;
+
+  ::ReleaseDC((HWND) GetHWND(),(HDC) m_tempHDC) ;
+}
+*/
+
+// Hook for new window just as it's being created,
+// when the window isn't yet associated with the handle
+wxWindow *wxWndHook = NULL;
+
+/*
+#if HAVE_SOCKET
+// DDE Interface Handler
+extern	"C" {
+  long	ddeWindowProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam);
+  void __ddeUnblock(HWND hWnd, WPARAM wParam);
+};
+#endif
+*/
+
+// Main Windows 3 window proc
+LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+  wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
+
+  if (!wnd && wxWndHook)
+  {
+	wxAssociateWinWithHandle(hWnd, wxWndHook);
+    wnd = wxWndHook;
+	wxWndHook = NULL;
+    wnd->m_hWnd = (WXHWND) hWnd;
+  }
+#if (DEBUG > 1)
+  wxDebugMsg("hWnd = %d, m_hWnd = %d, msg = %d\n", hWnd, m_hWnd, message);
+#endif
+  // Stop right here if we don't have a valid handle
+  // in our wxWnd object.
+  if (wnd && !wnd->m_hWnd) {
+//    wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n");
+    wnd->m_hWnd = (WXHWND) hWnd;
+    long res = wnd->MSWDefWindowProc(message, wParam, lParam );
+    wnd->m_hWnd = 0;
+    return res;
+  }
+
+  if (wnd) {
+    wnd->m_lastMsg = message;
+    wnd->m_lastWParam = wParam;
+    wnd->m_lastLParam = lParam;
+/* Don't know why this was here
+    if (message == WM_SETFONT)
+      return 0;
+    else if (message == WM_INITDIALOG)
+      return TRUE;
+*/
+  }
+  if (wnd)
+    return wnd->MSWWindowProc(message, wParam, lParam);
+  else
+    return DefWindowProc( hWnd, message, wParam, lParam );
+}
+
+// Should probably have a test for 'genuine' NT
+#if defined(__WIN32__)
+#define DIMENSION_TYPE short
+#else
+#define DIMENSION_TYPE int
+#endif
+
+// Main Windows 3 window proc
+long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+#if 0
+  switch (message)
+  {
+        case WM_INITDIALOG:
+        case WM_ACTIVATE:
+        case WM_SETFOCUS:
+        case WM_KILLFOCUS:
+	case WM_CREATE:
+	case WM_PAINT:
+	case WM_QUERYDRAGICON:
+        case WM_SIZE:
+        case WM_RBUTTONDOWN:
+        case WM_RBUTTONUP:
+        case WM_RBUTTONDBLCLK:
+        case WM_MBUTTONDOWN:
+        case WM_MBUTTONUP:
+        case WM_MBUTTONDBLCLK:
+        case WM_LBUTTONDOWN:
+        case WM_LBUTTONUP:
+        case WM_LBUTTONDBLCLK:
+        case WM_MOUSEMOVE:
+//        case WM_DESTROY:
+        case WM_COMMAND:
+        case WM_NOTIFY:
+        case WM_MENUSELECT:
+        case WM_INITMENUPOPUP:
+        case WM_DRAWITEM:
+        case WM_MEASUREITEM:
+        case WM_KEYDOWN:
+        case WM_KEYUP:
+        case WM_CHAR: // Always an ASCII character
+        case WM_HSCROLL:
+        case WM_VSCROLL:
+        case WM_CTLCOLORBTN:
+        case WM_CTLCOLORDLG:
+        case WM_CTLCOLORLISTBOX:
+        case WM_CTLCOLORMSGBOX:
+        case WM_CTLCOLORSCROLLBAR:
+        case WM_CTLCOLORSTATIC:
+        case WM_CTLCOLOREDIT:
+        case WM_SYSCOLORCHANGE:
+        case WM_ERASEBKGND:
+        case WM_MDIACTIVATE:
+        case WM_DROPFILES:
+        case WM_QUERYENDSESSION:
+//        case WM_CLOSE:
+        case WM_GETMINMAXINFO:
+            return MSWDefWindowProc(message, wParam, lParam );
+    }
+#endif
+
+
+  HWND hWnd = (HWND)m_hWnd;
+
+  switch (message)
+  {
+/*
+        case WM_SETFONT:
+        {
+          return 0;
+        }
+*/
+        case WM_ACTIVATE:
+        {
+#ifdef __WIN32__
+            WORD state = LOWORD(wParam);
+            WORD minimized = HIWORD(wParam);
+            HWND hwnd = (HWND)lParam;
+#else
+            WORD state = (WORD)wParam;
+            WORD minimized = LOWORD(lParam);
+            HWND hwnd = (HWND)HIWORD(lParam);
+#endif
+            MSWOnActivate(state, (minimized != 0), (WXHWND) hwnd);
+            return 0;
+            break;
+        }
+        case WM_SETFOCUS:
+        {
+            HWND hwnd = (HWND)wParam;
+//            return OnSetFocus(hwnd);
+
+            if (MSWOnSetFocus((WXHWND) hwnd))
+              return 0;
+            else return MSWDefWindowProc(message, wParam, lParam );
+            break;
+        }
+        case WM_KILLFOCUS:
+        {
+            HWND hwnd = (HWND)lParam;
+//            return OnKillFocus(hwnd);
+            if (MSWOnKillFocus((WXHWND) hwnd))
+              return 0;
+            else
+              return MSWDefWindowProc(message, wParam, lParam );
+            break;
+        }
+	case WM_CREATE:
+	{
+          MSWOnCreate((WXLPCREATESTRUCT) (LPCREATESTRUCT)lParam);
+          return 0;
+          break;
+	}
+	case WM_SHOWWINDOW:
+	{
+          MSWOnShow((wParam != 0), (int) lParam);
+          break;
+	}
+	case WM_PAINT:
+	{
+          if (MSWOnPaint())
+            return 0;
+          else return MSWDefWindowProc(message, wParam, lParam );
+          break;
+        }
+	case WM_QUERYDRAGICON:
+	{
+	  HICON hIcon = 0;
+          if ((hIcon = (HICON) MSWOnQueryDragIcon()))
+            return (long)hIcon;
+          else return MSWDefWindowProc(message, wParam, lParam );
+          break;
+        }
+
+        case WM_SIZE:
+        {
+          int width = LOWORD(lParam);
+          int height = HIWORD(lParam);
+          MSWOnSize(width, height, wParam);
+          break;
+        }
+
+        case WM_WINDOWPOSCHANGING:
+        {
+          WINDOWPOS *pos = (WINDOWPOS *)lParam;
+          MSWOnWindowPosChanging((void *)pos);
+          break;
+        }
+
+        case WM_RBUTTONDOWN:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnRButtonDown(x, y, wParam);
+            break;
+        }
+        case WM_RBUTTONUP:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnRButtonUp(x, y, wParam);
+            break;
+        }
+        case WM_RBUTTONDBLCLK:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnRButtonDClick(x, y, wParam);
+            break;
+        }
+        case WM_MBUTTONDOWN:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnMButtonDown(x, y, wParam);
+            break;
+        }
+        case WM_MBUTTONUP:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnMButtonUp(x, y, wParam);
+            break;
+        }
+        case WM_MBUTTONDBLCLK:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnMButtonDClick(x, y, wParam);
+            break;
+        }
+        case WM_LBUTTONDOWN:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnLButtonDown(x, y, wParam);
+            break;
+        }
+        case WM_LBUTTONUP:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnLButtonUp(x, y, wParam);
+            break;
+        }
+        case WM_LBUTTONDBLCLK:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnLButtonDClick(x, y, wParam);
+            break;
+        }
+        case WM_MOUSEMOVE:
+        {
+            int x = (DIMENSION_TYPE) LOWORD(lParam);
+            int y = (DIMENSION_TYPE) HIWORD(lParam);
+            MSWOnMouseMove(x, y, wParam);
+            break;
+        }
+        case MM_JOY1BUTTONDOWN:
+        {
+            int x = LOWORD(lParam);
+            int y = HIWORD(lParam);
+            MSWOnJoyDown(wxJOYSTICK1, x, y, wParam);
+            break;
+        }
+        case MM_JOY2BUTTONDOWN:
+        {
+            int x = LOWORD(lParam);
+            int y = HIWORD(lParam);
+            MSWOnJoyDown(wxJOYSTICK2, x, y, wParam);
+            break;
+        }
+        case MM_JOY1BUTTONUP:
+        {
+            int x = LOWORD(lParam);
+            int y = HIWORD(lParam);
+            MSWOnJoyUp(wxJOYSTICK1, x, y, wParam);
+            break;
+        }
+        case MM_JOY2BUTTONUP:
+        {
+            int x = LOWORD(lParam);
+            int y = HIWORD(lParam);
+            MSWOnJoyUp(wxJOYSTICK2, x, y, wParam);
+            break;
+        }
+        case MM_JOY1MOVE:
+        {
+            int x = LOWORD(lParam);
+            int y = HIWORD(lParam);
+            MSWOnJoyMove(wxJOYSTICK1, x, y, wParam);
+            break;
+        }
+        case MM_JOY2MOVE:
+        {
+            int x = LOWORD(lParam);
+            int y = HIWORD(lParam);
+            MSWOnJoyMove(wxJOYSTICK2, x, y, wParam);
+            break;
+        }
+        case MM_JOY1ZMOVE:
+        {
+            int z = LOWORD(lParam);
+            MSWOnJoyZMove(wxJOYSTICK1, z, wParam);
+            break;
+        }
+        case MM_JOY2ZMOVE:
+        {
+            int z = LOWORD(lParam);
+            MSWOnJoyZMove(wxJOYSTICK2, z, wParam);
+            break;
+        }
+        case WM_DESTROY:
+        {
+          if (MSWOnDestroy())
+            return 0;
+          else return MSWDefWindowProc(message, wParam, lParam );
+          break;
+        }
+        case WM_SYSCOMMAND:
+        {
+            return MSWOnSysCommand(wParam, lParam);
+            break;
+        }
+        case WM_COMMAND:
+	{
+#ifdef __WIN32__
+            WORD id = LOWORD(wParam);
+            HWND hwnd = (HWND)lParam;
+            WORD cmd = HIWORD(wParam);
+#else
+            WORD id = (WORD)wParam;
+            HWND hwnd = (HWND)LOWORD(lParam) ;
+            WORD cmd = HIWORD(lParam);
+#endif
+            if (!MSWOnCommand(id, cmd, (WXHWND) hwnd))
+              return MSWDefWindowProc(message, wParam, lParam );
+            break;
+	 }
+#if defined(__WIN95__)
+        case WM_NOTIFY:
+	{
+          if (!MSWOnNotify(wParam, lParam))
+            return MSWDefWindowProc(message, wParam, lParam );
+          break;
+        }
+#endif
+        case WM_MENUSELECT:
+        {
+#ifdef __WIN32__
+            WORD flags = HIWORD(wParam);
+            HMENU sysmenu = (HMENU)lParam;
+#else
+            WORD flags = LOWORD(lParam);
+            HMENU sysmenu = (HMENU)HIWORD(lParam);
+#endif
+            MSWOnMenuHighlight((WORD)wParam, flags, (WXHMENU) sysmenu);
+            break;
+        }
+        case WM_INITMENUPOPUP:
+        {
+            MSWOnInitMenuPopup((WXHMENU) (HMENU)wParam, (int)LOWORD(lParam), (HIWORD(lParam) != 0));
+            break;
+        }
+        case WM_DRAWITEM:
+        {
+          return MSWOnDrawItem((int)wParam, (WXDRAWITEMSTRUCT *)lParam);
+          break;
+        }
+        case WM_MEASUREITEM:
+        {
+          return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam);
+          break;
+        }
+        case WM_KEYDOWN:
+        {
+//            return Default();
+
+            if (wParam == VK_SHIFT)
+            	return Default();
+
+            else if (wParam == VK_CONTROL)
+            	return Default();
+
+            // Avoid duplicate messages to OnChar
+            else if ((wParam != VK_ESCAPE) && (wParam != VK_SPACE) && (wParam != VK_RETURN) && (wParam != VK_BACK) && (wParam != VK_TAB))
+	    	{
+              MSWOnChar((WORD)wParam, lParam);
+              if (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE)
+			    return Default();
+	    	}
+			else
+				return Default();
+            break;
+        }
+        case WM_KEYUP:
+        {
+/*
+            if (wParam == VK_SHIFT)
+              wxShiftDown = FALSE;
+            else if (wParam == VK_CONTROL)
+              wxControlDown = FALSE;
+*/
+            break;
+        }
+        case WM_CHAR: // Always an ASCII character
+        {
+          MSWOnChar((WORD)wParam, lParam, TRUE);
+          break;
+        }
+        case WM_HSCROLL:
+        {
+#ifdef __WIN32__
+            WORD code = LOWORD(wParam);
+            WORD pos = HIWORD(wParam);
+            HWND control = (HWND)lParam;
+#else
+            WORD code = (WORD)wParam;
+            WORD pos = LOWORD(lParam);
+            HWND control = (HWND)HIWORD(lParam);
+#endif
+            MSWOnHScroll(code, pos, (WXHWND) control);
+            break;
+        }
+        case WM_VSCROLL:
+        {
+#ifdef __WIN32__
+            WORD code = LOWORD(wParam);
+            WORD pos = HIWORD(wParam);
+            HWND control = (HWND)lParam;
+#else
+            WORD code = (WORD)wParam;
+            WORD pos = LOWORD(lParam);
+            HWND control = (HWND)HIWORD(lParam);
+#endif
+            MSWOnVScroll(code, pos, (WXHWND) control);
+            break;
+        }
+#ifdef __WIN32__
+        case WM_CTLCOLORBTN:
+	{
+          int nCtlColor = CTLCOLOR_BTN;
+          HWND control = (HWND)lParam;
+          HDC pDC = (HDC)wParam;
+          return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
+                                        message, wParam, lParam);
+          break;
+	}
+        case WM_CTLCOLORDLG:
+	{
+          int nCtlColor = CTLCOLOR_DLG;
+          HWND control = (HWND)lParam;
+          HDC pDC = (HDC)wParam;
+          return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
+                                        message, wParam, lParam);\
+          break;
+	}
+        case WM_CTLCOLORLISTBOX:
+	{
+          int nCtlColor = CTLCOLOR_LISTBOX;
+          HWND control = (HWND)lParam;
+          HDC pDC = (HDC)wParam;
+          return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
+                                        message, wParam, lParam);
+          break;
+	}
+        case WM_CTLCOLORMSGBOX:
+	{
+          int nCtlColor = CTLCOLOR_MSGBOX;
+          HWND control = (HWND)lParam;
+          HDC pDC = (HDC)wParam;
+          return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
+                                        message, wParam, lParam);
+          break;
+	}
+        case WM_CTLCOLORSCROLLBAR:
+	{
+          int nCtlColor = CTLCOLOR_SCROLLBAR;
+          HWND control = (HWND)lParam;
+          HDC pDC = (HDC)wParam;
+          return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
+                                        message, wParam, lParam);
+          break;
+	}
+        case WM_CTLCOLORSTATIC:
+	{
+          int nCtlColor = CTLCOLOR_STATIC;
+          HWND control = (HWND)lParam;
+          HDC pDC = (HDC)wParam;
+          return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
+                                        message, wParam, lParam);
+          break;
+	}
+        case WM_CTLCOLOREDIT:
+	{
+          int nCtlColor = CTLCOLOR_EDIT;
+          HWND control = (HWND)lParam;
+          HDC pDC = (HDC)wParam;
+          return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
+                                        message, wParam, lParam);
+          break;
+	}
+#else
+        case WM_CTLCOLOR:
+        {
+          HWND control = (HWND)LOWORD(lParam);
+          int nCtlColor = (int)HIWORD(lParam);
+          HDC pDC = (HDC)wParam;
+          return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
+                                        message, wParam, lParam);
+          break;
+        }
+#endif
+        case WM_SYSCOLORCHANGE:
+        {
+          // Return value of 0 means, we processed it.
+          if (MSWOnColorChange((WXHWND) hWnd, message, wParam, lParam) == 0)
+            return 0;
+          else
+            return MSWDefWindowProc(message, wParam, lParam );
+          break;
+        }
+        case WM_ERASEBKGND:
+        {
+          // Prevents flicker when dragging
+          if (IsIconic(hWnd)) return 1;
+
+          // EXPERIMENTAL
+//          return 1;
+          if (!MSWOnEraseBkgnd((WXHDC) (HDC)wParam))
+            return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
+          else return 1;
+          break;
+        }
+        case WM_MDIACTIVATE:
+        {
+#ifdef __WIN32__
+            HWND hWndActivate = GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam,lParam);
+            HWND hWndDeactivate = GET_WM_MDIACTIVATE_HWNDDEACT(wParam,lParam);
+            BOOL activate = GET_WM_MDIACTIVATE_FACTIVATE(hWnd,wParam,lParam);
+            return MSWOnMDIActivate((long) activate, (WXHWND) hWndActivate, (WXHWND) hWndDeactivate);
+#else
+            return MSWOnMDIActivate((BOOL)wParam, (HWND)LOWORD(lParam),
+                                               (HWND)HIWORD(lParam));
+#endif
+        }
+        case WM_DROPFILES:
+        {
+            MSWOnDropFiles(wParam);
+            break;
+		}
+        case WM_INITDIALOG:
+        {
+            return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
+            break;
+		}
+        case WM_QUERYENDSESSION:
+        {
+	    // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
+            return MSWOnClose();
+            break;
+        }
+        case WM_CLOSE:
+        {
+            if (MSWOnClose())
+              return 0L;
+            else
+              return 1L;
+            break;
+        }
+
+        case WM_GETMINMAXINFO:
+        {
+          MINMAXINFO *info = (MINMAXINFO *)lParam;
+          if (m_minSizeX != -1)
+           info->ptMinTrackSize.x = (int)m_minSizeX;
+          if (m_minSizeY != -1)
+           info->ptMinTrackSize.y = (int)m_minSizeY;
+          if (m_maxSizeX != -1)
+           info->ptMaxTrackSize.x = (int)m_maxSizeX;
+          if (m_maxSizeY != -1)
+           info->ptMaxTrackSize.y = (int)m_maxSizeY;
+          return MSWDefWindowProc(message, wParam, lParam );
+          break;
+        }
+
+/*
+#if HAVE_SOCKET
+        case WM_TIMER:
+	{
+          __ddeUnblock(hWnd, wParam);
+          break;
+	}
+
+ 	case ASYNC_SELECT_MESSAGE:
+ 	    return ddeWindowProc(hWnd,message,wParam,lParam);
+#endif
+*/
+
+        default:
+            return MSWDefWindowProc(message, wParam, lParam );
+    }
+    return 0; // Success: we processed this command.
+}
+
+// Dialog window proc
+LONG APIENTRY _EXPORT
+  wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+  return 0;
+}
+
+wxList *wxWinHandleList = NULL;
+wxWindow *wxFindWinFromHandle(WXHWND hWnd)
+{
+  wxNode *node = wxWinHandleList->Find((long)hWnd);
+  if (!node)
+    return NULL;
+  return (wxWindow *)node->Data();
+}
+
+void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
+{
+  if ( !wxWinHandleList->Find((long)hWnd) )
+    wxWinHandleList->Append((long)hWnd, win);
+}
+
+void wxRemoveHandleAssociation(wxWindow *win)
+{
+  wxWinHandleList->DeleteObject(win);
+}
+
+// Default destroyer - override if you destroy it in some other way
+// (e.g. with MDI child windows)
+void wxWindow::MSWDestroyWindow(void)
+{
+#if 0
+
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWDestroyWindow %d\n", handle);
+#endif
+  MSWDetachWindowMenu();
+//  SetWindowLong(handle, 0, (long)0);
+  HWND oldHandle = handle;
+  handle = NULL;
+
+  ::DestroyWindow(oldHandle);
+
+  // Menu is destroyed explicitly by wxMDIChild::DestroyWindow,
+  // or when Windows HWND is deleted if MDI parent or
+  // SDI frame.
+/*
+  if (m_hMenu)
+  {
+    ::DestroyMenu(m_hMenu);
+    m_hMenu = 0;
+  }
+ */
+#endif
+}
+
+void wxWindow::MSWCreate(const int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title,
+                    const int x, const int y, const int width, const int height,
+                    const WXDWORD style, const char *dialog_template, const WXDWORD extendedStyle)
+{
+  bool is_dialog = (dialog_template != NULL);
+  int x1 = CW_USEDEFAULT;
+  int y1 = 0;
+  int width1 = CW_USEDEFAULT;
+  int height1 = 100;
+
+  // Find parent's size, if it exists, to set up a possible default
+  // panel size the size of the parent window
+  RECT parent_rect;
+  if (parent)
+  {
+    // Was GetWindowRect: JACS 5/5/95
+    ::GetClientRect((HWND) parent->GetHWND(), &parent_rect);
+
+    width1 = parent_rect.right - parent_rect.left;
+    height1 = parent_rect.bottom - parent_rect.top;
+  }
+
+  if (x > -1) x1 = x;
+  if (y > -1) y1 = y;
+  if (width > -1) width1 = width;
+  if (height > -1) height1 = height;
+
+  HWND hParent = NULL;
+  if (parent)
+    hParent = (HWND) parent->GetHWND();
+
+  wxWndHook = this;
+
+  if (is_dialog)
+  {
+    // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
+    // other compilers???
+    // VZ: it's always needed for Win16 and never for Win32
+#ifdef __WIN32__
+    m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
+                            (DLGPROC)wxDlgProc);
+#else
+    DLGPROC dlgproc = (DLGPROC)MakeProcInstance((DLGPROC)wxWndProc, wxGetInstance());
+
+    m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
+                            (DLGPROC)dlgproc);
+#endif
+
+    if (m_hWnd == 0)
+       MessageBox(NULL, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
+                  "wxWindows Error", MB_ICONEXCLAMATION | MB_OK);
+    else MoveWindow((HWND) m_hWnd, x1, y1, width1, height1, FALSE);
+  }
+  else
+  {
+    int controlId = 0;
+    if (style & WS_CHILD)
+      controlId = id;
+    if (!title)
+      title = "";
+      
+    m_hWnd = (WXHWND) CreateWindowEx(extendedStyle, wclass,
+                title,
+                style,
+                x1, y1,
+                width1, height1,
+//                hParent, NULL, wxGetInstance(),
+                hParent, (HMENU)controlId, wxGetInstance(),
+                NULL);
+
+    if (m_hWnd == 0)
+    {
+       char buf[300];
+       sprintf(buf, "Can't create window of class %s! Weird.\nPossible Windows 3.x compatibility problem?",
+         wclass);
+       wxFatalError(buf,
+                  "Fatal wxWindows Error");
+    }
+  }
+  wxWndHook = NULL;
+  wxWinHandleList->Append((long)m_hWnd, this);
+
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWCreate %d\n", m_hWnd);
+#endif
+}
+
+void wxWindow::MSWOnCreate(WXLPCREATESTRUCT WXUNUSED(cs))
+{
+}
+
+bool wxWindow::MSWOnClose(void)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnClose %d\n", handle);
+#endif
+  return FALSE;
+}
+
+bool wxWindow::MSWOnDestroy(void)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnDestroy %d\n", handle);
+#endif
+  // delete our log target if we've got one
+#if USE_DRAG_AND_DROP
+    if ( m_pDropTarget != 0 ) {
+      m_pDropTarget->Revoke(m_hWnd);
+
+      delete m_pDropTarget;
+      m_pDropTarget = NULL;
+    }
+#endif
+
+  return TRUE;
+}
+
+// Deal with child commands from buttons etc.
+
+bool wxWindow::MSWOnNotify(const WXWPARAM wParam, const WXLPARAM lParam)
+{
+#if defined(__WIN95__)
+    // Find a child window to send the notification to, e.g. a toolbar.
+    // There's a problem here. NMHDR::hwndFrom doesn't give us the
+    // handle of the toolbar; it's probably the handle of the tooltip
+    // window (anyway, it's parent is also the toolbar's parent).
+    // So, since we don't know which hWnd or wxWindow originated the
+    // WM_NOTIFY, we'll need to go through all the children of this window
+    // trying out MSWNotify.
+	// This won't work now, though, because any number of controls
+	// could respond to the same generic messages :-(
+
+/* This doesn't work for toolbars, but try for other controls first.
+ */
+    NMHDR *hdr = (NMHDR *)lParam;
+    HWND hWnd = (HWND)hdr->hwndFrom;
+    wxWindow *win = wxFindWinFromHandle((WXHWND) hWnd);
+
+	if ( win )
+		return win->MSWNotify(wParam, lParam);
+	else
+	{
+		    // Rely on MSWNotify to check whether the message
+			// belongs to the window or not
+    		wxNode *node = GetChildren()->First();
+    		while (node)
+    		{
+      			wxWindow *child = (wxWindow *)node->Data();
+				if ( child->MSWNotify(wParam, lParam) )
+					return TRUE;
+				node = node->Next();
+    		}
+	}
+
+    return FALSE;
+
+#endif
+  return FALSE;
+}
+
+void wxWindow::MSWOnMenuHighlight(const WXWORD WXUNUSED(item), const WXWORD WXUNUSED(flags), const WXHMENU WXUNUSED(sysmenu))
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnMenuHighlight %d\n", handle);
+#endif
+}
+
+void wxWindow::MSWOnInitMenuPopup(const WXHMENU menu, const int pos, const bool isSystem)
+{
+  if (!isSystem)
+    OldOnInitMenuPopup(pos);
+}
+
+bool wxWindow::MSWOnActivate(const int state, const bool WXUNUSED(minimized), const WXHWND WXUNUSED(activate))
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnActivate %d\n", handle);
+#endif
+
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnActivate(((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)));
+#else
+  wxActivateEvent event(wxEVT_ACTIVATE, ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)),
+	  m_windowId);
+  event.m_eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+  return 0;
+}
+
+bool wxWindow::MSWOnSetFocus(const WXHWND WXUNUSED(hwnd))
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnSetFocus %d\n", m_hWnd);
+#endif
+    // Deal with caret
+    if (m_caretEnabled && (m_caretWidth > 0) && (m_caretHeight > 0))
+    {
+      ::CreateCaret((HWND) GetHWND(), NULL, m_caretWidth, m_caretHeight);
+      if (m_caretShown)
+        ::ShowCaret((HWND) GetHWND());
+    }
+
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSetFocus();
+#else
+  wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
+  event.m_eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+    return TRUE;
+}
+
+bool wxWindow::MSWOnKillFocus(const WXHWND WXUNUSED(hwnd))
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnKillFocus %d\n", m_hWnd);
+#endif
+    // Deal with caret
+    if (m_caretEnabled)
+    {
+      ::DestroyCaret();
+    }
+
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnKillFocus();
+#else
+  wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
+  event.m_eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+  return TRUE;
+}
+
+void wxWindow::MSWOnDropFiles(const WXWPARAM wParam)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnDropFiles %d\n", m_hWnd);
+#endif
+
+  HANDLE hFilesInfo = (HANDLE)wParam;
+  POINT dropPoint;
+  DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint);
+
+  // Get the total number of files dropped
+  WORD gwFilesDropped = (WORD)DragQueryFile ((HDROP)hFilesInfo,
+				   (UINT)-1,
+                                   (LPSTR)0,
+                                   (UINT)0);
+
+  wxString *files = new wxString[gwFilesDropped];
+  int wIndex;
+  for (wIndex=0; wIndex < (int)gwFilesDropped; wIndex++)
+  {
+    DragQueryFile (hFilesInfo, wIndex, (LPSTR) wxBuffer, 1000);
+    files[wIndex] = wxBuffer;
+  }
+  DragFinish (hFilesInfo);
+
+  wxDropFilesEvent event(wxEVT_DROP_FILES, gwFilesDropped, files);
+  event.m_eventObject = this;
+  event.m_pos.x = dropPoint.x; event.m_pos.x = dropPoint.y;
+
+  GetEventHandler()->ProcessEvent(event);
+
+  delete[] files;
+}
+
+bool wxWindow::MSWOnDrawItem(const int id, WXDRAWITEMSTRUCT *itemStruct)
+{
+#if USE_OWNER_DRAWN
+    if ( id == 0 ) {    // is it a menu item?
+      DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct;
+      wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData);
+      wxCHECK_RET( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
+
+      // prepare to call OnDrawItem()
+      wxDC dc;
+      dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE);
+      wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top,
+                  pDrawStruct->rcItem.right - pDrawStruct->rcItem.left, 
+                  pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top);
+      return pMenuItem->OnDrawItem(
+               dc, rect, 
+               (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction,
+               (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState
+             );
+    }
+#endif  // owner-drawn menus
+
+  wxWindow *item = FindItem(id);
+#if USE_DYNAMIC_CLASSES
+  if (item && item->IsKindOf(CLASSINFO(wxControl)))
+  {
+    return ((wxControl *)item)->MSWOnDraw(itemStruct);
+  }
+  else
+#endif
+    return FALSE;
+}
+
+bool wxWindow::MSWOnMeasureItem(const int id, WXMEASUREITEMSTRUCT *itemStruct)
+{
+#if USE_OWNER_DRAWN
+    if ( id == 0 ) {    // is it a menu item?
+      MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct;
+      wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
+      wxCHECK_RET( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
+
+      return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth, 
+                                      &pMeasureStruct->itemHeight);
+    }
+#endif  // owner-drawn menus
+
+  wxWindow *item = FindItem(id);
+#if USE_DYNAMIC_CLASSES
+  if (item && item->IsKindOf(CLASSINFO(wxControl)))
+  {
+    return ((wxControl *)item)->MSWOnMeasure(itemStruct);
+  }
+  else
+#endif
+    return FALSE;
+}
+
+WXHBRUSH wxWindow::MSWOnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+                         const WXUINT message, const WXWPARAM wParam, const WXLPARAM lParam)
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnCtlColour %d\n", m_hWnd);
+#endif
+  if (nCtlColor == CTLCOLOR_DLG)
+  {
+	return OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
+  }
+
+  wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE);
+
+  WXHBRUSH hBrush = 0;
+
+  if ( item )
+	hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
+
+  // I think that even for dialogs, we may need to call DefWindowProc (?)
+  // Or maybe just rely on the usual default behaviour.
+  if ( !hBrush )
+    hBrush = (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam);
+
+  return hBrush ;
+}
+
+// Define for each class of dialog and control
+WXHBRUSH wxWindow::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+			WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+    return (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam);
+}
+
+bool wxWindow::MSWOnColorChange(const WXHWND hWnd, const WXUINT message, const WXWPARAM wParam, const WXLPARAM lParam)
+{
+  wxSysColourChangedEvent event;
+  event.m_eventObject = this;
+
+  // Check if app handles this.
+  if (GetEventHandler()->ProcessEvent(event))
+    return 0;
+
+#if WXWIN_COMPATIBILITY
+  if (GetEventHandler()->OldOnSysColourChange())
+    return 0;
+#endif
+
+  // We didn't process it
+  return 1;
+}
+
+// Responds to colour changes: passes event on to children.
+void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
+{
+    wxNode *node = GetChildren()->First();
+    while ( node )
+    {
+        // Only propagate to non-top-level windows
+        wxWindow *win = (wxWindow *)node->Data();
+        if ( win->GetParent() )
+        {
+            wxSysColourChangedEvent event2;
+            event.m_eventObject = win;
+            win->GetEventHandler()->ProcessEvent(event2);
+        }
+
+        node = node->Next();
+    }
+}
+
+long wxWindow::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+  if ( m_oldWndProc )
+  	return ::CallWindowProc(CASTWNDPROC (FARPROC) m_oldWndProc, (HWND) GetHWND(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
+  else
+  	return ::DefWindowProc((HWND) GetHWND(), nMsg, wParam, lParam);
+}
+
+long wxWindow::Default()
+{
+  return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
+}
+
+bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
+{
+  if (!m_hWnd)
+    return FALSE;
+  else
+  {
+    // Suggestion by Andrew Davison to allow
+    // a panel to accept character input in user edit mode
+    
+    // OK, what we probably want to do here for wxWin 2.0
+    // is have a window style to indicate whether the window
+    // should process dialog-style input, since we can't
+    // otherwise tell whether it's supposed to do tab traversal
+    // or not.
+    if (GetWindowStyleFlag() & wxTAB_TRAVERSAL)
+      return (::IsDialogMessage((HWND) m_hWnd, (MSG *)pMsg) != 0);
+    else
+      return FALSE;
+  }
+}
+
+long wxWindow::MSWOnMDIActivate(const long WXUNUSED(flag), const WXHWND WXUNUSED(activate), const WXHWND WXUNUSED(deactivate))
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnMDIActivate %d\n", m_hWnd);
+#endif
+  return 1;
+}
+
+void wxWindow::MSWDetachWindowMenu(void)
+{
+  if (m_hMenu)
+  {
+    int N = GetMenuItemCount((HMENU) m_hMenu);
+    int i;
+    for (i = 0; i < N; i++)
+    {
+      char buf[100];
+      int chars = GetMenuString((HMENU) m_hMenu, i, buf, 100, MF_BYPOSITION);
+      if ((chars > 0) && (strcmp(buf, "&Window") == 0))
+      {
+        RemoveMenu((HMENU) m_hMenu, i, MF_BYPOSITION);
+        break;
+      }
+    }
+  }
+}
+
+bool wxWindow::MSWOnPaint(void)
+{
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnPaint();
+#else
+  wxPaintEvent event(m_windowId);
+  event.m_eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+  return TRUE;
+  
+#if 0
+
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnPaint %d\n", m_hWnd);
+#endif
+#ifdef __WIN32__
+  HRGN	tRgn=CreateRectRgn(0,0,0,0);	//Dummy call to get a handle!
+  if (GetUpdateRgn(m_hWnd, tRgn, FALSE))
+#else
+  RECT tRect;
+  if (GetUpdateRect((HWND) m_hWnd, &tRect, FALSE))
+#endif
+  {
+    PAINTSTRUCT ps;
+    // Hold a pointer to the dc so long as the OnPaint() message
+    // is being processed
+    HDC dc = BeginPaint(m_hWnd, &ps);
+    bool isPanel = IsKindOf(CLASSINFO(wxWindow));
+    m_paintHDC = (WXHDC) dc;
+    RECT updateRect1 = ps.rcPaint;
+	m_updateRect.x = updateRect1.left;
+	m_updateRect.y = updateRect1.top;
+	m_updateRect.width = updateRect1.right - updateRect1.left;
+	m_updateRect.height = updateRect1.bottom - updateRect1.top;
+
+    GetEventHandler()->OldOnPaint();
+
+    m_paintHDC = 0;
+    EndPaint((HWND) m_hWnd, &ps);
+#ifdef __WIN32__
+    DeleteObject(tRgn);
+#endif
+
+    if (isPanel)
+      // Do default processing
+      return FALSE;
+    else
+      return TRUE;
+  }
+#ifdef __WIN32__
+  DeleteObject(tRgn);
+#endif
+  return FALSE;
+#endif
+}
+
+void wxWindow::MSWOnSize(const int w, const int h, const WXUINT WXUNUSED(flag))
+{
+  if (m_inOnSize)
+    return;
+    
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnSize %d\n", m_hWnd);
+#endif
+  if (!m_hWnd)
+    return;
+
+  m_inOnSize = TRUE;
+
+#if WXWIN_COMPATIBILITY
+  GetEventHandler()->OldOnSize(w, h);
+#else
+  wxSizeEvent event(wxSize(w, h), m_windowId);
+  event.m_eventObject = this;
+  GetEventHandler()->ProcessEvent(event);
+#endif
+
+  m_inOnSize = FALSE;
+}
+
+void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos))
+{
+    Default();
+}
+
+// Deal with child commands from buttons etc.
+bool wxWindow::MSWOnCommand(const WXWORD id, const WXWORD cmd, const WXHWND WXUNUSED(control))
+{
+#if DEBUG > 1
+  wxDebugMsg("wxWindow::MSWOnCommand\n");
+#endif
+  if (wxCurrentPopupMenu)
+  {
+    wxMenu *popupMenu = wxCurrentPopupMenu;
+    wxCurrentPopupMenu = NULL;
+    bool succ = popupMenu->MSWCommand(cmd, id);
+    return succ;
+  }
+#if DEBUG > 1
+  char buf[80];
+  sprintf(buf, "Looking for item %d...\n", id);
+  wxDebugMsg(buf);
+#endif
+
+  wxWindow *item = FindItem(id);
+  if (item)
+  {
+    bool value = item->MSWCommand(cmd, id);
+#if DEBUG > 1
+    if (value)
+      wxDebugMsg("MSWCommand succeeded\n");
+    else
+      wxDebugMsg("MSWCommand failed\n");
+#endif
+    return value;
+  }
+  else
+  {
+#if DEBUG > 1
+    wxDebugMsg("Could not find item!\n");
+    char buf[100];
+    wxDebugMsg("Item ids for this panel:\n");
+
+    wxNode *current = GetChildren()->First();
+    while (current)
+    {
+      wxObject *obj = (wxObject *)current->Data() ;
+      if (obj->IsKindOf(CLASSINFO(wxControl)))
+      {
+        wxControl *item = (wxControl *)current->Data();
+        sprintf(buf, "  %d\n", (int)item->m_windowId);
+        wxDebugMsg(buf);
+      }
+      current = current->Next();  
+    }
+    wxYield();
+#endif
+    return FALSE;
+  }
+}
+
+long wxWindow::MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam)
+{
+    switch (wParam)
+    {
+        case SC_MAXIMIZE:
+        {
+            wxMaximizeEvent event(m_windowId);
+            event.SetEventObject(this);
+            if (!GetEventHandler()->ProcessEvent(event))
+                return Default();
+            else
+                return 0;
+            break;
+        }
+        case SC_MINIMIZE:
+        {
+            wxIconizeEvent event(m_windowId);
+            event.SetEventObject(this);
+            if (!GetEventHandler()->ProcessEvent(event))
+                return Default();
+            else
+                return 0;
+            break;
+        }
+        default:
+            return Default();
+    }
+    return 0;
+}
+
+void wxWindow::MSWOnLButtonDown(const int x, const int y, const WXUINT flags)
+{
+#if 0 // defined(__WIN32__) && !defined(WIN95)
+  // DClick not clean supported on Win3.1, except if someone know
+  // how to emulate Sleep()...
+  // This means that your app will receive Down-Up-Dclick sequences
+  // rather than Dclick
+  if (m_doubleClickAllowed)
+  {
+    UINT time = GetDoubleClickTime() ;
+    Sleep(time) ;
+    MSG dummy ;
+    if (PeekMessage(&dummy,m_hWnd,
+                    WM_LBUTTONDBLCLK,WM_LBUTTONDBLCLK,
+                    PM_NOREMOVE)
+       )
+    {
+      PeekMessage(&dummy,m_hWnd,WM_LBUTTONUP,WM_LBUTTONUP,PM_REMOVE);
+      return;
+    }
+  }
+#endif
+
+//wxDebugMsg("LButtonDown\n") ;
+  wxMouseEvent event(wxEVENT_TYPE_LEFT_DOWN);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_DOWN;
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnLButtonUp(const int x, const int y, const WXUINT flags)
+{
+//wxDebugMsg("LButtonUp\n") ;
+  wxMouseEvent event(wxEVENT_TYPE_LEFT_UP);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_UP;
+
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnLButtonDClick(const int x, const int y, const WXUINT flags)
+{
+//wxDebugMsg("LButtonDClick\n") ;
+  /* MATTHEW: If dclick not allowed, generate another single-click */
+  wxMouseEvent event(m_doubleClickAllowed ?
+		     wxEVENT_TYPE_LEFT_DCLICK : wxEVENT_TYPE_LEFT_DOWN);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON != 0));
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_DCLICK;
+
+//  if (m_doubleClickAllowed)
+     GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnMButtonDown(const int x, const int y, const WXUINT flags)
+{
+#if 0 // defined(__WIN32__) && !defined(__WIN95__)
+  // DClick not clean supported on Win3.1, except if someone know
+  // how to emulate Sleep()...
+  // This means that your app will receive Down-Up-Dclick sequences
+  // rather than Dclick
+  if (m_doubleClickAllowed)
+  {
+    UINT time = GetDoubleClickTime() ;
+    Sleep(time) ;
+    MSG dummy ;
+    if (PeekMessage(&dummy,m_hWnd,
+                    WM_MBUTTONDBLCLK,WM_MBUTTONDBLCLK,
+                    PM_NOREMOVE)
+       )
+    {
+      PeekMessage(&dummy,m_hWnd,WM_MBUTTONUP,WM_MBUTTONUP,PM_REMOVE);
+      return;
+    }
+  }
+#endif
+
+//wxDebugMsg("MButtonDown\n") ;
+  wxMouseEvent event(wxEVENT_TYPE_MIDDLE_DOWN);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_DOWN;
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnMButtonUp(const int x, const int y, const WXUINT flags)
+{
+//wxDebugMsg("MButtonUp\n") ;
+  wxMouseEvent event(wxEVENT_TYPE_MIDDLE_UP);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_UP;
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnMButtonDClick(const int x, const int y, const WXUINT flags)
+{
+//wxDebugMsg("MButtonDClick\n") ;
+  /* MATTHEW: If dclick not allowed, generate another single-click */
+  wxMouseEvent event((m_doubleClickAllowed) ?
+		     wxEVENT_TYPE_MIDDLE_DCLICK : wxEVENT_TYPE_MIDDLE_DOWN);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_DCLICK;
+//  if (m_doubleClickAllowed)
+     GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnRButtonDown(const int x, const int y, const WXUINT flags)
+{
+#if 0 // defined(__WIN32__) && !defined(__WIN95__)
+  // DClick not clean supported on Win3.1, except if someone know
+  // how to emulate Sleep()...
+  // This means that your app will receive Down-Up-Dclick sequences
+  // rather than Dclick
+  if (m_doubleClickAllowed)
+  {
+    UINT time = GetDoubleClickTime() ;
+    Sleep(time) ;
+    MSG dummy ;
+    if (PeekMessage(&dummy,m_hWnd,
+                    WM_RBUTTONDBLCLK,WM_RBUTTONDBLCLK,
+                    PM_NOREMOVE)
+       )
+    {
+      PeekMessage(&dummy,m_hWnd,WM_RBUTTONUP,WM_RBUTTONUP,PM_REMOVE);
+      return;
+    }
+  }
+#endif
+
+//wxDebugMsg("RButtonDown\n") ;
+  wxMouseEvent event(wxEVENT_TYPE_RIGHT_DOWN);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_RIGHT_DOWN;
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnRButtonUp(const int x, const int y, const WXUINT flags)
+{
+//wxDebugMsg("RButtonUp\n") ;
+  wxMouseEvent event(wxEVENT_TYPE_RIGHT_UP);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.m_eventObject = this;
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_RIGHT_UP;
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnRButtonDClick(const int x, const int y, const WXUINT flags)
+{
+//wxDebugMsg("RButtonDClick\n") ;
+  /* MATTHEW: If dclick not allowed, generate another single-click */
+  wxMouseEvent event((m_doubleClickAllowed) ?
+		     wxEVENT_TYPE_RIGHT_DCLICK : wxEVENT_TYPE_RIGHT_DOWN);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_RIGHT_DCLICK;
+//  if (m_doubleClickAllowed)
+     GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnMouseMove(const int x, const int y, const WXUINT flags)
+{
+  // 'normal' move event...
+  // Set cursor, but only if we're not in 'busy' mode
+  
+  // Trouble with this is that it sets the cursor for controls too :-(
+  if (m_windowCursor.Ok() && !wxIsBusy())
+    ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR());
+
+  wxMouseEvent event(wxEVENT_TYPE_MOTION);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  // Window gets a click down message followed by a mouse move
+  // message even if position isn't changed!  We want to discard
+  // the trailing move event if x and y are the same.
+  if ((m_lastEvent == wxEVENT_TYPE_RIGHT_DOWN || m_lastEvent == wxEVENT_TYPE_LEFT_DOWN ||
+       m_lastEvent == wxEVENT_TYPE_MIDDLE_DOWN) &&
+      (m_lastXPos == event.m_x && m_lastYPos == event.m_y))
+  {
+    m_lastXPos = event.m_x; m_lastYPos = event.m_y;
+    m_lastEvent = wxEVENT_TYPE_MOTION;
+    return;
+  }
+
+  m_lastEvent = wxEVENT_TYPE_MOTION;
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y;
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+/* TODO put back leave/enter code if required
+ */
+#if 0
+void wxWindow::MSWOnMouseMove(int x, int y, WXUINT flags)
+{
+//wxDebugMsg("Client 0x%08x Move Msg %d,%d\n",this,x,y) ;
+
+// #if MOUSE_EXIT_FIX //Should work now!!
+
+  // Don't do the Leave/Enter fix if we've captured the window,
+  // or SetCapture won't work properly.
+  if (!m_winCaptured)
+  {
+    HWND hunder ;
+    POINT pt ;
+    // See if we Leave/Enter the window.
+    GetCursorPos(&pt) ;
+    hunder = WindowFromPoint(pt) ;
+    if (hunder==m_hWnd)
+    {
+      // I'm in the Window, but perhaps in NC area.
+      RECT wind ;
+      RECT nc ;
+      GetClientRect(m_hWnd,&wind) ;
+      GetWindowRect(m_hWnd,&nc) ;
+      pt.x -= nc.left ;
+      pt.y -= nc.top ;
+      wind.left    += WINDOW_MARGIN ; // to be able to 'see' leave
+      wind.top     += WINDOW_MARGIN ; // to be able to 'see' leave
+      wind.right   -= WINDOW_MARGIN ; // to be able to 'see' leave
+      wind.bottom  -= WINDOW_MARGIN ; // to be able to 'see' leave
+
+      if (!PtInRect(&wind,pt))
+        hunder = NULL ; // So, I can simulate a Leave event...
+    }
+
+    if (hunder!=m_hWnd)
+    {
+      if (m_mouseInWindow)
+      {
+        m_mouseInWindow = FALSE ;
+        // Capture/Release is no more needed...
+        //ReleaseCapture() ;
+        MSWOnMouseLeave(x,y,flags) ;
+        return ;
+      }
+      // We never want to see Enter or Motion in this part of the Window...
+      return ;
+    }
+    else
+    {
+      // Event was triggered while I'm really into my client area.
+      // Do an Enter if not done.
+      if (!m_mouseInWindow)
+      {
+        m_mouseInWindow = TRUE ;
+        // Capture/Release is no more needed...
+        //SetCapture(m_hWnd) ;
+        // Set cursor, but only if we're not in 'busy' mode
+        if (m_windowCursor.Ok() && !wxIsBusy())
+          ::SetCursor(m_windowCursor.ms_cursor);
+        MSWOnMouseEnter(x,y,flags) ;
+        return ;
+      }
+    }
+  }
+// #endif //MOUSE_EXIT_FIX
+    
+  // 'normal' move event...
+  // Set cursor, but only if we're not in 'busy' mode
+  if (m_windowCursor.Ok() && !wxIsBusy())
+    ::SetCursor(m_windowCursor.ms_cursor);
+
+  wxMouseEvent event(wxEVENT_TYPE_MOTION);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  // Window gets a click down message followed by a mouse move
+  // message even if position isn't changed!  We want to discard
+  // the trailing move event if x and y are the same.
+  if ((m_lastEvent == wxEVENT_TYPE_RIGHT_DOWN || m_lastEvent == wxEVENT_TYPE_LEFT_DOWN ||
+       m_lastEvent == wxEVENT_TYPE_MIDDLE_DOWN) &&
+      (m_lastXPos == event.m_x && m_lastYPos == event.m_y))
+  {
+    m_lastXPos = event.m_x; m_lastYPos = event.m_y;
+    m_lastEvent = wxEVENT_TYPE_MOTION;
+    return;
+  }
+
+  m_lastEvent = wxEVENT_TYPE_MOTION;
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y;
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+#endif
+
+void wxWindow::MSWOnMouseEnter(const int x, const int y, const WXUINT flags)
+{
+//wxDebugMsg("Client 0x%08x Enter %d,%d\n",this,x,y) ;
+
+  // Set cursor, but only if we're not in 'busy' mode
+  if (m_windowCursor.Ok() && !wxIsBusy())
+    ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR());
+
+  wxMouseEvent event(wxEVENT_TYPE_ENTER_WINDOW);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastEvent = wxEVENT_TYPE_ENTER_WINDOW;
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y;
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnMouseLeave(const int x, const int y, const WXUINT flags)
+{
+//wxDebugMsg("Client 0x%08x Leave %d,%d\n",this,x,y) ;
+
+  // Set cursor, but only if we're not in 'busy' mode
+  if (m_windowCursor.Ok() && !wxIsBusy())
+    ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR());
+
+  wxMouseEvent event(wxEVENT_TYPE_LEAVE_WINDOW);
+
+/*
+  float px = (float)x;
+  float py = (float)y;
+
+  MSWDeviceToLogical(&px, &py);
+
+  CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y);
+*/
+
+  event.m_x = x; event.m_y = y;
+  event.m_shiftDown = ((flags & MK_SHIFT) != 0);
+  event.m_controlDown = ((flags & MK_CONTROL) != 0);
+  event.m_leftDown = ((flags & MK_LBUTTON) != 0);
+  event.m_middleDown = ((flags & MK_MBUTTON) != 0);
+  event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+  event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+  event.m_eventObject = this;
+
+  m_lastEvent = wxEVENT_TYPE_LEAVE_WINDOW;
+  m_lastXPos = event.m_x; m_lastYPos = event.m_y;
+  GetEventHandler()->OldOnMouseEvent(event);
+}
+
+void wxWindow::MSWOnChar(const WXWORD wParam, const WXLPARAM lParam, const bool isASCII)
+{
+  int id;
+  bool tempControlDown = FALSE;
+  if (isASCII)
+  {
+    // If 1 -> 26, translate to CTRL plus a letter.
+    id = wParam;
+    if ((id > 0) && (id < 27))
+    {
+      switch (id)
+      {
+        case 13:
+        {
+          id = WXK_RETURN;
+          break;
+        }
+        case 8:
+        {
+          id = WXK_BACK;
+          break;
+        }
+        case 9:
+        {
+          id = WXK_TAB;
+          break;
+        }
+        default:
+        {
+          tempControlDown = TRUE;
+          id = id + 96;
+        }
+      }
+    }
+  }
+  else
+    if ((id = wxCharCodeMSWToWX(wParam)) == 0)
+      id = -1;
+
+  if (id > -1)
+  {
+    wxKeyEvent event(wxEVT_CHAR);
+    event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
+    event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
+    if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
+      event.m_altDown = TRUE;
+
+    event.m_eventObject = this;
+    event.m_keyCode = id;
+    event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+
+    POINT pt ;
+    GetCursorPos(&pt) ;
+    RECT rect ;
+    GetWindowRect((HWND) GetHWND(),&rect) ;
+    pt.x -= rect.left ;
+    pt.y -= rect.top ;
+
+/*
+    float fx,fy ;
+    fx = (float)pt.x ;
+    fy = (float)pt.y ;
+    MSWDeviceToLogical(&fx,&fy) ;
+    CalcUnscrolledPosition((int)fx,(int)fy,&event.m_x,&event.m_y) ;
+*/
+    event.m_x = pt.x; event.m_y = pt.y;
+
+#if WXWIN_COMPATIBILITY
+    GetEventHandler()->OldOnChar(event);
+#else
+    if (!GetEventHandler()->ProcessEvent(event))
+		Default();
+#endif
+  }
+}
+
+void wxWindow::MSWOnJoyDown(const int joystick, const int x, const int y, const WXUINT flags)
+{
+    int buttons = 0;
+    int change = 0;
+    if (flags & JOY_BUTTON1CHG)
+        change = wxJOY_BUTTON1;
+    if (flags & JOY_BUTTON2CHG)
+        change = wxJOY_BUTTON2;
+    if (flags & JOY_BUTTON3CHG)
+        change = wxJOY_BUTTON3;
+    if (flags & JOY_BUTTON4CHG)
+        change = wxJOY_BUTTON4;
+
+    if (flags & JOY_BUTTON1)
+        buttons |= wxJOY_BUTTON1;
+    if (flags & JOY_BUTTON2)
+        buttons |= wxJOY_BUTTON2;
+    if (flags & JOY_BUTTON3)
+        buttons |= wxJOY_BUTTON3;
+    if (flags & JOY_BUTTON4)
+        buttons |= wxJOY_BUTTON4;
+
+    wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN, buttons, joystick, change);
+    event.SetPosition(wxPoint(x, y));
+    event.SetEventObject(this);
+
+    GetEventHandler()->ProcessEvent(event);
+}
+
+void wxWindow::MSWOnJoyUp(const int joystick, const int x, const int y, const WXUINT flags)
+{
+    int buttons = 0;
+    int change = 0;
+    if (flags & JOY_BUTTON1CHG)
+        change = wxJOY_BUTTON1;
+    if (flags & JOY_BUTTON2CHG)
+        change = wxJOY_BUTTON2;
+    if (flags & JOY_BUTTON3CHG)
+        change = wxJOY_BUTTON3;
+    if (flags & JOY_BUTTON4CHG)
+        change = wxJOY_BUTTON4;
+
+    if (flags & JOY_BUTTON1)
+        buttons |= wxJOY_BUTTON1;
+    if (flags & JOY_BUTTON2)
+        buttons |= wxJOY_BUTTON2;
+    if (flags & JOY_BUTTON3)
+        buttons |= wxJOY_BUTTON3;
+    if (flags & JOY_BUTTON4)
+        buttons |= wxJOY_BUTTON4;
+
+    wxJoystickEvent event(wxEVT_JOY_BUTTON_UP, buttons, joystick, change);
+    event.SetPosition(wxPoint(x, y));
+    event.SetEventObject(this);
+
+    GetEventHandler()->ProcessEvent(event);
+}
+
+void wxWindow::MSWOnJoyMove(const int joystick, const int x, const int y, const WXUINT flags)
+{
+    int buttons = 0;
+    if (flags & JOY_BUTTON1)
+        buttons |= wxJOY_BUTTON1;
+    if (flags & JOY_BUTTON2)
+        buttons |= wxJOY_BUTTON2;
+    if (flags & JOY_BUTTON3)
+        buttons |= wxJOY_BUTTON3;
+    if (flags & JOY_BUTTON4)
+        buttons |= wxJOY_BUTTON4;
+
+    wxJoystickEvent event(wxEVT_JOY_MOVE, buttons, joystick, 0);
+    event.SetPosition(wxPoint(x, y));
+    event.SetEventObject(this);
+
+    GetEventHandler()->ProcessEvent(event);
+}
+
+void wxWindow::MSWOnJoyZMove(const int joystick, const int z, const WXUINT flags)
+{
+    int buttons = 0;
+    if (flags & JOY_BUTTON1)
+        buttons |= wxJOY_BUTTON1;
+    if (flags & JOY_BUTTON2)
+        buttons |= wxJOY_BUTTON2;
+    if (flags & JOY_BUTTON3)
+        buttons |= wxJOY_BUTTON3;
+    if (flags & JOY_BUTTON4)
+        buttons |= wxJOY_BUTTON4;
+
+    wxJoystickEvent event(wxEVT_JOY_ZMOVE, buttons, joystick, 0);
+    event.SetZPosition(z);
+    event.SetEventObject(this);
+
+    GetEventHandler()->ProcessEvent(event);
+}
+
+void wxWindow::MSWOnVScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control)
+{
+  if (control)
+  {
+    wxWindow *child = wxFindWinFromHandle(control);
+	if ( child )
+    	child->MSWOnVScroll(wParam, pos, control);
+    return;
+  }
+
+    wxScrollEvent event;
+    event.SetPosition(pos);
+    event.SetOrientation(wxVERTICAL);
+    event.m_eventObject = this;
+
+	switch ( wParam )
+	{
+		case SB_TOP:
+			event.m_eventType = wxEVENT_TYPE_SCROLL_TOP;
+			break;
+
+		case SB_BOTTOM:
+			event.m_eventType = wxEVENT_TYPE_SCROLL_BOTTOM;
+			break;
+
+		case SB_LINEUP:
+			event.m_eventType = wxEVENT_TYPE_SCROLL_LINEUP;
+			break;
+
+		case SB_LINEDOWN:
+		        event.m_eventType = wxEVENT_TYPE_SCROLL_LINEDOWN;
+			break;
+
+		case SB_PAGEUP:
+                        event.m_eventType = wxEVENT_TYPE_SCROLL_PAGEUP;
+			break;
+
+		case SB_PAGEDOWN:
+                        event.m_eventType = wxEVENT_TYPE_SCROLL_PAGEDOWN;
+			break;
+
+        case SB_THUMBTRACK:
+        case SB_THUMBPOSITION:
+                        event.m_eventType = wxEVENT_TYPE_SCROLL_THUMBTRACK;
+			break;
+
+		default:
+                        return;
+                        break;
+	}
+
+  if (!GetEventHandler()->ProcessEvent(event))
+#if WXWIN_COMPATIBILITY
+    GetEventHandler()->OldOnScroll(event);
+#else
+    Default();
+#endif
+}
+
+void wxWindow::MSWOnHScroll( const WXWORD wParam, const WXWORD pos, const WXHWND control)
+{
+  if (control)
+  {
+    wxWindow *child = wxFindWinFromHandle(control);
+	if ( child )
+    	child->MSWOnHScroll(wParam, pos, control);
+    return;
+  }
+
+    wxScrollEvent event;
+    event.SetPosition(pos);
+    event.SetOrientation(wxHORIZONTAL);
+    event.m_eventObject = this;
+
+	switch ( wParam )
+	{
+		case SB_TOP:
+			event.m_eventType = wxEVENT_TYPE_SCROLL_TOP;
+			break;
+
+		case SB_BOTTOM:
+			event.m_eventType = wxEVENT_TYPE_SCROLL_BOTTOM;
+			break;
+
+		case SB_LINEUP:
+			event.m_eventType = wxEVENT_TYPE_SCROLL_LINEUP;
+			break;
+
+		case SB_LINEDOWN:
+		        event.m_eventType = wxEVENT_TYPE_SCROLL_LINEDOWN;
+			break;
+
+		case SB_PAGEUP:
+                        event.m_eventType = wxEVENT_TYPE_SCROLL_PAGEUP;
+			break;
+
+		case SB_PAGEDOWN:
+                        event.m_eventType = wxEVENT_TYPE_SCROLL_PAGEDOWN;
+			break;
+
+        case SB_THUMBTRACK:
+        case SB_THUMBPOSITION:
+                        event.m_eventType = wxEVENT_TYPE_SCROLL_THUMBTRACK;
+			break;
+
+		default:
+                        return;
+                        break;
+	}
+  if (!GetEventHandler()->ProcessEvent(event))
+#if WXWIN_COMPATIBILITY
+    GetEventHandler()->OldOnScroll(event);
+#else
+    Default();
+#endif
+}
+
+void wxWindow::MSWOnShow(bool show, int status)
+{
+	wxShowEvent event(GetId(), show);
+	event.m_eventObject = this;
+	GetEventHandler()->ProcessEvent(event);
+}
+
+bool wxWindow::MSWOnInitDialog(WXHWND WXUNUSED(hWndFocus))
+{
+	wxInitDialogEvent event(GetId());
+	event.m_eventObject = this;
+	GetEventHandler()->ProcessEvent(event);
+	return TRUE;
+}
+
+void wxWindow::InitDialog(void)
+{
+ wxInitDialogEvent event(GetId());
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent(event);
+}
+
+// Default init dialog behaviour is to transfer data to window
+void wxWindow::OnInitDialog(wxInitDialogEvent& event)
+{
+	TransferDataToWindow();
+}
+
+void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
+{
+  TEXTMETRIC tm;
+  HDC dc = ::GetDC((HWND) wnd);
+  HFONT fnt =0;
+  HFONT was = 0;
+  if (the_font)
+  {
+#if DEBUG > 1
+    wxDebugMsg("wxGetCharSize: Selecting HFONT %X\n", fnt);
+#endif
+//    the_font->UseResource();
+//    the_font->RealizeResource();
+    if ((fnt=(HFONT) the_font->GetResourceHandle()))
+      was = SelectObject(dc,fnt) ;
+  }
+  GetTextMetrics(dc, &tm);
+  if (the_font && fnt && was)
+  {
+#if DEBUG > 1
+    wxDebugMsg("wxGetCharSize: Selecting old HFONT %X\n", was);
+#endif
+    SelectObject(dc,was) ;
+  }
+  ReleaseDC((HWND)wnd, dc);
+  *x = tm.tmAveCharWidth;
+  *y = tm.tmHeight + tm.tmExternalLeading;
+
+//  if (the_font)
+//    the_font->ReleaseResource();
+}
+
+// Returns 0 if was a normal ASCII value, not a special key. This indicates that
+// the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
+int wxCharCodeMSWToWX(int keySym)
+{
+  int id = 0;
+  switch (keySym)
+  {
+    case VK_CANCEL:             id = WXK_CANCEL; break;
+    case VK_BACK:               id = WXK_BACK; break;
+    case VK_TAB:	        id = WXK_TAB; break;
+    case VK_CLEAR:		id = WXK_CLEAR; break;
+    case VK_RETURN:		id = WXK_RETURN; break;
+    case VK_SHIFT:		id = WXK_SHIFT; break;
+    case VK_CONTROL:		id = WXK_CONTROL; break;
+    case VK_MENU :		id = WXK_MENU; break;
+    case VK_PAUSE:		id = WXK_PAUSE; break;
+    case VK_SPACE:		id = WXK_SPACE; break;
+    case VK_ESCAPE:		id = WXK_ESCAPE; break;
+    case VK_PRIOR:		id = WXK_PRIOR; break;
+    case VK_NEXT :		id = WXK_NEXT; break;
+    case VK_END:		id = WXK_END; break;
+    case VK_HOME :		id = WXK_HOME; break;
+    case VK_LEFT :		id = WXK_LEFT; break;
+    case VK_UP:		        id = WXK_UP; break;
+    case VK_RIGHT:		id = WXK_RIGHT; break;
+    case VK_DOWN :		id = WXK_DOWN; break;
+    case VK_SELECT:		id = WXK_SELECT; break;
+    case VK_PRINT:		id = WXK_PRINT; break;
+    case VK_EXECUTE:		id = WXK_EXECUTE; break;
+    case VK_INSERT:		id = WXK_INSERT; break;
+    case VK_DELETE:		id = WXK_DELETE; break;
+    case VK_HELP :		id = WXK_HELP; break;
+    case VK_NUMPAD0:		id = WXK_NUMPAD0; break;
+    case VK_NUMPAD1:		id = WXK_NUMPAD1; break;
+    case VK_NUMPAD2:		id = WXK_NUMPAD2; break;
+    case VK_NUMPAD3:		id = WXK_NUMPAD3; break;
+    case VK_NUMPAD4:		id = WXK_NUMPAD4; break;
+    case VK_NUMPAD5:		id = WXK_NUMPAD5; break;
+    case VK_NUMPAD6:		id = WXK_NUMPAD6; break;
+    case VK_NUMPAD7:		id = WXK_NUMPAD7; break;
+    case VK_NUMPAD8:		id = WXK_NUMPAD8; break;
+    case VK_NUMPAD9:		id = WXK_NUMPAD9; break;
+    case VK_MULTIPLY:		id = WXK_MULTIPLY; break;
+    case VK_ADD:		id = WXK_ADD; break;
+    case VK_SUBTRACT:		id = WXK_SUBTRACT; break;
+    case VK_DECIMAL:		id = WXK_DECIMAL; break;
+    case VK_DIVIDE:		id = WXK_DIVIDE; break;
+    case VK_F1:		id = WXK_F1; break;
+    case VK_F2:		id = WXK_F2; break;
+    case VK_F3:		id = WXK_F3; break;
+    case VK_F4:		id = WXK_F4; break;
+    case VK_F5:		id = WXK_F5; break;
+    case VK_F6:		id = WXK_F6; break;
+    case VK_F7:		id = WXK_F7; break;
+    case VK_F8:		id = WXK_F8; break;
+    case VK_F9:		id = WXK_F9; break;
+    case VK_F10:		id = WXK_F10; break;
+    case VK_F11:		id = WXK_F11; break;
+    case VK_F12:		id = WXK_F12; break;
+    case VK_F13:		id = WXK_F13; break;
+    case VK_F14:		id = WXK_F14; break;
+    case VK_F15:		id = WXK_F15; break;
+    case VK_F16:		id = WXK_F16; break;
+    case VK_F17:		id = WXK_F17; break;
+    case VK_F18:		id = WXK_F18; break;
+    case VK_F19:		id = WXK_F19; break;
+    case VK_F20:		id = WXK_F20; break;
+    case VK_F21:		id = WXK_F21; break;
+    case VK_F22:		id = WXK_F22; break;
+    case VK_F23:		id = WXK_F23; break;
+    case VK_F24:		id = WXK_F24; break;
+    case VK_NUMLOCK:		id = WXK_NUMLOCK; break;
+    case VK_SCROLL:		id = WXK_SCROLL; break;
+    default:
+    {
+      return 0;
+    }
+  }
+  return id;
+}
+
+int wxCharCodeWXToMSW(int id, bool *isVirtual)
+{
+  *isVirtual = TRUE;
+  int keySym = 0;
+  switch (id)
+  {
+    case WXK_CANCEL:            keySym = VK_CANCEL; break;
+    case WXK_CLEAR:		keySym = VK_CLEAR; break;
+    case WXK_SHIFT:		keySym = VK_SHIFT; break;
+    case WXK_CONTROL:		keySym = VK_CONTROL; break;
+    case WXK_MENU :		keySym = VK_MENU; break;
+    case WXK_PAUSE:		keySym = VK_PAUSE; break;
+    case WXK_PRIOR:		keySym = VK_PRIOR; break;
+    case WXK_NEXT :		keySym = VK_NEXT; break;
+    case WXK_END:		keySym = VK_END; break;
+    case WXK_HOME :		keySym = VK_HOME; break;
+    case WXK_LEFT :		keySym = VK_LEFT; break;
+    case WXK_UP:		keySym = VK_UP; break;
+    case WXK_RIGHT:		keySym = VK_RIGHT; break;
+    case WXK_DOWN :		keySym = VK_DOWN; break;
+    case WXK_SELECT:		keySym = VK_SELECT; break;
+    case WXK_PRINT:		keySym = VK_PRINT; break;
+    case WXK_EXECUTE:		keySym = VK_EXECUTE; break;
+    case WXK_INSERT:		keySym = VK_INSERT; break;
+    case WXK_DELETE:		keySym = VK_DELETE; break;
+    case WXK_HELP :		keySym = VK_HELP; break;
+    case WXK_NUMPAD0:		keySym = VK_NUMPAD0; break;
+    case WXK_NUMPAD1:		keySym = VK_NUMPAD1; break;
+    case WXK_NUMPAD2:		keySym = VK_NUMPAD2; break;
+    case WXK_NUMPAD3:		keySym = VK_NUMPAD3; break;
+    case WXK_NUMPAD4:		keySym = VK_NUMPAD4; break;
+    case WXK_NUMPAD5:		keySym = VK_NUMPAD5; break;
+    case WXK_NUMPAD6:		keySym = VK_NUMPAD6; break;
+    case WXK_NUMPAD7:		keySym = VK_NUMPAD7; break;
+    case WXK_NUMPAD8:		keySym = VK_NUMPAD8; break;
+    case WXK_NUMPAD9:		keySym = VK_NUMPAD9; break;
+    case WXK_MULTIPLY:		keySym = VK_MULTIPLY; break;
+    case WXK_ADD:		keySym = VK_ADD; break;
+    case WXK_SUBTRACT:		keySym = VK_SUBTRACT; break;
+    case WXK_DECIMAL:		keySym = VK_DECIMAL; break;
+    case WXK_DIVIDE:		keySym = VK_DIVIDE; break;
+    case WXK_F1:		keySym = VK_F1; break;
+    case WXK_F2:		keySym = VK_F2; break;
+    case WXK_F3:		keySym = VK_F3; break;
+    case WXK_F4:		keySym = VK_F4; break;
+    case WXK_F5:		keySym = VK_F5; break;
+    case WXK_F6:		keySym = VK_F6; break;
+    case WXK_F7:		keySym = VK_F7; break;
+    case WXK_F8:		keySym = VK_F8; break;
+    case WXK_F9:		keySym = VK_F9; break;
+    case WXK_F10:		keySym = VK_F10; break;
+    case WXK_F11:		keySym = VK_F11; break;
+    case WXK_F12:		keySym = VK_F12; break;
+    case WXK_F13:		keySym = VK_F13; break;
+    case WXK_F14:		keySym = VK_F14; break;
+    case WXK_F15:		keySym = VK_F15; break;
+    case WXK_F16:		keySym = VK_F16; break;
+    case WXK_F17:		keySym = VK_F17; break;
+    case WXK_F18:		keySym = VK_F18; break;
+    case WXK_F19:		keySym = VK_F19; break;
+    case WXK_F20:		keySym = VK_F20; break;
+    case WXK_F21:		keySym = VK_F21; break;
+    case WXK_F22:		keySym = VK_F22; break;
+    case WXK_F23:		keySym = VK_F23; break;
+    case WXK_F24:		keySym = VK_F24; break;
+    case WXK_NUMLOCK:		keySym = VK_NUMLOCK; break;
+    case WXK_SCROLL:		keySym = VK_SCROLL; break;
+    default:
+    {
+      *isVirtual = FALSE;
+      keySym = id;
+      break;
+    }
+  }
+  return keySym;
+}
+
+// Caret manipulation
+void wxWindow::CreateCaret(const int w, const int h)
+{
+  m_caretWidth = w;
+  m_caretHeight = h;
+  m_caretEnabled = TRUE;
+}
+
+void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
+{
+  // Not implemented
+}
+
+void wxWindow::ShowCaret(const bool show)
+{
+  if (m_caretEnabled)
+  {
+    if (show)
+      ::ShowCaret((HWND) GetHWND());
+    else
+      ::HideCaret((HWND) GetHWND());
+    m_caretShown = show;
+  }
+}
+
+void wxWindow::DestroyCaret(void)
+{
+  m_caretEnabled = FALSE;
+}
+
+void wxWindow::SetCaretPos(const int x, const int y)
+{
+  ::SetCaretPos(x, y);
+}
+
+void wxWindow::GetCaretPos(int *x, int *y) const
+{
+  POINT point;
+  ::GetCaretPos(&point);
+  *x = point.x;
+  *y = point.y;
+}
+
+/*
+ * Update iterator. Use from within OnPaint.
+ */
+
+static RECT gs_UpdateRect;
+
+wxUpdateIterator::wxUpdateIterator(wxWindow* wnd)
+{
+  current = 0;					//start somewhere...
+#if defined(__WIN32__) && !defined(__win32s__)
+  rlist = NULL;					//make sure I don't free randomly
+  int len = GetRegionData((HRGN) wnd->m_updateRgn,0,NULL);	//Get buffer size
+  if (len)
+  {
+    rlist = (WXRGNDATA *) (RGNDATA *)new char[len];
+    GetRegionData((HRGN) wnd->m_updateRgn,len, (RGNDATA *)rlist);
+    rp = (void *)(RECT*) ((RGNDATA *)rlist)->Buffer;
+    rects = ((RGNDATA *)rlist)->rdh.nCount;
+  }
+  else
+#endif
+  {
+	gs_UpdateRect.left = wnd->m_updateRect.x;
+	gs_UpdateRect.top = wnd->m_updateRect.y;
+	gs_UpdateRect.right = wnd->m_updateRect.x + wnd->m_updateRect.width;
+	gs_UpdateRect.bottom = wnd->m_updateRect.y + wnd->m_updateRect.height;
+    rects = 1;
+    rp = (void *)&gs_UpdateRect;			//Only one available in Win16,32s
+  }
+}
+
+wxUpdateIterator::~wxUpdateIterator(void)
+{
+#ifdef __WIN32__
+#ifndef __win32s__
+  if (rlist) delete (RGNDATA *) rlist;
+#endif
+#endif
+}
+
+wxUpdateIterator::operator int (void)
+{
+  if (current < rects)
+  {
+    return TRUE;
+  }
+  else
+  {
+    return FALSE;
+  }
+}
+
+wxUpdateIterator* wxUpdateIterator::operator ++(int)
+{
+  current++;
+  return this;
+}
+
+void wxUpdateIterator::GetRect(wxRect *rect)
+{
+  RECT *mswRect = ((RECT *)rp)+current;	//ought to error check this...
+  rect->x = mswRect->left;
+  rect->y = mswRect->top;
+  rect->width = mswRect->right - mswRect->left;
+  rect->height = mswRect->bottom - mswRect->top;
+}
+
+int wxUpdateIterator::GetX()
+{
+  return ((RECT*)rp)[current].left;
+}
+
+int wxUpdateIterator::GetY()
+{
+  return ((RECT *)rp)[current].top;
+}
+
+int wxUpdateIterator::GetW()
+{
+ return ((RECT *)rp)[current].right-GetX();
+}
+
+int wxUpdateIterator::GetH()
+{
+  return ((RECT *)rp)[current].bottom-GetY();
+}
+
+wxWindow *wxGetActiveWindow(void)
+{
+  HWND hWnd = GetActiveWindow();
+  if (hWnd != 0)
+  {
+    return wxFindWinFromHandle((WXHWND) hWnd);
+  }
+  return NULL;
+}
+
+// Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
+// in active frames and dialogs, regardless of where the focus is.
+static HHOOK wxTheKeyboardHook = 0;
+static FARPROC wxTheKeyboardHookProc = 0;
+int APIENTRY _EXPORT
+  wxKeyboardHook(int nCode, WORD wParam, DWORD lParam);
+
+void wxSetKeyboardHook(bool doIt)
+{
+  if (doIt)
+  {
+    wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance());
+    wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(),
+#ifdef __WIN32__
+      GetCurrentThreadId());
+//      (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
+#else
+      GetCurrentTask());
+#endif
+  }
+  else
+  {
+    UnhookWindowsHookEx(wxTheKeyboardHook);
+    FreeProcInstance(wxTheKeyboardHookProc);
+  }
+}
+
+int APIENTRY _EXPORT
+  wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
+{
+  DWORD hiWord = HIWORD(lParam);
+  if (nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0))
+  {
+    int id;
+    if ((id = wxCharCodeMSWToWX(wParam)) != 0)
+    {
+      wxKeyEvent event(wxEVT_CHAR_HOOK);
+      if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
+        event.m_altDown = TRUE;
+
+      event.m_eventObject = NULL;
+      event.m_keyCode = id;
+/* begin Albert's fix for control and shift key 26.5 */
+      event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
+      event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
+/* end Albert's fix for control and shift key 26.5 */
+      event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
+
+#if WXWIN_COMPATIBILITY
+		if ( wxTheApp && wxTheApp->OldOnCharHook(event) )
+			return 1;
+#endif
+		wxWindow *win = wxGetActiveWindow();
+  		if (win)
+		{
+            if (win->GetEventHandler()->ProcessEvent(event))
+				return 1;
+		}
+		else
+		{
+			if ( wxTheApp && wxTheApp->ProcessEvent(event) )
+				return 1;
+		}
+    }
+  }
+  return (int)CallNextHookEx(wxTheKeyboardHook, nCode, wParam, lParam);
+}
+
+void wxWindow::SetSizeHints(const int minW, const int minH, const int maxW, const int maxH, const int WXUNUSED(incW), const int WXUNUSED(incH))
+{
+  m_minSizeX = minW;
+  m_minSizeY = minH;
+  m_maxSizeX = maxW;
+  m_maxSizeY = maxH;
+}
+
+void wxWindow::Centre(const int direction)
+{
+  int x, y, width, height, panel_width, panel_height, new_x, new_y;
+
+  wxWindow *father = (wxWindow *)GetParent();
+  if (!father)
+    return;
+
+  father->GetClientSize(&panel_width, &panel_height);
+  GetSize(&width, &height);
+  GetPosition(&x, &y);
+
+  new_x = -1;
+  new_y = -1;
+
+  if (direction & wxHORIZONTAL)
+    new_x = (int)((panel_width - width)/2);
+
+  if (direction & wxVERTICAL)
+    new_y = (int)((panel_height - height)/2);
+
+  SetSize(new_x, new_y, -1, -1);
+
+}
+
+/* TODO (maybe)
+void wxWindow::OnPaint(void)
+{
+  PaintSelectionHandles();
+}
+*/
+
+void wxWindow::WarpPointer (const int x_pos, const int y_pos)
+{
+  // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
+  // pixel coordinates, relatives to the canvas -- So, we first need to
+  // substract origin of the window, then convert to screen position
+
+  int x = x_pos; int y = y_pos;
+/* Leave this to the app to decide (and/or wxScrolledWindow)
+      x -= m_xScrollPosition * m_xScrollPixelsPerLine;
+      y -= m_yScrollPosition * m_yScrollPixelsPerLine;
+*/
+      RECT rect;
+      GetWindowRect ((HWND) GetHWND(), &rect);
+
+      x += rect.left;
+      y += rect.top;
+
+      SetCursorPos (x, y);
+}
+
+void wxWindow::MSWDeviceToLogical (float *x, float *y) const
+{
+    // TODO
+    // Do we have a SetUserScale in wxWindow too, so we can
+    // get mouse events scaled?
+/*
+      if (m_windowDC)
+      {
+        *x = m_windowDC->DeviceToLogicalX ((int) *x);
+        *y = m_windowDC->DeviceToLogicalY ((int) *y);
+      }
+*/
+}
+
+bool wxWindow::MSWOnEraseBkgnd (const WXHDC pDC)
+{
+    wxDC dc ;
+
+	dc.SetHDC(pDC);
+	dc.SetWindow(this);
+	dc.BeginDrawing();
+
+    wxEraseEvent event(m_windowId, &dc);
+    event.m_eventObject = this;
+    if (!GetEventHandler()->ProcessEvent(event))
+    {
+	    dc.EndDrawing();
+	    dc.SelectOldObjects(pDC);
+        return FALSE;
+    }
+    else
+    {
+	    dc.EndDrawing();
+	    dc.SelectOldObjects(pDC);
+    }
+
+    dc.SetHDC((WXHDC) NULL);
+    return TRUE;
+}
+
+void wxWindow::OnEraseBackground(wxEraseEvent& event)
+{
+  RECT rect;
+  ::GetClientRect((HWND) GetHWND(), &rect);
+
+  HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+  int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
+
+//  ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
+  ::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
+  ::DeleteObject(hBrush);
+  ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
+/*
+  // Less efficient version (and doesn't account for scrolling)
+  int w, h;
+  GetClientSize(& w, & h);
+  wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
+  event.GetDC()->SetBrush(brush);
+  event.GetDC()->SetPen(wxTRANSPARENT_PEN);
+
+  event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
+*/
+}
+
+#if WXWIN_COMPATIBILITY
+void wxWindow::SetScrollRange(const int orient, const int range, const bool refresh)
+{
+#if defined(__WIN95__)
+
+  int range1 = range;
+
+  // Try to adjust the range to cope with page size > 1
+  // - a Windows API quirk
+  int pageSize = GetScrollPage(orient);
+  if ( pageSize > 1 && range > 0)
+  {
+	range1 += (pageSize - 1);
+  }
+
+  SCROLLINFO info;
+  int dir;
+
+  if (orient == wxHORIZONTAL) {
+	dir = SB_HORZ;
+  } else {
+	dir = SB_VERT;
+  }
+
+  info.cbSize = sizeof(SCROLLINFO);
+  info.nPage = pageSize; // Have to set this, or scrollbar goes awry
+  info.nMin = 0;
+  info.nMax = range1;
+  info.nPos = 0;
+  info.fMask = SIF_RANGE | SIF_PAGE;
+
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    ::SetScrollInfo(hWnd, dir, &info, refresh);
+#else
+  int wOrient ;
+  if (orient == wxHORIZONTAL)
+    wOrient = SB_HORZ;
+  else
+    wOrient = SB_VERT;
+    
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    ::SetScrollRange(hWnd, wOrient, 0, range, refresh);
+#endif
+}
+
+void wxWindow::SetScrollPage(const int orient, const int page, const bool refresh)
+{
+#if defined(__WIN95__)
+  SCROLLINFO info;
+  int dir;
+
+  if (orient == wxHORIZONTAL) {
+	dir = SB_HORZ;
+    m_xThumbSize = page;
+  } else {
+	dir = SB_VERT;
+    m_yThumbSize = page;
+  }
+
+  info.cbSize = sizeof(SCROLLINFO);
+  info.nPage = page;
+  info.nMin = 0;
+  info.fMask = SIF_PAGE ;
+
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    ::SetScrollInfo(hWnd, dir, &info, refresh);
+#else
+  if (orient == wxHORIZONTAL)
+    m_xThumbSize = page;
+  else
+    m_yThumbSize = page;
+#endif
+}
+
+int wxWindow::OldGetScrollRange(const int orient) const
+{
+  int wOrient ;
+  if (orient == wxHORIZONTAL)
+    wOrient = SB_HORZ;
+  else
+    wOrient = SB_VERT;
+
+#if __WATCOMC__ && defined(__WINDOWS_386__)
+  short minPos, maxPos;
+#else
+  int minPos, maxPos;
+#endif
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+  {
+    ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos);
+#if defined(__WIN95__)
+    // Try to adjust the range to cope with page size > 1
+    // - a Windows API quirk
+    int pageSize = GetScrollPage(orient);
+    if ( pageSize > 1 )
+    {
+ 	  maxPos -= (pageSize - 1);
+    }
+#endif
+    return maxPos;
+  }
+  else
+    return 0;
+}
+
+int wxWindow::GetScrollPage(const int orient) const
+{
+  if (orient == wxHORIZONTAL)
+    return m_xThumbSize;
+  else
+    return m_yThumbSize;
+}
+#endif
+
+int wxWindow::GetScrollPos(const int orient) const
+{
+  int wOrient ;
+  if (orient == wxHORIZONTAL)
+    wOrient = SB_HORZ;
+  else
+    wOrient = SB_VERT;
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+  {
+    return ::GetScrollPos(hWnd, wOrient);
+  }
+  else
+    return 0;
+}
+
+// This now returns the whole range, not just the number
+// of positions that we can scroll.
+int wxWindow::GetScrollRange(const int orient) const
+{
+  int wOrient ;
+  if (orient == wxHORIZONTAL)
+    wOrient = SB_HORZ;
+  else
+    wOrient = SB_VERT;
+
+#if __WATCOMC__ && defined(__WINDOWS_386__)
+  short minPos, maxPos;
+#else
+  int minPos, maxPos;
+#endif
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+  {
+    ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos);
+#if defined(__WIN95__)
+    // Try to adjust the range to cope with page size > 1
+    // - a Windows API quirk
+    int pageSize = GetScrollPage(orient);
+    if ( pageSize > 1 )
+    {
+ 	  maxPos -= (pageSize - 1);
+    }
+    // October 10th: new range concept.
+    maxPos += pageSize;
+#endif
+
+    return maxPos;
+  }
+  else
+    return 0;
+}
+
+int wxWindow::GetScrollThumb(const int orient) const
+{
+  if (orient == wxHORIZONTAL)
+    return m_xThumbSize;
+  else
+    return m_yThumbSize;
+}
+
+void wxWindow::SetScrollPos(const int orient, const int pos, const bool refresh)
+{
+#if defined(__WIN95__)
+  SCROLLINFO info;
+  int dir;
+
+  if (orient == wxHORIZONTAL) {
+	dir = SB_HORZ;
+  } else {
+	dir = SB_VERT;
+  }
+
+  info.cbSize = sizeof(SCROLLINFO);
+  info.nPage = 0;
+  info.nMin = 0;
+  info.nPos = pos;
+  info.fMask = SIF_POS ;
+
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    ::SetScrollInfo(hWnd, dir, &info, refresh);
+#else
+  int wOrient ;
+  if (orient == wxHORIZONTAL)
+    wOrient = SB_HORZ;
+  else
+    wOrient = SB_VERT;
+    
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    ::SetScrollPos(hWnd, wOrient, pos, refresh);
+#endif
+}
+
+// New function that will replace some of the above.
+void wxWindow::SetScrollbar(const int orient, const int pos, const int thumbVisible,
+    const int range, const bool refresh)
+{
+/*
+    SetScrollPage(orient, thumbVisible, FALSE);
+
+    int oldRange = range - thumbVisible ;
+    SetScrollRange(orient, oldRange, FALSE);
+
+    SetScrollPos(orient, pos, refresh);
+*/
+#if defined(__WIN95__)
+  int oldRange = range - thumbVisible ;
+
+  int range1 = oldRange;
+
+  // Try to adjust the range to cope with page size > 1
+  // - a Windows API quirk
+  int pageSize = thumbVisible;
+  if ( pageSize > 1 && range > 0)
+  {
+	range1 += (pageSize - 1);
+  }
+
+  SCROLLINFO info;
+  int dir;
+
+  if (orient == wxHORIZONTAL) {
+	dir = SB_HORZ;
+  } else {
+	dir = SB_VERT;
+  }
+
+  info.cbSize = sizeof(SCROLLINFO);
+  info.nPage = pageSize; // Have to set this, or scrollbar goes awry
+  info.nMin = 0;
+  info.nMax = range1;
+  info.nPos = pos;
+  info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+    ::SetScrollInfo(hWnd, dir, &info, refresh);
+#else
+  int wOrient ;
+  if (orient == wxHORIZONTAL)
+    wOrient = SB_HORZ;
+  else
+    wOrient = SB_VERT;
+    
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd)
+  {
+    ::SetScrollRange(hWnd, wOrient, 0, range, FALSE);
+    ::SetScrollPos(hWnd, wOrient, pos, refresh);
+  }
+#endif
+  if (orient == wxHORIZONTAL) {
+    m_xThumbSize = thumbVisible;
+  } else {
+    m_yThumbSize = thumbVisible;
+  }
+}
+
+void wxWindow::ScrollWindow(const int dx, const int dy, const wxRectangle *rect)
+{
+	RECT rect2;
+	if ( rect )
+	{
+		rect2.left = rect->x;
+		rect2.top = rect->y;
+		rect2.right = rect->x + rect->width;
+		rect2.bottom = rect->y + rect->height;
+	}
+
+	if ( rect )
+		::ScrollWindow((HWND) GetHWND(), dx, dy, &rect2, NULL);
+	else
+		::ScrollWindow((HWND) GetHWND(), dx, dy, NULL, NULL);
+}
+
+void wxWindow::OnSize(wxSizeEvent& event)
+{
+	Default();
+#if USE_CONSTRAINTS
+  if (GetAutoLayout())
+    Layout();
+#endif
+}
+
+/*
+void wxWindow::CalcScrolledPosition(const int x, const int y, int *xx, int *yy) const
+{
+  *xx = x;
+  *yy = y;
+}
+
+void wxWindow::CalcUnscrolledPosition(const int x, const int y, float *xx, float *yy) const
+{
+  *xx = x;
+  *yy = y;
+}
+*/
+
+void wxWindow::SetFont(const wxFont& font)
+{
+  // Decrement the usage count of the old label font
+  // (we may be able to free it up)
+//  if (GetFont()->Ok())
+//    GetFont()->ReleaseResource();
+    
+  m_windowFont = font;
+
+  if (!m_windowFont.Ok())
+	return;
+
+//  m_windowFont.UseResource();
+
+  HWND hWnd = (HWND) GetHWND();
+  if (hWnd != 0)
+  {
+//      m_windowFont.RealizeResource();
+
+      if (m_windowFont.GetResourceHandle())
+        SendMessage(hWnd, WM_SETFONT,
+                  (WPARAM)m_windowFont.GetResourceHandle(),TRUE);
+  }
+}
+
+void wxWindow::SubclassWin(WXHWND hWnd)
+{
+  wxAssociateWinWithHandle((HWND)hWnd, this);
+
+  m_oldWndProc = (WXFARPROC) GetWindowLong((HWND) hWnd, GWL_WNDPROC);
+  SetWindowLong((HWND) hWnd, GWL_WNDPROC, (LONG) wxWndProc);
+}
+
+void wxWindow::UnsubclassWin(void)
+{
+	wxRemoveHandleAssociation(this);
+
+  // Restore old Window proc
+  if ((HWND) GetHWND())
+  {
+    FARPROC farProc = (FARPROC) GetWindowLong((HWND) GetHWND(), GWL_WNDPROC);
+    if ((m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc))
+	{
+      SetWindowLong((HWND) GetHWND(), GWL_WNDPROC, (LONG) m_oldWndProc);
+	  m_oldWndProc = 0;
+	}
+  }
+}
+
+// Make a Windows extended style from the given wxWindows window style
+WXDWORD wxWindow::MakeExtendedStyle(long style, bool eliminateBorders)
+{
+	WXDWORD exStyle = 0;
+	if ( style & wxTRANSPARENT_WINDOW )
+		exStyle |= WS_EX_TRANSPARENT ;
+
+  if ( !eliminateBorders )
+  {
+	if ( style & wxSUNKEN_BORDER )
+		exStyle |= WS_EX_CLIENTEDGE ;
+	if ( style & wxDOUBLE_BORDER )
+		exStyle |= WS_EX_DLGMODALFRAME ;
+#if defined(__WIN95__)
+	if ( style & wxRAISED_BORDER )
+		exStyle |= WS_EX_WINDOWEDGE ;
+	if ( style & wxSTATIC_BORDER )
+		exStyle |= WS_EX_STATICEDGE ;
+#endif
+  }
+  return exStyle;
+}
+
+// Determines whether native 3D effects or CTL3D should be used,
+// applying a default border style if required, and returning an extended
+// style to pass to CreateWindowEx.
+WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D)
+{
+  // If matches certain criteria, then assume no 3D effects
+  // unless specifically requested (dealt with in MakeExtendedStyle)
+  if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl)) || (m_windowStyle & wxNO_BORDER) )
+  {
+	*want3D = FALSE;
+	return MakeExtendedStyle(m_windowStyle, FALSE);
+  }
+
+  // Determine whether we should be using 3D effects or not.
+  bool nativeBorder = FALSE; // by default, we don't want a Win95 effect
+
+  // 1) App can specify global 3D effects
+  *want3D = wxTheApp->GetAuto3D();
+
+  // 2) If the parent is being drawn with user colours, or simple border specified,
+  // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
+  if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER))
+	*want3D = FALSE;
+
+  // 3) Control can override this global setting by defining
+  // a border style, e.g. wxSUNKEN_BORDER
+  if (m_windowStyle & wxSUNKEN_BORDER )
+	*want3D = TRUE;
+
+  // 4) If it's a special border, CTL3D can't cope so we want a native border
+  if ( (m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+       (m_windowStyle & wxSTATIC_BORDER) )
+  {
+	*want3D = TRUE;
+	nativeBorder = TRUE;
+  }
+
+  // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
+  // effects from extended style
+#if CTL3D
+  if ( *want3D )
+  	nativeBorder = FALSE;
+#endif
+
+  DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder);
+
+  // If we want 3D, but haven't specified a border here,
+  // apply the default border style specified.
+  // TODO what about non-Win95 WIN32? Does it have borders?
+#if defined(__WIN95__) && !CTL3D
+  if (defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+        (m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) ))
+	exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE ;
+#endif
+
+  return exStyle;
+}
+
+#if WXWIN_COMPATIBILITY
+void wxWindow::OldOnPaint(void)
+{
+  wxPaintEvent event(m_windowId);
+  event.m_eventObject = this;
+  if (!GetEventHandler()->ProcessEvent(event))
+    Default();
+};
+
+void wxWindow::OldOnSize(int w, int h)
+{
+  wxSizeEvent event(wxSize(w, h), m_windowId);
+  event.m_eventObject = this;
+  if (!GetEventHandler()->ProcessEvent(event))
+    Default();
+};
+
+void wxWindow::OldOnMouseEvent(wxMouseEvent& event)
+{
+  if (!GetEventHandler()->ProcessEvent(event))
+    Default();
+};
+
+void wxWindow::OldOnChar(wxKeyEvent& event)
+{
+  if (!GetEventHandler()->ProcessEvent(event))
+    Default();
+};
+
+void wxWindow::OldOnSetFocus(void)
+{
+  wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
+  event.m_eventObject = this;
+  if (!GetEventHandler()->ProcessEvent(event))
+    Default();
+};
+
+void wxWindow::OldOnKillFocus(void)
+{
+  wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
+  event.m_eventObject = this;
+  if (!GetEventHandler()->ProcessEvent(event))
+    Default();
+};
+#endif
+
+void wxWindow::OnChar(wxKeyEvent& event)
+{
+	bool isVirtual;
+	int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
+
+	if ( id == -1 )
+		id= m_lastWParam;
+
+    if ( !event.ControlDown() )
+	    (void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
+}
+
+void wxWindow::OnPaint(wxPaintEvent& event)
+{
+	Default();
+}
+
+bool wxWindow::IsEnabled(void) const
+{
+	return (::IsWindowEnabled((HWND) GetHWND()) != 0);
+}
+
+// Dialog support: override these and call
+// base class members to add functionality
+// that can't be done using validators.
+// NOTE: these functions assume that controls
+// are direct children of this window, not grandchildren
+// or other levels of descendant.
+
+// Transfer values to controls. If returns FALSE,
+// it's an application error (pops up a dialog)
+bool wxWindow::TransferDataToWindow(void)
+{
+	wxNode *node = GetChildren()->First();
+	while ( node )
+	{
+		wxWindow *child = (wxWindow *)node->Data();
+		if ( child->GetValidator() && /* child->GetValidator()->Ok() && */
+		!child->GetValidator()->TransferToWindow() )
+		{
+			wxMessageBox("Application Error", "Could not transfer data to window", wxOK|wxICON_EXCLAMATION);
+			return FALSE;
+		}
+
+		node = node->Next();
+	}
+	return TRUE;
+}
+
+// Transfer values from controls. If returns FALSE,
+// validation failed: don't quit
+bool wxWindow::TransferDataFromWindow(void)
+{
+	wxNode *node = GetChildren()->First();
+	while ( node )
+	{
+		wxWindow *child = (wxWindow *)node->Data();
+		if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->TransferFromWindow() )
+		{
+			return FALSE;
+		}
+
+		node = node->Next();
+	}
+	return TRUE;
+}
+
+bool wxWindow::Validate(void)
+{
+	wxNode *node = GetChildren()->First();
+	while ( node )
+	{
+		wxWindow *child = (wxWindow *)node->Data();
+		if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this) )
+		{
+			return FALSE;
+		}
+
+		node = node->Next();
+	}
+	return TRUE;
+}
+
+// Get the window with the focus
+wxWindow *wxWindow::FindFocus(void)
+{
+    HWND hWnd = ::GetFocus();
+    if ( hWnd )
+    {
+        return wxFindWinFromHandle((WXHWND) hWnd);
+    }
+    return NULL;
+}
+
+void wxWindow::AddChild(wxWindow *child)
+{
+  GetChildren()->Append(child);
+  child->m_windowParent = this;
+}
+
+void wxWindow::RemoveChild(wxWindow *child)
+{
+  if (GetChildren())
+    GetChildren()->DeleteObject(child);
+  child->m_windowParent = NULL;
+}
+
+void wxWindow::DestroyChildren(void)
+{
+  if (GetChildren()) {
+    wxNode *node;
+    while ((node = GetChildren()->First()) != (wxNode *)NULL) {
+      wxWindow *child;
+      if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) {
+        delete child;
+		if ( GetChildren()->Member(child) )
+			delete node;
+      }
+    } /* while */
+  }
+}
+
+void wxWindow::MakeModal(const bool modal)
+{
+  // Disable all other windows
+  if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
+  {
+    wxNode *node = wxTopLevelWindows.First();
+    while (node)
+    {
+      wxWindow *win = (wxWindow *)node->Data();
+      if (win != this)
+        win->Enable(!modal);
+
+      node = node->Next();
+    }
+  }
+}
+
+// If nothing defined for this, try the parent.
+// E.g. we may be a button loaded from a resource, with no callback function
+// defined.
+void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event)
+{
+  if (GetEventHandler()->ProcessEvent(event) )
+	return;
+  if (m_windowParent)
+    m_windowParent->GetEventHandler()->OnCommand(win, event);
+}
+
+void wxWindow::SetConstraints(wxLayoutConstraints *c)
+{
+  if (m_constraints)
+  {
+    UnsetConstraints(m_constraints);
+    delete m_constraints;
+  }
+  m_constraints = c;
+  if (m_constraints)
+  {
+    // Make sure other windows know they're part of a 'meaningful relationship'
+    if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this))
+      m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+    if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this))
+      m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+    if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this))
+      m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+    if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this))
+      m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+    if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this))
+      m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+    if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this))
+      m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+    if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this))
+      m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+    if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this))
+      m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+  }
+}
+
+// This removes any dangling pointers to this window
+// in other windows' constraintsInvolvedIn lists.
+void wxWindow::UnsetConstraints(wxLayoutConstraints *c)
+{
+  if (c)
+  {
+    if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this))
+      c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+    if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this))
+      c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+    if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this))
+      c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+    if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this))
+      c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+    if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this))
+      c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+    if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this))
+      c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+    if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this))
+      c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+    if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this))
+      c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+  }
+}
+
+// Back-pointer to other windows we're involved with, so if we delete
+// this window, we must delete any constraints we're involved with.
+void wxWindow::AddConstraintReference(wxWindow *otherWin)
+{
+  if (!m_constraintsInvolvedIn)
+    m_constraintsInvolvedIn = new wxList;
+  if (!m_constraintsInvolvedIn->Member(otherWin))
+    m_constraintsInvolvedIn->Append(otherWin);
+}
+
+// REMOVE back-pointer to other windows we're involved with.
+void wxWindow::RemoveConstraintReference(wxWindow *otherWin)
+{
+  if (m_constraintsInvolvedIn)
+    m_constraintsInvolvedIn->DeleteObject(otherWin);
+}
+
+// Reset any constraints that mention this window
+void wxWindow::DeleteRelatedConstraints(void)
+{
+  if (m_constraintsInvolvedIn)
+  {
+    wxNode *node = m_constraintsInvolvedIn->First();
+    while (node)
+    {
+      wxWindow *win = (wxWindow *)node->Data();
+      wxNode *next = node->Next();
+      wxLayoutConstraints *constr = win->GetConstraints();
+
+      // Reset any constraints involving this window
+      if (constr)
+      {
+        constr->left.ResetIfWin((wxWindow *)this);
+        constr->top.ResetIfWin((wxWindow *)this);
+        constr->right.ResetIfWin((wxWindow *)this);
+        constr->bottom.ResetIfWin((wxWindow *)this);
+        constr->width.ResetIfWin((wxWindow *)this);
+        constr->height.ResetIfWin((wxWindow *)this);
+        constr->centreX.ResetIfWin((wxWindow *)this);
+        constr->centreY.ResetIfWin((wxWindow *)this);
+      }
+      delete node;
+      node = next;
+    }
+    delete m_constraintsInvolvedIn;
+    m_constraintsInvolvedIn = NULL;
+  }
+}
+
+void wxWindow::SetSizer(wxSizer *sizer)
+{
+  m_windowSizer = sizer;
+  if (sizer)
+    sizer->SetSizerParent((wxWindow *)this);
+}
+
+/*
+ * New version
+ */
+
+bool wxWindow::Layout(void)
+{
+  if (GetConstraints())
+  {
+    int w, h;
+    GetClientSize(&w, &h);
+    GetConstraints()->width.SetValue(w);
+    GetConstraints()->height.SetValue(h);
+  }
+  
+  // If top level (one sizer), evaluate the sizer's constraints.
+  if (GetSizer())
+  {
+    int noChanges;
+    GetSizer()->ResetConstraints();   // Mark all constraints as unevaluated
+    GetSizer()->LayoutPhase1(&noChanges);
+    GetSizer()->LayoutPhase2(&noChanges);
+    GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
+    return TRUE;
+  }
+  else
+  {
+    // Otherwise, evaluate child constraints
+    ResetConstraints();   // Mark all constraints as unevaluated
+    DoPhase(1);           // Just one phase need if no sizers involved
+    DoPhase(2);
+    SetConstraintSizes(); // Recursively set the real window sizes
+  }
+  return TRUE;
+}
+
+
+// Do a phase of evaluating constraints:
+// the default behaviour. wxSizers may do a similar
+// thing, but also impose their own 'constraints'
+// and order the evaluation differently.
+bool wxWindow::LayoutPhase1(int *noChanges)
+{
+  wxLayoutConstraints *constr = GetConstraints();
+  if (constr)
+  {
+    return constr->SatisfyConstraints((wxWindow *)this, noChanges);
+  }
+  else
+    return TRUE;
+}
+
+bool wxWindow::LayoutPhase2(int *noChanges)
+{
+  *noChanges = 0;
+  
+  // Layout children
+  DoPhase(1);
+  DoPhase(2);
+  return TRUE;
+}
+
+// Do a phase of evaluating child constraints
+bool wxWindow::DoPhase(const int phase)
+{
+  int noIterations = 0;
+  int maxIterations = 500;
+  int noChanges = 1;
+  int noFailures = 0;
+  wxList succeeded;
+  while ((noChanges > 0) && (noIterations < maxIterations))
+  {
+    noChanges = 0;
+    noFailures = 0;
+    wxNode *node = GetChildren()->First();
+    while (node)
+    {
+      wxWindow *child = (wxWindow *)node->Data();
+      if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog)))
+      {
+        wxLayoutConstraints *constr = child->GetConstraints();
+        if (constr)
+        {
+          if (succeeded.Member(child))
+          {
+          }
+          else
+          {
+            int tempNoChanges = 0;
+            bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ;
+            noChanges += tempNoChanges;
+            if (success)
+            {
+              succeeded.Append(child);
+            }
+          }
+        }
+      }
+      node = node->Next();
+    }
+    noIterations ++;
+  }
+  return TRUE;
+}
+
+void wxWindow::ResetConstraints(void)
+{
+  wxLayoutConstraints *constr = GetConstraints();
+  if (constr)
+  {
+    constr->left.SetDone(FALSE);
+    constr->top.SetDone(FALSE);
+    constr->right.SetDone(FALSE);
+    constr->bottom.SetDone(FALSE);
+    constr->width.SetDone(FALSE);
+    constr->height.SetDone(FALSE);
+    constr->centreX.SetDone(FALSE);
+    constr->centreY.SetDone(FALSE);
+  }
+  wxNode *node = GetChildren()->First();
+  while (node)
+  {
+    wxWindow *win = (wxWindow *)node->Data();
+    if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
+      win->ResetConstraints();
+    node = node->Next();
+  }
+}
+
+// Need to distinguish between setting the 'fake' size for
+// windows and sizers, and setting the real values.
+void wxWindow::SetConstraintSizes(const bool recurse)
+{
+  wxLayoutConstraints *constr = GetConstraints();
+  if (constr && constr->left.GetDone() && constr->right.GetDone() &&
+                constr->width.GetDone() && constr->height.GetDone())
+  {
+    int x = constr->left.GetValue();
+    int y = constr->top.GetValue();
+    int w = constr->width.GetValue();
+    int h = constr->height.GetValue();
+
+    // If we don't want to resize this window, just move it...
+    if ((constr->width.GetRelationship() != wxAsIs) ||
+        (constr->height.GetRelationship() != wxAsIs))
+    {
+      // Calls Layout() recursively. AAAGH. How can we stop that.
+      // Simply take Layout() out of non-top level OnSizes.
+      SizerSetSize(x, y, w, h);
+    }
+    else
+    {
+      SizerMove(x, y);
+    }
+  }
+  else if (constr)
+  {
+    char *windowClass = this->GetClassInfo()->GetClassName();
+
+    wxString winName;
+	if (GetName() == "")
+		winName = "unnamed";
+	else
+		winName = GetName();
+    wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass, (const char *)winName);
+    if (!constr->left.GetDone())
+      wxDebugMsg("  unsatisfied 'left' constraint.\n");
+    if (!constr->right.GetDone())
+      wxDebugMsg("  unsatisfied 'right' constraint.\n");
+    if (!constr->width.GetDone())
+      wxDebugMsg("  unsatisfied 'width' constraint.\n");
+    if (!constr->height.GetDone())
+      wxDebugMsg("  unsatisfied 'height' constraint.\n");
+    wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
+  }
+
+  if (recurse)
+  {
+    wxNode *node = GetChildren()->First();
+    while (node)
+    {
+      wxWindow *win = (wxWindow *)node->Data();
+      if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
+        win->SetConstraintSizes();
+      node = node->Next();
+    }
+  }
+}
+
+// This assumes that all sizers are 'on' the same
+// window, i.e. the parent of this window.
+void wxWindow::TransformSizerToActual(int *x, int *y) const
+{
+  if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) ||
+  			 m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) )
+    return;
+    
+  int xp, yp;
+  m_sizerParent->GetPosition(&xp, &yp);
+  m_sizerParent->TransformSizerToActual(&xp, &yp);
+  *x += xp;
+  *y += yp;
+}
+
+void wxWindow::SizerSetSize(const int x, const int y, const int w, const int h)
+{
+	int xx = x;
+	int yy = y;
+  TransformSizerToActual(&xx, &yy);
+  SetSize(xx, yy, w, h);
+}
+
+void wxWindow::SizerMove(const int x, const int y)
+{
+	int xx = x;
+	int yy = y;
+  TransformSizerToActual(&xx, &yy);
+  Move(xx, yy);
+}
+
+// Only set the size/position of the constraint (if any)
+void wxWindow::SetSizeConstraint(const int x, const int y, const int w, const int h)
+{
+  wxLayoutConstraints *constr = GetConstraints();
+  if (constr)
+  {
+    if (x != -1)
+    {
+      constr->left.SetValue(x);
+      constr->left.SetDone(TRUE);
+    }
+    if (y != -1)
+    {
+      constr->top.SetValue(y);
+      constr->top.SetDone(TRUE);
+    }
+    if (w != -1)
+    {
+      constr->width.SetValue(w);
+      constr->width.SetDone(TRUE);
+    }
+    if (h != -1)
+    {
+      constr->height.SetValue(h);
+      constr->height.SetDone(TRUE);
+    }
+  }
+}
+
+void wxWindow::MoveConstraint(const int x, const int y)
+{
+  wxLayoutConstraints *constr = GetConstraints();
+  if (constr)
+  {
+    if (x != -1)
+    {
+      constr->left.SetValue(x);
+      constr->left.SetDone(TRUE);
+    }
+    if (y != -1)
+    {
+      constr->top.SetValue(y);
+      constr->top.SetDone(TRUE);
+    }
+  }
+}
+
+void wxWindow::GetSizeConstraint(int *w, int *h) const
+{
+  wxLayoutConstraints *constr = GetConstraints();
+  if (constr)
+  {
+    *w = constr->width.GetValue();
+    *h = constr->height.GetValue();
+  }
+  else
+    GetSize(w, h);
+}
+
+void wxWindow::GetClientSizeConstraint(int *w, int *h) const
+{
+  wxLayoutConstraints *constr = GetConstraints();
+  if (constr)
+  {
+    *w = constr->width.GetValue();
+    *h = constr->height.GetValue();
+  }
+  else
+    GetClientSize(w, h);
+}
+
+void wxWindow::GetPositionConstraint(int *x, int *y) const
+{
+  wxLayoutConstraints *constr = GetConstraints();
+  if (constr)
+  {
+    *x = constr->left.GetValue();
+    *y = constr->top.GetValue();
+  }
+  else
+    GetPosition(x, y);
+}
+
+bool wxWindow::Close(const bool force)
+{
+  // Let's generalise it to work the same for any window.
+/*
+  if (!IsKindOf(CLASSINFO(wxDialog)) && !IsKindOf(CLASSINFO(wxFrame)))
+  {
+    this->Destroy();
+    return TRUE;
+  }
+*/
+
+  wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
+  event.SetEventObject(this);
+  event.SetForce(force);
+
+  return GetEventHandler()->ProcessEvent(event);
+
+/*
+  if ( !force && event.GetVeto() )
+    return FALSE;
+
+  Show(FALSE);
+
+  if (!wxPendingDelete.Member(this))
+    wxPendingDelete.Append(this);
+
+  return TRUE;
+*/
+}
+
+wxObject* wxWindow::GetChild(const int number) const
+{
+  // Return a pointer to the Nth object in the Panel
+  if (!GetChildren())
+    return(NULL) ;
+  wxNode *node = GetChildren()->First();
+  int n = number;
+  while (node && n--)
+    node = node->Next() ;
+  if (node)
+  {
+    wxObject *obj = (wxObject *)node->Data();
+    return(obj) ;
+  }
+  else
+    return NULL ;
+}
+
+void wxWindow::OnDefaultAction(wxControl *initiatingItem)
+{
+  if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)) && initiatingItem->GetCallback())
+  {
+    wxListBox *lbox = (wxListBox *)initiatingItem;
+    wxCommandEvent event(wxEVENT_TYPE_LISTBOX_DCLICK_COMMAND);
+    event.m_commandInt = -1;
+    if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
+    {
+      event.m_commandString = copystring(lbox->GetStringSelection());
+      event.m_commandInt = lbox->GetSelection();
+      event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
+    }
+    event.m_eventObject = lbox;
+
+    lbox->ProcessCommand(event);
+
+    if (event.m_commandString)
+      delete[] event.m_commandString;
+    return;
+  }
+  
+  wxButton *but = GetDefaultItem();
+  if (but)
+  {
+    wxCommandEvent event(wxEVENT_TYPE_BUTTON_COMMAND);
+    but->Command(event);
+  }
+}
+
+void wxWindow::Clear(void)
+{
+	wxClientDC dc(this);
+    wxBrush brush(GetBackgroundColour(), wxSOLID);
+    dc.SetBackground(brush);
+    dc.Clear();
+}
+
+// Fits the panel around the items
+void wxWindow::Fit(void)
+{
+	int maxX = 0;
+	int maxY = 0;
+	wxNode *node = GetChildren()->First();
+	while ( node )
+	{
+		wxWindow *win = (wxWindow *)node->Data();
+		int wx, wy, ww, wh;
+		win->GetPosition(&wx, &wy);
+		win->GetSize(&ww, &wh);
+		if ( wx + ww > maxX )
+			maxX = wx + ww;
+		if ( wy + wh > maxY )
+			maxY = wy + wh;
+
+		node = node->Next();
+	}
+	SetClientSize(maxX + 5, maxY + 5);
+}
+
+void wxWindow::SetValidator(const wxValidator& validator)
+{
+	if ( m_windowValidator )
+		delete m_windowValidator;
+	m_windowValidator = validator.Clone();
+
+	if ( m_windowValidator )
+		m_windowValidator->SetWindow(this) ;
+}
+
+// Find a window by id or name
+wxWindow *wxWindow::FindWindow(const long id)
+{
+	if ( GetId() == id)
+		return this;
+
+	wxNode *node = GetChildren()->First();
+	while ( node )
+	{
+		wxWindow *child = (wxWindow *)node->Data();
+		wxWindow *found = child->FindWindow(id);
+		if ( found )
+			return found;
+		node = node->Next();
+	}
+	return NULL;
+}
+
+wxWindow *wxWindow::FindWindow(const wxString& name)
+{
+	if ( GetName() == name)
+		return this;
+
+	wxNode *node = GetChildren()->First();
+	while ( node )
+	{
+		wxWindow *child = (wxWindow *)node->Data();
+		wxWindow *found = child->FindWindow(name);
+		if ( found )
+			return found;
+		node = node->Next();
+	}
+	return NULL;
+}
+
+/* TODO
+// Default input behaviour for a scrolling canvas should be to scroll
+// according to the cursor keys pressed
+void wxWindow::OnChar(wxKeyEvent& event)
+{
+  int x_page = 0;
+  int y_page = 0;
+  int start_x = 0;
+  int start_y = 0;
+  // Bugfix Begin
+  int v_width = 0;
+  int v_height = 0;
+  int y_pages = 0;
+  // Bugfix End
+
+  GetScrollUnitsPerPage(&x_page, &y_page);
+  // Bugfix Begin
+  GetVirtualSize(&v_width,&v_height);
+  // Bugfix End
+  ViewStart(&start_x, &start_y);
+  // Bugfix begin
+  if (vert_units)
+	 y_pages = (int)(v_height/vert_units) - y_page;
+
+#ifdef __WINDOWS__
+  int y = 0;
+#else
+  int y = y_page-1;
+#endif
+ // Bugfix End
+  switch (event.keyCode)
+  {
+	 case WXK_PRIOR:
+	 {
+	 // BugFix Begin
+		if (y_page > 0)
+		  {
+		  if (start_y - y_page > 0)
+			 Scroll(start_x, start_y - y_page);
+		  else
+			 Scroll(start_x, 0);
+		  }
+		  // Bugfix End
+		break;
+	 }
+	 case WXK_NEXT:
+	 {
+	 // Bugfix Begin
+		if ((y_page > 0)  && (start_y <= y_pages-y-1))
+						 {
+			if (y_pages + y < start_y + y_page)
+			  Scroll(start_x, y_pages + y);
+			else
+			  Scroll(start_x, start_y + y_page);
+			}
+	 // Bugfix End
+		break;
+	 }
+	 case WXK_UP:
+	 {
+		if ((y_page > 0) && (start_y >= 1))
+		  Scroll(start_x, start_y - 1);
+		break;
+	 }
+	 case WXK_DOWN:
+	 {
+	 // Bugfix Begin
+		if ((y_page > 0) && (start_y <= y_pages-y-1))
+	 // Bugfix End
+		{
+		  Scroll(start_x, start_y + 1);
+		}
+		break;
+	 }
+	 case WXK_LEFT:
+	 {
+		if ((x_page > 0) && (start_x >= 1))
+		  Scroll(start_x - 1, start_y);
+		break;
+	 }
+	 case WXK_RIGHT:
+	 {
+		if (x_page > 0)
+		  Scroll(start_x + 1, start_y);
+		break;
+	 }
+	 case WXK_HOME:
+	 {
+		Scroll(0, 0);
+		break;
+	 }
+	 // This is new
+	 case WXK_END:
+	 {
+		Scroll(start_x, y_pages+y);
+		break;
+	 }
+	 // end
+  }
+}
+*/
+
+// Setup background and foreground colours correctly
+void wxWindow::SetupColours(void)
+{
+	if (GetParent())
+		SetBackgroundColour(GetParent()->GetBackgroundColour());
+}
+
+// Do Update UI processing for child controls
+
+// TODO: should this be implemented for the child window rather
+// than the parent? Then you can override it e.g. for wxCheckBox
+// to do the Right Thing rather than having to assume a fixed number
+// of control classes.
+
+void wxWindow::UpdateWindowUI(void)
+{
+		wxWindowID id = GetId();
+		if (id > 0)
+		{
+			wxUpdateUIEvent event(id);
+			event.m_eventObject = this;
+
+			if (this->GetEventHandler()->ProcessEvent(event))
+			{
+				if (event.GetSetEnabled())
+					this->Enable(event.GetEnabled());
+
+				if (event.GetSetText() && this->IsKindOf(CLASSINFO(wxControl)))
+					((wxControl*)this)->SetLabel(event.GetText());
+
+				if (this->IsKindOf(CLASSINFO(wxCheckBox)))
+				{
+					if (event.GetSetChecked())
+						((wxCheckBox *) this)->SetValue(event.GetChecked());
+				}
+				else if (this->IsKindOf(CLASSINFO(wxRadioButton)))
+				{
+					if (event.GetSetChecked())
+						((wxRadioButton *) this)->SetValue(event.GetChecked());
+				}
+			}
+		}
+
+}
+
+void wxWindow::OnIdle(wxIdleEvent& event)
+{
+	UpdateWindowUI();
+}
+
+// Raise the window to the top of the Z order
+void wxWindow::Raise(void)
+{
+    ::BringWindowToTop((HWND) GetHWND());
+}
+
+// Lower the window to the bottom of the Z order
+void wxWindow::Lower(void)
+{
+    ::SetWindowPos((HWND) GetHWND(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+}
+
diff --git a/src/msw/wx.def b/src/msw/wx.def
new file mode 100644
index 0000000000..28df1caa12
--- /dev/null
+++ b/src/msw/wx.def
@@ -0,0 +1,11 @@
+LIBRARY 	WX
+
+DESCRIPTION	"wxWindows DLL"
+
+VERSION 	1.0
+
+CODE		READ SHARED EXECUTE
+DATA		READ WRITE
+
+
+
diff --git a/src/ntwxwin.mak b/src/ntwxwin.mak
new file mode 100644
index 0000000000..40d03e4331
--- /dev/null
+++ b/src/ntwxwin.mak
@@ -0,0 +1,171 @@
+#
+# File:		ntwxwin.env
+# Author:	Ulrich Leodolter
+# Created:	Wed May 17 08:36:42 1995
+# Updated:
+#
+#	MSVC++ 32-bit makefile include file
+#
+!include <ntwin32.mak>
+
+WIN95=1
+
+!if "$(WIN95)" == "0"
+# With 3.50, Win95 will use your existing icons to show smaller ones.
+# With 4.0, you'll have to follow Win95 procedures for icons or you'll get the
+# default Windows icon.
+APPVER=3.50
+WINVERSION=-DWINVER=0x0350 # Generic WIN32
+!else
+APPVER=3.50 # 4.0
+# This means 'enable Windows 95 features' (in wxWindows and in VC++ 4.0).
+WINVERSION=-DWINVER=0x0400 /D__WIN95__
+!endif
+
+# On Alpha machines, change to CPU=ALPHA
+CPU=i386
+
+# Suffixes
+OBJSUFF=obj
+SRCSUFF=cpp
+
+WINFLAGS=-c -W3 -Dtry=__try -Dexcept=__except -Dleave=__leave -Dfinally=__finally -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -D_X86_=1 -DWIN32 -D__WIN32__ $(WINVERSION)
+#WINLINKFLAGS=/NODEFAULTLIB /INCREMENTAL:NO /NOLOGO -align:0x1000 -machine:$(CPU) -subsystem:windows,$(APPVER)
+WINLINKFLAGS=/INCREMENTAL:NO /NOLOGO -align:0x1000 -machine:$(CPU) -subsystem:windows,$(APPVER)
+#WINLIBS=kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib libc.lib oldnames.lib\
+# comctl32.lib ctl3d32.lib odbc32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib # libci.lib # libci.lib required for VC++ 4.2
+WINLIBS=kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib oldnames.lib\
+ comctl32.lib ctl3d32.lib odbc32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib # libci.lib # libci.lib required for VC++ 4.2
+
+# Change this to your WXWIN directory
+WXDIR=$(WXWIN)
+
+WXSRC=$(WXDIR)\src\msw
+WXINC=$(WXDIR)\include
+WXBASESRC=$(WXDIR)\src\common
+
+#####################################################################
+# These are the possible DLL/non-DLL usages:
+#
+# Type             	_DLL/_WINDLL WXUSINGDLL  WXMAKINGDLL  Library
+#--------------------------------------------------------------------
+# Normal application    -            -           -            wx.lib
+#
+# wxWin as DLL          Defined      -           Defined      wx200.lib
+#
+# App using wxWin DLL   -            Defined     -            wx200.lib
+#
+# App built as one DLL  Defined      -           -            wx.lib
+#
+######################################################################
+#
+# Compiling your app:
+#--------------------
+# when compiling an app to use the DLL version of wxWindows
+# (but not to be a DLL itself), set WXUSINGDLL to 1 in your
+# makefile just before including ntwxwin.mak.
+# To compile wxWin _and_ app itself as a DLL, set DLL to 1
+# in ntwxwin.mak, and do not set WXUSINGDLL.
+#
+# Compiling wxWindows:
+#---------------------
+# Use the dll target to compile wxWindows as DLL; then make 'pch'
+# to generate a precompiled header for your apps to use. BUG: must compile without
+# wxExpr (USE_WX_RESOURCES = 0) for this to link properly. Don't know why yet.
+# Use the dllapp target to compile wxWindows for making a DLL app (not implemented yet)
+
+#DLL=0
+
+!if "$(WXUSINGDLL)" == "1" || "$(WXMAKINGDLL)" == "1"
+WXLIB=$(WXDIR)\lib\wx200.lib
+!else
+WXLIB=$(WXDIR)\lib\wx.lib
+!endif
+
+!if "$(WXUSINGDLL)" == "1"
+EXTRADLLFLAGS=/DWXUSINGDLL=1
+!endif
+
+!if "$(WXMAKINGDLL)" == "1"
+EXTRADLLFLAGS=/DWXMAKINGDLL=1
+!endif
+
+!if "$(WXMAKINGDLL)" == "0" && "$(DLL)" == "1"
+EXTRADLLFLAGS=
+!endif
+
+!if "$(NOMAIN)" == "1"
+EXTRADLLFLAGS=$(EXTRADLLFLAGS) /DNOMAIN
+!endif
+
+INC=-I$(WXINC) -I$(WXDIR)/src/other/png -I$(WXDIR)/src/other/zlib $(EXTRAINC)
+LIBS = $(EXTRALIBS) $(WXLIB) $(WINLIBS)
+
+!ifndef FINAL
+FINAL=0
+!endif
+
+!ifndef DLL
+DLL=0
+!endif
+
+!ifndef DEBUG
+DEBUG=0
+!endif
+
+# Set this to 1 if you don't want to use precompiled headers
+NOPCH=0
+
+MAKEPRECOMP=/YcWX/WXPREC.H
+OPTIONS=
+
+!if "$(FINAL)" == "0"
+OPT = /Od /Gy
+# ***N.B.*** to save space/time, comment out /FR to avoid browse info (.sbr files) being generated
+DEBUG_FLAGS= /Zi # /FR
+LINK_DEBUG_FLAGS=-debug:full -debugtype:cv # /PDB:NONE
+!else
+# /O1 - smallest code
+# /O2 - fastest code
+OPT = /O1 # /O2 # /Od
+DEBUG_FLAGS=
+LINK_DEBUG_FLAGS=/RELEASE
+!endif
+
+!if "$(DLL)" == "0"
+
+!if "$(NOPCH)" == "1"
+PCH=
+PRECOMP=
+MAKEPRECOMP=
+!else
+PCH=WX.PCH
+PRECOMP=/YuWX/WXPREC.H /Fp$(WXDIR)\src\msw\$(PCH) /Fd$(WXDIR)\src\msw\wx.pdb
+MAKEPRECOMP=/YcWX/WXPREC.H
+!endif
+
+CPPFLAGS=$(WINFLAGS) $(DEBUG_FLAGS) $(PRECOMP) $(EXTRAFLAGS) /D__WINDOWS__ /DDEBUG=$(DEBUG) $(INC) $(OPT) $(EXTRADLLFLAGS) /MDd /GX # /D_DEBUG
+# If you don't include wxprec.h, use CPPFLAGS2
+CPPFLAGS2=$(WINFLAGS) $(DEBUG_FLAGS) /D__WINDOWS__ /DDEBUG=$(DEBUG) $(INC) $(EXTRAFLAGS) $(OPT) $(EXTRADLLFLAGS) /MDd /GX # /D_DEBUG
+LINKFLAGS=$(LINK_DEBUG_FLAGS) $(WINLINKFLAGS) -entry:WinMainCRTStartup
+DUMMY=dummy
+
+!else
+
+!if "$(WXMAKINGDLL)" == "1"
+PCH=WXDLL.PCH
+DUMMY=dummydll
+!else
+PCH=WX.PCH
+DUMMY=dummy
+!endif
+
+PRECOMP=/YuWX/WXPREC.H /Fp$(WXDIR)\src\msw\$(PCH) /Fd$(WXDIR)\src\msw\wx.pdb
+CPPFLAGS=$(WINFLAGS) $(DEBUG_FLAGS) $(PRECOMP) $(EXTRAFLAGS) /D__WINDOWS__ /DDEBUG=$(DEBUG) $(INC) $(OPT) /D_DLL /MT $(EXTRADLLFLAGS) /D_WINDOWS /D_WINDLL
+CPPFLAGS2=$(WINFLAGS) $(DEBUG_FLAGS) /D__WINDOWS__ /DDEBUG=$(DEBUG) $(INC) $(EXTRAFLAGS) $(OPT) /D_DLL /MT $(EXTRADLLFLAGS) /D_WINDOWS /D_WINDLL
+LINKFLAGS=$(LINK_DEBUG_FLAGS) -machine:i386 -subsystem:windows,$(APPVER) -dll # -entry:_DllMainCRTStartup$(DLLENTRY)
+!endif
+
+DUMMYOBJ=$(WXDIR)\src\msw\$(DUMMY).obj
+
+
diff --git a/utils/nplugin/makefile.nt b/utils/nplugin/makefile.nt
new file mode 100644
index 0000000000..a6a1d27258
--- /dev/null
+++ b/utils/nplugin/makefile.nt
@@ -0,0 +1,32 @@
+#
+# File:		makefile.nt
+# Author:	Julian Smart
+# Created:	1993
+# Updated:	
+# Copyright:	(c) 1993, AIAI, University of Edinburgh
+#
+# "%W% %G%"
+#
+# Makefile : Builds utilities for Win95, VC++ 4.0
+# Use FINAL=1 argument to nmake to build final version with no debugging
+# info
+
+# Set WXDIR for your system
+WXDIR = $(WXWIN)
+
+THISDIR=$(WXDIR)\utils\nplugin
+
+!include $(WXDIR)\src\ntwxwin.mak
+
+DEBUG_FLAGS="/Zi /FR"
+LINK_DEBUG_FLAGS="/RELEASE"
+
+clean:
+        cd $(WXDIR)\utils\nplugin\src
+        nmake -f makefile.nt clean
+        cd $(WXDIR)\utils\nplugin\samples\simple
+        nmake -f makefile.nt clean
+        cd $(WXDIR)\utils\nplugin\samples\gui
+        nmake -f makefile.nt clean
+        cd $(WXDIR)\utils\nplugin
+
-- 
2.50.0

