Assistant creation via code

delphi package - automated exception handling

Assistant creation via code

Postby StephaneGrobety » Thu Oct 17, 2019 7:13 am

Hello,

I would like to be able to create an assistant via code. The reason being that we have MANY different projects and that they should all share the same configuration. To that end, I have written common initialization code for configuring madExcept. The only thing I am now missing (and can't seem to find out) is how I can add an assistant template.

The reason why I need to create a template is that I just want the detailForm form to show, nothing else and there is no existing assistant that does this.

Is there any solution?
StephaneGrobety
 
Posts: 19
Joined: Tue Jul 17, 2018 9:21 am

Re: Assistant creation via code

Postby madshi » Tue Oct 22, 2019 2:57 pm

The current assistant solution is designed to be configured at compile time.

Anyway, you can experiment with using the following function exported by madNVAssistant.pas:

Code: Select all
function LoadAssistant (module          : HMODULE;
                        const title     : UnicodeString;
                        const forms     : array of UnicodeString;
                        const exception : IUnknown = nil) : INVAssistant;

And then you can use "INVAssistant.ShowModal()" to actually display the assistant. You can check madExcept.pas to see how madExcept uses these functions.

However, usually madExcept creates and shows the assistants automatically, as part of the exception handling. If you want to manually create custom assistants, you'll have to show them manually, as well, e.g. within a RegisterExceptionHandler() or RegisterExceptActionHandler() callback.

Maybe it would be easier to already prepare/create the assistant you need, and then use it for all your projects? There's a trick to have all your projects use the same mes file:

1) Create a proper *.mes file with the exact configuration you want.
2) Store this *.mes file in a "global" folder.
3) Using Notepad.exe create a "forward.mes" file which contains one line of text which is the file path/name of the global mes file.
4) Copy this "forward.mes" file to all your projects and rename it to match your project names.

This way all your projects will use the central/global mes file. Maybe that helps?
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm

Re: Assistant creation via code

Postby StephaneGrobety » Thu Oct 24, 2019 2:28 pm

Thank you for your answer.

Maybe it would be easier to already prepare/create the assistant you need, and then use it for all your projects? There's a trick to have all your projects use the same mes file:
1) Create a proper *.mes file with the exact configuration you want.
2) Store this *.mes file in a "global" folder.
3) Using Notepad.exe create a "forward.mes" file which contains one line of text which is the file path/name of the global mes file.
4) Copy this "forward.mes" file to all your projects and rename it to match your project names.


I will try that, but honestly, I'd much rathed be able to configure madExcept completely vial code: much less room for error that way.
StephaneGrobety
 
Posts: 19
Joined: Tue Jul 17, 2018 9:21 am


Return to madExcept

Who is online

Users browsing this forum: No registered users and 10 guests

cron