Results 1 to 21 of 21

Thread: CommonDialong font/color

  1. #1

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302

    CommonDialong font/color

    Hello. Ok this is the code i have so far

    VB Code:
    1. Private Sub xpcmdbutton9_Click()
    2. CommonDialog1.Flags = cdlCFBoth
    3. CommonDialog1.ShowFont
    4.  
    5. End Sub
    6. Private Sub xpcmdbutton10_Click()
    7. CommonDialog1.Flags = cdlCFBoth
    8. CommonDialog1.ShowColor
    9. End Sub

    What i want to happen is when the user selects their font, the textbox next to the command button displays their selected font name. And when the user selects their color, the backcolor of the label changes to that selected color. How do i do this?
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Private Sub xpcmdbutton9_Click()
    CommonDialog1.Flags = cdlCFBoth
    CommonDialog1.ShowFont
    Text1.Font.Name = CommonDialog1.FontName
    End Sub
    Private Sub xpcmdbutton10_Click()
    CommonDialog1.Flags = cdlCFBoth
    CommonDialog1.ShowColor
    LAbel1.BackColor = CommonDialog1.Color
    End Sub
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Instead of

    Text1.Font.Name = CommonDialog1.FontName

    use

    Text1.Text = CommonDialog1.FontName

    if you want to display the font name in the textbox.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  4. #4

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    Thankyou, and how do i change to font of the textbox to the font selected?
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  5. #5
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    VB Code:
    1. Text1.Font.Name = CommonDialog1.FontName
    2. Text1.Font.Bold = CommonDialog1.FontBold
    3. Text1.Font.Italic = CommonDialog1.FontItalic
    4. Text1.Font.Underline = CommonDialog1.FontUnderline
    5. Text1.Font.StrikeThough = CommonDialog1.FontStrikeThru
    6. Text1.Font.Size = CommonDialog1.FontSize


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  6. #6
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Originally posted by gamezfreakuk
    Thankyou, and how do i change to font of the textbox to the font selected?
    i already showed you how
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  7. #7

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    Thankyou!
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  8. #8

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    Ok new question, How do i save the font and font color to the registry so that the users font setttings are saved? I know how to use savesetting and getsetting (that is used with most of the login area of the program) but i am stuck on this can you help?
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  9. #9
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    waht do you mean? just save the font color and the font name in it. the font color is just a number and the font name is a string of text.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  10. #10

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    Huh?!?!

    I mean like say the user picks "Arial" as their font and "Red" as their font color, how do i save these values to the registry, so that next time my app loads the textbox will display "Arial" (in the font arial) and the label's backcolor will be red.
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  11. #11
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    save a key called "FontName" with string called "Arial" and a Key name "Color" with a string called "1667774595". then load the text and the color what part don't you get? you said you knew how to use savesetting and getsetting
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  12. #12
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402

    Well

    VB Code:
    1. SaveSettings("MyApp", "Font", "Name", CommonDialog1.FontName)
    2. 'SaveSettings("MyApp", "Font", "Size", CommonDialog1.FontSize)
    3. 'SaveSettings("MyApp", "Font", "Bold", CommonDialog1.FontBold)
    4. 'SaveSettings("MyApp", "Font", "Italic", CommonDialog1.FontItalic)
    5. 'SaveSettings("MyApp", "Font", "Underline", CommonDialog1.FontUnderline)
    6. 'SaveSettings("MyApp", "Font", "StrikeThru", CommonDialog1.FontStrikeThru)
    7. SaveSettings("MyApp", "Font", "Color", Str(CommonDialog1.Color))

    VB Code:
    1. Text1.Text = GetSettings("MyApp", "Font", "Name", Arial)
    2. Label1.BackColor = Val(GetSettings("MyApp", "Font", "Color", Str(vbBlack)))
    Last edited by Microbasic; Jul 14th, 2002 at 01:42 PM.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  13. #13

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    I know this might sound retarded but how do get back those settings?

    So that the textbox's font will be the saved font ect.
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  14. #14
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Read my previous post - I've already showed you how.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  15. #15

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    VB Code:
    1. Text1.Text = GetSettings("MyApp", "Font", "Name", Arial)
    2. Label1.BackColor = Val(GetSettings("MyApp", "Font", "Color", Str(vbBlack)))

    before i try this code, aint that a bit wrong, because if the user chooses "Comic Sans Ms" then the textbox will still display Arial
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  16. #16
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    the last argument for GetSetting is what it would give you do if there wasnt an entry.

    it should have been in quotes though
    Text1.Text = GetSettings("MyApp", "Font", "Name", "Arial")
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  17. #17
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    and remove the 'S' at the end of savesetting(s) and getsetting(s).
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  18. #18

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    Sorry you will have to explain this to me: -

    I want it when the program is next loaded the textbox is formatted with all the settings that the user saved before (eg Font = Arial, Bold)
    Or whatever font they saved.
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  19. #19
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Originally posted by BuggyProgrammer
    and remove the 'S' at the end of savesetting(s) and getsetting(s).
    Oops


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  20. #20
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    now... i've attached a projct with what you mean. it will work. i've tested it.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  21. #21

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    Thankyou, I dont need the zip file i have done it now, but thankyou very much please dont shout at me again
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width