Jump to content

GUIComboBox and Font


Recommended Posts

Hi all,

I'm currently working on a program using GUIComboBox.au3 (Beta). This UDF is amazing!

I would like to change the default font used for a ComboBox.

I tried GuiCtrlSetFont, but it doesn't have any effect (not too surprising).

Having done some research into the GUIComboBox.au3 UDF file, I suspect that I should use:

_WinAPI_SetFont ($hComboBox, $hFont)

But I don't know how to get a valid font handle ($hFont) to, let's say, use "Franklin Gothic Medium Cond" font with my ComboBox (or any other font installed on my PC).

I am neither familiar with WinAPI, nor with MSDN site, and my research there could not give me the solution...

By the way, I am not only interrested in getting an answer to my problem, but also in getting tips on how to do proper research on MSDN site (without getting hundreds of replies where I loose myself!)

Thanks in advance for any help.

Regards.

Link to comment
Share on other sites

Um, GuiCtrlSetFont() works fine, provided that the combobox is created with GUICtrlCreateCombo(), so I assume this is not the case for you...

To get font handle to use with _WinAPI_SetFont(), you have to create the font. For this the beta has _WinAPI_CreateFontIndirect()

Here's some shoddy wrapper for it

Func FontCreate($sName, $iSize, $iWeight=400)
    $sName = StringLeft($sName, 31)
;~  Local Const $tagLOGFONT = "int Height;int Width;int Escapement;int Orientation;int Weight;byte Italic;byte Underline;" & _
;~      "byte Strikeout;byte CharSet;byte OutPrecision;byte ClipPrecision;byte Quality;byte PitchAndFamily;char FaceName[32]"
    $tLOGFONT = DllStructCreate($tagLOGFONT)
    DllStructSetData($tLOGFONT, "Height", $iSize)
    DllStructSetData($tLOGFONT, "Width", 0)
    DllStructSetData($tLOGFONT, "Escapement", 0)
    DllStructSetData($tLOGFONT, "Orientation", 0)
    DllStructSetData($tLOGFONT, "Weight", $iWeight)
    DllStructSetData($tLOGFONT, "Italic", 0)
    DllStructSetData($tLOGFONT, "Underline", 0)
    DllStructSetData($tLOGFONT, "Strikeout", 0)
    DllStructSetData($tLOGFONT, "CharSet", 1)
    DllStructSetData($tLOGFONT, "OutPrecision", 0)
    DllStructSetData($tLOGFONT, "ClipPrecision", 0)
    DllStructSetData($tLOGFONT, "Quality", 0)
    DllStructSetData($tLOGFONT, "PitchAndFamily", 0)
    DllStructSetData($tLOGFONT, "FaceName", $sName)
    Return _WinAPI_CreateFontIndirect($tLOGFONT)
    
EndFunc

"be smart, drink your wine"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...