Same ContextMenu on different Controls

klaus

Expert
Licensed User
This is a small example, using the Door library, to manage a same ContextMenu on different Controls.

The request comes from the German forum on how to get the Control name from where the ContextMenu was triggered.

I think this could be usefull for others.

Best regards.
 

Attachments

PatrikL

Member
Licensed User
Hi klaus,

thanx for this sample program. I try it, but doesnt work on realtime designed componets. For designer placed object works fine. Can me explain why?
 

PatrikL

Member
Licensed User
Hi Klaus,

thanks for reply. Your demo works fine. I attach part of my prog, which dont work. Please check it (if You want) and say me why.

Thanks.
 

Attachments

klaus

Expert
Licensed User
I tried your program, works fine on my desktop (IDE and compiled) and on my devices (autoscale compiled) (Qtek9090 WM2003, htc HD WM6.1.
So, could you explain what doesn't work.

- do you get an error ?
- are the context menus not displayed ?
- are the context menus not working ?
- etc

Best regards.
 

PatrikL

Member
Licensed User
I run program in IDE for now.

After start shows only panel with scrollbar. Then You must call context menu and select Add Text. On newly created textbox again You must call context menu and select first item. Then program shows messagebox. In this messagebox should be name of textbox which is owner of context menu. But doesnt show nothing.
 

PatrikL

Member
Licensed User
In contextmenu click sub is code for giving name of textboxt which call context menu.

Sub cmtext_Click
'Dim Source
cmtextobj2.Value=cmtext.Value
cmtextobj1.Value=cmtextobj2.GetProperty("SourceControl")
Source=cmtextobj1.GetProperty("Text")
Msgbox(Source)
End Sub

According klaus demo program, this code show owner of context menu. In klaus demo program works fine. But not in my program. I cant understand why my code dont work (its same code as klaus code).
 

agraham

Expert
Licensed User
According klaus demo program, this code show owner of context menu..
Klaus' program is returning the text property of the owner control which just happens to be the name of the control in his demo. If you type into your textbox then use the context menu you will see the text you have typed.

To get the name try

Source=cmtextobj1.GetProperty("propName")

This will only work on Basic4ppc intrinsic controls, not those added from a library.
 

agraham

Expert
Licensed User
Btw. I search in ..for properties "Text" or "propsname". I cant find nothing about that.
Because they belong to the Textbox which is the source control, not the ContextMenu.

Exist any better documentation?
For using the Door library you've found it - MSDN!

P.S. agraham please look here
Sorry but I won't be doing that.
 

klaus

Expert
Licensed User
Sorry for answering that late, I was not at home this afternoon.

I checked both, my example and your program.
In fact it was not a good idea to use the Text property.

The Name property doesn't work because it returns Door.object.

I modyfied both programs using the Tag property,
- I set the Tag property to control's name
- Reading the Tag property gets it back.

Best regards.
 

Attachments

Top