簡體   English   中英

如何判斷用戶是否嘗試在C ++中關閉窗口?

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

當用戶點擊窗口上的關閉按鈕時,我需要打破一個while循環,但我不知道要檢查什么。 我正在使用allegro來運行GUI。

如果使用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)
{
}

使用Allegro 5,它更像是:

al_register_event_source(queue, al_get_display_event_source(display));

// in your event loop:

if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
}

有關所有詳細信息,請參閱手冊

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM