Hi, I am making a Sheduling program, in which I designed my own graphical interface using fillrect, lines, textout, ect...

I hold the picture in memory, then paint it when it changes like this:

mDC = CreateCompatibleDC(me.hdc)
hBitmap = CreateCompatibleBitmap(me.hdc, 100, 100)
SelectObject(hDC, hBitmap)

Form_Paint/Form_Click()
update chart and work shifts according to what the user clicks,
BitBlt Me.hdc , 0, 0, 100, 100, mDC, 0, 0, vbScrCopy
End

Once the user has finished, I need to be able to print the Shedule out.
Can anyone tell me how I would Print out mDC onto a piece of paper?

Thanks, Nick

Call PrintForm should get you where you want to go

I guess I should have added that I want to change the layout of the picture when I print to make a basic black and white representation of the users work. this r=new representation would still be held in a DC like the main one.
isnt there a way to print straight from a DC? like,
not sure if this would work but I noticed that the printer has an hDC
(printer.hDC)
is there a way I can do something like:

bitblt(printer.hdc,,,,myhDC)
Printer.print ?

well, I only tried it with virtual printer software so far, but it seems to work..

Thanks anyways...

Public Sub PrintDC(hDC As Long, nWidth As Long, nHeight As Long)
Dim mDC As Long
Dim mPIC As Long
Dim hBrush As Long
Dim rDC As Long, rPic As Long
Dim nColor As Long, cX As Long, cY As Long

'create the main image

mDC = CreateCompatibleDC(hDC)
mPIC = CreateCompatibleBitmap(hDC, nWidth, nHeight)
SelectObject mDC, mPIC

'and a buffer thing to put the rotated one into
rDC = CreateCompatibleDC(hDC)
rPic = CreateCompatibleBitmap(hDC, nHeight, nWidth)
SelectObject rDC, rPic


Printer.ScaleMode = vbPixels
BitBlt mDC, 0, 0, nWidth, nHeight, hDC, 0, 0, vbSrcCopy
'initialize the printer ("Printer" is a vb object, the printer wont initialized with an API call)
Printer.Print ""

'rotate the picture 90 degrees (I wanted mine to print like a landscape)
For cY = 0 To nHeight
For cX = 0 To nWidth
nColor = GetPixel(mDC, cX, cY)
SetPixel rDC, nHeight - cY, cX, nColor
Next cX
Next cY

'send it to the printer, the values "150" and "300" are used to create a margin

StretchBlt Printer.hDC, 150, 150, Printer.ScaleWidth - 300, Printer.ScaleHeight - 300, _
rDC, 0, 0, nHeight, nWidth, vbSrcCopy

'tell the printer too print what its got
Printer.EndDoc

'cleanup
DeleteObject mPIC
DeleteObject rPic

End Sub

'VBNick

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.