Font - ComboBox
-
ich habe mir schon 2 beispiele von codeguru angeschaut (HotFontComfo und FasterFontCombo). die habe ich beide erfolgreich in mein programm eingebunden. aber eines stört mich bei beiden:
beide comboboxen sind fett (die sind ungefähr 22 pixel hoch). meine anderen dialogfeld controls haben allerdings nur eine höhe von 18 pixeln oder ähnlich.
jetzt will ich natürlich die combobox so groß haben wie meine anderen controls.habe schon versucht während der laufzeit des programms die größe mit SetWindowPos() zu ändern, aber hat nicht geklappt.
jetzt meine frage: kennt jemand eine lösung wie ich die höhe verändern kann oder hat einer nen fetzen quellcode dazu ??
-
Du musst dir eine komplett eigene Combobox-Klasse schreiben. Das Windows-Combobox-Control hat eine statische Höhe. Da kann man afaik nichts dran ändern.
-
hmm, das ist ja nicht so toll.
aber ok, dann habe ich jetzt eine andere frage :D, habe es auch schon so versucht:
ich habe das schriftverzeichnis von windows ausgelesen und alle *.ttf -files in die combobox geladen. jetzt war nur das problem das die dateinamen der einzelnen schrift-typen erscheinen. aber wie kriegt man denn den schriftnamen aus den entsprechenden dateien ausgelesen ??
(wenn man mit dem explorer in das schriftverzeichniss geht, dann stehen da ja auch schon die schriftnamen und die dateinamen)
-
weiß echt keiner weiter ?? ich verzweifle

-
weiß echt keiner weiter ?? ich verzweifle

-
Nur so nebenbei...: mit CComboBox::SetItemHeight kann man die Höhe ändern.
-
es funktioniert, danke
-
Hi,
mir ist letzthin im Buch von Prosise "Programming Windows with MFC" ein Beispiel in die Hände gefallen. Das Zauberwort dürfte "::EnumFontFamilies" sein...
Beispiel zum Füllen einer Listbox:
void CMainWindow::FillListBox () { m_wndListBox.ResetContent (); CClientDC dc (this); ::EnumFontFamilies ((HDC) dc, NULL, (FONTENUMPROC) EnumFontFamProc, (LPARAM) this); }Zitat aus der Beschreibung im Buch:
Font Enumerations and Callback Functions
The job of filling the list box with font names falls to CMainWindow::FillListBox. FillListBox is called by OnCreate to initialize the list box when the program is started. It is also called by OnCheckBoxClicked to reinitialize the list box when the Show TrueType Fonts Only check box is clicked. FillListBox first clears the list box by calling CListBox::ResetContent. It then enumerates all the fonts installed in the system and adds the corresponding typeface names to the list box.
FillListBox begins the enumeration process by constructing a device context object named dc, using the CDC class's HDC operator to extract a device context handle, and passing that handle to the ::EnumFontFamilies function:
CClientDC dc (this);
::EnumFontFamilies ((HDC) dc, NULL, (FONTENUMPROC) EnumFontFamProc,
(LPARAM) this);The NULL second parameter tells ::EnumFontFamilies to enumerate all installed fonts. The next parameter is the address of a callback function. A callback function is a function in your application that Windows calls back with information you requested. For each font that ::EnumFontFamilies enumerates, Windows calls your callback function one time. An ::EnumFontFamilies callback function must be prototyped like this:
int CALLBACK EnumFontFamProc (ENUMLOGFONT* lpelf,
NEWTEXTMETRIC* lpntm, int nFontType, LPARAM lParam)Ich habe das Beispiel aus dem Buch getestet, es scheint zu funktionieren. Ob es auch das tut, was Du willst, kann ich allerdings nicht garantieren...
Gruss
yeti
-
ja, funktioniert auch super
danke