From 72f0c86eb3ecdda4cab53213302fad645bc571f0 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 25 Mar 2005 01:23:52 +0000 Subject: Cleaned up a bit by adding a base Window class. --- src/dialog.cpp | 61 ++++++++++++++-------------------------------------------- 1 file changed, 14 insertions(+), 47 deletions(-) (limited to 'src/dialog.cpp') 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() { } @@ -56,14 +53,6 @@ void Dialog::OnClose() } -// ------------------------------------------------------------ -// -HWND Dialog::GetHWND() -{ - return m_wnd; -} - - // ------------------------------------------------------------ // INT_PTR Dialog::ShowModal(HINSTANCE inst, HWND parent) @@ -71,7 +60,7 @@ INT_PTR Dialog::ShowModal(HINSTANCE inst, HWND parent) return ::DialogBoxParam(inst, MAKEINTRESOURCE(ResourceID()), parent, - &DialogProc, + &Window::WindowProc, reinterpret_cast(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(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(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 -- cgit v1.2.3