本文整理汇总了C++中wxStrlcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ wxStrlcpy函数的具体用法?C++ wxStrlcpy怎么用?C++ wxStrlcpy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxStrlcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxGetEmailAddress
// Get Full RFC822 style email address
bool wxGetEmailAddress(wxChar *address, int maxSize)
{
wxString email = wxGetEmailAddress();
if ( !email )
return false;
wxStrlcpy(address, email.t_str(), maxSize);
return true;
}
示例2: memset
bool wxTaskBarButtonImpl::InitOrUpdateThumbBarButtons()
{
THUMBBUTTON buttons[MAX_BUTTON_COUNT];
HRESULT hr;
for ( size_t i = 0; i < MAX_BUTTON_COUNT; ++i )
{
memset(&buttons[i], 0, sizeof buttons[i]);
buttons[i].iId = i;
buttons[i].dwFlags = THBF_HIDDEN;
buttons[i].dwMask = static_cast<THUMBBUTTONMASK>(THB_FLAGS);
}
for ( size_t i = 0; i < m_thumbBarButtons.size(); ++i )
{
buttons[i].hIcon = GetHiconOf(m_thumbBarButtons[i]->GetIcon());
buttons[i].dwFlags = GetNativeThumbButtonFlags(*m_thumbBarButtons[i]);
buttons[i].dwMask = static_cast<THUMBBUTTONMASK>(THB_ICON | THB_FLAGS);
wxString tooltip = m_thumbBarButtons[i]->GetTooltip();
if ( tooltip.empty() )
continue;
// Truncate the tooltip if its length longer than szTip(THUMBBUTTON)
// allowed length (260).
tooltip.Truncate(260);
wxStrlcpy(buttons[i].szTip, tooltip.t_str(), tooltip.length());
buttons[i].dwMask =
static_cast<THUMBBUTTONMASK>(buttons[i].dwMask | THB_TOOLTIP);
}
if ( !m_hasInitThumbnailToolbar )
{
hr = m_taskbarList->ThumbBarAddButtons(m_parent->GetHWND(),
MAX_BUTTON_COUNT,
buttons);
if ( FAILED(hr) )
{
wxLogApiError(wxT("ITaskbarList3::ThumbBarAddButtons"), hr);
}
m_hasInitThumbnailToolbar = true;
}
else
{
hr = m_taskbarList->ThumbBarUpdateButtons(m_parent->GetHWND(),
MAX_BUTTON_COUNT,
buttons);
if ( FAILED(hr) )
{
wxLogApiError(wxT("ITaskbarList3::ThumbBarUpdateButtons"), hr);
}
}
return SUCCEEDED(hr);
}
示例3: wxGetUserId
// returns %UserName%, $USER or just "user"
//
bool wxGetUserId(wxChar *buf, int n)
{
const wxChar *user = wxGetenv(wxT("UserName"));
if (!user)
user = wxGetenv(wxT("USER"));
if (!user)
user = wxT("user");
wxStrlcpy(buf, user, n);
return true;
}
示例4: wxGetHostName
// returns %ComputerName%, or $HOSTNAME, or "host"
//
bool wxGetHostName(wxChar *buf, int n)
{
const wxChar *host = wxGetenv(wxT("ComputerName"));
if (!host)
host = wxGetenv(wxT("HOSTNAME"));
if (!host)
host = wxT("host");
wxStrlcpy(buf, host, n);
return true;
}
示例5: wxGetUserId
bool wxGetUserId(wxChar *buf, int sz)
{
struct passwd *who;
*buf = wxT('\0');
if ((who = getpwuid(getuid ())) != NULL)
{
wxStrlcpy (buf, wxSafeConvertMB2WX(who->pw_name), sz);
return true;
}
return false;
}
示例6: wxStrlcpy
void wxFontEnumeratorHelper::DoEnumerate()
{
HDC hDC = ::GetDC(NULL);
LOGFONT lf;
lf.lfCharSet = (BYTE)m_charset;
wxStrlcpy(lf.lfFaceName, m_facename.c_str(), WXSIZEOF(lf.lfFaceName));
lf.lfPitchAndFamily = 0;
::EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)wxFontEnumeratorProc,
(LPARAM)this, 0 /* reserved */) ;
::ReleaseDC(NULL, hDC);
}
示例7: buf
bool wxSockAddressImpl::SetPath(const wxString& path)
{
sockaddr_un * const addr = Get<sockaddr_un>();
if ( !addr )
return false;
const wxScopedCharBuffer buf(path.utf8_str());
if ( strlen(buf) >= UNIX_PATH_MAX )
return false;
wxStrlcpy(addr->sun_path, buf, UNIX_PATH_MAX);
return true;
}
示例8: wxStrlcpy
// debugger helper: this function can be called from a debugger to show what
// the date really is
extern const char *wxDumpFont(const wxFont *font)
{
static char buf[256];
wxString s;
s.Printf(wxS("%s-%d-%s-%.2f-%d"),
font->GetFaceName(),
font->GetNumericWeight(),
font->GetStyle() == wxFONTSTYLE_NORMAL ? "regular" : "italic",
font->GetFractionalPointSize(),
font->GetEncoding());
wxStrlcpy(buf, s.mb_str(), WXSIZEOF(buf));
return buf;
}
示例9: wxGetHostName
// Get full hostname (eg. DoDo.BSn-Germany.crg.de)
bool wxGetHostName( wxChar* zBuf, int nMaxSize )
{
if (!zBuf) return false;
#if defined(wxUSE_NET_API) && wxUSE_NET_API
char zServer[256];
char zComputer[256];
unsigned long ulLevel = 0;
unsigned char* zBuffer = NULL;
unsigned long ulBuffer = 256;
unsigned long* pulTotalAvail = NULL;
NetBios32GetInfo( (const unsigned char*)zServer
,(const unsigned char*)zComputer
,ulLevel
,zBuffer
,ulBuffer
,pulTotalAvail
);
strcpy(zBuf, zServer);
#else
wxChar* zSysname;
const wxChar* zDefaultHost = _T("noname");
if ((zSysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL &&
(zSysname = wxGetenv(_T("HOSTNAME"))) == NULL)
{
::PrfQueryProfileString( HINI_PROFILE
,(PSZ)WX_SECTION
,(PSZ)eHOSTNAME
,(PSZ)zDefaultHost
,(void*)zBuf
,(ULONG)nMaxSize - 1
);
zBuf[nMaxSize] = _T('\0');
}
else
{
wxStrlcpy(zBuf, zSysname, nMaxSize);
}
#endif
return *zBuf ? true : false;
}
示例10: wxTaskBarIconWindow
// Operations
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
{
// NB: we have to create the window lazily because of backward compatibility,
// old applications may create a wxTaskBarIcon instance before wxApp
// is initialized (as samples/taskbar used to do)
if (!m_win)
{
m_win = new wxTaskBarIconWindow(this);
}
m_icon = icon;
m_strTooltip = tooltip;
NotifyIconData notifyData(GetHwndOf(m_win));
if (icon.IsOk())
{
notifyData.uFlags |= NIF_ICON;
notifyData.hIcon = GetHiconOf(icon);
}
// set NIF_TIP even for an empty tooltip: otherwise it would be impossible
// to remove an existing tooltip using this function
notifyData.uFlags |= NIF_TIP;
if ( !tooltip.empty() )
{
wxStrlcpy(notifyData.szTip, tooltip.t_str(), WXSIZEOF(notifyData.szTip));
}
bool ok = Shell_NotifyIcon(m_iconAdded ? NIM_MODIFY
: NIM_ADD, ¬ifyData) != 0;
if ( !ok )
{
wxLogLastError(wxT("Shell_NotifyIcon(NIM_MODIFY/ADD)"));
}
if ( !m_iconAdded && ok )
m_iconAdded = true;
return ok;
}
示例11: wxTestFontEncoding
bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
{
// try to create such font
LOGFONT lf;
wxZeroMemory(lf); // all default values
lf.lfCharSet = (BYTE)info.charset;
wxStrlcpy(lf.lfFaceName, info.facename.c_str(), WXSIZEOF(lf.lfFaceName));
HFONT hfont = ::CreateFontIndirect(&lf);
if ( !hfont )
{
// no such font
return false;
}
::DeleteObject((HGDIOBJ)hfont);
return true;
}
示例12: wxGetUserName
bool wxGetUserName(wxChar *buf, int sz)
{
#ifdef HAVE_PW_GECOS
struct passwd *who;
*buf = wxT('\0');
if ((who = getpwuid (getuid ())) != NULL)
{
char *comma = strchr(who->pw_gecos, ',');
if (comma)
*comma = '\0'; // cut off non-name comment fields
wxStrlcpy(buf, wxSafeConvertMB2WX(who->pw_gecos), sz);
return true;
}
return false;
#else // !HAVE_PW_GECOS
return wxGetUserId(buf, sz);
#endif // HAVE_PW_GECOS/!HAVE_PW_GECOS
}
示例13: wxStrlcpy
void wxFontEnumeratorHelper::DoEnumerate()
{
#ifndef __WXMICROWIN__
HDC hDC = ::GetDC(NULL);
#ifdef __WXWINCE__
::EnumFontFamilies(hDC,
m_facename.empty() ? NULL : m_facename.wx_str(),
(wxFONTENUMPROC)wxFontEnumeratorProc,
(LPARAM)this) ;
#else // __WIN32__
LOGFONT lf;
lf.lfCharSet = (BYTE)m_charset;
wxStrlcpy(lf.lfFaceName, m_facename.c_str(), WXSIZEOF(lf.lfFaceName));
lf.lfPitchAndFamily = 0;
::EnumFontFamiliesEx(hDC, &lf, (wxFONTENUMPROC)wxFontEnumeratorProc,
(LPARAM)this, 0 /* reserved */) ;
#endif // Win32/CE
::ReleaseDC(NULL, hDC);
#endif
}
示例14: notifyData
// Operations
bool gcTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
{
#ifdef WIN32
m_icon = icon;
m_strTooltip = tooltip;
NotifyIconData notifyData(GetHwndOf(m_win));
if (icon.Ok())
{
notifyData.uFlags |= NIF_ICON;
notifyData.hIcon = GetHiconOf(icon);
}
// set NIF_TIP even for an empty tooltip: otherwise it would be impossible
// to remove an existing tooltip using this function
notifyData.uFlags |= NIF_TIP;
if ( !tooltip.empty() )
{
wxStrlcpy(notifyData.szTip, tooltip.wx_str(), WXSIZEOF(notifyData.szTip));
}
bool ok = wxShellNotifyIcon(m_iconAdded ? NIM_MODIFY
: NIM_ADD, ¬ifyData) != 0;
if ( !ok )
{
wxLogLastError(wxT("wxShellNotifyIcon(NIM_MODIFY/ADD)"));
}
if ( !m_iconAdded && ok )
m_iconAdded = true;
return ok;
#else
return wxTaskBarIcon::SetIcon(icon, tooltip);
#endif
}
示例15: wxT
// debugger helper: this function can be called from a debugger to show what
// the date really is
extern const char *wxDumpFont(const wxFont *font)
{
static char buf[256];
const wxFontWeight weight = font->GetWeight();
wxString s;
s.Printf(wxS("%s-%s-%s-%d-%d"),
font->GetFaceName(),
weight == wxFONTWEIGHT_NORMAL
? wxT("normal")
: weight == wxFONTWEIGHT_BOLD
? wxT("bold")
: wxT("light"),
font->GetStyle() == wxFONTSTYLE_NORMAL
? wxT("regular")
: wxT("italic"),
font->GetPointSize(),
font->GetEncoding());
wxStrlcpy(buf, s.mb_str(), WXSIZEOF(buf));
return buf;
}