Sign in Join

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

Mailing lists / lazarus / 2017-01

Show a window under GTK2 in front without stealing the focus

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Michael Fuchs

Hello,

I try to use a notify-like window in one of my applications. That means that a window should be shown on top of all windows, but did not steal the focus from other running applications.

Under windows this works with

  ShowWindow(MyForm.Handle, SW_SHOWNOACTIVATE);

But how can I do this under GTK2?

Thx for help
Michael

Reply by email

zeljko
to Michael Fuchs
Michael Fuchs wrote 11 lines
Hello, I try to use a notify-like window in one of my applications. That means that a window should be shown on top of all windows, but did not steal the focus from other running applications. Under windows this works with ShowWindow(MyForm.Handle, SW_SHOWNOACTIVATE); But how can I do this under GTK2?

Don't know now exactly, but gtk_window_set_focus_on_map(Window, False) maybe could help. Have you looked into gtk2winapi ? eg Qt have such flag and it can show window without activating.

zeljko

Reply by email

Michael Fuchs
to zeljko
zeljko wrote
> Under windows this works with >> ShowWindow(MyForm.Handle, SW_SHOWNOACTIVATE); >> But how can I do

this under GTK2? > > Don't know now exactly, but
gtk_window_set_focus_on_map(Window, > False) maybe could help. Have you looked into gtk2winapi ? eg Qt have > such flag and it can show window without activating. > > zeljko

Hi,

thanks for your help. With gtk_window_set_focus_on_map and gtk_window_set_accept_focusit seems to work under GTK.

   MyForm.Visible := True;
   // HACK: SW_SHOWNOACTIVATE is not implemented under GTK2, we will use
a direct GTK calls
   {$IFDEF LCLGTK2}
     GtkWindow := PGtkWindow(MyForm.Handle);
     gtk_window_set_keep_above(GtkWindow, True);
     gtk_window_set_accept_focus(GtkWindow, False);
     gtk_window_set_focus_on_map(GtkWindow, False);
     gtk_window_present(GtkWindow);
   {$ELSE}
     ShowWindow(MyForm.Handle, SW_SHOWNOACTIVATE);
   {$ENDIF}

Unfortunately I discovered that under Windows SW_SHOWNOACTIVATE does not work as I expected. So in the end, I build a form that inherits from THintWindow. This resolves my problem.

Reply by email