I copied your code and tried them. It does work as what you expect when I run the code to set the trend format. Have you tried to walk through the code and see if there is any unexpected value/outcome during the code execution?
Thank you Han,
You are right, it is working but not in my project. Somehow, I am working on a project that was built by someone else and I built a test environment to help him. I think that the problem may reside in my references since I try building a fresh new project and it worked. I will be looking for the references then.
I have done some further research and have kind of ruled out the reference issue. On the other hand, I was able to reproduce the issue. Here are some details that I skipped in my first post since I thought it would not make any difference. In the VB6 project, here is the overal process taking place:
- The PI ActiveView ActiveX is added but its DisplayURL property is not set.
- In the code, we set the DisplayURL property to a PDI file on disk wich is empty (simply create a PDI file witout adding anything and save it empty.pdi).
- Programmatically, add a Trend symbol to the empty display.
- Progarmmatically, add a Trace to the Trend.
- Get the Trend Format
- Modify the ShowTagName and ShowServerName, set them to False
- Apply the format.
Strangely, this procedure will not work. The format values, if you look at them with a breakpoint, will be false but the information will still display on the trend. I did a test using a display which was already built (one trend with a sinusoid trace) and applied the same function to change the format. My tests have shown that the change format procedure will work if the DisplayURL property is set when the ActiveX is added. If we programmatically set the DisplayURL property, then the change format procedure will not work. Any idea?
Private Sub Command1_Click() Dim MyTrend As Trend Dim aFormat As TrendFormat Pbd1.DisplayURL = "C:\empty.pdi" Set MyTrend = Pbd1.Display.Symbols.Add(pbSymbolTrend) MyTrend.Maximize True ' Somehow the maximize function does not work the first time... MyTrend.Maximize True MyTrend.AddTrace "sinusoid" Set aFormat = MyTrend.GetFormat aFormat.ShowServerName = False aFormat.ShowTagName = False MyTrend.SetFormat aFormat End Sub
I am sure that when a Trend is maximised it will always show the Trace name (PI Point, Calculation or other Dataset) Value and Eng Units. So although the Trend Format is correct is stating the Booleans are False, they are overridden by some defaults for a Trend's maximised state. Only OSI snooping through the code could tell us for sure.
If you run your same code but don't maximise the trend I bet you don't see the Trace or Server name.
Thank you! I did not realized this and was looking for every other details but overlooked this maximize fonction. I tried it without the maximize and as you said, the server name and tag names were gone.
As an added comment, instead of maximise just use:
MyTrend.Left = Pbd1.Display.ViewLeft
MyTrend.Top = Pbd1.Display.ViewTop
MyTrend.Width = Pbd1.Display.ViewWidth
MyTrend.Height = pbd1.Display.ViewHeight