# MB-Ruler remote interface documentation

The MB-Ruler remote interface enables you do modify the properties of the ruler from an other application and receive the data evaluated by the ruler.
The data to and from the ruler is send by the windows message system via the WINAPI function Sendmessage/Postmessage.

This installation includes a complete application with source code written in Delphi 5.
Suggestion, correction and further example applications are welcome

### Messages sending to MB-Ruler

### Messages receiving from MB-Ruler

### How to connect a remote application to MB-Ruler

### Messages sending to MB-Ruler

MSG = WM_MBRULER_GENERELL

Checking version of remote interface wParam = GENERELL_DETECTVERSION lParam = REMOTEINTERFACE_VERSION If the result is 1 the the interface versions are equal, if the result is 0, the interface versions differ,a connection should not be established!.
Connect remote client to MB-Ruler wParam = GENERELL_ADDCLIENT lParam = window handle of remote application If the result is 1 the the connection is established.
Disconnect remote client from MB-Ruler wParam = GENERELL_DELCLIENT lParam = window handle of remote application Disconnects the remote application from MB-Ruler.

MSG = WM_MB_RULER_RULER

Set new center of the ruler in absolute coordinates wParam = RULER_MOVE_ABS lParamLo = x-coordinate of the ruler center to set (16 bit signed int) lParamHi = y-coordinate of the ruler center to set (16 bit signed int)
Move center of the ruler in relative coordinates wParam = RULER_MOVE_REL lParamLo = change of the x-coordinate (16 bit signed int) lParamHi = change of the y-coordinate (16 bit signed int)
Set new orientation of the ruler wParam = RULER_ROTATE_ABS lParamLo = orientation of the ruler to set (16 bit signed int) triangle mode lParamLo = orientation of the x1 angle of the coord system to set (16 bit signed int)coord system mode lParamHi = orientation of the x2 angle of the coord system to set (16 bit signed int)coord system mode
Change orientation of the ruler wParam = RULER_ROTATE_REL lParam = change of the orientation (16 bit signed int) lParamLo = change of the orientatio of the ruler (16 bit signed int) triangle mode lParamLo = change of the orientatio of the x1 angle of the coord system (16 bit signed int)coord system mode lParamHi = change of the orientatio of the x2 angle of the coord system (16 bit signed int)coord system mode
Show/hide the ruler wParam = RULER_SHOW lParam = RULER_SHOW_CHECK to check the visible state of the ruler lParam = RULER_SHOW_HIDE to hide the ruler lParam = RULER_SHOW_TRIANGEL to switch to triangle mode lParam = RULER_SHOW_COORDSYSTEM to switch to coord system mode The result is RULER_SHOW_SHOW if the ruler is the modeof the ruler.

### Messages receiving from MB-Ruler

MSG = WM_MBRULER_GENERELL

Verification for connection request of remote client wParam = GENERELL_ADDCLIENT lParam = window handle of MB-Ruler The result returned by the remote client must be the window handle of the remote client.

MSG = WM_MB_RULER_RULER

Sending center of the ruler in absolute coordinates wParam = RULER_POS lParamLo = x-coordinate of the ruler center (16 bit signed int) lParamHi = y-coordinate of the ruler center (16 bit signed int)
Sending orientation of ruler wParam = RULER_ANGLE lParam = orientation of the ruler (32 bit signed int)
Sending calculated distance wParam = RULER_CALC_DISTANCE lParam = calculated distance in pixel in triangle mode (32 bit unsigned int)
Sending calculated angle wParam = RULER_CALC_ANGLE lParam = calculated angle in triangle mode (32 bit signed int)
Sending calculated x1 coordinates wParam = RULER_CALC_DIST1 lParam = calculated x1 coordinate in coord system mode (32 bit signed int)
Sending calculated x2 coordinates wParam = RULER_CALC_DIST2 lParam = calculated x2 coordinate in coord system mode (32 bit signed int)

### How to connect a remote application to MB-Ruler

Detect the window handle of MB-Ruler by calling MBRulerHandle := FindWindow(nil,'MB-Ruler');

Call
SendMessage(MBRulerHandle, WM_MBRULER_GENERELL, GENERELL_DETECTVERSION, REMOTEINTERFACE_VERSION);

If the result is 1, the interface version is equal and you can connect to MB-Ruler. Then call
SendMessage(MBRulerHandle, WM_MBRULER_GENERELL, GENERELL_ADDCLIENT, RemoteApplicationWindowHandle); to connect to the ruler. MB-Ruler will recheck the request by sending
SendMessage(RemoteApplicationWindowHandle, WM_MBRULER_GENERELL, GENERELL_ADDCLIENT, MBRulerHandle);
The remote application must respond with RemoteApplicationWindowHandle as the result. Only if this check is handled correctly, the ruler accepts requests and sends information.

While an application is connected to MB-Ruler the text MB-Ruler remote interface active is displayed in the upper left corner of the screen in the unregistered version.

Homepage: http://www.Markus-Bader.de/MB-Ruler
If you have questions, suggestions or bug reports, please contact me at: MB-Ruler@Markus-Bader.de