Update to lzma 23.01.

This commit is contained in:
2023-09-24 03:13:03 +01:00
parent 5a6a32f513
commit dda9bcac54
530 changed files with 31937 additions and 14468 deletions

View File

@@ -43,10 +43,10 @@ LRESULT CComboBox::GetLBText(int index, UString &s)
s.Empty();
if (g_IsNT)
{
LRESULT len = SendMsgW(CB_GETLBTEXTLEN, MY__int_TO_WPARAM(index), 0);
LRESULT len = SendMsgW(CB_GETLBTEXTLEN, MY_int_TO_WPARAM(index), 0);
if (len == CB_ERR)
return len;
LRESULT len2 = SendMsgW(CB_GETLBTEXT, MY__int_TO_WPARAM(index), (LPARAM)s.GetBuf((unsigned)len));
LRESULT len2 = SendMsgW(CB_GETLBTEXT, MY_int_TO_WPARAM(index), (LPARAM)s.GetBuf((unsigned)len));
if (len2 == CB_ERR)
return len;
if (len > len2)
@@ -55,11 +55,11 @@ LRESULT CComboBox::GetLBText(int index, UString &s)
return len;
}
AString sa;
LRESULT len = GetLBText(index, sa);
const LRESULT len = GetLBText(index, sa);
if (len == CB_ERR)
return len;
s = GetUnicodeString(sa);
return s.Len();
return (LRESULT)s.Len();
}
#endif

View File

@@ -1,7 +1,7 @@
// Windows/Control/ComboBox.h
#ifndef __WINDOWS_CONTROL_COMBOBOX_H
#define __WINDOWS_CONTROL_COMBOBOX_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_COMBOBOX_H
#define ZIP7_INC_WINDOWS_CONTROL_COMBOBOX_H
#include "../../Common/MyWindows.h"
@@ -12,8 +12,6 @@
namespace NWindows {
namespace NControl {
#define MY__int_TO_WPARAM(i) ((WPARAM)(INT_PTR)(i))
class CComboBox: public CWindow
{
public:
@@ -24,7 +22,8 @@ public:
#endif
/* If this parameter is -1, any current selection in the list is removed and the edit control is cleared.*/
LRESULT SetCurSel(int index) { return SendMsg(CB_SETCURSEL, MY__int_TO_WPARAM(index), 0); }
LRESULT SetCurSel(int index) { return SendMsg(CB_SETCURSEL, MY_int_TO_WPARAM(index), 0); }
LRESULT SetCurSel(unsigned index) { return SendMsg(CB_SETCURSEL, index, 0); }
/* If no item is selected, it returns CB_ERR (-1) */
int GetCurSel() { return (int)SendMsg(CB_GETCURSEL, 0, 0); }
@@ -32,15 +31,16 @@ public:
/* If an error occurs, it is CB_ERR (-1) */
int GetCount() { return (int)SendMsg(CB_GETCOUNT, 0, 0); }
LRESULT GetLBTextLen(int index) { return SendMsg(CB_GETLBTEXTLEN, MY__int_TO_WPARAM(index), 0); }
LRESULT GetLBText(int index, LPTSTR s) { return SendMsg(CB_GETLBTEXT, MY__int_TO_WPARAM(index), (LPARAM)s); }
LRESULT GetLBTextLen(int index) { return SendMsg(CB_GETLBTEXTLEN, MY_int_TO_WPARAM(index), 0); }
LRESULT GetLBText(int index, LPTSTR s) { return SendMsg(CB_GETLBTEXT, MY_int_TO_WPARAM(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 SendMsg(CB_SETITEMDATA, MY__int_TO_WPARAM(index), lParam); }
LRESULT GetItemData(int index) { return SendMsg(CB_GETITEMDATA, MY__int_TO_WPARAM(index), 0); }
LRESULT SetItemData(int index, LPARAM lParam) { return SendMsg(CB_SETITEMDATA, MY_int_TO_WPARAM(index), lParam); }
LRESULT GetItemData(int index) { return SendMsg(CB_GETITEMDATA, MY_int_TO_WPARAM(index), 0); }
LRESULT GetItemData(unsigned index) { return SendMsg(CB_GETITEMDATA, index, 0); }
LRESULT GetItemData_of_CurSel() { return GetItemData(GetCurSel()); }
@@ -57,7 +57,7 @@ public:
/* Returns:
an INT value that represents the number of items remaining in the control.
If (index) is invalid, the message returns CB_ERR. */
LRESULT DeleteItem(int index) { return SendMsg(CBEM_DELETEITEM, MY__int_TO_WPARAM(index), 0); }
LRESULT DeleteItem(int index) { return SendMsg(CBEM_DELETEITEM, MY_int_TO_WPARAM(index), 0); }
LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_INSERTITEM, 0, (LPARAM)item); }
#ifndef _UNICODE
@@ -65,7 +65,7 @@ public:
#endif
LRESULT SetItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_SETITEM, 0, (LPARAM)item); }
DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMsg(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); }
DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMsg(CBEM_SETEXTENDEDSTYLE, exMask, (LPARAM)exStyle); }
HWND GetEditControl() { return (HWND)SendMsg(CBEM_GETEDITCONTROL, 0, 0); }
HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMsg(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); }
};

View File

@@ -1,7 +1,7 @@
// Windows/Control/CommandBar.h
#ifndef __WINDOWS_CONTROL_COMMANDBAR_H
#define __WINDOWS_CONTROL_COMMANDBAR_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_COMMANDBAR_H
#define ZIP7_INC_WINDOWS_CONTROL_COMMANDBAR_H
#ifdef UNDER_CE
@@ -26,12 +26,12 @@ public:
// Macros
// void Destroy() { CommandBar_Destroy(_window); }
// bool AddButtons(UINT numButtons, LPTBBUTTON buttons) { return BOOLToBool(SendMsg(TB_ADDBUTTONS, (WPARAM)numButtons, (LPARAM)buttons)); }
bool InsertButton(int iButton, LPTBBUTTON button) { return BOOLToBool(SendMsg(TB_INSERTBUTTON, (WPARAM)iButton, (LPARAM)button)); }
BOOL AddToolTips(UINT numToolTips, LPTSTR toolTips) { return BOOLToBool(SendMsg(TB_SETTOOLTIPS, (WPARAM)numToolTips, (LPARAM)toolTips)); }
// bool InsertButton(unsigned iButton, LPTBBUTTON button) { return BOOLToBool(SendMsg(TB_INSERTBUTTON, (WPARAM)iButton, (LPARAM)button)); }
// BOOL AddToolTips(UINT numToolTips, LPTSTR toolTips) { return BOOLToBool(SendMsg(TB_SETTOOLTIPS, (WPARAM)numToolTips, (LPARAM)toolTips)); }
void AutoSize() { SendMsg(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 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); }

