got rid of wxBuffer (finally!!!)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21571 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -486,8 +486,6 @@ private:
|
||||
// global data
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
WXDLLIMPEXP_DATA_BASE(extern wxChar*) wxBuffer;
|
||||
|
||||
WXDLLIMPEXP_DATA_BASE(extern HINSTANCE) wxhInstance;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@@ -56,12 +56,6 @@ class WXDLLIMPEXP_BASE wxPoint;
|
||||
// String functions (deprecated, use wxString)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Useful buffer (FIXME VZ: To be removed!!!)
|
||||
// Now only needed in MSW port
|
||||
#if !defined(__WXMOTIF__) && !defined(__WXGTK__) && !defined(__WXX11__) && !defined(__WXMGL__) && !defined(__WXMAC__)
|
||||
WXDLLIMPEXP_DATA_BASE(extern wxChar*) wxBuffer;
|
||||
#endif
|
||||
|
||||
// Make a copy of this string using 'new'
|
||||
WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s);
|
||||
|
||||
|
@@ -119,7 +119,6 @@
|
||||
// global variables
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
extern wxChar *wxBuffer;
|
||||
extern wxList WXDLLEXPORT wxPendingDelete;
|
||||
#ifndef __WXMICROWIN__
|
||||
extern void wxSetKeyboardHook(bool doIt);
|
||||
@@ -287,8 +286,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
}
|
||||
#endif // wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
|
||||
|
||||
wxBuffer = new wxChar[1500]; // FIXME
|
||||
|
||||
#if defined(__WIN95__) && !defined(__WXMICROWIN__)
|
||||
InitCommonControls();
|
||||
#endif // __WIN95__
|
||||
@@ -500,9 +497,6 @@ bool wxApp::UnregisterWindowClasses()
|
||||
|
||||
void wxApp::CleanUp()
|
||||
{
|
||||
delete[] wxBuffer;
|
||||
wxBuffer = NULL;
|
||||
|
||||
#ifndef __WXMICROWIN__
|
||||
wxSetKeyboardHook(FALSE);
|
||||
#endif
|
||||
|
@@ -583,13 +583,15 @@ void wxListBox::SetHorizontalExtent(const wxString& s)
|
||||
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
|
||||
|
||||
GetTextMetrics(dc, &lpTextMetric);
|
||||
int i;
|
||||
for (i = 0; i < m_noItems; i++)
|
||||
|
||||
// FIXME: buffer overflow!!
|
||||
wxChar buf[1024];
|
||||
for (int i = 0; i < m_noItems; i++)
|
||||
{
|
||||
int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LONG)wxBuffer);
|
||||
wxBuffer[len] = 0;
|
||||
int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LPARAM)buf);
|
||||
buf[len] = 0;
|
||||
SIZE extentXY;
|
||||
::GetTextExtentPoint(dc, (LPTSTR)wxBuffer, len, &extentXY);
|
||||
::GetTextExtentPoint(dc, buf, len, &extentXY);
|
||||
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
|
||||
if (extentX > largestExtent)
|
||||
largestExtent = extentX;
|
||||
|
@@ -240,100 +240,87 @@ bool wxGetUserId(wxChar *buf, int maxSize)
|
||||
// Get user name e.g. Julian Smart
|
||||
bool wxGetUserName(wxChar *buf, int maxSize)
|
||||
{
|
||||
#if wxUSE_PENWINDOWS && !defined(__WATCOMC__) && !defined(__GNUWIN32__)
|
||||
extern HANDLE g_hPenWin; // PenWindows Running?
|
||||
if (g_hPenWin)
|
||||
{
|
||||
// PenWindows Does have a user concept!
|
||||
// Get the current owner of the recognizer
|
||||
GetPrivateProfileString("Current", "User", default_name, wxBuffer, maxSize - 1, "PENWIN.INI");
|
||||
strncpy(buf, wxBuffer, maxSize - 1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef USE_NET_API
|
||||
CHAR szUserName[256];
|
||||
if ( !wxGetUserId(szUserName, WXSIZEOF(szUserName)) )
|
||||
return FALSE;
|
||||
CHAR szUserName[256];
|
||||
if ( !wxGetUserId(szUserName, WXSIZEOF(szUserName)) )
|
||||
return FALSE;
|
||||
|
||||
// TODO how to get the domain name?
|
||||
CHAR *szDomain = "";
|
||||
// TODO how to get the domain name?
|
||||
CHAR *szDomain = "";
|
||||
|
||||
// the code is based on the MSDN example (also see KB article Q119670)
|
||||
WCHAR wszUserName[256]; // Unicode user name
|
||||
WCHAR wszDomain[256];
|
||||
LPBYTE ComputerName;
|
||||
// the code is based on the MSDN example (also see KB article Q119670)
|
||||
WCHAR wszUserName[256]; // Unicode user name
|
||||
WCHAR wszDomain[256];
|
||||
LPBYTE ComputerName;
|
||||
|
||||
USER_INFO_2 *ui2; // User structure
|
||||
USER_INFO_2 *ui2; // User structure
|
||||
|
||||
// Convert ANSI user name and domain to Unicode
|
||||
MultiByteToWideChar( CP_ACP, 0, szUserName, strlen(szUserName)+1,
|
||||
wszUserName, WXSIZEOF(wszUserName) );
|
||||
MultiByteToWideChar( CP_ACP, 0, szDomain, strlen(szDomain)+1,
|
||||
wszDomain, WXSIZEOF(wszDomain) );
|
||||
// Convert ANSI user name and domain to Unicode
|
||||
MultiByteToWideChar( CP_ACP, 0, szUserName, strlen(szUserName)+1,
|
||||
wszUserName, WXSIZEOF(wszUserName) );
|
||||
MultiByteToWideChar( CP_ACP, 0, szDomain, strlen(szDomain)+1,
|
||||
wszDomain, WXSIZEOF(wszDomain) );
|
||||
|
||||
// Get the computer name of a DC for the domain.
|
||||
if ( NetGetDCName( NULL, wszDomain, &ComputerName ) != NERR_Success )
|
||||
{
|
||||
wxLogError(wxT("Can not find domain controller"));
|
||||
// Get the computer name of a DC for the domain.
|
||||
if ( NetGetDCName( NULL, wszDomain, &ComputerName ) != NERR_Success )
|
||||
{
|
||||
wxLogError(wxT("Can not find domain controller"));
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Look up the user on the DC
|
||||
NET_API_STATUS status = NetUserGetInfo( (LPWSTR)ComputerName,
|
||||
(LPWSTR)&wszUserName,
|
||||
2, // level - we want USER_INFO_2
|
||||
(LPBYTE *) &ui2 );
|
||||
switch ( status )
|
||||
{
|
||||
case NERR_Success:
|
||||
// ok
|
||||
break;
|
||||
|
||||
case NERR_InvalidComputer:
|
||||
wxLogError(wxT("Invalid domain controller name."));
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Look up the user on the DC
|
||||
NET_API_STATUS status = NetUserGetInfo( (LPWSTR)ComputerName,
|
||||
(LPWSTR)&wszUserName,
|
||||
2, // level - we want USER_INFO_2
|
||||
(LPBYTE *) &ui2 );
|
||||
switch ( status )
|
||||
{
|
||||
case NERR_Success:
|
||||
// ok
|
||||
break;
|
||||
case NERR_UserNotFound:
|
||||
wxLogError(wxT("Invalid user name '%s'."), szUserName);
|
||||
|
||||
case NERR_InvalidComputer:
|
||||
wxLogError(wxT("Invalid domain controller name."));
|
||||
goto error;
|
||||
|
||||
goto error;
|
||||
default:
|
||||
wxLogSysError(wxT("Can't get information about user"));
|
||||
|
||||
case NERR_UserNotFound:
|
||||
wxLogError(wxT("Invalid user name '%s'."), szUserName);
|
||||
goto error;
|
||||
}
|
||||
|
||||
goto error;
|
||||
// Convert the Unicode full name to ANSI
|
||||
WideCharToMultiByte( CP_ACP, 0, ui2->usri2_full_name, -1,
|
||||
buf, maxSize, NULL, NULL );
|
||||
|
||||
default:
|
||||
wxLogSysError(wxT("Can't get information about user"));
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Convert the Unicode full name to ANSI
|
||||
WideCharToMultiByte( CP_ACP, 0, ui2->usri2_full_name, -1,
|
||||
buf, maxSize, NULL, NULL );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
wxLogError(wxT("Couldn't look up full user name."));
|
||||
wxLogError(wxT("Couldn't look up full user name."));
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#else // !USE_NET_API
|
||||
// Could use NIS, MS-Mail or other site specific programs
|
||||
// Use wxWindows configuration data
|
||||
bool ok = GetProfileString(WX_SECTION, eUSERNAME, wxT(""), buf, maxSize - 1) != 0;
|
||||
if ( !ok )
|
||||
{
|
||||
ok = wxGetUserId(buf, maxSize);
|
||||
}
|
||||
|
||||
if ( !ok )
|
||||
{
|
||||
wxStrncpy(buf, wxT("Unknown User"), maxSize);
|
||||
}
|
||||
#endif // Win32/16
|
||||
// Could use NIS, MS-Mail or other site specific programs
|
||||
// Use wxWindows configuration data
|
||||
bool ok = GetProfileString(WX_SECTION, eUSERNAME, wxT(""), buf, maxSize - 1) != 0;
|
||||
if ( !ok )
|
||||
{
|
||||
ok = wxGetUserId(buf, maxSize);
|
||||
}
|
||||
|
||||
if ( !ok )
|
||||
{
|
||||
wxStrncpy(buf, wxT("Unknown User"), maxSize);
|
||||
}
|
||||
#endif // Win32/16
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -83,22 +83,23 @@ bool wxWriteResource(const wxString& section, const wxString& entry, int value,
|
||||
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
|
||||
{
|
||||
static const wxChar defunkt[] = wxT("$$default");
|
||||
|
||||
wxChar buf[1024];
|
||||
if (file != wxT(""))
|
||||
{
|
||||
int n = GetPrivateProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
|
||||
(LPTSTR)wxBuffer, 1000, (LPCTSTR)WXSTRINGCAST file);
|
||||
if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
|
||||
int n = GetPrivateProfileString(section, entry, defunkt,
|
||||
buf, WXSIZEOF(buf), file);
|
||||
if (n == 0 || wxStrcmp(buf, defunkt) == 0)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = GetProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
|
||||
(LPTSTR)wxBuffer, 1000);
|
||||
if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
|
||||
int n = GetProfileString(section, entry, defunkt, buf, WXSIZEOF(buf));
|
||||
if (n == 0 || wxStrcmp(buf, defunkt) == 0)
|
||||
return FALSE;
|
||||
}
|
||||
if (*value) delete[] (*value);
|
||||
*value = copystring(wxBuffer);
|
||||
*value = copystring(buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user