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
|
// global data
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
WXDLLIMPEXP_DATA_BASE(extern wxChar*) wxBuffer;
|
|
||||||
|
|
||||||
WXDLLIMPEXP_DATA_BASE(extern HINSTANCE) wxhInstance;
|
WXDLLIMPEXP_DATA_BASE(extern HINSTANCE) wxhInstance;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@@ -56,12 +56,6 @@ class WXDLLIMPEXP_BASE wxPoint;
|
|||||||
// String functions (deprecated, use wxString)
|
// 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'
|
// Make a copy of this string using 'new'
|
||||||
WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s);
|
WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s);
|
||||||
|
|
||||||
|
@@ -119,7 +119,6 @@
|
|||||||
// global variables
|
// global variables
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
extern wxChar *wxBuffer;
|
|
||||||
extern wxList WXDLLEXPORT wxPendingDelete;
|
extern wxList WXDLLEXPORT wxPendingDelete;
|
||||||
#ifndef __WXMICROWIN__
|
#ifndef __WXMICROWIN__
|
||||||
extern void wxSetKeyboardHook(bool doIt);
|
extern void wxSetKeyboardHook(bool doIt);
|
||||||
@@ -287,8 +286,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
|
#endif // wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
|
||||||
|
|
||||||
wxBuffer = new wxChar[1500]; // FIXME
|
|
||||||
|
|
||||||
#if defined(__WIN95__) && !defined(__WXMICROWIN__)
|
#if defined(__WIN95__) && !defined(__WXMICROWIN__)
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
#endif // __WIN95__
|
#endif // __WIN95__
|
||||||
@@ -500,9 +497,6 @@ bool wxApp::UnregisterWindowClasses()
|
|||||||
|
|
||||||
void wxApp::CleanUp()
|
void wxApp::CleanUp()
|
||||||
{
|
{
|
||||||
delete[] wxBuffer;
|
|
||||||
wxBuffer = NULL;
|
|
||||||
|
|
||||||
#ifndef __WXMICROWIN__
|
#ifndef __WXMICROWIN__
|
||||||
wxSetKeyboardHook(FALSE);
|
wxSetKeyboardHook(FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -583,13 +583,15 @@ void wxListBox::SetHorizontalExtent(const wxString& s)
|
|||||||
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
|
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
|
||||||
|
|
||||||
GetTextMetrics(dc, &lpTextMetric);
|
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);
|
int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LPARAM)buf);
|
||||||
wxBuffer[len] = 0;
|
buf[len] = 0;
|
||||||
SIZE extentXY;
|
SIZE extentXY;
|
||||||
::GetTextExtentPoint(dc, (LPTSTR)wxBuffer, len, &extentXY);
|
::GetTextExtentPoint(dc, buf, len, &extentXY);
|
||||||
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
|
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
|
||||||
if (extentX > largestExtent)
|
if (extentX > largestExtent)
|
||||||
largestExtent = extentX;
|
largestExtent = extentX;
|
||||||
|
@@ -240,100 +240,87 @@ bool wxGetUserId(wxChar *buf, int maxSize)
|
|||||||
// Get user name e.g. Julian Smart
|
// Get user name e.g. Julian Smart
|
||||||
bool wxGetUserName(wxChar *buf, int maxSize)
|
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
|
#ifdef USE_NET_API
|
||||||
CHAR szUserName[256];
|
CHAR szUserName[256];
|
||||||
if ( !wxGetUserId(szUserName, WXSIZEOF(szUserName)) )
|
if ( !wxGetUserId(szUserName, WXSIZEOF(szUserName)) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// TODO how to get the domain name?
|
// TODO how to get the domain name?
|
||||||
CHAR *szDomain = "";
|
CHAR *szDomain = "";
|
||||||
|
|
||||||
// the code is based on the MSDN example (also see KB article Q119670)
|
// the code is based on the MSDN example (also see KB article Q119670)
|
||||||
WCHAR wszUserName[256]; // Unicode user name
|
WCHAR wszUserName[256]; // Unicode user name
|
||||||
WCHAR wszDomain[256];
|
WCHAR wszDomain[256];
|
||||||
LPBYTE ComputerName;
|
LPBYTE ComputerName;
|
||||||
|
|
||||||
USER_INFO_2 *ui2; // User structure
|
USER_INFO_2 *ui2; // User structure
|
||||||
|
|
||||||
// Convert ANSI user name and domain to Unicode
|
// Convert ANSI user name and domain to Unicode
|
||||||
MultiByteToWideChar( CP_ACP, 0, szUserName, strlen(szUserName)+1,
|
MultiByteToWideChar( CP_ACP, 0, szUserName, strlen(szUserName)+1,
|
||||||
wszUserName, WXSIZEOF(wszUserName) );
|
wszUserName, WXSIZEOF(wszUserName) );
|
||||||
MultiByteToWideChar( CP_ACP, 0, szDomain, strlen(szDomain)+1,
|
MultiByteToWideChar( CP_ACP, 0, szDomain, strlen(szDomain)+1,
|
||||||
wszDomain, WXSIZEOF(wszDomain) );
|
wszDomain, WXSIZEOF(wszDomain) );
|
||||||
|
|
||||||
// Get the computer name of a DC for the domain.
|
// Get the computer name of a DC for the domain.
|
||||||
if ( NetGetDCName( NULL, wszDomain, &ComputerName ) != NERR_Success )
|
if ( NetGetDCName( NULL, wszDomain, &ComputerName ) != NERR_Success )
|
||||||
{
|
{
|
||||||
wxLogError(wxT("Can not find domain controller"));
|
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;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
// Look up the user on the DC
|
case NERR_UserNotFound:
|
||||||
NET_API_STATUS status = NetUserGetInfo( (LPWSTR)ComputerName,
|
wxLogError(wxT("Invalid user name '%s'."), szUserName);
|
||||||
(LPWSTR)&wszUserName,
|
|
||||||
2, // level - we want USER_INFO_2
|
|
||||||
(LPBYTE *) &ui2 );
|
|
||||||
switch ( status )
|
|
||||||
{
|
|
||||||
case NERR_Success:
|
|
||||||
// ok
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NERR_InvalidComputer:
|
goto error;
|
||||||
wxLogError(wxT("Invalid domain controller name."));
|
|
||||||
|
|
||||||
goto error;
|
default:
|
||||||
|
wxLogSysError(wxT("Can't get information about user"));
|
||||||
|
|
||||||
case NERR_UserNotFound:
|
goto error;
|
||||||
wxLogError(wxT("Invalid user name '%s'."), szUserName);
|
}
|
||||||
|
|
||||||
goto error;
|
// Convert the Unicode full name to ANSI
|
||||||
|
WideCharToMultiByte( CP_ACP, 0, ui2->usri2_full_name, -1,
|
||||||
|
buf, maxSize, NULL, NULL );
|
||||||
|
|
||||||
default:
|
return TRUE;
|
||||||
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;
|
|
||||||
|
|
||||||
error:
|
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
|
#else // !USE_NET_API
|
||||||
// Could use NIS, MS-Mail or other site specific programs
|
// Could use NIS, MS-Mail or other site specific programs
|
||||||
// Use wxWindows configuration data
|
// Use wxWindows configuration data
|
||||||
bool ok = GetProfileString(WX_SECTION, eUSERNAME, wxT(""), buf, maxSize - 1) != 0;
|
bool ok = GetProfileString(WX_SECTION, eUSERNAME, wxT(""), buf, maxSize - 1) != 0;
|
||||||
if ( !ok )
|
if ( !ok )
|
||||||
{
|
{
|
||||||
ok = wxGetUserId(buf, maxSize);
|
ok = wxGetUserId(buf, maxSize);
|
||||||
}
|
|
||||||
|
|
||||||
if ( !ok )
|
|
||||||
{
|
|
||||||
wxStrncpy(buf, wxT("Unknown User"), maxSize);
|
|
||||||
}
|
|
||||||
#endif // Win32/16
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !ok )
|
||||||
|
{
|
||||||
|
wxStrncpy(buf, wxT("Unknown User"), maxSize);
|
||||||
|
}
|
||||||
|
#endif // Win32/16
|
||||||
|
|
||||||
return TRUE;
|
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)
|
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
|
||||||
{
|
{
|
||||||
static const wxChar defunkt[] = wxT("$$default");
|
static const wxChar defunkt[] = wxT("$$default");
|
||||||
|
|
||||||
|
wxChar buf[1024];
|
||||||
if (file != wxT(""))
|
if (file != wxT(""))
|
||||||
{
|
{
|
||||||
int n = GetPrivateProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
|
int n = GetPrivateProfileString(section, entry, defunkt,
|
||||||
(LPTSTR)wxBuffer, 1000, (LPCTSTR)WXSTRINGCAST file);
|
buf, WXSIZEOF(buf), file);
|
||||||
if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
|
if (n == 0 || wxStrcmp(buf, defunkt) == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int n = GetProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
|
int n = GetProfileString(section, entry, defunkt, buf, WXSIZEOF(buf));
|
||||||
(LPTSTR)wxBuffer, 1000);
|
if (n == 0 || wxStrcmp(buf, defunkt) == 0)
|
||||||
if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (*value) delete[] (*value);
|
if (*value) delete[] (*value);
|
||||||
*value = copystring(wxBuffer);
|
*value = copystring(buf);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user