add last backwards-compatible version

This commit is contained in:
2021-12-14 00:33:46 -07:00
parent 68b10d413b
commit b0dd3f07f3
335 changed files with 4746 additions and 19627 deletions

View File

@@ -3,8 +3,19 @@
#ifdef _WIN32
#include <libPPUI/win32_op.h>
#include <libPPUI/win32_utility.h>
#include "win32_op.h"
class CloseHandleScope {
public:
CloseHandleScope(HANDLE handle) throw() : m_handle(handle) {}
~CloseHandleScope() throw() { CloseHandle(m_handle); }
HANDLE Detach() throw() { return pfc::replace_t(m_handle, INVALID_HANDLE_VALUE); }
HANDLE Get() const throw() { return m_handle; }
void Close() throw() { CloseHandle(Detach()); }
PFC_CLASS_NOT_COPYABLE_EX(CloseHandleScope)
private:
HANDLE m_handle;
};
class mutexScope {
@@ -20,7 +31,8 @@ private:
class registerclass_scope_delayed {
public:
registerclass_scope_delayed() {}
registerclass_scope_delayed() : m_class(0) {}
bool is_registered() const {return m_class != 0;}
void toggle_on(UINT p_style,WNDPROC p_wndproc,int p_clsextra,int p_wndextra,HICON p_icon,HCURSOR p_cursor,HBRUSH p_background,const TCHAR * p_classname,const TCHAR * p_menuname);
void toggle_off();
@@ -28,14 +40,51 @@ public:
~registerclass_scope_delayed() {toggle_off();}
private:
registerclass_scope_delayed(const registerclass_scope_delayed &) = delete;
const registerclass_scope_delayed & operator=(const registerclass_scope_delayed &) = delete;
registerclass_scope_delayed(const registerclass_scope_delayed &) {throw pfc::exception_not_implemented();}
const registerclass_scope_delayed & operator=(const registerclass_scope_delayed &) {throw pfc::exception_not_implemented();}
ATOM m_class = 0;
ATOM m_class;
};
typedef CGlobalLockScope CGlobalLock; // compatibility
typedef CGlobalLockScope CGlobalLock;//for compatibility, implementation moved elsewhere
bool SetClipboardDataBlock(UINT p_format, const void * p_block, t_size p_block_size);
template<typename t_array>
static bool SetClipboardDataBlock(UINT p_format,const t_array & p_array) {
PFC_STATIC_ASSERT( sizeof(p_array[0]) == 1 );
return SetClipboardDataBlock(p_format,p_array.get_ptr(),p_array.get_size());
}
template<typename t_array>
static bool GetClipboardDataBlock(UINT p_format,t_array & p_array) {
PFC_STATIC_ASSERT( sizeof(p_array[0]) == 1 );
if (OpenClipboard(NULL)) {
HANDLE handle = GetClipboardData(p_format);
if (handle == NULL) {
CloseClipboard();
return false;
}
{
CGlobalLock lock(handle);
const t_size size = lock.GetSize();
try {
p_array.set_size(size);
} catch(...) {
CloseClipboard();
throw;
}
memcpy(p_array.get_ptr(),lock.GetPtr(),size);
}
CloseClipboard();
return true;
} else {
return false;
}
}
class OleInitializeScope {
public:
@@ -55,7 +104,17 @@ private:
PFC_CLASS_NOT_COPYABLE_EX(CoInitializeScope)
};
WORD GetOSVersion();
unsigned QueryScreenDPI(HWND wnd = NULL);
unsigned QueryScreenDPI_X(HWND wnd = NULL);
unsigned QueryScreenDPI_Y(HWND wnd = NULL);
SIZE QueryScreenDPIEx(HWND wnd = NULL);
static WORD GetOSVersion() {
const DWORD ver = GetVersion();
return (WORD)HIBYTE(LOWORD(ver)) | ((WORD)LOBYTE(LOWORD(ver)) << 8);
}
#if _WIN32_WINNT >= 0x501
#define WS_EX_COMPOSITED_Safe() WS_EX_COMPOSITED
@@ -66,6 +125,26 @@ static DWORD WS_EX_COMPOSITED_Safe() {
#endif
class EnableWindowScope {
public:
EnableWindowScope(HWND p_window,BOOL p_state) throw() : m_window(p_window) {
m_oldState = IsWindowEnabled(m_window);
EnableWindow(m_window,p_state);
}
~EnableWindowScope() throw() {
EnableWindow(m_window,m_oldState);
}
private:
BOOL m_oldState;
HWND m_window;
};
bool IsMenuNonEmpty(HMENU menu);
class CModelessDialogEntry {
public:
CModelessDialogEntry() : m_wnd() {}
@@ -78,6 +157,12 @@ private:
HWND m_wnd;
};
void GetOSVersionString(pfc::string_base & out);
void GetOSVersionStringAppend(pfc::string_base & out);
void SetDefaultMenuItem(HMENU p_menu,unsigned p_id);
class CDLL {
public:
#ifdef _DEBUG
@@ -120,7 +205,7 @@ public:
void open(const char * inPath, file::ptr inReader, abort_callback & aborter);
void close();
winLocalFileScope() {}
winLocalFileScope() : m_isTemp() {}
winLocalFileScope(const char * inPath, file::ptr inReader, abort_callback & aborter) : m_isTemp() {
open(inPath, inReader, aborter);
}
@@ -130,9 +215,8 @@ public:
}
const wchar_t * Path() const { return m_path.c_str(); }
bool isTemp() const { return m_isTemp; }
private:
bool m_isTemp = false;
bool m_isTemp;
std::wstring m_path;
};
@@ -163,6 +247,8 @@ private:
CMutex & m_mutex;
};
LRESULT RelayEraseBkgnd(HWND p_from, HWND p_to, HDC p_dc);
bool IsWindowsS();
#endif // _WIN32