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>2009-08-17 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:00 +0300
commitc99f3ebdd639c2adb03d8b44001b10af18516504 (patch)
tree92aaf34e5edbd7287c3f55037190da75ab0a8000 /CPP/Windows/Control
parent829409452d85cd6dd9dfc9151f109d6e13a2bb1c (diff)
9.06 beta
Diffstat (limited to 'CPP/Windows/Control')
-rwxr-xr-xCPP/Windows/Control/ComboBox.cpp5
-rwxr-xr-xCPP/Windows/Control/ComboBox.h28
-rwxr-xr-xCPP/Windows/Control/CommandBar.h48
-rwxr-xr-xCPP/Windows/Control/Dialog.cpp116
-rwxr-xr-xCPP/Windows/Control/Dialog.h87
-rwxr-xr-xCPP/Windows/Control/ListView.h105
-rwxr-xr-xCPP/Windows/Control/ProgressBar.h38
-rwxr-xr-xCPP/Windows/Control/PropertyPage.h21
-rwxr-xr-xCPP/Windows/Control/Static.h23
-rwxr-xr-xCPP/Windows/Control/ToolBar.h37
-rwxr-xr-xCPP/Windows/Control/Window2.cpp10
-rwxr-xr-xCPP/Windows/Control/Window2.h1
12 files changed, 327 insertions, 192 deletions
diff --git a/CPP/Windows/Control/ComboBox.cpp b/CPP/Windows/Control/ComboBox.cpp
index d9738f32..40d2f865 100755
--- a/CPP/Windows/Control/ComboBox.cpp
+++ b/CPP/Windows/Control/ComboBox.cpp
@@ -1,8 +1,5 @@
// Windows/Control/ComboBox.cpp
-// #define _UNICODE
-// #define UNICODE
-
#include "StdAfx.h"
#ifndef _UNICODE
@@ -10,7 +7,6 @@
#endif
#include "Windows/Control/ComboBox.h"
-#include "Windows/Defs.h"
#ifndef _UNICODE
extern bool g_IsNT;
@@ -59,5 +55,4 @@ LRESULT CComboBox::GetLBText(int index, UString &s)
}
#endif
-
}}
diff --git a/CPP/Windows/Control/ComboBox.h b/CPP/Windows/Control/ComboBox.h
index 58c86703..aa0eb930 100755
--- a/CPP/Windows/Control/ComboBox.h
+++ b/CPP/Windows/Control/ComboBox.h
@@ -3,11 +3,10 @@
#ifndef __WINDOWS_CONTROL_COMBOBOX_H
#define __WINDOWS_CONTROL_COMBOBOX_H
-#include "Windows/Window.h"
-#include "Windows/Defs.h"
-
#include <commctrl.h>
+#include "../Window.h"
+
namespace NWindows {
namespace NControl {
@@ -15,33 +14,34 @@ class CComboBox: public CWindow
{
public:
void ResetContent() { SendMessage(CB_RESETCONTENT, 0, 0); }
- LRESULT AddString(LPCTSTR string) { return SendMessage(CB_ADDSTRING, 0, (LPARAM)string); }
+ LRESULT AddString(LPCTSTR s) { return SendMessage(CB_ADDSTRING, 0, (LPARAM)s); }
#ifndef _UNICODE
- LRESULT AddString(LPCWSTR string);
+ LRESULT AddString(LPCWSTR s);
#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, LPTSTR s) { return SendMessage(CB_GETLBTEXT, index, (LPARAM)s); }
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); }
+ LRESULT SetItemData(int index, LPARAM lParam) { return SendMessage(CB_SETITEMDATA, index, lParam); }
+ LRESULT GetItemData(int index) { return SendMessage(CB_GETITEMDATA, index, 0); }
- void ShowDropDown(bool show = true)
- { SendMessage(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); }
+ void ShowDropDown(bool show = true) { SendMessage(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); }
};
+#ifndef UNDER_CE
+
class CComboBoxEx: public CComboBox
{
public:
+ bool SetUnicodeFormat(bool fUnicode) { return LRESULTToBool(SendMessage(CBEM_SETUNICODEFORMAT, BOOLToBool(fUnicode), 0)); }
+
LRESULT DeleteItem(int index) { return SendMessage(CBEM_DELETEITEM, index, 0); }
LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMessage(CBEM_INSERTITEM, 0, (LPARAM)item); }
#ifndef _UNICODE
@@ -54,6 +54,8 @@ public:
HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); }
};
+#endif
+
}}
-#endif \ No newline at end of file
+#endif
diff --git a/CPP/Windows/Control/CommandBar.h b/CPP/Windows/Control/CommandBar.h
new file mode 100755
index 00000000..4cbe07b6
--- /dev/null
+++ b/CPP/Windows/Control/CommandBar.h
@@ -0,0 +1,48 @@
+// Windows/Control/CommandBar.h
+
+#ifndef __WINDOWS_CONTROL_COMMANDBAR_H
+#define __WINDOWS_CONTROL_COMMANDBAR_H
+
+#ifdef UNDER_CE
+
+#include "Windows/Window.h"
+
+namespace NWindows {
+namespace NControl {
+
+class CCommandBar: public NWindows::CWindow
+{
+public:
+ bool Create(HINSTANCE hInst, HWND hwndParent, int idCmdBar)
+ {
+ _window = ::CommandBar_Create(hInst, hwndParent, idCmdBar);
+ return (_window != NULL);
+ }
+
+ // Macros
+ // void Destroy() { CommandBar_Destroy(_window); }
+ bool AddButtons(int iButton, UINT numButtons, LPTBBUTTON buttons) { return BOOLToBool(SendMessage(TB_ADDBUTTONS, (WPARAM)numButtons, (LPARAM)buttons)); }
+ bool InsertButton(int iButton, LPTBBUTTON button) { return BOOLToBool(SendMessage(TB_INSERTBUTTON, (WPARAM)iButton, (LPARAM)button)); }
+ BOOL AddToolTips(UINT numToolTips, LPTSTR toolTips) { return BOOLToBool(SendMessage(TB_SETTOOLTIPS, (WPARAM)numToolTips, (LPARAM)toolTips)); }
+ void AutoSize() { SendMessage(TB_AUTOSIZE, 0, 0); }
+
+ bool AddAdornments(DWORD dwFlags) { return BOOLToBool(::CommandBar_AddAdornments(_window, dwFlags, 0)); }
+ int AddBitmap(HINSTANCE hInst, int idBitmap, int iNumImages, int iImageWidth, int iImageHeight) { return ::CommandBar_AddBitmap(_window, hInst, idBitmap, iNumImages, iImageWidth, iImageHeight); }
+ bool DrawMenuBar(WORD iButton) { return BOOLToBool(::CommandBar_DrawMenuBar(_window, iButton)); }
+ HMENU GetMenu(WORD iButton) { return ::CommandBar_GetMenu(_window, iButton); }
+ int Height() { return CommandBar_Height(_window); }
+ HWND InsertComboBox(HINSTANCE hInst, int iWidth, UINT dwStyle, WORD idComboBox, WORD iButton) { return ::CommandBar_InsertComboBox(_window, hInst, iWidth, dwStyle, idComboBox, iButton); }
+ bool InsertMenubar(HINSTANCE hInst, WORD idMenu, WORD iButton) { return BOOLToBool(::CommandBar_InsertMenubar(_window, hInst, idMenu, iButton)); }
+ bool InsertMenubarEx(HINSTANCE hInst, LPTSTR pszMenu, WORD iButton) { return BOOLToBool(::CommandBar_InsertMenubarEx(_window, hInst, pszMenu, iButton)); }
+ bool Show(bool cmdShow) { return BOOLToBool(::CommandBar_Show(_window, BoolToBOOL(cmdShow))); }
+
+
+ // CE 4.0
+ void AlignAdornments() { CommandBar_AlignAdornments(_window); }
+};
+
+}}
+
+#endif
+
+#endif \ No newline at end of file
diff --git a/CPP/Windows/Control/Dialog.cpp b/CPP/Windows/Control/Dialog.cpp
index 8bae85be..dd0cf066 100755
--- a/CPP/Windows/Control/Dialog.cpp
+++ b/CPP/Windows/Control/Dialog.cpp
@@ -15,8 +15,7 @@ extern bool g_IsNT;
namespace NWindows {
namespace NControl {
-static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message,
- WPARAM wParam, LPARAM lParam)
+static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
{
CWindow dialogTmp(dialogHWND);
if (message == WM_INITDIALOG)
@@ -27,30 +26,31 @@ static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message,
if (message == WM_INITDIALOG)
dialog->Attach(dialogHWND);
- return BoolToBOOL(dialog->OnMessage(message, wParam, lParam));
+ try { return BoolToBOOL(dialog->OnMessage(message, wParam, lParam)); }
+ catch(...) { return true; }
}
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);
+ case WM_INITDIALOG: return OnInit();
+ case WM_COMMAND: return OnCommand(wParam, lParam);
+ case WM_NOTIFY: return OnNotify((UINT)wParam, (LPNMHDR) lParam);
+ case WM_TIMER: return OnTimer(wParam, lParam);
+ case WM_SIZE: return OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
+ case WM_HELP: OnHelp(); return true;
+ /*
+ OnHelp(
+ #ifdef UNDER_CE
+ (void *)
+ #else
+ (LPHELPINFO)
+ #endif
+ lParam);
return true;
- }
- case WM_TIMER:
- {
- return OnTimer(wParam, lParam);
- }
- default:
- return false;
+ */
+ default: return false;
}
}
@@ -70,21 +70,77 @@ bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */)
{
switch(buttonID)
{
- case IDOK:
- OnOK();
- break;
- case IDCANCEL:
- OnCancel();
- break;
- case IDHELP:
- OnHelp();
- break;
- default:
- return false;
+ case IDOK: OnOK(); break;
+ case IDCANCEL: OnCancel(); break;
+ case IDHELP: OnHelp(); break;
+ default: return false;
}
return true;
}
+static bool GetWorkAreaRect(RECT *rect)
+{
+ // use another function for multi-monitor.
+ return BOOLToBool(::SystemParametersInfo(SPI_GETWORKAREA, NULL, rect, NULL));
+}
+
+bool IsDialogSizeOK(int xSize, int ySize)
+{
+ // it returns for system font. Real font uses another values
+ LONG v = GetDialogBaseUnits();
+ int x = LOWORD(v);
+ int y = HIWORD(v);
+
+ RECT rect;
+ GetWorkAreaRect(&rect);
+ int wx = RECT_SIZE_X(rect);
+ int wy = RECT_SIZE_Y(rect);
+ return
+ xSize / 4 * x <= wx &&
+ ySize / 8 * y <= wy;
+}
+
+void CDialog::NormalizeSize(bool fullNormalize)
+{
+ RECT workRect;
+ GetWorkAreaRect(&workRect);
+ int xSize = RECT_SIZE_X(workRect);
+ int ySize = RECT_SIZE_Y(workRect);
+ RECT rect;
+ GetWindowRect(&rect);
+ int xSize2 = RECT_SIZE_X(rect);
+ int ySize2 = RECT_SIZE_Y(rect);
+ bool needMove = (xSize2 > xSize || ySize2 > ySize);
+ if (xSize2 > xSize || (needMove && fullNormalize))
+ {
+ rect.left = workRect.left;
+ rect.right = workRect.right;
+ xSize2 = xSize;
+ }
+ if (ySize2 > ySize || (needMove && fullNormalize))
+ {
+ rect.top = workRect.top;
+ rect.bottom = workRect.bottom;
+ ySize2 = ySize;
+ }
+ if (needMove)
+ {
+ if (fullNormalize)
+ Show(SW_SHOWMAXIMIZED);
+ else
+ Move(rect.left, rect.top, xSize2, ySize2, true);
+ }
+}
+
+void CDialog::NormalizePosition()
+{
+ RECT workRect, rect;
+ GetWorkAreaRect(&workRect);
+ GetWindowRect(&rect);
+ if (rect.bottom > workRect.bottom && rect.top > workRect.top)
+ Move(rect.left, workRect.top, RECT_SIZE_X(rect), RECT_SIZE_Y(rect), true);
+}
+
bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow)
{
HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
diff --git a/CPP/Windows/Control/Dialog.h b/CPP/Windows/Control/Dialog.h
index daebb1bf..2b5147e7 100755
--- a/CPP/Windows/Control/Dialog.h
+++ b/CPP/Windows/Control/Dialog.h
@@ -4,7 +4,6 @@
#define __WINDOWS_CONTROL_DIALOG_H
#include "Windows/Window.h"
-#include "Windows/Defs.h"
namespace NWindows {
namespace NControl {
@@ -24,6 +23,8 @@ public:
bool ShowItem(int itemID, int cmdShow) const
{ return BOOLToBool(::ShowWindow(GetItem(itemID), cmdShow)); }
+ bool HideItem(int itemID) const { return ShowItem(itemID, SW_HIDE); }
+
bool SetItemText(int itemID, LPCTSTR s)
{ return BOOLToBool(SetDlgItemText(_window, itemID, s)); }
@@ -50,11 +51,11 @@ public:
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);
- }
+ {
+ BOOL result;
+ value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned));
+ return BOOLToBool(result);
+ }
HWND GetNextGroupItem(HWND control, bool previous)
{ return GetNextDlgGroupItem(_window, control, BoolToBOOL(previous)); }
@@ -87,8 +88,17 @@ public:
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 bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; }
+
+ /*
+ #ifdef UNDER_CE
+ virtual void OnHelp(void *) { OnHelp(); };
+ #else
+ virtual void OnHelp(LPHELPINFO) { OnHelp(); };
+ #endif
+ */
virtual void OnHelp() {};
+
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
virtual void OnOK() {};
virtual void OnCancel() {};
@@ -99,12 +109,63 @@ public:
{ return SetLongPtr(DWLP_MSGRESULT, newLongPtr); }
LONG_PTR GetMsgResult() const
{ return GetLongPtr(DWLP_MSGRESULT); }
+
+
+ bool GetMargins(int margin, int &x, int &y)
+ {
+ RECT rect;
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = margin;
+ rect.bottom = margin;
+ if (!MapRect(&rect))
+ return false;
+ x = rect.right - rect.left;
+ y = rect.bottom - rect.top;
+ return true;
+ }
+
+ int Units_To_Pixels_X(int units)
+ {
+ RECT rect;
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = units;
+ rect.bottom = units;
+ if (!MapRect(&rect))
+ return units * 3 / 2;
+ return rect.right - rect.left;
+ }
+
+ bool GetItemSizes(int id, int &x, int &y)
+ {
+ RECT rect;
+ if (!::GetWindowRect(GetItem(id), &rect))
+ return false;
+ x = rect.right - rect.left;
+ y = rect.bottom - rect.top;
+ return true;
+ }
+
+ void GetClientRectOfItem(int id, RECT &rect)
+ {
+ ::GetWindowRect(GetItem(id), &rect);
+ ScreenToClient(&rect);
+ }
+
+
+ bool MoveItem(int id, int x, int y, int width, int height, bool repaint = true)
+ { return BOOLToBool(::MoveWindow(GetItem(id), x, y, width, height, BoolToBOOL(repaint))); }
+
+ void NormalizeSize(bool fullNormalize = false);
+ void NormalizePosition();
};
class CModelessDialog: public CDialog
{
public:
bool Create(LPCTSTR templateName, HWND parentWindow);
+ bool Create(UINT resID, HWND parentWindow) { return Create(MAKEINTRESOURCEW(resID), parentWindow); }
#ifndef _UNICODE
bool Create(LPCWSTR templateName, HWND parentWindow);
#endif
@@ -116,22 +177,20 @@ class CModalDialog: public CDialog
{
public:
INT_PTR Create(LPCTSTR templateName, HWND parentWindow);
- INT_PTR Create(UINT resID, HWND parentWindow)
- { return Create(MAKEINTRESOURCEW(resID), 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)); }
+ 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;
+public:
void Init(const NWindows::NControl::CDialog &parentDialog, int id)
{
m_ID = id;
@@ -139,6 +198,8 @@ public:
}
};
+bool IsDialogSizeOK(int xSize, int ySize);
+
}}
-#endif \ No newline at end of file
+#endif
diff --git a/CPP/Windows/Control/ListView.h b/CPP/Windows/Control/ListView.h
index 0daf65f3..1258ec93 100755
--- a/CPP/Windows/Control/ListView.h
+++ b/CPP/Windows/Control/ListView.h
@@ -4,7 +4,6 @@
#define __WINDOWS_CONTROL_LISTVIEW_H
#include "Windows/Window.h"
-#include "Windows/Defs.h"
#include <commctrl.h>
@@ -19,17 +18,14 @@ public:
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance, LPVOID createParam);
- bool SetUnicodeFormat(bool fUnicode)
- { return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); }
+ #ifndef UNDER_CE
+ bool SetUnicodeFormat(bool fUnicode) { return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); }
+ #endif
- bool DeleteAllItems()
- { return BOOLToBool(ListView_DeleteAllItems(_window)); }
-
- bool DeleteColumn(int columnIndex)
- { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
+ bool DeleteAllItems() { return BOOLToBool(ListView_DeleteAllItems(_window)); }
+ bool DeleteColumn(int columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
- int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo)
- { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
+ int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
int InsertColumn(int columnIndex, LPCTSTR text, int width);
int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
int InsertItem(int index, LPCTSTR text);
@@ -38,8 +34,7 @@ public:
#ifndef _UNICODE
- int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo)
- { return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
+ int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
int InsertColumn(int columnIndex, LPCWSTR text, int width);
int InsertItem(const LV_ITEMW* item) { return (int)SendMessage(LVM_INSERTITEMW, 0, (LPARAM)item); }
int InsertItem(int index, LPCWSTR text);
@@ -48,41 +43,30 @@ public:
#endif
- bool DeleteItem(int itemIndex)
- { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
+ bool DeleteItem(int itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
- UINT GetSelectedCount() const
- { return ListView_GetSelectedCount(_window); }
- int GetItemCount() const
- { return ListView_GetItemCount(_window); }
+ UINT GetSelectedCount() const { return ListView_GetSelectedCount(_window); }
+ int GetItemCount() const { return ListView_GetItemCount(_window); }
- INT GetSelectionMark() const
- { return ListView_GetSelectionMark(_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); }
+ 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); }
+ 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 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); }
+ void GetItemText(int itemIndex, int subItemIndex, LPTSTR text, int textSizeMax) const
+ { ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax); }
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); }
+ void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask); }
+ void SetItemState_FocusedSelected(int index) { SetItemState(index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); }
+ 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)); }
@@ -91,48 +75,33 @@ public:
{ 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)); }
+ 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); }
+ void SetCheckState(UINT index, bool checkState) { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); }
+ 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 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)); }
+ 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) ; }
+ 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 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); }
+ bool RedrawItem(int index) { return RedrawItems(index, index); }
- int HitTest(LPLVHITTESTINFO info)
- { return ListView_HitTest(_window, info); }
-
- COLORREF GetBkColor()
- { return ListView_GetBkColor(_window); }
+ int HitTest(LPLVHITTESTINFO info) { return ListView_HitTest(_window, info); }
+ COLORREF GetBkColor() { return ListView_GetBkColor(_window); }
+ bool SetColumnWidth(int iCol, int cx) { return BOOLToBool(ListView_SetColumnWidth(_window, iCol, cx)); }
+ bool SetColumnWidthAuto(int iCol) { return SetColumnWidth(iCol, LVSCW_AUTOSIZE); }
};
}}
diff --git a/CPP/Windows/Control/ProgressBar.h b/CPP/Windows/Control/ProgressBar.h
index 6ce837cc..4591880a 100755
--- a/CPP/Windows/Control/ProgressBar.h
+++ b/CPP/Windows/Control/ProgressBar.h
@@ -3,8 +3,7 @@
#ifndef __WINDOWS_CONTROL_PROGRESSBAR_H
#define __WINDOWS_CONTROL_PROGRESSBAR_H
-#include "Windows/Window.h"
-#include "Windows/Defs.h"
+#include "../Window.h"
namespace NWindows {
namespace NControl {
@@ -12,30 +11,21 @@ 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); }
+ 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); }
+ #ifndef UNDER_CE
+ COLORREF SetBarColor(COLORREF color) { return (COLORREF)SendMessage(PBM_SETBARCOLOR, 0, color); }
+ COLORREF SetBackgroundColor(COLORREF color) { return (COLORREF)SendMessage(PBM_SETBKCOLOR, 0, color); }
+ #endif
};
}}
-#endif \ No newline at end of file
+#endif
diff --git a/CPP/Windows/Control/PropertyPage.h b/CPP/Windows/Control/PropertyPage.h
index e041d289..4e7e088e 100755
--- a/CPP/Windows/Control/PropertyPage.h
+++ b/CPP/Windows/Control/PropertyPage.h
@@ -3,8 +3,7 @@
#ifndef __WINDOWS_CONTROL_PROPERTYPAGE_H
#define __WINDOWS_CONTROL_PROPERTYPAGE_H
-#include "Windows/Control/Dialog.h"
-#include "Windows/Defs.h"
+#include "Dialog.h"
namespace NWindows {
namespace NControl {
@@ -16,21 +15,21 @@ 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)); }
+ 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 bool OnKillActive(const PSHNOTIFY *) { return OnKillActive(); }
virtual LONG OnSetActive() { return false; } // false = OK
- virtual LONG OnSetActive(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnKillActive(); }
+ virtual LONG OnSetActive(const PSHNOTIFY *) { return OnSetActive(); }
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(); }
+ virtual LONG OnApply(const PSHNOTIFY *) { return OnApply(); }
+ virtual void OnNotifyHelp() {}
+ virtual void OnNotifyHelp(const PSHNOTIFY *) { OnNotifyHelp(); }
+ virtual void OnReset() {}
+ virtual void OnReset(const PSHNOTIFY *) { OnReset(); }
};
struct CPageInfo
diff --git a/CPP/Windows/Control/Static.h b/CPP/Windows/Control/Static.h
index 5dded0ec..cb3126dd 100755
--- a/CPP/Windows/Control/Static.h
+++ b/CPP/Windows/Control/Static.h
@@ -3,8 +3,7 @@
#ifndef __WINDOWS_CONTROL_STATIC_H
#define __WINDOWS_CONTROL_STATIC_H
-#include "Windows/Window.h"
-#include "Windows/Defs.h"
+#include "../Window.h"
namespace NWindows {
namespace NControl {
@@ -12,16 +11,18 @@ 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); }
+ 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); }
+
+ #ifdef UNDER_CE
+ HICON SetIcon(HICON icon) { return (HICON)SetImage(IMAGE_ICON, icon); }
+ HICON GetIcon() { return (HICON)GetImage(IMAGE_ICON); }
+ #else
+ HICON SetIcon(HICON icon) { return (HICON)SendMessage(STM_SETICON, (WPARAM)icon, 0); }
+ HICON GetIcon() { return (HICON)SendMessage(STM_GETICON, 0, 0); }
+ #endif
};
}}
-#endif \ No newline at end of file
+#endif
diff --git a/CPP/Windows/Control/ToolBar.h b/CPP/Windows/Control/ToolBar.h
index 4bd21531..262184ae 100755
--- a/CPP/Windows/Control/ToolBar.h
+++ b/CPP/Windows/Control/ToolBar.h
@@ -4,7 +4,6 @@
#define __WINDOWS_CONTROL_TOOLBAR_H
#include "Windows/Window.h"
-#include "Windows/Defs.h"
namespace NWindows {
namespace NControl {
@@ -12,23 +11,33 @@ namespace NControl {
class CToolBar: public NWindows::CWindow
{
public:
+ void AutoSize() { SendMessage(TB_AUTOSIZE, 0, 0); }
+ DWORD GetButtonSize() { return (DWORD)SendMessage(TB_GETBUTTONSIZE, 0, 0); }
+
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)); }
+ #ifdef UNDER_CE
+ {
+ // maybe it must be fixed for more than 1 buttons
+ DWORD val = GetButtonSize();
+ size->cx = LOWORD(val);
+ size->cy = HIWORD(val);
+ return true;
+ }
+ #else
+ {
+ return LRESULTToBool(SendMessage(TB_GETMAXSIZE, 0, (LPARAM)size));
+ }
+ #endif
+
+ 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)); }
+ bool AddButtonW(UINT numButtons, LPTBBUTTON buttons) { return LRESULTToBool(SendMessage(TB_ADDBUTTONSW, numButtons, (LPARAM)buttons)); }
#endif
};
}}
-#endif \ No newline at end of file
+#endif
diff --git a/CPP/Windows/Control/Window2.cpp b/CPP/Windows/Control/Window2.cpp
index 3900f649..e1299048 100755
--- a/CPP/Windows/Control/Window2.cpp
+++ b/CPP/Windows/Control/Window2.cpp
@@ -20,15 +20,21 @@ ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
namespace NControl {
+#ifdef UNDER_CE
+#define MY_START_WM_CREATE WM_CREATE
+#else
+#define MY_START_WM_CREATE WM_NCCREATE
+#endif
+
static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
WPARAM wParam, LPARAM lParam)
{
CWindow tempWindow(aHWND);
- if (message == WM_NCCREATE)
+ if (message == MY_START_WM_CREATE)
tempWindow.SetUserDataLongPtr(
LONG_PTR(((LPCREATESTRUCT)lParam)->lpCreateParams));
CWindow2 *window = (CWindow2*)(tempWindow.GetUserDataLongPtr());
- if (window != NULL && message == WM_NCCREATE)
+ if (window != NULL && message == MY_START_WM_CREATE)
window->Attach(aHWND);
if (window == 0)
{
diff --git a/CPP/Windows/Control/Window2.h b/CPP/Windows/Control/Window2.h
index 8af902f8..b016a13d 100755
--- a/CPP/Windows/Control/Window2.h
+++ b/CPP/Windows/Control/Window2.h
@@ -4,7 +4,6 @@
#define __WINDOWS_CONTROL_WINDOW2_H
#include "Windows/Window.h"
-#include "Windows/Defs.h"
namespace NWindows {
namespace NControl {