summaryrefslogtreecommitdiff
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-03-24 02:09:13 +0000
committerIan C <ianc@noddybox.co.uk>2005-03-24 02:09:13 +0000
commit2d704117349864405f1c749b40bdd9d6f819ca03 (patch)
treef3b6c215db178fd94bd977ffd7c7961a243e6ee4 /src/dialog.cpp
parent5a11b5f4b59c46e919989a0fdd05d81ba5ac9347 (diff)
Code updates (first working version)
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index e84e22d..9291268 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -68,10 +68,11 @@ HWND Dialog::GetHWND()
//
INT_PTR Dialog::ShowModal(HINSTANCE inst, HWND parent)
{
- return ::DialogBox(inst,
- MAKEINTRESOURCE(ResourceID()),
- NULL,
- &this->DialogProc);
+ return ::DialogBoxParam(inst,
+ MAKEINTRESOURCE(ResourceID()),
+ parent,
+ &DialogProc,
+ reinterpret_cast<LPARAM>(this));
}
@@ -85,6 +86,14 @@ void Dialog::Close(INT_PTR result)
// ------------------------------------------------------------
//
+void Dialog::SetTitle(const char *text)
+{
+ SendMessage(m_wnd,WM_SETTEXT,0,reinterpret_cast<LPARAM>(text));
+}
+
+
+// ------------------------------------------------------------
+//
void Dialog::AddControl(Control *control)
{
m_cset.push_back(control);
@@ -99,12 +108,24 @@ BOOL Dialog::InstanceDialogProc(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:
m_wnd=wnd;
m_procset[wnd]=this;
+
+ for(ControlSet::iterator i=m_cset.begin();i!=m_cset.end();++i)
+ {
+ W32DEBUGOUT(MsgName(msg) << " for resource " << lo);
+ (*i)->ProcessMessage(msg,wp,lp);
+ }
+
OnInit();
+ ret=TRUE;
break;
case WM_CLOSE:
@@ -112,19 +133,17 @@ BOOL Dialog::InstanceDialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
m_procset.erase(wnd);
break;
- case WM_COMMAND:
+ default:
for(ControlSet::iterator i=m_cset.begin();i!=m_cset.end();++i)
{
if (lo==(*i)->ResourceID())
{
+ W32DEBUGOUT(MsgName(msg) << " for resource " << lo);
ret=(*i)->ProcessMessage(msg,wp,lp);
break;
}
}
break;
-
- default:
- break;
}
return ret;
@@ -135,13 +154,21 @@ BOOL Dialog::InstanceDialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
BOOL CALLBACK Dialog::DialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
{
- if (m_procset.count(wnd))
+ if (msg==WM_INITDIALOG)
{
- return m_procset[wnd]->InstanceDialogProc(wnd,msg,wp,lp);
+ Dialog *dlg=reinterpret_cast<Dialog*>(lp);
+ return dlg->InstanceDialogProc(wnd,msg,wp,lp);
}
else
{
- return FALSE;
+ if (m_procset.count(wnd))
+ {
+ return m_procset[wnd]->InstanceDialogProc(wnd,msg,wp,lp);
+ }
+ else
+ {
+ return FALSE;
+ }
}
}