Hook Request

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Hook Request

Post by drtech » Sun Sep 15, 2013 7:35 pm

_____________________________________________________________________
object[] parameters = {retVal};
if (Plugins.HookMethod(null, "OpenDental.PatientL.GetMainTitleMidInsert", parameters))
{
retVal = (string)parameters[0];
}
_____________________________________________________________________

need this placed right after line 79 in OpenDental.PatientL please.



*********************************************************************************************************************

Second Hook
_____________________________________________________________________
Plugins.HookAddCode(this, "FormSplash.FormSplash_Load_end");
_____________________________________________________________________

obviously placed after line 29 of FormSplash.FormSplash_Load.

Thanks!
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

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

Re: Hook Request

Post by jsalmon » Mon Sep 16, 2013 11:45 am

I've created a task in our system so that this Hook Request doesn't get missed. It might take us a little longer than usual to add this hook due to our programming resources being stretched pretty thin atm. Should be added by next week I'd imagine.
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
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook Request

Post by drtech » Tue Sep 17, 2013 5:58 am

I just figured out that the last request may not work? It compiles, but then it seems the number of plugins is still null for the program. I assume this is because it has not yet loaded the plugin info? Initially I was thinking I just had something improperly passed...

Would be nice to be able to use an embedded image in my plugin rather than have to copy and keep track of a *.jpg and a *.dll for a plugin to modify the splash screen.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook Request

Post by drtech » Wed Sep 18, 2013 8:44 am

So, unless you can make it work, I don't think my second request above will work. I see that plugins don't load until later and that is because the database is not yet connected, and all of that is supposed to run while the splash screen is showing, so I guess the *.jpg method you have implemented is the best workaround. If there is some other way to load an embedded image that I am not thinking of, let me know.

If you can still get the other hook entered, I would appreciate it. Thanks
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

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

Re: Hook Request

Post by jsalmon » Wed Sep 18, 2013 8:57 am

The original splash is just an embedded resource. The *.jpg method is the only way I'm aware of changing it other than going through a big headache of manipulating the resource.

I've got a programmer with the other hook on his TODO list.
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
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook Request

Post by drtech » Wed Sep 18, 2013 11:43 am

I actually have a modification I figured out that will allow me to hook the splash after the database is found. Currently the program reloads the splash screen after the database connection is established, so in that second time around, I can hook into it and then achieve the desired effect for my plugin. I will post that code shortly.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

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

Re: Hook Request

Post by allends » Wed Sep 18, 2013 11:45 am

This is Jordan. We are trying to add it, but it doesn't follow any of the patterns on our hooks page. Notice how HookMethods always replace an entire method, so they contain a "return". But you seem to have more of a HookAddCode. The pattern needs to look more like the example:

Code: Select all

object[] parameters={myInt,myStr};
Plugins.HookAddCode(this,"FormClaim.GetClaims_beginning", parameters);        
myInt=(int)parameters[0];
myStr=(string)parameters[1];
It also needs to be tested by you before we add it. We don't want to add it, only to have to revise it again later.
Allen
Open Dental Software
http://www.opendental.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook Request

Post by drtech » Wed Sep 18, 2013 1:32 pm

Sorry, I didn't realize I left it as a "AddMethod" and not "addcode" after my testing. Yes, it was tested and works fine, but I revised it below to follow the patterns since I had combined examples by mistake. I just want to add a string(plugin name) to the retVal so it shows in the title bar. If you have a better way of doing it, then by all means replace it or give me an idea of what you think would be better. This works great and is simpler:

Code: Select all

object[] parameters = {retVal};
Plugins.HookAddCode(null, "OpenDental.PatientL.GetMainTitleMidInsert", parameters);
retVal = (string)parameters[0];                 

added at line 80 of OpenDental.PatientL


for the splash screen, I will continue to work on it...
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook Request

Post by drtech » Wed Sep 18, 2013 3:31 pm

***************************
For the splash screen this modification will make it work on the second showing after the database info is loaded. The user gets the normal splash initially and then my plugin additions will popup. Not what I initially hoped for, but works pretty well actually since a plugin is an add-on anyway and visually represents that to the user.

Code: Select all

If (Plugins.PluginsAreLoaded) Plugins.HookAddCode(this, "FormSplash.FormSplash_Load_end");

to line 30 of OpenDental.FormSplash.cs


The to make it work, the Plugins need to loaded just a bit earlier. If you move

Code: Select all

                Plugins.LoadAllPlugins(this);
 
in FormOpenDental.FormOpenDental_load from line 1662 (before loading the splash screen for the second time) up to 1627, it works great.

All is tested and working.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

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

Re: Hook Request

Post by allends » Thu Sep 19, 2013 7:07 am

I will work on adding this today.
Allen
Open Dental Software
http://www.opendental.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook Request

Post by drtech » Sun Sep 22, 2013 7:09 pm

Thanks.

I have another request. In order to add a setup menu item for my plugin, I need menuItemSettings to be made public rather than private.

change line 66 in FormOpenDental.cs

FROM
***************
private System.Windows.Forms.MenuItem menuItemSettings;
***************

TO
***************
public System.Windows.Forms.MenuItem menuItemSettings;
***************

The hook is already present for me to use, just need this protection level changed. Thanks!
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook Request

Post by drtech » Tue Oct 01, 2013 3:22 pm

Any idea when these recent hooks from a few of us developers will be processed? Thanks.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Hook Request

Post by wjstarck » Tue Oct 01, 2013 3:46 pm

drtech wrote:Thanks.

I have another request. In order to add a setup menu item for my plugin, I need menuItemSettings to be made public rather than private.