View File

@@ -2,6 +2,8 @@
#include "StdAfx.h"
// #include "../../Windows/DLL.h"
#ifndef _UNICODE
#include "../../Common/StringConvert.h"
#endif
@@ -16,7 +18,14 @@ extern bool g_IsNT;
namespace NWindows {
namespace NControl {
static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
static
#ifdef Z7_OLD_WIN_SDK
BOOL
#else
INT_PTR
#endif
APIENTRY
DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
{
CWindow tempDialog(dialogHWND);
if (message == WM_INITDIALOG)
@@ -43,7 +52,7 @@ 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_COMMAND: return OnCommand(HIWORD(wParam), LOWORD(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));
@@ -63,19 +72,21 @@ bool CDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
}
}
bool CDialog::OnCommand(WPARAM wParam, LPARAM lParam)
/*
bool CDialog::OnCommand2(WPARAM wParam, LPARAM lParam)
{
return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam);
}
*/
bool CDialog::OnCommand(int code, int itemID, LPARAM lParam)
bool CDialog::OnCommand(unsigned code, unsigned itemID, LPARAM lParam)
{
if (code == BN_CLICKED)
return OnButtonClicked(itemID, (HWND)lParam);
return false;
}
bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */)
bool CDialog::OnButtonClicked(unsigned buttonID, HWND /* buttonHWND */)
{
switch (buttonID)
{
@@ -88,23 +99,77 @@ bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */)
return true;
}
static bool GetWorkAreaRect(RECT *rect)
#ifndef UNDER_CE
/* in win2000/win98 : monitor functions are supported.
We need dynamic linking, if we want nt4/win95 support in program.
Even if we compile the code with low (WINVER) value, we still
want to use monitor functions. So we declare missing functions here */
// #if (WINVER < 0x0500)
#ifndef MONITOR_DEFAULTTOPRIMARY
extern "C" {
DECLARE_HANDLE(HMONITOR);
#define MONITOR_DEFAULTTOPRIMARY 0x00000001
typedef struct tagMONITORINFO
{
// use another function for multi-monitor.
DWORD cbSize;
RECT rcMonitor;
RECT rcWork;
DWORD dwFlags;
} MONITORINFO, *LPMONITORINFO;
WINUSERAPI HMONITOR WINAPI MonitorFromWindow(HWND hwnd, DWORD dwFlags);
WINUSERAPI BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpmi);
}
#endif
#endif
static bool GetWorkAreaRect(RECT *rect, HWND hwnd)
{
if (hwnd)
{
#ifndef UNDER_CE
/* MonitorFromWindow() is supported in Win2000+
MonitorFromWindow() : retrieves a handle to the display monitor that has the
largest area of intersection with the bounding rectangle of a specified window.
dwFlags: Determines the function's return value if the window does not intersect any display monitor.
MONITOR_DEFAULTTONEAREST : Returns display that is nearest to the window.
MONITOR_DEFAULTTONULL : Returns NULL.
MONITOR_DEFAULTTOPRIMARY : Returns the primary display monitor.
*/
const HMONITOR hmon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY);
if (hmon)
{
MONITORINFO mi;
memset(&mi, 0, sizeof(mi));
mi.cbSize = sizeof(mi);
if (GetMonitorInfoA(hmon, &mi))
{
*rect = mi.rcWork;
return true;
}
}
#endif
}
/* Retrieves the size of the work area on the primary display monitor.
The work area is the portion of the screen not obscured
by the system taskbar or by application desktop toolbars.
Any DPI virtualization mode of the caller has no effect on this output. */
return BOOLToBool(::SystemParametersInfo(SPI_GETWORKAREA, 0, rect, 0));
}
bool IsDialogSizeOK(int xSize, int ySize)
bool IsDialogSizeOK(int xSize, int ySize, HWND hwnd)
{
// it returns for system font. Real font uses another values
LONG v = GetDialogBaseUnits();
int x = LOWORD(v);
int y = HIWORD(v);
const LONG v = GetDialogBaseUnits();
const int x = LOWORD(v);
const int y = HIWORD(v);
RECT rect;
GetWorkAreaRect(&rect);
int wx = RECT_SIZE_X(rect);
int wy = RECT_SIZE_Y(rect);
GetWorkAreaRect(&rect, hwnd);
const int wx = RECT_SIZE_X(rect);
const int wy = RECT_SIZE_Y(rect);
return
xSize / 4 * x <= wx &&
ySize / 8 * y <= wy;
@@ -138,7 +203,7 @@ int CDialog::Units_To_Pixels_X(int units)
return rect.right - rect.left;
}
bool CDialog::GetItemSizes(int id, int &x, int &y)
bool CDialog::GetItemSizes(unsigned id, int &x, int &y)
{
RECT rect;
if (!::GetWindowRect(GetItem(id), &rect))
@@ -148,62 +213,182 @@ bool CDialog::GetItemSizes(int id, int &x, int &y)
return true;
}
void CDialog::GetClientRectOfItem(int id, RECT &rect)
void CDialog::GetClientRectOfItem(unsigned id, RECT &rect)
{
::GetWindowRect(GetItem(id), &rect);
ScreenToClient(&rect);
}
bool CDialog::MoveItem(int id, int x, int y, int width, int height, bool repaint)
bool CDialog::MoveItem(unsigned id, int x, int y, int width, int height, bool repaint)
{
return BOOLToBool(::MoveWindow(GetItem(id), x, y, width, height, BoolToBOOL(repaint)));
}
/*
typedef BOOL (WINAPI * Func_DwmGetWindowAttribute)(
HWND hwnd, DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute);
static bool GetWindowsRect_DWM(HWND hwnd, RECT *rect)
{
// dll load and free is too slow : 300 calls in second.
NDLL::CLibrary dll;
if (!dll.Load(FTEXT("dwmapi.dll")))
return false;
Func_DwmGetWindowAttribute f = (Func_DwmGetWindowAttribute)dll.GetProc("DwmGetWindowAttribute" );
if (f)
{
#define MY__DWMWA_EXTENDED_FRAME_BOUNDS 9
// 30000 per second
RECT r;
if (f(hwnd, MY__DWMWA_EXTENDED_FRAME_BOUNDS, &r, sizeof(RECT)) == S_OK)
{
*rect = r;
return true;
}
}
return false;
}
*/
static bool IsRect_Small_Inside_Big(const RECT &sm, const RECT &big)
{
return sm.left >= big.left
&& sm.right <= big.right
&& sm.top >= big.top
&& sm.bottom <= big.bottom;
}
static bool AreRectsOverlapped(const RECT &r1, const RECT &r2)
{
return r1.left < r2.right
&& r1.right > r2.left
&& r1.top < r2.bottom
&& r1.bottom > r2.top;
}
static bool AreRectsEqual(const RECT &r1, const RECT &r2)
{
return r1.left == r2.left
&& r1.right == r2.right
&& r1.top == r2.top
&& r1.bottom == r2.bottom;
}
void CDialog::NormalizeSize(bool fullNormalize)
{
RECT workRect;
GetWorkAreaRect(&workRect);
int xSize = RECT_SIZE_X(workRect);
int ySize = RECT_SIZE_Y(workRect);
if (!GetWorkAreaRect(&workRect, *this))
return;
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))
if (!GetWindowRect(&rect))
return;
int xs = RECT_SIZE_X(rect);
int ys = RECT_SIZE_Y(rect);
// we don't want to change size using workRect, if window is outside of WorkArea
if (!AreRectsOverlapped(rect, workRect))
return;
/* here rect and workRect are overlapped, but it can be false
overlapping of small shadow when window in another display. */
const int xsW = RECT_SIZE_X(workRect);
const int ysW = RECT_SIZE_Y(workRect);
if (xs <= xsW && ys <= ysW)
return; // size of window is OK
if (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);
Show(SW_SHOWMAXIMIZED);
return;
}
int x = workRect.left;
int y = workRect.top;
if (xs < xsW) x += (xsW - xs) / 2; else xs = xsW;
if (ys < ysW) y += (ysW - ys) / 2; else ys = ysW;
Move(x, y, xs, ys, 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);
RECT workRect;
if (!GetWorkAreaRect(&workRect, *this))
return;
RECT rect2 = workRect;
bool useWorkArea = true;
const HWND parentHWND = GetParent();
if (parentHWND)
{
RECT workRectParent;
if (!GetWorkAreaRect(&workRectParent, parentHWND))
return;
// if windows are in different monitors, we use only workArea of current window
if (AreRectsEqual(workRectParent, workRect))
{
// RECT rect3; if (GetWindowsRect_DWM(parentHWND, &rect3)) {}
CWindow wnd(parentHWND);
if (wnd.GetWindowRect(&rect2))
{
// it's same monitor. So we try to use parentHWND rect.
/* we don't want to change position, if parent window is not inside work area.
In Win10 : parent window rect is 8 pixels larger for each corner than window size for shadow.
In maximize mode : window is outside of workRect.
if parent window is inside workRect, we will use parent window instead of workRect */
if (IsRect_Small_Inside_Big(rect2, workRect))
useWorkArea = false;
}
}
}
RECT rect;
if (!GetWindowRect(&rect))
return;
if (useWorkArea)
{
// we don't want to move window, if it's already inside.
if (IsRect_Small_Inside_Big(rect, workRect))
return;
// we don't want to move window, if it's outside of workArea
if (!AreRectsOverlapped(rect, workRect))
return;
rect2 = workRect;
}
{
const int xs = RECT_SIZE_X(rect);
const int ys = RECT_SIZE_Y(rect);
const int xs2 = RECT_SIZE_X(rect2);
const int ys2 = RECT_SIZE_Y(rect2);
// we don't want to change position if parent is smaller.
if (xs <= xs2 && ys <= ys2)
{
const int x = rect2.left + (xs2 - xs) / 2;
const int y = rect2.top + (ys2 - ys) / 2;
if (x != rect.left || y != rect.top)
Move(x, y, xs, ys, true);
// SetWindowPos(*this, HWND_TOP, x, y, 0, 0, SWP_NOSIZE);
return;
}
}
}
bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow)
{
HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
if (aHWND == 0)
const HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
if (!aHWND)
return false;
Attach(aHWND);
return true;

View File

@@ -1,7 +1,7 @@
// Windows/Control/Dialog.h
#ifndef __WINDOWS_CONTROL_DIALOG_H
#define __WINDOWS_CONTROL_DIALOG_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_DIALOG_H
#define ZIP7_INC_WINDOWS_CONTROL_DIALOG_H
#include "../Window.h"
@@ -10,65 +10,66 @@ namespace NControl {
class CDialog: public CWindow
{
// Z7_CLASS_NO_COPY(CDialog)
public:
CDialog(HWND wnd = NULL): CWindow(wnd){};
virtual ~CDialog() {};
CDialog(HWND wnd = NULL): CWindow(wnd) {}
virtual ~CDialog() {}
HWND GetItem(int itemID) const
{ return GetDlgItem(_window, itemID); }
HWND GetItem(unsigned itemID) const
{ return GetDlgItem(_window, (int)itemID); }
bool EnableItem(int itemID, bool enable) const
bool EnableItem(unsigned itemID, bool enable) const
{ return BOOLToBool(::EnableWindow(GetItem(itemID), BoolToBOOL(enable))); }
bool ShowItem(int itemID, int cmdShow) const
bool ShowItem(unsigned itemID, int cmdShow) const
{ return BOOLToBool(::ShowWindow(GetItem(itemID), cmdShow)); }
bool ShowItem_Bool(int itemID, bool show) const
bool ShowItem_Bool(unsigned itemID, bool show) const
{ return ShowItem(itemID, show ? SW_SHOW: SW_HIDE); }
bool HideItem(int itemID) const { return ShowItem(itemID, SW_HIDE); }
bool HideItem(unsigned itemID) const { return ShowItem(itemID, SW_HIDE); }
bool SetItemText(int itemID, LPCTSTR s)
{ return BOOLToBool(SetDlgItemText(_window, itemID, s)); }
bool SetItemText(unsigned itemID, LPCTSTR s)
{ return BOOLToBool(SetDlgItemText(_window, (int)itemID, s)); }
bool SetItemTextA(int itemID, LPCSTR s)
{ return BOOLToBool(SetDlgItemTextA(_window, itemID, s)); }
bool SetItemTextA(unsigned itemID, LPCSTR s)
{ return BOOLToBool(SetDlgItemTextA(_window, (int)itemID, s)); }
bool SetItemText_Empty(int itemID)
bool SetItemText_Empty(unsigned itemID)
{ return SetItemText(itemID, TEXT("")); }
#ifndef _UNICODE
bool SetItemText(int itemID, LPCWSTR s)
bool SetItemText(unsigned 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); }
UINT GetItemText(unsigned itemID, LPTSTR string, unsigned maxCount)
{ return GetDlgItemText(_window, (int)itemID, string, (int)maxCount); }
#ifndef _UNICODE
/*
bool GetItemText(int itemID, LPWSTR string, int maxCount)
bool GetItemText(unsigned itemID, LPWSTR string, int maxCount)
{
CWindow window(GetItem(itemID));
CWindow window(GetItem(unsigned));
return window.GetText(string, maxCount);
}
*/
#endif
bool GetItemText(int itemID, UString &s)
bool GetItemText(unsigned itemID, UString &s)
{
CWindow window(GetItem(itemID));
return window.GetText(s);
}
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 SetItemInt(unsigned itemID, UINT value, bool isSigned)
{ return BOOLToBool(SetDlgItemInt(_window, (int)itemID, value, BoolToBOOL(isSigned))); }
bool GetItemInt(unsigned itemID, bool isSigned, UINT &value)
{
BOOL result;
value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned));
value = GetDlgItemInt(_window, (int)itemID, &result, BoolToBOOL(isSigned));
return BOOLToBool(result);
}
@@ -80,7 +81,7 @@ public:
LRESULT SendMsg_NextDlgCtl(WPARAM wParam, LPARAM lParam)
{ return SendMsg(WM_NEXTDLGCTL, wParam, lParam); }
LRESULT SendMsg_NextDlgCtl_HWND(HWND hwnd) { return SendMsg_NextDlgCtl((WPARAM)hwnd, TRUE); }
LRESULT SendMsg_NextDlgCtl_CtlId(int id) { return SendMsg_NextDlgCtl_HWND(GetItem(id)); }
LRESULT SendMsg_NextDlgCtl_CtlId(unsigned id) { return SendMsg_NextDlgCtl_HWND(GetItem(id)); }
LRESULT SendMsg_NextDlgCtl_Next() { return SendMsg_NextDlgCtl(0, FALSE); }
LRESULT SendMsg_NextDlgCtl_Prev() { return SendMsg_NextDlgCtl(1, FALSE); }
@@ -90,26 +91,27 @@ public:
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); }
LRESULT SendItemMessage(unsigned itemID, UINT message, WPARAM wParam, LPARAM lParam)
{ return SendDlgItemMessage(_window, (int)itemID, message, wParam, lParam); }
bool CheckButton(int buttonID, UINT checkState)
{ return BOOLToBool(CheckDlgButton(_window, buttonID, checkState)); }
bool CheckButton(int buttonID, bool checkState)
bool CheckButton(unsigned buttonID, UINT checkState)
{ return BOOLToBool(CheckDlgButton(_window, (int)buttonID, checkState)); }
bool CheckButton(unsigned 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); }
UINT IsButtonChecked_BST(unsigned buttonID) const
{ return IsDlgButtonChecked(_window, (int)buttonID); }
bool IsButtonCheckedBool(unsigned buttonID) const
{ return (IsButtonChecked_BST(buttonID) == BST_CHECKED); }
bool CheckRadioButton(int firstButtonID, int lastButtonID, int checkButtonID)
{ return BOOLToBool(::CheckRadioButton(_window, firstButtonID, lastButtonID, checkButtonID)); }
bool CheckRadioButton(unsigned firstButtonID, unsigned lastButtonID, unsigned checkButtonID)
{ return BOOLToBool(::CheckRadioButton(_window,
(int)firstButtonID, (int)lastButtonID, (int)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 bool OnCommand2(WPARAM wParam, LPARAM lParam);
virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam);
virtual bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; }
virtual bool OnDestroy() { return false; }
@@ -120,11 +122,11 @@ public:
virtual void OnHelp(LPHELPINFO) { OnHelp(); }
#endif
*/
virtual void OnHelp() {};
virtual void OnHelp() {}
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
virtual void OnOK() {};
virtual void OnCancel() {};
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND);
virtual void OnOK() {}
virtual void OnCancel() {}
virtual void OnClose() {}
virtual bool OnNotify(UINT /* controlID */, LPNMHDR /* lParam */) { return false; }
virtual bool OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { return false; }
@@ -136,9 +138,11 @@ public:
bool GetMargins(int margin, int &x, int &y);
int Units_To_Pixels_X(int units);
bool GetItemSizes(int id, int &x, int &y);
void GetClientRectOfItem(int id, RECT &rect);
bool MoveItem(int id, int x, int y, int width, int height, bool repaint = true);
bool GetItemSizes(unsigned id, int &x, int &y);
void GetClientRectOfItem(unsigned id, RECT &rect);
bool MoveItem(unsigned id, int x, int y, int width, int height, bool repaint = true);
bool MoveItem_RECT(unsigned id, const RECT &r, bool repaint = true)
{ return MoveItem(id, r.left, r.top, RECT_SIZE_X(r), RECT_SIZE_Y(r), repaint); }
void NormalizeSize(bool fullNormalize = false);
void NormalizePosition();
@@ -152,9 +156,9 @@ public:
#ifndef _UNICODE
bool Create(LPCWSTR templateName, HWND parentWindow);
#endif
virtual void OnOK() { Destroy(); }
virtual void OnCancel() { Destroy(); }
virtual void OnClose() { Destroy(); }
virtual void OnOK() Z7_override { Destroy(); }
virtual void OnCancel() Z7_override { Destroy(); }
virtual void OnClose() Z7_override { Destroy(); }
};
class CModalDialog: public CDialog
@@ -167,23 +171,23 @@ public:
#endif
bool End(INT_PTR result) { return BOOLToBool(::EndDialog(_window, result)); }
virtual void OnOK() { End(IDOK); }
virtual void OnCancel() { End(IDCANCEL); }
virtual void OnClose() { End(IDCLOSE); }
virtual void OnOK() Z7_override { End(IDOK); }
virtual void OnCancel() Z7_override { End(IDCANCEL); }
virtual void OnClose() Z7_override { End(IDCLOSE); }
};
class CDialogChildControl: public NWindows::CWindow
{
int m_ID;
// unsigned m_ID;
public:
void Init(const NWindows::NControl::CDialog &parentDialog, int id)
void Init(const NWindows::NControl::CDialog &parentDialog, unsigned id)
{
m_ID = id;
// m_ID = id;
Attach(parentDialog.GetItem(id));
}
};
bool IsDialogSizeOK(int xSize, int ySize);
bool IsDialogSizeOK(int xSize, int ySize, HWND hwnd = NULL);
}}

View File

@@ -1,7 +1,7 @@
// Windows/Control/Edit.h
#ifndef __WINDOWS_CONTROL_EDIT_H
#define __WINDOWS_CONTROL_EDIT_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_EDIT_H
#define ZIP7_INC_WINDOWS_CONTROL_EDIT_H
#include "../Window.h"

View File

@@ -1,7 +1,7 @@
// Windows/Control/ImageList.h
#ifndef __WINDOWS_CONTROL_IMAGE_LIST_H
#define __WINDOWS_CONTROL_IMAGE_LIST_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_IMAGE_LIST_H
#define ZIP7_INC_WINDOWS_CONTROL_IMAGE_LIST_H
#include <CommCtrl.h>
@@ -56,7 +56,7 @@ public:
bool GetImageInfo(int index, IMAGEINFO* imageInfo) const
{ return BOOLToBool(ImageList_GetImageInfo(m_Object, index, imageInfo)); }
int Add(HBITMAP hbmImage, HBITMAP hbmMask = 0)
int Add(HBITMAP hbmImage, HBITMAP hbmMask = NULL)
{ return ImageList_Add(m_Object, hbmImage, hbmMask); }
int AddMasked(HBITMAP hbmImage, COLORREF mask)
{ return ImageList_AddMasked(m_Object, hbmImage, mask); }

View File

@@ -20,78 +20,85 @@ bool CListView::CreateEx(DWORD exStyle, DWORD style,
height, parentWindow, idOrHMenu, instance, createParam);
}
bool CListView::GetItemParam(int index, LPARAM &param) const
/* note: LVITEM and LVCOLUMN structures contain optional fields
depending from preprocessor macros:
#if (_WIN32_IE >= 0x0300)
#if (_WIN32_WINNT >= 0x0501)
#if (_WIN32_WINNT >= 0x0600)
*/
bool CListView::GetItemParam(unsigned index, LPARAM &param) const
{
LVITEM item;
item.iItem = index;
item.iItem = (int)index;
item.iSubItem = 0;
item.mask = LVIF_PARAM;
bool aResult = GetItem(&item);
const bool res = GetItem(&item);
param = item.lParam;
return aResult;
return res;
}
int CListView::InsertColumn(int columnIndex, LPCTSTR text, int width)
int CListView::InsertColumn(unsigned columnIndex, LPCTSTR text, int width)
{
LVCOLUMN ci;
ci.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
ci.pszText = (LPTSTR)(void *)text;
ci.iSubItem = columnIndex;
ci.iSubItem = (int)columnIndex;
ci.cx = width;
return InsertColumn(columnIndex, &ci);
}
int CListView::InsertItem(int index, LPCTSTR text)
int CListView::InsertItem(unsigned index, LPCTSTR text)
{
LVITEM item;
item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = index;
item.lParam = index;
item.iItem = (int)index;
item.lParam = (LPARAM)index;
item.pszText = (LPTSTR)(void *)text;
item.iSubItem = 0;
return InsertItem(&item);
}
int CListView::SetSubItem(int index, int subIndex, LPCTSTR text)
int CListView::SetSubItem(unsigned index, unsigned subIndex, LPCTSTR text)
{
LVITEM item;
item.mask = LVIF_TEXT;
item.iItem = index;
item.iItem = (int)index;
item.pszText = (LPTSTR)(void *)text;
item.iSubItem = subIndex;
item.iSubItem = (int)subIndex;
return SetItem(&item);
}
#ifndef _UNICODE
int CListView::InsertColumn(int columnIndex, LPCWSTR text, int width)
int CListView::InsertColumn(unsigned columnIndex, LPCWSTR text, int width)
{
LVCOLUMNW ci;
ci.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
ci.pszText = (LPWSTR)(void *)text;
ci.iSubItem = columnIndex;
ci.iSubItem = (int)columnIndex;
ci.cx = width;
return InsertColumn(columnIndex, &ci);
}
int CListView::InsertItem(int index, LPCWSTR text)
int CListView::InsertItem(unsigned index, LPCWSTR text)
{
LVITEMW item;
item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = index;
item.lParam = index;
item.iItem = (int)index;
item.lParam = (LPARAM)index;
item.pszText = (LPWSTR)(void *)text;
item.iSubItem = 0;
return InsertItem(&item);
}
int CListView::SetSubItem(int index, int subIndex, LPCWSTR text)
int CListView::SetSubItem(unsigned index, unsigned subIndex, LPCWSTR text)
{
LVITEMW item;
item.mask = LVIF_TEXT;
item.iItem = index;
item.iItem = (int)index;
item.pszText = (LPWSTR)(void *)text;
item.iSubItem = subIndex;
item.iSubItem = (int)subIndex;
return SetItem(&item);
}

