| View previous topic :: View next topic |
| Author |
Message |
sami
Joined: 07 Nov 2005 Posts: 32 Location: USA
|
Posted: Sat Sep 19, 2009 8:37 pm Post subject: How to force the Data to appear on the DBWPRichText Comp |
|
|
Am I missing a step to force the data referenced by the following to show up on the TDBWPRichText object?
TDataSource ds1;
TDBWPRichText DBRichEdit;
ds1->DataSet = <ADO Query>;
DBRichEdit->DataSource = ds1;
DBRichEdit->DataField = String("<Field Name>");
The same code still works and the Richtext retrieved is showing up as soon as the <field name> was updated in version 4.22 of the WpTools however the only way I can get RichText to show up with Wptools 6.0 is to trigger another output event (i.e post a message) after the DataField was updated!? There must be an Object Property I missed when I was migrating from the 4.22. Any idea what could be missing
Thanks
IDE : BCB6
WPTools: 6.0
Database: Oracle10g
OS : MS XP (SP3) |
|
| Back to top |
|
 |
wpsupport Site Admin
Joined: 24 Oct 2003 Posts: 5658
|
Posted: Mon Sep 21, 2009 4:28 am Post subject: |
|
|
Hi,
WPTools 6 formats and displays the text when the application is idle. Therefore, if after the loading or changing the text, the immediate output is required (usually PDF creation or print) a call to ReformatAll is required.
In Your case please use ReformatAll(false, true) to display the text.
Julian |
|
| Back to top |
|
 |
sami
Joined: 07 Nov 2005 Posts: 32 Location: USA
|
Posted: Tue Sep 22, 2009 12:54 am Post subject: |
|
|
Julian, Hi
No difference, the DBRichEdit dialog remained empty even after I included the ReformatAll() call, however Refresh() call did work but I can't run the following ...
TDataSource ds1;
TDBWPRichText DBRichEdit;
ds1->DataSet = <ADO Query>;
DBRichEdit->DataSource = ds1;
DBRichEdit->DataField = String("<Field Name>");
DBRichEdit->Refresh();
DBRichEdit->SelectAll(); <----- does not select |
|
| Back to top |
|
 |
wpsupport Site Admin
Joined: 24 Oct 2003 Posts: 5658
|
Posted: Thu Sep 24, 2009 11:22 am Post subject: |
|
|
Hi,
Hard to say. Was the text really loaded at this moment? You can check this by doing a SaveToFile.
What exactly is the purpose of the code?
Julian |
|
| Back to top |
|
 |
sami
Joined: 07 Nov 2005 Posts: 32 Location: USA
|
Posted: Thu Sep 24, 2009 6:25 pm Post subject: |
|
|
Hi,
The 4.22 ver of the TWPDBRichText got updated with the Oracle LOB content right after the Query FieldsName assignment! My expectation was to see as a minumum the same behaviour but I had to resort to 'Refresh()' to confirm the data was retrieved.
The aim of the exercise was to debug an issue with TWPDBRichText which is not Streaming the data out as an "RTF" format to an external file and rather than the RichText content we are getting just the RichText Controls when I load the RichText content back into the TWPDBRichText!?
The following code works perfect with ver 4.22
To Export in RTF format
TMemoryStream* mStream = new TMemoryStream();
WpDBRichText->SelectAll();
WpDBRichText->TextSaveFormat = "RTF";
WpDBRichText->SaveToStream(mStream);
To Retrieve in RTF Format |
|
| Back to top |
|
 |
sami
Joined: 07 Nov 2005 Posts: 32 Location: USA
|
Posted: Thu Sep 24, 2009 6:34 pm Post subject: |
|
|
Hi, again
I just got cut off
and to retrieve
WpDBRichText->Changing();
WpDBRichText->Lines->LoadFromFile(rtfFile);
The WPDBRichText object was updated with RichText as soon as LoadFromFile was complete with ver 4.22, but now it also needs a Refresh().
I know the ver 6.0 of the WPTOOLS is addressing the streaming of a Formatted content differently but so far haven't been able to locate anything which shows me how to correct for it.
Thanks |
|
| Back to top |
|
 |
wpsupport Site Admin
Joined: 24 Oct 2003 Posts: 5658
|
Posted: Thu Sep 24, 2009 6:49 pm Post subject: |
|
|
Hi,
I would not recommend to use this code.
To load the text into a TWPRichtext use
WPRichtext1.AsString := Field.AsString;
to save it use
WPRichText1.AsANSIString('RTF')
You do not need to use SelectAll.
Instead of strings You can use streams, too: LoadFromStream and SaveToStream. But do not use the Lines property.
If you database already contains RTF I would just save the field to a stream or string.
Julian |
|
| Back to top |
|
 |
sami
Joined: 07 Nov 2005 Posts: 32 Location: USA
|
Posted: Thu Sep 24, 2009 9:38 pm Post subject: |
|
|
Hi,
The following call managed to compile with a warning
On the Export:
WPDBRichText->AsANSIString('RTF');
[C++ Warning] : W8098 Multi-character character constant
WPDBRichText->SaveToStream(mStream);
On the Import:
WPDBRichText->AsANSIString('RTF');
[C++ Warning] : W8098 Multi-character character constant
WPDBRichText->LoadFromFile(rtfFile); <--- did not load anything
I know you indicated not to use the 'Lines' property but how else I can extract the file content?
Also Should I just ignore the Compiler Warning or I am not using the call correctly? |
|
| Back to top |
|
 |
sami
Joined: 07 Nov 2005 Posts: 32 Location: USA
|
Posted: Thu Sep 24, 2009 11:37 pm Post subject: |
|
|
Hi,
Based on your last reply and what you'v already posted related to problems with TWPDBRichText I am guessing that I would be better off using the TWPRichText instead. If that is the case can you please elaborate on the following
WPRichtext1.AsString := Field.AsString;
Any sample code which correctly ties the 'Field' to a query
Thanks |
|
| Back to top |
|
 |
sami
Joined: 07 Nov 2005 Posts: 32 Location: USA
|
Posted: Mon Sep 28, 2009 10:28 pm Post subject: The WPDBRichText problem resolved |
|
|
Hi
Thanks to your last e-mail I managed to resolve the problem with
the following, the same approach also worked fine with the Stream
WPRichtext1->AsString = Qry->Field->AsString;
WPDBRichtext1->AsString = WPRichtext1->AsString;
Again Thanks |
|
| Back to top |
|
 |
wpsupport Site Admin
Joined: 24 Oct 2003 Posts: 5658
|
Posted: Wed Sep 30, 2009 12:02 pm Post subject: |
|
|
Hi,
Why don't You use a TWPRichText for the display of the text and dump the TDBWPRichText?
This loads the text
WPRichtext1->AsString = Qry->Field->AsString;
This saves the text (in the "Post" event)
Qry->Field->AsString = WPRichtext1->AsString;
Your example:
| Code: | WPRichtext1->AsString = Qry->Field->AsString;
WPDBRichtext1->AsString = WPRichtext1->AsString; |
could be simplified to
WPDBRichtext1->AsString = Qry->Field->AsString;
Julian |
|
| Back to top |
|
 |
sami
Joined: 07 Nov 2005 Posts: 32 Location: USA
|
Posted: Wed Sep 30, 2009 10:03 pm Post subject: |
|
|
Julian,
I realized that as soon as I hooked the query to the WpRichText component. But the extra step is not required in this case since I am only moving the RTF content to a file.
For places that we actually use the WpDbRichText object to display the RTF content from the database the extra steps poses a problem since everything goes through the 'DataSource' objects. |
|
| Back to top |
|
 |
|