APIs and External Function not working correcting...

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by Jared >> Wed, 17 Aug 2005 11:20:49 GMT

Hi all. I tried converting some VB code, that captures the screen , into JADE but so far no luck. Its very basic. I have 4 external functions:

jBitBlt(hDCDest : Integer;
xDest : Integer;
yDest : Integer;
nWidth : Integer;
nHeight : Integer;
hDCSrc : Integer;
xSrc : Integer;
ySrc : Integer;
dwRop : Integer) : Boolean is BitBlt in gdi32;

jGetDesktopWindow() : Integer is GetDesktopWindow in user32;

jGetWindowDC(hWnd : Integer) : Integer is GetWindowDC in user32;

jReleaseDC(hWnd : Integer; hdc : Integer) : Integer is ReleaseDC in user32;

and the method is running off a button:

getScreenPlease_click(btn: Button input) updating;

constants
SRCCOPY : Integer = 13369376;
vars
hWndDesk : Integer;
hDCDesk : Integer;
leftDesk : Integer;
topDesk : Integer;
widthDesk : Integer;
heightDesk : Integer;
result : Boolean;
begin
leftDesk := 0;
topDesk := 0;
widthDesk := 1024;
heightDesk := 768;

hWndDesk := call jGetDesktopWindow();
hDCDesk := call jGetWindowDC(hWndDesk);

result := call jBitBlt(picture1.hwnd, 0, 0, widthDesk, heightDesk, hDCDesk, leftDesk, topDesk, SRCCOPY);

call jReleaseDC(hWndDesk, hDCDesk);

write "result: " & result.String;

end;

Does anyone see where I am going wrong? It keeps returning false and not copying the image into picture1.

Any help would be much appreciated.

Jared.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by cnwtb2 >> Wed, 24 Aug 2005 23:51:15 GMT

Have you tried to individually get the results from each external function call first?

Try this to see what integer numbers are received.

Also when you call "jReleaseDC", does this call have any effect on the result? The result may return false because of this call.

Place the "write result..." statement before the jReleaseDC call to see what happens.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by cnwtb2 >> Wed, 24 Aug 2005 23:51:49 GMT

Have you tried to individually get the results from each external function call first?

Try this to see what integer numbers are received.

Also when you call "jReleaseDC", does this call have any effect on the result? The result may return false because of this call.

Place the "write result..." statement before the jReleaseDC call to see what happens.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by cnwtb2 >> Wed, 24 Aug 2005 23:52:22 GMT

Have you tried to individually get the results from each external function call first?

Try this to see what integer numbers are received.

Also when you call "jReleaseDC", does this call have any effect on the result? The result may return false because of this call.

Place the "write result..." statement before the jReleaseDC call to see what happens.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by cnwtb2 >> Wed, 24 Aug 2005 23:53:03 GMT

Have you tried to individually get the results from each external function call first?

Try this to see what integer numbers are received.

Also when you call "jReleaseDC", does this call have any effect on the result? The result may return false because of this call.

Place the "write result..." statement before the jReleaseDC call to see what happens.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by Patwos >> Thu, 25 Aug 2005 11:16:03 GMT

If the result from call jBitBlt is zero, which your statement of always returning false suggests, then you may need to use GetLastError in kernel32 to find out more information about what error actually occurred during the BitBlt call.

Hope that helps,
Pat.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by Jared. >> Thu, 25 Aug 2005 20:53:18 GMT

Yes, in my code I write out the result. It is always zero (false).

I'll look up this GetLastError function and see if i can retrieve some information from that.

Thanks, Jared.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by Jared >> Sat, 27 Aug 2005 0:20:39 GMT

Yep, I added a little class to my program getting all the system errors and the error it returned was:

6 ERROR_INVALID_HANDLE
The handle is invalid.

This is using picture1.hwnd has the control handle.

I'm not too sure why that would return an error. Unless the return value of picture1s hwnd gets updated suddenly.

Any ideas?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by Van >> Fri, 11 Nov 2005 4:47:16 GMT

hDCPic := call jGetWindowDC(picture1.hwnd());

result := call jBitBlt(
hDCPic, //here request a hDC of your picture control
leftDesk, topDesk, widthDesk, heightDesk,
hDCDesk, leftDesk, topDesk,
SRCCOPY
);

call jReleaseDC(hWndDesk, hDCDesk);

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: APIs and External Function not working correcting...

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:53 pm

by Van >> Fri, 11 Nov 2005 4:53:43 GMT

hDCPic := call jGetWindowDC(picture1.hwnd());

result := call jBitBlt(
hDCPic, //here request a hDC of your picture control
leftDesk, topDesk, widthDesk, heightDesk,
hDCDesk, leftDesk, topDesk,
SRCCOPY
);

call jReleaseDC(picture1.hwnd(), hDCPic); //release picture hdc


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests