using only one window (not win32)
IronBob

i want to use only one window. when it starts the program it opens a console and then another window. how do i keep it to one window. i looked in docs and it said win_set_window(HWND wnd); ... but im not using win32 in the program and i cant use the HWND. how do i get it to only one window outside of win32.

23yrold3yrold

Compile (or rather, link) with the -mwindows switch.

IronBob

ok it works. but ive got one more question. how can i stop it from saying the thing about "closing the program my cause errors" when i click the X.

DanielH

Check the manual under Using Allegro.

int set_close_button_callback(void (*proc)(void));

IronBob

ok i cant find set_close_button_callback(). all i see is set_window_close_hook() and set_window_close_button().

[edit]i figured out that its set_window_close_hook() that im looking for but i dont know what i need to enter as an argument for it to close without asking for the "loss of data" thing.

Wetimer

void close_my_game()
{
// do something which will cause your game to close like:
gameover = true;
}

in main:
set_window_close_hook(close_my_game);

spellcaster

Aren't the set_windows_close_XXX functions depricated?

Evert
Quote:

Compile (or rather, link) with the -mwindows switch.

Better still, link with --Wl,--subsystem,windows instead. -mwindows, while shorter and easier to remember, is depricated.

Quote:

Aren't the set_windows_close_XXX functions depricated?

Yes, but emulated for backward compatibility.

gnolam

How 'bout int set_close_button_callback(void (*proc)(void)); then - that one isn't deprecated, right?

spellcaster

But if they are depricated, doesn't this mean that they
a) won't work as expected (so they go dpericated in the first place)
b) there's a better alternative to use (and that's why they got depricated)

Just curious...

Evert
Quote:

But if they are depricated, doesn't this mean that they

they didn't work as expected. By default, the closebutton handler would close the Allegro window from a callback function, which was something the docs explicidly told you not to do.
Hence, a better alternative was introduced, which makes the old broken functions obsolete. However, some programs used these functions, and in order not to break old sourecode, backward comptaibility inline functions were added.

spellcaster
Quote:

Hence, a better alternative was introduced,

Ok, what is the better alternative?

Evert
Quote:

Ok, what is the better alternative?

Disable the close button unless the user registers a callback function (using set_close_button_callback()), because it doesn't do anything useful if s/he doesn't.

Frankly, it looks more like a bugfix to me, since Allegro's original handler was broken...

IronBob

ok well i already tryed using the int set_close_button_callback(void (*proc)(void)); and it says "proc" not found. if i cant get that to work should i just use an empty function?

Evert
Quote:

and it says "proc" not found. if i cant get that to work should i just use an empty function?

Post some code, please.
It should look something like this:

void my_callback(void)
{
   //do some stuff
}

...


set_close_button_callback(my_callback);

IronBob
#include <allegro.h>

int main()
{
    allegro_init();
    install_keyboard();
    set_color_depth(16);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
    set_window_close_hook(void (*proc)(void));
    readkey();
    return 0;
} END_OF_MAIN();

MiquelFire

It should be:
<code>
#include <allegro.h>

void func_name(void)
{
// do something
}

int main()
{
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
set_window_close_hook(func_name);
readkey();
return 0;
} END_OF_MAIN();

spellcaster

Oh come on.. Winston posted the solution to your problem already.
Please read the replies you get. Please. Please. Please.

Please.

Pleeeeeeeeeeeeeeeeeeeeeeeeeeeeease.

IronBob

ok fine ... i got it.

Thread #255090. Printed from Allegro.cc