home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 4
/
BUGCD1997_05.BIN
/
aplic
/
clip4win
/
clip4win.exe
/
C4W30E.HUF
/
SOURCE
/
PRINTHEL.PRG
< prev
next >
Wrap
Text File
|
1996-06-27
|
4KB
|
150 lines
/////////////////////////
//
// printhel(lo).prg - print "Hello World!" on the default printer
//
// Written by: John M. Skelton, Jun-96.
//
// Copyright (C) 1993-1996 Skelton Software, Kendal Cottage, Hillam, Leeds LS25 5HP, UK.
// All Rights Reserved.
//
/////////////////////////
#include "windows.ch"
#include "font.ch"
#include "commdlg.ch"
#include "textmetr.ch"
#define NO_C4WCLASS
#include "commands.ch"
function main()
local oApp, oWnd
CREATE APPLICATION oApp ;
WINDOW oWnd ;
TITLE "Clip-4-Win Makes Windows Apps E-A-S-Y!" ;
ON INIT DoInit(oWnd)
return nil
static function DoInit(oWnd)
MenuSetup(oWnd)
return nil
static function DoHello(oWnd)
local hDC
if !empty(hDC := GetPrintDC()) // see also: PrintDlg()
StartDoc(hDC, "SomeDocument")
StartPage(hDC)
TextOut(hDC, 50, 50, "Clip-4-Win says: Hello World!")
EndPage(hDC)
EndDoc(hDC)
DeleteDC(hDC)
endif
return nil
static function DoArial(oWnd)
local hDC, hFont, hOldFont
if !empty(hDC := GetPrintDC()) // see also: PrintDlg()
CREATE FONT HANDLE hFont NAME "Arial" SIZE 10 DC hDC
StartDoc(hDC, "SomeDocument")
StartPage(hDC)
TextOut(hDC, 50, 50, "Clip-4-Win says: Hello World!")
hOldFont = SelectObject(hDC, hFont)
TextOut(hDC, 50, 150, "In Arial 10: Hello World!")
SelectObject(hDC, hOldFont)
EndPage(hDC)
EndDoc(hDC)
DeleteObject(hFont)
DeleteDC(hDC)
endif
return nil
static function DoFont(oWnd)
local hDC, aFont[14], nTenthsPoint, nPtSize, hFont, hOldFont
if !empty(hDC := GetPrintDC()) // see also: PrintDlg()
if ChooseFont(aFont, @nTenthsPoint) != nil
nPtSize = nTenthsPoint / 10
CREATE FONT HANDLE hFont NAME aFont[LF_FaceName] SIZE nPtSize DC hDC
StartDoc(hDC, "SomeDocument")
StartPage(hDC)
TextOut(hDC, 50, 50, "Clip-4-Win says: Hello World!")
hOldFont = SelectObject(hDC, hFont)
TextOut(hDC, 50, 150, "In " + aFont[LF_FaceName] + " " ;
+ ltrim(str(nPtSize)) + ": Hello World!")
PrintLines(hDC, 50, 250)
SelectObject(hDC, hOldFont)
EndPage(hDC)
EndDoc(hDC)
DeleteObject(hFont)
endif
DeleteDC(hDC)
endif
return nil
static function PrintLines(hDC, nX, nY)
local i, aTM, nVert := GetDeviceCaps(hDC, VERTRES) // page height
local nLineHeight, nLines
GetTextMetrics(hDC, @aTM)
nLineHeight = aTM[TM_Height] + aTM[TM_ExternalLeading]
nLines = int((nVert - nY) / nLineHeight)
for i = 1 to nLines
TextOut(hDC, nX, nY, "Just filling the paper!")
nX += aTM[TM_AveCharWidth]
nY += nLineHeight
next i
return nil
static function DoBmp(oWnd)
local hDC, cBmp
if !empty(hDC := GetPrintDC()) // see also: PrintDlg()
StartDoc(hDC, "SomeDocument")
StartPage(hDC)
TextOut(hDC, 50, 50, "Clip-4-Win says: Hello World!")
cBmp = ReadDIB("clip4win.bmp")
ShowDIB(hDC, cBmp, 100, 150)
EndPage(hDC)
EndDoc(hDC)
DeleteDC(hDC)
endif
return nil
static function MenuSetup(oWnd)
MENU IN oWnd
POPUP "&File"
MENUITEM "Print &Hello" ACTION DoHello(oWnd)
MENUITEM "Print Using &Arial Font" ACTION DoArial(oWnd)
MENUITEM "Print Using &Font" ACTION DoFont(oWnd)
MENUITEM "Print &Bitmap" ACTION DoBmp(oWnd)
MENUITEM SEPARATOR
MENUITEM "E&xit" ACTION PostQuitMessage(0)
ENDPOPUP
POPUP "&Help"
MENUITEM "&About" ACTION MessageBox( , "Easy!", "Clip-4-Win App")
ENDPOPUP
ENDMENU
return nil