Jump to content

Ellipsis styles (3 dots)


Recommended Posts

Hi everybody :)
Yesterday I found a script from @Melba23 where he used Ellipsis styles (3 dots) for label controls and I never heard about them before. Here is the script, where I added code for 3rd/4th labels and comments :

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

$spath = "C:\I am a very long path\Which needs to be\Shortened to fit\In the label.txt"

$hGUI = GUICreate("Test on ellipsis (3 dots)", 500, 250)

GUICtrlCreateLabel($sPath, 10, 10, 300, 40, $DT_PATH_ELLIPSIS) ; in fact SS_ENDELLIPSIS
GUICtrlSetBkColor(-1, 0xC0FFFF)

GUICtrlCreateLabel($sPath, 10, 70, 300, 40, $DT_END_ELLIPSIS) ; in fact SS_PATHELLIPSIS
GUICtrlSetBkColor(-1, 0xFFFF00)

GUICtrlCreateLabel($sPath, 10, 130, 300, 40, $DT_WORD_ELLIPSIS) ; 0x00040000 (but this is the WS_SIZEBOX style, nice effect on label !)
GUICtrlSetBkColor(-1, 0xC0FF00)

GUICtrlCreateLabel($sPath, 10, 190, 300, 40, 0x0000C000) ; SS_WORDELLIPSIS
GUICtrlSetBkColor(-1, 0xC0FFFF)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

#cs
Melba23's comments :
"Note that I am pretty sure the 2 values [$DT_PATH_ELLIPSIS and $DT_END_ELLIPSIS] have been reversed in the [Windows]Constants file
as I would have labelled them the other way round. But MS work in strange ways and perhaps they really are that way." :)

My research :
1) Found in WindowsConstants.au3 and in WinUser.h :
DrawText() Format Flags
#define DT_PATH_ELLIPSIS    0x00004000
#define DT_END_ELLIPSIS     0x00008000
#define DT_WORD_ELLIPSIS    0x00040000

2) Not found in WindowsConstants.au3 but found in WinUser.h :
Static Control Constants
#define SS_ENDELLIPSIS      0x00004000
#define SS_PATHELLIPSIS     0x00008000
#define SS_WORDELLIPSIS     0x0000C000
#ce

Testonellipsis(3dots).png.d0ee3360c8050ad6e7025d2faf12fab8.png

imho the Ellipsis styles applied to label (static) controls should be the ones found on msdn page (i.e. Static Control Styles : SS_ENDELLIPSIS, SS_PATHELLIPSIS and SS_WORDELLIPSIS) but not the ones found in the script above (DT_END_ELLIPSIS, DT_PATH_ELLIPSIS and DT_WORD_ELLIPSIS) which should be applied to the Draw Text function.

First of all, the corresponding styles don't have the same value (see comments at the end of the script) though it's not an issue in this case for two of them, as both 0x00004000 and 0x00008000 can't be mixed with GUI styles, but what about the 3rd ellipsis style (the Word ellipsis style) ?

See what happens in the script when I wrongly use the DT_WORD_ELLIPSIS style for the 3rd label :
It's value of 0x00040000 is the same as the WS_SIZEBOX Gui style (0x00040000) . That's why we see the 3rd label with a raised edge and a sizing border, which doesn't look bad at all (I'll have to remember that !) but the style did not fulfill its role.

The 4th label shows the style that should be applied : SS_WORDELLIPSIS (0x0000C000) instead of DT_WORD_ELLIPSIS (0x00040000)

For the record, as I didn't see any display difference between label 1 (SS_ENDELLIPSIS) and label 4 (SS_WORDELLIPSIS) then I searched on the Web and found this link on Stackoverflow

If you're curious to see a difference between both styles, you can try this on the _WinAPI_DrawText example, with the following change (not the best change but well... at least we can see different displays) :

_WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER) ; original line in help file example

; _WinAPI_DrawText($g_hDC, "Hi" & @crlf & " world, how are you ?", $g_tRECT, $DT_END_ELLIPSIS)
; _WinAPI_DrawText($g_hDC, "Hi" & @crlf & " world, how are you ?", $g_tRECT, $DT_WORD_ELLIPSIS)

Thanks Melba23 for this Ellipsis discovery and just feel free to comment if I wrote anything wrong.
Have a great week-end :bye:

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