Determine if user is editing event |
Post Reply |
Author | |
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1354 |
Post Options
Thanks(0)
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. |
|
wlcabral
Groupie Joined: 25 April 2007 Location: Brazil Status: Offline Points: 72 |
Post Options
Thanks(0)
|
In beforeEditOperation event you need to check opParams.operation :
if opParams.operation = xtpCalendarEO_InPlaceCreateEvent then you are editing the event. |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1354 |
Post Options
Thanks(0)
|
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. |
|
wlcabral
Groupie Joined: 25 April 2007 Location: Brazil Status: Offline Points: 72 |
Post Options
Thanks(0)
|
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
|
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1354 |
Post Options
Thanks(0)
|
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. |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1354 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |