Example #1
0
// @pymethod (int, int, int, int)|PyCTreeCtrl|GetItemRect|Retrieves the bounding rectangle of a tree view item.
PyObject *PyCTreeCtrl_GetItemRect( PyObject *self, PyObject *args )
{
	CTreeCtrl *pList = GetTreeCtrl(self);
	if (!pList) return NULL;
	PyObject *obItem;
	RECT rect;
	BOOL bTextOnly;
	if (!PyArg_ParseTuple( args, "Oi:GetItemRect",
		                   &obItem, // @pyparm HTREEITEM|item||The item whose Data is to be set.
						   &bTextOnly)) // @pyparm int|bTextOnly||f this parameter is nonzero, the bounding rectangle includes only the text of the item. Otherwise it includes the entire line that the item occupies in the tree view control.
		return NULL;
	HTREEITEM item;
	if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item))
		return NULL;
	GUI_BGN_SAVE;
	BOOL ok = pList->GetItemRect(item, &rect, bTextOnly);
	GUI_END_SAVE;
	if (!ok)
		RETURN_ERR("GetItemRect failed");
	return Py_BuildValue("(iiii)",rect.left, rect.top, rect.right, rect.bottom);
}