Sign in to follow this  
Followers 0
funkey

_GuiCtrlSetFont (rotating control texts)

6 posts in this topic

I hope you like it.

#Region _GuiCtrlSetFont.au3
;Copyrights to funkey !!

#include <WinAPI.au3>

OnAutoItExitRegister("_FontCleanUp")
Global $ahFontEx[1] = [0]

Func _GuiCtrlSetFont($controlID, $size, $weight = 400, $attribute = 0, $rotation = 0, $fontname= "", $quality = 2)
    Local $fdwItalic = BitAND($attribute, 1)
    Local $fdwUnderline = BitAND($attribute, 2)
    Local $fdwStrikeOut = BitAND($attribute, 4)
    
    ReDim $ahFontEx[UBound($ahFontEx) + 1]
    $ahFontEx[0] += 1   
    
    $ahFontEx[$ahFontEx[0]] = _WinAPI_CreateFont($size, 0, $rotation * 10, $rotation, $weight, _
                            $fdwItalic, $fdwUnderline, $fdwStrikeOut, -1, 0, 0, $quality, 0, $fontname)
    
    GUICtrlSendMsg($controlID, 48, $ahFontEx[$ahFontEx[0]], 1)
EndFunc

Func _FontCleanUp()
    For $i = 1 To $ahFontEx[0]
        _WinAPI_DeleteObject($ahFontEx[$i])
    Next
EndFunc
#EndRegion

Global $hGui1 = GuiCreate("AutoIt Main-GUI", 300, 340, 100, 100, -1, 0);


For $i = 0 To 350 Step 30
    GUICtrlCreateLabel("This is rotating", 50, 0, 300, 220, 0x201)
    _GuiCtrlSetFont(-1, 15, 1000, 1, $i)
    GUICtrlSetBkColor(-1, -2)
Next


GUICtrlCreateLabel("This is a vertical label", 10, 30,200, 200, 0x001)
_GuiCtrlSetFont(-1, 15, 400, 1, -90)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel("This too!!", 130, 50, 200, 200, 0x202)
_GuiCtrlSetFont(-1, 15, 400, 1, 90)
GUICtrlSetBkColor(-1, -2)

GuiCtrlCreateButton("This is a cool button text", 10, 220, 275, 60, 0x0800);
_GuiCtrlSetFont(-1, 20, 1000, 1, 8)

GuiCtrlCreateCombo("Hello", 10, 290, 275, 80, 0x3, -1);
_GuiCtrlSetFont(-1, 15, 1000, 1, -3)
GUICtrlSetData(-1, "Item2|Item3")

GuiSetState(@SW_SHOW, $hGui1);

Do
Until GUIGetMsg() = -3
2 people like this

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites



It's nice but why don't you clean up the font object after this line?

GUICtrlSendMsg($controlID, 48, $ahFontEx[$ahFontEx[0]], 1)

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Did you try it?


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

I hope you like it.

 

#Region _GuiCtrlSetFont.au3
;Copyrights to funkey !!

#include <WinAPI.au3>

OnAutoItExitRegister("_FontCleanUp")
Global $ahFontEx[1] = [0]

Func _GuiCtrlSetFont($controlID, $size, $weight = 400, $attribute = 0, $rotation = 0, $fontname= "", $quality = 2)
    Local $fdwItalic = BitAND($attribute, 1)
    Local $fdwUnderline = BitAND($attribute, 2)
    Local $fdwStrikeOut = BitAND($attribute, 4)
    
    ReDim $ahFontEx[UBound($ahFontEx) + 1]
    $ahFontEx[0] += 1   
    
    $ahFontEx[$ahFontEx[0]] = _WinAPI_CreateFont($size, 0, $rotation * 10, $rotation, $weight, _
                            $fdwItalic, $fdwUnderline, $fdwStrikeOut, -1, 0, 0, $quality, 0, $fontname)
    
    GUICtrlSendMsg($controlID, 48, $ahFontEx[$ahFontEx[0]], 1)
EndFunc

Func _FontCleanUp()
    For $i = 1 To $ahFontEx[0]
        _WinAPI_DeleteObject($ahFontEx[$i])
    Next
EndFunc
#EndRegion

Global $hGui1 = GuiCreate("AutoIt Main-GUI", 300, 340, 100, 100, -1, 0);


For $i = 0 To 350 Step 30
    GUICtrlCreateLabel("This is rotating", 50, 0, 300, 220, 0x201)
    _GuiCtrlSetFont(-1, 15, 1000, 1, $i)
    GUICtrlSetBkColor(-1, -2)
Next


GUICtrlCreateLabel("This is a vertical label", 10, 30,200, 200, 0x001)
_GuiCtrlSetFont(-1, 15, 400, 1, -90)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel("This too!!", 130, 50, 200, 200, 0x202)
_GuiCtrlSetFont(-1, 15, 400, 1, 90)
GUICtrlSetBkColor(-1, -2)

GuiCtrlCreateButton("This is a cool button text", 10, 220, 275, 60, 0x0800);
_GuiCtrlSetFont(-1, 20, 1000, 1, 8)

GuiCtrlCreateCombo("Hello", 10, 290, 275, 80, 0x3, -1);
_GuiCtrlSetFont(-1, 15, 1000, 1, -3)
GUICtrlSetData(-1, "Item2|Item3")

GuiSetState(@SW_SHOW, $hGui1);

Do
Until GUIGetMsg() = -3

 

nice but  font color  how?

Share this post


Link to post
Share on other sites

Just use GUICtrlSetColor() to set the font color. Only using background color is a problem.

#Region _GuiCtrlSetFont.au3
;Copyrights to funkey !!

#include <WinAPI.au3>

OnAutoItExitRegister("_FontCleanUp")
Global $ahFontEx[1] = [0]

Func _GuiCtrlSetFont($controlID, $size, $weight = 400, $attribute = 0, $rotation = 0, $fontname= "", $quality = 2)
Local $fdwItalic = BitAND($attribute, 1)
Local $fdwUnderline = BitAND($attribute, 2)
Local $fdwStrikeOut = BitAND($attribute, 4)

ReDim $ahFontEx[UBound($ahFontEx) + 1]
$ahFontEx[0] += 1

$ahFontEx[$ahFontEx[0]] = _WinAPI_CreateFont($size, 0, $rotation * 10, $rotation, $weight, _
$fdwItalic, $fdwUnderline, $fdwStrikeOut, -1, 0, 0, $quality, 0, $fontname)

GUICtrlSendMsg($controlID, 48, $ahFontEx[$ahFontEx[0]], 1)
EndFunc

Func _FontCleanUp()
For $i = 1 To $ahFontEx[0]
_WinAPI_DeleteObject($ahFontEx[$i])
Next
EndFunc
#EndRegion

Global $hGui1 = GuiCreate("_GuiCtrlSetFont example", 300, 340, 100, 100, -1, 0);


For $i = 0 To 350 Step 30
GUICtrlCreateLabel("This is rotating", 50, 0, 300, 220, 0x201)
GUICtrlSetColor(-1, Random(0, 0xffffff, 1))
_GuiCtrlSetFont(-1, 15, 1000, 1, $i)
GUICtrlSetBkColor(-1, -2)
Next


GUICtrlCreateLabel("This is a vertical label", 10, 30,200, 200, 0x001)
GUICtrlSetColor(-1, Random(0, 0xffffff, 1))
_GuiCtrlSetFont(-1, 15, 400, 1, -90)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel("This too!!", 130, 50, 200, 200, 0x202)
GUICtrlSetColor(-1, Random(0, 0xffffff, 1))
_GuiCtrlSetFont(-1, 15, 400, 1, 90)
GUICtrlSetBkColor(-1, -2)

GuiCtrlCreateButton("This is a cool button text", 10, 220, 275, 60, 0x0800);
_GuiCtrlSetFont(-1, 20, 1000, 1, 8)

