From 6aa9bd0f77dcb5128167fae62e32aa5252fe85c6 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 2 Dec 2013 00:55:24 +0100 Subject: Renew the updater branch Now with some actual consensus on what the updater will do! --- mmc_updater/depends/win32cpp/controls.h | 1074 ++++++ mmc_updater/depends/win32cpp/copyright.txt | 33 + mmc_updater/depends/win32cpp/cstring.h | 905 +++++ mmc_updater/depends/win32cpp/default_resource.h | 94 + mmc_updater/depends/win32cpp/default_resource.rc | 250 ++ mmc_updater/depends/win32cpp/dialog.h | 876 +++++ mmc_updater/depends/win32cpp/docking.h | 4214 ++++++++++++++++++++++ mmc_updater/depends/win32cpp/file.h | 392 ++ mmc_updater/depends/win32cpp/frame.h | 3303 +++++++++++++++++ mmc_updater/depends/win32cpp/gdi.h | 3944 ++++++++++++++++++++ mmc_updater/depends/win32cpp/info.txt | 205 ++ mmc_updater/depends/win32cpp/listview.h | 867 +++++ mmc_updater/depends/win32cpp/mdi.h | 783 ++++ mmc_updater/depends/win32cpp/menu.h | 600 +++ mmc_updater/depends/win32cpp/propertysheet.h | 960 +++++ mmc_updater/depends/win32cpp/rebar.h | 709 ++++ mmc_updater/depends/win32cpp/release notes.txt | 116 + mmc_updater/depends/win32cpp/ribbon.h | 527 +++ mmc_updater/depends/win32cpp/shared_ptr.h | 199 + mmc_updater/depends/win32cpp/socket.h | 778 ++++ mmc_updater/depends/win32cpp/statusbar.h | 226 ++ mmc_updater/depends/win32cpp/stdcontrols.h | 1000 +++++ mmc_updater/depends/win32cpp/tab.h | 1658 +++++++++ mmc_updater/depends/win32cpp/taskdialog.h | 811 +++++ mmc_updater/depends/win32cpp/thread.h | 241 ++ mmc_updater/depends/win32cpp/toolbar.h | 1361 +++++++ mmc_updater/depends/win32cpp/treeview.h | 624 ++++ mmc_updater/depends/win32cpp/wceframe.h | 420 +++ mmc_updater/depends/win32cpp/wcestddef.h | 58 + mmc_updater/depends/win32cpp/webbrowser.h | 760 ++++ mmc_updater/depends/win32cpp/wincore.h | 2977 +++++++++++++++ mmc_updater/depends/win32cpp/winutils.h | 649 ++++ 32 files changed, 31614 insertions(+) create mode 100644 mmc_updater/depends/win32cpp/controls.h create mode 100644 mmc_updater/depends/win32cpp/copyright.txt create mode 100644 mmc_updater/depends/win32cpp/cstring.h create mode 100644 mmc_updater/depends/win32cpp/default_resource.h create mode 100644 mmc_updater/depends/win32cpp/default_resource.rc create mode 100644 mmc_updater/depends/win32cpp/dialog.h create mode 100644 mmc_updater/depends/win32cpp/docking.h create mode 100644 mmc_updater/depends/win32cpp/file.h create mode 100644 mmc_updater/depends/win32cpp/frame.h create mode 100644 mmc_updater/depends/win32cpp/gdi.h create mode 100644 mmc_updater/depends/win32cpp/info.txt create mode 100644 mmc_updater/depends/win32cpp/listview.h create mode 100644 mmc_updater/depends/win32cpp/mdi.h create mode 100644 mmc_updater/depends/win32cpp/menu.h create mode 100644 mmc_updater/depends/win32cpp/propertysheet.h create mode 100644 mmc_updater/depends/win32cpp/rebar.h create mode 100644 mmc_updater/depends/win32cpp/release notes.txt create mode 100644 mmc_updater/depends/win32cpp/ribbon.h create mode 100644 mmc_updater/depends/win32cpp/shared_ptr.h create mode 100644 mmc_updater/depends/win32cpp/socket.h create mode 100644 mmc_updater/depends/win32cpp/statusbar.h create mode 100644 mmc_updater/depends/win32cpp/stdcontrols.h create mode 100644 mmc_updater/depends/win32cpp/tab.h create mode 100644 mmc_updater/depends/win32cpp/taskdialog.h create mode 100644 mmc_updater/depends/win32cpp/thread.h create mode 100644 mmc_updater/depends/win32cpp/toolbar.h create mode 100644 mmc_updater/depends/win32cpp/treeview.h create mode 100644 mmc_updater/depends/win32cpp/wceframe.h create mode 100644 mmc_updater/depends/win32cpp/wcestddef.h create mode 100644 mmc_updater/depends/win32cpp/webbrowser.h create mode 100644 mmc_updater/depends/win32cpp/wincore.h create mode 100644 mmc_updater/depends/win32cpp/winutils.h (limited to 'mmc_updater/depends/win32cpp') diff --git a/mmc_updater/depends/win32cpp/controls.h b/mmc_updater/depends/win32cpp/controls.h new file mode 100644 index 00000000..a15c8b5f --- /dev/null +++ b/mmc_updater/depends/win32cpp/controls.h @@ -0,0 +1,1074 @@ +// Win32++ Version 7.2 +// Released: 5th AUgust 2011 +// +// David Nash +// email: dnash@bigpond.net.au +// url: https://sourceforge.net/projects/win32-framework +// +// +// Copyright (c) 2005-2011 David Nash +// +// Permission is hereby granted, free of charge, to +// any person obtaining a copy of this software and +// associated documentation files (the "Software"), +// to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, +// merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom +// the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice +// shall be included in all copies or substantial portions +// of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +// OR OTHER DEALINGS IN THE SOFTWARE. +// +//////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////// +// controls.h +// Declaration of the following classes: +// CAnimation, CComboBox, CComboBoxEx, CProgressBar, +// CScrollBar, CSlider, CSpinButton + + +#ifndef _WIN32XX_CONTROLS_H_ +#define _WIN32XX_CONTROLS_H_ + +#include "wincore.h" + +namespace Win32xx +{ + class CAnimation : public CWnd + { + public: + CAnimation() {} + virtual ~CAnimation() {} + + BOOL Close() const; + BOOL Open(LPTSTR lpszName) const; + BOOL Play(UINT wFrom, UINT wTo, UINT cRepeat) const; + BOOL Seek(UINT wFrame) const; + BOOL Stop() const; + + protected: + // Overridables + virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = ANIMATE_CLASS; } + }; + + + class CComboBox : public CWnd + { + public: + CComboBox() {} + virtual ~CComboBox() {} + + int AddString(LPCTSTR lpszString) const; + void Clear() const; + void Copy() const; + void Cut() const; + int DeleteString(int nIndex) const; + int Dir(UINT attr, LPCTSTR lpszWildCard ) const; + int FindString(int nIndexStart, LPCTSTR lpszString) const; + int FindStringExact(int nIndexStart, LPCTSTR lpszString) const; + int GetCount() const; + int GetCurSel() const; + CRect GetDroppedControlRect() const; + BOOL GetDroppedState() const; + int GetDroppedWidth() const; + DWORD GetEditSel() const; + BOOL GetExtendedUI() const; + int GetHorizontalExtent() const; + DWORD GetItemData(int nIndex) const; + int GetItemHeight(int nIndex) const; + int GetLBText(int nIndex, LPTSTR lpszText) const; + int GetLBTextLen(int nIndex) const; + LCID GetLocale() const; + int GetTopIndex() const; + int InitStorage(int nItems, int nBytes) const; + int InsertString(int nIndex, LPCTSTR lpszString) const; + void LimitText(int nMaxChars) const; + void Paste() const; + void ResetContent() const; + int SelectString(int nStartAfter, LPCTSTR lpszString) const; + int SetCurSel(int nIndex) const; + int SetDroppedWidth(int nWidth) const; + BOOL SetEditSel(int nStartChar, int nEndChar) const; + int SetExtendedUI(BOOL bExtended = TRUE) const; + void SetHorizontalExtent(UINT nExtent ) const; + int SetItemData(int nIndex, DWORD dwItemData) const; + int SetItemHeight(int nIndex, UINT cyItemHeight) const; + LCID SetLocale( LCID NewLocale ) const; + int SetTopIndex(int nIndex) const; + void ShowDropDown(BOOL bShow = TRUE) const; + + protected: + // Overridables + virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = _T("ComboBox"); } + }; + + + class CComboBoxEx : public CWnd + { + public: + CComboBoxEx() {} + virtual ~CComboBoxEx() {} + + int DeleteItem(int nIndex ) const; + CWnd* GetComboBoxCtrl() const; + CWnd* GetEditCtrl() const; + DWORD GetExtendedStyle() const; + HIMAGELIST GetImageList() const; + BOOL GetItem(COMBOBOXEXITEM* pCBItem) const; + BOOL HasEditChanged () const; + int InsertItem(COMBOBOXEXITEM* lpcCBItem) const; + DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyles ) const; + HIMAGELIST SetImageList(HIMAGELIST himl) const; + BOOL SetItem(PCOMBOBOXEXITEM lpcCBItem) const; + + protected: + // Overridables + virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = WC_COMBOBOXEX; } + }; + + + class CProgressBar : public CWnd + { + public: + CProgressBar() {} + virtual ~CProgressBar() {} + + int GetPos() const; + int GetRange(BOOL fWhichLimit, PPBRANGE ppBRange) const; + int OffsetPos(int nIncrement) const; + int SetPos(int nNewPos) const; + int SetRange(short nMinRange, short nMaxRange) const; + int SetStep(int nStepInc) const; + int StepIt() const; + + protected: + // Overridables + virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = PROGRESS_CLASS; } + }; + + + class CScrollBar : public CWnd + { + public: + CScrollBar() {} + virtual ~CScrollBar() {} + + BOOL EnableScrollBar( UINT nArrowFlags = ESB_ENABLE_BOTH ) const; + BOOL GetScrollInfo(LPSCROLLINFO lpsi) const; + int GetScrollPos() const; + BOOL GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos ) const; + BOOL SetScrollInfo(LPSCROLLINFO lpsi, BOOL bRedraw = TRUE ) const; + int SetScrollPos(int nPos, BOOL bRedraw) const; + BOOL SetScrollRange( int nMinPos, int nMaxPos, BOOL bRedraw = TRUE ) const; + BOOL ShowScrollBar(BOOL bShow) const; + + protected: + // Overridables + virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = _T("SCROLLBAR"); ; } + }; + + + class CSlider : public CWnd + { + public: + CSlider() {} + virtual ~CSlider() {} + + void ClearSel() const; + void ClearTics(BOOL bRedraw = FALSE ) const; + CWnd* GetBuddy(BOOL fLocation = TRUE ) const; + CRect GetChannelRect() const; + int GetLineSize() const; + int GetNumTics() const; + int GetPageSize() const; + int GetPos() const; + int GetRangeMax() const; + int GetRangeMin() const; + int GetSelEnd() const; + int GetSelStart() const; + int GetThumbLength() const; + CRect GetThumbRect() const; + int GetTic(int nTic ) const; + int GetTicPos(int nTic) const; + CWnd* GetToolTips() const; + CWnd* SetBuddy(CWnd* pBuddy, BOOL fLocation = TRUE ) const; + int SetLineSize(int nSize) const; + int SetPageSize(int nSize) const; + void SetPos(int nPos, BOOL bRedraw = FALSE) const; + void SetRangeMax(int nMax, BOOL bRedraw = FALSE) const; + void SetRangeMin(int nMax, BOOL bRedraw = FALSE) const; + void SetSelection(int nMin, int nMax, BOOL bRedraw = FALSE) const; + BOOL SetTic(int nTic) const; + void SetTicFreq(int nFreq) const; + int SetTipSide(int nLocation) const; + void SetToolTips(CWnd* pToolTip) const; + + protected: + // Overridables + virtual void PreRegisterClass(WNDCLASS &wc) { wc.lpszClassName = TRACKBAR_CLASS; } + }; + + + // Also known as an Up/Down control + class CSpinButton : public CWnd + { + public: + CSpinButton() {} + virtual ~CSpinButton() {} + + int GetAccel(int cAccels, LPUDACCEL paAccels) const; + int GetBase() const; + CWnd* GetBuddy() const; + int GetPos() const; + DWORD GetRange() const; + BOOL SetAccel(int cAccels, LPUDACCEL paAccels) const; + int SetBase(int nBase) const; + CWnd* SetBuddy(CWnd* hwndBuddy) const; + int SetPos(int nPos) const; + void SetRange(int nLower, int nUpper) const; + + protected: + // Overridables + virtual void PreCreate(CREATESTRUCT &cs); + virtual void PreRegisterClass(WNDCLASS &wc); + }; + +} // namespace Win32xx + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +namespace Win32xx +{ + + //////////////////////////////////////// + // Definitions for the CAnimation class + // + inline BOOL CAnimation::Close() const + // Closes an AVI clip. + { + assert(IsWindow()); + return Animate_Close(m_hWnd); + } + + inline BOOL CAnimation::Open(LPTSTR lpszName) const + // Opens an AVI clip and displays its first frame in an animation control. + { + assert(IsWindow()); + return Animate_Open(m_hWnd, lpszName); + } + + inline BOOL CAnimation::Play(UINT wFrom, UINT wTo, UINT cRepeat) const + // Plays an AVI clip in an animation control. The control plays the clip + // in the background while the thread continues executing. + { + assert(IsWindow()); + return Animate_Play(m_hWnd, wFrom, wTo, cRepeat); + } + + inline BOOL CAnimation::Seek(UINT wFrame) const + // Directs an animation control to display a particular frame of an AVI clip. + // The control displays the clip in the background while the thread continues executing. + { + assert(IsWindow()); + return Animate_Seek(m_hWnd, wFrame); + } + + inline BOOL CAnimation::Stop() const + // Stops playing an AVI clip in an animation control. + { + assert(IsWindow()); + return Animate_Stop(m_hWnd); + } + + + //////////////////////////////////////// + // Definitions for the CComboBox class + // + inline int CComboBox::AddString(LPCTSTR lpszString) const + // Adds a string to the list box of a combo box. If the combo box does not + // have the CBS_SORT style, the string is added to the end of the list. + // Otherwise, the string is inserted into the list, and the list is sorted. + { + assert(IsWindow()); + return (int)SendMessage(CB_ADDSTRING, 0, (LPARAM)lpszString); + } + + inline void CComboBox::Clear() const + // Deletes the current selection, if any, from the combo box's edit control. + { + assert(IsWindow()); + SendMessage(WM_CLEAR, 0, 0); + } + + inline void CComboBox::Copy() const + // Copies the current selection to the clipboard in CF_TEXT format. + { + assert(IsWindow()); + SendMessage(WM_COPY, 0, 0); + } + + inline void CComboBox::Cut() const + // Deletes the current selection, if any, in the edit control and copies + // the deleted text to the clipboard in CF_TEXT format. + { + assert(IsWindow()); + SendMessage(WM_CUT, 0, 0); + } + + inline int CComboBox::DeleteString(int nIndex) const + // Deletes a string in the list box of a combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_DELETESTRING, (WPARAM)nIndex, 0); + } + + inline int CComboBox::Dir(UINT attr, LPCTSTR lpszWildCard ) const + // Adds the names of directories and files that match a specified string + // and set of file attributes. + { + assert(IsWindow()); + return (int)SendMessage(CB_DIR, (WPARAM)attr, (LPARAM)lpszWildCard); + } + + inline int CComboBox::FindString(int nIndexStart, LPCTSTR lpszString) const + // Search the list box of a combo box for an item beginning with the + // characters in a specified string. + { + assert(IsWindow()); + return (int)SendMessage(CB_FINDSTRING, (WPARAM)nIndexStart, (LPARAM)lpszString); + } + + inline int CComboBox::FindStringExact(int nIndexStart, LPCTSTR lpszString) const + // Find the first list box string in a combo box that matches the string specified in lpszString. + { + assert(IsWindow()); + return (int)SendMessage(CB_FINDSTRINGEXACT, (WPARAM)nIndexStart, (LPARAM)lpszString); + } + + inline int CComboBox::GetCount() const + // Retrieves the number of items in the list box of the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_GETCOUNT, 0,0); + } + + inline int CComboBox::GetCurSel() const + // Retrieves the index of the currently selected item, if any, in the list box of the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_GETCURSEL, 0,0); + } + + inline CRect CComboBox::GetDroppedControlRect() const + // Retrieves the screen coordinates of the combo box in its dropped-down state. + { + assert(IsWindow()); + CRect rc; + SendMessage(CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc); + return rc; + } + + inline BOOL CComboBox::GetDroppedState() const + // Determines whether the list box of the combo box is dropped down. + { + assert(IsWindow()); + return (BOOL)SendMessage(CB_GETDROPPEDSTATE, 0, 0); + } + + inline int CComboBox::GetDroppedWidth() const + // Retrieves the minimum allowable width, in pixels, of the list box of the combo box + // with the CBS_DROPDOWN or CBS_DROPDOWNLIST style. + { + assert(IsWindow()); + return (int)SendMessage(CB_GETDROPPEDWIDTH, 0, 0); + } + + inline DWORD CComboBox::GetEditSel() const + // Gets the starting and ending character positions of the current selection + // in the edit control of the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_GETEDITSEL, 0, 0); + } + + inline BOOL CComboBox::GetExtendedUI() const + // Determines whether the combo box has the default user interface or the extended user interface. + { + assert(IsWindow()); + return (BOOL)SendMessage(CB_GETEXTENDEDUI, 0, 0); + } + + inline int CComboBox::GetHorizontalExtent() const + // Retrieve from the combo box the width, in pixels, by which the list box can + // be scrolled horizontally (the scrollable width). + { + assert(IsWindow()); + return (int)SendMessage(CB_GETHORIZONTALEXTENT, 0, 0); + } + + inline DWORD CComboBox::GetItemData(int nIndex) const + // Retrieves the application-supplied value associated with the specified item in the combo box. + { + assert(IsWindow()); + return (DWORD)SendMessage(CB_GETITEMDATA, (WPARAM)nIndex, 0); + } + + inline int CComboBox::GetItemHeight(int nIndex) const + // Determines the height of list items or the selection field in the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_GETITEMHEIGHT, (WPARAM)nIndex, 0); + } + + inline int CComboBox::GetLBText(int nIndex, LPTSTR lpszText) const + // Retrieves a string from the list of the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)lpszText); + } + + inline int CComboBox::GetLBTextLen(int nIndex) const + // Retrieves the length, in characters, of a string in the list of the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_GETLBTEXTLEN, (WPARAM)nIndex, 0); + } + + inline LCID CComboBox::GetLocale() const + // Retrieves the current locale of the combo box. + { + assert(IsWindow()); + return (LCID)SendMessage(CB_GETLOCALE, 0, 0); + } + + inline int CComboBox::GetTopIndex() const + // Retrieves the zero-based index of the first visible item in the list box portion of the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_GETTOPINDEX, 0, 0); + } + + inline int CComboBox::InitStorage(int nItems, int nBytes) const + // Allocates memory for storing list box items. Use this before adding a + // large number of items to the list box portion of a combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_INITSTORAGE, (WPARAM)nItems, (LPARAM)nBytes); + } + + inline int CComboBox::InsertString(int nIndex, LPCTSTR lpszString) const + // Inserts a string into the list box of the combo box. Unlike the AddString, + // a list with the CBS_SORT style is not sorted. + { + assert(IsWindow()); + return (int)SendMessage(CB_INSERTSTRING, (WPARAM)nIndex, (LPARAM)lpszString); + } + + inline void CComboBox::Paste() const + // Copies the current content of the clipboard to the combo box's edit control at the current caret position. + { + assert(IsWindow()); + SendMessage(WM_PASTE, 0, 0); + } + + inline void CComboBox::LimitText(int nMaxChars) const + // Limits the length of the text the user may type into the edit control of the combo box. + { + assert(IsWindow()); + SendMessage(CB_LIMITTEXT, (WPARAM)nMaxChars, 0); + } + + inline void CComboBox::ResetContent() const + // Removes all items from the list box and edit control of the combo box. + { + assert(IsWindow()); + SendMessage(CB_RESETCONTENT, 0, 0); + } + + inline int CComboBox::SelectString(int nStartAfter, LPCTSTR lpszString) const + // Searches the list of a combo box for an item that begins with the characters in a + // specified string. If a matching item is found, it is selected and copied to the edit control. + { + assert(IsWindow()); + return (int)SendMessage(CB_SELECTSTRING, (WPARAM)nStartAfter, (LPARAM)lpszString); + } + + inline int CComboBox::SetCurSel(int nIndex) const + // Selects a string in the list of the combo box. If necessary, the list scrolls the string into view. + { + assert(IsWindow()); + return (int)SendMessage(CB_SETCURSEL, (WPARAM)nIndex, 0); + } + + inline int CComboBox::SetDroppedWidth(int nWidth) const + // Sets the maximum allowable width, in pixels, of the list box of the combo box with + // the CBS_DROPDOWN or CBS_DROPDOWNLIST style. + { + assert(IsWindow()); + return (int)SendMessage(CB_SETDROPPEDWIDTH, (WPARAM)nWidth, 0); + } + + inline BOOL CComboBox::SetEditSel(int nStartChar, int nEndChar) const + // Selects characters in the edit control of the combo box. + { + assert(IsWindow()); + return (BOOL)SendMessage(CB_SETEDITSEL, 0, (LPARAM)MAKELONG(nStartChar,nEndChar)); + } + + inline int CComboBox::SetExtendedUI(BOOL bExtended) const + // Selects either the default user interface or the extended user interface for the combo box that + // has the CBS_DROPDOWN or CBS_DROPDOWNLIST style. + { + assert(IsWindow()); + return (int)SendMessage(CB_SETEXTENDEDUI, (WPARAM)bExtended, 0); + } + + inline void CComboBox::SetHorizontalExtent(UINT nExtent ) const + // Sets the width, in pixels, by which the list box can be scrolled horizontally (the scrollable width). + { + assert(IsWindow()); + SendMessage(CB_SETHORIZONTALEXTENT, (WPARAM)nExtent, 0); + } + + inline int CComboBox::SetItemData(int nIndex, DWORD dwItemData) const + // Sets the value associated with the specified item in the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_SETITEMDATA, (WPARAM)nIndex, (LPARAM)dwItemData); + } + + inline int CComboBox::SetItemHeight(int nIndex, UINT cyItemHeight) const + // Sets the height of list items or the selection field in the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_SETITEMHEIGHT, (WPARAM)nIndex, (LPARAM)cyItemHeight); + } + + inline LCID CComboBox::SetLocale( LCID NewLocale ) const + // Sets the current locale of the combo box. + { + assert(IsWindow()); + return (LCID)SendMessage(CB_SETLOCALE, (WPARAM)NewLocale, 0); + } + + inline int CComboBox::SetTopIndex(int nIndex) const + // Ensure that a particular item is visible in the list box of the combo box. + { + assert(IsWindow()); + return (int)SendMessage(CB_SETTOPINDEX, (WPARAM)nIndex, 0); + } + + inline void CComboBox::ShowDropDown(BOOL bShow) const + // Shows or hides the list box of the combo box that has the CBS_DROPDOWN or CBS_DROPDOWNLIST style. + { + assert(IsWindow()); + SendMessage(CB_SHOWDROPDOWN, (WPARAM)bShow, 0); + } + + + //////////////////////////////////////// + // Definitions for the CComboBoxEx class + // + inline int CComboBoxEx::DeleteItem(int nIndex ) const + // Removes an item from the ComboBoxEx control. + { + assert(IsWindow()); + return (int)SendMessage(CBEM_DELETEITEM, (WPARAM)nIndex, 0); + } + + inline CWnd* CComboBoxEx::GetComboBoxCtrl() const + // Retrieves the handle to the child combo box control. + { + assert(IsWindow()); + return FromHandle((HWND)SendMessage(CBEM_GETCOMBOCONTROL, 0, 0)); + } + + inline CWnd* CComboBoxEx::GetEditCtrl() const + // Retrieves the handle to the edit control portion of the ComboBoxEx control. + { + assert(IsWindow()); + return FromHandle((HWND)SendMessage(CBEM_GETEDITCONTROL, 0, 0)); + } + + inline DWORD CComboBoxEx::GetExtendedStyle() const + // Retrieves the extended styles that are in use for the ComboBoxEx control. + { + assert(IsWindow()); + return (DWORD)SendMessage(CBEM_GETEXTENDEDSTYLE, 0, 0); + } + + inline HIMAGELIST CComboBoxEx::GetImageList() const + // Retrieves the handle to an image list assigned to the ComboBoxEx control. + { + assert(IsWindow()); + return (HIMAGELIST)SendMessage(CBEM_GETIMAGELIST, 0, 0); + } + + inline BOOL CComboBoxEx::GetItem(COMBOBOXEXITEM* pCBItem) const + // Retrieves item information for the given ComboBoxEx item. + { + assert(IsWindow()); + return (BOOL)SendMessage(CBEM_GETITEM, 0, (LPARAM)pCBItem); + } + + inline BOOL CComboBoxEx::HasEditChanged () const + // Determines whether or not the user has changed the text of the ComboBoxEx edit control. + { + assert(IsWindow()); + return (BOOL)SendMessage(CBEM_HASEDITCHANGED, 0, 0); + } + + inline int CComboBoxEx::InsertItem(COMBOBOXEXITEM* lpcCBItem) const + // Inserts a new item in the ComboBoxEx control. + { + assert(IsWindow()); + return (int)SendMessage(CBEM_INSERTITEM, 0, (LPARAM)lpcCBItem); + } + + inline DWORD CComboBoxEx::SetExtendedStyle(DWORD dwExMask, DWORD dwExStyles ) const + // Sets extended styles within the ComboBoxEx control. + { + assert(IsWindow()); + return (DWORD)SendMessage(CBEM_SETEXTENDEDSTYLE, (WPARAM)dwExMask, (LPARAM)dwExStyles); + } + + inline HIMAGELIST CComboBoxEx::SetImageList(HIMAGELIST himl) const + // Sets an image list for the ComboBoxEx control. + { + assert(IsWindow()); + return (HIMAGELIST)SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)himl); + } + + inline BOOL CComboBoxEx::SetItem(PCOMBOBOXEXITEM lpcCBItem) const + // Sets the attributes for an item in the ComboBoxEx control. + { + assert(IsWindow()); + return (BOOL)SendMessage(CBEM_SETITEM, 0, (LPARAM)lpcCBItem); + } + + + //////////////////////////////////////// + // Definitions for the CProgressBar class + // + inline int CProgressBar::GetPos() const + // Retrieves the current position of the progress bar. + { + assert(IsWindow()); + return (int)SendMessage(PBM_GETPOS, 0, 0); + } + + inline int CProgressBar::GetRange(BOOL fWhichLimit, PPBRANGE ppBRange) const + // Retrieves information about the current high and low limits of the progress bar control. + { + assert(IsWindow()); + return (int)SendMessage(PBM_GETRANGE, (WPARAM)fWhichLimit, (LPARAM) (PPBRANGE) ppBRange); + } + + inline int CProgressBar::OffsetPos(int nIncrement) const + // Advances the current position of the progress bar by a specified increment and redraws + // the bar to reflect the new position. + { + assert(IsWindow()); + return (int)SendMessage(PBM_DELTAPOS, (WPARAM)nIncrement, 0); + } + + inline int CProgressBar::SetPos(int nNewPos) const + // Sets the current position for the progress bar and redraws the bar to reflect the new position. + { + assert(IsWindow()); + return (int)SendMessage(PBM_SETPOS, (WPARAM)nNewPos, 0); + } + + inline int CProgressBar::SetRange(short nMinRange, short nMaxRange) const + // Sets the minimum and maximum values for the progress bar and redraws the bar to reflect the new range. + { + assert(IsWindow()); + return (int)SendMessage(PBM_SETRANGE, 0, (LPARAM) MAKELPARAM (nMinRange, nMaxRange)); + } + + inline int CProgressBar::SetStep(int nStepInc) const + // Specifies the step increment for the progress bar. + { + assert(IsWindow()); + return (int)SendMessage(PBM_SETSTEP, (WPARAM)nStepInc, 0); + } + + inline int CProgressBar::StepIt() const + // Advances the current position for a progress bar by the step increment and + // redraws the bar to reflect the new position. + { + assert(IsWindow()); + return (int)SendMessage(PBM_STEPIT, 0, 0); + } + + + //////////////////////////////////////// + // Definitions for the CScrollBar class + // + inline BOOL CScrollBar::EnableScrollBar( UINT nArrowFlags ) const + // Enables or disables the scroll bar arrows. + { + assert(IsWindow()); + return ::EnableScrollBar(m_hWnd, SB_CTL, nArrowFlags); + } + + inline BOOL CScrollBar::GetScrollInfo(LPSCROLLINFO lpsi) const + // Retrieves the parameters of a scroll bar, including the minimum and maximum + // scrolling positions, the page size, and the position of the scroll box (thumb). + { + assert(IsWindow()); + return ::GetScrollInfo(m_hWnd, SB_CTL, lpsi); + } + + inline int CScrollBar::GetScrollPos() const + // Retrieves the current position of the scroll box (thumb) in the scroll bar. + { + assert(IsWindow()); + return ::GetScrollPos(m_hWnd, SB_CTL); + } + + inline BOOL CScrollBar::GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos ) const + // Retrieves the current minimum and maximum scroll box (thumb) positions for the scroll bar. + { + assert(IsWindow()); + return ::GetScrollRange(m_hWnd, SB_CTL, lpMinPos, lpMaxPos); + } + + inline BOOL CScrollBar::SetScrollInfo(LPSCROLLINFO lpsi, BOOL bRedraw ) const + // Sets the parameters of the scroll bar, including the minimum and maximum scrolling positions, + // the page size, and the position of the scroll box (thumb). + { + assert(IsWindow()); + return ::SetScrollInfo(m_hWnd, SB_CTL, lpsi, bRedraw); + } + + inline int CScrollBar::SetScrollPos(int nPos, BOOL bRedraw) const + // Sets the position of the scroll box (thumb) in the scroll bar and, if requested, + // redraws the scroll bar to reflect the new position of the scroll box. + { + assert(IsWindow()); + return ::SetScrollPos(m_hWnd, SB_CTL, nPos, bRedraw); + } + + inline BOOL CScrollBar::SetScrollRange( int nMinPos, int nMaxPos, BOOL bRedraw ) const + // Sets the minimum and maximum scroll box positions for the scroll bar. + { + assert(IsWindow()); + return ::SetScrollRange(m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw); + } + + inline BOOL CScrollBar::ShowScrollBar(BOOL bShow) const + // Shows or hides the scroll bar. + { + assert(IsWindow()); + return ::ShowScrollBar(m_hWnd, SB_CTL, bShow); + } + + //////////////////////////////////////// + // Definitions for the CSlider class + // + inline void CSlider::ClearSel() const + // Clears the current selection range in the trackbar. + { + assert(IsWindow()); + SendMessage(TBM_CLEARSEL, 0, 0); + } + + inline void CSlider::ClearTics(BOOL bRedraw) const + // Removes the current tick marks from the trackbar. + { + assert(IsWindow()); + SendMessage(TBM_CLEARTICS, (WPARAM)bRedraw, 0); + } + + inline CWnd* CSlider::GetBuddy(BOOL fLocation) const + // Retrieves the handle to the trackbar control buddy window at a given location. + { + assert(IsWindow()); + return FromHandle((HWND)SendMessage(TBM_GETBUDDY, (WPARAM)fLocation, 0)); + } + + inline CRect CSlider::GetChannelRect() const + // Retrieves the size and position of the bounding rectangle for the trackbar's channel. + { + assert(IsWindow()); + CRect rc; + SendMessage(TBM_GETCHANNELRECT, 0, (LPARAM)&rc); + return rc; + } + + inline int CSlider::GetLineSize() const + // Retrieves the number of logical positions the trackbar's slider moves in response + // to keyboard input from the arrow keys. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETLINESIZE, 0, 0); + } + + inline int CSlider::GetNumTics() const + // Retrieves the number of tick marks in the trackbar. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETNUMTICS, 0, 0); + } + + inline int CSlider::GetPageSize() const + // Retrieves the number of logical positions the trackbar's slider moves in response to + // keyboard input, or mouse input, such as clicks in the trackbar's channel. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETPAGESIZE, 0, 0); + } + + inline int CSlider::GetPos() const + // Retrieves the current logical position of the slider in the trackbar. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETPOS, 0, 0); + } + + inline int CSlider::GetRangeMax() const + // Retrieves the maximum position for the slider in the trackbar. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETRANGEMAX, 0, 0); + } + + inline int CSlider::GetRangeMin() const + // Retrieves the minimum position for the slider in the trackbar. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETRANGEMIN, 0, 0); + } + + inline int CSlider::GetSelEnd() const + // Retrieves the ending position of the current selection range in the trackbar. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETSELEND, 0, 0); + } + + inline int CSlider::GetSelStart() const + // Retrieves the starting position of the current selection range in the trackbar. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETSELSTART, 0, 0); + } + + inline int CSlider::GetThumbLength() const + // Retrieves the length of the slider in the trackbar. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETTHUMBLENGTH, 0, 0); + } + + inline CRect CSlider::GetThumbRect() const + // Retrieves the size and position of the bounding rectangle for the slider in the trackbar. + { + CRect rc; + SendMessage(TBM_GETTHUMBRECT, 0, (LPARAM)&rc); + return rc; + } + + inline int CSlider::GetTic(int nTic ) const + // Retrieves the logical position of a tick mark in the trackbar. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETTIC, (WPARAM)nTic, 0); + } + + inline int CSlider::GetTicPos(int nTic) const + // Retrieves the current physical position of a tick mark in the trackbar. + { + assert(IsWindow()); + return (int)SendMessage(TBM_GETTICPOS, (WPARAM)nTic, 0); + } + + inline CWnd* CSlider::GetToolTips() const + // Retrieves the handle to the ToolTip control assigned to the trackbar, if any. + { + assert(IsWindow()); + return FromHandle((HWND)SendMessage(TBM_GETTOOLTIPS, 0, 0)); + } + + inline CWnd* CSlider::SetBuddy(CWnd* pBuddy, BOOL fLocation /*= TRUE*/ ) const + // Assigns a window as the buddy window for the trackbar control. + { + assert(IsWindow()); + return FromHandle((HWND)SendMessage(TBM_SETBUDDY, (WPARAM)fLocation, (LPARAM)pBuddy->GetHwnd())); + } + + inline int CSlider::SetLineSize(int nSize) const + // Sets the number of logical positions the trackbar's slider moves in response to + // keyboard input from the arrow keys. + { + assert(IsWindow()); + return(int)SendMessage(TBM_SETLINESIZE, 0, (LPARAM)nSize); + } + + inline int CSlider::SetPageSize(int nSize) const + // Sets the number of logical positions the trackbar's slider moves in response to + // keyboard input, or mouse input such as clicks in the trackbar's channel. + { + assert(IsWindow()); + return(int)SendMessage(TBM_SETPAGESIZE, 0, (LPARAM)nSize); + } + + inline void CSlider::SetPos(int nPos, BOOL bRedraw) const + // Sets the current logical position of the slider in the trackbar. + { + assert(IsWindow()); + SendMessage(TBM_SETPOS, (WPARAM)bRedraw, (LPARAM)nPos); + } + + inline void CSlider::SetRangeMax(int nMax, BOOL bRedraw) const + // Sets the maximum logical position for the slider in the trackbar. + { + assert(IsWindow()); + SendMessage(TBM_SETRANGEMAX, (WPARAM)bRedraw, (LPARAM)nMax); + } + + inline void CSlider::SetRangeMin(int nMax, BOOL bRedraw) const + // Sets the minimum logical position for the slider in the trackbar. + { + assert(IsWindow()); + SendMessage(TBM_SETRANGEMIN, (WPARAM)bRedraw, (LPARAM)nMax); + } + + inline void CSlider::SetSelection(int nMin, int nMax, BOOL bRedraw) const + // Sets the starting and ending positions for the available selection range in the trackbar. + { + assert(IsWindow()); + SendMessage(TBM_SETSEL, (WPARAM)bRedraw, (LPARAM)MAKELONG(nMax, nMin)); + } + + inline BOOL CSlider::SetTic(int nTic) const + // Sets a tick mark in the trackbar at the specified logical position. + { + assert(IsWindow()); + return (BOOL)SendMessage(TBM_SETTIC, 0, nTic); + } + + inline void CSlider::SetTicFreq(int nFreq) const + // Sets the interval frequency for tick marks in the trackbar. + { + assert(IsWindow()); + SendMessage(TBM_SETTICFREQ, (WPARAM)nFreq, 0); + } + + inline int CSlider::SetTipSide(int nLocation) const + // Positions a ToolTip control used by the trackbar control. + { + assert(IsWindow()); + return (int)SendMessage(TBM_SETTIPSIDE, (WPARAM)nLocation, 0); + } + + inline void CSlider::SetToolTips(CWnd* pToolTip) const + // Assigns a ToolTip control to the trackbar control. + { + assert(IsWindow()); + SendMessage(TBM_SETTOOLTIPS, (WPARAM)pToolTip->GetHwnd(), 0); + } + + //////////////////////////////////////// + // Definitions for the CSpinButton class + // + inline int CSpinButton::GetAccel(int cAccels, LPUDACCEL paAccels) const + // Retrieves acceleration information for the up-down control. + { + assert(IsWindow()); + return (int)SendMessage(UDM_GETACCEL, (WPARAM)cAccels, (LPARAM)paAccels); + } + + inline int CSpinButton::GetBase() const + // Retrieves the current radix base (that is, either base 10 or 16) for the up-down control. + { + assert(IsWindow()); + return (int)SendMessage(UDM_GETBASE, 0, 0); + } + + inline CWnd* CSpinButton::GetBuddy() const + // Retrieves the handle to the current buddy window. + { + assert(IsWindow()); + return FromHandle((HWND)SendMessage(UDM_GETBUDDY, 0, 0)); + } + + inline int CSpinButton::GetPos() const + // Retrieves the current position of the up-down control with 16-bit precision. + { + assert(IsWindow()); + return (int)SendMessage(UDM_GETPOS, 0, 0); + } + + inline DWORD CSpinButton::GetRange() const + // Retrieves the minimum and maximum positions (range) for the up-down control. + { + assert(IsWindow()); + return (DWORD)SendMessage(UDM_GETRANGE, 0, 0); + } + + inline void CSpinButton::PreCreate(CREATESTRUCT &cs) + { + cs.style = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VISIBLE |UDS_SETBUDDYINT; + } + + inline void CSpinButton::PreRegisterClass(WNDCLASS &wc) + { + wc.lpszClassName = UPDOWN_CLASS; + } + + inline BOOL CSpinButton::SetAccel(int cAccels, LPUDACCEL paAccels) const + // Sets the acceleration for the up-down control. + { + assert(IsWindow()); + return (BOOL)SendMessage(UDM_SETACCEL, (WPARAM)cAccels, (LPARAM)paAccels); + } + + inline int CSpinButton::SetBase(int nBase) const + // Sets the radix base for the up-down control. + { + assert(IsWindow()); + return (int)SendMessage(UDM_SETBASE, (WPARAM)nBase, 0); + } + + inline CWnd* CSpinButton::SetBuddy(CWnd* pBuddy) const + // Sets the buddy window for the up-down control. + { + assert(IsWindow()); + return FromHandle((HWND)SendMessage(UDM_SETBUDDY, (WPARAM)pBuddy->GetHwnd(), 0)); + } + + inline int CSpinButton::SetPos(int nPos) const + // Sets the current position for the up-down control with 16-bit precision. + { + assert(IsWindow()); + return (int)SendMessage(UDM_SETPOS, 0, (LPARAM)MAKELONG ((short) nPos, 0)); + } + + inline void CSpinButton::SetRange(int nLower, int nUpper) const + // Sets the minimum and maximum positions (range) for the up-down control. + { + assert(IsWindow()); + SendMessage(UDM_SETRANGE, 0, (LPARAM)MAKELONG(nUpper, nLower)); + } + +} // namespace Win32xx + +#endif // define _WIN32XX_CONTROLS_H_ + diff --git a/mmc_updater/depends/win32cpp/copyright.txt b/mmc_updater/depends/win32cpp/copyright.txt new file mode 100644 index 00000000..d2222fa7 --- /dev/null +++ b/mmc_updater/depends/win32cpp/copyright.txt @@ -0,0 +1,33 @@ +Win32++ Version 7.2 +Released: 5th AUgust 2011 + + David Nash + email: dnash@bigpond.net.au + url: https://sourceforge.net/projects/win32-framework + + +Copyright (c) 2005-2011 David Nash + +Permission is hereby granted, free of charge, to +any person obtaining a copy of this software and +associated documentation files (the "Software"), +to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/mmc_updater/depends/win32cpp/cstring.h b/mmc_updater/depends/win32cpp/cstring.h new file mode 100644 index 00000000..faf574d5 --- /dev/null +++ b/mmc_updater/depends/win32cpp/cstring.h @@ -0,0 +1,905 @@ +// Win32++ Version 7.2 +// Released: 5th AUgust 2011 +// +// David Nash +// email: dnash@bigpond.net.au +// url: https://sourceforge.net/projects/win32-framework +// +// +// Copyright (c) 2005-2011 David Nash +// +// Permission is hereby granted, free of charge, to +// any person obtaining a copy of this software and +// associated documentation files (the "Software"), +// to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, +// merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom +// the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice +// shall be included in all copies or substantial portions +// of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +// OR OTHER DEALINGS IN THE SOFTWARE. +// +//////////////////////////////////////////////////////// + + +// Acknowledgements: +// Thanks to Adam Szulc for his initial CString code. + +//////////////////////////////////////////////////////// +// cstring.h +// Declaration of the cstring.h + +// This class is intended to provide a simple alternative to the MFC/ATL +// CString class that ships with Microsoft compilers. The CString class +// specified here is compatible with other compilers such as Borland 5.5 +// and MinGW. + +// Differences between this class and the MFC/ATL CString class +// ------------------------------------------------------------ +// 1) The constructors for this class accepts only TCHARs. The various text conversion +// functions can be used to convert from other character types to TCHARs. +// +// 2) This class is not reference counted, so these CStrings should be passed as +// references or const references when used as function arguments. As a result there +// is no need for functions like LockBuffer and UnLockBuffer. +// +// 3) The Format functions only accepts POD (Plain Old Data) arguments. It does not +// accept arguments which are class or struct objects. In particular it does not +// accept CString objects, unless these are cast to LPCTSTR. +// This is demonstrates valid and invalid usage: +// CString string1(_T("Hello World")); +// CString string2; +// +// // This is invalid, and produces undefined behaviour. +// string2.Format(_T("String1 is: %s"), string1); // No! you can't do this +// +// // This is ok +// string2.Format(_T("String1 is: %s"), (LPCTSTR)string1); // Yes, this is correct +// +// Note: The MFC/ATL CString class uses a non portable hack to make its CString class +// behave like a POD. Other compilers (such as the MinGW compiler) specifically +// prohibit the use of non POD types for functions with variable argument lists. +// +// 4) This class provides a few additional functions: +// b_str Returns a BSTR string. This an an alternative for casting to BSTR. +// c_str Returns a const TCHAR string. This is an alternative for casting to LPCTSTR. +// GetErrorString Assigns CString to the error string for the specified System Error Code +// (from ::GetLastErrror() for example). +// GetString Returns a reference to the underlying std::basic_string. This +// reference can be used to modify the string directly. + + + +#ifndef _WIN32XX_CSTRING_H_ +#define _WIN32XX_CSTRING_H_ + + +#include "wincore.h" + + +namespace Win32xx +{ + + class CString + { + // friend functions allow the left hand side to be something other than CString + friend CString operator + (const CString& string1, const CString& string2); + friend CString operator + (const CString& string, LPCTSTR pszText); + friend CString operator + (const CString& string, TCHAR ch); + friend CString operator + (LPCTSTR pszText, const CString& string); + friend CString operator + (TCHAR ch, const CString& string); + + public: + CString(); + ~CString(); + CString(const CString& str); + CString(LPCTSTR pszText); + CString(TCHAR ch, int nLength = 1); + CString(LPCTSTR pszText, int nLength); + + CString& operator = (const CString& str); + CString& operator = (const TCHAR ch); + CString& operator = (LPCTSTR pszText); + BOOL operator == (LPCTSTR pszText); + BOOL operator != (LPCTSTR pszText); + BOOL operator < (LPCTSTR pszText); + BOOL operator > (LPCTSTR pszText); + BOOL operator <= (LPCTSTR pszText); + BOOL operator >= (LPCTSTR pszText); + operator LPCTSTR() const; + operator BSTR() const; + TCHAR& operator [] (int nIndex); + CString& operator += (const CString& str); + + // Attributes + BSTR b_str() const { return T2W(m_str.c_str()); } // alternative for casting to BSTR + LPCTSTR c_str() const { return m_str.c_str(); } // alternative for casting to LPCTSTR + tString& GetString() { return m_str; } // returns a reference to the underlying std::basic_string + int GetLength() const { return (int)m_str.length(); } // returns the length in characters + + // Operations + BSTR AllocSysString() const; + void AppendFormat(LPCTSTR pszFormat,...); + void AppendFormat(UINT nFormatID, ...); + int Compare(LPCTSTR pszText) const; + int CompareNoCase(LPCTSTR pszText) const; + int Delete(int nIndex, int nCount = 1); + int Find(TCHAR ch, int nIndex = 0 ) const; + int Find(LPCTSTR pszText, int nStart = 0) const; + int FindOneOf(LPCTSTR pszText) const; + void Format(UINT nID, ...); + void Format(LPCTSTR pszFormat,...); + void FormatV(LPCTSTR pszFormat, va_list args); + void FormatMessage(LPCTSTR pszFormat,...); + void FormatMessageV(LPCTSTR pszFormat, va_list args); + TCHAR GetAt(int nIndex) const; + LPTSTR GetBuffer(int nMinBufLength); + void GetErrorString(DWORD dwError); + void Empty(); + int Insert(int nIndex, TCHAR ch); + int Insert(int nIndex, const CString& str); + BOOL IsEmpty() const; + CString Left(int nCount) const; + BOOL LoadString(UINT nID); + void MakeLower(); + void MakeReverse(); + void MakeUpper(); + CString Mid(int nFirst) const; + CString Mid(int nFirst, int nCount) const; + void ReleaseBuffer( int nNewLength = -1 ); + int Remove(LPCTSTR pszText); + int Replace(TCHAR chOld, TCHAR chNew); + int Replace(const LPCTSTR pszOld, LPCTSTR pszNew); + int ReverseFind(LPCTSTR pszText, int nStart = -1) const; + CString Right(int nCount) const; + void SetAt(int nIndex, TCHAR ch); + BSTR SetSysString(BSTR* pBstr) const; + CString SpanExcluding(LPCTSTR pszText) const; + CString SpanIncluding(LPCTSTR pszText) const; + CString Tokenize(LPCTSTR pszTokens, int& iStart) const; + void Trim(); + void TrimLeft(); + void TrimLeft(TCHAR chTarget); + void TrimLeft(LPCTSTR pszTargets); + void TrimRight(); + void TrimRight(TCHAR chTarget); + void TrimRight(LPCTSTR pszTargets); + void Truncate(int nNewLength); + +#ifndef _WIN32_WCE + int Collate(LPCTSTR pszText) const; + int CollateNoCase(LPCTSTR pszText) const; + BOOL GetEnvironmentVariable(LPCTSTR pszVar); +#endif + + private: + tString m_str; + std::vector m_buf; + }; + + inline CString::CString() + { + } + + inline CString::~CString() + { + } + + inline CString::CString(const CString& str) + { + m_str.assign(str); + } + + inline CString::CString(LPCTSTR pszText) + { + m_str.assign(pszText); + } + + inline CString::CString(TCHAR ch, int nLength) + { + m_str.assign(nLength, ch); + } + + inline CString::CString(LPCTSTR pszText, int nLength) + { + m_str.assign(pszText, nLength); + } + + inline CString& CString::operator = (const CString& str) + { + m_str.assign(str); + return *this; + } + + inline CString& CString::operator = (const TCHAR ch) + { + m_str.assign(1, ch); + return *this; + } + + inline CString& CString::operator = (LPCTSTR pszText) + { + m_str.assign(pszText); + return *this; + } + + inline BOOL CString::operator == (LPCTSTR pszText) + // Returns TRUE if the strings have the same content + { + assert(pszText); + return (0 == Compare(pszText)); + } + + inline BOOL CString::operator != (LPCTSTR pszText) + // Returns TRUE if the strings have a different content + { + assert(pszText); + return Compare(pszText) != 0; + } + + inline BOOL CString::operator < (LPCTSTR pszText) + { + assert(pszText); + return Compare(pszText) < 0; + } + + inline BOOL CString::operator > (LPCTSTR pszText) + { + assert(pszText); + return Compare(pszText) > 0; + } + + inline BOOL CString::operator <= (LPCTSTR pszText) + { + assert(pszText); + return Compare(pszText) <= 0; + } + + inline BOOL CString::operator >= (LPCTSTR pszText) + { + assert(pszText); + return Compare(pszText) >= 0; + } + + inline CString::operator LPCTSTR() const + { + return m_str.c_str(); + } + + inline TCHAR& CString::operator [] (int nIndex) + { + assert(nIndex >= 0); + assert(nIndex < GetLength()); + return m_str[nIndex]; + } + + inline CString& CString::operator += (const CString& str) + { + m_str.append(str); + return *this; + } + + inline BSTR CString::AllocSysString() const + // Allocates a BSTR from the CString content. + { + return ::SysAllocStringLen(T2W(m_str.c_str()), (UINT)m_str.size()); + } + + inline void CString::AppendFormat(LPCTSTR pszFormat,...) + // Appends formatted data to an the CString content. + { + CString str; + str.Format(pszFormat); + m_str.append(str); + } + + inline void CString::AppendFormat(UINT nFormatID, ...) + // Appends formatted data to an the CString content. + { + CString str1; + CString str2; + if (str1.LoadString(nFormatID)) + { + str2.Format(str1); + m_str.append(str2); + } + } + +#ifndef _WIN32_WCE + inline int CString::Collate(LPCTSTR pszText) const + // Performs a case sensitive comparison of the two strings using locale-specific information. + { + assert(pszText); + return _tcscoll(m_str.c_str(), pszText); + } + + inline int CString::CollateNoCase(LPCTSTR pszText) const + // Performs a case insensitive comparison of the two strings using locale-specific information. + { + assert(pszText); + return _tcsicoll(m_str.c_str(), pszText); + } +#endif // _WIN32_WCE + + inline int CString::Compare(LPCTSTR pszText) const + // Performs a case sensitive comparison of the two strings. + { + assert(pszText); + return m_str.compare(pszText); + } + + inline int CString::CompareNoCase(LPCTSTR pszText) const + // Performs a case insensitive comparison of the two strings. + { + assert(pszText); + return _tcsicmp(m_str.data(), pszText); + } + + inline int CString::Delete(int nIndex, int nCount /* = 1 */) + // Deletes a character or characters from the string. + { + assert(nIndex >= 0); + assert(nCount >= 0); + + m_str.erase(nIndex, nCount); + return (int)m_str.size(); + } + + inline void CString::Empty() + // Erases the contents of the string. + { + m_str.erase(); + } + + inline int CString::Find(TCHAR ch, int nIndex /* = 0 */) const + // Finds a character in the string. + { + assert(nIndex >= 0); + return (int)m_str.find(ch, nIndex); + } + + inline int CString::Find(LPCTSTR pszText, int nIndex /* = 0 */) const + // Finds a substring within the string. + { + assert(pszText); + assert(nIndex >= 0); + return (int)m_str.find(pszText, nIndex); + } + + inline int CString::FindOneOf(LPCTSTR pszText) const + // Finds the first matching character from a set. + { + assert(pszText); + return (int)m_str.find_first_of(pszText); + } + + inline void CString::Format(LPCTSTR pszFormat,...) + // Formats the string as sprintf does. + { + va_list args; + va_start(args, pszFormat); + FormatV(pszFormat, args); + va_end(args); + } + + inline void CString::Format(UINT nID, ...) + // Formats the string as sprintf does. + { + Empty(); + CString str; + if (str.LoadString(nID)) + Format(str); + } + + inline void CString::FormatV(LPCTSTR pszFormat, va_list args) + // Formats the string using a variable list of arguments. + { + if (pszFormat) + { + int nResult = -1, nLength = 256; + + // A vector is used to store the TCHAR array + std::vector vBuffer;( nLength+1, _T('\0') ); + + while (-1 == nResult) + { + vBuffer.assign( nLength+1, _T('\0') ); + nResult = _vsntprintf(&vBuffer[0], nLength, pszFormat, args); + nLength *= 2; + } + m_str.assign(&vBuffer[0]); + } + } + + inline void CString::FormatMessage(LPCTSTR pszFormat,...) + // Formats a message string. + { + va_list args; + va_start(args, pszFormat); + FormatMessageV(pszFormat, args); + va_end(args); + } + + inline void CString::FormatMessageV(LPCTSTR pszFormat, va_list args) + // Formats a message string using a variable argument list. + { + LPTSTR pszTemp = 0; + if (pszFormat) + { + DWORD dwResult = ::FormatMessage(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER, pszFormat, 0, 0, pszTemp, 0, &args); + + if (0 == dwResult || 0 == pszTemp ) + throw std::bad_alloc(); + + m_str = pszTemp; + LocalFree(pszTemp); + } + } + + inline TCHAR CString::GetAt(int nIndex) const + // Returns the character at the specified location within the string. + { + assert(nIndex >= 0); + assert(nIndex < GetLength()); + return m_str[nIndex]; + } + + inline LPTSTR CString::GetBuffer(int nMinBufLength) + // Creates a buffer of nMinBufLength charaters (+1 extra for NULL termination) and returns + // a pointer to this buffer. This buffer can be used by any function which accepts a LPTSTR. + // Care must be taken not to exceed the length of the buffer. Use ReleaseBuffer to safely + // copy this buffer back to the CString object. + // + // Note: The buffer uses a vector. Vectors are required to be contiguous in memory under + // the current standard, whereas std::strings do not have this requirement. + { + assert (nMinBufLength >= 0); + + m_buf.assign(nMinBufLength + 1, _T('\0')); + tString::iterator it_end; + + if (m_str.length() >= (size_t)nMinBufLength) + { + it_end = m_str.begin(); + std::advance(it_end, nMinBufLength); + } + else + it_end = m_str.end(); + + std::copy(m_str.begin(), it_end, m_buf.begin()); + + return &m_buf[0]; + } + +#ifndef _WIN32_WCE + inline BOOL CString::GetEnvironmentVariable(LPCTSTR pszVar) + // Sets the string to the value of the specified environment variable. + { + assert(pszVar); + Empty(); + + int nLength = ::GetEnvironmentVariable(pszVar, NULL, 0); + if (nLength > 0) + { + std::vector vBuffer( nLength+1, _T('\0') ); + ::GetEnvironmentVariable(pszVar, &vBuffer[0], nLength); + m_str = &vBuffer[0]; + } + + return (BOOL)nLength; + } +#endif // _WIN32_WCE + + inline void CString::GetErrorString(DWORD dwError) + // Returns the error string for the specified System Error Code (e.g from GetLastErrror). + { + m_str.erase(); + + if (dwError != 0) + { + TCHAR* pTemp = 0; + DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; + ::FormatMessage(dwFlags, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&pTemp, 1, NULL); + m_str.assign(pTemp); + ::LocalFree(pTemp); + } + } + + inline int CString::Insert(int nIndex, TCHAR ch) + // Inserts a single character or a substring at the given index within the string. + { + assert(nIndex >= 0); + assert(ch); + + m_str.insert(nIndex, &ch, 1); + return (int)m_str.size(); + } + + inline int CString::Insert(int nIndex, const CString& str) + // Inserts a single character or a substring at the given index within the string. + { + assert(nIndex >= 0); + + m_str.insert(nIndex, str); + return (int)m_str.size(); + } + + inline BOOL CString::IsEmpty() const + // Returns TRUE if the string is empty + { + return m_str.empty(); + } + + inline CString CString::Left(int nCount) const + // Extracts the left part of a string. + { + assert(nCount >= 0); + + CString str; + str.m_str.assign(c_str(), 0, nCount); + return str; + } + + inline BOOL CString::LoadString(UINT nID) + // Loads the string from a Windows resource. + { + assert (GetApp()); + + int nSize = 64; + TCHAR* pTCharArray = 0; + std::vector vString; + int nTChars = nSize; + + Empty(); + + // Increase the size of our array in a loop until we load the entire string + // The ANSI and _UNICODE versions of LoadString behave differently. This technique works for both. + while ( nSize-1 <= nTChars ) + { + nSize = nSize * 4; + vString.assign(nSize+1, _T('\0')); + pTCharArray = &vString[0]; + nTChars = ::LoadString (GetApp()->GetResourceHandle(), nID, pTCharArray, nSize); + } + + if (nTChars > 0) + m_str.assign(pTCharArray); + + return (nTChars != 0); + } + + inline void CString::MakeLower() + // Converts all the characters in this string to lowercase characters. + { + std::transform(m_str.begin(), m_str.end(), m_str.begin(), &::tolower); + } + + inline void CString::MakeReverse() + // Reverses the string. + { + std::reverse(m_str.begin(), m_str.end()); + } + + inline void CString::MakeUpper() + // Converts all the characters in this string to uppercase characters. + { + std::transform(m_str.begin(), m_str.end(), m_str.begin(), &::toupper); + } + + inline CString CString::Mid(int nFirst) const + // Extracts the middle part of a string. + { + return Mid(nFirst, GetLength()); + } + + inline CString CString::Mid(int nFirst, int nCount) const + // Extracts the middle part of a string. + { + assert(nFirst >= 0); + assert(nCount >= 0); + + CString str; + str.m_str.assign(c_str(), nFirst, nFirst + nCount); + return str; + } + + inline int CString::ReverseFind(LPCTSTR pszText, int nIndex /* = -1 */) const + // Search for a substring within the string, starting from the end. + { + assert(pszText); + return (int)m_str.rfind(pszText, nIndex); + } + + inline void CString::SetAt(int nIndex, TCHAR ch) + // Sets the character at the specificed position to the specified value. + { + assert(nIndex >= 0); + assert(nIndex < GetLength()); + m_str[nIndex] = ch; + } + + inline void CString::ReleaseBuffer( int nNewLength /*= -1*/ ) + // This copies the contents of the buffer (acquired by GetBuffer) to this CString, + // and releases the contents of the buffer. The default length of -1 copies from the + // buffer until a null terminator is reached. If the buffer doesn't contain a null + // terminator, you must specify the buffer's length. + { + assert (nNewLength > 0 || -1 == nNewLength); + assert (nNewLength < (int)m_buf.size()); + + if (-1 == nNewLength) + nNewLength = lstrlen(&m_buf[0]); + m_str.assign(nNewLength+1, _T('\0')); + + std::vector::iterator it_end = m_buf.begin(); + std::advance(it_end, nNewLength); + + std::copy(m_buf.begin(), it_end, m_str.begin()); + m_buf.clear(); + } + + inline int CString::Remove(LPCTSTR pszText) + // Removes each occurrence of the specified substring from the string. + { + assert(pszText); + + int nCount = 0; + size_t pos = 0; + while ((pos = m_str.find(pszText, pos)) != std::string::npos) + { + m_str.erase(pos, lstrlen(pszText)); + ++nCount; + } + return nCount; + } + + inline int CString::Replace(TCHAR chOld, TCHAR chNew) + // Replaces each occurance of the old character with the new character. + { + int nCount = 0; + tString::iterator it = m_str.begin(); + while (it != m_str.end()) + { + if (*it == chOld) + { + *it = chNew; + ++nCount; + } + ++it; + } + return nCount; + } + + inline int CString::Replace(LPCTSTR pszOld, LPCTSTR pszNew) + // Replaces each occurance of the old substring with the new substring. + { + assert(pszOld); + assert(pszNew); + + int nCount = 0; + size_t pos = 0; + while ((pos = m_str.find(pszOld, pos)) != std::string::npos) + { + m_str.replace(pos, lstrlen(pszOld), pszNew); + pos += lstrlen(pszNew); + ++nCount; + } + return nCount; + } + + inline CString CString::Right(int nCount) const + // Extracts the right part of a string. + { + assert(nCount >= 0); + + CString str; + str.m_str.assign(c_str(), m_str.size() - nCount, nCount); + return str; + } + + inline BSTR CString::SetSysString(BSTR* pBstr) const + // Sets an existing BSTR object to the string. + { + assert(pBstr); + + if ( !::SysReAllocStringLen(pBstr, T2W(m_str.c_str()), (UINT)m_str.length()) ) + throw std::bad_alloc(); + + return *pBstr; + } + + inline CString CString::SpanExcluding(LPCTSTR pszText) const + // Extracts characters from the string, starting with the first character, + // that are not in the set of characters identified by pszCharSet. + { + assert (pszText); + + CString str; + size_t pos = 0; + + while ((pos = m_str.find_first_not_of(pszText, pos)) != std::string::npos) + { + str.m_str.append(1, m_str[pos++]); + } + + return str; + } + + inline CString CString::SpanIncluding(LPCTSTR pszText) const + // Extracts a substring that contains only the characters in a set. + { + assert (pszText); + + CString str; + size_t pos = 0; + + while ((pos = m_str.find_first_of(pszText, pos)) != std::string::npos) + { + str.m_str.append(1, m_str[pos++]); + } + + return str; + } + + inline CString CString::Tokenize(LPCTSTR pszTokens, int& iStart) const + // Extracts specified tokens in a target string. + { + assert(pszTokens); + assert(iStart >= 0); + + CString str; + size_t pos1 = m_str.find_first_not_of(pszTokens, iStart); + size_t pos2 = m_str.find_first_of(pszTokens, pos1); + + iStart = (int)pos2 + 1; + if (pos2 == m_str.npos) + iStart = -1; + + if (pos1 != m_str.npos) + str.m_str = m_str.substr(pos1, pos2-pos1); + + return str; + } + + inline void CString::Trim() + // Trims all leading and trailing whitespace characters from the string. + { + TrimLeft(); + TrimRight(); + } + + inline void CString::TrimLeft() + // Trims leading whitespace characters from the string. + { + // This method is supported by the Borland 5.5 compiler + tString::iterator iter; + for (iter = m_str.begin(); iter < m_str.end(); ++iter) + { + if (!isspace(*iter)) + break; + } + + m_str.erase(m_str.begin(), iter); + } + + inline void CString::TrimLeft(TCHAR chTarget) + // Trims the specified character from the beginning of the string. + { + m_str.erase(0, m_str.find_first_not_of(chTarget)); + } + + inline void CString::TrimLeft(LPCTSTR pszTargets) + // Trims the specified set of characters from the beginning of the string. + { + assert(pszTargets); + m_str.erase(0, m_str.find_first_not_of(pszTargets)); + } + + inline void CString::TrimRight() + // Trims trailing whitespace characters from the string. + { + // This method is supported by the Borland 5.5 compiler + tString::reverse_iterator riter; + for (riter = m_str.rbegin(); riter < m_str.rend(); ++riter) + { + if (!isspace(*riter)) + break; + } + + m_str.erase(riter.base(), m_str.end()); + } + + inline void CString::TrimRight(TCHAR chTarget) + // Trims the specified character from the end of the string. + { + size_t pos = m_str.find_last_not_of(chTarget); + if (pos != std::string::npos) + m_str.erase(++pos); + } + + inline void CString::TrimRight(LPCTSTR pszTargets) + // Trims the specified set of characters from the end of the string. + { + assert(pszTargets); + + size_t pos = m_str.find_last_not_of(pszTargets); + if (pos != std::string::npos) + m_str.erase(++pos); + } + + inline void CString::Truncate(int nNewLength) + // Reduces the length of the string to the specified amount. + { + if (nNewLength < GetLength()) + { + assert(nNewLength >= 0); + m_str.erase(nNewLength); + } + } + + + /////////////////////////////////// + // Global Functions + // + + // friend functions of CString + inline CString operator + (const CString& string1, const CString& string2) + { + CString str(string1); + str.m_str.append(string2.m_str); + return str; + } + + inline CString operator + (const CString& string, LPCTSTR pszText) + { + CString str(string); + str.m_str.append(pszText); + return str; + } + + inline CString operator +