Jump to content

help with text size and fount


Recommended Posts

hello,

im building an app that lets the user chose the size and colour of text and back ground but i hit a probelm i can set the size of text fine but when i try to change the fount as well to a different one it changes the fount and the size back.

please look and tell me were i have gone wrong, here is my code.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$temp = 8

;BACKGROUND COLOUR
$Form2 = GUICreate("SETTINGS", 403, 432, 500, 143)
$Group1 = GUICtrlCreateGroup("Back Ground Colour", 16, 16, 185, 97)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)

$RED = GUICtrlCreateButton("RED", 24, 40, 75, 25)
GUICtrlSetBkColor(-1, 0xFF0000)
$GREEN = GUICtrlCreateButton("GREEN", 112, 40, 75, 25)
GUICtrlSetBkColor(-1, 0x00FF00)
$YELLOW = GUICtrlCreateButton("YELLOW", 24, 72, 75, 25)
GUICtrlSetBkColor(-1, 0xFFFF00)
$BLUE = GUICtrlCreateButton("BLUE", 112, 72, 75, 25)
GUICtrlSetBkColor(-1, 0x00FFFF)
GUICtrlCreateGroup("", -99, -99, 1, 1)

;TEXT COLOUR
$Group2 = GUICtrlCreateGroup("Text Colour", 16, 128, 185, 97)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

$REDT = GUICtrlCreateButton("RED", 24, 152, 75, 25)
GUICtrlSetBkColor(-1, 0xFF0000)
$GREENT = GUICtrlCreateButton("GREEN", 112, 152, 75, 25)
GUICtrlSetBkColor(-1, 0x00FF00)
$YELLOWT = GUICtrlCreateButton("YELLOW", 24, 184, 75, 25)
GUICtrlSetBkColor(-1, 0xFFFF00)
$BLUET = GUICtrlCreateButton("BLUE", 112, 184, 75, 25)
GUICtrlSetBkColor(-1, 0x00FFFF)
GUICtrlCreateGroup("", -99, -99, 1, 1)

;TEXT SIZE
$Group3 = GUICtrlCreateGroup("Text Size", 216, 16, 169, 209)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

$Size1 = GUICtrlCreateButton("SIZE 10", 264, 40, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "")
$Size2 = GUICtrlCreateButton("SIZE 14", 256, 80, 91, 25)
GUICtrlSetFont(-1, 14, 800, 0, "")
$Size3 = GUICtrlCreateButton("SIZE 18", 248, 120, 107, 33)
GUICtrlSetFont(-1, 18, 800, 0, "")
$Size4 = GUICtrlCreateButton("SIZE 24", 240, 168, 123, 41)
GUICtrlSetFont(-1, 24, 800, 0, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)

;STYLE
$Group4 = GUICtrlCreateGroup("Style", 16, 240, 361, 105)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

$STYLE1 = GUICtrlCreateButton("STYLE1", 24, 264, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Napa Heavy SF")
$STYLE2 = GUICtrlCreateButton("STYLE2", 112, 264, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Microsoft Sans Serif")
$STYLE3 = GUICtrlCreateButton("STYLE3", 200, 264, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Lucida Sans Unicode")
$STYLE4 = GUICtrlCreateButton("STYLE4", 288, 264, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Lucida Console")
$STYLE5 = GUICtrlCreateButton("STYLE5", 24, 304, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Invite SF")
$STYLE6 = GUICtrlCreateButton("STYLE6", 112, 304, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Georgia")
$STYLE7 = GUICtrlCreateButton("STYLE7", 200, 304, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Fixedsys")
$STYLE8 = GUICtrlCreateButton("STYLE8", 288, 304, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Courier New")
GUICtrlCreateGroup("", -99, -99, 1, 1)

;Preview
$CLOSE = GUICtrlCreateButton("CLOSE", 24, 360, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

$Input1 = GUICtrlCreateInput("Preview", 128, 360, 249, 40)
GUICtrlSetFont(-1, $temp, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###




While 1
    $nMsg = GUIGetMsg()
        Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $STYLE1
            GUICtrlSetFont($Input1, $temp,"Napa Heavy SF")



        ;TEXT SIZE
        Case $Size1
            $temp = GUICtrlSetFont($Input1,10)
        Case $Size2
            $temp = GUICtrlSetFont($Input1,14)
        Case $Size3
            $temp = GUICtrlSetFont($Input1,18)
        Case $Size4
            $temp = GUICtrlSetFont($Input1,24)



            ;TEXT COLOUR CONTROLS
        Case $REDT
            GUICtrlSetColor($Input1,0xFF0000)
        Case $BLUET
            GUICtrlSetColor($Input1,0x00FFFF)
        Case $GREENT
            GUICtrlSetColor($Input1,0x00FF00)
        Case $YELLOWT
            GUICtrlSetColor($Input1,0xFFFF00)


            ;Back Ground Controls
        Case $RED
            GUISetBkColor(0xFF0000)
        Case $GREEN
            GUISetBkColor(0x00FF00)
        Case $BLUE
            GUISetBkColor(0x00FFFF)
        Case $YELLOW
            GUISetBkColor(0xFFFF00)


        EndSwitch
WEnd
Link to comment
Share on other sites

  • Moderators

madmorgan,

You have the correct syntax for GUICtrlSetFont when you change the size, why do you not use the correct syntax when changing the font itself?

From the Help file:

"GUICtrlSetFont (controlID, size [, weight [, attribute [, fontname[, quality]]]] )"

Hint: You need to set all the intervening parameters to Default. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

madmorgen,

In response to your PM:

It does not matter what parameter you want to change - you MUST complete all the parameters in the GUICtrlSetFont up to the one you want to change. So if you want to change the font and nothing else, you do this:

GUICtrlSetFont(controlID, Default, Default, Default, fontname)

M23

P.S. For anyone else reading - do NOT send PMs asking for help, it is considered rude here. :D

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...