00001 #ifndef _FOOBAR2000_HELPERS_WIN32_DIALOG_H_
00002 #define _FOOBAR2000_HELPERS_WIN32_DIALOG_H_
00003
00004
00005
00006 namespace dialog_helper
00007 {
00008
00009 class dialog
00010 {
00011 protected:
00012
00013 dialog() : wnd(0), m_is_modal(false) {}
00014 ~dialog() { }
00015
00016 virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0;
00017
00018 void end_dialog(int code);
00019
00020 public:
00021 inline HWND get_wnd() {return wnd;}
00022
00023 __declspec(deprecated) int run_modal(unsigned id,HWND parent);
00024
00025 __declspec(deprecated) HWND run_modeless(unsigned id,HWND parent);
00026 private:
00027 HWND wnd;
00028 static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp);
00029
00030 bool m_is_modal;
00031
00032 modal_dialog_scope m_modal_scope;
00033 };
00034
00036 class dialog_modal
00037 {
00038 public:
00039 __declspec(deprecated) int run(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance());
00040 protected:
00041 virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0;
00042
00043 inline dialog_modal() : m_wnd(0) {}
00044 void end_dialog(int p_code);
00045 inline HWND get_wnd() const {return m_wnd;}
00046 private:
00047 static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp);
00048
00049 HWND m_wnd;
00050 modal_dialog_scope m_modal_scope;
00051 };
00052
00055
00067 class dialog_modeless
00068 {
00069 public:
00072 __declspec(deprecated) bool create(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance());
00073 protected:
00075 virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0;
00076
00077 inline dialog_modeless() : m_wnd(0), m_destructor_status(destructor_none), m_is_in_create(false) {}
00078 inline HWND get_wnd() const {return m_wnd;}
00079 virtual ~dialog_modeless();
00080 private:
00081 static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp);
00082 void on_window_destruction();
00083
00084 BOOL on_message_wrap(UINT msg,WPARAM wp,LPARAM lp);
00085
00086 HWND m_wnd;
00087 enum {destructor_none,destructor_normal,destructor_fromwindow} m_destructor_status;
00088 bool m_is_in_create;
00089 };
00090
00091
00092 class dialog_modeless_v2
00093 {
00094 protected:
00095 __declspec(deprecated) explicit dialog_modeless_v2(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance(),bool p_stealfocus = true);
00096 virtual ~dialog_modeless_v2();
00097 HWND get_wnd() const {return m_wnd;}
00098 virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp) {return FALSE;}
00099
00100 static dialog_modeless_v2 * __unsafe__instance_from_window(HWND p_wnd) {return reinterpret_cast<dialog_modeless_v2*>(GetWindowLongPtr(p_wnd,DWLP_USER));}
00101 private:
00102 static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp);
00103 void detach_window();
00104 BOOL on_message_internal(UINT msg,WPARAM wp,LPARAM lp);
00105 enum {status_construction, status_lifetime, status_destruction_requested, status_destruction} m_status;
00106 HWND m_wnd;
00107 const bool m_stealfocus;
00108
00109 const dialog_modeless_v2 & operator=(const dialog_modeless_v2 &);
00110 dialog_modeless_v2(const dialog_modeless_v2 &);
00111 };
00112
00113 };
00114
00116 HWND uCreateDialog(UINT id,HWND parent,DLGPROC proc,LPARAM param = 0);
00118 int uDialogBox(UINT id,HWND parent,DLGPROC proc,LPARAM param = 0);
00119
00120
00121 #endif