Navigation:  Programmer's Reference > Sending data to DPlot from another application >

SetOutputWindow macro command

Print this Topic Previous pageReturn to chapter overviewNext page

Macro commands may be used either in macros or by sending the commands to DPlot via dynamic data exchange (DDE). Some commands are valid only in macros (noted by Macros Only). Commands sent to DPlot via DDE must be enclosed by square brackets [     ]. Macro commands should not include the brackets.

Command parameters shown in the descriptions below are placeholders for the actual values. Command parameters are either numeric values, equations that evaluate to numbers, or character strings. Character string parameters are always bound by double quotation marks. Equations must be preceded by an equals sign (=).

The pipe symbol (|) in the command syntax indicates that a parameter is optional, and should not be included in your macro unless otherwise noted.

All indices into arrays are 1-based, e.g. Curve1=1 refers to the first curve in a plot.

A 0x prefix for numbers in the descriptions below indicates hexadecimal notation; e.g. 0x0010 = 16.

JR/Viewer indicates that the command is supported by DPlot Jr or DPlot Viewer.
JR/Viewer indicates that the command is NOT supported by DPlot Jr or DPlot Viewer.


 

[SetOutputWindow(hwnd,left,top,right,bottom)]

JR   Viewer

Instructs DPlot to render all subsequent graphics to the window with HWND handle hwnd as opposed to the normal document window. left, top, right, bottom specify the output rectangle in pixels, relative to the client area of the window. If hwnd is set to 0, normal rendering to the DPlot document window is restored.

This command is not useful in macros, since there is no macro facility for retrieving window handles. It can be used, though, to send DPlot output to a window within another application that is controlling DPlot via DPLOTLIB. This command is primarily useful for real time applications that are updating a graph at a fast rate. If you want to create a plot from your applicaition that will not be updated frequently, DPlot_GetBitmap or DPlot_GetBitmapEx are preferable to this method.

For best (fastest) results with real-time graphing you should use the ManualScale command with XY plots. If ManualScale is used, then whether data is added to the graph using an XY or XYXY command or by calling the DPlot_AddData function in DPLOTLIB.DLL, only new line segments will be drawn. If ManualScale is not used (that is, you allow DPlot to determine good extents for the graph), then the entire graph will be redrawn each time it is updated. Another feature of ManualScale with real-time graphing is that if the X value is greater than or equal to the right extent of the graph, DPlot will shift the graph left by some fraction of the X extents. The default shift is 50% of the extents and may be controlled with SetPanFraction.

There are at least two consequences to using ManualScale:

1)Since no bitmap is saved and the drawing is done directly to another application's window, if that window is covered/uncovered then the image will not be automatically updated as it would with a bitmap assigned to the properties of a picture box. You can handle this by forcing DPlot to redraw the entire graph with a ViewRedraw command whenever a paint message is received.
2)For performance reasons, new line segments will always be drawn using solid lines regardless of any LineType settings. This might be a bit disconcerting if a window is covered/uncovered, since the repainted portion of a graph will be drawn using the specified line styles, but new line segments will be drawn using solid lines. For this reason it is recommended to always use solid lines with real-time applications.

Examples:

In the following examples the calling application wants output drawn to a control owned by that application.

Visual Basic:

Type RECT

   Left As Long

   Top As Long

   Right As Long

   Bottom As Long

End Type

Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

.

Dim rcPic As RECT

Dim sExec As String

.

ret = GetClientRect(Picture1.hwnd, rcPic)

sExec = "[SetOutputWindow(" + Str$(Picture1.hwnd) + "," + _

       Str$(rcPic.Left) + "," + _

       Str$(rcPic.Top) + "," + _

       Str$(rcPic.Right) + "," + _

       Str$(rcPic.Bottom) + ")]"

ret = DPlot_Command(DocNum, sExec)

C:

RECT rcFrame;

char szExec[256];

.

GetWindowRect(GetDlgItem(hwnd,DLG_PICTURE),&rcFrame);

MapWindowPoints(NULL,hwnd,(LPPOINT)&rcFrame,2);

sprintf(szExec,"[SetOutputWindow(%d,%d,%d,%d,%d)]",

 hwnd,rcFrame.left,rcFrame.top,rcFrame.right,rcFrame.bottom);

DPlot_Command(DocNum,szExec);

C#:

Rectangle rcPic;

.

rcPic = pictureBox1.ClientRectangle;

string cmds = String.Format("[SetOutputWindow({0},{1},{2},{3},{4})]",

   pictureBox1.Handle,

   rcPic.Left,

   rcPic.Top,

   rcPic.Right,

   rcPic.Bottom);

dplot.DPlot_Command(DocNum, cmds);

(where the dplot class is defined in dplot.cs in the various C# example folders)

 

 


Page url: https://www.dplot.com/help/index.htm?setoutputwindowcommand.htm