2011-12-07 2 views
1

이벤트가 어떻게 작동하는지 또는 Delphi Prism이 미쳐 버렸습니다.MouseDown 이벤트에 대해서만 왼쪽 마우스를 클릭하면 MouseMove 이벤트가 발생하는 이유는 무엇입니까?

winform, mousedown 이벤트 및 mousemove 이벤트가 있습니다. 마우스 왼쪽 단추 만 클릭 할 때마다 MouseDown 이벤트는 예상대로 발생하지만 ALSO MouseMove 이벤트는 발생하지 않을 때 발생합니다.

다음은 이벤트가 할당 된 WinForm 디자이너의 코드 조각입니다.

self.ClientSize := new System.Drawing.Size(751, 502); 
    self.KeyPreview := true; 
    self.Name := 'Maker'; 
    self.Text := 'Window Maker'; 
    self.Load += new System.EventHandler(@self.Maker_Load); 
    self.FormClosing += new System.Windows.Forms.FormClosingEventHandler(@self.Maker_FormClosing); 
    self.Shown += new System.EventHandler(@self.Maker_Shown); 
    self.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(@self.Maker_MouseDoubleClick); 
    self.MouseDown += new System.Windows.Forms.MouseEventHandler(@self.Maker_MouseDown); 
    self.MouseMove += new System.Windows.Forms.MouseEventHandler(@self.Maker_MouseMove); 
    self.MouseUp += new System.Windows.Forms.MouseEventHandler(@self.Maker_MouseUp); 
    self.Paint += new System.Windows.Forms.PaintEventHandler(@self.Maker_Paint); 
    self.ObjectPopup.ResumeLayout(false); 
    self.ResumeLayout(false); 

내가 뭘 잘못하고 있니? 내 프로그램의 다른 부분에 mousemove 이벤트가 있기 때문에이 문제에 대해 좌절감을 느끼지 않도록 도와주세요. 그들은 잘 작동합니다. 이 perticular mousemove 이벤트가 왜 작동하는지 알 수는 없습니다.

+0

뭘 MouseMove 이벤트 뜻은 불 안된다? MouseDown 이벤트 처리기가 MouseMove 처리기를 제거합니까? – rossisdead

+0

@rossisdead, 마우스 포인터를 움직이지 않고 마우스 왼쪽 버튼을 클릭하는 것만으로도 트리거 또는 발사가 예상되는 유일한 이벤트는 MouseDown뿐 아니라 mousemove뿐입니다. – ThN

+1

의도적으로 설계된 것입니다. MouseDown은 마우스를 캡처하고, MouseUp은 마우스를 릴리스합니다. Windows에서는 캡처가 끝난 후 마우스가있는 위치를 윈도우가 알고 있는지 확인하여 추가 MouseMove 메시지를 생성합니다. 이것은 결코 문제가되어서는 안되며, 나머지 코드가 왜 그럴 수 있는지를 알 수는 없습니다. –

답변

7

나는 그 이유를 잊어 버렸다.

그러나 주위에 가능한 작업

:

Point _LastPoint = Point.Empty; 

private void Form1_MouseMove(object sender, MouseEventArgs e) { 
    if (_LastPoint != e.Location) { 
    _LastPoint = e.Location; 
    // run MouseMove code: 
    } 
} 
+4

마우스 캡처가 해제 되었기 때문에 발생합니다. –