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
Adding attachment if custom checkbox in assistant is checked
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
http://help.madshi.net/madNVAssistantUnit.htm
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.
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
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;
Do you have a solution for this?
regards,
-Vegar
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.
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.