12 if (msg==WM_INITDIALOG)
14 p_this =
reinterpret_cast<dialog*
>(lp);
16 SetWindowLongPtr(wnd,DWLP_USER,lp);
20 else p_this =
reinterpret_cast<dialog*
>(GetWindowLongPtr(wnd,DWLP_USER));
22 rv = p_this ? p_this->
on_message(msg,wp,lp) : FALSE;
24 if (msg==WM_DESTROY && p_this)
26 SetWindowLongPtr(wnd,DWLP_USER,0);
34 int dialog::run_modal(
unsigned id,HWND
parent)
37 if (
wnd != 0)
return -1;
41 HWND dialog::run_modeless(
unsigned id,HWND parent)
44 if (
wnd != 0)
return 0;
64 int dialog_modal::run(
unsigned p_id,HWND p_parent,HINSTANCE p_instance)
71 status = (int)DialogBoxParam(p_instance,MAKEINTRESOURCE(p_id),p_parent,
DlgProc,
reinterpret_cast<LPARAM
>(
this));
80 EndDialog(m_wnd,p_code);
87 if (msg==WM_INITDIALOG)
91 SetWindowLongPtr(wnd,DWLP_USER,lp);
95 else _this =
reinterpret_cast<dialog_modal*
>(GetWindowLongPtr(wnd,DWLP_USER));
97 assert(_this == 0 || _this->
m_wnd == wnd);
99 return _this ? _this->
on_message(msg,wp,lp) : FALSE;
104 assert(!m_is_in_create);
105 if (m_is_in_create)
return false;
107 if (CreateDialogParam(p_instance,MAKEINTRESOURCE(p_id),p_parent,
DlgProc,reinterpret_cast<LPARAM>(
this)) == 0)
return false;
112 assert(!m_is_in_create);
113 switch(m_destructor_status)
115 case destructor_none:
116 m_destructor_status = destructor_normal;
119 DestroyWindow(m_wnd);
123 case destructor_fromwindow:
124 if (m_wnd != 0) SetWindowLongPtr(m_wnd,DWLP_USER,0);
140 switch(m_destructor_status)
142 case destructor_none:
143 m_destructor_status = destructor_fromwindow;
146 case destructor_fromwindow:
156 if (m_destructor_status == destructor_none)
166 if (msg == WM_INITDIALOG)
170 SetWindowLongPtr(wnd,DWLP_USER,lp);
173 else thisptr =
reinterpret_cast<dialog_modeless*
>(GetWindowLongPtr(wnd,DWLP_USER));
177 if (msg == WM_DESTROY)
180 if (msg == WM_DESTROY && thisptr != 0)
203 WIN32_OP( CreateDialogParam(p_instance,MAKEINTRESOURCE(p_id),p_parent,
DlgProc,reinterpret_cast<LPARAM>(
this)) != NULL );
214 if (is_window_being_destroyed)
217 DestroyWindow(
m_wnd);
225 if (msg == WM_INITDIALOG)
229 thisptr->
m_wnd = wnd;
230 SetWindowLongPtr(wnd,DWLP_USER,lp);
231 if (GetWindowLong(wnd,GWL_STYLE) & WS_POPUP) {
235 else thisptr =
reinterpret_cast<dialog_modeless_v2*
>(GetWindowLongPtr(wnd,DWLP_USER));
239 if (msg == WM_DESTROY)
252 SetWindowLongPtr(
m_wnd,DWLP_USER,0);
262 if (msg == WM_DESTROY)
274 if (msg == WM_INITDIALOG)
return m_stealfocus ? TRUE : FALSE;
286 int uDialogBox(UINT
id,HWND parent,DLGPROC proc,LPARAM param)
void end_dialog(int p_code)
static INT_PTR CALLBACK DlgProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
void initialize(HWND p_wnd)
Initializes the scope with specified window handle.
typedef BOOL(WINAPI *pPowerSetRequest_t)(__in HANDLE PowerRequest
HWND uCreateDialog(UINT id, HWND parent, DLGPROC proc, LPARAM param)
Wrapper (provided mainly for old code), simplifies parameters compared to standard CreateDialog() by ...
BOOL on_message_wrap(UINT msg, WPARAM wp, LPARAM lp)
void on_window_destruction()
This class is meant to be instantiated on-stack, as a local variable. Using new/delete operators inst...
static INT_PTR CALLBACK DlgProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
static void g_add(HWND p_wnd)
Static helper; see add().
static INT_PTR CALLBACK DlgProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
int uDialogBox(UINT id, HWND parent, DLGPROC proc, LPARAM param)
Wrapper (provided mainly for old code), simplifies parameters compared to standard DialogBox() by usi...
void end_dialog(int code)
static INT_PTR CALLBACK DlgProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
modal_dialog_scope m_modal_scope
enum dialog_helper::dialog_modeless_v2::@24 m_status
dialog_modeless_v2(const dialog_modeless_v2 &)
virtual BOOL on_message(UINT msg, WPARAM wp, LPARAM lp)=0
modal_dialog_scope m_modal_scope
virtual BOOL on_message(UINT msg, WPARAM wp, LPARAM lp)
void create(pfc::string_formatter &p_out, const t_entry_list &p_data)
virtual ~dialog_modeless_v2()
static void g_remove(HWND p_wnd)
Static helper; see remove().
HINSTANCE get_my_instance()
Retrieves HINSTANCE of calling DLL.
This class is meant to be used with new/delete operators only. Destroying the window - outside create...
BOOL on_message_internal(UINT msg, WPARAM wp, LPARAM lp)
virtual BOOL on_message(UINT msg, WPARAM wp, LPARAM lp)=0
virtual ~dialog_modeless()