Using offscreen TRichViewEdit
Posted: Tue Sep 12, 2006 2:08 pm
Hi there,
I've been experimenting with using offscreen RichViewEdit and RVStyle components, created on the fly and positioned offscreen (with negative left and top values) on the application's main form. I'm trying to use these components to read blocks of XHTML code and turn it into RVF, which I then store and stream in and out of RichView controls which are visible.
However, I'm having trouble getting the offscreen controls to function properly; when I read in data, then get the RVF, it's empty. In contrast, when I use exactly the same code but targetted at existing RVEs and RVSs that are visible on forms, the reading operations work correctly. I'm wondering if there is some error I'm making in creating and initializing the controls, or perhaps there's something intrinsic to RV controls which makes them function differently when they're offscreen (and therefore invisible, although Visible = True for the RVE). Here's the code I'm using to initialize the controls:
FRVE := TRichViewEdit.Create(Application.MainForm);
FRVE.Parent := TWinControl(Application.MainForm);
FRVS := TRVStyle.Create(Application.MainForm);
with FRVE do
begin
//Put it off-screen
Width := 500;
Height := 500;
Left := -600;
Top := -600;
Style := FRVS;
DoInPaletteMode := rvpaCreateCopies;
ReadOnly := False;
Options := [rvoAllowSelection, rvoScrollToEnd, rvoShowPageBreaks,
rvoTagsArePChars, rvoAutoCopyText, rvoAutoCopyRVF,
rvoAutoCopyImage, rvoAutoCopyRTF, rvoFormatInvalidate,
rvoDblClickSelectsWord, rvoRClickDeselects,
rvoFastFormatting];
RTFReadProperties.UnicodeMode := rvruOnlyUnicode;
RTFReadProperties.TextStyleMode := rvrsAddIfNeeded;
RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded;
RTFReadProperties.UseHypertextStyles := True;
RVFOptions := [rvfoSavePicturesBody, rvfoSaveControlsBody,
rvfoSaveBinary, rvfoSaveTextStyles, rvfoSaveParaStyles,
rvfoSaveDocProperties, rvfoLoadDocProperties];
end;
with FRVS do
begin
if TextStyles.Count > 0 then
for i := 0 to TextStyles.Count-1 do
TFontInfo(TextStyles).Unicode := True;
DefUnicodeStyle := 0;
end;
I've been experimenting with using offscreen RichViewEdit and RVStyle components, created on the fly and positioned offscreen (with negative left and top values) on the application's main form. I'm trying to use these components to read blocks of XHTML code and turn it into RVF, which I then store and stream in and out of RichView controls which are visible.
However, I'm having trouble getting the offscreen controls to function properly; when I read in data, then get the RVF, it's empty. In contrast, when I use exactly the same code but targetted at existing RVEs and RVSs that are visible on forms, the reading operations work correctly. I'm wondering if there is some error I'm making in creating and initializing the controls, or perhaps there's something intrinsic to RV controls which makes them function differently when they're offscreen (and therefore invisible, although Visible = True for the RVE). Here's the code I'm using to initialize the controls:
FRVE := TRichViewEdit.Create(Application.MainForm);
FRVE.Parent := TWinControl(Application.MainForm);
FRVS := TRVStyle.Create(Application.MainForm);
with FRVE do
begin
//Put it off-screen
Width := 500;
Height := 500;
Left := -600;
Top := -600;
Style := FRVS;
DoInPaletteMode := rvpaCreateCopies;
ReadOnly := False;
Options := [rvoAllowSelection, rvoScrollToEnd, rvoShowPageBreaks,
rvoTagsArePChars, rvoAutoCopyText, rvoAutoCopyRVF,
rvoAutoCopyImage, rvoAutoCopyRTF, rvoFormatInvalidate,
rvoDblClickSelectsWord, rvoRClickDeselects,
rvoFastFormatting];
RTFReadProperties.UnicodeMode := rvruOnlyUnicode;
RTFReadProperties.TextStyleMode := rvrsAddIfNeeded;
RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded;
RTFReadProperties.UseHypertextStyles := True;
RVFOptions := [rvfoSavePicturesBody, rvfoSaveControlsBody,
rvfoSaveBinary, rvfoSaveTextStyles, rvfoSaveParaStyles,
rvfoSaveDocProperties, rvfoLoadDocProperties];
end;
with FRVS do
begin
if TextStyles.Count > 0 then
for i := 0 to TextStyles.Count-1 do
TFontInfo(TextStyles).Unicode := True;
DefUnicodeStyle := 0;
end;