Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - DblClick on Commandbar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

DblClick on Commandbar

 Post Reply Post Reply
Author
Message
jpcoffeyXXX View Drop Down
Groupie
Groupie


Joined: 16 August 2005
Location: United States
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpcoffeyXXX Quote  Post ReplyReply Direct Link To This Post Topic: DblClick on Commandbar
    Posted: 03 May 2011 at 7:46pm
Format painting for JobTabs Job Search Software.
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

Back to Top
gibra View Drop Down
Senior Member
Senior Member


Joined: 31 October 2008
Location: Italy
Status: Offline
Points: 288
Post Options Post Options   Thanks (0) Thanks(0)   Quote gibra Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 2011 at 4:29am
You can use ControlRButtonUp event
that work as Execute event.
 
Wink
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
Back to Top
jpcoffeyXXX View Drop Down
Groupie
Groupie


Joined: 16 August 2005
Location: United States
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpcoffeyXXX Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 2011 at 7:59am
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,

  • Anybody implemented a DblClick via markup on the commandbars?  Markup is permitted on the status bars and the tabs, but I am not sure if it is available on the commandbars themselves.
  • Anybody implemented a DblClick via the ExecuteOnPressInterval property?  I am sure I could fake a double click if I manipulate this property wisely.  Wink

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.  Cry

Thank you!

Sincerely,

John Coffey Smile


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

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 2011 at 9:27am
Haven't tested it too thoroughly, but this seems to work:


Option Explicit

Private Declare Function GetDoubleClickTime Lib "user32.dll" () As Long
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long

Private mo_FormatBrush As CommandBarControl

Private m_LockFormatBrush As Boolean

Private Sub CommandBars1_Execute(ByVal Control As XtremeCommandBars.ICommandBarControl)
   Dim l_Tick As Long
  
   Select Case Control.Id
   Case 100
      Me.Cls
  
      On Error Resume Next
      l_Tick = Control.Parameter
      On Error GoTo 0
     
      If GetTickCount - l_Tick <= GetDoubleClickTime Then
         Control.Checked = True
         m_LockFormatBrush = True
      Else
         m_LockFormatBrush = False
         Control.Checked = Not Control.Checked
      End If
     
     
      Control.Parameter = GetTickCount
   End Select
End Sub

Private Sub ApplyFormatBrushIfActive()
   Me.Cls
  
   If mo_FormatBrush.Checked Then
      ' Do your formatting here
      Me.Print
      Me.Print
      Me.Print
      Me.Print "Apply format " & IIf(m_LockFormatBrush, " and deactivate format brush.", " and uncheck format brush")
   End If
  
   If Not m_LockFormatBrush Then
      ' FormatBrush hasn't been double-clicked, so reset
      mo_FormatBrush.Checked = False
   End If
End Sub

Private Sub Form_Click()
   ApplyFormatBrushIfActive
End Sub

Private Sub Form_Load()
   With Me.CommandBars1.AddMenuBar("Test").Controls
      Set mo_FormatBrush = .Add(xtpControlButton, 100, "Format")
   End With
End Sub

Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
jpcoffeyXXX View Drop Down
Groupie
Groupie


Joined: 16 August 2005
Location: United States
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpcoffeyXXX Quote  Post ReplyReply Direct Link To This Post Posted: 06 May 2011 at 4:06pm
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




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.