git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21571
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// global data
// ---------------------------------------------------------------------------
// global data
// ---------------------------------------------------------------------------
-WXDLLIMPEXP_DATA_BASE(extern wxChar*) wxBuffer;
-
WXDLLIMPEXP_DATA_BASE(extern HINSTANCE) wxhInstance;
// ---------------------------------------------------------------------------
WXDLLIMPEXP_DATA_BASE(extern HINSTANCE) wxhInstance;
// ---------------------------------------------------------------------------
// 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'
WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s);
// Make a copy of this string using 'new'
WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s);
// global variables
// ---------------------------------------------------------------------------
// global variables
// ---------------------------------------------------------------------------
-extern wxChar *wxBuffer;
extern wxList WXDLLEXPORT wxPendingDelete;
#ifndef __WXMICROWIN__
extern void wxSetKeyboardHook(bool doIt);
extern wxList WXDLLEXPORT wxPendingDelete;
#ifndef __WXMICROWIN__
extern void wxSetKeyboardHook(bool doIt);
}
#endif // wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
}
#endif // wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
- wxBuffer = new wxChar[1500]; // FIXME
-
#if defined(__WIN95__) && !defined(__WXMICROWIN__)
InitCommonControls();
#endif // __WIN95__
#if defined(__WIN95__) && !defined(__WXMICROWIN__)
InitCommonControls();
#endif // __WIN95__
- delete[] wxBuffer;
- wxBuffer = NULL;
-
#ifndef __WXMICROWIN__
wxSetKeyboardHook(FALSE);
#endif
#ifndef __WXMICROWIN__
wxSetKeyboardHook(FALSE);
#endif
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
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;
- ::GetTextExtentPoint(dc, (LPTSTR)wxBuffer, len, &extentXY);
+ ::GetTextExtentPoint(dc, buf, len, &extentXY);
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
if (extentX > largestExtent)
largestExtent = extentX;
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
if (extentX > largestExtent)
largestExtent = extentX;
// Get user name e.g. Julian Smart
bool wxGetUserName(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
- {
- 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"));
- // 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;
+ // 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."));
+ case NERR_InvalidComputer:
+ wxLogError(wxT("Invalid domain controller name."));
- case NERR_UserNotFound:
- wxLogError(wxT("Invalid user name '%s'."), szUserName);
+ case NERR_UserNotFound:
+ wxLogError(wxT("Invalid user name '%s'."), szUserName);
- default:
- wxLogSysError(wxT("Can't get information about user"));
+ default:
+ wxLogSysError(wxT("Can't get information about user"));
- // Convert the Unicode full name to ANSI
- WideCharToMultiByte( CP_ACP, 0, ui2->usri2_full_name, -1,
- buf, maxSize, NULL, NULL );
+ // Convert the Unicode full name to ANSI
+ WideCharToMultiByte( CP_ACP, 0, ui2->usri2_full_name, -1,
+ buf, maxSize, NULL, NULL );
- wxLogError(wxT("Couldn't look up full user name."));
+ wxLogError(wxT("Couldn't look up full user name."));
- // 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);
- }
+ // 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
+ if ( !ok )
+ {
+ wxStrncpy(buf, wxT("Unknown User"), maxSize);
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
{
static const wxChar defunkt[] = wxT("$$default");
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
{
static const wxChar defunkt[] = wxT("$$default");
- 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)
- 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);
return FALSE;
}
if (*value) delete[] (*value);
- *value = copystring(wxBuffer);
+ *value = copystring(buf);