VB.NET
Dim hWnd As Integer
Dim wMsg As Short
Dim Ret, SrqOn As Integer
hWnd = Handle.ToInt32 ' Handle is procedure handle
wMsg = WM_USER + &H30S ' user-specified number 400H to 7FFFH
' WM_USER = 0x400
SrqOn = 1 ' Create event
Ret = GpSrqEventEx(hWnd, wMsg, SrqOn)
' Event handler routin
Select Case message ' message is procedure's 2nd parameter
Case WM_USER + &H30: ' = wMsg
... ' Write necessary process
Ret = GpPoll(cmd, fstb)
...
Ret = GpSrqOn()
End Select
C
HANDLE hWnd;
WORD wMsg;
DWORD Ret, SrqOn;
hWnd = hDlg; /* hDlg is procedure handle */
wMsg = WM_USER + 0x30; /* user-specified number 400H to 7FFFH */
/* WM_USER = 0x400 */
SrqOn = 1; /* Create event */
Ret = GpSrqEventEx(hWnd, wMsg, SrqOn);
/* Event handler routin */
switch(message){ /* message is procedure's 2nd parameter */
case WM_USER + 0x30: /* = wMsg */
... /* Write necessary process */
Ret = GpPoll(cmd, fstb);
...
Ret = GpSrqOn();
break;
}
C#
int hWnd;
short wMsg;
uint Ret, SrqOn;
hWnd = this.Handle.ToInt32(); /* this.Handle is procedure handle */
wMsg = WM_USER + 0x30; /* user-specified number 400H to 7FFFH */
/* WM_USER = 0x400 */
SrqOn = 1; /* Create event */
Ret = gpib.SrqEventEx(hWnd, wMsg, SrqOn);
/* Event handler routin */
switch(message){ /* message is procedure's 2nd parameter */
case WM_USER + 0x30: /* = wMsg */
... /* Write necessary process */
Ret = gpib.Poll(cmd, fstb);
...
Ret = gpib.SrqOn();
break;
}
Python
wMsg = ctypes.c_ushort()
Ret, SrqOn = ctypes.c_ulong(), ctypes.c_ulong()
wMsg.value = WM_USER + 0x30 # user-specified number 400H to 7FFFH
# WM_USER = 0x400
hWnd = ctypes.windll.user32.FindWindowW(0, "Name") # "Name" is the caption of the currently running procedure
SrqOn.value = 1 # Create event
Ret.value = GpibPy.GpSrqEventEx(hWnd, wMsg, SrqOn)
# Event handler routine
# message is procedure's 2nd parameter
if message == WM_USER + 0x30: # WM_USER + 0x30 is the value set by GpSrqEventEx
... # Write necessary process
Ret.value = GpibPy.GpPoll(cmd, fstb)
...
Ret.value = GpibPy.GpSrqOn()