Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Customizing right-click options on Crystal Reports Viewer 1

Status
Not open for further replies.

Patricia Cu

Programmer
Mar 16, 2018
30
CA
Hello all,

We manage a desktop application developed with VFP9 that displays .RPT files via the Crystal Reports Viewer. Users are now requesting new functionality within the Viewer, where you right-click on a value, they want to see a custom option that would execute one of your VFP forms when clicked.

mockup_fkbz1x.png


Is this even possible? I think not, because once your code hands in control to the CR Viewer, the CR Viewer cannot give it back to the application, can it?

If this is not doable, I just need some documentation that I can back up my reply with.

Any information is appreciated!

Regards,
Patricia Cu
 
Indeed, I don't think you could extend the context menu of any application.

I know some software adds menu items to the Windows Explorer context menu, but that's because the Windows Explorer has that menu extensibility as a concept by design, not because context menus of any application are subject to be extensible.

Chriss
 
I never used CR, but you can do some test to check if all Event Handlers changed by... for example set a dual key combination to show an alert just before launching CR Shift+Click posible ? or Shift+A to start simple,
Unsure
 
I was reminded by using a special context menu item in Windows Explorer, that it allows any vendor to not only define an association of a file type and its extension to their application but it also allows to add context menus items for that file type. That's the only extensibility I think from the top of my head that is about context menus. It's not a general feature of any context menu of any application, though.

It's by design in Windows Explorer as it's a central system tool to explore the file system and open or start or print files. For example, 7Zip adds some items that are shown for .zip files and other files of the family of compressed archives like .rar, .cab, etc. and their own extension .7z.

I don't know if your users know about that Explorer feature and think it's possible in general. Well, once I tell you this is done in Windows Explorer by registry keys about file extensions. And when you ever programmed any own VFP context menu you know it is not typical or even a Windows standard to define context menus by registry keys and make them a common playground for anyone to modify. Let alone that any menu item could be a trojan, then, doing malicious things. So it's under your control, just like that CR viewer context menu is under its control.

It shold be sufficient to tell them the CR viewer is not your software, it's just started from your application and something you don't control and can extend or modify.

Chriss
 
Thanks Chris! Will definitely include it in my reply! :)

Regards,
Patricia Cu
 
Patricia,

As far as I know, you can't customise the viewer's right-click menu or assign events to it. The best you can do is to call events related to any of the controls within the viewer, such as the various buttons.

Each of the buttons has an associated event, the name of which is usually the name of the control followed by "Clicked", for example, RefreshButtonClicked or NextPageButtonClicked. These events are fired when you click on the corresponding button. You can put any VFP code you like in these events, including launching another form.

It's also possible, of course, to add your own VFP button or other VFP controls to the viewer form. Again, these can contain any code you like.

The problem with all this is that there is no way to associate this code with any particular item within the report. So if the user wants to be able to right-click on an an item and then to pass the value of that item to a form, I can't see how that would be possible.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, then you can mount a partial solution, with a button than executes some predefined macros, that opens some predefined forms and assumed a disctint valued passed, good to konw
Thanks for the info
 
As that's possible, one thing you could offer is a compromise: I assume the Copy menu item simply copies a value into the Windows clipboard, does it?

If so, you could use a custom button Mike Lewis talked about to start a VFP form which then takes _cliptext as a parameter of the form to know which item to handle. You will then need to verify the _cliptext is what you expect it to be, like a P followed by 7 digits in this case.

Chriss
 
Thats a good alternative Chris

The use of a table could be another one, specially if need to keep a history or for a later reprint , out of paper error :/.
 
Thank you Mike and Chris for your suggestion.

Would it be possible to point me to any documentation or example on how to add my own VFP button (or other VFP controls) to the crystal reports viewer form?
I would like to see the level of complexity it can work with regarding opening a VFP form that expects several parameters. Our VFP application has a form manager class that controls how all the forms are opened and I'm wondering if it would even be possible to work with that form manager from the crystal report viewer...

Regards,
Patricia Cu
 
Patricia,

You asked, "how to add my own VFP button (or other VFP controls) to the crystal reports viewer form?"

I'm assuming you are using the ActiveX version of the report viewer control (as opposed to the .NET version). If that's right, then the viewer will be embedded in a normal VFP form. That form can then also contain any other VFP controls that you care to add to it. So you would not be adding buttons to the viewer itself, but rather to the form that is hosting the viewer.

This might not be obvious. It's possible that the viewer occupies the entire height and width of the form, in which case you won't actually see the containing form either at design time or run time. So you would have to increase the size of the form (or decrease the size of the viewer) to create some space to hold the additional controls.

Regarding "if it would even be possible to work with that form manager from the crystal report viewer...". No, the CR viewer does not interact with the form manager. It is the buttons that you have added to the form that would call the form manager. Those are normal VFP buttons which can contain normal VFP code. And that code can include calling the form manager and passing parameters to it.

The problem is that the buttons have no way of knowing which item in the report has been selected by the user. This is different from a right-click menu, which operates on a particular report item (a field, label, image or whatever). With buttons, that context is lost. So, if your aim is to pass a value from the report to the new form, then I can't see how you could do that.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you for your response Mike, it did clarify things, and I agree with you re: passing the report value to the container form. Even with Chris' suggestion re: accesing _cliptext, it would only work if there was only 1 value needed to open the corresponding VFP form. In most of our VFP forms, more than one value is required, and there is no way of knowing/accessing the other values when you right-click on one of the report items to copy it to _cliptext.

I will summarize this discussion in a user friendly manner so our business analyst can reply to the clients.

Regards,
Patricia Cu
 
Patricia, I'm sorry I couldn't come up with a better solution. I hope your analysts can find a solution that will satisfy your clients.

Now, this is a bit of a long shot, but I wonder if it would be worth looking for a third-party report viewer control that might provide a solution. In another of your threads, I mentioned Millet Software (milletsoftware.com) as a possible source, but I am very out of date with all this, so have no idea if that would be a good place to look. It would have to be an ActiveX control in order to work with VFP, and it would have to be compatible with your version of CR.

It's just a thought.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike. I did pass along the Millet Software information to our Project Manager re: splitting a crystal report, in case they wanted to follow up (third party negotiations are above my pay grade =D). I will mention this scenario as well so they can include it in their discussions with Millet Software (if they decide to pursue).

I appreciate all the knowledge and advise both you and Chris have provided.

Regards,
Patricia Cu
 
Patricia, keep in mind that I mentioned Millet Software only as one example of a third-party product. There are almost certainly other vendors worth investigating. I used to know the CR add-on market very well, but it has been been over ten years since I did any serious work in that area.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Patricia,
Patricia Cu said:
Even with Chris' suggestion re: accessing _cliptext, it would only work if there was only 1 value needed to open the corresponding VFP form.
That begs the question: Even if you could add a menu item to the items of the report viewer, how can you assume you can pass on anything else than the value of the one item of which the context menu is? In the context of P2200014 you only have that value available, nothing more.

Even if you assume code hooked into the menu can access more data than the P2200014 value, wouldn't it be a bad interface idea to add a form start to one specific item, if it's not at all sufficient to steer a form into the one record the user wants to see?

As that's the case the possibility to use the ActiveX variant of the preview on a form that's otherwise a VFP form and can have any other controls and code on it would be more to the point anyway, just from the perspective of the user interface. So it wouldn't even be helpful to have a context menu at a specific value that's just one of several parts of data you need to know.

I'll reformulate it this way: Are the users perhaps not interested in forms that can show all data related to one value they right-click on? Like all data related to P2200014? Because that's the only thing that would make sense of that feature demand, isn't it?

Chriss
 
Thank you Mike, I do keep that in mind.
Chris, I don't think the users are sure of what they want, so I relayed to them the difficulties of this approach and left it at that. Back to my attempt to split a crystal report... [glasses]

Regards,
Patricia Cu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top