All pastes #348990 Raw Edit

Kiryn

public cpp v1 · immutable
·published 2007-02-10 13:59 UTC
rendered paste body
#include "WindowWrapping.h"WindowWrapping::WindowWrapping(){	// Nothing}WindowWrapping::WindowWrapping(char *ClassName, char *WindowTitle, DWORD dwStyles, RECT *rect, HINSTANCE hInstance): _pClassName(ClassName), _pWindowTitle(WindowTitle), _dwStyles(dwStyles),  _pRect(rect), _hInstance(hInstance){	RECT desktopRect;	GetWindowRect(GetDesktopWindow(),&desktopRect);	int wWidth	=	_pRect->right	-	_pRect->left;	int wHeight	=	_pRect->bottom	-	_pRect->top;	_pRect->left = ((desktopRect.right - desktopRect.left) - wWidth) /2;	_pRect->right =	((desktopRect.right	- desktopRect.left) + wWidth) /2;	_pRect->top	= ((desktopRect.bottom - desktopRect.top) - wHeight) /2;	_pRect->bottom = ((desktopRect.bottom - desktopRect.top) + wHeight) /2;}WindowWrapping::~WindowWrapping(){}LRESULT CALLBACK WindowWrapping::sfWinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){	WindowWrapping *pWnd;	if(uMsg == WM_NCCREATE)	{		SetWindowLong(hWnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams));	}	pWnd = (WindowWrapping *)GetWindowLong(hWnd, GWL_USERDATA);	if(pWnd)		return pWnd->WinProc(hWnd, uMsg, wParam, lParam);	else		return DefWindowProc(hWnd, uMsg, wParam, lParam);}BOOL WindowWrapping::Create(){	WNDCLASSEX WndClsEx;	WndClsEx.cbSize = sizeof(WNDCLASSEX);	WndClsEx.style = 0;	WndClsEx.lpfnWndProc = sfWinProc;	WndClsEx.cbClsExtra = 0;	WndClsEx.cbWndExtra = 0;	WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);	WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);	WndClsEx.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);	WndClsEx.lpszMenuName = NULL;	WndClsEx.lpszClassName = _pClassName;	WndClsEx.hInstance = _hInstance;	WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);	RegisterClassEx(&WndClsEx);	_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE,		_pClassName,		_pWindowTitle,		_dwStyles,		_pRect->left,		_pRect->top,		_pRect->right - _pRect->left,		_pRect->bottom - _pRect->top,		NULL,		NULL,		_hInstance,		(void *)this);	return (_hWnd != NULL);}BOOL WindowWrapping::Show(){	ShowWindow(_hWnd, SW_SHOW);	UpdateWindow(_hWnd);	return true;}LRESULT CALLBACK WindowWrapping::WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){	switch(uMsg)	{	case WM_DESTROY:		PostQuitMessage(WM_QUIT);		break;	default:		return DefWindowProc(hWnd, uMsg, wParam, lParam);	}	return(0);}