[ µwe||e ].Coding.Cpp.CWindow

Banner

[Home] + [Coding] + [Downloads] + [Bookmarks]

C++

      [ Get a sample Snippet ]
 
[ CWindow.hpp ]

//-------------------------------------------------------------------------------------//
//+++++++++++++++++[ Window_Class_Header ]+++++++++++++++++++++++++++++++++++++++++++++//
//-------------------------------------------------------------------------------------//
//
//
// Last modi: 10.03.07 L.ey (µ~)
//
//
//
#ifndef _C_WINDOW_H_
 #define _C_WINDOW_H_

 #include <windows.h>

 const int WINDOW_CLASS_STYLE_STANDART = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS|
CS_BYTEALIGNCLIENT|CS_BYTEALIGNWINDOW;

const int WINDOW_CLASS_STYLE_NOCLOSE = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS|
CS_BYTEALIGNCLIENT|CS_BYTEALIGNWINDOW|CS_NOCLOSE;


const int WINDOW_STYLE_STANDART = WS_OVERLAPPEDWINDOW;
const int WINDOW_STYLE_POPUP = WS_CLIPCHILDREN|WS_THICKFRAME|WS_POPUP|WS_TABSTOP;


const int EX_WINDOW_STYLE_STANDART = WS_EX_CONTROLPARENT;
const int EX_WINDOW_STYLE_TOOL = WS_EX_CONTROLPARENT|WS_EX_TOOLWINDOW;


struct S_C_Window
{
int Register; // 1 = Register the Class, 0 = Don't Register the Class char* ClassName; // ClassName HBRUSH BackColor; // Color UINT ClassStyle; // ClassStyle WNDPROC MsgLoop; // Callback Procedur HINSTANCE ProgInstanz; // Instance DWORD E_WindowStyle; // extented Window Style char* WindowCaption; // Caption DWORD WindowStyle; // Window Style int x; // x Position int y; // y Position int nWidth; // Width int nHeight; // Height HWND ParentWindow; // Parent Window HMENU ChildID; // Child-ID int Visible; // 1 = Visible, 0 = Invisible int XtraClassBytes; // count int XtraWindowBytes; // count HICON Icon; // Icon HCURSOR Cursor; // Cursor }; //+++++++++++++++++[ class C_Window ]++++++++++++++++++++++++++++++++++++++++++++++++++// class C_Window
{
public://+++++++öffentlicher Zugriff+++++++// C_Window(); ~C_Window(); S_C_Window* _Get_pWindow_Struct(); DWORD _Create();
DWORD _Delete();

DWORD _Set_Caption(char*);
DWORD _Move(DWORD, DWORD, DWORD, DWORD);

DWORD _Show();
DWORD _Hide();

DWORD _Max();
DWORD _Min();

DWORD _Get_Window_Xtra(int, DWORD*);
DWORD _Set_Window_Xtra(int, DWORD*);

HWND _Get_Hwnd() const;
HINSTANCE _Get_Hinstance() const;
RECT _Get_Rect() const;

private://++++++privater Zugriff+++++++++++// protected://++++geschützter Zugriff++++++++// DWORD _Register();
DWORD _UnRegister();

//----------Variabel---------------------// WNDCLASSEX _Window_ClassEx;
S_C_Window _Window_Struc;

HWND _Hwnd;
HINSTANCE _Hinstance;
RECT _Rect;
};

#endif // _C_WINDOW_H_

[ CWindow.cpp ]

//-------------------------------------------------------------------------------------//
//+++++++++++++++++[ 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);
}

[Сê] `.´ [µwe||e]
1
Hosted by www.Geocities.ws

1