ComboBox - supress Popup
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=13012
Printed Date: 07 October 2024 at 8:30am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: ComboBox - supress Popup
Posted By: DDTech
Subject: ComboBox - supress Popup
Date Posted: 25 December 2008 at 11:26am
I have a xtpControlComboBox member in one of my toolbars where I would like to show a form (with a date-picker) instead of the popup.
I thought the right place to look at would be ControlNotify. In this I check the incoming Control.id and if the "code" is 7 (XTP_CBN_DROPTDOWN), I set handled to .t. and expect the popup not to appear. Hovever the control is not impressed of my doing so.
Any other idea how to acomplish this?
VFP 9 SP2, WinXP SP2, XtremeCommandbars 12.1.1
Thanks for any hint
regards (and merry christmas)
Frank
|
Replies:
Posted By: DDTech
Date Posted: 27 December 2008 at 10:14am
Oleg,
any hint on that?
This is what I want to achieve.
This is what I currently do:
In an initialization procedure, after loading Designerbars, I do some size-Optimization and set the Combo's Dropdown to a width of 1 px. and the ItemCount to 0. This does not make the dropdown not appear but it's only a few pix in size so that the user does not realize.
loCBO = loToolbar.FindControl(5, ID_SCHEDMAIN_DATE)
*-- resize the combo's width to the space needed for *-- display of current date + room for the dropdown- *-- arrow + some "air" loCBO.Width = ; txtWidth(dtoc(date()), this.Text1.FontName, this.Text1.FontSize, "B")*; fontMetric(6, this.Text1.FontName, this.Text1.FontSize, "B")+; + sysMetric(5) + lnWidthAdd *-- try to hide as much of the combo as possible loCBO.DropdownWidth = 1 loCBO.DropDownItemCount = 0
I then listen to the ControlNotify-event and show the calendar as soon as the user clicks on the down-arrow. The actual ShowCalendar() procedure is separated from the event by calling it via timer with a short delay. This way we can leave the event immediately, which is crucial to avoid "letters to Bill" as I call them (a GPF is almost a sure thing when an error occurs within VFP-Code while still being in some kind of ActiveX-event). A delay of 20ms or even less is safe enough and almost not to realize,
PROCEDURE ControlNotify(Control as Object, Code as Long, NotifyData as variant, Handled as Variant) if Control.ID = ID_SCHEDMAIN_DATE if Code=7 && Dropdownarrow clicked and popup is about to open *-- "handled" is coming in via reference. *-- setting it to .T. should tell the toolbar *-- "I'll take care of it. Unfortunately it *-- does not seem to care. But we're good *-- good guys and do behave. Handled = .t. *-- this causes an immediate GPF: *oForm = Create("FORM") *oForm.halfHeightcaption = .T. *oForm.Show *--> letter to Bill
*-- ... so call the ShowCalender via timer and *-- let the event return immediately thisform.tmrAction.doCommand("thisform.ShowCalendar("+ trans(ID_SCHEDMAIN_DATE) +")") endif endif ENDPROC
ShowCalendar opens and positions the form below the control
PROCEDURE ShowCalendar(tnControlID as integer) as boolean tnControlID = iif(vartype(tnControlID) = "N", tnItemID, 1101)
public oCal
local a,b,c,d,a1,b1,c1,d1, loTB, loCBO, loCB
store 0 to a,b,c,d, a1,b1,c1,d1
loTB = this.TB loCBO = this.TB.FindControl(5, tnControlID)
if ! isNull(loCBO) && !!!! More generic - Test only !!! loCB = loTB.ActiveMenubar.Commandbars(3)
*-- get rectangles for control and commandbar loCB.GetWindowRect(@a,@b,@c,@d) loCBO.GetRect(@a1,@b1,@c1,@d1)
*-- frmDatePick is a class that releases itself *-- on lostfocus and binds itself to a target *-- it reports to in case a positive date-selection *-- is made oCal = newObject("frmDatePick", "SCHED_FORMS", "", ThisForm.txtDatum)
*-- move the form below the date-combo, align with the *-- right border oCal.Move(; a+c1-oCal.Width-2-_screen.left,; b-_screen.Top + d1+3)
oCal.Show endif && ! isNull(...)
ENDPROC
This works pretty well, though not the ideal solution. I'd really like to get rid of the combo's popup although the trick is almost perfect. Any recommendations gladly welcome.
Frank.
|
Posted By: Oleg
Date Posted: 05 January 2009 at 2:52am
Hi,
This code works for Visual Basic:
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Sub CommandBars_TrackingModeChanged(ByVal CommandBar As XtremeCommandBars.ICommandBar, ByVal Mode As Boolean) If (CommandBar.BarID = 100) Then DestroyWindow CommandBar.hwnd End If End Sub
Private Sub Form_Load()
CommandBars.EnableOffice2007Frame True Dim Combo As CommandBarComboBox Set Combo = CommandBars.ActiveMenuBar.Controls.Add(xtpControlComboBox, 100, "Date") Combo.DropDownListStyle = False Combo.Text = "01/01/2009"
Dim ComboDropDown As CommandBar Set ComboDropDown = CommandBars.Add("ComboDropDown", xtpBarPopup) ComboDropDown.BarID = 100
Set Combo.CommandBar = ComboDropDown
End Sub
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: DDTech
Date Posted: 06 January 2009 at 1:38pm
oleg wrote:
This code works for Visual Basic:
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Sub CommandBars_TrackingModeChanged(ByVal CommandBar As XtremeCommandBars.ICommandBar, ByVal Mode As Boolean) If (CommandBar.BarID = 100) Then DestroyWindow CommandBar.hwnd End If End Sub .... |
BANG - this directly sends VFP to hell. Same when I try to do it from within the ControlNotify.
However, the tip pointed into the right direction. Destroying the window only once seems to be enough, and when I do that directly after initializing the toolbar all further calls report a window handle of "0" and no popup appears.
So the working code now looks like this:
loCBO = loToolbar.FindControl(5, ID_SCHEDMAIN_DATE)
*-- resize the combo's width to the space needed for *-- display of current date + room for the dropdown- *-- arrow + some "air loCBO.Width = ; txtWidth(dtoc(date()), this.Text1.FontName, this.Text1.FontSize, "B")*; fontMetric(6, this.Text1.FontName, this.Text1.FontSize, "B") + sysMetric(5) + lnWidthAdd *-- DD changed on 06.01.09 *-- directly delete the combo's Commandbar-Window and *-- by that way prevent it from ever showing up. if loCBO.CommandBar.hWnd > 0 declare long DestroyWindow in USER32 as CB_DestroyWindow long hWnd CB_DestroyWindow(loCBO.CommandBar.hWnd) clear Dlls CB_DestroyWindow endif ...
This seems to work like a charm and clicking the down-arrow shows the calendar as if it ever belonged there.
|
|