-
Help with CHOOSEFONT
I'm creating a FontChooser class. I display the CHOOSEFONT dialog using the
following code. How can I get a font name that I can use from this?
How can I read (Get) the values of the variable that .lpLogFont points to?
(.lpLogFont is a Long Pointer to a LogFont data type and not a variable.)
' start code
Public Function Show(hWndOwner As Long) As Long
Dim iReturn As Integer
With mCF
.Flags = Me.Flags
.hWndOwner = hWndOwner
.hdc = vbNull
End With
iReturn = ChooseFont(mCF) 'mCF is a Module level variable [As
ChooseFont]
With mCF
' ***** my problem starts here ***** _
1 - OK, so how do I get a font name that I can use? _
2 - ".lpLogFont" is a Long Pointer to a LogFont data type _
How can I read (Get) the values of ".lpLogFont"?
' ***** *****
Me.Size = .iPointSize
Me.Font = .lpLogFont 'always returns 0
Me.Font = .nFontType 'returns a long
End With
Show = iReturn
End Function
' end code
TIA
--
Kent
rkcripps@softhome.net
-
Re: Help with CHOOSEFONT
Hi Kent,
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest
As Any, lpSource As Any, ByVal nCount As Long)
Assume "lf" is a LOGFONT struct, and "cf" is a CHOOSEFONT struct -- the code
goes something like this:
cf.lpLogFont = VarPtr(lf)
If ChooseFont(cf) <> 0 Then
Call CopyMemory(lf, ByVal cf.lpLogFont, Len(cf.lpLogFont))
With lf
....
"lf" will contain the returned LOGFONT structure. If you want to initialize
the dialog with your own LOGFONT struct and pass a pointer to it on the
CHOOSEFONT struct (as above), make sure you specify CF_INITTOLOGFONTSTRUCT
in the flags.
.. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
http://www.vbbox.com/
http://www.mvps.org/ccrp/
Please post/reply to the newsgroup(s)
"Kent" <rkcripps@softhome.net> wrote in message
news:39b11651$1@news.devx.com...
>
> I'm creating a FontChooser class. I display the CHOOSEFONT dialog using
the
> following code. How can I get a font name that I can use from this?
>
> How can I read (Get) the values of the variable that .lpLogFont points to?
> (.lpLogFont is a Long Pointer to a LogFont data type and not a variable.)
>
> ' start code
> Public Function Show(hWndOwner As Long) As Long
> Dim iReturn As Integer
>
> With mCF
> .Flags = Me.Flags
> .hWndOwner = hWndOwner
> .hdc = vbNull
> End With
> iReturn = ChooseFont(mCF) 'mCF is a Module level variable [As
> ChooseFont]
> With mCF
> ' ***** my problem starts here ***** _
> 1 - OK, so how do I get a font name that I can use? _
> 2 - ".lpLogFont" is a Long Pointer to a LogFont data type _
> How can I read (Get) the values of ".lpLogFont"?
> ' ***** *****
> Me.Size = .iPointSize
> Me.Font = .lpLogFont 'always returns 0
> Me.Font = .nFontType 'returns a long
> End With
> Show = iReturn
> End Function
> ' end code
>
> TIA
> --
> Kent
> rkcripps@softhome.net
>
-
Re: Help with CHOOSEFONT
Hi Kent,
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest
As Any, lpSource As Any, ByVal nCount As Long)
Assume "lf" is a LOGFONT struct, and "cf" is a CHOOSEFONT struct -- the code
goes something like this:
cf.lpLogFont = VarPtr(lf)
If ChooseFont(cf) <> 0 Then
Call CopyMemory(lf, ByVal cf.lpLogFont, Len(cf.lpLogFont))
With lf
....
"lf" will contain the returned LOGFONT structure. If you want to initialize
the dialog with your own LOGFONT struct and pass a pointer to it on the
CHOOSEFONT struct (as above), make sure you specify CF_INITTOLOGFONTSTRUCT
in the flags.
.. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
http://www.vbbox.com/
http://www.mvps.org/ccrp/
Please post/reply to the newsgroup(s)
"Kent" <rkcripps@softhome.net> wrote in message
news:39b11651$1@news.devx.com...
>
> I'm creating a FontChooser class. I display the CHOOSEFONT dialog using
the
> following code. How can I get a font name that I can use from this?
>
> How can I read (Get) the values of the variable that .lpLogFont points to?
> (.lpLogFont is a Long Pointer to a LogFont data type and not a variable.)
>
> ' start code
> Public Function Show(hWndOwner As Long) As Long
> Dim iReturn As Integer
>
> With mCF
> .Flags = Me.Flags
> .hWndOwner = hWndOwner
> .hdc = vbNull
> End With
> iReturn = ChooseFont(mCF) 'mCF is a Module level variable [As
> ChooseFont]
> With mCF
> ' ***** my problem starts here ***** _
> 1 - OK, so how do I get a font name that I can use? _
> 2 - ".lpLogFont" is a Long Pointer to a LogFont data type _
> How can I read (Get) the values of ".lpLogFont"?
> ' ***** *****
> Me.Size = .iPointSize
> Me.Font = .lpLogFont 'always returns 0
> Me.Font = .nFontType 'returns a long
> End With
> Show = iReturn
> End Function
> ' end code
>
> TIA
> --
> Kent
> rkcripps@softhome.net
>
-
Re: Help with CHOOSEFONT
Klaus,
Thanks a lot. This tested (stretched?) the limits of my knowledge. Please
check out the following snippet:
For i = 1 To 32
If mLF.lfFaceName(i) = 0 Then
Exit For ' *** is this OK(throwing away the rest of the
array)? ***
Else
szFontName = szFontName + Chr(mLF.lfFaceName(i))
End If
Next i
--
Kent
rkcripps@softhome.net
Klaus H. Probst <kprobst@vbbox.com> wrote in message
news:39b16917$1@news.devx.com...
> Hi Kent,
>
> Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
(lpDest
> As Any, lpSource As Any, ByVal nCount As Long)
>
> Assume "lf" is a LOGFONT struct, and "cf" is a CHOOSEFONT struct -- the
code
> goes something like this:
>
> cf.lpLogFont = VarPtr(lf)
>
> If ChooseFont(cf) <> 0 Then
> Call CopyMemory(lf, ByVal cf.lpLogFont, Len(cf.lpLogFont))
> With lf
> ....
>
> "lf" will contain the returned LOGFONT structure. If you want to
initialize
> the dialog with your own LOGFONT struct and pass a pointer to it on the
> CHOOSEFONT struct (as above), make sure you specify CF_INITTOLOGFONTSTRUCT
> in the flags.
>
> . . . . . . . . . . . . . . . . . . . . . .
> Klaus H. Probst, MVP
> http://www.vbbox.com/
> http://www.mvps.org/ccrp/
>
> Please post/reply to the newsgroup(s)
>
>
>
> "Kent" <rkcripps@softhome.net> wrote in message
> news:39b11651$1@news.devx.com...
> >
> > I'm creating a FontChooser class. I display the CHOOSEFONT dialog using
> the
> > following code. How can I get a font name that I can use from this?
> >
> > How can I read (Get) the values of the variable that .lpLogFont points
to?
> > (.lpLogFont is a Long Pointer to a LogFont data type and not a
variable.)
> >
> > ' start code
> > Public Function Show(hWndOwner As Long) As Long
> > Dim iReturn As Integer
> >
> > With mCF
> > .Flags = Me.Flags
> > .hWndOwner = hWndOwner
> > .hdc = vbNull
> > End With
> > iReturn = ChooseFont(mCF) 'mCF is a Module level variable [As
> > ChooseFont]
> > With mCF
> > ' ***** my problem starts here ***** _
> > 1 - OK, so how do I get a font name that I can use? _
> > 2 - ".lpLogFont" is a Long Pointer to a LogFont data type _
> > How can I read (Get) the values of ".lpLogFont"?
> > ' ***** *****
> > Me.Size = .iPointSize
> > Me.Font = .lpLogFont 'always returns 0
> > Me.Font = .nFontType 'returns a long
> > End With
> > Show = iReturn
> > End Function
> > ' end code
> >
> > TIA
> > --
> > Kent
> > rkcripps@softhome.net
> >
>
>
-
Re: Help with CHOOSEFONT
Klaus,
Thanks a lot. This tested (stretched?) the limits of my knowledge. Please
check out the following snippet:
For i = 1 To 32
If mLF.lfFaceName(i) = 0 Then
Exit For ' *** is this OK(throwing away the rest of the
array)? ***
Else
szFontName = szFontName + Chr(mLF.lfFaceName(i))
End If
Next i
--
Kent
rkcripps@softhome.net
Klaus H. Probst <kprobst@vbbox.com> wrote in message
news:39b16917$1@news.devx.com...
> Hi Kent,
>
> Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
(lpDest
> As Any, lpSource As Any, ByVal nCount As Long)
>
> Assume "lf" is a LOGFONT struct, and "cf" is a CHOOSEFONT struct -- the
code
> goes something like this:
>
> cf.lpLogFont = VarPtr(lf)
>
> If ChooseFont(cf) <> 0 Then
> Call CopyMemory(lf, ByVal cf.lpLogFont, Len(cf.lpLogFont))
> With lf
> ....
>
> "lf" will contain the returned LOGFONT structure. If you want to
initialize
> the dialog with your own LOGFONT struct and pass a pointer to it on the
> CHOOSEFONT struct (as above), make sure you specify CF_INITTOLOGFONTSTRUCT
> in the flags.
>
> . . . . . . . . . . . . . . . . . . . . . .
> Klaus H. Probst, MVP
> http://www.vbbox.com/
> http://www.mvps.org/ccrp/
>
> Please post/reply to the newsgroup(s)
>
>
>
> "Kent" <rkcripps@softhome.net> wrote in message
> news:39b11651$1@news.devx.com...
> >
> > I'm creating a FontChooser class. I display the CHOOSEFONT dialog using
> the
> > following code. How can I get a font name that I can use from this?
> >
> > How can I read (Get) the values of the variable that .lpLogFont points
to?
> > (.lpLogFont is a Long Pointer to a LogFont data type and not a
variable.)
> >
> > ' start code
> > Public Function Show(hWndOwner As Long) As Long
> > Dim iReturn As Integer
> >
> > With mCF
> > .Flags = Me.Flags
> > .hWndOwner = hWndOwner
> > .hdc = vbNull
> > End With
> > iReturn = ChooseFont(mCF) 'mCF is a Module level variable [As
> > ChooseFont]
> > With mCF
> > ' ***** my problem starts here ***** _
> > 1 - OK, so how do I get a font name that I can use? _
> > 2 - ".lpLogFont" is a Long Pointer to a LogFont data type _
> > How can I read (Get) the values of ".lpLogFont"?
> > ' ***** *****
> > Me.Size = .iPointSize
> > Me.Font = .lpLogFont 'always returns 0
> > Me.Font = .nFontType 'returns a long
> > End With
> > Show = iReturn
> > End Function
> > ' end code
> >
> > TIA
> > --
> > Kent
> > rkcripps@softhome.net
> >
>
>
-
Re: Help with CHOOSEFONT
Hi Kent,
> Thanks a lot. This tested (stretched?) the limits of my knowledge. Please
> check out the following snippet:
>
> For i = 1 To 32
> If mLF.lfFaceName(i) = 0 Then
> Exit For ' *** is this OK(throwing away the rest of the
> array)? ***
> Else
> szFontName = szFontName + Chr(mLF.lfFaceName(i))
> End If
> Next i
No need to loop through the individual characters. As long as you declared
the lfFaceName member as String * LF_FACESIZE (that is, String * 32), you
can just do this:
szFontName = StrConv(mLF.lfFaceName, vbUnicode)
.. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
http://www.vbbox.com/
http://www.mvps.org/ccrp/
Please post/reply to the newsgroup(s)
-
Re: Help with CHOOSEFONT
Hi Kent,
> Thanks a lot. This tested (stretched?) the limits of my knowledge. Please
> check out the following snippet:
>
> For i = 1 To 32
> If mLF.lfFaceName(i) = 0 Then
> Exit For ' *** is this OK(throwing away the rest of the
> array)? ***
> Else
> szFontName = szFontName + Chr(mLF.lfFaceName(i))
> End If
> Next i
No need to loop through the individual characters. As long as you declared
the lfFaceName member as String * LF_FACESIZE (that is, String * 32), you
can just do this:
szFontName = StrConv(mLF.lfFaceName, vbUnicode)
.. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
http://www.vbbox.com/
http://www.mvps.org/ccrp/
Please post/reply to the newsgroup(s)
-
Re: Help with CHOOSEFONT
Doh! I just went through this while working on a color chooser. I learns good. I know 'cuz I learn often ;-)
I take it that the Unicode vs. Ansi characters would explain why the bytes in the array that occurred after the value 0
appeared to have random values.
Is there a similar way to get my ANSI string into a byte array without looping? I've tried simple assignments [e.g.:
mLF.lfFaceName = Me.FontName], but they didn't work.
Thanks again.
--
Kent
rkcripps@softhome.net
Klaus H. Probst <kprobst@vbbox.com> wrote in message news:39b1d735$1@news.devx.com...
> Hi Kent,
> No need to loop through the individual characters. As long as you declared
> the lfFaceName member as String * LF_FACESIZE (that is, String * 32), you
> can just do this:
>
> szFontName = StrConv(mLF.lfFaceName, vbUnicode)
> . . . . . . . . . . . . . . . . . . . . . .
> Klaus H. Probst, MVP
> http://www.vbbox.com/
> http://www.mvps.org/ccrp/
>
> Please post/reply to the newsgroup(s)
>
>
>
-
Re: Help with CHOOSEFONT
Doh! I just went through this while working on a color chooser. I learns good. I know 'cuz I learn often ;-)
I take it that the Unicode vs. Ansi characters would explain why the bytes in the array that occurred after the value 0
appeared to have random values.
Is there a similar way to get my ANSI string into a byte array without looping? I've tried simple assignments [e.g.:
mLF.lfFaceName = Me.FontName], but they didn't work.
Thanks again.
--
Kent
rkcripps@softhome.net
Klaus H. Probst <kprobst@vbbox.com> wrote in message news:39b1d735$1@news.devx.com...
> Hi Kent,
> No need to loop through the individual characters. As long as you declared
> the lfFaceName member as String * LF_FACESIZE (that is, String * 32), you
> can just do this:
>
> szFontName = StrConv(mLF.lfFaceName, vbUnicode)
> . . . . . . . . . . . . . . . . . . . . . .
> Klaus H. Probst, MVP
> http://www.vbbox.com/
> http://www.mvps.org/ccrp/
>
> Please post/reply to the newsgroup(s)
>
>
>
-
Re: Help with CHOOSEFONT
Use StrConv with vbFromUnicode to convert to ANSI.
--
MichKa
random junk of dubious value at the
multilingual http://www.trigeminal.com/ and
a new book on internationalization in VB at
http://www.i18nWithVB.com/
"Kent" <rkcripps@softhome.net> wrote in message
news:39b259d0@news.devx.com...
> Doh! I just went through this while working on a color chooser. I learns
good. I know 'cuz I learn often ;-)
>
> I take it that the Unicode vs. Ansi characters would explain why the bytes
in the array that occurred after the value 0
> appeared to have random values.
>
> Is there a similar way to get my ANSI string into a byte array without
looping? I've tried simple assignments [e.g.:
> mLF.lfFaceName = Me.FontName], but they didn't work.
>
> Thanks again.
> --
> Kent
> rkcripps@softhome.net
>
> Klaus H. Probst <kprobst@vbbox.com> wrote in message
news:39b1d735$1@news.devx.com...
> > Hi Kent,
> > No need to loop through the individual characters. As long as you
declared
> > the lfFaceName member as String * LF_FACESIZE (that is, String * 32),
you
> > can just do this:
> >
> > szFontName = StrConv(mLF.lfFaceName, vbUnicode)
> > . . . . . . . . . . . . . . . . . . . . . .
> > Klaus H. Probst, MVP
> > http://www.vbbox.com/
> > http://www.mvps.org/ccrp/
> >
> > Please post/reply to the newsgroup(s)
> >
> >
> >
>
>
-
Re: Help with CHOOSEFONT
Use StrConv with vbFromUnicode to convert to ANSI.
--
MichKa
random junk of dubious value at the
multilingual http://www.trigeminal.com/ and
a new book on internationalization in VB at
http://www.i18nWithVB.com/
"Kent" <rkcripps@softhome.net> wrote in message
news:39b259d0@news.devx.com...
> Doh! I just went through this while working on a color chooser. I learns
good. I know 'cuz I learn often ;-)
>
> I take it that the Unicode vs. Ansi characters would explain why the bytes
in the array that occurred after the value 0
> appeared to have random values.
>
> Is there a similar way to get my ANSI string into a byte array without
looping? I've tried simple assignments [e.g.:
> mLF.lfFaceName = Me.FontName], but they didn't work.
>
> Thanks again.
> --
> Kent
> rkcripps@softhome.net
>
> Klaus H. Probst <kprobst@vbbox.com> wrote in message
news:39b1d735$1@news.devx.com...
> > Hi Kent,
> > No need to loop through the individual characters. As long as you
declared
> > the lfFaceName member as String * LF_FACESIZE (that is, String * 32),
you
> > can just do this:
> >
> > szFontName = StrConv(mLF.lfFaceName, vbUnicode)
> > . . . . . . . . . . . . . . . . . . . . . .
> > Klaus H. Probst, MVP
> > http://www.vbbox.com/
> > http://www.mvps.org/ccrp/
> >
> > Please post/reply to the newsgroup(s)
> >
> >
> >
>
>
-
Re: Help with CHOOSEFONT
Kent,
> Doh! I just went through this while working on a color chooser. I learns
good. I know 'cuz I learn often ;-)
>
> I take it that the Unicode vs. Ansi characters would explain why the bytes
in the array that occurred after the value 0
> appeared to have random values.
>
> Is there a similar way to get my ANSI string into a byte array without
looping? I've tried simple assignments [e.g.:
> mLF.lfFaceName = Me.FontName], but they didn't work.
I just noticed something weird in VB6 when using StrConv on the lfFaceName
member... I seem to remember this used to work, but now it doesn't. Did it
work for you?
Anyway, just to be absolutely sure, this is the way it should be done:
Declare Function lstrcpyA Lib "kernel32" (ByVal lpString1 As Any, ByVal
lpString2 As Any) As Long
Call lstrcpyA(lf.lfFaceName, "Arial")
and the other way around...
Dim sFontName As String
sFontName = String$(LF_FACESIZE,32)
Call lstrcpyA(sFontName, lf.lfFaceName)
sFontName = Trim$(sFontName)
or you might want to call lstrlenA() on the lfFaceName member to get the
size just right in the first place and avoid the final Trim$()
--
.. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
http://www.vbbox.com/
http://www.mvps.org/ccrp/
> Thanks again.
> --
> Kent
> rkcripps@softhome.net
>
> Klaus H. Probst <kprobst@vbbox.com> wrote in message
news:39b1d735$1@news.devx.com...
> > Hi Kent,
> > No need to loop through the individual characters. As long as you
declared
> > the lfFaceName member as String * LF_FACESIZE (that is, String * 32),
you
> > can just do this:
> >
> > szFontName = StrConv(mLF.lfFaceName, vbUnicode)
> > . . . . . . . . . . . . . . . . . . . . . .
> > Klaus H. Probst, MVP
> > http://www.vbbox.com/
> > http://www.mvps.org/ccrp/
> >
> > Please post/reply to the newsgroup(s)
> >
> >
> >
>
>
-
Re: Help with CHOOSEFONT
Kent,
> Doh! I just went through this while working on a color chooser. I learns
good. I know 'cuz I learn often ;-)
>
> I take it that the Unicode vs. Ansi characters would explain why the bytes
in the array that occurred after the value 0
> appeared to have random values.
>
> Is there a similar way to get my ANSI string into a byte array without
looping? I've tried simple assignments [e.g.:
> mLF.lfFaceName = Me.FontName], but they didn't work.
I just noticed something weird in VB6 when using StrConv on the lfFaceName
member... I seem to remember this used to work, but now it doesn't. Did it
work for you?
Anyway, just to be absolutely sure, this is the way it should be done:
Declare Function lstrcpyA Lib "kernel32" (ByVal lpString1 As Any, ByVal
lpString2 As Any) As Long
Call lstrcpyA(lf.lfFaceName, "Arial")
and the other way around...
Dim sFontName As String
sFontName = String$(LF_FACESIZE,32)
Call lstrcpyA(sFontName, lf.lfFaceName)
sFontName = Trim$(sFontName)
or you might want to call lstrlenA() on the lfFaceName member to get the
size just right in the first place and avoid the final Trim$()
--
.. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
http://www.vbbox.com/
http://www.mvps.org/ccrp/
> Thanks again.
> --
> Kent
> rkcripps@softhome.net
>
> Klaus H. Probst <kprobst@vbbox.com> wrote in message
news:39b1d735$1@news.devx.com...
> > Hi Kent,
> > No need to loop through the individual characters. As long as you
declared
> > the lfFaceName member as String * LF_FACESIZE (that is, String * 32),
you
> > can just do this:
> >
> > szFontName = StrConv(mLF.lfFaceName, vbUnicode)
> > . . . . . . . . . . . . . . . . . . . . . .
> > Klaus H. Probst, MVP
> > http://www.vbbox.com/
> > http://www.mvps.org/ccrp/
> >
> > Please post/reply to the newsgroup(s)
> >
> >
> >
>
>
-
Re: Help with CHOOSEFONT
When I tried to assign using ".lfFaceName = StrConv(Me.FontName, vbFromUnicode)",
I received a compile error: can't assign to array. FWIW, I'm using VB6 SP4 on a buggy Win98 machine.
I've been using this code. It may not be elegant, but it's mine & it works ;-)
szTemp = Me.FontName
For i = 1 To 32
If Len(szTemp) = 0 Then
Exit For
Else
.lfFaceName(i) = Asc(Left(szTemp, 1))
szTemp = Right(szTemp, Len(szTemp) - 1)
End If
Next i
End With
--
Kent
rkcripps@softhome.net
Klaus H. Probst <kprobst@vbbox.com> wrote in message news:39b4426f$1@news.devx.com...
> Kent,
>
> > Doh! I just went through this while working on a color chooser. I learns
> good. I know 'cuz I learn often ;-)
> >
> > I take it that the Unicode vs. Ansi characters would explain why the bytes
> in the array that occurred after the value 0
> > appeared to have random values.
> >
> > Is there a similar way to get my ANSI string into a byte array without
> looping? I've tried simple assignments [e.g.:
> > mLF.lfFaceName = Me.FontName], but they didn't work.
>
> I just noticed something weird in VB6 when using StrConv on the lfFaceName
> member... I seem to remember this used to work, but now it doesn't. Did it
> work for you?
>
> Anyway, just to be absolutely sure, this is the way it should be done:
>
> Declare Function lstrcpyA Lib "kernel32" (ByVal lpString1 As Any, ByVal
> lpString2 As Any) As Long
>
> Call lstrcpyA(lf.lfFaceName, "Arial")
>
> and the other way around...
>
> Dim sFontName As String
> sFontName = String$(LF_FACESIZE,32)
> Call lstrcpyA(sFontName, lf.lfFaceName)
> sFontName = Trim$(sFontName)
>
> or you might want to call lstrlenA() on the lfFaceName member to get the
> size just right in the first place and avoid the final Trim$()
>
>
>
> --
> . . . . . . . . . . . . . . . . . . . . . .
> Klaus H. Probst, MVP
> http://www.vbbox.com/
> http://www.mvps.org/ccrp/
>
>
>
>
>
>
>
>
> > Thanks again.
> > --
> > Kent
> > rkcripps@softhome.net
> >
> > Klaus H. Probst <kprobst@vbbox.com> wrote in message
> news:39b1d735$1@news.devx.com...
> > > Hi Kent,
> > > No need to loop through the individual characters. As long as you
> declared
> > > the lfFaceName member as String * LF_FACESIZE (that is, String * 32),
> you
> > > can just do this:
> > >
> > > szFontName = StrConv(mLF.lfFaceName, vbUnicode)
> > > . . . . . . . . . . . . . . . . . . . . . .
> > > Klaus H. Probst, MVP
> > > http://www.vbbox.com/
> > > http://www.mvps.org/ccrp/
> > >
> > > Please post/reply to the newsgroup(s)
> > >
> > >
> > >
> >
> >
>
>
-
Re: Help with CHOOSEFONT
When I tried to assign using ".lfFaceName = StrConv(Me.FontName, vbFromUnicode)",
I received a compile error: can't assign to array. FWIW, I'm using VB6 SP4 on a buggy Win98 machine.
I've been using this code. It may not be elegant, but it's mine & it works ;-)
szTemp = Me.FontName
For i = 1 To 32
If Len(szTemp) = 0 Then
Exit For
Else
.lfFaceName(i) = Asc(Left(szTemp, 1))
szTemp = Right(szTemp, Len(szTemp) - 1)
End If
Next i
End With
--
Kent
rkcripps@softhome.net
Klaus H. Probst <kprobst@vbbox.com> wrote in message news:39b4426f$1@news.devx.com...
> Kent,
>
> > Doh! I just went through this while working on a color chooser. I learns
> good. I know 'cuz I learn often ;-)
> >
> > I take it that the Unicode vs. Ansi characters would explain why the bytes
> in the array that occurred after the value 0
> > appeared to have random values.
> >
> > Is there a similar way to get my ANSI string into a byte array without
> looping? I've tried simple assignments [e.g.:
> > mLF.lfFaceName = Me.FontName], but they didn't work.
>
> I just noticed something weird in VB6 when using StrConv on the lfFaceName
> member... I seem to remember this used to work, but now it doesn't. Did it
> work for you?
>
> Anyway, just to be absolutely sure, this is the way it should be done:
>
> Declare Function lstrcpyA Lib "kernel32" (ByVal lpString1 As Any, ByVal
> lpString2 As Any) As Long
>
> Call lstrcpyA(lf.lfFaceName, "Arial")
>
> and the other way around...
>
> Dim sFontName As String
> sFontName = String$(LF_FACESIZE,32)
> Call lstrcpyA(sFontName, lf.lfFaceName)
> sFontName = Trim$(sFontName)
>
> or you might want to call lstrlenA() on the lfFaceName member to get the
> size just right in the first place and avoid the final Trim$()
>
>
>
> --
> . . . . . . . . . . . . . . . . . . . . . .
> Klaus H. Probst, MVP
> http://www.vbbox.com/
> http://www.mvps.org/ccrp/
>
>
>
>
>
>
>
>
> > Thanks again.
> > --
> > Kent
> > rkcripps@softhome.net
> >
> > Klaus H. Probst <kprobst@vbbox.com> wrote in message
> news:39b1d735$1@news.devx.com...
> > > Hi Kent,
> > > No need to loop through the individual characters. As long as you
> declared
> > > the lfFaceName member as String * LF_FACESIZE (that is, String * 32),
> you
> > > can just do this:
> > >
> > > szFontName = StrConv(mLF.lfFaceName, vbUnicode)
> > > . . . . . . . . . . . . . . . . . . . . . .
> > > Klaus H. Probst, MVP
> > > http://www.vbbox.com/
> > > http://www.mvps.org/ccrp/
> > >
> > > Please post/reply to the newsgroup(s)
> > >
> > >
> > >
> >
> >
>
>
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks