Collapse drop down in combobox from the program? (SOLVED)

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Collapse drop down in combobox from the program? (SOLVED)

Post by ic2 »

I use a subclassed Combobox which auto drops down using the following code:

METHOD FocusChange( oEvent ) CLASS Ic2ComboBox
IF lGotFocus // Drop down automatically each time control receives focus
PostMessage( SELF:Handle(), CB_SHOWDROPDOWN, 1, 0L )
ENDIF

Problem is when I assign a value to the combobox manually it also drops down where it shouldn't. I thought to counteract that as follows:

SELF:oDCMyComboBox:VALUE:="Some value present in the elements of the combobox"
SendMessage(SELF:oDCMyComboBox:Handle(), CB_SHOWDROPDOWN,0, 0)
but it does not collapse and stays dropped down.

How can I achieve that?

Dick
User avatar
TimothyS
Posts: 62
Joined: Thu Dec 15, 2016 3:39 pm
Location: Australia

Collapse drop down in combobox from the program?

Post by TimothyS »

Hi Dick,

What about:

EXPORT lDrop := TRUE as LOGIC

METHOD FocusChange( oEvent ) CLASS Ic2ComboBox
IF lGotFocus .and. SELF:lDrop // Drop down automatically each time control receives focus
PostMessage( SELF:Handle(), CB_SHOWDROPDOWN, 1, 0L )
ENDIF
SELF:lDrop := TRUE

METHOD Set_Value( uNewValue as usual)
self:value := uNewValue
self:lDrop := FALSE

RETURN NIL

Then assign as per below:

SELF:oDCMyComboBox:Set_Value( "Some value present in the elements of the combobox")

Haven't tested this, but might help.

Regards,
Tim
FFF
Posts: 1581
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Collapse drop down in combobox from the program?

Post by FFF »

Timothy Shea wrote:

Code: Select all

METHOD Set_Value( uNewValue as usual)
self:value := uNewValue 
self:lDrop := FALSE

RETURN NIL
Might be better to swap:
self:lDrop := FALSE
self:value := uNewValue
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Collapse drop down in combobox from the program?

Post by ic2 »

Hello Thomoty, Karl,

Thanks for the reply. This is one of those situations where it's hard to understand what the computer is doing. I tried something like this already and refined it with your remarks. What happened?

// Set the lDropDown variable here
SELF:oDCMyComboBox:VALUE:="Some value"
- Despite the above settings, _Debout shows lDropDown is false in FocusChange!
- The FocusChange does NOT seem to be called directly after assigning a value. I put a few statements with waiting time in it to see what happens
- Then some totally unrelated code is executed
- AFTER THAT the FocusChange is executed, with lDropDown false, so still dropping down the combobox.

Solved

I did solve it however:
PostMessage( SELF:oDCMyComboBox:Handle(), CB_SHOWDROPDOWN, 0, 0L )

Contrary to SendMessage this statement actively lets the combobox collapse. It now drops down and directly collapses at the right time, where the statement is exectuted.

Dick
Post Reply