Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » TreeCtrl » Tree Control - how to access properties of node.ctrl?
Tree Control - how to access properties of node.ctrl? [message #10424] Mon, 09 July 2007 07:10 Go to previous message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Hi,

I have my own subclass of Option which I pass into TreeCtrl. However, much later I try to get the control from the TreeCtrl but all I get is a standard Ctrl object and I am not allowed to cast it to the type of control which I originally passed in.

I try this within my TreeCtrl derived class

	TreeCtrl::Node node = GetNode(id);	
	LayerOption* ptr = (LayerOption*)(node.ctrl);
	Layer* pLayer = ptr->GetLayer();



but I am not allowed the cast on the second line. The Ctrl I want to cast to looks like this

class LayerOption : public Option {
private:
	virtual void LeftDown(Point p, dword keyflags) 
	{
		if(p.x<this->GetSize().cy)
			Option::LeftDown(p, keyflags);
		if(this->GetData()==true)
			SetFocus();	
		
		// now send pass on this event to the parent for possible drag and drop 
		Ctrl* pCtrl = this->GetParent();
		Point pt = p + GetRect().TopLeft(); // transform event into parent coordinates
		if(p.x>this->GetSize().cy)
			pCtrl->LeftDown(pt,keyflags);

		Refresh();
	}

	class Layer* m_pLayer; // these classes need to know about each other

public:
	Layer* GetLayer(){return m_pLayer;} // allows the option ctrl to identify its own layer
	void SetLayer(Layer* pLayer){m_pLayer = pLayer;}
	
	bool DropTarget();
	bool DragObject();

	
};


and is the same type of control I pass into the tree control in the first place and its LeftDown function gets executed so I know its being used.

Is there any way to access this control from the TreeCtrl object please?

Nick

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Two problems (1 serious) with TreeCtrl
Next Topic: Right Clicking Tree Nodes?
Goto Forum:
  


Current Time: Thu Aug 21 14:42:24 CEST 2025

Total time taken to generate the page: 0.05059 seconds