LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dr. Damien's Development - The Xylophone Project X - Font Issues and Front Panel Layout

The Show Raw Data button was made active in this installment. Doing this in a robust fashion was more involved than one might think, due to font and platform issues (remember I want to port this to a Windows Mobile device eventually). The following changes were made.


  • The A frequency indicator was made active. This was an oversight from the last update.
  • A front panel object, XylophoneFP.lvclass, was created to hold the front panel references and methods.
  • The front panel object was used to implement the Show Raw Data button.
  • The front panel object was used to compensate for font issues.

 

When testing this application on Windows Vista, I noticed that the font differences between Vista and XP were annoying enough that I wanted to fix them. This will also lay the groundwork for any layout issues when porting to Windows Mobile. Usually, I create a cluster containing all my front panel references, but this time I put them into an object. Besides the usual object boilerplate, there are two methods, one to rearrange the front panel and one to show/hide the data graphs.


Once the controls and indicators are properly arranged, showing and hiding the data graphs is simple. VI server methods are used to find the edges of the outer controls, some whitespace is added, then the front panel size is reset. Arranging the controls in the first place is much more complex. Dialog controls are used, and these controls change size based on the default font size. Font sizes can change due to user preference or when using the application in a different operating system than it was developed in. Button sizes can also change due to localization.


This problem is difficult to solve cleanly, and the VI which does this, XylFP.lvlib:XylophoneFP.lvclass:ArrangeControls.vi, shows the problem. It relies on the actual sizes of the controls/indicators to rearrange the front panel in a hopefully pleasing fashion. Even though this is a relatively simple UI, the VI is fairly complex. It uses VI server calls to determine the current sizes of controls and then rearrange them. If you choose to do something similar, consider the following hints:


  • The Bounds property of all controls is not writable. To change the size of controls, you need to find the property or properties which change the size. There may be more than one (which is why Bounds is not writable). For example, to change the size of a boolean, use the Button Size property.
  • In many cases, the property you use to change the size of the control will not be the same value as the Bounds property. Using the boolean again, the Bounds of a 3D LED include the 3D effect around the LED, but the Button Size only includes the LED itself. Comparing the Bounds property to the result of a query to the property you will be setting will give you the necessary offset to convert between the two.
  • Make sure you label your wires if you attempt to do things like this. Long wires are very common in this type of programming. It is difficult enough to keep track of things without the added aggravation of having the trace wires back to their source to identify them.
  • A few judiciously placed type converters can eliminate many type conversion dots. This is not usually a real problem in this context, but you should get into the habit of efficient programming.

I will be hiking through the mountains of New Mexico with the Boy Scouts for the next couple of weeks, so do not be dismayed if I do not reply to comments very quickly. However, comments and suggestions are still welcome and encouraged. I will reply when I return.

Previous Installments

Message Edited by DFGray on 06-05-2009 03:09 PM
Message 1 of 1
(4,104 Views)