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 » ArrayCtrl, HeaderCtrl & GridCtrl » Embed editfields in ArrayCtrl
Re: Embed editfields in ArrayCtrl [message #24271 is a reply to message #24264] Fri, 08 January 2010 13:45 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mdelfede wrote on Thu, 07 January 2010 18:30

Embedding Editfields in ArrayCtrl offers nice editing and filtering capabilities, and the function
Ctrl<EditField>()

offers a fast way to do it but.... it has also a couple of caveats :

1 - Embedded fields get frames, which is ugly inside the array
2 - Embedded fields grab ArrayCtrl rightclick context menu

This simple template solves both :
template<class E> class Embedded : public E
{
	protected:

		void RightDown(Point p, dword keyflags)
		{
			Ctrl *c = this;
			ArrayCtrl *a;
			while( (c = c->GetParent()) != NULL && ((a = dynamic_cast<ArrayCtrl *>(c)) == NULL))
				;
			if(a)
			{
				Rect cRect = E::GetScreenRect();
				Rect aRect = a->GetScreenRect();
				p.y += cRect.top - aRect.top - a->HeaderObject().GetHeight();
				p.x += cRect.left - aRect.left;
				a->RightDown(p, keyflags);
			}
		}
		
	public:
		typedef Embedded<E> CLASSNAME;
		
		Embedded<E>() { E::ClearFrames(); }
};


It's usage is simple, just define your ctrl as, for example :
typedef Embedded<EditDouble> EditDoubleEmbedded;

Then use as a normal editfield in arrayctrl.
The field will get no frames and forward context menu clicks to its ArrayCtrl container.

Ciao

Max



Actually, as long as you override RightDown, there is no need to make the menu indirectly. Remember, the problem we had was because there was a call to SetFocus after the menu handling...

No RightDown, no SetFocus...

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: problems with ArrayCtrl and SetFont
Next Topic: Assertion in GridCtrl
Goto Forum:
  


Current Time: Thu Apr 25 23:12:56 CEST 2024

Total time taken to generate the page: 0.02742 seconds