foobar2000 SDK  2015-08-03
Public Member Functions | Data Fields | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
dialog_helper::dialog_modelessabstract

#include <win32_dialog.h>

Public Member Functions

 __declspec (deprecated) bool create(unsigned p_id
 

Data Fields

HWND HINSTANCE p_instance = core_api::get_my_instance())
 
HWND p_parent
 

Protected Member Functions

 dialog_modeless ()
 
virtual ~dialog_modeless ()
 
HWND get_wnd () const
 
virtual BOOL on_message (UINT msg, WPARAM wp, LPARAM lp)=0
 

Private Types

enum  { destructor_none, destructor_normal, destructor_fromwindow }
 

Private Member Functions

BOOL on_message_wrap (UINT msg, WPARAM wp, LPARAM lp)
 
void on_window_destruction ()
 

Static Private Member Functions

static INT_PTR CALLBACK DlgProc (HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
 

Private Attributes

enum dialog_helper::dialog_modeless:: { ... }  m_destructor_status
 
bool m_is_in_create
 
HWND m_wnd
 

Detailed Description

This class is meant to be used with new/delete operators only. Destroying the window - outside create() / WM_INITDIALOG - will result in object calling delete this. If object is deleted directly using delete operator, WM_DESTROY handler may not be called so it should not be used (use destructor of derived class instead). Classes derived from dialog_modeless must not be instantiated in any other way than operator new().

Typical usage :
class mydialog : public dialog_helper::dialog_modeless {...}; (...) bool createmydialog() { mydialog * instance = new mydialog; if (instance == 0) return flase; if (!instance->create(...)) {delete instance; return false;} return true; }

Definition at line 69 of file win32_dialog.h.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

dialog_helper::dialog_modeless::dialog_modeless ( )
inlineprotected
dialog_helper::dialog_modeless::~dialog_modeless ( )
protectedvirtual

Definition at line 111 of file win32_dialog.cpp.

111  {
112  assert(!m_is_in_create);
113  switch(m_destructor_status)
114  {
115  case destructor_none:
117  if (m_wnd != 0)
118  {
119  DestroyWindow(m_wnd);
120  m_wnd = 0;
121  }
122  break;
124  if (m_wnd != 0) SetWindowLongPtr(m_wnd,DWLP_USER,0);
125  break;
126  default:
127  //should never trigger
128  pfc::crash();
129  break;
130  }
131  }
enum dialog_helper::dialog_modeless::@23 m_destructor_status
void crash()
Definition: other.cpp:112

Member Function Documentation

dialog_helper::dialog_modeless::__declspec ( deprecated  )

Creates the dialog window. This will call on_message with WM_INITDIALOG. To abort creation, you can call DestroyWindow() on our window; it will not delete the object but make create() return false instead. You should not delete the object from inside WM_INITDIALOG handler or anything else possibly called from create().

Returns
true on success, false on failure.
INT_PTR CALLBACK dialog_helper::dialog_modeless::DlgProc ( HWND  wnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
staticprivate

Definition at line 162 of file win32_dialog.cpp.

163  {
164  dialog_modeless * thisptr;
165  BOOL rv;
166  if (msg == WM_INITDIALOG)
167  {
168  thisptr = reinterpret_cast<dialog_modeless*>(lp);
169  thisptr->m_wnd = wnd;
170  SetWindowLongPtr(wnd,DWLP_USER,lp);
172  }
173  else thisptr = reinterpret_cast<dialog_modeless*>(GetWindowLongPtr(wnd,DWLP_USER));
174 
175  rv = thisptr ? thisptr->on_message_wrap(msg,wp,lp) : FALSE;
176 
177  if (msg == WM_DESTROY)
179 
180  if (msg == WM_DESTROY && thisptr != 0)
181  thisptr->on_window_destruction();
182 
183  return rv;
184  }
typedef BOOL(WINAPI *pPowerSetRequest_t)(__in HANDLE PowerRequest
static void g_add(HWND p_wnd)
Static helper; see add().
static void g_remove(HWND p_wnd)
Static helper; see remove().
HWND dialog_helper::dialog_modeless::get_wnd ( ) const
inlineprotected

Definition at line 80 of file win32_dialog.h.

virtual BOOL dialog_helper::dialog_modeless::on_message ( UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
protectedpure virtual

Standard windows message handler (DialogProc-style). Use get_wnd() to retrieve our dialog window handle.

BOOL dialog_helper::dialog_modeless::on_message_wrap ( UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
private

Definition at line 154 of file win32_dialog.cpp.

155  {
157  return on_message(msg,wp,lp);
158  else
159  return FALSE;
160  }
enum dialog_helper::dialog_modeless::@23 m_destructor_status
virtual BOOL on_message(UINT msg, WPARAM wp, LPARAM lp)=0
Standard windows message handler (DialogProc-style). Use get_wnd() to retrieve our dialog window hand...
void dialog_helper::dialog_modeless::on_window_destruction ( )
private

Definition at line 133 of file win32_dialog.cpp.

134  {
135  if (m_is_in_create)
136  {
137  m_wnd = 0;
138  }
139  else
140  switch(m_destructor_status)
141  {
142  case destructor_none:
144  delete this;
145  break;
147  pfc::crash();
148  break;
149  default:
150  break;
151  }
152  }
enum dialog_helper::dialog_modeless::@23 m_destructor_status
void crash()
Definition: other.cpp:112

Field Documentation

enum { ... } dialog_helper::dialog_modeless::m_destructor_status
bool dialog_helper::dialog_modeless::m_is_in_create
private

Definition at line 90 of file win32_dialog.h.

HWND dialog_helper::dialog_modeless::m_wnd
private

Definition at line 88 of file win32_dialog.h.

HWND HINSTANCE dialog_helper::dialog_modeless::p_instance = core_api::get_my_instance())

Definition at line 74 of file win32_dialog.h.

HWND dialog_helper::dialog_modeless::p_parent

Definition at line 74 of file win32_dialog.h.


The documentation for this class was generated from the following files: