I just posted a Choose Font Include file which may answer some questions:
================================================
"If you want to make an apple pie from scratch,
you must first create the universe."
Carl Sagan
================================================
Announcement
Collapse
No announcement yet.
How to get lpFaceName from choosefont
Collapse
X
-
Of course everything should be set 100% but it might be a better idea to read the contents from lf and not via the pointer.
It more logical since you pass this pointer only to set this lf type var. but not to use it.
But then, if it crashes or not, it should be written correctly after all.
Leave a comment:
-
You get/don't get a GPF depending on your #DEBUG ERROR setting.
This line...
Code:fcnm$ = cf.[COLOR="Red"]@lplogfont[/COLOR].lfFaceName
When you don't set the LOGFONT PTR member of the CHOOSEFONT structure, you have a null pointer at "@plogFont".
With #DEBUG ERROR ON, because the pointer is null the statement is not attempted and ERROR 9 is set. Without this setting, the program attempts to read memory using a null pointer... which is a protection fault since you don't own the memory at 0x00000000
MCM
Leave a comment:
-
Thanks edwin. I didnt get a GPF and it does work. Using version 8.01 for this instead of 9.01.
I had put in the
local lf as logfont
but failed to add
cf.lpLogFont = VARPTR(lf)
Thanks also to Peter and Michael.Last edited by Fred Buffington; 13 Apr 2009, 12:30 PM.
Leave a comment:
-
You get a gpf, this seems to work but i didn't check msdn to verify all poss. errors:
Code:' and the incredibly complicated code for what WinMain does: Local cf As choosefontapi ' comdlg32 Local lf As logfont cf.lstructSize = SizeOf(cf) cf.flags = %CF_BOTH Or %CF_EFFECTS cf.lplogfont = VarPtr( lf ) Function = ChooseFont(cf) Local ips&, fcnm$ ips&=cf.ipointsize fcnm$ = [email protected] MsgBox Str$(ips&)+fcnm$ Function = 5
Leave a comment:
-
Hi Fred,
You need to provide the LOGFONT structure for the API to populate with data (currently the lpLogFont member points nowhere). Try this:
Code:#COMPILE EXE #DEBUG ERROR ON #REGISTER NONE #INCLUDE "WIN32API.INC" ' file date: 2/25/02 (PB version date). #INCLUDE "COMDLG32.INC" #RESOURCE "CHOOSE_FONT.PBR" FUNCTION WINMAIN (BYVAL hInstance AS LONG, _ BYVAL hPrevInstance AS LONG, _ BYVAL lpCmdLine AS ASCIIZ PTR, _ BYVAL iCmdShow AS LONG) AS LONG ' and the incredibly complicated code for what WinMain does: LOCAL cf AS choosefontapi ' comdlg32 LOCAL lf AS LOGFONT '<---- added cf.lpLogFont = VARPTR(lf) '<---- added cf.lstructSize = SIZEOF(cf) cf.flags = %CF_BOTH OR %CF_EFFECTS FUNCTION = ChooseFont(cf) ips&=cf.ipointsize fcnm$ = [email protected] MSGBOX STR$(ips&)+fcnm$ FUNCTION = 5 END FUNCTION
Pete.
Leave a comment:
-
Thanks edwin, I had the @ sign in the wrong place. Thanks.
Well, it didnt come back with anything.
Here is the code (from Michael's example)
Code:#COMPILE EXE #DEBUG ERROR ON #REGISTER NONE #INCLUDE "WIN32API.INC" ' file date: 2/25/02 (PB version date). #INCLUDE "COMDLG32.INC" #RESOURCE "CHOOSE_FONT.PBR" FUNCTION WINMAIN (BYVAL hInstance AS LONG, _ BYVAL hPrevInstance AS LONG, _ BYVAL lpCmdLine AS ASCIIZ PTR, _ BYVAL iCmdShow AS LONG) AS LONG ' and the incredibly complicated code for what WinMain does: LOCAL cf AS choosefontapi ' comdlg32 cf.lstructSize = SIZEOF(cf) cf.flags = %CF_BOTH OR %CF_EFFECTS FUNCTION = ChooseFont(cf) ips&=cf.ipointsize fcnm$ = [email protected] MSGBOX STR$(ips&)+fcnm$ FUNCTION = 5 END FUNCTION
Last edited by Fred Buffington; 12 Apr 2009, 02:13 PM.
Leave a comment:
-
lfFaceName As Asciiz * %LF_FACESIZE
and thus no pointer..
If lplogfont in choosefontapi.lplogfont is a pointer use @
A$ = [email protected]
Leave a comment:
-
How to get lpFaceName from choosefont
I want to use a user selectable font option and choosefont is easy to
use. I can't seem to figure out, though how to get the chosen lpfacename
from the choosefontapi.lplogfont pointer to lpfacename
in the logfont type def.Tags: None
Leave a comment: