Jump to content

[SOLVED] Radio Button long text


Recommended Posts

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

Opt("GUIResizeMode", $GUI_DOCKAUTO)

Global $q1 = "Welcome, I am glad you're willing to help me so I hope" & @CRLF & "everytime this GUI is resized while in qloop function, the script is crashing with following error: "& @CRLF & @CRLF & _
'"C:\Users\wk\Desktop\williamas kumeliukas\test quiz example.au3" (213) : ==> Subscript used on non-accessible variable.:' & @CRLF & @CRLF & _
"If $aRect[3] <= $aPos[3] Then" & @CRLF & @CRLF & _
"If $aRect^ ERROR"

Global $_width = @DesktopWidth / 1.20
Global $_height = @DesktopHeight / 1.30

#Region Var
Global $iGuiWidth = $_width, $iGuiHeight = $_height, $iGuiXPos = (@DesktopWidth / 2) - $iGuiWidth / 2, $iGuiYpos = (@DesktopHeight / 2) - $iGuiHeight / 2
Global $file = @ScriptDir & "\1.p"
Global $msg, $i = 0, $qf, $gui
Global $GUI_InitWidth = 800, $GUI_InitHeight = 600
#EndRegion Var
Main()

Func Main()
#Region GUI
Global $gui = GUICreate("Example", $GUI_InitWidth, $GUI_InitHeight, -1, -1,BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX))

Global $info = GUICtrlCreateLabel($q1, 110, 10, 560, 180, BitOR($WS_BORDER,$SS_CENTER) )

  Global $a = GUICtrlCreateRadio("A)", 20, 200, 320, 150, BitOR($BS_MULTILINE, $BS_TOP,$WS_EX_TOPMOST))

  Global $b = GUICtrlCreateRadio("B)", 20, 360, 320, 150, BitOR($BS_MULTILINE,$BS_TOP,$WS_EX_TOPMOST))

  Global $c = GUICtrlCreateRadio("C)", 460, 200, 330, 150, BitOR($BS_MULTILINE,$BS_TOP,$WS_EX_TOPMOST))

  Global $d = GUICtrlCreateRadio( "D)", 460, 360, 330, 150, BitOR($BS_MULTILINE,$BS_TOP,$WS_EX_TOPMOST))

  Global $start = GUICtrlCreateButton("Start", 340, 450, 120, 30,$WS_EX_TOPMOST)

  Global $valid = GUICtrlCreateButton("Confirm", 340, 470, 120, 30,$WS_EX_TOPMOST)
  GUICtrlSetState($valid, 32)
  GUISetState(@SW_SHOW)
#ENDREGION GUI
  If $iGuiHeight < $GUI_InitHeight Then
      Global $calc=Int($GUI_InitHeight-$iGuiheight)
      $iGuiHeight = $GUI_InitHeight
      WinMove($gui,"",$iGuiXPos,$iGuiYpos-$calc - 5,$iGuiWidth,$iGuiHeight)
  Else
      WinMove($gui,"",$iGuiXPos,$iGuiYpos,$iGuiWidth,$iGuiHeight)
  EndIf

  $aPos = ControlGetPos($gui,"",$info)
  $sText = $q1
  $sFormattedText = _GetFontSize($q1, $aPos)
  GUICtrlSetFont($info,@extended)
  GUICtrlSetData($info,$sFormattedText)
adjustFont()
  While 1
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        Exit
        Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
            adjustFont()
            Case $start
            Global $qf = StringSplit(StringStripWS(FileRead($file), 6), @CRLF, 0)
            GUICtrlSetState($start, 32)
            qloop($file)
        EndSwitch
    WEnd
EndFunc

Func _GetFontSize($sText, $aPos)
    For $iSize = 24 to 1 Step -1
        Local $aRect = _StringSize($sText, $iSize, Default, Default, Default, $aPos[2] - 25)
        If $aRect[3] <= $aPos[3] Then
            ExitLoop
        EndIf
    Next
    Return SetError(0, $iSize, $aRect[0])
EndFunc

Func qloop($file)
  For $i = 1 To $qf[0] Step 8

    $aPos=ControlGetPos($gui,"",$info)
    $sText=$qf[$i]
    $sFormattedText = _GetFontSize( $sText,$aPos)
    GUICtrlSetFont($info, @extended)
    GUICtrlSetData($info,$sFormattedText)

    $aPos = ControlGetPos($gui, "", $a)
    $sText=$qf[$i+1]
    $sFormattedText = _GetFontSize( $sText, $aPos)
    GUICtrlSetFont($a, @extended)
    GUICtrlSetData($a, $sFormattedText)

    $sText=$qf[$i+2]
    $sFormattedText = _GetFontSize( $sText, $aPos)
    GUICtrlSetFont($b, @extended)
    GUICtrlSetData($b, $sFormattedText)
    $sText=$qf[$i+3]
    $sFormattedText = _GetFontSize($sText, $aPos)
    GUICtrlSetFont($c, @extended)
    GUICtrlSetData($c, $sFormattedText)
    $sText = $qf[$i+4]
    $sFormattedText = _GetFontSize($sText , $aPos)
    GUICtrlSetFont($d, @extended)
    GUICtrlSetData($d, $sFormattedText)

    Do
      Switch GUIGetMsg()
          Case $GUI_EVENT_MAXIMIZE,$GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
            adjustFont()
          Case $GUI_EVENT_CLOSE
              Exit
          Case $valid
              $msg = GUIGetMsg()
            If $msg = $GUI_EVENT_CLOSE Then
            Exit
            EndIf
          EndSwitch
      If $msg = -3 Then Exit
    Until 0
    Next
EndFunc   ;==>qloop

