Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Determine if user is editing event
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Determine if user is editing event

 Post Reply Post Reply
Author
Message
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Topic: Determine if user is editing event
    Posted: 18 January 2008 at 4:09pm
Is there a way to determine if a user is editing an event in-place?  (e.g. an IsEditing or EditHwnd property?)

Thanks.
Back to Top
wlcabral View Drop Down
Groupie
Groupie
Avatar

Joined: 25 April 2007
Location: Brazil
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote wlcabral Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2008 at 12:48pm
In beforeEditOperation event you need to check opParams.operation :
 

if opParams.operation = xtpCalendarEO_InPlaceCreateEvent  then you are editing the event. 

 
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2008 at 6:31pm
Thanks for the help on the other 2 questions, I was able to get the results I required.

Unfortunately, the BeforeEditOperation event isn't where I need to test for the InPlace edit window, I need to know if the edit window is visible during the KeyDown event. What I am trying to do is automatically bring up a detailed event window when the user presses return, but not if the edit window is visible (since return in this case should complete the edit operation).

If anyone from Codejock is reading, the following events and properties would be useful:

AfterEditOperation event (fired after the user finishes inplace editing in particular)
EditHwnd property or InPlaceEditVisible property (to determine at any time if the inplace editor is visible)

Thanks.
Back to Top
wlcabral View Drop Down
Groupie
Groupie
Avatar

Joined: 25 April 2007
Location: Brazil
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote wlcabral Quote  Post ReplyReply Direct Link To This Post Posted: 20 January 2008 at 1:10pm

If you set a flag before start editing :

if opParams.operation = xtpCalendarEO_InPlaceCreateEvent 

                I_was_editing = True

endif

and check for this flag in keyDow event :

if keycode = ENTER

                if I_was_editing = True

                                I_was_editing = False

                                ‘call any code

                endif

endif

wlcabral
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 20 January 2008 at 3:39pm
Hi wlcabral, thanks again for your help. Here is what I have had to do to allow me to show a special event modification form when the user hits return while not currently editing an event:

'-------------------------------------------------------------------------------------
Private mlngEditing As Boolean

Private Sub CalendarControl_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
    Case vbKeyReturn
        If Not mblnEditing Then
            ' User is not using in-place editor
            If Me.CalendarControl.ActiveView.GetSelectedEvents.Count = 1 Then
                ' Only one event is selected, so modify it
                ModifyEvent Me.CalendarControl.ActiveView.GetSelectedEvents.ViewEvent(0).Event
            End If
        Else
            ' User hit return, so editing is finished (even if no change to the event was made)
            mblnEditing = False
        End If
    Case vbKeyEscape
        ' User cancelled editing, so clear the in-place editor flag
        mblnEditing = False
    End Select
End Sub

Private Sub CalendarControl_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim objHit As CalendarHitTestInfo

    Set objHit = Me.CalendarControl.ActiveView.HitTest

    Select Case objHit.HitCode
    Case Is <> xtpCalendarHitTestEventTextArea
        ' User clicked outside of the in-place editor
        ' Turn-off the inplace editor flag
        mblnEditing = False
    End Select

    Set objHit = Nothing
End Sub

Private Sub CalendarControl_BeforeEditOperation(ByVal OpParams As XtremeCalendarControl.CalendarEditOperationParameters, CancelOperation As Boolean)
    Select Case OpParams.Operation
    Case xtpCalendarEO_EditSubject_ByF2, xtpCalendarEO_EditSubject_ByTab, xtpCalendarEO_EditSubject_AfterEventResize, xtpCalendarEO_EditSubject_ByMouseClick, xtpCalendarEO_InPlaceCreateEvent
        ' User is editing an event using the in-place editor
        ' So set the in-place editor flag to True
        mblnEditing = True
    Case Else
        ' User is performing another edit action, so the in-place
        ' editor is not visible. Set the in-place editor flag to False
        mblnEditing = False
    End Select
End Sub

Private Sub CalendarControl_EventChangedEx(ByVal pEvent As XtremeCalendarControl.CalendarEvent)
    ' Turn off the in-place editing flag since the event has been changed by the user.
    ' NOTE: This event only fires if changes have been made to the event, so we still have to manually turn off the flag in cases where the user clicks off of the in-place editor, or hits the ESC key
    mblnEditing = False
End Sub
'-------------------------------------------------------------------------------------

Unfortunately, a pretty big chunk of code that also happens to run the risk of a bug if there are situations that I don't know about that can cause the in-place editor to hide.

A property to check whether the in-place editor is visible or not would be really valuable, as wold a way to be able to start/stop in-place editing via a method.
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 20 January 2008 at 4:06pm
Here's a better way if you don't mind using the API. First in a Module:

Private mlngEditHwnd As Long

Private Function EnumWindowsCallback(ByVal hwnd As Long, ByVal lParam As Long) As Long
    Dim strClass As String
    Const cstrCalendarEditClass As String = "edit" ' Class name of the in-place editor
    Const clngMaxClassName As Long = 255
   
    strClass = Space$(clngMaxClassName)
    GetClassName hwnd, strClass, Len(strClass)

    Select Case LCase$(TrimToNull(strClass))
    Case cstrCalendarEditClass
        ' Found the edit window of the CalendarControl, so it is visible/in-use
        mlngEditHwnd = hwnd
    Case Else
        ' Different class found, so keep searching
        EnumWindowsCallback = 1
    End Select
End Function

Public Function InplaceEditHwnd(pCalendarHwnd As Long) As Long
    mlngEditHwnd = 0    ' Reset the last found hWnd
    EnumChildWindows pCalendarHwnd, AddressOf EnumWindowsCallback, 0
    InplaceEditHwnd = mlngEditHwnd ' Return the new hWnd if found, or 0 if not found
End Function

Public Function InplaceEditVisible(pCalendarHwnd As Long) As Boolean
    InplaceEditVisible = CBool(InplaceEditHwnd(pCalendarHwnd))
End Function


Then in the form with the Calendar control:

Private Sub CalendarControl_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
    Case vbKeyReturn
        If Not InplaceEditVisible(Me.CalendarControl.hwnd) Then
            ' User is not editing the select event
            If CalendarControl.ActiveView.GetSelectedEvents.Count = 1 Then
                ' Only one event is selected, so show the custom editor form
                ModifyEvent CalendarControl.ActiveView.GetSelectedEvents.ViewEvent(0).Event
            End If
        End If
    End Select
End Sub
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.