View File

@@ -1,7 +1,7 @@
// Windows/Control/ListView.h
#ifndef __WINDOWS_CONTROL_LISTVIEW_H
#define __WINDOWS_CONTROL_LISTVIEW_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
#define ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
#include "../../Common/MyWindows.h"
@@ -28,11 +28,11 @@ public:
}
bool DeleteAllItems() { return BOOLToBool(ListView_DeleteAllItems(_window)); }
bool DeleteColumn(int columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
bool DeleteColumn(unsigned columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
int InsertColumn(int columnIndex, LPCTSTR text, int width);
bool SetColumnOrderArray(int count, const int *columns)
int InsertColumn(unsigned columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
int InsertColumn(unsigned columnIndex, LPCTSTR text, int width);
bool SetColumnOrderArray(unsigned count, const int *columns)
{ return BOOLToBool(ListView_SetColumnOrderArray(_window, count, (int *)(void *)columns)); }
/*
@@ -46,43 +46,49 @@ public:
*/
int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
int InsertItem(int index, LPCTSTR text);
int InsertItem(unsigned index, LPCTSTR text);
bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }
int SetSubItem(int index, int subIndex, LPCTSTR text);
int SetSubItem(unsigned index, unsigned subIndex, LPCTSTR text);
#ifndef _UNICODE
int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMsg(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
int InsertColumn(int columnIndex, LPCWSTR text, int width);
int InsertColumn(unsigned columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMsg(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
int InsertColumn(unsigned columnIndex, LPCWSTR text, int width);
int InsertItem(const LV_ITEMW* item) { return (int)SendMsg(LVM_INSERTITEMW, 0, (LPARAM)item); }
int InsertItem(int index, LPCWSTR text);
int InsertItem(unsigned index, LPCWSTR text);
bool SetItem(const LV_ITEMW* item) { return BOOLToBool((BOOL)SendMsg(LVM_SETITEMW, 0, (LPARAM)item)); }
int SetSubItem(int index, int subIndex, LPCWSTR text);
int SetSubItem(unsigned index, unsigned subIndex, LPCWSTR text);
#endif
bool DeleteItem(int itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
bool DeleteItem(unsigned 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); }
void SetItemCount(unsigned numItems) { ListView_SetItemCount(_window, numItems); }
void SetItemCountEx(unsigned numItems, DWORD flags) { ListView_SetItemCountEx(_window, numItems, flags); }
/* startIndex : The index of the item with which to begin the search,
or -1 to find the first item that matches the specified flags.
The specified item itself is excluded from the search. */
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 subItemIndex, LPTSTR text, int textSizeMax) const
{ ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax); }
bool GetItemParam(unsigned itemIndex, LPARAM &param) const;
/*
void GetItemText(unsigned itemIndex, unsigned subItemIndex, LPTSTR text, unsigned 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); }
// If (index == -1), then the state change is applied to all items.
void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask) }
void SetItemState_Selected(int index, bool select) { SetItemState(index, select ? LVIS_SELECTED : 0, LVIS_SELECTED); }
void SetItemState_Selected(int index) { SetItemState(index, LVIS_SELECTED, LVIS_SELECTED); }
void SelectAll() { SetItemState_Selected(-1); }
@@ -90,7 +96,7 @@ public:
UINT GetItemState(int index, UINT mask) const { return ListView_GetItemState(_window, index, mask); }
bool IsItemSelected(int index) const { return GetItemState(index, LVIS_SELECTED) == LVIS_SELECTED; }
bool GetColumn(int columnIndex, LVCOLUMN* columnInfo) const
bool GetColumn(unsigned columnIndex, LVCOLUMN* columnInfo) const
{ return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
HIMAGELIST SetImageList(HIMAGELIST imageList, int imageListType)
@@ -101,7 +107,7 @@ public:
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)); }
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))); }
@@ -129,7 +135,10 @@ public:
class CListView2: public CListView
{
WNDPROC _origWindowProc;
// ~CListView2() ZIP7_eq_delete;
public:
virtual ~CListView2() {}
CListView2() {}
void SetWindowProc();
virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
};

View File

@@ -1,7 +1,7 @@
// Windows/Control/ProgressBar.h
#ifndef __WINDOWS_CONTROL_PROGRESSBAR_H
#define __WINDOWS_CONTROL_PROGRESSBAR_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_PROGRESSBAR_H
#define ZIP7_INC_WINDOWS_CONTROL_PROGRESSBAR_H
#include "../../Common/MyWindows.h"
@@ -15,18 +15,18 @@ namespace NControl {
class CProgressBar: public CWindow
{
public:
LRESULT SetPos(int pos) { return SendMsg(PBM_SETPOS, pos, 0); }
LRESULT DeltaPos(int increment) { return SendMsg(PBM_DELTAPOS, increment, 0); }
UINT GetPos() { return (UINT)SendMsg(PBM_GETPOS, 0, 0); }
LRESULT SetRange(unsigned short minValue, unsigned short maxValue) { return SendMsg(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); }
DWORD SetRange32(int minValue, int maxValue) { return (DWORD)SendMsg(PBM_SETRANGE32, minValue, maxValue); }
int SetStep(int step) { return (int)SendMsg(PBM_SETSTEP, step, 0); }
LRESULT StepIt() { return SendMsg(PBM_STEPIT, 0, 0); }
INT GetRange(bool minValue, PPBRANGE range) { return (INT)SendMsg(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); }
LRESULT SetPos(int pos) { return SendMsg(PBM_SETPOS, (unsigned)pos, 0); }
// LRESULT DeltaPos(int increment) { return SendMsg(PBM_DELTAPOS, increment, 0); }
// UINT GetPos() { return (UINT)SendMsg(PBM_GETPOS, 0, 0); }
// LRESULT SetRange(unsigned short minValue, unsigned short maxValue) { return SendMsg(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); }
DWORD SetRange32(int minValue, int maxValue) { return (DWORD)SendMsg(PBM_SETRANGE32, (unsigned)minValue, (LPARAM)(unsigned)maxValue); }
// int SetStep(int step) { return (int)SendMsg(PBM_SETSTEP, step, 0); }
// LRESULT StepIt() { return SendMsg(PBM_STEPIT, 0, 0); }
// INT GetRange(bool minValue, PPBRANGE range) { return (INT)SendMsg(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); }
#ifndef UNDER_CE
COLORREF SetBarColor(COLORREF color) { return (COLORREF)SendMsg(PBM_SETBARCOLOR, 0, color); }
COLORREF SetBackgroundColor(COLORREF color) { return (COLORREF)SendMsg(PBM_SETBKCOLOR, 0, color); }
COLORREF SetBarColor(COLORREF color) { return (COLORREF)SendMsg(PBM_SETBARCOLOR, 0, (LPARAM)color); }
COLORREF SetBackgroundColor(COLORREF color) { return (COLORREF)SendMsg(PBM_SETBKCOLOR, 0, (LPARAM)color); }
#endif
};

View File

@@ -16,7 +16,13 @@ extern bool g_IsNT;
namespace NWindows {
namespace NControl {
static INT_PTR APIENTRY MyProperyPageProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
static
#ifdef Z7_OLD_WIN_SDK
BOOL
#else
INT_PTR
#endif
APIENTRY MyProperyPageProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
{
CWindow tempDialog(dialogHWND);
if (message == WM_INITDIALOG)
@@ -34,75 +40,91 @@ 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;
case PSN_APPLY: SetMsgResult(OnApply2(LPPSHNOTIFY(lParam))); break;
case PSN_KILLACTIVE: SetMsgResult(BoolToBOOL(OnKillActive2(LPPSHNOTIFY(lParam)))); break;
case PSN_SETACTIVE: SetMsgResult(OnSetActive2(LPPSHNOTIFY(lParam))); break;
case PSN_RESET: OnReset2(LPPSHNOTIFY(lParam)); break;
case PSN_HELP: OnNotifyHelp2(LPPSHNOTIFY(lParam)); break;
default: return false;
}
return true;
}
/*
PROPSHEETPAGE fields depend from
#if (_WIN32_WINNT >= 0x0600)
#elif (_WIN32_WINNT >= 0x0501)
#elif (_WIN32_IE >= 0x0400)
PROPSHEETHEADER fields depend from
#if (_WIN32_IE >= 0x0400)
*/
#if defined(PROPSHEETPAGEA_V1_SIZE) && !defined(Z7_OLD_WIN_SDK)
#ifndef _UNICODE
#define my_compatib_PROPSHEETPAGEA PROPSHEETPAGEA_V1
#endif
#define my_compatib_PROPSHEETPAGEW PROPSHEETPAGEW_V1
#else
// for old mingw:
#ifndef _UNICODE
#define my_compatib_PROPSHEETPAGEA PROPSHEETPAGEA
#endif
#define my_compatib_PROPSHEETPAGEW PROPSHEETPAGEW
#endif
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;
unsigned i;
#ifndef _UNICODE
AStringVector titles;
for (i = 0; i < pagesInfo.Size(); i++)
titles.Add(GetSystemString(pagesInfo[i].Title));
CRecordVector<my_compatib_PROPSHEETPAGEA> pagesA;
#endif
CRecordVector<my_compatib_PROPSHEETPAGEW> pagesW;
for (i = 0; i < pagesInfo.Size(); i++)
{
const CPageInfo &pageInfo = pagesInfo[i];
#ifndef _UNICODE
{
PROPSHEETPAGE page;
my_compatib_PROPSHEETPAGEA page;
memset(&page, 0, sizeof(page));
page.dwSize = sizeof(page);
page.dwFlags = PSP_HASHELP;
page.hInstance = g_hInstance;
page.pszTemplate = MAKEINTRESOURCE(pageInfo.ID);
page.pszIcon = NULL;
page.pszTemplate = MAKEINTRESOURCEA(pageInfo.ID);
// page.pszIcon = NULL;
page.pfnDlgProc = NWindows::NControl::MyProperyPageProcedure;
if (titles[i].IsEmpty())
page.pszTitle = NULL;
else
if (!titles[i].IsEmpty())
{
page.dwFlags |= PSP_USETITLE;
page.pszTitle = titles[i];
page.dwFlags |= PSP_USETITLE;
}
// else page.pszTitle = NULL;
page.lParam = (LPARAM)pageInfo.Page;
page.pfnCallback = NULL;
// page.pfnCallback = NULL;
pagesA.Add(page);
}
#endif
{
PROPSHEETPAGEW page;
my_compatib_PROPSHEETPAGEW page;
memset(&page, 0, sizeof(page));
page.dwSize = sizeof(page);
page.dwFlags = PSP_HASHELP;
page.hInstance = g_hInstance;
page.pszTemplate = MAKEINTRESOURCEW(pageInfo.ID);
page.pszIcon = NULL;
// page.pszIcon = NULL;
page.pfnDlgProc = NWindows::NControl::MyProperyPageProcedure;
if (pageInfo.Title.IsEmpty())
page.pszTitle = NULL;
else
if (!pageInfo.Title.IsEmpty())
{
page.dwFlags |= PSP_USETITLE;
page.pszTitle = pageInfo.Title;
page.dwFlags |= PSP_USETITLE;
}
// else page.pszTitle = NULL;
page.lParam = (LPARAM)pageInfo.Page;
page.pfnCallback = NULL;
// page.pfnCallback = NULL;
pagesW.Add(page);
}
}
@@ -110,16 +132,16 @@ INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndPare
#ifndef _UNICODE
if (!g_IsNT)
{
PROPSHEETHEADER sheet;
PROPSHEETHEADERA 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.nPages = pagesA.Size();
sheet.nStartPage = 0;
sheet.ppsp = &pagesA.Front();
sheet.ppsp = (LPCPROPSHEETPAGEA)(const void *)&pagesA.Front();
sheet.pfnCallback = NULL;
return ::PropertySheetA(&sheet);
}
@@ -132,9 +154,9 @@ INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndPare
sheet.hwndParent = hwndParent;
sheet.hInstance = g_hInstance;
sheet.pszCaption = title;
sheet.nPages = pagesInfo.Size();
sheet.nPages = pagesW.Size();
sheet.nStartPage = 0;
sheet.ppsp = &pagesW.Front();
sheet.ppsp = (LPCPROPSHEETPAGEW)(const void *)&pagesW.Front();
sheet.pfnCallback = NULL;
return ::PropertySheetW(&sheet);
}

View File

@@ -1,11 +1,11 @@
// Windows/Control/PropertyPage.h
#ifndef __WINDOWS_CONTROL_PROPERTYPAGE_H
#define __WINDOWS_CONTROL_PROPERTYPAGE_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_PROPERTYPAGE_H
#define ZIP7_INC_WINDOWS_CONTROL_PROPERTYPAGE_H
#include "../../Common/MyWindows.h"
#include <PrSht.h>
#include <prsht.h>
#include "Dialog.h"
@@ -17,23 +17,23 @@ INT_PTR APIENTRY ProperyPageProcedure(HWND dialogHWND, UINT message, WPARAM wPar
class CPropertyPage: public CDialog
{
public:
CPropertyPage(HWND window = NULL): CDialog(window){};
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 OnNotify(UINT controlID, LPNMHDR lParam) Z7_override;
virtual bool OnKillActive() { return false; } // false = OK
virtual bool OnKillActive(const PSHNOTIFY *) { return OnKillActive(); }
virtual bool OnKillActive2(const PSHNOTIFY *) { return OnKillActive(); }
virtual LONG OnSetActive() { return false; } // false = OK
virtual LONG OnSetActive(const PSHNOTIFY *) { return OnSetActive(); }
virtual LONG OnSetActive2(const PSHNOTIFY *) { return OnSetActive(); }
virtual LONG OnApply() { return PSNRET_NOERROR; }
virtual LONG OnApply(const PSHNOTIFY *) { return OnApply(); }
virtual LONG OnApply2(const PSHNOTIFY *) { return OnApply(); }
virtual void OnNotifyHelp() {}
virtual void OnNotifyHelp(const PSHNOTIFY *) { OnNotifyHelp(); }
virtual void OnNotifyHelp2(const PSHNOTIFY *) { OnNotifyHelp(); }
virtual void OnReset() {}
virtual void OnReset(const PSHNOTIFY *) { OnReset(); }
virtual void OnReset2(const PSHNOTIFY *) { OnReset(); }
};
struct CPageInfo

View File

@@ -1,7 +1,7 @@
// Windows/Control/ReBar.h
#ifndef __WINDOWS_CONTROL_REBAR_H
#define __WINDOWS_CONTROL_REBAR_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_REBAR_H
#define ZIP7_INC_WINDOWS_CONTROL_REBAR_H
#include "../Window.h"
@@ -14,7 +14,7 @@ public:
bool SetBarInfo(LPREBARINFO barInfo)
{ return LRESULTToBool(SendMsg(RB_SETBARINFO, 0, (LPARAM)barInfo)); }
bool InsertBand(int index, LPREBARBANDINFO bandInfo)
{ return LRESULTToBool(SendMsg(RB_INSERTBAND, index, (LPARAM)bandInfo)); }
{ return LRESULTToBool(SendMsg(RB_INSERTBAND, MY_int_TO_WPARAM(index), (LPARAM)bandInfo)); }
bool SetBandInfo(unsigned index, LPREBARBANDINFO bandInfo)
{ return LRESULTToBool(SendMsg(RB_SETBANDINFO, index, (LPARAM)bandInfo)); }
void MaximizeBand(unsigned index, bool ideal)

View File

@@ -1,7 +1,7 @@
// Windows/Control/Static.h
#ifndef __WINDOWS_CONTROL_STATIC_H
#define __WINDOWS_CONTROL_STATIC_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_STATIC_H
#define ZIP7_INC_WINDOWS_CONTROL_STATIC_H
#include "../Window.h"

View File

@@ -1,7 +1,7 @@
// Windows/Control/StatusBar.h
#ifndef __WINDOWS_CONTROL_STATUSBAR_H
#define __WINDOWS_CONTROL_STATUSBAR_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_STATUSBAR_H
#define ZIP7_INC_WINDOWS_CONTROL_STATUSBAR_H
#include "../Window.h"
@@ -12,7 +12,7 @@ class CStatusBar: public NWindows::CWindow
{
public:
bool Create(LONG style, LPCTSTR text, HWND hwndParent, UINT id)
{ return (_window = ::CreateStatusWindow(style, text, hwndParent, id)) != 0; }
{ return (_window = ::CreateStatusWindow(style, text, hwndParent, id)) != NULL; }
bool SetText(LPCTSTR text)
{ return CWindow::SetText(text); }
bool SetText(unsigned index, LPCTSTR text, UINT type)
@@ -22,7 +22,7 @@ public:
#ifndef _UNICODE
bool Create(LONG style, LPCWSTR text, HWND hwndParent, UINT id)
{ return (_window = ::CreateStatusWindowW(style, text, hwndParent, id)) != 0; }
{ return (_window = ::CreateStatusWindowW(style, text, hwndParent, id)) != NULL; }
bool SetText(LPCWSTR text)
{ return CWindow::SetText(text); }
bool SetText(unsigned index, LPCWSTR text, UINT type)
@@ -34,7 +34,7 @@ public:
bool SetParts(unsigned numParts, const int *edgePostions)
{ return LRESULTToBool(SendMsg(SB_SETPARTS, numParts, (LPARAM)edgePostions)); }
void Simple(bool simple)
{ SendMsg(SB_SIMPLE, BoolToBOOL(simple), 0); }
{ SendMsg(SB_SIMPLE, (WPARAM)BoolToBOOL(simple), 0); }
};
}}

View File

@@ -1,8 +1,11 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#ifndef ZIP7_INC_STDAFX_H
#define ZIP7_INC_STDAFX_H
#if defined(_MSC_VER) && _MSC_VER >= 1800
#pragma warning(disable : 4464) // relative include path contains '..'
#endif
#include "../../Common/Common.h"
#endif

View File

@@ -1,7 +1,7 @@
// Windows/Control/ToolBar.h
#ifndef __WINDOWS_CONTROL_TOOLBAR_H
#define __WINDOWS_CONTROL_TOOLBAR_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_TOOLBAR_H
#define ZIP7_INC_WINDOWS_CONTROL_TOOLBAR_H
#include "../Window.h"
@@ -18,7 +18,7 @@ public:
#ifdef UNDER_CE
{
// maybe it must be fixed for more than 1 buttons
DWORD val = GetButtonSize();
const DWORD val = GetButtonSize();
size->cx = LOWORD(val);
size->cy = HIWORD(val);
return true;

View File

@@ -1,7 +1,7 @@
// Windows/Control/Trackbar.h
#ifndef __WINDOWS_CONTROL_TRACKBAR_H
#define __WINDOWS_CONTROL_TRACKBAR_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_TRACKBAR_H
#define ZIP7_INC_WINDOWS_CONTROL_TRACKBAR_H
#include "../Window.h"

View File

@@ -32,9 +32,9 @@ static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message, WPARAM wParam,
if (message == MY_START_WM_CREATE)
tempWindow.SetUserDataLongPtr((LONG_PTR)(((LPCREATESTRUCT)lParam)->lpCreateParams));
CWindow2 *window = (CWindow2 *)(tempWindow.GetUserDataLongPtr());
if (window != NULL && message == MY_START_WM_CREATE)
if (window && message == MY_START_WM_CREATE)
window->Attach(aHWND);
if (window == 0)
if (!window)
{
#ifndef _UNICODE
if (g_IsNT)
@@ -140,7 +140,7 @@ LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return -1;
break;
case WM_COMMAND:
if (OnCommand(wParam, lParam, result))
if (OnCommand(HIWORD(wParam), LOWORD(wParam), lParam, result))
return result;
break;
case WM_NOTIFY:
@@ -160,12 +160,14 @@ LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return DefProc(message, wParam, lParam);
}
bool CWindow2::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result)
/*
bool CWindow2::OnCommand2(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 */)
bool CWindow2::OnCommand(unsigned /* code */, unsigned /* itemID */, LPARAM /* lParam */, LRESULT & /* result */)
{
return false;
// return DefProc(message, wParam, lParam);
@@ -176,7 +178,7 @@ bool CWindow2::OnCommand(int /* code */, int /* itemID */, LPARAM /* lParam */,
}
/*
bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
bool CDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
switch (buttonID)
{

View File

@@ -1,7 +1,7 @@
// Windows/Control/Window2.h
#ifndef __WINDOWS_CONTROL_WINDOW2_H
#define __WINDOWS_CONTROL_WINDOW2_H
#ifndef ZIP7_INC_WINDOWS_CONTROL_WINDOW2_H
#define ZIP7_INC_WINDOWS_CONTROL_WINDOW2_H
#include "../Window.h"
@@ -10,10 +10,12 @@ namespace NControl {
class CWindow2: public CWindow
{
// Z7_CLASS_NO_COPY(CWindow2)
LRESULT DefProc(UINT message, WPARAM wParam, LPARAM lParam);
public:
CWindow2(HWND newWindow = NULL): CWindow(newWindow){};
virtual ~CWindow2() {};
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,
@@ -28,8 +30,8 @@ public:
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);
// bool OnCommand2(WPARAM wParam, LPARAM lParam, LRESULT &result);
virtual bool OnCommand(unsigned code, unsigned 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); }
@@ -37,7 +39,7 @@ public:
/*
virtual LRESULT OnHelp(LPHELPINFO helpInfo) { OnHelp(); }
virtual LRESULT OnHelp() {};
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND);
virtual void OnOK() {};
virtual void OnCancel() {};
*/