[CMAKE]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 2 May 2011 15:18:57 +0000 (15:18 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 2 May 2011 15:18:57 +0000 (15:18 +0000)
sync with trunk (r51543)
(I had to comment out sv-SE.rc in rapps, there are problems with characters)

svn path=/branches/cmake-bringup/; revision=51553

368 files changed:
1  2 
base/applications/CMakeLists.txt
base/applications/calc/convert.c
base/applications/charmap/charmap.c
base/applications/charmap/lang/bg-BG.rc
base/applications/charmap/lang/ca-ES.rc
base/applications/charmap/lang/cs-CZ.rc
base/applications/charmap/lang/de-DE.rc
base/applications/charmap/lang/el-GR.rc
base/applications/charmap/lang/en-US.rc
base/applications/charmap/lang/es-ES.rc
base/applications/charmap/lang/fr-FR.rc
base/applications/charmap/lang/id-ID.rc
base/applications/charmap/lang/it-IT.rc
base/applications/charmap/lang/ja-JP.rc
base/applications/charmap/lang/ko-KR.rc
base/applications/charmap/lang/lt-LT.rc
base/applications/charmap/lang/nl-NL.rc
base/applications/charmap/lang/no-NO.rc
base/applications/charmap/lang/pl-PL.rc
base/applications/charmap/lang/pt-BR.rc
base/applications/charmap/lang/ru-RU.rc
base/applications/charmap/lang/sk-SK.rc
base/applications/charmap/lang/sv-SE.rc
base/applications/charmap/lang/uk-UA.rc
base/applications/charmap/lang/zh-CN.rc
base/applications/charmap/lang/zh-TW.rc
base/applications/charmap/precomp.h
base/applications/charmap/resource.h
base/applications/cmdutils/find/lang/sv-SE.rc
base/applications/dxdiag/lang/sv-SE.rc
base/applications/mplay32/lang/sv-SE.rc
base/applications/mplay32/rsrc.rc
base/applications/msconfig/lang/sv-SE.rc
base/applications/msconfig/msconfig.c
base/applications/msconfig/rsrc.rc
base/applications/mscutils/devmgmt/lang/sv-SE.rc
base/applications/mscutils/devmgmt/rsrc.rc
base/applications/mscutils/eventvwr/eventvwr.c
base/applications/mscutils/eventvwr/lang/bg-BG.rc
base/applications/mscutils/eventvwr/lang/de-DE.rc
base/applications/mscutils/eventvwr/lang/el-GR.rc
base/applications/mscutils/eventvwr/lang/en-US.rc
base/applications/mscutils/eventvwr/lang/es-ES.rc
base/applications/mscutils/eventvwr/lang/fr-FR.rc
base/applications/mscutils/eventvwr/lang/it-IT.rc
base/applications/mscutils/eventvwr/lang/ja-JP.rc
base/applications/mscutils/eventvwr/lang/ko-KR.rc
base/applications/mscutils/eventvwr/lang/no-NO.rc
base/applications/mscutils/eventvwr/lang/pl-PL.rc
base/applications/mscutils/eventvwr/lang/ro-RO.rc
base/applications/mscutils/eventvwr/lang/ru-RU.rc
base/applications/mscutils/eventvwr/lang/sk-SK.rc
base/applications/mscutils/eventvwr/lang/sv-SE.rc
base/applications/mscutils/eventvwr/lang/uk-UA.rc
base/applications/mscutils/eventvwr/resource.h
base/applications/mscutils/eventvwr/rsrc.rc
base/applications/mscutils/servman/lang/sv-SE.rc
base/applications/mscutils/servman/rsrc.rc
base/applications/mspaint/winproc.c
base/applications/mstsc/lang/sv-SE.rc
base/applications/mstsc/rsrc.rc
base/applications/network/ipconfig/ipconfig.rc
base/applications/network/ipconfig/lang/sv-SE.rc
base/applications/network/ping/lang/sv-SE.rc
base/applications/network/ping/ping.rc
base/applications/notepad/lang/no-NO.rc
base/applications/notepad/lang/sv-SE.rc
base/applications/rapps/lang/sv-SE.rc
base/applications/rapps/rapps/abyss.txt
base/applications/rapps/rapps/fap.txt
base/applications/rapps/rapps/firefox2.txt
base/applications/rapps/rapps/firefox3.txt
base/applications/rapps/rapps/firefox36.txt
base/applications/rapps/rapps/kdewin.txt
base/applications/rapps/rapps/mono2.txt
base/applications/rapps/rapps/mpc.txt
base/applications/rapps/rapps/net11.txt
base/applications/rapps/rapps/net20.txt
base/applications/rapps/rapps/net20sp2.txt
base/applications/rapps/rapps/python.txt
base/applications/rapps/rapps/python3.txt
base/applications/rapps/rapps/remood.txt
base/applications/rapps/rapps/steam.txt
base/applications/rapps/rapps/sumatrapdf.txt
base/applications/rapps/rapps/superfinder.txt
base/applications/rapps/rapps/tahoma.txt
base/applications/rapps/rapps/vlc.txt
base/applications/rapps/rapps/wme9.txt
base/applications/rapps/rsrc.rc
base/applications/rapps/winmain.c
base/applications/regedit/childwnd.c
base/applications/regedit/clb/lang/fr-FR.rc
base/applications/regedit/clb/rsrc.rc
base/applications/regedit/framewnd.c
base/applications/regedit/lang/sv-SE.rc
base/applications/screensavers/3dtext/lang/sv-SE.rc
base/applications/screensavers/3dtext/rsrc.rc
base/applications/screensavers/logon/lang/sv-SE.rc
base/applications/screensavers/logon/logon.rc
base/applications/shutdown/lang/sv-SE.rc
base/applications/shutdown/rsrc.rc
base/applications/sndrec32/lang/en-US.rc
base/applications/sndrec32/lang/fr-FR.rc
base/applications/sndrec32/lang/sv-SE.rc
base/applications/sndrec32/rsrc.rc
base/applications/sndvol32/lang/sv-SE.rc
base/applications/sndvol32/sndvol32.c
base/applications/taskmgr/endproc.c
base/applications/taskmgr/lang/pl-PL.rc
base/applications/taskmgr/procpage.c
base/applications/taskmgr/taskmgr.c
base/services/eventlog/CMakeLists.txt
base/services/eventlog/eventlog.c
base/services/eventlog/eventlog.h
base/services/eventlog/eventsource.c
base/services/eventlog/file.c
base/services/eventlog/rpc.c
base/setup/reactos/lang/pl-PL.rc
base/setup/usetup/lang/pl-PL.h
base/setup/usetup/lang/sv-SE.h
base/setup/vmwinst/lang/sv-SE.rc
base/setup/vmwinst/rsrc.rc
base/shell/cmd/lang/sv-SE.rc
base/shell/explorer/desktop/desktop.cpp
base/shell/explorer/explorer.cpp
base/shell/explorer/shell/mainframe.cpp
base/shell/explorer/shell/shellbrowser.cpp
base/shell/explorer/taskbar/desktopbar.cpp
base/shell/explorer/taskbar/taskbar.cpp
base/system/smss/init.c
base/system/smss/initenv.c
base/system/subst/CMakeLists.txt
base/system/subst/lang/en-US.rc
base/system/subst/lang/es-ES.rc
base/system/subst/lang/it-IT.rc
base/system/subst/resource.h
base/system/subst/rsrc.rc
base/system/subst/subst.c
base/system/subst/subst.rbuild
base/system/subst/subst.rc
base/system/winlogon/sas.c
boot/bootdata/hivesys_i386.inf
boot/freeldr/freeldr/CMakeLists.txt
boot/freeldr/freeldr/arch/i386/i386pxe.S
boot/freeldr/freeldr/arch/i386/machpc.c
boot/freeldr/freeldr/arch/i386/pcdisk.c
boot/freeldr/freeldr/disk/ramdisk.c
boot/freeldr/freeldr/fs/fs.c
boot/freeldr/freeldr/fs/pxe.c
boot/freeldr/freeldr/include/arch/i386/hardware.h
boot/freeldr/freeldr/include/arch/i386/machpc.h
boot/freeldr/freeldr/include/arch/i386/pxe.h
boot/freeldr/freeldr/include/freeldr.h
boot/freeldr/freeldr/include/fs/pxe.h
dll/cpl/desk/appearance.c
dll/cpl/desk/lang/fr-FR.rc
dll/win32/comctl32/comctl32_ros.diff
dll/win32/comctl32/listview.c
dll/win32/comctl32/rebar.c
dll/win32/kernel32/file/volume.c
dll/win32/kernel32/misc/ldr.c
dll/win32/mshtml/mshtml.inf
dll/win32/netevent/CMakeLists.txt
dll/win32/shell32/lang/sk-SK.rc
dll/win32/shell32/shlview.c
dll/win32/shimgvw/lang/fr-FR.rc
dll/win32/shimgvw/rsrc.rc
dll/win32/shimgvw/shimgvw.c
dll/win32/shimgvw/shimgvw.spec
dll/win32/user32/controls/appswitch.c
dll/win32/user32/windows/defwnd.c
dll/win32/user32/windows/menu.c
include/ndk/psfuncs.h
include/psdk/devguid.h
include/reactos/mc/neteventmsg.mc
include/reactos/undocuser.h
include/reactos/win32k/ntuser.h
lib/3rdparty/freetype/ChangeLog
lib/3rdparty/freetype/Jamfile
lib/3rdparty/freetype/README
lib/3rdparty/freetype/README.git
lib/3rdparty/freetype/configure
lib/3rdparty/freetype/devel/ftoption.h
lib/3rdparty/freetype/freetype_ros.diff
lib/3rdparty/freetype/include/freetype/config/ftconfig.h
lib/3rdparty/freetype/include/freetype/config/ftoption.h
lib/3rdparty/freetype/include/freetype/freetype.h
lib/3rdparty/freetype/include/freetype/ftcache.h
lib/3rdparty/freetype/include/freetype/fterrdef.h
lib/3rdparty/freetype/include/freetype/ftimage.h
lib/3rdparty/freetype/include/freetype/ftlcdfil.h
lib/3rdparty/freetype/include/freetype/ftlist.h
lib/3rdparty/freetype/include/freetype/ftmodapi.h
lib/3rdparty/freetype/include/freetype/ftrender.h
lib/3rdparty/freetype/include/freetype/ftsystem.h
lib/3rdparty/freetype/include/freetype/internal/ftmemory.h
lib/3rdparty/freetype/include/freetype/internal/ftobjs.h
lib/3rdparty/freetype/include/freetype/ttnameid.h
lib/3rdparty/freetype/include/freetype/tttables.h
lib/3rdparty/freetype/src/autofit/afcjk.c
lib/3rdparty/freetype/src/autofit/afglobal.c
lib/3rdparty/freetype/src/autofit/afhints.c
lib/3rdparty/freetype/src/autofit/afhints.h
lib/3rdparty/freetype/src/autofit/aflatin.c
lib/3rdparty/freetype/src/autofit/aflatin2.c
lib/3rdparty/freetype/src/autofit/afpic.c
lib/3rdparty/freetype/src/base/ftbase.h
lib/3rdparty/freetype/src/base/ftdbgmem.c
lib/3rdparty/freetype/src/base/ftgloadr.c
lib/3rdparty/freetype/src/base/ftglyph.c
lib/3rdparty/freetype/src/base/ftgxval.c
lib/3rdparty/freetype/src/base/ftinit.c
lib/3rdparty/freetype/src/base/ftlcdfil.c
lib/3rdparty/freetype/src/base/ftobjs.c
lib/3rdparty/freetype/src/base/ftotval.c
lib/3rdparty/freetype/src/base/ftoutln.c
lib/3rdparty/freetype/src/base/ftpfr.c
lib/3rdparty/freetype/src/base/ftrfork.c
lib/3rdparty/freetype/src/base/ftstream.c
lib/3rdparty/freetype/src/base/ftsynth.c
lib/3rdparty/freetype/src/base/ftsystem.c
lib/3rdparty/freetype/src/bdf/bdfdrivr.c
lib/3rdparty/freetype/src/bdf/bdflib.c
lib/3rdparty/freetype/src/cache/ftcbasic.c
lib/3rdparty/freetype/src/cache/ftccache.c
lib/3rdparty/freetype/src/cache/ftccache.h
lib/3rdparty/freetype/src/cache/ftccmap.c
lib/3rdparty/freetype/src/cache/ftcglyph.c
lib/3rdparty/freetype/src/cache/ftcglyph.h
lib/3rdparty/freetype/src/cache/ftcimage.c
lib/3rdparty/freetype/src/cache/ftcmanag.c
lib/3rdparty/freetype/src/cache/ftcmanag.h
lib/3rdparty/freetype/src/cache/ftcmru.h
lib/3rdparty/freetype/src/cache/ftcsbits.c
lib/3rdparty/freetype/src/cff/cffcmap.c
lib/3rdparty/freetype/src/cff/cffdrivr.c
lib/3rdparty/freetype/src/cff/cffgload.c
lib/3rdparty/freetype/src/cff/cffload.c
lib/3rdparty/freetype/src/cff/cffload.h
lib/3rdparty/freetype/src/cff/cffobjs.c
lib/3rdparty/freetype/src/cff/cffparse.c
lib/3rdparty/freetype/src/cff/cffpic.c
lib/3rdparty/freetype/src/cff/cfftypes.h
lib/3rdparty/freetype/src/cid/cidgload.c
lib/3rdparty/freetype/src/cid/cidobjs.c
lib/3rdparty/freetype/src/gxvalid/gxvcommn.c
lib/3rdparty/freetype/src/gzip/ftgzip.c
lib/3rdparty/freetype/src/lzw/ftlzw.c
lib/3rdparty/freetype/src/otvalid/otvmath.c
lib/3rdparty/freetype/src/otvalid/otvmod.c
lib/3rdparty/freetype/src/pcf/pcfdrivr.c
lib/3rdparty/freetype/src/pcf/pcfread.c
lib/3rdparty/freetype/src/pfr/pfrdrivr.c
lib/3rdparty/freetype/src/pfr/pfrgload.c
lib/3rdparty/freetype/src/pfr/pfrload.c
lib/3rdparty/freetype/src/pfr/pfrobjs.c
lib/3rdparty/freetype/src/pfr/pfrsbit.c
lib/3rdparty/freetype/src/psaux/afmparse.c
lib/3rdparty/freetype/src/psaux/afmparse.h
lib/3rdparty/freetype/src/psaux/psobjs.c
lib/3rdparty/freetype/src/psaux/t1decode.c
lib/3rdparty/freetype/src/pshinter/pshalgo.c
lib/3rdparty/freetype/src/pshinter/pshglob.c
lib/3rdparty/freetype/src/pshinter/pshpic.c
lib/3rdparty/freetype/src/psnames/psmodule.c
lib/3rdparty/freetype/src/psnames/pspic.c
lib/3rdparty/freetype/src/raster/ftmisc.h
lib/3rdparty/freetype/src/raster/ftraster.c
lib/3rdparty/freetype/src/raster/rastpic.c
lib/3rdparty/freetype/src/sfnt/sfdriver.c
lib/3rdparty/freetype/src/sfnt/sfntpic.c
lib/3rdparty/freetype/src/sfnt/sfobjs.c
lib/3rdparty/freetype/src/sfnt/ttbdf.c
lib/3rdparty/freetype/src/sfnt/ttcmap.c
lib/3rdparty/freetype/src/sfnt/ttkern.c
lib/3rdparty/freetype/src/sfnt/ttload.c
lib/3rdparty/freetype/src/sfnt/ttpost.c
lib/3rdparty/freetype/src/sfnt/ttsbit.c
lib/3rdparty/freetype/src/smooth/ftgrays.c
lib/3rdparty/freetype/src/smooth/ftsmooth.c
lib/3rdparty/freetype/src/smooth/ftspic.c
lib/3rdparty/freetype/src/tools/apinames.c
lib/3rdparty/freetype/src/truetype/ttgload.c
lib/3rdparty/freetype/src/truetype/ttgxvar.c
lib/3rdparty/freetype/src/truetype/ttinterp.c
lib/3rdparty/freetype/src/truetype/ttinterp.h
lib/3rdparty/freetype/src/truetype/ttobjs.c
lib/3rdparty/freetype/src/truetype/ttpic.c
lib/3rdparty/freetype/src/truetype/ttpload.c
lib/3rdparty/freetype/src/type1/t1afm.c
lib/3rdparty/freetype/src/type1/t1load.c
lib/3rdparty/freetype/src/type1/t1objs.c
lib/3rdparty/freetype/src/type42/t42objs.c
lib/3rdparty/freetype/src/type42/t42parse.c
lib/3rdparty/freetype/src/winfonts/winfnt.c
lib/3rdparty/mingw/crtdll.c
ntoskrnl/fstub/disksup.c
ntoskrnl/include/internal/ob.h
ntoskrnl/ob/obinit.c
ntoskrnl/ob/oblife.c
ntoskrnl/ob/oblink.c
ntoskrnl/ob/obname.c
subsystems/win32/csrss/win32csr/CMakeLists.txt
subsystems/win32/csrss/win32csr/dllmain.c
subsystems/win32/csrss/win32csr/file.c
subsystems/win32/csrss/win32csr/guiconsole.c
subsystems/win32/csrss/win32csr/lang/sk-SK.rc
subsystems/win32/win32k/eng/driverobj.c
subsystems/win32/win32k/eng/engbrush.c
subsystems/win32/win32k/eng/engwindow.c
subsystems/win32/win32k/eng/pdevobj.c
subsystems/win32/win32k/eng/surface.c
subsystems/win32/win32k/include/brush.h
subsystems/win32/win32k/include/color.h
subsystems/win32/win32k/include/dc.h
subsystems/win32/win32k/include/dib.h
subsystems/win32/win32k/include/driverobj.h
subsystems/win32/win32k/include/gdidebug.h
subsystems/win32/win32k/include/gdiobj.h
subsystems/win32/win32k/include/hotkey.h
subsystems/win32/win32k/include/misc.h
subsystems/win32/win32k/include/palette.h
subsystems/win32/win32k/include/path.h
subsystems/win32/win32k/include/pen.h
subsystems/win32/win32k/include/region.h
subsystems/win32/win32k/include/surface.h
subsystems/win32/win32k/include/text.h
subsystems/win32/win32k/include/win32.h
subsystems/win32/win32k/include/win32kp.h
subsystems/win32/win32k/main/dllmain.c
subsystems/win32/win32k/ntddraw/dxeng.c
subsystems/win32/win32k/ntuser/cursoricon.c
subsystems/win32/win32k/ntuser/defwnd.c
subsystems/win32/win32k/ntuser/desktop.c
subsystems/win32/win32k/ntuser/hotkey.c
subsystems/win32/win32k/ntuser/input.c
subsystems/win32/win32k/ntuser/message.c
subsystems/win32/win32k/ntuser/monitor.c
subsystems/win32/win32k/ntuser/msgqueue.c
subsystems/win32/win32k/ntuser/ntstubs.c
subsystems/win32/win32k/ntuser/painting.c
subsystems/win32/win32k/ntuser/sysparams.c
subsystems/win32/win32k/ntuser/vis.c
subsystems/win32/win32k/ntuser/windc.c
subsystems/win32/win32k/ntuser/window.c
subsystems/win32/win32k/ntuser/winpos.c
subsystems/win32/win32k/ntuser/winsta.c
subsystems/win32/win32k/objects/arc.c
subsystems/win32/win32k/objects/bitblt.c
subsystems/win32/win32k/objects/bitmaps.c
subsystems/win32/win32k/objects/brush.c
subsystems/win32/win32k/objects/cliprgn.c
subsystems/win32/win32k/objects/dcattr.c
subsystems/win32/win32k/objects/dclife.c
subsystems/win32/win32k/objects/dcobjs.c
subsystems/win32/win32k/objects/dcstate.c
subsystems/win32/win32k/objects/dibobj.c
subsystems/win32/win32k/objects/drawing.c
subsystems/win32/win32k/objects/fillshap.c
subsystems/win32/win32k/objects/gdibatch.c
subsystems/win32/win32k/objects/gdidbg.c
subsystems/win32/win32k/objects/gdiobj.c
subsystems/win32/win32k/objects/gdipool.c
subsystems/win32/win32k/objects/icm.c
subsystems/win32/win32k/objects/palette.c
subsystems/win32/win32k/objects/path.c
subsystems/win32/win32k/objects/pen.c
subsystems/win32/win32k/objects/region.c

index 7ff5a0b,0000000..0540d69
mode 100644,000000..100644
--- /dev/null
@@@ -1,37 -1,0 +1,37 @@@
- add_subdirectory(msconfig)
 +
 +add_subdirectory(cacls)
 +add_subdirectory(calc)
 +add_subdirectory(charmap)
 +add_subdirectory(cmdutils)
 +add_subdirectory(control)
 +add_subdirectory(dxdiag)
 +add_subdirectory(extrac32)
 +add_subdirectory(findstr)
 +add_subdirectory(fontview)
 +add_subdirectory(games)
 +add_subdirectory(hh)
 +add_subdirectory(iexplore)
 +add_subdirectory(kbswitch)
 +add_subdirectory(logoff)
 +add_subdirectory(magnify)
 +add_subdirectory(mmc)
 +add_subdirectory(mplay32)
++# add_subdirectory(msconfig)
 +add_subdirectory(mscutils)
 +add_subdirectory(mstsc)
 +add_subdirectory(network)
 +add_subdirectory(notepad)
 +add_subdirectory(mspaint)
 +add_subdirectory(rapps)
 +add_subdirectory(regedit)
 +add_subdirectory(regedt32)
 +add_subdirectory(sc)
 +add_subdirectory(screensavers)
 +add_subdirectory(shutdown)
 +add_subdirectory(sndrec32)
 +add_subdirectory(sndvol32)
 +add_subdirectory(taskmgr)
 +add_subdirectory(winhlp32)
 +add_subdirectory(winver)
 +add_subdirectory(wordpad)
 +add_subdirectory(write)
Simple merge
Simple merge
Simple merge
Simple merge
index 1bab332,0000000..5ea9624
mode 100644,000000..100644
--- /dev/null
@@@ -1,17 -1,0 +1,18 @@@
 +#include <windows.h>
 +#include "resource.h"
 +
 +#include "lang/bg-BG.rc"
 +#include "lang/cs-CZ.rc"
 +#include "lang/de-DE.rc"
 +#include "lang/en-US.rc"
 +#include "lang/es-ES.rc"
 +#include "lang/fr-FR.rc"
 +#include "lang/it-IT.rc"
 +// #include "lang/ja-JP.rc" FIXME: iconv issue
 +#include "lang/nl-NL.rc"
 +#include "lang/no-NO.rc"
 +#include "lang/pl-PL.rc"
 +#include "lang/ru-RU.rc"
 +#include "lang/sk-SK.rc"
++#include "lang/sv-SE.rc"
 +#include "lang/uk-UA.rc"
Simple merge
Simple merge
index b4cec35,0000000..5a099c3
mode 100644,000000..100644
--- /dev/null
@@@ -1,32 -1,0 +1,33 @@@
 +#include <windows.h>
 +#include "resource.h"
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +
 +IDI_MAIN_ICON   ICON    "res/computer.ico"
 +IDB_ROOT_IMAGE  BITMAP  "res/root.bmp"
 +
 +/* main toolbar icons */
 +IDB_PROP    BITMAP DISCARDABLE "res/properties.bmp"
 +IDB_REFRESH BITMAP DISCARDABLE "res/refresh.bmp"
 +IDB_HELP    BITMAP DISCARDABLE "res/help.bmp"
 +IDB_EXIT    BITMAP DISCARDABLE "res/exit.bmp"
 +
 +#include "lang/bg-BG.rc"
 +#include "lang/de-DE.rc"
 +#include "lang/el-GR.rc"
 +#include "lang/en-US.rc"
 +#include "lang/es-ES.rc"
 +#include "lang/fr-FR.rc"
 +#include "lang/id-ID.rc"
 +#include "lang/it-IT.rc"
 +//#include "lang/ja-JP.rc" FIXME: iconv issue
 +#include "lang/ko-KR.rc"
 +#include "lang/no-NO.rc"
 +#include "lang/pl-PL.rc"
 +#include "lang/ro-RO.rc"
 +#include "lang/ru-RU.rc"
 +#include "lang/sk-SK.rc"
++#include "lang/sv-SE.rc"
 +#include "lang/th-TH.rc"
 +#include "lang/uk-UA.rc"
 +
index b109367,0000000..43d786e
mode 100644,000000..100644
--- /dev/null
@@@ -1,27 -1,0 +1,28 @@@
 +#include <windows.h>
 +#include "resource.h"
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +
 +// Shared icons
 +IDI_EVENTVWR            ICON  "res/eventvwr.ico"
 +IDI_WARNINGICON         ICON  "res/warning.ico"
 +IDI_INFORMATIONICON     ICON  "res/info.ico"
 +IDI_ERRORICON           ICON  "res/error.ico"
 +
 +#include "lang/bg-BG.rc"
 +#include "lang/de-DE.rc"
 +#include "lang/el-GR.rc"
 +#include "lang/en-US.rc"
 +#include "lang/es-ES.rc"
 +#include "lang/fr-FR.rc"
 +#include "lang/it-IT.rc"
 +//#include "lang/ja-JP.rc" FIXME: iconv issue
 +#include "lang/ko-KR.rc"
 +#include "lang/no-NO.rc"
 +//#include "lang/pl-PL.rc" FIXME: iconv issue
 +#include "lang/ro-RO.rc"
 +#include "lang/ru-RU.rc"
 +#include "lang/sk-SK.rc"
++#include "lang/sv-SE.rc"
 +#include "lang/uk-UA.rc"
 +
index 63b5dfb,0000000..21dafd6
mode 100644,000000..100644
--- /dev/null
@@@ -1,39 -1,0 +1,40 @@@
 +#include <windows.h>
 +#include "resource.h"
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +
 +IDI_SM_ICON ICON "res/system.ico"
 +
 +/* main toolbar icons */
 +IDB_PROP    BITMAP DISCARDABLE "res/properties.bmp"
 +IDB_REFRESH BITMAP DISCARDABLE "res/refresh.bmp"
 +IDB_EXPORT  BITMAP DISCARDABLE "res/export.bmp"
 +IDB_CREATE  BITMAP DISCARDABLE "res/create.bmp"
 +IDB_DELETE  BITMAP DISCARDABLE "res/delete.bmp"
 +IDB_START   BITMAP DISCARDABLE "res/start.bmp"
 +IDB_STOP    BITMAP DISCARDABLE "res/stop.bmp"
 +IDB_PAUSE   BITMAP DISCARDABLE "res/pause.bmp"
 +IDB_RESTART BITMAP DISCARDABLE "res/restart.bmp"
 +
 +IDI_NODEPENDS   ICON "res/nodepends.ico"
 +IDI_SERVICE     ICON "res/system.ico"
 +IDI_DRIVER      ICON "res/driver.ico"
 +
 +#include "lang/bg-BG.rc"
 +#include "lang/de-DE.rc"
 +#include "lang/el-GR.rc"
 +#include "lang/en-US.rc"
 +#include "lang/es-ES.rc"
 +#include "lang/fr-FR.rc"
 +#include "lang/id-ID.rc"
 +#include "lang/it-IT.rc"
 +//#include "lang/ja-JP.rc" FIXME: iconv issue
 +#include "lang/ko-KR.rc"
 +#include "lang/no-NO.rc"
 +#include "lang/pl-PL.rc"
 +#include "lang/ro-RO.rc"
 +#include "lang/ru-RU.rc"
 +#include "lang/sk-SK.rc"
++#include "lang/sv-SE.rc"
 +#include "lang/th-TH.rc"
 +#include "lang/uk-UA.rc"
Simple merge
index 6d1bedc,0000000..e37fd29
mode 100644,000000..100644
--- /dev/null
@@@ -1,30 -1,0 +1,31 @@@
 +#include <windows.h>
 +#include "resource.h"
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +
 +IDI_MSTSC   ICON   "res/mstsc.ico"
 +IDI_LOGON   ICON   "res/logon.ico"
 +IDI_CONN    ICON   "res/connection.ico"
 +IDI_REMOTE  ICON   "res/remote.ico"
 +IDI_COLORS  ICON   "res/colors.ico"
 +
 +IDB_HEADER  BITMAP "res/header.bmp"
 +IDB_SPECT   BITMAP "res/spectrum.bmp"
 +
 +#include "lang/bg-BG.rc"
 +#include "lang/ca-ES.rc"
 +#include "lang/de-DE.rc"
 +#include "lang/el-GR.rc"
 +#include "lang/en-US.rc"
 +#include "lang/es-ES.rc"
 +#include "lang/fr-FR.rc"
 +#include "lang/it-IT.rc"
 +//#include "lang/ja-JP.rc" FIXME: iconv issue
 +#include "lang/ko-KR.rc"
 +#include "lang/lt-LT.rc"
 +#include "lang/no-NO.rc"
 +#include "lang/pl-PL.rc"
 +#include "lang/ru-RU.rc"
 +#include "lang/sk-SK.rc"
++#include "lang/sv-SE.rc"
 +#include "lang/uk-UA.rc"
index 181bcf4,0000000..a92453f
mode 100644,000000..100644
--- /dev/null
@@@ -1,202 -1,0 +1,202 @@@
-  * FILE:                  \base\applications\rapps\lang\sv-SE.rc
 +/*
 + * PROJECT:         ReactOS RAPPS
-  * Translation:      Jaix Bly
++ * FILE:            \base\applications\rapps\lang\sv-SE.rc
 + * PURPOSE:         Swedish resource file
-               MENUITEM "&Ändra",   ID_MODIFY
++ * Translation:     Jaix Bly
 + */
 +
 +#pragma code_page(65001) // UTF-8
 +
 +LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL
 +
 +IDR_MAINMENU MENU
 +BEGIN
 +      POPUP "&Arkiv"
 +      BEGIN
 +              MENUITEM "&Inställningar", ID_SETTINGS
 +              MENUITEM SEPARATOR
 +              MENUITEM "A&vsluta",     ID_EXIT
 +      END
 +      POPUP "&Program"
 +      BEGIN
 +              MENUITEM "&Installera",  ID_INSTALL
 +              MENUITEM "&Avinstallera",ID_UNINSTALL
-               MENUITEM "&Uppdatere",  ID_REFRESH
++              MENUITEM "&Ã\x84ndra",   ID_MODIFY
 +              MENUITEM SEPARATOR
 +              MENUITEM "&Ta bort från Registret", ID_REGREMOVE
 +              MENUITEM SEPARATOR
-               MENUITEM "&Öppne länk i webläsare", ID_OPEN_LINK
-               MENUITEM "&Kopier länk till urklipp", ID_COPY_LINK
++              MENUITEM "&Uppdatera",  ID_REFRESH
 +      END
 +      POPUP "Hjälp"
 +      BEGIN
 +              MENUITEM "Hjälp",      ID_HELP, GRAYED
 +              MENUITEM "Om...",     ID_ABOUT
 +      END
 +END
 +
 +IDR_LINKMENU MENU
 +BEGIN
 +      POPUP "popup"
 +      BEGIN
-               MENUITEM "&Ändre",    ID_MODIFY
++              MENUITEM "&Öppna länk i webläsare", ID_OPEN_LINK
++              MENUITEM "&Kopiera länk till urklipp", ID_COPY_LINK
 +      END
 +END
 +
 +IDR_APPLICATIONMENU MENU
 +BEGIN
 +      POPUP "popup"
 +      BEGIN
 +              MENUITEM "&Installera",   ID_INSTALL
 +              MENUITEM "&Avinstallera", ID_UNINSTALL
-       GROUPBOX "Allmänna", -1, 4, 2, 240, 61
-       AUTOCHECKBOX "&Spara fönster position", IDC_SAVE_WINDOW_POS, 15, 12, 219, 12
-       AUTOCHECKBOX "&Uppdatera listan med tillgängliga program vid start", IDC_UPDATE_AVLIST, 15, 29, 219, 12
++              MENUITEM "&Ändra",    ID_MODIFY
 +              MENUITEM SEPARATOR
 +              MENUITEM "&Ta bort från Registret", ID_REGREMOVE
 +              MENUITEM SEPARATOR
 +              MENUITEM "&Uppdatera",   ID_REFRESH
 +      END
 +END
 +
 +IDD_SETTINGS_DIALOG DIALOGEX DISCARDABLE  0, 0, 250, 144
 +STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 +CAPTION "Inställningar"
 +FONT 8, "MS Shell Dlg"
 +BEGIN
-       AUTOCHECKBOX "&Ta bort programms installerare efter installation", IDC_DEL_AFTER_INSTALL, 16, 100, 218, 12
++      GROUPBOX "Allmänna", -1, 4, 2, 240, 61
++      AUTOCHECKBOX "&Spara fönsterposition", IDC_SAVE_WINDOW_POS, 15, 12, 219, 12
++      AUTOCHECKBOX "&Uppdatera listan med tillgängliga program vid start", IDC_UPDATE_AVLIST, 15, 29, 219, 12
 +      AUTOCHECKBOX "&Logga ur installation och borttagning program", IDC_LOG_ENABLED, 15, 46, 219, 12
 +
 +      GROUPBOX "Nerladding", -1, 4, 65, 240, 51
 +      LTEXT "Mapp för nerladdningar:", -1, 16, 75, 100, 9
 +      EDITTEXT IDC_DOWNLOAD_DIR_EDIT, 15, 86, 166, 12, WS_CHILD | WS_VISIBLE | WS_GROUP
 +      PUSHBUTTON "&Välj", IDC_CHOOSE, 187, 85, 50, 14
-       PUSHBUTTON "Förinställd", IDC_DEFAULT_SETTINGS, 8, 124, 60, 14
++      AUTOCHECKBOX "&Ta bort programinstallerare efter installation", IDC_DEL_AFTER_INSTALL, 16, 100, 218, 12
 +
-       IDS_WELCOME_TITLE "Välkommen till ReactOS programhanterare!\n\n"
-       IDS_WELCOME_TEXT "Välj en kategori till vänstre, och sedan ett program för att installera eller avinstallera.\nReactOS Web sida: "
++      PUSHBUTTON "Standard", IDC_DEFAULT_SETTINGS, 8, 124, 60, 14
 +      PUSHBUTTON "OK", IDOK, 116, 124, 60, 14
 +      PUSHBUTTON "Avbryt", IDCANCEL, 181, 124, 60, 14
 +END
 +
 +IDD_INSTALL_DIALOG DIALOGEX DISCARDABLE  0, 0, 216, 97
 +STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 +CAPTION "Programinstallation"
 +FONT 8, "MS Shell Dlg"
 +BEGIN
 +      LTEXT "...", IDC_INSTALL_TEXT, 4, 5, 209, 35
 +
 +      AUTORADIOBUTTON "&Installera från disk (CD or DVD)", IDC_CD_INSTALL, 10, 46, 197, 11, WS_GROUP
 +      AUTORADIOBUTTON "&Ladda ner och installera", IDC_DOWNLOAD_INSTALL, 10, 59, 197, 11, NOT WS_TABSTOP
 +
 +      PUSHBUTTON "OK", IDOK, 86, 78, 60, 14
 +      PUSHBUTTON "Avbryt", IDCANCEL, 150, 78, 60, 14
 +END
 +
 +IDD_DOWNLOAD_DIALOG DIALOGEX LOADONCALL MOVEABLE DISCARDABLE  0, 0, 220, 76
 +STYLE DS_SHELLFONT | DS_CENTER | WS_BORDER | WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_VISIBLE
 +CAPTION "Ladda ner..."
 +FONT 8, "MS Shell Dlg"
 +BEGIN
 +    CONTROL "Progress1", IDC_DOWNLOAD_PROGRESS, "msctls_progress32", WS_BORDER | PBS_SMOOTH, 10, 10, 200, 12
 +    LTEXT "", IDC_DOWNLOAD_STATUS, 10, 30, 200, 10, SS_CENTER
 +    PUSHBUTTON "Avbryt", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
 +END
 +
 +IDD_ABOUT_DIALOG DIALOGEX 22, 16, 190, 66
 +STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
 +CAPTION "Om"
 +FONT 8, "MS Shell Dlg"
 +BEGIN
 +      LTEXT "ReactOS Programhanterare\nCopyright (C) 2009\nav Dmitry Chapyshev (dmitry@reactos.org)", IDC_STATIC, 48, 7, 130, 39
 +      PUSHBUTTON "Stäng", IDOK, 133, 46, 50, 14
 +      ICON IDI_MAIN, IDC_STATIC, 10, 10, 7, 30
 +END
 +
 +STRINGTABLE DISCARDABLE
 +BEGIN
 +      IDS_TOOLTIP_INSTALL "Installera"
 +      IDS_TOOLTIP_UNINSTALL "Avinstallera"
 +      IDS_TOOLTIP_MODIFY "Redigera"
 +      IDS_TOOLTIP_SETTINGS "Inställingar"
 +      IDS_TOOLTIP_REFRESH "Uppdatera"
 +      IDS_TOOLTIP_EXIT "Avsluta"
 +END
 +
 +STRINGTABLE DISCARDABLE
 +BEGIN
 +      IDS_APP_NAME "Namn"
 +      IDS_APP_INST_VERSION "Version"
 +      IDS_APP_DESCRIPTION "Beskrivning"
 +END
 +
 +STRINGTABLE DISCARDABLE
 +BEGIN
 +      IDS_INFO_VERSION "\nVersion: "
 +      IDS_INFO_DESCRIPTION "\nBeskrivning: "
 +      IDS_INFO_PUBLISHER "\nUtgivare: "
 +      IDS_INFO_HELPLINK "\nHjälplänk: "
 +      IDS_INFO_HELPPHONE "\nHjälptelefon: "
 +      IDS_INFO_README "\nLäs mig: "
 +      IDS_INFO_REGOWNER "\nRegistrerad ägare: "
 +      IDS_INFO_PRODUCTID "\nProdukt ID: "
 +      IDS_INFO_CONTACT "\nKontakt: "
 +      IDS_INFO_UPDATEINFO "\nUppdaterinsinformation: "
 +      IDS_INFO_INFOABOUT "\nInformation om: "
 +      IDS_INFO_COMMENTS "\nKommentarer: "
 +      IDS_INFO_INSTLOCATION "\nInstallationsplacering: "
 +      IDS_INFO_INSTALLSRC "\nInstallationskälla: "
 +      IDS_INFO_UNINSTALLSTR "\nAvinstallationssträng: "
 +      IDS_INFO_MODIFYPATH "\nÄndra sökväg: "
 +      IDS_INFO_INSTALLDATE "\nInstallationsdatum: "
 +END
 +
 +STRINGTABLE DISCARDABLE
 +BEGIN
 +      IDS_AINFO_VERSION "\nVersion: "
 +      IDS_AINFO_DESCRIPTION "\nBeskrivning: "
 +      IDS_AINFO_SIZE "\nStorlek: "
 +      IDS_AINFO_URLSITE "\nHemsida: "
 +      IDS_AINFO_LICENCE "\nLicens: "
 +END
 +
 +STRINGTABLE DISCARDABLE
 +BEGIN
 +      IDS_CAT_AUDIO "Audio"
 +      IDS_CAT_DEVEL "Utveckling"
 +      IDS_CAT_DRIVERS "Drivrutiner"
 +      IDS_CAT_EDU "Edutainment"
 +      IDS_CAT_ENGINEER "Engineering"
 +      IDS_CAT_FINANCE "Finans"
 +      IDS_CAT_GAMES "Spel & kul"
 +      IDS_CAT_GRAPHICS "Grafik"
 +      IDS_CAT_INTERNET "Internet & Nätverk"
 +      IDS_CAT_LIBS "Bibliotek"
 +      IDS_CAT_OFFICE "Kontor"
 +      IDS_CAT_OTHER "Annat"
 +      IDS_CAT_SCIENCE "Vetenskap"
 +      IDS_CAT_TOOLS "Verktyg"
 +      IDS_CAT_VIDEO "Video"
 +END
 +
 +STRINGTABLE DISCARDABLE
 +BEGIN
 +      IDS_APPTITLE "ReactOS programhanterare"
 +      IDS_SEARCH_TEXT "Sök..."
 +      IDS_INSTALL "Installera"
 +      IDS_UNINSTALL "Avinstallera"
 +      IDS_MODIFY "Ändra"
 +      IDS_APPS_COUNT "Programantal: %d"
-       IDS_CHOOSE_FOLDER_ERROR "Du har specificrat en obefintlig mapp!"
++      IDS_WELCOME_TITLE "Välkommen till ReactOS programhanterare!\n\n"
++      IDS_WELCOME_TEXT "Välj en kategori till vänster, och sedan ett program för att installera eller avinstallera.\nReactOS Web sida: "
 +      IDS_WELCOME_URL "http://www.reactos.org"
 +      IDS_INSTALLED "Installerat"
 +      IDS_AVAILABLEFORINST "Tillgängliga for installation"
 +      IDS_UPDATES "Uppdateringar"
 +      IDS_APPLICATIONS "Program"
 +      IDS_CHOOSE_FOLDER_TEXT "Välj en mapp som kommer att användas för nerladdning av program:"
++      IDS_CHOOSE_FOLDER_ERROR "Du har specificrat en ej existerande mapp! Vill du skapa den?"
 +      IDS_USER_NOT_ADMIN "Du måste vara administratör för att starta ""ReactOS programhanterare""!"
 +      IDS_APP_REG_REMOVE "Är du säker på att du vill ta bort data det installerade programmets data från registret?"
 +      IDS_INFORMATION "Information"
 +      IDS_UNABLE_TO_REMOVE "Det gick ej att ta bort programmets data från registret!"
 +END
Simple merge
Simple merge
Simple merge
index 6b04463,0000000..ad83eca
mode 100644,000000..100644
--- /dev/null
@@@ -1,14 -1,0 +1,14 @@@
- #include "lang/sv-SE.rc"
 +#include "lang/bg-BG.rc"
 +#include "lang/cs-CZ.rc"
 +#include "lang/de-DE.rc"
 +#include "lang/en-US.rc"
 +#include "lang/es-ES.rc"
 +#include "lang/fr-FR.rc"
 +#include "lang/it-IT.rc"
 +//#include "lang/ja-JP.rc" FIXME: iconv issue
 +#include "lang/no-NO.rc"
 +#include "lang/pl-PL.rc"
 +#include "lang/ru-RU.rc"
 +#include "lang/sk-SK.rc"
++//#include "lang/sv-SE.rc"
 +#include "lang/uk-UA.rc"
Simple merge
Simple merge
Simple merge
Simple merge
index 14464dc,0000000..6392735
mode 100644,000000..100644
--- /dev/null
@@@ -1,31 -1,0 +1,32 @@@
 +#include <windows.h>
 +#include <scrnsave.h>
 +#include "resource.h"
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +
 +#define REACTOS_VERSION_DLL
 +#define REACTOS_STR_FILE_DESCRIPTION    "ReactOS Logon ScreenSaver\0"
 +#define REACTOS_STR_INTERNAL_NAME       "logon\0"
 +#define REACTOS_STR_ORIGINAL_FILENAME   "logon.scr\0"
 +
 +#include <reactos/version.rc>
 +
 +IDB_WORKSTATION BITMAP DISCARDABLE    "res/0.bmp"
 +IDB_SERVER    BITMAP DISCARDABLE      "res/1.bmp"
 +
 +#include "lang/bg-BG.rc"
 +#include "lang/de-DE.rc"
 +#include "lang/en-US.rc"
 +#include "lang/es-ES.rc"
 +#include "lang/eu-ES.rc"
 +#include "lang/fr-FR.rc"
 +//#include "lang/ja-JP.rc" FIXME: iconv issue
 +#include "lang/ko-KR.rc"
 +#include "lang/lt-LT.rc"
 +#include "lang/nl-NL.rc"
 +#include "lang/no-NO.rc"
 +#include "lang/ro-RO.rc"
 +#include "lang/sk-SK.rc"
++#include "lang/sv-SE.rc"
 +#include "lang/uk-UA.rc"
 +#include "lang/ru-RU.rc"
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 570c1c3,0000000..a8f5b4a
mode 100644,000000..100644
--- /dev/null
@@@ -1,21 -1,0 +1,22 @@@
 +
 +include_directories(${REACTOS_BINARY_DIR}/include/reactos/idl)
 +
 +set_unicode()
 +
 +list(APPEND SOURCE
 +    eventlog.c
++    eventsource.c
 +    logport.c
 +    eventlog.rc
 +    rpc.c
 +    file.c)
 +
 +add_executable(eventlog ${CMAKE_CURRENT_BINARY_DIR}/eventlog_eventlog.h.gch ${SOURCE})
 +
 +target_link_libraries(eventlog eventlogrpc ${PSEH_LIB})
 +
 +add_pch(eventlog ${CMAKE_CURRENT_SOURCE_DIR}/eventlog.h ${SOURCE})
 +
 +set_module_type(eventlog win32cui)
 +add_importlibs(eventlog advapi32 rpcrt4 msvcrt kernel32 ntdll)
 +add_cab_target(eventlog 1)
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 0000000,a2aba4d..a2aba4d
mode 000000,100644..100644
--- /dev/null
index db03960,0000000..11cb5ba
mode 100644,000000..100644
--- /dev/null
@@@ -1,32 -1,0 +1,33 @@@
 +#include <windows.h>
 +#include "vmwinst.h"
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +
 +/* Bitmaps */
 +IDB_WATERMARK BITMAP "resources/watermark.bmp"
 +IDB_HEADER    BITMAP "resources/header.bmp"
 +
 +/*
 + * Everything specific to any language goes in one of the specific
 + * files. Note that you can and may override resources which also have
 + * a neutral version. This is to get localized bitmaps for example.
 + */
 +#include "lang/bg-BG.rc"
 +#include "lang/cs-CZ.rc"
 +#include "lang/da-DK.rc"
 +#include "lang/de-DE.rc"
 +#include "lang/el-GR.rc"
 +#include "lang/en-US.rc"
 +#include "lang/es-ES.rc"
 +#include "lang/fr-FR.rc"
 +#include "lang/hu-HU.rc"
 +#include "lang/id-ID.rc"
 +#include "lang/it-IT.rc"
 +//#include "lang/ja-JP.rc" FIXME: iconv issue
 +#include "lang/lt-LT.rc"
 +#include "lang/no-NO.rc"
 +#include "lang/pl-PL.rc"
 +#include "lang/ru-RU.rc"
++#include "lang/sv-SE.rc"
 +#include "lang/uk-UA.rc"
 +#include "lang/zh-CN.rc"
index 0000000,e2630f2..e2630f2
mode 000000,100644..100644
--- /dev/null
Simple merge
Simple merge
Simple merge
index fd3997a,0000000..8910445
mode 100644,000000..100644
--- /dev/null
@@@ -1,8 -1,0 +1,11 @@@
- add_importlibs(subst msvcrt kernel32 ntdll)
 +
++include_directories(.)
++set_rc_compiler()
++
 +add_definitions(-D_DLL -D__USE_CRTIMP)
 +
 +add_executable(subst subst.c subst.rc)
 +
 +set_module_type(subst win32cui)
++add_importlibs(subst msvcrt kernel32 user32 ntdll)
 +add_cab_target(subst 1)
index 0000000,790555b..790555b
mode 000000,100644..100644
--- /dev/null
index 0000000,7bbefe4..7bbefe4
mode 000000,100644..100644
--- /dev/null
index 0000000,5a2c1d3..5a2c1d3
mode 000000,100644..100644
--- /dev/null
index 0000000,9baa5b3..9baa5b3
mode 000000,100644..100644
--- /dev/null
index 0000000,f50bcd9..f50bcd9
mode 000000,100644..100644
--- /dev/null
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 46db35c,0000000..05e8a63
mode 100644,000000..100644
--- /dev/null
@@@ -1,241 -1,0 +1,243 @@@
 +
 +include_directories(BEFORE include)
 +include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
 +
 +if(ARCH MATCHES arm)
 +    if(SARCH MATCHES omap-zoom2)
 +        add_definitions(-D_ZOOM2_)
 +    endif()
 +endif()
 +
 +if(ARCH MATCHES i386)
 +    if(MSVC)
 +        list(APPEND FREELDR_BASE64K_SOURCE
 +            arch/i386/realmode.S)
 +    else()
 +        list(APPEND FREELDR_STARTUP_SOURCE
 +            arch/i386/fathelp.S
 +            arch/i386/arch.S)
 +    endif()
 +elseif(ARCH MATCHES amd64)
 +    list(APPEND FREELDR_STARTUP_SOURCE
 +        arch/i386/fathelp.S
 +        arch/amd64/arch.S)
 +endif()
 +
 +if(ARCH MATCHES i386)
 +    if(NOT MSVC)
 +        list(APPEND FREELDR_BASE64K_SOURCE
 +            arch/i386/boot.S
 +            arch/i386/drvmap.S
 +            arch/i386/i386cpu.S
 +            arch/i386/i386idt.S
 +            arch/i386/i386pnp.S
++            arch/i386/i386pxe.S
 +            arch/i386/i386trap.S
 +            arch/i386/int386.S
 +            arch/i386/linux.S
 +            arch/i386/mb.S
 +            arch/i386/i386bug.c)
 +    endif()
 +elseif(ARCH MATCHES amd64)
 +    list(APPEND FREELDR_BASE64K_SOURCE
 +        arch/i386/drvmap.S
 +        arch/i386/i386cpu.S
 +        arch/i386/i386idt.S
 +        arch/i386/i386trap.S
 +        arch/amd64/mb.S)
 +endif()
 +
 +set_source_files_properties(${FREELDR_BASE64K_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_")
 +
 +include_directories(${REACTOS_SOURCE_DIR}/lib/cmlib)
 +
 +list(APPEND FREELDR_BASE_SOURCE
 +    arcemul/mm.c
 +    arcemul/time.c
 +    cache/blocklist.c
 +    cache/cache.c
 +    comm/rs232.c
 +    disk/disk.c
 +    disk/partition.c
 +    disk/ramdisk.c
 +    disk/scsiport.c
 +    fs/ext2.c
 +    fs/fat.c
 +    fs/fs.c
 +    fs/iso.c
 +    fs/ntfs.c
++    fs/pxe.c
 +    inifile/ini_init.c
 +    inifile/inifile.c
 +    inifile/parse.c
 +    mm/meminit.c
 +    mm/mm.c
 +    reactos/registry.c
 +    reactos/arcname.c
 +    reactos/archwsup.c
 +    reactos/binhive.c
 +    reactos/reactos.c
 +    reactos/imageldr.c
 +    rtl/bget.c
 +    rtl/libsupp.c
 +    ui/directui.c
 +    ui/gui.c
 +    ui/minitui.c
 +    ui/noui.c
 +    ui/tui.c
 +    ui/tuimenu.c
 +    ui/ui.c
 +    video/fade.c
 +    video/palette.c
 +    video/video.c
 +    windows/conversion.c
 +    windows/peloader.c
 +    windows/winldr.c
 +    windows/wlmemory.c
 +    windows/wlregistry.c
 +    freeldr.c
 +    debug.c
 +    version.c
 +    cmdline.c
 +    machine.c
 +    options.c
 +    linuxboot.c
 +    oslist.c)
 +
 +if(ARCH MATCHES i386)
 +    list(APPEND FREELDR_BASE_SOURCE
 +        windows/headless.c
 +        disk/scsiport.c)
 +endif()
 +
 +set_source_files_properties(${FREELDR_BASE_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_;_BLDR_;_NTSYSTEM_")
 +
 +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs)
 +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/elf)
 +
 +if(ARCH MATCHES i386)
 +    list(APPEND FREELDR_ARCH_SOURCE
 +        arch/i386/archmach.c
 +        arch/i386/custom.c
 +        arch/i386/drivemap.c
 +        arch/i386/halstub.c
 +        arch/i386/hardware.c
 +        arch/i386/hwacpi.c
 +        arch/i386/hwapm.c
 +        arch/i386/hwpci.c
 +        arch/i386/i386disk.c
 +        arch/i386/i386rtl.c
 +        arch/i386/i386vid.c
 +        arch/i386/loader.c
 +        arch/i386/machpc.c
 +        arch/i386/miscboot.c
 +        arch/i386/ntoskrnl.c
 +        arch/i386/pccons.c
 +        arch/i386/pcdisk.c
 +        arch/i386/pcmem.c
 +        arch/i386/pcrtc.c
 +        arch/i386/pcvideo.c
 +        arch/i386/machxbox.c
 +        arch/i386/xboxcons.c
 +        arch/i386/xboxdisk.c
 +        arch/i386/xboxfont.c
 +        arch/i386/xboxhw.c
 +        arch/i386/xboxi2c.c
 +        arch/i386/xboxmem.c
 +        arch/i386/xboxrtc.c
 +        arch/i386/xboxvideo.c
 +        windows/i386/ntsetup.c
 +        windows/i386/wlmemory.c)
 +else()
 +#TBD
 +endif()
 +
 +set_source_files_properties(${FREELDR_ARCH_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_;_BLDR_;_NTSYSTEM_")
 +add_library(freeldr_arch ${FREELDR_ARCH_SOURCE})
 +
 +list(APPEND FREELDR_SOURCE
 +    bootmgr.c
 +    ${FREELDR_STARTUP_SOURCE}
 +    ${FREELDR_BASE64K_SOURCE}
 +    ${FREELDR_BASE_SOURCE}
 +    )
 +
 +add_library(freeldr SHARED
 +    ${CMAKE_CURRENT_BINARY_DIR}/freeldr_freeldr.h.gch
 +    ${FREELDR_SOURCE})
 +
 +if(NOT MSVC)
 +    set_target_properties(freeldr PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk" SUFFIX ".sys")
 +set_image_base(freeldr 0x8000)
 +else()
 +    set_target_properties(freeldr PROPERTIES LINK_FLAGS "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION" SUFFIX ".sys")
 +set_image_base(freeldr 0x10000)
 +endif()
 +
 +set_subsystem(freeldr native)
 +set_entrypoint(freeldr mainCRTStartup)
 +
 +if(ARCH MATCHES i386)
 +    target_link_libraries(freeldr mini_hal)
 +endif()
 +
 +target_link_libraries(freeldr
 +    freeldr_arch
 +    cportlib
 +    rossym
 +    cmlib
 +    rtl
 +    libcntpr)
 +
 +add_pch(freeldr ${CMAKE_CURRENT_SOURCE_DIR}/include/freeldr.h ${FREELDR_SOURCE})
 +add_dependencies(freeldr asm)
 +
 +list(APPEND SETUPLDR_MAIN_SOURCE
 +    bootmgr.c
 +    inffile/inffile.c
 +    reactos/setupldr.c)
 +
 +if(ARCH MATCHES i386 OR ARCH MATCHES amd64)
 +    list(APPEND SETUPLDR_MAIN_SOURCE windows/setupldr2.c)
 +endif()
 +
 +if(NOT MSVC)
 +    set_source_files_properties(${SETUPLDR_MAIN_SOURCE} PROPERTIES COMPILE_FLAGS "-ffreestanding -fno-builtin -fno-inline -fno-zero-initialized-in-bss")
 +endif()
 +
 +list(APPEND SETUPLDR_SOURCE
 +    ${FREELDR_STARTUP_SOURCE}
 +    ${FREELDR_BASE64K_SOURCE}
 +    ${FREELDR_BASE_SOURCE}
 +    ${SETUPLDR_MAIN_SOURCE})
 +
 +add_library(setupldr SHARED ${SETUPLDR_SOURCE})
 +
 +if(NOT MSVC)
 +    set_target_properties(setupldr PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk" SUFFIX ".sys" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP")
 +set_image_base(setupldr 0x8000)
 +else()
 +    set_target_properties(setupldr PROPERTIES LINK_FLAGS "/DRIVER /SECTION:.text,ERWP,ALIGN=0x1000" SUFFIX ".sys" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP")
 +endif()
 +
 +set_subsystem(setupldr native)
 +set_entrypoint(setupldr mainCRTStartup)
 +
 +if(ARCH MATCHES i386)
 +    target_link_libraries(setupldr mini_hal)
 +endif()
 +
 +target_link_libraries(setupldr
 +    freeldr_arch
 +    cportlib
 +    rossym
 +    cmlib
 +    rtl
 +    libcntpr)
 +
 +add_dependencies(setupldr asm)
 +
 +# Bootcd files
 +add_minicd_target(setupldr loader setupldr.sys)
 +add_minicd_target(freeldr loader freeldr.sys)
 +add_livecd_target(setupldr loader)
Simple merge
Simple merge
index 0000000,1e7f3b5..1e7f3b5
mode 000000,100644..100644
--- /dev/null
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 1ea76dd,0000000..986a8ca
mode 100644,000000..100644
--- /dev/null
@@@ -1,15 -1,0 +1,13 @@@
- spec2def(netevent.dll netevent.spec)
- add_library(netevent SHARED netevent.c netevt.rc ${CMAKE_CURRENT_BINARY_DIR}/netevent.def)
 +
 +set_unicode()
 +
 +include_directories(${REACTOS_BINARY_DIR}/include/reactos)
 +
++add_library(netevent SHARED netevt.rc)
 +
 +set_module_type(netevent win32dll)
 +
 +add_importlibs(netevent msvcrt kernel32)
 +
 +add_dependencies(netevent neteventmsg)
 +add_cab_target(netevent 1)
Simple merge
Simple merge
index 0000000,6440bae..6440bae
mode 000000,100644..100644
--- /dev/null
Simple merge
Simple merge
index 262cb50,0000000..427eaa4
mode 100644,000000..100644
--- /dev/null
@@@ -1,14 -1,0 +1,14 @@@
- @ stdcall imageview_fullscreenW(ptr ptr wstr long)
 +@ stub ImageView_COMServer
 +@ stdcall ImageView_Fullscreen(ptr ptr wstr long)
 +@ stdcall ImageView_FullscreenA(ptr ptr str long)
 +@ stdcall ImageView_FullscreenW(ptr ptr wstr long)
 +@ stdcall ImageView_PrintTo(ptr ptr wstr long)
 +@ stdcall ImageView_PrintToA(ptr ptr str long)
 +@ stdcall ImageView_PrintToW(ptr ptr wstr long)
++@ stdcall imageview_fullscreenW(ptr ptr wstr long) ImageView_FullscreenW
 +@ stub ConvertDIBSECTIONToThumbnail
 +@ stub -private DllCanUnloadNow
 +@ stub -private DllGetClassObject
 +@ stub -private DllInstall
 +@ stub -private DllRegisterServer
 +@ stub -private DllUnregisterServer
Simple merge
Simple merge
index 3408d73,0000000..34eaac9
mode 100644,000000..100644
--- /dev/null
@@@ -1,5279 -1,0 +1,5268 @@@
-     {
 +/*
 + * COPYRIGHT:       See COPYING in the top level directory
 + * PROJECT:         ReactOS user32.dll
 + * FILE:            user32/windows/menu.c
 + * PURPOSE:         Menus
 + *
 + * PROGRAMMERS:     Casper S. Hornstrup
 + *                  James Tabor
 + */
 +
 +/* INCLUDES ******************************************************************/
 +
 +#include <user32.h>
 +#include <wine/debug.h>
 +
 +LRESULT DefWndNCPaint(HWND hWnd, HRGN hRgn, BOOL Active);
 +
 +WINE_DEFAULT_DEBUG_CHANNEL(menu);
 +
 +/* internal popup menu window messages */
 +
 +#define MM_SETMENUHANDLE      (WM_USER + 0)
 +#define MM_GETMENUHANDLE      (WM_USER + 1)
 +
 +/* internal flags for menu tracking */
 +
 +#define TF_ENDMENU              0x10000
 +#define TF_SUSPENDPOPUP         0x20000
 +#define TF_SKIPREMOVE           0x40000
 +
 +#define ITEM_PREV             -1
 +#define ITEM_NEXT              1
 +
 +/* Internal MenuTrackMenu() flags */
 +#define TPM_INTERNAL          0xF0000000
 +#define TPM_BUTTONDOWN                0x40000000              /* menu was clicked before tracking */
 +#define TPM_POPUPMENU           0x20000000              /* menu is a popup menu */
 +
 +
 +#define MENU_TYPE_MASK (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR)
 +
 +#define MENU_ITEM_TYPE(flags) ((flags) & MENU_TYPE_MASK)
 +
 +/* macro to test that flags do not indicate bitmap, ownerdraw or separator */
 +#define IS_STRING_ITEM(flags) (MF_STRING == MENU_ITEM_TYPE(flags))
 +#define IS_MAGIC_BITMAP(id) ((id) && ((INT_PTR)(id) < 12) && ((INT_PTR)(id) >= -1))
 +
 +#define IS_SYSTEM_MENU(MenuInfo)  \
 +      (0 == ((MenuInfo)->Flags & MF_POPUP) && 0 != ((MenuInfo)->Flags & MF_SYSMENU))
 +
 +#define IS_SYSTEM_POPUP(MenuInfo) \
 +      (0 != ((MenuInfo)->Flags & MF_POPUP) && 0 != ((MenuInfo)->Flags & MF_SYSMENU))
 +
 +#define IS_BITMAP_ITEM(flags) (MF_BITMAP == MENU_ITEM_TYPE(flags))
 +
 +/* Use global popup window because there's no way 2 menus can
 + * be tracked at the same time.  */
 +static HWND top_popup;
 +static HMENU top_popup_hmenu;
 +
 +/* Flag set by EndMenu() to force an exit from menu tracking */
 +static BOOL fEndMenu = FALSE;
 +
 +#define MENU_ITEM_HBMP_SPACE (5)
 +#define MENU_BAR_ITEMS_SPACE (12)
 +#define SEPARATOR_HEIGHT (5)
 +#define MENU_TAB_SPACE (8)
 +
 +typedef struct
 +{
 +  UINT  TrackFlags;
 +  HMENU CurrentMenu; /* current submenu (can be equal to hTopMenu)*/
 +  HMENU TopMenu;     /* initial menu */
 +  HWND  OwnerWnd;    /* where notifications are sent */
 +  POINT Pt;
 +} MTRACKER;
 +
 +
 +/*********************************************************************
 + * PopupMenu class descriptor
 + */
 +const struct builtin_class_descr POPUPMENU_builtin_class =
 +{
 +    WC_MENU,                     /* name */
 +    CS_SAVEBITS | CS_DBLCLKS,                  /* style  */
 +    (WNDPROC) NULL,                            /* FIXME - procA */
 +    (WNDPROC) PopupMenuWndProcW,               /* FIXME - procW */
 +    sizeof(MENUINFO *),                        /* extra */
 +    (LPCWSTR) IDC_ARROW,                       /* cursor */
 +    (HBRUSH)(COLOR_MENU + 1)                   /* brush */
 +};
 +
 +#ifndef GET_WORD
 +#define GET_WORD(ptr)  (*(WORD *)(ptr))
 +#endif
 +#ifndef GET_DWORD
 +#define GET_DWORD(ptr) (*(DWORD *)(ptr))
 +#endif
 +
 +HFONT hMenuFont = NULL;
 +HFONT hMenuFontBold = NULL;
 +
 +/* Dimension of the menu bitmaps */
 +static HBITMAP BmpSysMenu = NULL;
 +
 +static SIZE MenuCharSize;
 +
 +/***********************************************************************
 + *           MenuGetRosMenuInfo
 + *
 + * Get full information about menu
 + */
 +static BOOL FASTCALL
 +MenuGetRosMenuInfo(PROSMENUINFO MenuInfo, HMENU Menu)
 +{
 +  MenuInfo->cbSize = sizeof(ROSMENUINFO);
 +  MenuInfo->fMask = MIM_BACKGROUND | MIM_HELPID | MIM_MAXHEIGHT | MIM_MENUDATA | MIM_STYLE;
 +
 +  return NtUserMenuInfo(Menu, MenuInfo, FALSE);
 +}
 +
 +/***********************************************************************
 + *           MenuSetRosMenuInfo
 + *
 + * Set full information about menu
 + */
 +static BOOL FASTCALL
 +MenuSetRosMenuInfo(PROSMENUINFO MenuInfo)
 +{
 +  MenuInfo->cbSize = sizeof(ROSMENUINFO);
 +  MenuInfo->fMask = MIM_BACKGROUND | MIM_HELPID | MIM_MAXHEIGHT | MIM_MENUDATA | MIM_STYLE;
 +
 +  return NtUserMenuInfo(MenuInfo->Self, MenuInfo, TRUE);
 +}
 +
 +/***********************************************************************
 + *           MenuInitRosMenuItemInfo
 + *
 + * Initialize a buffer for use with MenuGet/SetRosMenuItemInfo
 + */
 +static VOID FASTCALL
 +MenuInitRosMenuItemInfo(PROSMENUITEMINFO ItemInfo)
 +{
 +  ZeroMemory(ItemInfo, sizeof(ROSMENUITEMINFO));
 +  ItemInfo->cbSize = sizeof(ROSMENUITEMINFO);
 +}
 +
 +/***********************************************************************
 + *           MenuGetRosMenuItemInfo
 + *
 + * Get full information about a menu item
 + */
 +static BOOL FASTCALL
 +MenuGetRosMenuItemInfo(HMENU Menu, UINT Index, PROSMENUITEMINFO ItemInfo)
 +{
 +  UINT Save_Mask = ItemInfo->fMask; /* Save the org mask bits. */
 +
 +  if (ItemInfo->dwTypeData != NULL)
 +    {
 +      HeapFree(GetProcessHeap(), 0, ItemInfo->dwTypeData);
 +    }
 +
 +
 +  ItemInfo->fMask = MIIM_BITMAP | MIIM_CHECKMARKS | MIIM_DATA | MIIM_FTYPE
 +             | MIIM_ID | MIIM_STATE | MIIM_STRING | MIIM_SUBMENU | MIIM_TYPE;
 +  ItemInfo->dwTypeData = NULL;
 +
 +  if (! NtUserMenuItemInfo(Menu, Index, TRUE, ItemInfo, FALSE))
 +    {
 +      ItemInfo->fType = 0;
 +      return FALSE;
 +    }
 +
 +  if (MENU_ITEM_TYPE(ItemInfo->fType) == MF_STRING)
 +    {
 +      ItemInfo->cch++;
 +      ItemInfo->dwTypeData = HeapAlloc(GetProcessHeap(), 0,
 +                                       ItemInfo->cch * sizeof(WCHAR));
 +      if (NULL == ItemInfo->dwTypeData)
 +        {
 +          return FALSE;
 +        }
 +
 +      if (! NtUserMenuItemInfo(Menu, Index, TRUE, ItemInfo, FALSE))
 +        {
 +          ItemInfo->fType = 0;
 +          return FALSE;
 +        }
 +      ItemInfo->dwTypeData[ItemInfo->cch - 1] = UNICODE_NULL;
 +    }
 +  ItemInfo->fMask =  Save_Mask;
 +  return TRUE;
 +}
 +
 +/***********************************************************************
 + *           MenuSetRosMenuItemInfo
 + *
 + * Set selected information about a menu item, need to set the mask bits.
 + */
 +static BOOL FASTCALL
 +MenuSetRosMenuItemInfo(HMENU Menu, UINT Index, PROSMENUITEMINFO ItemInfo)
 +{
 +  BOOL Ret;
 +
 +  if (MENU_ITEM_TYPE(ItemInfo->fType) == MF_STRING &&
 +      ItemInfo->dwTypeData != NULL)
 +  {
 +    ItemInfo->cch = strlenW(ItemInfo->dwTypeData);
 +  }
 +  Ret = NtUserMenuItemInfo(Menu, Index, TRUE, ItemInfo, TRUE);
 +
 +  return Ret;
 +}
 +
 +/***********************************************************************
 + *           MenuCleanupRosMenuItemInfo
 + *
 + * Cleanup after use of MenuGet/SetRosMenuItemInfo
 + */
 +static VOID FASTCALL
 +MenuCleanupRosMenuItemInfo(PROSMENUITEMINFO ItemInfo)
 +{
 +  if (ItemInfo->dwTypeData != NULL)
 +    {
 +      HeapFree(GetProcessHeap(), 0, ItemInfo->dwTypeData);
 +      ItemInfo->dwTypeData = NULL;
 +    }
 +}
 +
 +/***********************************************************************
 + *           MenuGetAllRosMenuItemInfo
 + *
 + * Get full information about all menu items
 + */
 +static INT FASTCALL
 +MenuGetAllRosMenuItemInfo(HMENU Menu, PROSMENUITEMINFO *ItemInfo)
 +{
 +  DWORD BufSize;
 +
 +  BufSize = NtUserBuildMenuItemList(Menu, (VOID *) 1, 0, 0);
 +  if (BufSize == (DWORD) -1 || BufSize == 0)
 +    {
 +      return -1;
 +    }
 +  *ItemInfo = HeapAlloc(GetProcessHeap(), 0, BufSize);
 +  if (NULL == *ItemInfo)
 +    {
 +      return -1;
 +    }
 +
 +  return NtUserBuildMenuItemList(Menu, *ItemInfo, BufSize, 0);
 +}
 +
 +/***********************************************************************
 + *           MenuCleanupAllRosMenuItemInfo
 + *
 + * Cleanup after use of MenuGetAllRosMenuItemInfo
 + */
 +static VOID FASTCALL
 +MenuCleanupAllRosMenuItemInfo(PROSMENUITEMINFO ItemInfo)
 +{
 +  HeapFree(GetProcessHeap(), 0, ItemInfo);
 +}
 +
 +/***********************************************************************
 + *           MenuInitSysMenuPopup
 + *
 + * Grey the appropriate items in System menu.
 + */
 +void FASTCALL MenuInitSysMenuPopup(HMENU hmenu, DWORD style, DWORD clsStyle, LONG HitTest )
 +{
 +    BOOL gray;
 +    UINT DefItem;
 +    #if 0
 +    MENUITEMINFOW mii;
 +    #endif
 +
 +    gray = !(style & WS_THICKFRAME) || (style & (WS_MAXIMIZE | WS_MINIMIZE));
 +    EnableMenuItem( hmenu, SC_SIZE, (gray ? MF_GRAYED : MF_ENABLED) );
 +    gray = ((style & WS_MAXIMIZE) != 0);
 +    EnableMenuItem( hmenu, SC_MOVE, (gray ? MF_GRAYED : MF_ENABLED) );
 +    gray = !(style & WS_MINIMIZEBOX) || (style & WS_MINIMIZE);
 +    EnableMenuItem( hmenu, SC_MINIMIZE, (gray ? MF_GRAYED : MF_ENABLED) );
 +    gray = !(style & WS_MAXIMIZEBOX) || (style & WS_MAXIMIZE);
 +    EnableMenuItem( hmenu, SC_MAXIMIZE, (gray ? MF_GRAYED : MF_ENABLED) );
 +    gray = !(style & (WS_MAXIMIZE | WS_MINIMIZE));
 +    EnableMenuItem( hmenu, SC_RESTORE, (gray ? MF_GRAYED : MF_ENABLED) );
 +    gray = (clsStyle & CS_NOCLOSE) != 0;
 +
 +    /* The menu item must keep its state if it's disabled */
 +    if(gray)
 +        EnableMenuItem( hmenu, SC_CLOSE, MF_GRAYED);
 +
 +    /* Set default menu item */
 +    if(style & WS_MINIMIZE) DefItem = SC_RESTORE;
 +    else if(HitTest == HTCAPTION) DefItem = ((style & (WS_MAXIMIZE | WS_MINIMIZE)) ? SC_RESTORE : SC_MAXIMIZE);
 +    else DefItem = SC_CLOSE;
 +#if 0
 +    mii.cbSize = sizeof(MENUITEMINFOW);
 +    mii.fMask |= MIIM_STATE;
 +    if((DefItem != SC_CLOSE) && GetMenuItemInfoW(hmenu, DefItem, FALSE, &mii) &&
 +       (mii.fState & (MFS_GRAYED | MFS_DISABLED))) DefItem = SC_CLOSE;
 +#endif
 +    SetMenuDefaultItem(hmenu, DefItem, MF_BYCOMMAND);
 +}
 +
 +/******************************************************************************
 + *
 + *   UINT MenuGetStartOfNextColumn(
 + *     PROSMENUINFO MenuInfo)
 + *
 + *****************************************************************************/
 +static UINT MenuGetStartOfNextColumn(
 +    PROSMENUINFO MenuInfo)
 +{
 +    PROSMENUITEMINFO MenuItems;
 +    UINT i;
 +
 +    i = MenuInfo->FocusedItem;
 +    if ( i == NO_SELECTED_ITEM )
 +        return i;
 +
 +    if (MenuGetAllRosMenuItemInfo(MenuInfo->Self, &MenuItems) <= 0)
 +        return NO_SELECTED_ITEM;
 +
 +    for (i++ ; i < MenuInfo->MenuItemCount; i++)
 +        if (0 != (MenuItems[i].fType & (MF_MENUBREAK | MF_MENUBARBREAK)))
 +            return i;
 +
 +    return NO_SELECTED_ITEM;
 +}
 +
 +/******************************************************************************
 + *
 + *   UINT MenuGetStartOfPrevColumn(
 + *     PROSMENUINFO MenuInfo)
 + *
 + *****************************************************************************/
 +
 +static UINT FASTCALL MenuGetStartOfPrevColumn(
 +    PROSMENUINFO MenuInfo)
 +{
 +    PROSMENUITEMINFO MenuItems;
 +    UINT i;
 +
 +    if (!MenuInfo->FocusedItem || MenuInfo->FocusedItem == NO_SELECTED_ITEM)
 +        return NO_SELECTED_ITEM;
 +
 +    if (MenuGetAllRosMenuItemInfo(MenuInfo->Self, &MenuItems) <= 0)
 +        return NO_SELECTED_ITEM;
 +
 +    /* Find the start of the column */
 +    for (i = MenuInfo->FocusedItem;
 +         0 != i && 0 == (MenuItems[i].fType & (MF_MENUBREAK | MF_MENUBARBREAK));
 +         --i)
 +    {
 +        ; /* empty */
 +    }
 +
 +    if (i == 0)
 +    {
 +        MenuCleanupAllRosMenuItemInfo(MenuItems);
 +        return NO_SELECTED_ITEM;
 +    }
 +
 +    for (--i; 0 != i; --i)
 +        if (MenuItems[i].fType & (MF_MENUBREAK | MF_MENUBARBREAK))
 +            break;
 +
 +    MenuCleanupAllRosMenuItemInfo(MenuItems);
 +    TRACE("ret %d.\n", i );
 +
 +    return i;
 +}
 +
 +/***********************************************************************
 + *           MenuFindSubMenu
 + *
 + * Find a Sub menu. Return the position of the submenu, and modifies
 + * *hmenu in case it is found in another sub-menu.
 + * If the submenu cannot be found, NO_SELECTED_ITEM is returned.
 + */
 +static UINT FASTCALL MenuFindSubMenu(HMENU *hmenu, HMENU hSubTarget )
 +{
 +    ROSMENUINFO menu;
 +    UINT i;
 +    ROSMENUITEMINFO item;
 +    if (((*hmenu)==(HMENU)0xffff) ||
 +          (!MenuGetRosMenuInfo(&menu, *hmenu)))
 +        return NO_SELECTED_ITEM;
 +
 +    MenuInitRosMenuItemInfo(&item);
 +    for (i = 0; i < menu.MenuItemCount; i++) {
 +        if (! MenuGetRosMenuItemInfo(menu.Self, i, &item))
 +        {
 +            MenuCleanupRosMenuItemInfo(&item);
 +            return NO_SELECTED_ITEM;
 +        }
 +        if (!(item.fType & MF_POPUP)) continue;
 +        if (item.hSubMenu == hSubTarget) {
 +            MenuCleanupRosMenuItemInfo(&item);
 +            return i;
 +        }
 +        else  {
 +            HMENU hsubmenu = item.hSubMenu;
 +            UINT pos = MenuFindSubMenu(&hsubmenu, hSubTarget );
 +            if (pos != NO_SELECTED_ITEM) {
 +                *hmenu = hsubmenu;
 +                return pos;
 +           }
 +        }
 +    }
 +    MenuCleanupRosMenuItemInfo(&item);
 +    return NO_SELECTED_ITEM;
 +}
 +
 +/***********************************************************************
 + *           MenuLoadBitmaps
 + *
 + * Load the arrow bitmap. We can't do this from MenuInit since user32
 + * can also be used (and thus initialized) from text-mode.
 + */
 +static void FASTCALL
 +MenuLoadBitmaps(VOID)
 +{
 +  /* Load system buttons bitmaps */
 +  if (NULL == BmpSysMenu)
 +    {
 +      BmpSysMenu = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CLOSE));
 +    }
 +}
 +
 +/***********************************************************************
 + *           MenuDrawPopupGlyph
 + *
 + * Draws popup magic glyphs (can be found in system menu).
 + */
 +static void FASTCALL
 +MenuDrawPopupGlyph(HDC dc, LPRECT r, INT_PTR popupMagic, BOOL inactive, BOOL hilite)
 +{
 +  LOGFONTW lf;
 +  HFONT hFont, hOldFont;
 +  COLORREF clrsave;
 +  INT bkmode;
 +  TCHAR symbol;
 +  switch (popupMagic)
 +  {
 +  case (INT_PTR) HBMMENU_POPUP_RESTORE:
 +    symbol = '2';
 +    break;
 +  case (INT_PTR) HBMMENU_POPUP_MINIMIZE:
 +    symbol = '0';
 +    break;
 +  case (INT_PTR) HBMMENU_POPUP_MAXIMIZE:
 +    symbol = '1';
 +    break;
 +  case (INT_PTR) HBMMENU_POPUP_CLOSE:
 +    symbol = 'r';
 +    break;
 +  default:
 +    ERR("Invalid popup magic bitmap %d\n", (int)popupMagic);
 +    return;
 +  }
 +  ZeroMemory(&lf, sizeof(LOGFONTW));
 +  InflateRect(r, -2, -2);
 +  lf.lfHeight = r->bottom - r->top;
 +  lf.lfWidth = 0;
 +  lf.lfWeight = FW_NORMAL;
 +  lf.lfCharSet = DEFAULT_CHARSET;
 +  lstrcpy(lf.lfFaceName, TEXT("Marlett"));
 +  hFont = CreateFontIndirect(&lf);
 +  /* save font and text color */
 +  hOldFont = SelectObject(dc, hFont);
 +  clrsave = GetTextColor(dc);
 +  bkmode = GetBkMode(dc);
 +  /* set color and drawing mode */
 +  SetBkMode(dc, TRANSPARENT);
 +  if (inactive)
 +  {
 +    /* draw shadow */
 +    if (!hilite)
 +    {
 +      SetTextColor(dc, GetSysColor(COLOR_HIGHLIGHTTEXT));
 +      TextOut(dc, r->left + 1, r->top + 1, &symbol, 1);
 +    }
 +  }
 +  SetTextColor(dc, GetSysColor(inactive ? COLOR_GRAYTEXT : (hilite ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)));
 +  /* draw selected symbol */
 +  TextOut(dc, r->left, r->top, &symbol, 1);
 +  /* restore previous settings */
 +  SetTextColor(dc, clrsave);
 +  SelectObject(dc, hOldFont);
 +  SetBkMode(dc, bkmode);
 +  DeleteObject(hFont);
 +}
 +
 +/***********************************************************************
 + *           MenuFindItemByKey
 + *
 + * Find the menu item selected by a key press.
 + * Return item id, -1 if none, -2 if we should close the menu.
 + */
 +static UINT FASTCALL MenuFindItemByKey(HWND WndOwner, PROSMENUINFO MenuInfo,
 +                  WCHAR Key, BOOL ForceMenuChar)
 +{
 +  ROSMENUINFO SysMenuInfo;
 +  PROSMENUITEMINFO Items, ItemInfo;
 +  LRESULT MenuChar;
 +  UINT i;
 +
 +  TRACE("\tlooking for '%c' (0x%02x) in [%p]\n", (char) Key, Key, MenuInfo);
 +
 +  if (NULL == MenuInfo || ! IsMenu(MenuInfo->Self))
-         {
++  {
 +      if (MenuGetRosMenuInfo(&SysMenuInfo, GetSystemMenu(WndOwner, FALSE)))
-         }
++      {
 +          MenuInfo = &SysMenuInfo;
-         {
++      }
 +      else
-         }
-     }
++      {
 +          MenuInfo = NULL;
-     {
++      }
++  }
 +
 +  if (NULL != MenuInfo)
-         {
++  {
 +      if (MenuGetAllRosMenuItemInfo(MenuInfo->Self, &Items) <= 0)
-         }
-       if (! ForceMenuChar)
-         {
-           Key = toupperW(Key);
++      {
 +          return -1;
-             {
++      }
++      if ( !ForceMenuChar )
++      {
 +          ItemInfo = Items;
 +          for (i = 0; i < MenuInfo->MenuItemCount; i++, ItemInfo++)
-                 {
++          {
 +              if ((ItemInfo->lpstr) && NULL != ItemInfo->dwTypeData)
-                     {
-                       p = strchrW(p + 2, '&');
-                   }
-                   while (NULL != p && L'&' == p[1]);
-                   if (NULL != p && (toupperW(p[1]) == Key))
-                     {
-                       return i;
-                     }
-                 }
-             }
-         }
++              {
 +                  WCHAR *p = (WCHAR *) ItemInfo->dwTypeData - 2;
 +                  do
-       if (2 == HIWORD(MenuChar))
-         {
-           return LOWORD(MenuChar);
-         }
-       if (1 == HIWORD(MenuChar))
-         {
-           return (UINT) (-2);
-         }
++                  {
++                      p = strchrW (p + 2, '&');
++                  }
++                  while (p != NULL && p [1] == '&');
++                  if (p && (toupperW(p[1]) == toupperW(Key))) return i;
++              }
++          }
++      }
 +
 +      MenuChar = SendMessageW(WndOwner, WM_MENUCHAR,
 +                              MAKEWPARAM(Key, MenuInfo->Flags), (LPARAM) MenuInfo->Self);
++      if (HIWORD(MenuChar) == MNC_EXECUTE) return LOWORD(MenuChar);
++      if (HIWORD(MenuChar) == MNC_CLOSE) return (UINT)(-2);
 +    }
-     /* ReactOS Check */
-     if (!ValidateHwnd(hwndOwner))
-     {  // This window maybe already DEAD!!!
 +  return (UINT)(-1);
 +}
 +
 +/***********************************************************************
 + *           MenuGetBitmapItemSize
 + *
 + * Get the size of a bitmap item.
 + */
 +static void FASTCALL MenuGetBitmapItemSize(PROSMENUITEMINFO lpitem, SIZE *size, HWND WndOwner)
 +{
 +    BITMAP bm;
 +    HBITMAP bmp = lpitem->hbmpItem;
 +
 +    size->cx = size->cy = 0;
 +
 +    /* check if there is a magic menu item associated with this item */
 +    if (IS_MAGIC_BITMAP(bmp))
 +    {
 +      switch((INT_PTR) bmp)
 +        {
 +            case (INT_PTR)HBMMENU_CALLBACK:
 +            {
 +                MEASUREITEMSTRUCT measItem;
 +                measItem.CtlType = ODT_MENU;
 +                measItem.CtlID = 0;
 +                measItem.itemID = lpitem->wID;
 +                measItem.itemWidth = lpitem->Rect.right - lpitem->Rect.left;
 +                measItem.itemHeight = lpitem->Rect.bottom - lpitem->Rect.top;
 +                measItem.itemData = lpitem->dwItemData;
 +                SendMessageW( WndOwner, WM_MEASUREITEM, lpitem->wID, (LPARAM)&measItem);
 +                size->cx = measItem.itemWidth;
 +                size->cy = measItem.itemHeight;
 +                return;
 +            }
 +            break;
 +
 +          case (INT_PTR) HBMMENU_SYSTEM:
 +            if (0 != lpitem->dwItemData)
 +              {
 +                bmp = (HBITMAP) lpitem->dwItemData;
 +                break;
 +              }
 +            /* fall through */
 +          case (INT_PTR) HBMMENU_MBAR_RESTORE:
 +          case (INT_PTR) HBMMENU_MBAR_MINIMIZE:
 +          case (INT_PTR) HBMMENU_MBAR_CLOSE:
 +          case (INT_PTR) HBMMENU_MBAR_MINIMIZE_D:
 +          case (INT_PTR) HBMMENU_MBAR_CLOSE_D:
 +          case (INT_PTR) HBMMENU_POPUP_CLOSE:
 +          case (INT_PTR) HBMMENU_POPUP_RESTORE:
 +          case (INT_PTR) HBMMENU_POPUP_MAXIMIZE:
 +          case (INT_PTR) HBMMENU_POPUP_MINIMIZE:
 +            /* FIXME: Why we need to subtract these magic values? */
 +            /* to make them smaller than the menu bar? */
 +            size->cx = GetSystemMetrics(SM_CXSIZE) - 2;
 +            size->cy = GetSystemMetrics(SM_CYSIZE) - 4;
 +            return;
 +        }
 +    }
 +
 +    if (GetObjectW(bmp, sizeof(BITMAP), &bm))
 +    {
 +        size->cx = bm.bmWidth;
 +        size->cy = bm.bmHeight;
 +    }
 +}
 +
 +/***********************************************************************
 + *           MenuDrawBitmapItem
 + *
 + * Draw a bitmap item.
 + */
 +static void FASTCALL MenuDrawBitmapItem(HDC hdc, PROSMENUITEMINFO lpitem, const RECT *rect,
 +                    HMENU hmenu, HWND WndOwner, UINT odaction, BOOL MenuBar)
 +{
 +    BITMAP bm;
 +    DWORD rop;
 +    HDC hdcMem;
 +    HBITMAP bmp;
 +    int w = rect->right - rect->left;
 +    int h = rect->bottom - rect->top;
 +    int bmp_xoffset = 0;
 +    int left, top;
 +    HBITMAP hbmToDraw = lpitem->hbmpItem;
 +    bmp = hbmToDraw;
 +
 +    /* Check if there is a magic menu item associated with this item */
 +    if (IS_MAGIC_BITMAP(hbmToDraw))
 +    {
 +        UINT flags = 0;
 +        RECT r;
 +
 +      r = *rect;
 +      switch ((INT_PTR)hbmToDraw)
 +        {
 +        case (INT_PTR)HBMMENU_SYSTEM:
 +            if (lpitem->dwTypeData)
 +            {
 +                bmp = (HBITMAP)lpitem->dwTypeData;
 +                if (!GetObjectW( bmp, sizeof(bm), &bm )) return;
 +            }
 +            else
 +            {
 +                if (!BmpSysMenu) BmpSysMenu = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CLOSE));
 +                bmp = BmpSysMenu;
 +                if (! GetObjectW(bmp, sizeof(bm), &bm)) return;
 +                /* only use right half of the bitmap */
 +                bmp_xoffset = bm.bmWidth / 2;
 +                bm.bmWidth -= bmp_xoffset;
 +            }
 +            goto got_bitmap;
 +        case (INT_PTR)HBMMENU_MBAR_RESTORE:
 +            flags = DFCS_CAPTIONRESTORE;
 +            break;
 +        case (INT_PTR)HBMMENU_MBAR_MINIMIZE:
 +            r.right += 1;
 +            flags = DFCS_CAPTIONMIN;
 +            break;
 +        case (INT_PTR)HBMMENU_MBAR_MINIMIZE_D:
 +            r.right += 1;
 +            flags = DFCS_CAPTIONMIN | DFCS_INACTIVE;
 +            break;
 +        case (INT_PTR)HBMMENU_MBAR_CLOSE:
 +            flags = DFCS_CAPTIONCLOSE;
 +            break;
 +        case (INT_PTR)HBMMENU_MBAR_CLOSE_D:
 +            flags = DFCS_CAPTIONCLOSE | DFCS_INACTIVE;
 +            break;
 +        case (INT_PTR)HBMMENU_CALLBACK:
 +            {
 +                DRAWITEMSTRUCT drawItem;
 +                POINT origorg;
 +                drawItem.CtlType = ODT_MENU;
 +                drawItem.CtlID = 0;
 +                drawItem.itemID = lpitem->wID;
 +                drawItem.itemAction = odaction;
 +                drawItem.itemState = (lpitem->fState & MF_CHECKED)?ODS_CHECKED:0;
 +                drawItem.itemState |= (lpitem->fState & MF_DEFAULT)?ODS_DEFAULT:0;
 +                drawItem.itemState |= (lpitem->fState & MF_DISABLED)?ODS_DISABLED:0;
 +                drawItem.itemState |= (lpitem->fState & MF_GRAYED)?ODS_GRAYED|ODS_DISABLED:0;
 +                drawItem.itemState |= (lpitem->fState & MF_HILITE)?ODS_SELECTED:0;
 +                drawItem.hwndItem = (HWND)hmenu;
 +                drawItem.hDC = hdc;
 +                drawItem.rcItem = *rect;
 +                drawItem.itemData = lpitem->dwItemData;
 +                /* some applications make this assumption on the DC's origin */
 +                SetViewportOrgEx( hdc, lpitem->Rect.left, lpitem->Rect.top, &origorg);
 +                OffsetRect( &drawItem.rcItem, - lpitem->Rect.left, - lpitem->Rect.top);
 +                SendMessageW( WndOwner, WM_DRAWITEM, 0, (LPARAM)&drawItem);
 +                SetViewportOrgEx( hdc, origorg.x, origorg.y, NULL);
 +                return;
 +            }
 +            break;
 +
 +          case (INT_PTR) HBMMENU_POPUP_CLOSE:
 +          case (INT_PTR) HBMMENU_POPUP_RESTORE:
 +          case (INT_PTR) HBMMENU_POPUP_MAXIMIZE:
 +          case (INT_PTR) HBMMENU_POPUP_MINIMIZE:
 +            MenuDrawPopupGlyph(hdc, &r, (INT_PTR)hbmToDraw, lpitem->fState & MF_GRAYED, lpitem->fState & MF_HILITE);
 +            return;
 +        }
 +      InflateRect(&r, -1, -1);
 +      if (0 != (lpitem->fState & MF_HILITE))
 +      {
 +          flags |= DFCS_PUSHED;
 +      }
 +      DrawFrameControl(hdc, &r, DFC_CAPTION, flags);
 +      return;
 +    }
 +
 +    if (!bmp || !GetObjectW( bmp, sizeof(bm), &bm )) return;
 +
 + got_bitmap:
 +    hdcMem = CreateCompatibleDC( hdc );
 +    SelectObject( hdcMem, bmp );
 +
 +    /* handle fontsize > bitmap_height */
 +    top = (h>bm.bmHeight) ? rect->top+(h-bm.bmHeight)/2 : rect->top;
 +    left=rect->left;
 +    rop=((lpitem->fState & MF_HILITE) && !IS_MAGIC_BITMAP(hbmToDraw)) ? NOTSRCCOPY : SRCCOPY;
 +    if ((lpitem->fState & MF_HILITE) && lpitem->hbmpItem)
 +        SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
 +    BitBlt( hdc, left, top, w, h, hdcMem, bmp_xoffset, 0, rop );
 +    DeleteDC( hdcMem );
 +}
 +
 +/***********************************************************************
 + *           MenuCalcItemSize
 + *
 + * Calculate the size of the menu item and store it in lpitem->rect.
 + */
 +static void FASTCALL MenuCalcItemSize( HDC hdc, PROSMENUITEMINFO lpitem, PROSMENUINFO MenuInfo, HWND hwndOwner,
 +                 INT orgX, INT orgY, BOOL menuBar)
 +{
 +    WCHAR *p;
 +    UINT check_bitmap_width = GetSystemMetrics( SM_CXMENUCHECK );
 +    INT itemheight = 0;
 +
 +    TRACE("dc=%x owner=%x (%d,%d)\n", hdc, hwndOwner, orgX, orgY);
 +
 +    MenuCharSize.cx = GdiGetCharDimensions( hdc, NULL, &MenuCharSize.cy );
 +
 +    SetRect( &lpitem->Rect, orgX, orgY, orgX, orgY );
 +
 +    if (lpitem->fType & MF_OWNERDRAW)
 +    {
 +        MEASUREITEMSTRUCT mis;
 +        mis.CtlType    = ODT_MENU;
 +        mis.CtlID      = 0;
 +        mis.itemID     = lpitem->wID;
 +        mis.itemData   = lpitem->dwItemData;
 +        mis.itemHeight = HIWORD( GetDialogBaseUnits());
 +        mis.itemWidth  = 0;
 +        SendMessageW( hwndOwner, WM_MEASUREITEM, 0, (LPARAM)&mis );
 +        /* Tests reveal that Windows ( Win95 thru WinXP) adds twice the average
 +         * width of a menufont character to the width of an owner-drawn menu.
 +         */
 +        lpitem->Rect.right += mis.itemWidth + 2 * MenuCharSize.cx;
 +
 +        if (menuBar) {
 +            /* under at least win95 you seem to be given a standard
 +               height for the menu and the height value is ignored */
 +            lpitem->Rect.bottom += GetSystemMetrics(SM_CYMENUSIZE);
 +        } else
 +            lpitem->Rect.bottom += mis.itemHeight;
 +
 +        TRACE("id=%04lx size=%dx%d\n",
 +                lpitem->wID, mis.itemWidth, mis.itemHeight);
 +        return;
 +    }
 +
 +    if (lpitem->fType & MF_SEPARATOR)
 +    {
 +        lpitem->Rect.bottom += SEPARATOR_HEIGHT;
 +        if( !menuBar)
 +            lpitem->Rect.right += check_bitmap_width +  MenuCharSize.cx;
 +        return;
 +    }
 +
 +    lpitem->dxTab = 0;
 +
 +    if (lpitem->hbmpItem)
 +    {
 +        SIZE size;
 +
 +        if (!menuBar) {
 +            MenuGetBitmapItemSize(lpitem, &size, hwndOwner );
 +            /* Keep the size of the bitmap in callback mode to be able
 +             * to draw it correctly */
 +            lpitem->Rect.right = lpitem->Rect.left + size.cx;
 +            if (MenuInfo->maxBmpSize.cx < abs(size.cx) +  MENU_ITEM_HBMP_SPACE ||
 +                MenuInfo->maxBmpSize.cy < abs(size.cy))
 +            {
 +                MenuInfo->maxBmpSize.cx = abs(size.cx) + MENU_ITEM_HBMP_SPACE;
 +                MenuInfo->maxBmpSize.cy = abs(size.cy);
 +            }
 +            MenuSetRosMenuInfo(MenuInfo);
 +            itemheight = size.cy + 2;
 +
 +            if( !(MenuInfo->dwStyle & MNS_NOCHECK))
 +                lpitem->Rect.right += 2 * check_bitmap_width;
 +            lpitem->Rect.right += 4 + MenuCharSize.cx;
 +            lpitem->dxTab = lpitem->Rect.right;
 +            lpitem->Rect.right += check_bitmap_width;
 +        } else /* hbmpItem & MenuBar */ {
 +            MenuGetBitmapItemSize(lpitem, &size, hwndOwner );
 +            lpitem->Rect.right  += size.cx;
 +            if( lpitem->lpstr) lpitem->Rect.right  += 2;
 +            itemheight = size.cy;
 +
 +            /* Special case: Minimize button doesn't have a space behind it. */
 +            if (lpitem->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE ||
 +                lpitem->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE_D)
 +            lpitem->Rect.right -= 1;
 +        }
 +    }
 +    else if (!menuBar) {
 +        if( !(MenuInfo->dwStyle & MNS_NOCHECK))
 +             lpitem->Rect.right += check_bitmap_width;
 +        lpitem->Rect.right += 4 + MenuCharSize.cx;
 +        lpitem->dxTab = lpitem->Rect.right;
 +        lpitem->Rect.right += check_bitmap_width;
 +    }
 +
 +    /* it must be a text item - unless it's the system menu */
 +    if (!(lpitem->fType & MF_SYSMENU) && lpitem->lpstr) {
 +        HFONT hfontOld = NULL;
 +        RECT rc = lpitem->Rect;
 +        LONG txtheight, txtwidth;
 +
 +        if ( lpitem->fState & MFS_DEFAULT ) {
 +            hfontOld = SelectObject( hdc, hMenuFontBold );
 +        }
 +        if (menuBar) {
 +            txtheight = DrawTextW( hdc, lpitem->dwTypeData, -1, &rc,
 +                    DT_SINGLELINE|DT_CALCRECT);
 +            lpitem->Rect.right  += rc.right - rc.left;
 +            itemheight = max( max( itemheight, txtheight),
 +                    GetSystemMetrics( SM_CYMENU) - 1);
 +            lpitem->Rect.right +=  2 * MenuCharSize.cx;
 +        } else {
 +            if ((p = strchrW( lpitem->dwTypeData, '\t' )) != NULL) {
 +                RECT tmprc = rc;
 +                LONG tmpheight;
 +                int n = (int)( p - lpitem->dwTypeData);
 +                /* Item contains a tab (only meaningful in popup menus) */
 +                /* get text size before the tab */
 +                txtheight = DrawTextW( hdc, lpitem->dwTypeData, n, &rc,
 +                        DT_SINGLELINE|DT_CALCRECT);
 +                txtwidth = rc.right - rc.left;
 +                p += 1; /* advance past the Tab */
 +                /* get text size after the tab */
 +                tmpheight = DrawTextW( hdc, p, -1, &tmprc,
 +                        DT_SINGLELINE|DT_CALCRECT);
 +                lpitem->dxTab += txtwidth;
 +                txtheight = max( txtheight, tmpheight);
 +                txtwidth += MenuCharSize.cx + /* space for the tab */
 +                    tmprc.right - tmprc.left; /* space for the short cut */
 +            } else {
 +                txtheight = DrawTextW( hdc, lpitem->dwTypeData, -1, &rc,
 +                        DT_SINGLELINE|DT_CALCRECT);
 +                txtwidth = rc.right - rc.left;
 +                lpitem->dxTab += txtwidth;
 +            }
 +            lpitem->Rect.right  += 2 + txtwidth;
 +            itemheight = max( itemheight,
 +                                  max( txtheight + 2, MenuCharSize.cy + 4));
 +        }
 +        if (hfontOld) SelectObject (hdc, hfontOld);
 +    } else if( menuBar) {
 +        itemheight = max( itemheight, GetSystemMetrics(SM_CYMENU)-1);
 +    }
 +    lpitem->Rect.bottom += itemheight;
 +    TRACE("(%ld,%ld)-(%ld,%ld)\n", lpitem->Rect.left, lpitem->Rect.top, lpitem->Rect.right, lpitem->Rect.bottom);
 +}
 +
 +/***********************************************************************
 + *           MenuPopupMenuCalcSize
 + *
 + * Calculate the size of a popup menu.
 + */
 +static void FASTCALL MenuPopupMenuCalcSize(PROSMENUINFO MenuInfo, HWND WndOwner)
 +{
 +    ROSMENUITEMINFO lpitem;
 +    HDC hdc;
 +    int start, i;
 +    int orgX, orgY, maxX, maxTab, maxTabWidth;
 +
 +    MenuInfo->Width = MenuInfo->Height = 0;
 +    if (MenuInfo->MenuItemCount == 0)
 +    {
 +        MenuSetRosMenuInfo(MenuInfo);
 +        return;
 +    }
 +
 +    hdc = GetDC(NULL);
 +    SelectObject( hdc, hMenuFont );
 +
 +    start = 0;
 +    maxX = 2 + 1;
 +
 +    MenuInfo->maxBmpSize.cx = 0;
 +    MenuInfo->maxBmpSize.cy = 0;
 +
 +    MenuInitRosMenuItemInfo(&lpitem);
 +    while (start < MenuInfo->MenuItemCount)
 +    {
 +      orgX = maxX;
 +      orgY = 2;
 +
 +      maxTab = maxTabWidth = 0;
 +
 +      /* Parse items until column break or end of menu */
 +      for (i = start; i < MenuInfo->MenuItemCount; i++)
 +      {
 +          if (! MenuGetRosMenuItemInfo(MenuInfo->Self, i, &lpitem))
 +          {
 +              MenuCleanupRosMenuItemInfo(&lpitem);
 +              MenuSetRosMenuInfo(MenuInfo);
 +              return;
 +          }
 +          if (i != start &&
 +               (lpitem.fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
 +
 +          MenuCalcItemSize(hdc, &lpitem, MenuInfo, WndOwner, orgX, orgY, FALSE);
 +          if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &lpitem))
 +          {
 +              MenuCleanupRosMenuItemInfo(&lpitem);
 +              MenuSetRosMenuInfo(MenuInfo);
 +              return;
 +          }
 +// Not sure here,, The patch from wine removes this.
 +//        if ((lpitem.fType & MF_MENUBARBREAK) != 0)
 +//        {
 +//              OrgX++;
 +//        }
 +          maxX = max(maxX, lpitem.Rect.right);
 +          orgY = lpitem.Rect.bottom;
 +          if ((lpitem.lpstr) && lpitem.dxTab )
 +            {
 +              maxTab = max( maxTab, lpitem.dxTab );
 +              maxTabWidth = max(maxTabWidth, lpitem.Rect.right - lpitem.dxTab);
 +          }
 +        }
 +
 +        /* Finish the column (set all items to the largest width found) */
 +        maxX = max( maxX, maxTab + maxTabWidth );
 +        while (start < i)
 +        {
 +            if (MenuGetRosMenuItemInfo(MenuInfo->Self, start, &lpitem))
 +            {
 +                lpitem.Rect.right = maxX;
 +                if ((lpitem.lpstr) && 0 != lpitem.dxTab)
 +                {
 +                    lpitem.dxTab = maxTab;
 +                }
 +                MenuSetRosMenuItemInfo(MenuInfo->Self, start, &lpitem);
 +            }
 +            start++;
 +          }
 +        MenuInfo->Height = max(MenuInfo->Height, orgY);
 +    }
 +
 +    MenuInfo->Width  = maxX;
 +
 +    /* space for 3d border */
 +    MenuInfo->Height += 2;
 +    MenuInfo->Width += 2;
 +
 +    MenuCleanupRosMenuItemInfo(&lpitem);
 +    MenuSetRosMenuInfo(MenuInfo);
 +    ReleaseDC( 0, hdc );
 +}
 +
 +/***********************************************************************
 + *           MenuMenuBarCalcSize
 + *
 + * FIXME: Word 6 implements its own MDI and its own 'close window' bitmap
 + * height is off by 1 pixel which causes lengthy window relocations when
 + * active document window is maximized/restored.
 + *
 + * Calculate the size of the menu bar.
 + */
 +static void FASTCALL MenuMenuBarCalcSize( HDC hdc, LPRECT lprect,
 +                                          PROSMENUINFO MenuInfo, HWND hwndOwner )
 +{
 +    ROSMENUITEMINFO ItemInfo;
 +    int start, i, orgX, orgY, maxY, helpPos;
 +
 +    if ((lprect == NULL) || (MenuInfo == NULL)) return;
 +    if (MenuInfo->MenuItemCount == 0) return;
 +    TRACE("left=%ld top=%ld right=%ld bottom=%ld\n", lprect->left, lprect->top, lprect->right, lprect->bottom);
 +    MenuInfo->Width = lprect->right - lprect->left;
 +    MenuInfo->Height = 0;
 +    maxY = lprect->top + 1;
 +    start = 0;
 +    helpPos = -1;
 +
 +    MenuInfo->maxBmpSize.cx = 0;
 +    MenuInfo->maxBmpSize.cy = 0;
 +
 +    MenuInitRosMenuItemInfo(&ItemInfo);
 +    while (start < MenuInfo->MenuItemCount)
 +    {
 +        if (! MenuGetRosMenuItemInfo(MenuInfo->Self, start, &ItemInfo))
 +        {
 +            MenuCleanupRosMenuItemInfo(&ItemInfo);
 +            return;
 +        }
 +        orgX = lprect->left;
 +        orgY = maxY;
 +
 +        /* Parse items until line break or end of menu */
 +        for (i = start; i < MenuInfo->MenuItemCount; i++)
 +          {
 +            if ((helpPos == -1) && (ItemInfo.fType & MF_RIGHTJUSTIFY)) helpPos = i;
 +            if ((i != start) &&
 +               (ItemInfo.fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
 +
 +            TRACE("calling MENU_CalcItemSize org=(%d, %d)\n", orgX, orgY);
 +            MenuCalcItemSize(hdc, &ItemInfo, MenuInfo, hwndOwner, orgX, orgY, TRUE);
 +            if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo))
 +            {
 +                MenuCleanupRosMenuItemInfo(&ItemInfo);
 +                return;
 +            }
 +
 +            if (ItemInfo.Rect.right > lprect->right)
 +            {
 +                if (i != start) break;
 +                else ItemInfo.Rect.right = lprect->right;
 +            }
 +            maxY = max( maxY, ItemInfo.Rect.bottom );
 +            orgX = ItemInfo.Rect.right;
 +            if (i + 1 < MenuInfo->MenuItemCount)
 +            {
 +                if (! MenuGetRosMenuItemInfo(MenuInfo->Self, i + 1, &ItemInfo))
 +                {
 +                    MenuCleanupRosMenuItemInfo(&ItemInfo);
 +                    return;
 +                }
 +            }
 +      }
 +
 +/* FIXME: Is this really needed? */ /*NO! it is not needed, why make the
 +HBMMENU_MBAR_CLOSE, MINIMIZE & RESTORE, look the same size as the menu bar! */
 +#if 0
 +        /* Finish the line (set all items to the largest height found) */
 +        while (start < i)
 +        {
 +            if (MenuGetRosMenuItemInfo(MenuInfo->Self, start, &ItemInfo))
 +            {
 +                ItemInfo.Rect.bottom = maxY;
 +                MenuSetRosMenuItemInfo(MenuInfo->Self, start, &ItemInfo);
 +            }
 +            start++;
 +        }
 +#else
 +        start = i; /* This works! */
 +#endif
 +    }
 +
 +    lprect->bottom = maxY;
 +    MenuInfo->Height = lprect->bottom - lprect->top;
 +    MenuSetRosMenuInfo(MenuInfo);
 +
 +    if (helpPos != -1)
 +    {
 +      /* Flush right all items between the MF_RIGHTJUSTIFY and */
 +      /* the last item (if several lines, only move the last line) */
 +      if (! MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->MenuItemCount - 1, &ItemInfo))
 +      {
 +          MenuCleanupRosMenuItemInfo(&ItemInfo);
 +          return;
 +      }
 +      orgY = ItemInfo.Rect.top;
 +      orgX = lprect->right;
 +      for (i = MenuInfo->MenuItemCount - 1; helpPos <= i; i--)
 +        {
 +          if (i < helpPos)
 +          {
 +              break;                          /* done */
 +          }
 +          if (ItemInfo.Rect.top != orgY)
 +          {
 +              break;                          /* Other line */
 +          }
 +          if (orgX <= ItemInfo.Rect.right)
 +          {
 +              break;                          /* Too far right already */
 +          }
 +          ItemInfo.Rect.left += orgX - ItemInfo.Rect.right;
 +          ItemInfo.Rect.right = orgX;
 +          orgX = ItemInfo.Rect.left;
 +          MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo);
 +          if (helpPos + 1 <= i &&
 +              ! MenuGetRosMenuItemInfo(MenuInfo->Self, i - 1, &ItemInfo))
 +            {
 +                MenuCleanupRosMenuItemInfo(&ItemInfo);
 +                return;
 +            }
 +        }
 +    }
 +
 +    MenuCleanupRosMenuItemInfo(&ItemInfo);
 +}
 +
 +/***********************************************************************
 + *           MenuDrawMenuItem
 + *
 + * Draw a single menu item.
 + */
 +static void FASTCALL MenuDrawMenuItem(HWND hWnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC hdc,
 +                 PROSMENUITEMINFO lpitem, UINT Height, BOOL menuBar, UINT odaction)
 +{
 +    RECT rect;
 +    PWCHAR Text;
 +    BOOL flat_menu = FALSE;
 +    int bkgnd;
 +    PWND Wnd = ValidateHwnd(hWnd);
 +
 +    if (!Wnd)
 +      return;
 +
 +    if (lpitem->fType & MF_SYSMENU)
 +    {
 +        if ( (Wnd->style & WS_MINIMIZE))
 +        {
 +          UserGetInsideRectNC(Wnd, &rect);
 +          UserDrawSysMenuButton(hWnd, hdc, &rect,
 +                                lpitem->fState & (MF_HILITE | MF_MOUSESELECT));
 +          }
 +        return;
 +    }
 +
 +    SystemParametersInfoW (SPI_GETFLATMENU, 0, &flat_menu, 0);
 +    bkgnd = (menuBar && flat_menu) ? COLOR_MENUBAR : COLOR_MENU;
 +
 +    /* Setup colors */
 +
 +    if (lpitem->fState & MF_HILITE)
 +    {
 +        if(menuBar && !flat_menu) {
 +            SetTextColor(hdc, GetSysColor(COLOR_MENUTEXT));
 +            SetBkColor(hdc, GetSysColor(COLOR_MENU));
 +        } else {
 +            if (lpitem->fState & MF_GRAYED)
 +                SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
 +            else
 +                SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
 +            SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
 +        }
 +    }
 +    else
 +    {
 +        if (lpitem->fState & MF_GRAYED)
 +            SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
 +        else
 +            SetTextColor( hdc, GetSysColor( COLOR_MENUTEXT ) );
 +        SetBkColor( hdc, GetSysColor( bkgnd ) );
 +    }
 +
 +    rect = lpitem->Rect;
 +
 +    if (lpitem->fType & MF_OWNERDRAW)
 +    {
 +        /*
 +        ** Experimentation under Windows reveals that an owner-drawn
 +        ** menu is given the rectangle which includes the space it requested
 +        ** in its response to WM_MEASUREITEM _plus_ width for a checkmark
 +        ** and a popup-menu arrow.  This is the value of lpitem->rect.
 +        ** Windows will leave all drawing to the application except for
 +        ** the popup-menu arrow.  Windows always draws that itself, after
 +        ** the menu owner has finished drawing.
 +        */
 +        DRAWITEMSTRUCT dis;
 +
 +        dis.CtlType   = ODT_MENU;
 +        dis.CtlID     = 0;
 +        dis.itemID    = lpitem->wID;
 +        dis.itemData  = (DWORD)lpitem->dwItemData;
 +        dis.itemState = 0;
 +        if (lpitem->fState & MF_CHECKED) dis.itemState |= ODS_CHECKED;
 +        if (lpitem->fState & MF_GRAYED)  dis.itemState |= ODS_GRAYED | ODS_DISABLED;
 +        if (lpitem->fState & MF_HILITE)  dis.itemState |= ODS_SELECTED;
 +        dis.itemAction = odaction; /* ODA_DRAWENTIRE | ODA_SELECT | ODA_FOCUS; */
 +        dis.hwndItem   = (HWND) MenuInfo->Self;
 +        dis.hDC        = hdc;
 +        dis.rcItem     = rect;
 +        TRACE("Ownerdraw: owner=%p itemID=%d, itemState=%d, itemAction=%d, "
 +              "hwndItem=%p, hdc=%p, rcItem={%ld,%ld,%ld,%ld}\n", hWnd,
 +              dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem,
 +              dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right,
 +              dis.rcItem.bottom);
 +        SendMessageW(WndOwner, WM_DRAWITEM, 0, (LPARAM) &dis);
 +        /* Draw the popup-menu arrow */
 +        if (lpitem->fType & MF_POPUP)
 +        {
 +            RECT rectTemp;
 +            CopyRect(&rectTemp, &rect);
 +            rectTemp.left = rectTemp.right - GetSystemMetrics(SM_CXMENUCHECK);
 +            DrawFrameControl(hdc, &rectTemp, DFC_MENU, DFCS_MENUARROW);
 +        }
 +        return;
 +    }
 +
 +    if (menuBar && (lpitem->fType & MF_SEPARATOR)) return;
 +
 +    if (lpitem->fState & MF_HILITE)
 +    {
 +        if (flat_menu)
 +        {
 +            InflateRect (&rect, -1, -1);
 +            FillRect(hdc, &rect, GetSysColorBrush(COLOR_MENUHILIGHT));
 +            InflateRect (&rect, 1, 1);
 +            FrameRect(hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT));
 +        }
 +        else
 +        {
 +            if(menuBar)
 +                DrawEdge(hdc, &rect, BDR_SUNKENOUTER, BF_RECT);
 +            else
 +                FillRect(hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT));
 +        }
 +    }
 +    else
 +        FillRect( hdc, &rect, GetSysColorBrush(bkgnd) );
 +
 +    SetBkMode( hdc, TRANSPARENT );
 +
 +    /* vertical separator */
 +    if (!menuBar && (lpitem->fType & MF_MENUBARBREAK))
 +    {
 +        HPEN oldPen;
 +        RECT rc = rect;
 +
 +        rc.left -= 3;
 +        rc.top = 3;
 +        rc.bottom = Height - 3;
 +        if (flat_menu)
 +        {
 +            oldPen = SelectObject( hdc, GetStockObject(DC_PEN) );
 +            SetDCPenColor(hdc, GetSysColor(COLOR_BTNSHADOW));
 +            MoveToEx( hdc, rc.left, rc.top, NULL );
 +            LineTo( hdc, rc.left, rc.bottom );
 +            SelectObject( hdc, oldPen );
 +        }
 +        else
 +            DrawEdge (hdc, &rc, EDGE_ETCHED, BF_LEFT);
 +    }
 +
 +    /* horizontal separator */
 +    if (lpitem->fType & MF_SEPARATOR)
 +    {
 +        HPEN oldPen;
 +        RECT rc = rect;
 +
 +        rc.left++;
 +        rc.right--;
 +        rc.top += SEPARATOR_HEIGHT / 2;
 +        if (flat_menu)
 +        {
 +            oldPen = SelectObject( hdc, GetStockObject(DC_PEN) );
 +            SetDCPenColor( hdc, GetSysColor(COLOR_BTNSHADOW));
 +            MoveToEx( hdc, rc.left, rc.top, NULL );
 +            LineTo( hdc, rc.right, rc.top );
 +            SelectObject( hdc, oldPen );
 +        }
 +        else
 +            DrawEdge (hdc, &rc, EDGE_ETCHED, BF_TOP);
 +        return;
 +    }
 +
 +#if 0
 +    /* helper lines for debugging */
 +    /* This is a very good test tool when hacking menus! (JT) 07/16/2006 */
 +    FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH));
 +    SelectObject(hdc, GetStockObject(DC_PEN));
 +    SetDCPenColor(hdc, GetSysColor(COLOR_WINDOWFRAME));
 +    MoveToEx(hdc, rect.left, (rect.top + rect.bottom) / 2, NULL);
 +    LineTo(hdc, rect.right, (rect.top + rect.bottom) / 2);
 +#endif
 +
 +    if (!menuBar)
 +    {
 +        HBITMAP bm;
 +        INT y = rect.top + rect.bottom;
 +        RECT rc = rect;
 +        int checked = FALSE;
 +        UINT check_bitmap_width = GetSystemMetrics( SM_CXMENUCHECK );
 +        UINT check_bitmap_height = GetSystemMetrics( SM_CYMENUCHECK );
 +        /* Draw the check mark
 +         *
 +         * FIXME:
 +         * Custom checkmark bitmaps are monochrome but not always 1bpp.
 +         */
 +        if( !(MenuInfo->dwStyle & MNS_NOCHECK)) {
 +            bm = (lpitem->fState & MF_CHECKED) ? lpitem->hbmpChecked :
 +                lpitem->hbmpUnchecked;
 +            if (bm)  /* we have a custom bitmap */
 +            {
 +                HDC hdcMem = CreateCompatibleDC( hdc );
 +
 +                SelectObject( hdcMem, bm );
 +                BitBlt( hdc, rc.left, (y - check_bitmap_height) / 2,
 +                        check_bitmap_width, check_bitmap_height,
 +                        hdcMem, 0, 0, SRCCOPY );
 +                DeleteDC( hdcMem );
 +                checked = TRUE;
 +            }
 +            else if (lpitem->fState & MF_CHECKED) /* standard bitmaps */
 +            {
 +                RECT r;
 +                CopyRect(&r, &rect);
 +                r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
 +                DrawFrameControl( hdc, &r, DFC_MENU,
 +                                 (lpitem->fType & MFT_RADIOCHECK) ?
 +                                 DFCS_MENUBULLET : DFCS_MENUCHECK);
 +                checked = TRUE;
 +            }
 +        }
 +        if ( lpitem->hbmpItem )
 +        {
 +            RECT bmpRect;
 +            CopyRect(&bmpRect, &rect);
 +            if (!(MenuInfo->dwStyle & MNS_CHECKORBMP) && !(MenuInfo->dwStyle & MNS_NOCHECK))
 +                bmpRect.left += check_bitmap_width + 2;
 +            if (!(checked && (MenuInfo->dwStyle & MNS_CHECKORBMP)))
 +            {
 +                bmpRect.right = bmpRect.left + MenuInfo->maxBmpSize.cx;
 +                MenuDrawBitmapItem(hdc, lpitem, &bmpRect, MenuInfo->Self, WndOwner, odaction, menuBar);
 +            }
 +        }
 +        /* Draw the popup-menu arrow */
 +        if (lpitem->fType & MF_POPUP)
 +        {
 +            RECT rectTemp;
 +            CopyRect(&rectTemp, &rect);
 +            rectTemp.left = rectTemp.right - GetSystemMetrics(SM_CXMENUCHECK);
 +            DrawFrameControl(hdc, &rectTemp, DFC_MENU, DFCS_MENUARROW);
 +        }
 +        rect.left += 4;
 +        if( !(MenuInfo->dwStyle & MNS_NOCHECK))
 +            rect.left += check_bitmap_width;
 +        rect.right -= check_bitmap_width;
 +    }
 +    else if( lpitem->hbmpItem)
 +    { /* Draw the bitmap */
 +        MenuDrawBitmapItem(hdc, lpitem, &rect, MenuInfo->Self, WndOwner, odaction, menuBar);
 +    }
 +
 +    /* process text if present */
 +    if (lpitem->lpstr)
 +    {
 +        register int i = 0;
 +        HFONT hfontOld = 0;
 +
 +        UINT uFormat = menuBar ? DT_CENTER | DT_VCENTER | DT_SINGLELINE
 +                       : DT_LEFT | DT_VCENTER | DT_SINGLELINE;
 +
 +        if(MenuInfo->dwStyle & MNS_CHECKORBMP)
 +             rect.left += max(0, MenuInfo->maxBmpSize.cx - GetSystemMetrics(SM_CXMENUCHECK));
 +        else
 +             rect.left += MenuInfo->maxBmpSize.cx;
 +
 +        if ( lpitem->fState & MFS_DEFAULT )
 +        {
 +            hfontOld = SelectObject(hdc, hMenuFontBold);
 +        }
 +
 +        if (menuBar) {
 +            rect.left += MENU_BAR_ITEMS_SPACE / 2;
 +            rect.right -= MENU_BAR_ITEMS_SPACE / 2;
 +        }
 +
 +        Text = (PWCHAR) lpitem->dwTypeData;
 +        if(Text)
 +        {
 +            for (i = 0; L'\0' != Text[i]; i++)
 +                if (Text[i] == L'\t' || Text[i] == L'\b')
 +                    break;
 +        }
 +
 +        if(lpitem->fState & MF_GRAYED)
 +        {
 +            if (!(lpitem->fState & MF_HILITE) )
 +            {
 +                ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
 +                SetTextColor(hdc, RGB(0xff, 0xff, 0xff));
 +                DrawTextW( hdc, Text, i, &rect, uFormat );
 +                --rect.left; --rect.top; --rect.right; --rect.bottom;
 +              }
 +            SetTextColor(hdc, RGB(0x80, 0x80, 0x80));
 +        }
 +
 +        DrawTextW( hdc, Text, i, &rect, uFormat);
 +
 +        /* paint the shortcut text */
 +        if (!menuBar && L'\0' != Text[i])  /* There's a tab or flush-right char */
 +        {
 +            if (L'\t' == Text[i])
 +            {
 +                rect.left = lpitem->dxTab;
 +                uFormat = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
 +            }
 +            else
 +            {
 +                rect.right = lpitem->dxTab;
 +                uFormat = DT_RIGHT | DT_VCENTER | DT_SINGLELINE;
 +            }
 +
 +            if (lpitem->fState & MF_GRAYED)
 +            {
 +                if (!(lpitem->fState & MF_HILITE) )
 +                {
 +                    ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
 +                    SetTextColor(hdc, RGB(0xff, 0xff, 0xff));
 +                    DrawTextW( hdc, Text + i + 1, -1, &rect, uFormat);
 +                    --rect.left; --rect.top; --rect.right; --rect.bottom;
 +                }
 +                SetTextColor(hdc, RGB(0x80, 0x80, 0x80));
 +              }
 +          DrawTextW( hdc, Text + i + 1, -1, &rect, uFormat );
 +        }
 +
 +        if (hfontOld)
 +          SelectObject (hdc, hfontOld);
 +    }
 +}
 +
 +/***********************************************************************
 + *           MenuDrawPopupMenu
 + *
 + * Paint a popup menu.
 + */
 +static void FASTCALL MenuDrawPopupMenu(HWND hwnd, HDC hdc, HMENU hmenu )
 +{
 +    HBRUSH hPrevBrush = 0;
 +    RECT rect;
 +
 +    TRACE("wnd=%p dc=%p menu=%p\n", hwnd, hdc, hmenu);
 +
 +    GetClientRect( hwnd, &rect );
 +
 +    if((hPrevBrush = SelectObject( hdc, GetSysColorBrush(COLOR_MENU) ))
 +        && (SelectObject( hdc, hMenuFont)))
 +    {
 +        HPEN hPrevPen;
 +
 +        Rectangle( hdc, rect.left, rect.top, rect.right, rect.bottom );
 +
 +        hPrevPen = SelectObject( hdc, GetStockObject( NULL_PEN ) );
 +        if ( hPrevPen )
 +        {
 +            BOOL flat_menu = FALSE;
 +            ROSMENUINFO MenuInfo;
 +            ROSMENUITEMINFO ItemInfo;
 +
 +            SystemParametersInfoW (SPI_GETFLATMENU, 0, &flat_menu, 0);
 +            if (flat_menu)
 +               FrameRect(hdc, &rect, GetSysColorBrush(COLOR_BTNSHADOW));
 +            else
 +               DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT);
 +
 +            /* draw menu items */
 +            if (MenuGetRosMenuInfo(&MenuInfo, hmenu) && MenuInfo.MenuItemCount)
 +            {
 +                UINT u;
 +
 +                              MenuInitRosMenuItemInfo(&ItemInfo);
 +
 +                for (u = 0; u < MenuInfo.MenuItemCount; u++)
 +                {
 +                    if (MenuGetRosMenuItemInfo(MenuInfo.Self, u, &ItemInfo))
 +                    {
 +                        MenuDrawMenuItem(hwnd, &MenuInfo, MenuInfo.WndOwner, hdc, &ItemInfo,
 +                        MenuInfo.Height, FALSE, ODA_DRAWENTIRE);
 +                    }
 +                }
 +
 +                MenuCleanupRosMenuItemInfo(&ItemInfo);
 +            }
 +         } else
 +         {
 +             SelectObject( hdc, hPrevBrush );
 +         }
 +    }
 +}
 +
 +/***********************************************************************
 + *           MenuDrawMenuBar
 + *
 + * Paint a menu bar. Returns the height of the menu bar.
 + * called from [windows/nonclient.c]
 + */
 +UINT MenuDrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd,
 +                         BOOL suppress_draw)
 +{
 +    ROSMENUINFO lppop;
 +    HFONT hfontOld = 0;
 +    HMENU hMenu = GetMenu(hwnd);
 +
 +    if (! MenuGetRosMenuInfo(&lppop, hMenu) || lprect == NULL)
 +    {
 +        return GetSystemMetrics(SM_CYMENU);
 +    }
 +
 +    if (suppress_draw)
 +    {
 +        hfontOld = SelectObject(hDC, hMenuFont);
 +
 +        MenuMenuBarCalcSize(hDC, lprect, &lppop, hwnd);
 +
 +        lprect->bottom = lprect->top + lppop.Height;
 +
 +        if (hfontOld) SelectObject( hDC, hfontOld);
 +        return lppop.Height;
 +    }
 +      else
 +        return DrawMenuBarTemp(hwnd, hDC, lprect, hMenu, NULL);
 +}
 +
 +/***********************************************************************
 + *           MenuShowPopup
 + *
 + * Display a popup menu.
 + */
 +static BOOL FASTCALL MenuShowPopup(HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
 +                              INT x, INT y, INT xanchor, INT yanchor )
 +{
 +    ROSMENUINFO MenuInfo;
 +    ROSMENUITEMINFO ItemInfo;
 +    UINT width, height;
 +    POINT pt;
 +    HMONITOR monitor;
 +    MONITORINFO info;
 +
 +    TRACE("owner=%p hmenu=%p id=0x%04x x=0x%04x y=0x%04x xa=0x%04x ya=0x%04x\n",
 +          hwndOwner, hmenu, id, x, y, xanchor, yanchor);
 +
 +    if (! MenuGetRosMenuInfo(&MenuInfo, hmenu)) return FALSE;
 +    if (MenuInfo.FocusedItem != NO_SELECTED_ITEM)
 +    {
 +        MenuInitRosMenuItemInfo(&ItemInfo);
 +        if (MenuGetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo))
 +        {
 +            ItemInfo.fMask |= MIIM_STATE;
 +            ItemInfo.fState &= ~(MF_HILITE|MF_MOUSESELECT);
 +            MenuSetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo);
 +        }
 +        MenuCleanupRosMenuItemInfo(&ItemInfo);
 +        MenuInfo.FocusedItem = NO_SELECTED_ITEM;
 +    }
 +