change line 66 in FormOpenDental.cs

FROM
***************
private System.Windows.Forms.MenuItem menuItemSettings;
***************

TO
***************
public System.Windows.Forms.MenuItem menuItemSettings;
***************

The hook is already present for me to use, just need this protection level changed. Thanks!
David-

Sorry to butt in :oops: , but do you just want to add a custom menuItem somewhere? PM me, you can do that without OD staff having to change the access modifier for that control
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

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

Re: Hook Request

Post by allends » Wed Oct 02, 2013 2:33 pm

drtech wrote:***************************
The to make it work, the Plugins need to loaded just a bit earlier. If you move

Code: Select all

                Plugins.LoadAllPlugins(this);
 
in FormOpenDental.FormOpenDental_load from line 1662 (before loading the splash screen for the second time) up to 1627, it works great.

All is tested and working.
For this change could you give me the code around it so I can get this in the correct place. Currently if I place it on the line it will not compile.
Allen
Open Dental Software
http://www.opendental.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook Request

Post by drtech » Wed Oct 02, 2013 4:41 pm

if(!formChooseDb.TryToConnect()) {
formChooseDb.ShowDialog();
if(formChooseDb.DialogResult==DialogResult.Cancel) {
Application.Exit();
return;
}
}
}
else {
formChooseDb.ShowDialog();
if(formChooseDb.DialogResult==DialogResult.Cancel) {
Application.Exit();
return;
}
}
Cursor=Cursors.WaitCursor;
Plugins.LoadAllPlugins(this);//moved again for splash screen plugins-->moved up from right after optimizing tooth chart graphics. New position might cause problems.
Splash = new FormSplash();
if(CommandLineArgs.Length==0) {
Splash.Show();
}
if(!PrefsStartup()){//looks for the AtoZ folder here, but would like to eventually move that down to after login
Cursor=Cursors.Default;
Splash.Dispose();
Application.Exit();
return;
}
__________________________________________________________________________________---
this is the new position and compiles and runs fine if you place it here. Thanks, David.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

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

Re: Hook Request

Post by allends » Thu Oct 03, 2013 8:10 am

DrTech,

Were you able to access the private control through our public Controls property?

http://www.opendental.com/manual/plugins.html

1. To access the private controls on an existing form from outside the form, look through the public Controls property as shown in the posted example.

Changing the privacy setting on a control to public is generally not good practice, but you should still be able to access it this way.
Allen
Open Dental Software
http://www.opendental.com

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

Re: Hook Request

Post by allends » Thu Oct 03, 2013 11:21 am

drtech wrote:***************************
For the splash screen this modification will make it work on the second showing after the database info is loaded. The user gets the normal splash initially and then my plugin additions will popup. Not what I initially hoped for, but works pretty well actually since a plugin is an add-on anyway and visually represents that to the user.

Code: Select all

If (Plugins.PluginsAreLoaded) Plugins.HookAddCode(this, "FormSplash.FormSplash_Load_end");

to line 30 of OpenDental.FormSplash.cs


The to make it work, the Plugins need to loaded just a bit earlier. If you move

Code: Select all

                Plugins.LoadAllPlugins(this);
 
in FormOpenDental.FormOpenDental_load from line 1662 (before loading the splash screen for the second time) up to 1627, it works great.

All is tested and working.
Due to moving Plugins.LoadAllPlugins I am not going to backport this to the beta, but it will exist in the head.
Allen
Open Dental Software
http://www.opendental.com

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

Re: Hook Request

Post by allends » Thu Oct 03, 2013 11:52 am

drtech wrote:Sorry, I didn't realize I left it as a "AddMethod" and not "addcode" after my testing. Yes, it was tested and works fine, but I revised it below to follow the patterns since I had combined examples by mistake. I just want to add a string(plugin name) to the retVal so it shows in the title bar. If you have a better way of doing it, then by all means replace it or give me an idea of what you think would be better. This works great and is simpler:

Code: Select all

object[] parameters = {retVal};
Plugins.HookAddCode(null, "OpenDental.PatientL.GetMainTitleMidInsert", parameters);
retVal = (string)parameters[0];                 

added at line 80 of OpenDental.PatientL


for the splash screen, I will continue to work on it...
This has been backported to the beta.
Allen
Open Dental Software
http://www.opendental.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook Request

Post by drtech » Fri Oct 04, 2013 8:19 pm

Thanks for the other additions
DrTech,

Were you able to access the private control through our public Controls property?

http://www.opendental.com/manual/plugins.html

1. To access the private controls on an existing form from outside the form, look through the public Controls property as shown in the posted example.

Changing the privacy setting on a control to public is generally not good practice, but you should still be able to access it this way.
No, I have added other controls to the forms and manipulated lots of other controls, but I can't seem to access menus through the "Controls" property.

Here is what I am doing, but this only works if the menu itself is public. I can't use "menuItemSettings.MenuItems.Add" or seem to add a menu item using the standard "Controls.Add"

Code: Select all

        public static void OpenDental_Load_end(OpenDental.FormOpenDental sender)
        {
            formModuleSetupP = new FormModuleSetupP();
            MenuItem mnu = new MenuItem();
            mnu.Text = "Plugin Customized Setup";
            mnu.Name = "PluginSetup";
            mnu.Index = 0;
            mnu.Click += formModuleSetupP.aGoldPluginOptionsToolStripMenuItem1_Click;
            sender.menuItemSettings.MenuItems.Add(0, mnu);
   

        

        }
wjstarck sent me an alternate method of adding a menu item, but I have not yet have time to try it out.....
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

Post Reply