========================================================================
Microsoft Foundation Class Library for Windows CE: MorphGear
========================================================================
AppWizard has created this MorphGear application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your MorphGear application.
MorphGear.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CMorphGearApp application class.
MorphGear.cpp
This is the main application source file that contains the application
class CMorphGearApp.
MorphGear.rc
This is a listing of all of the Microsoft Windows CE resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
eMbedded Visual C++.
res\MorphGear.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file MorphGear.rc.
res\MorphGear.rc2
This file contains resources that are not edited by Microsoft
eMbedded Visual C++. You should place all resources not
editable by the resource editor in this file.
MorphGear.vcc
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file to store
information needed to create and edit message maps and dialog data
maps and to create prototype member functions.
/////////////////////////////////////////////////////////////////////////////
For the main frame window:
MainFrm.h, MainFrm.cpp
These files contain the frame class CMainFrame, which is derived from
CFrameWnd and controls all SDI frame features.
res\Cmdbar.bmp
This bitmap file is used to create tiled images for the command bar.
The initial command bar is constructed in the CMainFrame class.
Edit this cmdbar bitmap along with the array in MainFrm.cpp
to add more command bar buttons.
/////////////////////////////////////////////////////////////////////////////
AppWizard creates one view:
MorphGearView.h, MorphGearView.cpp - the view of the document
These files contain your CMorphGearView class.
CMorphGearView objects are used to view CMorphGearDoc objects.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named MorphGear.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft eMbedded Visual C++ reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, and your application is
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFCWCXXX.DLL from
the Microsoft eMbedded Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
For example, MFCWCDEU.DLL contains resources translated to German.) If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.
/////////////////////////////////////////////////////////////////////////////
//CDC * dc = gb->win->GetDC();
//XPal8[N] = (unsigned char) dc->GetNearestColor(RGB(R,G,B)) >> 24;
// XPal8[N] = N;
#if 0
if(gb->hPalette && gb->pfScreen->bpp == 8) {
PALETTEENTRY *myPalette = new PALETTEENTRY[gb->paletteSize];
GetPaletteEntries(gb->hPalette,0,gb->paletteSize,myPalette);
for(int i = 0; i < gb->paletteSize; i++) {
if(myPalette[i].peBlue == B
&& myPalette[i].peRed == R
&& myPalette[i].peGreen == G) {
XPal8[N] = i;
delete myPalette;
return;
}
}
myPalette[gb->paletteIndex].peBlue = B;
myPalette[gb->paletteIndex].peGreen = G;
myPalette[gb->paletteIndex].peRed = R;
SetPaletteEntries(gb->hPalette,gb->paletteIndex,1,&myPalette[gb->paletteIndex]);
XPal8[N] = gb->paletteIndex++;
delete myPalette;
return;
}
#endif
// dc->DeleteDC();
#if 0
nPixelFormat pf565(16, 0x0000F800, 0x000007E0, 0x0000001F, 0x0);
nPixelFormat pf888(24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000);
pf565.BeginConv(&pf888);
unsigned short RGB565;
pf565.Conv((uchar*)&RGB,(uchar*)&RGB565,1,4);
pf565.EndConv();
XPal16[N] = RGB565;
#endif
#if 0
// If 16-bit, we have to take pf into consideration
unsigned short* img = ((unsigned short*)screenBuffer) + sx + sy;
byte* screen = screenMemory + dx + dy;
pfScreen->BeginConv(&pf565);
for(int y = 0; y < h; ++y) {
pfScreen->Conv((uchar*)img,screen,w,gfxProperties.cbxPitch);
screen += gfxProperties.cbyPitch;
img += WIDTH;
}
pfScreen->EndConv();
#endif
#if 0
/*TrapBadOps=1;*/LineDelay=0;CheckCRC=1;
VPeriod=70224/*69905*/;UPeriod=2;//IntSync=1;
Verbose=0;SndName=NULL;
#endif
#if 0
if(N < paletteSize) {
// Get the RGB values for that color
PALETTEENTRY palEntry;
palEntry.peBlue = B;
palEntry.peGreen = G;
palEntry.peRed = R;
palEntry.peFlags = 0;
SetPaletteEntries( hPalette, N, 1, &palEntry );
XPal8[N] = N;
paletteSet = false;
}
else {
XPal8[N] = GetNearestPaletteIndex( hPalette, RGB(R,G,B) );
}
#endif
//XPal8[N] = GetNearestPaletteIndex( hPalette, RGB(R>>2,G>>1,B>>3) );
//paletteSet = false;
//HDC dc = ::GetDC(win->GetSafeHwnd());
//COLORREF clr = GetNearestColor(dc,RGB(R,G,B));
//::ReleaseDC(win->GetSafeHwnd(),dc);
//XPal8[N] = (GetRValue(clr)+GetGValue(clr)+GetBValue(clr));
/*int tempR=R>>2;
int tempG=G>>1;
int tempB=B>>3;
int co1=tempR+tempG+tempB;
co1 = co1>>3;
XPal8[N] = co1;*/
if(dstImage->format & kfLandscape)
dy += (h-1) * dstImage->ypitch; // only on landsscape
#if 1
// Move to bottom of image
img += srcImage->w * (h-1);
// Write columns
for(int x = 0; x < w; ++x) {
byte* scrPixel = screen;
unsigned short* imgPixel = img;
for(int y = h; y > 1; y-=2) {
*((unsigned int*)scrPixel) = *imgPixel | (*(imgPixel-srcImage->w) << 16);
scrPixel -= dstImage->ypitch<<1;
imgPixel -= (srcImage->w<<1);
}
// If there's an odd pixel left to draw, do it
if(y == 1) {
scrPixel += dstImage->ypitch;
imgPixel += (srcImage->w);
*((unsigned short*)scrPixel) = *imgPixel;
}
screen += dstImage->xpitch;
img += 1;
}
#else
//int w2 = w>>1;
//byte* scrPixel = screen;
//unsigned short* imgPixel = img;
/*for(int x = 0; x < w; ++x) {
*((unsigned short*)scrPixel) = *imgPixel++;
scrPixel += dstImage->xpitch;
}*/
/*int* scrPixel = (int*)screen;
int* imgPixel = (int*)img;
for(int x = 0; x < w2; ++x) {
*scrPixel++ = *imgPixel++;
}*/
#if 0
theApp.m_pMainWnd->Invalidate();
//#if (_WIN32_WCE < 300)
theApp.m_pMainWnd->UpdateWindow();
//#endif
// TBD: Dispatch all messages
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
//#pragma message("Put this in too")//engine->GetVideo()->UpdateWindowPos();
//OnPaint();
#endif
//engine->GetWindow()->In