142 lines
3.4 KiB
C++
142 lines
3.4 KiB
C++
#include <string.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <mdiwin/main.hpp>
|
||
#include <mdiwin/frame.hpp>
|
||
#include <mdiwin/view.hpp>
|
||
#include <mdiwin/slide.hpp>
|
||
#include <mdiwin/logowin.hpp>
|
||
#include <mdiwin/inifile.hpp>
|
||
|
||
HINSTANCE Main::smhInstance=0;
|
||
HINSTANCE Main::smhPrevInstance=0;
|
||
OwnerDraw Main::smhBitmap;
|
||
int Main::smnCmdShow=0;
|
||
BWindow *Main::smlpStatusBar=0;
|
||
|
||
void Main::hmemcpy(UHUGE *destination,UHUGE *source,unsigned long length)
|
||
{
|
||
for(unsigned long count=0;count<length;count++)*destination++=*source++;
|
||
}
|
||
|
||
void Main::hmemset(UHUGE *destination,UCHAR ch,unsigned long length)
|
||
{
|
||
for(unsigned long count=0;count<length;count++)*destination++=ch;
|
||
}
|
||
|
||
HGLOBAL Main::upsideDown(WORD width,WORD height,UHUGE *srcPtr)
|
||
{
|
||
HGLOBAL hGlobal;
|
||
UHUGE *destPtr;
|
||
|
||
hGlobal=::GlobalAlloc(GMEM_ZEROINIT|GMEM_MOVEABLE,(LONG)width*(LONG)height);
|
||
destPtr=(UHUGE*)::GlobalLock(hGlobal);
|
||
for(int i=0;i<height;i++)
|
||
Main::hmemcpy(
|
||
destPtr+((LONG)i*(LONG)width),
|
||
(srcPtr+((LONG)height-(LONG)i)*(LONG)width)-(LONG)width,width);
|
||
::GlobalUnlock(hGlobal);
|
||
return hGlobal;
|
||
}
|
||
|
||
HGLOBAL Main::rotateRight(UHUGE *srcPtr,WORD width,WORD height)
|
||
{
|
||
HGLOBAL hGlobalDest;
|
||
UHUGE *destPtr;
|
||
int srcCol;
|
||
int srcRow;
|
||
int destCols;
|
||
int destRow;
|
||
int destCol;
|
||
|
||
hGlobalDest=::GlobalAlloc(GMEM_FIXED,(long)width*(long)height);
|
||
if(!hGlobalDest)return 0;
|
||
destPtr=(UHUGE *)::GlobalLock(hGlobalDest);
|
||
destRow=0;
|
||
destCol=0;
|
||
destCols=height;
|
||
for(srcCol=0;srcCol<width;srcCol++)
|
||
{
|
||
for(srcRow=height-1;srcRow>=0;srcRow--)
|
||
{
|
||
*(destPtr+(((long)destRow*(long)destCols)+(long)destCol))=
|
||
*(srcPtr+(((long)srcRow*(long)width)+(long)srcCol));
|
||
if(destCol+1>=destCols)
|
||
{
|
||
destRow++;
|
||
destCol=0;
|
||
}
|
||
else destCol++;
|
||
}
|
||
}
|
||
::GlobalUnlock(hGlobalDest);
|
||
return hGlobalDest;
|
||
}
|
||
|
||
HGLOBAL Main::rotateLeft(UHUGE *srcPtr,WORD width,WORD height)
|
||
{
|
||
HGLOBAL hGlobalDest;
|
||
UHUGE *destPtr;
|
||
int srcCol;
|
||
int srcRow;
|
||
int destRows;
|
||
int destCols;
|
||
int destRow;
|
||
int destCol;
|
||
|
||
hGlobalDest=::GlobalAlloc(GMEM_FIXED,(long)width*(long)height);
|
||
if(!hGlobalDest)return 0;
|
||
destPtr=(UHUGE *)::GlobalLock(hGlobalDest);
|
||
destRows=width;
|
||
destCols=height;
|
||
destRow=destRows-1;
|
||
destCol=0;
|
||
for(srcRow=0;srcRow<height;srcRow++)
|
||
{
|
||
for(srcCol=0;srcCol<width;srcCol++)
|
||
{
|
||
*(destPtr+(((long)destRow*(long)destCols)+(long)destCol))=
|
||
*(srcPtr+(((long)srcRow*(long)width)+(long)srcCol));
|
||
if(destRow-1<0)
|
||
{
|
||
destCol++;
|
||
destRow=destRows-1;
|
||
}
|
||
else destRow--;
|
||
}
|
||
}
|
||
::GlobalUnlock(hGlobalDest);
|
||
return hGlobalDest;
|
||
}
|
||
|
||
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR /*lpszCmdLine*/,int nCmdSHow)
|
||
{
|
||
Main::smhInstance=hInstance;
|
||
Main::smhPrevInstance=hPrevInstance;
|
||
Main::smnCmdShow=nCmdSHow;
|
||
|
||
|
||
if(Main::smhPrevInstance)
|
||
{
|
||
HWND hWnd=::FindWindow(Frame::ClassName(),Frame::ClassName());
|
||
if(!hWnd)
|
||
{
|
||
::MessageBox(GetFocus(),
|
||
(LPSTR)"Failed to maximize previously running App",
|
||
(LPSTR)"Critical Error",MB_ICONSTOP|MB_SYSTEMMODAL);
|
||
return 0;
|
||
}
|
||
::PostMessage(hWnd,WM_REACTIVATE,0,0L);
|
||
return 0;
|
||
}
|
||
Frame::Register(Main::smhInstance);
|
||
ViewWindow::Register(Main::smhInstance);
|
||
SlideWindow::Register(Main::smhInstance);
|
||
BWindow::registerClass();
|
||
LogoWindow logoWindow(Main::smhInstance,Main::smhBitmap.getHandle());
|
||
logoWindow.showLogo(String("LOGO"));
|
||
Frame frameWindow;
|
||
frameWindow.setAcceleratorTable("mdiAccel");
|
||
return frameWindow.messageLoop();
|
||
}
|
||
|