pnwidth, @pnheight) *-- 根据屏幕和打印机得到缩放值 xscale = getdevicecaps(hprndc, logpixelsx)/getdevicecaps(hformdc,logpixelsx) yscale = getdevicecaps(hprndc, logpixelsy)/getdevicecaps(hformdc,logpixelsy) *-- 将屏幕的内容创建为位图图象数据 hmemdc = createcompatibledc (hformdc) hmembmp = createcompatiblebitmap (hformdc, pnwidth, pnheight) hsavedbitmap = selectobject(hmemdc, hmembmp) *-- 将位图数据从屏幕拷贝到虚拟设备上 = bitblt (hmemdc, 0,0, pnwidth,pnheight, hformdc, 0,0, srccopy) = selectobject(hmemdc, hsavedbitmap) * retrieving bits from the compatible bitmap into a buffer * as a device-independent bitmap (dib) with a bitsperpixel value * as one of the printer device context lcbinfo = initbitmapinfo(hprndc) lpbitsarray = initbitsarray() = getdibits (hmemdc, hmembmp, 0, pnheight,; lpbitsarray, @lcbinfo, dib_rgb_colors) lcdocinfo = chr(20) + repli(chr(0), 19) &;&; docinfo struct - 20 bytes if startdoc(hprndc, @lcdocinfo) > 0 = startpage(hprndc) = stretchdibits (hprndc, xoffsprn, yoffsprn,; xoffsprn + int(xscale * pnwidth),; yoffsprn + int(yscale * pnheight),; 0,0, pnwidth, pnheight,; lpbitsarray, @lcbinfo, dib_rgb_colors, srccopy) = endpage(hprndc) = enddoc(hprndc)
endif *-- 退出时释放
系统资源 = globalfree(lpbitsarray) = deleteobject(hmembmp) = deletedc(hmemdc) = deletedc(hprndc) = releasedc(hwnd, hformdc) return procedure getwinrect (lnhwnd, lnwidth, lnheight) *-- 返回指定句柄的窗口的宽和高 #define maxdword 4294967295 &;&; 0xffffffff local lprect, lnleft, lntop, lnright, lnbottom lprect = repli (chr(0), 16) = getwindowrect (lnhwnd, @lprect) lnright = buf2dword(substr(lprect, 9,4)) lnbottom = buf2dword(substr(lprect, 13,4)) lnleft = buf2d
word(substr(lprect, 1,4)) if lnleft > lnright lnleft = lnleft - maxdword endif lntop = buf2dword(substr(lprect, 5,4)) if lntop > lnbottom lntop = lntop - maxdword endif lnwidth = lnright - lnleft lnheight = lnbottom - lntop return function getdefaultprndc * returns device context for the default printer #define pd_returndc 2