Declare in a ComboBox

I want to show the List Box of a Combo Box by code.

Using this declare it shows the list box but it immediately hides it again.
What am I doing wrong?
Thanks in advance.

Soft Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As UInt32, ByVal wParam As Integer, lParam As Integer) As Integer

Const CB_SHOWDROPDOWN  = &H14F
Call SendMessage(Me.Handle, CB_SHOWDROPDOWN, 1, 0)

Hello Professor,

I slightly changed the SendMessage Declare and created the following YouTube video to show the working Listbox. YouTube Video Showing Listbox of ComboBox with Declare

LBofCBScreenGrab

Here is a link to the working project: Listbox of ComboBox

Code for the example is:

Does this example work on your machine?

Warm regards.

1 Like

Thanks a lot Eugene,

My code was Ok, and no, unfortunately your code did not work as I had it in my machine.
But thanks to your example I noticed that the problem was where I put my code.
I wanted to show the ListBox when somebody clicked in the ComoboBox rectangle, not only on the down arrow.
And I decided to put this code on the MouseDown event. But when I changed it to MouseUp event everything has worked.
So, thank you very much

1 Like