Sign in to follow this  
Followers 0
WeMartiansAreFriendly

_FontSelect

13 posts in this topic

#1 ·  Posted (edited)

Here is a custom Font Selection dialog

Some advantages compared to _ChooseFont()

1. Fully customizable.

2. The parameters are similar to that of GuiCtrlSetFont()

3. Better looking GUI.

Some disadvantages

1. No color selection added 2009-11-12, v0.6a

2. Larger overhead

_ChooseFont() - included with Misc.au3

Posted Image

_FontSelect() - alternative

Posted Image

Changes:

[2009-11-12, v0.6c]
Fixed - Misc typos, bugs
Changed - Returns same values (as _ChooseFont())  for colors

[2009-11-12, v0.6a]
Added - Color option
Added - Default preview text option
Added - Window x and y pos options
Changed - Window is now centered on desktop by default
Changed - Resized window to accomendate screen space
Changed - Parameter names scheme
Changed - Cancel now returns 0
Changed - Parameters support either "", -1 or default for optional values. 
Changed - Updated screenshot

Planned
* Use same paramaters as _ChooseFont() ??
* Return the same values as _ChooseFont() ??
* Replace color label with a combobox similar to _ChooseFont() ??


[first release]
Fixed: Documention header.

The Script (example is at the end)

#include-once
;#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#Include <GuiListBox.au3>
#include <GUIComboBox.au3>
#include <Misc.au3> ; needed for _ChooseColor()
#include <Color.au3> ;needed for _GetRGB() and SetRGB()

