#include <common/control.hpp>

Control::~Control()
{
}

HWND Control::createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParentWnd,int controlID)
{
	dwStyle|=WS_CHILD;
	if(isValid())return *this;
	this->controlID(controlID);
  createWindow(className,windowName,dwStyle,initRect,hParentWnd,(HMENU)controlID,(HINSTANCE)processInstance(),0);
	disposition(GUIWindow::AssumeAndDestroy);
	return *this;
}

HWND Control::createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParentWnd,int controlID)
{
	dwStyle|=WS_CHILD;
	if(isValid())return *this;
	this->controlID(controlID);
	createWindow(extendedStyle,className,windowName,dwStyle,initRect,hParentWnd,(HMENU)controlID,(HINSTANCE)processInstance(),0);
	disposition(GUIWindow::AssumeAndDestroy);
	return *this;
}

HWND Control::createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,Window &parentWindow,int controlID)
{
	dwStyle|=WS_CHILD;
	if(isValid())return *this;
	this->controlID(controlID);
	createWindow(className,windowName,dwStyle,initRect,parentWindow,(HMENU)controlID,parentWindow.processInstance(),0);
	disposition(GUIWindow::AssumeAndDestroy);
	return *this;
}

HWND Control::createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,Window &parentWindow,int controlID)
{
	dwStyle|=WS_CHILD;
	if(isValid())return *this;
	this->controlID(controlID);
	createWindow(extendedStyle,className,windowName,dwStyle,initRect,parentWindow,(HMENU)controlID,parentWindow.processInstance(),0);
	disposition(GUIWindow::AssumeAndDestroy);
	return *this;
}

HWND Control::assumeControl(HWND hControlWnd,UINT controlID,BOOL destroyWindow)
{
  if(isValid())return *this;
	this->controlID(controlID);
	setHandle(hControlWnd);
	disposition((destroyWindow?GUIWindow::AssumeAndDestroy:GUIWindow::Assume));
	return *this;
}

