LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error raised when using a CallBack function on a Richtextbox

Hi,

 

I am using a RichTextBox with a Callback VI attached to the Keypress event.  Everytime I cause the kepress event to go off I get the attached error.

 

I have created a small project to demonstrate the issue, also attached.

 

I'm running Labview 2009 but have seen the issue on other version as well.


Any ideas on what is causing the error would be most useful.  Have not implemented the CallBack VI correctly or is there some other issue I need to be aware of?

 

Thanks

Download All
0 Kudos
Message 1 of 12
(2,934 Views)

I don't have 2009 running right now to see your code, but I just tried a simple KeyPress Event Callback with 8.2 and 8.6 and it worked just fine - no crashes. As soon as I have 2009 running again I can try to run your project.

 

P.S. Your images in the message point to files on your hard drive. If you want to embed images you first need to upload them to NI's servers. 

0 Kudos
Message 2 of 12
(2,913 Views)

As best I can tell my attachements are uploaded to the server, at the following addresses:

 

http://forums.ni.com/ni/attachments/ni/170/480510/1/Error%20message.png

http://forums.ni.com/ni/attachments/ni/170/480510/2/RichTextBoxCallback.zip

 

I have also saved the VI's for previous versions of Labview and on 8.5 with the same code the issue does not occur.

 

Thanks

0 Kudos
Message 3 of 12
(2,886 Views)

A slight addition to my previous post....

 

The error message is not displayed in 8.5 but action of the Callback VI is not performed either.

 

Attached are the simple VI's I'm using saved in 8.2 format.

0 Kudos
Message 4 of 12
(2,883 Views)

Your original message contains 4 broken images, and each of them shows a source as being your hard drive. If you right-click on the first one, for example, it has a source of "file:///C:/DOCUME%7E1/daver/LOCALS%7E1/Temp/moz-screenshot-1.png". It appears as if you were trying to embed images into your message.

 

The 8.2 version of your code worked just fine on my 8.2. When I tried the original LV 9 version it crashed as you experienced. When I tried to recreate the VI from scratch I ran into an additional issue. When I created the callback VI the control reference placed on the callback VI had no assigned class. Thus, if you connected it to an Invoke node no methods showed up (since the class for the control wasn't set). I would concur that some "funny things" are going on with LV 2009 and .NET, at least in this case. Of course, this is pretty much par for the course with LabVIEW and .NET since LV 7. Smiley Sad

0 Kudos
Message 5 of 12
(2,869 Views)
If you right click on the Control Ref on the front panel of the CallBack VI you can "Select .net Class" and then the invoke node will allow you to select methods related to the Richtextbox.
0 Kudos
Message 6 of 12
(2,867 Views)

Ruffdi wrote:
If you right click on the Control Ref on the front panel of the CallBack VI you can "Select .net Class" and then the invoke node will allow you to select methods related to the Richtextbox.

Yes, I know that. My point in mentioning it was that this did not happen in previous versions, and it shouldn't be required to be done in the first place. Clearly, something is not quite right with LV 2009 in this case.

0 Kudos
Message 7 of 12
(2,864 Views)
Ok, sorry.  Regarding the code working correctly in 8.2; does the callback VI actually get executed?  In 8.5 I do not see the error I get in LV 9 but the "keypress detected" message that should be appended to the Richtextbox when the KeyPress event occurs does not get inserted either which makes me suspect that the Callback VI is not being executed?   
0 Kudos
Message 8 of 12
(2,860 Views)
Now that you mention it, no, I did not see the "Keypress Detected" being added when I ran the 8.2 version of your code. However, when I recreated the top-level VI (though I simplified the loop to just have a Stop button and Wait For Front Panel Activity function) and the callback VI from scratch and ran it in 8.2, then the "Keypress Detected" showed up, indicating the callback was being called. When I tried to recreate the VIs from scratch in 2009 I got the error you mentioned in the original post.
0 Kudos
Message 9 of 12
(2,856 Views)

Hello Ruffdi,

 

In order to get your 8.5 code to work as intended, you should wire the RichTextBox reference to your User Parameter input on the Event Callback (see pic below), and you should see the "KeyPress Detected" appear on your front panel.

 

link parameter.PNG

 

Also, make sure you add a little delay in your while loop, and a Close Reference function at the end of your code right after the while loop, to close the reference you open with the RichTextBox.

 

I hope this helps for now, as I cannot find a workaround to the issue we are seeing in LabVIEW 2009.

Let me work on this slightly more and see what we can do.

 

smercurio_fc, thank you kindly for all your help so far, it is much appreciated.

 

Kind Regards,

Michael S.
Applications Engineer
NI UK & Ireland

0 Kudos
Message 10 of 12
(2,826 Views)