> ----- Original Message -----
> From: "Walter Prins" <[EMAIL PROTECTED]>
> To: [email protected]
> Subject: Re: [delphi-en] Crystal 8 UDF's
> Date: Thu, 16 Nov 2006 00:44:09 +0000
> 
> 
> Hello Paul,
> 
> At the risk of belaboring this too much... :-) I think you might maybe
> (?) still be making the same mistake I made (which prompted me to chip
> in earlier on as well.)  Notice, there are *2* PostMessage lines in your
> code.  The first one, happens **before** the line where n is assigned a
> value.  Thus, n is undefined for the first PostMessage, and as Rob's
> pointed out, the compiler should've warned you about it. :-)
> 
> Eg (quoting original code again, see lines marked with <<<<<<<<<<) :
> 
> function LaunchApplication (ParamBlock : PUFParamBlock) : UFError;
> var
> ···Param1 : PUFParamListElement; //a pointer to the first parameter
> ···n : integer;
> ···fWakeup : Cardinal;
> ···MyWakeup: PChar;
> begin
> ···//the first param is the AppID to launch
> ···Param1 := GetParam (ParamBlock, 1);
> 
> ···//check if the correct number of parameters is passed to our function
> ···if (Param1 = nil) then
> ···begin
> ······MyWakeup := Error;
> ······fWakeup := RegisterWindowMessage(MyWakeup);
> ······If fWakeup <> 0 Then
> ·········nResult := PostMessage(hWnd_BROADCAST, fWakeUp, n, n);
> //<<<<<<<< n is undefined!
> ······Result := UFNotEnoughParameters;
> ······EXIT;
> ···end;
> 
> ···n := Param1.Parameter.ParamInteger;
> ···MyWakeup := Wakeup;
> ···fWakeup := RegisterWindowMessage(MyWakeup);
> ···If fWakeup <> 0 Then
> ······nResult := PostMessage(hWnd_BROADCAST, fWakeUp, n, n)  // <<<<<< n
> is defined here!
> ···Else
> ······nResult := False;
> 
> ···ParamBlock^.ReturnValue.ReturnNumber := Param1.Parameter.ParamInteger;
> ···Result := UFNoError;
> end;
> 
> Cheers
> 
> Walter
> 

The first call to PostMessage only takes place if the Param1 variable is null, 
in which case the value on n is immaterial, it is a case of 'cut and paste' 
without checking what the code actually says! That said, the receiving 
application ignores the 'n' parameters received from the Error message.

I think the problem is clearly with the method of passing parmaters from 
Crystal Reports to the dll. As I said earlier, this code was taken from an 
example of how to create UDFs in Delphi. So what I probably need is advise on 
how to create Crystal Reports UDFs in Delphi.

 Paul Bennett

   Experience is something you don't get until just after you need it. 


-- 
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 9 at http://www.opera.com

Powered by Outblaze

Reply via email to