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 » Hand cursor over ArrayCtrl Column
Hand cursor over ArrayCtrl Column [message #40394] Mon, 29 July 2013 21:07 Go to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Hi, there!

I want to change cursor icon to hand shape when hovering mouse pointer over an ArrayCtrl column, for I wish to grab ArrayCtrl cells and DnD them. Any suggestions on what's the best and simplest way of getting it done?

Tks!
Re: Hand cursor over ArrayCtrl Column [message #40542 is a reply to message #40394] Sun, 11 August 2013 12:56 Go to previous message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
This example works also when user drags and drops header to another position:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MyArrayCtrl : public ArrayCtrl
{
	public:
		
		MyArrayCtrl()
		{
			AddColumn("Column 1");
			AddColumn("Hand cursor column");
			AddColumn("Column 2");
			
			for(int i = 0; i < 10; i++) {
				Add("foo", "bar", "foo");
			}
		}
		
		virtual Image MouseEvent(int event, Point p, int zdelta, dword flags)
		{
			Image img = ArrayCtrl::MouseEvent(event, p, zdelta, flags);
			if(GetLineAt(p.y) >= 0) {
				int width;
				int x0 = 0;
				for(int col = 0; col < GetColumnCount(); col++) {
					width = HeaderObject().GetTabWidth(col);
					if(HeaderTab(col).GetText().IsEqual("Hand cursor column"))
						break;
					x0 += width;
				}
				if((p.x >= x0) && (p.x < x0 + width))
					img = Image::Hand();
			}
			return img;
		}
		
		typedef MyArrayCtrl CLASSNAME;
};

struct MyApp : public TopWindow
{
	public:
	
		MyArrayCtrl arr;
		MyApp() {
			Add(arr.SizePos());
		}
};

GUI_APP_MAIN
{
	MyApp().Run();
}

Comments??
tks.
Previous Topic: Copy and paste for ArrayCtrl
Next Topic: [bug] ArrayCtrl removing all rows upon removing only last row
Goto Forum:
  


Current Time: Thu Mar 28 19:19:43 CET 2024

Total time taken to generate the page: 0.01245 seconds