Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Forcing a window into the foreground

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dhbayne@ihug.co.nz - 18 Apr 2005 09:41 GMT
Hi All,

I am trying to write an application (an OOS exercise tool) that will
periodically  display a form in the foreground, and move back to the
foreground every time it loses focus, or once every 1/10th of a second
by a timer.

The problem is that myForm.BringToFront() isn't working; the
application is highlighted in the taskbar, but the application window
itself stays behind any other windows (e.g. SharpDevelop) that're in
the foreground.

Is there any way of doing what I want?  I've tried using DllImport to
invoke the SetForegroundWindow() function in user32.dll, but that has
exactly the same effect as the C# BringToFront() method.

TIA,
Duncan Bayne
AMercer - 18 Apr 2005 12:46 GMT
I set the form's TopMost boolean property for this function.  It works fine
in a VB application.

> Hi All,
>
[quoted text clipped - 14 lines]
> TIA,
> Duncan Bayne
Herfried K. Wagner [MVP] - 18 Apr 2005 18:56 GMT
<dhbayne@ihug.co.nz> schrieb:
> I am trying to write an application (an OOS exercise tool) that will
> periodically  display a form in the foreground, and move back to the
> foreground every time it loses focus, or once every 1/10th of a second
> by a timer.

You'll have to use p/invoke with 'AttachThreadInput' +
'SetForegroundWindow'.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.