How can I find the pitch and style of the font being used by the printer? I want to be able to read the font parameters into variables, change them, do some printing and then put them back to what they were originally.
Announcement
Collapse
No announcement yet.
find the pitch and style of the font
Collapse
X
-
Assuming you have a handle to the printer device context (which you can get any number of ways eg PrinttDlg()), GetCurrentObject () can return a handle to the current font, against which you can call GetObject () which will return a LOGFONT structure containing that info.
But to do what you want (change the font to something else, then restore when done), you don't really need to gather all the detail info.. a handle is sufficient.
You can just SelectObject (hDc, hNewfont), returning the current font handle, then when you are done, select the old font into the DC and delete your new font.
You usually see this done kind of in this order...
Code:hNewFont = CreateFont[Indirect] ... ' create font for special printing hOldfont = SelectObject (hDc, hNewFont) *** Printing operations here *** DeleteObject Selectobject (hDc, hOldFont) ' restore old font and destroy new
Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
-
Hi!
Please show me how to get Graphic to work in my PBCC4.0, such as
#include "Win32API.inc" or Graphic windows ..... to draw a line or to change font size:
I found this from Keyword Help but I dont know what lib or include do I need to make it in PBCC4.0.
Please help by add detail such as:
Function PBMAIN () AS LONG:
' Set the font for the selected graphic window to
' Times New Roman, 18 points, bold + italic + underline =(1+2+4).
GRAPHIC FONT "Times New Roman", 18, 7
' or:
GRAPHIC TEXT SIZE txt$ TO nWidth!, nHeight!
' and
GRAPHIC LINE (10, 10) - (10, 100)
GRAPHIC LINE END
END FUNCTION
' I had error with _ hypen on graphic end or no line, it works when I run source code samples so my setup is ok with the compiler.
Thank youLast edited by Can Le; 3 Jan 2008, 03:01 PM.
Comment
-
Thank,
I have this example works ok, from Keyword G in PBCC4 document
FUNCTION PBMAIN () AS LONG
' Create and show a Graphic window on screen
LOCAL hWin AS DWORD
GRAPHIC WINDOW "Box", 300, 300, 130, 130 TO hWin
GRAPHIC ATTACH hWin, 0
GRAPHIC BOX (10, 10) - (120, 120), 0, %BLUE
SLEEP 5000 ' show it for 5 seconds, then end
END FUNCTION
Comment
-
Here's a simple graphic window with a polygon and a print statement
Code:'PBCC4 program #COMPILE EXE #REGISTER NONE 'no need for include files for the graphic statements alone. 'polygon type defs as outlined in help TYPE PolyPoint x AS SINGLE y AS SINGLE END TYPE TYPE PolyArray count AS LONG xy(1 TO 1024) AS PolyPoint END TYPE FUNCTION PBMAIN () AS LONG DIM pi AS EXT pi=3.1415926535 'not used in this program '************************************* 'create and attach the graphic window '************************************* GRAPHIC WINDOW "Graphics", 100, 100, 400, 400 TO hWin??? GRAPHIC ATTACH hWin???, 0 DIM MyPolygon AS PolyArray MyPolygon.count=3 'specify 3 points in this polygon '************************************* 'set the polygon points for my arrow '(filled triangle) '************************************* MyPolygon.xy(1).x=100 MyPolygon.xy(1).y=100 MyPolygon.xy(2).x=100 MyPolygon.xy(2).y=200 MyPolygon.xy(3).x=200 MyPolygon.xy(3).y=150 '************************* 'show the graphic window 'and print a line and 'a big arrow '************************ GRAPHIC POLYGON MyPolygon ,%BLACK, %BLACK ' [, [fillstyle&] [, fillmode&]]]] GRAPHIC FONT "Times New Roman", 18, 7 GRAPHIC SET POS (10,300) GRAPHIC PRINT "hello this is times new roman pitch 18" WAITKEY$ GRAPHIC WINDOW END END FUNCTION
Last edited by Fred Buffington; 4 Jan 2008, 05:35 PM.
Comment
Comment