Link to home
Start Free TrialLog in
Avatar of egono
egono

asked on

ActiveX questions

1. Please leave this question open to other experts - thanks!
2. This is a technical question related to ActiveX and delphi. I have to use ActiveX and delphi (JavaScript only to exchange data between the ActiveX control and the html form). I will not accept answers which solve my problems with other techniques.
3. I asked a simular question here
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20143423
but I'm running out of time.


Lets say I want to write two ActiveX controls which are embedded in a html form. The first one is a TDateTimePicker to select a date and the second one is a SpinEdit which calculates a duration related to the date.
Sample html page:

<html>
<body>
<form method="post" action="http://myserver/mycgi">
my statement: <input size=12 name="statement">
my birthday: <my ActiveX TDateTimePicker>
my age: <my ActiveX SpinEdit>
</form>
</body>
</html>

After the user enters the birthday the second ActiveX (SpinEdit) should automatically calculate the age.

The problems are:
1. How do I send the data from the ActiveX back to the html form.
2. How do I communicate from one ActiveX to the other.

I found these two links but I don't understand it (I have only very minor C++ and VB knowledge).

Accessing the Object Model from Within an ActiveX Control
http://support.microsoft.com/support/kb/articles/Q172/7/63.ASP

Enumerate OLE and VB Controls from an OLE Control
http://support.microsoft.com/support/kb/articles/Q141/4/14.asp

I would like to have some sample delphi code - thanks.
Avatar of Epsylon
Epsylon

Examine this:

<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<script language="JavaScript">
function SubmitTheForm()
{
 form1.spinedit1.value = spinedit1.value;
 form1.submit();
}
</script>
<form name="form1" onSubmit="SubmitTheForm()" method="get" action="someurl" >
 <input type="submit" name="SubmitButton" value="Submit">
 <input type="hidden" name="spinedit1">
</form>
<OBJECT classid="clsid:FCEB1431-3721-11D4-82FD-0040332B69A2"
codebase="http://domain/MySpinEditXControl1.cab"
name="spinedit1">
</OBJECT>
</body>
</html>


For communicating between ActiveX controls you need to create event in you controls.
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of egono

ASKER

do you have a delphi sample which create own events in a ActiveX?
I could do that but I don't know what event to add. Just look how the OnChange, OnClick, OnDblClick and OnKeyPress event are implemented. The other TSpinEdit events can't be added to the ActiveX control because they have parameters which can't be translated into the type library.


Here is a short explanation how to create an event, e.g. OnClick. So lets pretend it's not there:

1) Add a new event (method) in the Type Library Window under IMySpinEditEvents. Name it OnClick. Click on the refresh button in the Type Library Window.


2) In MySpinEditImpl1.pas add

    procedure ClickEvent(Sender: TObject);

in the private section of TMySpinEdit and

procedure TMySpinEdit.ClickEvent(Sender: TObject);
begin
  if FEvents <> nil then FEvents.OnClick;
end;

in the implementation section of the unit.


3) Now find TMySpinEdit.InitializeControl and add this line:

  FDelphiControl.OnClick := ClickEvent;


That should be all.
Having problems?
Avatar of egono

ASKER

sorry I'm busy get things working

I stumbled over another problem:

I've created a ActiveForm with a TMemo, a TStatusbar, a TToolBar with several TToolButtons. When I put it on my html page and scroll it in to view (it's located at the end of the page), then the layout of the ActiveForm get messed up. I found this patch somewhere in the newsgroups but it didn't help

function TActiveXControl.SetObjectRects(const rcPosRect: TRect;  const rcClipRect: TRect): HResult;
var
  IxRect: TRect;
  NewWindowRgn: HRGN;
  DoIntersect: Boolean;
Label the_end;
begin
  try
    //(*===========================================
    // GW's fix, follows
    // CComControlBase::IOleInPlaceObject_SetObjectRects
    //-------------------------------------------

    if (@rcPosRect = nil) or (@rcClipRect = nil) then
    Begin
      Result := E_POINTER;
      goto the_end;
    end;

    If FWinControl.HandleAllocated then
    Begin
      DoIntersect := IntersectRect(IxRect, rcPosRect, rcClipRect);
      NewWindowRgn := 0; // default to request no clipping

      //------------------------------
      // check if clipping is needed
      //------------------------------
      if DoIntersect and (not EqualRect(IxRect, rcPosRect)) then
      Begin
        //------------------------------
        // set up clipping region
        //------------------------------
        OffsetRect(IxRect, -rcPosRect.Left, -rcPosRect.Top);
        NewWindowRgn := CreateRectRgnIndirect(IxRect);
      end;

      SetWindowRgn(FWinControl.Handle, NewWindowRgn, True);
      FWinControl.BoundsRect := rcPosRect;
    end;
    //===========================================*)

    Result := S_OK;
  the_end:
  except
    Result := HandleException;
  end;
end;


any ideas?

Avatar of egono

ASKER

forget my last comment, I missed the point with recompiling the vcl - now it works
Avatar of egono

ASKER

I'm done with this problem - thanks ...

https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20143423 is still open ...
Thank you too.

I already had a look at the other Q and successfully tried some of edey's code...