Brilliant Database Software - Home
Database software - Online Help System

Online Help System

Back to Brilliant Database Web-Site | Write to Support | Help Index

SendMessage, WinAPI

table border="0" width="100%" cellspacing="0" cellpadding="4" bgcolor="#00000077">
SendMessage, WinAPI


This section describes how you can implement interaction between Brilliant Database and a third party program using the SendMessage WinAPI function that allows sending messages to other windows.

Brilliant Database can receive and send two types of messages:

  • WM_USER - to pass two numbers of the int type (4 bytes);
  • WM_COPYDATA - to pass one number of the int type (4 bytes) and a string of any length.

To use this function, you need to know the identifier of the window (HWND) that will process these messages. In Brilliant Database this HWDN is stored in the [$_hwnd] variable.

Receiving messages from external programs

When WM_USER or WM_COPYDATA messages are received, the "System->On SendMessage" script available from the Script Editor (Design->Database Scripts...) is called.

In this script, values received in the message are stored into three variables:

  • [$wparam] - WParam value, for the WM_USER message (number);
  • [$lparam] - lParam value, for the WM_USER message (number);
  • [$dwdata] - dwdata value from the COPYDATASTRUCT structure (number);
  • [$lpdata] - lpdata value from the COPYDATASTRUCT structure (string).

For example, the following processor script will simply write sent data into the [InText] field of the current record:

The external program sending a message needs to know the HWND of a receiving window of Brilliant Database. To get this value, use the [_$hwnd] system variable. You can pass this value to another program, for example, by launching the program from Brilliant Database using the Open File/URL action with [$_hwnd] as a parameter.

Note. The value stored in [$_hwnd] is not the identifier of the Brilliant Database main window, but is the identifier of a special window processing an external message. When the database is closed, this window is removed for security purposes.

To learn how to send the WM_COPYDATA message, see MSDN web site.

Sending messages to other programs (windows)

To send a message, use the "Win SendMessage" action. Parameters:

  • Target hWnd - identifier of the window (HWDN) to which a message should be sent;
  • Message - sent message. There are only two variants possible - WM_USER and WM_COPYDATA;
  • wParam - value written to wParam when the WM_USER message is passed (number).
  • lParam/lpData
    • For the WM_USER message - value written to lParam;
    • For the WM_COPYDATA message - string written to lpData of the COPYDATASTRUCT structure.

All topics in the "Creating Addons and Integration" section: