My program defines a text layer which I call "CaptionLayer" and specifies properties different from normal text layers. The code performs a lookup in external data sources to provide a suggested caption for an image. I find the font size needs to vary depending on the megapixels of the image, so I wanted streamlined access to the font property dialog. The CaptionLayer has these properties, among others:
TIETextLayer(ImageEnView1.CurrentLayer).IsRuler := false;
TIETextLayer(ImageEnView1.CurrentLayer).EnableFormatting := True;
ImageEnView1.LayerOptions := [loAllowReturnsInRichText, loAutoUndoChangesByUser,loAutoUndoChangesByCode,loKeyboardShortcuts, loAllowMultiSelect, loAutoSelectMask , loPreventOutOfBounds ];
It uses word wrapping but does not use rich text since that would be too complex for this purpose. Researching the help file I found the OnShowDialog event and this is what I've tried. Commented lines did not work.
procedure TfrmImagePopUp.ImageEnView1ShowDialog(Sender: TObject; DlgType: TIEDlgType; Form: TForm);
var
sLayerName : string;
LayerType : TIELayerKind ;
iPPI : integer;
begin
if DlgType = iefLayerProperties then
begin
if (ImageEnView1.LayersCount > 1) and (ImageEnView1.LayersCurrent > 0) then
begin
sLayerName := ImageEnView1.CurrentLayer.Name;
LayerType := ImageEnView1.CurrentLayer.Kind;
if (LayerType = ielkText) and (sLayerName = 'CaptionLayer') then
begin
TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabText.TabVisible := true; //false doesn't work
TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabGeneral.TabVisible := False;
TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabStyle.TabVisible := false;
// TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabText.update;
// TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabText.repaint;
// TIELayerPropertiesDlg(Form).IELayerProps.Update; //this caused tabStyle to be visible
TIELayerPropertiesDlg(Form).IELayerProps.Frame.btnRemoveFormatting.Click;
// ImageEnView1.Update;
end;
end;
end;
end;
The major problem that causes my question is that when I hide the General and Style tab, the text tab is displayed as a blank dialog. I have to click on the actual Text tab to refresh the display. As you can see from my commented lines, I found and tried a few ways to refresh the tab display, but none worked. Is there a way to refresh that tab?
Since I'm not using rich text, the Text tab always displays the Remove Formatting button and that needs to be clicked to see the font adjustments. I was pleased to discover the ability to programmatically click that button so the user isn't mystified. But I wonder if a property exists that I'm missing so that this tab would automatically display the font adjustments when rich text isn't used?
J.R.