diff options
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r-- | src/dialog.cpp | 61 |
1 files changed, 14 insertions, 47 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp index 9291268..96d80f9 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -18,19 +18,16 @@ // // ------------------------------------------------------------------------- // +#include "w32dlib/window.h" #include "w32dlib/dialog.h" #include "w32dlib/control.h" namespace W32DLib { -// ------------------------------------------------------------ -// -Dialog::ProcSet Dialog::m_procset; - // ------------------------------------------------------------ // -Dialog::Dialog() +Dialog::Dialog() : Window() { } @@ -58,20 +55,12 @@ void Dialog::OnClose() // ------------------------------------------------------------ // -HWND Dialog::GetHWND() -{ - return m_wnd; -} - - -// ------------------------------------------------------------ -// INT_PTR Dialog::ShowModal(HINSTANCE inst, HWND parent) { return ::DialogBoxParam(inst, MAKEINTRESOURCE(ResourceID()), parent, - &DialogProc, + &Window::WindowProc, reinterpret_cast<LPARAM>(this)); } @@ -86,9 +75,12 @@ void Dialog::Close(INT_PTR result) // ------------------------------------------------------------ // -void Dialog::SetTitle(const char *text) +void Dialog::Enable(bool enable) { - SendMessage(m_wnd,WM_SETTEXT,0,reinterpret_cast<LPARAM>(text)); + for(ControlSet::iterator i=m_cset.begin();i!=m_cset.end();++i) + { + (*i)->Enable(enable); + } } @@ -103,20 +95,16 @@ void Dialog::AddControl(Control *control) // ------------------------------------------------------------ // -BOOL Dialog::InstanceDialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) +BOOL Dialog::InstanceProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { BOOL ret=FALSE; WORD lo=LOWORD(wp); - W32DEBUGOUT("resource=" << ResourceID() << - " wnd= " << wnd << " msg=" << MsgName(msg) << - " wp=" << wp << " lp=" << lp); - switch(msg) { case WM_INITDIALOG: + Window::InstanceProc(wnd,msg,wp,lp); m_wnd=wnd; - m_procset[wnd]=this; for(ControlSet::iterator i=m_cset.begin();i!=m_cset.end();++i) { @@ -130,7 +118,10 @@ BOOL Dialog::InstanceDialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) case WM_CLOSE: OnClose(); - m_procset.erase(wnd); + break; + + case WM_DESTROY: + ret=Window::InstanceProc(wnd,msg,wp,lp); break; default: @@ -149,30 +140,6 @@ BOOL Dialog::InstanceDialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) return ret; } -// ------------------------------------------------------------ -// - -BOOL CALLBACK Dialog::DialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) -{ - if (msg==WM_INITDIALOG) - { - Dialog *dlg=reinterpret_cast<Dialog*>(lp); - return dlg->InstanceDialogProc(wnd,msg,wp,lp); - } - else - { - if (m_procset.count(wnd)) - { - return m_procset[wnd]->InstanceDialogProc(wnd,msg,wp,lp); - } - else - { - return FALSE; - } - } -} - - }; // namespace w32dlib // END OF FILE |