beautypg.com

Onevent – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 348

background image

III. COMMAND REFERENCES - 15. Command References

15B. Driver488/SUB, W31, W95, & WNT

Personal488 User’s Manual, Rev. 3.0

III-333

determine the state of Driver488 and take appropriate action.

OnEvent

is most often used to respond

to Service Requests (

SRQ

).

OnEvent

Driver488/W31 (C only) and Driver488/W95 only

SYNTAX

int pascal OnEvent(DevHandleT devHandle, HWND hWnd, OpaqueP

lParam);

devHandle

refers to either an interface or an external device.

hWnd

is the window handle to receive the event notification.

lParam

value will be passed in the notification message.

RETURNS

-1 if error

MODE

Any

SEE ALSO

Arm, Disarm

BUS STATES

None

EXAMPLE

ieee = OpenName (“ieee”);
OnEvent (ieee, hWnd, (OpaqueP) 12345678L);
Arm (ieee, acSRQ | acError);
break;

The

OnEvent

command causes the event handling mechanism to issue a message upon occurrence of

an

Arm

ed event. The message will have a type of

WM_IEEE488EVENT

, whose value is retrieved via:

RegisterWindowMessage ((LPSTR) “WM_IEEE488EVENT”);

The associated

wParam

is an event mask indicating which

Arm

ed event(s) caused the notification, and

the

lParam

is the value passed to

OnEvent

. Note that although there is a macro for

WM_IEEE488EVENT

in the header file for each language, this macro resolves to a function call and

therefore cannot be used as a case label. The preferred implementation is to include a default case in
the message handling case statement and directly compare the message ID with

WM_IEEE488EVENT

.

The following is a full example of a program using the

OnEvent

function:

LONG FAR PASCAL export
WndProc(HWND hWnd, unsigned iMessage, WORD wParam, LONG lParam);
{
HANDLE
ieee;
switch (iMessage)

{
case WM_CREATE:

ieee = OpenName (“ieee”);
OnEvent (ieee, hWnd, (OpaqueP) 12345678L);
Arm (ieee, acSRQ | acError);
break;

default:

if (iMessage == WM_IEEE488EVENT) {

char buff [80];
wsprintf (buff, “Condition = %04X, Param = %081X”,
wParam, lParam);
MessageBox (hWnd, (LPSTR) buff,(LPSTR) “Event
Noted”, MB OK);
return TRUE;

}

}

}