Double Click notification

Technical discussions
Post Reply
Claude
Posts: 23
Joined: Thu Jan 05, 2017 3:58 am

Double Click notification

Post by Claude »

Good day,

Is there a way to detect a Double Click on the KCad control ? I have been searching for this and cannot find anything close.

Thanks.

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Re: Double Click notification

Post by nickz »

Hi Claude
We do not do anything with it inside.
See the attachment. It is an example of handling it in DIView sample. See the MessageFilter.vb and how it is added to the app in DIViewForm.New()
Double click in the case toggles visibility of the first object
We will add this to the next update

Code: Select all

Imports System.Security.Permissions
Imports KernCADnet

Public Class MessageFilter
    Implements IMessageFilter
    Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
        ' if message is double-click
        If m.Msg = WM_LBUTTONDBLCLK Then
            ' obtain cursor pos
            Dim x As Integer = (m.LParam.ToInt32() And &HFFFF)
            Dim y As Integer = (m.LParam.ToInt32() And &HFFFF0000) >> 16

            ' obtain control under ther cursor
            Dim control As Control = form.GetChildAtPoint(New Point(x, y))

            If TypeOf control Is AxKernCADnet.AxKernCADnet Then
                Dim kernCAD As AxKernCADnet.AxKernCADnet = form.AxKernCADnet1
                Dim iModel As IModel_DG = kernCAD.GetModel()
                Dim iEntity As IEntity_DG = iModel.GetEntityAt(0)

                Dim bVisible As Boolean = iEntity.IsVisible()
                iEntity.SetVisible(Not bVisible)
                kernCAD.UpdateView()
                Return True
            End If
        End If

        Return False
    End Function

    Public Sub New(formToFilter As DIViewForm)
        form = formToFilter
    End Sub

    Private WM_LBUTTONDBLCLK As Integer = &H203
    Private form As DIViewForm
End Class

Code: Select all

Public Sub New()
        MyBase.New()
        InitializeComponent()
        Application.AddMessageFilter(New MessageFilter(Me))
    End Sub
Attachments
DIView.zip
(19.83 KiB) Downloaded 488 times

Post Reply