Article View: borland.public.cppbuilder.upgrade
Article #2315Problem using ComponentWorks with BCB5
From: Karl Daggfeldt
Date: Fri, 03 Mar 2000 00:00
Date: Fri, 03 Mar 2000 00:00
133 lines
4579 bytes
4579 bytes
Hi there,
In BCB4 there were some errors in the files generated for ComponentWorks
from National Instruments activeX controlls. These could however be
corrected by a little bit of editing (see National Instruments Knowledge
base document ID 1NB765B5, copyed to the end of this document). It seems
that BCB5 still have the same errors (corrected in the same way) but I have
also come across a new problem using ComponenWorks in BCB5.
In BCB4 the following code will put the bitmap "bmp" on the ComponentWorks
(National Instruments) activeX controll CWGraph. In BCB5 it will however
fail in the set_Picture call with an acess violation. Why and are there any
work-around if I want to paint a bitmap to the "Plot Area"?
Grateful for answers
Kalle
Builder code
Graphics::TBitmap *bmp;
bmp = new Graphics::TBitmap;
bmp->Width=50;
bmp->Height=50;
bmp->Canvas->Brush->Color=clRed;
bmp->Canvas->FloodFill(0,0,clGreen,fsBorder);
CWImageDisp cwid;
cwid=CWGraph1->Images("Plot Area");
TPicture *tp;
tp=new TPicture;
tp->Bitmap=bmp;
_di_IPictureDisp ip;
GetOlePicture(tp,ip);
cwid.set_Picture(ip);
delete bmp;
delete tp;
End of builder code
National Instruments Knowledge base document ID 1NB765B5
ComponentWorks Graph Control: Assigning a Plot to a Graph Cursor in Borland
C++ Builder
Product Group: ComponentWare Software
Product Name: ComponentWorks
(Ver / Rev.): 2.0.1
Problem: When using the correct syntax in Borland C++ Builder to assigning a
plot to a graph cursor, the code will execute without error but the
assignment does not seem to take effect. This behavior has been observed in
versions 3.0 and 4.0.
Solution: Borland C++ Builder generates wrapper classes that invoke the
methods on the ComponentWorks controls. For methods that take references to
OleAutomation objects the Invoke method should be called with
PropertyPutRef, but Builder is calling PropertyPut. This same workaround
will apply to other methods such as the SetAxis method on a CWPlot object. A
good indication this workaround applies can be found in the ComponentWorks
reference. Note that the help for CWCursor.Plot specifies a datatype of
CWPlot as the argument. Methods that require CWobjects should be modified as
follows to work successfully:
In Borland\CBuilder4\Include\vcl\utilcls.h file, add the following function
after the existing OlePropertyPut function.
// Property put ref (always has parameters)
HRESULT OlePropertyPutRef(DISPID dispid, TAutoArgsBase& args)
{
return Invoke(dfPropPutRef, dispid, &args, false);
}
This function is calling Invoke with the parameter dfPropPutRef, which
indicates that a reference to an object is being passed in. OlePropertyPut
uses dfPropPut. dfPropPutRef and dfPropPut are already defined in one of the
header files.
Next, edit each Builder Wrapper class for "set" methods that take references
as arguments. In the case of assinging a plot to a cursor, change the
following code in
Borland\CBuilder4\Imports\CWUIControlsLib_TLB.h
template void __fastcall
CWCursorDispT::set_Plot(Cwuicontrolslib_tlb::CWPlot* /*[VT_USERDEFINED:1]*/
Value)
{
static _TDispID _dispid(*this, OLETEXT("Plot"), DISPID(8));
TAutoArgs<1> _args;
_args[1] = (LPDISPATCH) /*[VT_DISPATCH:1]*/ (Cwuicontrolslib_tlb::CWPlot*
/*[VT_USERDEFINED:1]*/)Value;
OlePropertyPutRef(_dispid, _args);
}
The original Builder-generated wrapper class uses the OlePropertyPut method.
Change this to use the new OlePropertyPutRef function that we defined.
In your BCB program, use the following syntax to assign a plot to a cursor:
CWPlotsDisp cwplots;
CWPlotDisp oneplot;
cwplots = CWGraph1->Plots;
Variant index = 1;
oneplot = cwplots.Item(index);
CWCursorsDisp cwcs;
CWCursorDisp cwcursor;
cwcs = CWGraph1->Cursors;
cwcursor = cwcs.Item(index);
cwcursor.Plot = oneplot;
Related Links:
Fixed Ver #:
Report Date: 07/12/99
Last Review: 08/12/99
Document ID: 1NB765B5
Technical Details
Message-ID:
<89ocao$ps43@bornews.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10529a,e716c2308f3610e8,start X-Google-Attributes: gid10529a,public From: "Karl Daggfeldt" <karl.daggfeldt@neuro.ki.se> Subject: Problem using ComponentWorks with BCB5 Date: 2000/03/03 Message-ID: <89ocao$ps43@bornews.borland.com> X-Deja-AN: 592647600 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.cppbuilder.upgrade