Printing Screen - Forms ?? (OpenInsight Specific)
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 THENOk=1End Elsecall 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=0returnend
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=0RETURNEND
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=0RETURNEND
PAGE_WIDE=GETDEVICECAPS(PRN_HANDLE, HORZRES%)
PAGE_HIGH=GETDEVICECAPS(PRN_HANDLE, VERTRES%)
ans=Utility('CURSOR','H')
* START_PAGE
START_PAGE:
—– Start PageSTATUS=1STATUS=STARTPAGE(PRN_HANDLE)IF STATUS LT 0 THENCALL AMSG('A Printing Error Occurred|StartPage. Code=:STATUS)VALID=0RETURNENDans=Utility('CURSOR','H')destx=100desty=100destdevwidth=page_widedestdevheight=page_highhwnd=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 =sizeif mod(window_width,4)=1 thenwindow_width -= 1endwindow_height=sizehbmp_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=40bitmapinfo=window_widthbitmapinfo=window_heightbitmapinfo=1bitmapinfo=bitsperpixel * colorplanesbitmapinfo=BI_RGB%bitmapinfo=0bitmapinfo=0bitmapinfo=0bitmapinfo=0bitmapinfo=0bitmapinfo=str(' ',1024)bitmapinfo=var_to_struct(bitmapinfo, 'BITMAPINFO')widthratio=window_width / screenwidthheightaspectratio=window_height / window_widthprintwidth=widthratio * destdevwidthprintheight=heightaspectratio * printwidthbytesneeded=(window_width + 1) * (window_height + 1)cdata=bytesneededbytesneeded=cdatahmem=GlobalAlloc(GMEM_MOVABLE%, bytesneeded)ans=Utility('CURSOR','H')if hdc_window 0 and hbmp_window 0 and hdc_dest 0 and hmem 0 thenlpbits=GlobalLock(hmem)cdata=lpbitslpbits=cdatar2=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 elseamsg(hdc_window:'|':hbmp_window:'|':hdc_dest:'|':hmem)r2=0r3=0endif r2 0 and r3 0 elsevalid=0gosub offreturnendans=Utility('CURSOR','H')* FORM_FEED
FORM_FEED:
—– Form FeedSTATUS=1STATUS=ENDPAGE(PRN_HANDLE)IF STATUS LT 0 THENCALL AMSG('A Printing Error Occurred|EndPage. Code=:STATUS)VALID=0RETURNENDans=Utility('CURSOR','H')* OFF
OFF:
—– End DocSTATUS=1STATUS=ENDDOC(PRN_HANDLE)IF STATUS LT 0 THENCALL AMSG('A Printing Error Occurred|EndDoc. Code=:STATUS)VALID=0ENDSTATUS=1STATUS=DeleteDC(PRN_HANDLE)IF STATUS LE 0 THENCALL AMSG('A Printing Error Occurred|DeleteDC. Code=:STATUS)VALID=0RETURNENDans=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=PTHEX_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=PTHEX_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