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?
Printable View
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?
To get the window, you need to use the StdFont type. This code has always worked well with me.
VB Code:
Private WithEvents m_Font As StdFont Public Property Get Font() As StdFont 'Returns the font of the control Set Font = m_Font End Property Public Property Set Font(ByVal objFont As StdFont) 'Sets the font and forces a repaint With m_Font .Bold = objFont.Bold .Charset = objFont.Charset .Italic = objFont.Italic .Name = objFont.Name .Size = objFont.Size .Strikethrough = objFont.Strikethrough .Underline = objFont.Underline .Weight = objFont.Weight End With PropertyChanged "Font" Refresh End Property Private Sub m_Font_FontChanged(ByVal PropertyName As String) 'set the font of the usercontrol Set UserControl.Font = m_Font Refresh End Sub
Hope this helps :)
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
make sure it's Public Property Set and not Property Let
for a default, try Set m_Font = Ambient.Font
b
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
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 :)
Thank You
not a problem