Behavior.OnMouseDoubleClick(Glyph, MouseButtons, Point) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Dipanggil ketika pesan klik ganda memasuki jendela pelamar BehaviorService.
public:
virtual bool OnMouseDoubleClick(System::Windows::Forms::Design::Behavior::Glyph ^ g, System::Windows::Forms::MouseButtons button, System::Drawing::Point mouseLoc);
public virtual bool OnMouseDoubleClick (System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc);
public virtual bool OnMouseDoubleClick (System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc);
abstract member OnMouseDoubleClick : System.Windows.Forms.Design.Behavior.Glyph * System.Windows.Forms.MouseButtons * System.Drawing.Point -> bool
override this.OnMouseDoubleClick : System.Windows.Forms.Design.Behavior.Glyph * System.Windows.Forms.MouseButtons * System.Drawing.Point -> bool
Public Overridable Function OnMouseDoubleClick (g As Glyph, button As MouseButtons, mouseLoc As Point) As Boolean
Parameter
- button
- MouseButtons
Nilai MouseButtons yang menunjukkan tombol mana yang diklik.
- mouseLoc
- Point
Lokasi di mana klik terjadi.
Mengembalikan
true
jika pesan ditangani; jika tidak, false
.
Contoh
Contoh kode berikut menunjukkan cara menangani pesan klik ganda. Untuk daftar kode lengkap, lihat Cara: Memperluas Tampilan dan Perilaku Kontrol dalam Mode Desain.
// When you double-click on an AnchorGlyph, the value of
// the control's Anchor property is toggled.
//
// Note that the value of the Anchor property is not set
// by direct assignment. Instead, the
// PropertyDescriptor.SetValue method is used. This
// enables notification of the design environment, so
// related events can be raised, for example, the
// IComponentChangeService.ComponentChanged event.
public override bool OnMouseDoubleClick(
Glyph g,
MouseButtons button,
Point mouseLoc)
{
base.OnMouseDoubleClick(g, button, mouseLoc);
if (button == MouseButtons.Left)
{
AnchorGlyph ag = g as AnchorGlyph;
PropertyDescriptor pdAnchor =
TypeDescriptor.GetProperties(ag.relatedControl)["Anchor"];
if (ag.IsEnabled)
{
// The glyph is enabled.
// Clear the AnchorStyle flag to disable the Glyph.
pdAnchor.SetValue(
ag.relatedControl,
ag.relatedControl.Anchor ^ ag.anchorStyle );
}
else
{
// The glyph is disabled.
// Set the AnchorStyle flag to enable the Glyph.
pdAnchor.SetValue(
ag.relatedControl,
ag.relatedControl.Anchor | ag.anchorStyle);
}
}
return true;
}
' When you double-click on an AnchorGlyph, the value of
' the control's Anchor property is toggled.
'
' Note that the value of the Anchor property is not set
' by direct assignment. Instead, the
' PropertyDescriptor.SetValue method is used. This
' enables notification of the design environment, so
' related events can be raised, for example, the
' IComponentChangeService.ComponentChanged event.
Public Overrides Function OnMouseDoubleClick( _
ByVal g As Glyph, _
ByVal button As MouseButtons, _
ByVal mouseLoc As Point) As Boolean
MyBase.OnMouseDoubleClick(g, button, mouseLoc)
If button = MouseButtons.Left Then
Dim ag As AnchorGlyph = g
Dim pdAnchor As PropertyDescriptor = _
TypeDescriptor.GetProperties(ag.relatedControl)("Anchor")
If ag.IsEnabled Then
' The glyph is enabled.
' Clear the AnchorStyle flag to disable the Glyph.
pdAnchor.SetValue(ag.relatedControl, _
ag.relatedControl.Anchor Xor ag.anchorStyle)
Else
' The glyph is disabled.
' Set the AnchorStyle flag to enable the Glyph.
pdAnchor.SetValue(ag.relatedControl, _
ag.relatedControl.Anchor Or ag.anchorStyle)
End If
End If
Return True
End Function
Keterangan
Metode OnMouseDoubleClick ini dipanggil ketika pesan klik ganda memasuki WndProc
jendela dari pelamar BehaviorService. Pesan pertama kali diteruskan di sini, ke paling Behavior atas dalam tumpukan perilaku. Mengembalikan true
dari metode ini menandakan bahwa pesan ditangani oleh Behavior dan tidak boleh terus diproses. Dari sini, pesan dikirim ke perilaku yang sesuai.
Berlaku untuk
Lihat juga
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk