Solved

ActiveX questions

Posted on 2001-07-03
9
307 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 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