foobar2000 SDK  2015-08-03
win32_dialog.h
Go to the documentation of this file.
1 #ifdef _WIN32
2 
3 #ifndef _FOOBAR2000_HELPERS_WIN32_DIALOG_H_
4 #define _FOOBAR2000_HELPERS_WIN32_DIALOG_H_
5 
6 //DEPRECATED dialog helpers - kept only for compatibility with old code - do not use in new code, use WTL instead.
7 
8 namespace dialog_helper
9 {
10 
11  class dialog
12  {
13  protected:
14 
15  dialog() : wnd(0), m_is_modal(false) {}
16  ~dialog() { }
17 
18  virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0;
19 
20  void end_dialog(int code);
21 
22  public:
23  inline HWND get_wnd() {return wnd;}
24 
25  __declspec(deprecated) int run_modal(unsigned id,HWND parent);
26 
27  __declspec(deprecated) HWND run_modeless(unsigned id,HWND parent);
28  private:
29  HWND wnd;
30  static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp);
31 
32  bool m_is_modal;
33 
35  };
36 
39  {
40  public:
41  __declspec(deprecated) int run(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance());
42  protected:
43  virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0;
44 
45  inline dialog_modal() : m_wnd(0) {}
46  void end_dialog(int p_code);
47  inline HWND get_wnd() const {return m_wnd;}
48  private:
49  static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp);
50 
51  HWND m_wnd;
53  };
54 
57 
70  {
71  public:
74  __declspec(deprecated) bool create(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance());
75  protected:
77  virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0;
78 
79  inline dialog_modeless() : m_wnd(0), m_destructor_status(destructor_none), m_is_in_create(false) {}
80  inline HWND get_wnd() const {return m_wnd;}
81  virtual ~dialog_modeless();
82  private:
83  static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp);
84  void on_window_destruction();
85 
86  BOOL on_message_wrap(UINT msg,WPARAM wp,LPARAM lp);
87 
88  HWND m_wnd;
89  enum {destructor_none,destructor_normal,destructor_fromwindow} m_destructor_status;
91  };
92 
93 
95  {
96  protected:
97  __declspec(deprecated) explicit dialog_modeless_v2(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance(),bool p_stealfocus = true);
98  virtual ~dialog_modeless_v2();
99  HWND get_wnd() const {return m_wnd;}
100  virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp) {return FALSE;}
101 
102  static dialog_modeless_v2 * __unsafe__instance_from_window(HWND p_wnd) {return reinterpret_cast<dialog_modeless_v2*>(GetWindowLongPtr(p_wnd,DWLP_USER));}
103  private:
104  static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp);
105  void detach_window();
106  BOOL on_message_internal(UINT msg,WPARAM wp,LPARAM lp);
107  enum {status_construction, status_lifetime, status_destruction_requested, status_destruction} m_status;
108  HWND m_wnd;
109  const bool m_stealfocus;
110 
111  const dialog_modeless_v2 & operator=(const dialog_modeless_v2 &);
113  };
114 
115 };
116 
118 HWND uCreateDialog(UINT id,HWND parent,DLGPROC proc,LPARAM param = 0);
120 int uDialogBox(UINT id,HWND parent,DLGPROC proc,LPARAM param = 0);
121 
122 
123 #endif
124 
125 
126 #endif // _WIN32
__declspec(deprecated) int run_modal(unsigned id
The purpose of modal_dialog_scope is to help to avoid the modal dialog recursion problem. Current toplevel modal dialog handle is stored globally, so when creation of a new modal dialog is blocked, it can be activated to indicate the reason for the task being blocked.
Definition: shared.h:504
typedef BOOL(WINAPI *pPowerSetRequest_t)(__in HANDLE PowerRequest
HWND uCreateDialog(UINT id, HWND parent, DLGPROC proc, LPARAM param=0)
Wrapper (provided mainly for old code), simplifies parameters compared to standard CreateDialog() by ...
This class is meant to be instantiated on-stack, as a local variable. Using new/delete operators inst...
Definition: win32_dialog.h:38
static INT_PTR CALLBACK DlgProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win32_dialog.cpp:8
void end_dialog(int code)
modal_dialog_scope m_modal_scope
Definition: win32_dialog.h:52
virtual BOOL on_message(UINT msg, WPARAM wp, LPARAM lp)=0
static dialog_modeless_v2 * __unsafe__instance_from_window(HWND p_wnd)
Definition: win32_dialog.h:102
modal_dialog_scope m_modal_scope
Definition: win32_dialog.h:34
virtual BOOL on_message(UINT msg, WPARAM wp, LPARAM lp)
Definition: win32_dialog.h:100
void create(pfc::string_formatter &p_out, const t_entry_list &p_data)
Definition: cue_creator.cpp:44
HINSTANCE get_my_instance()
Retrieves HINSTANCE of calling DLL.
int uDialogBox(UINT id, HWND parent, DLGPROC proc, LPARAM param=0)
Wrapper (provided mainly for old code), simplifies parameters compared to standard DialogBox() by usi...
This class is meant to be used with new/delete operators only. Destroying the window - outside create...
Definition: win32_dialog.h:69