PDA

View Full Version : Visual Basic & Girder



worel
March 14th, 2005, 12:25 PM
Hi,

the DLL gireventlib.dll has two functions (gir_send_event & gir_send_event_easy)
for sending something to girder.

How can i **read** events using VB / VB6 ?

I would like to receive a string from Igor's "IgorPlug.dll" (this DLL is a plugin
DLL, written by Igor).

No matter what kind of button on the remote control is pressed,
i want to get a result string,
some string like "A4F6".

The string should "characterize" the button i press on the remote control.

How can i read events using Visual Basic ?

Mark F
March 14th, 2005, 01:24 PM
Nothing in Girder "reads" events. Plugins, commands and other event handlers can be notified when events occur but they don't "read".

Do you control the source of the VB/VB6 program that you want to receive Girder events? If so, I would suggest using the Girder SendMessage plugin to send a windows message containing something to specify the event to the VB/VB6 application as events are generated by the Igor plugin.

If you don't control the source to the VB application, something else will need to be used (keyboard shortcuts, TCP/IP, ???) to send the data to the application from Girder.

worel
March 14th, 2005, 03:46 PM
With "reading" events i mean that my VB program will be notified, when an
"Igor-Plugin" event appears.

So, i mean the same thing as you annotated.

I want my program to receive events from the Girder "StatusBar" window.

-This Girder "StatusBar" window has the class-name "TStatusBar" .

In the statusbar-window, a string like (e.g.) "A4F6" pops up,
when pressing a button on the remote control.

Now, i am looking for a method to read that string.

- As i wrote from VB, if possible.

Mark F
March 15th, 2005, 06:48 AM
In your program, create a window. The window's message handler must accept and process WM_COPYDATA messages.

In Girder, enable the CopyData plugin. Add a command to the tree and assign it the CopyData plugin. In the settings, put [EventString] into the lpData field. Use the Target button to point this at your application's window. Press Apply.

Highlight the new command in the tree. In the dropdown box next to the Learn Event button, choose Girder Event. Press Learn Event. In the top dropdown box select On Event. In the bottom dropdown box choose the Igor plugin. Press select.

When the Igor plugin generates an event, the command will execute and send the event string in a WM_COPYDATA message to your application window.

Does this make sense?

worel
March 15th, 2005, 10:44 AM
Unfortunately a vb window like a textbox does not accept the WM_COPYDATA message.
It rather accepts something like WM_GETTEXT.

So, i made a VB6 project to read the girder statusbar text :

Link:
http://www.promixis.com/phpBB2/viewtopic.php?t=10731

But to read the girder statusbar text is not the best method.
-Therefore it would be better if my visual basic program simulates Girder,
so that i use the "IgorPlug.dll" as it uses Girder.


Is it possible?

Mark F
March 15th, 2005, 11:03 AM
Unfortunately a vb window like a textbox does not accept the WM_COPYDATA message.
It rather accepts something like WM_GETTEXT.

While this is true of the standard controls, I was under the impression that a VB developer could build a real Windows application using this platform. This would mean a window could be built that accepts the WM_COPYDATA message. I guess it is a good thing no one ever forced me to use VB if it is this limited. :(


But to read the girder statusbar text is not the best method.

Especially on a timer. UGH!



-Therefore it would be better if my visual basic program simulates Girder,
so that i use the "IgorPlug.dll" as it uses Girder.

Is it possible?
No. :(

The plugin interface is large, complex and not compatible with VB variable types.

birty
March 15th, 2005, 11:18 AM
also it is part of the girder licence that you will not use the plugin interface in another product

vb-elmar
March 17th, 2005, 10:47 AM
Mark F

>> Especially on a timer. UGH!

You are right - a timer is not the best method. WM_COPYDATA
is better.

-Now i created a VB6 Form that can receive messages from other
VB and non-VB applications. It also accepts the WM_COPYDATA message
generated from the "Igor" plugin.

I guess the "sendmessage wm_copydata" method is a good (and fast) solution. It works
very well with the Girder "CopyData" plugin you described above.

-When the "Igor" plugin generates an event, the "HEX" string will
be shown in the visual basic textbox (have a look at the code below).




Needs:
=======
1 Form
1 Textbox
1 Module





Form1:
____________________

Private Sub Form_Load()
Call Init(Me.hWnd)
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call Terminate(Me.hWnd)
End Sub






Module1:
____________________

Private Declare Sub CopyMemory Lib "kernel32" Alias _
"RtlMoveMemory" (hpvDest As Any, hpvSource As Any, _
ByVal cbCopy As Long)

Private Declare Function CallWindowProc Lib "user32" Alias _
"CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal _
hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As _
Long, ByVal dwNewLong As Long) As Long

Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As Long
End Type

Const GWL_WNDPROC As Long = -4&
Const WM_COPYDATA As Long = &H4A

Dim PrevWndProc As Long

Public Sub Init(hWnd As Long)
PrevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Terminate(hWnd As Long)
Call SetWindowLong(hWnd, GWL_WNDPROC, PrevWndProc)
End Sub

Private Function WindowProc(ByVal hWnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

If Msg = WM_COPYDATA Then
Dim aa As String, B(0 To 255) As Byte
Dim CD As COPYDATASTRUCT

Call CopyMemory(CD, ByVal lParam, Len(CD))

If CD.dwData = 0 Then
Call CopyMemory(B(0), ByVal CD.lpData, CD.cbData)
aa = StrConv(B, vbUnicode)
aa = Left$(aa, InStr(1, aa, Chr$(0)) - 1)
Form1.Text1 = Form1.Text1 & aa & " "
End If

End If

WindowProc = CallWindowProc(PrevWndProc, hWnd, Msg, wParam, lParam)
End Function

Mark F
March 17th, 2005, 11:41 AM
Cool. :)

skavan
April 4th, 2005, 05:57 PM
Just to stick my oar in here, wouldn't the best solution (clean, simple, reliable) be to use LuaCOM?

s.