Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-01-20 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:49 +0300
commitd9666cf046a8453b33b3e2fbf4d82295a9f87df3 (patch)
treec722ed19b844b53042aec0c1d7d2f8381140a5ed /CPP/Windows/Control
parent804edc5756fede54dbb1aefda6d39d306111938d (diff)
4.44 beta
Diffstat (limited to 'CPP/Windows/Control')
-rwxr-xr-xCPP/Windows/Control/ComboBox.cpp63
-rwxr-xr-xCPP/Windows/Control/ComboBox.h54
-rwxr-xr-xCPP/Windows/Control/Dialog.cpp145
-rwxr-xr-xCPP/Windows/Control/Dialog.h144
-rwxr-xr-xCPP/Windows/Control/Edit.h21
-rwxr-xr-xCPP/Windows/Control/ImageList.cpp11
-rwxr-xr-xCPP/Windows/Control/ImageList.h86
-rwxr-xr-xCPP/Windows/Control/ListView.cpp58
-rwxr-xr-xCPP/Windows/Control/ListView.h138
-rwxr-xr-xCPP/Windows/Control/ProgressBar.h41
-rwxr-xr-xCPP/Windows/Control/PropertyPage.cpp163
-rwxr-xr-xCPP/Windows/Control/PropertyPage.h47
-rwxr-xr-xCPP/Windows/Control/ReBar.h35
-rwxr-xr-xCPP/Windows/Control/Static.h27
-rwxr-xr-xCPP/Windows/Control/StatusBar.h43
-rwxr-xr-xCPP/Windows/Control/StdAfx.h9
-rwxr-xr-xCPP/Windows/Control/ToolBar.h34
-rwxr-xr-xCPP/Windows/Control/Trackbar.h28
-rwxr-xr-xCPP/Windows/Control/Window2.cpp203
-rwxr-xr-xCPP/Windows/Control/Window2.h59
20 files changed, 1409 insertions, 0 deletions
diff --git a/CPP/Windows/Control/ComboBox.cpp b/CPP/Windows/Control/ComboBox.cpp
new file mode 100755
index 00000000..5b1d2651
--- /dev/null
+++ b/CPP/Windows/Control/ComboBox.cpp
@@ -0,0 +1,63 @@
+// Windows/Control/ComboBox.cpp
+
+// #define _UNICODE
+// #define UNICODE
+
+#include "StdAfx.h"
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Defs.h"
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+namespace NControl {
+
+LRESULT CComboBox::GetLBText(int index, CSysString &s)
+{
+ s.Empty();
+ LRESULT len = GetLBTextLen(index);
+ if (len == CB_ERR)
+ return len;
+ len = GetLBText(index, s.GetBuffer((int)len + 1));
+ s.ReleaseBuffer();
+ return len;
+}
+
+#ifndef _UNICODE
+LRESULT CComboBox::AddString(LPCWSTR s)
+{
+ if (g_IsNT)
+ return SendMessageW(CB_ADDSTRING, 0, (LPARAM)s);
+ return AddString(GetSystemString(s));
+}
+
+LRESULT CComboBox::GetLBText(int index, UString &s)
+{
+ s.Empty();
+ if (g_IsNT)
+ {
+ LRESULT len = SendMessageW(CB_GETLBTEXTLEN, index, 0);
+ if (len == CB_ERR)
+ return len;
+ len = SendMessageW(CB_GETLBTEXT, index, (LPARAM)s.GetBuffer((int)len + 1));
+ s.ReleaseBuffer();
+ return len;
+ }
+ AString sa;
+ LRESULT len = GetLBText(index, sa);
+ if (len == CB_ERR)
+ return len;
+ s = GetUnicodeString(sa);
+ return s.Length();
+}
+#endif
+
+
+}}
diff --git a/CPP/Windows/Control/ComboBox.h b/CPP/Windows/Control/ComboBox.h
new file mode 100755
index 00000000..2fb2302e
--- /dev/null
+++ b/CPP/Windows/Control/ComboBox.h
@@ -0,0 +1,54 @@
+// Windows/Control/ComboBox.h
+
+#ifndef __WINDOWS_CONTROL_COMBOBOX_H
+#define __WINDOWS_CONTROL_COMBOBOX_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+#include <commctrl.h>
+
+namespace NWindows {
+namespace NControl {
+
+class CComboBox: public CWindow
+{
+public:
+ void ResetContent() { SendMessage(CB_RESETCONTENT, 0, 0); }
+ LRESULT AddString(LPCTSTR string) { return SendMessage(CB_ADDSTRING, 0, (LPARAM)string); }
+ #ifndef _UNICODE
+ LRESULT AddString(LPCWSTR string);
+ #endif
+ LRESULT SetCurSel(int index) { return SendMessage(CB_SETCURSEL, index, 0); }
+ int GetCurSel() { return (int)SendMessage(CB_GETCURSEL, 0, 0); }
+ int GetCount() { return (int)SendMessage(CB_GETCOUNT, 0, 0); }
+
+ LRESULT GetLBTextLen(int index) { return SendMessage(CB_GETLBTEXTLEN, index, 0); }
+ LRESULT GetLBText(int index, LPTSTR string) { return SendMessage(CB_GETLBTEXT, index, (LPARAM)string); }
+ LRESULT GetLBText(int index, CSysString &s);
+ #ifndef _UNICODE
+ LRESULT GetLBText(int index, UString &s);
+ #endif
+
+ LRESULT SetItemData(int index, LPARAM lParam)
+ { return SendMessage(CB_SETITEMDATA, index, lParam); }
+ LRESULT GetItemData(int index)
+ { return SendMessage(CB_GETITEMDATA, index, 0); }
+};
+
+class CComboBoxEx: public CWindow
+{
+public:
+ LRESULT DeleteItem(int index)
+ { return SendMessage(CBEM_DELETEITEM, index, 0); }
+ LRESULT InsertItem(COMBOBOXEXITEM *item)
+ { return SendMessage(CBEM_INSERTITEM, 0, (LPARAM)item); }
+ DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle)
+ { return (DWORD)SendMessage(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); }
+ HWND GetEditControl()
+ { return (HWND)SendMessage(CBEM_GETEDITCONTROL, 0, 0); }
+};
+
+}}
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/Dialog.cpp b/CPP/Windows/Control/Dialog.cpp
new file mode 100755
index 00000000..64009b79
--- /dev/null
+++ b/CPP/Windows/Control/Dialog.cpp
@@ -0,0 +1,145 @@
+// Windows/Control/Dialog.cpp
+
+#include "StdAfx.h"
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+#include "Windows/Control/Dialog.h"
+
+extern HINSTANCE g_hInstance;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+namespace NControl {
+
+static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ CWindow dialogTmp(dialogHWND);
+ if (message == WM_INITDIALOG)
+ dialogTmp.SetUserDataLongPtr(lParam);
+ CDialog *dialog = (CDialog *)(dialogTmp.GetUserDataLongPtr());
+ if (dialog == NULL)
+ return FALSE;
+ if (message == WM_INITDIALOG)
+ dialog->Attach(dialogHWND);
+
+ return BoolToBOOL(dialog->OnMessage(message, wParam, lParam));
+}
+
+bool CDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ return OnInit();
+ case WM_COMMAND:
+ return OnCommand(wParam, lParam);
+ case WM_NOTIFY:
+ return OnNotify((UINT)wParam, (LPNMHDR) lParam);
+ case WM_HELP:
+ {
+ OnHelp((LPHELPINFO)lParam);
+ return true;
+ }
+ case WM_TIMER:
+ {
+ return OnTimer(wParam, lParam);
+ }
+ default:
+ return false;
+ }
+}
+
+bool CDialog::OnCommand(WPARAM wParam, LPARAM lParam)
+{
+ return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam);
+}
+
+bool CDialog::OnCommand(int code, int itemID, LPARAM lParam)
+{
+ if (code == BN_CLICKED)
+ return OnButtonClicked(itemID, (HWND)lParam);
+ return false;
+}
+
+bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */)
+{
+ switch(buttonID)
+ {
+ case IDOK:
+ OnOK();
+ break;
+ case IDCANCEL:
+ OnCancel();
+ break;
+ case IDHELP:
+ OnHelp();
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow)
+{
+ HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
+ if (aHWND == 0)
+ return false;
+ Attach(aHWND);
+ return true;
+}
+
+INT_PTR CModalDialog::Create(LPCTSTR templateName, HWND parentWindow)
+{
+ return DialogBoxParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
+}
+
+#ifndef _UNICODE
+
+bool CModelessDialog::Create(LPCWSTR templateName, HWND parentWindow)
+{
+ HWND aHWND;
+ if (g_IsNT)
+ aHWND = CreateDialogParamW(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
+ else
+ {
+ AString name;
+ LPCSTR templateNameA;
+ if (IS_INTRESOURCE(templateName))
+ templateNameA = (LPCSTR)templateName;
+ else
+ {
+ name = GetSystemString(templateName);
+ templateNameA = name;
+ }
+ aHWND = CreateDialogParamA(g_hInstance, templateNameA, parentWindow, DialogProcedure, (LPARAM)this);
+ }
+ if (aHWND == 0)
+ return false;
+ Attach(aHWND);
+ return true;
+}
+
+INT_PTR CModalDialog::Create(LPCWSTR templateName, HWND parentWindow)
+{
+ if (g_IsNT)
+ return DialogBoxParamW(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
+ AString name;
+ LPCSTR templateNameA;
+ if (IS_INTRESOURCE(templateName))
+ templateNameA = (LPCSTR)templateName;
+ else
+ {
+ name = GetSystemString(templateName);
+ templateNameA = name;
+ }
+ return DialogBoxParamA(g_hInstance, templateNameA, parentWindow, DialogProcedure, (LPARAM)this);
+}
+#endif
+
+}}
diff --git a/CPP/Windows/Control/Dialog.h b/CPP/Windows/Control/Dialog.h
new file mode 100755
index 00000000..f6182c4b
--- /dev/null
+++ b/CPP/Windows/Control/Dialog.h
@@ -0,0 +1,144 @@
+// Windows/Control/Dialog.h
+
+#ifndef __WINDOWS_CONTROL_DIALOG_H
+#define __WINDOWS_CONTROL_DIALOG_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CDialog: public CWindow
+{
+public:
+ CDialog(HWND wndow = NULL): CWindow(wndow){};
+ virtual ~CDialog() {};
+
+ HWND GetItem(int itemID) const
+ { return GetDlgItem(_window, itemID); }
+
+ bool EnableItem(int itemID, bool enable) const
+ { return BOOLToBool(::EnableWindow(GetItem(itemID), BoolToBOOL(enable))); }
+
+ bool ShowItem(int itemID, int cmdShow) const
+ { return BOOLToBool(::ShowWindow(GetItem(itemID), cmdShow)); }
+
+ bool SetItemText(int itemID, LPCTSTR s)
+ { return BOOLToBool(SetDlgItemText(_window, itemID, s)); }
+
+ #ifndef _UNICODE
+ bool SetItemText(int itemID, LPCWSTR s)
+ {
+ CWindow window(GetItem(itemID));
+ return window.SetText(s);
+ }
+ #endif
+
+ UINT GetItemText(int itemID, LPTSTR string, int maxCount)
+ { return GetDlgItemText(_window, itemID, string, maxCount); }
+ #ifndef _UNICODE
+ /*
+ bool GetItemText(int itemID, LPWSTR string, int maxCount)
+ {
+ CWindow window(GetItem(itemID));
+ return window.GetText(string, maxCount);
+ }
+ */
+ #endif
+
+ bool SetItemInt(int itemID, UINT value, bool isSigned)
+ { return BOOLToBool(SetDlgItemInt(_window, itemID, value, BoolToBOOL(isSigned))); }
+ bool GetItemInt(int itemID, bool isSigned, UINT &value)
+ {
+ BOOL result;
+ value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned));
+ return BOOLToBool(result);
+ }
+
+ HWND GetNextGroupItem(HWND control, bool previous)
+ { return GetNextDlgGroupItem(_window, control, BoolToBOOL(previous)); }
+ HWND GetNextTabItem(HWND control, bool previous)
+ { return GetNextDlgTabItem(_window, control, BoolToBOOL(previous)); }
+
+ bool MapRect(LPRECT rect)
+ { return BOOLToBool(MapDialogRect(_window, rect)); }
+
+ bool IsMessage(LPMSG message)
+ { return BOOLToBool(IsDialogMessage(_window, message)); }
+
+ LRESULT SendItemMessage(int itemID, UINT message, WPARAM wParam, LPARAM lParam)
+ { return SendDlgItemMessage(_window, itemID, message, wParam, lParam); }
+
+ bool CheckButton(int buttonID, UINT checkState)
+ { return BOOLToBool(CheckDlgButton(_window, buttonID, checkState)); }
+ bool CheckButton(int buttonID, bool checkState)
+ { return CheckButton(buttonID, UINT(checkState ? BST_CHECKED : BST_UNCHECKED)); }
+
+ UINT IsButtonChecked(int buttonID) const
+ { return IsDlgButtonChecked(_window, buttonID); }
+ bool IsButtonCheckedBool(int buttonID) const
+ { return (IsButtonChecked(buttonID) == BST_CHECKED); }
+
+ bool CheckRadioButton(int firstButtonID, int lastButtonID, int checkButtonID)
+ { return BOOLToBool(::CheckRadioButton(_window, firstButtonID, lastButtonID, checkButtonID)); }
+
+ virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual bool OnInit() { return true; }
+ virtual bool OnCommand(WPARAM wParam, LPARAM lParam);
+ virtual bool OnCommand(int code, int itemID, LPARAM lParam);
+ virtual void OnHelp(LPHELPINFO /* helpInfo */) { OnHelp(); };
+ virtual void OnHelp() {};
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ virtual void OnOK() {};
+ virtual void OnCancel() {};
+ virtual bool OnNotify(UINT /* controlID */, LPNMHDR /* lParam */) { return false; }
+ virtual bool OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { return false; }
+
+ LONG_PTR SetMsgResult(LONG_PTR newLongPtr )
+ { return SetLongPtr(DWLP_MSGRESULT, newLongPtr); }
+ LONG_PTR GetMsgResult() const
+ { return GetLongPtr(DWLP_MSGRESULT); }
+};
+
+class CModelessDialog: public CDialog
+{
+public:
+ bool Create(LPCTSTR templateName, HWND parentWindow);
+ #ifndef _UNICODE
+ bool Create(LPCWSTR templateName, HWND parentWindow);
+ #endif
+ virtual void OnOK() { Destroy(); }
+ virtual void OnCancel() { Destroy(); }
+};
+
+class CModalDialog: public CDialog
+{
+public:
+ INT_PTR Create(LPCTSTR templateName, HWND parentWindow);
+ INT_PTR Create(UINT resID, HWND parentWindow)
+ { return Create(MAKEINTRESOURCEW(resID), parentWindow); }
+ #ifndef _UNICODE
+ INT_PTR Create(LPCWSTR templateName, HWND parentWindow);
+ #endif
+
+ bool End(INT_PTR result)
+ { return BOOLToBool(::EndDialog(_window, result)); }
+ virtual void OnOK() { End(IDOK); }
+ virtual void OnCancel() { End(IDCANCEL); }
+};
+
+class CDialogChildControl: public NWindows::CWindow
+{
+public:
+ int m_ID;
+ void Init(const NWindows::NControl::CDialog &parentDialog, int id)
+ {
+ m_ID = id;
+ Attach(parentDialog.GetItem(id));
+ }
+};
+
+}}
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/Edit.h b/CPP/Windows/Control/Edit.h
new file mode 100755
index 00000000..d1af3644
--- /dev/null
+++ b/CPP/Windows/Control/Edit.h
@@ -0,0 +1,21 @@
+// Windows/Control/Edit.h
+
+#ifndef __WINDOWS_CONTROL_EDIT_H
+#define __WINDOWS_CONTROL_EDIT_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CEdit: public CWindow
+{
+public:
+ void SetPasswordChar(WPARAM c)
+ { SendMessage(EM_SETPASSWORDCHAR, c); }
+};
+
+}}
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/ImageList.cpp b/CPP/Windows/Control/ImageList.cpp
new file mode 100755
index 00000000..16a46fa4
--- /dev/null
+++ b/CPP/Windows/Control/ImageList.cpp
@@ -0,0 +1,11 @@
+// Windows/Control/ImageList.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/Control/ImageList.h"
+
+namespace NWindows {
+namespace NControl {
+
+}}
+
diff --git a/CPP/Windows/Control/ImageList.h b/CPP/Windows/Control/ImageList.h
new file mode 100755
index 00000000..fc8ddfbd
--- /dev/null
+++ b/CPP/Windows/Control/ImageList.h
@@ -0,0 +1,86 @@
+// Windows/Control/ImageList.h
+
+#ifndef __WINDOWS_CONTROL_IMAGELIST_H
+#define __WINDOWS_CONTROL_IMAGELIST_H
+
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CImageList
+{
+ HIMAGELIST m_Object;
+public:
+ operator HIMAGELIST() const {return m_Object; }
+ CImageList(): m_Object(NULL) {}
+ bool Attach(HIMAGELIST imageList)
+ {
+ if(imageList == NULL)
+ return false;
+ m_Object = imageList;
+ return true;
+ }
+
+ HIMAGELIST Detach()
+ {
+ HIMAGELIST imageList = m_Object;
+ m_Object = NULL;
+ return imageList;
+ }
+
+ bool Create(int width, int height, UINT flags, int initialNumber, int grow)
+ {
+ HIMAGELIST a = ImageList_Create(width, height, flags,
+ initialNumber, grow);
+ if(a == NULL)
+ return false;
+ return Attach(a);
+ }
+
+ bool Destroy() // DeleteImageList() in MFC
+ {
+ if (m_Object == NULL)
+ return false;
+ return BOOLToBool(ImageList_Destroy(Detach()));
+ }
+
+ ~CImageList()
+ { Destroy(); }
+
+ int GetImageCount() const
+ { return ImageList_GetImageCount(m_Object); }
+
+ bool GetImageInfo(int index, IMAGEINFO* imageInfo) const
+ { return BOOLToBool(ImageList_GetImageInfo(m_Object, index, imageInfo)); }
+
+ int Add(HBITMAP hbmImage, HBITMAP hbmMask = 0)
+ { return ImageList_Add(m_Object, hbmImage, hbmMask); }
+ int AddMasked(HBITMAP hbmImage, COLORREF mask)
+ { return ImageList_AddMasked(m_Object, hbmImage, mask); }
+ int AddIcon(HICON icon)
+ { return ImageList_AddIcon(m_Object, icon); }
+ int Replace(int index, HICON icon)
+ { return ImageList_ReplaceIcon(m_Object, index, icon); }
+
+ // If index is -1, the function removes all images.
+ bool Remove(int index)
+ { return BOOLToBool(ImageList_Remove(m_Object, index)); }
+ bool RemoveAll()
+ { return BOOLToBool(ImageList_RemoveAll(m_Object)); }
+
+ HICON ExtractIcon(int index)
+ { return ImageList_ExtractIcon(NULL, m_Object, index); }
+ HICON GetIcon(int index, UINT flags)
+ { return ImageList_GetIcon(m_Object, index, flags); }
+
+ bool GetIconSize(int &width, int &height) const
+ { return BOOLToBool(ImageList_GetIconSize(m_Object, &width, &height)); }
+ bool SetIconSize(int width, int height)
+ { return BOOLToBool(ImageList_SetIconSize(m_Object, width, height)); }
+};
+
+}}
+
+#endif
+ \ No newline at end of file
diff --git a/CPP/Windows/Control/ListView.cpp b/CPP/Windows/Control/ListView.cpp
new file mode 100755
index 00000000..b532a7a4
--- /dev/null
+++ b/CPP/Windows/Control/ListView.cpp
@@ -0,0 +1,58 @@
+// Windows/Control/ListView.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/Control/ListView.h"
+
+namespace NWindows {
+namespace NControl {
+
+bool CListView::CreateEx(DWORD exStyle, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance, LPVOID createParam)
+{
+ return CWindow::CreateEx(exStyle, WC_LISTVIEW, TEXT(""), style, x, y, width,
+ height, parentWindow, idOrHMenu, instance, createParam);
+}
+
+bool CListView::GetItemParam(int itemIndex, LPARAM &param) const
+{
+ LVITEM item;
+ item.iItem = itemIndex;
+ item.iSubItem = 0;
+ item.mask = LVIF_PARAM;
+ bool aResult = GetItem(&item);
+ param = item.lParam;
+ return aResult;
+}
+
+/*
+int CListView::InsertItem(UINT mask, int item, LPCTSTR itemText,
+ UINT nState, UINT nStateMask, int nImage, LPARAM lParam)
+{
+ LVITEM item;
+ item.mask = nMask;
+ item.iItem = nItem;
+ item.iSubItem = 0;
+ item.pszText = (LPTSTR)itemText;
+ item.state = nState;
+ item.stateMask = nStateMask;
+ item.iImage = nImage;
+ item.lParam = lParam;
+ return InsertItem(&item);
+}
+
+int CListView::InsertItem(int nItem, LPCTSTR itemText)
+{
+ return InsertItem(LVIF_TEXT, nItem, itemText, 0, 0, 0, 0);
+}
+
+int CListView::InsertItem(int nItem, LPCTSTR itemText, int nImage)
+{
+ return InsertItem(LVIF_TEXT | LVIF_IMAGE, nItem, itemText, 0, 0, nImage, 0);
+}
+*/
+
+}}
+
diff --git a/CPP/Windows/Control/ListView.h b/CPP/Windows/Control/ListView.h
new file mode 100755
index 00000000..60b8146e
--- /dev/null
+++ b/CPP/Windows/Control/ListView.h
@@ -0,0 +1,138 @@
+// Windows/Control/ListView.h
+
+#ifndef __WINDOWS_CONTROL_LISTVIEW_H
+#define __WINDOWS_CONTROL_LISTVIEW_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+#include <commctrl.h>
+
+namespace NWindows {
+namespace NControl {
+
+class CListView: public NWindows::CWindow
+{
+public:
+ bool CreateEx(DWORD exStyle, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance, LPVOID createParam);
+
+ bool SetUnicodeFormat(bool fUnicode)
+ { return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); }
+
+ bool DeleteAllItems()
+ { return BOOLToBool(ListView_DeleteAllItems(_window)); }
+ int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo)
+ { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
+ #ifndef _UNICODE
+ int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo)
+ { return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
+ #endif
+ bool DeleteColumn(int columnIndex)
+ { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
+
+ int InsertItem(const LVITEM* item)
+ { return ListView_InsertItem(_window, item); }
+ #ifndef _UNICODE
+ int InsertItem(const LV_ITEMW* item)
+ { return (int)SendMessage(LVM_INSERTITEMW, 0, (LPARAM)item); }
+ #endif
+
+ bool SetItem(const LVITEM* item)
+ { return BOOLToBool(ListView_SetItem(_window, item)); }
+ #ifndef _UNICODE
+ bool SetItem(const LV_ITEMW* item)
+ { return BOOLToBool((BOOL)SendMessage(LVM_SETITEMW, 0, (LPARAM)item)); }
+ #endif
+
+ bool DeleteItem(int itemIndex)
+ { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
+
+ UINT GetSelectedCount() const
+ { return ListView_GetSelectedCount(_window); }
+ int GetItemCount() const
+ { return ListView_GetItemCount(_window); }
+
+ INT GetSelectionMark() const
+ { return ListView_GetSelectionMark(_window); }
+
+ void SetItemCount(int numItems)
+ { ListView_SetItemCount(_window, numItems); }
+ void SetItemCountEx(int numItems, DWORD flags)
+ { ListView_SetItemCountEx(_window, numItems, flags); }
+
+ int GetNextItem(int startIndex, UINT flags) const
+ { return ListView_GetNextItem(_window, startIndex, flags); }
+ int GetNextSelectedItem(int startIndex) const
+ { return GetNextItem(startIndex, LVNI_SELECTED); }
+ int GetFocusedItem() const
+ { return GetNextItem(-1, LVNI_FOCUSED); }
+
+ bool GetItem(LVITEM* item) const
+ { return BOOLToBool(ListView_GetItem(_window, item)); }
+ bool GetItemParam(int itemIndex, LPARAM &param) const;
+ void GetItemText(int itemIndex, int aSubItemIndex, LPTSTR aText, int aTextSizeMax) const
+ { ListView_GetItemText(_window, itemIndex, aSubItemIndex, aText, aTextSizeMax); }
+ bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
+ { return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
+
+ void SetItemState(int index, UINT state, UINT mask)
+ { ListView_SetItemState(_window, index, state, mask); }
+ UINT GetItemState(int index, UINT mask) const
+ { return ListView_GetItemState(_window, index, mask); }
+
+ bool GetColumn(int columnIndex, LVCOLUMN* columnInfo) const
+ { return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
+
+ HIMAGELIST SetImageList(HIMAGELIST imageList, int imageListType)
+ { return ListView_SetImageList(_window, imageList, imageListType); }
+
+ // version 4.70: NT5 | (NT4 + ie3) | w98 | (w95 + ie3)
+ DWORD GetExtendedListViewStyle()
+ { return ListView_GetExtendedListViewStyle(_window); }
+ void SetExtendedListViewStyle(DWORD exStyle)
+ { ListView_SetExtendedListViewStyle(_window, exStyle); }
+ void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle)
+ { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
+
+ #ifndef _WIN32_WCE
+ void SetCheckState(UINT index, bool checkState)
+ { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); }
+ #endif
+ bool GetCheckState(UINT index)
+ { return BOOLToBool(ListView_GetCheckState(_window, index)); }
+
+
+ bool EnsureVisible(int index, bool partialOK)
+ { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
+
+ bool GetItemRect(int index, RECT *rect, int code)
+ { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); }
+
+ HWND GetEditControl()
+ { return ListView_GetEditControl(_window) ; }
+ HWND EditLabel(int itemIndex)
+ { return ListView_EditLabel(_window, itemIndex) ; }
+
+ bool RedrawItems(int firstIndex, int lastIndex)
+ { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
+ bool RedrawAllItems()
+ {
+ if (GetItemCount() > 0)
+ return RedrawItems(0, GetItemCount() - 1);
+ return true;
+ }
+ bool RedrawItem(int index)
+ { return RedrawItems(index, index); }
+
+ int HitTest(LPLVHITTESTINFO info)
+ { return ListView_HitTest(_window, info); }
+
+ COLORREF GetBkColor()
+ { return ListView_GetBkColor(_window); }
+};
+
+}}
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/ProgressBar.h b/CPP/Windows/Control/ProgressBar.h
new file mode 100755
index 00000000..6ce837cc
--- /dev/null
+++ b/CPP/Windows/Control/ProgressBar.h
@@ -0,0 +1,41 @@
+// Windows/Control/ProgressBar.h
+
+#ifndef __WINDOWS_CONTROL_PROGRESSBAR_H
+#define __WINDOWS_CONTROL_PROGRESSBAR_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CProgressBar: public CWindow
+{
+public:
+ LRESULT SetPos(int pos)
+ { return SendMessage(PBM_SETPOS, pos, 0); }
+ LRESULT DeltaPos(int increment)
+ { return SendMessage(PBM_DELTAPOS, increment, 0); }
+ UINT GetPos()
+ { return (UINT)SendMessage(PBM_GETPOS, 0, 0); }
+ LRESULT SetRange(unsigned short minValue, unsigned short maxValue)
+ { return SendMessage(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); }
+ DWORD SetRange32(int minValue, int maxValue)
+ { return (DWORD)SendMessage(PBM_SETRANGE32, minValue, maxValue); }
+ int SetStep(int step)
+ { return (int)SendMessage(PBM_SETSTEP, step, 0); }
+ LRESULT StepIt()
+ { return SendMessage(PBM_STEPIT, 0, 0); }
+
+ INT GetRange(bool minValue, PPBRANGE range)
+ { return (INT)SendMessage(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); }
+
+ COLORREF SetBarColor(COLORREF color)
+ { return (COLORREF)SendMessage(PBM_SETBARCOLOR, 0, color); }
+ COLORREF SetBackgroundColor(COLORREF color)
+ { return (COLORREF)SendMessage(PBM_SETBKCOLOR, 0, color); }
+};
+
+}}
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/PropertyPage.cpp b/CPP/Windows/Control/PropertyPage.cpp
new file mode 100755
index 00000000..f8996be1
--- /dev/null
+++ b/CPP/Windows/Control/PropertyPage.cpp
@@ -0,0 +1,163 @@
+// Windows/Control/PropertyPage.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/Control/PropertyPage.h"
+#include "../../Common/Vector.h"
+#ifndef _UNICODE
+#include "../../Common/StringConvert.h"
+#endif
+
+extern HINSTANCE g_hInstance;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+namespace NControl {
+
+INT_PTR APIENTRY ProperyPageProcedure(HWND dialogHWND, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ CDialog tempDialog(dialogHWND);
+ if (message == WM_INITDIALOG)
+ tempDialog.SetUserDataLongPtr(((PROPSHEETPAGE *)lParam)->lParam);
+ CDialog *dialog = (CDialog *)(tempDialog.GetUserDataLongPtr());
+ if (message == WM_INITDIALOG)
+ dialog->Attach(dialogHWND);
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ return dialog->OnInit();
+ case WM_COMMAND:
+ return dialog->OnCommand(wParam, lParam);
+ case WM_NOTIFY:
+ return dialog->OnNotify((UINT)wParam, (LPNMHDR) lParam);
+ }
+ if (dialog == NULL)
+ return false;
+ return dialog->OnMessage(message, wParam, lParam);
+}
+
+bool CPropertyPage::OnNotify(UINT /* controlID */, LPNMHDR lParam)
+{
+ switch(lParam->code)
+ {
+ case PSN_APPLY:
+ SetMsgResult(OnApply(LPPSHNOTIFY(lParam)));
+ break;
+ case PSN_KILLACTIVE:
+ SetMsgResult(BoolToBOOL(OnKillActive(LPPSHNOTIFY(lParam))));
+ break;
+ case PSN_SETACTIVE:
+ SetMsgResult(OnSetActive(LPPSHNOTIFY(lParam)));
+ break;
+ case PSN_RESET:
+ OnReset(LPPSHNOTIFY(lParam));
+ break;
+ case PSN_HELP:
+ OnNotifyHelp(LPPSHNOTIFY(lParam));
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndParent, const UString &title)
+{
+ #ifndef _UNICODE
+ AStringVector titles;
+ #endif
+ #ifndef _UNICODE
+ CRecordVector<PROPSHEETPAGEA> pagesA;
+ #endif
+ CRecordVector<PROPSHEETPAGEW> pagesW;
+
+ int i;
+ #ifndef _UNICODE
+ for (i = 0; i < pagesInfo.Size(); i++)
+ titles.Add(GetSystemString(pagesInfo[i].Title));
+ #endif
+
+ for (i = 0; i < pagesInfo.Size(); i++)
+ {
+ const CPageInfo &pageInfo = pagesInfo[i];
+ #ifndef _UNICODE
+ {
+ PROPSHEETPAGE page;
+ page.dwSize = sizeof(page);
+ page.dwFlags = PSP_HASHELP;
+ page.hInstance = g_hInstance;
+ page.pszTemplate = MAKEINTRESOURCE(pageInfo.ID);
+ page.pszIcon = NULL;
+ page.pfnDlgProc = NWindows::NControl::ProperyPageProcedure;
+
+ if (titles[i].IsEmpty())
+ page.pszTitle = NULL;
+ else
+ {
+ page.dwFlags |= PSP_USETITLE;
+ page.pszTitle = titles[i];
+ }
+ page.lParam = (LPARAM)pageInfo.Page;
+ page.pfnCallback = NULL;
+ pagesA.Add(page);
+ }
+ #endif
+ {
+ PROPSHEETPAGEW page;
+ page.dwSize = sizeof(page);
+ page.dwFlags = PSP_HASHELP;
+ page.hInstance = g_hInstance;
+ page.pszTemplate = MAKEINTRESOURCEW(pageInfo.ID);
+ page.pszIcon = NULL;
+ page.pfnDlgProc = NWindows::NControl::ProperyPageProcedure;
+
+ if (pageInfo.Title.IsEmpty())
+ page.pszTitle = NULL;
+ else
+ {
+ page.dwFlags |= PSP_USETITLE;
+ page.pszTitle = pageInfo.Title;
+ }
+ page.lParam = (LPARAM)pageInfo.Page;
+ page.pfnCallback = NULL;
+ pagesW.Add(page);
+ }
+ }
+
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ PROPSHEETHEADER sheet;
+ sheet.dwSize = sizeof(sheet);
+ sheet.dwFlags = PSH_PROPSHEETPAGE;
+ sheet.hwndParent = hwndParent;
+ sheet.hInstance = g_hInstance;
+ AString titleA = GetSystemString(title);
+ sheet.pszCaption = titleA;
+ sheet.nPages = pagesInfo.Size();
+ sheet.nStartPage = 0;
+ sheet.ppsp = &pagesA.Front();
+ sheet.pfnCallback = NULL;
+ return ::PropertySheetA(&sheet);
+ }
+ else
+ #endif
+ {
+ PROPSHEETHEADERW sheet;
+ sheet.dwSize = sizeof(sheet);
+ sheet.dwFlags = PSH_PROPSHEETPAGE;
+ sheet.hwndParent = hwndParent;
+ sheet.hInstance = g_hInstance;
+ sheet.pszCaption = title;
+ sheet.nPages = pagesInfo.Size();
+ sheet.nStartPage = 0;
+ sheet.ppsp = &pagesW.Front();
+ sheet.pfnCallback = NULL;
+ return ::PropertySheetW(&sheet);
+ }
+}
+
+}}
diff --git a/CPP/Windows/Control/PropertyPage.h b/CPP/Windows/Control/PropertyPage.h
new file mode 100755
index 00000000..e041d289
--- /dev/null
+++ b/CPP/Windows/Control/PropertyPage.h
@@ -0,0 +1,47 @@
+// Windows/Control/PropertyPage.h
+
+#ifndef __WINDOWS_CONTROL_PROPERTYPAGE_H
+#define __WINDOWS_CONTROL_PROPERTYPAGE_H
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+INT_PTR APIENTRY ProperyPageProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam);
+
+class CPropertyPage: public CDialog
+{
+public:
+ CPropertyPage(HWND window = NULL): CDialog(window){};
+
+ void Changed() { PropSheet_Changed(GetParent(), HWND(*this)); }
+ void UnChanged() { PropSheet_UnChanged(GetParent(), HWND(*this)); }
+
+ virtual bool OnNotify(UINT controlID, LPNMHDR lParam);
+
+ virtual bool OnKillActive() { return false; } // false = OK
+ virtual bool OnKillActive(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnKillActive(); }
+ virtual LONG OnSetActive() { return false; } // false = OK
+ virtual LONG OnSetActive(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnKillActive(); }
+ virtual LONG OnApply() { return PSNRET_NOERROR; }
+ virtual LONG OnApply(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnApply(); }
+ virtual void OnNotifyHelp() { }
+ virtual void OnNotifyHelp(const PSHNOTIFY * /* aPSHNOTIFY */) { OnNotifyHelp(); }
+ virtual void OnReset() { }
+ virtual void OnReset(const PSHNOTIFY * /* aPSHNOTIFY */) { OnReset(); }
+};
+
+struct CPageInfo
+{
+ CPropertyPage *Page;
+ UString Title;
+ UINT ID;
+};
+
+INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndParent, const UString &title);
+
+}}
+
+#endif
diff --git a/CPP/Windows/Control/ReBar.h b/CPP/Windows/Control/ReBar.h
new file mode 100755
index 00000000..ec27f0ed
--- /dev/null
+++ b/CPP/Windows/Control/ReBar.h
@@ -0,0 +1,35 @@
+// Windows/Control/ReBar.h
+
+#ifndef __WINDOWS_CONTROL_REBAR_H
+#define __WINDOWS_CONTROL_REBAR_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CReBar: public NWindows::CWindow
+{
+public:
+ bool SetBarInfo(LPREBARINFO barInfo)
+ { return LRESULTToBool(SendMessage(RB_SETBARINFO, 0, (LPARAM)barInfo)); }
+ bool InsertBand(int index, LPREBARBANDINFO bandInfo)
+ { return LRESULTToBool(SendMessage(RB_INSERTBAND, index, (LPARAM)bandInfo)); }
+ bool SetBandInfo(int index, LPREBARBANDINFO bandInfo)
+ { return LRESULTToBool(SendMessage(RB_SETBANDINFO, index, (LPARAM)bandInfo)); }
+ void MaximizeBand(int index, bool ideal)
+ { SendMessage(RB_MAXIMIZEBAND, index, BoolToBOOL(ideal)); }
+ bool SizeToRect(LPRECT rect)
+ { return LRESULTToBool(SendMessage(RB_SIZETORECT, 0, (LPARAM)rect)); }
+ UINT GetHeight()
+ { return (UINT)SendMessage(RB_GETBARHEIGHT); }
+ UINT GetBandCount()
+ { return (UINT)SendMessage(RB_GETBANDCOUNT); }
+ bool DeleteBand(UINT index)
+ { return LRESULTToBool(SendMessage(RB_DELETEBAND, index)); }
+};
+
+}}
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/Static.h b/CPP/Windows/Control/Static.h
new file mode 100755
index 00000000..5dded0ec
--- /dev/null
+++ b/CPP/Windows/Control/Static.h
@@ -0,0 +1,27 @@
+// Windows/Control/Static.h
+
+#ifndef __WINDOWS_CONTROL_STATIC_H
+#define __WINDOWS_CONTROL_STATIC_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CStatic: public CWindow
+{
+public:
+ HICON SetIcon(HICON icon)
+ { return (HICON)SendMessage(STM_SETICON, (WPARAM)icon, 0); }
+ HICON GetIcon()
+ { return (HICON)SendMessage(STM_GETICON, 0, 0); }
+ HANDLE SetImage(WPARAM imageType, HANDLE handle)
+ { return (HANDLE)SendMessage(STM_SETIMAGE, imageType, (LPARAM)handle); }
+ HANDLE GetImage(WPARAM imageType)
+ { return (HANDLE)SendMessage(STM_GETIMAGE, imageType, 0); }
+};
+
+}}
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/StatusBar.h b/CPP/Windows/Control/StatusBar.h
new file mode 100755
index 00000000..e8018a56
--- /dev/null
+++ b/CPP/Windows/Control/StatusBar.h
@@ -0,0 +1,43 @@
+// Windows/Control/StatusBar.h
+
+#ifndef __WINDOWS_CONTROL_STATUSBAR_H
+#define __WINDOWS_CONTROL_STATUSBAR_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CStatusBar: public NWindows::CWindow
+{
+public:
+ bool Create(LONG style, LPCTSTR text, HWND hwndParent, UINT id)
+ { return (_window = ::CreateStatusWindow(style, text, hwndParent, id)) != 0; }
+ bool SetParts(int numParts, const int *edgePostions)
+ { return LRESULTToBool(SendMessage(SB_SETPARTS, numParts, (LPARAM)edgePostions)); }
+ bool SetText(LPCTSTR text)
+ { return CWindow::SetText(text); }
+
+ bool SetText(int index, LPCTSTR text, UINT type)
+ { return LRESULTToBool(SendMessage(SB_SETTEXT, index | type, (LPARAM)text)); }
+ bool SetText(int index, LPCTSTR text)
+ { return SetText(index, text, 0); }
+ void Simple(bool simple)
+ { SendMessage(SB_SIMPLE, BoolToBOOL(simple), 0); }
+
+ #ifndef _UNICODE
+ bool Create(LONG style, LPCWSTR text, HWND hwndParent, UINT id)
+ { return (_window = ::CreateStatusWindowW(style, text, hwndParent, id)) != 0; }
+ bool SetText(LPCWSTR text)
+ { return CWindow::SetText(text); }
+ bool SetText(int index, LPCWSTR text, UINT type)
+ { return LRESULTToBool(SendMessage(SB_SETTEXTW, index | type, (LPARAM)text)); }
+ bool SetText(int index, LPCWSTR text)
+ { return SetText(index, text, 0); }
+ #endif
+};
+
+}}
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/StdAfx.h b/CPP/Windows/Control/StdAfx.h
new file mode 100755
index 00000000..27a77b10
--- /dev/null
+++ b/CPP/Windows/Control/StdAfx.h
@@ -0,0 +1,9 @@
+// StdAfx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#include "../../Common/MyWindows.h"
+#include "../../Common/NewHandler.h"
+
+#endif
diff --git a/CPP/Windows/Control/ToolBar.h b/CPP/Windows/Control/ToolBar.h
new file mode 100755
index 00000000..ff5cafd2
--- /dev/null
+++ b/CPP/Windows/Control/ToolBar.h
@@ -0,0 +1,34 @@
+// Windows/Control/ToolBar.h
+
+#ifndef __WINDOWS_CONTROL_TOOLBAR_H
+#define __WINDOWS_CONTROL_TOOLBAR_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CToolBar: public NWindows::CWindow
+{
+public:
+ bool GetMaxSize(LPSIZE size)
+ { return LRESULTToBool(SendMessage(TB_GETMAXSIZE, 0, (LPARAM)size)); }
+ bool EnableButton(UINT buttonID, bool enable)
+ { return LRESULTToBool(SendMessage(TB_ENABLEBUTTON, buttonID,
+ MAKELONG(BoolToBOOL(enable), 0))); }
+ void ButtonStructSize()
+ { SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON)); }
+ HIMAGELIST SetImageList(UINT listIndex, HIMAGELIST imageList)
+ { return HIMAGELIST(SendMessage(TB_SETIMAGELIST, listIndex, (LPARAM)imageList)); }
+ bool AddButton(UINT numButtons, LPTBBUTTON buttons)
+ { return LRESULTToBool(SendMessage(TB_ADDBUTTONS, numButtons, (LPARAM)buttons)); }
+ #ifndef _UNICODE
+ bool AddButtonW(UINT numButtons, LPTBBUTTON buttons)
+ { return LRESULTToBool(SendMessage(TB_ADDBUTTONSW, numButtons, (LPARAM)buttons)); }
+ #endif
+};
+
+}}
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/Trackbar.h b/CPP/Windows/Control/Trackbar.h
new file mode 100755
index 00000000..bbd7009a
--- /dev/null
+++ b/CPP/Windows/Control/Trackbar.h
@@ -0,0 +1,28 @@
+// Windows/Control/Trackbar.h
+
+#ifndef __WINDOWS_CONTROL_TRACKBAR_H
+#define __WINDOWS_CONTROL_TRACKBAR_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CTrackbar: public CWindow
+{
+public:
+ void SetRange(int minimum, int maximum, bool redraw = true)
+ { SendMessage(TBM_SETRANGE, BoolToBOOL(redraw), MAKELONG(minimum, maximum)); }
+ void SetPos(int pos, bool redraw = true)
+ { SendMessage(TBM_SETPOS, BoolToBOOL(redraw), pos); }
+ void SetTicFreq(int freq)
+ { SendMessage(TBM_SETTICFREQ, freq); }
+
+ int GetPos()
+ { return SendMessage(TBM_GETPOS); }
+};
+
+}}
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/Window2.cpp b/CPP/Windows/Control/Window2.cpp
new file mode 100755
index 00000000..66857523
--- /dev/null
+++ b/CPP/Windows/Control/Window2.cpp
@@ -0,0 +1,203 @@
+// Windows/Control/Window2.cpp
+
+#include "StdAfx.h"
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+#include "Windows/Control/Window2.h"
+
+// extern HINSTANCE g_hInstance;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+
+#ifndef _UNICODE
+ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
+#endif
+
+namespace NControl {
+
+static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ CWindow tempWindow(aHWND);
+ if (message == WM_NCCREATE)
+ tempWindow.SetUserDataLongPtr(
+ LONG_PTR(((LPCREATESTRUCT)lParam)->lpCreateParams));
+ CWindow2 *window = (CWindow2*)(tempWindow.GetUserDataLongPtr());
+ if (window != NULL && message == WM_NCCREATE)
+ window->Attach(aHWND);
+ if (window == 0)
+ {
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(aHWND, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(aHWND, message, wParam, lParam);
+ }
+ return window->OnMessage(message, wParam, lParam);
+}
+
+bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className,
+ LPCTSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance)
+{
+ WNDCLASS windowClass;
+ if(!::GetClassInfo(instance, className, &windowClass))
+ {
+ // windowClass.style = CS_HREDRAW | CS_VREDRAW;
+ windowClass.style = 0;
+
+ windowClass.lpfnWndProc = WindowProcedure;
+ windowClass.cbClsExtra = NULL;
+ windowClass.cbWndExtra = NULL;
+ windowClass.hInstance = instance;
+ windowClass.hIcon = NULL;
+ windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ windowClass.lpszMenuName = NULL;
+ windowClass.lpszClassName = className;
+ if (::RegisterClass(&windowClass) == 0)
+ return false;
+ }
+ return CWindow::CreateEx(exStyle, className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, this);
+}
+
+#ifndef _UNICODE
+
+bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance)
+{
+ bool needRegister;
+ if(g_IsNT)
+ {
+ WNDCLASSW windowClass;
+ needRegister = ::GetClassInfoW(instance, className, &windowClass) == 0;
+ }
+ else
+ {
+ WNDCLASSA windowClassA;
+ AString classNameA;
+ LPCSTR classNameP;
+ if (IS_INTRESOURCE(className))
+ classNameP = (LPCSTR)className;
+ else
+ {
+ classNameA = GetSystemString(className);
+ classNameP = classNameA;
+ }
+ needRegister = ::GetClassInfoA(instance, classNameP, &windowClassA) == 0;
+ }
+ if (needRegister)
+ {
+ WNDCLASSW windowClass;
+ // windowClass.style = CS_HREDRAW | CS_VREDRAW;
+ windowClass.style = 0;
+ windowClass.lpfnWndProc = WindowProcedure;
+ windowClass.cbClsExtra = NULL;
+ windowClass.cbWndExtra = NULL;
+ windowClass.hInstance = instance;
+ windowClass.hIcon = NULL;
+ windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ windowClass.lpszMenuName = NULL;
+ windowClass.lpszClassName = className;
+ if (MyRegisterClass(&windowClass) == 0)
+ return false;
+ }
+ return CWindow::CreateEx(exStyle, className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, this);
+
+}
+#endif
+
+LRESULT CWindow2::DefProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(_window, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(_window, message, wParam, lParam);
+}
+
+LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT result;
+ switch (message)
+ {
+ case WM_CREATE:
+ if (!OnCreate((CREATESTRUCT *)lParam))
+ return -1;
+ break;
+ case WM_COMMAND:
+ if (OnCommand(wParam, lParam, result))
+ return result;
+ break;
+ case WM_NOTIFY:
+ if (OnNotify((UINT)wParam, (LPNMHDR) lParam, result))
+ return result;
+ break;
+ case WM_DESTROY:
+ OnDestroy();
+ break;
+ case WM_CLOSE:
+ OnClose();
+ return 0;
+ case WM_SIZE:
+ if (OnSize(wParam, LOWORD(lParam), HIWORD(lParam)))
+ return 0;
+ }
+ return DefProc(message, wParam, lParam);
+}
+
+bool CWindow2::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result)
+{
+ return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam, result);
+}
+
+bool CWindow2::OnCommand(int /* code */, int /* itemID */, LPARAM /* lParam */, LRESULT & /* result */)
+{
+ return false;
+ // return DefProc(message, wParam, lParam);
+ /*
+ if (code == BN_CLICKED)
+ return OnButtonClicked(itemID, (HWND)lParam);
+ */
+}
+
+/*
+bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(aButtonID)
+ {
+ case IDOK:
+ OnOK();
+ break;
+ case IDCANCEL:
+ OnCancel();
+ break;
+ case IDHELP:
+ OnHelp();
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+*/
+
+}}
diff --git a/CPP/Windows/Control/Window2.h b/CPP/Windows/Control/Window2.h
new file mode 100755
index 00000000..2d0e574d
--- /dev/null
+++ b/CPP/Windows/Control/Window2.h
@@ -0,0 +1,59 @@
+// Windows/Control/Window2.h
+
+#ifndef __WINDOWS_CONTROL_WINDOW2_H
+#define __WINDOWS_CONTROL_WINDOW2_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CWindow2: public CWindow
+{
+ LRESULT DefProc(UINT message, WPARAM wParam, LPARAM lParam);
+public:
+ CWindow2(HWND newWindow = NULL): CWindow(newWindow){};
+ virtual ~CWindow2() {};
+
+
+ bool CreateEx(DWORD exStyle, LPCTSTR className,
+ LPCTSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance);
+
+ #ifndef _UNICODE
+ bool CreateEx(DWORD exStyle, LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance);
+ #endif
+
+ virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual bool OnCreate(CREATESTRUCT * /* createStruct */) { return true; }
+ // virtual LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
+ virtual bool OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result);
+ virtual bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result);
+ virtual bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; }
+ virtual bool OnNotify(UINT /* controlID */, LPNMHDR /* lParam */, LRESULT & /* result */) { return false; }
+ virtual void OnDestroy() { PostQuitMessage(0); }
+ virtual void OnClose() { Destroy(); }
+ /*
+ virtual LRESULT OnHelp(LPHELPINFO helpInfo) { OnHelp(); };
+ virtual LRESULT OnHelp() {};
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ virtual void OnOK() {};
+ virtual void OnCancel() {};
+ */
+
+ LONG_PTR SetMsgResult(LONG_PTR newLongPtr )
+ { return SetLongPtr(DWLP_MSGRESULT, newLongPtr); }
+ LONG_PTR GetMsgResult() const
+ { return GetLongPtr(DWLP_MSGRESULT); }
+};
+
+}}
+
+#endif \ No newline at end of file