JPBro, you nailed it. :-) The extra effort for retrieving the user's double-click interval as opposed to assuming it is 500 ms is worthy of extra kudos. This was the most logical solution. I will put my code here for anyone who cares to use this functionality. Excuse the formatting as it got out of hand.
Cheers,
John
Private Sub cbrsEditor_Execute(ByVal Control As XtremeCommandBars.ICommandBarControl)
Select Case Control.ID Case ID_CURSOR_FORMAT_PAINTER
Dim lngDoubleClickTime As Long, lngTickCount As Long, lngParm As Long
lngDoubleClickTime = GetDoubleClickTime
lngTickCount = GetTickCount
If Len(Control.Parameter) = 0 Then lngParm = 0 Else lngParm = CLng(Control.Parameter)
If (lngTickCount - lngParm) <=
lngDoubleClickTime Then
bChecked = True
Control.Checked = bChecked
m_blnMultiFormatPaint = True
Else
bChecked = Not Control.Checked
Control.Checked = bChecked
m_blnMultiFormatPaint = False
End If
If bChecked Then
If m_blnMultiFormatPaint = False Then 'Do work here. This may be time consuming in some cases, so I placed the GetTickCount at the very end to give people plenty of time for their second click. Also we need to keep in mind that if we are simulating a double-click, the first click will fire this process. We don't want the second click to fire it as well, therefore we test the m_blnMultiFormatPaint variable.
Set Me.MouseIcon = IconColl.Icons.GetImage(ID_CURSOR_FORMAT_PAINTER,
32).CreatePicture(xtpImageNormal)
Me.MousePointer = vbCustom
'Give users with slow reflexes plenty of
time for their second click
Control.Parameter = GetTickCount
Else
Control.Parameter = 0'A breakpoint placed here should catch
every dblclick event. I zero out the parm because a double-click is relative.
End If
Else
'Turn off multi-paste
m_blnMultiFormatPaint = False
'Reset the mousepointer
Me.MousePointer = vbDefault
Set Me.MouseIcon = Nothing
End If
End Select
Private Sub txBody_MouseUp(Button
As Integer, Shift As Integer, x As Single, y As Single)
Dim cTX As cTextControl, tx As TXTextControl,
ctrl As
CommandBarControl
Set tx = txBody
If Button = vbLeftButton Then
If tx.SelLength > 0 Then
If Not m_ObjectWithFormatting Is Nothing Then
FormatPainterApply TXTextControl, m_ObjectWithFormatting
If m_blnMultiFormatPaint = False Then
'If apply once then . . .
'Reset the mousepointer
Me.MousePointer = vbDefault ' tell vb to use
this
Set Me.MouseIcon = Nothing
'Uncheck the control
Set ctrl = CommandBars.FindControl(xtpControlError, ID_EDIT_FORMAT_PAINTER, , True)
If Not ctrl Is Nothing Then ctrl.Checked = False
Set ctrl = Nothing
'Clear the formatting
Set m_ObjectWithFormatting = Nothing
End If
End If
End If
End If
End Sub
|