Sign in to follow this  
Followers 0
James

DropDown Boxes

15 posts in this topic

Hiya,

I am just wandering how I could make:

$FontCombo = GUICtrlCreateCombo("Arial", 403, 11, 100, 22)
GUICtrlSetData(-1, "Arial Bold|Comic Sans MS|Courier New|Tahoma|Times New Roman")

Set itself to the font chosen without having to press a button to select it.

E.G. You select a font, and it automatically changes.

Secure

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How about...

If $lastfont <> GUICtrlRead($combo) Then
    $lastfont = GUICtrlRead($combo)
    GUICtrlSetFont($combo, -1, -1, -1, $lastfont)
EndIf

EDIT : forgot something. Also, what about using combo-style $CBS_DROPDOWNLIST,

in case you don't want the user to type anything into the combo ?

Edited by Helge

Share this post


Link to post
Share on other sites

I dont understand how that would work, Im using a RichText control. To set a font you have to do:

$DocEd1.SelFontName = "Verdana"

How could I do that? But instead of Verdana, it will change depending on what the dropdown is.

Share this post


Link to post
Share on other sites

Where do I put this? Because it doesnt work in a Case obviously. Also it gives me a warning:

C:\BetaPad\V2\AVE2.au3(432,17) : WARNING: $lastfont: possibly used before declaration.

If $lastfont <>

~~~~~~~~~~~~~^

Share this post


Link to post
Share on other sites

Declare $lastfont on top of your script and put the If-statement in your message/keep-alive loop.

Share this post


Link to post
Share on other sites

Ok, so at the top of my script I put

$lastfont = ""

and then:

where do i put the script? in the While statement?

Why don't you just experiment... we shouldn't have to walk your hand all the way through. I would assume it would go where ever you are calling the function that needs it.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Yes, I know. I have experimented, the only way I can make it work is with a button.

1. In your first post, you ask a question that assumes anyone knows you were using: $DocEd1.SelFontName

2. Now you are assuming that anyone even knows what your script is, to even want to help you.

I see you are using betapad\something, but I certainly wouldn't go out of my way to download your script to help. If you want help, recreate a "small" example that shows the issue you are having, and maybe someone can show you where it would go.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I said where you should put it although it shouldn't be needed. Even after I said it you didn't know.

EDIT : I thought automatically that if you selected a combo it wouldn't affect GUIGetMsg, due to

the obvious fact that you found this issue hard to solve. Seems like I shouldn't assume things

like that.

#include <GUIConstants.au3>

$sLastFont = ""

GUICreate("", 300, 300)
$nEdit = GUICtrlCreateEdit("Was it really that hard ?", 10, 10, 280, 250)
$nCombo = GUICtrlCreateCombo("", 10, 270, 280, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Arial Bold|Comic Sans MS|Courier New|Tahoma|Times New Roman")

GUISetState()

While 1
    $iMsg = GUIGetMsg()
    
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $nCombo
            GUICtrlSetFont($nEdit, -1, -1, -1, GUICtrlRead($nCombo))
        ;$DocEd1.SelFontName = GUICtrlRead($nCombo)
    EndSwitch
WEnd
Edited by Helge

Share this post


Link to post
Share on other sites

From what you've explained in this topic it should work, so what's so difficult ?

Share this post


Link to post
Share on other sites

$DocEd1.SelFontName = "Verdana"

If you're able to put that line in your script and make it work, I can't really see how more difficult it

would be to just make the font-changing be triggered by the selecting of the combo-items, and to

change that line from "Verdana" to a simple GUICtrlRead...

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