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

Keep form focused and on top

Status
Not open for further replies.

ShaneBrennan

Programmer
May 19, 1999
198
GB
I'm trying to write a small program that will keep a VB form on top and constantly focused so the user can not switch to other applications.

I've got code to enable a form to stay on top, but once I click on another application such as notepad, the focus stays there.

Is there a way to tell VB to move the focus back to a specific form or form control?

thanks for any help I get

Shane Brennan Shane Brennan

'-----------------------

' Emails: shanebrennan@postmaster.co.uk
' Personal WebPage:
 
Okay. I've got a little further.

I now have a little bit of code to detect when I've left the application.

So I've got code:
to make the form topmost (Z order)
Detect when I've tabbed out of the application.

All I need now is to return windows focus back to my application. If I use form1.text1.setfocus - the cursor does go into the textbox BUT the system is still focussed on the other application - say notepad - so as I type the text appears in notepad instead of the text box.

Has anyone got any ideas on how I can do this last step?

Many thanks

Shane
Shane Brennan

'-----------------------

' Emails: shanebrennan@postmaster.co.uk
' Personal WebPage:
 
Hi Shane,

it seems that you have to get into the WIN32API in order to get it done. It would need to much room to explain the functions which are required. But as a good start, you should search the web for the Windows message WM_ACTIVATEAPP and the API Function SendMessage or SendNotifyMessage.

Have a nice day

OpenWater
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top