Solved

ActiveX questions

Posted on 2001-07-03
9
301 Views
Last Modified: 2010-04-04
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
http://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.
0
Comment
Question by:egono
  • 5
  • 4
9 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6249168
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.
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 300 total points
ID: 6249340
This example uses 2 SpinEdits (Delphi ActiveX control). The necessary OnChange event is already in the control, so you don't need to create it. Don't forget to change the GUID's to your onw SpinEdit controls GUID.


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript" for="spin1" event="OnChange">
spin2.value = spin1.value;
</script>
<script language="JavaScript" for="spin2" event="OnChange">
spin1.value = spin2.value;
</script>
<body bgcolor="#FFFFFF" text="#000000">
<object width="50" height="24" classid="clsid:58007014-6F76-4CA8-AD91-14B782A4F1F2" name="spin1">
</object> <object width="50" height="24" classid="clsid:58007014-6F76-4CA8-AD91-14B782A4F1F2" name="spin2">
</object>
</body>
</html>
0
 
LVL 2

Author Comment

by:egono
ID: 6249367
do you have a delphi sample which create own events in a ActiveX?
0
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 13

Expert Comment

by:Epsylon
ID: 6249673
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.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6253923
Having problems?
0
 
LVL 2

Author Comment

by:egono
ID: 6255026
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?

0
 
LVL 2

Author Comment

by:egono
ID: 6255090
forget my last comment, I missed the point with recompiling the vcl - now it works
0
 
LVL 2

Author Comment

by:egono
ID: 6270077
I'm done with this problem - thanks ...

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20143423 is still open ...
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6270566
Thank you too.

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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question