DblClick on Commandbar |
Post Reply |
Author | |
jpcoffeyXXX
Groupie Joined: 16 August 2005 Location: United States Status: Offline Points: 31 |
Post Options
Thanks(0)
Posted: 03 May 2011 at 7:46pm |
I am trying to mimic the format painter in MS Word. If the user clicks the format painter button once, they can paste the format to a selection and they are done. If they DblClick the button, the button will stay down until they uncheck the button. My problem is the command bar control does not have a DblClick event. I am at my wits end in trying to come up with a solution. Can anybody suggest a solution or a work around? Thank you. Sincerely, John Coffey VB6, Service Pack 6 WindowsXP O/S Codejock 13.4, but will soon install Codejock 15.0 |
|
gibra
Senior Member Joined: 31 October 2008 Location: Italy Status: Offline Points: 288 |
Post Options
Thanks(0)
|
You can use ControlRButtonUp event
that work as Execute event.
|
|
gibra
CJ SuiteControl v: 13.x to 19.x Windows 10 64bit VS2019 - VB6.0 SP6 <a href="http://nuke.vbcorner.net/Home/tabid/36/language/en-US/Default.aspx" rel="nofollow">VS/VB 6.0 Installer v6.8 |
|
jpcoffeyXXX
Groupie Joined: 16 August 2005 Location: United States Status: Offline Points: 31 |
Post Options
Thanks(0)
|
Gibra, thank you for the suggestion. I will consider that if I do not find a more traditional solution.
After I posted the question, it occurred to me that I should have suggested a couple of hacks I was kicking around in hope that someone else had succeeded in implementing them. For example,
If anybody could help me squeeze a DblClick event out of the commandbars I would be very appreciative. Otherwise, I will have to deviate from the accepted norms (Microsoft Word) of doing things and prospective customers never like that. Thank you! Sincerely, John Coffey |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Haven't tested it too thoroughly, but this seems to work:
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
jpcoffeyXXX
Groupie Joined: 16 August 2005 Location: United States Status: Offline Points: 31 |
Post Options
Thanks(0)
|
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 |
|
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 |