Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5] Display always on top?

Credits go to AMCerasoli for helping out!
This thread is locked; no one can reply to it. rss feed Print
[A5] Display always on top?
Mark Oates
Member #1,146
March 2001
avatar

Is it possible to create a (fullscreen window) display so that it is always in front?

In a multi-monitor configuration like this:

{"name":"607332","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/d\/5da3049d8c624dd915871ee08ae0bbb6.png","w":478,"h":269,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/d\/5da3049d8c624dd915871ee08ae0bbb6"}607332

If I drag a window over, that window becomes the focused window and is brought to the front, on top of the allegro display:

{"name":"607333","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/2\/d28c445acf967ef59e5cf2caf197cd9d.png","w":478,"h":269,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/2\/d28c445acf967ef59e5cf2caf197cd9d"}607333

But I want the display to always be on top, like a powerpoint presentation window:

{"name":"607331","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/8\/4894e3d65d89b11c104c3209d7dcabb1.png","w":478,"h":269,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/8\/4894e3d65d89b11c104c3209d7dcabb1"}607331

Is there a setting for that somewhere?

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

AMCerasoli
Member #11,955
May 2010
avatar

I don't understand what you're trying to do...... hahahahahaha I'm kidding. You almost made a movie there man!.

Anyway, and what if you create a "real" fullscreen display in the second monitor? is not possible? I think that way nothing would be able to get on top.

Mark Oates
Member #1,146
March 2001
avatar

I don't understand what you're trying to do.

Ok, that was funny. :P

Quote:

Anyway, and what if you create a "real" fullscreen display in the second monitor? is not possible? I think that way nothing would be able to get on top.

The problem with that is when I just select a window in the primary display, the fullscreen is disappears (minimizes?)

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

AMCerasoli
Member #11,955
May 2010
avatar

The problem with that is when I just select a window in the primary display, the fullscreen is disappears (minimizes?)

Awww it's true. But I'm almost 100% sure that there is a way of doing it with the Windows handler (you know the HWND stuff) but I haven't done it before.

You'll probably need to get the Handler (al_get_win_window_handle(ALLEGRO_DISPLAY *display)) and then with some Windows specific code set it to be at the top all the time.

Maybe using something like SetWindowPos?

Mark Oates
Member #1,146
March 2001
avatar

You'll probably need to get the Handler (al_get_win_window_handle(ALLEGRO_DISPLAY *display)) and then with some Windows specific code set it to be at the top all the time.Maybe using something like SetWindowPos [msdn.microsoft.com]?

That's it!!! ;D ;D

AMCerasoli, you're a genjus!!!

I just added this code:

  HWND window_handle = al_get_win_window_handle(control_display->display);
  SetWindowPos(window_handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);

[edit] That makes me so haappyyyy!!! :D

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Matthew Leverton
Supreme Loser
January 1999
avatar

Now set that same flag on the other window and see what happens.

Mark Oates
Member #1,146
March 2001
avatar

Oh neat. It's like a topmost group.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Thomas Fjellstrom
Member #476
June 2000
avatar

Needs more bunnies.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

pkrcel
Member #14,001
February 2012

Needs more bunnies.

Ditto.

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

AMCerasoli
Member #11,955
May 2010
avatar

Well I want to announce to everybody that Mark asked me to get marry with him. He sent me a PM because he was afraid that I could reject him.

The wedding is around 15 of April of this year in Tokyo. You're of course all invited.

That makes me so haappyyyy!!!

Me too!

Thomas Fjellstrom
Member #476
June 2000
avatar

Congrats!

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Mark Oates
Member #1,146
March 2001
avatar

Well I want to announce to everybody that Mark asked me to get marry with him.

{"name":"607335","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/5\/35d34c734e7448f1e0307f7f2356b28e.gif","w":500,"h":281,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/5\/35d34c734e7448f1e0307f7f2356b28e"}607335

Well..... OK :-*.

But we have to get a prenup. You ain't gettin' my Bitcoinzz! >:(

[edit]

On topic, I should note that when using ALLEGRO_FULLSCREEN_WINDOW, it does not have the expected behavior and a dragged window will appear above it. However, if the display is created with ALLEGRO_NOFRAME then it does work as expected.

#SelectExpand
1#include <allegro5/allegro_windows.h> 2 3// ... 4 5int adapter_to_pick = 0; // the monitor to display it on 6 7// grab the monitor info 8ALLEGRO_MONITOR_INFO monitor_info; 9al_get_monitor_info(adapter_to_pick, &monitor_info); 10int monitor_width = monitor_info.x2 - monitor_info.x1; 11int monitor_height = monitor_info.y2 - monitor_info.y1; 12 13// create the display 14al_set_new_display_adapter(adapter_to_pick); 15al_set_new_display_flags(ALLEGRO_NOFRAME); 16ALLEGRO_DISPLAY *display = al_create_display(width, height); 17 18// make it a fullscreen window that is always on top, and does not move or resize 19HWND window_handle = al_get_win_window_handle(display); 20SetWindowPos(window_handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE); 21 22// prevent the mouse cursor from showing as well 23al_hide_mouse_cursor(display);

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Trent Gamblin
Member #261
April 2000
avatar

Quote:

SWP_NOMOVE + SWP_NOSIZE

Nit pick, but those mean don't honor the position and size parameters from the call, not what the comment says. :)

Go to: