Finding the Authorware window

In Authorware 3.0, Macromedia introduced a new way for UCDs to get the Authorware presentation window. This means that you don't have to pass the WindowHandle value to the function. This is done by using a modification of the resource file APW uses to load UCDs. If the first argument of the parameter list is "A", then APW passes back a structure back containing, among other things, the presentation window handle. To use this feature, we need to declare a record for this structure, called the AWPARAM structure. The record looks like this:

Type AWPARAM = {$ifdef WIN32} packed {$endif} record
     size: UINT;
     wnd: HWND;
     authoring: Bool;
     reserved1: LongInt;
     reserved2: LongInt;
     end;

type AWPARAM_PTR = ^AWPARAM;

Add this declaration to the apwpost.pas file, just before the implementation keyword.
Next, we have to change the functions so that they will know about the record that will be passed to them. Open the code.pas file. The function declarations will need to be changed like this:

procedure Add( aw : AWPARAM_PTR ) ; export ; {$ifdef WIN32} stdcall ; {$endif}
procedure UCase( aw : AWPARAM_PTR ) ; export ; {$ifdef WIN32} stdcall ; {$endif}

The functions will also need to be changed to use the AWPARAM information. Note that if there is more than one argument in a function, the AWPARAM will always be the first one.

procedure Add( aw : AWPARAM_PTR );
var
   num1 , num2 : LongInt;
begin
     if GetApwNumber( 'num1' , num1 , aw^.wnd ) = true then
        if GetApwNumber( 'num2' , num2 , aw^.wnd ) = true then
           SetApwNumber( 'res' , num1 + num2 , aw^.wnd );
end;

procedure UCase( aw : AWPARAM_PTR );
var
   buff : array[0..256] of char;
begin
     if GetApwString( 'str' , buff , 256 , aw^.wnd ) = true then
        begin
        StrUpper( buff );
        SetApwString( 'str' , buff , aw^.wnd );
        end;
end;

After changing the functions in this way, we must then use a resource file to load the functions. If you try to load the functions directly from the dll, then a crash will most probably occur.

On to: Creating the resource file

Back to: The UCase function      Start