|
List Info
Thread: Crystal 8 UDF's
|
|
| Crystal 8 UDF's |

|
2006-11-13 16:36:10 |
|
> ----- Original Message -----
> From: "Rob Kennedy" < rkennedy%40cs.wisc.edu">rkennedy cs.wisc.edu>
> To: delphi-en%40yahoogroups.com">delphi-en yahoogroups.com
> Subject: Re: [delphi-en] Crystal 8 UDF's
> Date: Mon, 13 Nov 2006 09:53:44 -0600 (CST)
>
>
> Paul Bennett wrote:
> > I am trying to create a Crystal 8 User Defined Function dll which
> > takes a single integer as a parameter and packs that integer up into
> > a broadcast Message as the wparam parameter.
> >
> > My code is shown below.
> >
> > function LaunchApplication (ParamBlock : PUFParamBlock) : UFError;
>
> Is this the function exported by your DLL? It should probably use the
> stdcall calling convention, not register.
>
> > var Param1 : PUFParamListElement; //a pointer to the first parameter
> > var n : integer;
> > fWakeup : Cardinal;
> > MyWakeup: PChar;
> > begin
> > Param1 := GetParam (ParamBlock, 1); //the first param is the AppID
> > to launch
> > //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);
>
> What is the value of n?
n Is an integer value which should have been passed int to the function from Crystal
> Why are you storing an error string in a variable named fWakeup, as though
> it's the same status the wakeup message you store in that variable later?
> Go ahead and use different variables with appropriate names. It will make
> the code easier to read.
Your right, Error should have been declared as a PChar, it is basically another (different) string used to generate a Unique Windows Message ID.
> And what is nResult?
nResult is just a holder to contain the result of the postmessage method (and should have been declared in the var block).
>
> --
> Rob
re-writing the Error check below may be clearer
var
MyErrorID: PChar;
fError : Cardinal
....
if (Param1 = nil) then
begin
MyErrorID := Error;
fError := RegisterWindowMessage(MyErrorID);
If fError <> 0 Then // fError is valid Message #
nResult := PostMessage(hWnd_BROADCAST, fError, n, n);
I don't think either of those oversights are the problem though, it would seem that the call to PostMessage(hWnd_BROADCAST, fWakeUp, n, n) is not passing the integer variable 'n'
Regardless of which message handler I use in the eventual target I get a value of 0 in both parameter positions.
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
__._,_.___
.
__,_._,___
|
| Crystal 8 UDF's |

|
2006-11-13 18:19:37 |
|
Paul Bennett wrote:
>>> var Param1 : PUFParamListElement; //a pointer to the first parameter
>>> var n : integer;
>>> fWakeup : Cardinal;
>>> MyWakeup: PChar;
>>> begin
>>> Param1 := GetParam (ParamBlock, 1); //the first param is the AppID
>>> to launch
>>> //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);
>>
>> What is the value of n?
>
> n Is an integer value which should have been passed int to the function
> from Crystal
Read my question again. 
You do have all compiler hints and warnings enabled, don't you?
> re-writing the Error check below may be clearer
> var
> MyErrorID: PChar;
> fError : Cardinal
> ....
> if (Param1 = nil) then
> begin
> MyErrorID := Error;
> fError := RegisterWindowMessage(MyErrorID);
> If fError <> 0 Then // fError is valid Message #
> nResult := PostMessage(hWnd_BROADCAST, fError, n, n);
>
> I don't think either of those oversights are the problem though, it would
> seem that the call to PostMessage(hWnd_BROADCAST, fWakeUp, n, n) is not
> passing the integer variable 'n'
It's passing the value in that variable, but what, exactly, should that
value be?
> Regardless of which message handler I use in the eventual target I get a
> value of 0 in both parameter positions.
What value were you expecting, and why?
--
Rob
__._,_.___
.
__,_._,___
|
| Crystal 8 UDF's |

|
2006-11-14 18:50:06 |
|
Just a comment to hopefully help (and I might be going off wildly on the
wrong tangent here,) but it appears to me that there's a
misunderstanding below: Rob is asking what the value of n is (implying,
as I read him, that it's undefined.) However its value would be the
value of the first parameter passed to the report (I think), and is set
in the line reading:
n := Param1.Parameter.ParamInteger;
Unfortunately this line was trimmed off which might've given the
impression that n is not set anywhere, giving rise to the
misunderstanding. (Or, as I say, I'm barking up entirely the wrong tree
)
Walter
Rob Kennedy wrote:
>
>
> >>> nResult := PostMessage(hWnd_BROADCAST, fWakeUp, n, n);
> >>
> >> What is the value of n?
> >
> > n Is an integer value which should have been passed int to the function
> > from Crystal
>
> Read my question again. 
>
[Non-text portions of this message have been removed]
__._,_.___
.
__,_._,___
|
| Crystal 8 UDF's |

|
2006-11-14 19:55:17 |
|
Walter Prins wrote:
> Just a comment to hopefully help (and I might be going off wildly on the
> wrong tangent here,) but it appears to me that there's a
> misunderstanding below: Rob is asking what the value of n is (implying,
> as I read him, that it's undefined.) However its value would be the
> value of the first parameter passed to the report (I think), and is set
> in the line reading:
>
> n := Param1.Parameter.ParamInteger;
>
> Unfortunately this line was trimmed off which might've given the
> impression that n is not set anywhere, giving rise to the
> misunderstanding. (Or, as I say, I'm barking up entirely the wrong tree
> )
It was trimmed off _below_ the line I asked about, not above.
There's also still the question about calling conventions.
--
Rob
__._,_.___
.
__,_._,___
|
| Crystal 8 UDF's |

|
2006-11-14 22:05:53 |
|
Aha! So I *was* barking up qutie the wrong tree... live and learn eh.
Will teach me to be more careful next time. 
Thanks
Walter
Rob Kennedy wrote:
>
> It was trimmed off _below_ the line I asked about, not above.
>
> There's also still the question about calling conventions.
>
[Non-text portions of this message have been removed]
__._,_.___
.
__,_._,___
|
[1-5]
|
|