LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Tristate with arbitrary shape

Hello all and happy new year...

 

I want to do a custom control with a few states and an arbitrary shape (say a triangle). This combines several things I've already seen and several I have no idea about.

- custom controls. Never used before. But from reading about them, you already need to have a working (set of) controls and the associate code. So this can wait.

- tristate with shapes. Probably best handled with a picture ring. Right ?

 

So I did create 3 triangles as PNG, with transparent outside, black border and colored inside. Saved as PNG.

 

First problem: the transparency is ignored after I load them in the picture ring control. Is this a 'feature' or did I miss something ?

Second problem: when resizing this control, the vertical line (one pixel thick) disapears for smaller sizes. Any way to get aliasing ?

 

As a complex workaround, I imagine I could catch a RESIZE event on the control, call a function to creates a temporary canvas of the same size, draw what I want there and copy it back to the control in the proper position. Not very simple, might as well work directly with canvases.

 

Any suggestions ?

0 Kudos
Message 1 of 4
(2,659 Views)

The answer to your first question is probably to paint the ring control itself in transparent so that it does not add its frame to the panel. Now, this can become a little tricky if you are using windows theme (Use Windows Visual Styles For Controls panel parameter), since in this case the frame cannot be painted in transparent. If this is the case and you want to maintain this aspect on the application you need to do the following:

 

  • Create a new panel and deactivate theme on it
  • Create a Classic-style picture ring on that panel
  • Paint both the ring and its frame in transparent
  • Copy the ring to your final panel et voilà: transparency will be maintained Smiley Wink

After doing that you can load images in the ring. Regarding the use of the control, you will need to manage EVENT_LEFT_CLICK event, since a picture ring only generates commit events when you actually change the image with keyboard or mouse (I suppose you want to hide selecting arrows on the ring, and you will need to discard some keyboard events too like up, down, home, end and so on if you want to mimic a button).

 

 

I cannot help you for the second question.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(2,657 Views)

Thank you, that worked. It's worth noting that classic picture rings can be transparent while new ones cannot. I'd never noticed.

 

But I don't see the need to avoid this 'Windows Visual Styles For Controls'. I can just create a new classic picture ring and remove its frame, the result seems to be the same (no need to paint the frame transparent).

 

I need it only as an indicator, so no problem with events.

 

As for the aliasing, I seemed to remember an option, but it's probably only for canvases. I'll see what I can do creating an already antialiased image, but that usually works poorly with partial transparencies.

 

Thanks.

0 Kudos
Message 3 of 4
(2,644 Views)

You're right: the picture ring is more tolerant than other controls on this matter; almost all other controls do not permit to paint frame in transparent, while classic-style ones yes.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(2,639 Views)