Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 09 OCT 1998 10:20:52AM BC wrote:

Other than having a button on a form that would somehow read

all the controls and text work up a print routine are there any built

in ways to "Print Screen" a form.

Could I read the clipboard and put the screen into a bitmap and then

print?

Looking for solutions….

Thanks


At 09 OCT 1998 03:06PM Hamlin wrote:

I needed to create a series of print screen images to prepare

end user documentation. I was able to do it by using the "print

scrn" key to place a screen image on the clipboard. Next, I used

the paint feature to crop and edit the image to a bitmap file.

From there I was able to print it. The process is tedious but it

works. Good Luck!


At 13 OCT 1998 01:09PM Dean Todd - Computer Resource Team, Orlando, FL wrote:

If you need the data, rather than a bitmap of the window, you can create a report, and put a button on the form, which calls the report.

Here's a script example.

*

declare Function Rlist,Get_Property, Repository,Get_Property, Set_Property, Start_Window, Send_Event

$Insert SYSPROCS, RLIST_EQUATES

Call Utility("CURSOR", "H")

PLAN_CODE= Get_Property (@WINDOW : '.PLAN_CODE', 'TEXT')

PERIOD=Get_Property (@WINDOW : '.PERIODBOX', 'TEXT')

Id=PLAN_CODE : '*' : PERIOD

if Len(Id) then

Report_Name=CAPITATED_SUMMERY.RPT'

ListName=CAP'

* instead of RList select, write Key directly to list file.

OPEN 'SYSLISTS' TO LIST_FILE ELSE NULL

  WRITE Id ON LIST_FILE, ListName THEN
  Ok=1
End Else
  call MSG( "", "Unable to write to SYSLISTS file!" )
Ok='

end

Win=@Window

  Stat=Utility( 'RUNWIN', 'REPORTER.EXE /REPOS /RP= : Report_Name : ' /AP=FMN /UN=FMN /PV=1 /QU=1' )

end

Flush

GarbageCollect

RETURN 0

*end code

Notice that it writes directly to syslists. The report selection is GETLIST CAP.

Works every time!!


At 17 OCT 1998 05:46AM JC wrote:

BC,

Imagine pressing "Print Scrn" and having the form print to the printer (as it appears one screen). The following should do the tirck.

PS: I know its a bit of a mess. If you clean it up I'd appreciate a copy emailed back (jcurby@tpg.com.au). I use it in production so it works just fine (standard disclaimers though).

Regards

John

Print Screen

compile subroutine Lib_Print_Win (window, outp, data, valid, parent)

* This routine prints an on-screen window layout to the printer

* Note AMsg is just a custom replacement for Msg

* Note there may some redundant code in here

declare subroutine amsg, Create_Dialog, End_Dialog

declare function get_property, build_struct, var_to_struct, get_printer, set_printer, Utility

declare function GetWindowDC, CreateCompatibleDC, GetDeviceCaps, CreateCompatibleBitMap

declare function SelectObject, BitBlt, GlobalAlloc, GlobalLock, GetDIBits, StretchDIBits, GlobalUnlock, GlobalFree

declare function DeleteDC, DeleteObject, ReleaseDC, StartDoc, EndDoc, GetProfileString, CreateDC, GetDC

declare function startpage, endpage, SetMapMode

declare subroutine GetWindowRect

ans=Utility('CURSOR','H')

if assigned(window) else

amsg('A window name has not been identified for printing','BOk')
valid=0
return

end

outp='

data='

valid='

parent=window

* definitions

HORZRES%=8

VERTRES%=10

SRCCOPY%=13369376

BITSPIXEL%=12

PLANES%=14

BI_RGB%=0

GMEM_MOVABLE%=2

DIB_RGB_COLORS%=0

* build rect structure

size=get_property(window, 'SIZE')

left=size

top=size

right=size + size

bott=size + size

rect=left:@fm:top:@fm:right:@fm:bott

rect=var_to_struct(rect, 'RECT')

ans=Utility('CURSOR','H')

doc_name=testing'

CreateParams=Printing':@FM:DOC_NAME

*—– Get Printer Name

PRN_NAME=SPACE(80)

GP_PTR=windows':CHAR(0)

ITEM_PTR=device':CHAR(0)

DFLT_PTR=,,,'

NAME_LEN=80

NO_CHARS=GetProfileString(GP_PTR, ITEM_PTR, DFLT_PTR, PRN_NAME, NAME_LEN)

IF NO_CHARS ELSE

AMSG('Could not find a default printer','','',PARENT)
VALID=0
RETURN

END

SWAP CHAR(0) WITH IN PRN_NAME *—– Get the Printer Handle DEVICE_NAME=TRIM(FIELD(PRN_NAME,',',1)):CHAR(0) DRIVER_NAME=TRIM(FIELD(PRN_NAME,',',2)):CHAR(0) OUT_PORT=TRIM(FIELD(PRN_NAME,',',3)):CHAR(0) PRN_HANDLE=CREATEDC(DRIVER_NAME, DEVICE_NAME, OUT_PORT, )

hdc_dest=prn_handle

ans=SetMapMode(hdc_dest, 1)

*—– Start Doc

STATUS=1

OUT_FILE=CHAR(0)

DOC_NAME=DOC_NAME1,' '

DOCINFO=DOC_NAME:CHAR(0)

FILEINFO=OUT_PORT:CHAR(0)

info_len=len(docinfo)+len(fileinfo)-2

LOCKVARIABLE DOCINFO AS CHAR

LOCKVARIABLE FILEINFO AS CHAR

PT=GETPOINTER(DOCINFO)

GOSUB GET_32HEX_PTS

DOC_PTR=HEX_PTS

PT=GETPOINTER(FILEINFO)

GOSUB GET_32HEX_PTS

FILE_PTR=HEX_PTS

pt=info_len

GOSUB GET_16HEX_PTS

DOCINFO=hex_pts:DOC_PTR:FILE_PTR

STATUS=STARTDOC(PRN_HANDLE, DOCINFO)

UNLOCKVARIABLE DOCINFO

UNLOCKVARIABLE FILEINFO

IF STATUS LT 0 THEN

CALL AMSG('A Printing Error Occurred|StartDoc. Code=:STATUS)
VALID=0
RETURN

END

PAGE_WIDE=GETDEVICECAPS(PRN_HANDLE, HORZRES%)

PAGE_HIGH=GETDEVICECAPS(PRN_HANDLE, VERTRES%)

ans=Utility('CURSOR','H')

* START_PAGE

START_PAGE:

  • —– Start Page
STATUS=1
STATUS=STARTPAGE(PRN_HANDLE)
IF STATUS LT 0 THEN
  CALL AMSG('A Printing Error Occurred|StartPage. Code=:STATUS)
  VALID=0
  RETURN
END
ans=Utility('CURSOR','H')
destx=100
desty=100
destdevwidth=page_wide
destdevheight=page_high
hwnd=get_property(window, 'HANDLE')
hdc_window=GetWindowDC(hwnd)
hdc_Mem=CreateCompatibleDC(hdc_window)
screenwidth=GetDeviceCaps(hdc_window, HORZRES%)
screenheight=GetDeviceCaps(hdc_window, VERTRES%)
ans=Utility('CURSOR','H')
GetWindowRect(hwnd, rect)
window_width =size
if mod(window_width,4)=1 then
  window_width -= 1
end
window_height=size
hbmp_window=CreateCompatibleBitMap(hdc_window, window_width, window_height)
ans=Utility('CURSOR','H')
hprevbmp=SelectObject(hdc_mem, hbmp_window)
r1=BitBlt(hdc_mem, 0, 0, window_width, window_height, hdc_window, 0, 0, SRCCOPY%)
bitsperpixel=GetDeviceCaps(hdc_mem, BITSPIXEL%)
colorplanes=GetDeviceCaps(hdc_mem, PLANES%)
bitmapinfo='
bitmapinfo=40
bitmapinfo=window_width
bitmapinfo=window_height
bitmapinfo=1
bitmapinfo=bitsperpixel * colorplanes
bitmapinfo=BI_RGB%
bitmapinfo=0
bitmapinfo=0
bitmapinfo=0
bitmapinfo=0
bitmapinfo=0
bitmapinfo=str(' ',1024)
bitmapinfo=var_to_struct(bitmapinfo, 'BITMAPINFO') 
widthratio=window_width / screenwidth
heightaspectratio=window_height / window_width
printwidth=widthratio * destdevwidth
printheight=heightaspectratio * printwidth
bytesneeded=(window_width + 1) * (window_height + 1)
cdata=bytesneeded
bytesneeded=cdata
hmem=GlobalAlloc(GMEM_MOVABLE%, bytesneeded)
ans=Utility('CURSOR','H')
if hdc_window  0 and hbmp_window  0 and hdc_dest  0 and hmem  0 then
  lpbits=GlobalLock(hmem)
  cdata=lpbits 
  lpbits=cdata
  r2=getdibits(hdc_mem, hbmp_window, 0, window_height, lpbits, bitmapinfo, DIB_RGB_COLORS%) 
  r3=stretchdibits(hdc_dest, destx, desty, printwidth, printheight, 0, 0, window_width, window_height, lpbits, bitmapinfo, DIB_RGB_COLORS%, SRCCOPY%)
  ans=Utility('CURSOR','H')
end else
  amsg(hdc_window:'|':hbmp_window:'|':hdc_dest:'|':hmem)
  r2=0
  r3=0
end
if r2  0 and r3  0 else
  valid=0
  gosub off
  return
end
ans=Utility('CURSOR','H')

* FORM_FEED

FORM_FEED:

  • —– Form Feed
STATUS=1
STATUS=ENDPAGE(PRN_HANDLE)
IF STATUS LT 0 THEN
  CALL AMSG('A Printing Error Occurred|EndPage. Code=:STATUS)
  VALID=0
  RETURN
END
ans=Utility('CURSOR','H')

* OFF

OFF:

  • —– End Doc
STATUS=1
STATUS=ENDDOC(PRN_HANDLE)
IF STATUS LT 0 THEN
  CALL AMSG('A Printing Error Occurred|EndDoc. Code=:STATUS)
  VALID=0
END
STATUS=1
STATUS=DeleteDC(PRN_HANDLE)
IF STATUS LE 0 THEN
  CALL AMSG('A Printing Error Occurred|DeleteDC. Code=:STATUS)
  VALID=0
  RETURN
END
ans=Utility('CURSOR','H')
r=SelectObject(hdc_mem, hprevbmp)
r=GlobalUnlock(hmem)
r=GlobalFree(hmem)
r=DeleteDC(hdc_window)
r=DeleteDC(hdc_dest)
r=DeleteObject(hbmp_window)
r=ReleaseDC(hwnd, hdc_window)

return

* GET_32HEX_PTS

GET_32HEX_PTS:

HEX_PT=PT
HEX_PT=OCONV(HEX_PT,'MB')
HEX_PT=FMT(('00000000000000000000000000000000':HEX_PT), 'R#32')
HEX_PTS=CHAR(ICONV(HEX_PT25,8, 'MB')) : CHAR(ICONV(HEX_PT17,8, 'MB'))
HEX_PTS := CHAR(ICONV(HEX_PT9,8, 'MB')) : CHAR(ICONV(HEX_PT1,8, 'MB'))

RETURN

* GET_16HEX_PTS

GET_16HEX_PTS:

HEX_PT=PT
HEX_PT=OCONV(HEX_PT,'MB')
HEX_PT=FMT(('0000000000000000':HEX_PT), 'R#16')
HEX_PTS=CHAR(ICONV(HEX_PT9,8, 'MB')) : CHAR(ICONV(HEX_PT1,8, 'MB'))

RETURN

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/aa0ba21c9bb97e1085256698004ed0c6.txt
  • Last modified: 2023/12/28 07:40
  • by 127.0.0.1