Print Page | Close Window

Add DateTimePicker to a RibbonBar

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=14773
Printed Date: 22 November 2024 at 11:29am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Add DateTimePicker to a RibbonBar
Posted By: cmm2006
Subject: Add DateTimePicker to a RibbonBar
Date Posted: 19 July 2009 at 3:42pm
Hi,
I was just wondering in how to add a custom control (DateTimePikcer) to a ribbonbar. when I tried the following code:
 
    Set ItemCustom = GroupView.Add(xtpControlCustom, ID_VIEW_BY_DATE, "By Date:", True, True)
    ItemCustom.Handle = TimePicker.hWnd

 
the DateTimePicker control is shown on the ribbonbar with no problem when I first run the application, but the caption "By Date: " is not shown, plus when I click the dropdown arrow to select the date, the DateTimePicker is moved to the default location where was first place in the design mode.
Any idea why or how to get this to work?
Thank you


-------------
Language: Visual Basic 6 SP6
OS: Windows XP Pro SP3
Product: Codejock Xtreme SuitePro 13.1



Replies:
Posted By: JantjeKeizer
Date Posted: 19 July 2009 at 7:00pm
Can't test it right now, but in my experience setting the handle property of the actual control often causes problems.
Try to place it in a picturebox and give that handle.


Posted By: markp.uk
Date Posted: 15 February 2014 at 2:15pm
I had the same problem and solved it with a combo box. handle the position problem in the InitCommandsPopup event of the command bar, as below.

  Dim Combo            As CommandBarComboBox
  Dim Control            As CommandBarControl
  Dim DatePicker       As XtremeCalendarControl.DatePicker


If CommandBar.Parent.Type = xtpControlComboBox Then
      Set Combo = CommandBar.Parent
      Set Control = Combo
    
      Select Case Combo.Id
        Case ID_PREDICT_START, ID_CHART_START
          dppStart.VisualTheme = xtpCalendarThemeResource
          Set DatePicker = dppStart
          strCurrentDate = m_strPopupStartDay
        Case ID_PREDICT_END, ID_CHART_END
          dppEnd.VisualTheme = xtpCalendarThemeResource
          Set DatePicker = dppEnd
          strCurrentDate = m_strPopupEndDay
      End Select
      If Combo.Id = ID_PREDICT_START Or Combo.Id = ID_PREDICT_END Or Combo.Id = ID_CHART_START Or Combo.Id = ID_CHART_END Then
        'get the current value of the combo box
        strCurrentDate = Combo.Text
        bRestore = False
    
        If IsDate(Combo.Text) Then
          DatePicker.EnsureVisible Combo.Text
        End If
        Combo.GetRect lngLeft, lngTop, lngRight, lngBottom
        'GetPosition lngLeft, lngTop, CommandBar, Combo
        
        DatePicker.Left = lngLeft
    
        DatePicker.Top = lngTop + (lngBottom - lngTop)
        Debug.Print lngTop
        
        If DatePicker.ShowModal(1, 1) Then
    
          Dim strDate0         As String, strDate1 As String
          Dim nCount           As Long
    
          nCount = DatePicker.Selection.BlocksCount
          If nCount > 0 Then
            'Control.Refresh
            Combo.Clear
            Combo.AddItem DatePicker.Selection.Blocks(0).DateBegin
            Combo.AutoComplete = True
            Combo.Text = DatePicker.Selection.Blocks(0).DateBegin
            strDate0 = DatePicker.Selection.Blocks(0).DateBegin
            strDate1 = DatePicker.Selection.Blocks(nCount - 1).DateEnd
          Else
            Combo.Clear
            Combo.AddItem strCurrentDate
            Combo.Text = strCurrentDate
            strCurrentDate = "?-?-?"
          End If
        Else
          Combo.Clear
          Combo.AddItem strCurrentDate
          Combo.Text = strCurrentDate
          strCurrentDate = "?-?-?"
        End If  
        Combo.ListIndex = 1
        cbMain_TrackingModeChanged CommandBar, False
        SendKeys vbCrLf
      End If
    End If

works fine for me. good luck


-------------
The weekend has landed.....

Long live the weekend!!!





Product: Xtreme SuitePro

(ActiveX) version 16.3.1

Platform: Windows XP (32bit) - SP 3

Language: Visual Basic 6.0 SP6



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net