Author Topic: ModStyle with CBS_DROPDOWNLIST on a combo box doesn't work  (Read 414 times)

Quin

  • Sr. Member
  • ****
  • Posts: 299
    • View Profile
    • Quin's site
ModStyle with CBS_DROPDOWNLIST on a combo box doesn't work
« on: June 29, 2024, 10:51:59 PM »
Hi,
I have a combo box in my application that I create like so:
Code: [Select]
    EngineCombo = Bcx_Combobox("SAPI5", MainForm, 101, 110, 30, 100, 21)
    Modstyle(VoiceCombo, CBS_DROPDOWNLIST)
The combo box creates, but the edit field doesn't go away. Is there a way I can accomplish this?

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2538
    • View Profile
Re: ModStyle with CBS_DROPDOWNLIST on a combo box doesn't work
« Reply #1 on: June 29, 2024, 11:24:18 PM »
The edit field is its own Windows control with its own message loop, so no that won't work.

But this will, if your goal is to hide the edit box:

Code: [Select]
GUI "Form1", PIXELS

CONST Cmb1_Style = WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_HASSTRINGS|CBS_SORT|CBS_DROPDOWN
const ID_Cmb1 = WM_USER + 100
   

GLOBAL Form1 AS HWND
GLOBAL hCmb1 AS CONTROL


SUB FORMLOAD()
    Form1 = BCX_FORM("Form1", 0, 0, 805, 406)
    hCmb1 = BCX_COMBOBOX("", Form1, ID_Cmb1, 28, 25, 349, 21, Cmb1_Style)

    '============ HIDE EDIT CONTROL ==================

    DIM AS HWND hEdit = FindWindowEx(hCmb1, NULL, "Edit", NULL)
    IF hEdit THEN HIDE (hEdit)

    '============================================

    CENTER(Form1)
    SHOW(Form1)
END SUB



BEGIN EVENTS
END EVENTS



Quin

  • Sr. Member
  • ****
  • Posts: 299
    • View Profile
    • Quin's site
Re: ModStyle with CBS_DROPDOWNLIST on a combo box doesn't work
« Reply #2 on: June 30, 2024, 12:34:52 AM »
Kevin,
Thanks to you, did it a different way ;)

I didn't need to manually hide the edit control, I just took your Combo_Style line, removed CBS_Sort, and changed CBS_DROPDOWN to CBS_DROPDOWNLIST and it all works now :)