Announcement

Collapse
No announcement yet.

Combobox dropdown list won't show

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Combobox dropdown list won't show

    I use PB/WIN 9.01 in combination with with PB Forms 1.51 and have a problem with the DDT CONTROL ADD COMBOBOX command.

    The combobox won't show a listbox when clicking on the arrow button but instead (after a a little flicker on the area where the list box should appear) a black horizontal bar is drawn under the combo box control.

    I have found a workaround which could point to the source of the problem: When I explicitly set the vertical size of the dropdown listbox with the MOVEWINDOW API function, the list box is drawn as expected (see sample code).

    Is this a bug or am I overlooking something?

    Thank you for your help!

    Heinz Salomon


    Code:
    #PBFORMS CREATED V1.51
    #COMPILE EXE
    #DIM ALL
    
    #PBFORMS BEGIN INCLUDES 
    #IF NOT %DEF(%WINAPI)
      #INCLUDE "WIN32API.INC"
    #ENDIF
    #PBFORMS END INCLUDES
    #PBFORMS BEGIN CONSTANTS 
      %IDD_DIALOG1   =  101
      %IDC_COMBOBOX1 = 1002
      %IDC_BUTTON1   = 1003
    #PBFORMS END CONSTANTS
    
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE FUNCTION SampleComboBox(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL _
        lCount AS LONG) AS LONG
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
      
      GLOBAL hDlg AS DWORD
    
      FUNCTION PBMAIN()
        ShowDIALOG1 %HWND_DESKTOP
      END FUNCTION
    
      CALLBACK FUNCTION ShowDIALOG1Proc()
        LOCAL x, y, xx, yy, hCombo AS DWORD
        SELECT CASE AS LONG CBMSG
          CASE %WM_COMMAND
              SELECT CASE AS LONG CBCTL
                CASE %IDC_BUTTON1
                  IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                    CONTROL GET LOC  hDlg, %IDC_COMBOBOX1 TO x, y
                    CONTROL GET SIZE hDlg, %IDC_COMBOBOX1 TO xx, yy
                    DIALOG UNITS hDlg, x, y TO PIXELS x, y
                    DIALOG UNITS hDlg, xx, yy TO PIXELS xx, yy
                    CONTROL HANDLE hDlg, %IDC_COMBOBOX1 TO hCombo
                    MOVEWINDOW hCombo, x, y, xx, 300, %TRUE
                  END IF
              END SELECT
          END SELECT
      END FUNCTION
    
      FUNCTION SampleComboBox(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL lCount _
        AS LONG) AS LONG
        LOCAL i AS LONG
        CONTROL SEND hDlg, lID, %CB_SETEXTENDEDUI, %TRUE, 0
        FOR i = 1 TO lCount
          COMBOBOX ADD hDlg, lID, USING$("Test Item #", i)
        NEXT i
      END FUNCTION
    
      FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
          LOCAL lRslt AS LONG
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
        'LOCAL hDlg  AS DWORD
        DIALOG NEW hParent, "'Invisible' Dropdown ListBox Problem", 70, 70, 175, _
            48, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR _
            %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
            %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
            OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD COMBOBOX, hDlg, %IDC_COMBOBOX1, , 5, 5, 165, 15
        CONTROL ADD BUTTON,   hDlg, %IDC_BUTTON1, "Set Size of Dropdown ListBox " + _
            "to 300 px", 5, 25, 165, 15
    #PBFORMS END DIALOG
        SampleComboBox hDlg, %IDC_COMBOBOX1, 30
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
        FUNCTION = lRslt
      END FUNCTION

  • #2
    A common mistake, the height of the combo control on creation is actually the list height. Change the height to 150 (or more) and the list will appear. The actual height of the non-list part of the control is fixed by Windows.

    Code:
    CONTROL ADD COMBOBOX, hDlg, %IDC_COMBOBOX1, , 5, 5, 165, [b]150[/b]
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Issue solved!

      Coming from the VB world I obviously made the wrong assumptions:
      In the VB IDE you can't set neither the combobox height nor the dropdown listbox height. Additionally, the list box part is completely hidden from the form designer's view (no drag points).

      Thank you for your lightning fast response!

      Heinz Salomon

      Comment

      Working...
      X