Feb 27th, 2002, 09:14 PM
#1
Thread Starter
Addicted Member
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...
Feb 28th, 2002, 12:31 AM
#2
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
Feb 28th, 2002, 06:12 AM
#3
Thread Starter
Addicted Member
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...
Feb 28th, 2002, 06:59 AM
#4
make sure it's Public Property Set and not Property Let
for a default, try Set m_Font = Ambient.Font
b
Mar 2nd, 2002, 06:13 AM
#5
Thread Starter
Addicted Member
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
Some Days, i just get this feeling that i'm helping to write dozens of Viruses...
Mar 4th, 2002, 01:21 AM
#6
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
Mar 4th, 2002, 04:45 AM
#7
Thread Starter
Addicted Member
Some Days, i just get this feeling that i'm helping to write dozens of Viruses...
Mar 4th, 2002, 06:15 AM
#8
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width