Develop Authorware's U32 with Delphi

xiaoxiao2021-03-06  43

Develop Authorware's U32 with Delphi

The function function is the most prominent feature of Authorware, and the system function provided by Authorware can complete some complex control tasks. For some special tasks, Authorware allows users to define functions themselves so that program design has greater flexibility. For Windows systems, custom functions are stored in Dynamic Link Library (DLL) files, so files that store custom functions are discrete to the current interactive application file. This article describes how to develop Authorware's custom functions in Delphi -32 bit U32, this article is developed in Delphi to call the U32 of the Message Box in Authorware as an example. Although Authorware Attain 5.0 has provided the function using Knowledge Objects to display the Message Box, but in the previous version of the previous version, this can be used to develop its own U32 in other languages, and call in Authorware.

Developing U32 can be divided into five steps:

Create project file

Create a function

Create a resource file

Compile resource file

Create U32

1. Create project files

Select DLL to generate a DLL file in File / New Select DLL, in File / Add To Project ... Add a unit MyUnit.PAS containing the U32 function code (this unit details in the second step creation function) must declare all after Uses The function called in Authorware. E.g:

Exports msgbox;

The final code is as follows:

Library Authorware;

Uses

SYSUTILS, CLASSES,

Myunit in 'myUnit.pas';

Exports msgbox;

Begin

End.

2. Create a function

When you create a function can be used in Authorware, you must declare an exported function to join the code behind the keyword interface as follows:

Interface

Uses, Dialogs, Sysutils, Windows

Function msgbox (msg: string; MbType:

Word; title: string: word; export;

Delphi32 needs to add {$ IFDEF WIN32} stdcall;

($ ENDIF}) behind the function declaration, such as:

Function msgbox (msg: string; MbType:

Word; title: string: word; export;

{$ IFDEF WIN32} stdcall; {$ ENDIF}

Now we join the code for the function in the Implementation:

Const

Okonly = 0;

Okcancel = 1;

AbortretryIgnore = 2;

YESNOCANCEL = 3;

YESNO = 4;

Retrycancel = 5;

Critical = 16;

Question = 32;

Excalamation = 48;

Information = 64;

DEFAULTBUTTON1 = 0;

DEFAULTBUTTON2 = 256;

DEFAULTBUTTON3 = 512;

ApplicationModal = 0;

Systemmodal = 4096;

Function Strtopch (str: string): PCHAR;

VAR A: PCHAR;

Begin

A: = Stralloc (Length (STR) 1);

Strpcopy (A, STR);

STRTOPCH: = a;

END;

Function msgbox (msg: string; MbType:

Word; Title: String): Word; Var

LPText, LPCAPTION: PCHAR;

H: hwnd;

Begin

LPTEXT: = STRTOPCH (Title);

LPCAPTION: = STRTOPCH (MSG);

H: = getActiveWindow ();

Msgbox: = MessageBox (h, lptext, lpcaption, mbType);

END;

3. Create a resource file

Finally, what we have to do is create a resource file so that Authorware can call the function directly. You must first create a .rc file and compile it into .res file. Use Notepad to create a .rc resource file. Join the following definition: I will explain these definitions later:

1 DLL_HEADER PRELOAD DISCARDABLE

Begin

"Msgbox / 0",

"/ 0"

End

MSGBOX DLL_HEADER Preload Discardable

Begin

"/ 0",

"W / 0",

"SWS / 0",

"Result: = MsgBox (MSG, MbType, Title) / R / N",

"/ r / n",

"Show Messagebox / 0",

End

If a DLL file is written according to Authorware call conversion format, the directory stored in all custom functions is also included in the file, and Authorware is also included in the information required to call these functions, and its directory is called The directory source, and each function in the directory source has a corresponding definition, these definitions are called definition sources. The specific format is as follows:

Directory source

The format of the directory source is as follows:

| DLL_HEADER PRELOAD DISCARDABLE

Begin

"FunctionName [= exportname] / 0",

"FunctionName [= exportname] / 0",

.

"FunctionName [= exportname] / 0",

"/ 0"

End

1 | is a directory source identifier;

2 DLL_HEADER is the starting mark for creating a descriptive text;

3 BeGin means the beginning of the directory source file,

End represents the end of the directory source.

2. Custom function definition format

There is a corresponding definition format for each function in the directory source, and the specific format is as follows:

FunctionName DLL_HEADER Prelioad Discardable

Begin

"DLLFILENAME / 0"

ReturnValue / 0 "

"Argumentlist / 0"

"Description>",

"Description",

...

"Description / 0"

End

1 FunctionName refers to a function name defined in the directory source;

2 DLL FileName indicates the DLL file name of the storage function;

3 ReturnValue indicates the type of function return value;

4 argumentlist represents a list of parameter types in this function;

5 DESCRIPTION indicates the function descriptive body.

The descriptive body can have a lot of rows, but the last line must be added with the "/ 0" end.

3. Parameter Type Description Format

The parameter type is represented by a uppercase letter, each letter represents a parameter format, as shown in the following table:

Description Format Type Description Format Type

C Signed Char P Far Pointer

B Unsigned Char f Float

I Signed Short Integer D Double

W Unsignedshort Integer S Handle

L Signed long integer v void

U Unsigned long integer

4. Compile resource files

Save the.rc resource file as a3W.rc (Note You cannot save the file name and the DLL file name.

C: / delphi32 / bin / brc32 -r A3w.rc -foa3w32.res

Now add the resource file to the project, return Delphi to open the project file in View / Projcet Source

Exports msgbox; after you see:

{$ R * .res}

Delete the line to join: {$ IFDEF WIN32}

{$ R a3w32.res}

{$ else}

{$ R a3w16.res}

{$ ENDIF}

Compile the project file.

5. Create U32

We have created 32bit's Authorware.dll, and the name is renamed into Authorware.u32. It has been successfully created in Authorware.U32 in Authorware.u32 Add code in the operation design button:

MSGBOX ("Warning Box", 1 32 0 4096, "Do you quit this system?")

转载请注明原文地址:https://www.9cbs.com/read-58418.html

New Post(0)