; #FUNCTION# ====================================================================================================================
; Name...........: _FontSelect
; Modified........: 2009-11-12, v0.6c
; Description ...: Adds a specified value at the end of an existing array.
; Syntax.........: _FontSelect($iSize, $iWeight, $iStyle, $sName, $iParent, $sTitle, $sText, $iX, $iY)
; Parameters ....: $iSize  - [optional] Font Size, Default is 9
;                $iWeight   - [optional] Font Weight, (default 400 = normal).
;                   |100-400 - Normal
;                   |500-600 - Bold
;                   |700-900 - Bolder
;               $iStyle    - [optional] Font Style, (default 0 = normal).
;               (Styles may be combined e.g. 2+4 = Italic and Underlined).
;                   |0 - Normal
;                   |2 - Italic
;                   |4 - Underlined
;                   |8 - Strike
;               $sName  - [optional] Font Name, (default is Arial)
;               $sColor - [optional] The color to use (default is black/0x000000)
;               $iParent   - [optional] Parent Window, (default is 0)
;               $sTitle    - [optional] Window Title (default is "" [Font Select])
;               $sText  - [optional] Preview text (default is -1 [alphabet lowercase/uppercase])
;               $iX     - [optional] X-Window position (default = -1 [center of screen])
;               $iX     - [optional] Y-Window position (default = -1 [center of screen])
; Return values .: Success:  Array in the following format:
;                   |0 - Font Size
;                   |1 - Font Weight
;                   |2 - Font Attribute
;                   |3 - Font Name
;                   |4 - Font Color (COLORREF rgbColors)
;                   |5 - Font Color (Hex BGR Color)
;                   |6 - Font Color (Hex RGB Color)
;                  Failure: -1
; Author ........: mrRevoked
; Contributors...: AlmarM
; Remarks .......:
; Related .......: _ChooseFont from misc.au3
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================
Func _FontSelect($iSize=Default,$iWeight=Default,$iStyle=Default,$sName=Default,$nColor=Default,$iParent=0,$sTitle="",$sText="",$iX=-1,$iY=-1)
    Local $nGUImode = Opt("GuiOnEventMode", 0)
    Local $hGUI, $gcFontFamily, $gcFontStyle, $gcFontSize, $gcFontWeight, $gcFontPreview, $gcFontOk, $gcFontCancel
    Local $szString, $nSelect, $i = 1, $s = ""

    If Not $iSize Or $iSize = Default Then $iSize = 9
    If Not $iWeight Or $iWeight = Default Then $iWeight = 400
    If Not $iStyle Or $iStyle = Default Then $iStyle = 0
    If Not $sName Or $sName = Default Then $sName = "Arial"
    If Not $nColor Or $nColor = Default Then $nColor = 0x000000
    If Not $sTitle Or $sTitle = Default Then $sTitle = "Font Select"
    If Not $iX Or $iX = Default Then $iX = @DesktopWidth/2-(448/2) ;center
    If Not $iY Or $iY = Default Then $iY = @DesktopHeight/2-(340/2)

    If $iSize < 0 Then $iSize = 9
    If $iWeight < 100 Or $iWeight > 900 Then $iWeight = 400

    $n = _ColorGetRGB($nColor)
    $nColor = _ColorSetRGB($n)
    $r = hex($n[0], 2)
    $g = hex($n[1], 2)
    $b = hex($n[2], 2)

    Dim $azFontOptions[7] = [$iSize, $iWeight, $iStyle, $sName, $nColor, "0x"&$b&$g&$r, "0x"&$r&$g&$b]

    $hGUI = GUICreate($sTitle, 448, 340, $iX, $iY, -1, -1, $iParent)

    GUICtrlCreateGroup("Font", 8, 8, 433, 290)

    ; Font Group
    GUICtrlCreateLabel("Family", 16, 30, 33, 17)
    $gcFontFamily = GUICtrlCreateCombo("", 16, 48, 217, 150, _
    BitOR($CBS_SIMPLE, $WS_VSCROLL, $CBS_SORT, $CBS_AUTOHSCROLL, $CBS_HASSTRINGS))
    $szString = ""
    If @OSTYPE = "WIN32_NT" Then $regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
    If @OSTYPE = "WIN32_WINDOWS" Then $regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts"
    While 1
        $s = RegEnumVal($regkey, $i)
        If @error <> 0 Then ExitLoop
        ;RegRead($regkey, $s) font filename
        $s = StringRegExpReplace($s,"\s\(.*?\)(\s*)?","")
        $szString &= $s & "|"
        $i = $i + 1
    WEnd
    GUICtrlSetData($gcFontFamily, $szString)
    $nSelect = _GUICtrlComboBox_SetCurSel($gcFontFamily, _GUICtrlComboBox_FindString($gcFontFamily, $sName))
    If $nSelect = -1 Then _GUICtrlComboBox_SetCurSel($gcFontFamily, "Arial")

    ; Size
    GUICtrlCreateLabel("Size", 240, 30, 24, 17)
    $gcFontSize = GUICtrlCreateCombo("", 240, 48, 105, 110, BitOR($CBS_SIMPLE, $WS_VSCROLL, $CBS_AUTOHSCROLL))
    $szString = ""
    For $i = 1 to 75
        $szString &= StringFormat("%01d", $i) & "|"
    Next
    GUICtrlSetData($gcFontSize, $szString)
    _GUICtrlComboBox_SetCurSel($gcFontSize, _GUICtrlComboBox_FindString($gcFontSize, $iSize))

    ; Color
    GUICtrlCreateLabel("Color", 240, 160, 24, 17)
    $gcColor = GUICtrlCreateLabel("", 240, 175, 105, 17, 0x1000)
    GUICtrlSetBkColor($gcColor, "0x"&$b&$g&$r) ; Added by AlmarM

    ; Style
    GUICtrlCreateLabel("Style", 352, 30, 27, 17)
    Local $avStyle[4][2] = [['Normal', 0], ['Italic', 2], ['Underlined', 4], ['Strike', 8]]
    $gcFontStyle = GUICtrlCreateList("", 352, 48, 80, 60, _
    BitOR($LBS_NOTIFY, $WS_VSCROLL, $LBS_MULTIPLESEL, $LBS_EXTENDEDSEL, $LBS_NOINTEGRALHEIGHT))
    $szString = ""
    For $i = 0 to UBound($avStyle)-1
        $szString &= $avStyle[$i][0] & "|"
    Next
    GUICtrlSetData($gcFontStyle, $szString)
    $nSelect = -1
    For $i = 0 to UBound($avStyle)-1
        If BitAND($iStyle, $avStyle[$i][1]) Then
            For $y = 0 to _GUICtrlListBox_GetCount($gcFontStyle)
                If $avStyle[$i][0] = _GUICtrlListBox_GetText($gcFontStyle, $y) Then
                    $nSelect = _GUICtrlListBox_SetSel($gcFontStyle, $y)
                EndIf
            Next
        EndIf
    Next
    If $nSelect = -1 Then _GUICtrlListBox_SetSel($gcFontStyle, 0)

    ; Weight
    GUICtrlCreateLabel("Weight", 352, 115, 40, 25)
    Local $avWeight[3][2] = [['Normal', 400], ['Bold', 700], ['Bolder', 600]];wtf
    $gcFontWeight = GUICtrlCreateList("", 352, 130, 80, 60, _
    BitOR($LBS_NOTIFY, $WS_VSCROLL, $LBS_NOINTEGRALHEIGHT))
    $szString = ""
    For $i = 0 to UBound($avWeight)-1
        $szString &= $avWeight[$i][0] & "|"
    Next
    $szString = StringTrimRight($szString, 1)
    GUICtrlSetData($gcFontWeight, $szString)
    If $iWeight >= 100  And $iWeight <= 400 Then  _GUICtrlListBox_SetCurSel($gcFontWeight, 0)
    If $iWeight >= 500 And $iWeight <= 700 Then  _GUICtrlListBox_SetCurSel($gcFontWeight, 1)
    If $iWeight >= 800 And $iWeight <= 900 Then  _GUICtrlListBox_SetCurSel($gcFontWeight, 2)

    ; Preview
    GUICtrlCreateLabel("Preview", 16, 200, 42, 17)
    $gcFontPreview = GUICtrlCreateEdit("", 16, 220, 417, 65, $WS_VSCROLL)
    $szString = ""
    If $sText Then
        $szString = $sText
    Else
        For $i = 33 To 126
            $szString &= Chr($i)
        Next
    EndIf
    GUICtrlSetData($gcFontPreview, $szString)
    GUICtrlSetFont($gcFontPreview, $iSize, $iWeight, $iStyle, $sName)
    GUICtrlSetColor($gcFontPreview, "0x"&$b&$g&$r)

    ; Ok, Cancel
    $gcFontOk = GUICtrlCreateButton("Ok", 8, 308, 75, 25, 0)
    $gcFontCancel = GUICtrlCreateButton("Cancel", 88, 308, 75, 25, 0)

    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $gcFontOk, $gcFontCancel
                Opt("GuiOnEventMode", $nGUImode)
                GUIDelete($hGUI)
                Switch $nMsg
                    Case $gcFontOk
                        Return $azFontOptions
                    Case Else
                        Return -1
                EndSwitch

            Case $gcColor
                $nColor = _ChooseColor(0, $nColor, 0, $hGUI)
                If $nColor >-1 Then
                    $n = _ColorGetRGB($nColor)
                    $nColor = _ColorSetRGB($n)
                    $r = hex($n[0], 2)
                    $g = hex($n[1], 2)
                    $b = hex($n[2], 2)
                    $azFontOptions[4] = $nColor
                    $azFontOptions[5] = "0x"&$b&$g&$r
                    $azFontOptions[6] = "0x"&$r&$g&$b
                    GUICtrlSetColor($gcFontPreview, "0x"&$b&$g&$r)
                    GUICtrlSetBkColor($gcColor, "0x"&$b&$g&$r)
                EndIf

            Case $gcFontWeight, $gcFontSize, $gcFontStyle, $gcFontFamily
                $azFontOptions[2] = 0
                For $i = 0 to UBound($avStyle)-1
                    $av = _GUICtrlListBox_GetSelItemsText($gcFontStyle)
                    For $y  = 0 To $av[0]
                        If $av[$y] = $avStyle[$i][0] Then
                            $azFontOptions[2] += $avStyle[$i][1]
                        EndIf
                    Next
                Next
                $azFontOptions[0] = _GUICtrlComboBox_GetEditText($gcFontSize)               ;Font Size
                $azFontOptions[1] = $avWeight[_GUICtrlListBox_GetCurSel($gcFontWeight)][1]  ;Font Weight
                $azFontOptions[2] = $azFontOptions[2]                                       ;Font Style
                $azFontOptions[3] = _GUICtrlComboBox_GetEditText($gcFontFamily)             ;Font Family
                GUICtrlSetFont($gcFontPreview, $azFontOptions[0], $azFontOptions[1], $azFontOptions[2],$azFontOptions[3])
        EndSwitch
    WEnd
EndFunc










;EXAMPLE
;====================================
#include <Array.au3> ; only needed for example

;Choose Font
#include <Misc.au3>
$a = _ChooseFont("Courier New", 12, 0x0000ff, 600, True, True, True, 0)
_ArrayDisplay($a, "Choosefont:")

;FontSelect
$a = _FontSelect(12, 600, BitOR(2, 4, 8), "Courier New", 0x0000ff)
_ArrayDisplay($a, "FontSelect:")

;====================================
Edited by RockemSockem

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

script is good and works properly. Nice work. :)

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Hi!

Good work.

Suggest : add fonts choosen recently (stored in a .ini file?)

Share this post


Link to post
Share on other sites

Beautiful.

@Michel Claveau; this is something that you would call inside (by) main application (script), so creating some additional files somewhere is not good idea, I think.

@mrRevoked; canceling or X-ing gui still assignes '$a' with input parameters, maybe would be better just to return 0.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Amazing thanks for this

Share this post


Link to post
Share on other sites

What do you think about the color ^^,?

AlmarM


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

its cool...

but AlmarM is definitly right!

What do you think about the color ^^,?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Here, I tried to add the color...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#Include <GuiListBox.au3>
#include <GUIComboBox.au3>
#include <Misc.au3> ; Added by AlmarM

