Microsoft KB Archive/86776

= How to Use a Linked Paintbrush Object with OLECLIEN.VBX =

Article ID: 86776

Article Last Modified on 10/30/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Professional Toolkit for Microsoft Visual Basic programming system for Windows

-



This article was previously published under Q86776



SUMMARY
The following example program demonstrates how to use the Visual Basic OLE Client (OLECLIEN.VBX) custom control to create a linked Paintbrush object.

The following OLEClient property settings are required to create a Paintbrush Object Linking and Embedding (OLE) object:   Class      - &quot;PBrush&quot;

SourceDoc - The full path of a bitmap file to use (for example,                c:\windows\arches.bmp).

SourceItem - A string containing the pixel coordinates of the part of the bitmap to display. These coordinates should be               in the format &quot;x1 y1 x2 y2&quot;. This information applies to the OLECLIEN.VBX custom control in Visual Basic.

Note that Windows version 3.0 Paintbrush does not support OLE; you must have Windows version 3.1 in order to use this example.



MORE INFORMATION
The following program demonstrates how to create a linked Paintbrush object in Visual Basic using the OLECLIEN.VBX custom control.

Step-by-Step Example
 Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default. From the File menu, choose Add File. In the Files box, select the OLECLIEN.VBX custom control file. The OLE Client tool appears in the Toolbox. Place a command button and an OLEClient control on Form1.  Enter the following code: Sub Command1_Click OLEClient1.Class = &quot;PBrush&quot; OLEClient1.Protocol = &quot;StdFileEditing&quot; OLEClient1.SourceDoc = &quot;c:\windows\arches.bmp&quot;

' The SourceItem for Paintbrush is the coordinates of      '  of an object image in bitmap - &quot;x1 y1 x2 y2&quot;. OLEClient1.SourceItem = &quot;0 0 121 159&quot;

OLEClient1.ServerType = 0 ' Linked. OLEClient1.Action = 1     ' CreateFromFile. Command1.Enabled = 0 End Sub

Sub OleClient1_DblClick OLEClient1.Action = 7 ' Activate (open for editing). End Sub

Sub Form_Unload (Cancel As Integer) OLEClient1.Action = 9 ' Close (terminate connection). End Sub  Press F5 to run the program. Click the command button to create the OLE object. Double-clicking the OLEClient control will start Paintbrush for you to edit the OLE object.

<div class="references_section">