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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AppActivate not working

Status
Not open for further replies.

GlynA

Programmer
May 1, 2002
77
0
0
GB
I have a VB6 ActiveX exe which displays a form.
I want this form to be activated once it has been populated.
To do this I use AppActivate(formname.caption).
This code appears to work on some machines, but on others the item on the task bar flashes but the form is not brought to the front. All machines use Windows 2000.
When AppActivate is used from another application it works correctly, bringing the form to the front.
Is this a VB bug? Is there a work round to get the behaviour I want?
 
Hi,

try

---------------------------------------
Form1.WindowState = vbNormal
Form1.SetFocus
----------------------------------------
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Thanks for the suggestion sunaj, but the problem remains.
The WindowState was already normal. (The form can be seen behind that of the calling applcation). Setting focus only changes focus within the application (in this case the ActiveX EXE) and not from the calling application.

Has anyone got any other ideas?
 
You might want to try the BringWindowToTop API call.

Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long

Private Sub Command1_Click()

BringWindowToTop formname.hwnd

End Sub
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
BringWindowToTop seems to give the same results as AppActivate.
This looks more and more like a windows problem rather than a VB issue.
 
Dear GlynA

Try setting the zorder to 0...
form1.zorder 0

if this does not work...
add on more form (form2) to ur application and load the actual form (form1) from form2...

eg:
form1_Activate()
form2.show
form2.zorder 0

and the use appactivate(form2.caption)

Hope this helps.

Bye
Mahesh
mshetti@yahoo.com
 
I have now created a new ActiveX EXE with a single class clsActivate containing the following code:

Public Sub Activate(ByVal sCaption As String)
AppActivate sCaption
End Sub

Rather than using appActivate directly I now create an object of clsActivate and use the routine above. This works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top