Add wxRESERVED_PARAM symbolic constant and use it instead of 0

This is more readable than just using "0" or "NULL" and shorter than
writing a comment every time.

No real changes.
This commit is contained in:
Vadim Zeitlin
2021-01-09 21:31:41 +01:00
parent 1ebfda6d89
commit 24c7baa07e
8 changed files with 28 additions and 28 deletions

View File

@@ -34,6 +34,10 @@ class WXDLLIMPEXP_FWD_CORE wxWindowBase;
#define MAX_PATH 260 #define MAX_PATH 260
#endif #endif
// Many MSW functions have parameters which are "reserved". Passing them this
// constant is more clear than just using "0" or "NULL".
#define wxRESERVED_PARAM 0
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// standard icons from the resources // standard icons from the resources
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -665,7 +665,7 @@ size_t wxDialUpManagerMSW::GetISPNames(wxArrayString& names) const
{ {
dwRet = ms_pfnRasEnumEntries dwRet = ms_pfnRasEnumEntries
( (
NULL, // reserved wxRESERVED_PARAM,
NULL, // default phone book (or all) NULL, // default phone book (or all)
rasEntries, // [out] buffer for the entries rasEntries, // [out] buffer for the entries
&size, // [in/out] size of the buffer &size, // [in/out] size of the buffer
@@ -963,7 +963,7 @@ bool wxDialUpManagerMSW::IsAlwaysOnline() const
if ( pfnInternetGetConnectedState ) if ( pfnInternetGetConnectedState )
{ {
DWORD flags = 0; DWORD flags = 0;
if ( pfnInternetGetConnectedState(&flags, 0 /* reserved */) ) if ( pfnInternetGetConnectedState(&flags, wxRESERVED_PARAM) )
{ {
// there is some connection to the net, see of which type // there is some connection to the net, see of which type
isAlwaysOnline = (flags & (INTERNET_CONNECTION_LAN | isAlwaysOnline = (flags & (INTERNET_CONNECTION_LAN |

View File

@@ -454,7 +454,7 @@ bool wxDisplayMSW::ChangeMode(const wxVideoMode& mode)
( (
GetName().t_str(), // display name GetName().t_str(), // display name
pDevMode, // dev mode or NULL to reset pDevMode, // dev mode or NULL to reset
NULL, // reserved wxRESERVED_PARAM,
flags, flags,
NULL // pointer to video parameters (not used) NULL // pointer to video parameters (not used)
) ) ) )

View File

@@ -147,7 +147,7 @@ void wxFontEnumeratorHelper::DoEnumerate()
wxStrlcpy(lf.lfFaceName, m_facename.c_str(), WXSIZEOF(lf.lfFaceName)); wxStrlcpy(lf.lfFaceName, m_facename.c_str(), WXSIZEOF(lf.lfFaceName));
lf.lfPitchAndFamily = 0; lf.lfPitchAndFamily = 0;
::EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)wxFontEnumeratorProc, ::EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)wxFontEnumeratorProc,
(LPARAM)this, 0 /* reserved */) ; (LPARAM)this, wxRESERVED_PARAM) ;
::ReleaseDC(NULL, hDC); ::ReleaseDC(NULL, hDC);
} }

View File

@@ -76,10 +76,6 @@ aStdKeys[] =
// the registry name separator (perhaps one day MS will change it to '/' ;-) // the registry name separator (perhaps one day MS will change it to '/' ;-)
#define REG_SEPARATOR wxT('\\') #define REG_SEPARATOR wxT('\\')
// useful for Windows programmers: makes somewhat more clear all these zeroes
// being passed to Windows APIs
#define RESERVED (0)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// macros // macros
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -383,7 +379,7 @@ bool wxRegKey::GetKeyInfo(size_t *pnSubKeys,
(HKEY) m_hKey, (HKEY) m_hKey,
NULL, // class name NULL, // class name
NULL, // (ptr to) size of class name buffer NULL, // (ptr to) size of class name buffer
RESERVED, wxRESERVED_PARAM,
REG_PARAM(SubKeys), // [out] number of subkeys REG_PARAM(SubKeys), // [out] number of subkeys
REG_PARAM(MaxKeyLen), // [out] max length of a subkey name REG_PARAM(MaxKeyLen), // [out] max length of a subkey name
NULL, // longest subkey class name NULL, // longest subkey class name
@@ -437,7 +433,7 @@ bool wxRegKey::Open(AccessMode mode)
( (
(HKEY) m_hRootKey, (HKEY) m_hRootKey,
m_strKey.t_str(), m_strKey.t_str(),
RESERVED, wxRESERVED_PARAM,
GetMSWAccessFlags(mode, m_viewMode), GetMSWAccessFlags(mode, m_viewMode),
&tmpKey &tmpKey
); );
@@ -468,7 +464,7 @@ bool wxRegKey::Create(bool bOkIfExists)
HKEY tmpKey; HKEY tmpKey;
DWORD disposition; DWORD disposition;
m_dwLastError = RegCreateKeyEx((HKEY) m_hRootKey, m_strKey.t_str(), m_dwLastError = RegCreateKeyEx((HKEY) m_hRootKey, m_strKey.t_str(),
0, // reserved and must be 0 wxRESERVED_PARAM,
NULL, // The user-defined class type of this key. NULL, // The user-defined class type of this key.
REG_OPTION_NON_VOLATILE, // supports other values as well; see MS docs REG_OPTION_NON_VOLATILE, // supports other values as well; see MS docs
GetMSWAccessFlags(wxRegKey::Write, m_viewMode), GetMSWAccessFlags(wxRegKey::Write, m_viewMode),
@@ -756,7 +752,7 @@ bool wxRegKey::DeleteSelf()
{ {
m_dwLastError = (*pfnRegDeleteKeyEx)((HKEY) m_hRootKey, m_strKey.t_str(), m_dwLastError = (*pfnRegDeleteKeyEx)((HKEY) m_hRootKey, m_strKey.t_str(),
GetMSWViewFlags(m_viewMode), GetMSWViewFlags(m_viewMode),
0); // This parameter is reserved and must be zero. wxRESERVED_PARAM);
} }
else else
#endif // wxUSE_DYNLIB_CLASS #endif // wxUSE_DYNLIB_CLASS
@@ -817,7 +813,7 @@ bool wxRegKey::HasValue(const wxString& szValue) const
LONG dwRet = ::RegQueryValueEx((HKEY) m_hKey, LONG dwRet = ::RegQueryValueEx((HKEY) m_hKey,
RegValueStr(szValue), RegValueStr(szValue),
RESERVED, wxRESERVED_PARAM,
NULL, NULL, NULL); NULL, NULL, NULL);
return dwRet == ERROR_SUCCESS; return dwRet == ERROR_SUCCESS;
} }
@@ -864,7 +860,7 @@ wxRegKey::ValueType wxRegKey::GetValueType(const wxString& szValue) const
return Type_None; return Type_None;
DWORD dwType; DWORD dwType;
m_dwLastError = RegQueryValueEx((HKEY) m_hKey, RegValueStr(szValue), RESERVED, m_dwLastError = RegQueryValueEx((HKEY) m_hKey, RegValueStr(szValue), wxRESERVED_PARAM,
&dwType, NULL, NULL); &dwType, NULL, NULL);
if ( m_dwLastError != ERROR_SUCCESS ) { if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, _("Can't read value of key '%s'"), wxLogSysError(m_dwLastError, _("Can't read value of key '%s'"),
@@ -879,7 +875,7 @@ bool wxRegKey::SetValue(const wxString& szValue, long lValue)
{ {
if ( CONST_CAST Open() ) { if ( CONST_CAST Open() ) {
m_dwLastError = RegSetValueEx((HKEY) m_hKey, RegValueStr(szValue), m_dwLastError = RegSetValueEx((HKEY) m_hKey, RegValueStr(szValue),
(DWORD) RESERVED, REG_DWORD, wxRESERVED_PARAM, REG_DWORD,
(RegString)&lValue, sizeof(lValue)); (RegString)&lValue, sizeof(lValue));
if ( m_dwLastError == ERROR_SUCCESS ) if ( m_dwLastError == ERROR_SUCCESS )
return true; return true;
@@ -896,7 +892,7 @@ bool wxRegKey::QueryValue(const wxString& szValue, long *plValue) const
DWORD dwType, dwSize = sizeof(DWORD); DWORD dwType, dwSize = sizeof(DWORD);
RegString pBuf = (RegString)plValue; RegString pBuf = (RegString)plValue;
m_dwLastError = RegQueryValueEx((HKEY) m_hKey, RegValueStr(szValue), m_dwLastError = RegQueryValueEx((HKEY) m_hKey, RegValueStr(szValue),
RESERVED, wxRESERVED_PARAM,
&dwType, pBuf, &dwSize); &dwType, pBuf, &dwSize);
if ( m_dwLastError != ERROR_SUCCESS ) { if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, _("Can't read value of key '%s'"), wxLogSysError(m_dwLastError, _("Can't read value of key '%s'"),
@@ -921,7 +917,7 @@ bool wxRegKey::SetValue(const wxString& szValue, const wxMemoryBuffer& buffer)
{ {
if ( CONST_CAST Open() ) { if ( CONST_CAST Open() ) {
m_dwLastError = RegSetValueEx((HKEY) m_hKey, RegValueStr(szValue), m_dwLastError = RegSetValueEx((HKEY) m_hKey, RegValueStr(szValue),
(DWORD) RESERVED, REG_BINARY, wxRESERVED_PARAM, REG_BINARY,
(RegBinary)buffer.GetData(),buffer.GetDataLen()); (RegBinary)buffer.GetData(),buffer.GetDataLen());
if ( m_dwLastError == ERROR_SUCCESS ) if ( m_dwLastError == ERROR_SUCCESS )
return true; return true;
@@ -938,7 +934,7 @@ bool wxRegKey::QueryValue(const wxString& szValue, wxMemoryBuffer& buffer) const
// first get the type and size of the data // first get the type and size of the data
DWORD dwType, dwSize; DWORD dwType, dwSize;
m_dwLastError = RegQueryValueEx((HKEY) m_hKey, RegValueStr(szValue), m_dwLastError = RegQueryValueEx((HKEY) m_hKey, RegValueStr(szValue),
RESERVED, wxRESERVED_PARAM,
&dwType, NULL, &dwSize); &dwType, NULL, &dwSize);
if ( m_dwLastError == ERROR_SUCCESS ) { if ( m_dwLastError == ERROR_SUCCESS ) {
@@ -952,7 +948,7 @@ bool wxRegKey::QueryValue(const wxString& szValue, wxMemoryBuffer& buffer) const
const RegBinary pBuf = (RegBinary)buffer.GetWriteBuf(dwSize); const RegBinary pBuf = (RegBinary)buffer.GetWriteBuf(dwSize);
m_dwLastError = RegQueryValueEx((HKEY) m_hKey, m_dwLastError = RegQueryValueEx((HKEY) m_hKey,
RegValueStr(szValue), RegValueStr(szValue),
RESERVED, wxRESERVED_PARAM,
&dwType, &dwType,
pBuf, pBuf,
&dwSize); &dwSize);
@@ -986,7 +982,7 @@ bool wxRegKey::QueryValue(const wxString& szValue,
DWORD dwType=REG_NONE, dwSize=0; DWORD dwType=REG_NONE, dwSize=0;
m_dwLastError = RegQueryValueEx((HKEY) m_hKey, m_dwLastError = RegQueryValueEx((HKEY) m_hKey,
RegValueStr(szValue), RegValueStr(szValue),
RESERVED, wxRESERVED_PARAM,
&dwType, NULL, &dwSize); &dwType, NULL, &dwSize);
if ( m_dwLastError == ERROR_SUCCESS ) if ( m_dwLastError == ERROR_SUCCESS )
{ {
@@ -1012,7 +1008,7 @@ bool wxRegKey::QueryValue(const wxString& szValue,
wxStringBufferLength strBuf(strValue, chars); wxStringBufferLength strBuf(strValue, chars);
m_dwLastError = RegQueryValueEx((HKEY) m_hKey, m_dwLastError = RegQueryValueEx((HKEY) m_hKey,
RegValueStr(szValue), RegValueStr(szValue),
RESERVED, wxRESERVED_PARAM,
&dwType, &dwType,
(RegString)(wxChar*)strBuf, (RegString)(wxChar*)strBuf,
&dwSize); &dwSize);
@@ -1063,7 +1059,7 @@ bool wxRegKey::SetValue(const wxString& szValue, const wxString& strValue)
if ( CONST_CAST Open() ) { if ( CONST_CAST Open() ) {
m_dwLastError = RegSetValueEx((HKEY) m_hKey, m_dwLastError = RegSetValueEx((HKEY) m_hKey,
RegValueStr(szValue), RegValueStr(szValue),
(DWORD) RESERVED, REG_SZ, wxRESERVED_PARAM, REG_SZ,
reinterpret_cast<const BYTE*>(wxMSW_CONV_LPCTSTR(strValue)), reinterpret_cast<const BYTE*>(wxMSW_CONV_LPCTSTR(strValue)),
(strValue.Len() + 1)*sizeof(wxChar)); (strValue.Len() + 1)*sizeof(wxChar));
if ( m_dwLastError == ERROR_SUCCESS ) if ( m_dwLastError == ERROR_SUCCESS )
@@ -1110,7 +1106,7 @@ bool wxRegKey::GetNextValue(wxString& strValueName, long& lIndex) const
m_dwLastError = RegEnumValue((HKEY) m_hKey, lIndex++, m_dwLastError = RegEnumValue((HKEY) m_hKey, lIndex++,
szValueName, &dwValueLen, szValueName, &dwValueLen,
RESERVED, wxRESERVED_PARAM,
NULL, // [out] type NULL, // [out] type
NULL, // [out] buffer for value NULL, // [out] buffer for value
NULL); // [i/o] it's length NULL); // [i/o] it's length
@@ -1484,7 +1480,7 @@ bool KeyExists(WXHKEY hRootKey,
( (
(HKEY)hRootKey, (HKEY)hRootKey,
szKey.t_str(), szKey.t_str(),
RESERVED, wxRESERVED_PARAM,
// we might not have enough rights for rw access // we might not have enough rights for rw access
GetMSWAccessFlags(wxRegKey::Read, viewMode), GetMSWAccessFlags(wxRegKey::Read, viewMode),
&hkeyDummy &hkeyDummy

View File

@@ -2218,7 +2218,7 @@ void wxTreeCtrl::SortChildren(const wxTreeItemId& item)
tvSort.hParent = HITEM(item); tvSort.hParent = HITEM(item);
tvSort.lpfnCompare = wxTreeSortHelper::Compare; tvSort.lpfnCompare = wxTreeSortHelper::Compare;
tvSort.lParam = (LPARAM)this; tvSort.lParam = (LPARAM)this;
if ( !TreeView_SortChildrenCB(GetHwnd(), &tvSort, 0 /* reserved */) ) if ( !TreeView_SortChildrenCB(GetHwnd(), &tvSort, wxRESERVED_PARAM) )
wxLogLastError(wxS("TreeView_SortChildrenCB()")); wxLogLastError(wxS("TreeView_SortChildrenCB()"));
} }
} }

View File

@@ -257,7 +257,7 @@ void wxWebRequestWinHTTP::Start()
m_sessionWinHTTP.GetHandle(), m_sessionWinHTTP.GetHandle(),
wxString(urlComps.lpszHostName, urlComps.dwHostNameLength), wxString(urlComps.lpszHostName, urlComps.dwHostNameLength),
urlComps.nPort, urlComps.nPort,
0 // reserved wxRESERVED_PARAM
); );
if ( m_connect == NULL ) if ( m_connect == NULL )
{ {
@@ -296,7 +296,7 @@ void wxWebRequestWinHTTP::Start()
WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE | WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE |
WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE | WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE |
WINHTTP_CALLBACK_FLAG_REQUEST_ERROR, WINHTTP_CALLBACK_FLAG_REQUEST_ERROR,
0) == WINHTTP_INVALID_STATUS_CALLBACK ) wxRESERVED_PARAM) == WINHTTP_INVALID_STATUS_CALLBACK )
{ {
SetFailedWithLastError(); SetFailedWithLastError();
return; return;

View File

@@ -997,7 +997,7 @@ bool wxWindowMSW::EnableTouchEvents(int eventsMask)
if ( !GestureFuncs::SetGestureConfig() if ( !GestureFuncs::SetGestureConfig()
( (
m_hWnd, m_hWnd,
0, // Reserved, must be always 0. wxRESERVED_PARAM,
numConfigs, // Number of gesture configurations. numConfigs, // Number of gesture configurations.
ptrConfigs, // Pointer to the first one. ptrConfigs, // Pointer to the first one.
sizeof(GESTURECONFIG) // Size of each configuration. sizeof(GESTURECONFIG) // Size of each configuration.