GuiCtrlCreateCombo("Hello", 10, 290, 275, 80, 0x3, -1);
GUICtrlSetColor(-1, Random(0, 0xffffff, 1))
_GuiCtrlSetFont(-1, 15, 1000, 1, -3)
GUICtrlSetData(-1, "Item2|Item3")

GuiSetState(@SW_SHOW, $hGui1);

Do
Until GUIGetMsg() = -3
1 person likes this

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

very cool

but text  color and  background color transparent  how?

this code

#Region _GuiCtrlSetFont.au3
;Copyrights to funkey !!
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>

OnAutoItExitRegister("_FontCleanUp")
Global $ahFontEx[1] = [0]

Func _GuiCtrlSetFont($controlID, $size, $weight = 400, $attribute = 0, $rotation = 0, $fontname= "", $quality = 2)
Local $fdwItalic = BitAND($attribute, 1)
Local $fdwUnderline = BitAND($attribute, 2)
Local $fdwStrikeOut = BitAND($attribute, 4)

ReDim $ahFontEx[UBound($ahFontEx) + 1]
$ahFontEx[0] += 1

$ahFontEx[$ahFontEx[0]] = _WinAPI_CreateFont($size, 0, $rotation * 10, $rotation, $weight, _
$fdwItalic, $fdwUnderline, $fdwStrikeOut, -1, 0, 0, $quality, 0, $fontname)

GUICtrlSendMsg($controlID, 48, $ahFontEx[$ahFontEx[0]], 1)
EndFunc

Func _FontCleanUp()
For $i = 1 To $ahFontEx[0]
_WinAPI_DeleteObject($ahFontEx[$i])
Next
EndFunc
#EndRegion
Global $TemaShe = @ScriptDir & "\BLacK.she"
Global $TemaDLL = @ScriptDir & "\BLacK.dll"
$Dll = DllOpen ($TemaDLL)
DllCall ( $Dll, "int", "SkinH_AttachEx", "str",$TemaShe, "str", "mhgd" )
DllCall ( $Dll, "int", "SkinH_SetAero", "int", 1 )
Global $hGui1 = GUICreate("GDI ", 400, 400)
$Pic1 = GUICtrlCreatePic(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1)) & "Examples\GUI\msoobe.jpg", 0, 0, 400, 400, 0)
GUICtrlSetState( $Pic1 , $GUI_disable)



For $i = 0 To 350 Step 30
GUICtrlCreateLabel("This is rotating", 50, 0, 300, 220, 0x201)
GUICtrlSetColor(-1, Random(0, 0xffffff, 1))
_GuiCtrlSetFont(-1, 15, 1000, 1, $i)
GUICtrlSetBkColor(-1, -2)
Next


GUICtrlCreateLabel("This is a vertical label", 10, 30,200, 200, 0x001)
GUICtrlSetColor(-1, Random(0, 0xffffff, 1))
_GuiCtrlSetFont(-1, 15, 400, 1, -90)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel("This too!!", 130, 50, 200, 200, 0x202)
GUICtrlSetColor(-1, Random(0, 0xffffff, 1))
_GuiCtrlSetFont(-1, 15, 400, 1, 90)
GUICtrlSetBkColor(-1, -2)

GuiCtrlCreateButton("This is a cool button text", 10, 220, 275, 60, 0x0800);
_GuiCtrlSetFont(-1, 20, 1000, 1, 8)

GuiCtrlCreateCombo("Hello", 10, 290, 275, 80, 0x3, -1);
GUICtrlSetColor(-1, Random(0, 0xffffff, 1))
_GuiCtrlSetFont(-1, 15, 1000, 1, -3)
GUICtrlSetData(-1, "Item2|Item3")

GuiSetState(@SW_SHOW, $hGui1);

Do
Until GUIGetMsg() = -3

and files

http://www.mediafire.com/?b3fy46l481d1yzb

Edited by mesale0077

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