Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>createdc()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
CreateDC()
Create a device context
------------------------------------------------------------------------------

Syntax
CreateDC( <cDriver>, <cDevice>, <cPort> [ , <cData> ] )   -->   hDC

Arguments
<cDriver> is the name of the Windows device driver filename
(e.g. "HPPCL5A").

<cDevice> is the name of the device controlled by the device
driver.

<cPort> is the name of the output port or file for the
driver's output (e.g. "LPT1:").

<cData> is optional initialisation data (a Windows DEVMODE
structure).  The details of this parameter are beyond the
scope of this manual.  The default value (NIL) is likely to be
all you need.

Returns
If successful, this function returns a handle to a device
context.  This handle will be a non-zero numeric.  Otherwise,
zero (0) is returned.

Description
Drawing in Windows is done using GDI (graphics device
interface) functions, which require a handle to a device
context.  This function returns a suitable handle for drawing
on the device specified.  For the display it is easier to use
the GetDC() function.  For printing, you may prefer to use
GetPrintDC().

When you have finished using the handle be sure to free it
with the DeleteDC() function.

Example
// use the printer in WIN.INI
cPrintInfo = GetProfString( "windows", "device", "" )

// separate the fields, which are delimitted by commas ( "," )
cPrintDevice = alltrim( left( cPrintInfo, at( ",", cPrintInfo) - 1 ) )
cPrintInfo   = substr( cPrintInfo, at( ",", cPrintInfo ) + 1 )
cPrintDriver = alltrim( left( cPrintInfo, at( ",", cPrintInfo) - 1 ) )
cPrintInfo   = substr( cPrintInfo, at( ",", cPrintInfo ) + 1 )
cPrintPort   = cPrintInfo

hPrintDC = CreateDC( cPrintDriver, cPrintDevice, cPrintPort )
if hPrintDC != 0
     StartDoc( hPrintDC, "TestOutput" )
     StartPage( hPrintDC )
     TextOut( hPrintDC, 10, 10, "Hello from John Skelton" )
     EndPage( hPrintDC )
     EndDoc( hPrintDC )
     DeleteDC( hPrintDC )
endif


See Also: DeleteDC() GetDC() GetPrintDC() ReleaseDC()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson