Jump to content

What controls checkbox size?


qwert
 Share

Recommended Posts

Setting the width and heigth causes it to occupy more space, but the checkbox itself is still small. I've tried both GUISetFont and GUICtrlSetFont with no success, even though the help file says:

By default, controls use the font set by GUISetFont

Thanks for any help.
Link to comment
Share on other sites

  • Moderators

qwert,

As far as I know you cannot change the size of an API-created checkbox. If you want a larger one you need to create your own custom version - perhaps along these lines:

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

$hGUI = GUICreate("Test", 500, 500)

GUICtrlCreateLabel("", 9, 9, 22, 22)
GUICtrlSetBkColor(-1, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
$hCheck = GUICtrlCreateLabel("", 10, 10, 20, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 16)
GUICtrlCreateLabel("A user-drawn checkbox", 35, 15, 200, 20)

GUICtrlCreateCheckbox("An API-created checkbox", 10, 100, 200, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hCheck
            Switch GUICtrlRead($hCheck)
                Case ""
                    GUICtrlSetData($hCheck, "X")
                Case Else
                    GUICtrlSetData($hCheck, "")
            EndSwitch
    EndSwitch
WEnd

A lot more work, but a pretty pleasing result. :graduated:

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

I was afraid that might be the case, since so few dialogs have anything other than the "tiny standard". It's hard to believe Windows has gotten away with such a limited implementation for all these years.

I had already thought of toggling between two graphics. When I get more time, I'll use your script to test and refine that technique.

I appreciate your response.

Link to comment
Share on other sites

qwert,

As far as I know you cannot change the size of an API-created checkbox. If you want a larger one you need to create your own custom version - perhaps along these lines:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
 
$hGUI = GUICreate("Test", 500, 500)
 
GUICtrlCreateLabel("", 9, 9, 22, 22)
GUICtrlSetBkColor(-1, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
$hCheck = GUICtrlCreateLabel("", 10, 10, 20, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 16)
GUICtrlCreateLabel("A user-drawn checkbox", 35, 15, 200, 20)
 
GUICtrlCreateCheckbox("An API-created checkbox", 10, 100, 200, 20)
 
GUISetState()
 
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hCheck
            Switch GUICtrlRead($hCheck)
                Case ""
                    GUICtrlSetData($hCheck, "X")
                Case Else
                    GUICtrlSetData($hCheck, "")
            EndSwitch
    EndSwitch
WEnd

A lot more work, but a pretty pleasing result. :graduated:

M23

Wow this is really good. Took me a minute to get my head around what it was doing.. Does the possibilities of Autoit never end?! You got me thinking now about what kinds of things like this I have missed. Nice job!

Link to comment
Share on other sites

  • Moderators

Morthawt,

Does the possibilities of Autoit never end?!

I rather think not! :graduated:

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

You can use the font 'Marlett' to have the original characters.

$hGUI = GUICreate("Test", 200, 150)

$hCheck1 = GUICtrlCreateLabel("", 10, 10, 20, 20, 0x1201)
GUICtrlSetFont(-1, 19, 400, 0, "Marlett")
GUICtrlSetBkColor(-1, 0xFFFFFF)
$hLbl1 = GUICtrlCreateLabel("A user-drawn checkbox", 35, 15, 200, 20)

$hCheck2 = GUICtrlCreateLabel("", 10, 50, 25, 25, 0x1201)
GUICtrlSetFont(-1, 24, 400, 0, "Marlett")
GUICtrlSetBkColor(-1, 0xFFFFFF)
$hLbl2 = GUICtrlCreateLabel("Another user-drawn checkbox", 40, 57, 200, 20)

GUICtrlCreateCheckbox("An API-created checkbox", 10, 100, 200, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $hCheck1, $hLbl1
            Switch GUICtrlRead($hCheck1)
                Case ""
                    GUICtrlSetData($hCheck1, "a")
                Case Else
                    GUICtrlSetData($hCheck1, "")
            EndSwitch
        Case $hCheck2, $hLbl2
            Switch GUICtrlRead($hCheck2)
                Case ""
                    GUICtrlSetData($hCheck2, "r")
                Case Else
                    GUICtrlSetData($hCheck2, "")
            EndSwitch
    EndSwitch
WEnd

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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