Open form without losing focus

a_jam_sandwich

Junior Contributor
Joined
Dec 10, 2002
Messages
367
Location
Uk
Im trying to create a support system program.

When using the system you can run it in the Systray, and when a request come in a POPUP form will display indicating the request.

The problem is I dont want to lose focus from the program that the users in as it just a notiforcation (VISUAL ONLY).

I know the API method in VB6 with ShowWindow using SW_SHOWNOACTIVE but have no idea what to do in VB.NET

Can anyone help

Cheers

Andy
 
When you have created form do not display it with Show method!
Use API function ShowWindow found in User32.dll like this :

Declare Ansi Function ShowWindow Lib "User32" (ByVal HWND As IntPtr, ByVal nCmdShow As Integer) As Boolean
Const SW_SHOWNOACTIVATE As Integer = 4

Call it like this :

Dim F As MyForm
F = New MyForm()
ShowWindow(F.Handle, SW_SHOWNOACTIVATE)
 
Instead of using .Show just use .Visible=True. This doesn't effect the window ZOrder (at least, it didn't in my tests) and keeps the active window active.
 
I believe the question was how to show form without activating it and I assume that a_jam_sandwich has tried what you just writed. Setting visible to True do activates form!!! Can you send me your source code of the test where you can do what you have described?
 
Ahh - it could be a quirk with my system (Win2000). I often get windows opening behind active windows, such as my outlook reminders which often open in the background and without focus.
 
Have you checked your declaration of ShowWindow function and constant? Where do you put it? Have you replaced MyForm with name of your form?
 
Back
Top