Adding attachment if custom checkbox in assistant is checked

delphi package - automated exception handling

Adding attachment if custom checkbox in assistant is checked

Postby format71 » Wed Jan 27, 2010 1:28 pm

Hi,

I want to give my customer the possibility to add data files to the bug report.

I have added a custom checkbox to the send assistant, but how can I check for the value of this checkbox and attach the necessary files before sending?

regards,
-Vegar
format71
 
Posts: 8
Joined: Thu Jan 21, 2010 8:29 pm

Postby madshi » Sat Jan 30, 2010 1:14 pm

You can define your own "OnAction" handler (this is a property of an assistant form). In your OnAction handler you can check for "nvaItemEvent" (check box state was changed) or for "nvaFormClose" and then do whatever you want to do. E.g. call GetOpenFileName and then attach the selected file(s) to the exception. More information here:

http://help.madshi.net/madNVAssistantUnit.htm
madshi
Site Admin
 
Posts: 7780
Joined: Sun Mar 21, 2004 5:25 pm

Postby format71 » Mon Feb 01, 2010 3:00 pm

Thanks,

I tried to assign an OnAction-event, but found it easier to use the ExceptAction-event on the VCL component.

I have a small problem, though.

Code: Select all
procedure TMainForm.MadExceptionHandler1ExceptAction(action: TExceptAction;
  const exceptIntf: IMEException; var handled: Boolean);
var
  cbSendData: INVCheckbox;
  zipfile: String;
  assistant: INVAssistant;
begin
  if (action = eaSendBugReport) then
  begin
    assistant := exceptIntf.GetAssistant(exceptIntf.SendAssistant);
    cbSendData := assistant.Forms[1].nvCheckBox('SendDataChk');

    cbSendData.Enabled := HasData;
    cbSendData.Checked := HasData;
  end
  else if action = eaSendBugReport2 then
  begin
    assistant := exceptIntf.GetAssistant(exceptIntf.SendAssistant);
    cbSendData := assistant.Forms[1].nvCheckBox('SendDataChk');

    exceptIntf.AdditionalAttachments.Clear;
    if cbSendData.Checked then
      exceptIntf.AdditionalAttachments.Add(datafile);
  end;
end;


When action equals eaSendBugReport, I disable the checkbox if no data exists, but when the assistant pops up, the checkbox is still enabled.

Do you have a solution for this?

regards,
-Vegar
format71
 
Posts: 8
Joined: Thu Jan 21, 2010 8:29 pm

Postby madshi » Mon Feb 01, 2010 3:55 pm

Calling "GetAssistant" returns a new instance of the specified assistant and any changes you do only apply to this new instance. Once your local variable "assistant" goes out of scope, the new instance is destroyed and all your changes are lost.

You can manually show the assistant, if you want, by doing "assistant.ShowModal", but that way you are bypassing the normal madExcept chain of action. So if you do this, you should disable the assistant in the madExcept settings so that madExcept doesn't show the same assistant another time after you've shown the modified instance.

Of course the cleanest approach is the one I suggested in my first comment.
madshi
Site Admin
 
Posts: 7780
Joined: Sun Mar 21, 2004 5:25 pm

Postby format71 » Mon Feb 01, 2010 4:30 pm

OK. I will see if I make a second attempt tomorrow, or just skip the first part, and ignore the checkbox if no data exists.

I'm still using the evaluation/noncommercial version. Guess everything will get easier once I get the source. :-)

thanks,
-Vegar
format71
 
Posts: 8
Joined: Thu Jan 21, 2010 8:29 pm


Return to madExcept

Who is online

Users browsing this forum: No registered users and 2 guests