Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why the form always cannot got focus ?

Status
Not open for further replies.

Johnweida

MIS
Apr 29, 2003
91
CN
experts,

I define a form from a prg file but it always cannot got focus when I click a button in another form to call it.

*****************
Public oform1
oform1=createobject("form1")
oform1.Show
Return
******************************************************
Define Class form1 As Form

Height = 400
Width = 620
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
AutoCenter = .T.
ShowWindow = 2

Add Object cmdExit As CommandButton With ;
Top = 330, ;
Left = 504, ;
Height = 27, ;
Width = 84, ;
Caption = &quot;E\<xit&quot;, ;
Name = &quot;CmdExit

Procedure cmdExit.Click
Thisform.Release()
Endproc
Enddefine
****************************
Please help me.Thanks.

John Satellite
 
Is the problem really that the form doesn't get focus or that the form isn't on top? If the problem is that the new form isn't on top, it may be that the calling form has AlwaysOnTop set to .T.

If the problem is the focus it may be because the new form isn't modal, and some code is running after to call the new form that moves the focus elsewhere.



-BP
 
I think you will find that the Form does in fact get focus, no matter how briefly. If you put:

Messagebox(&quot;FORM HAS FOCUS!&quot;)

...in the GotFocus event of that form, you will see that the messagebox is displayed when the form activates. It will also be displayed whenever you minimize and then restore the form...there are some other times that the form can get focus again, but they all generally have to do with the Activate of the form.

The focus then moves off of the form onto whatever control is the first in the tab order on the form (assuming you have some controls on this form that can receive focus). After that you will not be able to get the GotFocus event to run again by say simply clicking on the form.

So, it would lead me to believe that what you said is not what you meant and that BPeisch is on the right track with her line of questioning.

Please post back and clarify further what you mean when you say that the form can't get focus. I am going to guess and say that you need to make your form modal, which would require you to set the WindowType property of your form to &quot;1 - Modal&quot;.

Slighthaze = NULL
craig1442@mchsi.com
&quot;Whom computers would destroy, they must first drive mad.&quot; - Anon​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top