Method Overwrite Contact Edit Form

This forum is for programmers who have questions about the source code.
Post Reply
jaynahar
Posts: 40
Joined: Wed Apr 23, 2014 6:35 am

Method Overwrite Contact Edit Form

Post by jaynahar » Wed Mar 11, 2015 10:12 pm

Hi All,

I want to over write the ok button click event of contact edit form.

I am using the below code but it is not working. Please guide me what i am doing wrong in it.

public override bool HookAddCode(object sender, string hookName, params object[] parameters)
{
try
{
switch (hookName)
{

case "FormContactEdit.Load_end":
MessageBox.Show("inside contact edit in plugin");
return true;
default:
return false;
}
}
catch (Exception pcex)
{

return false;
}

}

allends
Posts: 235
Joined: Fri Aug 23, 2013 11:29 am

Re: Method Overwrite Contact Edit Form

Post by allends » Thu Mar 12, 2015 9:10 am

First, if you want to overwrite the method OK click, this:

Code: Select all

public override bool HookAddCode(object sender, string hookName, params object[] parameters)
needs to be this:

Code: Select all

public override bool HookMethod(object sender, string hookName, params object[] parameters)
Next, your hook doesn't exist in the program. Meaning this:

Code: Select all

case "FormContactEdit.Load_end":
will never get hit.

To test it, you can build your own version of OD with this:

Code: Select all

Plugins.HookMethod(this,"FormContactEdit_butOK_Click_Start");
added to the beginning of butOK_Click in FormContactEdit.

Lastly, to make it so you don't need to keep building and redistributing your own version of OD, you will need to submit a hook request for that hook I just posted.
The pattern for that can be found here
http://opendental.com/manual/patternplugins.html
Allen
Open Dental Software
http://www.opendental.com

Post Reply