Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BitBlt
Message
From
16/06/1999 23:47:54
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
BitBlt
Miscellaneous
Thread ID:
00230716
Message ID:
00230716
Views:
186
Sorry about long post -
I am trying to automate copying the contents of a window into the clipboard, but when using Bitblt, the clipboard takes on the right bitmap dimensions, etc, but the image is being filled as though I told the Bitblt() to use BLACKNESS instead of SRCCOPY.

I also had problems getting the corner points for the Rect structure.

Any input would be greatly appreciated.
Code Below:
* #DEFINE SRCCOPY hex2dec("CC") - TRIED DIFFERENT FORMAT FOR RASTER OPERATION
#DEFINE SRCCOPY hex2dec("00CC0020")
#DEFINE CF_BITMAP = 2
PUBLIC CRECT
CRECT = REPLICATE(CHR(0), 16) &&SIMULATE STRUCT FOR Rectangle

DECLARE INTEGER GetDesktopWindow in win32api
DECLARE INTEGER GetActiveWindow in win32api
DECLARE INTEGER GetForegroundWindow in win32api
DECLARE INTEGER GetWindowRect IN Win32API ;
INTEGER, STRING @

DECLARE INTEGER GetDC in win32api INTEGER Hwnd
DECLARE INTEGER CreateCompatibleDC in win32api INTEGER hdc
DECLARE INTEGER CreateCompatibleBitmap in win32api INTEGER hdc, ;
INTEGER nwidth, INTEGER nheight

DECLARE INTEGER SelectObject in win32api INTEGER hdc, INTEGER hObject
DECLARE INTEGER BitBlt in win32api INTEGER hDestDC, INTEGER x, ;
INTEGER y, INTEGER nwidth, INTEGER nheight, INTEGER hSrcDC, ;
INTEGER xSrc, INTEGER ySrc, INTEGER dwRop

DECLARE INTEGER OpenClipboard in win32api INTEGER Hwnd
DECLARE INTEGER SetClipboardData in win32api INTEGER uformat, INTEGER hmem
DECLARE INTEGER EmptyClipboard in win32api
DECLARE INTEGER CloseClipboard in win32api
DECLARE INTEGER DeleteDC in win32api INTEGER hdcMem
DECLARE INTEGER ReleaseDC in win32api INTEGER DeskHwnd, INTEGER hdc
****** end of declarations ****************

NDESKTOP = GetDesktopWindow()
NWINDOW = GetActivewindow()
** NWINDOW = GetForegroundWindow()
LNSUCCESS = GetWindowRect(nwindow, @CRECT)

nleft = Str2Word(SUBSTR(CRECT, 1, 4))
ntop = Str2Word(SUBSTR(CRECT, 5, 4))
nright = Str2Word(SUBSTR(CRECT, 9, 4))
nbottom = Str2Word(SUBSTR(CRECT, 13, 4))

nleft = -4
ntop = -4
nwidth = nright - nleft
nheight = nbottom - ntop

NCLIPBOARD = OpenClipboard(nwindow)
NEMPTY = EmptyClipboard()

ndc = GetDC(ndesktop)
ccdc = CreateCompatibleDC(ndc)
hbitmap = CreateCompatibleBitmap(ndc, nwidth, nheight)

IF hbitmap <> 0 
junk = BitBlt(ccdc, 0, 0, nwidth, nheight, ndc, nleft, ntop, SRCCOPY)
junk = SetClipboardData(2, hbitmap)
junk = CloseClipBoard()
ENDIF
junk = DeleteDC(ccdc)
junk = ReleaseDC(NDESKTOP, ndc)

************FUNCTIONS**************************

* Function hex2dec - Convert a character hex value into decimal.
* Handy for dealing with Hex declarations in API calls.
* Passed: m.hex (character hex value)
* Returns: Decimal value

FUNCTION hex2dec
PARAMETER m.hex

m.decimal = 0
FOR i = LEN(m.hex) TO 1 STEP -1
m.decimal = m.decimal + (AT(SUBSTR(m.hex, i, 1), ;
"0123456789ABCDEF") - 1) * 16 ^ (i - 1)
NEXT
RETURN m.decimal


* Function str2word - Converts low-high format string representation
* to a 16-bit integer (word) value. Useful for unrolling structure
* members containg WORD types.
*
* Passed: Low-high string representation of 16-bit integer
* Returns: numeric value
FUNCTION Str2Word
PARAMETERS m.wordstr

PRIVATE i, m.retval

m.retval = 0
FOR i = 0 TO 8 STEP 8
m.retval = m.retval + (ASC(m.wordstr) * (2^i))
m.wordstr = RIGHT(m.wordstr, LEN(m.wordstr) - 1)
NEXT
RETURN m.retval
Next
Reply
Map
View

Click here to load this message in the networking platform