Exemplo n.º 1
0
//最后一步真正的释放对象
//释放自己,也释放关注自己的对象
void AWinControlBase::_lastRelease()
{
	AContainer* pcParent = dynamic_cast<AContainer*>(GetParent());
	if( pcParent )
		pcParent->GetUICore()->RemoveWatcher(this);

	m_aWatchDelete.Clear();
	Release();
}
Exemplo n.º 2
0
bool AWinControlBase::Create()
{
	if( m_pWindow ) return true;
	
	InitControls();

	m_pWindow = CreateWnd();
	if( m_pWindow == NULL ) return false;
	m_pWindow->AddRef();

	HWND hParent = NULL;
	AControl* pParent = dynamic_cast<AControl*>( GetParent() );
	if( pParent ) hParent = pParent->GetUICore()->GetHandle();
	
	if( !m_pWindow->Create(hParent,m_WindowPos) ) 
	{
		m_pWindow->Release();
		m_pWindow = NULL;
		throw AException(_T("窗口创建失败!"));
		return false;
	}

	AContainer* pcParent = dynamic_cast<AContainer*>(GetParent());
	if( pcParent )
		pcParent->GetUICore()->AddWatcher(this);

	//再进行下面的处理
	if( m_WindowPos == wpDesign )
	{
		::SetWindowPos(GetHandle(),HWND_NOTOPMOST,GetLeft(),GetTop(),GetWidth(),GetHeight(),SWP_NOREDRAW|SWP_HIDEWINDOW);
	}
	else if( m_WindowPos == wpCenterScreen )
	{
		ARect rScreen;
		SystemParametersInfo(SPI_GETWORKAREA,0,&rScreen,0);
		int dw = (rScreen.right-rScreen.left-GetWidth())/2;
		int dh = (rScreen.bottom-rScreen.top-GetHeight())/2;
		m_iLeft = (rScreen.left+dw);
		m_iTop = (rScreen.top+dh);
		::SetWindowPos(GetHandle(),HWND_NOTOPMOST,GetLeft(),GetTop(),GetWidth(),GetHeight(),SWP_NOREDRAW|SWP_HIDEWINDOW);
	}
	else
	{
		ARect r;
		::GetWindowRect(GetHandle(),&r);
		//::SetWindowPos(GetHandle(),HWND_NOTOPMOST,r.left,r.top+1,r.GetWidth(),r.GetHeight(),0);
		m_iLeft = r.left;
		m_iTop = r.top;
		m_iWidth = r.GetWidth();
		m_iHeight = r.GetHeight();
		
	}
	//::SetWindowPos(GetHandle(),HWND_NOTOPMOST,GetLeft(),GetTop(),GetWidth(),GetHeight(),0);//SWP_NOREDRAW|SWP_HIDEWINDOW);
	//::SetWindowPos(GetHandle(),HWND_NOTOPMOST,GetLeft(),GetTop(),GetWidth(),GetHeight(),SWP_NOREDRAW|SWP_HIDEWINDOW);
	DoCreate();
	ConnectEvent();
	DoLayout();
	Refresh();


	//HRGN hRgn = ::CreateRoundRectRgn(0,0,GetWidth()+1,GetHeight()+1,5,5);
	//::SetWindowRgn(m_pWindow->GetHandle(),hRgn,FALSE);
	//::DeleteObject(hRgn);

	AEvent evt;
	OnCreate.Call(this,&evt);
	return true;
}