PDA

View Full Version : Delphi and ShowModal() problem



digitstudios
11-13-2006, 02:42 AM
Hey,

I have following problem: I have an application with several forms. On the main form I put an OleContainer, and in this olecontainer, I run MapPoint. This works fine. But when I want to show a form using ShowModal() (I'm using BCB6 C++), the modal form is shown behind the main form (and as the mainform is disabled because the other form is modal,the entire application is stuck).

I know for sure that it's the MapPoint in the olecontainer that causes the problem.

Does anyone has the same problems? Or better: does anyone know how to solve this?


Thanks in advance!
Gianluca

Wilfried
11-13-2006, 07:21 AM
Hi,

Hmm I have had that problem, but I forgot what the fix was. Please try following constructor and creation. Put a Panel on your form, name it MPPanel and use following code:


procedure TForm1.Button1Click(Sender: TObject);
begin
MP := TMP.Create(Self, MPPanel);
end;

This is the constructor:


constructor TMP.Create(AOwner: TComponent; ParentControl: TWinControl);
var
vGuid: TGuid;
begin;
OleContainer := TOleContainer.create(AOwner);
OleContainer.Width := ParentControl.Width;
OleContainer.Height := ParentControl.height;
OleContainer.Parent := ParentControl;
OleContainer.CreateObject('MapPoint.Map.EU.11',Fal se);
OleContainer.DoVerb(1);
OleContainer.OleObjectInterface.GetUserClassID(vGu id);
OleContainer.Align := alClient;
FMap:= IDispatch(OleContainer.OleObject) as map;
end;