Tuesday, February 22, 2005

IThumbnailCapture and Delphi

From a request in borland.public.delphi.nativeapi.win32 , I found that the IThumbnailCapture interface wasn't very well documented - or rather, what wasn't was how to create an instance that supported such an interface. So I spent some time making a demo, modifying the CoolStuf demo that comes with Delphi. (In the Demos\CoolStuf folder).

The actual translation of the interface is :


const
IID_IThumbnailCapture : TGUID = (
D1:$4ea39266; D2:$7211; D3:$409f;
D4:($b6,$22,$f6,$3d,$bd,$16,$c5,$33));
type
SIZE = record
cx, cy : LongInt;
end;
PSIZE = ^SIZE;

IThumbnailCapture = interface( IUnknown )
['{4ea39266-7211-409f-b622-f63dbd16c533}']
// *** IThumbnailCapture methods ***
function CaptureThumbnail( pMaxSize : PSIZE;
pHTMLDoc2 : IUnknown;
var phbmThumbnail : HBiTMAP ) : HResult;
stdcall;


and the way to create an instance is:


CoCreateInstance(ClassID, nil,
CLSCTX_INPROC_SERVER or
CLSCTX_LOCAL_SERVER,
IThumbnailCapture, Capture);


Hope this helps. Download the code.

Friday, February 11, 2005

Getting WSDL using basic authentication

Well, this one's tricky. The concept of getting a WSDL that needs authentication to get to - there's one simple way of course, do it yourself, read the WSDL using an Indy component and write it to a local file, and use the local file in Delphi SOAP.

But a far more complicated method is described in my post to the Delphi SOAP newsgroup.

1) Set up an event called OnBeforeGet in THTTPReqResp (the same way
TOnBeforePost is set up)
a) add a private declaration:

// Deepak 11 Feb 2005
FOnBeforeGet: TBeforePostEvent;
// End Deepak 11 Feb 2005

b) in the public part:

// Deepak 11 Feb 2005
{ Events }
property OnBeforeGet: TBeforePostEvent read FOnBeforeGet write FOnBeforeGet;
// End Deepak 11 Feb 2005

2) In the SendGet method of THTTPReqResp, add this line after

Check(not Assigned(Request), False);

Add:

// Deepak 11 Feb 2005
if Assigned(FOnBeforeGet) then
FOnBeforeGet(Self, Request);
// End Deepak 11 Feb 2005

Thats part 1. Now, part 2 is quite complicated, because, as it turns
out, the way the WSDL is fetched is totally inaccessible to us. what
you need to do is:

1) Set up a new event in THTTPRIO - call it TOnGetWSDLItems;

// Deepak 11 Feb 2005
TOnGetWSDLItems = Function( Sender : TObject ) : TWSDLItems of object;
// End Deepak 11 Feb 2005
... (setup an event called OnGetWSDLItems)

2) in the CheckWSDLView procedure, after:

procedure THTTPRIO.CheckWSDLView;
begin
if not Assigned(FWSDLItems) then
begin

add:

If Assigned( FOnGetWSDLItems) then
FWSDLItems := FOnGetWSDLItems( Self );

3) in your main form you'll have to go to HTTPUtil.pas, copy the entire
definition of TStreamLoader over to your main form.

4) Now in the main form, add a funciton like this:

var StreamLoader : TStreamLoader;
begin
StreamLoader := TStreamLoader.Create;
StreamLoader.FUserName := HTTPRIO1.HTTPWebNode.UserName;
StreamLoader.FPassword := HTTPRIO1.HTTPWebNode.Password;
StreamLoader.FHTTPReqResp.GetHTTPReqResp.OnBeforeGet :=
Self.HTTPRIO1HTTPWebNode1BeforePost;
result := TWSDLItems.Create(nil, StreamLoader);
end;

5) Before you do anything, set up your HTTPRIO1 like so:

HTTPRio1.OnGetWSDLItems := OnGetWsdlItems;

Okay, if you're still here, and you've managed to successfully do this,
let me know. I can't post all the code, because it's mostly Borland
code, but it does work. Let me know here if you need it and i'll send
it to you by email.

Google, mapped.

Yep, everyone's talking about maps.google.com. Note: this is of absolutely no use to me right now, because they don't map India (yet). Heck, there's a business idea...no, wait. anyhow, that's a LONG story, which I'll leave for another day. Suffice it to say that I'm not going to be looking for chinese restaurants in Mumbai using maps.google.com.

Anyhow, what I wanted to tell you was that you can now see how it's done. Google is just awesome.

Tuesday, February 08, 2005

Soap paper updated

It's time I'd done this. My paper on Using ADO.NET datasets in Delphi has been updated. Check it out, let me know what you think.