#ifndef REMOTING_HOST_WIN_SIMPLE_TASK_DIALOG_H_
#define REMOTING_HOST_WIN_SIMPLE_TASK_DIALOG_H_
#include <windows.h>
#include <commctrl.h>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/sequence_checker.h"
#include "base/thread_annotations.h"
#include "base/time/time.h"
namespace remoting {
class SimpleTaskDialog final {
public:
explicit SimpleTaskDialog(HMODULE resource_module);
~SimpleTaskDialog();
void set_title_text(const std::wstring& title_text) {
title_text_ = title_text;
}
void set_message_text(const std::wstring& message_text) {
message_text_ = message_text;
}
void set_default_button(int default_button) {
default_button_ = default_button;
}
void set_dialog_timeout(base::TimeDelta dialog_timeout) {
dialog_timeout_ = dialog_timeout;
}
bool SetTitleTextWithStringId(int title_text_id);
bool SetMessageTextWithStringId(int message_text_id);
void AppendButton(int button_id, const std::wstring& button_text);
bool AppendButtonWithStringId(int button_id, int button_text_id);
std::optional<int> Show();
SimpleTaskDialog(const SimpleTaskDialog&) = delete;
SimpleTaskDialog& operator=(const SimpleTaskDialog&) = delete;
private:
static HRESULT CALLBACK TaskDialogCallbackProc(HWND hwnd,
UINT notification,
WPARAM w_param,
LPARAM l_param,
LONG_PTR ref_data);
SEQUENCE_CHECKER(sequence_checker_);
HMODULE resource_module_;
std::wstring title_text_;
std::wstring message_text_;
int default_button_ = -1;
std::vector<std::pair<int, std::wstring>> dialog_buttons_;
base::TimeDelta dialog_timeout_;
bool is_foreground_window_ GUARDED_BY_CONTEXT(sequence_checker_) = true;
};
}
#endif