开发者

How can I tell if the user tries to close the window in C++?

开发者 https://www.devze.com 2023-03-13 18:54 出处:网络
I need to break a while loop when the开发者_Python百科 use clicks the close button on the window, but I don\'t know what to check for. I\'m using allegro to run the GUI.If using Allegro 4: set_close_b

I need to break a while loop when the开发者_Python百科 use clicks the close button on the window, but I don't know what to check for. I'm using allegro to run the GUI.


If using Allegro 4: set_close_button_callback()

volatile int hit_closed = 0;

void close_button_proc()
{
  hit_closed = 1;
}

// later after creating the display:

set_close_button_callback(close_button_proc);

while (!hit_closed)
{
}

With Allegro 5, it's more like:

al_register_event_source(queue, al_get_display_event_source(display));

// in your event loop:

if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
}

See the manual for all the details.

0

精彩评论

暂无评论...
验证码 换一张
取 消