diff options
-rw-r--r-- | src/GNUmakefile | 7 | ||||
-rw-r--r-- | src/control.cpp | 22 | ||||
-rw-r--r-- | src/debug.cpp | 231 | ||||
-rw-r--r-- | src/dialog.cpp | 49 | ||||
-rw-r--r-- | src/static.cpp | 43 | ||||
-rw-r--r-- | src/test/dialog.rc | 2 | ||||
-rw-r--r-- | src/test/w32dtst.cpp | 44 | ||||
-rw-r--r-- | src/w32dlib/base.h | 30 | ||||
-rw-r--r-- | src/w32dlib/control.h | 20 | ||||
-rw-r--r-- | src/w32dlib/dialog.h | 9 | ||||
-rw-r--r-- | src/w32dlib/static.h | 6 | ||||
-rw-r--r-- | src/w32dlib/w32dlib.h | 12 |
12 files changed, 449 insertions, 26 deletions
diff --git a/src/GNUmakefile b/src/GNUmakefile index 9891e01..1a4c078 100644 --- a/src/GNUmakefile +++ b/src/GNUmakefile @@ -18,7 +18,7 @@ # # ------------------------------------------------------------------------- # -# $Id: GNUmakefile,v 1.2 2005-03-24 00:07:40 ianc Exp $ +# $Id: GNUmakefile,v 1.3 2005-03-24 02:09:12 ianc Exp $ # @@ -37,7 +37,7 @@ CREATECONF = 1 # Uncomment this if you want a debug build # -DEBUG = -g +DEBUG = -g -DW32D_DEBUG # # **************************************** END OF CONFIGURATION @@ -54,7 +54,8 @@ SOURCES = autocheck.cpp \ control.cpp \ dialog.cpp \ text.cpp \ - static.cpp + static.cpp \ + debug.cpp HEADERS = w32dlib/*.h diff --git a/src/control.cpp b/src/control.cpp index b824cca..392c72e 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -54,6 +54,7 @@ int Control::ResourceID() // void Control::SetText(const char *text) { + SetDlgItemText(m_parent->GetHWND(),m_resid,text); } @@ -77,8 +78,29 @@ std::string Control::GetText(int maxlen) // ------------------------------------------------------------ // +HWND Control::GetHWND() +{ + return m_wnd; +} + + +// ------------------------------------------------------------ +// +void Control::Enable(bool enable) +{ + EnableWindow(m_wnd,enable); +} + + +// ------------------------------------------------------------ +// BOOL Control::ProcessMessage(UINT msg, WPARAM wp, LPARAM lp) { + if (msg==WM_INITDIALOG) + { + m_wnd=GetDlgItem(m_parent->GetHWND(),m_resid); + } + if (m_cblist.count(msg)>0) { CallbackDetails details=m_cblist[msg]; diff --git a/src/debug.cpp b/src/debug.cpp new file mode 100644 index 0000000..593069f --- /dev/null +++ b/src/debug.cpp @@ -0,0 +1,231 @@ +// w32dlib - Win32 Control Helpers +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +#include "w32dlib/base.h" + +namespace W32DLib +{ + +#ifdef W32D_DEBUG + +const char *MsgName(UINT msg) +{ + switch(msg) + { + case WM_APP: return "WM_APP"; + case WM_ACTIVATE: return "WM_ACTIVATE"; + case WM_ACTIVATEAPP: return "WM_ACTIVATEAPP"; + case WM_AFXFIRST: return "WM_AFXFIRST"; + case WM_AFXLAST: return "WM_AFXLAST"; + case WM_ASKCBFORMATNAME: return "WM_ASKCBFORMATNAME"; + case WM_CANCELJOURNAL: return "WM_CANCELJOURNAL"; + case WM_CANCELMODE: return "WM_CANCELMODE"; + case WM_CAPTURECHANGED: return "WM_CAPTURECHANGED"; + case WM_CHANGECBCHAIN: return "WM_CHANGECBCHAIN"; + case WM_CHAR: return "WM_CHAR"; + case WM_CHARTOITEM: return "WM_CHARTOITEM"; + case WM_CHILDACTIVATE: return "WM_CHILDACTIVATE"; + case WM_CLEAR: return "WM_CLEAR"; + case WM_CLOSE: return "WM_CLOSE"; + case WM_COMMAND: return "WM_COMMAND"; + case WM_COMMNOTIFY: return "WM_COMMNOTIFY"; + case WM_COMPACTING: return "WM_COMPACTING"; + case WM_COMPAREITEM: return "WM_COMPAREITEM"; + case WM_CONTEXTMENU: return "WM_CONTEXTMENU"; + case WM_COPY: return "WM_COPY"; + case WM_COPYDATA: return "WM_COPYDATA"; + case WM_CREATE: return "WM_CREATE"; + case WM_CTLCOLORBTN: return "WM_CTLCOLORBTN"; + case WM_CTLCOLORDLG: return "WM_CTLCOLORDLG"; + case WM_CTLCOLOREDIT: return "WM_CTLCOLOREDIT"; + case WM_CTLCOLORLISTBOX: return "WM_CTLCOLORLISTBOX"; + case WM_CTLCOLORMSGBOX: return "WM_CTLCOLORMSGBOX"; + case WM_CTLCOLORSCROLLBAR: return "WM_CTLCOLORSCROLLBAR"; + case WM_CTLCOLORSTATIC: return "WM_CTLCOLORSTATIC"; + case WM_CUT: return "WM_CUT"; + case WM_DEADCHAR: return "WM_DEADCHAR"; + case WM_DELETEITEM: return "WM_DELETEITEM"; + case WM_DESTROY: return "WM_DESTROY"; + case WM_DESTROYCLIPBOARD: return "WM_DESTROYCLIPBOARD"; + case WM_DEVICECHANGE: return "WM_DEVICECHANGE"; + case WM_DEVMODECHANGE: return "WM_DEVMODECHANGE"; + case WM_DISPLAYCHANGE: return "WM_DISPLAYCHANGE"; + case WM_DRAWCLIPBOARD: return "WM_DRAWCLIPBOARD"; + case WM_DRAWITEM: return "WM_DRAWITEM"; + case WM_DROPFILES: return "WM_DROPFILES"; + case WM_ENABLE: return "WM_ENABLE"; + case WM_ENDSESSION: return "WM_ENDSESSION"; + case WM_ENTERIDLE: return "WM_ENTERIDLE"; + case WM_ENTERMENULOOP: return "WM_ENTERMENULOOP"; + case WM_ENTERSIZEMOVE: return "WM_ENTERSIZEMOVE"; + case WM_ERASEBKGND: return "WM_ERASEBKGND"; + case WM_EXITMENULOOP: return "WM_EXITMENULOOP"; + case WM_EXITSIZEMOVE: return "WM_EXITSIZEMOVE"; + case WM_FONTCHANGE: return "WM_FONTCHANGE"; + case WM_GETDLGCODE: return "WM_GETDLGCODE"; + case WM_GETFONT: return "WM_GETFONT"; + case WM_GETHOTKEY: return "WM_GETHOTKEY"; + case WM_GETICON: return "WM_GETICON"; + case WM_GETMINMAXINFO: return "WM_GETMINMAXINFO"; + case WM_GETTEXT: return "WM_GETTEXT"; + case WM_GETTEXTLENGTH: return "WM_GETTEXTLENGTH"; + case WM_HANDHELDFIRST: return "WM_HANDHELDFIRST"; + case WM_HANDHELDLAST: return "WM_HANDHELDLAST"; + case WM_HELP: return "WM_HELP"; + case WM_HOTKEY: return "WM_HOTKEY"; + case WM_HSCROLL: return "WM_HSCROLL"; + case WM_HSCROLLCLIPBOARD: return "WM_HSCROLLCLIPBOARD"; + case WM_ICONERASEBKGND: return "WM_ICONERASEBKGND"; + case WM_INITDIALOG: return "WM_INITDIALOG"; + case WM_INITMENU: return "WM_INITMENU"; + case WM_INITMENUPOPUP: return "WM_INITMENUPOPUP"; + case WM_INPUTLANGCHANGE: return "WM_INPUTLANGCHANGE"; + case WM_INPUTLANGCHANGEREQUEST: return "WM_INPUTLANGCHANGEREQUEST"; + case WM_KEYDOWN: return "WM_KEYDOWN"; + case WM_KEYUP: return "WM_KEYUP"; + case WM_KILLFOCUS: return "WM_KILLFOCUS"; + case WM_MDIACTIVATE: return "WM_MDIACTIVATE"; + case WM_MDICASCADE: return "WM_MDICASCADE"; + case WM_MDICREATE: return "WM_MDICREATE"; + case WM_MDIDESTROY: return "WM_MDIDESTROY"; + case WM_MDIGETACTIVE: return "WM_MDIGETACTIVE"; + case WM_MDIICONARRANGE: return "WM_MDIICONARRANGE"; + case WM_MDIMAXIMIZE: return "WM_MDIMAXIMIZE"; + case WM_MDINEXT: return "WM_MDINEXT"; + case WM_MDIREFRESHMENU: return "WM_MDIREFRESHMENU"; + case WM_MDIRESTORE: return "WM_MDIRESTORE"; + case WM_MDISETMENU: return "WM_MDISETMENU"; + case WM_MDITILE: return "WM_MDITILE"; + case WM_MEASUREITEM: return "WM_MEASUREITEM"; + //case WM_MENURBUTTONUP: return "WM_MENURBUTTONUP"; + case WM_MENUCHAR: return "WM_MENUCHAR"; + case WM_MENUSELECT: return "WM_MENUSELECT"; + case WM_NEXTMENU: return "WM_NEXTMENU"; + case WM_MOVE: return "WM_MOVE"; + case WM_MOVING: return "WM_MOVING"; + case WM_NCACTIVATE: return "WM_NCACTIVATE"; + case WM_NCCALCSIZE: return "WM_NCCALCSIZE"; + case WM_NCCREATE: return "WM_NCCREATE"; + case WM_NCDESTROY: return "WM_NCDESTROY"; + case WM_NCHITTEST: return "WM_NCHITTEST"; + case WM_NCLBUTTONDBLCLK: return "WM_NCLBUTTONDBLCLK"; + case WM_NCLBUTTONDOWN: return "WM_NCLBUTTONDOWN"; + case WM_NCLBUTTONUP: return "WM_NCLBUTTONUP"; + case WM_NCMBUTTONDBLCLK: return "WM_NCMBUTTONDBLCLK"; + case WM_NCMBUTTONDOWN: return "WM_NCMBUTTONDOWN"; + case WM_NCMBUTTONUP: return "WM_NCMBUTTONUP"; + case WM_NCMOUSEMOVE: return "WM_NCMOUSEMOVE"; + case WM_NCPAINT: return "WM_NCPAINT"; + case WM_NCRBUTTONDBLCLK: return "WM_NCRBUTTONDBLCLK"; + case WM_NCRBUTTONDOWN: return "WM_NCRBUTTONDOWN"; + case WM_NCRBUTTONUP: return "WM_NCRBUTTONUP"; + case WM_NEXTDLGCTL: return "WM_NEXTDLGCTL"; + case WM_NOTIFY: return "WM_NOTIFY"; + case WM_NOTIFYFORMAT: return "WM_NOTIFYFORMAT"; + case WM_NULL: return "WM_NULL"; + case WM_PAINT: return "WM_PAINT"; + case WM_PAINTCLIPBOARD: return "WM_PAINTCLIPBOARD"; + case WM_PAINTICON: return "WM_PAINTICON"; + case WM_PALETTECHANGED: return "WM_PALETTECHANGED"; + case WM_PALETTEISCHANGING: return "WM_PALETTEISCHANGING"; + case WM_PARENTNOTIFY: return "WM_PARENTNOTIFY"; + case WM_PASTE: return "WM_PASTE"; + case WM_PENWINFIRST: return "WM_PENWINFIRST"; + case WM_PENWINLAST: return "WM_PENWINLAST"; + case WM_POWER: return "WM_POWER"; + case WM_POWERBROADCAST: return "WM_POWERBROADCAST"; + case WM_PRINT: return "WM_PRINT"; + case WM_PRINTCLIENT: return "WM_PRINTCLIENT"; + case WM_QUERYDRAGICON: return "WM_QUERYDRAGICON"; + case WM_QUERYENDSESSION: return "WM_QUERYENDSESSION"; + case WM_QUERYNEWPALETTE: return "WM_QUERYNEWPALETTE"; + case WM_QUERYOPEN: return "WM_QUERYOPEN"; + case WM_QUEUESYNC: return "WM_QUEUESYNC"; + case WM_QUIT: return "WM_QUIT"; + case WM_RENDERALLFORMATS: return "WM_RENDERALLFORMATS"; + case WM_RENDERFORMAT: return "WM_RENDERFORMAT"; + case WM_SETCURSOR: return "WM_SETCURSOR"; + case WM_SETFOCUS: return "WM_SETFOCUS"; + case WM_SETFONT: return "WM_SETFONT"; + case WM_SETHOTKEY: return "WM_SETHOTKEY"; + case WM_SETICON: return "WM_SETICON"; + case WM_SETREDRAW: return "WM_SETREDRAW"; + case WM_SETTEXT: return "WM_SETTEXT"; + case WM_SETTINGCHANGE: return "WM_SETTINGCHANGE"; + case WM_SHOWWINDOW: return "WM_SHOWWINDOW"; + case WM_SIZE: return "WM_SIZE"; + case WM_SIZECLIPBOARD: return "WM_SIZECLIPBOARD"; + case WM_SIZING: return "WM_SIZING"; + case WM_SPOOLERSTATUS: return "WM_SPOOLERSTATUS"; + case WM_STYLECHANGED: return "WM_STYLECHANGED"; + case WM_STYLECHANGING: return "WM_STYLECHANGING"; + case WM_SYSCHAR: return "WM_SYSCHAR"; + case WM_SYSCOLORCHANGE: return "WM_SYSCOLORCHANGE"; + case WM_SYSCOMMAND: return "WM_SYSCOMMAND"; + case WM_SYSDEADCHAR: return "WM_SYSDEADCHAR"; + case WM_SYSKEYDOWN: return "WM_SYSKEYDOWN"; + case WM_SYSKEYUP: return "WM_SYSKEYUP"; + case WM_TCARD: return "WM_TCARD"; + case WM_TIMECHANGE: return "WM_TIMECHANGE"; + case WM_TIMER: return "WM_TIMER"; + case WM_UNDO: return "WM_UNDO"; + case WM_USER: return "WM_USER"; + case WM_USERCHANGED: return "WM_USERCHANGED"; + case WM_VKEYTOITEM: return "WM_VKEYTOITEM"; + case WM_VSCROLL: return "WM_VSCROLL"; + case WM_VSCROLLCLIPBOARD: return "WM_VSCROLLCLIPBOARD"; + case WM_WINDOWPOSCHANGED: return "WM_WINDOWPOSCHANGED"; + case WM_WINDOWPOSCHANGING: return "WM_WINDOWPOSCHANGING"; + //case WM_WININICHANGE: return "WM_WININICHANGE"; + //case WM_KEYFIRST: return "WM_KEYFIRST"; + //case WM_KEYLAST: return "WM_KEYLAST"; + case WM_SYNCPAINT: return "WM_SYNCPAINT"; + case WM_MOUSEACTIVATE: return "WM_MOUSEACTIVATE"; + case WM_MOUSEMOVE: return "WM_MOUSEMOVE"; + case WM_LBUTTONDOWN: return "WM_LBUTTONDOWN"; + case WM_LBUTTONUP: return "WM_LBUTTONUP"; + case WM_LBUTTONDBLCLK: return "WM_LBUTTONDBLCLK"; + case WM_RBUTTONDOWN: return "WM_RBUTTONDOWN"; + case WM_RBUTTONUP: return "WM_RBUTTONUP"; + case WM_RBUTTONDBLCLK: return "WM_RBUTTONDBLCLK"; + case WM_MBUTTONDOWN: return "WM_MBUTTONDOWN"; + case WM_MBUTTONUP: return "WM_MBUTTONUP"; + case WM_MBUTTONDBLCLK: return "WM_MBUTTONDBLCLK"; + case WM_MOUSEWHEEL: return "WM_MOUSEWHEEL"; + //case WM_MOUSEFIRST: return "WM_MOUSEFIRST"; + //case WM_MOUSELAST: return "WM_MOUSELAST"; + case WM_MOUSEHOVER: return "WM_MOUSEHOVER"; + case WM_MOUSELEAVE: return "WM_MOUSELEAVE"; + default: return "UNKNOWN"; + } +} + +#else + +const char *MsgName(UINT msg) +{ + return "Not available"; +} + +#endif // W32D_DEBUG + +}; // namespace W32DLib + +// END OF FILE 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; + } } } diff --git a/src/static.cpp b/src/static.cpp new file mode 100644 index 0000000..0dc10e3 --- /dev/null +++ b/src/static.cpp @@ -0,0 +1,43 @@ +// w32dlib - Win32 Control Helpers +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +#include "w32dlib/static.h" + +namespace W32DLib +{ + +// ------------------------------------------------------------ +// +StaticText::StaticText(Dialog *parent, int resource_id) : + Control(parent,resource_id) +{ +} + + +// ------------------------------------------------------------ +// +StaticText::~StaticText() +{ +} + + +}; // namespace W32DLib + +// END OF FILE diff --git a/src/test/dialog.rc b/src/test/dialog.rc index 5655da6..cae59bb 100644 --- a/src/test/dialog.rc +++ b/src/test/dialog.rc @@ -6,7 +6,7 @@ TESTDLG DIALOG 10, 10, 240, 100 "Test Dialog" FONT 8,"MS Shell Dlg" { - LTEXT "Text:", IDSTATIC1, 10, 10, 50, 12 + LTEXT "Text:", IDSTATIC1, 10, 10, 35, 12 EDITTEXT IDTEXT, 50, 10, 100, 12 PUSHBUTTON "Try Me!", IDBUTTON, 10, 30, 150, 18 AUTOCHECKBOX "Check", IDCHECK, 10,50,150,18 diff --git a/src/test/w32dtst.cpp b/src/test/w32dtst.cpp index ca796db..984df33 100644 --- a/src/test/w32dtst.cpp +++ b/src/test/w32dtst.cpp @@ -27,14 +27,23 @@ class Test : public W32DLib::Dialog { public: - Test() : //m_static(this,IDSTATIC1), + Test() : m_static(this,IDSTATIC1), m_text(this,IDTEXT), m_check(this,IDCHECK), m_button(this,IDBUTTON), m_quit(this,IDQUIT) { + AddControl(&m_text); + AddControl(&m_check); + AddControl(&m_button); + AddControl(&m_quit); + + m_button.OnPress + (this,static_cast<W32DLib::W32DLibCallback>(&Test::OnButton)); m_quit.OnPress (this,static_cast<W32DLib::W32DLibCallback>(&Test::OnQuit)); + m_check.OnPress + (this,static_cast<W32DLib::W32DLibCallback>(&Test::OnCheck)); } virtual ~Test() @@ -46,8 +55,16 @@ public: return TESTDLG; } + virtual void OnInit() + { + std::cout << "OnInit()" << std::endl; + m_text.SetText("Hello"); + m_check.SetState(W32DLib::AutoCheck::eIndeterminate); + m_quit.Enable(true); + } + private: - //W32DLib::StaticText m_static; + W32DLib::StaticText m_static; W32DLib::Text m_text; W32DLib::AutoCheck m_check; W32DLib::Button m_button; @@ -59,6 +76,29 @@ private: Dialog::Close(IDOK); return TRUE; } + + BOOL OnButton(UINT msg, WPARAM wp, LPARAM lp) + { + std::string txt=m_text.GetText(512); + + std::cout << "Called OnButton()" << std::endl; + std::cout << "text=" << txt << std::endl; + std::cout << "check=" << m_check.GetState() << std::endl; + m_static.SetText(txt.c_str()); + SetTitle((txt+" [Title]").c_str()); + return TRUE; + } + + BOOL OnCheck(UINT msg, WPARAM wp, LPARAM lp) + { + W32DLib::AutoCheck::EState state=m_check.GetState(); + + std::cout << "Called OnCheck() - state " << state << std::endl; + + m_quit.Enable(state==W32DLib::AutoCheck::eChecked); + + return TRUE; + } }; int WINAPI WinMain (HINSTANCE hInstance, diff --git a/src/w32dlib/base.h b/src/w32dlib/base.h index 0d6f453..fbae2e4 100644 --- a/src/w32dlib/base.h +++ b/src/w32dlib/base.h @@ -27,6 +27,11 @@ #include <map> #include <string> +#ifdef W32D_DEBUG +#include <iostream> +#include <sstream> +#endif + namespace W32DLib { class Dialog; @@ -50,6 +55,31 @@ typedef BOOL (W32DLibCallbackInterface::*W32DLibCallback) (UINT msg, WPARAM wp, LPARAM lp); +#ifdef W32D_DEBUG + +/// \brief Debug macro for debug builds +/// +#define W32DEBUGOUT(x) \ + do \ + { \ + std::ostringstream s; \ + s << __FUNCTION__ << "(" << __FILE__ << "): " << x; \ + OutputDebugString(s.str().c_str()); \ + } while(0) + +/// \brief A table of Windows message names +/// +const char *MsgName(UINT msg); + +#else + +/// \brief Debug macro for non-debug builds (does nothing). +/// +#define W32DEBUGOUT(x) while(false) + +#endif + + }; #endif // W32DLIB_BASE_H diff --git a/src/w32dlib/control.h b/src/w32dlib/control.h index 7aef528..85106a9 100644 --- a/src/w32dlib/control.h +++ b/src/w32dlib/control.h @@ -63,6 +63,22 @@ namespace W32DLib /// std::string GetText(int maxlen); + /// \brief Enables or disables the control. + /// + /// Calling this when the dialog is not on display is undefined. + /// + /// \param enable Set true to enable, false to disable. + /// + void Enable(bool enable); + + /// \brief Gets the control's window handle + /// + /// Calling this when the dialog is not on display is undefined. + /// + /// \return The window handle + /// + HWND GetHWND(); + /// \brief Processes a windows event. /// /// \param msg The Windows event parameters @@ -94,6 +110,10 @@ namespace W32DLib /// int m_resid; + /// \brief Filled in when the WM_INITDIALOG message is recieved. + /// + HWND m_wnd; + private: struct CallbackDetails diff --git a/src/w32dlib/dialog.h b/src/w32dlib/dialog.h index cac003e..bbc1d51 100644 --- a/src/w32dlib/dialog.h +++ b/src/w32dlib/dialog.h @@ -88,6 +88,15 @@ namespace W32DLib /// void Close(INT_PTR result); + /// \brief Sets the title in a dialog box + /// + /// This call will only work while the dialog is on display. + /// The behaviour is undefined if it is called at any other time. + /// + /// \param text The title + /// + void SetTitle(const char *text); + protected: /// \brief Adds a control to the dialog. diff --git a/src/w32dlib/static.h b/src/w32dlib/static.h index 3eca8af..a0c4951 100644 --- a/src/w32dlib/static.h +++ b/src/w32dlib/static.h @@ -18,9 +18,9 @@ // // ------------------------------------------------------------------------- // -#ifndef W32DLIB_TEXT_H +#ifndef W32DLIB_STATIC_H -#define W32DLIB_TEXT_H "$Id$" +#define W32DLIB_STATIC_H "$Id$" #include "w32dlib/base.h" #include "w32dlib/control.h" @@ -53,7 +53,7 @@ namespace W32DLib }; // namespace w32dlib -#endif // W32DLIB_TEXT_H +#endif // W32DLIB_STATIC_H // END OF FILE diff --git a/src/w32dlib/w32dlib.h b/src/w32dlib/w32dlib.h index a295226..9f9dabb 100644 --- a/src/w32dlib/w32dlib.h +++ b/src/w32dlib/w32dlib.h @@ -22,12 +22,12 @@ #define W32DLIB_H "$Id$" -#include "w32dlib/dialog.h" -#include "w32dlib/control.h" -#include "w32dlib/button.h" -#include "w32dlib/text.h" -#include "w32dlib/static.h" -#include "w32dlib/autocheck.h" +#include <w32dlib/dialog.h> +#include <w32dlib/control.h> +#include <w32dlib/button.h> +#include <w32dlib/text.h> +#include <w32dlib/static.h> +#include <w32dlib/autocheck.h> #endif // W32DLIB_H |