[英]calling an child form event replacing or avoiding the mdi parent form event
In mdimain_MdiChildActivate
the application logic is defined for all child forms related to GridControl
mouseDoubleClick
event . 在
mdimain_MdiChildActivate
,为与GridControl
mouseDoubleClick
事件相关的所有子窗体定义了应用程序逻辑。 It is working fine for all grid containing child forms but in some case where grid mouseDoubleClick
is defined internal for the Child Form. 对于所有包含子表单的网格,它都可以正常工作,但在某些情况下,为子表单内部定义了网格
mouseDoubleClick
。 So, the event is fired twice one from MdiParent
and for internal part. 因此,该事件从
MdiParent
触发两次,并从内部触发。 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. 是否有任何方法可以针对此
mouseDoubleClick
案例在不更改MDI表单中的代码的情况下比较/验证子窗体的ifexist
大小写而不会触发MdiParent
父控件事件。
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
}
This approach detects WM_NCHITTEST
message sent to your MainGridControl
before MdiChildActivate
is fired. 这种方法检测
WM_NCHITTEST
发送到您的邮件MainGridControl
之前MdiChildActivate
被解雇了。 This can only detect if your mouse is used (Click, DoubleClick) on the MainGridControl
but I think it suits in your case. 这只能检测是否在
MainGridControl
上使用了鼠标(Click,DoubleClick),但我认为它适合您的情况。
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;}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.