View Issue Details

IDProjectCategoryView StatusLast Update
0004615JEDI VCL00 JVCL Componentspublic2008-12-22 04:17
ReporterSteve009aAssigned Toobones 
PrioritynormalSeveritytrivialReproducibilityhave not tried
Status resolvedResolutionno change required 
Product Version3.35 
Target VersionFixed in Version 
Summary0004615: Runtime Assignment of DataConnector.DataSource
DescriptionI need to make the following assignment in c++ code (BCB6):
JvValidateEdit1->DataConnector->DataSource = JvDataSource1;
...compiler gives the error:
E2034 Cannot convert 'TJvDataSource *' to '_di_IJvDataSource'

Having tried various casts and tried the Assign function without success,
What would the correct syntax be?

Apologies if this isn't the correct area to ask this type of question.
Thanks for your help.
TagsNo tags attached.

Activities

obones

2008-12-10 07:53

administrator   ~0015086

You need to query the interface, like this:

IJvDataSource* Tmp;
JvDataSource1->QueryInterface(__uuidof(IJvDataSource), (void**)&Tmp);
JvValidateEdit1->DataConnector->DataSource = Tmp;


You should even check the result of QueryInterface to be sure you actually received a valid interface in Tmp.

Let me know if this helps.

Steve009a

2008-12-10 17:31

reporter   ~0015092

Thanks for your reply, now I understand about querying the interface.
But the compiling the following code...

  IJvDataSource* Tmp;
  dm->JvDataSource1->QueryInterface(__uuidof(IJvDataSource), (void**)&Tmp);
  if(Tmp)
      JvValidateEdit1->DataConnector->DataSource = Tmp;

Gives the compile error:
[C++ Error] Config.cpp(389): E2247 '__stdcall TComponent::QueryInterface(const _GUID &,void *)' is not accessible

obones

2008-12-18 01:02

administrator   ~0015107

Maybe you could try using SysUtils::Supports method then. Something like this:

IJvDataSource Tmp;
if (Supports(dm->JvDataSource1, __uuidof(IJvDataSource), &Tmp))
      JvValidateEdit1->DataConnector->DataSource = Tmp;

If that does not work, there is the possibility to call GetInterface as well, something like that:

IJvDataSource Tmp;
if (dm->JvDataSource1->GetInterface(Tmp))
      JvValidateEdit1->DataConnector->DataSource = Tmp;

It's always more complicated with C++ Builder, but one of these methods work.

Steve009a

2008-12-20 18:19

reporter   ~0015119

Both the methods you suggested worked.
Thank you, the issue is resolved.

obones

2008-12-22 04:17

administrator   ~0015126

No worries, thanks for letting us know.

Issue History

Date Modified Username Field Change
2008-12-09 21:08 Steve009a New Issue
2008-12-10 07:53 obones Note Added: 0015086
2008-12-10 07:53 obones Status new => feedback
2008-12-10 17:31 Steve009a Note Added: 0015092
2008-12-18 01:02 obones Note Added: 0015107
2008-12-20 18:19 Steve009a Note Added: 0015119
2008-12-22 04:17 obones Note Added: 0015126
2008-12-22 04:17 obones Status feedback => resolved
2008-12-22 04:17 obones Resolution open => no change required
2008-12-22 04:17 obones Assigned To => obones