LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Hide controls while drawing?

Solved!
Go to solution

Roberto, Please see the edited version of your code that I attached to this post. 

 

By moving the duplication of the controls to a separate function that is called by a button on the main panel, I was able to genterate the same behavior in your code as I am seeing in mine.  You'll see that if you comment out the lines assocciated with the Text Message, the display behaves as expected.  One thing I should note is that I'm using CVI v8.1.  It looked like you were using a later version.  If you still don't see what I'm seeing, than maybe that's why?

 

So far, the only solution that I've come up with is to place the text message off of the viewable portion of the panel upon creation.  Then, AFTER the visibility has been changed to hidden, adjust the position back to where it should be.

 

Thanks!

0 Kudos
Message 11 of 15
(1,538 Views)

Ok, I saw the effect and I don't know how to eliminate it if you absolutely need to create textmessage controls from scratch.

What I can propose you as a workaround is either to duplicate existing controls or to use a properly formatted string control that mimics the appearance of a simple text message control: I wasn't able to see any visual effect in either of two cases. Look at the attached project.

 

 

Two last comments to your problem, even if maybe is too difficult for you to change your application at this moment.

 

1. Couldn't you use the label of a control instead of a text message? I couldn't observe any effect creating controls with a lable assigned to them.

 

2. Have you considered to use subpanels instead of creating a lot of controls? I see that you are actually creating groups of controls, I suppose each group relates to some unit in your equipment or something like this. You could create a panel with controls for a single group and load it as a child panel of your main panel once for every group you need. This way you will only need to save the panel handles, while addressing individual controls will always be made using the standard 'panel_control' way, that is: SetCtrlVal (handle[i], PANEL_LED, 1);

It is really the panel handle in this approach that differentiates which control you are setting.



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?
Message 12 of 15
(1,519 Views)
Solution
Accepted by topic author byrd01

After some poking around in the CVI internals, I found the problem with the text message creation. The function NewCtrl ends up showing the text message immediately as a side-effect of setting its value to the string that you pass it to NewCtrl. Fortunately, this has a pretty easy workaround: instead of passing the string value to NewCtrl, pass an empty string instead, and then use SetCtrlVal to set its value after you have hidden the control.

 

For example:

 

    ...

    txt[i] = NewCtrl (panelHandle, CTRL_TEXT_MSG, "", top - 17, left);
    SetCtrlAttribute (panelHandle, ctl[i], ATTR_VISIBLE, 0);
    SetCtrlAttribute (panelHandle, txt[i], ATTR_VISIBLE, 0);
    SetCtrlVal (panelHandle, txt[i], msg);

    ...

 

Luis

Message 13 of 15
(1,504 Views)

Roberto Bozzolo wrote:

Ok, I saw the effect and I don't know how to eliminate it if you absolutely need to create textmessage controls from scratch.

What I can propose you as a workaround is either to duplicate existing controls or to use a properly formatted string control that mimics the appearance of a simple text message control: I wasn't able to see any visual effect in either of two cases. Look at the attached project.

 

 

Two last comments to your problem, even if maybe is too difficult for you to change your application at this moment.

 

1. Couldn't you use the label of a control instead of a text message? I couldn't observe any effect creating controls with a lable assigned to them.

 

2. Have you considered to use subpanels instead of creating a lot of controls? I see that you are actually creating groups of controls, I suppose each group relates to some unit in your equipment or something like this. You could create a panel with controls for a single group and load it as a child panel of your main panel once for every group you need. This way you will only need to save the panel handles, while addressing individual controls will always be made using the standard 'panel_control' way, that is: SetCtrlVal (handle[i], PANEL_LED, 1);

It is really the panel handle in this approach that differentiates which control you are setting.


I did think of using a string control rather than a text message control.  I liked the appearance of the text message control though, thus my extra efforts.  I also thought about using a label for another control, but I'm already using the labels for the all the controls that are being created.  So I would have to create a new control just for the label. 

 

Using separate subpanels would be a good solution.  The set of controls do indeed correspond to separate peices of equipment.  The exact number of controls, labels, and various other parameters for each peice of equiment is specified by the user from a configuration panel.  Panels could be generated at startup or updated when the configuation is changed.  At this point, however, changing the general operation of the panels may be a bit more effort than I'm looking for right now.  If we have available time in our schedule at some point, it might be a worthwhile modification.

 

Thanks for all the help!!

0 Kudos
Message 14 of 15
(1,490 Views)

LuisG wrote:

After some poking around in the CVI internals, I found the problem with the text message creation. The function NewCtrl ends up showing the text message immediately as a side-effect of setting its value to the string that you pass it to NewCtrl. Fortunately, this has a pretty easy workaround: instead of passing the string value to NewCtrl, pass an empty string instead, and then use SetCtrlVal to set its value after you have hidden the control.

 

For example:

 

    ...

    txt[i] = NewCtrl (panelHandle, CTRL_TEXT_MSG, "", top - 17, left);
    SetCtrlAttribute (panelHandle, ctl[i], ATTR_VISIBLE, 0);
    SetCtrlAttribute (panelHandle, txt[i], ATTR_VISIBLE, 0);
    SetCtrlVal (panelHandle, txt[i], msg);

    ...

 

Luis


 

Thanks Luis!!  I thougt that I had tried that at one point, but I must not have, because this definitely did the trick.  Roberto's suggestion above to use additional sub panels is a good one that is worth considering for future improvements.  However, but this solution is quick and easy and will certainly do what I want for the time being.

 

Thanks for all the help guys!  I really appreciate it!

0 Kudos
Message 15 of 15
(1,489 Views)