Jump to content
Sign in to follow this  
Fossil Rock

Font picker using _ChooseFont

Recommended Posts

Fossil Rock

When selecting a font, _ChooseFont can reuse the font Name and Size, but is there a way to reuse the other parameters like style and effects ?

I would like to select a new font starting with the current font being used with all the current attibutes.

Modified example from help file.

#include <Misc.au3>

Local $a_font

$a_font = _ChooseFont ("Arial",10)
If (@error) Then
   MsgBox(0, "", "Error _ChooseFont: " & @error)
Else
   MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf

$a_font = _ChooseFont ($a_font[2], $a_font[3])
If (@error) Then
   MsgBox(0, "", "Error _ChooseFont: " & @error)
Else
   MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
GaryFrost

Suggest looking at the function in the Misc.au3, I left the structure information commented in there.

If you want to make a customized or re-vamp for a better one with optional params that's ok with me.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Fossil Rock

I also noticed that, with the code above, it doesn't return the right Size when it goes back the second time.

http://www.autoitscript.com/fileman/users/Fossil%20Rock/Font%20Selector.PNG


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
Fossil Rock

Suggest looking at the function in the Misc.au3, I left the structure information commented in there.

If you want to make a customized or re-vamp for a better one with optional params that's ok with me.

Ok, I'll give it a go ... maybe I'll find the font Size thing too.


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
GaryFrost

Ok, I'll give it a go ... maybe I'll find the font Size thing too.

to help you out with the size, 2 lines are the problem

Local $lfHeight = Round(($i_size * $ret[2]) / 72, 0)
oÝ÷ Ù©Ýjëh×6
    DllStructSetData($lf, 1, $lfHeight + 1)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Fossil Rock

I was immediately drawn to those 2 lines, but I don't have a clue about the dll stuff ... but I'm trying. :">


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
GaryFrost

I was immediately drawn to those 2 lines, but I don't have a clue about the dll stuff ... but I'm trying. :">

At the time I wrote that I didn't either.

I'm thinking a diff. dll call might be better, maybe textmextrics instead of devicecaps


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Fossil Rock

Works like a charm, Thanks.

Would it be asking to much to help me figure out the other stuff ? I really have no clue how to modify <misc.au3> for the style, effects and color.

Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
GaryFrost

Works like a charm, Thanks.

Would it be asking to much to help me figure out the other stuff ? I really have no clue how to modify <misc.au3> for the style, effects and color.

I'll take a look at it when I get a chance.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
GaryFrost

#include <Misc.au3>

Local $a_font

$a_font = _ChooseFont("Courier New", 10)
If (@error) Then
    MsgBox(0, "", "Error _ChooseFont: " & @error)
    Exit
Else
    MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf

$a_font = _ChooseFont($a_font[2], $a_font[3],$a_font[5], $a_font[4] ,BitAND($a_font[1],2),BitAND($a_font[1],4),BitAND($a_font[1],8))
If (@error) Then
    MsgBox(0, "", "Error _ChooseFont: " & @error)
Else
    MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Fossil Rock

Very nice thank you .... but BOLD is not returning correctly, it sets back to normal.


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
Fossil Rock

Now it goes back to regular regardless if it's Italic, Bold or Bold Italic. I've been looking at differences hoping I could figure it out, but haven't so far.

Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
GaryFrost

#include <Misc.au3>

Local $a_font

; Example 1
$a_font = _ChooseFont("Arial", 8)
If (@error) Then
    MsgBox(0, "", "Error _ChooseFont: " & @error)
Else
    MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf

; Example 2
$a_font = _ChooseFont()
If (@error) Then
    MsgBox(0, "", "Error _ChooseFont: " & @error)
    Exit
Else
    MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf

; Example 3
Local $FontName = $a_font[2]
Local $FontSize = $a_font[3]
Local $ColorRef = $a_font[5]
Local $FontWeight = $a_font[4]
Local $Italic = BitAND($a_font[1], 2)
Local $Underline = BitAND($a_font[1], 4)
Local $Strikethru = BitAND($a_font[1], 8)
$a_font = _ChooseFont($FontName, $FontSize, $ColorRef, $FontWeight, $Italic, $Underline, $Strikethru)
If (@error) Then
    MsgBox(0, "", "Error _ChooseFont: " & @error)
Else
    MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
GaryFrost

Now it goes back to regular regardless if it's Italic, Bold or Bold Italic. I've been looking at differences hoping I could figure it out, but haven't so far.

Nothing to figure out, see my above examples, especially the 3rd one.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.