; Example
#include <Array.au3>

$a = _FontSelect(10, 500, 2, "Webdings", "", "Font Select", 0xFFFFFF)
_ArrayDisplay($a)

; End Example

; #FUNCTION# ====================================================================================================
; Name...........: _FontSelect
; Description ...: Adds a specified value at the end of an existing array.
; Syntax.........: _FontSelect($nzSize, $nzWeight, $nzStyle, $szName, $nzParent, $szTitle)
; Parameters ....: $nzSize  - [optional] Font Size, Default is 9
;               $nzWeight   - [optional] Font Weight, (default 400 = normal).
;               |100-400 - Normal
;               |500-600 - Bold
;               |700-900 - Bolder
;               $nzStyle    - [optional] Font Style, (default 40 = normal).
;               (Styles may be combined e.g. 2+4 = Italic and Underlined).
;               |0 - Normal
;               |2 - Italic
;               |4 - Underlined
;               |8 - Strike
;               $szName  - [optional] Font Name, (default is Arial)
;               $nzParent   - [optional] Parent Window, (default is 0)
;               $szTitle    - [optional] Window Title
; Return values .: Success - An array with an index of 4.
;               |0 - Font Size
;               |1 - Font Weight
;               |2 - Font Attribute
;               |3 - Font Name
;                  Failure - sets @error to 1
; Author ........: mrRevoked
; Remarks .......:
; Related .......: None
; Link ..........;
; Modified ......; AlmarM (Color)
; Example .......; Yes
; ====================================================================================================
Func _FontSelect($nzSize = Default, $nzWeight = Default, $nzStyle = Default, $szName = Default, $nzParent = 0, $szTitle = "Font Select", $nzColor = 0x000000) ; $nzColor Added by AlmarM
    Local $nGUImode = Opt("GuiOnEventMode", 0)
    Local $hGUI, $gcFontFamily, $gcFontStyle, $gcFontSize, $gcFontWeight, $gcFontPreview, $gcFontOk, $gcFontCancel
    Local $szString, $nSelect, $i = 1, $s = ""

    If $nzSize = Default Or $nzSize = -1 Then $nzSize = 9
    If $nzWeight = Default Or $nzWeight = -1 Then $nzWeight = 400
    If $nzStyle = Default Or $nzStyle = -1 Then $nzStyle = 0
    If $szName = Default Or $szName = "" Then $szName = "Arial"
    If $szTitle = Default Or $szTitle = "" Then $szTitle = "Font Select"
    If $nzColor = Default Or $nzColor = "" Then $nzColor = 0x000000 ; Added by AlmarM
    If IsNumber($nzColor) Then $nzColor = "0x" & Hex($nzColor,6) ; Added by ProgAndy

    If $nzSize < 0 Then $nzSize = 9
    If $nzWeight < 100 Or $nzWeight > 900 Then $nzWeight = 400
   
    Dim $azFontOptions[5] = [$nzSize, $nzWeight, $nzStyle, $szName, $nzColor] ; Modified by AlmarM
   
    $hGUI = GUICreate($szTitle, 448, 420, -1, -1, -1, -1, $nzParent)
    GUICtrlCreateGroup("Font", 8, 8, 433, 405)
   
    ; Font Group
    GUICtrlCreateLabel("Family", 16, 30, 33, 17)
    $gcFontFamily = GUICtrlCreateCombo("", 16, 48, 217, 250, _
    BitOR($CBS_SIMPLE, $WS_VSCROLL, $CBS_SORT, $CBS_AUTOHSCROLL, $CBS_HASSTRINGS))
    $szString = ""
    If @OSTYPE = "WIN32_NT" Then $regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
    If @OSTYPE = "WIN32_WINDOWS" Then $regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts"
    While 1
        $s = RegEnumVal($regkey, $i)
        If @error <> 0 Then ExitLoop
        ;RegRead($regkey, $s) font filename
        $s = StringRegExpReplace($s,"\s\(.*?\)(\s*)?","")
        $szString &= $s & "|"
        $i = $i + 1
    WEnd
    GUICtrlSetData($gcFontFamily, $szString)
    $nSelect = _GUICtrlComboBox_SetCurSel($gcFontFamily, _GUICtrlComboBox_FindString($gcFontFamily, $szName))
    If $nSelect = -1 Then _GUICtrlComboBox_SetCurSel($gcFontFamily, "Arial")
   
    ; Size
    GUICtrlCreateLabel("Size", 240, 30, 24, 17)
    $gcFontSize = GUICtrlCreateCombo("", 240, 48, 105, 250, BitOR($CBS_SIMPLE, $WS_VSCROLL, $CBS_AUTOHSCROLL))
    $szString = ""
    For $i = 1 to 75
        $szString &= StringFormat("%01d", $i) & "|"
    Next
    GUICtrlSetData($gcFontSize, $szString)
    _GUICtrlComboBox_SetCurSel($gcFontSize, _GUICtrlComboBox_FindString($gcFontSize, $nzSize))
   
    ; Style
    GUICtrlCreateLabel("Style", 352, 30, 27, 17)
    Local $avStyle[4][2] = [['Normal', 0], ['Italic', 2], ['Underlined', 4], ['Strike', 8]]
    $gcFontStyle = GUICtrlCreateList("", 352, 48, 80, 100, _
    BitOR($LBS_NOTIFY, $WS_VSCROLL, $LBS_MULTIPLESEL, $LBS_EXTENDEDSEL, $LBS_NOINTEGRALHEIGHT))
    $szString = ""
    For $i = 0 to UBound($avStyle)-1
        $szString &= $avStyle[$i][0] & "|"
    Next
    GUICtrlSetData($gcFontStyle, $szString)
    $nSelect = -1
    For $i = 0 to UBound($avStyle)-1
        If BitAND($nzStyle, $avStyle[$i][1]) Then
            For $y = 0 to _GUICtrlListBox_GetCount($gcFontStyle)
                If $avStyle[$i][0] = _GUICtrlListBox_GetText($gcFontStyle, $y) Then
                    $nSelect = _GUICtrlListBox_SetSel($gcFontStyle, $y)
                EndIf
            Next
        EndIf
    Next
    If $nSelect = -1 Then _GUICtrlListBox_SetSel($gcFontStyle, 0)
   
    ; Weight
    GUICtrlCreateLabel("Weight", 352, 160, 40, 25)
    Local $avWeight[3][2] = [['Normal', 400], ['Bold', 700], ['Bolder', 600]]
    $gcFontWeight = GUICtrlCreateList("", 352, 178, 80, 115, _
    BitOR($LBS_NOTIFY, $WS_VSCROLL, $LBS_NOINTEGRALHEIGHT))
    $szString = ""
    For $i = 0 to UBound($avWeight)-1
        $szString &= $avWeight[$i][0] & "|"
    Next
    $szString = StringTrimRight($szString, 1)
    GUICtrlSetData($gcFontWeight, $szString)
    If $nzWeight >= 100  And $nzWeight <= 400 Then  _GUICtrlListBox_SetCurSel($gcFontWeight, 0)
    If $nzWeight >= 500 And $nzWeight <= 700 Then  _GUICtrlListBox_SetCurSel($gcFontWeight, 1)
    If $nzWeight >= 800 And $nzWeight <= 900 Then  _GUICtrlListBox_SetCurSel($gcFontWeight, 2)
   
    ; Preview
    GUICtrlCreateLabel("Preview", 70, 305, 42, 17)
    $gcFontPreview = GUICtrlCreateEdit("", 70, 325, 362, 40, $WS_VSCROLL)
    $szString = ""
    For $i = 33 To 126
        $szString &= Chr($i)
    Next
    GUICtrlSetData($gcFontPreview, $szString)
    GUICtrlSetFont($gcFontPreview, $nzSize, $nzWeight, $nzStyle, $szName)
    
    ; Color
    GUICtrlCreateLabel("Color", 16, 305) ; Added by AlmarM
    $gcColorLabel = GUICtrlCreateLabel("", 16, 325, 40, 40) ; Added by AlmarM
    GUICtrlSetBkColor($gcColorLabel, $nzColor) ; Added by AlmarM
   
    ; Ok, Cancel
    $gcFontOk = GUICtrlCreateButton("Ok", 16, 375, 75, 25, 0)
    $gcFontCancel = GUICtrlCreateButton("Cancel", 94, 375, 75, 25, 0)

    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $gcFontOk, $gcFontCancel
                Opt("GuiOnEventMode", $nGUImode)
                GUIDelete($hGUI)
                Switch $nMsg
                    Case $gcFontOk
                        Return $azFontOptions
                    Case Else
                        Dim $azFontOptions[4] = [$nzSize, $nzWeight, $nzStyle, $szName]
                        Return SetError(1, 0, $azFontOptions)
                EndSwitch
            Case $gcColorLabel
                $csColor = _ChooseColor(2, "", 2, $hGUI) ; Added by AlmarM
                GUICtrlSetBkColor($gcColorLabel, $csColor) ; Added by AlmarM
                GUICtrlSetColor($gcFontPreview, $csColor) ; Added by AlmarM
                $azFontOptions[4] = $csColor            ;Font Color
            Case $gcFontWeight, $gcFontSize, $gcFontStyle, $gcFontFamily
                $azFontOptions[2] = 0
                For $i = 0 to UBound($avStyle)-1
                    $av = _GUICtrlListBox_GetSelItemsText($gcFontStyle)
                    For $y  = 0 To $av[0]
                        If $av[$y] = $avStyle[$i][0] Then
                            $azFontOptions[2] += $avStyle[$i][1]
                        EndIf
                    Next
                Next
                $azFontOptions[0] = _GUICtrlComboBox_GetEditText($gcFontSize)            ;Font Size
                $azFontOptions[1] = $avWeight[_GUICtrlListBox_GetCurSel($gcFontWeight)][1]  ;Font Weight
                $azFontOptions[2] = $azFontOptions[2]                              ;Font Style
                $azFontOptions[3] = _GUICtrlComboBox_GetEditText($gcFontFamily)    ;Font Family
                GUICtrlSetFont($gcFontPreview, $azFontOptions[0], $azFontOptions[1], $azFontOptions[2], $azFontOptions[3])
        EndSwitch
    WEnd
EndFunc

All things I added I marked with '; Added by Almar'.

The only problem is when you run the program and (without pressing or touching anything) you press OK, the $azFontOptions[4] (color) returns 16777215

AlmarM

EDIT: Screenshot

Posted Image

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

If you want return as hex-string, just add this line at the top of the func:

If IsNumber($nzColor) Then $nzColor = "0x" & Hex($nzColor,6)


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Thx :)

AlmarM


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Updated 2009-11-12, v0.6a

Looks pretty sweet now! :)

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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  
Followers 0