Jump to content

Vertical Label?


Recommended Posts

I think I've just about searched the whole forum for this and haven't found anything(correct me if I'm wrong). Is there a way to have a label control displays text vertically? Or maybe rotate the control? Would it be possible to achieve this with GDI+ maybe?

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

There is a way to rotate a label but it's not perfect... you can search for it, I'm too busy now

here is a work around

GUICreate("")
GUISetFont(40, 500)

GUICtrlCreateLabel("L", 50, 100)
GUICtrlCreateLabel("a", 50, 150)
GUICtrlCreateLabel("b", 50, 200)
GUICtrlCreateLabel("e", 50, 250)
GUICtrlCreateLabel("l", 57, 300)

GUISetState()

Sleep(5000)

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Malkey's work with GDIPlus here:

http://www.autoitscript.com/forum/index.php?s=&showtopic=93289&view=findpost&p=670844

BugFix's work with WinApi rotation here:

http://www.autoitscript.com/forum/index.php?s=&showtopic=93402&view=findpost&p=671084

Link to comment
Share on other sites

One prob with the WinAPI method though. I managed to put it all in a function, but it only allows me to draw one lot of text at a time.

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

Here an example from BugFix:

#include <WinApi.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

_Main()

Func _Main ()
    Local $hGUI, $tRect, $rotate, $RotateMe, $rFont, $hDC

    ; Create GUI
    $hGUI = GUICreate ('', 500, 400)
    GUISetState ()

    ; Updates the specified rectangle or region in a window's client area
    _WinAPI_RedrawWindow ($hGUI)

    ; Create RECT-structure, fill data
    $tRect = DllStructCreate ($tagRECT)
    DllStructSetData ($tRect, 'Left', 180)
    DllStructSetData ($tRect, 'Top', 390)

    ; Set rotation
    $rotate = 90 *10 ; angle *10

    ; Create structure for rotate text, fill data
    $RotateMe = DllStructCreate ($tagLOGFONT)
    DllStructSetData ($RotateMe, 'Escapement', $rotate)
    DllStructSetData ($RotateMe, 'Height', (60 * -20)/_WinAPI_TwipsPerPixelY())
    DllStructSetData ($RotateMe, 'Weight', 800)
    DllStructSetData ($RotateMe, 'Italic', True)
;~ ;DllStructSetData ($RotateMe, 'Underline', True)
;~ ;DllStructSetData ($RotateMe, 'StrikeOut', True)
    DllStructSetData ($RotateMe, 'FaceName', 'Courier New')

    ; Creates a logical font that has specific characteristics
    $rFont = _WinAPI_CreateFontIndirect ($RotateMe)

    ; Retrieves a handle of a display device context for the client area a window
    $hDC = _WinAPI_GetDC ($hGUI)

    ; Set text- and back color
    _WinAPI_SetTextColor ($hDC, 0x0000FF)
    _WinAPI_SetBkColor ($hDC, 0xFFFF00)

    ; Selects an object into the specified device context
    _WinAPI_SelectObject ($hdc, $rFont)

    ; Draws formatted text in the specified rectangle
    _WinAPI_DrawText ($hDC, ' Hallo! ', $tRect, BitOR ($DT_NOCLIP,$DT_NOPREFIX))

    ; Loop until user exits
    Do
    Until GUIGetMsg () = -3

    ; Clean up resources
    _WinAPI_ReleaseDC ($hGUI, $hDC)

EndFunc ;==>_Main

Or just as a function which I used in Fussbal Chronograph (German only):

;danke an BugFix für das Beispiel
Func Display_Rotated_Text($hGUI, $text, $px, $py, $angle = 90, $tw = 400, $th = 12, $tcolor = 0x000000, $bcolor = 0xF0F0F0, $font = 'Arial', $transparent = True)
    Local $tRect, $rotate, $RotateMe, $rFont, $hDC

    ; Create RECT-structure, fill data
    $tRect = DllStructCreate ($tagRECT)
    DllStructSetData ($tRect, 'Left', $px)
    DllStructSetData ($tRect, 'Top', $py)

    ; Set rotation
    $rotate = $angle * 10

    ; Create structure for rotate text, fill data
    $RotateMe = DllStructCreate ($tagLOGFONT)
    DllStructSetData ($RotateMe, 'Escapement', $rotate)
    DllStructSetData ($RotateMe, 'Weight', $tw)
    DllStructSetData ($RotateMe, 'Height', $th)
    DllStructSetData ($RotateMe, 'FaceName', $font)

    ; Creates a logical font that has specific characteristics
    $rFont = _WinAPI_CreateFontIndirect ($RotateMe)

    ; Retrieves a handle of a display device context for the client area a window
    $hDC = _WinAPI_GetDC ($hGUI)

    ; Set text- and back color
    _WinAPI_SetTextColor ($hDC, $tcolor)
    _WinAPI_SetBkColor ($hDC, $bcolor)
    If $transparent Then _WinAPI_SetBkMode($hDC, $TRANSPARENT)

    ; Selects an object into the specified device context
    _WinAPI_SelectObject ($hdc, $rFont)

    ; Draws formatted text in the specified rectangle
    _WinAPI_DrawText ($hDC, $text, $tRect, $DT_NOCLIP + $DT_NOPREFIX)

    $tRect = 0
EndFunc

Have fun!

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks, your bottom one works perfect when using it more than once. I found out the top one didn't because of the _WinAPI_RedrawWindow().

However now I am faced with another problem: The text will disappear when the windows is hidden, then shown again, or even after a minimize and restore. Any way to fix this?

EDIT: What about drawing the text in a TabItem? I haven't been able to find to do so.

Edited by Vadersapien
Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

Here an example with redraw:

;example by UEZ
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
Local $hWnd = GUICreate("Rotating Text", 320, 200)
GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

Display_Text()

GUIRegisterMsg(0x000F, "Redraw_GUI")


While Sleep(10000000)
WEnd

Func Display_Text()
    Display_Rotated_Text($hWnd, "Rotated Text #1", 10, 150, 90, 800)
    Display_Rotated_Text($hWnd, "Rotated Text #2", 100, 15, 0, 800)
    Display_Rotated_Text($hWnd, "Rotated Text #3", 300, 15, 270, 800)
    Display_Rotated_Text($hWnd, "Rotated Text #4", 200, 180, 180, 800)
    Display_Rotated_Text($hWnd, "Rotated Text #5", 100, 110, 45, 800)
    Display_Rotated_Text($hWnd, "Rotated Text #6", 160, 120, 135, 800)
EndFunc

Func Redraw_GUI($hWnd, $msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hWnd, "", "", $RDW_UPDATENOW + $RDW_FRAME)
    Display_Text()
    Return $GUI_RUNDEFMSG
EndFunc ;==>Redraw_GUI


;danke an BugFix für das Beispiel
Func Display_Rotated_Text($hGUI, $text, $px, $py, $angle = 90, $tw = 400, $th = 12, $tcolor = 0x000000, $bcolor = 0xF0F0F0, $font = 'Arial', $transparent = True)
    Local $tRect, $rotate, $RotateMe, $rFont, $hDC

    ; Create RECT-structure, fill data
    $tRect = DllStructCreate ($tagRECT)
    DllStructSetData ($tRect, 'Left', $px)
    DllStructSetData ($tRect, 'Top', $py)

    ; Set rotation
    $rotate = $angle * 10

    ; Create structure for rotate text, fill data
    $RotateMe = DllStructCreate ($tagLOGFONT)
    DllStructSetData ($RotateMe, 'Escapement', $rotate)
    DllStructSetData ($RotateMe, 'Weight', $tw)
    DllStructSetData ($RotateMe, 'Height', $th)
    DllStructSetData ($RotateMe, 'FaceName', $font)

    ; Creates a logical font that has specific characteristics
    $rFont = _WinAPI_CreateFontIndirect ($RotateMe)

    ; Retrieves a handle of a display device context for the client area a window
    $hDC = _WinAPI_GetDC ($hGUI)

    ; Set text- and back color
    _WinAPI_SetTextColor ($hDC, $tcolor)
    _WinAPI_SetBkColor ($hDC, $bcolor)
    If $transparent Then _WinAPI_SetBkMode($hDC, $TRANSPARENT)

    ; Selects an object into the specified device context
    _WinAPI_SelectObject ($hdc, $rFont)

    ; Draws formatted text in the specified rectangle
    _WinAPI_DrawText ($hDC, $text, $tRect, $DT_NOCLIP + $DT_NOPREFIX)

    $tRect = 0
EndFunc

Func _Exit()
    Exit
EndFunc

Maybe it is working also for Tabitems! I need to test it later...

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Ok, that works, and I figured out a crude way to let in work in TabItems(hide and show when needed).

My redraw function:

Func Redraw($hWnd, $msg, $wParam, $lParam)
    If GUICtrlRead($LiveControlCommandsTab) = 1 Then
        _WinAPI_RedrawWindow($hWnd, '', '', $RDW_UPDATENOW)
        _WinAPI_DrawRotatedText($hGUI, 'Test', 5, 50)
        _WinAPI_DrawRotatedText($hGUI, 'Test', 25, 50)
        _WinAPI_DrawRotatedText($hGUI, 'Test', 45, 50)
        _WinAPI_DrawRotatedText($hGUI, 'Test', 65, 50)
    Else
        _WinAPI_RedrawWindow($hWnd)
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc

Is there a better way to do it?

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
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...