Jump to content

StringSize - M23 - New version 16 Aug 11


Recommended Posts

Hi again,

Soooo... this is awkward.... i went through my code did a little cleaning and tidying up, switched and changed some stuff here and there... added other things... lo and behold it suddenly works fine...
What was it you ask? well... its like... you know... i have no clue :P
I even tried to break it again by commenting out new things and a few changes i did to revert them but it stays working.
I'm happy tho :P

Link to post
Share on other sites
  • Replies 84
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

New version - 16 Aug 11 New: New method to get the required font into the Display Context for sizing via GetTextExtentPoint32W. Default code (by trancexx ) or you can add the handle of your GUI

Local $aSize2 = _StringSize(" ", $iFontSize, $iWeight, 0, $sFontName) for $i = 0 to 3 $aSize[$i] += $aSize2[$i] Next I believe this would work as a workaround Reading thro

Posted (edited)

I'm getting a:
;                  |2 - DLL call error - extended set as follows:
;                       |2 - SendMessage failure

what does this mean?

Error msgbox with the parameters and the 2 error codes
$StringInfo = _StringSize($Talker_Name,$TempFontSize,$TempFontWeight,0,$TempFontType,$GuiWidth-$TempLabelSpacingH-12,$hGUI)
S9PUosn.png

Edit:
GUISwitch($hGUI) prior to calling _StringSize seems to get around it

Edited by Aapjuh
Link to post
Share on other sites
  • Moderators

Aapjuh,

18 hours ago, Aapjuh said:

what does this mean?

Exactly what it says - there was an error in the SendMessage call (which returns the current font) to the GUI you specified in the StringSize call. Using GUISwitch to get that particular GUI active would have been my suggestion, so I am delighted to see that doing so solved the 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 post
Share on other sites
Posted (edited)

Me again :P

Getting error 3 (|3 - Font too large for chosen max width - a word will not fit )

; Check at least 1 word completed or return error
This part in your code says it checks if  'at least 1 fits' but its actually 'if 1 word doesn't fit throw error'

if i have a maxwidth of 50, and the string passed is "bla bla bla blaaaaaaaaaaaaaaaaa" even tho 'bla bla bla' each fit, there's 1 word that doesn't and it throws the error.
it would be nice to wrap 'blaaaaaaaaaaaaaaaaa' like:

bla
bla
bla
b
l
a
a
a
a
a
a
a

Reason im asking is because the program im making read chatlog and removes the usual system stuf like color codes and time stamps, but people in chat are prone to spam dramatic 'Noooooooooooo...!!'

Edited by Aapjuh
Link to post
Share on other sites
  • Moderators

Aapjuh,

Two possible solutions:

1. Increase the MaxWidth parameter - 50 is not very wide.

2. Preprocess your string so that you split words that are too long - here is a simple example based on your string above:

#include <Array.au3>
#include <StringSize.au3>

$sText = "bla bla bla blaaaaaaaaaaaaaaaaa"

$aSplit_1 = StringSplit($sText, " ")

_ArrayDisplay($aSplit_1, "", Default, 8)

For $i = 1 To $aSplit_1[0]
    $aRet = _StringSize($aSplit_1[$i])
    If $aRet[2] > 50 Then
        $aSplit_2 = StringSplit($aSplit_1[$i], "")
        For $j = 1 To $aSplit_2[0]
            ConsoleWrite($aSplit_2[$j] & @CRLF)
        Next
    Else
        ConsoleWrite($aSplit_1[$i] & @CRLF)
    EndIf
Next

That gives you the result you require - but you have to do the work to split the overlong string.

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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...