chore: initial commit (extracted from Launchers monorepo)
Plugin: ns7zip v2.0.0 Architectures: x86-ansi, x86-unicode, amd64-unicode License: LGPL-2.1-or-later
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
// Windows/Control/ComboBox.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
#include "../../Common/StringConvert.h"
|
||||
#endif
|
||||
|
||||
#include "ComboBox.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); // length, excluding the terminating null character
|
||||
if (len == CB_ERR)
|
||||
return len;
|
||||
LRESULT len2 = GetLBText(index, s.GetBuf((unsigned)len));
|
||||
if (len2 == CB_ERR)
|
||||
return len;
|
||||
if (len > len2)
|
||||
len = len2;
|
||||
s.ReleaseBuf_CalcLen((unsigned)len);
|
||||
return len;
|
||||
}
|
||||
|
||||
#ifndef _UNICODE
|
||||
LRESULT CComboBox::AddString(LPCWSTR s)
|
||||
{
|
||||
if (g_IsNT)
|
||||
return SendMsgW(CB_ADDSTRING, 0, (LPARAM)s);
|
||||
return AddString(GetSystemString(s));
|
||||
}
|
||||
|
||||
LRESULT CComboBox::GetLBText(int index, UString &s)
|
||||
{
|
||||
s.Empty();
|
||||
if (g_IsNT)
|
||||
{
|
||||
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));
|
||||
if (len2 == CB_ERR)
|
||||
return len;
|
||||
if (len > len2)
|
||||
len = len2;
|
||||
s.ReleaseBuf_CalcLen((unsigned)len);
|
||||
return len;
|
||||
}
|
||||
AString sa;
|
||||
const LRESULT len = GetLBText(index, sa);
|
||||
if (len == CB_ERR)
|
||||
return len;
|
||||
s = GetUnicodeString(sa);
|
||||
return (LRESULT)s.Len();
|
||||
}
|
||||
#endif
|
||||
|
||||
LRESULT CComboBox::AddString_SetItemData(LPCWSTR s, LPARAM lParam)
|
||||
{
|
||||
const LRESULT index = AddString(s);
|
||||
// NOTE: SetItemData((int)-1, lParam) works as unexpected.
|
||||
if (index >= 0) // optional check, because (index < 0) is not expected for normal inputs
|
||||
SetItemData((int)index, lParam);
|
||||
return index;
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,79 @@
|
||||
// Windows/Control/ComboBox.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_COMBOBOX_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_COMBOBOX_H
|
||||
|
||||
#include "../../Common/MyWindows.h"
|
||||
|
||||
#include <CommCtrl.h>
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
class CComboBox: public CWindow
|
||||
{
|
||||
public:
|
||||
void ResetContent() { SendMsg(CB_RESETCONTENT, 0, 0); }
|
||||
LRESULT AddString(LPCTSTR s) { return SendMsg(CB_ADDSTRING, 0, (LPARAM)s); }
|
||||
#ifndef _UNICODE
|
||||
LRESULT AddString(LPCWSTR s);
|
||||
#endif
|
||||
|
||||
LRESULT AddString_SetItemData(LPCWSTR s, LPARAM lParam);
|
||||
|
||||
/* 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(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); }
|
||||
|
||||
/* 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 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 GetItemData(unsigned index) { return SendMsg(CB_GETITEMDATA, index, 0); }
|
||||
|
||||
LRESULT GetItemData_of_CurSel() { return GetItemData(GetCurSel()); }
|
||||
|
||||
void ShowDropDown(bool show = true) { SendMsg(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); }
|
||||
};
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
class CComboBoxEx: public CComboBox
|
||||
{
|
||||
public:
|
||||
bool SetUnicodeFormat(bool fUnicode) { return LRESULTToBool(SendMsg(CBEM_SETUNICODEFORMAT, BOOLToBool(fUnicode), 0)); }
|
||||
|
||||
/* 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 InsertItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_INSERTITEM, 0, (LPARAM)item); }
|
||||
#ifndef _UNICODE
|
||||
LRESULT InsertItem(COMBOBOXEXITEMW *item) { return SendMsg(CBEM_INSERTITEMW, 0, (LPARAM)item); }
|
||||
#endif
|
||||
|
||||
LRESULT SetItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_SETITEM, 0, (LPARAM)item); }
|
||||
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); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
// Windows/Control/CommandBar.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_COMMANDBAR_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_COMMANDBAR_H
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
#include "../../Common/MyWindows.h"
|
||||
|
||||
#include <commctrl.h>
|
||||
|
||||
#include "../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(UINT numButtons, LPTBBUTTON buttons) { return BOOLToBool(SendMsg(TB_ADDBUTTONS, (WPARAM)numButtons, (LPARAM)buttons)); }
|
||||
// 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 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
|
||||
@@ -0,0 +1,446 @@
|
||||
// Windows/Control/Dialog.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
// #include "../../Windows/DLL.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
#include "../../Common/StringConvert.h"
|
||||
#endif
|
||||
|
||||
#include "Dialog.h"
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
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)
|
||||
tempDialog.SetUserDataLongPtr(lParam);
|
||||
CDialog *dialog = (CDialog *)(tempDialog.GetUserDataLongPtr());
|
||||
if (dialog == NULL)
|
||||
return FALSE;
|
||||
if (message == WM_INITDIALOG)
|
||||
dialog->Attach(dialogHWND);
|
||||
|
||||
/* MSDN: The dialog box procedure should return
|
||||
TRUE - if it processed the message
|
||||
FALSE - if it did not process the message
|
||||
If the dialog box procedure returns FALSE,
|
||||
the dialog manager performs the default dialog operation in response to the message.
|
||||
*/
|
||||
|
||||
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(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));
|
||||
case WM_DESTROY: return OnDestroy();
|
||||
case WM_HELP: OnHelp(); return true;
|
||||
/*
|
||||
OnHelp(
|
||||
#ifdef UNDER_CE
|
||||
(void *)
|
||||
#else
|
||||
(LPHELPINFO)
|
||||
#endif
|
||||
lParam);
|
||||
return true;
|
||||
*/
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bool CDialog::OnCommand2(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam);
|
||||
}
|
||||
*/
|
||||
|
||||
bool CDialog::OnCommand(unsigned code, unsigned itemID, LPARAM lParam)
|
||||
{
|
||||
if (code == BN_CLICKED)
|
||||
return OnButtonClicked(itemID, (HWND)lParam);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDialog::OnButtonClicked(unsigned buttonID, HWND /* buttonHWND */)
|
||||
{
|
||||
switch (buttonID)
|
||||
{
|
||||
case IDOK: OnOK(); break;
|
||||
case IDCANCEL: OnCancel(); break;
|
||||
case IDCLOSE: OnClose(); break;
|
||||
case IDCONTINUE: OnContinue(); break;
|
||||
case IDHELP: OnHelp(); break;
|
||||
default: return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#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
|
||||
{
|
||||
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, HWND hwnd)
|
||||
{
|
||||
// it returns for system font. Real font uses another values
|
||||
const LONG v = GetDialogBaseUnits();
|
||||
const int x = LOWORD(v);
|
||||
const int y = HIWORD(v);
|
||||
|
||||
RECT 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;
|
||||
}
|
||||
|
||||
bool CDialog::GetMargins(int margin, int &x, int &y)
|
||||
{
|
||||
x = margin;
|
||||
y = margin;
|
||||
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 CDialog::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 CDialog::GetItemSizes(unsigned id, int &x, int &y)
|
||||
{
|
||||
RECT rect;
|
||||
if (!::GetWindowRect(GetItem(id), &rect))
|
||||
return false;
|
||||
x = RECT_SIZE_X(rect);
|
||||
y = RECT_SIZE_Y(rect);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDialog::GetClientRectOfItem(unsigned id, RECT &rect)
|
||||
{
|
||||
::GetWindowRect(GetItem(id), &rect);
|
||||
ScreenToClient(&rect);
|
||||
}
|
||||
|
||||
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;
|
||||
if (!GetWorkAreaRect(&workRect, *this))
|
||||
return;
|
||||
RECT rect;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
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)
|
||||
{
|
||||
const HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
|
||||
if (!aHWND)
|
||||
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
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,213 @@
|
||||
// Windows/Control/Dialog.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_DIALOG_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_DIALOG_H
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
#ifndef IDCONTINUE
|
||||
#define IDCONTINUE 11
|
||||
#endif
|
||||
|
||||
class CDialog: public CWindow
|
||||
{
|
||||
// Z7_CLASS_NO_COPY(CDialog)
|
||||
public:
|
||||
CDialog(HWND wnd = NULL): CWindow(wnd) {}
|
||||
virtual ~CDialog() {}
|
||||
|
||||
HWND GetItem(unsigned itemID) const
|
||||
{ return GetDlgItem(_window, (int)itemID); }
|
||||
|
||||
bool EnableItem(unsigned itemID, bool enable) const
|
||||
{ return BOOLToBool(::EnableWindow(GetItem(itemID), BoolToBOOL(enable))); }
|
||||
|
||||
bool ShowItem(unsigned itemID, int cmdShow) const
|
||||
{ return BOOLToBool(::ShowWindow(GetItem(itemID), cmdShow)); }
|
||||
|
||||
bool ShowItem_Bool(unsigned itemID, bool show) const
|
||||
{ return ShowItem(itemID, show ? SW_SHOW: SW_HIDE); }
|
||||
|
||||
bool HideItem(unsigned itemID) const { return ShowItem(itemID, SW_HIDE); }
|
||||
|
||||
bool SetItemText(unsigned itemID, LPCTSTR s)
|
||||
{ return BOOLToBool(SetDlgItemText(_window, (int)itemID, s)); }
|
||||
|
||||
bool SetItemTextA(unsigned itemID, LPCSTR s)
|
||||
{ return BOOLToBool(SetDlgItemTextA(_window, (int)itemID, s)); }
|
||||
|
||||
bool SetItemText_Empty(unsigned itemID)
|
||||
{ return SetItemText(itemID, TEXT("")); }
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool SetItemText(unsigned itemID, LPCWSTR s)
|
||||
{
|
||||
CWindow window(GetItem(itemID));
|
||||
return window.SetText(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
UINT GetItemText(unsigned itemID, LPTSTR string, unsigned maxCount)
|
||||
{ return GetDlgItemText(_window, (int)itemID, string, (int)maxCount); }
|
||||
#ifndef _UNICODE
|
||||
/*
|
||||
bool GetItemText(unsigned itemID, LPWSTR string, int maxCount)
|
||||
{
|
||||
CWindow window(GetItem(unsigned));
|
||||
return window.GetText(string, maxCount);
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
bool GetItemText(unsigned itemID, UString &s)
|
||||
{
|
||||
CWindow window(GetItem(itemID));
|
||||
return window.GetText(s);
|
||||
}
|
||||
|
||||
/*
|
||||
bool SetItemInt(unsigned itemID, UINT value, bool isSigned)
|
||||
{ return BOOLToBool(SetDlgItemInt(_window, (int)itemID, value, BoolToBOOL(isSigned))); }
|
||||
*/
|
||||
bool SetItemUInt(unsigned itemID, UINT value)
|
||||
{ return BOOLToBool(SetDlgItemInt(_window, (int)itemID, value, FALSE)); }
|
||||
/*
|
||||
bool GetItemInt(unsigned itemID, bool isSigned, UINT &value)
|
||||
{
|
||||
BOOL result;
|
||||
value = GetDlgItemInt(_window, (int)itemID, &result, BoolToBOOL(isSigned));
|
||||
return BOOLToBool(result);
|
||||
}
|
||||
*/
|
||||
bool GetItemUInt(unsigned itemID, UINT &value)
|
||||
{
|
||||
BOOL result;
|
||||
value = GetDlgItemInt(_window, (int)itemID, &result, FALSE);
|
||||
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)); }
|
||||
|
||||
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(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); }
|
||||
|
||||
bool MapRect(LPRECT rect)
|
||||
{ return BOOLToBool(MapDialogRect(_window, rect)); }
|
||||
|
||||
bool IsMessage(LPMSG message)
|
||||
{ return BOOLToBool(IsDialogMessage(_window, message)); }
|
||||
|
||||
LRESULT SendItemMessage(unsigned itemID, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{ return SendDlgItemMessage(_window, (int)itemID, message, wParam, lParam); }
|
||||
|
||||
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_BST(unsigned buttonID) const
|
||||
{ return IsDlgButtonChecked(_window, (int)buttonID); }
|
||||
bool IsButtonCheckedBool(unsigned buttonID) const
|
||||
{ return (IsButtonChecked_BST(buttonID) == BST_CHECKED); }
|
||||
|
||||
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 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; }
|
||||
|
||||
/*
|
||||
#ifdef UNDER_CE
|
||||
virtual void OnHelp(void *) { OnHelp(); }
|
||||
#else
|
||||
virtual void OnHelp(LPHELPINFO) { OnHelp(); }
|
||||
#endif
|
||||
*/
|
||||
virtual void OnHelp() {}
|
||||
|
||||
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND);
|
||||
virtual void OnOK() {}
|
||||
virtual void OnContinue() {}
|
||||
virtual void OnCancel() {}
|
||||
virtual void OnClose() {}
|
||||
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); }
|
||||
|
||||
bool GetMargins(int margin, int &x, int &y);
|
||||
int Units_To_Pixels_X(int units);
|
||||
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();
|
||||
};
|
||||
|
||||
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
|
||||
virtual void OnOK() Z7_override { Destroy(); }
|
||||
virtual void OnContinue() Z7_override { Destroy(); }
|
||||
virtual void OnCancel() Z7_override { Destroy(); }
|
||||
virtual void OnClose() Z7_override { 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() Z7_override { End(IDOK); }
|
||||
virtual void OnContinue() Z7_override { End(IDCONTINUE); }
|
||||
virtual void OnCancel() Z7_override { End(IDCANCEL); }
|
||||
virtual void OnClose() Z7_override { End(IDCLOSE); }
|
||||
};
|
||||
|
||||
class CDialogChildControl: public NWindows::CWindow
|
||||
{
|
||||
// unsigned m_ID;
|
||||
public:
|
||||
void Init(const NWindows::NControl::CDialog &parentDialog, unsigned id)
|
||||
{
|
||||
// m_ID = id;
|
||||
Attach(parentDialog.GetItem(id));
|
||||
}
|
||||
};
|
||||
|
||||
bool IsDialogSizeOK(int xSize, int ySize, HWND hwnd = NULL);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
// Windows/Control/Edit.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_EDIT_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_EDIT_H
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
class CEdit: public CWindow
|
||||
{
|
||||
public:
|
||||
void SetPasswordChar(WPARAM c) { SendMsg(EM_SETPASSWORDCHAR, c); }
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
// Windows/Control/ImageList.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ImageList.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,87 @@
|
||||
// Windows/Control/ImageList.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_IMAGE_LIST_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_IMAGE_LIST_H
|
||||
|
||||
#include <CommCtrl.h>
|
||||
|
||||
#include "../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 = NULL)
|
||||
{ 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
|
||||
@@ -0,0 +1,162 @@
|
||||
// Windows/Control/ListView.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ListView.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* 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 ¶m) const
|
||||
{
|
||||
LVITEM item;
|
||||
item.iItem = (int)index;
|
||||
item.iSubItem = 0;
|
||||
item.mask = LVIF_PARAM;
|
||||
const bool res = GetItem(&item);
|
||||
param = item.lParam;
|
||||
return res;
|
||||
}
|
||||
|
||||
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 = (int)columnIndex;
|
||||
ci.cx = width;
|
||||
return InsertColumn(columnIndex, &ci);
|
||||
}
|
||||
|
||||
int CListView::InsertItem(unsigned index, LPCTSTR text)
|
||||
{
|
||||
LVITEM item;
|
||||
item.mask = LVIF_TEXT | LVIF_PARAM;
|
||||
item.iItem = (int)index;
|
||||
item.lParam = (LPARAM)index;
|
||||
item.pszText = (LPTSTR)(void *)text;
|
||||
item.iSubItem = 0;
|
||||
return InsertItem(&item);
|
||||
}
|
||||
|
||||
int CListView::SetSubItem(unsigned index, unsigned subIndex, LPCTSTR text)
|
||||
{
|
||||
LVITEM item;
|
||||
item.mask = LVIF_TEXT;
|
||||
item.iItem = (int)index;
|
||||
item.pszText = (LPTSTR)(void *)text;
|
||||
item.iSubItem = (int)subIndex;
|
||||
return SetItem(&item);
|
||||
}
|
||||
|
||||
#ifndef _UNICODE
|
||||
|
||||
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 = (int)columnIndex;
|
||||
ci.cx = width;
|
||||
return InsertColumn(columnIndex, &ci);
|
||||
}
|
||||
|
||||
int CListView::InsertItem(unsigned index, LPCWSTR text)
|
||||
{
|
||||
LVITEMW item;
|
||||
item.mask = LVIF_TEXT | LVIF_PARAM;
|
||||
item.iItem = (int)index;
|
||||
item.lParam = (LPARAM)index;
|
||||
item.pszText = (LPWSTR)(void *)text;
|
||||
item.iSubItem = 0;
|
||||
return InsertItem(&item);
|
||||
}
|
||||
|
||||
int CListView::SetSubItem(unsigned index, unsigned subIndex, LPCWSTR text)
|
||||
{
|
||||
LVITEMW item;
|
||||
item.mask = LVIF_TEXT;
|
||||
item.iItem = (int)index;
|
||||
item.pszText = (LPWSTR)(void *)text;
|
||||
item.iSubItem = (int)subIndex;
|
||||
return SetItem(&item);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CWindow window(hwnd);
|
||||
CListView2 *w = (CListView2 *)(window.GetUserDataLongPtr());
|
||||
if (w == NULL)
|
||||
return 0;
|
||||
return w->OnMessage(message, wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT CListView2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
|
||||
else
|
||||
#endif
|
||||
return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
|
||||
}
|
||||
|
||||
void CListView2::SetWindowProc()
|
||||
{
|
||||
SetUserDataLongPtr((LONG_PTR)this);
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
_origWindowProc = (WNDPROC)SetLongPtrW(GWLP_WNDPROC, (LONG_PTR)ListViewSubclassProc);
|
||||
else
|
||||
#endif
|
||||
_origWindowProc = (WNDPROC)SetLongPtr(GWLP_WNDPROC, (LONG_PTR)ListViewSubclassProc);
|
||||
}
|
||||
|
||||
/*
|
||||
LRESULT CListView3::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT res = CListView2::OnMessage(message, wParam, lParam);
|
||||
if (message == WM_GETDLGCODE)
|
||||
{
|
||||
// when user presses RETURN, windows sends default (first) button command to parent dialog.
|
||||
// we disable this:
|
||||
MSG *msg = (MSG *)lParam;
|
||||
WPARAM key = wParam;
|
||||
bool change = false;
|
||||
if (msg)
|
||||
{
|
||||
if (msg->message == WM_KEYDOWN && msg->wParam == VK_RETURN)
|
||||
change = true;
|
||||
}
|
||||
else if (wParam == VK_RETURN)
|
||||
change = true;
|
||||
if (change)
|
||||
res |= DLGC_WANTALLKEYS;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
*/
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,156 @@
|
||||
// Windows/Control/ListView.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
|
||||
|
||||
#include "../../Common/MyWindows.h"
|
||||
|
||||
#include <CommCtrl.h>
|
||||
|
||||
#include "../Window.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);
|
||||
|
||||
void SetUnicodeFormat()
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
ListView_SetUnicodeFormat(_window, TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DeleteAllItems() { return BOOLToBool(ListView_DeleteAllItems(_window)); }
|
||||
bool DeleteColumn(unsigned columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
|
||||
|
||||
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)); }
|
||||
|
||||
/*
|
||||
int GetNumColumns()
|
||||
{
|
||||
HWND header = ListView_GetHeader(_window);
|
||||
if (!header)
|
||||
return -1;
|
||||
return Header_GetItemCount(header);
|
||||
}
|
||||
*/
|
||||
|
||||
int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
|
||||
int InsertItem(unsigned index, LPCTSTR text);
|
||||
bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }
|
||||
int SetSubItem(unsigned index, unsigned subIndex, LPCTSTR text);
|
||||
|
||||
#ifndef _UNICODE
|
||||
|
||||
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(unsigned index, LPCWSTR text);
|
||||
bool SetItem(const LV_ITEMW* item) { return BOOLToBool((BOOL)SendMsg(LVM_SETITEMW, 0, (LPARAM)item)); }
|
||||
int SetSubItem(unsigned index, unsigned subIndex, LPCWSTR text);
|
||||
|
||||
#endif
|
||||
|
||||
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(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(unsigned itemIndex, LPARAM ¶m) 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)); }
|
||||
|
||||
// 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); }
|
||||
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 IsItemSelected(int index) const { return GetItemState(index, LVIS_SELECTED) == LVIS_SELECTED; }
|
||||
|
||||
bool GetColumn(unsigned 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); }
|
||||
|
||||
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 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); }
|
||||
bool SetColumnWidth(int iCol, int cx) { return BOOLToBool(ListView_SetColumnWidth(_window, iCol, cx)); }
|
||||
bool SetColumnWidthAuto(int iCol) { return SetColumnWidth(iCol, LVSCW_AUTOSIZE); }
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
/*
|
||||
class CListView3: public CListView2
|
||||
{
|
||||
public:
|
||||
virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
*/
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
// Windows/Control/ProgressBar.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_PROGRESSBAR_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_PROGRESSBAR_H
|
||||
|
||||
#include "../../Common/MyWindows.h"
|
||||
|
||||
#include <CommCtrl.h>
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
class CProgressBar: public CWindow
|
||||
{
|
||||
public:
|
||||
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, (LPARAM)color); }
|
||||
COLORREF SetBackgroundColor(COLORREF color) { return (COLORREF)SendMsg(PBM_SETBKCOLOR, 0, (LPARAM)color); }
|
||||
#endif
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,165 @@
|
||||
// Windows/Control/PropertyPage.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
#include "../../Common/StringConvert.h"
|
||||
#endif
|
||||
|
||||
#include "PropertyPage.h"
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
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)
|
||||
tempDialog.SetUserDataLongPtr(((PROPSHEETPAGE *)lParam)->lParam);
|
||||
CDialog *dialog = (CDialog *)(tempDialog.GetUserDataLongPtr());
|
||||
if (dialog == NULL)
|
||||
return FALSE;
|
||||
if (message == WM_INITDIALOG)
|
||||
dialog->Attach(dialogHWND);
|
||||
try { return BoolToBOOL(dialog->OnMessage(message, wParam, lParam)); }
|
||||
catch(...) { return TRUE; }
|
||||
}
|
||||
|
||||
bool CPropertyPage::OnNotify(UINT /* controlID */, LPNMHDR lParam)
|
||||
{
|
||||
switch (lParam->code)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
my_compatib_PROPSHEETPAGEA page;
|
||||
memset(&page, 0, sizeof(page));
|
||||
page.dwSize = sizeof(page);
|
||||
page.dwFlags = PSP_HASHELP;
|
||||
page.hInstance = g_hInstance;
|
||||
page.pszTemplate = MAKEINTRESOURCEA(pageInfo.ID);
|
||||
// page.pszIcon = NULL;
|
||||
page.pfnDlgProc = NWindows::NControl::MyProperyPageProcedure;
|
||||
|
||||
if (!titles[i].IsEmpty())
|
||||
{
|
||||
page.pszTitle = titles[i];
|
||||
page.dwFlags |= PSP_USETITLE;
|
||||
}
|
||||
// else page.pszTitle = NULL;
|
||||
page.lParam = (LPARAM)pageInfo.Page;
|
||||
// page.pfnCallback = NULL;
|
||||
pagesA.Add(page);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
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.pfnDlgProc = NWindows::NControl::MyProperyPageProcedure;
|
||||
|
||||
if (!pageInfo.Title.IsEmpty())
|
||||
{
|
||||
page.pszTitle = pageInfo.Title;
|
||||
page.dwFlags |= PSP_USETITLE;
|
||||
}
|
||||
// else page.pszTitle = NULL;
|
||||
page.lParam = (LPARAM)pageInfo.Page;
|
||||
// page.pfnCallback = NULL;
|
||||
pagesW.Add(page);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _UNICODE
|
||||
if (!g_IsNT)
|
||||
{
|
||||
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 = pagesA.Size();
|
||||
sheet.nStartPage = 0;
|
||||
sheet.ppsp = (LPCPROPSHEETPAGEA)(const void *)pagesA.ConstData();
|
||||
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 = pagesW.Size();
|
||||
sheet.nStartPage = 0;
|
||||
sheet.ppsp = (LPCPROPSHEETPAGEW)(const void *)pagesW.ConstData();
|
||||
sheet.pfnCallback = NULL;
|
||||
return ::PropertySheetW(&sheet);
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,50 @@
|
||||
// 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 "Dialog.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) Z7_override;
|
||||
|
||||
virtual bool OnKillActive() { return false; } // false = OK
|
||||
virtual bool OnKillActive2(const PSHNOTIFY *) { return OnKillActive(); }
|
||||
virtual LONG OnSetActive() { return false; } // false = OK
|
||||
virtual LONG OnSetActive2(const PSHNOTIFY *) { return OnSetActive(); }
|
||||
virtual LONG OnApply() { return PSNRET_NOERROR; }
|
||||
virtual LONG OnApply2(const PSHNOTIFY *) { return OnApply(); }
|
||||
virtual void OnNotifyHelp() {}
|
||||
virtual void OnNotifyHelp2(const PSHNOTIFY *) { OnNotifyHelp(); }
|
||||
virtual void OnReset() {}
|
||||
virtual void OnReset2(const PSHNOTIFY *) { OnReset(); }
|
||||
};
|
||||
|
||||
struct CPageInfo
|
||||
{
|
||||
CPropertyPage *Page;
|
||||
UString Title;
|
||||
UINT ID;
|
||||
};
|
||||
|
||||
INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndParent, const UString &title);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
// Windows/Control/ReBar.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_REBAR_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_REBAR_H
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
class CReBar: public NWindows::CWindow
|
||||
{
|
||||
public:
|
||||
bool SetBarInfo(LPREBARINFO barInfo)
|
||||
{ return LRESULTToBool(SendMsg(RB_SETBARINFO, 0, (LPARAM)barInfo)); }
|
||||
bool InsertBand(int index, LPREBARBANDINFO 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)
|
||||
{ SendMsg(RB_MAXIMIZEBAND, index, BoolToBOOL(ideal)); }
|
||||
bool SizeToRect(LPRECT rect)
|
||||
{ return LRESULTToBool(SendMsg(RB_SIZETORECT, 0, (LPARAM)rect)); }
|
||||
UINT GetHeight()
|
||||
{ return (UINT)SendMsg(RB_GETBARHEIGHT); }
|
||||
UINT GetBandCount()
|
||||
{ return (UINT)SendMsg(RB_GETBANDCOUNT); }
|
||||
bool DeleteBand(UINT index)
|
||||
{ return LRESULTToBool(SendMsg(RB_DELETEBAND, index)); }
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
// Windows/Control/Static.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_STATIC_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_STATIC_H
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
class CStatic: public CWindow
|
||||
{
|
||||
public:
|
||||
HANDLE SetImage(WPARAM imageType, HANDLE handle) { return (HANDLE)SendMsg(STM_SETIMAGE, imageType, (LPARAM)handle); }
|
||||
HANDLE GetImage(WPARAM imageType) { return (HANDLE)SendMsg(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)SendMsg(STM_SETICON, (WPARAM)icon, 0); }
|
||||
HICON GetIcon() { return (HICON)SendMsg(STM_GETICON, 0, 0); }
|
||||
#endif
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
// Windows/Control/StatusBar.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_STATUSBAR_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_STATUSBAR_H
|
||||
|
||||
#include "../Window.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)) != NULL; }
|
||||
bool SetText(LPCTSTR text)
|
||||
{ return CWindow::SetText(text); }
|
||||
bool SetText(unsigned index, LPCTSTR text, UINT type)
|
||||
{ return LRESULTToBool(SendMsg(SB_SETTEXT, index | type, (LPARAM)text)); }
|
||||
bool SetText(unsigned index, LPCTSTR text)
|
||||
{ return SetText(index, text, 0); }
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool Create(LONG style, LPCWSTR text, HWND hwndParent, UINT id)
|
||||
{ return (_window = ::CreateStatusWindowW(style, text, hwndParent, id)) != NULL; }
|
||||
bool SetText(LPCWSTR text)
|
||||
{ return CWindow::SetText(text); }
|
||||
bool SetText(unsigned index, LPCWSTR text, UINT type)
|
||||
{ return LRESULTToBool(SendMsg(SB_SETTEXTW, index | type, (LPARAM)text)); }
|
||||
bool SetText(unsigned index, LPCWSTR text)
|
||||
{ return SetText(index, text, 0); }
|
||||
#endif
|
||||
|
||||
bool SetParts(unsigned numParts, const int *edgePostions)
|
||||
{ return LRESULTToBool(SendMsg(SB_SETPARTS, numParts, (LPARAM)edgePostions)); }
|
||||
void Simple(bool simple)
|
||||
{ SendMsg(SB_SIMPLE, (WPARAM)BoolToBOOL(simple), 0); }
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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
|
||||
@@ -0,0 +1,43 @@
|
||||
// Windows/Control/ToolBar.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_TOOLBAR_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_TOOLBAR_H
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
class CToolBar: public NWindows::CWindow
|
||||
{
|
||||
public:
|
||||
void AutoSize() { SendMsg(TB_AUTOSIZE, 0, 0); }
|
||||
DWORD GetButtonSize() { return (DWORD)SendMsg(TB_GETBUTTONSIZE, 0, 0); }
|
||||
|
||||
bool GetMaxSize(LPSIZE size)
|
||||
#ifdef UNDER_CE
|
||||
{
|
||||
// maybe it must be fixed for more than 1 buttons
|
||||
const DWORD val = GetButtonSize();
|
||||
size->cx = LOWORD(val);
|
||||
size->cy = HIWORD(val);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return LRESULTToBool(SendMsg(TB_GETMAXSIZE, 0, (LPARAM)size));
|
||||
}
|
||||
#endif
|
||||
|
||||
bool EnableButton(UINT buttonID, bool enable) { return LRESULTToBool(SendMsg(TB_ENABLEBUTTON, buttonID, MAKELONG(BoolToBOOL(enable), 0))); }
|
||||
void ButtonStructSize() { SendMsg(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON)); }
|
||||
HIMAGELIST SetImageList(UINT listIndex, HIMAGELIST imageList) { return HIMAGELIST(SendMsg(TB_SETIMAGELIST, listIndex, (LPARAM)imageList)); }
|
||||
bool AddButton(UINT numButtons, LPTBBUTTON buttons) { return LRESULTToBool(SendMsg(TB_ADDBUTTONS, numButtons, (LPARAM)buttons)); }
|
||||
#ifndef _UNICODE
|
||||
bool AddButtonW(UINT numButtons, LPTBBUTTON buttons) { return LRESULTToBool(SendMsg(TB_ADDBUTTONSW, numButtons, (LPARAM)buttons)); }
|
||||
#endif
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
// Windows/Control/Trackbar.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_TRACKBAR_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_TRACKBAR_H
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
class CTrackbar: public CWindow
|
||||
{
|
||||
public:
|
||||
void SetRange(int minimum, int maximum, bool redraw = true)
|
||||
{ SendMsg(TBM_SETRANGE, BoolToBOOL(redraw), MAKELONG(minimum, maximum)); }
|
||||
void SetPos(int pos, bool redraw = true)
|
||||
{ SendMsg(TBM_SETPOS, BoolToBOOL(redraw), pos); }
|
||||
void SetTicFreq(int freq)
|
||||
{ SendMsg(TBM_SETTICFREQ, freq); }
|
||||
|
||||
int GetPos()
|
||||
{ return (int)SendMsg(TBM_GETPOS); }
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,202 @@
|
||||
// Windows/Control/Window2.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
#include "../../Common/StringConvert.h"
|
||||
#endif
|
||||
|
||||
#include "Window2.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
namespace NWindows {
|
||||
|
||||
#ifndef _UNICODE
|
||||
ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
|
||||
#endif
|
||||
|
||||
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 == MY_START_WM_CREATE)
|
||||
tempWindow.SetUserDataLongPtr((LONG_PTR)(((LPCREATESTRUCT)lParam)->lpCreateParams));
|
||||
CWindow2 *window = (CWindow2 *)(tempWindow.GetUserDataLongPtr());
|
||||
if (window && message == MY_START_WM_CREATE)
|
||||
window->Attach(aHWND);
|
||||
if (!window)
|
||||
{
|
||||
#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 wc;
|
||||
if (!::GetClassInfo(instance, className, &wc))
|
||||
{
|
||||
// wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = WindowProcedure;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = instance;
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = className;
|
||||
if (::RegisterClass(&wc) == 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 wc;
|
||||
needRegister = ::GetClassInfoW(instance, className, &wc) == 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 wc;
|
||||
// wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = WindowProcedure;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = instance;
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = className;
|
||||
if (MyRegisterClass(&wc) == 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(HIWORD(wParam), LOWORD(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::OnCommand2(WPARAM wParam, LPARAM lParam, LRESULT &result)
|
||||
{
|
||||
return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam, result);
|
||||
}
|
||||
*/
|
||||
|
||||
bool CWindow2::OnCommand(unsigned /* code */, unsigned /* itemID */, LPARAM /* lParam */, LRESULT & /* result */)
|
||||
{
|
||||
return false;
|
||||
// return DefProc(message, wParam, lParam);
|
||||
/*
|
||||
if (code == BN_CLICKED)
|
||||
return OnButtonClicked(itemID, (HWND)lParam);
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
bool CDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
|
||||
{
|
||||
switch (buttonID)
|
||||
{
|
||||
case IDOK:
|
||||
OnOK();
|
||||
break;
|
||||
case IDCANCEL:
|
||||
OnCancel();
|
||||
break;
|
||||
case IDHELP:
|
||||
OnHelp();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Windows/Control/Window2.h
|
||||
|
||||
#ifndef ZIP7_INC_WINDOWS_CONTROL_WINDOW2_H
|
||||
#define ZIP7_INC_WINDOWS_CONTROL_WINDOW2_H
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
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() {}
|
||||
|
||||
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);
|
||||
// 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); }
|
||||
virtual void OnClose() { Destroy(); }
|
||||
/*
|
||||
virtual LRESULT OnHelp(LPHELPINFO helpInfo) { OnHelp(); }
|
||||
virtual LRESULT OnHelp() {};
|
||||
virtual bool OnButtonClicked(unsigned 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
|
||||
Reference in New Issue
Block a user