SetBackgroundImage(Rect: IGxRect; BackgroundBitmap: IGxBitmap);
Rect. Rectangle that defines the part of the image to be set as the background.
BackgroundBitmap. The image to be set as the background.
The SetBackgroundImage method sets the specified part of the image as the background for the workspace.
Use the IWxView.AutoScroll method to put an image to the center of the workspace without changing zoom.
Executing the example requires a form with the Button1 button, the WorkspaceBox component with the WorkspaceBox1 identifier and the UiWorkspaceOblect component with the UiWorkspaceOblect1 identifier. Set UiWorkspaceOblect1 as a data source for the WorkspaceBox1 component. The example is the OnClick event handler for the Button1 component. It is also required to have the ConnectedCPs.gif image.
Add links to the Andy, Drawing system assemblies.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
ws: IWxWorkspace;
view: IWxView;
Rect: IGxRect;
Bmp: IGxBitmap;
Begin
// Get workspace for editing
ws := UiWorkspace1.WxWorkspace;
view := ws.CreateView;
view := ws.Views.Item(0);
Rect := New GxRect.Create(0, 0, WorkspaceBox1.ClientWidth, WorkspaceBox1.ClientHeight);
Bmp := GxBitmap.FromFile("C:\ConnectedCPs.gif") As IGxBitmap;
view.BeginUpdate;
view.SetBackgroundImage(Rect, Bmp);
view.EndUpdate;
End Sub Button1OnClick;
On clicking the button the selected image is set as the background for the workspace. Size of the image part, which is set as the background, corresponds to client-based size of the WorkspaceBox1 component.
See also: