Beispiel #1
0
/*----------------------------------------------------------------------------------------------
	Attach the given hwnd to this AfWnd.  This means that we save hwnd as m_hwns, and store a
	pointer to this AfWnd object as the user data associated with the hwnd.  This is normally
	called when WM_CREATE is processed, but may be called at a later time, especially for
	controls in dialogs.

	@param hwnd Handle to a window.
----------------------------------------------------------------------------------------------*/
void AfWnd::AttachHwnd(HWND hwnd)
{
	AssertObj(this);
	Assert(hwnd != NULL);

	if (m_hwnd)
	{
		if (m_hwnd == hwnd)
			return;
		AssertMsg(false, "AfWnd already attached to a different HWND.");
		ThrowHr(E_FAIL);
	}

	AfWnd * pwnd = reinterpret_cast<AfWnd *>(::GetWindowLong(hwnd, GWL_USERDATA));
	if (pwnd)
	{
		AssertMsg(false, "Hwnd already attached to an AfWnd");
		ThrowHr(E_FAIL);
	}

	::SetWindowLong(hwnd, GWL_USERDATA, (long)this);
	AddRef();
	m_hwnd = hwnd;

	PostAttach();
}
Beispiel #2
0
void AttachableComponent::Attach(TransformationNode * node)
{
    if(node != m_Node)
    {
        Detach();

        m_Node = node;
        m_Node->NotifyAttach(this);

        PostAttach();
    }
}