Solved

ActiveX questions

Posted on 2001-07-03
9
299 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
Comment Utility
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
Comment Utility
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
Comment Utility
do you have a delphi sample which create own events in a ActiveX?
0
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
Having problems?
0
 
LVL 2

Author Comment

by:egono
Comment Utility
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
Comment Utility
forget my last comment, I missed the point with recompiling the vcl - now it works
0
 
LVL 2

Author Comment

by:egono
Comment Utility
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
Comment Utility
Thank you too.

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now