4Eyes Posted September 13, 2009 Share Posted September 13, 2009 I would like to change the font of a ComboBoxEx but have had no success. The UDF uses: _WinAPI_SetFont($hCombo, _WinAPI_GetStockObject($__COMBOBOXCONSTANT_DEFAULT_GUI_FONT)) 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? Regards, 4Eyes Link to comment Share on other sites More sharing options...
smashly Posted September 13, 2009 Share Posted September 13, 2009 Hi, #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) GUISetState() ;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_BeginUpdate($hCombo) _GUICtrlComboBox_AddDir($hCombo, "", $DDL_DRIVES, False) _GUICtrlComboBox_EndUpdate($hCombo) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Dispose of the font object when finished with it _WinAPI_DeleteObject($hFont) GUIDelete() 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. Cheers Link to comment Share on other sites More sharing options...
4Eyes Posted September 13, 2009 Author Share Posted September 13, 2009 (edited) smashly, 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, 4Eyes PS 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 September 13, 2009 by 4Eyes Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now