Sign in to follow this  
Followers 0
TheSaint

Rotate a Label &/or Input

9 posts in this topic

#1 ·  Posted (edited)

This is essentially solved enough for me ... while not actually rotating either type of control, the code Bugfix supplied allowed me to do what I ultimately wanted.

See Posts #3 & #9 below.

I've just done a mostly fruitless search, where only a GDI+ topic about angled text came close to what I want. I haven't taken that topic apart yet, but thought while I was here, I might as well ask for help or advice. I did searches on text direction, angled text, label angle, rotate label & rotate input.

I've got a project on the wings which is a CD Cover Creator addon to one of my other major projects. Obviously, for a CD Cover creating project to be even viable, I need to be able to have text be rotated through 90 degrees, for the case's two spines. To do this with a label or input would be ideal, but I don't know if this is possible ... either with or without a DLL, or whether it has to be image based (as in the GDI+ topic mentioned). Obviously clicking on an image, could produce an input, which could be turned into a rotated text image when you click OK, and then placed in position ... but I was wondering if I could do without that method, or if an existing Windows DLL or EXE (command-line) would make that relatively easy?

Any help or advice will be much appreciated!

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You will probably need a DLL call or some GDI+ to get it right but this is the general idea. The only thing wrong is that the lower label should be flipped vertically. I don't think there is anything like _GDIPlus_Image_FromString() but you might be able to do something with _GDIPlus_StringFormatCreate()

;
#include<String.au3>
#include<StaticConstants.au3>
$Gw = 600
$Gh = 650
$sText = "My CD Title"
$Frm_main = GUICreate("U-Jacket", $Gw, $Gh)
GUISetFont(9)
$Lbl_Left = GUICtrlCreateLabel($sText, 10, 0, $Gw-20, 25, $SS_CENTERIMAGE)
$Lbl_Right = GUICtrlCreateLabel(_StringReverse($sText), 10, $Gh-25, $Gw-20, 25, BitOR($SS_RIGHT, $SS_CENTERIMAGE))
GUISetState()
While 1
   If GUIGetMsg() = -3 Then Exit
WEnd
;

EDIT. For my own U-Jackets I just use a Word template that I created so that is another possibility that you could look at.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Is it, what you want:

#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

Best Regards BugFix  

Share this post


Link to post
Share on other sites

You will probably need a DLL call or some GDI+ to get it right but this is the general idea. The only thing wrong is that the lower label should be flipped vertically. I don't think there is anything like _GDIPlus_Image_FromString() but you might be able to do something with _GDIPlus_StringFormatCreate()

EDIT. For my own U-Jackets I just use a Word template that I created so that is another possibility that you could look at.

Thanks for responding, and I'll check it out shortly!

As far as Word templates go, I created a superb one myself several years ago, that later incorporated a DVD element, with a full range of sizes for all CD's & DVD's. It has very comprehensive macros, that read the Cdplayer.ini file, scan the CD's for times, create's table, read's data discs, etc, etc, etc. But I always wanted a stand-alone program not reliant on Word, that I could have full control of. I have many CD Cover creating programs (been collecting them for years), and none satisfy me ... but my Word template gets closest.

My CDIni Database program can now scan CD times into it, read CDText and query FreeDB. I've just started work on an Ipod notes feature for it, and having it create CD covers with almost full automation would be a nice element to add next. I've added so many great features into the program since I last uploaded it to the Forum (currently working on v5.5), that I haven't had the right moment to upload the latest versions ... keep saying - "I'll just add one more feature".


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Is it, what you want:

Thanks, that could be it ... seems to work well, though I'm yet to understand what's actually going on. ;)

Now all I have to do is study it, understand it, etc ... and check it's flexibility! ^_^


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

@BugFix - once again, I'd like to thank you. I've had a chance now, to play around a bit and see a possible way forward, but need to figure out a few more things when I get the time to do so. So far, I've got positioning and font size sorted out and have several ideas about live adjustments (slider toolbars probably, etc), but I'm yet to try having both left and right spines exist at the same time ... but what you've provided me with is very promising, and so you will be sure to get a mention when I'm finished.

THANKS!

@GEOSoft - thanks to you also, even though at this stage, I don't think I need to pursue what you suggest any further. I forgot to add, that my Word macros, are also great for creating many page CD/DVD booklets (double-sided of course). In fact, I have a specific scenario for a Mp3 CD, that I house in a DVD case, that I use with a HTML based program (Neon Goat I think it's called), that extracts all the Mp3 data to a web page, that the program allows me to fully configure, which my Word macros interact with, so that I end up with a many page DVD booklet, that lists a few hundred Mp3's by filename and full detail (artist, title, time, bit rate, etc), and a Artists list only on the back of the case ... but I haven't tried it with a Mp3 DVD yet though ... that might be too much methinks.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

My templates are pretty straight forward and there are plenty available. The only reason I created a template for U-Jackets was because all the ones I found did 1 per page. Mine is a 2 up layout. I also use 28lb paper for them and I hate a bunch of waste paper. I also have other CD/DVD templates like the one for doing the slip in covers for the large plastic DVD cases that you see movies come in. I have a large supply of empty cases so I do use them qite often. For example the wife hates those movie cases wher they use a combination of plastic and light cardboard and I often have to make up new cases for her collection.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

My templates are pretty straight forward and there are plenty available. The only reason I created a template for U-Jackets was because all the ones I found did 1 per page. Mine is a 2 up layout. I also use 28lb paper for them and I hate a bunch of waste paper. I also have other CD/DVD templates like the one for doing the slip in covers for the large plastic DVD cases that you see movies come in. I have a large supply of empty cases so I do use them qite often. For example the wife hates those movie cases wher they use a combination of plastic and light cardboard and I often have to make up new cases for her collection.

I should provide my Word stuff to others I guess ... I have given them to a few friends, and one old workmate still uses them last I heard ... though they might seem a bit complex to some. ;)

As mentioned on another topic in Chat - You know when you are using AutoIt too much .... when you have a huge backlog of CD/DVD covers to create (mostly DVD). It's not that I burn heaps of DVD's (or CD's very often these days), I just haven't kept up for such a long time now (mostly TV episode thingies & Doco's ... many of which I still haven't even watched). Have I got a life ... probably not! Have I got a wife ... just! :(

My life is full of endless little slips of paper ... which funnily enough, are scraps left over from making many covers eons ago (or damn nearly) ... and I had a regular icecream container full when I started ... nearly empty now. ^_^


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

It's only early days, but you can see how far I've taken this so far, here.

It's a little quick and dirty, but seems very promising.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


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
Sign in to follow this  
Followers 0