Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing: setting Handles to Device Contexts

Status
Not open for further replies.

RSGB

Technical User
Feb 14, 2001
45
GB
Hi guys,

I'm using a gantt control (phGantX1) in some Access forms and I have a problem with the fact that Access doesn't have a Printer object.

The control comes with some VB example code for printing (VB DOES have a printer object...):


Printer.Print "This is a test printout"
phGantX1.PrintToHdc Printer.hdc, 100, 100, 5, 5, 200, phGantX1.TopItemTree, -1, True, Now - 30, Now + 30, 300, 30, w, h
Printer.EndDoc


Having read in various places that I should use the windows api CreateDC to create a handle to device context for the default printer I have done this:

lpReturnedString$ = Space$(128)
nPrinter = GetProfileString("windows", "device", ",,,", lpReturnedString$, Len(lpReturnedString$))

nDevice = InStr(lpReturnedString$, ",")
nDriver = InStr(nDevice + 2, lpReturnedString$, ",")
szDevice = Mid$(lpReturnedString$, 1, nDevice - 1)
szDriver = Mid$(lpReturnedString$, nDevice + 1, nDriver - _
nDevice - 1)
szOutPut = Mid$(lpReturnedString$, nDriver + 1)

ThehDC = CreateDC(szDriver, szDevice, 0, 0)

Which seems to work according to debug. But I can't seem to work out exactly how to substitute it into the example successfully.

Does anyone have experience of this sort of thing and can see what I need to do to get it to work?

TIA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top