Custom Button Add to Confirm List 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

Custom Button Add to Confirm List Form

Post by jaynahar » Thu Jul 31, 2014 6:14 am

Hi All,

I am trying to add the buttons in appointment confirm list form (FormConfirmList) by overriding the HookAddCode method but i am not able to get the reference of confirm list form (FormConfirmList) in my code. I am using the open dental version 12.XX.XX.

How can i add my custom button in this form? Please help me with sample code. Any helping hands will be greatly appreciated.

Regards

Jay.

User avatar
jsalmon
Posts: 1553
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Custom Button Add to Confirm List Form

Post by jsalmon » Thu Jul 31, 2014 9:33 am

You should use the ContrChartP class as an example to follow because it has good things like finding other controls on forms so that you can put your button next to other buttons relatively instead of hard coding some location into it.
Other than that, it's very simple:

The calling method from Plugin.cs:

Code: Select all

case "FormConfirmList.Load_End":
		FormConfirmListP.AddCustomButton((OpenDental.FormConfirmList)sender,parameters);
		return true;
Where the magic happens:

Code: Select all

public static void AddCustomButton(OpenDental.FormConfirmList sender,object[] parameters) {
	Button customButton=new Button();
	//Set up however you want the button to look:
	customButton.Location=new System.Drawing.Point(10,10);
	customButton.Size=new System.Drawing.Size(100,100);
	customButton.Text="Custom";
	//Add the button to FormConfirmList:
	sender.Controls.Add(customButton);
}
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

jaynahar
Posts: 40
Joined: Wed Apr 23, 2014 6:35 am

Re: Custom Button Add to Confirm List Form

Post by jaynahar » Fri Aug 01, 2014 5:54 am

Hi,

Thank you for your quick help. I am following your instructions but i am not getting my custom buttons in confirmation list form of open dental version 12.xx.xx.

Please help me with code and also let me know how to add the events for these buttons from my custom dll. See my code below:

Plugin.cs
-----------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenDental;
using OpenDentBusiness;

using System.Windows.Forms;

namespace SynergyTopPlugin
{

public class Plugin : PluginBase
{




public Plugin()
{
}

public override bool HookAddCode(object sender, string hookName, params object[] parameters)
{
string str = hookName;
string str1 = str;
if (str != null)
{
switch (str1)
{
case "FormConfirmList.Load_End":
FormConfirmListP.AddCustomButton((OpenDental.FormConfirmList)sender);
return true;
}
}
return false;
}
public override void LaunchToolbarButton(long patNum)
{
new FormConfirmListP().ShowDialog();
}

}
}

-----------------------------------------------------------------------------------------------------------------------------------------

FormConfirmListP.cs

----------------------------------------------------------------------------------------------------

using OpenDental;
using OpenDentBusiness;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;



namespace SynergyTopPlugin
{
public class FormConfirmListP :Form
{

private IContainer components;

public FormConfirmListP()
{


}

protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}

public static void AddCustomButton(OpenDental.FormConfirmList sender)
{


Button customButton = new Button();
//Set up however you want the button to look:
customButton.Location = new System.Drawing.Point(10, 10);
customButton.Size = new System.Drawing.Size(100, 100);
customButton.Text = "Synergy SMS";
//Add the button to FormConfirmList:
sender.Controls.Add(customButton);
}




}
}

User avatar
jsalmon
Posts: 1553
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Custom Button Add to Confirm List Form

Post by jsalmon » Fri Aug 01, 2014 9:07 am

Your code looks fine from what I can see, it's probably just not getting hit if it's not getting added to the form. Do you have your plugin enabled in program links? Does a break point get hit if you put it in your plugin code and launch the confirmation list window?

Now that you are inside your custom plugin, any typical C# code should work as it would in a normal application that you make. So just add a click event handler like you normally would.
http://msdn.microsoft.com/en-us/library ... .110).aspx
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

User avatar
jsalmon
Posts: 1553
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Custom Button Add to Confirm List Form

Post by jsalmon » Fri Aug 01, 2014 11:01 pm

It's probably just hiding behind something on the form now that I look at a screenshot of the confirmation list window. You shouldn't use the exact location of my button add code because I just made something up. You should move it relatively next to whatever you want it to show up next to like I mentioned above.
You should use the ContrChartP class as an example to follow because it has good things like finding other controls on forms so that you can put your button next to other buttons relatively...
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

Post Reply