Page 1 of 1
Saving BackgroundStyle
Posted: Fri Oct 28, 2005 4:22 pm
by Mauro
Hello,
Is there any property to set to save the BackgroundStyle using DBRichViewEdit?
The BackgroundBitmap is being saved and loaded, but the Style seems to be always bsCentered.
Regards.
Mauro.
Posted: Fri Oct 28, 2005 7:12 pm
by Mauro
Hello,
I've found when the problem occurs.
If I insert/edit a record and the only change I do is in the Background Bitmap or Style it's not saved (neither).
If I edit any text inside the DBRichViewEdit, then the background bitmap and style are saved fine.
I hope this help you.
Mauro.
Posted: Fri Oct 28, 2005 8:45 pm
by Michel
Hi Mauro,
Sergey will correct me if I'm wrong, but here are my observations that may be of some help.
Before modifying things (not necessarily all things, but at least some, e.g., table/cell format), you should call:
if (!RichViewEdit->CanChange()) return;
Making this function call seems to be absolutely essential. Without it, changes are applied but can't be undone, and they don't put the dataset in editing mode (in my experience).
And after the modifications, you should call:
RichViewEdit->Change();
Hope this helps,
Michel
Posted: Sat Oct 29, 2005 1:31 pm
by Mauro
This is really happening.
Thanks for the tip, I'd not saw this problem.
But the other problem still occurs.
I've observed the following:
If I set the backgroundbitmap/style and after this I edit the text, everithing is saved fine.
If I edit the entire text and after this I set the backgroundbitmap/style, the style is not saved.
As a workaround to this I'm insert via delphi a 'X' at the end of the text and sending a Backspace message, this done I put the focus and, finally, exit the focus from the RVE, so this works (but it's not very beautifull).
Mauro.
Posted: Sat Oct 29, 2005 1:47 pm
by Michel
Strange indeed. Maybe there's something else that is supposed to be done that neither of us is aware of... The only remaining thought I have is: I believe RVActionTest has the functionality you have trouble with (backgrounds, etc.), albeit not in a DB-aware context. Perhaps reading the relevant portion of the source code would give you some ideas. Good luck!
Michel
Posted: Sat Oct 29, 2005 4:09 pm
by Sergey Tkachenko
The Michel's suggestion is absolutely correct.
Call CanChange before (this will change table to the editing mode), and call Change after (this will inform table that RichViewEdit was modified).
All these operations are required only when you modify documents by non-editing methods (including changing BackgroundBitmap and BackgroundStyle properties).
Mauro, what did you mean by "edit the entire text"?
Posted: Mon Oct 31, 2005 10:45 am
by Mauro
When I saw "edit the entire text and after this set background" I mean that the last thing that is done is to set the background. I've saw this to explain that if I make any modification to the text after seting BackgroupBitmap/BackgroundStyle, then everything works fine.
Due to this I've inserted the following code before posting the record.
Code: Select all
if trim(GetAllText(dbrveModelo)) <> '' then
begin
LockWindowUpdate(Handle);
ItemNo := dbrveModelo.ItemCount-1;
Offs := dbrveModelo.GetOffsAfterItem(ItemNo);
dbrveModelo.SetSelectionBounds(ItemNo,Offs,ItemNo,Offs);
dbrveModelo.InsertText('X');
dbrveModelo.Perform(WM_KEYDOWN, VK_BACK,1);
dbrveModelo.SetFocus;
dbeNome.SetFocus;
dbrveModelo.Invalidate;
LockWindowUpdate(0);
end;
where dbrveModelo is TDBRichViewEdit and dbeNome is TDBEdit.[/code]
Posted: Mon Oct 31, 2005 11:13 am
by Mauro
I've now used the .CanChange and .Change; "alone" they don't work as expected (ClientDataSet has still .Modified = False and .ChangeCount = 0), but using this and keeping
Code: Select all
if trim(GetAllText(dbrveModelo)) <> '' then
begin
rv.SetFocus;
dbEdit.SetFocus;
end;
in the beforepost solved my problem.
Posted: Mon Oct 31, 2005 4:24 pm
by Sergey Tkachenko
CanChange + Change must do the same work as inserting&deleting the character. And I do not understand how SetFocus affects to this problem.
Posted: Mon Oct 31, 2005 6:49 pm
by Mauro
This is what happens. But this is not bugging me more.
Using this approach with the SetFocus is working fine.
Thank you Michel and Sergey by the help.
Posted: Mon Oct 31, 2005 8:00 pm
by Michel
Not at all. However, if I were you, I'd investigate this much further: what's happening is not normal, so you don't know what else may be going wrong "in the background". Maybe you're missing a call to Format() or something as simple as that somewhere. Or try doing something completely different (but "ideologically similar") instead of playing with the background. Basically, try varying everything you can until something gives you a clue.
Good luck once again!
Michel