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
Embed editfields in ArrayCtrl [message #24264] Fri, 08 January 2010 00:30 Go to previous message
mdelfede is currently offline  mdelfede
Messages: 1264
Registered: September 2007
Senior Contributor
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
 
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 Jul 16 19:50:37 CEST 2020

Total time taken to generate the page: 0.01146 seconds