Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

set focus a component on my activeform after create

Posted on 1998-04-15
5
Medium Priority
?
263 Views
Last Modified: 2010-04-06
How can i set the focus to one of my components on my activeform after opening the html page and creating the activeform without user intervention ???
0
Comment
Question by:PatrickDecottignies
[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
  • 3
  • 2
5 Comments
 

Accepted Solution

by:
malander earned 20 total points
ID: 1361544
Set the ActiveControl property on your ActiveForm to the component you wish to have focus.  This would be done at design time.  If you need to change it at run time, you should publish a new method or procedure that uses the components SetFocus method (i.e.  Button1.SetFocus; ) and call the published method from a javascript.  Publishing a new method is done by having the ActiveForm's .PAS file open and selecting EDIT and Add To Interface... You can follow the HELP from there.  
0
 

Author Comment

by:PatrickDecottignies
ID: 1361545
This doesn't work !! The focus is still outside my activeform
0
 

Expert Comment

by:malander
ID: 1361546
I tried to duplicate your problem and my first suggestion didn't work (setting ActiveControl property at design time).  However, the second suggestion did work.  I published a method FormFocus similar to

procedure TActiveForm.FormFocus;
begin
     SetFocus;
     Edit1.SetFocus;
end;

I then called this from a javascript acting on the OnLoad event like this

<script LANGUAGE="JavaScript" FOR="window" EVENT="onLoad()">
<!--
MyActiveForm.FormFocus()

//-->
    </script>

I used IE 4.01 and Delphi 3.  My OLEMISC tags on TActiveFormFactory.Create were ACTIVATEWHENVISIBLE.  One other thing to think about is that any activity after the call my change focus from where you set it.  Hope this helps!
0
 

Author Comment

by:PatrickDecottignies
ID: 1361547
Can you please send me the whole description of your html page.
I'm not so familar with javascript, so i do the test but it doesn't work
0
 

Author Comment

by:PatrickDecottignies
ID: 1361548
Here it is!  The important part is the object declaration for the active form object and the javascript.  The object ID is the name you make up to label your active form. That way you can call to it in Javascript.  I labeled mine StatWeb.  "window" is the constant term for the page you are working with so that will always be the same.  Hope this helps out!


<html>

<head><script LANGUAGE="JavaScript" FOR="window" EVENT="onLoad()">
<!--
StatWeb.FormFocus()

//-->
    </script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Status</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">


<meta name="Microsoft Theme" content="safari 111"><meta name="Microsoft Border" content="t"></head>

<body background="_themes/safari/saftextr.jpg" bgcolor="#000000" text="#CCCC99" link="#CC9900" vlink="#996600" alink="#FF3300"><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><!--mstheme--><font face="trebuchet ms, arial, helvetica">

<p align="center"><br>
<img src="_derived/Status.htm_cmp_safari110_bnr.gif" width="600" height="60" border="0" alt="Status"></p>

<p align="center"><script language="JavaScript"><!--
MSFPhover =
  (((navigator.appName == "Netscape") && 
  (parseInt(navigator.appVersion) >= 3 )) ||
  ((navigator.appName == "Microsoft Internet Explorer") && 
  (parseInt(navigator.appVersion) >= 4 )));
function MSFPpreload(img)
{
  var a=new Image(); a.src=img; return a;
}
// --></script><script language="JavaScript"><!--
if(MSFPhover) { MSFPnav1n=MSFPpreload('_derived/home_cmp_safari110_hbtn.gif'); MSFPnav1h=MSFPpreload('_derived/home_cmp_safari110_hbtn_a.gif'); }
// --></script><a href="./" onmouseover="if(MSFPhover) document['MSFPnav1'].src=MSFPnav1h.src" onmouseout="if(MSFPhover) document['MSFPnav1'].src=MSFPnav1n.src"><img src="_derived/home_cmp_safari110_hbtn.gif" width="140" height="60" border="0" alt="Home" align="middle" name="MSFPnav1"></a></p>

<p align="center">&nbsp;</p>
<!--mstheme--></font></td></tr><!--msnavigation--></table><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><!--msnavigation--><td valign="top"><!--mstheme--><font face="trebuchet ms, arial, helvetica">

<p align="center"><script LANGUAGE="JavaScript">
    </script>
<object ID="StatWeb" WIDTH="464" HEIGHT="712" align="center" hspace="0" vspace="0" CLASSID="CLSID:30831D6F-C985-11D1-9C9C-0060B0A11A32" CODEBASE="http://mtdmalan/newhire/XStatus.ocx#version=1,0,0,0">
</object>
<!--mstheme--></font><!--msnavigation--></td></tr><!--msnavigation--></table></body>
</html>
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

719 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