[SOLVED] Opening a Combo/DropDown when GetFocus

Author: gianni.sandigliano@unifacesolutions.com (gianni)

Hi Unifacers, I am trying to reuse the same technique already described from D.Iseli (thanks Daniel, it works!) in this sample: https://unifaceinfo.com/forum/uniface9/howcanipositionthecursorwithinaneditbox/ to automatically open a comboBox or a dropDownList when end user is getting focus on it. The message to be passed to the widget should be: CB_SHOWDROPDOWN = 335 ; 0x014F and the related ASYNC instruction is: activate "USER32".SendMessage(lngHWnd, <CB_SHOWDROPDOWN>, 1, 0) It seems everything is executed but the result is not as expected...nothing happen! :-( Can anyone help me to understand why it should not work with ComboBox or DropDownList as of 9.7.04 ? Thanks! Gianni


  1. Hi Gianni, I've created a small sample that is using the USER32 function keybd_event (see the Community Sample Automatically open Drop-Down List). The mentioned function can synthesize a keystroke (in the sample form it's the DOWN ARROW key). Hope this helps. Daniel

    Author: diseli (daniel.iseli@uniface.com)
  2. Thanks Daniel, your solution is working either with DropDown and Combo! In the mean time I've made some further analysis on possible reasons my solution did not work. It should work when: An application sends a CB_SHOWDROPDOWN message to show or hide the list box of a combo box that has the CBS_DROPDOWN or CBS_DROPDOWNLIST style. but: The message has no effect on a combo box created with the CBS_SIMPLE style. My conclusion is: Uniface is using the simple style. Thanks again for your help. This thread could be marked as SOLVED. Gianni

    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  3. Thanks Gianni. The combo box is actually using the CBS_DROPDOWN style. When I send the message CB_SHOWDROPDOWN to the drop-down list or combo box then I can see that the list part is opened, but then it's immediately closed again. I (so far) could not find a way to prevent this from happening. Using keybd_event seems to be a better choice here. Daniel

    Author: diseli (daniel.iseli@uniface.com)