Func adjustFont()
    If $qf = "" Then
        $aPos = ControlGetPos($gui,"",$info)
        $sText = $q1
        $sFormattedText = _GetFontSize($sText,$aPos)
        GUICtrlSetFont($info, @extended)
        GUICtrlSetData($info,$sFormattedText)
    Else
        $sText=$qf[$i]
        $aPos = ControlGetPos($gui,"",$info)
        $sFormattedText = _GetFontSize($sText,$aPos)
        GUICtrlSetFont($info, @extended)
        GUICtrlSetData($info,$sFormattedText)

        $aPos = ControlGetPos($gui, "", $a)
        $sText=$qf[$i+1]
        $sFormattedText = _GetFontSize( $sText, $aPos)
        GUICtrlSetFont($a, @extended)
        GUICtrlSetData($a, $sFormattedText)

        $sText=$qf[$i+2]
        $sFormattedText = _GetFontSize( $sText, $aPos)
        GUICtrlSetFont($b, @extended)
        GUICtrlSetData($b, $sFormattedText)

        $sText=$qf[$i+3]
        $sFormattedText = _GetFontSize($sText, $aPos)
        GUICtrlSetFont($c, @extended)
        GUICtrlSetData($c, $sFormattedText)

        $sText = $qf[$i+4]
        $sFormattedText = _GetFontSize($sText, $aPos)
        GUICtrlSetFont($d, @extended)
        GUICtrlSetData($d, $sFormattedText)
    EndIf
EndFunc

this version is stripped-down to 164 lines, tested and still reproduce the same error in the same circumstance as previous one.

Williamas kumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

Spoiler

#1. I am a native French speaker and learned English mainly from chatting with others players in online games.

#2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ^_^

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Link to comment
Share on other sites

Could you confirm me that your looking into the script I provided in previous post please,@Melba23 ?

I just want to make sure that I am not waiting like an idiot for nothing.

Br,

WilliamasKumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

Spoiler

#1. I am a native French speaker and learned English mainly from chatting with others players in online games.

#2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ^_^

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Link to comment
Share on other sites

  • Moderators

WilliamasKumeliukas,

Sorry, I was not aware I was your personal code slave to do your bidding immediately you request it.

I will look into your code as and when I have time - the real world is giving me quite enough problems to deal with at the moment.

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

43 minutes ago, Melba23 said:

WilliamasKumeliukas,

Sorry, I was not aware I was your personal code slave to do your bidding immediately you request it.

Melba23,

I apologize for my misleading question, I didn't mean it that way nor was it intentional :( . I mean't if you are willing to take a look into my code once you have some spare time.

43 minutes ago, Melba23 said:

the real world is giving me quite enough problems to deal with at the moment.

Sorry to hear of it, I hope you'll soon get through them.

Once again, I apologize for my clumsiness at writing right sentences.

Sincerely,

WilliamasKumeliukas

Edited by WilliamasKumeliukas
better choice of words

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

Spoiler

#1. I am a native French speaker and learned English mainly from chatting with others players in online games.

#2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ^_^

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Link to comment
Share on other sites

  • Moderators

WilliamasKumeliukas,

No problem - those real-world problems were getting just a bit too much just now. I will try and look into the code this weekend - we are forecast thunderstorms and lots of rain.

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

WilliamasKumeliukas,

As forecast - pouring with rain!

The problem is your adjustfont function - you are using the various elements of your $qf array to set the text of the controls without defining the index value to use within the function as a Local variable. Thus AutoIt uses the default Global value of the variable 0 and as a result the first value passed to StringSize is not a valid text string and so the function fails (and actually gives you this information in @error and @extended).

Here is a reworked version of your example which works for me:

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

Opt("GUIResizeMode", $GUI_DOCKAUTO)

Global $q1 = "Welcome, I am glad you're willing to help me so I hope" & @CRLF & "everytime this GUI is resized while in qloop function, the script is crashing with following error: " & @CRLF & @CRLF & _
        '"C:\Users\wk\Desktop\williamas kumeliukas\test quiz example.au3" (213) : ==> Subscript used on non-accessible variable.:' & @CRLF & @CRLF & _
        "If $aRect[3] <= $aPos[3] Then" & @CRLF & @CRLF & _
        "If $aRect^ ERROR"

Global $_width = @DesktopWidth / 1.20
Global $_height = @DesktopHeight / 1.30

#Region Var
    Global $iGuiWidth = $_width, $iGuiHeight = $_height, $iGuiXPos = (@DesktopWidth / 2) - $iGuiWidth / 2, $iGuiYpos = (@DesktopHeight / 2) - $iGuiHeight / 2
    Global $file = @ScriptDir & "\1.txt"
    Global $msg, $iIndex = 0, $qf, $gui ; Redefine the $iIndex variable to be the current index value within the file <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Global $GUI_InitWidth = 800, $GUI_InitHeight = 600
#EndRegion Var
Main()

