Authorware UCD Development Big Secret (3)

xiaoxiao2021-03-06  18

Discharged

Simple development process.

In fact, this function is used to implement this function is too simple. Just call the Pascal function inputbox itself, but there is still a problem: Authorware gets a string returned value to acquire the memory assigned to this string. Therefore, we must declare a Handle type variable in unit file to store the handle of the string return value, and this return value variable must be a global variable rather than local variables, remember! 1! The following is the specific specific Implementation:

//Aw_InputBoxDemo.dpr

Library INPUTBOXDEMO;

Interface

Uses

SYSUTILS,

Windows,

Messages,

Dialogs, // These lines of manual join

Classes;

VAR

SaveExit: Pointer; // Process pointer exiting the dynamic link library

ReturnHandle: Thandle; // Declare string return value handle

{$ R * .res}

{$ R awresource.res} // load string resources, essential!

// Function implementation process

Function DisplayInputBox (Caption, Tiptxt, Defaulttxt: Pchar): Thandle; StdCall;

VAR / / private variable declaration

Str_RETURN, STR_CAPTION, STR_TIPTXT, STR_DEFAULTTXT: STRING; / / String variable corresponding to PCHAR type

PRETURnstr: PCHAR; / / Represents PCHAR type variables of returning strings

Begin

ReturnstrHandle: = GlobalAlloc (GHND, 255); // Call the API function to allocate memory space to the global variable (255 characters,

// is big enough

P_returnstr: = Globalock (ReturnstrHandle); // Lock the memory and assigns the value to p_returnstr;

STR_CAPTION: = STRPAS (CAPTION); // Transforming PCHAR parameters for string parameters

STR_TIPTXT: = STRPAS (Tiptxt);

Str_defaulttxt: = strpaas (defaulttxt);

Str_RETURN: = INPUTBOX (Str_CAPTION, STR_TIPTXT, STR_DEFAULTTXT);

Strpcopy (p_returnstr, str_return); // Transformation return value is PCHAR type

GlobalUnlock (ReturnstrHandle); // Memory Unlock

Result: = returnstrHandle; // get the return value

END;

Exports // Output function description

DisplayInputbox DISPLAYINPUTBOX

Procedure freehandle; // Release the private process of memory

Begin

GlobalFree (ReturnstrHandle);

END;

Procedure libexit; // Dynamic Link Library Exit Process

Begin

Freehandle;

EXITPROC: = saveexit;

END;

Begin // Dynamic Link Library Initialization Process

SaveExit: = exitproc;

EXITPROC: = @ libexit;

End.

Ok, compile it into an InputBoxDemo.dll file, and change its extension to .u32, start authorware, use the "Function" function to introduce file inputboxDemo.u32 in the Find Dialog box, see what there is:

How to use: Enter: in the computing icon:

Username is the final return value.

The implementation is shown in the figure (in the IDE environment):

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

New Post(0)