109 lines
2.5 KiB
C++
109 lines
2.5 KiB
C++
#include <mdiwin/logowin.hpp>
|
|
|
|
char LogoWindow::smszClassName[]={"NepalNight"};
|
|
|
|
LogoWindow::LogoWindow(HINSTANCE hInstance,HINSTANCE hLibrary)
|
|
: mhInstance(hInstance), mhLibrary(hLibrary), mIsDestroyed(FALSE), mhBitmap(0)
|
|
{
|
|
registerClass();
|
|
}
|
|
|
|
LogoWindow::~LogoWindow()
|
|
{
|
|
if(mhBitmap)::DeleteObject(mhBitmap);
|
|
if(::IsWindow(GetHandle()))::DestroyWindow(GetHandle());
|
|
}
|
|
|
|
WORD LogoWindow::showLogo(String &bitmapName)
|
|
{
|
|
RECT windowRect;
|
|
HWND hCaptureWindow(::GetCapture());
|
|
|
|
if(mhLibrary)mhBitmap=::LoadBitmap(mhLibrary,bitmapName);
|
|
else mhBitmap=::LoadBitmap(mhInstance,bitmapName);
|
|
if(!mhBitmap)
|
|
{
|
|
mIsDestroyed=TRUE;
|
|
return FALSE;
|
|
}
|
|
centerRect(mhBitmap,windowRect);
|
|
::CreateWindow(
|
|
(LPSTR)smszClassName,0,WS_POPUP|WS_BORDER,
|
|
windowRect.left,windowRect.top,windowRect.right,windowRect.bottom,
|
|
0x00,0x00,mhInstance,(LPSTR)(Window*)this);
|
|
Show(SW_SHOW);
|
|
Update();
|
|
::SetCapture(GetHandle());
|
|
waitCursor(TRUE);
|
|
while(!mIsDestroyed)messageLoop();
|
|
waitCursor(FALSE);
|
|
::SetCapture(hCaptureWindow);
|
|
return TRUE;
|
|
}
|
|
|
|
void LogoWindow::registerClass(void)
|
|
{
|
|
WNDCLASS wndClass;
|
|
|
|
if(::GetClassInfo(mhInstance,smszClassName,(WNDCLASS FAR *)&wndClass))return;
|
|
wndClass.style =CS_HREDRAW|CS_VREDRAW;
|
|
wndClass.lpfnWndProc =(WNDPROC)Window::WndProc;
|
|
wndClass.cbClsExtra =0;
|
|
wndClass.cbWndExtra =sizeof(LogoWindow*);
|
|
wndClass.hInstance =mhInstance;
|
|
wndClass.hIcon =0;
|
|
wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW);
|
|
wndClass.hbrBackground =(HBRUSH)::GetStockObject(LTGRAY_BRUSH);
|
|
wndClass.lpszMenuName =0;
|
|
wndClass.lpszClassName =smszClassName;
|
|
::RegisterClass(&wndClass);
|
|
}
|
|
|
|
void LogoWindow::messageLoop(void)
|
|
{
|
|
MSG msg;
|
|
|
|
while(!mIsDestroyed)
|
|
{
|
|
while(::PeekMessage(&msg,0,0,0,PM_REMOVE))
|
|
{
|
|
::TranslateMessage(&msg);
|
|
::DispatchMessage(&msg);
|
|
}
|
|
}
|
|
}
|
|
|
|
long LogoWindow::WndProc(UINT message,WPARAM wParam,LPARAM lParam)
|
|
{
|
|
switch(message)
|
|
{
|
|
case WM_CREATE :
|
|
::SetTimer(GetHandle(),TimerID,TimeOut,0);
|
|
return TRUE;
|
|
case WM_TIMER :
|
|
::KillTimer(GetHandle(),TimerID);
|
|
::PostMessage(GetHandle(),WM_CLOSE,0,0L);
|
|
return FALSE;
|
|
case WM_PAINT :
|
|
paint();
|
|
return FALSE;
|
|
case WM_DESTROY :
|
|
mIsDestroyed=TRUE;
|
|
return FALSE;
|
|
case WM_CLOSE :
|
|
::DestroyWindow(GetHandle());
|
|
mIsDestroyed=TRUE;
|
|
return FALSE;
|
|
}
|
|
return ::DefWindowProc(GetHandle(),message,wParam,lParam);
|
|
}
|
|
|
|
void LogoWindow::paint()const
|
|
{
|
|
PAINTSTRUCT ps;
|
|
|
|
::BeginPaint(GetHandle(),(PAINTSTRUCT FAR *)&ps);
|
|
drawBitmap(GetHandle(),mhBitmap);
|
|
::EndPaint(GetHandle(),(PAINTSTRUCT FAR *)&ps);
|
|
}
|