Jump to content

"Select VI Server Class" on Refnum Control programatically


PiDi

Recommended Posts

I have a refnum control on my Front Panel and I want to change its class. Easy (well, if you don't count four "wait-for-menu-open" moments in process) to do manually

post-50361-0-44145700-1451340407.png

 

Problem: How can I do it programatically?

 

This is as far as I got with this - I was sure there would be some property/method of LVObjectRefNum class to do it, but I was wrong:

post-50361-0-78041900-1451340834.png

 

 I've attached the project with this VI for the convenience  ;)

ChangeRefnumClass.zip

Link to comment

I've got the workaround:

1. Create ClassSpecifierConstant on block diagram - this one has SetType method.

2. Change it to control.

3. Now that you have the control with desired type, replace old control.

 

It's a bit more wiring than those three points, so I'm just attaching the project with this implementation.

ChangeRefnumClass.zip

Link to comment

Control Refnums don't really work like that. It is a container that assumes the type of the contents a bit like ,NET and ActiveX containers rather than LabVIEW objects, per se. So you have to do something like this.

 

post-15232-0-99013600-1451509388.png

 

You will notice that by inserting the control into the reference; the reference now assumes the [type] name of the control.

 

ChangeRefnumClass Folder.zip

Edited by ShaunR
  • Like 1
Link to comment

@Shaun: Nice catch, I didn't though of refnums as containers - now it seems pretty obvious (I forgot I can drop control on the refnum to change its type). However, there are two problems with the code on your screen:

1. The "style" input of New VI Object is a mess. I want to provide Class Name and nothing else, so I'd have to somehow decide how to translate the Class Name to style. I can think of couple of ways to do it, all of which would probably require a lot of coding.

2. This only allows to create GObject references. This is quite OK, because that's what I need for now, but my method allows me to create any type of reference (like ProjectItem, or Panel).

 

 

Link to comment

@Shaun: Nice catch, I didn't though of refnums as containers - now it seems pretty obvious (I forgot I can drop control on the refnum to change its type). However, there are two problems with the code on your screen:

1. The "style" input of New VI Object is a mess. I want to provide Class Name and nothing else, so I'd have to somehow decide how to translate the Class Name to style. I can think of couple of ways to do it, all of which would probably require a lot of coding.

2. This only allows to create GObject references. This is quite OK, because that's what I need for now, but my method allows me to create any type of reference (like ProjectItem, or Panel).

 

I see no problems. Only a solution to the question asked and the beginning of other solutions :)

Link to comment

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.