Func Main()
    #Region GUI
        Global $gui = GUICreate("Example", $GUI_InitWidth, $GUI_InitHeight, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX))

        Global $info = GUICtrlCreateLabel($q1, 110, 10, 560, 180, BitOR($WS_BORDER, $SS_CENTER))

        Global $a = GUICtrlCreateRadio("A)", 20, 200, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $b = GUICtrlCreateRadio("B)", 20, 360, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $c = GUICtrlCreateRadio("C)", 460, 200, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $d = GUICtrlCreateRadio("D)", 460, 360, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $start = GUICtrlCreateButton("Start", 340, 450, 120, 30, $WS_EX_TOPMOST)

        Global $valid = GUICtrlCreateButton("Confirm", 340, 470, 120, 30, $WS_EX_TOPMOST)
        GUICtrlSetState($valid, 32)
        GUISetState(@SW_SHOW)
    #EndRegion GUI
    If $iGuiHeight < $GUI_InitHeight Then
        Global $calc = Int($GUI_InitHeight - $iGuiHeight)
        $iGuiHeight = $GUI_InitHeight
        WinMove($gui, "", $iGuiXPos, $iGuiYpos - $calc - 5, $iGuiWidth, $iGuiHeight)
    Else
        WinMove($gui, "", $iGuiXPos, $iGuiYpos, $iGuiWidth, $iGuiHeight)
    EndIf

    $aPos = ControlGetPos($gui, "", $info)
    $sText = $q1
    $sFormattedText = _GetFontSize($q1, $aPos)
    GUICtrlSetFont($info, @extended)
    GUICtrlSetData($info, $sFormattedText)

    adjustfont($iIndex) ; This time the function gets 0 as an index so it knows it is the start point <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                adjustfont($iIndex) ; Here the function gets the current index <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Case $start
                Global $qf = StringSplit(StringStripWS(FileRead($file), 6), @CRLF, 0)
                GUICtrlSetState($start, 32)
                qloop($file)
        EndSwitch
    WEnd
EndFunc   ;==>Main

Func _GetFontSize($sText, $aPos)
    For $iSize = 24 To 1 Step -1
        Local $aRect = _StringSize($sText, $iSize, Default, Default, Default, $aPos[2] - 25)

        $iError = @error
        $iExtended = @extended

        If $iError Then

            ConsoleWrite(@error & " - " & @extended & @CRLF & $sText & @CRLF)

        EndIf

        If $aRect[3] <= $aPos[3] Then
            ExitLoop
        EndIf
    Next
    Return SetError(0, $iSize, $aRect[0])
EndFunc   ;==>_GetFontSize

Func qloop($file)

    For $i = 1 To $qf[0] Step 8

        $iIndex = $i ; Set the Global variable to the current index <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        adjustfont($iIndex) ; And use it here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        Do
            Switch GUIGetMsg()
                Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                    adjustfont($iIndex) ; and here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $valid
                    $msg = GUIGetMsg()
                    If $msg = $GUI_EVENT_CLOSE Then
                        Exit
                    EndIf
            EndSwitch
            If $msg = -3 Then Exit
        Until 0
    Next
EndFunc   ;==>qloop

Func adjustfont($iIndex)

    If $iIndex = 0 Then ; It is the initial run <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        $aPos = ControlGetPos($gui, "", $info)
        $sText = $q1
        $sFormattedText = _GetFontSize($sText, $aPos)
        GUICtrlSetFont($info, @extended)
        GUICtrlSetData($info, $sFormattedText)

    Else ; There is a valid index to use <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        $aPos = ControlGetPos($gui, "", $info)
        $sText = $qf[$iIndex]
        $sFormattedText = _GetFontSize($sText, $aPos)
        GUICtrlSetFont($info, @extended)
        GUICtrlSetData($info, $sFormattedText)

        $aPos = ControlGetPos($gui, "", $a)
        $sText = $qf[$iIndex + 1]
        $sFormattedText = _GetFontSize($sText, $aPos)
        GUICtrlSetFont($a, @extended)
        GUICtrlSetData($a, $sFormattedText)

        $sText = $qf[$iIndex + 2]
        $sFormattedText = _GetFontSize($sText, $aPos)
        GUICtrlSetFont($b, @extended)
        GUICtrlSetData($b, $sFormattedText)

        $sText = $qf[$iIndex + 3]
        $sFormattedText = _GetFontSize($sText, $aPos)
        GUICtrlSetFont($c, @extended)
        GUICtrlSetData($c, $sFormattedText)

        $sText = $qf[$iIndex + 4]
        $sFormattedText = _GetFontSize($sText, $aPos)
        GUICtrlSetFont($d, @extended)
        GUICtrlSetData($d, $sFormattedText)

    EndIf

EndFunc   ;==>adjustfont

Look for the <<<<<<<<<<<< lines. I hope it was worth the wait.

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

@Melba23,

I tried your version and there still a problem once we click start it does indeed display the text but the Font size does not change anymore, @extended return 24 to all controls no matters how I resize GUI.

is there a reason why it does this?

EDIT: $i not being declared as global variable was something I accidentally removed while removing all irrelevant variables from the example my bad.

I did not change anything from your version yet.

WilliamasKumeliukas

Edited by WilliamasKumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

Spoiler

#1. I am a native French speaker and learned English mainly from chatting with others players in online games.

#2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ^_^

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Link to comment
Share on other sites

  • Moderators

WilliamasKumeliukas,

The font does not change because with the short strings you are using the default max font size (24pt) means that the text still fits in the control as it gets smaller. Try increasing the length of one of the strings to be displayed and you will see that the font will reduce in size as the GUI is made smaller.

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

4 hours ago, Melba23 said:

WilliamasKumeliukas,

The font does not change because with the short strings you are using the default max font size (24pt) means that the text still fits in the control as it gets smaller. Try increasing the length of one of the strings to be displayed and you will see that the font will reduce in size as the GUI is made smaller.

M23

if you resize GUI with same text to example 800x600, it will crash instead of reduce fontsize returning error code 3 - font too large to fit text in the rectangle.

Edited by WilliamasKumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

Spoiler

#1. I am a native French speaker and learned English mainly from chatting with others players in online games.

#2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ^_^

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Link to comment
Share on other sites

  • Moderators

WilliamasKumeliukas,

That is because one of the strings to display includes "_GetFontSize($sText," which has no spaces - and so will not be broken by the StringSize UDF.

I have added some errorchecking to the various functions - if the text will not fit with the smallest usable font size (8pt) the script now tells the user that the GUI is too small:

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

Opt("GUIResizeMode", $GUI_DOCKAUTO)

Global $q1 = "Welcome, I am glad you're willing to help me so I hope" & @CRLF & "everytime this GUI is resized while in qloop function, the script is crashing with following error: " & @CRLF & @CRLF & _
        '"C:\Users\wk\Desktop\williamas kumeliukas\test quiz example.au3" (213) : ==> Subscript used on non-accessible variable.:' & @CRLF & @CRLF & _
        "If $aRect[3] <= $aPos[3] Then" & @CRLF & @CRLF & _
        "If $aRect^ ERROR"

Global $_width = @DesktopWidth / 1.20
Global $_height = @DesktopHeight / 1.30

#Region Var
    Global $iGuiWidth = $_width, $iGuiHeight = $_height, $iGuiXPos = (@DesktopWidth / 2) - $iGuiWidth / 2, $iGuiYpos = (@DesktopHeight / 2) - $iGuiHeight / 2
    Global $file = @ScriptDir & "\1.txt"
    Global $msg, $iIndex = 0, $qf, $gui ; Redefine the $iIndex variable to be the current index value within the file <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Global $GUI_InitWidth = 800, $GUI_InitHeight = 600
#EndRegion Var
Main()

Func Main()
    #Region GUI
        Global $gui = GUICreate("Example", $GUI_InitWidth, $GUI_InitHeight, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX))

        Global $info = GUICtrlCreateLabel($q1, 110, 10, 560, 180, BitOR($WS_BORDER, $SS_CENTER))

        Global $a = GUICtrlCreateRadio("A)", 20, 200, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $b = GUICtrlCreateRadio("B)", 20, 360, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $c = GUICtrlCreateRadio("C)", 460, 200, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $d = GUICtrlCreateRadio("D)", 460, 360, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $start = GUICtrlCreateButton("Start", 340, 450, 120, 30, $WS_EX_TOPMOST)

        Global $valid = GUICtrlCreateButton("Confirm", 340, 470, 120, 30, $WS_EX_TOPMOST)
        GUICtrlSetState($valid, 32)
        GUISetState(@SW_SHOW)
    #EndRegion GUI
    If $iGuiHeight < $GUI_InitHeight Then
        Global $calc = Int($GUI_InitHeight - $iGuiHeight)
        $iGuiHeight = $GUI_InitHeight
        WinMove($gui, "", $iGuiXPos, $iGuiYpos - $calc - 5, $iGuiWidth, $iGuiHeight)
    Else
        WinMove($gui, "", $iGuiXPos, $iGuiYpos, $iGuiWidth, $iGuiHeight)
    EndIf

    $aPos = ControlGetPos($gui, "", $info)
    $sText = $q1
    $sFormattedText = _GetFontSize($q1, $aPos)
    GUICtrlSetFont($info, @extended)
    GUICtrlSetData($info, $sFormattedText)

    adjustfont($iIndex) ; This time the function gets 0 as an index so it knows it is the start point <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                adjustfont($iIndex) ; Here the function gets the current index <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Case $start
                Global $qf = StringSplit(StringStripWS(FileRead($file), 6), @CRLF, 0)
                GUICtrlSetState($start, 32)
                qloop($file)
        EndSwitch
    WEnd
EndFunc   ;==>Main

Func _GetFontSize($sText, $aPos)
    For $iSize = 24 To 8 Step -1 ; 8pt is probably the lowest you want to go

        Local $aRect = _StringSize($sText, $iSize, Default, Default, Default, $aPos[2] - 25)
        ; Save @ & @extendederror
        $iError = @error
        $iExtended = @extended

        Switch $iError
            ; Do nothing
            Case 0
            ; If single word in text too large to fit in the rectangle - continue to reduce size
            Case 3
                ContinueLoop
            ; Any other error is likely to be fatal so set return error flag
            Case Else
                Return SetError($iError, 0, "")
        EndSwitch

        ; Check if text fits
        If $aRect[3] <= $aPos[3] Then
            ; Return font size
            ExitLoop
        EndIf
    Next
    ; If even smallest font size will not fit
    If $iError = 3 Then
        Return SetError(1, 0, "")
    EndIf
    Return SetError(0, $iSize, $aRect[0])
EndFunc   ;==>_GetFontSize

Func qloop($file)

    For $i = 1 To $qf[0] Step 8

        $iIndex = $i ; Set the Global variable to the current index <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        adjustfont($iIndex) ; And use it here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        Do
            Switch GUIGetMsg()
                Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                    adjustfont($iIndex) ; and here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $valid
                    $msg = GUIGetMsg()
                    If $msg = $GUI_EVENT_CLOSE Then
                        Exit
                    EndIf
            EndSwitch
            If $msg = -3 Then Exit
        Until 0
    Next
EndFunc   ;==>qloop

Func adjustfont($iIndex)

    If $iIndex = 0 Then ; It is the initial run <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        $aPos = ControlGetPos($gui, "", $info)
        $sText = $q1
        $sFormattedText = _GetFontSize($sText, $aPos)
        ; If error then <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        If @error Then
            ; Tell user
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($info, @extended)
        EndIf
        GUICtrlSetData($info, $sFormattedText)

    Else ; There is a valid index to use <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        $aPos = ControlGetPos($gui, "", $info)
        $sText = $qf[$iIndex]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @error = 1 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($info, @extended)
        EndIf
        GUICtrlSetData($info, $sFormattedText)

        $aPos = ControlGetPos($gui, "", $a)
        $sText = $qf[$iIndex + 1]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @error = 1 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($a, @extended)
        EndIf
        GUICtrlSetData($a, $sFormattedText)

        $sText = $qf[$iIndex + 2]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @error = 1 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($b, @extended)
        EndIf
        GUICtrlSetData($b, $sFormattedText)

        $sText = $qf[$iIndex + 3]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @extended = 0 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($c, @extended)
        EndIf
        GUICtrlSetData($c, $sFormattedText)

        $sText = $qf[$iIndex + 4]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @error = 1 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($d, @extended)
        EndIf
        GUICtrlSetData($d, $sFormattedText)

    EndIf

EndFunc   ;==>adjustfont

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

1 hour ago, Melba23 said:

WilliamasKumeliukas,

That is because one of the strings to display includes "_GetFontSize($sText," which has no spaces - and so will not be broken by the StringSize UDF.

I have added some errorchecking to the various functions - if the text will not fit with the smallest usable font size (8pt) the script now tells the user that the GUI is too small:

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

Opt("GUIResizeMode", $GUI_DOCKAUTO)

Global $q1 = "Welcome, I am glad you're willing to help me so I hope" & @CRLF & "everytime this GUI is resized while in qloop function, the script is crashing with following error: " & @CRLF & @CRLF & _
        '"C:\Users\wk\Desktop\williamas kumeliukas\test quiz example.au3" (213) : ==> Subscript used on non-accessible variable.:' & @CRLF & @CRLF & _
        "If $aRect[3] <= $aPos[3] Then" & @CRLF & @CRLF & _
        "If $aRect^ ERROR"

Global $_width = @DesktopWidth / 1.20
Global $_height = @DesktopHeight / 1.30

#Region Var
    Global $iGuiWidth = $_width, $iGuiHeight = $_height, $iGuiXPos = (@DesktopWidth / 2) - $iGuiWidth / 2, $iGuiYpos = (@DesktopHeight / 2) - $iGuiHeight / 2
    Global $file = @ScriptDir & "\1.txt"
    Global $msg, $iIndex = 0, $qf, $gui ; Redefine the $iIndex variable to be the current index value within the file <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Global $GUI_InitWidth = 800, $GUI_InitHeight = 600
#EndRegion Var
Main()

Func Main()
    #Region GUI
        Global $gui = GUICreate("Example", $GUI_InitWidth, $GUI_InitHeight, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX))

        Global $info = GUICtrlCreateLabel($q1, 110, 10, 560, 180, BitOR($WS_BORDER, $SS_CENTER))

        Global $a = GUICtrlCreateRadio("A)", 20, 200, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $b = GUICtrlCreateRadio("B)", 20, 360, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $c = GUICtrlCreateRadio("C)", 460, 200, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $d = GUICtrlCreateRadio("D)", 460, 360, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

        Global $start = GUICtrlCreateButton("Start", 340, 450, 120, 30, $WS_EX_TOPMOST)

        Global $valid = GUICtrlCreateButton("Confirm", 340, 470, 120, 30, $WS_EX_TOPMOST)
        GUICtrlSetState($valid, 32)
        GUISetState(@SW_SHOW)
    #EndRegion GUI
    If $iGuiHeight < $GUI_InitHeight Then
        Global $calc = Int($GUI_InitHeight - $iGuiHeight)
        $iGuiHeight = $GUI_InitHeight
        WinMove($gui, "", $iGuiXPos, $iGuiYpos - $calc - 5, $iGuiWidth, $iGuiHeight)
    Else
        WinMove($gui, "", $iGuiXPos, $iGuiYpos, $iGuiWidth, $iGuiHeight)
    EndIf

    $aPos = ControlGetPos($gui, "", $info)
    $sText = $q1
    $sFormattedText = _GetFontSize($q1, $aPos)
    GUICtrlSetFont($info, @extended)
    GUICtrlSetData($info, $sFormattedText)

    adjustfont($iIndex) ; This time the function gets 0 as an index so it knows it is the start point <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                adjustfont($iIndex) ; Here the function gets the current index <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Case $start
                Global $qf = StringSplit(StringStripWS(FileRead($file), 6), @CRLF, 0)
                GUICtrlSetState($start, 32)
                qloop($file)
        EndSwitch
    WEnd
EndFunc   ;==>Main

Func _GetFontSize($sText, $aPos)
    For $iSize = 24 To 8 Step -1 ; 8pt is probably the lowest you want to go

        Local $aRect = _StringSize($sText, $iSize, Default, Default, Default, $aPos[2] - 25)
        ; Save @ & @extendederror
        $iError = @error
        $iExtended = @extended

        Switch $iError
            ; Do nothing
            Case 0
            ; If single word in text too large to fit in the rectangle - continue to reduce size
            Case 3
                ContinueLoop
            ; Any other error is likely to be fatal so set return error flag
            Case Else
                Return SetError($iError, 0, "")
        EndSwitch

        ; Check if text fits
        If $aRect[3] <= $aPos[3] Then
            ; Return font size
            ExitLoop
        EndIf
    Next
    ; If even smallest font size will not fit
    If $iError = 3 Then
        Return SetError(1, 0, "")
    EndIf
    Return SetError(0, $iSize, $aRect[0])
EndFunc   ;==>_GetFontSize

Func qloop($file)

    For $i = 1 To $qf[0] Step 8

        $iIndex = $i ; Set the Global variable to the current index <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        adjustfont($iIndex) ; And use it here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        Do
            Switch GUIGetMsg()
                Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                    adjustfont($iIndex) ; and here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $valid
                    $msg = GUIGetMsg()
                    If $msg = $GUI_EVENT_CLOSE Then
                        Exit
                    EndIf
            EndSwitch
            If $msg = -3 Then Exit
        Until 0
    Next
EndFunc   ;==>qloop

Func adjustfont($iIndex)

    If $iIndex = 0 Then ; It is the initial run <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        $aPos = ControlGetPos($gui, "", $info)
        $sText = $q1
        $sFormattedText = _GetFontSize($sText, $aPos)
        ; If error then <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        If @error Then
            ; Tell user
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($info, @extended)
        EndIf
        GUICtrlSetData($info, $sFormattedText)

    Else ; There is a valid index to use <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        $aPos = ControlGetPos($gui, "", $info)
        $sText = $qf[$iIndex]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @error = 1 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($info, @extended)
        EndIf
        GUICtrlSetData($info, $sFormattedText)

        $aPos = ControlGetPos($gui, "", $a)
        $sText = $qf[$iIndex + 1]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @error = 1 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($a, @extended)
        EndIf
        GUICtrlSetData($a, $sFormattedText)

        $sText = $qf[$iIndex + 2]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @error = 1 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($b, @extended)
        EndIf
        GUICtrlSetData($b, $sFormattedText)

        $sText = $qf[$iIndex + 3]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @extended = 0 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($c, @extended)
        EndIf
        GUICtrlSetData($c, $sFormattedText)

        $sText = $qf[$iIndex + 4]
        $sFormattedText = _GetFontSize($sText, $aPos)
        If @error = 1 Then
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($d, @extended)
        EndIf
        GUICtrlSetData($d, $sFormattedText)

    EndIf

EndFunc   ;==>adjustfont

M23

Melba23,

Thanks for the errorchecking I understand a bit more, but since I'm using the following code to block GUI size from going lower than Width : 800 and Height : 600

Func _WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) ; used to limit the minimum size of the GUI
    #forceref $hWnd, $Msg, $wParam, $lParam
    
    If $hWnd = $gui Then
        Global $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
            DllStructSetData($tagMaxinfo, 7, $GUI_InitWidth) ; min width
            DllStructSetData($tagMaxinfo, 8, $GUI_InitHeight) ; min height
            DllStructSetData($tagMaxinfo, 9, @DesktopWidth) ; max width
            DllStructSetData($tagMaxinfo, 10, @DesktopHeight) ; max height
        Return $GUI_RUNDEFMSG
    EndIf
EndFunc   ;==>_WM_GETMINMAXINFO
;ADD GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") in Main() Function after #EndRegion GUI
GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ;>>>>>>>>>>> Retrieve informations of GUI and Set Min/Max GUI size <<<<<<<<<<<<

my idea would be to increment GUI Height using WinMove until text fit in control but my question is: how can I compare $aRect[3] to $aPos[3] when $aRect[3] only exist if text fit in control ?

If you don't understand my question, please mention it,

Br,

WilliamasKumeliukas

Edited by WilliamasKumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

Spoiler

#1. I am a native French speaker and learned English mainly from chatting with others players in online games.

#2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ^_^

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Link to comment
Share on other sites

  • Moderators

WilliamasKumeliukas,

Limiting the size of the GUI was something I was going to suggest - so good for you!

I do indeed understand the question - but I would counsel against increasing the size of the GUI just to fit long unbroken text strings. Best to make sure you do not have any in the text you wish to display!

If you insist on resizing the GUI when text does not fit, then you are going to have to increase the size of the GUI and then rerun the text sizing code to see if the control is now large enough to display the text. It all sounds horribly recursive and, quite frankly, I am not prepared to continue helping if you do decide to go this way.

If you are prepared to arbitrarily change the GUI size for the user when the text does not fit, why not go for a non-resizeable GUI to begin with? That way you can test the various strings to display before you release them and the user will not have a problem.

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

Melba23,

I don't really like the idea myself about increasing GUI size I just want to do it as last resort, what I really want to understand is why the first text displayed in menu is resized everytime it doesnt fit anymore or has some space free in rectangle but once we click start, NONE of the displayed texts will resize if ANY of them is getting out of their rectangle, it will keep them at 24pt. this is the only reason that make me want to increase GUI size because I didnt understand yet why it crash instead of decreasing $iSize like it should.

5 hours ago, Melba23 said:

but I would counsel against increasing the size of the GUI just to fit long unbroken text strings. Best to make sure you do not have any in the text you wish to display!

If I've understood correctly, your saying that _StringSize will never be able to calculate properly the size a string like : "hello wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww" because these wwww are unbroken ?

Br,

WilliamasKumeliukas

 

Edited by WilliamasKumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

Spoiler

#1. I am a native French speaker and learned English mainly from chatting with others players in online games.

#2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ^_^

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Link to comment
Share on other sites

  • Moderators

WilliamasKumeliukas,

As the code is written, a text will only decrease in font size if the specific control containing it becomes too small to display that particular text - the other texts will remain at the maximum possible font size which fits their own control.  So smaller texts will remain at the maximum size longer than longer ones as the GUI decreases in size. Do I now understand that you want ALL the displayed text to be at the same font size? If so then the code needs to be reworked quite a bit.

And to answer the StringSize question:

StringSize will calculate the size of the string you propose correctly - but if you set a limit on the width for the formatting then the UDF will return an error if the unbroken section is too wide to fit in the required space. The UDF does not know where it can break the string passed to it other then at spaces - hyphenation is well beyond its scope!

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

 

Melba23,

Script is finally working without crashes so far! I did not test everything yet so I wont update thread title as resolved before I tested everything twice.

____________________________________________________________________________________________________________________________________________________________

7 hours ago, Melba23 said:

 Do I now understand that you want ALL the displayed text to be at the same font size? If so then the code needs to be reworked quite a bit.

No, I did not want it but I was planning later to add it as an option in bottom of the GUI, giving ability to users of choosing whether Font size in controls must all be displayed at equal size or not (by default it will be unchecked) but I aldready have few ideas on how i'll do this.

( You might think I am over complicating myself on barely importants details which is adding more time spent and will probably not worth it from your point of view and it's probably true but all this motivation is coming from an important reason which makes this by far from being close to: Just another Quiz script. )

If it piqued your curiousity to know more about it then, say it and I'll be glad to share here for you.

Thank you Melba23 for all the help you gave me and time spent to help me understand, It's greatly appreciated :)

Best Regards,

WilliamasKumeliukas

Edited by WilliamasKumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

Spoiler

#1. I am a native French speaker and learned English mainly from chatting with others players in online games.

#2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ^_^

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Link to comment
Share on other sites

  • Moderators

WilliamasKumeliukas,

Glad I could help. I reworked the script a bit to maker it a bit cleaner - here it is if you are interested:

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

#include "StringSize.au3"

Opt("GUIResizeMode", $GUI_DOCKAUTO)

Global $sStart_Text = "Welcome, I am glad you're willing to help me so I hope" & @CRLF & "everytime this GUI is resized while in qloop function, the script is crashing with following error: " & @CRLF & @CRLF & _
        '"C:\Users\wk\Desktop\williamas kumeliukas\test quiz example.au3" (213) : ==> Subscript used on non-accessible variable.:' & @CRLF & @CRLF & _
        "If $aRect[3] <= $aPos[3] Then" & @CRLF & @CRLF & _
        "If $aRect^ ERROR"

Global $iGUIWidth = Int(@DesktopWidth / 1.20), $iGuiHeight = Int(@DesktopHeight / 1.30)
Global $iGuiXPos = (@DesktopWidth / 2) - $iGUIWidth / 2, $iGuiYpos = (@DesktopHeight / 2) - $iGuiHeight / 2
Global $iGUI_InitWidth = 800, $iGUI_InitHeight = 600
Global $sFileName = @ScriptDir & "\1.txt"
Global $iIndex = 0, $aDisplayText, $hGUI
Global $aDisplay_CIDs[5]
Global $cStart, $cValid

Main()

Func Main()
    $hGUI = GUICreate("Example", $iGUI_InitWidth, $iGUI_InitHeight, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX))

    ; Store display control CIDs in an array
    $aDisplay_CIDs[0] = GUICtrlCreateLabel($sStart_Text, 110, 10, 560, 180, BitOR($WS_BORDER, $SS_CENTER))
    $aDisplay_CIDs[1] = GUICtrlCreateRadio("A)", 20, 200, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))
    $aDisplay_CIDs[2] = GUICtrlCreateRadio("B)", 20, 360, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))
    $aDisplay_CIDs[3] = GUICtrlCreateRadio("C)", 460, 200, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))
    $aDisplay_CIDs[4] = GUICtrlCreateRadio("D)", 460, 360, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

    $cStart = GUICtrlCreateButton("Start", 340, 450, 120, 30, $WS_EX_TOPMOST)
    $cValid = GUICtrlCreateButton("Confirm", 340, 470, 120, 30, $WS_EX_TOPMOST)
    GUICtrlSetState($cValid, $GUI_HIDE)

    GUISetState(@SW_SHOW)

    If $iGuiHeight < $iGUI_InitHeight Then
        Global $iCalc = Int($iGUI_InitHeight - $iGuiHeight)
        $iGuiHeight = $iGUI_InitHeight
        WinMove($hGUI, "", $iGuiXPos, $iGuiYpos - $iCalc - 5, $iGuiWidth, $iGuiHeight)
    Else
        WinMove($hGUI, "", $iGuiXPos, $iGuiYpos, $iGuiWidth, $iGuiHeight)
    EndIf

    $aPos = ControlGetPos($hGUI, "", $aDisplay_CIDs[0])
    $sText = $sStart_Text
    $sFormattedText = _GetFontSize($sText, $aPos)
    GUICtrlSetFont($aDisplay_CIDs[0], @extended)
    GUICtrlSetData($aDisplay_CIDs[0], $sFormattedText)

    adjustfont($iIndex)

    GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; Limit GUI size to 800x600 <<<<<<<<<<

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                adjustfont($iIndex)
            Case $cStart
                $aDisplayText = StringSplit(StringStripWS(FileRead($sFileName), 6), @CRLF, 0)
                GUICtrlSetState($cStart, $GUI_HIDE)
                qloop()
        EndSwitch
    WEnd
EndFunc   ;==>Main

Func qloop()

    For $i = 1 To $aDisplayText[0] Step 8
        $iIndex = $i
        adjustfont($iIndex)
        While 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                    adjustfont($iIndex)
                Case $GUI_EVENT_CLOSE
                    Exit
            EndSwitch
        WEnd
    Next
EndFunc   ;==>qloop

Func adjustfont($iIndex)

    If $iIndex = 0 Then ; It is the initial run <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        $aPos = ControlGetPos($hGUI, "", $aDisplay_CIDs[0])
        $sText = $sStart_Text
        $sFormattedText = _GetFontSize($sText, $aPos)
        ; If error then <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        If @error Then
            ; Tell user
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($aDisplay_CIDs[0], @extended)
        EndIf
        GUICtrlSetData($aDisplay_CIDs[0], $sFormattedText)

    Else ; There is a valid index to use <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        ; Loop through display controls

        For $i = 0 To 4
            $aPos = ControlGetPos($hGUI, "", $aDisplay_CIDs[$i])
            $sText = $aDisplayText[$iIndex + $i]
            ; Will return formatted text or error message
            $sFormattedText = _GetFontSize($sText, $aPos)
            $iFontSize = @extended
            ; If no valid font size returned, set minimum value for error display <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            If @error Then
                $iFontSize = 8
            EndIf
            GUICtrlSetFont($aDisplay_CIDs[$i], $iFontSize)
            GUICtrlSetData($aDisplay_CIDs[$i], $sFormattedText)
        Next

    EndIf

EndFunc   ;==>adjustfont

Func _GetFontSize($sText, $aPos)

    Local $iMinSize = 8

    For $iSize = 24 To $iMinSize Step -1 ; 8pt is probably the lowest you want to go

        Local $aRect = _StringSize($sText, $iSize, Default, Default, Default, $aPos[2] - 25)
        ; Save @error
        $iError = @error

        Switch $iError
            ; Do nothing
            Case 0
            ; If single word in text too large to fit in the rectangle - continue to reduce size
            Case 3
                ContinueLoop
            ; Any other error is likely to be fatal so set return error flag
            Case Else
                ; Return with error text
                Return SetError($iError, 0, "StringSize Error")
        EndSwitch

        ; Check if text fits vertically
        If $aRect[3] <= $aPos[3] Then
            ; Return font size
            ExitLoop
        EndIf
    Next

    ; If even smallest font size will not fit
    If $iError = 3 Or $iSize < $iMinSize Then
        ; Return with error text
        Return SetError(1, 0, "GUI too small")
    EndIf

Return SetError(0, $iSize, $aRect[0])
EndFunc   ;==>_GetFontSize

; Set min and max GUI sizes
 Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
     $tMinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
     DllStructSetData($tMinMaxInfo,  7, $iGUI_InitWidth)
     DllStructSetData($tMinMaxInfo,  8, $iGUI_InitHeight)
     DllStructSetData($tMinMaxInfo,  9, @DesktopWidth)
     DllStructSetData($tMinMaxInfo, 10, @DesktopHeight)
     Return 0
 EndFunc   ;==>_WM_GETMINMAXINFO

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

5 minutes ago, Melba23 said:

WilliamasKumeliukas,

Glad I could help. I reworked the script a bit to maker it a bit cleaner - here it is if you are interested:

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

#include "StringSize.au3"

Opt("GUIResizeMode", $GUI_DOCKAUTO)

Global $sStart_Text = "Welcome, I am glad you're willing to help me so I hope" & @CRLF & "everytime this GUI is resized while in qloop function, the script is crashing with following error: " & @CRLF & @CRLF & _
        '"C:\Users\wk\Desktop\williamas kumeliukas\test quiz example.au3" (213) : ==> Subscript used on non-accessible variable.:' & @CRLF & @CRLF & _
        "If $aRect[3] <= $aPos[3] Then" & @CRLF & @CRLF & _
        "If $aRect^ ERROR"

Global $iGUIWidth = Int(@DesktopWidth / 1.20), $iGuiHeight = Int(@DesktopHeight / 1.30)
Global $iGuiXPos = (@DesktopWidth / 2) - $iGUIWidth / 2, $iGuiYpos = (@DesktopHeight / 2) - $iGuiHeight / 2
Global $iGUI_InitWidth = 800, $iGUI_InitHeight = 600
Global $sFileName = @ScriptDir & "\1.txt"
Global $iIndex = 0, $aDisplayText, $hGUI
Global $aDisplay_CIDs[5]
Global $cStart, $cValid

Main()

Func Main()
    $hGUI = GUICreate("Example", $iGUI_InitWidth, $iGUI_InitHeight, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX))

    ; Store display control CIDs in an array
    $aDisplay_CIDs[0] = GUICtrlCreateLabel($sStart_Text, 110, 10, 560, 180, BitOR($WS_BORDER, $SS_CENTER))
    $aDisplay_CIDs[1] = GUICtrlCreateRadio("A)", 20, 200, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))
    $aDisplay_CIDs[2] = GUICtrlCreateRadio("B)", 20, 360, 320, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))
    $aDisplay_CIDs[3] = GUICtrlCreateRadio("C)", 460, 200, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))
    $aDisplay_CIDs[4] = GUICtrlCreateRadio("D)", 460, 360, 330, 150, BitOR($BS_MULTILINE, $BS_TOP, $WS_EX_TOPMOST))

    $cStart = GUICtrlCreateButton("Start", 340, 450, 120, 30, $WS_EX_TOPMOST)
    $cValid = GUICtrlCreateButton("Confirm", 340, 470, 120, 30, $WS_EX_TOPMOST)
    GUICtrlSetState($cValid, $GUI_HIDE)

    GUISetState(@SW_SHOW)

    If $iGuiHeight < $iGUI_InitHeight Then
        Global $iCalc = Int($iGUI_InitHeight - $iGuiHeight)
        $iGuiHeight = $iGUI_InitHeight
        WinMove($hGUI, "", $iGuiXPos, $iGuiYpos - $iCalc - 5, $iGuiWidth, $iGuiHeight)
    Else
        WinMove($hGUI, "", $iGuiXPos, $iGuiYpos, $iGuiWidth, $iGuiHeight)
    EndIf

    $aPos = ControlGetPos($hGUI, "", $aDisplay_CIDs[0])
    $sText = $sStart_Text
    $sFormattedText = _GetFontSize($sText, $aPos)
    GUICtrlSetFont($aDisplay_CIDs[0], @extended)
    GUICtrlSetData($aDisplay_CIDs[0], $sFormattedText)

    adjustfont($iIndex)

    GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; Limit GUI size to 800x600 <<<<<<<<<<

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                adjustfont($iIndex)
            Case $cStart
                $aDisplayText = StringSplit(StringStripWS(FileRead($sFileName), 6), @CRLF, 0)
                GUICtrlSetState($cStart, $GUI_HIDE)
                qloop()
        EndSwitch
    WEnd
EndFunc   ;==>Main

Func qloop()

    For $i = 1 To $aDisplayText[0] Step 8
        $iIndex = $i
        adjustfont($iIndex)
        While 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE, $GUI_EVENT_RESIZED
                    adjustfont($iIndex)
                Case $GUI_EVENT_CLOSE
                    Exit
            EndSwitch
        WEnd
    Next
EndFunc   ;==>qloop

Func adjustfont($iIndex)

    If $iIndex = 0 Then ; It is the initial run <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        $aPos = ControlGetPos($hGUI, "", $aDisplay_CIDs[0])
        $sText = $sStart_Text
        $sFormattedText = _GetFontSize($sText, $aPos)
        ; If error then <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        If @error Then
            ; Tell user
            $sFormattedText = "GUI too small"
        Else
            GUICtrlSetFont($aDisplay_CIDs[0], @extended)
        EndIf
        GUICtrlSetData($aDisplay_CIDs[0], $sFormattedText)

    Else ; There is a valid index to use <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        ; Loop through display controls

        For $i = 0 To 4
            $aPos = ControlGetPos($hGUI, "", $aDisplay_CIDs[$i])
            $sText = $aDisplayText[$iIndex + $i]
            ; Will return formatted text or error message
            $sFormattedText = _GetFontSize($sText, $aPos)
            $iFontSize = @extended
            ; If no valid font size returned, set minimum value for error display <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            If @error Then
                $iFontSize = 8
            EndIf
            GUICtrlSetFont($aDisplay_CIDs[$i], $iFontSize)
            GUICtrlSetData($aDisplay_CIDs[$i], $sFormattedText)
        Next

    EndIf

EndFunc   ;==>adjustfont

Func _GetFontSize($sText, $aPos)

    Local $iMinSize = 8

    For $iSize = 24 To $iMinSize Step -1 ; 8pt is probably the lowest you want to go

        Local $aRect = _StringSize($sText, $iSize, Default, Default, Default, $aPos[2] - 25)
        ; Save @error
        $iError = @error

        Switch $iError
            ; Do nothing
            Case 0
            ; If single word in text too large to fit in the rectangle - continue to reduce size
            Case 3
                ContinueLoop
            ; Any other error is likely to be fatal so set return error flag
            Case Else
                ; Return with error text
                Return SetError($iError, 0, "StringSize Error")
        EndSwitch

        ; Check if text fits vertically
        If $aRect[3] <= $aPos[3] Then
            ; Return font size
            ExitLoop
        EndIf
    Next

    ; If even smallest font size will not fit
    If $iError = 3 Or $iSize < $iMinSize Then
        ; Return with error text
        Return SetError(1, 0, "GUI too small")
    EndIf

Return SetError(0, $iSize, $aRect[0])
EndFunc   ;==>_GetFontSize

; Set min and max GUI sizes
 Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
     $tMinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
     DllStructSetData($tMinMaxInfo,  7, $iGUI_InitWidth)
     DllStructSetData($tMinMaxInfo,  8, $iGUI_InitHeight)
     DllStructSetData($tMinMaxInfo,  9, @DesktopWidth)
     DllStructSetData($tMinMaxInfo, 10, @DesktopHeight)
     Return 0
 EndFunc   ;==>_WM_GETMINMAXINFO

M23

Melba23,

Thank you, it's definitely cleaner than mine by far, honestly my full script is currently 1801 lines long lol It will take few hours to convert it into your version but I'm still down to do it.

Once again thank you,

Br,

WilliamasKumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

Spoiler

#1. I am a native French speaker and learned English mainly from chatting with others players in online games.

#2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ^_^

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

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

×
×
  • Create New...