TE Edit Control Win32 / Win64 Help
Product page

Using the Editor as a DLL

This method can be used to create an editor window which is not contained within a Visual Basic form. The editor window can be independedly moved and sized. You can enable the menu bar. Thus, using this method, you can create a word processor window which handles all user interaction. The initial window is created using the 'CreateTerWindow' API function. If you simply need to edit a file, you do not need to use any other API functions. However, the package provides a list of API functions that can be used for various text manipulation tasks.

The API functions for the use with Visual Basic are defined in the TER.BAS file. The product provides three additional functions: 'DiscardNull', 'StrToHandle' and 'HandleToStr' specifically for the use in the Visual Basic environment. All other functions are the same as those available for the 'C' environment. A brief description of often used API functions for the Visual Basic environment is presented here in alphabetic order. However, please refer to the 'Application Interface Function' chapter for a complete list of API functions. Also, please study the demo program (dmo_vb) for a practical example of using these functions.

CloseTer

CloseTer(hWnd as integer, force as integer) as integer

Description: Use to close a TER window.

The function returns a TRUE value if the window is closed.

DiscardNull

DiscardNull(InString as string) as string

Description: Unlike other functions, the body of this function is defined in the TER.BAS file. This function is needed to discard the terminating NULL character that a 'C' DLL appends to the string output data. This function is not needed when a string is used for input only

GetTerFields

GetTerFields(hWnd as integer, field as StrTerField) as integer

Description: Retrieves the operational variables for the specified TER window. This information is returned in the 'StrTerField' structure type specified by the second argument. The 'StrTerField' structure type is defined in the TER.BAS file. If you wish to modify a TER operation variable, you must call this function before calling the 'SetTerFields' function.

This function returns a TRUE value if successful.

HandleToStr

HandleToStr(OutString as string, StringLen as long, hMem as integer) as integer

Description: This function can be used to copy the contents a global memory block to a Visual Basic string. The third argument specifies the handle of the global memory block. You must specify the length of data to retrieve using the second argument. The length must not exceed the size of the global memory block. The first argument specifies the Visual Basic string that will receive the data. This string must he large enough to hold the specified length of data. Use the 'space' (VB) function to set the string size. Example:

Dim OutString as string

Dim result as integer

OutString = space(BufferLen)

result = HandleToStr(OutString,BufferLen,hMem)

This function also frees the global memory handle after copying. To simply free the block without retrieving the data, call this function with the second argument as zero:

result = HandleToStr(" ",0,hMem)

This function returns a TRUE value if successful.

SetTerFields

SetTerFields(hWnd as integer, field as StrTerField) as integer

Description: Use this function to modify the operational variables for the specified TER window. Your program should call the 'GetTerFields' to get the existing variables in a StrTerField structure type variable. You can then modify within the structure the variables that you wish to change and call the 'StrTerFields' function to make the changes effective.

This function returns a TRUE value if successful.

StrToHandle

StrToHandle(InString as string, StringLen as long) as integer

Description: This function creates a global memory handle and copies the specified string to the global memory block. The length of the string to copy is specified by the second argument. This function returns the global memory handle if successful. Otherwise it returns a zero value. Example:

Dim InString as string

Dim hMem as integer

InString = "This is a test line"

hMem=StrToHandle(InString,len(InString))

if hMem = 0 then MsgBox "Error creating global memory block"

CreateTerWindow

CreateTerWindow(arg as arg_list) as integer

Description: This most frequently used function is called to open a new TER window. The parameter to open the TER window is specified by the 'arg_list' argument. The 'arg_list' structure type is defined in the TER.BAS file. After the call, the handle of the TER window is returned in the 'hTerWnd' member variable.

This function returns a TRUE value if successful.