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 » U++ Widgets - General questions or Mixed problems » Context menu in a embedded class?
Context menu in a embedded class? [message #19528] Thu, 11 December 2008 19:23 Go to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Hi,
I have this code:

Class x:
tabdlg.dbgrid1.AddColumn("ID");
tabdlg.dbgrid1.AddColumn("Date");
tabdlg.dbgrid1.AddColumn("Value");
tabdlg.dbgrid1.AddColumn("Paid");
tabdlg.dbgrid1.ColumnWidths("0 50 50 200");
tabdlg.dbgrid1.WhenLeftDouble = THISBACK(OnAnuidDBClick);

tabdlg is a member of the class x. It is also defined in the .h of the class x like this:

class CTablDlg : public WithPaidLayout<TopWindow> {
typedef CTablDlg CLASSNAME;

public:
CTablDlg();
};

Is it possible to trap the context menu event of this dbgrid as I trap the left dbclick? How?

Thanks

Alex
Re: Context menu in a embedded class? [message #19535 is a reply to message #19528] Fri, 12 December 2008 11:26 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
It depends on what type of Ctrl dbgrid1 is.

If it's ArrayCtrl then use the WhenBar callback
If it's GridCtrl then I'm not very familiar with it, but WhenMenuBar seems to be what you need.

Searching for 'Bar&' in a Ctrl's header file usually points you at the correct callback if it has one.

For a generic 'simple' Ctrl that doesn't have a callback you can use something like this template:
template <class T>
struct WithBar : public T 
{
	Callback1<Bar&> WhenBar;
	
	virtual void RightDown(Point p, dword keyflags) { MenuBar::Execute(WhenBar); }
};

[Updated on: Fri, 12 December 2008 11:26]

Report message to a moderator

Re: Context menu in a embedded class? [message #19537 is a reply to message #19535] Fri, 12 December 2008 13:08 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Sorry for the lack of information.

dbgrid1 is an ArrayCtrl that was drawn during design time...

I am trying this:

tabdlg.dbgrid1.WhenBar = THISBACK(OnRClick);

But compiler says:
error: no match for 'operator=' in ' ...

Please, could you help me?

Alex

[Updated on: Fri, 12 December 2008 13:08]

Report message to a moderator

Re: Context menu in a embedded class? [message #19538 is a reply to message #19537] Fri, 12 December 2008 14:18 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Not enough information again Smile, but my guess is that OnRClick is defined incorrectly. It should be:
void OnRClick(Bar &bar) {
    bar.Add("Menu Item", THISBACK(OnMenuItem));
}
Re: Context menu in a embedded class? [message #19539 is a reply to message #19538] Fri, 12 December 2008 14:29 Go to previous message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Ok, I got it!

Thank you very much!


Alex
Upp: I like it!

[Updated on: Fri, 12 December 2008 14:45]

Report message to a moderator

Previous Topic: win32 multiscreen / multimonitor problem fix
Next Topic: Printing with times new roman font?
Goto Forum:
  


Current Time: Fri Apr 19 22:17:03 CEST 2024

Total time taken to generate the page: 0.02875 seconds