Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-07

How to bring application to from (top)

11 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tommi Prami

Hello,

I thought this would be very trivial, but I have tried very many different things and searched from the net, and tried several code snippets...

Here is some kind of list what I have tried so far...

1.  Application.MainForm.BringToFront;
2.  Application.RestoreStayOnTop(True);
3. MessageDlg('Come to papa', mtError, [mbOK], 0);
4.  BringWindowToTop(Application.MainForm.Handle); // IE 5.5 related hack
      SetForegroundWindow(Application.MainForm.Handle);
5.
   Windows.MessageBox(
        Self.Handle,
        'Program already started',
        'Program already started',
        MB_SYSTEMMODAL or MB_SETFOREGROUND or MB_TOPMOST or
MB_ICONINFORMATION) ;

So far any of them have worked OK,,,

Main form can have modal children etc...

But I just cant pop the application to the surface :(

Is there any that would work... It should work on Windows Win32 and WiCE...

-TP-

Reply by email

Graeme Geldenhuys
to Tommi Prami
Tommi Prami wrote
But I just cant pop the application to the surface :(

That is considered a rule practice. So what the window managers (including Windows, Linux etc) simply do, is flash the taskbar entry for your application. Notifying the user in a non-intrusive way that your application would like some love and attention.

If you really want your app to always be on top. Then create a fullscreen application.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Mark Morgan Lloyd
to Graeme Geldenhuys
Graeme Geldenhuys wrote 10 lines
On 07/08/2011 01:38 PM, Tommi Prami wrote: > But I just cant pop the application to the surface :( That is considered a rule practice. So what the window managers (including Windows, Linux etc) simply do, is flash the taskbar entry for your application. Notifying the user in a non-intrusive way that your application would like some love and attention. If you really want your app to always be on top. Then create a fullscreen application.

Could possibly do it using a dbus (or whatever) message. But the rule still is that that sort of thing is considered rude.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Tommi Prami
to Mark Morgan Lloyd
Could possibly do it using a dbus (or whatever) message. But the rule still is that that sort of thing is considered rude.

Let me explain here a bit...

It is mainly an WinCE app that is more than less Full screen. If the user goes on purpose or accidently to the system side... Then it might be that he/she does not know how to bring the already running application to the screen.

But, what they surely know or are at least told how to do is to start the app. And now my app check that it is already running, informs the running one that wake up, and kills it self (to put nicely).

Now it works perfectly only I can't get unfocused App to come to the Screen to the top most app. ..

If there is some force way to do it. Any will do, would be good...

.-Tee-.

Reply by email

Sven Barth
to Tommi Prami
Tommi Prami wrote 19 lines
> Could possibly do it using a dbus (or whatever) message. But the rule > still is that that sort of thing is considered rude. > Let me explain here a bit... It is mainly an WinCE app that is more than less Full screen. If the user goes on purpose or accidently to the system side... Then it might be that he/she does not know how to bring the already running application to the screen. But, what they surely know or are at least told how to do is to start the app. And now my app check that it is already running, informs the running one that wake up, and kills it self (to put nicely). Now it works perfectly only I can't get unfocused App to come to the Screen to the top most app. .. If there is some force way to do it. Any will do, would be good...

In our Windows Mobile application we are using this way from within the newly started application. It searches for the form window (this is important; focusing the invisible application window does not work, so you need to give the form a different title than the application) and puts it into the foreground.

=== source begin ===

   // h is a THandle
   h := FindWindow('Window', PWideChar(wTitle));
   if h  0 then
     SetForegroundWindow(h);

=== source end ===

A maybe better solution (I need to test this...) is to somehow send the old application a message and then that application could do the following when receiving that message:

=== source begin ===

SetForegroundWindow(Screen.ActiveForm.Handle);

=== source end ===

As said, I have not tested it yet, but if it works it would be a better/nicer solution than the (working) solution above.

Regards,
Sven

Reply by email

Luca Olivetti
to Sven Barth

Al 08/07/2011 17:19, En/na Sven Barth ha escrit:

A maybe better solution (I need to test this...) is to somehow send the old application a message and then that application could do the following when receiving that message

You could use TSimpleIPCServer/TSimpleIPCClient (either by themselves or wrapped by UniqueInstance).

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es Tel. +34 935883004 (Ext.133) Fax +34 935883007

Reply by email

Sven Barth
to Tommi Prami: I think that at least in Windows XP the system will block the App from coming into the…
Tommi Prami wrote 8 lines
> SetForegroundWindow(Screen.ActiveForm.Handle); > I think that at least in Windows XP the system will block the App from coming into the Front. Othervice it would work. Have to test this on Windows Mobile also,...

Well... as you said it's for Windows Mobile (or WinCE to be precisely) I've posted a solution for that. On desktop Windows I've never needed that functionality yet, cause I personally dislike it when an application jumps to front when I don't want it to. Thus I prefer the blinking solution there.

Regards,
Sven

Reply by email

Tommi Prami
to Sven Barth
Sven Barth wrote 15 lines
On 08.07.2011 19:23, Tommi Prami wrote: > >> SetForegroundWindow(Screen.ActiveForm.Handle); >> > > I think that at least in Windows XP the system will block the App from > coming into the Front. > > Othervice it would work. Have to test this on Windows Mobile also,... Well... as you said it's for Windows Mobile (or WinCE to be precisely) I've posted a solution for that. On desktop Windows I've never needed that functionality yet, cause I personally dislike it when an application jumps to front when I don't want it to. Thus I prefer the blinking solution there.

Seems to work...

Thanks...

-TP-

Reply by email

Sven Barth
to Tommi Prami
Tommi Prami wrote 20 lines
On 8.7.2011 21:39, Sven Barth wrote: > On 08.07.2011 19:23, Tommi Prami wrote: >> >>> SetForegroundWindow(Screen.ActiveForm.Handle); >>> >> >> I think that at least in Windows XP the system will block the App from >> coming into the Front. >> >> Othervice it would work. Have to test this on Windows Mobile also,... > > Well... as you said it's for Windows Mobile (or WinCE to be precisely) > I've posted a solution for that. On desktop Windows I've never needed > that functionality yet, cause I personally dislike it when an > application jumps to front when I don't want it to. Thus I prefer the > blinking solution there. Seems to work... Thanks...

You're welcome :)

Regards,
Sven

Reply by email