Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Add DateTimePicker to a RibbonBar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Add DateTimePicker to a RibbonBar

 Post Reply Post Reply
Author
Message
cmm2006 View Drop Down
Senior Member
Senior Member


Joined: 26 September 2006
Status: Offline
Points: 118
Post Options Post Options   Thanks (0) Thanks(0)   Quote cmm2006 Quote  Post ReplyReply Direct Link To This Post Topic: Add DateTimePicker to a RibbonBar
    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
Back to Top
JantjeKeizer View Drop Down
Groupie
Groupie


Joined: 12 February 2008
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote JantjeKeizer Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
markp.uk View Drop Down
Groupie
Groupie
Avatar

Joined: 23 August 2006
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote markp.uk Quote  Post ReplyReply Direct Link To This Post 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
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.141 seconds.