Whenever I print the 16 Pen Trend at Run Time its background colour changes from White to Black - wonderware

I am working on Schneider Electric WonderWare InTouch 10.5 version.
I am using 16 Pen Trend to see the historical values, but when at run time I print this trend, the background colour of trend changes from White to Black.
Following is the script I am using for the printing purpose :
PrintWindow("report1",0,0,11.7,7.9,1);
Following is the Syntax for above function :
PrintWindow (windowname, leftmargin, topmargin, width, height, options);
Parameters
windowname
The name of the window to be printed. A literal string value, message tagname, or string expression.
leftmargin
Left margin offset (in inches). A literal numeric value, analog tagname, or numeric expression.
topmargin
Top margin offset (in inches). A literal numeric value, analog tagname, or numeric expression.
width
Printout width (in inches). Set this value to 0 for largest aspect ratio. A literal numeric value, analog tagname, or numeric expression.
height
Printout height (in inches). Set this value to 0 for largest aspect ratio. A literal numeric value, analog tagname, or numeric expression.
options
A discrete value, 0 or 1, that is only used if width and height are 0. A literal Boolean value, discrete tagname or Boolean expression. Set to:
1 - The window is printed with the largest aspect ratio that is an integer multiple of the window size.
0 - The window is printed with the largest aspect ratio that fits on the page.
If any knowledge about it, please help me.
Thanks in advance.

Related

Delphi - How to calculate the border-width of a SpeedButton

How can I calculate the exact width of the border of a TSpeedButton?
Depending on the values of the Flat and Down properties it seems to have a different width and a text starts at a different pixel. (with Margin <> -1 and no glyph set)
Delphi 10.2.3

Word Wrap text in Argox OS214 - PPLA

I use PPLA language to print labels directly to an Argox OS-214.
How can I word wrap long texts?
Do I have to make the calculations or is there any function that does that for me?
If I have to calculate, do you hav any tips on how to do it?
In the PPLA language manual there are no functions to word wrap long text lines, so you have to calculate yourself where to insert the line breaks before sending the commands to the printer.
How to do it depends by the programming language that you are using; for example in the PHP language there is a wordwrap function that can do it for you (the C source code of the wordwrap function is here, at line 803).
A simple description of a word wrapping algorithm can be found on the wikipedia:
SpaceLeft := LineWidth
for each Word in Text
if (Width(Word) + SpaceWidth) > SpaceLeft
insert line break before Word in Text
SpaceLeft := LineWidth - Width(Word)
else
SpaceLeft := SpaceLeft - (Width(Word) + SpaceWidth)
First of all, you have to split the text in words, but I suppose that this is not a problem for you, so I won't elaborate further.
LineWidth should be calculated as the label width minus the left and right margins width.
Assuming that for your text you're using a single fixed-width (non proportional) font, you can convert the LineWidth to a number of characters by simply dividing it by the character width (or by simply printing a long line of text and then counting the number of characters that gets printed); this way each word length corresponds to the number of its characters.
Otherwise, if you're using a proportional font, calculating each word width is more difficult, unless you know each character width.
An idea could be using an image with the same pixel size of the label, just to simulate the printing and for calculating where to insert the line breaks, but this requires to have a function to calculate the pixel width of each word (for example in PHP there is the imagettfbbox function), and also to use exactly the same font on the printer and the PC.
Be aware that you could also have to handle some words that are longer than the label width; in this case you must simply split the word at LineWidth and continue on the next line.

How to set the width of a textbox, depending on a specific format string?

I have a TextBox that uses a specific format string to display its content. The width of the box is set to take exactly the amount of space that is needed to display the text. For this purpose I use the width that the formatted text would have:
box.width = new FormattedText(
String.Format(Format, value),
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface("Arial"),
8,
Brushes.Black).Width;
When doing this the textbox almost has the right width. But I still need to add an offset of 12, otherwise the area of the text would be cropped by some pixels:
I got the number 12 by try-and-error. So two questions arise:
Why do I need this offset, were does the lost width go to (whitespace and border?)?
Is there a better approach to get the right offset than to just guess it?

DrawText with DT_CALCRECT - Is there a way to calculate the height of the rect WITHOUT modifying the width (with large strings)?

I have a string that i need to calculate the Rect size (text height) when drawing. My implementation uses the DrawTextW() function with DT_WORDBREAK or DT_CALCRECT flags.
An example of my string:
thisisaverylonglonglonglineoftextthatneedstofitinsideagivenrectwidth
I can see in the MSDN docs, that DrawTextW() method states:
If the largest word is wider than the rectangle, the width is expanded. If the text is less than the width of the rectangle, the width is reduced. If there is only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line.
however in the MSDN docs, then DrawTextExW() method does not state this.
So i tried to calculate the height using the DrawTextExW() method, however the result is the same as with DrawTextW() function, where it extends the width of the rect to fit the largest line of text.
So how can i correctly calculate the height of the text rect with a given (fixed) width when drawing a large string (with no spaces) where DT_WORDBREAK and DT_CALCRECT are specified?
EDIT:
As a side note, does anyone know how Microsoft Excel does cell text drawing? Is there an API call for this text drawing? This was where my original question stemmed from, however the way it is implemented in Excel is to draw the text and wordbreak/wordwrap on any character (not just a space).
You need to use the DT_WORD_ELLIPSIS flag in uFormat parameter (along with DT_WORDBREAK of course). That will prevent the widening due to long strings with no spaces. It still will not break those long strings though, but your width problem will be solved.
If you also specify DT_MODIFYSTRING, then you could kind of figure out where to break that long string yourself, prior to the final draw.
As for the difference between DrawText(W) and DrawTextEx(W): the latter provides tab formatting, setting margins and returns the actual number of drawn characters. There is no difference in (dimensioning) functionality.

How can I know the line number of editfield of blackberry

I would like to know the line number in EditField while I am typing some text in this component.
Get the width of the edit field. (int returned) (e.g. 320 px)
Get the font width of your current text. Font class have getAdvance() method that accepts the string parameter (int returned) (e.g. 650 px)
if string width > edit field width you can divide string width and edit width and on the other step get the modulo of it. (here you will get 2 as division and 10 will be yr modulo. That means you have filled two lines + in third line you are having characters that can be fit into 10 px.
I hope it will solve your problem, but be careful if you use any long words, the module had never been tested with long words but I fear about result's accuracy with long words.

Resources