本文整理汇总了C++中zerostruct函数的典型用法代码示例。如果您正苦于以下问题:C++ zerostruct函数的具体用法?C++ zerostruct怎么用?C++ zerostruct使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zerostruct函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: millisToUTC
static std::tm millisToUTC (int64 millis) noexcept
{
#if JUCE_WINDOWS && JUCE_MINGW
time_t now = (time_t) (millis / 1000);
return *gmtime (&now);
#elif JUCE_WINDOWS
std::tm result;
millis /= 1000;
if (_gmtime64_s (&result, &millis) != 0)
zerostruct (result);
return result;
#else
std::tm result;
time_t now = (time_t) (millis / 1000);
if (gmtime_r (&now, &result) == nullptr)
zerostruct (result);
return result;
#endif
}
示例2: zerostruct
ID3D11ShaderResourceView* D3D11Context::createShaderResourceView (ID3D11Texture2D* texture, DXGI_FORMAT srvFormat)
{
D3D11_TEXTURE2D_DESC texdesc;
texture->GetDesc (&texdesc);
D3D11_SHADER_RESOURCE_VIEW_DESC desc;
zerostruct (desc);
if (-1 == srvFormat)
desc.Format = texdesc.Format;
else
desc.Format = srvFormat;
if (1 == texdesc.ArraySize)
{
desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
desc.Texture2D.MipLevels = texdesc.MipLevels;
desc.Texture2D.MostDetailedMip = 0;
}
else
{
desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
desc.Texture2DArray.ArraySize = texdesc.ArraySize;
desc.Texture2DArray.FirstArraySlice = 0;
desc.Texture2DArray.MipLevels = texdesc.MipLevels;
desc.Texture2DArray.MostDetailedMip = 0;
}
Hold<ID3D11ShaderResourceView> srview;
if (m_failed (device->CreateShaderResourceView (texture, &desc, srview)))
return nullptr;
return srview.drop();
}
示例3: defined
//==============================================================================
void VstPluginExternalEditor::mouseExit (const MouseEvent& e)
{
#if defined(LINUX)
if (! handle) return;
XEvent ev;
zerostruct (ev);
ev.xcrossing.display = display;
ev.xcrossing.type = LeaveNotify;
ev.xcrossing.window = handle;
ev.xcrossing.root = RootWindow (display, DefaultScreen (display));
ev.xcrossing.time = CurrentTime;
ev.xcrossing.x = e.x;
ev.xcrossing.y = e.y;
ev.xcrossing.x_root = e.getScreenX ();
ev.xcrossing.y_root = e.getScreenY ();
ev.xcrossing.mode = NotifyNormal; // NotifyGrab, NotifyUngrab
ev.xcrossing.detail = NotifyAncestor; // NotifyVirtual, NotifyInferior, NotifyNonlinear,NotifyNonlinearVirtual
ev.xcrossing.focus = hasKeyboardFocus (true); // TODO - yes ?
translateJuceToXCrossingModifiers (e, ev);
sendEventToChild (& ev);
#endif
}
示例4: zerostruct
void AudioPlayHead::CurrentPositionInfo::resetToDefault()
{
zerostruct (*this);
timeSigNumerator = 4;
timeSigDenominator = 4;
bpm = 120;
}
示例5: Pimpl
Pimpl (SystemTrayIconComponent& owner_, HICON hicon, HWND hwnd)
: owner (owner_),
originalWndProc ((WNDPROC) GetWindowLongPtr (hwnd, GWLP_WNDPROC)),
taskbarCreatedMessage (RegisterWindowMessage (TEXT ("TaskbarCreated")))
{
SetWindowLongPtr (hwnd, GWLP_WNDPROC, (LONG_PTR) hookedWndProc);
zerostruct (iconData);
iconData.cbSize = sizeof (iconData);
iconData.hWnd = hwnd;
iconData.uID = (UINT) (pointer_sized_int) hwnd;
iconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
iconData.uCallbackMessage = WM_TRAYNOTIFY;
iconData.hIcon = hicon;
Shell_NotifyIcon (NIM_ADD, &iconData);
// In order to receive the "TaskbarCreated" message, we need to request that it's not filtered out.
// (Need to load dynamically, as ChangeWindowMessageFilter is only available in Vista and later)
typedef BOOL (WINAPI* ChangeWindowMessageFilterType) (UINT, DWORD);
ChangeWindowMessageFilterType changeWindowMessageFilter
= (ChangeWindowMessageFilterType) getUser32Function ("ChangeWindowMessageFilter");
if (changeWindowMessageFilter != nullptr)
changeWindowMessageFilter (taskbarCreatedMessage, 1 /* MSGFLT_ADD */);
}
示例6: defined
void VstPluginExternalEditor::updateWindowPosition (const int x, const int y)
{
#if defined(LINUX)
if (! handle) return;
XEvent ev;
zerostruct (ev);
ev.xgravity.type = GravityNotify;
ev.xgravity.display = display;
ev.xgravity.window = handle;
ev.xgravity.event = (Window) window->getWindowHandle ();
ev.xgravity.x = x;
ev.xgravity.y = y;
// DBG ("Window Position Updated to: " + String (x) + " " + String (y));
sendEventToChild (& ev);
#endif
//#ifdef JUCE_MAC
#if 0
if (vstGuiWindow)
vstGuiWindow->setTopLeftPosition(window->getX() + offsetX, window->getY() + offsetY);
#endif
}
示例7: CreateCompatibleDC
const StringArray Font::findAllTypefaceNames()
{
StringArray results;
HDC dc = CreateCompatibleDC (0);
{
LOGFONTW lf;
zerostruct (lf);
lf.lfWeight = FW_DONTCARE;
lf.lfOutPrecision = OUT_OUTLINE_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfPitchAndFamily = FF_DONTCARE;
lf.lfFaceName[0] = 0;
EnumFontFamiliesEx (dc, &lf,
(FONTENUMPROCW) &wfontEnum1,
(LPARAM) &results, 0);
}
DeleteDC (dc);
results.sort (true);
return results;
}
示例8: childBoundsChanged
void childBoundsChanged (juce::Component* child)
{
setSize (child->getWidth(), child->getHeight());
child->setTopLeftPosition (0, 0);
#if JUCE_WIN32
resizeHostWindow (hostWindow, titleW, titleH, this);
owner->updateSize();
#else
Rect r;
GetWindowBounds ((WindowRef) hostWindow, kWindowContentRgn, &r);
HIRect p;
zerostruct (p);
HIViewConvertRect (&p, parentView, 0); // find the X position of our view in case there's space to the left of it
r.right = r.left + jmax (titleW, ((int) p.origin.x) + getWidth());
r.bottom = r.top + getHeight() + titleH;
SetWindowBounds ((WindowRef) hostWindow, kWindowContentRgn, &r);
owner->updateSize();
owner->Invalidate();
#endif
}
示例9: wfontEnum1
static int CALLBACK wfontEnum1 (ENUMLOGFONTEXW* lpelfe,
NEWTEXTMETRICEXW*,
int type,
LPARAM lParam)
{
if (lpelfe != 0 && (type & RASTER_FONTTYPE) == 0)
{
LOGFONTW lf;
zerostruct (lf);
lf.lfWeight = FW_DONTCARE;
lf.lfOutPrecision = OUT_OUTLINE_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfPitchAndFamily = FF_DONTCARE;
const String fontName (lpelfe->elfLogFont.lfFaceName);
fontName.copyToUnicode (lf.lfFaceName, LF_FACESIZE - 1);
HDC dc = CreateCompatibleDC (0);
EnumFontFamiliesEx (dc, &lf,
(FONTENUMPROCW) &wfontEnum2,
lParam, 0);
DeleteDC (dc);
}
return 1;
}
示例10: fin
MD5::MD5 (const File& file)
{
FileInputStream fin (file);
if (fin.getStatus().wasOk())
processStream (fin, -1);
else
zerostruct (result);
}
示例11: Stat
JUCE_COMRESULT Stat (STATSTG* stat, DWORD)
{
if (stat == nullptr)
return STG_E_INVALIDPOINTER;
zerostruct (*stat);
stat->type = STGTY_STREAM;
stat->cbSize.QuadPart = jmax ((int64) 0, source.getTotalLength());
return S_OK;
}
示例12: zerostruct
BEGIN_JUCE_NAMESPACE
#include "juce_MD5.h"
#include "../io/files/juce_FileInputStream.h"
//==============================================================================
MD5::MD5()
{
zerostruct (result);
}
示例13: zerostruct
BEGIN_JUCE_NAMESPACE
#include "juce_MidiKeyboardState.h"
#include "../../core/juce_Time.h"
//==============================================================================
MidiKeyboardState::MidiKeyboardState()
{
zerostruct (noteStates);
}
示例14: millisToLocal
struct tm millisToLocal (const int64 millis) noexcept
{
struct tm result;
const int64 seconds = millis / 1000;
if (seconds < literal64bit (86400) || seconds >= literal64bit (2145916800))
{
// use extended maths for dates beyond 1970 to 2037..
const int timeZoneAdjustment = 31536000 - (int) (Time (1971, 0, 1, 0, 0).toMilliseconds() / 1000);
const int64 jdm = seconds + timeZoneAdjustment + literal64bit (210866803200);
const int days = (int) (jdm / literal64bit (86400));
const int a = 32044 + days;
const int b = (4 * a + 3) / 146097;
const int c = a - (b * 146097) / 4;
const int d = (4 * c + 3) / 1461;
const int e = c - (d * 1461) / 4;
const int m = (5 * e + 2) / 153;
result.tm_mday = e - (153 * m + 2) / 5 + 1;
result.tm_mon = m + 2 - 12 * (m / 10);
result.tm_year = b * 100 + d - 6700 + (m / 10);
result.tm_wday = (days + 1) % 7;
result.tm_yday = -1;
int t = (int) (jdm % literal64bit (86400));
result.tm_hour = t / 3600;
t %= 3600;
result.tm_min = t / 60;
result.tm_sec = t % 60;
result.tm_isdst = -1;
}
else
{
time_t now = static_cast <time_t> (seconds);
#if JUCE_WINDOWS
#ifdef USE_NEW_SECURE_TIME_FNS
if (now >= 0 && now <= 0x793406fff)
localtime_s (&result, &now);
else
zerostruct (result);
#else
result = *localtime (&now);
#endif
#else
localtime_r (&now, &result); // more thread-safe
#endif
}
return result;
}
示例15: bindSocketToPort
static bool bindSocketToPort (const SocketHandle handle, const int port) noexcept
{
if (handle <= 0 || port <= 0)
return false;
struct sockaddr_in servTmpAddr;
zerostruct (servTmpAddr); // (can't use "= { 0 }" on this object because it's typedef'ed as a C struct)
servTmpAddr.sin_family = PF_INET;
servTmpAddr.sin_addr.s_addr = htonl (INADDR_ANY);
servTmpAddr.sin_port = htons ((uint16) port);
return bind (handle, (struct sockaddr*) &servTmpAddr, sizeof (struct sockaddr_in)) >= 0;
}