-     /* store the owner for DrawItem */
++    /* store the owner for DrawItem */
++    if (!IsWindow(hwndOwner))
++    {
++       SetLastError( ERROR_INVALID_WINDOW_HANDLE );
 +       return FALSE;
 +    }
-             PostMessageW( hwnd, WM_KEYDOWN, VK_DOWN, 0L );
 +    MenuInfo.WndOwner = hwndOwner;
 +    MenuSetRosMenuInfo(&MenuInfo);
 +
 +    MenuPopupMenuCalcSize(&MenuInfo, hwndOwner);
 +
 +    /* adjust popup menu pos so that it fits within the desktop */
 +
 +    width = MenuInfo.Width + GetSystemMetrics(SM_CXBORDER);
 +    height = MenuInfo.Height + GetSystemMetrics(SM_CYBORDER);
 +
 +    /* FIXME: should use item rect */
 +    pt.x = x;
 +    pt.y = y;
 +    monitor = MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST );
 +    info.cbSize = sizeof(info);
 +    GetMonitorInfoW( monitor, &info );
 +
 +    if( flags & TPM_RIGHTALIGN ) x -= width;
 +    if( flags & TPM_CENTERALIGN ) x -= width / 2;
 +
 +    if( flags & TPM_BOTTOMALIGN ) y -= height;
 +    if( flags & TPM_VCENTERALIGN ) y -= height / 2;
 +
 +    if( x + width > info.rcMonitor.right)
 +    {
 +        if( xanchor && x >= width - xanchor )
 +            x -= width - xanchor;
 +
 +        if( x + width > info.rcMonitor.right)
 +            x = info.rcMonitor.right - width;
 +    }
 +    if( x < info.rcMonitor.left ) x = info.rcMonitor.left;
 +
 +    if( y + height > info.rcMonitor.bottom)
 +    {
 +        if( yanchor && y >= height + yanchor )
 +            y -= height + yanchor;
 +
 +        if( y + height > info.rcMonitor.bottom)
 +            y = info.rcMonitor.bottom - height;
 +    }
 +    if( y < info.rcMonitor.top ) y = info.rcMonitor.top;
 +
 +    /* NOTE: In Windows, top menu popup is not owned. */
 +    MenuInfo.Wnd = CreateWindowExW( 0, WC_MENU, NULL,
 +                                  WS_POPUP, x, y, width, height,
 +                                  hwndOwner, 0, (HINSTANCE) GetWindowLongPtrW(hwndOwner, GWLP_HINSTANCE),
 +                                 (LPVOID) MenuInfo.Self);
 +    if ( !MenuInfo.Wnd || ! MenuSetRosMenuInfo(&MenuInfo)) return FALSE;
 +    if (!top_popup) {
 +        top_popup = MenuInfo.Wnd;
 +        top_popup_hmenu = hmenu;
 +    }
 +
 +    IntNotifyWinEvent(EVENT_SYSTEM_MENUPOPUPSTART, MenuInfo.Wnd, OBJID_CLIENT, CHILDID_SELF, 0);
 +
 +    /* Display the window */
 +
 +    SetWindowPos( MenuInfo.Wnd, HWND_TOPMOST, 0, 0, 0, 0,
 +                  SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
 +    UpdateWindow( MenuInfo.Wnd );
 +    return TRUE;
 +}
 +
 +
 +/***********************************************************************
 + *           MenuSelectItem
 + */
 +static void FASTCALL MenuSelectItem(HWND hwndOwner, PROSMENUINFO hmenu, UINT wIndex,
 +                                    BOOL sendMenuSelect, HMENU topmenu)
 +{
 +    ROSMENUITEMINFO ItemInfo;
 +    ROSMENUINFO TopMenuInfo;
 +    HDC hdc;
 +
 +    TRACE("owner=%p menu=%p index=0x%04x select=0x%04x\n", hwndOwner, hmenu, wIndex, sendMenuSelect);
 +
 +     if (!hmenu || !hmenu->MenuItemCount || !hmenu->Wnd) return;
 +    if (hmenu->FocusedItem == wIndex) return;
 +    if (hmenu->Flags & MF_POPUP) hdc = GetDC(hmenu->Wnd);
 +    else hdc = GetDCEx(hmenu->Wnd, 0, DCX_CACHE | DCX_WINDOW);
 +    if (!top_popup) {
 +        top_popup = hmenu->Wnd;
 +        top_popup_hmenu = hmenu->Self;
 +    }
 +
 +    SelectObject( hdc, hMenuFont );
 +
 +    MenuInitRosMenuItemInfo(&ItemInfo);
 +
 +     /* Clear previous highlighted item */
 +    if (hmenu->FocusedItem != NO_SELECTED_ITEM)
 +    {
 +        if (MenuGetRosMenuItemInfo(hmenu->Self, hmenu->FocusedItem, &ItemInfo))
 +        {
 +            ItemInfo.fMask |= MIIM_STATE;
 +            ItemInfo.fState &= ~(MF_HILITE|MF_MOUSESELECT);
 +            MenuSetRosMenuItemInfo(hmenu->Self, hmenu->FocusedItem, &ItemInfo);
 +        }
 +        MenuDrawMenuItem(hmenu->Wnd, hmenu, hwndOwner, hdc, &ItemInfo,
 +                       hmenu->Height, ! (hmenu->Flags & MF_POPUP),
 +                       ODA_SELECT);
 +    }
 +
 +    /* Highlight new item (if any) */
 +    hmenu->FocusedItem = wIndex;
 +    MenuSetRosMenuInfo(hmenu);
 +    if (hmenu->FocusedItem != NO_SELECTED_ITEM)
 +    {
 +        if (MenuGetRosMenuItemInfo(hmenu->Self, hmenu->FocusedItem, &ItemInfo))
 +        {
 +            if (!(ItemInfo.fType & MF_SEPARATOR))
 +            {
 +                ItemInfo.fMask |= MIIM_STATE;
 +                ItemInfo.fState |= MF_HILITE;
 +                MenuSetRosMenuItemInfo(hmenu->Self, hmenu->FocusedItem, &ItemInfo);
 +                MenuDrawMenuItem(hmenu->Wnd, hmenu, hwndOwner, hdc,
 +                               &ItemInfo, hmenu->Height, ! (hmenu->Flags & MF_POPUP),
 +                               ODA_SELECT);
 +            }
 +            if (sendMenuSelect)
 +            {
 +                SendMessageW(hwndOwner, WM_MENUSELECT,
 +                           MAKELONG(ItemInfo.fType & MF_POPUP ? wIndex : ItemInfo.wID,
 +                                    ItemInfo.fType | ItemInfo.fState | MF_MOUSESELECT |
 +                                    (hmenu->Flags & MF_SYSMENU)), (LPARAM) hmenu->Self);
 +            }
 +        }
 +    }
 +    else if (sendMenuSelect) {
 +        if(topmenu) {
 +            int pos;
 +            pos = MenuFindSubMenu(&topmenu, hmenu->Self);
 +            if (pos != NO_SELECTED_ITEM)
 +            {
 +                if (MenuGetRosMenuInfo(&TopMenuInfo, topmenu)
 +                    && MenuGetRosMenuItemInfo(topmenu, pos, &ItemInfo))
 +                {
 +                    SendMessageW(hwndOwner, WM_MENUSELECT,
 +                               MAKELONG(Pos, ItemInfo.fType | ItemInfo.fState
 +                                             | MF_MOUSESELECT
 +                                             | (TopMenuInfo.Flags & MF_SYSMENU)),
 +                               (LPARAM) topmenu);
 +                }
 +            }
 +        }
 +    }
 +    MenuCleanupRosMenuItemInfo(&ItemInfo);
 +    ReleaseDC(hmenu->Wnd, hdc);
 +}
 +
 +/***********************************************************************
 + *           MenuMoveSelection
 + *
 + * Moves currently selected item according to the Offset parameter.
 + * If there is no selection then it should select the last item if
 + * Offset is ITEM_PREV or the first item if Offset is ITEM_NEXT.
 + */
 +static void FASTCALL
 +MenuMoveSelection(HWND WndOwner, PROSMENUINFO MenuInfo, INT Offset)
 +{
 +  INT i;
 +  ROSMENUITEMINFO ItemInfo;
 +  INT OrigPos;
 +
 +  TRACE("hwnd=%x menu=%x off=0x%04x\n", WndOwner, MenuInfo, Offset);
 +
 +  /* Prevent looping */
 +  if (0 == MenuInfo->MenuItemCount || 0 == Offset)
 +    return;
 +  else if (Offset < -1)
 +    Offset = -1;
 +  else if (Offset > 1)
 +    Offset = 1;
 +
 +  MenuInitRosMenuItemInfo(&ItemInfo);
 +
 +  OrigPos = MenuInfo->FocusedItem;
 +  if (OrigPos == NO_SELECTED_ITEM) /* NO_SELECTED_ITEM is not -1 ! */
 +    {
 +       OrigPos = 0;
 +       i = -1;
 +    }
 +  else
 +    {
 +      i = MenuInfo->FocusedItem;
 +    }
 +
 +  do
 +    {
 +      /* Step */
 +      i += Offset;
 +      /* Clip and wrap around */
 +      if (i < 0)
 +        {
 +          i = MenuInfo->MenuItemCount - 1;
 +        }
 +      else if (i >= MenuInfo->MenuItemCount)
 +        {
 +          i = 0;
 +        }
 +      /* If this is a good candidate; */
 +      if (MenuGetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo) &&
 +          0 == (ItemInfo.fType & MF_SEPARATOR))
 +        {
 +          MenuSelectItem(WndOwner, MenuInfo, i, TRUE, NULL);
 +          MenuCleanupRosMenuItemInfo(&ItemInfo);
 +          return;
 +        }
 +    } while (i != OrigPos);
 +
 +  /* Not found */
 +  MenuCleanupRosMenuItemInfo(&ItemInfo);
 +}
 +
 +//
 +// This breaks some test results. Should handle A2U if called!
 +//
 +LRESULT WINAPI PopupMenuWndProcA(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
 +{
 +  TRACE("YES! hwnd=%x msg=0x%04x wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
 +#ifdef __REACTOS__
 +  PWND pWnd;
 +
 +  pWnd = ValidateHwnd(Wnd);
 +  if (pWnd)
 +  {
 +     if (!pWnd->fnid)
 +     {
 +        NtUserSetWindowFNID(Wnd, FNID_MENU);
 +     }
 +  }    
 +#endif    
 +
 +  switch(Message)
 +    {
 +    case WM_CREATE:
 +      {
 +        CREATESTRUCTA *cs = (CREATESTRUCTA *) lParam;
 +        SetWindowLongPtrA(Wnd, 0, (LONG_PTR)cs->lpCreateParams);
 +        return 0;
 +      }
 +
 +    case WM_MOUSEACTIVATE:  /* We don't want to be activated */
 +      return MA_NOACTIVATE;
 +
 +    case WM_PAINT:
 +      {
 +        PAINTSTRUCT ps;
 +        BeginPaint(Wnd, &ps);
 +        MenuDrawPopupMenu(Wnd, ps.hdc, (HMENU)GetWindowLongPtrA(Wnd, 0));
 +        EndPaint(Wnd, &ps);
 +        return 0;
 +      }
 +
 +    case WM_PRINTCLIENT:
 +      {
 +        MenuDrawPopupMenu( Wnd, (HDC)wParam,
 +                                (HMENU)GetWindowLongPtrW( Wnd, 0 ) );
 +        return 0;
 +      }
 +
 +    case WM_ERASEBKGND:
 +      return 1;
 +
 +    case WM_DESTROY:
 +      /* zero out global pointer in case resident popup window was destroyed. */
 +      if (Wnd == top_popup)
 +        {
 +          top_popup = NULL;
 +          top_popup_hmenu = NULL;
 +        }
 +#ifdef __REACTOS__
 +      NtUserSetWindowFNID(Wnd, FNID_DESTROY);
 +#endif
 +      break;
 +
 +    case WM_SHOWWINDOW:
 +      if (0 != wParam)
 +        {
 +          if (0 == GetWindowLongPtrA(Wnd, 0))
 +            {
 +              OutputDebugStringA("no menu to display\n");
 +            }
 +        }
 +      else
 +        {
 +          SetWindowLongPtrA(Wnd, 0, 0);
 +        }
 +      break;
 +
 +    case MM_SETMENUHANDLE:
 +      SetWindowLongPtrA(Wnd, 0, wParam);
 +      break;
 +
 +    case MM_GETMENUHANDLE:
 +    case MN_GETHMENU:
 +      return GetWindowLongPtrA(Wnd, 0);
 +
 +    default:
 +      return DefWindowProcA(Wnd, Message, wParam, lParam);
 +    }
 +  return 0;
 +}
 +
 +LRESULT WINAPI
 +PopupMenuWndProcW(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
 +{
 +  TRACE("hwnd=%x msg=0x%04x wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
 +#ifdef __REACTOS__ // Do this now, remove after Server side is fixed.
 +  PWND pWnd;
 +
 +  pWnd = ValidateHwnd(Wnd);
 +  if (pWnd)
 +  {
 +     if (!pWnd->fnid)
 +     {
 +        NtUserSetWindowFNID(Wnd, FNID_MENU);
 +     }
 +  }    
 +#endif    
 +
 +  switch(Message)
 +    {
 +    case WM_CREATE:
 +      {
 +        CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
 +        SetWindowLongPtrW(Wnd, 0, (LONG_PTR)cs->lpCreateParams);
 +        return 0;
 +      }
 +
 +    case WM_MOUSEACTIVATE:  /* We don't want to be activated */
 +      return MA_NOACTIVATE;
 +
 +    case WM_PAINT:
 +      {
 +        PAINTSTRUCT ps;
 +        BeginPaint(Wnd, &ps);
 +        MenuDrawPopupMenu(Wnd, ps.hdc, (HMENU)GetWindowLongPtrW(Wnd, 0));
 +        EndPaint(Wnd, &ps);
 +        return 0;
 +      }
 +
 +    case WM_PRINTCLIENT:
 +      {
 +         MenuDrawPopupMenu( Wnd, (HDC)wParam,
 +                                (HMENU)GetWindowLongPtrW( Wnd, 0 ) );
 +         return 0;
 +      }
 +
 +    case WM_ERASEBKGND:
 +      return 1;
 +
 +    case WM_DESTROY:
 +      /* zero out global pointer in case resident popup window was destroyed. */
 +      if (Wnd == top_popup)
 +        {
 +          top_popup = NULL;
 +          top_popup_hmenu = NULL;
 +        }
 +#ifdef __REACTOS__
 +      NtUserSetWindowFNID(Wnd, FNID_DESTROY);
 +#endif
 +      break;
 +
 +    case WM_SHOWWINDOW:
 +      if (0 != wParam)
 +        {
 +          if (0 == GetWindowLongPtrW(Wnd, 0))
 +            {
 +              OutputDebugStringA("no menu to display\n");
 +            }
 +        }
 +      else
 +        {
 +          SetWindowLongPtrW(Wnd, 0, 0);
 +        }
 +      break;
 +
 +    case MM_SETMENUHANDLE:
 +      SetWindowLongPtrW(Wnd, 0, wParam);
 +      break;
 +
 +    case MM_GETMENUHANDLE:
 +    case MN_GETHMENU:
 +      return GetWindowLongPtrW(Wnd, 0);
 +
 +    default:
 +      return DefWindowProcW(Wnd, Message, wParam, lParam);
 +    }
 +
 +  return 0;
 +}
 +
 +/**********************************************************************
 + *         MENU_ParseResource
 + *
 + * Parse a standard menu resource and add items to the menu.
 + * Return a pointer to the end of the resource.
 + *
 + * NOTE: flags is equivalent to the mtOption field
 + */
 +static LPCSTR MENU_ParseResource( LPCSTR res, HMENU hMenu, BOOL unicode )
 +{
 +    WORD flags, id = 0;
 +    HMENU hSubMenu;
 +    LPCSTR str;
 +    BOOL end = FALSE;
 +
 +    do
 +    {
 +        flags = GET_WORD(res);
 +
 +        /* remove MF_END flag before passing it to AppendMenu()! */
 +        end = (flags & MF_END);
 +        if(end) flags ^= MF_END;
 +
 +        res += sizeof(WORD);
 +        if(!(flags & MF_POPUP))
 +        {
 +            id = GET_WORD(res);
 +            res += sizeof(WORD);
 +        }
 +        str = res;
 +        if(!unicode)
 +            res += strlen(str) + 1;
 +        else
 +            res += (strlenW((LPCWSTR)str) + 1) * sizeof(WCHAR);
 +        if (flags & MF_POPUP)
 +        {
 +            hSubMenu = CreatePopupMenu();
 +            if(!hSubMenu) return NULL;
 +            if(!(res = MENU_ParseResource(res, hSubMenu, unicode)))
 +                return NULL;
 +            if(!unicode)
 +                AppendMenuA(hMenu, flags, (UINT)hSubMenu, str);
 +            else
 +                AppendMenuW(hMenu, flags, (UINT)hSubMenu, (LPCWSTR)str);
 +        }
 +        else  /* Not a popup */
 +        {
 +            if(!unicode)
 +            {
 +                if (*str == 0)
 +                    flags = MF_SEPARATOR;
 +            }
 +            else
 +            {
 +                if (*(LPCWSTR)str == 0)
 +                    flags = MF_SEPARATOR;
 +            }
 +
 +            if (flags & MF_SEPARATOR)
 +            {
 +                if (!(flags & (MF_GRAYED | MF_DISABLED)))
 +                    flags |= MF_GRAYED | MF_DISABLED;
 +            }
 +
 +            if(!unicode)
 +                AppendMenuA(hMenu, flags, id, *str ? str : NULL);
 +            else
 +                AppendMenuW(hMenu, flags, id,
 +                    *(LPCWSTR)str ? (LPCWSTR)str : NULL);
 +        }
 +    } while(!end);
 +    return res;
 +}
 +
 +
 +/**********************************************************************
 + *         MENUEX_ParseResource
 + *
 + * Parse an extended menu resource and add items to the menu.
 + * Return a pointer to the end of the resource.
 + */
 +static LPCSTR MENUEX_ParseResource( LPCSTR res, HMENU hMenu)
 +{
 +    WORD resinfo;
 +    do {
 +        MENUITEMINFOW mii;
 +
 +        mii.cbSize = sizeof(mii);
 +        mii.fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE;
 +        mii.fType = GET_DWORD(res);
 +        res += sizeof(DWORD);
 +        mii.fState = GET_DWORD(res);
 +        res += sizeof(DWORD);
 +        mii.wID = GET_DWORD(res);
 +        res += sizeof(DWORD);
 +        resinfo = GET_WORD(res);
 +        res += sizeof(WORD);
 +        /* Align the text on a word boundary.  */
 +        res += (~((UINT_PTR)res - 1)) & 1;
 +        mii.dwTypeData = (LPWSTR) res;
 +        res += (1 + strlenW(mii.dwTypeData)) * sizeof(WCHAR);
 +        /* Align the following fields on a dword boundary.  */
 +        res += (~((UINT_PTR)res - 1)) & 3;
 +
 +        TRACE("Menu item: [%08x,%08x,%04x,%04x,%S]\n",
 +              mii.fType, mii.fState, mii.wID, resinfo, mii.dwTypeData);
 +
 +              if (resinfo & 1) { /* Pop-up? */
 +            /* DWORD helpid = GET_DWORD(res); FIXME: use this.  */
 +            res += sizeof(DWORD);
 +            mii.hSubMenu = CreatePopupMenu();
 +            if (!mii.hSubMenu)
 +                return NULL;
 +            if (!(res = MENUEX_ParseResource(res, mii.hSubMenu))) {
 +                DestroyMenu(mii.hSubMenu);
 +                return NULL;
 +            }
 +            mii.fMask |= MIIM_SUBMENU;
 +            mii.fType |= MF_POPUP;
 +            mii.wID = (UINT) mii.hSubMenu;
 +        }
 +        else if(!*mii.dwTypeData && !(mii.fType & MF_SEPARATOR))
 +        {
 +            mii.fType |= MF_SEPARATOR;
 +        }
 +        InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii);
 +    } while (!(resinfo & MF_END));
 +    return res;
 +}
 +
 +NTSTATUS WINAPI
 +User32LoadSysMenuTemplateForKernel(PVOID Arguments, ULONG ArgumentLength)
 +{
 +  HMENU hmenu = LoadMenuW(User32Instance, L"SYSMENU");
 +  LRESULT Result = (LRESULT)hmenu;
 +  MENUINFO menuinfo = {0};
 +  MENUITEMINFOW info = {0};
 +
 +  // removing space for checkboxes from menu
 +  menuinfo.cbSize = sizeof(menuinfo);
 +  menuinfo.fMask = MIM_STYLE;
 +  GetMenuInfo(hmenu, &menuinfo);
 +  menuinfo.dwStyle |= MNS_NOCHECK;
 +  SetMenuInfo(hmenu, &menuinfo);
 +
 +  // adding bitmaps to menu items
 +  info.cbSize = sizeof(info);
 +  info.fMask |= MIIM_BITMAP;
 +  info.hbmpItem = HBMMENU_POPUP_MINIMIZE;
 +  SetMenuItemInfoW(hmenu, SC_MINIMIZE, FALSE, &info);
 +  info.hbmpItem = HBMMENU_POPUP_RESTORE;
 +  SetMenuItemInfoW(hmenu, SC_RESTORE, FALSE, &info);
 +  info.hbmpItem = HBMMENU_POPUP_MAXIMIZE;
 +  SetMenuItemInfoW(hmenu, SC_MAXIMIZE, FALSE, &info);
 +  info.hbmpItem = HBMMENU_POPUP_CLOSE;
 +  SetMenuItemInfoW(hmenu, SC_CLOSE, FALSE, &info);
 +
 +  return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS));
 +}
 +
 +
 +BOOL
 +MenuInit(VOID)
 +{
 +  NONCLIENTMETRICSW ncm;
 +
 +  /* get the menu font */
 +  if(!hMenuFont || !hMenuFontBold)
 +  {
 +    ncm.cbSize = sizeof(ncm);
 +    if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0))
 +    {
 +      DbgPrint("MenuInit(): SystemParametersInfoW(SPI_GETNONCLIENTMETRICS) failed!\n");
 +      return FALSE;
 +    }
 +
 +    hMenuFont = CreateFontIndirectW(&ncm.lfMenuFont);
 +    if(hMenuFont == NULL)
 +    {
 +      DbgPrint("MenuInit(): CreateFontIndirectW(hMenuFont) failed!\n");
 +      return FALSE;
 +    }
 +
 +    ncm.lfMenuFont.lfWeight = max(ncm.lfMenuFont.lfWeight + 300, 1000);
 +    hMenuFontBold = CreateFontIndirectW(&ncm.lfMenuFont);
 +    if(hMenuFontBold == NULL)
 +    {
 +      DbgPrint("MenuInit(): CreateFontIndirectW(hMenuFontBold) failed!\n");
 +      DeleteObject(hMenuFont);
 +      hMenuFont = NULL;
 +      return FALSE;
 +    }
 +  }
 +
 +  return TRUE;
 +}
 +
 +VOID
 +MenuCleanup(VOID)
 +{
 +  if (hMenuFont)
 +  {
 +    DeleteObject(hMenuFont);
 +    hMenuFont = NULL;
 +  }
 +
 +  if (hMenuFontBold)
 +  {
 +    DeleteObject(hMenuFontBold);
 +    hMenuFontBold = NULL;
 +  }
 +}
 +
 +/***********************************************************************
 + *           DrawMenuBarTemp   (USER32.@)
 + *
 + * UNDOCUMENTED !!
 + *
 + * called by W98SE desk.cpl Control Panel Applet
 + *
 + * Not 100% sure about the param names, but close.
 + *
 + * @implemented
 + */
 +DWORD WINAPI
 +DrawMenuBarTemp(HWND Wnd, HDC DC, LPRECT Rect, HMENU Menu, HFONT Font)
 +{
 +  ROSMENUINFO MenuInfo;
 +  ROSMENUITEMINFO ItemInfo;
 +  UINT i;
 +  HFONT FontOld = NULL;
 +  BOOL flat_menu = FALSE;
 +
 +  SystemParametersInfoW (SPI_GETFLATMENU, 0, &flat_menu, 0);
 +
 +  if (NULL == Menu)
 +    {
 +      Menu = GetMenu(Wnd);
 +    }
 +
 +  if (NULL == Font)
 +    {
 +      Font = hMenuFont;
 +    }
 +
 +  if (NULL == Rect || ! MenuGetRosMenuInfo(&MenuInfo, Menu))
 +    {
 +      return GetSystemMetrics(SM_CYMENU);
 +    }
 +
 +  TRACE("(%x, %x, %p, %x, %x)\n", Wnd, DC, Rect, Menu, Font);
 +
 +  FontOld = SelectObject(DC, Font);
 +
 +  if (0 == MenuInfo.Height)
 +    {
 +      MenuMenuBarCalcSize(DC, Rect, &MenuInfo, Wnd);
 +    }
 +
 +  Rect->bottom = Rect->top + MenuInfo.Height;
 +
 +  FillRect(DC, Rect, GetSysColorBrush(flat_menu ? COLOR_MENUBAR : COLOR_MENU));
 +
 +  SelectObject(DC, GetStockObject(DC_PEN));
 +  SetDCPenColor(DC, GetSysColor(COLOR_3DFACE));
 +  MoveToEx(DC, Rect->left, Rect->bottom - 1, NULL);
 +  LineTo(DC, Rect->right, Rect->bottom - 1);
 +
 +  if (0 == MenuInfo.MenuItemCount)
 +    {
 +      SelectObject(DC, FontOld);
 +      return GetSystemMetrics(SM_CYMENU);
 +    }
 +
 +  MenuInitRosMenuItemInfo(&ItemInfo);
 +  for (i = 0; i < MenuInfo.MenuItemCount; i++)
 +    {
 +      if (MenuGetRosMenuItemInfo(MenuInfo.Self, i, &ItemInfo))
 +        {
 +          MenuDrawMenuItem(Wnd, &MenuInfo, Wnd, DC, &ItemInfo,
 +                           MenuInfo.Height, TRUE, ODA_DRAWENTIRE);
 +        }
 +    }
 +  MenuCleanupRosMenuItemInfo(&ItemInfo);
 +
 +  SelectObject(DC, FontOld);
 +
 +  return MenuInfo.Height;
 +}
 +
 +/***********************************************************************
 + *           MenuShowSubPopup
 + *
 + * Display the sub-menu of the selected item of this menu.
 + * Return the handle of the submenu, or menu if no submenu to display.
 + */
 +static HMENU FASTCALL
 +MenuShowSubPopup(HWND WndOwner, PROSMENUINFO MenuInfo, BOOL SelectFirst, UINT Flags)
 +{
 +  extern void FASTCALL NcGetSysPopupPos(HWND Wnd, RECT *Rect);
 +  RECT Rect;
 +  ROSMENUITEMINFO ItemInfo;
 +  ROSMENUINFO SubMenuInfo;
 +  HDC Dc;
 +  HMENU Ret;
 +
 +  TRACE("owner=%x menu=%p 0x%04x\n", WndOwner, MenuInfo, SelectFirst);
 +
 +  if (NO_SELECTED_ITEM == MenuInfo->FocusedItem)
 +    {
 +      return MenuInfo->Self;
 +    }
 +
 +  MenuInitRosMenuItemInfo(&ItemInfo);
 +  if (! MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo))
 +    {
 +      MenuCleanupRosMenuItemInfo(&ItemInfo);
 +      return MenuInfo->Self;
 +    }
 +  if (0 == (ItemInfo.fType & MF_POPUP) || 0 != (ItemInfo.fState & (MF_GRAYED | MF_DISABLED)))
 +    {
 +      MenuCleanupRosMenuItemInfo(&ItemInfo);
 +      return MenuInfo->Self;
 +    }
 +
 +  /* message must be sent before using item,
 +     because nearly everything may be changed by the application ! */
 +
 +  /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
 +  if (0 == (Flags & TPM_NONOTIFY))
 +    {
 +      SendMessageW(WndOwner, WM_INITMENUPOPUP, (WPARAM) ItemInfo.hSubMenu,
 +                   MAKELONG(MenuInfo->FocusedItem, IS_SYSTEM_MENU(MenuInfo)));
 +    }
 +
 +  if (! MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo))
 +    {
 +      MenuCleanupRosMenuItemInfo(&ItemInfo);
 +      return MenuInfo->Self;
 +    }
 +  Rect = ItemInfo.Rect;
 +
 +  /* correct item if modified as a reaction to WM_INITMENUPOPUP message */
 +  if (0 == (ItemInfo.fState & MF_HILITE))
 +    {
 +      if (0 != (MenuInfo->Flags & MF_POPUP))
 +        {
 +          Dc = GetDC(MenuInfo->Wnd);
 +        }
 +      else
 +        {
 +          Dc = GetDCEx(MenuInfo->Wnd, 0, DCX_CACHE | DCX_WINDOW);
 +        }
 +
 +      SelectObject(Dc, hMenuFont);
 +      ItemInfo.fMask |= MIIM_STATE;
 +      ItemInfo.fState |= MF_HILITE;
 +      MenuSetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo);
 +      MenuDrawMenuItem(MenuInfo->Wnd, MenuInfo, WndOwner, Dc, &ItemInfo, MenuInfo->Height,
 +                       ! (MenuInfo->Flags & MF_POPUP), ODA_DRAWENTIRE);
 +      ReleaseDC(MenuInfo->Wnd, Dc);
 +    }
 +
 +  if (0 == ItemInfo.Rect.top && 0 == ItemInfo.Rect.left
 +      && 0 == ItemInfo.Rect.bottom && 0 == ItemInfo.Rect.right)
 +    {
 +      ItemInfo.Rect = Rect;
 +    }
 +
 +  ItemInfo.fMask |= MIIM_STATE;
 +  ItemInfo.fState |= MF_MOUSESELECT;
 +  MenuSetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo);
 +
 +  if (IS_SYSTEM_MENU(MenuInfo))
 +    {
 +      MenuInitSysMenuPopup(ItemInfo.hSubMenu, GetWindowLongPtrW(MenuInfo->Wnd, GWL_STYLE),
 +                           GetClassLongPtrW(MenuInfo->Wnd, GCL_STYLE), HTSYSMENU);
 +
 +      NcGetSysPopupPos(MenuInfo->Wnd, &Rect);
 +      Rect.top = Rect.bottom;
 +      Rect.right = GetSystemMetrics(SM_CXSIZE);
 +      Rect.bottom = GetSystemMetrics(SM_CYSIZE);
 +    }
 +  else
 +    {
 +      GetWindowRect(MenuInfo->Wnd, &Rect);
 +      if (0 != (MenuInfo->Flags & MF_POPUP))
 +      {
 +          Rect.left += ItemInfo.Rect.right - GetSystemMetrics(SM_CXBORDER);
 +          Rect.top += ItemInfo.Rect.top - 3;
 +          Rect.right = ItemInfo.Rect.left - ItemInfo.Rect.right + GetSystemMetrics(SM_CXBORDER);
 +          Rect.bottom = ItemInfo.Rect.top - ItemInfo.Rect.bottom - 3 - 2
 +                                                    - GetSystemMetrics(SM_CYBORDER);
 +        }
 +      else
 +        {
 +          Rect.left += ItemInfo.Rect.left;
 +          Rect.top += ItemInfo.Rect.bottom;
 +          Rect.right = ItemInfo.Rect.right - ItemInfo.Rect.left;
 +          Rect.bottom = ItemInfo.Rect.bottom - ItemInfo.Rect.top;
 +        }
 +    }
 +
 +  MenuShowPopup(WndOwner, ItemInfo.hSubMenu, MenuInfo->FocusedItem, Flags,
 +                Rect.left, Rect.top, Rect.right, Rect.bottom );
 +  if (SelectFirst && MenuGetRosMenuInfo(&SubMenuInfo, ItemInfo.hSubMenu))
 +    {
 +      MenuMoveSelection(WndOwner, &SubMenuInfo, ITEM_NEXT);
 +    }
 +
 +  Ret = ItemInfo.hSubMenu;
 +  MenuCleanupRosMenuItemInfo(&ItemInfo);
 +
 +  return Ret;
 +}
 +
 +/**********************************************************************
 + *         MENU_EndMenu
 + *
 + * Calls EndMenu() if the hwnd parameter belongs to the menu owner
 + *
 + * Does the (menu stuff) of the default window handling of WM_CANCELMODE
 + */
 +void MENU_EndMenu( HWND hwnd )
 +{
 +    ROSMENUINFO MenuInfo;
 +    BOOL Ret = FALSE;
 +    if (top_popup_hmenu)
 +       Ret = MenuGetRosMenuInfo(&MenuInfo, top_popup_hmenu);
 +    if (Ret && hwnd == MenuInfo.WndOwner) EndMenu();
 +}
 +
 +/***********************************************************************
 + *           MenuHideSubPopups
 + *
 + * Hide the sub-popup menus of this menu.
 + */
 +static void FASTCALL
 +MenuHideSubPopups(HWND WndOwner, PROSMENUINFO MenuInfo,
 +                               BOOL SendMenuSelect, UINT wFlags)
 +{
 +  ROSMENUINFO SubMenuInfo;
 +  ROSMENUITEMINFO ItemInfo;
 +
 +  TRACE("owner=%x menu=%x 0x%04x\n", WndOwner, MenuInfo, SendMenuSelect);
 +
 +  if (NULL != MenuInfo && NULL != top_popup && NO_SELECTED_ITEM != MenuInfo->FocusedItem)
 +  {
 +      MenuInitRosMenuItemInfo(&ItemInfo);
 +      ItemInfo.fMask |= MIIM_FTYPE | MIIM_STATE;
 +      if (! MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo)
 +          || 0 == (ItemInfo.fType & MF_POPUP)
 +          || 0 == (ItemInfo.fState & MF_MOUSESELECT))
 +      {
 +          MenuCleanupRosMenuItemInfo(&ItemInfo);
 +          return;
 +      }
 +      ItemInfo.fState &= ~MF_MOUSESELECT;
 +      ItemInfo.fMask |= MIIM_STATE;
 +      MenuSetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo);
 +      if (MenuGetRosMenuInfo(&SubMenuInfo, ItemInfo.hSubMenu))
 +      {
 +          MenuHideSubPopups(WndOwner, &SubMenuInfo, FALSE, wFlags);
 +          MenuSelectItem(WndOwner, &SubMenuInfo, NO_SELECTED_ITEM, SendMenuSelect, NULL);
 +          DestroyWindow(SubMenuInfo.Wnd);
 +          SubMenuInfo.Wnd = NULL;
 +          MenuSetRosMenuInfo(&SubMenuInfo);
 +
 +          if (!(wFlags & TPM_NONOTIFY))
 +             SendMessageW( WndOwner, WM_UNINITMENUPOPUP, (WPARAM)ItemInfo.hSubMenu,
 +                                 MAKELPARAM(0, IS_SYSTEM_MENU(&SubMenuInfo)) );
 +      }
 +  }
 +}
 +
 +/***********************************************************************
 + *           MenuSwitchTracking
 + *
 + * Helper function for menu navigation routines.
 + */
 +static void FASTCALL
 +MenuSwitchTracking(MTRACKER* Mt, PROSMENUINFO PtMenuInfo, UINT Index, UINT wFlags)
 +{
 +  ROSMENUINFO TopMenuInfo;
 +
 +  TRACE("%x menu=%x 0x%04x\n", Mt, PtMenuInfo->Self, Index);
 +
 +  if (MenuGetRosMenuInfo(&TopMenuInfo, Mt->TopMenu) &&
 +      Mt->TopMenu != PtMenuInfo->Self &&
 +      0 == ((PtMenuInfo->Flags | TopMenuInfo.Flags) & MF_POPUP))
 +    {
 +      /* both are top level menus (system and menu-bar) */
 +      MenuHideSubPopups(Mt->OwnerWnd, &TopMenuInfo, FALSE, wFlags);
 +      MenuSelectItem(Mt->OwnerWnd, &TopMenuInfo, NO_SELECTED_ITEM, FALSE, NULL);
 +      Mt->TopMenu = PtMenuInfo->Self;
 +    }
 +  else
 +    {
 +      MenuHideSubPopups(Mt->OwnerWnd, PtMenuInfo, FALSE, wFlags);
 +    }
 +
 +  MenuSelectItem(Mt->OwnerWnd, PtMenuInfo, Index, TRUE, NULL);
 +}
 +
 +/***********************************************************************
 + *           MenuExecFocusedItem
 + *
 + * Execute a menu item (for instance when user pressed Enter).
 + * Return the wID of the executed item. Otherwise, -1 indicating
 + * that no menu item was executed, -2 if a popup is shown;
 + * Have to receive the flags for the TrackPopupMenu options to avoid
 + * sending unwanted message.
 + *
 + */
 +static INT FASTCALL
 +MenuExecFocusedItem(MTRACKER *Mt, PROSMENUINFO MenuInfo, UINT Flags)
 +{
 +  ROSMENUITEMINFO ItemInfo;
 +  UINT wID;
 +
 +  TRACE("%p menu=%p\n", Mt, MenuInfo);
 +
 +  if (0 == MenuInfo->MenuItemCount || NO_SELECTED_ITEM == MenuInfo->FocusedItem)
 +    {
 +      return -1;
 +    }
 +
 +  MenuInitRosMenuItemInfo(&ItemInfo);
 +  if (! MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo))
 +    {
 +      MenuCleanupRosMenuItemInfo(&ItemInfo);
 +      return -1;
 +    }
 +
 +  TRACE("%p %08x %p\n", MenuInfo, ItemInfo.wID, ItemInfo.hSubMenu);
 +
 +  if (0 == (ItemInfo.fType & MF_POPUP))
 +    {
 +      if (0 == (ItemInfo.fState & (MF_GRAYED | MF_DISABLED))
 +          && 0 == (ItemInfo.fType & MF_SEPARATOR))
 +        {
 +          /* If TPM_RETURNCMD is set you return the id, but
 +            do not send a message to the owner */
 +          if (0 == (Flags & TPM_RETURNCMD))
 +          {
 +              if (0 != (MenuInfo->Flags & MF_SYSMENU))
 +                {
 +                  PostMessageW(Mt->OwnerWnd, WM_SYSCOMMAND, ItemInfo.wID,
 +                               MAKELPARAM((SHORT) Mt->Pt.x, (SHORT) Mt->Pt.y));
 +                }
 +              else
 +                {
 +                  if (MenuInfo->dwStyle & MNS_NOTIFYBYPOS)
 +                      PostMessageW(Mt->OwnerWnd, WM_MENUCOMMAND,
 +                                                 MenuInfo->FocusedItem,
 +                                                       (LPARAM)MenuInfo->Self);
 +                  else
 +                    PostMessageW(Mt->OwnerWnd, WM_COMMAND, ItemInfo.wID, 0);
 +                }
 +            }
 +          wID = ItemInfo.wID;
 +          MenuCleanupRosMenuItemInfo(&ItemInfo);
 +        return wID;
 +        }
 +    }
 +  else
 +    {
 +      Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, MenuInfo, TRUE, Flags);
 +      return -2;
 +    }
 +
 +  return -1;
 +}
 +
 +/***********************************************************************
 + *           MenuButtonDown
 + *
 + * Return TRUE if we can go on with menu tracking.
 + */
 +static BOOL FASTCALL
 +MenuButtonDown(MTRACKER* Mt, HMENU PtMenu, UINT Flags)
 +{
 +  int Index;
 +  ROSMENUINFO MenuInfo;
 +  ROSMENUITEMINFO Item;
 +
 +  TRACE("%x PtMenu=%p\n", Mt, PtMenu);
 +
 +  if (NULL != PtMenu)
 +    {
 +      if (! MenuGetRosMenuInfo(&MenuInfo, PtMenu))
 +        {
 +          return FALSE;
 +        }
 +      if (IS_SYSTEM_MENU(&MenuInfo))
 +        {
 +          Index = 0;
 +        }
 +      else
 +        {
 +          Index = NtUserMenuItemFromPoint(Mt->OwnerWnd, PtMenu, Mt->Pt.x, Mt->Pt.y);
 +        }
 +      MenuInitRosMenuItemInfo(&Item);
 +      if (NO_SELECTED_ITEM == Index || ! MenuGetRosMenuItemInfo(PtMenu, Index, &Item))
 +        {
 +          MenuCleanupRosMenuItemInfo(&Item);
 +          return FALSE;
 +        }
 +
 +      if (!(Item.fType & MF_SEPARATOR) &&
 +          !(Item.fState & (MFS_DISABLED | MFS_GRAYED)) )
 +      {
 +          if (MenuInfo.FocusedItem != Index)
 +            {
 +              MenuSwitchTracking(Mt, &MenuInfo, Index, Flags);
 +            }
 +
 +          /* If the popup menu is not already "popped" */
 +          if (0 == (Item.fState & MF_MOUSESELECT))
 +            {
 +              Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &MenuInfo, FALSE, Flags);
 +            }
 +        }
 +
 +      MenuCleanupRosMenuItemInfo(&Item);
 +
 +      return TRUE;
 +    }
 +
 +  /* else the click was on the menu bar, finish the tracking */
 +
 +  return FALSE;
 +}
 +
 +/***********************************************************************
 + *           MenuButtonUp
 + *
 + * Return the value of MenuExecFocusedItem if
 + * the selected item was not a popup. Else open the popup.
 + * A -1 return value indicates that we go on with menu tracking.
 + *
 + */
 +static INT FASTCALL
 +MenuButtonUp(MTRACKER *Mt, HMENU PtMenu, UINT Flags)
 +{
 +  UINT Id;
 +  ROSMENUINFO MenuInfo;
 +  ROSMENUITEMINFO ItemInfo;
 +
 +  TRACE("%p hmenu=%x\n", Mt, PtMenu);
 +
 +  if (NULL != PtMenu)
 +    {
 +      Id = 0;
 +      if (! MenuGetRosMenuInfo(&MenuInfo, PtMenu))
 +        {
 +          return -1;
 +        }
 +
 +      if (! IS_SYSTEM_MENU(&MenuInfo))
 +        {
 +          Id = NtUserMenuItemFromPoint(Mt->OwnerWnd, MenuInfo.Self, Mt->Pt.x, Mt->Pt.y);
 +        }
 +      MenuInitRosMenuItemInfo(&ItemInfo);
 +      if (0 <= Id && MenuGetRosMenuItemInfo(MenuInfo.Self, Id, &ItemInfo) &&
 +          MenuInfo.FocusedItem == Id)
 +        {
 +          if (0 == (ItemInfo.fType & MF_POPUP))
 +            {
 +              INT ExecutedMenuId = MenuExecFocusedItem(Mt, &MenuInfo, Flags);
 +              MenuCleanupRosMenuItemInfo(&ItemInfo);
 +              return (ExecutedMenuId < 0) ? -1 : ExecutedMenuId;
 +            }
 +          MenuCleanupRosMenuItemInfo(&ItemInfo);
 +
 +          /* If we are dealing with the top-level menu            */
 +          /* and this is a click on an already "popped" item:     */
 +          /* Stop the menu tracking and close the opened submenus */
 +          if (Mt->TopMenu == MenuInfo.Self && MenuInfo.TimeToHide)
 +            {
 +              MenuCleanupRosMenuItemInfo(&ItemInfo);
 +              return 0;
 +            }
 +        }
 +      MenuCleanupRosMenuItemInfo(&ItemInfo);
 +      MenuInfo.TimeToHide = TRUE;
 +      MenuSetRosMenuInfo(&MenuInfo);
 +    }
 +
 +  return -1;
 +}
 +
 +/***********************************************************************
 + *           MenuPtMenu
 + *
 + * Walks menu chain trying to find a menu pt maps to.
 + */
 +static HMENU FASTCALL
 +MenuPtMenu(HMENU Menu, POINT Pt)
 +{
 +  extern LRESULT DefWndNCHitTest(HWND hWnd, POINT Point);
 +  ROSMENUINFO MenuInfo;
 +  ROSMENUITEMINFO ItemInfo;
 +  HMENU Ret = NULL;
 +  INT Ht;
 +
 +  if (! MenuGetRosMenuInfo(&MenuInfo, Menu))
 +    {
 +      return NULL;
 +    }
 +
 +  /* try subpopup first (if any) */
 +  if (NO_SELECTED_ITEM != MenuInfo.FocusedItem)
 +    {
 +      MenuInitRosMenuItemInfo(&ItemInfo);
 +      if (MenuGetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo) &&
 +          0 != (ItemInfo.fType & MF_POPUP) &&
 +          0 != (ItemInfo.fState & MF_MOUSESELECT))
 +        {
 +          Ret = MenuPtMenu(ItemInfo.hSubMenu, Pt);
 +          if (NULL != Ret)
 +            {
 +              MenuCleanupRosMenuItemInfo(&ItemInfo);
 +              return Ret;
 +            }
 +        }
 +      MenuCleanupRosMenuItemInfo(&ItemInfo);
 +    }
 +
 +  /* check the current window (avoiding WM_HITTEST) */
 +  Ht = DefWndNCHitTest(MenuInfo.Wnd, Pt);
 +  if (0 != (MenuInfo.Flags & MF_POPUP))
 +    {
 +      if (HTNOWHERE != Ht && HTERROR != Ht)
 +        {
 +          Ret = Menu;
 +        }
 +    }
 +  else if (HTSYSMENU == Ht)
 +    {
 +      Ret = NtUserGetSystemMenu(MenuInfo.Wnd, FALSE);
 +    }
 +  else if (HTMENU == Ht)
 +    {
 +      Ret = GetMenu(MenuInfo.Wnd);
 +    }
 +
 +  return Ret;
 +}
 +
 +/***********************************************************************
 + *           MenuMouseMove
 + *
 + * Return TRUE if we can go on with menu tracking.
 + */
 +static BOOL FASTCALL
 +MenuMouseMove(MTRACKER *Mt, HMENU PtMenu, UINT Flags)
 +{
 +  UINT Index;
 +  ROSMENUINFO MenuInfo;
 +  ROSMENUITEMINFO ItemInfo;
 +
 +  if (NULL != PtMenu)
 +    {
 +      if (! MenuGetRosMenuInfo(&MenuInfo, PtMenu))
 +        {
 +          return TRUE;
 +        }
 +      if (IS_SYSTEM_MENU(&MenuInfo))
 +        {
 +          Index = 0;
 +        }
 +      else
 +        {
 +          Index = NtUserMenuItemFromPoint(Mt->OwnerWnd, PtMenu, Mt->Pt.x, Mt->Pt.y);
 +        }
 +    }
 +  else
 +    {
 +      Index = NO_SELECTED_ITEM;
 +    }
 +
 +  if (NO_SELECTED_ITEM == Index)
 +    {
 +      if (Mt->CurrentMenu == MenuInfo.Self ||
 +          MenuGetRosMenuInfo(&MenuInfo, Mt->CurrentMenu))
 +        {
 +          MenuSelectItem(Mt->OwnerWnd, &MenuInfo, NO_SELECTED_ITEM,
 +                         TRUE, Mt->TopMenu);
 +        }
 +    }
 +  else if (MenuInfo.FocusedItem != Index)
 +    {
 +      MenuInitRosMenuItemInfo(&ItemInfo);
 +      if (MenuGetRosMenuItemInfo(MenuInfo.Self, Index, &ItemInfo) &&
 +           !(ItemInfo.fType & MF_SEPARATOR))
 +      {
 +          MenuSwitchTracking(Mt, &MenuInfo, Index, Flags);
 +        if (!(ItemInfo.fState & (MFS_DISABLED | MFS_GRAYED)))
 +              Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &MenuInfo, FALSE, Flags);
 +      }
 +      MenuCleanupRosMenuItemInfo(&ItemInfo);
 +    }
 +
 +  return TRUE;
 +}
 +
 +/***********************************************************************
 + *           MenuGetSubPopup
 + *
 + * Return the handle of the selected sub-popup menu (if any).
 + */
 +static HMENU FASTCALL
 +MenuGetSubPopup(HMENU Menu)
 +{
 +  ROSMENUINFO MenuInfo;
 +  ROSMENUITEMINFO ItemInfo;
 +
 +  if (! MenuGetRosMenuInfo(&MenuInfo, Menu)
 +      || NO_SELECTED_ITEM == MenuInfo.FocusedItem)
 +    {
 +      return NULL;
 +    }
 +
 +  MenuInitRosMenuItemInfo(&ItemInfo);
 +  if (! MenuGetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo))
 +    {
 +      MenuCleanupRosMenuItemInfo(&ItemInfo);
 +      return NULL;
 +    }
 +  if (0 != (ItemInfo.fType & MF_POPUP) && 0 != (ItemInfo.fState & MF_MOUSESELECT))
 +    {
 +      MenuCleanupRosMenuItemInfo(&ItemInfo);
 +      return ItemInfo.hSubMenu;
 +    }
 +
 +  MenuCleanupRosMenuItemInfo(&ItemInfo);
 +  return NULL;
 +}
 +
 +/***********************************************************************
 + *           MenuDoNextMenu
 + *
 + * NOTE: WM_NEXTMENU documented in Win32 is a bit different.
 + */
 +static LRESULT FASTCALL
 +MenuDoNextMenu(MTRACKER* Mt, UINT Vk, UINT wFlags)
 +{
 +  ROSMENUINFO TopMenuInfo;
 +  ROSMENUINFO MenuInfo;
 +
 +  if (! MenuGetRosMenuInfo(&TopMenuInfo, Mt->TopMenu))
 +    {
 +      return (LRESULT) FALSE;
 +    }
 +
 +  if ((VK_LEFT == Vk && 0 == TopMenuInfo.FocusedItem)
 +      || (VK_RIGHT == Vk && TopMenuInfo.FocusedItem == TopMenuInfo.MenuItemCount - 1))
 +    {
 +      MDINEXTMENU NextMenu;
 +      HMENU NewMenu;
 +      HWND NewWnd;
 +      UINT Id = 0;
 +
 +      NextMenu.hmenuIn = (IS_SYSTEM_MENU(&TopMenuInfo)) ? GetSubMenu(Mt->TopMenu, 0) : Mt->TopMenu;
 +      NextMenu.hmenuNext = NULL;
 +      NextMenu.hwndNext = NULL;
 +      SendMessageW(Mt->OwnerWnd, WM_NEXTMENU, Vk, (LPARAM) &NextMenu);
 +
 +      TRACE("%p [%p] -> %p [%p]\n",
 +             Mt->CurrentMenu, Mt->OwnerWnd, NextMenu.hmenuNext, NextMenu.hwndNext );
 +
 +      if (NULL == NextMenu.hmenuNext || NULL == NextMenu.hwndNext)
 +        {
 +          DWORD Style = GetWindowLongPtrW(Mt->OwnerWnd, GWL_STYLE);
 +          NewWnd = Mt->OwnerWnd;
 +          if (IS_SYSTEM_MENU(&TopMenuInfo))
 +            {
 +              /* switch to the menu bar */
 +
 +              if (0 != (Style & WS_CHILD)
 +                  || NULL == (NewMenu = GetMenu(NewWnd)))
 +                {
 +                  return FALSE;
 +                }
 +
 +              if (VK_LEFT == Vk)
 +                {
 +                  if (! MenuGetRosMenuInfo(&MenuInfo, NewMenu))
 +                    {
 +                      return FALSE;
 +                    }
 +                  Id = MenuInfo.MenuItemCount - 1;
 +                }
 +            }
 +          else if (0 != (Style & WS_SYSMENU))
 +            {
 +              /* switch to the system menu */
 +              NewMenu = NtUserGetSystemMenu(NewWnd, FALSE);
 +            }
 +          else
 +            {
 +              return FALSE;
 +            }
 +        }
 +      else    /* application returned a new menu to switch to */
 +        {
 +          NewMenu = NextMenu.hmenuNext;
 +          NewWnd = NextMenu.hwndNext;
 +
 +          if (IsMenu(NewMenu) && IsWindow(NewWnd))
 +            {
 +              DWORD Style = GetWindowLongPtrW(NewWnd, GWL_STYLE);
 +
 +              if (0 != (Style & WS_SYSMENU)
 +                  && GetSystemMenu(NewWnd, FALSE) == NewMenu)
 +                {
 +                  /* get the real system menu */
 +                  NewMenu = NtUserGetSystemMenu(NewWnd, FALSE);
 +                }
 +              else if (0 != (Style & WS_CHILD) || GetMenu(NewWnd) != NewMenu)
 +                {
 +                  /* FIXME: Not sure what to do here;
 +                   * perhaps try to track NewMenu as a popup? */
 +
 +                  WARN(" -- got confused.\n");
 +                  return FALSE;
 +                }
 +            }
 +          else
 +            {
 +              return FALSE;
 +            }
 +        }
 +
 +      if (NewMenu != Mt->TopMenu)
 +        {
 +          MenuSelectItem(Mt->OwnerWnd, &TopMenuInfo, NO_SELECTED_ITEM,
 +                         FALSE, 0 );
 +          if (Mt->CurrentMenu != Mt->TopMenu)
 +            {
 +              MenuHideSubPopups(Mt->OwnerWnd, &TopMenuInfo, FALSE, wFlags);
 +            }
 +        }
 +
 +      if (NewWnd != Mt->OwnerWnd)
 +        {
 +          Mt->OwnerWnd = NewWnd;
 +          SetCapture(Mt->OwnerWnd);
 +          (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, Mt->OwnerWnd);
 +        }
 +
 +      Mt->TopMenu = Mt->CurrentMenu = NewMenu; /* all subpopups are hidden */
 +      if (MenuGetRosMenuInfo(&TopMenuInfo, Mt->TopMenu))
 +        {
 +          MenuSelectItem(Mt->OwnerWnd, &TopMenuInfo, Id, TRUE, 0);
 +        }
 +
 +      return TRUE;
 +    }
 +
 +  return FALSE;
 +}
 +
 +/***********************************************************************
 + *           MenuSuspendPopup
 + *
 + * The idea is not to show the popup if the next input message is
 + * going to hide it anyway.
 + */
 +static BOOL FASTCALL
 +MenuSuspendPopup(MTRACKER* Mt, UINT Message)
 +{
 +  MSG Msg;
 +
 +  Msg.hwnd = Mt->OwnerWnd;
 +
 +  PeekMessageW(&Msg, 0, 0, 0, PM_NOYIELD | PM_REMOVE);
 +  Mt->TrackFlags |= TF_SKIPREMOVE;
 +
 +  switch (Message)
 +    {
 +      case WM_KEYDOWN:
 +        PeekMessageW(&Msg, 0, 0, 0, PM_NOYIELD | PM_NOREMOVE);
 +        if (WM_KEYUP == Msg.message || WM_PAINT == Msg.message)
 +          {
 +            PeekMessageW(&Msg, 0, 0, 0, PM_NOYIELD | PM_REMOVE);
 +            PeekMessageW(&Msg, 0, 0, 0, PM_NOYIELD | PM_NOREMOVE);
 +            if (WM_KEYDOWN == Msg.message
 +                && (VK_LEFT == Msg.wParam || VK_RIGHT == Msg.wParam))
 +              {
 +                Mt->TrackFlags |= TF_SUSPENDPOPUP;
 +                return TRUE;
 +              }
 +          }
 +        break;
 +    }
 +
 +  /* failures go through this */
 +  Mt->TrackFlags &= ~TF_SUSPENDPOPUP;
 +
 +  return FALSE;
 +}
 +
 +/***********************************************************************
 + *           MenuKeyEscape
 + *
 + * Handle a VK_ESCAPE key event in a menu.
 + */
 +static BOOL FASTCALL
 +MenuKeyEscape(MTRACKER *Mt, UINT Flags)
 +{
 +  BOOL EndMenu = TRUE;
 +  ROSMENUINFO MenuInfo;
 +  HMENU MenuTmp, MenuPrev;
 +
 +  if (Mt->CurrentMenu != Mt->TopMenu)
 +    {
 +      if (MenuGetRosMenuInfo(&MenuInfo, Mt->CurrentMenu)
 +          && 0 != (MenuInfo.Flags & MF_POPUP))
 +        {
 +          MenuPrev = MenuTmp = Mt->TopMenu;
 +
 +          /* close topmost popup */
 +          while (MenuTmp != Mt->CurrentMenu)
 +            {
 +              MenuPrev = MenuTmp;
 +              MenuTmp = MenuGetSubPopup(MenuPrev);
 +            }
 +
 +          if (MenuGetRosMenuInfo(&MenuInfo, MenuPrev))
 +            {
 +              MenuHideSubPopups(Mt->OwnerWnd, &MenuInfo, TRUE, Flags);
 +            }
 +          Mt->CurrentMenu = MenuPrev;
 +          EndMenu = FALSE;
 +        }
 +    }
 +
 +  return EndMenu;
 +}
 +
 +/***********************************************************************
 + *           MenuKeyLeft
 + *
 + * Handle a VK_LEFT key event in a menu.
 + */
 +static void FASTCALL
 +MenuKeyLeft(MTRACKER* Mt, UINT Flags)
 +{
 +  ROSMENUINFO MenuInfo;
 +  ROSMENUINFO TopMenuInfo;
 +  ROSMENUINFO PrevMenuInfo;
 +  HMENU MenuTmp, MenuPrev;
 +  UINT PrevCol;
 +
 +  MenuPrev = MenuTmp = Mt->TopMenu;
 +
 +  if (! MenuGetRosMenuInfo(&MenuInfo, Mt->CurrentMenu))
 +    {
 +      return;
 +    }
 +
 +  /* Try to move 1 column left (if possible) */
 +  if (NO_SELECTED_ITEM != (PrevCol = MenuGetStartOfPrevColumn(&MenuInfo)))
 +    {
 +      if (MenuGetRosMenuInfo(&MenuInfo, Mt->CurrentMenu))
 +        {
 +          MenuSelectItem(Mt->OwnerWnd, &MenuInfo, PrevCol, TRUE, 0);
 +        }
 +      return;
 +    }
 +
 +  /* close topmost popup */
 +  while (MenuTmp != Mt->CurrentMenu)
 +    {
 +      MenuPrev = MenuTmp;
 +      MenuTmp = MenuGetSubPopup(MenuPrev);
 +    }
 +
 +  if (! MenuGetRosMenuInfo(&PrevMenuInfo, MenuPrev))
 +    {
 +      return;
 +    }
 +  MenuHideSubPopups(Mt->OwnerWnd, &PrevMenuInfo, TRUE, Flags);
 +  Mt->CurrentMenu = MenuPrev;
 +
 +  if (! MenuGetRosMenuInfo(&TopMenuInfo, Mt->TopMenu))
 +    {
 +      return;
 +    }
 +  if ((MenuPrev == Mt->TopMenu) && 0 == (TopMenuInfo.Flags & MF_POPUP))
 +    {
 +      /* move menu bar selection if no more popups are left */
 +
 +      if (! MenuDoNextMenu(Mt, VK_LEFT, Flags))
 +        {
 +          MenuMoveSelection(Mt->OwnerWnd, &TopMenuInfo, ITEM_PREV);
 +        }
 +
 +      if (MenuPrev != MenuTmp || 0 != (Mt->TrackFlags & TF_SUSPENDPOPUP))
 +        {
 +          /* A sublevel menu was displayed - display the next one
 +           * unless there is another displacement coming up */
 +
 +          if (! MenuSuspendPopup(Mt, WM_KEYDOWN)
 +              && MenuGetRosMenuInfo(&TopMenuInfo, Mt->TopMenu))
 +            {
 +              Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &TopMenuInfo,
 +                                                 TRUE, Flags);
 +            }
 +        }
 +    }
 +}
 +
 +/***********************************************************************
 + *           MenuKeyRight
 + *
 + * Handle a VK_RIGHT key event in a menu.
 + */
 +static void FASTCALL MenuKeyRight(MTRACKER *Mt, UINT Flags)
 +{
 +    HMENU hmenutmp;
 +    ROSMENUINFO MenuInfo;
 +    ROSMENUINFO CurrentMenuInfo;
 +    UINT NextCol;
 +
 +    TRACE("MenuKeyRight called, cur %p, top %p.\n",
 +         Mt->CurrentMenu, Mt->TopMenu);
 +
 +    if (! MenuGetRosMenuInfo(&MenuInfo, Mt->TopMenu)) return;
 +    if ((MenuInfo.Flags & MF_POPUP) || (Mt->CurrentMenu != Mt->TopMenu))
 +    {
 +      /* If already displaying a popup, try to display sub-popup */
 +
 +      hmenutmp = Mt->CurrentMenu;
 +      if (MenuGetRosMenuInfo(&CurrentMenuInfo, Mt->CurrentMenu))
 +        {
 +          Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &CurrentMenuInfo, TRUE, Flags);
 +        }
 +
 +      /* if subpopup was displayed then we are done */
 +      if (hmenutmp != Mt->CurrentMenu) return;
 +    }
 +
 +  if (! MenuGetRosMenuInfo(&CurrentMenuInfo, Mt->CurrentMenu))
 +    {
 +      return;
 +    }
 +
 +  /* Check to see if there's another column */
 +  if (NO_SELECTED_ITEM != (NextCol = MenuGetStartOfNextColumn(&CurrentMenuInfo)))
 +    {
 +      TRACE("Going to %d.\n", NextCol);
 +      if (MenuGetRosMenuInfo(&MenuInfo, Mt->CurrentMenu))
 +        {
 +          MenuSelectItem(Mt->OwnerWnd, &MenuInfo, NextCol, TRUE, 0);
 +        }
 +      return;
 +    }
 +
 +  if (0 == (MenuInfo.Flags & MF_POPUP))       /* menu bar tracking */
 +    {
 +      if (Mt->CurrentMenu != Mt->TopMenu)
 +        {
 +          MenuHideSubPopups(Mt->OwnerWnd, &MenuInfo, FALSE, Flags);
 +          hmenutmp = Mt->CurrentMenu = Mt->TopMenu;
 +        }
 +      else
 +        {
 +          hmenutmp = NULL;
 +        }
 +
 +      /* try to move to the next item */
 +      if ( !MenuDoNextMenu(Mt, VK_RIGHT, Flags))
 +          MenuMoveSelection(Mt->OwnerWnd, &MenuInfo, ITEM_NEXT);
 +
 +      if ( hmenutmp || Mt->TrackFlags & TF_SUSPENDPOPUP )
 +        {
 +          if (! MenuSuspendPopup(Mt, WM_KEYDOWN)
 +              && MenuGetRosMenuInfo(&MenuInfo, Mt->TopMenu))
 +            {
 +              Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &MenuInfo,
 +                                                 TRUE, Flags);
 +            }
 +        }
 +    }
 +}
 +
 +/***********************************************************************
 + *           MenuTrackMenu
 + *
 + * Menu tracking code.
 + */
 +static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y,
 +                            HWND hwnd, const RECT *lprect )
 +{
 +    MSG msg;
 +    ROSMENUINFO MenuInfo;
 +    ROSMENUITEMINFO ItemInfo;
 +    BOOL fRemove;
 +    INT executedMenuId = -1;
 +    MTRACKER mt;
 +    HWND capture_win;
 +    BOOL enterIdleSent = FALSE;
 +
 +    mt.TrackFlags = 0;
 +    mt.CurrentMenu = hmenu;
 +    mt.TopMenu = hmenu;
 +    mt.OwnerWnd = hwnd;
 +    mt.Pt.x = x;
 +    mt.Pt.y = y;
 +
 +    TRACE("hmenu=%p flags=0x%08x (%d,%d) hwnd=%x (%ld,%ld)-(%ld,%ld)\n",
 +         hmenu, wFlags, x, y, hwnd, lprect ? lprect->left : 0, lprect ? lprect->top : 0,
 +         lprect ? lprect->right : 0, lprect ? lprect->bottom : 0);
 +
 +    if (!IsMenu(hmenu))
 +    {
 +        WARN("Invalid menu handle %p\n", hmenu);
 +        SetLastError( ERROR_INVALID_MENU_HANDLE );
 +        return FALSE;
 +    }
 +
 +    fEndMenu = FALSE;
 +    if (! MenuGetRosMenuInfo(&MenuInfo, hmenu))
 +    {
 +        return FALSE;
 +    }
 +
 +    if (wFlags & TPM_BUTTONDOWN)
 +    {
 +        /* Get the result in order to start the tracking or not */
 +        fRemove = MenuButtonDown( &mt, hmenu, wFlags );
 +        fEndMenu = !fRemove;
 +    }
 +
 +    if (wFlags & TF_ENDMENU) fEndMenu = TRUE;
 +
 +    /* owner may not be visible when tracking a popup, so use the menu itself */
 +    capture_win = (wFlags & TPM_POPUPMENU) ? MenuInfo.Wnd : mt.OwnerWnd;
 +    (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, capture_win); // 1
 +    SetCapture(capture_win);                                          // 2
 +
 +    while (! fEndMenu)
 +    {
 +        BOOL ErrorExit = FALSE;
 +        PVOID menu = ValidateHandle(mt.CurrentMenu, VALIDATE_TYPE_MENU);
 +        if (!menu) /* sometimes happens if I do a window manager close */
 +           break;
 +
 +        /* we have to keep the message in the queue until it's
 +         * clear that menu loop is not over yet. */
 +
 +        for (;;)
 +        {
 +            if (PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ))
 +            {
 +                if (!CallMsgFilterW( &msg, MSGF_MENU )) break;
 +                /* remove the message from the queue */
 +                PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
 +            }
 +            else
 +            {
 +                /* ReactOS Check */
 +                if (!ValidateHwnd(mt.OwnerWnd) || !ValidateHwnd(MenuInfo.Wnd))
 +                {
 +                   ErrorExit = TRUE; // Do not wait on dead windows, now test_capture_4 works.
 +                   break;
 +                }
 +                if (!enterIdleSent)
 +                {
 +                  HWND win = MenuInfo.Flags & MF_POPUP ? MenuInfo.Wnd : NULL;
 +                  enterIdleSent = TRUE;
 +                  SendMessageW( mt.OwnerWnd, WM_ENTERIDLE, MSGF_MENU, (LPARAM) win);
 +                }
 +                WaitMessage();
 +            }
 +        }
 +
 +        if (ErrorExit) break; // Gracefully dropout.
 +
 +        /* check if EndMenu() tried to cancel us, by posting this message */
 +        if (msg.message == WM_CANCELMODE)
 +        {
 +            /* we are now out of the loop */
 +            fEndMenu = TRUE;
 +
 +            /* remove the message from the queue */
 +            PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
 +
 +            /* break out of internal loop, ala ESCAPE */
 +            break;
 +        }
 +
 +        TranslateMessage( &msg );
 +        mt.Pt = msg.pt;
 +
 +        if ( (msg.hwnd == MenuInfo.Wnd) || (msg.message!=WM_TIMER) )
 +            enterIdleSent=FALSE;
 +
 +        fRemove = FALSE;
 +        if ((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST))
 +        {
 +            /*
 +             * Use the mouse coordinates in lParam instead of those in the MSG
 +             * struct to properly handle synthetic messages. They are already
 +             * in screen coordinates.
 +             */
 +            mt.Pt.x = (short)LOWORD(msg.lParam);
 +            mt.Pt.y = (short)HIWORD(msg.lParam);
 +
 +            /* Find a menu for this mouse event */
 +            hmenu = MenuPtMenu(mt.TopMenu, mt.Pt);
 +
 +            switch(msg.message)
 +            {
 +                /* no WM_NC... messages in captured state */
 +
 +                case WM_RBUTTONDBLCLK:
 +                case WM_RBUTTONDOWN:
 +                     if (!(wFlags & TPM_RIGHTBUTTON)) break;
 +                    /* fall through */
 +                case WM_LBUTTONDBLCLK:
 +                case WM_LBUTTONDOWN:
 +                    /* If the message belongs to the menu, removes it from the queue */
 +        &nbs