PC Review


Reply
Thread Tools Rate Thread

Dealing with the FontDialog

 
 
active
Guest
Posts: n/a
 
      5th Dec 2003
A few questions about the FontDialog and dealing with Fonts

Is it necessary to pass the parameters ByRef so that updated values can be
returned.?

I wouldn't think it is necessary for the font but is required for the color.
Is that correct??

Private Sub DialogSetFontVariable(ByRef acolor As Drawing.Color, ByRef
audtFontVariable As Font)

Dim FontDialog1 As New FontDialog

FontDialog1.Font = audtFontVariable ????Does this mean changes made by the
dialog are made to audtFontVariable????

FontDialog1.ShowColor = True

FontDialog1.Color = acolor

If FontDialog1.ShowDialog() <> DialogResult.Cancel Then

audtFontVariable = FontDialog1.Font.Clone ????Is this needed to update
audtFontVariable????Is clone necessary??

acolor = FontDialog1.Color ????Is this needed to update aColor????

End If





Thanks in advance for any answers,

Cal


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      5th Dec 2003
* " active" <(E-Mail Removed)> scripsit:
> A few questions about the FontDialog and dealing with Fonts
>
> Is it necessary to pass the parameters ByRef so that updated values can be
> returned.?
>
> I wouldn't think it is necessary for the font but is required for the color.
> Is that correct??
>
> Private Sub DialogSetFontVariable(ByRef acolor As Drawing.Color, ByRef
> audtFontVariable As Font)


'Color' is a value type, so you will have to pass it 'ByRef', 'Font' is
a reference type, you want to allow the procedure to change this
reference, so pass it 'ByRef' too.

> Dim FontDialog1 As New FontDialog
>
> FontDialog1.Font = audtFontVariable ????Does this mean changes made by the
> dialog are made to audtFontVariable????


Why not test it on your own?

> FontDialog1.ShowColor = True
>
> FontDialog1.Color = acolor
>
> If FontDialog1.ShowDialog() <> DialogResult.Cancel Then
>
> audtFontVariable = FontDialog1.Font.Clone ????Is this needed to update
> audtFontVariable????Is clone necessary??


Yes. Doesn't it work if you skip the 'Clone'?

> acolor = FontDialog1.Color ????Is this needed to update aColor????


Yes.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
active
Guest
Posts: n/a
 
      5th Dec 2003
Before I sent this I found a little bug that I don't even what to mention.
So thanks for the answers
Cal


> > Dim FontDialog1 As New FontDialog
> >
> > FontDialog1.Font = audtFontVariable ????Does this mean changes made by

the
> > dialog are made to audtFontVariable????

>
> Why not test it on your own?


I'd would really appreciate an answer to this.
The more I'm sure of the better debugging I can do.

I've been testing all day and for some reason after I leave this routine the
font is Nothing.

I've tried everything I can think of.
I'd guess that assigning audtFontVariable to FontDialog1.Font would cause
the dialog box to change the values stored in it.
If that were the case I could pass it byVal and skip the assignment below.

Except if I understand the Help the font properties are read only so that is
why I did it the way I did it.



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      5th Dec 2003
* " active" <(E-Mail Removed)> scripsit:
>>> Dim FontDialog1 As New FontDialog
>>>
>>> FontDialog1.Font = audtFontVariable ????Does this mean changes made by the
>>> dialog are made to audtFontVariable????

>>
>> Why not test it on your own?

>
> I'd would really appreciate an answer to this.
> The more I'm sure of the better debugging I can do.
>
> I've been testing all day and for some reason after I leave this routine the
> font is Nothing.
>
> I've tried everything I can think of.
> I'd guess that assigning audtFontVariable to FontDialog1.Font would cause
> the dialog box to change the values stored in it.
> If that were the case I could pass it byVal and skip the assignment below.
>
> Except if I understand the Help the font properties are read only so that is
> why I did it the way I did it.


I would use something like this:

\\\
Public Function GetIt(ByRef DestColor As Color, ByRef DestFont As Font)
Dim f As New FontDialog()
f.Font = DestFont
f.Color = DestColor
f.ShowColor = True
f.ShowDialog()
DestFont = f.Font
DestColor = f.Color
End Function

Private Sub Test()
GetIt(Me.Label1.ForeColor, Me.Label1.Font)
End Sub
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FontDialog Only Allows Integrals? =?Utf-8?B?TWlrZQ==?= Microsoft Dot NET Framework Forms 3 11th Jul 2006 09:32 PM
fontDialog.Color =?Utf-8?B?TGlvbmVs?= Microsoft Dot NET Framework Forms 1 24th May 2006 10:07 PM
Fontdialog =?Utf-8?B?Z3JvYXN0?= Microsoft C# .NET 0 11th May 2005 08:31 AM
FontDialog??? JustMe Microsoft Dot NET Compact Framework 1 28th Aug 2003 05:52 PM
FontDialog joannelai Microsoft C# .NET 1 15th Jul 2003 08:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:34 PM.