Monday 5 July 2010

Customizing oomui (Out of Memory User Interface Component)

Hello guys,

There are quite a lot helpful articles trying to guide you to the more or less painful steps of substitution of public CE components. First I had a look at the CE 6.0 online help and "Customizing a UI Component". MS advices you to modify public code ...

Everyone knows - that's really a bad!
Some time ago there was an article by Steve Maillet, referenced by many newsgroup posts. But it isn't there anymore (http://www.embeddedfusion.com/Articles/CustomCoreUI.htm). Do you have a local copy? Please spread it!

In the end I played around with the various environment variables listed in the help topic and - what a wonder - when sysgen finally buildt gwes.dll the linker took my own oomui.lib. So, technically the solution works - but only at first glance! I didn't want to run an extra sysgen step to get my version of gwes.dll. The solution has to work in a single sysgen run, too.
One of my colleagues told me that he runs nmake to build the usb stack. So, I spent some time playing around with nmake, environment variables and trying to understand the involved makefiles, batches and so on. Finally I arrived at the conclusion that this way does not work. Unfortunately, some libraries are deleted by building the gwes target so I always ended up with linker errors (at least _GwesMain).

May be I missed something. If you have got a clue let me know! But as far as I noticed there is no other way to hook into the sysgen step (after platform binaries have been built) to get gwes.dll linked with the platforms oomui.lib.

My solution is quite simple and definitively works without any changes to public code. The only disadvantage is that you have to copy the files after you changed something in your oomui code.

1. Clone oomui code from \PUBLIC\COMMON\OAK\DRIVERS\OOMUI
2. Adapt it according to your requirements, e.g.



void OomUI_OnShow (void)
{
RETAILMSG(1, (TEXT("%S"), "This Text is just for checking correct linking"));
}
BOOL OomUI_FShowOomWindow (void)
{
return 0;
}
LRESULT CALLBACK OomUI_OomWndProc (HWND hwnd, UINT message, WPARAM uParam, LPARAM Param)
{
return DefWindowProc(hwnd, message, uParam, lParam);
}

LRESULT CALLBACK
OomUI_NotRespondingWndProc (HWND hwnd, UINT message, WPARAM uParam, LPARAM lParam)
{
return DefWindowProc (hwnd, message, uParam, lParam);
}
void OomUI_SetWindowsInfo (int cApps, WINDOWINFO *rgwi)
{
}



3. Compile (modify sources and makefile.inc before)

makefile.inc:

resfile: $(_RELEASELIBDIR)\$(RESFILE)

$(_RELEASELIBDIR)\$(RESFILE) : $(_OBJDIR)\$(RESFILE)
copy $? $@


sources

resfile: $(_RELEASELIBDIR)\$(RESFILE)
$(_RELEASELIBDIR)\$(RESFILE) : $(_OBJDIR)\$(RESFILE)
# lib will be stored in C:\WINCE600\OSDesigns\\\Wince600\_\oak\lib\\\oomui.lib
RELEASETYPE=OAK

TARGETNAME=oomui
TARGETTYPE=LIBRARY

CDEFINES= $(CDEFINES) -DGWE

!IFDEF MEM_ACCOUNT
CDEFINES=$(CDEFINES) -DMEM_ACCOUNT=1
!ENDIF

SOURCES=oomui.cpp
RESFILE=oomui.res
WINCETARGETFILES=resfile
FILE_VIEW_INCLUDES_FOLDER=oomuirc.h
FILE_VIEW_ROOT_FOLDER=oomui.rc


4. Add oomui to the appropriate dirs file
5. Copy oomui.* files to \prebuild\oomui\ directory (you have to add this directory to change control system)
6. Extend your .bat:


set REPLACE_SYSGEN_OOMUI=1
set GWES_REPLACE_COMPONENTS=oomui
set REPLACE_ROOT=%_PROJECTOAKROOT%\..


Done!

As already mentioned: I really appreciate improvements, hints, comments!

Cheers,
Jürgen

No comments: