mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 01:15:00 -06:00
9.06 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
829409452d
commit
c99f3ebdd6
@@ -13,7 +13,15 @@ namespace NCOM {
|
||||
class CComInitializer
|
||||
{
|
||||
public:
|
||||
CComInitializer() { CoInitialize(NULL);};
|
||||
CComInitializer()
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
#else
|
||||
// it's single thread. Do we need multithread?
|
||||
CoInitialize(NULL);
|
||||
#endif
|
||||
};
|
||||
~CComInitializer() { CoUninitialize(); };
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#include <winuserm.h>
|
||||
#endif
|
||||
|
||||
#include "Windows/Clipboard.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/Memory.h"
|
||||
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#include <commdlg.h>
|
||||
#endif
|
||||
|
||||
#ifndef _UNICODE
|
||||
#include "Common/StringConvert.h"
|
||||
#endif
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "CommonDialog.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
@@ -62,7 +69,15 @@ void CDoubleZeroStringListW::SetForBuffer(LPWSTR buffer)
|
||||
buffer[m_Indexes[i]] = L'\0';
|
||||
}
|
||||
|
||||
bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s, UString &resPath)
|
||||
#define MY_OFN_PROJECT 0x00400000
|
||||
#define MY_OFN_SHOW_ALL 0x01000000
|
||||
|
||||
bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName,
|
||||
LPCWSTR s, UString &resPath
|
||||
#ifdef UNDER_CE
|
||||
, bool openFolder
|
||||
#endif
|
||||
)
|
||||
{
|
||||
const int kBufferSize = MAX_PATH * 2;
|
||||
#ifndef _UNICODE
|
||||
@@ -146,7 +161,12 @@ bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s
|
||||
|
||||
info.lpstrTitle = title;
|
||||
|
||||
info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
|
||||
info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY
|
||||
#ifdef UNDER_CE
|
||||
| (openFolder ? (MY_OFN_PROJECT | MY_OFN_SHOW_ALL) : 0)
|
||||
#endif
|
||||
;
|
||||
|
||||
info.nFileOffset = 0;
|
||||
info.nFileExtension = 0;
|
||||
info.lpstrDefExt = NULL;
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
// Windows/CommonDialog.h
|
||||
|
||||
#ifndef __WINDOWS_COMMONDIALOG_H
|
||||
#define __WINDOWS_COMMONDIALOG_H
|
||||
|
||||
#include <windows.h>
|
||||
#ifndef __WINDOWS_COMMON_DIALOG_H
|
||||
#define __WINDOWS_COMMON_DIALOG_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
namespace NWindows{
|
||||
|
||||
bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s, UString &resPath);
|
||||
bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName,
|
||||
LPCWSTR s, UString &resPath
|
||||
#ifdef UNDER_CE
|
||||
, bool openFolder = false
|
||||
#endif
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
// Windows/Control/ComboBox.cpp
|
||||
|
||||
// #define _UNICODE
|
||||
// #define UNICODE
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
@@ -10,7 +7,6 @@
|
||||
#endif
|
||||
|
||||
#include "Windows/Control/ComboBox.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
@@ -59,5 +55,4 @@ LRESULT CComboBox::GetLBText(int index, UString &s)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}}
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
#ifndef __WINDOWS_CONTROL_COMBOBOX_H
|
||||
#define __WINDOWS_CONTROL_COMBOBOX_H
|
||||
|
||||
#include "Windows/Window.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include <commctrl.h>
|
||||
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
@@ -15,33 +14,34 @@ class CComboBox: public CWindow
|
||||
{
|
||||
public:
|
||||
void ResetContent() { SendMessage(CB_RESETCONTENT, 0, 0); }
|
||||
LRESULT AddString(LPCTSTR string) { return SendMessage(CB_ADDSTRING, 0, (LPARAM)string); }
|
||||
LRESULT AddString(LPCTSTR s) { return SendMessage(CB_ADDSTRING, 0, (LPARAM)s); }
|
||||
#ifndef _UNICODE
|
||||
LRESULT AddString(LPCWSTR string);
|
||||
LRESULT AddString(LPCWSTR s);
|
||||
#endif
|
||||
LRESULT SetCurSel(int index) { return SendMessage(CB_SETCURSEL, index, 0); }
|
||||
int GetCurSel() { return (int)SendMessage(CB_GETCURSEL, 0, 0); }
|
||||
int GetCount() { return (int)SendMessage(CB_GETCOUNT, 0, 0); }
|
||||
|
||||
LRESULT GetLBTextLen(int index) { return SendMessage(CB_GETLBTEXTLEN, index, 0); }
|
||||
LRESULT GetLBText(int index, LPTSTR string) { return SendMessage(CB_GETLBTEXT, index, (LPARAM)string); }
|
||||
LRESULT GetLBText(int index, LPTSTR s) { return SendMessage(CB_GETLBTEXT, index, (LPARAM)s); }
|
||||
LRESULT GetLBText(int index, CSysString &s);
|
||||
#ifndef _UNICODE
|
||||
LRESULT GetLBText(int index, UString &s);
|
||||
#endif
|
||||
|
||||
LRESULT SetItemData(int index, LPARAM lParam)
|
||||
{ return SendMessage(CB_SETITEMDATA, index, lParam); }
|
||||
LRESULT GetItemData(int index)
|
||||
{ return SendMessage(CB_GETITEMDATA, index, 0); }
|
||||
LRESULT SetItemData(int index, LPARAM lParam) { return SendMessage(CB_SETITEMDATA, index, lParam); }
|
||||
LRESULT GetItemData(int index) { return SendMessage(CB_GETITEMDATA, index, 0); }
|
||||
|
||||
void ShowDropDown(bool show = true)
|
||||
{ SendMessage(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); }
|
||||
void ShowDropDown(bool show = true) { SendMessage(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); }
|
||||
};
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
class CComboBoxEx: public CComboBox
|
||||
{
|
||||
public:
|
||||
bool SetUnicodeFormat(bool fUnicode) { return LRESULTToBool(SendMessage(CBEM_SETUNICODEFORMAT, BOOLToBool(fUnicode), 0)); }
|
||||
|
||||
LRESULT DeleteItem(int index) { return SendMessage(CBEM_DELETEITEM, index, 0); }
|
||||
LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMessage(CBEM_INSERTITEM, 0, (LPARAM)item); }
|
||||
#ifndef _UNICODE
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
48
CPP/Windows/Control/CommandBar.h
Executable file
48
CPP/Windows/Control/CommandBar.h
Executable file
@@ -0,0 +1,48 @@
|
||||
// Windows/Control/CommandBar.h
|
||||
|
||||
#ifndef __WINDOWS_CONTROL_COMMANDBAR_H
|
||||
#define __WINDOWS_CONTROL_COMMANDBAR_H
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
#include "Windows/Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
class CCommandBar: public NWindows::CWindow
|
||||
{
|
||||
public:
|
||||
bool Create(HINSTANCE hInst, HWND hwndParent, int idCmdBar)
|
||||
{
|
||||
_window = ::CommandBar_Create(hInst, hwndParent, idCmdBar);
|
||||
return (_window != NULL);
|
||||
}
|
||||
|
||||
// Macros
|
||||
// void Destroy() { CommandBar_Destroy(_window); }
|
||||
bool AddButtons(int iButton, UINT numButtons, LPTBBUTTON buttons) { return BOOLToBool(SendMessage(TB_ADDBUTTONS, (WPARAM)numButtons, (LPARAM)buttons)); }
|
||||
bool InsertButton(int iButton, LPTBBUTTON button) { return BOOLToBool(SendMessage(TB_INSERTBUTTON, (WPARAM)iButton, (LPARAM)button)); }
|
||||
BOOL AddToolTips(UINT numToolTips, LPTSTR toolTips) { return BOOLToBool(SendMessage(TB_SETTOOLTIPS, (WPARAM)numToolTips, (LPARAM)toolTips)); }
|
||||
void AutoSize() { SendMessage(TB_AUTOSIZE, 0, 0); }
|
||||
|
||||
bool AddAdornments(DWORD dwFlags) { return BOOLToBool(::CommandBar_AddAdornments(_window, dwFlags, 0)); }
|
||||
int AddBitmap(HINSTANCE hInst, int idBitmap, int iNumImages, int iImageWidth, int iImageHeight) { return ::CommandBar_AddBitmap(_window, hInst, idBitmap, iNumImages, iImageWidth, iImageHeight); }
|
||||
bool DrawMenuBar(WORD iButton) { return BOOLToBool(::CommandBar_DrawMenuBar(_window, iButton)); }
|
||||
HMENU GetMenu(WORD iButton) { return ::CommandBar_GetMenu(_window, iButton); }
|
||||
int Height() { return CommandBar_Height(_window); }
|
||||
HWND InsertComboBox(HINSTANCE hInst, int iWidth, UINT dwStyle, WORD idComboBox, WORD iButton) { return ::CommandBar_InsertComboBox(_window, hInst, iWidth, dwStyle, idComboBox, iButton); }
|
||||
bool InsertMenubar(HINSTANCE hInst, WORD idMenu, WORD iButton) { return BOOLToBool(::CommandBar_InsertMenubar(_window, hInst, idMenu, iButton)); }
|
||||
bool InsertMenubarEx(HINSTANCE hInst, LPTSTR pszMenu, WORD iButton) { return BOOLToBool(::CommandBar_InsertMenubarEx(_window, hInst, pszMenu, iButton)); }
|
||||
bool Show(bool cmdShow) { return BOOLToBool(::CommandBar_Show(_window, BoolToBOOL(cmdShow))); }
|
||||
|
||||
|
||||
// CE 4.0
|
||||
void AlignAdornments() { CommandBar_AlignAdornments(_window); }
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -15,8 +15,7 @@ extern bool g_IsNT;
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CWindow dialogTmp(dialogHWND);
|
||||
if (message == WM_INITDIALOG)
|
||||
@@ -27,30 +26,31 @@ static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message,
|
||||
if (message == WM_INITDIALOG)
|
||||
dialog->Attach(dialogHWND);
|
||||
|
||||
return BoolToBOOL(dialog->OnMessage(message, wParam, lParam));
|
||||
try { return BoolToBOOL(dialog->OnMessage(message, wParam, lParam)); }
|
||||
catch(...) { return true; }
|
||||
}
|
||||
|
||||
bool CDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return OnInit();
|
||||
case WM_COMMAND:
|
||||
return OnCommand(wParam, lParam);
|
||||
case WM_NOTIFY:
|
||||
return OnNotify((UINT)wParam, (LPNMHDR) lParam);
|
||||
case WM_HELP:
|
||||
{
|
||||
OnHelp((LPHELPINFO)lParam);
|
||||
case WM_INITDIALOG: return OnInit();
|
||||
case WM_COMMAND: return OnCommand(wParam, lParam);
|
||||
case WM_NOTIFY: return OnNotify((UINT)wParam, (LPNMHDR) lParam);
|
||||
case WM_TIMER: return OnTimer(wParam, lParam);
|
||||
case WM_SIZE: return OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
|
||||
case WM_HELP: OnHelp(); return true;
|
||||
/*
|
||||
OnHelp(
|
||||
#ifdef UNDER_CE
|
||||
(void *)
|
||||
#else
|
||||
(LPHELPINFO)
|
||||
#endif
|
||||
lParam);
|
||||
return true;
|
||||
}
|
||||
case WM_TIMER:
|
||||
{
|
||||
return OnTimer(wParam, lParam);
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
*/
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,21 +70,77 @@ bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */)
|
||||
{
|
||||
switch(buttonID)
|
||||
{
|
||||
case IDOK:
|
||||
OnOK();
|
||||
break;
|
||||
case IDCANCEL:
|
||||
OnCancel();
|
||||
break;
|
||||
case IDHELP:
|
||||
OnHelp();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
case IDOK: OnOK(); break;
|
||||
case IDCANCEL: OnCancel(); break;
|
||||
case IDHELP: OnHelp(); break;
|
||||
default: return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool GetWorkAreaRect(RECT *rect)
|
||||
{
|
||||
// use another function for multi-monitor.
|
||||
return BOOLToBool(::SystemParametersInfo(SPI_GETWORKAREA, NULL, rect, NULL));
|
||||
}
|
||||
|
||||
bool IsDialogSizeOK(int xSize, int ySize)
|
||||
{
|
||||
// it returns for system font. Real font uses another values
|
||||
LONG v = GetDialogBaseUnits();
|
||||
int x = LOWORD(v);
|
||||
int y = HIWORD(v);
|
||||
|
||||
RECT rect;
|
||||
GetWorkAreaRect(&rect);
|
||||
int wx = RECT_SIZE_X(rect);
|
||||
int wy = RECT_SIZE_Y(rect);
|
||||
return
|
||||
xSize / 4 * x <= wx &&
|
||||
ySize / 8 * y <= wy;
|
||||
}
|
||||
|
||||
void CDialog::NormalizeSize(bool fullNormalize)
|
||||
{
|
||||
RECT workRect;
|
||||
GetWorkAreaRect(&workRect);
|
||||
int xSize = RECT_SIZE_X(workRect);
|
||||
int ySize = RECT_SIZE_Y(workRect);
|
||||
RECT rect;
|
||||
GetWindowRect(&rect);
|
||||
int xSize2 = RECT_SIZE_X(rect);
|
||||
int ySize2 = RECT_SIZE_Y(rect);
|
||||
bool needMove = (xSize2 > xSize || ySize2 > ySize);
|
||||
if (xSize2 > xSize || (needMove && fullNormalize))
|
||||
{
|
||||
rect.left = workRect.left;
|
||||
rect.right = workRect.right;
|
||||
xSize2 = xSize;
|
||||
}
|
||||
if (ySize2 > ySize || (needMove && fullNormalize))
|
||||
{
|
||||
rect.top = workRect.top;
|
||||
rect.bottom = workRect.bottom;
|
||||
ySize2 = ySize;
|
||||
}
|
||||
if (needMove)
|
||||
{
|
||||
if (fullNormalize)
|
||||
Show(SW_SHOWMAXIMIZED);
|
||||
else
|
||||
Move(rect.left, rect.top, xSize2, ySize2, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CDialog::NormalizePosition()
|
||||
{
|
||||
RECT workRect, rect;
|
||||
GetWorkAreaRect(&workRect);
|
||||
GetWindowRect(&rect);
|
||||
if (rect.bottom > workRect.bottom && rect.top > workRect.top)
|
||||
Move(rect.left, workRect.top, RECT_SIZE_X(rect), RECT_SIZE_Y(rect), true);
|
||||
}
|
||||
|
||||
bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow)
|
||||
{
|
||||
HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#define __WINDOWS_CONTROL_DIALOG_H
|
||||
|
||||
#include "Windows/Window.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
@@ -24,6 +23,8 @@ public:
|
||||
bool ShowItem(int itemID, int cmdShow) const
|
||||
{ return BOOLToBool(::ShowWindow(GetItem(itemID), cmdShow)); }
|
||||
|
||||
bool HideItem(int itemID) const { return ShowItem(itemID, SW_HIDE); }
|
||||
|
||||
bool SetItemText(int itemID, LPCTSTR s)
|
||||
{ return BOOLToBool(SetDlgItemText(_window, itemID, s)); }
|
||||
|
||||
@@ -50,11 +51,11 @@ public:
|
||||
bool SetItemInt(int itemID, UINT value, bool isSigned)
|
||||
{ return BOOLToBool(SetDlgItemInt(_window, itemID, value, BoolToBOOL(isSigned))); }
|
||||
bool GetItemInt(int itemID, bool isSigned, UINT &value)
|
||||
{
|
||||
BOOL result;
|
||||
value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned));
|
||||
return BOOLToBool(result);
|
||||
}
|
||||
{
|
||||
BOOL result;
|
||||
value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned));
|
||||
return BOOLToBool(result);
|
||||
}
|
||||
|
||||
HWND GetNextGroupItem(HWND control, bool previous)
|
||||
{ return GetNextDlgGroupItem(_window, control, BoolToBOOL(previous)); }
|
||||
@@ -87,8 +88,17 @@ public:
|
||||
virtual bool OnInit() { return true; }
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam);
|
||||
virtual bool OnCommand(int code, int itemID, LPARAM lParam);
|
||||
virtual void OnHelp(LPHELPINFO /* helpInfo */) { OnHelp(); };
|
||||
virtual bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; }
|
||||
|
||||
/*
|
||||
#ifdef UNDER_CE
|
||||
virtual void OnHelp(void *) { OnHelp(); };
|
||||
#else
|
||||
virtual void OnHelp(LPHELPINFO) { OnHelp(); };
|
||||
#endif
|
||||
*/
|
||||
virtual void OnHelp() {};
|
||||
|
||||
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
|
||||
virtual void OnOK() {};
|
||||
virtual void OnCancel() {};
|
||||
@@ -99,12 +109,63 @@ public:
|
||||
{ return SetLongPtr(DWLP_MSGRESULT, newLongPtr); }
|
||||
LONG_PTR GetMsgResult() const
|
||||
{ return GetLongPtr(DWLP_MSGRESULT); }
|
||||
|
||||
|
||||
bool GetMargins(int margin, int &x, int &y)
|
||||
{
|
||||
RECT rect;
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = margin;
|
||||
rect.bottom = margin;
|
||||
if (!MapRect(&rect))
|
||||
return false;
|
||||
x = rect.right - rect.left;
|
||||
y = rect.bottom - rect.top;
|
||||
return true;
|
||||
}
|
||||
|
||||
int Units_To_Pixels_X(int units)
|
||||
{
|
||||
RECT rect;
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = units;
|
||||
rect.bottom = units;
|
||||
if (!MapRect(&rect))
|
||||
return units * 3 / 2;
|
||||
return rect.right - rect.left;
|
||||
}
|
||||
|
||||
bool GetItemSizes(int id, int &x, int &y)
|
||||
{
|
||||
RECT rect;
|
||||
if (!::GetWindowRect(GetItem(id), &rect))
|
||||
return false;
|
||||
x = rect.right - rect.left;
|
||||
y = rect.bottom - rect.top;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GetClientRectOfItem(int id, RECT &rect)
|
||||
{
|
||||
::GetWindowRect(GetItem(id), &rect);
|
||||
ScreenToClient(&rect);
|
||||
}
|
||||
|
||||
|
||||
bool MoveItem(int id, int x, int y, int width, int height, bool repaint = true)
|
||||
{ return BOOLToBool(::MoveWindow(GetItem(id), x, y, width, height, BoolToBOOL(repaint))); }
|
||||
|
||||
void NormalizeSize(bool fullNormalize = false);
|
||||
void NormalizePosition();
|
||||
};
|
||||
|
||||
class CModelessDialog: public CDialog
|
||||
{
|
||||
public:
|
||||
bool Create(LPCTSTR templateName, HWND parentWindow);
|
||||
bool Create(UINT resID, HWND parentWindow) { return Create(MAKEINTRESOURCEW(resID), parentWindow); }
|
||||
#ifndef _UNICODE
|
||||
bool Create(LPCWSTR templateName, HWND parentWindow);
|
||||
#endif
|
||||
@@ -116,22 +177,20 @@ class CModalDialog: public CDialog
|
||||
{
|
||||
public:
|
||||
INT_PTR Create(LPCTSTR templateName, HWND parentWindow);
|
||||
INT_PTR Create(UINT resID, HWND parentWindow)
|
||||
{ return Create(MAKEINTRESOURCEW(resID), parentWindow); }
|
||||
INT_PTR Create(UINT resID, HWND parentWindow) { return Create(MAKEINTRESOURCEW(resID), parentWindow); }
|
||||
#ifndef _UNICODE
|
||||
INT_PTR Create(LPCWSTR templateName, HWND parentWindow);
|
||||
#endif
|
||||
|
||||
bool End(INT_PTR result)
|
||||
{ return BOOLToBool(::EndDialog(_window, result)); }
|
||||
bool End(INT_PTR result) { return BOOLToBool(::EndDialog(_window, result)); }
|
||||
virtual void OnOK() { End(IDOK); }
|
||||
virtual void OnCancel() { End(IDCANCEL); }
|
||||
};
|
||||
|
||||
class CDialogChildControl: public NWindows::CWindow
|
||||
{
|
||||
public:
|
||||
int m_ID;
|
||||
public:
|
||||
void Init(const NWindows::NControl::CDialog &parentDialog, int id)
|
||||
{
|
||||
m_ID = id;
|
||||
@@ -139,6 +198,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool IsDialogSizeOK(int xSize, int ySize);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#define __WINDOWS_CONTROL_LISTVIEW_H
|
||||
|
||||
#include "Windows/Window.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include <commctrl.h>
|
||||
|
||||
@@ -19,17 +18,14 @@ public:
|
||||
HWND parentWindow, HMENU idOrHMenu,
|
||||
HINSTANCE instance, LPVOID createParam);
|
||||
|
||||
bool SetUnicodeFormat(bool fUnicode)
|
||||
{ return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); }
|
||||
#ifndef UNDER_CE
|
||||
bool SetUnicodeFormat(bool fUnicode) { return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); }
|
||||
#endif
|
||||
|
||||
bool DeleteAllItems()
|
||||
{ return BOOLToBool(ListView_DeleteAllItems(_window)); }
|
||||
bool DeleteAllItems() { return BOOLToBool(ListView_DeleteAllItems(_window)); }
|
||||
bool DeleteColumn(int columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
|
||||
|
||||
bool DeleteColumn(int columnIndex)
|
||||
{ return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
|
||||
|
||||
int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo)
|
||||
{ return ListView_InsertColumn(_window, columnIndex, columnInfo); }
|
||||
int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
|
||||
int InsertColumn(int columnIndex, LPCTSTR text, int width);
|
||||
int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
|
||||
int InsertItem(int index, LPCTSTR text);
|
||||
@@ -38,8 +34,7 @@ public:
|
||||
|
||||
#ifndef _UNICODE
|
||||
|
||||
int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo)
|
||||
{ return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
|
||||
int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
|
||||
int InsertColumn(int columnIndex, LPCWSTR text, int width);
|
||||
int InsertItem(const LV_ITEMW* item) { return (int)SendMessage(LVM_INSERTITEMW, 0, (LPARAM)item); }
|
||||
int InsertItem(int index, LPCWSTR text);
|
||||
@@ -48,41 +43,30 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
bool DeleteItem(int itemIndex)
|
||||
{ return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
|
||||
bool DeleteItem(int itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
|
||||
|
||||
UINT GetSelectedCount() const
|
||||
{ return ListView_GetSelectedCount(_window); }
|
||||
int GetItemCount() const
|
||||
{ return ListView_GetItemCount(_window); }
|
||||
UINT GetSelectedCount() const { return ListView_GetSelectedCount(_window); }
|
||||
int GetItemCount() const { return ListView_GetItemCount(_window); }
|
||||
|
||||
INT GetSelectionMark() const
|
||||
{ return ListView_GetSelectionMark(_window); }
|
||||
INT GetSelectionMark() const { return ListView_GetSelectionMark(_window); }
|
||||
|
||||
void SetItemCount(int numItems)
|
||||
{ ListView_SetItemCount(_window, numItems); }
|
||||
void SetItemCountEx(int numItems, DWORD flags)
|
||||
{ ListView_SetItemCountEx(_window, numItems, flags); }
|
||||
void SetItemCount(int numItems) { ListView_SetItemCount(_window, numItems); }
|
||||
void SetItemCountEx(int numItems, DWORD flags) { ListView_SetItemCountEx(_window, numItems, flags); }
|
||||
|
||||
int GetNextItem(int startIndex, UINT flags) const
|
||||
{ return ListView_GetNextItem(_window, startIndex, flags); }
|
||||
int GetNextSelectedItem(int startIndex) const
|
||||
{ return GetNextItem(startIndex, LVNI_SELECTED); }
|
||||
int GetFocusedItem() const
|
||||
{ return GetNextItem(-1, LVNI_FOCUSED); }
|
||||
int GetNextItem(int startIndex, UINT flags) const { return ListView_GetNextItem(_window, startIndex, flags); }
|
||||
int GetNextSelectedItem(int startIndex) const { return GetNextItem(startIndex, LVNI_SELECTED); }
|
||||
int GetFocusedItem() const { return GetNextItem(-1, LVNI_FOCUSED); }
|
||||
|
||||
bool GetItem(LVITEM* item) const
|
||||
{ return BOOLToBool(ListView_GetItem(_window, item)); }
|
||||
bool GetItem(LVITEM* item) const { return BOOLToBool(ListView_GetItem(_window, item)); }
|
||||
bool GetItemParam(int itemIndex, LPARAM ¶m) const;
|
||||
void GetItemText(int itemIndex, int aSubItemIndex, LPTSTR aText, int aTextSizeMax) const
|
||||
{ ListView_GetItemText(_window, itemIndex, aSubItemIndex, aText, aTextSizeMax); }
|
||||
void GetItemText(int itemIndex, int subItemIndex, LPTSTR text, int textSizeMax) const
|
||||
{ ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax); }
|
||||
bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
|
||||
{ return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
|
||||
|
||||
void SetItemState(int index, UINT state, UINT mask)
|
||||
{ ListView_SetItemState(_window, index, state, mask); }
|
||||
UINT GetItemState(int index, UINT mask) const
|
||||
{ return ListView_GetItemState(_window, index, mask); }
|
||||
void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask); }
|
||||
void SetItemState_FocusedSelected(int index) { SetItemState(index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); }
|
||||
UINT GetItemState(int index, UINT mask) const { return ListView_GetItemState(_window, index, mask); }
|
||||
|
||||
bool GetColumn(int columnIndex, LVCOLUMN* columnInfo) const
|
||||
{ return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
|
||||
@@ -91,48 +75,33 @@ public:
|
||||
{ return ListView_SetImageList(_window, imageList, imageListType); }
|
||||
|
||||
// version 4.70: NT5 | (NT4 + ie3) | w98 | (w95 + ie3)
|
||||
DWORD GetExtendedListViewStyle()
|
||||
{ return ListView_GetExtendedListViewStyle(_window); }
|
||||
void SetExtendedListViewStyle(DWORD exStyle)
|
||||
{ ListView_SetExtendedListViewStyle(_window, exStyle); }
|
||||
void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle)
|
||||
{ ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
|
||||
DWORD GetExtendedListViewStyle() { return ListView_GetExtendedListViewStyle(_window); }
|
||||
void SetExtendedListViewStyle(DWORD exStyle) { ListView_SetExtendedListViewStyle(_window, exStyle); }
|
||||
void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle) { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
void SetCheckState(UINT index, bool checkState)
|
||||
{ ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); }
|
||||
#endif
|
||||
bool GetCheckState(UINT index)
|
||||
{ return BOOLToBool(ListView_GetCheckState(_window, index)); }
|
||||
void SetCheckState(UINT index, bool checkState) { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); }
|
||||
bool GetCheckState(UINT index) { return BOOLToBool(ListView_GetCheckState(_window, index)); }
|
||||
|
||||
bool EnsureVisible(int index, bool partialOK) { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
|
||||
|
||||
bool EnsureVisible(int index, bool partialOK)
|
||||
{ return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
|
||||
bool GetItemRect(int index, RECT *rect, int code) { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); }
|
||||
|
||||
bool GetItemRect(int index, RECT *rect, int code)
|
||||
{ return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); }
|
||||
HWND GetEditControl() { return ListView_GetEditControl(_window) ; }
|
||||
HWND EditLabel(int itemIndex) { return ListView_EditLabel(_window, itemIndex) ; }
|
||||
|
||||
HWND GetEditControl()
|
||||
{ return ListView_GetEditControl(_window) ; }
|
||||
HWND EditLabel(int itemIndex)
|
||||
{ return ListView_EditLabel(_window, itemIndex) ; }
|
||||
|
||||
bool RedrawItems(int firstIndex, int lastIndex)
|
||||
{ return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
|
||||
bool RedrawItems(int firstIndex, int lastIndex) { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
|
||||
bool RedrawAllItems()
|
||||
{
|
||||
if (GetItemCount() > 0)
|
||||
return RedrawItems(0, GetItemCount() - 1);
|
||||
return true;
|
||||
}
|
||||
bool RedrawItem(int index)
|
||||
{ return RedrawItems(index, index); }
|
||||
bool RedrawItem(int index) { return RedrawItems(index, index); }
|
||||
|
||||
int HitTest(LPLVHITTESTINFO info)
|
||||
{ return ListView_HitTest(_window, info); }
|
||||
|
||||
COLORREF GetBkColor()
|
||||
{ return ListView_GetBkColor(_window); }
|
||||
int HitTest(LPLVHITTESTINFO info) { return ListView_HitTest(_window, info); }
|
||||
COLORREF GetBkColor() { return ListView_GetBkColor(_window); }
|
||||
bool SetColumnWidth(int iCol, int cx) { return BOOLToBool(ListView_SetColumnWidth(_window, iCol, cx)); }
|
||||
bool SetColumnWidthAuto(int iCol) { return SetColumnWidth(iCol, LVSCW_AUTOSIZE); }
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#ifndef __WINDOWS_CONTROL_PROGRESSBAR_H
|
||||
#define __WINDOWS_CONTROL_PROGRESSBAR_H
|
||||
|
||||
#include "Windows/Window.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
@@ -12,30 +11,21 @@ namespace NControl {
|
||||
class CProgressBar: public CWindow
|
||||
{
|
||||
public:
|
||||
LRESULT SetPos(int pos)
|
||||
{ return SendMessage(PBM_SETPOS, pos, 0); }
|
||||
LRESULT DeltaPos(int increment)
|
||||
{ return SendMessage(PBM_DELTAPOS, increment, 0); }
|
||||
UINT GetPos()
|
||||
{ return (UINT)SendMessage(PBM_GETPOS, 0, 0); }
|
||||
LRESULT SetRange(unsigned short minValue, unsigned short maxValue)
|
||||
{ return SendMessage(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); }
|
||||
DWORD SetRange32(int minValue, int maxValue)
|
||||
{ return (DWORD)SendMessage(PBM_SETRANGE32, minValue, maxValue); }
|
||||
int SetStep(int step)
|
||||
{ return (int)SendMessage(PBM_SETSTEP, step, 0); }
|
||||
LRESULT StepIt()
|
||||
{ return SendMessage(PBM_STEPIT, 0, 0); }
|
||||
|
||||
INT GetRange(bool minValue, PPBRANGE range)
|
||||
{ return (INT)SendMessage(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); }
|
||||
LRESULT SetPos(int pos) { return SendMessage(PBM_SETPOS, pos, 0); }
|
||||
LRESULT DeltaPos(int increment) { return SendMessage(PBM_DELTAPOS, increment, 0); }
|
||||
UINT GetPos() { return (UINT)SendMessage(PBM_GETPOS, 0, 0); }
|
||||
LRESULT SetRange(unsigned short minValue, unsigned short maxValue) { return SendMessage(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); }
|
||||
DWORD SetRange32(int minValue, int maxValue) { return (DWORD)SendMessage(PBM_SETRANGE32, minValue, maxValue); }
|
||||
int SetStep(int step) { return (int)SendMessage(PBM_SETSTEP, step, 0); }
|
||||
LRESULT StepIt() { return SendMessage(PBM_STEPIT, 0, 0); }
|
||||
INT GetRange(bool minValue, PPBRANGE range) { return (INT)SendMessage(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); }
|
||||
|
||||
COLORREF SetBarColor(COLORREF color)
|
||||
{ return (COLORREF)SendMessage(PBM_SETBARCOLOR, 0, color); }
|
||||
COLORREF SetBackgroundColor(COLORREF color)
|
||||
{ return (COLORREF)SendMessage(PBM_SETBKCOLOR, 0, color); }
|
||||
#ifndef UNDER_CE
|
||||
COLORREF SetBarColor(COLORREF color) { return (COLORREF)SendMessage(PBM_SETBARCOLOR, 0, color); }
|
||||
COLORREF SetBackgroundColor(COLORREF color) { return (COLORREF)SendMessage(PBM_SETBKCOLOR, 0, color); }
|
||||
#endif
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#ifndef __WINDOWS_CONTROL_PROPERTYPAGE_H
|
||||
#define __WINDOWS_CONTROL_PROPERTYPAGE_H
|
||||
|
||||
#include "Windows/Control/Dialog.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Dialog.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
@@ -16,21 +15,21 @@ class CPropertyPage: public CDialog
|
||||
public:
|
||||
CPropertyPage(HWND window = NULL): CDialog(window){};
|
||||
|
||||
void Changed() { PropSheet_Changed(GetParent(), HWND(*this)); }
|
||||
void UnChanged() { PropSheet_UnChanged(GetParent(), HWND(*this)); }
|
||||
void Changed() { PropSheet_Changed(GetParent(), (HWND)*this); }
|
||||
void UnChanged() { PropSheet_UnChanged(GetParent(), (HWND)*this); }
|
||||
|
||||
virtual bool OnNotify(UINT controlID, LPNMHDR lParam);
|
||||
|
||||
virtual bool OnKillActive() { return false; } // false = OK
|
||||
virtual bool OnKillActive(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnKillActive(); }
|
||||
virtual bool OnKillActive(const PSHNOTIFY *) { return OnKillActive(); }
|
||||
virtual LONG OnSetActive() { return false; } // false = OK
|
||||
virtual LONG OnSetActive(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnKillActive(); }
|
||||
virtual LONG OnSetActive(const PSHNOTIFY *) { return OnSetActive(); }
|
||||
virtual LONG OnApply() { return PSNRET_NOERROR; }
|
||||
virtual LONG OnApply(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnApply(); }
|
||||
virtual void OnNotifyHelp() { }
|
||||
virtual void OnNotifyHelp(const PSHNOTIFY * /* aPSHNOTIFY */) { OnNotifyHelp(); }
|
||||
virtual void OnReset() { }
|
||||
virtual void OnReset(const PSHNOTIFY * /* aPSHNOTIFY */) { OnReset(); }
|
||||
virtual LONG OnApply(const PSHNOTIFY *) { return OnApply(); }
|
||||
virtual void OnNotifyHelp() {}
|
||||
virtual void OnNotifyHelp(const PSHNOTIFY *) { OnNotifyHelp(); }
|
||||
virtual void OnReset() {}
|
||||
virtual void OnReset(const PSHNOTIFY *) { OnReset(); }
|
||||
};
|
||||
|
||||
struct CPageInfo
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#ifndef __WINDOWS_CONTROL_STATIC_H
|
||||
#define __WINDOWS_CONTROL_STATIC_H
|
||||
|
||||
#include "Windows/Window.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "../Window.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
@@ -12,16 +11,18 @@ namespace NControl {
|
||||
class CStatic: public CWindow
|
||||
{
|
||||
public:
|
||||
HICON SetIcon(HICON icon)
|
||||
{ return (HICON)SendMessage(STM_SETICON, (WPARAM)icon, 0); }
|
||||
HICON GetIcon()
|
||||
{ return (HICON)SendMessage(STM_GETICON, 0, 0); }
|
||||
HANDLE SetImage(WPARAM imageType, HANDLE handle)
|
||||
{ return (HANDLE)SendMessage(STM_SETIMAGE, imageType, (LPARAM)handle); }
|
||||
HANDLE GetImage(WPARAM imageType)
|
||||
{ return (HANDLE)SendMessage(STM_GETIMAGE, imageType, 0); }
|
||||
HANDLE SetImage(WPARAM imageType, HANDLE handle) { return (HANDLE)SendMessage(STM_SETIMAGE, imageType, (LPARAM)handle); }
|
||||
HANDLE GetImage(WPARAM imageType) { return (HANDLE)SendMessage(STM_GETIMAGE, imageType, 0); }
|
||||
|
||||
#ifdef UNDER_CE
|
||||
HICON SetIcon(HICON icon) { return (HICON)SetImage(IMAGE_ICON, icon); }
|
||||
HICON GetIcon() { return (HICON)GetImage(IMAGE_ICON); }
|
||||
#else
|
||||
HICON SetIcon(HICON icon) { return (HICON)SendMessage(STM_SETICON, (WPARAM)icon, 0); }
|
||||
HICON GetIcon() { return (HICON)SendMessage(STM_GETICON, 0, 0); }
|
||||
#endif
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#define __WINDOWS_CONTROL_TOOLBAR_H
|
||||
|
||||
#include "Windows/Window.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
@@ -12,23 +11,33 @@ namespace NControl {
|
||||
class CToolBar: public NWindows::CWindow
|
||||
{
|
||||
public:
|
||||
void AutoSize() { SendMessage(TB_AUTOSIZE, 0, 0); }
|
||||
DWORD GetButtonSize() { return (DWORD)SendMessage(TB_GETBUTTONSIZE, 0, 0); }
|
||||
|
||||
bool GetMaxSize(LPSIZE size)
|
||||
{ return LRESULTToBool(SendMessage(TB_GETMAXSIZE, 0, (LPARAM)size)); }
|
||||
bool EnableButton(UINT buttonID, bool enable)
|
||||
{ return LRESULTToBool(SendMessage(TB_ENABLEBUTTON, buttonID,
|
||||
MAKELONG(BoolToBOOL(enable), 0))); }
|
||||
void ButtonStructSize()
|
||||
{ SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON)); }
|
||||
HIMAGELIST SetImageList(UINT listIndex, HIMAGELIST imageList)
|
||||
{ return HIMAGELIST(SendMessage(TB_SETIMAGELIST, listIndex, (LPARAM)imageList)); }
|
||||
bool AddButton(UINT numButtons, LPTBBUTTON buttons)
|
||||
{ return LRESULTToBool(SendMessage(TB_ADDBUTTONS, numButtons, (LPARAM)buttons)); }
|
||||
#ifdef UNDER_CE
|
||||
{
|
||||
// maybe it must be fixed for more than 1 buttons
|
||||
DWORD val = GetButtonSize();
|
||||
size->cx = LOWORD(val);
|
||||
size->cy = HIWORD(val);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return LRESULTToBool(SendMessage(TB_GETMAXSIZE, 0, (LPARAM)size));
|
||||
}
|
||||
#endif
|
||||
|
||||
bool EnableButton(UINT buttonID, bool enable) { return LRESULTToBool(SendMessage(TB_ENABLEBUTTON, buttonID, MAKELONG(BoolToBOOL(enable), 0))); }
|
||||
void ButtonStructSize() { SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON)); }
|
||||
HIMAGELIST SetImageList(UINT listIndex, HIMAGELIST imageList) { return HIMAGELIST(SendMessage(TB_SETIMAGELIST, listIndex, (LPARAM)imageList)); }
|
||||
bool AddButton(UINT numButtons, LPTBBUTTON buttons) { return LRESULTToBool(SendMessage(TB_ADDBUTTONS, numButtons, (LPARAM)buttons)); }
|
||||
#ifndef _UNICODE
|
||||
bool AddButtonW(UINT numButtons, LPTBBUTTON buttons)
|
||||
{ return LRESULTToBool(SendMessage(TB_ADDBUTTONSW, numButtons, (LPARAM)buttons)); }
|
||||
bool AddButtonW(UINT numButtons, LPTBBUTTON buttons) { return LRESULTToBool(SendMessage(TB_ADDBUTTONSW, numButtons, (LPARAM)buttons)); }
|
||||
#endif
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -20,15 +20,21 @@ ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
|
||||
|
||||
namespace NControl {
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define MY_START_WM_CREATE WM_CREATE
|
||||
#else
|
||||
#define MY_START_WM_CREATE WM_NCCREATE
|
||||
#endif
|
||||
|
||||
static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CWindow tempWindow(aHWND);
|
||||
if (message == WM_NCCREATE)
|
||||
if (message == MY_START_WM_CREATE)
|
||||
tempWindow.SetUserDataLongPtr(
|
||||
LONG_PTR(((LPCREATESTRUCT)lParam)->lpCreateParams));
|
||||
CWindow2 *window = (CWindow2*)(tempWindow.GetUserDataLongPtr());
|
||||
if (window != NULL && message == WM_NCCREATE)
|
||||
if (window != NULL && message == MY_START_WM_CREATE)
|
||||
window->Attach(aHWND);
|
||||
if (window == 0)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#define __WINDOWS_CONTROL_WINDOW2_H
|
||||
|
||||
#include "Windows/Window.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NControl {
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "DLL.h"
|
||||
#include "Defs.h"
|
||||
#ifndef _UNICODE
|
||||
#include "../Common/StringConvert.h"
|
||||
#endif
|
||||
|
||||
#include "DLL.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
@@ -15,11 +15,6 @@ extern bool g_IsNT;
|
||||
namespace NWindows {
|
||||
namespace NDLL {
|
||||
|
||||
CLibrary::~CLibrary()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
bool CLibrary::Free()
|
||||
{
|
||||
if (_module == 0)
|
||||
|
||||
@@ -8,17 +8,25 @@
|
||||
namespace NWindows {
|
||||
namespace NDLL {
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define My_GetProcAddress(module, proceName) GetProcAddressA(module, proceName)
|
||||
#else
|
||||
#define My_GetProcAddress(module, proceName) ::GetProcAddress(module, proceName)
|
||||
#endif
|
||||
|
||||
class CLibrary
|
||||
{
|
||||
bool LoadOperations(HMODULE newModule);
|
||||
protected:
|
||||
HMODULE _module;
|
||||
public:
|
||||
CLibrary(): _module(NULL) {};
|
||||
~CLibrary() { Free(); }
|
||||
|
||||
operator HMODULE() const { return _module; }
|
||||
HMODULE* operator&() { return &_module; }
|
||||
bool IsLoaded() const { return (_module != NULL); };
|
||||
|
||||
CLibrary():_module(NULL) {};
|
||||
~CLibrary();
|
||||
void Attach(HMODULE m)
|
||||
{
|
||||
Free();
|
||||
@@ -31,8 +39,6 @@ public:
|
||||
return m;
|
||||
}
|
||||
|
||||
// operator HMODULE() const { return _module; };
|
||||
bool IsLoaded() const { return (_module != NULL); };
|
||||
bool Free();
|
||||
bool LoadEx(LPCTSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE);
|
||||
bool Load(LPCTSTR fileName);
|
||||
@@ -40,8 +46,7 @@ public:
|
||||
bool LoadEx(LPCWSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE);
|
||||
bool Load(LPCWSTR fileName);
|
||||
#endif
|
||||
FARPROC GetProcAddress(LPCSTR procName) const
|
||||
{ return ::GetProcAddress(_module, procName); }
|
||||
FARPROC GetProc(LPCSTR procName) const { return My_GetProcAddress(_module, procName); }
|
||||
};
|
||||
|
||||
bool MyGetModuleFileName(HMODULE hModule, CSysString &result);
|
||||
|
||||
@@ -38,6 +38,8 @@ static CSysString GetSysPath(LPCWSTR sysPath)
|
||||
{ return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
|
||||
#endif
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
bool MyGetWindowsDirectory(CSysString &path)
|
||||
{
|
||||
UINT needLength = ::GetWindowsDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
|
||||
@@ -52,6 +54,8 @@ bool MyGetSystemDirectory(CSysString &path)
|
||||
return (needLength > 0 && needLength <= MAX_PATH);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool MyGetWindowsDirectory(UString &path)
|
||||
{
|
||||
@@ -441,7 +445,41 @@ bool RemoveDirectoryWithSubItems(const UString &path)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName)
|
||||
{
|
||||
int index;
|
||||
if (!MyGetFullPathName(fileName, resultName, index))
|
||||
return false;
|
||||
resultName = resultName.Left(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetOnlyName(LPCTSTR fileName, CSysString &resultName)
|
||||
{
|
||||
int index;
|
||||
if (!MyGetFullPathName(fileName, resultName, index))
|
||||
return false;
|
||||
resultName = resultName.Mid(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef UNDER_CE
|
||||
bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath)
|
||||
{
|
||||
resultPath = fileName;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex)
|
||||
{
|
||||
resultPath = fileName;
|
||||
// change it
|
||||
fileNamePartStartIndex = resultPath.ReverseFind('\\');
|
||||
fileNamePartStartIndex++;
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath)
|
||||
{
|
||||
@@ -534,15 +572,6 @@ bool MyGetFullPathName(LPCWSTR fileName, UString &path)
|
||||
}
|
||||
#endif
|
||||
|
||||
bool GetOnlyName(LPCTSTR fileName, CSysString &resultName)
|
||||
{
|
||||
int index;
|
||||
if (!MyGetFullPathName(fileName, resultName, index))
|
||||
return false;
|
||||
resultName = resultName.Mid(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool GetOnlyName(LPCWSTR fileName, UString &resultName)
|
||||
{
|
||||
@@ -554,15 +583,6 @@ bool GetOnlyName(LPCWSTR fileName, UString &resultName)
|
||||
}
|
||||
#endif
|
||||
|
||||
bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName)
|
||||
{
|
||||
int index;
|
||||
if (!MyGetFullPathName(fileName, resultName, index))
|
||||
return false;
|
||||
resultName = resultName.Left(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName)
|
||||
{
|
||||
@@ -603,7 +623,6 @@ bool MyGetCurrentDirectory(UString &path)
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
|
||||
CSysString &resultPath, UINT32 &filePart)
|
||||
@@ -615,6 +634,7 @@ bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
|
||||
resultPath.ReleaseBuffer();
|
||||
return (value > 0 && value <= MAX_PATH);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
|
||||
@@ -715,9 +735,13 @@ bool CTempFile::Create(LPCTSTR prefix, CSysString &resultPath)
|
||||
return false;
|
||||
if (Create(tempPath, prefix, resultPath) != 0)
|
||||
return true;
|
||||
#ifdef UNDER_CE
|
||||
return false;
|
||||
#else
|
||||
if (!MyGetWindowsDirectory(tempPath))
|
||||
return false;
|
||||
return (Create(tempPath, prefix, resultPath) != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CTempFile::Remove()
|
||||
|
||||
@@ -41,14 +41,16 @@ bool DeleteFileAlways(LPCWSTR name);
|
||||
bool RemoveDirectoryWithSubItems(const UString &path);
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
|
||||
bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
|
||||
#ifdef UNDER_CE
|
||||
bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath);
|
||||
bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex);
|
||||
#else
|
||||
bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath);
|
||||
|
||||
bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
|
||||
int &fileNamePartStartIndex);
|
||||
bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, int &fileNamePartStartIndex);
|
||||
bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath);
|
||||
bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
|
||||
bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
|
||||
#ifndef _UNICODE
|
||||
bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
|
||||
int &fileNamePartStartIndex);
|
||||
@@ -64,31 +66,28 @@ bool MyGetCurrentDirectory(CSysString &resultPath);
|
||||
bool MySetCurrentDirectory(LPCWSTR path);
|
||||
bool MyGetCurrentDirectory(UString &resultPath);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
|
||||
CSysString &resultPath, UINT32 &filePart);
|
||||
bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, CSysString &resultPath, UINT32 &filePart);
|
||||
#ifndef _UNICODE
|
||||
bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
|
||||
UString &resultPath, UINT32 &filePart);
|
||||
bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, UString &resultPath, UINT32 &filePart);
|
||||
#endif
|
||||
|
||||
inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
|
||||
CSysString &resultPath)
|
||||
inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, CSysString &resultPath)
|
||||
{
|
||||
UINT32 value;
|
||||
return MySearchPath(path, fileName, extension, resultPath, value);
|
||||
}
|
||||
|
||||
#ifndef _UNICODE
|
||||
inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
|
||||
UString &resultPath)
|
||||
inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, UString &resultPath)
|
||||
{
|
||||
UINT32 value;
|
||||
return MySearchPath(path, fileName, extension, resultPath, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
bool MyGetTempPath(CSysString &resultPath);
|
||||
#ifndef _UNICODE
|
||||
bool MyGetTempPath(UString &resultPath);
|
||||
|
||||
@@ -61,10 +61,10 @@ bool CFileInfoW::IsDots() const
|
||||
fi.IsDevice = false;
|
||||
|
||||
/*
|
||||
#ifndef _WIN32_WCE
|
||||
fi.ReparseTag = fd.dwReserved0;
|
||||
#else
|
||||
#ifdef UNDER_CE
|
||||
fi.ObjectID = fd.dwOID;
|
||||
#else
|
||||
fi.ReparseTag = fd.dwReserved0;
|
||||
#endif
|
||||
*/
|
||||
|
||||
@@ -390,7 +390,7 @@ HANDLE CFindChangeNotification::FindFirst(LPCWSTR pathName, bool watchSubtree, D
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
#ifndef UNDER_CE
|
||||
bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings)
|
||||
{
|
||||
driveStrings.Clear();
|
||||
|
||||
@@ -37,10 +37,10 @@ public:
|
||||
bool IsDevice;
|
||||
|
||||
/*
|
||||
#ifndef _WIN32_WCE
|
||||
UINT32 ReparseTag;
|
||||
#else
|
||||
#ifdef UNDER_CE
|
||||
DWORD ObjectID;
|
||||
#else
|
||||
UINT32 ReparseTag;
|
||||
#endif
|
||||
*/
|
||||
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
bool FindNext() { return BOOLToBool(::FindNextChangeNotification(_handle)); }
|
||||
};
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
#ifndef UNDER_CE
|
||||
bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings);
|
||||
#ifndef _UNICODE
|
||||
bool MyGetLogicalDriveStrings(UStringVector &driveStrings);
|
||||
|
||||
@@ -21,6 +21,14 @@ namespace NFile {
|
||||
#ifdef SUPPORT_DEVICE_FILE
|
||||
bool IsDeviceName(LPCTSTR n)
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
int len = (int)MyStringLen(n);
|
||||
if (len < 5 || len > 5 || memcmp(n, TEXT("DSK"), 3 * sizeof(TCHAR)) != 0)
|
||||
return false;
|
||||
if (n[4] != ':')
|
||||
return false;
|
||||
// for reading use SG_REQ sg; if (DeviceIoControl(dsk, IOCTL_DISK_READ));
|
||||
#else
|
||||
if (n[0] != '\\' || n[1] != '\\' || n[2] != '.' || n[3] != '\\')
|
||||
return false;
|
||||
int len = (int)MyStringLen(n);
|
||||
@@ -31,6 +39,7 @@ bool IsDeviceName(LPCTSTR n)
|
||||
for (int i = 17; i < len; i++)
|
||||
if (n[i] < '0' || n[i] > '9')
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -241,6 +250,11 @@ void CInFile::GetDeviceLength()
|
||||
{
|
||||
if (_handle != INVALID_HANDLE_VALUE && IsDeviceFile)
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
LengthDefined = true;
|
||||
Length = 128 << 20;
|
||||
|
||||
#else
|
||||
PARTITION_INFORMATION partInfo;
|
||||
LengthDefined = true;
|
||||
Length = 0;
|
||||
@@ -257,6 +271,7 @@ void CInFile::GetDeviceLength()
|
||||
Length = geom.Cylinders.QuadPart * geom.TracksPerCylinder * geom.SectorsPerTrack * geom.BytesPerSector;
|
||||
}
|
||||
// SeekToBegin();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,10 +375,10 @@ bool COutFile::Create(LPCTSTR fileName, bool createAlways)
|
||||
#ifndef _UNICODE
|
||||
|
||||
bool COutFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
|
||||
{ return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
|
||||
{ return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
|
||||
|
||||
bool COutFile::Open(LPCWSTR fileName, DWORD creationDisposition)
|
||||
{ return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
|
||||
{ return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
|
||||
|
||||
bool COutFile::Create(LPCWSTR fileName, bool createAlways)
|
||||
{ return Open(fileName, GetCreationDisposition(createAlways)); }
|
||||
|
||||
@@ -29,10 +29,10 @@ protected:
|
||||
HANDLE _handle;
|
||||
|
||||
bool Create(LPCTSTR fileName, DWORD desiredAccess,
|
||||
DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
|
||||
DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
|
||||
#ifndef _UNICODE
|
||||
bool Create(LPCWSTR fileName, DWORD desiredAccess,
|
||||
DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
|
||||
DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
|
||||
#endif
|
||||
|
||||
public:
|
||||
@@ -82,6 +82,7 @@ class CInFile: public CFileBase
|
||||
bool DeviceIoControlOut(DWORD controlCode, LPVOID outBuffer, DWORD outSize) const
|
||||
{ return DeviceIoControl(controlCode, NULL, 0, outBuffer, outSize); }
|
||||
|
||||
#ifndef UNDER_CE
|
||||
bool GetGeometry(DISK_GEOMETRY *res) const
|
||||
{ return DeviceIoControlOut(IOCTL_DISK_GET_DRIVE_GEOMETRY, res, sizeof(*res)); }
|
||||
|
||||
@@ -90,6 +91,7 @@ class CInFile: public CFileBase
|
||||
|
||||
bool GetPartitionInfo(PARTITION_INFORMATION *res)
|
||||
{ return DeviceIoControlOut(IOCTL_DISK_GET_PARTITION_INFO, LPVOID(res), sizeof(*res)); }
|
||||
#endif
|
||||
|
||||
void GetDeviceLength();
|
||||
#endif
|
||||
|
||||
@@ -3,46 +3,58 @@
|
||||
#ifndef __WINDOWS_FILEMAPPING_H
|
||||
#define __WINDOWS_FILEMAPPING_H
|
||||
|
||||
#include "Windows/Handle.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Common/Types.h"
|
||||
|
||||
#include "Handle.h"
|
||||
|
||||
namespace NWindows {
|
||||
// namespace NFile {
|
||||
// namespace NMapping {
|
||||
|
||||
class CFileMapping: public CHandle
|
||||
{
|
||||
public:
|
||||
bool Create(HANDLE file, LPSECURITY_ATTRIBUTES attributes,
|
||||
DWORD protect, UINT64 maximumSize, LPCTSTR name)
|
||||
WRes Create(DWORD protect, UInt64 maxSize, LPCTSTR name)
|
||||
{
|
||||
_handle = ::CreateFileMapping(file, attributes,
|
||||
protect, DWORD(maximumSize >> 32), DWORD(maximumSize), name);
|
||||
return (_handle != NULL);
|
||||
_handle = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, protect, (DWORD)(maxSize >> 32), (DWORD)maxSize, name);
|
||||
return ::GetLastError();
|
||||
}
|
||||
|
||||
bool Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name)
|
||||
WRes Open(DWORD desiredAccess, LPCTSTR name)
|
||||
{
|
||||
_handle = ::OpenFileMapping(desiredAccess, BoolToBOOL(inheritHandle), name);
|
||||
return (_handle != NULL);
|
||||
#ifdef UNDER_CE
|
||||
WRes res = Create(PAGE_READONLY, 0, name);
|
||||
if (res == ERROR_ALREADY_EXISTS)
|
||||
return 0;
|
||||
Close();
|
||||
if (res == 0)
|
||||
res = ERROR_FILE_NOT_FOUND;
|
||||
return res;
|
||||
#else
|
||||
_handle = ::OpenFileMapping(desiredAccess, FALSE, name);
|
||||
if (_handle != 0)
|
||||
return 0;
|
||||
return ::GetLastError();
|
||||
#endif
|
||||
}
|
||||
|
||||
LPVOID MapViewOfFile(DWORD desiredAccess, UINT64 fileOffset,
|
||||
SIZE_T numberOfBytesToMap)
|
||||
LPVOID Map(DWORD desiredAccess, UInt64 fileOffset, SIZE_T numberOfBytesToMap)
|
||||
{
|
||||
return ::MapViewOfFile(_handle, desiredAccess,
|
||||
DWORD(fileOffset >> 32), DWORD(fileOffset), numberOfBytesToMap);
|
||||
return ::MapViewOfFile(_handle, desiredAccess, (DWORD)(fileOffset >> 32), (DWORD)fileOffset, numberOfBytesToMap);
|
||||
}
|
||||
|
||||
LPVOID MapViewOfFileEx(DWORD desiredAccess, UINT64 fileOffset,
|
||||
SIZE_T numberOfBytesToMap, LPVOID baseAddress)
|
||||
#ifndef UNDER_CE
|
||||
LPVOID Map(DWORD desiredAccess, UInt64 fileOffset, SIZE_T numberOfBytesToMap, LPVOID baseAddress)
|
||||
{
|
||||
return ::MapViewOfFileEx(_handle, desiredAccess,
|
||||
DWORD(fileOffset >> 32), DWORD(fileOffset),
|
||||
numberOfBytesToMap, baseAddress);
|
||||
return ::MapViewOfFileEx(_handle, desiredAccess, (DWORD)(fileOffset >> 32), (DWORD)fileOffset, numberOfBytesToMap, baseAddress);
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
class CFileUnmapper
|
||||
{
|
||||
const void *_data;
|
||||
public:
|
||||
CFileUnmapper(const void *data) : _data(data) {}
|
||||
~CFileUnmapper() { ::UnmapViewOfFile(_data); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
operator HANDLE() { return _handle; }
|
||||
CHandle(): _handle(NULL) {}
|
||||
~CHandle() { Close(); }
|
||||
bool IsCreated() const { return (_handle != NULL); }
|
||||
bool Close()
|
||||
{
|
||||
if (_handle == NULL)
|
||||
@@ -22,8 +23,7 @@ public:
|
||||
_handle = NULL;
|
||||
return true;
|
||||
}
|
||||
void Attach(HANDLE handle)
|
||||
{ _handle = handle; }
|
||||
void Attach(HANDLE handle) { _handle = handle; }
|
||||
HANDLE Detach()
|
||||
{
|
||||
HANDLE handle = _handle;
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
namespace NWindows {
|
||||
namespace NMemory {
|
||||
|
||||
CGlobal::~CGlobal()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
bool CGlobal::Alloc(UINT flags, SIZE_T size)
|
||||
{
|
||||
HGLOBAL newBlock = ::GlobalAlloc(flags, size);
|
||||
@@ -29,29 +24,6 @@ bool CGlobal::Free()
|
||||
return (m_MemoryHandle == NULL);
|
||||
}
|
||||
|
||||
void CGlobal::Attach(HGLOBAL hGlobal)
|
||||
{
|
||||
Free();
|
||||
m_MemoryHandle = hGlobal;
|
||||
}
|
||||
|
||||
HGLOBAL CGlobal::Detach()
|
||||
{
|
||||
HGLOBAL h = m_MemoryHandle;
|
||||
m_MemoryHandle = NULL;
|
||||
return h;
|
||||
}
|
||||
|
||||
LPVOID CGlobal::Lock() const
|
||||
{
|
||||
return ::GlobalLock(m_MemoryHandle);
|
||||
}
|
||||
|
||||
void CGlobal::Unlock() const
|
||||
{
|
||||
::GlobalUnlock(m_MemoryHandle);
|
||||
}
|
||||
|
||||
bool CGlobal::ReAlloc(SIZE_T size)
|
||||
{
|
||||
HGLOBAL newBlock = ::GlobalReAlloc(m_MemoryHandle, size, GMEM_MOVEABLE);
|
||||
|
||||
@@ -11,18 +11,26 @@ class CGlobal
|
||||
HGLOBAL m_MemoryHandle;
|
||||
public:
|
||||
CGlobal(): m_MemoryHandle(NULL){};
|
||||
~CGlobal();
|
||||
~CGlobal() { Free(); }
|
||||
operator HGLOBAL() const { return m_MemoryHandle; };
|
||||
void Attach(HGLOBAL hGlobal);
|
||||
HGLOBAL Detach();
|
||||
void Attach(HGLOBAL hGlobal)
|
||||
{
|
||||
Free();
|
||||
m_MemoryHandle = hGlobal;
|
||||
}
|
||||
HGLOBAL Detach()
|
||||
{
|
||||
HGLOBAL h = m_MemoryHandle;
|
||||
m_MemoryHandle = NULL;
|
||||
return h;
|
||||
}
|
||||
bool Alloc(UINT flags, SIZE_T size);
|
||||
bool Free();
|
||||
LPVOID Lock() const;
|
||||
void Unlock() const;
|
||||
LPVOID Lock() const { return GlobalLock(m_MemoryHandle); }
|
||||
void Unlock() const { GlobalUnlock(m_MemoryHandle); }
|
||||
bool ReAlloc(SIZE_T size);
|
||||
};
|
||||
|
||||
|
||||
class CGlobalLock
|
||||
{
|
||||
HGLOBAL m_Global;
|
||||
@@ -31,12 +39,12 @@ public:
|
||||
LPVOID GetPointer() const { return m_Pointer; }
|
||||
CGlobalLock(HGLOBAL hGlobal): m_Global(hGlobal)
|
||||
{
|
||||
m_Pointer = ::GlobalLock(hGlobal);
|
||||
m_Pointer = GlobalLock(hGlobal);
|
||||
};
|
||||
~CGlobalLock()
|
||||
{
|
||||
if (m_Pointer != NULL)
|
||||
::GlobalUnlock(m_Global);
|
||||
GlobalUnlock(m_Global);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
namespace NWindows {
|
||||
namespace NSecurity {
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
#ifndef _UNICODE
|
||||
typedef BOOL (WINAPI * OpenProcessTokenP)(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle);
|
||||
typedef BOOL (WINAPI * LookupPrivilegeValueP)(LPCTSTR lpSystemName, LPCTSTR lpName, PLUID lpLuid);
|
||||
@@ -75,4 +77,6 @@ bool EnableLockMemoryPrivilege(bool enable)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
namespace NWindows {
|
||||
namespace NSecurity {
|
||||
|
||||
#ifndef UNDER_CE
|
||||
bool EnableLockMemoryPrivilege(bool enable = true);
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -161,7 +161,20 @@ bool CMenu::InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item)
|
||||
ConvertItemToSysForm(item, si);
|
||||
if (item.IsString())
|
||||
si.dwTypeData = (LPWSTR)(LPCWSTR)item.StringValue;
|
||||
#ifdef UNDER_CE
|
||||
UINT flags = (item.fType & MFT_SEPARATOR) ? MF_SEPARATOR : MF_STRING;
|
||||
UINT id = item.wID;
|
||||
if ((item.fMask & MIIM_SUBMENU) != 0)
|
||||
{
|
||||
flags |= MF_POPUP;
|
||||
id = (UINT)item.hSubMenu;
|
||||
}
|
||||
if (!Insert(itemIndex, flags | (byPosition ? MF_BYPOSITION : MF_BYCOMMAND), id, item.StringValue))
|
||||
return false;
|
||||
return SetItemInfo(itemIndex, byPosition, &si);
|
||||
#else
|
||||
return InsertItem(itemIndex, byPosition, &si);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ struct CMenuItem
|
||||
// HBITMAP hbmpItem;
|
||||
bool IsString() const // change it MIIM_STRING
|
||||
{ return ((fMask & MIIM_TYPE) != 0 && (fType == MFT_STRING)); }
|
||||
bool IsSeparator() const { return (fType == MFT_SEPARATOR); }
|
||||
CMenuItem(): fMask(0), fType(0), fState(0), wID(0), hSubMenu(0), hbmpChecked(0),
|
||||
hbmpUnchecked(0), dwItemData(0) {}
|
||||
};
|
||||
@@ -63,23 +64,33 @@ public:
|
||||
}
|
||||
|
||||
int GetItemCount()
|
||||
{ return GetMenuItemCount(_menu); }
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
for (int i = 0;; i++)
|
||||
{
|
||||
CMenuItem item;
|
||||
item.fMask = MIIM_STATE;
|
||||
if (!GetItem(i, true, item))
|
||||
return i;
|
||||
}
|
||||
#else
|
||||
return GetMenuItemCount(_menu);
|
||||
#endif
|
||||
}
|
||||
|
||||
HMENU GetSubMenu(int pos)
|
||||
{ return ::GetSubMenu(_menu, pos); }
|
||||
HMENU GetSubMenu(int pos) { return ::GetSubMenu(_menu, pos); }
|
||||
#ifndef UNDER_CE
|
||||
bool GetItemString(UINT idItem, UINT flag, CSysString &result)
|
||||
{
|
||||
result.Empty();
|
||||
int len = ::GetMenuString(_menu, idItem, 0, 0, flag);
|
||||
len = ::GetMenuString(_menu, idItem, result.GetBuffer(len + 2),
|
||||
len + 1, flag);
|
||||
len = ::GetMenuString(_menu, idItem, result.GetBuffer(len + 2), len + 1, flag);
|
||||
result.ReleaseBuffer();
|
||||
return (len != 0);
|
||||
}
|
||||
UINT GetItemID(int pos)
|
||||
{ return ::GetMenuItemID(_menu, pos); }
|
||||
UINT GetItemState(UINT id, UINT flags)
|
||||
{ return ::GetMenuState(_menu, id, flags); }
|
||||
UINT GetItemID(int pos) { return ::GetMenuItemID(_menu, pos); }
|
||||
UINT GetItemState(UINT id, UINT flags) { return ::GetMenuState(_menu, id, flags); }
|
||||
#endif
|
||||
|
||||
bool GetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFO itemInfo)
|
||||
{ return BOOLToBool(::GetMenuItemInfo(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); }
|
||||
@@ -92,11 +103,14 @@ public:
|
||||
bool Insert(UINT position, UINT flags, UINT_PTR idNewItem, LPCTSTR newItem)
|
||||
{ return BOOLToBool(::InsertMenu(_menu, position, flags, idNewItem, newItem)); }
|
||||
|
||||
#ifndef UNDER_CE
|
||||
bool InsertItem(UINT itemIndex, bool byPosition, LPCMENUITEMINFO itemInfo)
|
||||
{ return BOOLToBool(::InsertMenuItem(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); }
|
||||
#endif
|
||||
|
||||
bool RemoveItem(UINT item, UINT flags)
|
||||
{ return BOOLToBool(::RemoveMenu(_menu, item, flags)); }
|
||||
bool RemoveItem(UINT item, UINT flags) { return BOOLToBool(::RemoveMenu(_menu, item, flags)); }
|
||||
void RemoveAllItemsFrom(UINT index) { while (RemoveItem(index, MF_BYPOSITION)); }
|
||||
void RemoveAllItems() { RemoveAllItemsFrom(0); }
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool GetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFOW itemInfo)
|
||||
@@ -112,16 +126,15 @@ public:
|
||||
bool SetItem(UINT itemIndex, bool byPosition, const CMenuItem &item);
|
||||
bool InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item);
|
||||
|
||||
int Track(UINT flags, int x, int y, HWND hWnd)
|
||||
{ return ::TrackPopupMenuEx(_menu, flags, x, y, hWnd, NULL); }
|
||||
int Track(UINT flags, int x, int y, HWND hWnd) { return ::TrackPopupMenuEx(_menu, flags, x, y, hWnd, NULL); }
|
||||
|
||||
bool CheckRadioItem(UINT idFirst, UINT idLast, UINT idCheck, UINT flags)
|
||||
{ return BOOLToBool(::CheckMenuRadioItem(_menu, idFirst, idLast, idCheck, flags)); }
|
||||
DWORD CheckItem(UINT id, UINT uCheck)
|
||||
{ return ::CheckMenuItem(_menu, id, uCheck); }
|
||||
|
||||
BOOL EnableItem(UINT uIDEnableItem, UINT uEnable)
|
||||
{ return EnableMenuItem(_menu, uIDEnableItem, uEnable); }
|
||||
DWORD CheckItem(UINT id, UINT uCheck) { return ::CheckMenuItem(_menu, id, uCheck); }
|
||||
DWORD CheckItemByID(UINT id, bool check) { return CheckItem(id, MF_BYCOMMAND | (check ? MF_CHECKED : MF_UNCHECKED)); }
|
||||
|
||||
BOOL EnableItem(UINT uIDEnableItem, UINT uEnable) { return EnableMenuItem(_menu, uIDEnableItem, uEnable); }
|
||||
};
|
||||
|
||||
class CMenuDestroyer
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Windows/Net.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
#include "Common/StringConvert.h"
|
||||
#endif
|
||||
|
||||
#include "Windows/Net.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
@@ -105,7 +105,7 @@ static void SetComplexString2(LPWSTR *destString, bool defined, const UString &s
|
||||
*destString = 0;
|
||||
}
|
||||
|
||||
static void ConvertCResourceToNETRESOURCE(const CResourceW &resource, NETRESOURCEW &netResource)
|
||||
static void ConvertCResourceToNETRESOURCE(const CResourceW &resource, NETRESOURCEW &netResource)
|
||||
{
|
||||
netResource.dwScope = resource.Scope;
|
||||
netResource.dwType = resource.Type;
|
||||
@@ -209,7 +209,7 @@ DWORD CEnum::Next(CResource &resource)
|
||||
ZeroMemory(lpnrLocal, kBufferSize);
|
||||
DWORD bufferSize = kBufferSize;
|
||||
DWORD numEntries = 1;
|
||||
DWORD result = Next(&numEntries, lpnrLocal, &bufferSize);
|
||||
DWORD result = Next(&numEntries, lpnrLocal, &bufferSize);
|
||||
if (result != NO_ERROR)
|
||||
return result;
|
||||
if (numEntries != 1)
|
||||
@@ -230,7 +230,7 @@ DWORD CEnum::Next(CResourceW &resource)
|
||||
ZeroMemory(lpnrLocal, kBufferSize);
|
||||
DWORD bufferSize = kBufferSize;
|
||||
DWORD numEntries = 1;
|
||||
DWORD result = NextW(&numEntries, lpnrLocal, &bufferSize);
|
||||
DWORD result = NextW(&numEntries, lpnrLocal, &bufferSize);
|
||||
if (result != NO_ERROR)
|
||||
return result;
|
||||
if (numEntries != 1)
|
||||
@@ -256,7 +256,7 @@ DWORD GetResourceParent(const CResource &resource, CResource &parentResource)
|
||||
DWORD bufferSize = kBufferSize;
|
||||
NETRESOURCE netResource;
|
||||
ConvertCResourceToNETRESOURCE(resource, netResource);
|
||||
DWORD result = ::WNetGetResourceParent(&netResource, lpnrLocal, &bufferSize);
|
||||
DWORD result = ::WNetGetResourceParent(&netResource, lpnrLocal, &bufferSize);
|
||||
if (result != NO_ERROR)
|
||||
return result;
|
||||
ConvertNETRESOURCEToCResource(lpnrLocal[0], parentResource);
|
||||
@@ -276,7 +276,7 @@ DWORD GetResourceParent(const CResourceW &resource, CResourceW &parentResource)
|
||||
DWORD bufferSize = kBufferSize;
|
||||
NETRESOURCEW netResource;
|
||||
ConvertCResourceToNETRESOURCE(resource, netResource);
|
||||
DWORD result = ::WNetGetResourceParentW(&netResource, lpnrLocal, &bufferSize);
|
||||
DWORD result = ::WNetGetResourceParentW(&netResource, lpnrLocal, &bufferSize);
|
||||
if (result != NO_ERROR)
|
||||
return result;
|
||||
ConvertNETRESOURCEToCResource(lpnrLocal[0], parentResource);
|
||||
|
||||
44
CPP/Windows/NtCheck.h
Executable file
44
CPP/Windows/NtCheck.h
Executable file
@@ -0,0 +1,44 @@
|
||||
// Windows/NtCheck.h
|
||||
|
||||
#ifndef __WINDOWS_NT_CHECK_H
|
||||
#define __WINDOWS_NT_CHECK_H
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
static inline bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO vi;
|
||||
vi.dwOSVersionInfoSize = sizeof(vi);
|
||||
return (::GetVersionEx(&vi) && vi.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _UNICODE
|
||||
#if defined(_WIN64) || defined(UNDER_CE)
|
||||
bool g_IsNT = true;
|
||||
#define SET_IS_NT
|
||||
#else
|
||||
bool g_IsNT = false;
|
||||
#define SET_IS_NT g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
#define NT_CHECK_ACTION
|
||||
// #define NT_CHECK_ACTION { NT_CHECK_FAIL_ACTION }
|
||||
#else
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
#define NT_CHECK_ACTION if (!IsItWindowsNT()) { NT_CHECK_FAIL_ACTION }
|
||||
#else
|
||||
#define NT_CHECK_ACTION
|
||||
#endif
|
||||
#define SET_IS_NT
|
||||
#endif
|
||||
|
||||
#define NT_CHECK NT_CHECK_ACTION SET_IS_NT
|
||||
|
||||
#else
|
||||
|
||||
#define NT_CHECK
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
81
CPP/Windows/Process.cpp
Executable file
81
CPP/Windows/Process.cpp
Executable file
@@ -0,0 +1,81 @@
|
||||
// Process.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../Common/StringConvert.h"
|
||||
|
||||
#include "Process.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif _UNICODE
|
||||
|
||||
namespace NWindows {
|
||||
|
||||
static UString GetQuotedString(const UString &s)
|
||||
{
|
||||
return UString(L'\"') + s + UString(L'\"');
|
||||
}
|
||||
|
||||
WRes CProcess::Create(LPCWSTR imageName, const UString ¶ms, LPCWSTR curDir)
|
||||
{
|
||||
Close();
|
||||
const UString params2 =
|
||||
#ifndef UNDER_CE
|
||||
GetQuotedString(imageName) + L' ' +
|
||||
#endif
|
||||
params;
|
||||
#ifdef UNDER_CE
|
||||
curDir = 0;
|
||||
#else
|
||||
imageName = 0;
|
||||
#endif
|
||||
PROCESS_INFORMATION pi;
|
||||
BOOL result;
|
||||
#ifndef _UNICODE
|
||||
if (!g_IsNT)
|
||||
{
|
||||
STARTUPINFOA si;
|
||||
si.cb = sizeof(si);
|
||||
si.lpReserved = 0;
|
||||
si.lpDesktop = 0;
|
||||
si.lpTitle = 0;
|
||||
si.dwFlags = 0;
|
||||
si.cbReserved2 = 0;
|
||||
si.lpReserved2 = 0;
|
||||
|
||||
CSysString curDirA;
|
||||
if (curDir != 0)
|
||||
curDirA = GetSystemString(curDir);
|
||||
result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params2),
|
||||
NULL, NULL, FALSE, 0, NULL, ((curDir != 0) ? (LPCSTR)curDirA: 0), &si, &pi);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
STARTUPINFOW si;
|
||||
si.cb = sizeof(si);
|
||||
si.lpReserved = 0;
|
||||
si.lpDesktop = 0;
|
||||
si.lpTitle = 0;
|
||||
si.dwFlags = 0;
|
||||
si.cbReserved2 = 0;
|
||||
si.lpReserved2 = 0;
|
||||
|
||||
result = CreateProcessW(imageName, (LPWSTR)(LPCWSTR)params2,
|
||||
NULL, NULL, FALSE, 0, NULL, (LPWSTR)curDir, &si, &pi);
|
||||
}
|
||||
if (result == 0)
|
||||
return ::GetLastError();
|
||||
::CloseHandle(pi.hThread);
|
||||
_handle = pi.hProcess;
|
||||
return 0;
|
||||
}
|
||||
|
||||
WRes MyCreateProcess(LPCWSTR imageName, const UString ¶ms)
|
||||
{
|
||||
CProcess process;
|
||||
return process.Create(imageName, params, 0);
|
||||
}
|
||||
|
||||
}
|
||||
100
CPP/Windows/Process.h
Executable file
100
CPP/Windows/Process.h
Executable file
@@ -0,0 +1,100 @@
|
||||
// Windows/Process.h
|
||||
|
||||
#ifndef __WINDOWS_PROCESS_H
|
||||
#define __WINDOWS_PROCESS_H
|
||||
|
||||
#include <psapi.h>
|
||||
|
||||
#include "../Common/MyString.h"
|
||||
|
||||
#include "Defs.h"
|
||||
#include "Handle.h"
|
||||
|
||||
namespace NWindows {
|
||||
|
||||
class CProcess: public CHandle
|
||||
{
|
||||
public:
|
||||
bool Open(DWORD desiredAccess, bool inheritHandle, DWORD processId)
|
||||
{
|
||||
_handle = ::OpenProcess(desiredAccess, inheritHandle, processId);
|
||||
return (_handle != 0);
|
||||
}
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
bool GetExitCodeProcess(LPDWORD lpExitCode) { return BOOLToBool(::GetExitCodeProcess(_handle, lpExitCode)); }
|
||||
bool Terminate(UINT exitCode) { return BOOLToBool(::TerminateProcess(_handle, exitCode)); }
|
||||
#if(WINVER >= 0x0500)
|
||||
DWORD GetGuiResources (DWORD uiFlags) { return ::GetGuiResources(_handle, uiFlags); }
|
||||
#endif
|
||||
bool SetPriorityClass(DWORD dwPriorityClass) { return BOOLToBool(::SetPriorityClass(_handle, dwPriorityClass)); }
|
||||
DWORD GetPriorityClass() { return ::GetPriorityClass(_handle); }
|
||||
bool GetIoCounters(PIO_COUNTERS lpIoCounters ) { return BOOLToBool(::GetProcessIoCounters(_handle, lpIoCounters )); }
|
||||
|
||||
bool GetTimes(LPFILETIME creationTime, LPFILETIME exitTime, LPFILETIME kernelTime, LPFILETIME userTime)
|
||||
{ return BOOLToBool(::GetProcessTimes(_handle, creationTime, exitTime, kernelTime, userTime)); }
|
||||
|
||||
DWORD WaitForInputIdle(DWORD milliseconds) { return ::WaitForInputIdle(_handle, milliseconds); }
|
||||
|
||||
// Debug
|
||||
|
||||
bool ReadMemory(LPCVOID baseAddress, LPVOID buffer, SIZE_T size, SIZE_T* numberOfBytesRead)
|
||||
{ return BOOLToBool(::ReadProcessMemory(_handle, baseAddress, buffer, size, numberOfBytesRead)); }
|
||||
|
||||
bool WriteMemory(LPVOID baseAddress, LPCVOID buffer, SIZE_T size, SIZE_T* numberOfBytesWritten)
|
||||
{ return BOOLToBool(::WriteProcessMemory(_handle, baseAddress, buffer, size, numberOfBytesWritten)); }
|
||||
|
||||
bool FlushInstructionCache(LPCVOID baseAddress = 0, SIZE_T size = 0)
|
||||
{ return BOOLToBool(::FlushInstructionCache(_handle, baseAddress, size)); }
|
||||
|
||||
LPVOID VirtualAlloc(LPVOID address, SIZE_T size, DWORD allocationType, DWORD protect)
|
||||
{ return VirtualAllocEx(_handle, address, size, allocationType, protect); }
|
||||
|
||||
bool VirtualFree(LPVOID address, SIZE_T size, DWORD freeType)
|
||||
{ return BOOLToBool(::VirtualFreeEx(_handle, address, size, freeType)); }
|
||||
|
||||
// Process Status API (PSAPI)
|
||||
|
||||
bool EmptyWorkingSet()
|
||||
{ return BOOLToBool(::EmptyWorkingSet(_handle)); }
|
||||
bool EnumModules(HMODULE *hModules, DWORD arraySizeInBytes, LPDWORD receivedBytes)
|
||||
{ return BOOLToBool(::EnumProcessModules(_handle, hModules, arraySizeInBytes, receivedBytes)); }
|
||||
|
||||
DWORD MyGetModuleBaseName(HMODULE hModule, LPTSTR baseName, DWORD size)
|
||||
{ return ::GetModuleBaseName(_handle, hModule, baseName, size); }
|
||||
bool MyGetModuleBaseName(HMODULE hModule, CSysString &name)
|
||||
{
|
||||
const int length = 1000;
|
||||
DWORD resultLen = MyGetModuleBaseName(hModule, name.GetBuffer(length), length);
|
||||
name.ReleaseBuffer();
|
||||
return (resultLen != 0);
|
||||
}
|
||||
|
||||
DWORD MyGetModuleFileNameEx(HMODULE hModule, LPTSTR baseName, DWORD size)
|
||||
{ return ::GetModuleFileNameEx(_handle, hModule, baseName, size); }
|
||||
bool MyGetModuleFileNameEx(HMODULE hModule, CSysString &name)
|
||||
{
|
||||
const int length = MAX_PATH + 100;
|
||||
DWORD resultLen = MyGetModuleFileNameEx(hModule, name.GetBuffer(length), length);
|
||||
name.ReleaseBuffer();
|
||||
return (resultLen != 0);
|
||||
}
|
||||
|
||||
bool GetModuleInformation(HMODULE hModule, LPMODULEINFO moduleInfo)
|
||||
{ return BOOLToBool(::GetModuleInformation(_handle, hModule, moduleInfo, sizeof(MODULEINFO))); }
|
||||
bool GetMemoryInfo(PPROCESS_MEMORY_COUNTERS memCounters)
|
||||
{ return BOOLToBool(::GetProcessMemoryInfo(_handle, memCounters, sizeof(PROCESS_MEMORY_COUNTERS))); }
|
||||
|
||||
#endif
|
||||
|
||||
WRes Create(LPCWSTR imageName, const UString ¶ms, LPCWSTR curDir);
|
||||
|
||||
DWORD Wait() { return ::WaitForSingleObject(_handle, INFINITE); }
|
||||
};
|
||||
|
||||
WRes MyCreateProcess(LPCWSTR imageName, const UString ¶ms);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "PropVariantConversions.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "PropVariantConversions.h"
|
||||
|
||||
static UString ConvertUInt64ToString(UInt64 value)
|
||||
{
|
||||
@@ -64,10 +64,10 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool
|
||||
return true;
|
||||
}
|
||||
|
||||
UString ConvertFileTimeToString(const FILETIME &fileTime, bool includeTime, bool includeSeconds)
|
||||
UString ConvertFileTimeToString(const FILETIME &ft, bool includeTime, bool includeSeconds)
|
||||
{
|
||||
char s[32];
|
||||
ConvertFileTimeToString(fileTime, s, includeTime, includeSeconds);
|
||||
ConvertFileTimeToString(ft, s, includeTime, includeSeconds);
|
||||
return GetUnicodeString(s);
|
||||
}
|
||||
|
||||
@@ -88,12 +88,7 @@ UString ConvertPropVariantToString(const PROPVARIANT &prop)
|
||||
case VT_I4: return ConvertInt64ToString(prop.lVal);
|
||||
case VT_I8: return ConvertInt64ToString(prop.hVal.QuadPart);
|
||||
case VT_BOOL: return VARIANT_BOOLToBool(prop.boolVal) ? L"+" : L"-";
|
||||
default:
|
||||
#ifndef _WIN32_WCE
|
||||
throw 150245;
|
||||
#else
|
||||
return UString();
|
||||
#endif
|
||||
default: throw 150245;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,11 +100,6 @@ UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &prop)
|
||||
case VT_UI2: return prop.uiVal;
|
||||
case VT_UI4: return prop.ulVal;
|
||||
case VT_UI8: return (UInt64)prop.uhVal.QuadPart;
|
||||
default:
|
||||
#ifndef _WIN32_WCE
|
||||
throw 151199;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
default: throw 151199;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Windows/PropVariantConversions.h
|
||||
|
||||
#ifndef __PROPVARIANTCONVERSIONS_H
|
||||
#define __PROPVARIANTCONVERSIONS_H
|
||||
#ifndef __PROP_VARIANT_CONVERSIONS_H
|
||||
#define __PROP_VARIANT_CONVERSIONS_H
|
||||
|
||||
#include "Common/Types.h"
|
||||
#include "Common/MyString.h"
|
||||
#include "Common/Types.h"
|
||||
|
||||
bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime = true, bool includeSeconds = true);
|
||||
UString ConvertFileTimeToString(const FILETIME &ft, bool includeTime = true, bool includeSeconds = true);
|
||||
UString ConvertPropVariantToString(const PROPVARIANT &propVariant);
|
||||
UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &propVariant);
|
||||
UString ConvertPropVariantToString(const PROPVARIANT &prop);
|
||||
UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &prop);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,24 +16,6 @@ namespace NRegistry {
|
||||
|
||||
#define MYASSERT(expr) // _ASSERTE(expr)
|
||||
|
||||
CKey::~CKey()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
HKEY CKey::Detach()
|
||||
{
|
||||
HKEY hKey = _object;
|
||||
_object = NULL;
|
||||
return hKey;
|
||||
}
|
||||
|
||||
void CKey::Attach(HKEY hKey)
|
||||
{
|
||||
MYASSERT(_object == NULL);
|
||||
_object = hKey;
|
||||
}
|
||||
|
||||
LONG CKey::Create(HKEY parentKey, LPCTSTR keyName,
|
||||
LPTSTR keyClass, DWORD options, REGSAM accessMask,
|
||||
LPSECURITY_ATTRIBUTES securityAttributes, LPDWORD disposition)
|
||||
@@ -224,6 +206,24 @@ LONG CKey::QueryValue(LPCTSTR name, bool &value)
|
||||
return res;
|
||||
}
|
||||
|
||||
LONG CKey::GetValue_IfOk(LPCTSTR name, UInt32 &value)
|
||||
{
|
||||
UInt32 newVal;
|
||||
LONG res = QueryValue(name, newVal);
|
||||
if (res == ERROR_SUCCESS)
|
||||
value = newVal;
|
||||
return res;
|
||||
}
|
||||
|
||||
LONG CKey::GetValue_IfOk(LPCTSTR name, bool &value)
|
||||
{
|
||||
bool newVal;
|
||||
LONG res = QueryValue(name, newVal);
|
||||
if (res == ERROR_SUCCESS)
|
||||
value = newVal;
|
||||
return res;
|
||||
}
|
||||
|
||||
LONG CKey::QueryValue(LPCTSTR name, LPTSTR value, UInt32 &count)
|
||||
{
|
||||
MYASSERT(count != NULL);
|
||||
@@ -321,4 +321,49 @@ LONG CKey::EnumKeys(CSysStringVector &keyNames)
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
LONG CKey::SetValue_Strings(LPCTSTR valueName, const UStringVector &strings)
|
||||
{
|
||||
UInt32 numChars = 0;
|
||||
int i;
|
||||
for (i = 0; i < strings.Size(); i++)
|
||||
numChars += strings[i].Length() + 1;
|
||||
CBuffer<wchar_t> buffer;
|
||||
buffer.SetCapacity(numChars);
|
||||
int pos = 0;
|
||||
for (i = 0; i < strings.Size(); i++)
|
||||
{
|
||||
const UString &s = strings[i];
|
||||
MyStringCopy((wchar_t *)buffer + pos, (const wchar_t *)s);
|
||||
pos += s.Length() + 1;
|
||||
}
|
||||
return SetValue(valueName, buffer, numChars * sizeof(wchar_t));
|
||||
}
|
||||
|
||||
LONG CKey::GetValue_Strings(LPCTSTR valueName, UStringVector &strings)
|
||||
{
|
||||
strings.Clear();
|
||||
CByteBuffer buffer;
|
||||
UInt32 dataSize;
|
||||
LONG res = QueryValue(valueName, buffer, dataSize);
|
||||
if (res != ERROR_SUCCESS)
|
||||
return res;
|
||||
if (dataSize % sizeof(wchar_t) != 0)
|
||||
return E_FAIL;
|
||||
const wchar_t *data = (const wchar_t *)(const Byte *)buffer;
|
||||
int numChars = dataSize / sizeof(wchar_t);
|
||||
UString s;
|
||||
for (int i = 0; i < numChars; i++)
|
||||
{
|
||||
wchar_t c = data[i];
|
||||
if (c == 0)
|
||||
{
|
||||
strings.Add(s);
|
||||
s.Empty();
|
||||
}
|
||||
else
|
||||
s += c;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -17,19 +17,23 @@ class CKey
|
||||
HKEY _object;
|
||||
public:
|
||||
CKey(): _object(NULL) {}
|
||||
~CKey();
|
||||
~CKey() { Close(); }
|
||||
|
||||
operator HKEY() const { return _object; }
|
||||
void Attach(HKEY key) { _object = key; }
|
||||
HKEY Detach()
|
||||
{
|
||||
HKEY key = _object;
|
||||
_object = NULL;
|
||||
return key;
|
||||
}
|
||||
|
||||
HKEY Detach();
|
||||
void Attach(HKEY key);
|
||||
LONG Create(HKEY parentKey, LPCTSTR keyName,
|
||||
LPTSTR keyClass = REG_NONE, DWORD options = REG_OPTION_NON_VOLATILE,
|
||||
REGSAM accessMask = KEY_ALL_ACCESS,
|
||||
LPSECURITY_ATTRIBUTES securityAttributes = NULL,
|
||||
LPDWORD disposition = NULL);
|
||||
LONG Open(HKEY parentKey, LPCTSTR keyName,
|
||||
REGSAM accessMask = KEY_ALL_ACCESS);
|
||||
LONG Open(HKEY parentKey, LPCTSTR keyName, REGSAM accessMask = KEY_ALL_ACCESS);
|
||||
|
||||
LONG Close();
|
||||
|
||||
@@ -52,6 +56,9 @@ public:
|
||||
|
||||
LONG SetValue(LPCTSTR name, const void *value, UInt32 size);
|
||||
|
||||
LONG SetValue_Strings(LPCTSTR valueName, const UStringVector &strings);
|
||||
LONG GetValue_Strings(LPCTSTR valueName, UStringVector &strings);
|
||||
|
||||
LONG SetKeyValue(LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value);
|
||||
|
||||
LONG QueryValue(LPCTSTR name, UInt32 &value);
|
||||
@@ -59,6 +66,9 @@ public:
|
||||
LONG QueryValue(LPCTSTR name, LPTSTR value, UInt32 &dataSize);
|
||||
LONG QueryValue(LPCTSTR name, CSysString &value);
|
||||
|
||||
LONG GetValue_IfOk(LPCTSTR name, UInt32 &value);
|
||||
LONG GetValue_IfOk(LPCTSTR name, bool &value);
|
||||
|
||||
#ifndef _UNICODE
|
||||
LONG QueryValue(LPCWSTR name, LPWSTR value, UInt32 &dataSize);
|
||||
LONG QueryValue(LPCWSTR name, UString &value);
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#ifndef __WINDOWS_SECURITY_H
|
||||
#define __WINDOWS_SECURITY_H
|
||||
|
||||
#include "Defs.h"
|
||||
|
||||
#include <NTSecAPI.h>
|
||||
|
||||
#include "Defs.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NSecurity {
|
||||
|
||||
@@ -128,8 +128,8 @@ public:
|
||||
PLSA_ENUMERATION_INFORMATION *enumerationBuffer, PULONG countReturned)
|
||||
{ return LsaEnumerateAccountsWithUserRight(_handle, userRights, (void **)enumerationBuffer, countReturned); }
|
||||
|
||||
NTSTATUS EnumerateAccountRights(PSID sid, PLSA_UNICODE_STRING* userRights, PULONG countOfRights)
|
||||
{ return ::LsaEnumerateAccountRights(_handle, sid, userRights, countOfRights); }
|
||||
NTSTATUS EnumerateAccountRights(PSID sid, PLSA_UNICODE_STRING* userRights, PULONG countOfRights)
|
||||
{ return ::LsaEnumerateAccountRights(_handle, sid, userRights, countOfRights); }
|
||||
|
||||
NTSTATUS LookupSids(ULONG count, PSID* sids,
|
||||
PLSA_REFERENCED_DOMAIN_LIST* referencedDomains, PLSA_TRANSLATED_NAME* names)
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#ifndef _UNICODE
|
||||
#include "Common/StringConvert.h"
|
||||
#endif
|
||||
#include "Common/MyCom.h"
|
||||
#include "Windows/Shell.h"
|
||||
|
||||
#include "Windows/COM.h"
|
||||
#include "Windows/Shell.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
@@ -16,8 +17,9 @@ extern bool g_IsNT;
|
||||
namespace NWindows {
|
||||
namespace NShell {
|
||||
|
||||
/////////////////////////
|
||||
// CItemIDList
|
||||
#ifndef UNDER_CE
|
||||
|
||||
// SHGetMalloc is unsupported in Windows Mobile?
|
||||
|
||||
void CItemIDList::Free()
|
||||
{
|
||||
@@ -62,6 +64,7 @@ CItemIDList& CItemIDList::operator=(const CItemIDList &object)
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
|
||||
/////////////////////////////
|
||||
// CDrop
|
||||
|
||||
@@ -79,11 +82,6 @@ void CDrop::Free()
|
||||
m_Assigned = false;
|
||||
}
|
||||
|
||||
CDrop::~CDrop()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
UINT CDrop::QueryCountOfFiles()
|
||||
{
|
||||
return QueryFile(0xFFFFFFFF, (LPTSTR)NULL, 0);
|
||||
@@ -121,9 +119,6 @@ void CDrop::QueryFileNames(UStringVector &fileNames)
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Functions
|
||||
|
||||
bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path)
|
||||
{
|
||||
bool result = BOOLToBool(::SHGetPathFromIDList(itemIDList, path.GetBuffer(MAX_PATH * 2)));
|
||||
@@ -131,6 +126,40 @@ bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path)
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
bool BrowseForFolder(LPBROWSEINFO, CSysString)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BrowseForFolder(HWND, LPCTSTR, UINT, LPCTSTR, CSysString &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BrowseForFolder(HWND owner, LPCTSTR title,
|
||||
LPCTSTR initialFolder, CSysString &resultPath)
|
||||
{
|
||||
/*
|
||||
// SHBrowseForFolder doesn't work before CE 6.0 ?
|
||||
if (GetProcAddress(LoadLibrary(L"ceshell.dll", L"SHBrowseForFolder") == 0)
|
||||
MessageBoxW(0, L"no", L"", 0);
|
||||
else
|
||||
MessageBoxW(0, L"yes", L"", 0);
|
||||
*/
|
||||
/*
|
||||
UString s = L"all files";
|
||||
s += L" (*.*)";
|
||||
return MyGetOpenFileName(owner, title, initialFolder, s, resultPath, true);
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool BrowseForFolder(LPBROWSEINFO browseInfo, CSysString &resultPath)
|
||||
{
|
||||
NWindows::NCOM::CComInitializer comInitializer;
|
||||
@@ -145,6 +174,7 @@ bool BrowseForFolder(LPBROWSEINFO browseInfo, CSysString &resultPath)
|
||||
|
||||
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM data)
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
switch(uMsg)
|
||||
{
|
||||
case BFFM_INITIALIZED:
|
||||
@@ -166,6 +196,7 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM da
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -177,8 +208,15 @@ bool BrowseForFolder(HWND owner, LPCTSTR title, UINT ulFlags,
|
||||
BROWSEINFO browseInfo;
|
||||
browseInfo.hwndOwner = owner;
|
||||
browseInfo.pidlRoot = NULL;
|
||||
|
||||
// there are Unicode/astring problems in WinCE SDK!!!
|
||||
#ifdef UNDER_CE
|
||||
browseInfo.pszDisplayName = (LPSTR)displayName.GetBuffer(MAX_PATH);
|
||||
browseInfo.lpszTitle = (LPCSTR)title;
|
||||
#else
|
||||
browseInfo.pszDisplayName = displayName.GetBuffer(MAX_PATH);
|
||||
browseInfo.lpszTitle = title;
|
||||
#endif
|
||||
browseInfo.ulFlags = ulFlags;
|
||||
browseInfo.lpfn = (initialFolder != NULL) ? BrowseCallbackProc : NULL;
|
||||
browseInfo.lParam = (LPARAM)initialFolder;
|
||||
@@ -189,7 +227,10 @@ bool BrowseForFolder(HWND owner, LPCTSTR title,
|
||||
LPCTSTR initialFolder, CSysString &resultPath)
|
||||
{
|
||||
return BrowseForFolder(owner, title,
|
||||
BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, initialFolder, resultPath);
|
||||
#ifndef UNDER_CE
|
||||
BIF_NEWDIALOGSTYLE |
|
||||
#endif
|
||||
BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, initialFolder, resultPath);
|
||||
// BIF_STATUSTEXT; BIF_USENEWUI (Version 5.0)
|
||||
}
|
||||
|
||||
@@ -289,4 +330,6 @@ bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#include "Common/MyString.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
|
||||
namespace NWindows{
|
||||
namespace NShell{
|
||||
|
||||
/////////////////////////
|
||||
// CItemIDList
|
||||
#ifndef UNDER_CE
|
||||
|
||||
class CItemIDList
|
||||
{
|
||||
@@ -55,9 +55,9 @@ class CDrop
|
||||
bool m_Assigned;
|
||||
void Free();
|
||||
public:
|
||||
CDrop(bool mustBeFinished) : m_MustBeFinished(mustBeFinished),
|
||||
m_Assigned(false) {}
|
||||
~CDrop();
|
||||
CDrop(bool mustBeFinished) : m_MustBeFinished(mustBeFinished), m_Assigned(false) {}
|
||||
~CDrop() { Free(); }
|
||||
|
||||
void Attach(HDROP object);
|
||||
operator HDROP() { return m_Object;}
|
||||
bool QueryPoint(LPPOINT point)
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
void QueryFileNames(UStringVector &fileNames);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/////////////////////////////
|
||||
// Functions
|
||||
|
||||
@@ -88,5 +90,4 @@ bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &
|
||||
#endif
|
||||
}}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -25,12 +25,10 @@ public:
|
||||
~CBaseEvent() { Close(); }
|
||||
WRes Close() { return Event_Close(&_object); }
|
||||
#ifdef _WIN32
|
||||
WRes Create(bool manualReset, bool initiallyOwn, LPCTSTR name = NULL,
|
||||
LPSECURITY_ATTRIBUTES securityAttributes = NULL)
|
||||
WRes Create(bool manualReset, bool initiallyOwn, LPCTSTR name = NULL, LPSECURITY_ATTRIBUTES sa = NULL)
|
||||
{
|
||||
_object = ::CreateEvent(securityAttributes, BoolToBOOL(manualReset),
|
||||
BoolToBOOL(initiallyOwn), name);
|
||||
if (_object != 0)
|
||||
_object = ::CreateEvent(sa, BoolToBOOL(manualReset), BoolToBOOL(initiallyOwn), name);
|
||||
if (name == NULL && _object != 0)
|
||||
return 0;
|
||||
return ::GetLastError();
|
||||
}
|
||||
@@ -95,14 +93,14 @@ public:
|
||||
class CMutex: public CObject
|
||||
{
|
||||
public:
|
||||
WRes Create(bool initiallyOwn, LPCTSTR name = NULL,
|
||||
LPSECURITY_ATTRIBUTES securityAttributes = NULL)
|
||||
WRes Create(bool initiallyOwn, LPCTSTR name = NULL, LPSECURITY_ATTRIBUTES sa = NULL)
|
||||
{
|
||||
_handle = ::CreateMutex(securityAttributes, BoolToBOOL(initiallyOwn), name);
|
||||
if (_handle != 0)
|
||||
_handle = ::CreateMutex(sa, BoolToBOOL(initiallyOwn), name);
|
||||
if (name == NULL && _handle != 0)
|
||||
return 0;
|
||||
return ::GetLastError();
|
||||
}
|
||||
#ifndef UNDER_CE
|
||||
WRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name)
|
||||
{
|
||||
_handle = ::OpenMutex(desiredAccess, BoolToBOOL(inheritHandle), name);
|
||||
@@ -110,6 +108,7 @@ public:
|
||||
return 0;
|
||||
return ::GetLastError();
|
||||
}
|
||||
#endif
|
||||
WRes Release()
|
||||
{
|
||||
return ::ReleaseMutex(_handle) ? 0 : ::GetLastError();
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../Common/Defs.h"
|
||||
|
||||
#include "System.h"
|
||||
|
||||
namespace NWindows {
|
||||
@@ -14,6 +16,8 @@ UInt32 GetNumberOfProcessors()
|
||||
return (UInt32)systemInfo.dwNumberOfProcessors;
|
||||
}
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
#if !defined(_WIN64) && defined(__GNUC__)
|
||||
|
||||
typedef struct _MY_MEMORYSTATUSEX {
|
||||
@@ -37,26 +41,30 @@ typedef struct _MY_MEMORYSTATUSEX {
|
||||
|
||||
typedef BOOL (WINAPI *GlobalMemoryStatusExP)(MY_LPMEMORYSTATUSEX lpBuffer);
|
||||
|
||||
#endif
|
||||
|
||||
UInt64 GetRamSize()
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
MY_MEMORYSTATUSEX stat;
|
||||
stat.dwLength = sizeof(stat);
|
||||
#endif
|
||||
#ifdef _WIN64
|
||||
if (!::GlobalMemoryStatusEx(&stat))
|
||||
return 0;
|
||||
return stat.ullTotalPhys;
|
||||
return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
|
||||
#else
|
||||
#ifndef UNDER_CE
|
||||
GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
|
||||
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
|
||||
"GlobalMemoryStatusEx");
|
||||
if (globalMemoryStatusEx != 0)
|
||||
if (globalMemoryStatusEx(&stat))
|
||||
return stat.ullTotalPhys;
|
||||
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GlobalMemoryStatusEx");
|
||||
if (globalMemoryStatusEx != 0 && globalMemoryStatusEx(&stat))
|
||||
return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
|
||||
#endif
|
||||
{
|
||||
MEMORYSTATUS stat;
|
||||
stat.dwLength = sizeof(stat);
|
||||
GlobalMemoryStatus(&stat);
|
||||
return stat.dwTotalPhys;
|
||||
::GlobalMemoryStatus(&stat);
|
||||
return MyMin(stat.dwTotalVirtual, stat.dwTotalPhys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2,45 +2,129 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Time.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "Time.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NTime {
|
||||
|
||||
bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime)
|
||||
static const UInt32 kNumTimeQuantumsInSecond = 10000000;
|
||||
static const UInt32 kFileTimeStartYear = 1601;
|
||||
static const UInt32 kDosTimeStartYear = 1980;
|
||||
static const UInt32 kUnixTimeStartYear = 1970;
|
||||
static const UInt64 kUnixTimeStartValue = ((UInt64)kNumTimeQuantumsInSecond) *
|
||||
60 * 60 * 24 * (89 + 365 * (kUnixTimeStartYear - kFileTimeStartYear));
|
||||
|
||||
bool DosTimeToFileTime(UInt32 dosTime, FILETIME &ft)
|
||||
{
|
||||
return BOOLToBool(::DosDateTimeToFileTime((UInt16)(dosTime >> 16), (UInt16)(dosTime & 0xFFFF), &fileTime));
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
return BOOLToBool(::DosDateTimeToFileTime((UInt16)(dosTime >> 16), (UInt16)(dosTime & 0xFFFF), &ft));
|
||||
#else
|
||||
ft.dwLowDateTime = 0;
|
||||
ft.dwHighDateTime = 0;
|
||||
UInt64 res;
|
||||
if (!GetSecondsSince1601(kDosTimeStartYear + (dosTime >> 25), (dosTime >> 21) & 0xF, (dosTime >> 16) & 0x1F,
|
||||
(dosTime >> 11) & 0x1F, (dosTime >> 5) & 0x3F, (dosTime & 0x1F) * 2, res))
|
||||
return false;
|
||||
res *= kNumTimeQuantumsInSecond;
|
||||
ft.dwLowDateTime = (UInt32)res;
|
||||
ft.dwHighDateTime = (UInt32)(res >> 32);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
static const UInt32 kHighDosTime = 0xFF9FBF7D;
|
||||
static const UInt32 kLowDosTime = 0x210000;
|
||||
|
||||
bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime)
|
||||
#define PERIOD_4 (4 * 365 + 1)
|
||||
#define PERIOD_100 (PERIOD_4 * 25 - 1)
|
||||
#define PERIOD_400 (PERIOD_100 * 4 + 1)
|
||||
|
||||
bool FileTimeToDosTime(const FILETIME &ft, UInt32 &dosTime)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
|
||||
WORD datePart, timePart;
|
||||
if (!::FileTimeToDosDateTime(&fileTime, &datePart, &timePart))
|
||||
if (!::FileTimeToDosDateTime(&ft, &datePart, &timePart))
|
||||
{
|
||||
dosTime = (fileTime.dwHighDateTime >= 0x01C00000) ? kHighDosTime : kLowDosTime;
|
||||
dosTime = (ft.dwHighDateTime >= 0x01C00000) ? kHighDosTime : kLowDosTime;
|
||||
return false;
|
||||
}
|
||||
dosTime = (((UInt32)datePart) << 16) + timePart;
|
||||
|
||||
#else
|
||||
|
||||
unsigned year, mon, day, hour, min, sec;
|
||||
UInt64 v64 = ft.dwLowDateTime | ((UInt64)ft.dwHighDateTime << 32);
|
||||
Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
unsigned temp;
|
||||
UInt32 v;
|
||||
v64 += (kNumTimeQuantumsInSecond * 2 - 1);
|
||||
v64 /= kNumTimeQuantumsInSecond;
|
||||
sec = (unsigned)(v64 % 60);
|
||||
v64 /= 60;
|
||||
min = (unsigned)(v64 % 60);
|
||||
v64 /= 60;
|
||||
hour = (unsigned)(v64 % 24);
|
||||
v64 /= 24;
|
||||
|
||||
v = (UInt32)v64;
|
||||
|
||||
year = (unsigned)(kFileTimeStartYear + v / PERIOD_400 * 400);
|
||||
v %= PERIOD_400;
|
||||
|
||||
temp = (unsigned)(v / PERIOD_100);
|
||||
if (temp == 4)
|
||||
temp = 3;
|
||||
year += temp * 100;
|
||||
v -= temp * PERIOD_100;
|
||||
|
||||
temp = v / PERIOD_4;
|
||||
if (temp == 25)
|
||||
temp = 24;
|
||||
year += temp * 4;
|
||||
v -= temp * PERIOD_4;
|
||||
|
||||
temp = v / 365;
|
||||
if (temp == 4)
|
||||
temp = 3;
|
||||
year += temp;
|
||||
v -= temp * 365;
|
||||
|
||||
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
|
||||
ms[1] = 29;
|
||||
for (mon = 1; mon <= 12; mon++)
|
||||
{
|
||||
unsigned s = ms[mon - 1];
|
||||
if (v < s)
|
||||
break;
|
||||
v -= s;
|
||||
}
|
||||
day = (unsigned)v + 1;
|
||||
|
||||
dosTime = kLowDosTime;
|
||||
if (year < kDosTimeStartYear)
|
||||
return false;
|
||||
year -= kDosTimeStartYear;
|
||||
dosTime = kHighDosTime;
|
||||
if (year >= 128)
|
||||
return false;
|
||||
dosTime = (year << 25) | (mon << 21) | (day << 16) | (hour << 11) | (min << 5) | (sec >> 1);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
static const UInt32 kNumTimeQuantumsInSecond = 10000000;
|
||||
static const UInt64 kUnixTimeStartValue = ((UInt64)kNumTimeQuantumsInSecond) * 60 * 60 * 24 * 134774;
|
||||
|
||||
void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime)
|
||||
void UnixTimeToFileTime(UInt32 unixTime, FILETIME &ft)
|
||||
{
|
||||
UInt64 v = kUnixTimeStartValue + ((UInt64)unixTime) * kNumTimeQuantumsInSecond;
|
||||
fileTime.dwLowDateTime = (DWORD)v;
|
||||
fileTime.dwHighDateTime = (DWORD)(v >> 32);
|
||||
ft.dwLowDateTime = (DWORD)v;
|
||||
ft.dwHighDateTime = (DWORD)(v >> 32);
|
||||
}
|
||||
|
||||
bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime)
|
||||
bool FileTimeToUnixTime(const FILETIME &ft, UInt32 &unixTime)
|
||||
{
|
||||
UInt64 winTime = (((UInt64)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime;
|
||||
UInt64 winTime = (((UInt64)ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||
if (winTime < kUnixTimeStartValue)
|
||||
{
|
||||
unixTime = 0;
|
||||
@@ -60,10 +144,10 @@ bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day,
|
||||
unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds)
|
||||
{
|
||||
resSeconds = 0;
|
||||
if (year < 1601 || year >= 10000 || month < 1 || month > 12 ||
|
||||
if (year < kFileTimeStartYear || year >= 10000 || month < 1 || month > 12 ||
|
||||
day < 1 || day > 31 || hour > 23 || min > 59 || sec > 59)
|
||||
return false;
|
||||
UInt32 numYears = year - 1601;
|
||||
UInt32 numYears = year - kFileTimeStartYear;
|
||||
UInt32 numDays = numYears * 365 + numYears / 4 - numYears / 100 + numYears / 400;
|
||||
Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef __WINDOWS_WINDOW_H
|
||||
#define __WINDOWS_WINDOW_H
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "Defs.h"
|
||||
#include "Common/MyString.h"
|
||||
|
||||
namespace NWindows {
|
||||
@@ -22,6 +22,13 @@ bool MySetWindowText(HWND wnd, LPCWSTR s);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define GWLP_USERDATA GWL_USERDATA
|
||||
#define GWLP_WNDPROC GWL_WNDPROC
|
||||
#define BTNS_BUTTON TBSTYLE_BUTTON
|
||||
#define WC_COMBOBOXW L"ComboBox"
|
||||
#define DWLP_MSGRESULT DWL_MSGRESULT
|
||||
#endif
|
||||
|
||||
class CWindow
|
||||
{
|
||||
@@ -45,9 +52,13 @@ public:
|
||||
return window;
|
||||
}
|
||||
|
||||
bool Foreground() { return BOOLToBool(::SetForegroundWindow(_window)); }
|
||||
|
||||
HWND GetParent() const { return ::GetParent(_window); }
|
||||
bool GetWindowRect(LPRECT rect) const { return BOOLToBool(::GetWindowRect(_window,rect )); }
|
||||
bool GetWindowRect(LPRECT rect) const { return BOOLToBool(::GetWindowRect(_window,rect)); }
|
||||
#ifndef UNDER_CE
|
||||
bool IsZoomed() const { return BOOLToBool(::IsZoomed(_window)); }
|
||||
#endif
|
||||
bool ClientToScreen(LPPOINT point) const { return BOOLToBool(::ClientToScreen(_window, point)); }
|
||||
bool ScreenToClient(LPPOINT point) const { return BOOLToBool(::ScreenToClient(_window, point)); }
|
||||
|
||||
@@ -101,45 +112,73 @@ public:
|
||||
bool IsWindow() { return BOOLToBool(::IsWindow(_window)); }
|
||||
bool Move(int x, int y, int width, int height, bool repaint = true)
|
||||
{ return BOOLToBool(::MoveWindow(_window, x, y, width, height, BoolToBOOL(repaint))); }
|
||||
|
||||
bool ChangeSubWindowSizeX(HWND hwnd, int xSize)
|
||||
{
|
||||
RECT rect;
|
||||
::GetWindowRect(hwnd, &rect);
|
||||
POINT p1;
|
||||
p1.x = rect.left;
|
||||
p1.y = rect.top;
|
||||
ScreenToClient(&p1);
|
||||
return BOOLToBool(::MoveWindow(hwnd, p1.x, p1.y, xSize, rect.bottom - rect.top, TRUE));
|
||||
}
|
||||
|
||||
void ScreenToClient(RECT *rect)
|
||||
{
|
||||
POINT p1, p2;
|
||||
p1.x = rect->left;
|
||||
p1.y = rect->top;
|
||||
p2.x = rect->right;
|
||||
p2.y = rect->bottom;
|
||||
ScreenToClient(&p1);
|
||||
ScreenToClient(&p2);
|
||||
|
||||
rect->left = p1.x;
|
||||
rect->top = p1.y;
|
||||
rect->right = p2.x;
|
||||
rect->bottom = p2.y;
|
||||
}
|
||||
|
||||
bool GetClientRect(LPRECT rect) { return BOOLToBool(::GetClientRect(_window, rect)); }
|
||||
bool Show(int cmdShow) { return BOOLToBool(::ShowWindow(_window, cmdShow)); }
|
||||
#ifndef UNDER_CE
|
||||
bool SetPlacement(CONST WINDOWPLACEMENT *placement) { return BOOLToBool(::SetWindowPlacement(_window, placement)); }
|
||||
bool GetPlacement(WINDOWPLACEMENT *placement) { return BOOLToBool(::GetWindowPlacement(_window, placement)); }
|
||||
#endif
|
||||
bool Update() { return BOOLToBool(::UpdateWindow(_window)); }
|
||||
bool InvalidateRect(LPCRECT rect, bool backgroundErase = true)
|
||||
{ return BOOLToBool(::InvalidateRect(_window, rect, BoolToBOOL(backgroundErase))); }
|
||||
void SetRedraw(bool redraw = true) { SendMessage(WM_SETREDRAW, BoolToBOOL(redraw), 0); }
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
LONG_PTR SetStyle(LONG_PTR style)
|
||||
{ return SetLongPtr(GWL_STYLE, style); }
|
||||
LONG_PTR GetStyle( ) const
|
||||
{ return GetLongPtr(GWL_STYLE); }
|
||||
LONG_PTR SetStyle(LONG_PTR style) { return SetLongPtr(GWL_STYLE, style); }
|
||||
LONG_PTR GetStyle() const { return GetLongPtr(GWL_STYLE); }
|
||||
// bool MyIsMaximized() const { return ((GetStyle() & WS_MAXIMIZE) != 0); }
|
||||
|
||||
LONG_PTR SetLong(int index, LONG newLongPtr) { return ::SetWindowLong(_window, index, newLongPtr); }
|
||||
LONG_PTR GetLong(int index) const { return ::GetWindowLong(_window, index); }
|
||||
LONG_PTR SetUserDataLong(LONG newLongPtr) { return SetLong(GWLP_USERDATA, newLongPtr); }
|
||||
LONG_PTR GetUserDataLong() const { return GetLong(GWLP_USERDATA); }
|
||||
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr) { return SetLong(index, newLongPtr); }
|
||||
LONG_PTR GetLongPtr(int index) const { return GetLong(index); }
|
||||
|
||||
LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr) { return SetUserDataLong(newLongPtr); }
|
||||
LONG_PTR GetUserDataLongPtr() const { return GetUserDataLong(); }
|
||||
|
||||
#else
|
||||
LONG SetStyle(LONG_PTR style)
|
||||
{ return SetLong(GWL_STYLE, style); }
|
||||
DWORD GetStyle( ) const
|
||||
{ return GetLong(GWL_STYLE); }
|
||||
#endif
|
||||
|
||||
LONG_PTR SetLong(int index, LONG newLongPtr )
|
||||
{ return ::SetWindowLong(_window, index, newLongPtr); }
|
||||
LONG_PTR GetLong(int index) const
|
||||
{ return ::GetWindowLong(_window, index ); }
|
||||
LONG_PTR SetUserDataLong(LONG newLongPtr )
|
||||
{ return SetLong(GWLP_USERDATA, newLongPtr); }
|
||||
LONG_PTR GetUserDataLong() const
|
||||
{ return GetLong(GWLP_USERDATA); }
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr )
|
||||
|
||||
LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr)
|
||||
{ return ::SetWindowLongPtr(_window, index,
|
||||
#ifndef _WIN64
|
||||
(LONG)
|
||||
#endif
|
||||
newLongPtr); }
|
||||
#ifndef _UNICODE
|
||||
LONG_PTR SetLongPtrW(int index, LONG_PTR newLongPtr )
|
||||
LONG_PTR SetLongPtrW(int index, LONG_PTR newLongPtr)
|
||||
{ return ::SetWindowLongPtrW(_window, index,
|
||||
#ifndef _WIN64
|
||||
(LONG)
|
||||
@@ -147,12 +186,10 @@ public:
|
||||
newLongPtr); }
|
||||
#endif
|
||||
|
||||
LONG_PTR GetLongPtr(int index) const
|
||||
{ return ::GetWindowLongPtr(_window, index ); }
|
||||
LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr )
|
||||
{ return SetLongPtr(GWLP_USERDATA, newLongPtr); }
|
||||
LONG_PTR GetUserDataLongPtr() const
|
||||
{ return GetLongPtr(GWLP_USERDATA); }
|
||||
LONG_PTR GetLongPtr(int index) const { return ::GetWindowLongPtr(_window, index); }
|
||||
LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr) { return SetLongPtr(GWLP_USERDATA, newLongPtr); }
|
||||
LONG_PTR GetUserDataLongPtr() const { return GetLongPtr(GWLP_USERDATA); }
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -202,7 +239,7 @@ public:
|
||||
bool IsEnabled()
|
||||
{ return BOOLToBool(::IsWindowEnabled(_window)); }
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
#ifndef UNDER_CE
|
||||
HMENU GetSystemMenu(bool revert)
|
||||
{ return ::GetSystemMenu(_window, BoolToBOOL(revert)); }
|
||||
#endif
|
||||
@@ -211,8 +248,13 @@ public:
|
||||
{ return ::SetTimer(_window, idEvent, elapse, timerFunc); }
|
||||
bool KillTimer(UINT_PTR idEvent)
|
||||
{return BOOLToBool(::KillTimer(_window, idEvent)); }
|
||||
|
||||
HICON SetIcon(WPARAM sizeType, HICON icon) { return (HICON)SendMessage(WM_SETICON, sizeType, (LPARAM)icon); }
|
||||
};
|
||||
|
||||
#define RECT_SIZE_X(r) ((r).right - (r).left)
|
||||
#define RECT_SIZE_Y(r) ((r).bottom - (r).top)
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user