1
votes

In mdimain_MdiChildActivate the application logic is defined for all child forms related to GridControl mouseDoubleClick event . It is working fine for all grid containing child forms but in some case where grid mouseDoubleClick is defined internal for the Child Form. So, the event is fired twice one from MdiParent and for internal part. Is there any way such that MdiParent Parent Control event does not fire's for this mouseDoubleClick case comparing/validating the ifexist case for Child Form without changing the code in MDI form.

sample example :

private void MDIMain_MdiChildActivate(object sender, EventArgs e)
{
    // code should not work
}      

private void MainGridControl_MouseDoubleClick(object sender, MouseEventArgs e)
{
  ///  Child Form : code should work
}
1
What is GridControl? some kind of DataGridView?King King
yes! An DevExpress XtraGrid ControlViZ

1 Answers

0
votes

This approach detects WM_NCHITTEST message sent to your MainGridControl before MdiChildActivate is fired. This can only detect if your mouse is used (Click, DoubleClick) on the MainGridControl but I think it suits in your case.

public class Form1 : Form {
   public Form1(){
      InitializeComponent();
      Load += (s,e) => {
         gridProc.AssignHandle(MainGridControl.Handle);
      };
   }
   MainGridProc gridProc = new MainGridProc();
   private void MDIMain_MdiChildActivate(object sender, EventArgs e)
   {
       if(gridProc.HitTestOn) { gridProc.HitTestOn = false; return; }
       //code is still run if HitTestOn = false
       //.......
   }   
   public class MainGridProc : NativeWindow {
      protected override void WndProc(ref Message m){
         if(m.Msg == 0x84)//WM_NCHITTEST
         {
            HitTestOn = true;
         }
         base.WndProc(ref m);
      }
      public bool HitTestOn {get;set;}
   }
}