Link to home
Start Free TrialLog in
Avatar of prakash_gs
prakash_gs

asked on

Displaying Drop down List in CComboBox

Hi
I have been trying to get a CComboBox with a Drop-List to show fonts. I think Ive done everything right but I still cant seem to see a full-drop down list. I get a very small list with 2 buttons for scrolling up and down and i can view only one of the items and not all.
Note that I also do FontComboBox.ShowDropDown(TRUE);

Please help !!

I created the combobox using the Resource View tab in Visual Studio.
The code in my OnInitDialog() is as show below:

BOOL ConfigDialog::OnInitDialog()
{
      //Load the fonts
      InstalledFontCollection *installedFontCollection =
            new InstalledFontCollection();

      // Get the count of FontFamily objects.
      int count = installedFontCollection->GetFamilyCount();
      cout<<"installedFontCollection :"<<count<<endl;

      FontFamily *fontFamilies ;
      FontFamily *loopFamilies ;
      fontFamilies = new FontFamily[count];

      int temp = 0;
      installedFontCollection->GetFamilies( count,fontFamilies,&temp );

      loopFamilies = fontFamilies;
      // loop and get all font family names.
      for(int j = 0; j < count; ++j)
      {
            WCHAR  familyName[LF_FACESIZE];
            cout<<"FamilyName::"<<familyName<<endl;
            loopFamilies->GetFamilyName(familyName,LANG_NEUTRAL);  
            CString name(familyName);
            cout<<"Name::"<<name<<endl;
            FontComboBox.AddString(name);
            loopFamilies++;
      }
      cout<<"No of items :"<<FontComboBox.GetCount()<<endl;

      FontComboBox.ShowDropDown(TRUE);

      return TRUE;  // return TRUE  unless you set the focus to a control
}

-P
ASKER CERTIFIED SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial