Page 1 of 1

Another hooks request...and a question

Posted: Tue Mar 22, 2011 12:44 pm
by wjstarck
I want to add the following hooks before and after line 5047 on method gridProg_CellDoubleClick on ContrChart:

Code: Select all

Plugins.HookAddCode(this, "ContrChart.gridProg_CellDoubleClick_begin", proc, FormP);
FormP.ShowDialog();
Plugins.HookAddCode(this, "ContrChart.gridProg_CellDoubleClick_begin2", proc, FormP);
However, I want to conditionally dispose of FormProcEdit within my HookAddCode method which presents a problem for line 5048 on ContrChart which is

Code: Select all

FormP.ShowDialog();


So, I'm wondering: could you make the following change to line 5048 on ContrChart

Code: Select all

if (!FormP.IsDisposed) { //might be disposed by above hook <-----
FormP.ShowDialog();
} <-----
to accomodate my hooks?

So, it would look like:

Code: Select all

FormProcEdit FormP=new FormProcEdit(proc,PatCur,FamCur);
Plugins.HookAddCode(this, "ContrChart.gridProg_CellDoubleClick_begin", proc, FormP); <-----
if (!FormP.IsDisposed) { //might be disposed by above hook <-----
FormP.ShowDialog();
} <-----
Plugins.HookAddCode(this, "ContrChart.gridProg_CellDoubleClick_begin2", proc, FormP); <-----
if(FormP.DialogResult!=DialogResult.OK) {
return;
}
I know I could just replace the whole method, but that seems like overkill for this situation. And I don't think this change would ever create a problem for a non-plugin user, since nothing should ever dispose of FormProcEdit here.

What this hook does is prevent a second user from editing a note when another user has it open, thus losing all his/her changes when the first user saves his/her edit.

The third hook for this is on FormProcEdit, method butOK_Click, after line 4420:

Code: Select all

SaveAndClose();
Plugins.HookAddCode(this, "FormProcEdit.butOK_Click_end", ProcCur); <----- 
Thanks, and apologies for all the hook requests as of late. I know you guys are busy.... :oops: