trichview.support
Keeping controls hidden in RichView |
Author |
Message |
Simon Moscrop |
Posted: 03/23/2005 19:10:39 Hello, We have an application where users can embed controls in a TRichView editor and then write script to manipulate these controls. Sometimes users like to write script to hide controls (e.g. AControl.visible = false). Whilst this appears to work the controls reappear every time the editor is resized. [calls from 'WMSize' eventually call 'TRVControlItemInfo.AdjustInserted' which in turn calls 'Control.Visible = true']. I would like control that have been hidden to stay hidden. My 'workaround' for this is to change the 'WMSize' implementatioon to: procedure TCustomRichView.WMSize(var Message: TWMSize); var lstHiddenControls : TList; i : integer; Item : TCustomRVItemInfo; begin // prevent flicker LockWindowUpdate(Handle); // Build up a list of all hidden controls lstHiddencontrols := TList.Create; try for i := 0 to pred(ItemCount) do begin Item := GetItem(i); if (Item is TRVControlItemInfo) and ( not TRVControlItemInfo(Item).Control.Visible) then begin lstHiddenControls.Add(Item); end; end; Format_(True, False, Canvas, False); inherited; // iterate the controls and re-hide the hidden controls. for i := 0 to pred(ItemCount) do begin Item := GetItem(i); if lstHiddenControls.IndexOf(Item) >= 0 then begin TRVControlItemInfo(Item).Control.Visible := False; end; end; finally lstHiddenControls.Free; // if Assigned(FOnResized) then FOnResized(Self); LockWindowUpdate(0); end; end; Does this look correct to you (it works but I suspect there may be a better way to achieve what I am after)? I'd be grateful for any comments & suggestions that you have. |
Powered by ABC Amber Outlook Express Converter