Jump to content
Sign in to follow this  

How to change font of ComboBoxEx?

Recommended Posts


I would like to change the font of a ComboBoxEx but have had no success.

The UDF uses:


I tried changing (a renamed copy of this function ... sorry, don't mean to step on authors toes) this to:

_WinAPI_SetFont($hCombo, _WinAPI_GetStockObject($DEFAULT_GUI_FONT))

which I thought would work considering I've previously used GUISetFont(10, 400, 0, "Comic Sans MS")

I've also tried _WinAPI_SetFont($hCombo, _WinAPI_GetStockObject($DEFAULT_GUI_FONT)) after the GUI build code, again with no success.

Can anybody give me a pointer to what I'm doing wrong please?



Share this post

Link to post
Share on other sites


#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>
#include <Constants.au3>
#include <FontConstants.au3>

Global $hGUI, $hCombo, $hFont

$hGUI = GUICreate("(UDF) ComboBox Create", 400, 296)
$hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 396, 296)

;Create a handle to a font object
$hFont = _WinAPI_CreateFont(20, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Comic Sans MS')

;Pass the handle to _WinAPI_SetFont
_WinAPI_SetFont($hCombo,  $hFont)

_GUICtrlComboBox_AddDir($hCombo, "", $DDL_DRIVES, False)


; Dispose of the font object when finished with it


I'm aware you said ComboBoxEx() , but atm on my win 7 x64 ComboBoxEx() examples from help file hard crash AutoIt... doh

But I'd imagine the above method should still work with ComboBoxEx() as well.


Share this post

Link to post
Share on other sites


I saw the reference to using a font handle somewhere in the examples but I thought using $DEFAULT_GUI_FONT should work. Oh well, thanks for the help.

Yeah, I started with a ComboBox, but had to resort to a ComboBoxEx to be able to determine when the edit box had changed.

Your code works fine on my 32 bit XP box.

Thanks muchly,



Excellent! Setting the font height parameter to 18 is equivalent to a point size of 10. Adding:

_GUICtrlComboBoxEx_SetItemHeight($hCombo, 0, 18)

sets the line spacing correctly, otherwise it's too high.

Looks like I'll get what I wanted after all! Me sooooo happy.

Edited by 4Eyes

Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.