Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

dash lines with width greater than 1 are drawn solid

Using CWGraph or CNiGraph and trying to draw a dashed or dotted line with thickness greater than 1 ends up always drawing a solid line. When the thickness is 1, it draws fine. Just wondering if anyone knows if this bug will ever be fixed. I found a similar unanswered question from 12/28/1999 entitled "dotted lines do not print with CWGraph's" that mentions the exact same problem. Using MS Visual C++ 6 and Measurement Studio 7 now, it appears to still have the same problem.
0 Kudos
Message 1 of 5
(4,289 Views)
This issue is due to a limitation of GDI in Windows and is documented in the CNiPlot::LineStyle and CNiPlot::LineWidth properties in Measurement Studio 7.0. For more information on the GDI limitations, see the documentation for CreatePen in MSDN. Specifically, it says:

"CreatePen returns a pen with the specified width bit with the PS_SOLID style if you specify a width greater than one for the following styles: PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT."

Also, in the remarks section, it says:

"If the value specified by nWidth is greater than 1, the fnPenStyle parameter must be PS_NULL, PS_SOLID, or PS_INSIDEFRAME."


These limitations are reflected in the graph because Measurement Studio uses GDI for its drawing.

- Elton
0 Kudos
Message 2 of 5
(4,289 Views)
Another side note - since you mentioned you're using Measurement Studio 7, you might want to take a look at the .NET Windows Forms graph that ships with Measurement Studio 7. The Measurement Studio .NET graph uses GDI+ for its drawing, and this issue does not seem to be a limitation in GDI+. You can see this in action with the .NET graph by configuring the LineStyle and LineWidth properties on the WaveformPlot or ScatterPlot accordingly.

- Elton
0 Kudos
Message 3 of 5
(4,289 Views)
Actually, there are ways to draw these using GDI and I was hoping that NI would implement them so that dashed line drawing would work within this control. The easiest method that I know of is to use a geometric pen instead of a cosmetic pen by using the second constructor instead of the first for CPen, as mentioned in MSDN here. An example of a dotted pen construction is shown at the bottom of this page here.

I've used a geometric pen in my own GDI based drawing functions with thickness > 1 and it worked fine. Perhaps there was some other r
eason a geometric pen was not used in this control? Maybe this second constructor was not available before?

Thanks!
0 Kudos
Message 4 of 5
(4,289 Views)
The CPen constructor that you mentioned calls the ExtCreatePen Win32 function in its implementation. The documentation for ExtCreatePen explicitly states that several pen styles that you would OR with PS_GEOMETRIC are not supported for Windows 9x, and PS_USERSTYLE is Windows NT and higher. Windows 9x was the majority target platform at the time that the ActiveX controls were initially developed, so that would be my guess why these pen styles were not used.

I will file a suggestion to consider using these styles in Windows 2000 and XP in a future release. Thanks for the feedback.

- Elton
0 Kudos
Message 5 of 5
(4,289 Views)