[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ActiveX questions

Posted on 2001-07-03
9
Medium Priority
?
312 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 1200 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 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