//-------------------------------------------------------------------------------------//
//+++++++++++++++++[ Window_Class_Source ]+++++++++++++++++++++++++++++++++++++++++++++//
//-------------------------------------------------------------------------------------//
#include "C_Window.hpp"
/////////////////////////////////////////////////////////////////////////////////////////
//////// [Konstructor] ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
C_Window::C_Window()
{
_Hwnd = 0; _Hinstance = 0;
ZeroMemory(&_Window_ClassEx, sizeof(_Window_ClassEx)); ZeroMemory(&_Window_Struc, sizeof(_Window_Struc)); ZeroMemory(&_Rect, sizeof(_Rect)); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [Destructor] /////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
C_Window::~C_Window()
{
DestroyWindow(_Hwnd);
} ///////////////////////////////////////////////////////////////////////////////////////// //////// [_Get_pWindow_Struc] ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// S_C_Window* C_Window::_Get_pWindow_Struct() { return(&_Window_Struc); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Create] ////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Create() { HWND TempHwnd = 0;
if(_Window_Struc.Register == 1) { if(_Register() != 1) return(2); }
TempHwnd = CreateWindowEx(_Window_Struc.E_WindowStyle, _Window_Struc.ClassName, _Window_Struc.WindowCaption, _Window_Struc.WindowStyle, _Window_Struc.x, _Window_Struc.y, _Window_Struc.nWidth, _Window_Struc.nHeight, _Window_Struc.ParentWindow, _Window_Struc.ChildID, _Window_Struc.ProgInstanz, NULL);
if(TempHwnd != 0) { _Hwnd = TempHwnd; _Hinstance = _Window_Struc.ProgInstanz;
ShowWindow(_Hwnd, _Window_Struc.Visible); UpdateWindow(_Hwnd); } else return(3); return(1); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Delete] ////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Delete() { if(DestroyWindow(_Hwnd) == 0) return(0); return(1); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Register] //////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Register() { _Window_ClassEx.cbSize = sizeof(_Window_ClassEx);
_Window_ClassEx.lpfnWndProc = _Window_Struc.MsgLoop; _Window_ClassEx.style = _Window_Struc.ClassStyle; _Window_ClassEx.hInstance = _Window_Struc.ProgInstanz; _Window_ClassEx.hbrBackground = _Window_Struc.BackColor; _Window_ClassEx.lpszClassName = _Window_Struc.ClassName;
_Window_ClassEx.cbClsExtra = _Window_Struc.XtraClassBytes; _Window_ClassEx.cbWndExtra = _Window_Struc.XtraWindowBytes;
_Window_ClassEx.hIcon = _Window_Struc.Icon; _Window_ClassEx.hCursor = LoadCursor (NULL, 0); _Window_ClassEx.lpszMenuName = 0; _Window_ClassEx.hIconSm = _Window_Struc.Icon; _Window_ClassEx.hCursor = _Window_Struc.Cursor;
if(!RegisterClassEx (&_Window_ClassEx)) return(0); // error
return(1); // ready
}
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_UnRegister] ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_UnRegister() { if(_Window_Struc.Register == 1) { if(UnregisterClass(_Window_Struc.ClassName, _Window_Struc.ProgInstanz) == 0) return(0); // error
}
return(1); // ready
}
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Move] //////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Move(DWORD x, DWORD y, DWORD xh, DWORD yb) { if(SetWindowPos(_Hwnd, 0, x, y, xh, yb, SWP_SHOWWINDOW) == 0) return(0); return(1); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Set_Caption] ///////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Set_Caption(char* psCaption) { if(SetWindowText(_Hwnd, psCaption) == 0) return(0); return(1); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Hide] //////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Hide() { if(ShowWindow(_Hwnd, SW_HIDE) == 0) return(0); return(1); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Show] //////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Show() { if(ShowWindow(_Hwnd, SW_SHOW) != 0) return(0); return(1); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Max] ///////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Max() { if(ShowWindow(_Hwnd, SW_MAXIMIZE) != 0) return(0); return(1); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Min] ///////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Min() { if(ShowWindow(_Hwnd, SW_MINIMIZE) != 0) return(0); return(1); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Set_Window_Xtra] ///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Set_Window_Xtra(int offset, DWORD* pData) { DWORD Result = 0;
if( (_Window_Struc.XtraWindowBytes > 0) && (_Window_Struc.XtraWindowBytes > offset) ) { Result = SetWindowLong(_Hwnd, offset, (long) *pData);
if(Result == 0) { Result = SetWindowLong(_Hwnd, offset, (long) *pData);
if(Result == 0) return(0); // error
}
}
else return(2); // error
return(1); // ready
}
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Get_Window_Xtra] ///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
DWORD C_Window::_Get_Window_Xtra(int offset, DWORD* pData) { DWORD tData = 0;
if( (_Window_Struc.XtraWindowBytes > 0) && (_Window_Struc.XtraWindowBytes > offset) ) { tData = GetWindowLong(_Hwnd, offset);
if(tData == 0) return(0); // error
}
else return(2); // error
*pData = tData;
return(1); // ready
}
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Get_Hwnd] //////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
HWND C_Window::_Get_Hwnd() const
{
return(_Hwnd); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Get_Hinstance] /////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
HINSTANCE C_Window::_Get_Hinstance() const
{
return(_Hinstance); }
/////////////////////////////////////////////////////////////////////////////////////////
//////// [_Get_Rect] //////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
RECT C_Window::_Get_Rect() const
{
return(_Rect); }
|