errors

errors

having trouble getting app to print a dialog box like a bitmap in colour. I understand that there are common printing dialog boxes. How do you get them to open and how can the programs interface be printed not just the text/graphics it contains?

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Here's the routine which invokes common print dialog and prints contents of window with handle hWnd. If you're using QuickWin, use GETHWNDQQ to obtain window handle:

subroutine PrintWindow(hwnd)

 use comdlg32
 use gdi32
 use user32
 use dfwin

 TYPE(T_PRINTDLG) pd
 TYPE(T_DOCINFO) DocInfo
 TYPE(T_RECT) Rect

 INTEGER hdc, iSt,hwnd, iXRes, iYRes

 hdc = GetWindowDC(hWnd)

 call ZeroMemory(LOC(pd), sizeof(pd))

 pd%lStructSize= sizeof(pd)
 pd%hwndOwner= hWnd
 pd%Flags= PD_RETURNDC

 iSt=PrintDlg(pd)
 DocInfo%cbSize = sizeof(DOCINFO)
 DocInfo%lpszDocName = LOC("TEST"C)
 DocInfo%lpszOutput = NULL
 iSt=StartDoc(pd%hDC, DocInfo)
 iSt=StartPage(pd%hDC)
 iSt=GetWindowRect(hWnd,Rect)
 iXRes=GetDeviceCaps(pd%hDC, HORZRES)
 iYRes=GetDeviceCaps(pd%hDC, HORZRES)

 iSt=StretchBlt(pd%hdc, 0, 0,  (Rect%Right-Rect%Left)*iXRes/96,  &
             (Rect%Bottom-Rect%Top)*iYRes/96,                    &
       hDC, 0, 0, Rect%Right-Rect%Left, Rect%Bottom-Rect%Top, SRCCOPY)
 iSt=GetLastError()
 iSt=EndPage(pd%hDC)
 iSt=EndDoc(pd%hDC)
 if (pd%hDevMode /= NULL) iSt=GlobalFree(pd%hDevMode)
 if (pd%hDevMode /= NULL) iSt=GlobalFree(pd%hDevNames)
 iSt=ReleaseDC(hWnd,hdc)
 iSt=DeleteDC(pd%hDC)

 end subroutine

Jugoslav

Leave a Comment

Please sign in to add a comment. Not a member? Join today