├── .gitattributes ├── .gitignore ├── Accel.cpp ├── Accel.hpp ├── App.cpp ├── App.hpp ├── AppConfig.cpp ├── AppConfig.hpp ├── AutoBool.hpp ├── AutoCom.hpp ├── AutoThreadLock.hpp ├── Bitmap.cpp ├── Bitmap.hpp ├── Brush.cpp ├── Brush.hpp ├── Buffer.cpp ├── Buffer.hpp ├── BusyCursor.cpp ├── BusyCursor.hpp ├── Button.cpp ├── Button.hpp ├── CheckBox.cpp ├── CheckBox.hpp ├── CheckBoxList.cpp ├── CheckBoxList.hpp ├── Clipboard.cpp ├── Clipboard.hpp ├── CmdBmp.cpp ├── CmdBmp.hpp ├── CmdBtn.cpp ├── CmdBtn.hpp ├── CmdCtrl.cpp ├── CmdCtrl.hpp ├── ComCtl32.cpp ├── ComCtl32.hpp ├── ComException.cpp ├── ComException.hpp ├── ComPtr.hpp ├── ComStr.cpp ├── ComStr.hpp ├── ComboBox.cpp ├── ComboBox.hpp ├── Common.hpp ├── CommonRsc.h ├── CommonUI.hpp ├── ConsoleApp.cpp ├── ConsoleApp.hpp ├── ConsoleCmd.cpp ├── ConsoleCmd.hpp ├── ContextMenu.cpp ├── ContextMenu.hpp ├── CriticalSection.cpp ├── CriticalSection.hpp ├── CtrlWnd.cpp ├── CtrlWnd.hpp ├── Cursor.cpp ├── Cursor.hpp ├── DC.cpp ├── DC.hpp ├── Date.cpp ├── Date.hpp ├── DateSpan.hpp ├── DateTime.cpp ├── DateTime.hpp ├── DateTimePicker.cpp ├── DateTimePicker.hpp ├── DecimalBox.cpp ├── DecimalBox.hpp ├── DevNotes.txt ├── Dialog.cpp ├── Dialog.hpp ├── DlgFrame.cpp ├── DlgFrame.hpp ├── Dll.cpp ├── Dll.hpp ├── DllMain.cpp ├── DllMain.hpp ├── Doc.cpp ├── Doc.hpp ├── Doxygen.cfg ├── EditBox.cpp ├── EditBox.hpp ├── Event.hpp ├── Exception.cpp ├── Exception.hpp ├── ExternalCmdController.cpp ├── ExternalCmdController.hpp ├── File.cpp ├── File.hpp ├── FileException.cpp ├── FileException.hpp ├── FolderIterator.cpp ├── FolderIterator.hpp ├── Font.cpp ├── Font.hpp ├── FrameMenu.cpp ├── FrameMenu.hpp ├── FrameWnd.cpp ├── FrameWnd.hpp ├── HelpFile.hpp ├── HintBar.cpp ├── HintBar.hpp ├── IAppConfigReader.hpp ├── IAppConfigWriter.hpp ├── ICmdController.hpp ├── ICommandWnd.hpp ├── IConfigProvider.hpp ├── IFacePtr.hpp ├── IFaceTraits.hpp ├── IInputStream.hpp ├── IMsgFilter.hpp ├── IMsgThread.hpp ├── IOutputStream.hpp ├── IStreamBase.hpp ├── IThreadLock.hpp ├── IUiCommand.hpp ├── Icon.cpp ├── Icon.hpp ├── IconCtrl.cpp ├── IconCtrl.hpp ├── ImageList.cpp ├── ImageList.hpp ├── IniFile.cpp ├── IniFile.hpp ├── IniFileCfgProvider.cpp ├── IniFileCfgProvider.hpp ├── LICENSE.txt ├── Label.cpp ├── Label.hpp ├── Library.cpp ├── Library.hpp ├── ListBox.cpp ├── ListBox.hpp ├── ListView.cpp ├── ListView.hpp ├── LogFont.cpp ├── LogFont.hpp ├── MRUList.cpp ├── MRUList.hpp ├── MainDlg.cpp ├── MainDlg.hpp ├── MainThread.cpp ├── MainThread.hpp ├── MemDC.cpp ├── MemDC.hpp ├── MemStream.cpp ├── MemStream.hpp ├── MemStreamException.cpp ├── MemStreamException.hpp ├── Menu.cpp ├── Menu.hpp ├── Module.cpp ├── Module.hpp ├── MsgThread.cpp ├── MsgThread.hpp ├── MsgWnd.cpp ├── MsgWnd.hpp ├── NetFinder.cpp ├── NetFinder.hpp ├── NullCmdController.hpp ├── Path.cpp ├── Path.hpp ├── PathEditBox.cpp ├── PathEditBox.hpp ├── Pen.cpp ├── Pen.hpp ├── Point.hpp ├── PopupMenu.cpp ├── PopupMenu.hpp ├── PopupWnd.cpp ├── PopupWnd.hpp ├── Pragmas.hpp ├── Printer.cpp ├── Printer.hpp ├── PrinterDC.cpp ├── PrinterDC.hpp ├── ProgressBar.cpp ├── ProgressBar.hpp ├── PropertyPage.cpp ├── PropertyPage.hpp ├── PropertySheet.cpp ├── PropertySheet.hpp ├── RadioBtn.cpp ├── RadioBtn.hpp ├── ReadMe.txt ├── Rect.hpp ├── RegKey.cpp ├── RegKey.hpp ├── RegistryCfgProvider.cpp ├── RegistryCfgProvider.hpp ├── RegistryException.hpp ├── ResourceString.cpp ├── ResourceString.hpp ├── SDIApp.cpp ├── SDIApp.hpp ├── SDICmds.cpp ├── SDICmds.hpp ├── SDIDoc.cpp ├── SDIDoc.hpp ├── SDIFrame.cpp ├── SDIFrame.hpp ├── ScreenDC.cpp ├── ScreenDC.hpp ├── SeTranslator.cpp ├── SeTranslator.hpp ├── Size.hpp ├── SplitWnd.cpp ├── SplitWnd.hpp ├── StaticCtrl.cpp ├── StaticCtrl.hpp ├── StatusBar.cpp ├── StatusBar.hpp ├── StatusBarIcon.cpp ├── StatusBarIcon.hpp ├── StatusBarLabel.cpp ├── StatusBarLabel.hpp ├── StatusBarPanel.cpp ├── StatusBarPanel.hpp ├── StdWnd.cpp ├── StdWnd.hpp ├── StrArray.hpp ├── StrCvt.cpp ├── StrCvt.hpp ├── StrCvtException.cpp ├── StrCvtException.hpp ├── StrTok.cpp ├── StrTok.hpp ├── Stream.cpp ├── Stream.hpp ├── StreamException.hpp ├── String.cpp ├── String.hpp ├── StringIO.hpp ├── StringUtils.cpp ├── StringUtils.hpp ├── StructuredException.cpp ├── StructuredException.hpp ├── SysInfo.cpp ├── SysInfo.hpp ├── TODO.Txt ├── TabCtrl.cpp ├── TabCtrl.hpp ├── TabWndHost.cpp ├── TabWndHost.hpp ├── Test ├── AppConfigTests.cpp ├── CmdControlTests.cpp ├── ComExceptionTests.cpp ├── ComPtrTests.cpp ├── ComStrTests.cpp ├── Common.hpp ├── ConsoleCmdTests.cpp ├── DateTests.cpp ├── DateTimeTests.cpp ├── ExternalCmdControllerTests.cpp ├── FolderIteratorTests.cpp ├── IFacePtrTests.cpp ├── IniFileCfgProviderTests.cpp ├── IniFileTests.cpp ├── InputOutputStreamTests.cpp ├── MemStreamTests.cpp ├── NullCmdControllerTests.cpp ├── PathTests.cpp ├── PtrTest.hpp ├── RectTests.cpp ├── RegistryCfgProviderTests.cpp ├── ResourceStringTests.cpp ├── SeTranslatorTests.cpp ├── StringTests.cpp ├── StringUtilsTests.cpp ├── Test.cbp ├── Test.cpp ├── Test.rc ├── Test.rcv ├── Test.sln ├── Test.vcproj ├── Test.workspace ├── TestIFaceTraits.hpp ├── TimeTests.cpp ├── UiCommandBaseTests.cpp ├── VariantTests.cpp ├── VariantVectorTests.cpp ├── VerInfoReaderTests.cpp ├── pch.cpp └── resource.h ├── Thread.hpp ├── ThreadJob.cpp ├── ThreadJob.hpp ├── ThreadPool.cpp ├── ThreadPool.hpp ├── ThreadPoolThread.cpp ├── ThreadPoolThread.hpp ├── Time.cpp ├── Time.hpp ├── TimeSpan.hpp ├── ToolBar.cpp ├── ToolBar.hpp ├── ToolTip.cpp ├── ToolTip.hpp ├── TraceLogger.cpp ├── TraceLogger.hpp ├── TransparentBmp.cpp ├── TransparentBmp.hpp ├── TrayIcon.cpp ├── TrayIcon.hpp ├── TreeView.cpp ├── TreeView.hpp ├── URLLabel.cpp ├── URLLabel.hpp ├── UiCommandBase.cpp ├── UiCommandBase.hpp ├── UpDownBtns.cpp ├── UpDownBtns.hpp ├── Variant.cpp ├── Variant.hpp ├── VariantBool.hpp ├── VariantVector.hpp ├── VerInfoReader.cpp ├── VerInfoReader.hpp ├── View.cpp ├── View.hpp ├── Wcl.cbp ├── Wcl.vcproj ├── WclTypes.hpp ├── Win32Exception.hpp ├── WinMain.cpp ├── WinMain.hpp ├── Wnd.cpp ├── Wnd.hpp ├── WndMap.cpp ├── WndMap.hpp └── pch.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual C++ 2 | [Dd]ebug 3 | [Rr]elease 4 | *.ncb 5 | *.suo 6 | *.user 7 | 8 | # Code::Blocks 9 | *.layout 10 | *.depend 11 | *.gch 12 | 13 | # Doxygen 14 | /dox 15 | -------------------------------------------------------------------------------- /Accel.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: ACCEL.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CAccel class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef ACCEL_HPP 13 | #define ACCEL_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** This encapsulates a Windows accelerator table. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CAccel /*: private NotCopyable*/ 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CAccel(); 33 | ~CAccel(); 34 | 35 | void LoadRsc(uint iRscID); 36 | 37 | // 38 | // Member access. 39 | // 40 | HACCEL Handle() const; 41 | 42 | // 43 | // Message handling. 44 | // 45 | bool Translate(HWND hWnd, MSG& rMsg); 46 | 47 | protected: 48 | // 49 | // Members. 50 | // 51 | HACCEL m_hAccel; 52 | 53 | private: 54 | // NotCopyable. 55 | CAccel(const CAccel&); 56 | CAccel& operator=(const CAccel&); 57 | }; 58 | 59 | /****************************************************************************** 60 | ** 61 | ** Implementation of inline functions. 62 | ** 63 | ******************************************************************************* 64 | */ 65 | 66 | inline HACCEL CAccel::Handle() const 67 | { 68 | return m_hAccel; 69 | } 70 | 71 | #endif //ACCEL_HPP 72 | -------------------------------------------------------------------------------- /AutoBool.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: AUTOBOOL.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CAutoBool class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef AUTOBOOL_HPP 13 | #define AUTOBOOL_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** A class for toggling a boolean value on/off that is exception safe. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CAutoBool 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CAutoBool(bool* pBool); 33 | ~CAutoBool(); 34 | 35 | protected: 36 | // 37 | // Members. 38 | // 39 | bool* m_pBool; // The bool to toggle. 40 | 41 | #ifdef _DEBUG 42 | bool m_bInitVal; // The initial value. 43 | #endif 44 | }; 45 | 46 | /****************************************************************************** 47 | ** 48 | ** Implementation of inline functions. 49 | ** 50 | ******************************************************************************* 51 | */ 52 | 53 | inline CAutoBool::CAutoBool(bool* pBool) 54 | : m_pBool(pBool) 55 | { 56 | ASSERT(m_pBool != nullptr); 57 | 58 | #ifdef _DEBUG 59 | m_bInitVal = *m_pBool; 60 | #endif 61 | 62 | *m_pBool = !*m_pBool; 63 | } 64 | 65 | inline CAutoBool::~CAutoBool() 66 | { 67 | *m_pBool = !*m_pBool; 68 | 69 | #ifdef _DEBUG 70 | ASSERT(*m_pBool == m_bInitVal); 71 | #endif 72 | } 73 | 74 | #endif // AUTOBOOL_HPP 75 | -------------------------------------------------------------------------------- /AutoThreadLock.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: AUTOTHREADLOCK.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CAutoThreadLock class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef AUTOTHREADLOCK_HPP 13 | #define AUTOTHREADLOCK_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** Helper class to automatically acquire and release a thread lock. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CAutoThreadLock 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CAutoThreadLock(IThreadLock& oLock); 33 | ~CAutoThreadLock(); 34 | 35 | protected: 36 | // 37 | // Members. 38 | // 39 | IThreadLock& m_oLock; 40 | }; 41 | 42 | /****************************************************************************** 43 | ** 44 | ** Implementation of inline functions. 45 | ** 46 | ******************************************************************************* 47 | */ 48 | 49 | inline CAutoThreadLock::CAutoThreadLock(IThreadLock& oLock) 50 | : m_oLock(oLock) 51 | { 52 | m_oLock.Acquire(); 53 | } 54 | 55 | inline CAutoThreadLock::~CAutoThreadLock() 56 | { 57 | m_oLock.Release(); 58 | } 59 | 60 | #endif // AUTOTHREADLOCK_HPP 61 | -------------------------------------------------------------------------------- /Bitmap.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: BITMAP.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CBitmap class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef BITMAP_HPP 13 | #define BITMAP_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Size.hpp" 20 | 21 | // Forward reference. 22 | class CDC; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** This encapsulates a device dependant bitmap. 27 | ** 28 | ******************************************************************************* 29 | */ 30 | 31 | class CBitmap /*: private NotCopyable*/ 32 | { 33 | public: 34 | // 35 | // Constructors/Destructor. 36 | // 37 | CBitmap(); 38 | CBitmap(uint iRscID); 39 | ~CBitmap(); 40 | 41 | void Create(const CSize& rSize); 42 | void Create(const CSize& rSize, const CDC& rDC); 43 | void LoadRsc(uint iRscID); 44 | 45 | // 46 | // Member access. 47 | // 48 | HBITMAP Handle() const; 49 | CSize Size() const; 50 | 51 | protected: 52 | // 53 | // Members. 54 | // 55 | HBITMAP m_hBitmap; 56 | CSize m_Size; 57 | 58 | private: 59 | // NotCopyable. 60 | CBitmap(const CBitmap&); 61 | CBitmap& operator=(const CBitmap&); 62 | }; 63 | 64 | /****************************************************************************** 65 | ** 66 | ** Implementation of inline functions. 67 | ** 68 | ******************************************************************************* 69 | */ 70 | 71 | inline HBITMAP CBitmap::Handle() const 72 | { 73 | return m_hBitmap; 74 | } 75 | 76 | inline CSize CBitmap::Size() const 77 | { 78 | ASSERT(m_hBitmap); 79 | 80 | return m_Size; 81 | } 82 | 83 | #endif //BITMAP_HPP 84 | -------------------------------------------------------------------------------- /Brush.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: BRUSH.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CBrush class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "Brush.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Constructor. 16 | ** 17 | ** Description: . 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CBrush::CBrush() 27 | : m_hBrush(NULL) 28 | , m_bOwner(false) 29 | { 30 | } 31 | 32 | CBrush::CBrush(int iID) 33 | : m_hBrush() 34 | , m_bOwner() 35 | { 36 | Create(iID); 37 | } 38 | 39 | CBrush::CBrush(COLORREF crClr) 40 | : m_hBrush() 41 | , m_bOwner() 42 | { 43 | Create(crClr); 44 | } 45 | 46 | CBrush::CBrush(HBRUSH hBrush, bool bOwn) 47 | : m_hBrush() 48 | , m_bOwner() 49 | { 50 | m_hBrush = hBrush; 51 | m_bOwner = bOwn; 52 | 53 | ASSERT(m_hBrush != NULL); 54 | } 55 | 56 | /****************************************************************************** 57 | ** Method: Destructor. 58 | ** 59 | ** Description: . 60 | ** 61 | ** Parameters: None. 62 | ** 63 | ** Returns: Nothing. 64 | ** 65 | ******************************************************************************* 66 | */ 67 | 68 | CBrush::~CBrush() 69 | { 70 | // Delete if valid and we own it. 71 | if ( (m_hBrush) && (m_bOwner) ) 72 | ::DeleteObject(m_hBrush); 73 | } 74 | 75 | void CBrush::Create(int iID) 76 | { 77 | m_hBrush = GetStockBrush(iID); 78 | m_bOwner = false; 79 | 80 | ASSERT(m_hBrush != NULL); 81 | } 82 | 83 | void CBrush::Create(COLORREF crClr) 84 | { 85 | m_hBrush = ::CreateSolidBrush(crClr); 86 | m_bOwner = true; 87 | 88 | ASSERT(m_hBrush != NULL); 89 | } 90 | -------------------------------------------------------------------------------- /Brush.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: BRUSH.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CBrush class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef BRUSH_HPP 13 | #define BRUSH_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** This class wraps a standard GDI brush. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CBrush /*: private NotCopyable*/ 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CBrush(); 33 | CBrush(int iID); 34 | CBrush(COLORREF crClr); 35 | CBrush(HBRUSH hBrush, bool bOwn = false); 36 | ~CBrush(); 37 | 38 | void Create(int iID); 39 | void Create(COLORREF crClr); 40 | 41 | // 42 | // Member access. 43 | // 44 | HBRUSH Handle() const; 45 | 46 | protected: 47 | // 48 | // Members. 49 | // 50 | HBRUSH m_hBrush; 51 | bool m_bOwner; 52 | 53 | private: 54 | // NotCopyable. 55 | CBrush(const CBrush&); 56 | CBrush& operator=(const CBrush&); 57 | }; 58 | 59 | /****************************************************************************** 60 | ** 61 | ** Implementation of inline functions. 62 | ** 63 | ******************************************************************************* 64 | */ 65 | 66 | inline HBRUSH CBrush::Handle() const 67 | { 68 | return m_hBrush; 69 | } 70 | 71 | #endif //BRUSH_HPP 72 | -------------------------------------------------------------------------------- /BusyCursor.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: BUSYCURSOR.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CBusyCursor class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "BusyCursor.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Constructor. 16 | ** 17 | ** Description: . 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CBusyCursor::CBusyCursor() 27 | : m_hOldCursor() 28 | { 29 | // Save old cursor. 30 | m_hOldCursor = ::GetCursor(); 31 | 32 | // Show hourglass. 33 | Restore(); 34 | } 35 | 36 | /****************************************************************************** 37 | ** Method: Destructor. 38 | ** 39 | ** Description: . 40 | ** 41 | ** Parameters: None. 42 | ** 43 | ** Returns: Nothing. 44 | ** 45 | ******************************************************************************* 46 | */ 47 | 48 | CBusyCursor::~CBusyCursor() 49 | { 50 | // Restore old cursor. 51 | ::SetCursor(m_hOldCursor); 52 | } 53 | 54 | /****************************************************************************** 55 | ** Method: Restore() 56 | ** 57 | ** Description: Restores the hourglass cursor. 58 | ** 59 | ** Parameters: None. 60 | ** 61 | ** Returns: Nothing. 62 | ** 63 | ******************************************************************************* 64 | */ 65 | 66 | void CBusyCursor::Restore() 67 | { 68 | // Restore old cursor. 69 | ::SetCursor(::LoadCursor(NULL, IDC_WAIT)); 70 | } 71 | -------------------------------------------------------------------------------- /BusyCursor.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: BUSYCURSOR.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CBusyCursor class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef BUSYCURSOR_HPP 13 | #define BUSYCURSOR_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** Shows the hourglass cursor on construction and restores it on destruction. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CBusyCursor /*: private NotCopyable*/ 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CBusyCursor(); 33 | ~CBusyCursor(); 34 | 35 | void Restore(); 36 | 37 | protected: 38 | // 39 | // Members. 40 | // 41 | HCURSOR m_hOldCursor; // The old cursor. 42 | 43 | private: 44 | // NotCopyable. 45 | CBusyCursor(const CBusyCursor&); 46 | CBusyCursor& operator=(const CBusyCursor&); 47 | }; 48 | 49 | /****************************************************************************** 50 | ** 51 | ** Implementation of inline functions. 52 | ** 53 | ******************************************************************************* 54 | */ 55 | 56 | #endif //BUSYCURSOR_HPP 57 | -------------------------------------------------------------------------------- /Button.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: BUTTON.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CButton class methods. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "Button.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Default constructor. 16 | ** 17 | ** Description: Override any default settings for the window class and style. 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CButton::CButton() 27 | { 28 | } 29 | 30 | /****************************************************************************** 31 | ** Method: GetCreateParams() 32 | ** 33 | ** Description: Template method to get the window creation data. 34 | ** 35 | ** Parameters: rParams The create structure to fill. 36 | ** 37 | ** Returns: Nothing. 38 | ** 39 | ******************************************************************************* 40 | */ 41 | 42 | void CButton::GetCreateParams(WNDCREATE& rParams) 43 | { 44 | // Get base class settings. 45 | CCtrlWnd::GetCreateParams(rParams); 46 | 47 | // Override any settings. 48 | rParams.pszClassName = TXT("BUTTON"); 49 | rParams.dwStyle |= BS_PUSHBUTTON; 50 | } 51 | -------------------------------------------------------------------------------- /Button.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: BUTTON.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CButton class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef BUTTON_HPP 13 | #define BUTTON_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StdWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is a button control. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CButton : public CStdWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CButton(); 35 | 36 | // 37 | // Standard methods. 38 | // 39 | 40 | protected: 41 | // 42 | // Members. 43 | // 44 | 45 | // 46 | // Window creation template methods. 47 | // 48 | virtual void GetCreateParams(WNDCREATE& rParams); 49 | }; 50 | 51 | /****************************************************************************** 52 | ** 53 | ** Implementation of inline functions. 54 | ** 55 | ******************************************************************************* 56 | */ 57 | 58 | #endif //BUTTON_HPP 59 | -------------------------------------------------------------------------------- /CheckBox.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: CHECKBOX.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CCheckBox class methods. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "CheckBox.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Default constructor. 16 | ** 17 | ** Description: Override any default settings for the window class and style. 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CCheckBox::CCheckBox() 27 | { 28 | } 29 | 30 | /****************************************************************************** 31 | ** Method: GetCreateParams() 32 | ** 33 | ** Description: Template method to get the window creation data. 34 | ** 35 | ** Parameters: rParams The create structure to fill. 36 | ** 37 | ** Returns: Nothing. 38 | ** 39 | ******************************************************************************* 40 | */ 41 | 42 | void CCheckBox::GetCreateParams(WNDCREATE& rParams) 43 | { 44 | // Get base class settings. 45 | CCtrlWnd::GetCreateParams(rParams); 46 | 47 | // Override any settings. 48 | rParams.pszClassName = TXT("BUTTON"); 49 | rParams.dwStyle |= BS_AUTOCHECKBOX; 50 | } 51 | -------------------------------------------------------------------------------- /CheckBox.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: CHECKBOX.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CCheckBox class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef CHECKBOX_HPP 13 | #define CHECKBOX_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StdWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is a check-box control. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CCheckBox : public CStdWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CCheckBox(); 35 | 36 | // 37 | // Standard methods. 38 | // 39 | void Check(bool bCheck = true) const; 40 | bool IsChecked() const; 41 | 42 | protected: 43 | // 44 | // Members. 45 | // 46 | 47 | // 48 | // Window creation template methods. 49 | // 50 | virtual void GetCreateParams(WNDCREATE& rParams); 51 | }; 52 | 53 | /****************************************************************************** 54 | ** 55 | ** Implementation of inline functions. 56 | ** 57 | ******************************************************************************* 58 | */ 59 | 60 | inline void CCheckBox::Check(bool bCheck) const 61 | { 62 | SendMessage(BM_SETCHECK, bCheck, 0); 63 | } 64 | 65 | inline bool CCheckBox::IsChecked() const 66 | { 67 | return static_cast(SendMessage(BM_GETCHECK, 0, 0)); 68 | } 69 | 70 | #endif //CHECKBOX_HPP 71 | -------------------------------------------------------------------------------- /CheckBoxList.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: CHECKBOXLIST.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CCheckBoxList class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "CheckBoxList.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Constructor. 16 | ** 17 | ** Description: . 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CCheckBoxList::CCheckBoxList() 27 | { 28 | } 29 | 30 | /****************************************************************************** 31 | ** Method: Destructor. 32 | ** 33 | ** Description: . 34 | ** 35 | ** Parameters: None. 36 | ** 37 | ** Returns: Nothing. 38 | ** 39 | ******************************************************************************* 40 | */ 41 | 42 | CCheckBoxList::~CCheckBoxList() 43 | { 44 | } 45 | 46 | /****************************************************************************** 47 | ** Method: OnCreate() 48 | ** 49 | ** Description: Sets the check box mode of the listview. 50 | ** 51 | ** Parameters: rcClient The client rectangle. 52 | ** 53 | ** Returns: Nothing. 54 | ** 55 | ******************************************************************************* 56 | */ 57 | 58 | void CCheckBoxList::OnCreate(const CRect& rcClient) 59 | { 60 | CheckBoxes(true); 61 | 62 | CListView::OnCreate(rcClient); 63 | } 64 | -------------------------------------------------------------------------------- /CheckBoxList.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: CHECKBOXLIST.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CCheckBoxList class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef CHECKBOXLIST_HPP 13 | #define CHECKBOXLIST_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "ListView.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is a ListView derived class used to display a list of check boxes. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CCheckBoxList : public CListView 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CCheckBoxList(); 35 | ~CCheckBoxList(); 36 | 37 | // 38 | // Methods. 39 | // 40 | void ItemCheck(size_t nItem, bool bChecked); 41 | bool IsItemChecked(size_t nItem); 42 | 43 | protected: 44 | // 45 | // Members. 46 | // 47 | 48 | // 49 | // Message processors. 50 | // 51 | virtual void OnCreate(const CRect& rcClient); 52 | }; 53 | 54 | /****************************************************************************** 55 | ** 56 | ** Implementation of inline functions. 57 | ** 58 | ******************************************************************************* 59 | */ 60 | 61 | inline void CCheckBoxList::ItemCheck(size_t nItem, bool bChecked) 62 | { 63 | uint nState = INDEXTOSTATEIMAGEMASK((bChecked ? 2 : 1)); 64 | 65 | ListView_SetItemState(m_hWnd, nItem, nState, LVIS_STATEIMAGEMASK); 66 | } 67 | 68 | inline bool CCheckBoxList::IsItemChecked(size_t nItem) 69 | { 70 | return ListView_GetCheckState(m_hWnd, nItem); 71 | } 72 | 73 | #endif //CHECKBOXLIST_HPP 74 | -------------------------------------------------------------------------------- /CmdBmp.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: CMDBMP.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CCmdBitmap class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef CMDBMP_HPP 13 | #define CMDBMP_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Bitmap.hpp" 20 | 21 | // Forward declarations. 22 | class CRect; 23 | class CDC; 24 | 25 | /****************************************************************************** 26 | ** 27 | ** The class used to store the visual representation (enabled and disabled) of 28 | ** all commands. It is used by the tool bar buttons and menu to draw the command 29 | ** icons. 30 | ** 31 | ******************************************************************************* 32 | */ 33 | 34 | class CCmdBitmap 35 | { 36 | public: 37 | // 38 | // Constructors/Destructor. 39 | // 40 | CCmdBitmap(); 41 | ~CCmdBitmap(); 42 | 43 | void LoadRsc(uint iRscID); 44 | 45 | // 46 | // Methods. 47 | // 48 | void DrawCmd(uint iIndex, CDC& rDC, const CRect& rDst, bool bEnabled) const; 49 | 50 | protected: 51 | // 52 | // Members. 53 | // 54 | uint m_iCmdSize; 55 | CBitmap m_EnabledBmp; 56 | CBitmap m_DisabledBmp; 57 | }; 58 | 59 | /****************************************************************************** 60 | ** 61 | ** Implementation of inline functions. 62 | ** 63 | ******************************************************************************* 64 | */ 65 | 66 | #endif //CMDBMP_HPP 67 | -------------------------------------------------------------------------------- /CmdBtn.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: CMDBTN.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CCmdButton class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef CMDBTN_HPP 13 | #define CMDBTN_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Button.hpp" 20 | #include "WclTypes.hpp" 21 | 22 | /****************************************************************************** 23 | ** 24 | ** This is a bitmap based button control used on a tool bar. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CCmdButton : public CButton 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CCmdButton(); 36 | 37 | protected: 38 | // 39 | // Members. 40 | // 41 | bool m_bOnToolbar; 42 | bool m_bTimerOn; 43 | 44 | // 45 | // Window creation template methods. 46 | // 47 | virtual void GetCreateParams(WNDCREATE& rParams); 48 | 49 | // 50 | // Message processors. 51 | // 52 | virtual LRESULT WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam); 53 | virtual void OnNCDestroy(); 54 | virtual void OnDrawItem(uint iID, uint iAction, uint iState, CDC& rDC, uint iItem, const CRect& rcItem); 55 | virtual void OnMouseMove(const CPoint& ptCursor, WCL::KeyFlags iKeyFlags); 56 | virtual void OnTimer(WCL::TimerID iTimerID); 57 | 58 | // 59 | // Class members. 60 | // 61 | static CCmdButton* g_pActiveBtn; 62 | }; 63 | 64 | /****************************************************************************** 65 | ** 66 | ** Implementation of inline functions. 67 | ** 68 | ******************************************************************************* 69 | */ 70 | 71 | #endif //CMDBTN_HPP 72 | -------------------------------------------------------------------------------- /ComCtl32.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: COMCTL32.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CComCtl32 class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef COMCTL32_HPP 13 | #define COMCTL32_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Library.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** Helper class used to interrogate and initialise COMCTL32.DLL. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CComCtl32 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CComCtl32(); 35 | ~CComCtl32(); 36 | 37 | // 38 | // Methods. 39 | // 40 | bool IsLoaded() const; 41 | bool GetVersion(DWORD& dwMajor, DWORD& dwMinor); 42 | bool Initialise(DWORD dwICC); 43 | 44 | protected: 45 | // 46 | // Members. 47 | // 48 | CLibrary m_oDLL; 49 | }; 50 | 51 | /****************************************************************************** 52 | ** 53 | ** Implementation of inline functions. 54 | ** 55 | ******************************************************************************* 56 | */ 57 | 58 | inline bool CComCtl32::IsLoaded() const 59 | { 60 | return m_oDLL.IsLoaded(); 61 | } 62 | 63 | #endif // COMCTL32_HPP 64 | -------------------------------------------------------------------------------- /Common.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file Common.hpp 3 | //! \brief Wrapper to include the most common WCL library headers. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_COMMON_HPP 8 | #define WCL_COMMON_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | //////////////////////////////////////////////////////////////////////////////// 15 | // Library documentation 16 | // 17 | //! \namespace WCL 18 | //! \brief The Windows C++ Library namespace. 19 | //! 20 | //! \mainpage Windows C++ Library 21 | //! \section introduction Introduction 22 | //! This is a framework for writing Windows based applications. It is a class 23 | //! library along the same lines as MFC, that provides a wrapper facade for the 24 | //! Win32 API. 25 | 26 | //////////////////////////////////////////////////////////////////////////////// 27 | // Standard headers. 28 | 29 | #include // Core library common headers. 30 | #include // Standard Windows header. 31 | #include // Additional Windows types and macros. 32 | 33 | //////////////////////////////////////////////////////////////////////////////// 34 | // Library headers. 35 | 36 | #include "WCLTypes.hpp" 37 | #include "String.hpp" 38 | 39 | #endif // WCL_COMMON_HPP 40 | -------------------------------------------------------------------------------- /CommonRsc.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file CommonRsc.h 3 | //! \brief Wrapper include file for the basic Resource file defintions. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_COMMONRSC_H 8 | #define WCL_COMMONRSC_H 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #ifdef APSTUDIO_INVOKED 15 | //! Hide the following symbols from the resource editor. 16 | #define APSTUDIO_HIDDEN_SYMBOLS 17 | #endif 18 | 19 | #include 20 | #include 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | //! Stop hiding symbols. 24 | #undef APSTUDIO_HIDDEN_SYMBOLS 25 | #endif 26 | 27 | //////////////////////////////////////////////////////////////////////////////// 28 | // System Menu hints. 29 | 30 | #define IDS_SYS_RESTORE 61728 31 | #define IDS_SYS_MOVE 61456 32 | #define IDS_SYS_SIZE 61440 33 | #define IDS_SYS_MINIMIZE 61472 34 | #define IDS_SYS_MAXIMIZE 61488 35 | #define IDS_SYS_CLOSE 61536 36 | #define IDS_SYS_SWITCH 61744 37 | 38 | #endif // WCL_COMMONRSC_H 39 | -------------------------------------------------------------------------------- /CommonUI.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file CommonUI.hpp 3 | //! \brief Wrapper to include the most common UI class headers. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_COMMONUI_HPP 8 | #define WCL_COMMONUI_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | //////////////////////////////////////////////////////////////////////////////// 15 | // System headers. 16 | 17 | #include // Core library common headers. 18 | #include // Windows C++ library common headers. 19 | 20 | //////////////////////////////////////////////////////////////////////////////// 21 | // Library headers. 22 | 23 | // Container windows. 24 | #include 25 | #include 26 | 27 | // Controls. 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #endif // WCL_COMMONUI_HPP 45 | -------------------------------------------------------------------------------- /ConsoleCmd.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file ConsoleCmd.cpp 3 | //! \brief The ConsoleCmd class definition. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include "ConsoleCmd.hpp" 8 | #include 9 | #include 10 | 11 | namespace WCL 12 | { 13 | 14 | //////////////////////////////////////////////////////////////////////////////// 15 | //! Default constructor. 16 | 17 | ConsoleCmd::ConsoleCmd(SwitchCIter itFirstSwitch, SwitchCIter itLastSwitch, int argc, tchar* argv[], int usageId) 18 | : m_argc(argc) 19 | , m_argv(argv) 20 | , m_parser(itFirstSwitch, itLastSwitch) 21 | , m_usageId(usageId) 22 | { 23 | } 24 | 25 | //////////////////////////////////////////////////////////////////////////////// 26 | //! Destructor. 27 | 28 | ConsoleCmd::~ConsoleCmd() 29 | { 30 | } 31 | 32 | //////////////////////////////////////////////////////////////////////////////// 33 | //! Execute the command. 34 | 35 | int ConsoleCmd::execute(tostream& out, tostream& err) 36 | { 37 | try 38 | { 39 | // Parse the command line. 40 | m_parser.parse(m_argc, m_argv); 41 | 42 | // Request for command help? 43 | if (m_parser.isSwitchSet(m_usageId)) 44 | { 45 | showUsage(out); 46 | return EXIT_SUCCESS; 47 | } 48 | 49 | // Execute it. 50 | return doExecute(out, err); 51 | } 52 | catch (const Core::CmdLineException& e) 53 | { 54 | err << TXT("ERROR: ") << e.twhat() << std::endl; 55 | showUsage(out); 56 | return EXIT_FAILURE; 57 | } 58 | } 59 | 60 | //////////////////////////////////////////////////////////////////////////////// 61 | //! Display the command specific usage. 62 | 63 | void ConsoleCmd::showUsage(tostream& out) 64 | { 65 | out << std::endl; 66 | out << getDescription() << std::endl; 67 | out << std::endl; 68 | out << getUsage() << std::endl; 69 | out << std::endl; 70 | out << m_parser.formatSwitches(Core::CmdLineParser::UNIX); 71 | } 72 | 73 | //namespace WCL 74 | } 75 | -------------------------------------------------------------------------------- /ConsoleCmd.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file ConsoleCmd.hpp 3 | //! \brief The ConsoleCmd class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_CONSOLECMD_HPP 8 | #define WCL_CONSOLECMD_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include 15 | #include 16 | 17 | namespace WCL 18 | { 19 | 20 | //////////////////////////////////////////////////////////////////////////////// 21 | //! The base class for all commands. 22 | 23 | class ConsoleCmd 24 | { 25 | public: 26 | //! Destructor. 27 | virtual ~ConsoleCmd(); 28 | 29 | // 30 | // Methods. 31 | // 32 | 33 | //! Execute the command. 34 | virtual int execute(tostream& out, tostream& err); 35 | 36 | protected: 37 | //! Type aliases. 38 | typedef Core::CmdLineParser::SwitchCIter SwitchCIter; 39 | 40 | //! Default constructor. 41 | ConsoleCmd(SwitchCIter itFirstSwitch, SwitchCIter itLastSwitch, int argc, tchar* argv[], int usageId); 42 | 43 | // 44 | // Members. 45 | // 46 | int m_argc; //!< The number of command line arguments. 47 | tchar** m_argv; //!< The array of command line arguments 48 | Core::CmdLineParser m_parser; //!< The command specific command line parser. 49 | int m_usageId; //!< The ID of the usage switch. 50 | 51 | // 52 | // Callback methods. 53 | // 54 | 55 | //! Get the description of the command. 56 | virtual const tchar* getDescription() = 0; 57 | 58 | //! Get the expected command usage. 59 | virtual const tchar* getUsage() = 0; 60 | 61 | //! The implementation of the command. 62 | virtual int doExecute(tostream& out, tostream& err) = 0; 63 | 64 | private: 65 | //! Display the command specific usage. 66 | void showUsage(tostream& out); 67 | }; 68 | 69 | //! The default ConsoleCmd smart-pointer type. 70 | typedef Core::SharedPtr ConsoleCmdPtr; 71 | 72 | //namespace WCL 73 | } 74 | 75 | #endif // WCL_CONSOLECMD_HPP 76 | -------------------------------------------------------------------------------- /ContextMenu.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file ContextMenu.cpp 3 | //! \brief The ContextMenu class definition. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include "ContextMenu.hpp" 8 | #include "App.hpp" 9 | #include "Point.hpp" 10 | #include "FrameWnd.hpp" 11 | 12 | namespace WCL 13 | { 14 | 15 | //////////////////////////////////////////////////////////////////////////////// 16 | //! Construction from the menu resource ID. 17 | 18 | ContextMenu::ContextMenu(uint resourceId) 19 | : CPopupMenu(resourceId) 20 | { 21 | } 22 | 23 | //////////////////////////////////////////////////////////////////////////////// 24 | //! Destructor. 25 | 26 | ContextMenu::~ContextMenu() 27 | { 28 | } 29 | 30 | //////////////////////////////////////////////////////////////////////////////// 31 | //! Display the context menu and invoke the selected command. 32 | 33 | void ContextMenu::display(const CFrameWnd& appWnd) const 34 | { 35 | const CPoint position(CApp::This().m_MainThread.CurrentMsg().pt); 36 | 37 | const uint command = TrackMenu(appWnd, position); 38 | 39 | if (command != 0) 40 | appWnd.PostCommand(command); 41 | } 42 | 43 | //////////////////////////////////////////////////////////////////////////////// 44 | //! Display the context menu and invoke the selected command. 45 | 46 | void ContextMenu::display(uint resourceId, const CFrameWnd& appWnd) 47 | { 48 | const ContextMenu menu(resourceId); 49 | 50 | menu.display(appWnd); 51 | } 52 | 53 | //namespace WCL 54 | } 55 | -------------------------------------------------------------------------------- /ContextMenu.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file ContextMenu.hpp 3 | //! \brief The ContextMenu class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_CONTEXTMENU_HPP 8 | #define WCL_CONTEXTMENU_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include "PopupMenu.hpp" 15 | 16 | // Forward declarations. 17 | class CFrameWnd; 18 | 19 | namespace WCL 20 | { 21 | 22 | //////////////////////////////////////////////////////////////////////////////// 23 | //! A menu used to invoke context dependent commands. This is usually used when 24 | //! right-clicking on an object in a view. 25 | 26 | class ContextMenu : public CPopupMenu 27 | { 28 | public: 29 | //! Construction from the menu resource ID. 30 | ContextMenu(uint resourceId); 31 | 32 | //! Destructor. 33 | virtual ~ContextMenu(); 34 | 35 | // 36 | // Methods. 37 | // 38 | 39 | //! Display the context menu and invoke the selected command. 40 | void display(const CFrameWnd& appWnd) const; 41 | 42 | // 43 | // Class methods. 44 | // 45 | 46 | //! Display the context menu and invoke the selected command. 47 | static void display(uint resourceId, const CFrameWnd& appWnd); 48 | }; 49 | 50 | //namespace WCL 51 | } 52 | 53 | #endif // WCL_CONTEXTMENU_HPP 54 | -------------------------------------------------------------------------------- /CriticalSection.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: CRITICALSECTION.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CCriticalSection class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef CRITICALSECTION_HPP 13 | #define CRITICALSECTION_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "IThreadLock.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** A Critical Section thread lock. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CCriticalSection : public IThreadLock 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CCriticalSection(); 35 | ~CCriticalSection(); 36 | 37 | // 38 | // Methods. 39 | // 40 | virtual void Acquire(); 41 | virtual void Release(); 42 | 43 | protected: 44 | // 45 | // Members. 46 | // 47 | CRITICAL_SECTION m_oLock; 48 | }; 49 | 50 | /****************************************************************************** 51 | ** 52 | ** Implementation of inline functions. 53 | ** 54 | ******************************************************************************* 55 | */ 56 | 57 | #endif // CRITICALSECTION_HPP 58 | -------------------------------------------------------------------------------- /CtrlWnd.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: CTRLWND.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CCtrlWnd class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef CTRLWND_HPP 13 | #define CTRLWND_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "PopupWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is the base class for all window child controls. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CCtrlWnd : public CPopupWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CCtrlWnd(); 35 | virtual ~CCtrlWnd(); 36 | 37 | virtual bool PreRegister(); 38 | virtual bool Create(CMsgWnd& rParent, uint iID, const CRect& rcPos); 39 | virtual bool Create(CMsgWnd& rParent, uint iID, const CRect& rcPos, DWORD dwExStyle, DWORD dwStyle); 40 | virtual bool Create(CMsgWnd& rParent, uint iID, HWND hWnd); 41 | 42 | protected: 43 | // 44 | // Members. 45 | // 46 | uint m_iID; 47 | CMsgWnd* m_pParent; 48 | CRect m_rcPos; 49 | 50 | // 51 | // Window creation template methods. 52 | // 53 | virtual void GetCreateParams(WNDCREATE& rParams); 54 | 55 | private: 56 | // NotCopyable. 57 | CCtrlWnd(const CCtrlWnd&); 58 | CCtrlWnd& operator=(const CCtrlWnd&); 59 | }; 60 | 61 | /****************************************************************************** 62 | ** 63 | ** Implementation of inline functions. 64 | ** 65 | ******************************************************************************* 66 | */ 67 | 68 | #endif //CTRLWND_HPP 69 | -------------------------------------------------------------------------------- /Cursor.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: CURSOR.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CCursor class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef CURSOR_HPP 13 | #define CURSOR_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Point.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This class wraps a standard GDI cursor. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CCursor /*: private NotCopyable*/ 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CCursor(); 35 | ~CCursor(); 36 | 37 | void LoadRsc(uint nRscID); 38 | void LoadRsc(const tchar* pszRsc); 39 | 40 | // 41 | // Member access. 42 | // 43 | HCURSOR Handle() const; 44 | 45 | // 46 | // Methods. 47 | // 48 | 49 | //! Release the resource. 50 | void Release(); 51 | 52 | // 53 | // Class methods. 54 | // 55 | 56 | //! Get the current cursor position in screen co-ordinates. 57 | static CPoint CurrentPos(); 58 | 59 | //! Get the current cursor position in window co-ordinates. 60 | static CPoint CurrentPos(HWND hWnd); 61 | 62 | protected: 63 | // 64 | // Members. 65 | // 66 | HCURSOR m_hCursor; 67 | bool m_bOwner; 68 | 69 | private: 70 | // NotCopyable. 71 | CCursor(const CCursor&); 72 | CCursor& operator=(const CCursor&); 73 | }; 74 | 75 | /****************************************************************************** 76 | ** 77 | ** Implementation of inline functions. 78 | ** 79 | ******************************************************************************* 80 | */ 81 | 82 | inline HCURSOR CCursor::Handle() const 83 | { 84 | return m_hCursor; 85 | } 86 | 87 | #endif //CURSOR_HPP 88 | -------------------------------------------------------------------------------- /DateSpan.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: DATESPAN.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CDateSpan class declarations. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef WCL_DATESPAN_HPP 13 | #define WCL_DATESPAN_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** This class is used to represent the distance between two dates in days. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CDateSpan 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CDateSpan(); 33 | CDateSpan(WCL::Days nDays); 34 | 35 | // Accessors. 36 | WCL::Days Days() const; 37 | 38 | protected: 39 | // 40 | // Members. 41 | // 42 | WCL::Days m_nSpan; 43 | 44 | // 45 | // Friends. 46 | // 47 | friend class CDate; 48 | }; 49 | 50 | /****************************************************************************** 51 | ** 52 | ** Implementation of CDateSpan inline functions. 53 | ** 54 | ******************************************************************************* 55 | */ 56 | 57 | inline CDateSpan::CDateSpan() 58 | : m_nSpan(0) 59 | { 60 | } 61 | 62 | inline CDateSpan::CDateSpan(WCL::Days nDays) 63 | : m_nSpan(nDays) 64 | { 65 | } 66 | 67 | inline WCL::Days CDateSpan::Days() const 68 | { 69 | return m_nSpan; 70 | } 71 | 72 | #endif // WCL_DATESPAN_HPP 73 | -------------------------------------------------------------------------------- /DecimalBox.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: DECIMALBOX.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CDecimalBox class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef DECIMALBOX_HPP 13 | #define DECIMALBOX_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "EditBox.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This class is used for EditBoxes which only allow decimal numbers. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CDecimalBox : public CEditBox 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CDecimalBox(bool bSigned, uint nIntDigits, uint nDecDigits = 0, uint nFlags = 0x00); 35 | ~CDecimalBox(); 36 | 37 | // 38 | // Methods. 39 | // 40 | double RealValue() const; 41 | void RealValue(double dValue); 42 | 43 | int IntValue() const; 44 | void IntValue(int nValue); 45 | 46 | // Flags. 47 | enum Flags 48 | { 49 | DEFAULTS = 0x00, 50 | NO_TRAIL_ZEROES = 0x01, 51 | // ALLOW_FRACTIONS = 0x02, 52 | }; 53 | 54 | protected: 55 | // 56 | // Members. 57 | // 58 | bool m_bSigned; // Allow signed numbers? 59 | uint m_nIntDigits; // Number of integer digits. 60 | uint m_nDecDigits; // Number of decimal digits. 61 | uint m_nMaxChars; // Maximum number of chars. 62 | uint m_nFlags; // Options. 63 | 64 | // 65 | // Message handlers. 66 | // 67 | virtual void OnCreate(const CRect& rcClient); 68 | virtual bool FilterKey(tchar cChar); 69 | }; 70 | 71 | /****************************************************************************** 72 | ** 73 | ** Implementation of inline functions. 74 | ** 75 | ******************************************************************************* 76 | */ 77 | 78 | #endif //DECIMALBOX_HPP 79 | -------------------------------------------------------------------------------- /DevNotes.txt: -------------------------------------------------------------------------------- 1 | Development Structure 2 | --------------------- 3 | 4 | The source folder structure is required by the solution & projects to be like 5 | this:- 6 | 7 | +- 8 | | +- 9 | +-Lib 10 | | +-Core 11 | | +-WCL 12 | | +-Test 13 | +-Scripts 14 | 15 | The following commands will create that structure by cloning the various 16 | application and library repositories:- 17 | 18 | C:\> mkdir Win32\Lib 19 | C:\> git clone https://github.com/chrisoldwood/Core.git Win32\Lib\Core 20 | C:\> git clone https://github.com/chrisoldwood/WCL.git Win32\Lib\WCL 21 | 22 | C:\> git clone https://github.com/chrisoldwood/Scripts.git Win32\Scripts 23 | 24 | Command Line Builds 25 | ------------------- 26 | 27 | Included in the scripts folder is one for building via the command line:- 28 | 29 | C:\> Win32\Scripts\SetVars vc90 30 | C:\> Win32\Scripts\Build debug Win32\Lib\WCL\Test\Test.sln 31 | 32 | There is also one for upgrading to a later version of Visual C++:- 33 | 34 | C:\> Win32\Scripts\SetVars vc140 35 | C:\> Win32\Scripts\Upgrade Win32\Lib\WCL\Test\Test.sln 36 | 37 | Chris Oldwood 38 | 22nd October 2013 39 | -------------------------------------------------------------------------------- /DlgFrame.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: DLGFRAME.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CDlgFrame class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef DLGFRAME_HPP 13 | #define DLGFRAME_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "FrameWnd.hpp" 20 | 21 | // Forward declarations. 22 | class CMainDlg; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** This is a frame window derived class used in applications that have a dialog 27 | ** as their main window. 28 | ** 29 | ******************************************************************************* 30 | */ 31 | 32 | class CDlgFrame : public CFrameWnd 33 | { 34 | public: 35 | // 36 | // Constructors/Destructor. 37 | // 38 | CDlgFrame(uint iIconID, CMainDlg& rDialog, bool bFixedSize); 39 | virtual ~CDlgFrame(); 40 | 41 | protected: 42 | // 43 | // Members. 44 | // 45 | CMainDlg& m_rDialog; 46 | bool m_bFixedSize; 47 | 48 | // 49 | // Window creation template methods. 50 | // 51 | virtual void GetCreateParams(WNDCREATE& rParams); 52 | 53 | // 54 | // Message processors. 55 | // 56 | virtual void OnCreate(const CRect& rcClient); 57 | virtual void OnDestroy(); 58 | virtual void OnResize(int iFlag, const CSize& NewSize); 59 | virtual void OnFocus(); 60 | }; 61 | 62 | /****************************************************************************** 63 | ** 64 | ** Implementation of inline functions. 65 | ** 66 | ******************************************************************************* 67 | */ 68 | 69 | #endif //DLGFRAME_HPP 70 | -------------------------------------------------------------------------------- /Dll.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: DLL.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CDll class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef WCL_DLL_HPP 13 | #define WCL_DLL_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Module.hpp" 20 | #include "DllMain.hpp" 21 | 22 | /****************************************************************************** 23 | ** 24 | ** This is base class from which the dll component class is derived. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CDll 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CDll(); 36 | virtual ~CDll(); 37 | 38 | //! Check if the dll singleton is valid. 39 | static bool IsValid(); 40 | 41 | //! Global access to the dll singleton. 42 | static CDll& This(); 43 | 44 | // 45 | // Members. 46 | // 47 | CModule m_Module; //! The component. 48 | 49 | protected: 50 | // 51 | // Members. 52 | // 53 | 54 | // 55 | // DllMain template methods. 56 | // (Overridden in the derived class). 57 | // 58 | virtual void OnLoad(); 59 | virtual void OnUnload(); 60 | virtual void OnThreadAttached(); 61 | virtual void OnThreadDetached(); 62 | 63 | private: 64 | // 65 | // Start-up and shut-down methods. 66 | // (Called from DllMain). 67 | // 68 | void Load(); 69 | void Unload(); 70 | void ThreadAttached(); 71 | void ThreadDetached(); 72 | 73 | friend BOOL WCL::dllMain(HINSTANCE hInst, DWORD dwReason); 74 | 75 | // 76 | // Class members. 77 | // 78 | 79 | //! The singleton DLL component object. 80 | static CDll* g_pThis; 81 | }; 82 | 83 | /****************************************************************************** 84 | ** 85 | ** Implementation of inline functions. 86 | ** 87 | ******************************************************************************* 88 | */ 89 | 90 | #endif // WCL_DLL_HPP 91 | -------------------------------------------------------------------------------- /DllMain.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file DllMain.cpp 3 | //! \brief DLL entry point. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include "Dll.hpp" 8 | 9 | namespace WCL 10 | { 11 | 12 | //////////////////////////////////////////////////////////////////////////////// 13 | //! The logical (WCL) entry point for a Windows DLL. 14 | 15 | BOOL dllMain(HINSTANCE hInstance, DWORD dwReason) 16 | { 17 | // Get dll object. 18 | CDll& oDll = CDll::This(); 19 | 20 | switch (dwReason) 21 | { 22 | case DLL_PROCESS_ATTACH: 23 | // Initialise members. 24 | oDll.m_Module.m_hInstance = hInstance; 25 | oDll.Load(); 26 | break; 27 | 28 | case DLL_THREAD_ATTACH: 29 | oDll.ThreadAttached(); 30 | break; 31 | 32 | case DLL_THREAD_DETACH: 33 | oDll.ThreadDetached(); 34 | break; 35 | 36 | case DLL_PROCESS_DETACH: 37 | oDll.Unload(); 38 | break; 39 | 40 | default: 41 | ASSERT_FALSE(); 42 | break; 43 | } 44 | 45 | return TRUE; 46 | } 47 | 48 | //namespace WCL 49 | } 50 | 51 | #ifdef __GNUG__ 52 | // no previous declaration for 'BOOL DllMain(HINSTANCE__*, DWORD, void*)' 53 | extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); 54 | #endif 55 | 56 | // Symbol used to ensure DllMain.cpp is linked. 57 | bool g_bLinkDllMain = false; 58 | 59 | //////////////////////////////////////////////////////////////////////////////// 60 | //! This is the real (C SDK) entry point for a Windows DLL. 61 | //! 62 | //! \note This entry point is linked by virtue of the CDll class referencing the 63 | //! symbol above. If you're not using the CDll class you'll either need to do 64 | //! the same or copy the stub below to the Dll project codebase. 65 | 66 | extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/) 67 | { 68 | return WCL::dllMain(hInstance, dwReason); 69 | } 70 | -------------------------------------------------------------------------------- /DllMain.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file DllMain.hpp 3 | //! \brief DLL entry point. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_DLLMAIN_HPP 8 | #define WCL_DLLMAIN_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | namespace WCL 15 | { 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | //! The logical (WCL) entry point for a Windows application. 19 | 20 | BOOL dllMain(HINSTANCE hInstance, DWORD dwReason); 21 | 22 | //namespace WCL 23 | } 24 | 25 | #endif // WCL_DLLMAIN_HPP 26 | -------------------------------------------------------------------------------- /Exception.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file Exception.cpp 3 | //! \brief The Exception class definition and utility functions. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include "Exception.hpp" 8 | #include "App.hpp" 9 | #include "ConsoleApp.hpp" 10 | 11 | namespace WCL 12 | { 13 | 14 | //////////////////////////////////////////////////////////////////////////////// 15 | //! Report an unhandled exception. This is called by all the outer try/catch 16 | //! blocks to report an unexpected exception. 17 | 18 | void ReportUnhandledException(const tchar* pszMsg, ...) 19 | { 20 | CString strMsg; 21 | 22 | // Setup arguments. 23 | va_list args; 24 | va_start(args, pszMsg); 25 | 26 | // Format message. 27 | strMsg.FormatEx(pszMsg, args); 28 | 29 | // Display message if an application. 30 | if (CApp::IsValid()) 31 | { 32 | CApp::This().FatalMsg(TXT("%s"), strMsg.c_str()); 33 | } 34 | else if (ConsoleApp::isValid()) 35 | { 36 | ConsoleApp::instance().reportFatalError(strMsg); 37 | } 38 | // Otherwise send to debugger. 39 | else 40 | { 41 | ASSERT_FALSE(); 42 | 43 | Core::debugWrite(TXT("%s\n"), strMsg.c_str()); 44 | } 45 | } 46 | 47 | //namespace WCL 48 | } 49 | -------------------------------------------------------------------------------- /Exception.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file Exception.hpp 3 | //! \brief The Exception class declaration and utility functions. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_EXCEPTION_HPP 8 | #define WCL_EXCEPTION_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | namespace WCL 15 | { 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | // Report an unhandled exception. 19 | 20 | CORE_MSPRINTF(1, 2) 21 | void ReportUnhandledException(const tchar* pszMsg, ...); 22 | 23 | //namespace WCL 24 | } 25 | 26 | #endif // WCL_EXCEPTION_HPP 27 | -------------------------------------------------------------------------------- /FileException.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: FILEEXCEPTION.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CFileException class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef FILEEXCEPTION_HPP 13 | #define FILEEXCEPTION_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StreamException.hpp" 20 | 21 | // Forward declarations. 22 | class CFile; 23 | class CPath; 24 | 25 | /****************************************************************************** 26 | ** 27 | ** This exception class is thrown by CFile. 28 | ** 29 | ******************************************************************************* 30 | */ 31 | 32 | class CFileException : public CStreamException 33 | { 34 | public: 35 | // 36 | // Exception codes (File specific). 37 | // (0 - 9) defined by CStreamException 38 | // 39 | enum ErrCode 40 | { 41 | E_READ_ONLY = 10, // File is read-only. 42 | E_PATH_INVALID, // Path is invalid. 43 | }; 44 | 45 | // 46 | // Constructors/Destructor. 47 | // 48 | CFileException(int eErrCode, const CPath& rPath, DWORD dwLastError); 49 | virtual ~CFileException() throw(); 50 | 51 | protected: 52 | // 53 | // Members. 54 | // 55 | }; 56 | 57 | /****************************************************************************** 58 | ** 59 | ** Implementation of inline functions. 60 | ** 61 | ******************************************************************************* 62 | */ 63 | 64 | #endif //FILEEXCEPTION_HPP 65 | -------------------------------------------------------------------------------- /Font.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: FONT.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CFont class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef FONT_HPP 13 | #define FONT_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "LogFont.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This class wraps a standard GDI font. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CFont 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CFont(); 35 | CFont(int iID); 36 | CFont(const CLogFont& rLogFont); 37 | CFont(HFONT hFont, bool bOwn = false); 38 | CFont(const CFont& rhs); 39 | ~CFont(); 40 | 41 | CFont& operator=(const CFont& rhs); 42 | 43 | // 44 | // Properties. 45 | // 46 | HFONT Handle() const; 47 | 48 | // 49 | // Methods. 50 | // 51 | bool Create(int iID); 52 | bool Create(const CLogFont& rLogFont); 53 | void Create(HFONT hFont, bool bOwn = false); 54 | 55 | bool Select(const CWnd& rParent); 56 | 57 | CString Format(CLogFont::FontFormat eFormat) const; 58 | static bool Parse(const tchar* pszFont, CFont& oFont); 59 | 60 | protected: 61 | // 62 | // Members. 63 | // 64 | HFONT m_hFont; 65 | bool m_bOwner; 66 | 67 | // 68 | // Internal methods. 69 | // 70 | void Release(); 71 | }; 72 | 73 | /****************************************************************************** 74 | ** 75 | ** Implementation of inline functions. 76 | ** 77 | ******************************************************************************* 78 | */ 79 | 80 | inline HFONT CFont::Handle() const 81 | { 82 | return m_hFont; 83 | } 84 | 85 | #endif //FONT_HPP 86 | -------------------------------------------------------------------------------- /FrameMenu.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: FRAMEMENU.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CFrameMenu class methods. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "FrameMenu.hpp" 13 | #include "Module.hpp" 14 | 15 | /****************************************************************************** 16 | ** Method: Constructor 17 | ** 18 | ** Description: . 19 | ** 20 | ** Parameters: None. 21 | ** 22 | ** Returns: Nothing. 23 | ** 24 | ******************************************************************************* 25 | */ 26 | 27 | CFrameMenu::CFrameMenu() 28 | { 29 | } 30 | 31 | /****************************************************************************** 32 | ** Method: Destructor 33 | ** 34 | ** Description: . 35 | ** 36 | ** Parameters: None. 37 | ** 38 | ** Returns: Nothing. 39 | ** 40 | ******************************************************************************* 41 | */ 42 | 43 | CFrameMenu::~CFrameMenu() 44 | { 45 | if (m_hMenu != NULL) 46 | ::DestroyMenu(m_hMenu); 47 | } 48 | 49 | /****************************************************************************** 50 | ** Method: LoadRsc() 51 | ** 52 | ** Description: Loads a menu from the resource file. 53 | ** 54 | ** Parameters: iRscID The resource ID. 55 | ** 56 | ** Returns: Nothing. 57 | ** 58 | ******************************************************************************* 59 | */ 60 | 61 | void CFrameMenu::LoadRsc(uint iRscID) 62 | { 63 | // Free previous menu. 64 | if (m_hMenu != NULL) 65 | { 66 | ::DestroyMenu(m_hMenu); 67 | m_hMenu = NULL; 68 | } 69 | 70 | // Load the resource. 71 | m_hMenu = ::LoadMenu(CModule::This().Handle(), MAKEINTRESOURCE(iRscID)); 72 | 73 | ASSERT(m_hMenu != NULL); 74 | } 75 | -------------------------------------------------------------------------------- /FrameMenu.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: FRAMEMENU.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CFrameMenu class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef FRAMEMENU_HPP 13 | #define FRAMEMENU_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Menu.hpp" 20 | #include "PopupMenu.hpp" 21 | 22 | /****************************************************************************** 23 | ** 24 | ** This is a menu derived class for frame window menus. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CFrameMenu : public CMenu 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CFrameMenu(); 36 | ~CFrameMenu(); 37 | 38 | void LoadRsc(uint iRscID); 39 | 40 | // 41 | // Methods. 42 | // 43 | // CPopupMenu Popup(uint nPos); 44 | 45 | protected: 46 | // 47 | // Members. 48 | // 49 | }; 50 | 51 | /****************************************************************************** 52 | ** 53 | ** Implementation of inline functions. 54 | ** 55 | ******************************************************************************* 56 | */ 57 | /* 58 | inline CPopupMenu CFrameMenu::Popup(uint nPos) 59 | { 60 | return CPopupMenu(::GetSubMenu(m_hMenu, nPos)); 61 | } 62 | */ 63 | #endif //FRAMEMENU_HPP 64 | -------------------------------------------------------------------------------- /HelpFile.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: HELPFILE.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CHelpFile class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef HELPFILE_HPP 13 | #define HELPFILE_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** This class provides a simple wrapper around a Windows Help File. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CHelpFile 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CHelpFile(CWnd& rParent); 33 | 34 | // 35 | // Commands. 36 | // 37 | void Contents(); 38 | void Topic(DWORD dwTopic); 39 | void Close(); 40 | 41 | // 42 | // Members. 43 | // 44 | CPath m_HelpFile; 45 | CWnd& m_rParent; 46 | }; 47 | 48 | 49 | /****************************************************************************** 50 | ** 51 | ** Implementation of inline functions. 52 | ** 53 | ******************************************************************************* 54 | */ 55 | 56 | inline CHelpFile::CHelpFile(CWnd& rParent) 57 | : m_rParent(rParent) 58 | { 59 | } 60 | 61 | inline void CHelpFile::Contents() 62 | { 63 | WinHelp(m_rParent.Handle(), m_HelpFile, HELP_CONTENTS, 0L); 64 | } 65 | 66 | inline void CHelpFile::Topic(DWORD dwTopic) 67 | { 68 | WinHelp(m_rParent.Handle(), m_HelpFile, HELP_CONTEXT, dwTopic); 69 | } 70 | 71 | inline void CHelpFile::Close() 72 | { 73 | WinHelp(m_rParent.Handle(), m_HelpFile, HELP_QUIT, 0L); 74 | } 75 | 76 | #endif //HELPFILE_HPP 77 | -------------------------------------------------------------------------------- /HintBar.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: HINTBAR.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CHintBar class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef HINTBAR_HPP 13 | #define HINTBAR_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "CtrlWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is a child window used to display hints. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CHintBar : public CCtrlWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CHintBar(); 35 | 36 | // 37 | // Member setting. 38 | // 39 | void Hint(uint iRscID); 40 | void Hint(const tchar* pszHint); 41 | 42 | protected: 43 | // 44 | // Members. 45 | // 46 | CString m_strHint; 47 | 48 | // 49 | // Window creation template methods. 50 | // 51 | virtual void GetClassParams(WNDCLASS& rParams); 52 | virtual void GetCreateParams(WNDCREATE& rParams); 53 | 54 | // 55 | // Message processors. 56 | // 57 | virtual void OnPaint(CDC& rDC); 58 | }; 59 | 60 | /****************************************************************************** 61 | ** 62 | ** Implementation of inline functions. 63 | ** 64 | ******************************************************************************* 65 | */ 66 | 67 | #endif //HINTBAR_HPP 68 | -------------------------------------------------------------------------------- /ICmdController.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file ICmdController.hpp 3 | //! \brief The ICmdController interface declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_ICMDCONTROLLER_HPP 8 | #define WCL_ICMDCONTROLLER_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | // Forward declarations. 15 | class CDC; 16 | class CRect; 17 | 18 | namespace WCL 19 | { 20 | 21 | //////////////////////////////////////////////////////////////////////////////// 22 | //! The controller used to execute commands and update the UI. 23 | 24 | class ICmdController 25 | { 26 | public: 27 | //! Destructor. 28 | virtual ~ICmdController() {}; 29 | 30 | //! Execute a command. 31 | virtual void Execute(uint command) = 0; 32 | 33 | //! Refresh the entire UI. 34 | virtual void UpdateUI() = 0; 35 | 36 | //! Draw the icon for a command. 37 | virtual void DrawCmd(uint command, CDC& dc, const CRect& rect, bool enabled) const = 0; 38 | 39 | //! Get the hint string for a command. 40 | virtual CString CmdHintStr(uint command) const = 0; 41 | 42 | //! Get the tool tip for a command. 43 | virtual CString CmdToolTipStr(uint command) const = 0; 44 | }; 45 | 46 | //namespace WCL 47 | } 48 | 49 | #endif // WCL_ICMDCONTROLLER_HPP 50 | -------------------------------------------------------------------------------- /ICommandWnd.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file ICommandWnd.hpp 3 | //! \brief The ICommandWnd interface declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_ICOMMANDWND_HPP 8 | #define WCL_ICOMMANDWND_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | namespace WCL 15 | { 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | //! A window that is used to invoke application commands. This is usually the 19 | //! main application window. 20 | 21 | class ICommandWnd 22 | { 23 | public: 24 | //! Handle updates to any command states. 25 | virtual void OnCommandsUpdated() = 0; 26 | 27 | protected: 28 | // Make abstract. 29 | virtual ~ICommandWnd() {}; 30 | }; 31 | 32 | //namespace WCL 33 | } 34 | 35 | #endif // WCL_ICOMMANDWND_HPP 36 | -------------------------------------------------------------------------------- /IConfigProvider.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file IConfigProvider.hpp 3 | //! \brief The IConfigProvider interface declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_ICONFIGPROVIDER_HPP 8 | #define WCL_ICONFIGPROVIDER_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | namespace WCL 15 | { 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | //! The interface for providers that store application settings. 19 | 20 | class IConfigProvider 21 | { 22 | public: 23 | //! Destructor. 24 | virtual ~IConfigProvider() {}; 25 | 26 | // 27 | // Methods. 28 | // 29 | 30 | //! Read a string value. 31 | virtual tstring readString(const tstring& sectionName, const tstring& keyName, const tstring& defaultValue) const = 0; 32 | 33 | //! Write a string value. 34 | virtual void writeString(const tstring& sectionName, const tstring& keyName, const tstring& value) = 0; 35 | 36 | //! Delete the entire section. 37 | virtual void deleteSection(const tstring& sectionName) = 0; 38 | }; 39 | 40 | //! The default IConfigProvider smart-pointer type. 41 | typedef Core::SharedPtr IConfigProviderPtr; 42 | 43 | //namespace WCL 44 | } 45 | 46 | #endif // WCL_ICONFIGPROVIDER_HPP 47 | -------------------------------------------------------------------------------- /IFaceTraits.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file IFaceTraits.hpp 3 | //! \brief The IFaceTraits class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_IFACETRAITS_HPP 8 | #define WCL_IFACETRAITS_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include 15 | 16 | namespace WCL 17 | { 18 | 19 | //////////////////////////////////////////////////////////////////////////////// 20 | //! Interface traits used to workaround compilers which do not support the 21 | //! __uuidof() extension. If the compiler doesn't support the extension you need 22 | //! to specialise the template for each interface type. 23 | 24 | // Visual C++ 25 | #ifdef _MSC_VER 26 | 27 | template 28 | struct IFaceTraits 29 | { 30 | //! Get the GUID for the interface. 31 | static const IID& uuidof() 32 | { 33 | return __uuidof(T); 34 | } 35 | }; 36 | 37 | // GCC etc. 38 | #else 39 | 40 | template 41 | struct IFaceTraits; 42 | 43 | //////////////////////////////////////////////////////////////////////////////// 44 | //! Declare the traits for a COM interface. 45 | //! NB: Remember to use an #ifdef guard around the macro for non-MS compilers. 46 | 47 | #define WCL_DECLARE_IFACETRAITS(iface, iid) \ 48 | namespace WCL \ 49 | { \ 50 | template<> \ 51 | struct IFaceTraits \ 52 | { \ 53 | static const IID& uuidof() \ 54 | { return iid; } \ 55 | }; \ 56 | } 57 | 58 | #endif 59 | 60 | //namespace WCL 61 | } 62 | 63 | #endif // WCL_IFACETRAITS_HPP 64 | -------------------------------------------------------------------------------- /IInputStream.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file IInputStream.hpp 3 | //! \brief The IInputStream interface declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_IINPUTSTREAM_HPP 8 | #define WCL_IINPUTSTREAM_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include "IStreamBase.hpp" 15 | 16 | namespace WCL 17 | { 18 | 19 | //////////////////////////////////////////////////////////////////////////////// 20 | //! The interface implemented by streams that support reading. 21 | 22 | class IInputStream : public WCL::IStreamBase 23 | { 24 | public: 25 | //! Read a number of bytes from the stream. 26 | virtual void Read(void* pBuffer, size_t iNumBytes) = 0; 27 | 28 | //! Query if the End of File has been reached. 29 | virtual bool IsEOF() = 0; 30 | 31 | protected: 32 | //! Protected destructor. 33 | virtual ~IInputStream() {}; 34 | }; 35 | 36 | //namespace WCL 37 | } 38 | 39 | //////////////////////////////////////////////////////////////////////////////// 40 | // Stream extractors for the primitive types. 41 | 42 | inline void operator>>(WCL::IInputStream& rStream, bool& rBuffer) 43 | { 44 | rStream.Read(&rBuffer, sizeof(bool)); 45 | } 46 | 47 | inline void operator>>(WCL::IInputStream& rStream, int8& rBuffer) 48 | { 49 | rStream.Read(&rBuffer, sizeof(int8)); 50 | } 51 | 52 | inline void operator>>(WCL::IInputStream& rStream, int16& rBuffer) 53 | { 54 | rStream.Read(&rBuffer, sizeof(int16)); 55 | } 56 | 57 | inline void operator>>(WCL::IInputStream& rStream, int32& rBuffer) 58 | { 59 | rStream.Read(&rBuffer, sizeof(int32)); 60 | } 61 | 62 | inline void operator>>(WCL::IInputStream& rStream, uint8& rBuffer) 63 | { 64 | rStream.Read(&rBuffer, sizeof(uint8)); 65 | } 66 | 67 | inline void operator>>(WCL::IInputStream& rStream, uint16& rBuffer) 68 | { 69 | rStream.Read(&rBuffer, sizeof(uint16)); 70 | } 71 | 72 | inline void operator>>(WCL::IInputStream& rStream, uint32& rBuffer) 73 | { 74 | rStream.Read(&rBuffer, sizeof(uint32)); 75 | } 76 | 77 | #endif // WCL_IINPUTSTREAM_HPP 78 | -------------------------------------------------------------------------------- /IMsgFilter.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: IMSGFILTER.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The IMsgFilter interface declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef IMSGFILTER_HPP 13 | #define IMSGFILTER_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** The interface used for pre-processing Windows messages. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class IMsgFilter 27 | { 28 | public: 29 | // 30 | // Methods. 31 | // 32 | virtual bool ProcessMsg(MSG& rMsg) = 0; 33 | 34 | protected: 35 | // Make abstract. 36 | virtual ~IMsgFilter() {}; 37 | }; 38 | 39 | #endif //IMSGFILTER_HPP 40 | -------------------------------------------------------------------------------- /IMsgThread.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file IMsgThread.hpp 3 | //! \brief The IMsgThread interface declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_IMSGTHREAD_HPP 8 | #define WCL_IMSGTHREAD_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | // Forward declarations. 15 | class IMsgFilter; 16 | 17 | namespace WCL 18 | { 19 | 20 | //////////////////////////////////////////////////////////////////////////////// 21 | //! A thread that contains a message queue. This type of thread is used for 22 | //! UI based code. 23 | 24 | class IMsgThread 25 | { 26 | public: 27 | //! Attach a message queue filter. 28 | virtual void AddMsgFilter(IMsgFilter* pFilter) = 0; 29 | 30 | //! Detach a message queue filter. 31 | virtual void RemoveMsgFilter(IMsgFilter* pFilter) = 0; 32 | 33 | protected: 34 | // Make abstract. 35 | virtual ~IMsgThread() {}; 36 | }; 37 | 38 | //namespace WCL 39 | } 40 | 41 | #endif // WCL_IMSGTHREAD_HPP 42 | -------------------------------------------------------------------------------- /IStreamBase.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file IStreamBase.hpp 3 | //! \brief The IStreamBase interface declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_ISTREAMBASE_HPP 8 | #define WCL_ISTREAMBASE_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | namespace WCL 15 | { 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | //! The base interface for the IInputStream and IOutputStream interfaces. This 19 | //! interface allows a format and version number to be associated with the 20 | //! stream so that lower-level code can handle schema changes. 21 | 22 | class IStreamBase 23 | { 24 | public: 25 | // 26 | // Types. 27 | // 28 | 29 | //! The relative file position to seek from. 30 | enum SeekPos 31 | { 32 | BEGIN = FILE_BEGIN, 33 | CURRENT = FILE_CURRENT, 34 | END = FILE_END, 35 | }; 36 | 37 | // 38 | // Properties. 39 | // 40 | 41 | //! Get the stream contents format. 42 | virtual uint32 Format() const = 0; 43 | 44 | //! Set the stream contents format. 45 | virtual void SetFormat(uint32 nFormat) = 0; 46 | 47 | //! Get the stream contents version. 48 | virtual uint32 Version() const = 0; 49 | 50 | //! Set the stream contents version. 51 | virtual void SetVersion(uint32 nVersion) = 0; 52 | 53 | // 54 | // Methods. 55 | // 56 | 57 | //! Move the stream pointer. 58 | virtual StreamPos Seek(StreamPos lPos, SeekPos eFrom = BEGIN) = 0; 59 | 60 | //! Throw a stream specific exception with the specified error code. 61 | virtual void Throw(int eErrCode, DWORD dwLastError) = 0; 62 | 63 | protected: 64 | //! Protected destructor. 65 | virtual ~IStreamBase() {}; 66 | }; 67 | 68 | //namespace WCL 69 | } 70 | 71 | #endif // WCL_ISTREAMBASE_HPP 72 | -------------------------------------------------------------------------------- /IThreadLock.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: ITHREADLOCK.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The IThreadLock interface declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef ITHREADLOCK_HPP 13 | #define ITHREADLOCK_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** Interface for controlling a thread lock. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class IThreadLock 27 | { 28 | public: 29 | // 30 | // Methods. 31 | // 32 | virtual void Acquire() = 0; 33 | virtual void Release() = 0; 34 | 35 | protected: 36 | // Make interface. 37 | virtual ~IThreadLock() {}; 38 | }; 39 | 40 | /****************************************************************************** 41 | ** 42 | ** Implementation of inline functions. 43 | ** 44 | ******************************************************************************* 45 | */ 46 | 47 | #endif // ITHREADLOCK_HPP 48 | -------------------------------------------------------------------------------- /IUiCommand.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file IUiCommand.hpp 3 | //! \brief The IUiCommand interface declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_IUICOMMAND_HPP 8 | #define WCL_IUICOMMAND_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include 15 | 16 | // Forward declarations. 17 | class CDC; 18 | class CRect; 19 | 20 | namespace WCL 21 | { 22 | 23 | //////////////////////////////////////////////////////////////////////////////// 24 | //! A user interface command. These commands are usually exposed as menu items 25 | //! and tool bar buttons and dispatched by implementations of ICmdController. 26 | 27 | class IUiCommand 28 | { 29 | public: 30 | // 31 | // Properties. 32 | // 33 | 34 | //! Get the unique ID of the command. 35 | virtual uint id() const = 0; 36 | 37 | //! Get the hint for the command. 38 | virtual tstring hint() const = 0; 39 | 40 | //! Get the tool tip for the command. 41 | virtual tstring toolTip() const = 0; 42 | 43 | // 44 | // Methods. 45 | // 46 | 47 | //! Execute the command. 48 | virtual void execute() = 0; 49 | 50 | //! Refresh the UI for the command. 51 | virtual void updateUi() = 0; 52 | 53 | //! Draw the icon for a command. 54 | virtual void drawIcon(CDC& dc, const CRect& rect, bool enabled) const = 0; 55 | 56 | public: 57 | //! Make abstract. 58 | virtual ~IUiCommand() /*= 0*/ {}; 59 | }; 60 | 61 | //! The default smart-pointer type. 62 | typedef Core::SharedPtr IUiCommandPtr; 63 | 64 | //namespace WCL 65 | } 66 | 67 | #endif // WCL_IUICOMMAND_HPP 68 | -------------------------------------------------------------------------------- /Icon.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: ICON.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CIcon class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef ICON_HPP 13 | #define ICON_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** This class wraps a standard GDI icon. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CIcon /*: private NotCopyable*/ 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CIcon(); 33 | CIcon(uint nRscID); 34 | CIcon(uint nRscID, uint nWidth, uint nHeight); 35 | ~CIcon(); 36 | 37 | void LoadRsc(uint nRscID); 38 | void LoadRsc(uint nRscID, uint nWidth, uint nHeight); 39 | void LoadRsc(const tchar* pszRsc); 40 | 41 | // 42 | // Member access. 43 | // 44 | HICON Handle() const; 45 | 46 | protected: 47 | // 48 | // Members. 49 | // 50 | HICON m_hIcon; 51 | bool m_bOwner; 52 | 53 | private: 54 | // NotCopyable. 55 | CIcon(const CIcon&); 56 | CIcon& operator=(const CIcon&); 57 | }; 58 | 59 | /****************************************************************************** 60 | ** 61 | ** Implementation of inline functions. 62 | ** 63 | ******************************************************************************* 64 | */ 65 | 66 | inline HICON CIcon::Handle() const 67 | { 68 | return m_hIcon; 69 | } 70 | 71 | #endif // ICON_HPP 72 | -------------------------------------------------------------------------------- /IconCtrl.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: ICONCTRL.CPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: CIconCtrl class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "IconCtrl.hpp" 13 | #include "Icon.hpp" 14 | 15 | /****************************************************************************** 16 | ** Method: Constructor. 17 | ** 18 | ** Description: . 19 | ** 20 | ** Parameters: None. 21 | ** 22 | ** Returns: Nothing. 23 | ** 24 | ******************************************************************************* 25 | */ 26 | 27 | CIconCtrl::CIconCtrl() 28 | { 29 | } 30 | 31 | /****************************************************************************** 32 | ** Method: GetCreateParams() 33 | ** 34 | ** Description: Template method to get the window creation data. 35 | ** 36 | ** Parameters: rParams The create structure to fill. 37 | ** 38 | ** Returns: Nothing. 39 | ** 40 | ******************************************************************************* 41 | */ 42 | 43 | void CIconCtrl::GetCreateParams(WNDCREATE& rParams) 44 | { 45 | // Get base class settings. 46 | CCtrlWnd::GetCreateParams(rParams); 47 | 48 | // Override any settings. 49 | rParams.pszClassName = TXT("STATIC"); 50 | rParams.dwStyle |= SS_ICON; 51 | } 52 | 53 | /****************************************************************************** 54 | ** Method: Icon() 55 | ** 56 | ** Description: Set the icon to the resource specified. 57 | ** 58 | ** Parameters: nRscID The icon resource ID. 59 | ** 60 | ** Returns: Nothing. 61 | ** 62 | ******************************************************************************* 63 | */ 64 | 65 | void CIconCtrl::Icon(uint nRscID) 66 | { 67 | CIcon oIcon; 68 | 69 | oIcon.LoadRsc(nRscID); 70 | 71 | Icon(oIcon.Handle()); 72 | } 73 | -------------------------------------------------------------------------------- /IconCtrl.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: ICONCTRL.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CIconCtrl class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef ICONCTRL_HPP 13 | #define ICONCTRL_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StdWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is a static control used to display an Icon. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CIconCtrl : public CStdWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CIconCtrl(); 35 | 36 | // 37 | // Standard methods. 38 | // 39 | void Icon(HICON hIcon); 40 | void Icon(uint nRscID); 41 | 42 | protected: 43 | // 44 | // Members. 45 | // 46 | 47 | // 48 | // Window creation template methods. 49 | // 50 | virtual void GetCreateParams(WNDCREATE& rParams); 51 | }; 52 | 53 | /****************************************************************************** 54 | ** 55 | ** Implementation of inline functions. 56 | ** 57 | ******************************************************************************* 58 | */ 59 | 60 | inline void CIconCtrl::Icon(HICON hIcon) 61 | { 62 | ::SendMessage(m_hWnd, STM_SETICON, reinterpret_cast(hIcon), 0L); 63 | } 64 | 65 | #endif // ICONCTRL_HPP 66 | -------------------------------------------------------------------------------- /ImageList.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: IMAGELIST.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CImageList class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef IMAGELIST_HPP 13 | #define IMAGELIST_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This class wraps the ImageList image collection. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CImageList /*: private NotCopyable*/ 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CImageList(); 35 | ~CImageList(); 36 | 37 | void LoadRsc(uint nRscID, uint nImgWidth, COLORREF crMask, bool bOwner = false); 38 | 39 | // 40 | // Properties. 41 | // 42 | HIMAGELIST Handle() const; 43 | bool Owner() const; 44 | 45 | protected: 46 | // 47 | // Members. 48 | // 49 | HIMAGELIST m_hImageList; 50 | bool m_bOwner; 51 | 52 | private: 53 | // NotCopyable. 54 | CImageList(const CImageList&); 55 | CImageList& operator=(const CImageList&); 56 | }; 57 | 58 | /****************************************************************************** 59 | ** 60 | ** Implementation of inline functions. 61 | ** 62 | ******************************************************************************* 63 | */ 64 | 65 | inline HIMAGELIST CImageList::Handle() const 66 | { 67 | return m_hImageList; 68 | } 69 | 70 | inline bool CImageList::Owner() const 71 | { 72 | return m_bOwner; 73 | } 74 | 75 | #endif // IMAGELIST_HPP 76 | -------------------------------------------------------------------------------- /IniFileCfgProvider.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file IniFileCfgProvider.hpp 3 | //! \brief The IniFileCfgProvider class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_INIFILECFGPROVIDER_HPP 8 | #define WCL_INIFILECFGPROVIDER_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include "IConfigProvider.hpp" 15 | #include "IniFile.hpp" 16 | 17 | namespace WCL 18 | { 19 | 20 | //////////////////////////////////////////////////////////////////////////////// 21 | //! The config data provider that uses an .ini file for storage. The .ini file 22 | //! resides in the application folder. 23 | 24 | class IniFileCfgProvider : public IConfigProvider 25 | { 26 | public: 27 | //! Constructor. 28 | IniFileCfgProvider(const tstring& publisher, const tstring& application); 29 | 30 | //! Destructor. 31 | virtual ~IniFileCfgProvider(); 32 | 33 | // 34 | // Methods. 35 | // 36 | 37 | //! Check if there is a config file already. 38 | static bool isAvailable(); 39 | 40 | //! Remove the config information. 41 | static void removeConfig(); 42 | 43 | // 44 | // IConfigProvider methods. 45 | // 46 | 47 | //! Read a string value. 48 | virtual tstring readString(const tstring& sectionName, const tstring& keyName, const tstring& defaultValue) const; 49 | 50 | //! Write a string value. 51 | virtual void writeString(const tstring& sectionName, const tstring& keyName, const tstring& value); 52 | 53 | //! Delete the entire section. 54 | virtual void deleteSection(const tstring& sectionName); 55 | 56 | private: 57 | // 58 | // Members. 59 | // 60 | tstring m_publisher; //!< The name of the publisher. 61 | tstring m_application; //!< The application name. 62 | CIniFile m_iniFile; //!< The underlying storage. 63 | }; 64 | 65 | //namespace WCL 66 | } 67 | 68 | #endif // WCL_INIFILECFGPROVIDER_HPP 69 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Chris Oldwood 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Label.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: LABEL.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CLabel class methods. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "Label.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Default constructor. 16 | ** 17 | ** Description: Does nothing. 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CLabel::CLabel() 27 | { 28 | } 29 | 30 | /****************************************************************************** 31 | ** Method: GetCreateParams() 32 | ** 33 | ** Description: Template method to get the window creation data. 34 | ** 35 | ** Parameters: rParams The create structure to fill. 36 | ** 37 | ** Returns: Nothing. 38 | ** 39 | ******************************************************************************* 40 | */ 41 | 42 | void CLabel::GetCreateParams(WNDCREATE& rParams) 43 | { 44 | // Get base class settings. 45 | CCtrlWnd::GetCreateParams(rParams); 46 | 47 | // Override any settings. 48 | rParams.pszClassName = TXT("STATIC"); 49 | rParams.dwStyle |= SS_SIMPLE; 50 | } 51 | -------------------------------------------------------------------------------- /Label.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: LABEL.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CLabel class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef LABEL_HPP 13 | #define LABEL_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StdWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is a text label. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CLabel : public CStdWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CLabel(); 35 | 36 | // 37 | // Standard methods. 38 | // 39 | void Text(const tchar* pszText); 40 | void Text(const tstring& text); 41 | 42 | protected: 43 | // 44 | // Members. 45 | // 46 | 47 | // 48 | // Window creation template methods. 49 | // 50 | virtual void GetCreateParams(WNDCREATE& rParams); 51 | }; 52 | 53 | /****************************************************************************** 54 | ** 55 | ** Implementation of inline functions. 56 | ** 57 | ******************************************************************************* 58 | */ 59 | 60 | inline void CLabel::Text(const tchar* pszText) 61 | { 62 | Title(pszText); 63 | } 64 | 65 | //////////////////////////////////////////////////////////////////////////////// 66 | //! Set the text of the control. 67 | 68 | inline void CLabel::Text(const tstring& text) 69 | { 70 | Title(text); 71 | } 72 | 73 | #endif //LABEL_HPP 74 | -------------------------------------------------------------------------------- /LogFont.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: LOGFONT.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CLogFont class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef LOGFONT_HPP 13 | #define LOGFONT_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | // Forward declarations 20 | class CWnd; 21 | 22 | /****************************************************************************** 23 | ** 24 | ** A thin wrapper around the LOGFONT structure. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CLogFont : public LOGFONT 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CLogFont(); 36 | CLogFont(HFONT hFont); 37 | ~CLogFont(); 38 | 39 | //! Construction from a face name and height in pixels. 40 | CLogFont(const tchar* pszFace, long nHeight); 41 | 42 | // 43 | // Methods. 44 | // 45 | bool Select(const CWnd& rParent); 46 | 47 | // 48 | // Serialisation formats. 49 | // 50 | enum FontFormat 51 | { 52 | FMT_MINIMAL = 2, // Face name + Height. 53 | FMT_SHORT = 6, // + Weight + Italic + Underline + Strikeout 54 | FMT_FULL = 14 // All fields. 55 | }; 56 | 57 | CString Format(FontFormat eFormat) const; 58 | static bool Parse(const tchar* pszFont, CLogFont& oLogFont); 59 | 60 | protected: 61 | // 62 | // Internal methods. 63 | // 64 | 65 | //! Common construction. 66 | void Initialise(); 67 | }; 68 | 69 | /****************************************************************************** 70 | ** 71 | ** Implementation of inline functions. 72 | ** 73 | ******************************************************************************* 74 | */ 75 | 76 | #endif //LOGFONT_HPP 77 | -------------------------------------------------------------------------------- /MainDlg.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: MAINDLG.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CMainDlg class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef MAINDLG_HPP 13 | #define MAINDLG_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Dialog.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is the base class for the main dialog in a dialog based app. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CMainDlg : public CDialog 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CMainDlg(uint iRscID); 35 | virtual ~CMainDlg(); 36 | 37 | protected: 38 | // 39 | // Members. 40 | // 41 | 42 | // 43 | // Message processors. 44 | // 45 | virtual void OnPaint(CDC& rDC); 46 | }; 47 | 48 | /****************************************************************************** 49 | ** 50 | ** Implementation of inline functions. 51 | ** 52 | ******************************************************************************* 53 | */ 54 | 55 | #endif //MAINDLG_HPP 56 | -------------------------------------------------------------------------------- /MainThread.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: MAINTHREAD.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CMainThread class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef MAINTHREAD_HPP 13 | #define MAINTHREAD_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "MsgThread.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** The main application thread. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CMainThread : public CMsgThread 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CMainThread(); 35 | virtual ~CMainThread(); 36 | 37 | protected: 38 | // 39 | // Members. 40 | // 41 | 42 | // The main thread function. 43 | virtual void Run(); 44 | 45 | // 46 | // Message handlers. 47 | // 48 | virtual void OnThreadMsg(UINT nMsg, WPARAM wParam, LPARAM lParam); 49 | 50 | // Friends. 51 | friend class CApp; 52 | }; 53 | 54 | /****************************************************************************** 55 | ** 56 | ** Implementation of inline functions. 57 | ** 58 | ******************************************************************************* 59 | */ 60 | 61 | #endif // MAINTHREAD_HPP 62 | -------------------------------------------------------------------------------- /MemDC.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: MEMDC.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CMemDC class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef MEMDC_HPP 13 | #define MEMDC_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "DC.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is a Device derived class that is used when creating a dc compatible 24 | ** with another dc. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CMemDC : public CDC 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CMemDC(const CDC& rDC); 36 | virtual ~CMemDC(); 37 | 38 | // RTTI 39 | virtual Device Type() const; 40 | 41 | protected: 42 | // 43 | // Members. 44 | // 45 | Device m_devType; 46 | }; 47 | 48 | /****************************************************************************** 49 | ** 50 | ** Implementation of inline functions. 51 | ** 52 | ******************************************************************************* 53 | */ 54 | 55 | #endif //MEMDC_HPP 56 | -------------------------------------------------------------------------------- /MemStreamException.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: MEMSTREAMEXCEPTION.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CMemStreamException class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "MemStreamException.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Constructor. 16 | ** 17 | ** Description: . 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CMemStreamException::CMemStreamException(int eErrCode) 27 | { 28 | // Convert error to string. 29 | switch(eErrCode) 30 | { 31 | case E_OPEN_FAILED: 32 | m_details = TXT("An error occured opening a memory stream"); 33 | break; 34 | 35 | case E_CREATE_FAILED: 36 | m_details = TXT("An error occured creating a memory stream"); 37 | break; 38 | 39 | case E_READ_FAILED: 40 | m_details = TXT("An error occured reading from a memory stream"); 41 | break; 42 | 43 | case E_WRITE_FAILED: 44 | m_details = TXT("An error occured writing to a memory stream"); 45 | break; 46 | 47 | case E_SEEK_FAILED: 48 | m_details = TXT("An error occured seeking to a memory stream position"); 49 | break; 50 | 51 | // Shouldn't happen! 52 | default: 53 | ASSERT_FALSE(); 54 | break; 55 | } 56 | } 57 | 58 | /****************************************************************************** 59 | ** Method: Destructor. 60 | ** 61 | ** Description: . 62 | ** 63 | ** Parameters: None. 64 | ** 65 | ** Returns: Nothing. 66 | ** 67 | ******************************************************************************* 68 | */ 69 | 70 | CMemStreamException::~CMemStreamException() throw() 71 | { 72 | } 73 | -------------------------------------------------------------------------------- /MemStreamException.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: MEMSTREAMEXCEPTION.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CMemStreamException class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef MEMSTREAMEXCEPTION_HPP 13 | #define MEMSTREAMEXCEPTION_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StreamException.hpp" 20 | 21 | // Forward declarations. 22 | class CMemStream; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** This exception class is thrown by CMemStream. 27 | ** 28 | ******************************************************************************* 29 | */ 30 | 31 | class CMemStreamException : public CStreamException 32 | { 33 | public: 34 | // 35 | // Constructors/Destructor. 36 | // 37 | CMemStreamException(int eErrCode); 38 | virtual ~CMemStreamException() throw(); 39 | 40 | protected: 41 | // 42 | // Members. 43 | // 44 | }; 45 | 46 | /****************************************************************************** 47 | ** 48 | ** Implementation of inline functions. 49 | ** 50 | ******************************************************************************* 51 | */ 52 | 53 | #endif //MEMSTREAMEXCEPTION_HPP 54 | -------------------------------------------------------------------------------- /Module.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: MODULE.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CModule class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef WCL_MODULE_HPP 13 | #define WCL_MODULE_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Path.hpp" 20 | #include "WinMain.hpp" 21 | #include "DllMain.hpp" 22 | 23 | /****************************************************************************** 24 | ** 25 | ** This class holds the instance handle of an EXE or DLL module. 26 | ** 27 | ******************************************************************************* 28 | */ 29 | 30 | class CModule /*: private NotCopyable*/ 31 | { 32 | public: 33 | // 34 | // Constructors/Destructor. 35 | // 36 | CModule(); 37 | CModule(HINSTANCE hInstance); 38 | ~CModule(); 39 | 40 | // 41 | // Member access. 42 | // 43 | HINSTANCE Handle() const; 44 | 45 | // Global access to the object. 46 | static CModule& This(); 47 | 48 | // 49 | // Methods. 50 | // 51 | 52 | //! Get the full path to the module. 53 | CPath Path() const; 54 | 55 | protected: 56 | // 57 | // Members. 58 | // 59 | HINSTANCE m_hInstance; 60 | 61 | friend int WCL::winMain(HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); 62 | friend BOOL WCL::dllMain(HINSTANCE hInst, DWORD dwReason); 63 | 64 | private: 65 | // NotCopyable. 66 | CModule(const CModule&); 67 | CModule& operator=(const CModule&); 68 | }; 69 | 70 | /****************************************************************************** 71 | ** 72 | ** Implementation of inline functions. 73 | ** 74 | ******************************************************************************* 75 | */ 76 | 77 | inline HINSTANCE CModule::Handle() const 78 | { 79 | return m_hInstance; 80 | } 81 | 82 | #endif // WCL_MODULE_HPP 83 | -------------------------------------------------------------------------------- /NetFinder.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: NETFINDER.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CNetFinder class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef NETFINDER_HPP 13 | #define NETFINDER_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** Class used to enumerate network resources. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CNetFinder 27 | { 28 | public: 29 | // 30 | // Methods. 31 | // 32 | static size_t FindDomains (CStrArray& astrDomains); 33 | static size_t FindComputers(CStrArray& astrComputers); 34 | static size_t FindComputers(const tchar* pszDomain, CStrArray& astrComputers); 35 | 36 | protected: 37 | // 38 | // Members. 39 | // 40 | 41 | // 42 | // Internal methods. 43 | // 44 | static DWORD FindDomains (NETRESOURCE* pNetRsc, CStrArray& astrDomains); 45 | static DWORD FindComputers(NETRESOURCE* pNetRsc, CStrArray& astrComputers); 46 | }; 47 | 48 | /****************************************************************************** 49 | ** 50 | ** Implementation of inline functions. 51 | ** 52 | ******************************************************************************* 53 | */ 54 | 55 | #endif // NETFINDER_HPP 56 | -------------------------------------------------------------------------------- /PathEditBox.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: PATHEDITBOX.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CPathEditBox class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "PathEditBox.hpp" 13 | 14 | /****************************************************************************** 15 | ** 16 | ** Local variables. 17 | ** 18 | ******************************************************************************* 19 | */ 20 | 21 | // Character filter (invalid characters in a path). 22 | static const tchar* s_pszFilter = TXT("*?\"<>|"); 23 | 24 | /****************************************************************************** 25 | ** Method: Constructor. 26 | ** 27 | ** Description: . 28 | ** 29 | ** Parameters: None. 30 | ** 31 | ** Returns: Nothing. 32 | ** 33 | ******************************************************************************* 34 | */ 35 | 36 | CPathEditBox::CPathEditBox() : CEditBox() 37 | { 38 | // Setup character filter. 39 | SetFilterDefault(true); 40 | Filter(s_pszFilter, false); 41 | } 42 | 43 | /****************************************************************************** 44 | ** Method: Destructor. 45 | ** 46 | ** Description: . 47 | ** 48 | ** Parameters: None. 49 | ** 50 | ** Returns: Nothing. 51 | ** 52 | ******************************************************************************* 53 | */ 54 | 55 | CPathEditBox::~CPathEditBox() 56 | { 57 | } 58 | -------------------------------------------------------------------------------- /PathEditBox.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: PATHEDITBOX.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CPathEditBox class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef PATHEDITBOX_HPP 13 | #define PATHEDITBOX_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "EditBox.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This edit box derived control is used for entering file paths. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CPathEditBox : public CEditBox 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CPathEditBox(); 35 | ~CPathEditBox(); 36 | 37 | protected: 38 | // 39 | // Members. 40 | // 41 | }; 42 | 43 | /****************************************************************************** 44 | ** 45 | ** Implementation of inline functions. 46 | ** 47 | ******************************************************************************* 48 | */ 49 | 50 | #endif //PATHEDITBOX_HPP 51 | -------------------------------------------------------------------------------- /Pen.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: PEN.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CPen class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "Pen.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Constructor. 16 | ** 17 | ** Description: . 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CPen::CPen() 27 | : m_hPen(NULL) 28 | , m_bOwner(false) 29 | { 30 | } 31 | 32 | CPen::CPen(int iID) 33 | : m_hPen() 34 | , m_bOwner() 35 | { 36 | Create(iID); 37 | } 38 | 39 | CPen::CPen(int iStyle, int iWidth, COLORREF crClr) 40 | : m_hPen() 41 | , m_bOwner() 42 | { 43 | Create(iStyle, iWidth, crClr); 44 | } 45 | 46 | /****************************************************************************** 47 | ** Method: Destructor. 48 | ** 49 | ** Description: . 50 | ** 51 | ** Parameters: None. 52 | ** 53 | ** Returns: Nothing. 54 | ** 55 | ******************************************************************************* 56 | */ 57 | 58 | CPen::~CPen() 59 | { 60 | // Delete if valid and we own it. 61 | if ( (m_hPen) && (m_bOwner) ) 62 | ::DeleteObject(m_hPen); 63 | } 64 | 65 | void CPen::Create(int iID) 66 | { 67 | m_hPen = GetStockPen(iID); 68 | m_bOwner = false; 69 | 70 | ASSERT(m_hPen != NULL); 71 | } 72 | 73 | void CPen::Create(int iStyle, int iWidth, COLORREF crClr) 74 | { 75 | m_hPen = ::CreatePen(iStyle, iWidth, crClr); 76 | m_bOwner = true; 77 | 78 | ASSERT(m_hPen != NULL); 79 | } 80 | -------------------------------------------------------------------------------- /Pen.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: PEN.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CPen class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef PEN_HPP 13 | #define PEN_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** This class wraps a standard GDI pen. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CPen /*: private NotCopyable*/ 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CPen(); 33 | CPen(int iID); 34 | CPen(int iStyle, int iWidth, COLORREF crClr); 35 | ~CPen(); 36 | 37 | void Create(int iID); 38 | void Create(int iStyle, int iWidth, COLORREF crClr); 39 | 40 | // 41 | // Member access. 42 | // 43 | HPEN Handle() const; 44 | 45 | protected: 46 | // 47 | // Members. 48 | // 49 | HPEN m_hPen; 50 | bool m_bOwner; 51 | 52 | CORE_NOT_COPYABLE(CPen); 53 | }; 54 | 55 | /****************************************************************************** 56 | ** 57 | ** Implementation of inline functions. 58 | ** 59 | ******************************************************************************* 60 | */ 61 | 62 | inline HPEN CPen::Handle() const 63 | { 64 | return m_hPen; 65 | } 66 | 67 | #endif //PEN_HPP 68 | -------------------------------------------------------------------------------- /Point.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: POINT.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CPoint class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef POINT_HPP 13 | #define POINT_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | // Forward declarations 20 | class CRect; 21 | 22 | /****************************************************************************** 23 | ** 24 | ** This is a class based version of the Windows standard POINT structure. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CPoint : public tagPOINT 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CPoint(); 36 | CPoint(const POINT& pt); 37 | CPoint(int iX, int iY); 38 | 39 | // 40 | // Methods. 41 | // 42 | void Set(int iX, int iY); 43 | bool IsIn(const CRect& rcRect) const; 44 | }; 45 | 46 | 47 | /****************************************************************************** 48 | ** 49 | ** Implementation of inline functions. 50 | ** 51 | ******************************************************************************* 52 | */ 53 | 54 | inline CPoint::CPoint() 55 | { 56 | Set(0, 0); 57 | } 58 | 59 | inline CPoint::CPoint(const POINT& pt) 60 | { 61 | Set(pt.x, pt.y); 62 | } 63 | 64 | inline CPoint::CPoint(int iX, int iY) 65 | { 66 | Set(iX, iY); 67 | } 68 | 69 | inline void CPoint::Set(int iX, int iY) 70 | { 71 | x = iX; 72 | y = iY; 73 | } 74 | 75 | inline bool CPoint::IsIn(const CRect& rcRect) const 76 | { 77 | // NB: reinterpret_cast is needed because of the forward declaration of CRect. 78 | return ::PtInRect(reinterpret_cast(&rcRect), *this); 79 | } 80 | 81 | #endif //POINT_HPP 82 | -------------------------------------------------------------------------------- /PopupMenu.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: POPUPMENU.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CPopupMenu class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef POPUPMENU_HPP 13 | #define POPUPMENU_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Menu.hpp" 20 | 21 | // Forward declarations. 22 | class CWnd; 23 | class CPoint; 24 | 25 | /****************************************************************************** 26 | ** 27 | ** This is a menu derived class for pop-up (context) menus. 28 | ** 29 | ******************************************************************************* 30 | */ 31 | 32 | class CPopupMenu : public CMenu 33 | { 34 | public: 35 | // 36 | // Constructors/Destructor. 37 | // 38 | CPopupMenu(); 39 | CPopupMenu(HMENU hMenu); 40 | CPopupMenu(uint iRscID); 41 | CPopupMenu(const CPopupMenu& rhs); 42 | virtual ~CPopupMenu(); 43 | 44 | void LoadRsc(uint iRscID); 45 | 46 | uint TrackMenu(const CWnd& rParent, const CPoint& ptOrigin) const; 47 | 48 | protected: 49 | // 50 | // Members. 51 | // 52 | HMENU m_hParent; 53 | 54 | private: 55 | // NotCopyable. 56 | CPopupMenu& operator=(const CPopupMenu&); 57 | }; 58 | 59 | /****************************************************************************** 60 | ** 61 | ** Implementation of inline functions. 62 | ** 63 | ******************************************************************************* 64 | */ 65 | 66 | #endif //POPUPMENU_HPP 67 | -------------------------------------------------------------------------------- /Pragmas.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: PRAGMAS.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: Disable annoying Level 4 warnings. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef PRAGMAS_HPP 13 | #define PRAGMAS_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | // Nameless struct/union. 20 | #pragma warning ( disable : 4201 ) 21 | 22 | // 'this' used in base member initialisation list. 23 | #pragma warning ( disable : 4355 ) 24 | 25 | // Unreferenced local function has been removed. 26 | #pragma warning ( disable : 4505 ) 27 | 28 | // Copy constructor could not be generated. 29 | // Caused by members which are references. 30 | #pragma warning ( disable : 4511 ) 31 | 32 | // No assignment operator could be generated. 33 | // Caused by members which are references. 34 | #pragma warning ( disable : 4512 ) 35 | 36 | // Unreferenced inline function removed. 37 | #pragma warning ( disable : 4514 ) 38 | 39 | // Creating/using precompiled header. 40 | #pragma warning ( disable : 4699 ) 41 | 42 | // Statement has no effect 43 | //#pragma warning ( disable : 4705 ) 44 | 45 | // Inline function not expanded. 46 | #pragma warning ( disable : 4710 ) 47 | 48 | // Forcing value to bool true or false. 49 | #pragma warning ( disable : 4800 ) 50 | 51 | #ifdef _DEBUG 52 | 53 | // Unreachable code. 54 | // Caused by ASSERT macros when compiling a release build with asserts. 55 | #pragma warning ( disable : 4702 ) 56 | 57 | #endif 58 | 59 | #endif //PRAGMAS_HPP 60 | -------------------------------------------------------------------------------- /Printer.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: PRINTER.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CPrinter class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef PRINTER_HPP 13 | #define PRINTER_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | // Forward declarations. 20 | class CWnd; 21 | 22 | /****************************************************************************** 23 | ** 24 | ** A wrapper class used to hold the parameters required to create a printer DC. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CPrinter 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CPrinter(); 36 | ~CPrinter(); 37 | 38 | bool Select(const CWnd& rParent); 39 | 40 | // 41 | // Members. 42 | // 43 | CString m_strName; // The human-readable name. 44 | CString m_strDriver; // The printer driver. 45 | CString m_strPort; // The output port. 46 | }; 47 | 48 | /****************************************************************************** 49 | ** 50 | ** Implementation of inline functions. 51 | ** 52 | ******************************************************************************* 53 | */ 54 | 55 | #endif //PRINTER_HPP 56 | -------------------------------------------------------------------------------- /PrinterDC.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: PRINTERDC.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CPrinterDC class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef PRINTERDC_HPP 13 | #define PRINTERDC_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "DC.hpp" 20 | 21 | // Forward declarations. 22 | class CPrinter; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** This is a CDC derived class that is used for printing. 27 | ** 28 | ******************************************************************************* 29 | */ 30 | 31 | class CPrinterDC : public CDC 32 | { 33 | public: 34 | // 35 | // Constructors/Destructor. 36 | // 37 | CPrinterDC(const CPrinter& rPrinter); 38 | ~CPrinterDC(); 39 | 40 | // RTTI 41 | virtual Device Type() const; 42 | 43 | // 44 | // Commands. 45 | // 46 | bool Start(const tchar* pszTitle); 47 | void Abort(); 48 | bool End(); 49 | bool StartPage(); 50 | bool EndPage(); 51 | 52 | // 53 | // Attributes. 54 | // 55 | CRect PageArea() const; 56 | CRect PrintableArea() const; 57 | size_t PageNum() const; 58 | 59 | protected: 60 | // 61 | // Members. 62 | // 63 | size_t m_nPage; 64 | }; 65 | 66 | /****************************************************************************** 67 | ** 68 | ** Implementation of inline functions. 69 | ** 70 | ******************************************************************************* 71 | */ 72 | 73 | 74 | inline size_t CPrinterDC::PageNum() const 75 | { 76 | return m_nPage; 77 | } 78 | 79 | #endif //PRINTERDC_HPP 80 | -------------------------------------------------------------------------------- /ProgressBar.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: PROGRESSBAR.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CProgressBar class methods. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "ProgressBar.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Default constructor. 16 | ** 17 | ** Description: Does nothing. 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CProgressBar::CProgressBar() 27 | { 28 | } 29 | 30 | /****************************************************************************** 31 | ** Method: GetCreateParams() 32 | ** 33 | ** Description: Template method to get the window creation data. 34 | ** 35 | ** Parameters: rParams The create structure to fill. 36 | ** 37 | ** Returns: Nothing. 38 | ** 39 | ******************************************************************************* 40 | */ 41 | 42 | void CProgressBar::GetCreateParams(WNDCREATE& rParams) 43 | { 44 | // Get base class settings. 45 | CCtrlWnd::GetCreateParams(rParams); 46 | 47 | // Override any settings. 48 | rParams.pszClassName = PROGRESS_CLASS; 49 | // rParams.dwStyle |= ; 50 | } 51 | -------------------------------------------------------------------------------- /PropertyPage.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: PROPERTYPAGE.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CPropertyPage class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef PROPERTYPAGE_HPP 13 | #define PROPERTYPAGE_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Dialog.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is the base class for all property page dialogs. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CPropertyPage : public CDialog 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CPropertyPage(uint nRscID); 35 | virtual ~CPropertyPage(); 36 | 37 | protected: 38 | // 39 | // Members. 40 | // 41 | 42 | // 43 | // General message handlers. 44 | // 45 | static WCL::DlgResult DIALOGPROC PropPageProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam); 46 | 47 | // 48 | // Message processors. 49 | // 50 | virtual LRESULT OnCtrlMsg(NMHDR& rMsgHdr); 51 | virtual bool OnValidate(); 52 | virtual bool OnOk(); 53 | 54 | // 55 | // Friends. 56 | // 57 | friend class CPropertySheet; 58 | }; 59 | 60 | /****************************************************************************** 61 | ** 62 | ** Implementation of inline functions. 63 | ** 64 | ******************************************************************************* 65 | */ 66 | 67 | #endif //PROPERTYPAGE_HPP 68 | -------------------------------------------------------------------------------- /RadioBtn.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: RADIOBTN.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CRadioBtn class methods. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "RadioBtn.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Default constructor. 16 | ** 17 | ** Description: Override any default settings for the window class and style. 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CRadioBtn::CRadioBtn() 27 | { 28 | } 29 | 30 | /****************************************************************************** 31 | ** Method: GetCreateParams() 32 | ** 33 | ** Description: Template method to get the window creation data. 34 | ** 35 | ** Parameters: rParams The create structure to fill. 36 | ** 37 | ** Returns: Nothing. 38 | ** 39 | ******************************************************************************* 40 | */ 41 | 42 | void CRadioBtn::GetCreateParams(WNDCREATE& rParams) 43 | { 44 | // Get base class settings. 45 | CCtrlWnd::GetCreateParams(rParams); 46 | 47 | // Override any settings. 48 | rParams.pszClassName = TXT("BUTTON"); 49 | rParams.dwStyle |= BS_AUTORADIOBUTTON; 50 | } 51 | -------------------------------------------------------------------------------- /RadioBtn.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: RADIOBTN.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CRadioBtn class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef RADIOBTN_HPP 13 | #define RADIOBTN_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StdWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is a radio button control. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CRadioBtn : public CStdWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CRadioBtn(); 35 | 36 | // 37 | // Standard methods. 38 | // 39 | void Check(bool bCheck = true) const; 40 | bool IsChecked() const; 41 | 42 | protected: 43 | // 44 | // Members. 45 | // 46 | 47 | // 48 | // Window creation template methods. 49 | // 50 | virtual void GetCreateParams(WNDCREATE& rParams); 51 | }; 52 | 53 | /****************************************************************************** 54 | ** 55 | ** Implementation of inline functions. 56 | ** 57 | ******************************************************************************* 58 | */ 59 | 60 | inline void CRadioBtn::Check(bool bCheck) const 61 | { 62 | SendMessage(BM_SETCHECK, bCheck, 0); 63 | } 64 | 65 | inline bool CRadioBtn::IsChecked() const 66 | { 67 | return static_cast(SendMessage(BM_GETCHECK, 0, 0)); 68 | } 69 | 70 | #endif //RADIOBTN_HPP 71 | -------------------------------------------------------------------------------- /ReadMe.txt: -------------------------------------------------------------------------------- 1 | WCL (Windows C++) Library 2 | ========================= 3 | 4 | Introduction 5 | ------------ 6 | 7 | This C++ class library provides the core support for the Windows platform. 8 | Historically it also used to be the base class library too, but I've tried to 9 | push as much of the platform agnostic code down into the Core library. 10 | 11 | Documentation 12 | ------------- 13 | 14 | See http://www.chrisoldwood.com/win32/dox/wcl/index.html. 15 | 16 | Development 17 | ----------- 18 | 19 | See DevNotes.txt 20 | 21 | Contact Details 22 | --------------- 23 | 24 | Email: gort@cix.co.uk 25 | Web: http://www.chrisoldwood.com 26 | 27 | Chris Oldwood 28 | 22nd October 2013 29 | -------------------------------------------------------------------------------- /RegistryException.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file RegistryException.hpp 3 | //! \brief The RegistryException class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef REGISTRYEXCEPTION_HPP 8 | #define REGISTRYEXCEPTION_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include "Win32Exception.hpp" 15 | 16 | namespace WCL 17 | { 18 | 19 | //////////////////////////////////////////////////////////////////////////////// 20 | //! The exception type thrown by the RegKey class. 21 | 22 | class RegistryException : public Win32Exception 23 | { 24 | public: 25 | //! Construction from a fully formatted error message. 26 | RegistryException(const tstring& strOperation); 27 | 28 | //! Full constructor. 29 | RegistryException(LONG lError, const tchar* pszOperation); 30 | 31 | //! Full constructor. 32 | RegistryException(LONG lError, const tstring& strOperation); 33 | }; 34 | 35 | //////////////////////////////////////////////////////////////////////////////// 36 | //! Construction from a fully formatted error message. 37 | 38 | inline RegistryException::RegistryException(const tstring& strOperation) 39 | : Win32Exception() 40 | { 41 | m_details = strOperation.c_str(); 42 | } 43 | 44 | //////////////////////////////////////////////////////////////////////////////// 45 | //! Full constructor. 46 | 47 | inline RegistryException::RegistryException(LONG lError, const tchar* pszOperation) 48 | : Win32Exception(lError, pszOperation) 49 | { 50 | } 51 | 52 | //////////////////////////////////////////////////////////////////////////////// 53 | //! Full constructor. 54 | 55 | inline RegistryException::RegistryException(LONG lError, const tstring& strOperation) 56 | : Win32Exception(lError, strOperation.c_str()) 57 | { 58 | } 59 | 60 | //namespace WCL 61 | } 62 | 63 | #endif // REGISTRYEXCEPTION_HPP 64 | -------------------------------------------------------------------------------- /ResourceString.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file ResourceString.cpp 3 | //! \brief Utility functions for handling strings in module resources. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include "ResourceString.hpp" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace WCL 13 | { 14 | 15 | //////////////////////////////////////////////////////////////////////////////// 16 | //! Load a string from the specified module. 17 | 18 | tstring loadString(HMODULE module, uint resourceId) 19 | { 20 | typedef Core::ArrayPtr BufferPtr; 21 | 22 | const size_t DEFAULT_LENGTH = 256; 23 | 24 | size_t length = DEFAULT_LENGTH; 25 | BufferPtr buffer(new tchar[length+1]); 26 | 27 | for (;;) 28 | { 29 | const int bufsize = static_cast(length+1); 30 | const int copied = ::LoadString(module, resourceId, buffer.get(), bufsize); 31 | 32 | if (copied == 0) 33 | return TXT(""); 34 | 35 | if (static_cast(copied) != length) 36 | return buffer.get(); 37 | 38 | length *= 2; 39 | buffer.reset(new tchar[length+1]); 40 | } 41 | } 42 | 43 | //////////////////////////////////////////////////////////////////////////////// 44 | //! Load a string from the application module resources. 45 | 46 | tstring loadString(uint resourceId) 47 | { 48 | HMODULE module = CModule::This().Handle(); 49 | 50 | return loadString(module, resourceId); 51 | } 52 | 53 | //namespace WCL 54 | } 55 | -------------------------------------------------------------------------------- /ResourceString.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file ResourceString.hpp 3 | //! \brief Utility functions for handling strings in module resources. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_RESOURCESTRING_HPP 8 | #define WCL_RESOURCESTRING_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | namespace WCL 15 | { 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | // Load a string from the specified module. 19 | 20 | tstring loadString(HMODULE module, uint resourceId); 21 | 22 | //////////////////////////////////////////////////////////////////////////////// 23 | // Load a string from the application module resources. 24 | 25 | tstring loadString(uint resourceId); 26 | 27 | //namespace WCL 28 | } 29 | 30 | #endif // WCL_RESOURCESTRING_HPP 31 | -------------------------------------------------------------------------------- /SDICmds.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: SDICMDS.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CSDICmds class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef SDICMDS_HPP 13 | #define SDICMDS_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "CmdCtrl.hpp" 20 | 21 | // Forward declarations. 22 | class CSDIDoc; 23 | class CPath; 24 | 25 | /****************************************************************************** 26 | ** 27 | ** This is the base class for SDI application commands. 28 | ** 29 | ******************************************************************************* 30 | */ 31 | 32 | class CSDICmds : public CCmdControl 33 | { 34 | public: 35 | //! Construction with the main command window. 36 | CSDICmds(WCL::ICommandWnd& commandWnd); 37 | 38 | //! Construction with the main command window and bitmap resource ID. 39 | CSDICmds(WCL::ICommandWnd& commandWnd, uint bitmapId); 40 | 41 | virtual ~CSDICmds(); 42 | 43 | // 44 | // File commands. 45 | // 46 | bool NewFile(); 47 | bool OpenFile(); 48 | bool OpenMRUFile(size_t nIndex); 49 | bool OpenFile(const CPath& strPath); 50 | bool SaveFile(); 51 | bool SaveFileAs(); 52 | bool CloseFile(); 53 | bool ExitApp(); 54 | 55 | protected: 56 | // 57 | // Members. 58 | // 59 | 60 | // 61 | // Template methods.. 62 | // 63 | virtual void OnFileCreated(CSDIDoc& oDoc); 64 | virtual void OnFileOpened(CSDIDoc& oDoc); 65 | virtual void OnFileSaved(CSDIDoc& oDoc); 66 | virtual void OnFileClosed(CSDIDoc& oDoc); 67 | }; 68 | 69 | /****************************************************************************** 70 | ** 71 | ** Implementation of inline functions. 72 | ** 73 | ******************************************************************************* 74 | */ 75 | 76 | #endif //SDICMDS_HPP 77 | -------------------------------------------------------------------------------- /SDIDoc.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: SDIDOC.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CSDIDoc class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "SDIDoc.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Constructor. 16 | ** 17 | ** Description: . 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CSDIDoc::CSDIDoc() 27 | : m_pView(nullptr) 28 | { 29 | } 30 | 31 | /****************************************************************************** 32 | ** Method: Destructor. 33 | ** 34 | ** Description: . 35 | ** 36 | ** Parameters: None. 37 | ** 38 | ** Returns: Nothing. 39 | ** 40 | ******************************************************************************* 41 | */ 42 | 43 | CSDIDoc::~CSDIDoc() 44 | { 45 | ASSERT(m_pView == nullptr); 46 | } 47 | -------------------------------------------------------------------------------- /SDIDoc.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: SDIDOC.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CSDIDoc class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef SDIDOC_HPP 13 | #define SDIDOC_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Doc.hpp" 20 | 21 | // Forward declarations. 22 | class CView; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** This is the base class for documents used with a SDI app. 27 | ** 28 | ******************************************************************************* 29 | */ 30 | 31 | class CSDIDoc : public CDoc 32 | { 33 | public: 34 | // 35 | // Constructors/Destructor. 36 | // 37 | CSDIDoc(); 38 | virtual ~CSDIDoc(); 39 | 40 | // 41 | // Members. 42 | // 43 | CView* m_pView; // The documents' view. 44 | 45 | protected: 46 | // 47 | // Members. 48 | // 49 | 50 | private: 51 | // NotCopyable. 52 | CSDIDoc(const CSDIDoc&); 53 | CSDIDoc& operator=(const CSDIDoc&); 54 | }; 55 | 56 | //! The SDI document smart-pointer type. 57 | typedef Core::SharedPtr SDIDocPtr; 58 | 59 | #endif //SDIDOC_HPP 60 | -------------------------------------------------------------------------------- /SDIFrame.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: SDIFRAME.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CSDIFrame class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef SDIFRAME_HPP 13 | #define SDIFRAME_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "FrameWnd.hpp" 20 | 21 | // Forward declarations. 22 | class CView; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** This is the base class for an SDI applications' main window. 27 | ** 28 | ******************************************************************************* 29 | */ 30 | 31 | class CSDIFrame : public CFrameWnd 32 | { 33 | public: 34 | // 35 | // Constructors/Destructor. 36 | // 37 | CSDIFrame(uint iIconID); 38 | virtual ~CSDIFrame(); 39 | 40 | // 41 | // Methods. 42 | // 43 | void View(CView* pView); 44 | 45 | void UpdateTitle(); 46 | 47 | protected: 48 | // 49 | // Members. 50 | // 51 | CView* m_pView; // The only doc view. 52 | 53 | // Child window IDs. 54 | enum 55 | { 56 | IDC_VIEW = 100 57 | }; 58 | 59 | // 60 | // Message processors (Overridden from the base class). 61 | // 62 | virtual void OnCreate(const CRect& rcClient); 63 | virtual void OnResize(int iFlag, const CSize& rNewSize); 64 | virtual void OnDropFile(int nFile, const tchar* pszPath); 65 | virtual void OnDestroy(); 66 | 67 | //! Query whether to close the window. 68 | virtual bool OnQueryClose(); 69 | 70 | private: 71 | // NotCopyable. 72 | CSDIFrame(const CSDIFrame&); 73 | CSDIFrame& operator=(const CSDIFrame&); 74 | }; 75 | 76 | /****************************************************************************** 77 | ** 78 | ** Implementation of inline functions. 79 | ** 80 | ******************************************************************************* 81 | */ 82 | 83 | #endif //SDIFRAME_HPP 84 | -------------------------------------------------------------------------------- /ScreenDC.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: SCREENDC.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CScreenDC class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef SCREENDC_HPP 13 | #define SCREENDC_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "DC.hpp" 20 | 21 | // Forward declaration. 22 | class CWnd; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** This is a Device derived class that is appropriate for drawing to the 27 | ** display such as painting windows. 28 | ** 29 | ******************************************************************************* 30 | */ 31 | 32 | class CScreenDC : public CDC 33 | { 34 | public: 35 | // 36 | // Constructors/Destructor. 37 | // 38 | CScreenDC(); 39 | CScreenDC(const CWnd& rWnd); 40 | CScreenDC(PAINTSTRUCT& psPaint); 41 | CScreenDC(HDC hDC); 42 | virtual ~CScreenDC(); 43 | 44 | // RTTI 45 | virtual Device Type() const; 46 | 47 | protected: 48 | // 49 | // Members. 50 | // 51 | HWND m_hWnd; // Window handle of windows' device context. 52 | 53 | private: 54 | // NotCopyable. 55 | CScreenDC(const CScreenDC&); 56 | CScreenDC& operator=(const CScreenDC&); 57 | }; 58 | 59 | /****************************************************************************** 60 | ** 61 | ** Implementation of inline functions. 62 | ** 63 | ******************************************************************************* 64 | */ 65 | 66 | #endif //SCREENDC_HPP 67 | -------------------------------------------------------------------------------- /SeTranslator.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file SeTranslator.cpp 3 | //! \brief The SeTranslator class definition. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include "SeTranslator.hpp" 8 | #include "StructuredException.hpp" 9 | 10 | namespace WCL 11 | { 12 | 13 | //////////////////////////////////////////////////////////////////////////////// 14 | //! Default constructor. Install our handler. 15 | 16 | SeTranslator::SeTranslator() 17 | : m_lpfnOldTranslator(nullptr) 18 | { 19 | #ifdef _MSC_VER 20 | m_lpfnOldTranslator = _set_se_translator(Translate); 21 | #endif 22 | } 23 | 24 | //////////////////////////////////////////////////////////////////////////////// 25 | //! Destructor. Re-installs the old handler. 26 | 27 | SeTranslator::~SeTranslator() 28 | { 29 | #ifdef _MSC_VER 30 | _se_translator_function lpfn = _set_se_translator(m_lpfnOldTranslator); 31 | 32 | ASSERT(lpfn == Translate); 33 | 34 | DEBUG_USE_ONLY(lpfn); 35 | #endif 36 | } 37 | 38 | //////////////////////////////////////////////////////////////////////////////// 39 | //! Install our translator function. The method returns the previous translator 40 | //! function and assumes that we never want to uninstall it. 41 | 42 | _se_translator_function SeTranslator::Install() 43 | { 44 | #ifdef _MSC_VER 45 | return _set_se_translator(Translate); 46 | #else 47 | return nullptr; 48 | #endif 49 | } 50 | 51 | //////////////////////////////////////////////////////////////////////////////// 52 | //! The translator function. 53 | 54 | void SeTranslator::Translate(uint nCode, _EXCEPTION_POINTERS* pInfo) 55 | { 56 | throw StructuredException(nCode, pInfo); 57 | } 58 | 59 | //namespace WCL 60 | } 61 | -------------------------------------------------------------------------------- /SeTranslator.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file SeTranslator.hpp 3 | //! \brief The SeTranslator class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_SETRANSLATOR_HPP 8 | #define WCL_SETRANSLATOR_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #ifdef _MSC_VER 15 | #include 16 | #else 17 | typedef void (__cdecl *_se_translator_function)(unsigned int, struct _EXCEPTION_POINTERS*); 18 | #endif 19 | 20 | namespace WCL 21 | { 22 | 23 | //////////////////////////////////////////////////////////////////////////////// 24 | //! The RAII style class used to install and uninstall the Structured Exception 25 | //! translator function. 26 | 27 | class SeTranslator 28 | { 29 | public: 30 | //! Default constructor. 31 | SeTranslator(); 32 | 33 | //! Destructor. 34 | ~SeTranslator(); 35 | 36 | //! Install the translator function. 37 | static _se_translator_function Install(); 38 | 39 | private: 40 | // 41 | // Members. 42 | // 43 | _se_translator_function m_lpfnOldTranslator; //!< The old translator function. 44 | 45 | //! The translator function. 46 | static void Translate(uint nCode, _EXCEPTION_POINTERS* pInfo); 47 | }; 48 | 49 | //namespace WCL 50 | } 51 | 52 | #endif // WCL_SETRANSLATOR_HPP 53 | -------------------------------------------------------------------------------- /Size.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: SIZE.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CSize class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef SIZE_HPP 13 | #define SIZE_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** This is a class based version of the standard Windows SIZE structure. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CSize : public tagSIZE 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CSize(); 33 | CSize(int iWidth, int iHeight); 34 | 35 | void Set(int iWidth, int iHeight); 36 | 37 | // 38 | // Operators. 39 | // 40 | bool operator ==(const CSize& rRHS) const; 41 | bool operator !=(const CSize& rRHS) const; 42 | }; 43 | 44 | 45 | /****************************************************************************** 46 | ** 47 | ** Implementation of inline functions. 48 | ** 49 | ******************************************************************************* 50 | */ 51 | 52 | inline CSize::CSize() 53 | { 54 | Set(0, 0); 55 | } 56 | 57 | inline CSize::CSize(int iWidth, int iHeight) 58 | { 59 | Set(iWidth, iHeight); 60 | } 61 | 62 | inline void CSize::Set(int iWidth, int iHeight) 63 | { 64 | cx = iWidth; 65 | cy = iHeight; 66 | } 67 | 68 | inline bool CSize::operator ==(const CSize& rRHS) const 69 | { 70 | return ( (cx == rRHS.cx) && (cy == rRHS.cy) ); 71 | } 72 | 73 | inline bool CSize::operator !=(const CSize& rRHS) const 74 | { 75 | return ( (cx != rRHS.cx) || (cy != rRHS.cy) ); 76 | } 77 | 78 | #endif //SIZE_HPP 79 | -------------------------------------------------------------------------------- /StaticCtrl.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: STATICCTRL.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CStaticCtrl class methods. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "StaticCtrl.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Default constructor. 16 | ** 17 | ** Description: Does nothing. 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CStaticCtrl::CStaticCtrl() 27 | { 28 | } 29 | 30 | /****************************************************************************** 31 | ** Method: GetCreateParams() 32 | ** 33 | ** Description: Template method to get the window creation data. 34 | ** 35 | ** Parameters: rParams The create structure to fill. 36 | ** 37 | ** Returns: Nothing. 38 | ** 39 | ******************************************************************************* 40 | */ 41 | 42 | void CStaticCtrl::GetCreateParams(WNDCREATE& rParams) 43 | { 44 | // Get base class settings. 45 | CCtrlWnd::GetCreateParams(rParams); 46 | 47 | // Override any settings. 48 | rParams.pszClassName = TXT("STATIC"); 49 | rParams.dwStyle |= SS_SIMPLE; 50 | } 51 | -------------------------------------------------------------------------------- /StaticCtrl.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: STATICCTRL.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CStaticCtrl class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef STATICCTRL_HPP 13 | #define STATICCTRL_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StdWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This a static control. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CStaticCtrl : public CStdWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CStaticCtrl(); 35 | 36 | // 37 | // Standard methods. 38 | // 39 | 40 | protected: 41 | // 42 | // Members. 43 | // 44 | 45 | // 46 | // Window creation template methods. 47 | // 48 | virtual void GetCreateParams(WNDCREATE& rParams); 49 | }; 50 | 51 | /****************************************************************************** 52 | ** 53 | ** Implementation of inline functions. 54 | ** 55 | ******************************************************************************* 56 | */ 57 | 58 | #endif //STATICCTRL_HPP 59 | -------------------------------------------------------------------------------- /StatusBarIcon.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: STATUSBARICON.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CStatusBarIcon class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef STATUSBARICON_HPP 13 | #define STATUSBARICON_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StatusBarPanel.hpp" 20 | 21 | // Forward declarations. 22 | class CTransparentBmp; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** A status bar field which contains an icon. 27 | ** 28 | ******************************************************************************* 29 | */ 30 | 31 | class CStatusBarIcon : public CStatusBarPanel 32 | { 33 | public: 34 | // 35 | // Constructors/Destructor. 36 | // 37 | CStatusBarIcon(); 38 | virtual ~CStatusBarIcon(); 39 | 40 | // 41 | // Methods. 42 | // 43 | void ClearIcon(bool bForcePaint = false); 44 | void SetIcon(const CTransparentBmp& oBitmap, uint nIndex, bool bForcePaint = false); 45 | 46 | protected: 47 | // 48 | // Members. 49 | // 50 | const CTransparentBmp* m_pBitmap; 51 | uint m_nIndex; 52 | 53 | // 54 | // Window creation template methods. 55 | // 56 | virtual void GetClassParams(WNDCLASS& rParams); 57 | virtual void GetCreateParams(WNDCREATE& rParams); 58 | 59 | // 60 | // Message processors. 61 | // 62 | virtual void OnPaint(CDC& rDC); 63 | 64 | private: 65 | // NotCopyable. 66 | CStatusBarIcon(const CStatusBarIcon&); 67 | CStatusBarIcon& operator=(const CStatusBarIcon&); 68 | }; 69 | 70 | /****************************************************************************** 71 | ** 72 | ** Implementation of inline functions. 73 | ** 74 | ******************************************************************************* 75 | */ 76 | 77 | #endif // STATUSBARICON_HPP 78 | -------------------------------------------------------------------------------- /StatusBarLabel.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: STATUSBARLABEL.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CStatusBarLabel class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef STATUSBARLABEL_HPP 13 | #define STATUSBARLABEL_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StatusBarPanel.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** A status bar field which contains text. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CStatusBarLabel : public CStatusBarPanel 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CStatusBarLabel(size_t nChars); 35 | virtual ~CStatusBarLabel(); 36 | 37 | // 38 | // Methods. 39 | // 40 | void SetLabel(const tchar* pszLabel); 41 | 42 | protected: 43 | // 44 | // Members. 45 | // 46 | size_t m_nChars; // Width in characters. 47 | CString m_strLabel; // Text value. 48 | 49 | // 50 | // Window creation template methods. 51 | // 52 | virtual void GetClassParams(WNDCLASS& rParams); 53 | virtual void GetCreateParams(WNDCREATE& rParams); 54 | 55 | // 56 | // Message processors. 57 | // 58 | virtual void OnPaint(CDC& rDC); 59 | }; 60 | 61 | /****************************************************************************** 62 | ** 63 | ** Implementation of inline functions. 64 | ** 65 | ******************************************************************************* 66 | */ 67 | 68 | #endif // STATUSBARLABEL_HPP 69 | -------------------------------------------------------------------------------- /StatusBarPanel.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: STATUSBARPANEL.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CStatusBarPanel class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef STATUSBARPANEL_HPP 13 | #define STATUSBARPANEL_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "CtrlWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** The base class for child windows that sit on the right of the status bar. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CStatusBarPanel : public CCtrlWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CStatusBarPanel(); 35 | virtual ~CStatusBarPanel(); 36 | 37 | // 38 | // Constants. 39 | // 40 | static const int BORDER_SIZE = 2; // Width of border around content. 41 | 42 | protected: 43 | // 44 | // Members. 45 | // 46 | 47 | // 48 | // Window creation template methods. 49 | // 50 | virtual void GetClassParams(WNDCLASS& rParams); 51 | virtual void GetCreateParams(WNDCREATE& rParams); 52 | 53 | // 54 | // Message processors. 55 | // 56 | virtual void OnPaint(CDC& rDC); 57 | }; 58 | 59 | /****************************************************************************** 60 | ** 61 | ** Implementation of inline functions. 62 | ** 63 | ******************************************************************************* 64 | */ 65 | 66 | #endif // STATUSBARPANEL_HPP 67 | -------------------------------------------------------------------------------- /StdWnd.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: STDWND.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CStdWnd class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef STDWND_HPP 13 | #define STDWND_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "CtrlWnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is the base class for all built-in window controls. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CStdWnd : public CCtrlWnd 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CStdWnd(); 35 | virtual ~CStdWnd(); 36 | 37 | protected: 38 | // 39 | // Window creation template methods. 40 | // 41 | virtual bool Register(WNDCLASS& rParams); 42 | 43 | // 44 | // Message handlers. 45 | // 46 | virtual LRESULT WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam); 47 | }; 48 | 49 | /****************************************************************************** 50 | ** 51 | ** Implementation of inline functions. 52 | ** 53 | ******************************************************************************* 54 | */ 55 | 56 | #endif //STDWND_HPP 57 | -------------------------------------------------------------------------------- /StrCvtException.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: STRCVTEXCEPTION.CPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: CStrCvtException class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "StrCvtException.hpp" 13 | #include 14 | 15 | /****************************************************************************** 16 | ** Method: Constructor. 17 | ** 18 | ** Description: . 19 | ** 20 | ** Parameters: None. 21 | ** 22 | ** Returns: Nothing. 23 | ** 24 | ******************************************************************************* 25 | */ 26 | 27 | CStrCvtException::CStrCvtException(int eErrCode) 28 | { 29 | // Convert error to string. 30 | switch(eErrCode) 31 | { 32 | case E_INVALID_FORMAT: 33 | m_details = TXT("Invalid format"); 34 | break; 35 | 36 | case E_INVALID_RANGE: 37 | m_details = TXT("Number out of range"); 38 | break; 39 | 40 | // Shouldn't happen! 41 | default: 42 | ASSERT_FALSE(); 43 | break; 44 | } 45 | } 46 | 47 | /****************************************************************************** 48 | ** Method: Destructor. 49 | ** 50 | ** Description: . 51 | ** 52 | ** Parameters: None. 53 | ** 54 | ** Returns: Nothing. 55 | ** 56 | ******************************************************************************* 57 | */ 58 | 59 | CStrCvtException::~CStrCvtException() throw() 60 | { 61 | } 62 | -------------------------------------------------------------------------------- /StrCvtException.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: STRCVTEXCEPTION.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CStrCvtException class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef STRCVTEXCEPTION_HPP 13 | #define STRCVTEXCEPTION_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | /****************************************************************************** 22 | ** 23 | ** The exception class thrown by the CStrCvt functions. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CStrCvtException : public Core::Exception 29 | { 30 | public: 31 | // 32 | // Exception codes. 33 | // 34 | enum ErrCode 35 | { 36 | E_INVALID_FORMAT = 10, // String has an invalid format. 37 | E_INVALID_RANGE = 11, // String value too small/large for type. 38 | }; 39 | 40 | // 41 | // Constructors/Destructor. 42 | // 43 | CStrCvtException(int eErrCode); 44 | virtual ~CStrCvtException() throw(); 45 | }; 46 | 47 | /****************************************************************************** 48 | ** 49 | ** Implementation of inline functions. 50 | ** 51 | ******************************************************************************* 52 | */ 53 | 54 | #endif // STRCVTEXCEPTION_HPP 55 | -------------------------------------------------------------------------------- /Stream.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file Stream.hpp 3 | //! \brief The CStream class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_STREAM_HPP 8 | #define WCL_STREAM_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include "IStreamBase.hpp" 15 | #include "IInputStream.hpp" 16 | #include "IOutputStream.hpp" 17 | #include 18 | 19 | //////////////////////////////////////////////////////////////////////////////// 20 | //! The legacy abstract base class used for bidirectional I/O. 21 | 22 | class CStream : public WCL::IInputStream, public WCL::IOutputStream 23 | { 24 | public: 25 | //! Constructor. 26 | CStream(); 27 | 28 | //! Destructor. 29 | virtual ~CStream(); 30 | 31 | // 32 | // Text stream specific operations. 33 | // 34 | 35 | //! Read a line of text. 36 | CString ReadLine(TextFormat eFormat); 37 | 38 | //! Write a line of text. 39 | void WriteLine(const CString& str, TextFormat eFormat); 40 | 41 | // 42 | // Default implementation of IStreamBase. 43 | // 44 | 45 | //! Get the stream contents format. 46 | virtual uint32 Format() const; 47 | 48 | //! Set the stream contents format. 49 | virtual void SetFormat(uint32 nFormat); 50 | 51 | //! Get the stream contents version. 52 | virtual uint32 Version() const; 53 | 54 | //! Set the stream contents version. 55 | virtual void SetVersion(uint32 nVersion); 56 | 57 | protected: 58 | // 59 | // Members. 60 | // 61 | uint m_nMode; //!< The read/write mode. 62 | uint32 m_nFormat; //!< The stream contents format. 63 | uint32 m_nVersion; //!< The stream contents version. 64 | 65 | // 66 | // Internal methods. 67 | // 68 | template 69 | size_t ReadLine(std::vector& vBuffer); 70 | }; 71 | 72 | #endif // WCL_STREAM_HPP 73 | -------------------------------------------------------------------------------- /StreamException.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: STREAMEXCEPTION.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CStreamException class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef WCL_STREAMEXCEPTION_HPP 13 | #define WCL_STREAMEXCEPTION_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This is the base class for all exceptions thrown from streams. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CStreamException : public Core::Exception 29 | { 30 | public: 31 | virtual ~CStreamException() CORE_NO_THROW {} 32 | 33 | // 34 | // Exception codes (0 - 9). 35 | // 36 | enum 37 | { 38 | E_INVALID_FILE, //!< The file does not exist. 39 | E_INVALID_FOLDER, //!< The folder does not exist. 40 | E_OPEN_FAILED, // Generic open failure. 41 | E_CREATE_FAILED, // Generic create failure. 42 | E_READ_FAILED, // Read failure. 43 | E_WRITE_FAILED, // Write failure. 44 | E_SEEK_FAILED, // Seek failure. 45 | E_FORMAT_INVALID, // Invalid stream format. 46 | E_VERSION_INVALID, // Invalid stream version. 47 | }; 48 | }; 49 | 50 | #endif // WCL_STREAMEXCEPTION_HPP 51 | -------------------------------------------------------------------------------- /StringIO.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file StringIO.hpp 3 | //! \brief I/O stream helper functions for the legacy CString class. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_STRINGIO_HPP 8 | #define WCL_STRINGIO_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include 15 | 16 | //////////////////////////////////////////////////////////////////////////////// 17 | //! STL output stream inserter. 18 | 19 | inline tostream& operator<<(tostream& os, const CString& str) 20 | { 21 | os << str.c_str(); 22 | 23 | return os; 24 | } 25 | 26 | #endif // WCL_STRINGIO_HPP 27 | -------------------------------------------------------------------------------- /StringUtils.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file StringUtils.cpp 3 | //! \brief String utility functions for Windows specific types. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include "StringUtils.hpp" 8 | #include 9 | #include 10 | #include "Rect.hpp" 11 | 12 | namespace WCL 13 | { 14 | 15 | //namespace WCL 16 | } 17 | 18 | namespace Core 19 | { 20 | 21 | //////////////////////////////////////////////////////////////////////////////// 22 | //! Format a rectangle into a string. 23 | 24 | template<> 25 | tstring format(const CRect& value) 26 | { 27 | return Core::fmt(TXT("%ld,%ld,%ld,%ld"), value.left, value.top, value.right, value.bottom); 28 | } 29 | 30 | //////////////////////////////////////////////////////////////////////////////// 31 | //! Parse a rectangle from a string. 32 | 33 | template<> 34 | CRect parse(const tstring& buffer) 35 | { 36 | Core::Tokeniser::Tokens tokens; 37 | 38 | if (Core::Tokeniser::split(buffer, TXT(","), tokens) != 4) 39 | throw Core::ParseException(Core::fmt(TXT("Failed to parse the rectangle: '%s'"), buffer.c_str())); 40 | 41 | int left = Core::parse(tokens[0]); 42 | int top = Core::parse(tokens[1]); 43 | int right = Core::parse(tokens[2]); 44 | int bottom = Core::parse(tokens[3]); 45 | 46 | return CRect(left, top, right, bottom); 47 | } 48 | 49 | //namespace Core 50 | } 51 | -------------------------------------------------------------------------------- /StringUtils.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file StringUtils.hpp 3 | //! \brief String utility functions for Windows specific types. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_STRINGUTILS_HPP 8 | #define WCL_STRINGUTILS_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include 15 | 16 | namespace WCL 17 | { 18 | 19 | //////////////////////////////////////////////////////////////////////////////// 20 | //! Convert a BSTR to a C-style wide character string. This functions adjusts 21 | //! for the behaviour where a BSTR can be NULL to represent an empty string. 22 | 23 | inline const wchar_t* BstrToWide(const BSTR bstr) 24 | { 25 | return (bstr != nullptr) ? bstr : L""; 26 | } 27 | 28 | //! Convert a BSTR to a safe C++ wide character string. 29 | #define BSTR2W(bstr) WCL::BstrToWide(bstr) 30 | 31 | //namespace WCL 32 | } 33 | 34 | // Forward declarations. 35 | class CRect; 36 | 37 | namespace Core 38 | { 39 | 40 | //////////////////////////////////////////////////////////////////////////////// 41 | // Format a rectangle into a string. 42 | 43 | template<> 44 | tstring format(const CRect& value); 45 | 46 | //////////////////////////////////////////////////////////////////////////////// 47 | // Parse a rectangle from a string. 48 | 49 | template<> 50 | CRect parse(const tstring& buffer); // throw(ParseException) 51 | 52 | //namespace Core 53 | } 54 | 55 | #endif // WCL_STRINGUTILS_HPP 56 | -------------------------------------------------------------------------------- /StructuredException.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file StructuredException.hpp 3 | //! \brief The StructuredException class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_STRUCTUREDEXCEPTION_HPP 8 | #define WCL_STRUCTUREDEXCEPTION_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include 15 | 16 | namespace WCL 17 | { 18 | 19 | //////////////////////////////////////////////////////////////////////////////// 20 | //! The type of exception thrown when a Win32 structured exception occurs. 21 | 22 | class StructuredException : public Core::Exception 23 | { 24 | public: 25 | //! Constructor. 26 | StructuredException(uint nCode, _EXCEPTION_POINTERS* pInfo); 27 | 28 | //! Destructor. 29 | ~StructuredException() throw(); 30 | 31 | // 32 | // Members. 33 | // 34 | uint m_nCode; //!< The Win32 exception code. 35 | 36 | private: 37 | // 38 | // Internal methods. 39 | // 40 | 41 | //! Internal method to convert the exception code to a string. 42 | static const tchar* FormatCode(uint nCode); 43 | }; 44 | 45 | //namespace WCL 46 | } 47 | 48 | #endif // WCL_STRUCTUREDEXCEPTION_HPP 49 | -------------------------------------------------------------------------------- /SysInfo.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: SYSINFO.CPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: CSysInfo class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "SysInfo.hpp" 13 | #include 14 | #include "Win32Exception.hpp" 15 | 16 | /****************************************************************************** 17 | ** Method: ComputerName() 18 | ** 19 | ** Description: Gets the name of the computer. 20 | ** 21 | ** Parameters: None. 22 | ** 23 | ** Returns: The name. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | CString CSysInfo::ComputerName() 29 | { 30 | tchar szName[MAX_COMPUTERNAME_LENGTH+1] = { 0 }; 31 | DWORD dwSize = MAX_COMPUTERNAME_LENGTH; 32 | 33 | if (::GetComputerName(szName, &dwSize) == 0) 34 | throw WCL::Win32Exception(::GetLastError(), TXT("Failed to retrieve the name of the computer")); 35 | 36 | return szName; 37 | } 38 | 39 | /****************************************************************************** 40 | ** Method: UserName() 41 | ** 42 | ** Description: Gets the name of the user. 43 | ** 44 | ** Parameters: None. 45 | ** 46 | ** Returns: The name. 47 | ** 48 | ******************************************************************************* 49 | */ 50 | 51 | CString CSysInfo::UserName() 52 | { 53 | tchar szName[UNLEN+1] = { 0 }; 54 | DWORD dwSize = UNLEN; 55 | 56 | if (::GetUserName(szName, &dwSize) == 0) 57 | throw WCL::Win32Exception(::GetLastError(), TXT("Failed to retrieve the name of the user")); 58 | 59 | return szName; 60 | } 61 | -------------------------------------------------------------------------------- /SysInfo.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: SYSINFO.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CSysInfo class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef SYSINFO_HPP 13 | #define SYSINFO_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** A class of static methods to get system information. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CSysInfo 27 | { 28 | public: 29 | // 30 | // Methods. 31 | // 32 | static CString ComputerName(); 33 | static CString UserName(); 34 | }; 35 | 36 | /****************************************************************************** 37 | ** 38 | ** Implementation of inline functions. 39 | ** 40 | ******************************************************************************* 41 | */ 42 | 43 | #endif // SYSINFO_HPP 44 | -------------------------------------------------------------------------------- /Test/Common.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file Common.hpp 3 | //! \brief File to include the most commonly used headers. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef APP_COMMON_HPP 8 | #define APP_COMMON_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #endif // APP_COMMON_HPP 19 | -------------------------------------------------------------------------------- /Test/DateTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file DateTests.cpp 3 | //! \brief The unit tests for the CDate class. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | 10 | TEST_SET(Date) 11 | { 12 | CDate testDate(1, 2, 2003); 13 | 14 | TEST_CASE("using ISO format outputs year, month and day separated by a dash") 15 | { 16 | TEST_TRUE(testDate.ToString(CDate::FMT_ISO) == TXT("2003-02-01")); 17 | } 18 | TEST_CASE_END 19 | 20 | TEST_CASE("using Windows short format outputs day, month and year separated by a slash") 21 | { 22 | TEST_TRUE(testDate.ToString(CDate::FMT_WIN_SHORT) == TXT("01/02/2003")); 23 | } 24 | TEST_CASE_END 25 | 26 | TEST_CASE("using Windows long format day, month name and year separated by a space") 27 | { 28 | TEST_TRUE(testDate.ToString(CDate::FMT_WIN_LONG) == TXT("01 February 2003")); 29 | } 30 | TEST_CASE_END 31 | 32 | } 33 | TEST_SET_END 34 | -------------------------------------------------------------------------------- /Test/DateTimeTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file DateTimeTests.cpp 3 | //! \brief The unit tests for the CDateTime class. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | 10 | TEST_SET(DateTime) 11 | { 12 | CDateTime testDateTime(CDate(1, 2, 2003), CTime(1, 2, 3)); 13 | 14 | TEST_CASE("using ISO format outputs an ISO date and time separated by a 'T'") 15 | { 16 | TEST_TRUE(testDateTime.ToString(CDate::FMT_ISO, CTime::FMT_ISO) == TXT("2003-02-01T01:02:03")); 17 | } 18 | TEST_CASE_END 19 | 20 | TEST_CASE("using Windows short format outputs a short date and time separated by a space") 21 | { 22 | TEST_TRUE(testDateTime.ToString(CDate::FMT_WIN_SHORT, CTime::FMT_WIN_SHORT) == TXT("01/02/2003 01:02")); 23 | } 24 | TEST_CASE_END 25 | 26 | } 27 | TEST_SET_END 28 | -------------------------------------------------------------------------------- /Test/IniFileTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file IniFileTests.cpp 3 | //! \brief The unit tests for the IniFile class. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | 10 | TEST_SET(IniFile) 11 | { 12 | 13 | TEST_CASE("default construction refers to a file with the name of the process and an .ini extension") 14 | { 15 | const tchar* processName = TXT("test"); 16 | const CPath folder = CPath::ApplicationDir(); 17 | 18 | tstring expected = Core::fmt(TXT("%s\\%s.ini"), folder.c_str(), processName); 19 | 20 | CIniFile oIniFile; 21 | 22 | TEST_TRUE(tstricmp(expected.c_str(), oIniFile.m_strPath) == 0); 23 | } 24 | TEST_CASE_END 25 | 26 | } 27 | TEST_SET_END 28 | -------------------------------------------------------------------------------- /Test/MemStreamTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file MemStreamTests.cpp 3 | //! \brief The unit tests for the MemStream class. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | TEST_SET(MemStream) 13 | { 14 | 15 | TEST_CASE("a stream is empty when the underlying buffer is empty") 16 | { 17 | CBuffer buffer; 18 | CMemStream stream(buffer); 19 | 20 | TEST_TRUE(stream.Size() == 0); 21 | } 22 | TEST_CASE_END 23 | 24 | TEST_CASE("a stream has the same size as the underlying buffer") 25 | { 26 | CBuffer buffer(100); 27 | CMemStream stream(buffer); 28 | 29 | TEST_TRUE(stream.Size() == buffer.Size()); 30 | } 31 | TEST_CASE_END 32 | 33 | TEST_CASE("writing to a stream writes to the underlying buffer") 34 | { 35 | CBuffer buffer; 36 | CMemStream stream(buffer); 37 | 38 | const char* testValue = "unit test"; 39 | 40 | stream.Create(); 41 | stream.Write(testValue, strlen(testValue)); 42 | stream.Close(); 43 | 44 | TEST_TRUE(buffer.Size() == strlen(testValue)); 45 | TEST_TRUE(memcmp(buffer.Buffer(), testValue, strlen(testValue)) == 0); 46 | } 47 | TEST_CASE_END 48 | 49 | TEST_CASE("reading from a stream reads from the underlying buffer") 50 | { 51 | const char* testValue = "unit test"; 52 | 53 | CBuffer buffer(testValue, strlen(testValue)); 54 | CMemStream stream(buffer); 55 | 56 | Core::ArrayPtr readValue(new char[strlen(testValue)]); 57 | 58 | stream.Open(); 59 | stream.Read(readValue.get(), buffer.Size()); 60 | stream.Close(); 61 | 62 | TEST_TRUE(memcmp(readValue.get(), testValue, strlen(testValue)) == 0); 63 | } 64 | TEST_CASE_END 65 | 66 | } 67 | TEST_SET_END 68 | -------------------------------------------------------------------------------- /Test/NullCmdControllerTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file NullCmdControllerTests.cpp 3 | //! \brief The unit tests for the NullCmdController class. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | TEST_SET(NullCmdController) 13 | { 14 | 15 | TEST_CASE("All methods should throw a not implemented exception") 16 | { 17 | typedef Core::UniquePtr ICmdControllerPtr; 18 | 19 | const uint TEST_COMMAND_ID = 99; 20 | 21 | ICmdControllerPtr controller(new WCL::NullCmdController); 22 | 23 | TEST_THROWS(controller->Execute(TEST_COMMAND_ID)); 24 | 25 | TEST_THROWS(controller->UpdateUI()); 26 | 27 | CDC& dc = *((CDC*)nullptr); // Shouldn't be invoked. 28 | 29 | TEST_THROWS(controller->DrawCmd(TEST_COMMAND_ID, dc, CRect(), true)); 30 | 31 | TEST_THROWS(controller->CmdHintStr(TEST_COMMAND_ID)); 32 | 33 | TEST_THROWS(controller->CmdToolTipStr(TEST_COMMAND_ID)); 34 | } 35 | TEST_CASE_END 36 | 37 | } 38 | TEST_SET_END 39 | -------------------------------------------------------------------------------- /Test/PtrTest.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file PtrTest.hpp 3 | //! \brief The classes used in unit testing of the smart pointer classes.. 4 | //! \author Chris Oldwood 5 | 6 | //////////////////////////////////////////////////////////////////////////////// 7 | //! The test interface. 8 | 9 | class IPtrTest 10 | { 11 | public: 12 | virtual ~IPtrTest() {} 13 | virtual ulong AddRef() = 0; 14 | virtual ulong Release() = 0; 15 | virtual bool Run() = 0; 16 | }; 17 | 18 | //////////////////////////////////////////////////////////////////////////////// 19 | //! The test concrete class. 20 | 21 | class PtrTest : public IPtrTest 22 | { 23 | public: 24 | PtrTest() 25 | : m_nRefCount(1) 26 | { } 27 | 28 | virtual ulong AddRef() 29 | { 30 | return ++m_nRefCount; 31 | } 32 | 33 | virtual ulong Release() 34 | { 35 | if (--m_nRefCount == 0) 36 | delete this; 37 | return m_nRefCount; 38 | } 39 | 40 | virtual bool Run() 41 | { 42 | return true; 43 | } 44 | 45 | ulong m_nRefCount; 46 | }; 47 | 48 | //////////////////////////////////////////////////////////////////////////////// 49 | //! The test derived concrete class. 50 | 51 | class Derived : public PtrTest 52 | { 53 | }; 54 | 55 | //////////////////////////////////////////////////////////////////////////////// 56 | //! The test unrelated concrete class. 57 | 58 | class Unrelated 59 | { 60 | }; 61 | -------------------------------------------------------------------------------- /Test/RectTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file MiscTests.cpp 3 | //! \brief The unit tests for the CRect class. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | 10 | TEST_SET(Rect) 11 | { 12 | 13 | TEST_CASE("initial state is an empty rectangle positioned at the origin") 14 | { 15 | CRect rc; 16 | 17 | TEST_TRUE(rc.Empty()); 18 | 19 | TEST_TRUE(rc.left == 0); 20 | TEST_TRUE(rc.top == 0); 21 | TEST_TRUE(rc.right == 0); 22 | TEST_TRUE(rc.bottom == 0); 23 | } 24 | TEST_CASE_END 25 | 26 | TEST_CASE("equality is dependent on the left, top, right and bottom members being equal") 27 | { 28 | CRect rect(1, 2, 3, 4); 29 | 30 | TEST_TRUE(rect == rect); 31 | 32 | TEST_TRUE(rect != CRect(0, 2, 3, 4)); 33 | TEST_TRUE(rect != CRect(1, 0, 3, 4)); 34 | TEST_TRUE(rect != CRect(1, 2, 0, 4)); 35 | TEST_TRUE(rect != CRect(1, 2, 3, 0)); 36 | } 37 | TEST_CASE_END 38 | 39 | } 40 | TEST_SET_END 41 | -------------------------------------------------------------------------------- /Test/ResourceStringTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file ResourceStringTests.cpp 3 | //! \brief The unit tests for the resource string utility functions. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | #include "Resource.h" 10 | 11 | TEST_SET(ResourceString) 12 | { 13 | HMODULE module = ::GetModuleHandle(NULL); 14 | 15 | TEST_CASE("Loading a string for an invalid ID returns an empty string") 16 | { 17 | const uint INVALID_STRING_ID = 999; 18 | const tstring expected = TXT(""); 19 | 20 | const tstring actual = WCL::loadString(module, INVALID_STRING_ID); 21 | 22 | TEST_TRUE(actual == expected); 23 | } 24 | TEST_CASE_END 25 | 26 | TEST_CASE("A string can be loaded from the application module resources") 27 | { 28 | const tstring expected = TXT("unit test"); 29 | const tstring actual = WCL::loadString(module, ID_TEST_STRING); 30 | 31 | TEST_TRUE(actual == expected); 32 | } 33 | TEST_CASE_END 34 | 35 | } 36 | TEST_SET_END 37 | -------------------------------------------------------------------------------- /Test/SeTranslatorTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file SeTranslatorTests.cpp 3 | //! \brief The unit tests for the SeTranslator class. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | TEST_SET(SeTranslator) 12 | { 13 | 14 | #ifdef _MSC_VER 15 | 16 | TEST_CASE("dereferencing a null pointer causes an access violation exception to occur") 17 | { 18 | WCL::SeTranslator oSeTranslator; 19 | 20 | tchar* p = nullptr; 21 | 22 | try 23 | { 24 | *p = TXT('\0'); 25 | 26 | TEST_FAILED("No exception thrown"); 27 | } 28 | catch (const WCL::StructuredException& /*e*/) 29 | { 30 | TEST_PASSED("StructuredException thrown"); 31 | } 32 | catch (...) 33 | { 34 | TEST_FAILED("Non StructuredException exception thrown"); 35 | } 36 | } 37 | TEST_CASE_END 38 | 39 | #endif 40 | 41 | } 42 | TEST_SET_END 43 | -------------------------------------------------------------------------------- /Test/StringUtilsTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file StringUtilsTests.cpp 3 | //! \brief The unit tests for the string utility functions. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | TEST_SET(StringUtils) 12 | { 13 | 14 | TEST_CASE("a rectangle is serialised to a string as a comma separated list of the members") 15 | { 16 | TEST_TRUE(Core::format<>(CRect(1,2,3,4)) == TXT("1,2,3,4")); 17 | TEST_TRUE(Core::parse(TXT("1,2,3,4")) == CRect(1,2,3,4)); 18 | 19 | TEST_THROWS(Core::parse(TXT("1,2,3"))); 20 | TEST_THROWS(Core::parse(TXT("A,B,C,D"))); 21 | } 22 | TEST_CASE_END 23 | 24 | } 25 | TEST_SET_END 26 | -------------------------------------------------------------------------------- /Test/Test.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file Test.cpp 3 | //! \brief The test harness entry point. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | 10 | int _tmain(int argc, _TCHAR* argv[]) 11 | { 12 | TEST_SUITE_MAIN(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /Test/Test.rcv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: TEST.RCV 5 | ** COMPONENT: The Application. 6 | ** DESCRIPTION: The application version information resource. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include 12 | 13 | /****************************************************************************** 14 | ** 15 | ** Version information. 16 | ** 17 | ******************************************************************************* 18 | */ 19 | 20 | VS_VERSION_INFO VERSIONINFO 21 | FILEVERSION 1,0,0,0 22 | PRODUCTVERSION 1,0,0,0 23 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 24 | #ifdef _DEBUG 25 | FILEFLAGS VS_FF_DEBUG | VS_FF_PRERELEASE 26 | #else 27 | FILEFLAGS 0 28 | #endif 29 | FILEOS VOS__WINDOWS32 30 | FILETYPE VFT_APP 31 | FILESUBTYPE 0 32 | BEGIN 33 | BLOCK "StringFileInfo" 34 | BEGIN 35 | BLOCK "080904E4" 36 | BEGIN 37 | VALUE "FileDescription", "Test\0" 38 | VALUE "FileVersion", "1.0\0" 39 | VALUE "InternalName", "Test.exe\0" 40 | VALUE "LegalCopyright", "(C) Chris Oldwood\0" 41 | VALUE "OriginalFilename", "Test.exe\0" 42 | VALUE "ProductName", "Test\0" 43 | VALUE "ProductVersion", "1.0\0" 44 | #ifdef _DEBUG 45 | VALUE "Comments", "Debug Build\0" 46 | #endif 47 | END 48 | END 49 | BLOCK "VarFileInfo" 50 | BEGIN 51 | VALUE "Translation", 0x0809, 0x04E4 52 | END 53 | END 54 | -------------------------------------------------------------------------------- /Test/Test.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Test/TestIFaceTraits.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file TestIFaceTraits.hpp 3 | //! \brief The IFaceTraits used for the COM based tests. 4 | //! \author Chris Oldwood 5 | 6 | #ifndef _MSC_VER 7 | #include 8 | WCL_DECLARE_IFACETRAITS(IUnknown, IID_IUnknown); 9 | WCL_DECLARE_IFACETRAITS(IClassFactory, IID_IClassFactory); 10 | WCL_DECLARE_IFACETRAITS(IMalloc, IID_IMalloc); 11 | WCL_DECLARE_IFACETRAITS(IErrorLog, IID_IErrorLog); 12 | WCL_DECLARE_IFACETRAITS(IErrorInfo, IID_IErrorInfo); 13 | #endif 14 | -------------------------------------------------------------------------------- /Test/TimeTests.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file TimeTests.cpp 3 | //! \brief The unit tests for the CTime class. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | 10 | TEST_SET(Time) 11 | { 12 | CTime testTime(1, 2, 3); 13 | 14 | TEST_CASE("using ISO format outputs hours, minutes and seconds separated by a colon") 15 | { 16 | TEST_TRUE(testTime.ToString(CTime::FMT_ISO) == TXT("01:02:03")); 17 | } 18 | TEST_CASE_END 19 | 20 | TEST_CASE("using Windows short format outputs hours and minutes only separated by a colon") 21 | { 22 | TEST_TRUE(testTime.ToString(CTime::FMT_WIN_SHORT) == TXT("01:02")); 23 | } 24 | TEST_CASE_END 25 | 26 | TEST_CASE("using Windows long format outputs hours, minutes and seconds separated by a colon") 27 | { 28 | TEST_TRUE(testTime.ToString(CTime::FMT_WIN_LONG) == TXT("01:02:03")); 29 | } 30 | TEST_CASE_END 31 | 32 | } 33 | TEST_SET_END 34 | -------------------------------------------------------------------------------- /Test/pch.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file pch.cpp 3 | //! \brief The file used when creating the pre-compiled header. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | -------------------------------------------------------------------------------- /Test/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Test.rc 4 | // 5 | #define ID_TEST_COMMAND 100 6 | #define ID_HINT_NO_TOOLTIP 101 7 | #define ID_EMPTY_HINT 102 8 | #define ID_HINT_TIP_SEP_ONLY 103 9 | #define ID_TEST_STRING 200 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NEXT_RESOURCE_VALUE 101 16 | #define _APS_NEXT_COMMAND_VALUE 40001 17 | #define _APS_NEXT_CONTROL_VALUE 1001 18 | #define _APS_NEXT_SYMED_VALUE 101 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /ThreadJob.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: THREADJOB.CPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: CThreadJob class definition. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "ThreadJob.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Constructor. 16 | ** 17 | ** Description: . 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CThreadJob::CThreadJob() 27 | : m_eStatus(PENDING) 28 | { 29 | } 30 | 31 | /****************************************************************************** 32 | ** Method: Destructor. 33 | ** 34 | ** Description: . 35 | ** 36 | ** Parameters: None. 37 | ** 38 | ** Returns: Nothing. 39 | ** 40 | ******************************************************************************* 41 | */ 42 | 43 | CThreadJob::~CThreadJob() 44 | { 45 | } 46 | -------------------------------------------------------------------------------- /ThreadJob.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: THREADJOB.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CThreadJob class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef THREADJOB_HPP 13 | #define THREADJOB_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** A job that runs on a worker thread in a thread pool. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CThreadJob 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CThreadJob(); 33 | virtual ~CThreadJob(); 34 | 35 | // Job status. 36 | enum JobStatus 37 | { 38 | PENDING, 39 | RUNNING, 40 | COMPLETED, 41 | CANCELLED, 42 | }; 43 | 44 | // 45 | // Accessors. 46 | // 47 | JobStatus Status() const; 48 | void Status(JobStatus eStatus); 49 | 50 | // 51 | // Methods. 52 | // 53 | virtual void Run() = 0; 54 | 55 | protected: 56 | // 57 | // Members. 58 | // 59 | JobStatus m_eStatus; 60 | }; 61 | 62 | //! The CThreadJob smart-pointer type. 63 | typedef Core::SharedPtr ThreadJobPtr; 64 | 65 | /****************************************************************************** 66 | ** 67 | ** Implementation of inline functions. 68 | ** 69 | ******************************************************************************* 70 | */ 71 | 72 | inline CThreadJob::JobStatus CThreadJob::Status() const 73 | { 74 | return m_eStatus; 75 | } 76 | 77 | inline void CThreadJob::Status(JobStatus eStatus) 78 | { 79 | m_eStatus = eStatus; 80 | } 81 | 82 | #endif // THREADJOB_HPP 83 | -------------------------------------------------------------------------------- /TimeSpan.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: TIMESPAN.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CTimeSpan class declarations. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef WCL_TIMESPAN_HPP 13 | #define WCL_TIMESPAN_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | /****************************************************************************** 20 | ** 21 | ** This class is used to represent a period between two times in seconds. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | class CTimeSpan 27 | { 28 | public: 29 | // 30 | // Constructors/Destructor. 31 | // 32 | CTimeSpan(); 33 | CTimeSpan(WCL::Seconds tSecs); 34 | 35 | // Accessors. 36 | int Secs() const; 37 | int Mins() const; 38 | int Hours() const; 39 | int Days() const; 40 | 41 | protected: 42 | // 43 | // Members. 44 | // 45 | WCL::Seconds m_tSpan; 46 | 47 | // 48 | // Friends. 49 | // 50 | friend class CTime; 51 | }; 52 | 53 | /****************************************************************************** 54 | ** 55 | ** Implementation of CTimeSpan inline functions. 56 | ** 57 | ******************************************************************************* 58 | */ 59 | 60 | inline CTimeSpan::CTimeSpan() 61 | : m_tSpan(0) 62 | { 63 | } 64 | 65 | inline CTimeSpan::CTimeSpan(WCL::Seconds tSecs) 66 | : m_tSpan(tSecs) 67 | { 68 | } 69 | 70 | inline int CTimeSpan::Secs() const 71 | { 72 | return static_cast(m_tSpan); 73 | } 74 | 75 | inline int CTimeSpan::Mins() const 76 | { 77 | return static_cast(m_tSpan / WCL::SECS_PER_MIN); 78 | } 79 | 80 | inline int CTimeSpan::Hours() const 81 | { 82 | return static_cast(m_tSpan / WCL::SECS_PER_HOUR); 83 | } 84 | 85 | inline int CTimeSpan::Days() const 86 | { 87 | return static_cast(m_tSpan / WCL::SECS_PER_DAY); 88 | } 89 | 90 | #endif // WCL_TIMESPAN_HPP 91 | -------------------------------------------------------------------------------- /ToolTip.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: TOOLTIP.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CToolTip class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef TOOLTIP_HPP 13 | #define TOOLTIP_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StdWnd.hpp" 20 | #include 21 | 22 | /****************************************************************************** 23 | ** 24 | ** This is a tooltip control. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CToolTip : public CStdWnd 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CToolTip(); 36 | virtual ~CToolTip(); 37 | 38 | // 39 | // Methods. 40 | // 41 | void AddTool(CWnd& oParent, CWnd& oTool, const tchar* pszText); 42 | 43 | protected: 44 | // 45 | // Members. 46 | // 47 | 48 | // 49 | // Window creation template methods. 50 | // 51 | virtual void GetCreateParams(WNDCREATE& rParams); 52 | 53 | // 54 | // Message processors. 55 | // 56 | virtual void OnCreate(const CRect& rcClient); 57 | 58 | // 59 | // Internal methods. 60 | // 61 | void AddTool(uint nFlags, CWnd& oParent, WCL::HandleOrID nID, const CRect* prcRect, const tchar* pszText); 62 | }; 63 | 64 | /****************************************************************************** 65 | ** 66 | ** Implementation of inline functions. 67 | ** 68 | ******************************************************************************* 69 | */ 70 | 71 | inline void CToolTip::AddTool(CWnd& oParent, CWnd& oTool, const tchar* pszText) 72 | { 73 | AddTool(TTF_IDISHWND | TTF_SUBCLASS, oParent, reinterpret_cast(oTool.Handle()), NULL, pszText); 74 | } 75 | 76 | #endif //TOOLTIP_HPP 77 | -------------------------------------------------------------------------------- /TraceLogger.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file TraceLogger.hpp 3 | //! \brief The TraceLogger class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef TRACELOGGER_HPP 8 | #define TRACELOGGER_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | namespace WCL 15 | { 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | //! The logger used to write CRT output message to a file. This class consists 19 | //! entirely of static members and functions as once installed, it can never be 20 | //! uninstalled. 21 | 22 | class TraceLogger 23 | { 24 | public: 25 | //! Install the logger.. 26 | static void Install(); 27 | 28 | //! Set the log file. 29 | static void SetLogFile(const tchar* pszLogFile); 30 | 31 | //! Set whether to display ASSERTs. 32 | static void EnableDialogs(bool bEnable); 33 | 34 | private: 35 | // 36 | // Class members. 37 | // 38 | static tchar g_szTraceLog[MAX_PATH+1]; //!< Trace log file path. 39 | static bool g_bNewLine; //!< Did last message include CRLF? 40 | static bool g_bConsume; //!< Disable ASSERT dialogs? 41 | 42 | //! The CRT callback.function. 43 | static int ReportHook(int /*nType*/, char* pszMessage, int* piRetVal); 44 | }; 45 | 46 | //namespace WCL 47 | } 48 | 49 | #endif // TRACELOGGER_HPP 50 | -------------------------------------------------------------------------------- /TransparentBmp.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: TRANSPARENTBMP.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CTransparentBmp class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef TRANSPARENTBMP_HPP 13 | #define TRANSPARENTBMP_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Bitmap.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** This class is used to create transparent bitmaps. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CTransparentBmp 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CTransparentBmp(); 35 | ~CTransparentBmp(); 36 | 37 | void LoadRsc(uint iRscID, COLORREF clrTransparent); 38 | 39 | // 40 | // Member access. 41 | // 42 | const CBitmap& Mask() const; 43 | const CBitmap& Image() const; 44 | const CSize& Size() const; 45 | 46 | protected: 47 | // 48 | // Members. 49 | // 50 | CBitmap m_bmpMask; // The image mask. 51 | CBitmap m_bmpImage; // The image. 52 | CSize m_Size; // The images dimensions. 53 | COLORREF m_clrTransparent; // The colour used for transparency. 54 | }; 55 | 56 | /****************************************************************************** 57 | ** 58 | ** Implementation of inline functions. 59 | ** 60 | ******************************************************************************* 61 | */ 62 | 63 | inline const CBitmap& CTransparentBmp::Mask() const 64 | { 65 | return m_bmpMask; 66 | } 67 | 68 | inline const CBitmap& CTransparentBmp::Image() const 69 | { 70 | return m_bmpImage; 71 | } 72 | 73 | inline const CSize& CTransparentBmp::Size() const 74 | { 75 | ASSERT(m_bmpMask.Handle() != NULL); 76 | ASSERT(m_bmpImage.Handle() != NULL); 77 | 78 | return m_Size; 79 | } 80 | 81 | #endif //TRANSPARENTBMP_HPP 82 | -------------------------------------------------------------------------------- /TrayIcon.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: TRAYICON.HPP 5 | ** COMPONENT: Windows C++ Library 6 | ** DESCRIPTION: The CTrayIcon class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef TRAYICON_HPP 13 | #define TRAYICON_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Wnd.hpp" 20 | 21 | /****************************************************************************** 22 | ** 23 | ** A class to encapsulate a system tray icon. 24 | ** 25 | ******************************************************************************* 26 | */ 27 | 28 | class CTrayIcon /*: private NotCopyable*/ 29 | { 30 | public: 31 | // 32 | // Constructors/Destructor. 33 | // 34 | CTrayIcon(); 35 | ~CTrayIcon(); 36 | 37 | // 38 | // Properties. 39 | // 40 | bool IsVisible() const; 41 | 42 | // 43 | // Methods. 44 | // 45 | void Add(const CWnd& oWnd, uint nTrayID, uint nMsgID, uint nRscID, const tchar* pszToolTip = NULL); 46 | void Modify(uint nRscID, const tchar* pszToolTip); 47 | void ModifyIcon(uint nRscID); 48 | void ModifyToolTip(const tchar* pszToolTip); 49 | void Remove(); 50 | 51 | protected: 52 | // 53 | // Members. 54 | // 55 | HWND m_hWnd; 56 | uint m_nTrayID; 57 | uint m_nMsgID; 58 | 59 | private: 60 | // NotCopyable. 61 | CTrayIcon(const CTrayIcon&); 62 | CTrayIcon& operator=(const CTrayIcon&); 63 | }; 64 | 65 | /****************************************************************************** 66 | ** 67 | ** Implementation of inline functions. 68 | ** 69 | ******************************************************************************* 70 | */ 71 | 72 | inline bool CTrayIcon::IsVisible() const 73 | { 74 | return (m_hWnd != NULL); 75 | } 76 | 77 | inline void CTrayIcon::ModifyIcon(uint nRscID) 78 | { 79 | Modify(nRscID, nullptr); 80 | } 81 | 82 | inline void CTrayIcon::ModifyToolTip(const tchar* pszToolTip) 83 | { 84 | Modify(0, pszToolTip); 85 | } 86 | 87 | #endif // TRAYICON_HPP 88 | -------------------------------------------------------------------------------- /URLLabel.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: URLLABEL.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CURLLabel class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef URLLABEL_HPP 13 | #define URLLABEL_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "Label.hpp" 20 | #include "Cursor.hpp" 21 | 22 | /****************************************************************************** 23 | ** 24 | ** A STATIC based control with the ability to behave like a hyper-link. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CURLLabel : public CLabel 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CURLLabel(); 36 | virtual ~CURLLabel(); 37 | 38 | // 39 | // Methods. 40 | // 41 | void Protocol(const tchar* pszProtocol); 42 | 43 | protected: 44 | // 45 | // Members. 46 | // 47 | CString m_strProtocol; 48 | CCursor m_oCursor; 49 | CFont m_oFont; 50 | 51 | // 52 | // Message handlers. 53 | // 54 | virtual LRESULT WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam); 55 | virtual void OnSetCursor(HWND hWnd, uint nHitCode, uint nMouseMsg); 56 | virtual void OnClick(); 57 | virtual HBRUSH OnReflectedCtlClr(uint nCtlClrMsg, HDC hDC); 58 | }; 59 | 60 | /****************************************************************************** 61 | ** 62 | ** Implementation of inline functions. 63 | ** 64 | ******************************************************************************* 65 | */ 66 | 67 | inline void CURLLabel::Protocol(const tchar* pszProtocol) 68 | { 69 | ASSERT(pszProtocol != nullptr); 70 | 71 | m_strProtocol = pszProtocol; 72 | } 73 | 74 | #endif //URLLABEL_HPP 75 | -------------------------------------------------------------------------------- /UiCommandBase.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file UiCommandBase.cpp 3 | //! \brief The UiCommandBase class definition. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | #include "UiCommandBase.hpp" 8 | #include "ExternalCmdController.hpp" 9 | 10 | namespace WCL 11 | { 12 | 13 | //////////////////////////////////////////////////////////////////////////////// 14 | //! Construction from the ID. 15 | 16 | UiCommandBase::UiCommandBase(uint cmdId) 17 | : m_id(cmdId) 18 | { 19 | } 20 | 21 | //////////////////////////////////////////////////////////////////////////////// 22 | //! Get the unique ID of the command. 23 | 24 | uint UiCommandBase::id() const 25 | { 26 | return m_id; 27 | } 28 | 29 | //////////////////////////////////////////////////////////////////////////////// 30 | //! Get the hint for the command. 31 | 32 | tstring UiCommandBase::hint() const 33 | { 34 | return ExternalCmdController::defaultHint(m_id); 35 | } 36 | 37 | //////////////////////////////////////////////////////////////////////////////// 38 | //! Get the tool tip for the command. 39 | 40 | tstring UiCommandBase::toolTip() const 41 | { 42 | return ExternalCmdController::defaultToolTip(m_id); 43 | } 44 | 45 | //////////////////////////////////////////////////////////////////////////////// 46 | //! Execute the command. 47 | 48 | void UiCommandBase::execute() 49 | { 50 | } 51 | 52 | //////////////////////////////////////////////////////////////////////////////// 53 | //! Refresh the UI for the command. 54 | 55 | void UiCommandBase::updateUi() 56 | { 57 | } 58 | 59 | //////////////////////////////////////////////////////////////////////////////// 60 | //! Draw the icon for a command. 61 | 62 | void UiCommandBase::drawIcon(CDC& /*dc*/, const CRect& /*rect*/, bool /*enabled*/) const 63 | { 64 | } 65 | 66 | //namespace WCL 67 | } 68 | -------------------------------------------------------------------------------- /UiCommandBase.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file UiCommandBase.hpp 3 | //! \brief The UiCommandBase class declaration. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_UICOMMANDBASE_HPP 8 | #define WCL_UICOMMANDBASE_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | #include "IUiCommand.hpp" 15 | 16 | namespace WCL 17 | { 18 | 19 | //////////////////////////////////////////////////////////////////////////////// 20 | //! The default implementation for the IUiCommand interface. 21 | 22 | class UiCommandBase : public IUiCommand 23 | { 24 | public: 25 | //! Construction from the ID. 26 | UiCommandBase(uint id); 27 | 28 | // 29 | // IUiCommand properties. 30 | // 31 | 32 | //! Get the unique ID of the command. 33 | virtual uint id() const; 34 | 35 | //! Get the hint for the command. 36 | virtual tstring hint() const; 37 | 38 | //! Get the tool tip for the command. 39 | virtual tstring toolTip() const; 40 | 41 | // 42 | // IUiCommand methods. 43 | // 44 | 45 | //! Execute the command. 46 | virtual void execute(); 47 | 48 | //! Refresh the UI for the command. 49 | virtual void updateUi(); 50 | 51 | //! Draw the icon for a command. 52 | virtual void drawIcon(CDC& dc, const CRect& rect, bool enabled) const; 53 | 54 | public: 55 | //! Make abstract. 56 | virtual ~UiCommandBase() /*= 0*/ {}; 57 | 58 | private: 59 | // 60 | // Members. 61 | // 62 | uint m_id; //!< The command ID. 63 | }; 64 | 65 | //namespace WCL 66 | } 67 | 68 | #endif // WCL_UICOMMANDBASE_HPP 69 | -------------------------------------------------------------------------------- /UpDownBtns.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: UPDOWNBTNS.CPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: CUpDownBtns class methods. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | #include "Common.hpp" 12 | #include "UpDownBtns.hpp" 13 | 14 | /****************************************************************************** 15 | ** Method: Default constructor. 16 | ** 17 | ** Description: Does nothing. 18 | ** 19 | ** Parameters: None. 20 | ** 21 | ** Returns: Nothing. 22 | ** 23 | ******************************************************************************* 24 | */ 25 | 26 | CUpDownBtns::CUpDownBtns() 27 | { 28 | } 29 | 30 | /****************************************************************************** 31 | ** Method: GetCreateParams() 32 | ** 33 | ** Description: Template method to get the window creation data. 34 | ** 35 | ** Parameters: rParams The create structure to fill. 36 | ** 37 | ** Returns: Nothing. 38 | ** 39 | ******************************************************************************* 40 | */ 41 | 42 | void CUpDownBtns::GetCreateParams(WNDCREATE& rParams) 43 | { 44 | // Get base class settings. 45 | CCtrlWnd::GetCreateParams(rParams); 46 | 47 | // Override any settings. 48 | rParams.pszClassName = UPDOWN_CLASS; 49 | // rParams.dwStyle |= ; 50 | } 51 | -------------------------------------------------------------------------------- /UpDownBtns.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: UPDOWNBTNS.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CUpDownBtns class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef UPDOWNBTNS_HPP 13 | #define UPDOWNBTNS_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "StdWnd.hpp" 20 | #include 21 | 22 | /****************************************************************************** 23 | ** 24 | ** This is an up-down buttons control. 25 | ** 26 | ******************************************************************************* 27 | */ 28 | 29 | class CUpDownBtns : public CStdWnd 30 | { 31 | public: 32 | // 33 | // Constructors/Destructor. 34 | // 35 | CUpDownBtns(); 36 | 37 | // 38 | // Standard methods. 39 | // 40 | bool PosValid(); 41 | 42 | int Pos(); 43 | void Pos(int nPos); 44 | 45 | void Range(int nMin, int nMax); 46 | 47 | protected: 48 | // 49 | // Members. 50 | // 51 | 52 | // 53 | // Window creation template methods. 54 | // 55 | virtual void GetCreateParams(WNDCREATE& rParams); 56 | }; 57 | 58 | /****************************************************************************** 59 | ** 60 | ** Implementation of inline functions. 61 | ** 62 | ******************************************************************************* 63 | */ 64 | 65 | inline bool CUpDownBtns::PosValid() 66 | { 67 | return (HIWORD(SendMessage(UDM_GETPOS, 0, 0)) == 0); 68 | } 69 | 70 | inline int CUpDownBtns::Pos() 71 | { 72 | LRESULT result = SendMessage(UDM_GETPOS, 0, 0); 73 | 74 | return static_cast(result); 75 | } 76 | 77 | inline void CUpDownBtns::Pos(int nPos) 78 | { 79 | SendMessage(UDM_SETPOS, 0, MAKELONG(nPos, 0)); 80 | } 81 | 82 | inline void CUpDownBtns::Range(int nMin, int nMax) 83 | { 84 | SendMessage(UDM_SETRANGE, 0, MAKELONG(nMin, nMax)); 85 | } 86 | 87 | #endif //UPDOWNBTNS_HPP 88 | -------------------------------------------------------------------------------- /VariantBool.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file VariantBool.hpp 3 | //! \brief Helper functions for dealing with the COM VARIANT_BOOL type. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_VARIANTBOOL_HPP 8 | #define WCL_VARIANTBOOL_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | //////////////////////////////////////////////////////////////////////////////// 15 | //! Convert a C++ bool to a VARIANT_BOOL. 16 | 17 | inline VARIANT_BOOL ToVariantBool(bool bValue) 18 | { 19 | return (bValue) ? VARIANT_TRUE : VARIANT_FALSE; 20 | } 21 | 22 | //////////////////////////////////////////////////////////////////////////////// 23 | //! Query if a VARIANT_BOOL is equivalent to 'true'. 24 | 25 | inline bool IsTrue(VARIANT_BOOL bValue) 26 | { 27 | return (bValue == VARIANT_TRUE) ? true : false; 28 | } 29 | 30 | //////////////////////////////////////////////////////////////////////////////// 31 | //! Query if a VARIANT_BOOL is equivalent to 'false'. 32 | 33 | inline bool IsFalse(VARIANT_BOOL bValue) 34 | { 35 | return (bValue != VARIANT_TRUE) ? true : false; 36 | } 37 | 38 | #endif // WCL_VARIANTBOOL_HPP 39 | -------------------------------------------------------------------------------- /View.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: VIEW.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CView class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef VIEW_HPP 13 | #define VIEW_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include "CtrlWnd.hpp" 20 | 21 | // Forward declarations. 22 | class CDoc; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** This is the base class for all View windows. 27 | ** 28 | ******************************************************************************* 29 | */ 30 | 31 | class CView : public CCtrlWnd 32 | { 33 | public: 34 | // 35 | // Constructors/Destructor. 36 | // 37 | CView(CDoc& rDoc); 38 | virtual ~CView(); 39 | 40 | protected: 41 | // 42 | // Members. 43 | // 44 | CDoc& m_Doc; // The views' data. 45 | 46 | // 47 | // Window creation template methods. 48 | // 49 | virtual void GetClassParams(WNDCLASS& rParams); 50 | virtual void GetCreateParams(WNDCREATE& rParams); 51 | 52 | // 53 | // Message processors. 54 | // 55 | virtual void OnPaint(CDC& rDC); 56 | }; 57 | 58 | //! The document view smart-pointer type. 59 | typedef Core::SharedPtr ViewPtr; 60 | 61 | #endif //VIEW_HPP 62 | -------------------------------------------------------------------------------- /WinMain.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file WinMain.hpp 3 | //! \brief Application entry point. 4 | //! \author Chris Oldwood 5 | 6 | // Check for previous inclusion 7 | #ifndef WCL_WINMAIN_HPP 8 | #define WCL_WINMAIN_HPP 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif 13 | 14 | namespace WCL 15 | { 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | //! The logical (WCL) entry point for a Windows application. 19 | 20 | int winMain(HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); 21 | 22 | //namespace WCL 23 | } 24 | 25 | #endif // WCL_WINMAIN_HPP 26 | -------------------------------------------------------------------------------- /WndMap.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** (C) Chris Oldwood 3 | ** 4 | ** MODULE: WNDMAP.HPP 5 | ** COMPONENT: Windows C++ Library. 6 | ** DESCRIPTION: The CWndMap class declaration. 7 | ** 8 | ******************************************************************************* 9 | */ 10 | 11 | // Check for previous inclusion 12 | #ifndef WNDMAP_HPP 13 | #define WNDMAP_HPP 14 | 15 | #if _MSC_VER > 1000 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | // Forward declarations. 22 | class CWnd; 23 | 24 | /****************************************************************************** 25 | ** 26 | ** This is the map used to link window handles to their objects. 27 | ** NB: This used to be based on the WCL HandleMap class. 28 | ** 29 | ******************************************************************************* 30 | */ 31 | 32 | class CWndMap 33 | { 34 | public: 35 | // 36 | // Constructors/Destructor. 37 | // 38 | CWndMap(); 39 | ~CWndMap(); 40 | 41 | // 42 | // Methods. 43 | // 44 | void Add(CWnd& rWnd); 45 | void Remove(CWnd& rWnd); 46 | CWnd* Find(HWND hWnd) const; 47 | 48 | private: 49 | // Type shorthands. 50 | typedef std::map Map; 51 | 52 | // 53 | // Members. 54 | // 55 | Map m_oMap; //!< The underlying container. 56 | }; 57 | 58 | /****************************************************************************** 59 | ** 60 | ** Implementation of inline functions. 61 | ** 62 | ******************************************************************************* 63 | */ 64 | 65 | #endif //WNDMAP_HPP 66 | -------------------------------------------------------------------------------- /pch.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | //! \file pch.cpp 3 | //! \brief The file used when creating the pre-compiled header. 4 | //! \author Chris Oldwood 5 | 6 | #include "Common.hpp" 7 | --------------------------------------------------------------------------------