Results 1 to 8 of 8

Thread: Font Property

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246

    Font Property

    How do i do a font property in an activeX Control?, what type do i need to set the property of to get the font selection window?
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    To get the window, you need to use the StdFont type. This code has always worked well with me.
    VB Code:
    1. Private WithEvents m_Font As StdFont
    2.  
    3. Public Property Get Font() As StdFont
    4.     'Returns the font of the control
    5.     Set Font = m_Font
    6. End Property
    7.  
    8. Public Property Set Font(ByVal objFont As StdFont)
    9.     'Sets the font and forces a repaint
    10.     With m_Font
    11.         .Bold = objFont.Bold
    12.         .Charset = objFont.Charset
    13.         .Italic = objFont.Italic
    14.         .Name = objFont.Name
    15.         .Size = objFont.Size
    16.         .Strikethrough = objFont.Strikethrough
    17.         .Underline = objFont.Underline
    18.         .Weight = objFont.Weight
    19.     End With
    20.     PropertyChanged "Font"
    21.     Refresh
    22. End Property
    23.  
    24. Private Sub m_Font_FontChanged(ByVal PropertyName As String)
    25.     'set the font of the usercontrol
    26.     Set UserControl.Font = m_Font
    27.     Refresh
    28. End Sub

    Hope this helps

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Thanks, that works, but i'm trying to set the font of a label, and i get an error "Wrong Number of Arguments or invalid property assignment"

    Do you know how to fix this?


    Thanks

    Also what can i use as a default value in the init, read write properties.

    thanks
    Last edited by Nirces; Feb 28th, 2002 at 06:22 AM.
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  4. #4
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    make sure it's Public Property Set and not Property Let

    for a default, try Set m_Font = Ambient.Font

    b

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Still not working, here is a copy of my control + test app.

    I did have a let, upon changing it to a set, i now get "Invalid Property Value" error

    Thanks for your help
    Attached Files Attached Files
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  6. #6
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    i've changed a couple of things in ur project - look for ADDED and REMOVED comments

    the changes should be in:
    UserControl_Initialize
    UserControl_InitProperties
    UserControl_WriteProperties
    UserControl_ReadProperties
    Randomise
    Property Set Font


    good luck & have fun

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Thank You
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  8. #8
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    not a problem

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