Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Locating Window on screen

This thread is locked; no one can reply to it. rss feed Print
Locating Window on screen
AceBlkwell
Member #13,038
July 2011
avatar

All,

My program uses a smaller display than the machine's screen size. By placing a marker on the computer screen it appears the program starts at the same screen upper LH coordinates regardless of what size display the program is using. The problem is if the program alters the display to a larger size display, say 1600x900, a portion of the program is off computer screen.

I write to the buffer then use

al_draw_scaled_bitmap(buffer, 0, 0, nBufferWD, nBufferHT, 0, 0, nDispWD, nDispHT, 0);

After this I flip the display.

I guess essentially I'm asking is there a way of having the program window start in a given location on the screen.

Thanks.

DanielH
Member #934
January 2001
avatar

It's usually centered. There is no Allegro4 way to do that. You would have to use platform specific functions.

Are you using 4 or 5? You could set resize limits with 5.

LennyLen
Member #5,313
December 2004
avatar

DanielH said:

Are you using 4 or 5?

A5 going by the function used.

AceBlkwell
Member #13,038
July 2011
avatar

Allegro 5

You know, I'm running the program from a compiler. I wonder if that it contributing. In any case, I'm including a couple pictures that might help define the problem.

Nevermind, it doesn't look like the site is gong to let me upload pictures.

DanielH
Member #934
January 2001
avatar

You can upload pics. However, weird. you must upload pics. save post to establish correct links. Then re-edit pics to get correct urls.
Edit: maybe not. Doesn't seem to work.

void al_set_window_position(ALLEGRO_DISPLAY *display, int x, int y);
bool al_set_window_constraints(ALLEGRO_DISPLAY *display, int min_w, int min_h, int max_w, int max_h);
void al_apply_window_constraints(ALLEGRO_DISPLAY *display, bool onoff);

These are not guaranteed, but will attempt

AceBlkwell
Member #13,038
July 2011
avatar

I'll give it a shot. Today I ran the program without the compiler. The window upper LH corner is in the same place with the same results. So, not a compiler thing. Thanks for the info.

DanielH
Member #934
January 2001
avatar

Compiler shouldn't matter. Default is center of screen when starting app.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

AceBlkwell
Member #13,038
July 2011
avatar

Thanks guys. I had luck with the

al_set_window_position(ALLEGRO_DISPLAY *display, int x, int y);

command. I appreciate the help.

Go to: