Esempio n. 1
0
/*----------------------------------------------------------------------------------------------
	Create and subclass the HWND associated with this AfWnd object.

	@param wcs Pointer to the object containing the values for calling ::CreateWindowEx.
----------------------------------------------------------------------------------------------*/
void AfWnd::CreateAndSubclassHwnd(WndCreateStruct & wcs)
{
	AssertObj(this);
	Assert(!m_hwnd);

	PreCreateHwnd(wcs);

	HWND hwnd = ::CreateWindowEx(wcs.dwExStyle, wcs.lpszClass, wcs.lpszName, wcs.style,
		wcs.x, wcs.y, wcs.cx, wcs.cy, wcs.hwndParent, wcs.hMenu, wcs.hInstance,
		wcs.lpCreateParams);

	Assert(!m_hwnd);
	if (!hwnd)
		ThrowHr(WarnHr(E_FAIL));

	try
	{
		SubclassHwnd(hwnd);
	}
	catch (...)
	{
		::DestroyWindow(hwnd);
		throw;
	}
}
Esempio n. 2
0
/*----------------------------------------------------------------------------------------------
	This function must be called before the treeview control has been initialized with any data.
	(i.e. before any items are inserted into it.)
----------------------------------------------------------------------------------------------*/
void NetworkTreeView::SubclassTreeView(HWND hwnd)
{
	SubclassHwnd(hwnd);
	Assert(GetCount() == 0);

	// Initialize image list into the tree control
	if (!m_himlTree)
		m_himlTree = AfGdi::ImageList_Create(17, 17, ILC_COLORDDB | ILC_MASK, 5, 5);
	HBITMAP hbmpImageTree = AfGdi::LoadBitmap(ModuleEntry::GetModuleHandle(),
		MAKEINTRESOURCE(kridImagesNetwork));
	ImageList_AddMasked(m_himlTree, hbmpImageTree, RGB(255,255,255));
	AfGdi::DeleteObjectBitmap(hbmpImageTree);
	HIMAGELIST himlProjOld = TreeView_SetImageList(Hwnd(), m_himlTree, TVSIL_NORMAL);
	if (himlProjOld)
		AfGdi::ImageList_Destroy(himlProjOld);

	// Populate the network tree
	_PopulateTopNetworkNodes();
}