WPCubed Product Support

Custom editors - WPDefEditor, MDIChild problem

In my application i added a copy of WPDefActions and WPDefEditor.pas, so, from my aplication i call my custom Editor doing this:

procedure CreateEditor;
var
lForm : TWPToolsEditor;
begin
lForm := TWPToolsEditor.Create(nil);
lForm.ShowModal;
FreeAndNil(lForm);
end;

That´s ok. But my main form is a mdi parent. So i tried do change WPDefEditor.FormStyle to fsMDIChild.
When i create WPDefEditor form, it gets on an infinite loop! Always redrawing screen as crazy. But getting back to fsNormal FormStyle, everything works.

How can make a custom editor be showed as MdiChild ?

#1 ♥ 0
4k Views 2 users read 2 min
support

Hi,

How can make a custom editor be showed as MdiChild ?

try this:

// This event for auto free !
procedure TWPMdiDemo.WPDefEditorFormClose(Sender: TObject; var Action: TCloseAction);
begin
   Action := caFree;
end;

// Create a new wptools default editor as MDI child
procedure TWPMdiDemo.Button1Click(Sender: TObject);
var
  lForm : TWPToolsEditor;
begin
  WPIsMDIApp := true; // Make the Toolbar MDI compatible
  lForm := TWPToolsEditor.Create(Self);
  lForm.FormStyle := fsMDIChild;
  lForm.OnClose := WPDefEditorFormClose;
end;

WPIsMDIApp is required to avoid the flickering. It changes the behavior of the auto sizing of the TWPToolBar.

Julian

#2 ♥ 0

Hi Julian,

YES! this woked, but when Editor get closed, an exception is raised. So just to make you know, to avoid that exception, custom editor must be create with NIL, like this:

WPIsMDIApp := true; // Make the Toolbar MDI compatible
lForm := TWPToolsEditor.Create(nil);
lForm.FormStyle := fsMDIChild;
lForm.OnClose := WPDefEditorFormClose;

#3 ♥ 0
This category is archived. No new posts are possible.