本文整理汇总了C++中LPDIRECTDRAWSURFACE7::UpdateOverlay方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE7::UpdateOverlay方法的具体用法?C++ LPDIRECTDRAWSURFACE7::UpdateOverlay怎么用?C++ LPDIRECTDRAWSURFACE7::UpdateOverlay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWSURFACE7
的用法示例。
在下文中一共展示了LPDIRECTDRAWSURFACE7::UpdateOverlay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InternalWndProc
LRESULT CALLBACK InternalWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps; // Structure for the paint message
POINT p = {0, 0}; // Translation point for the window's client region
HRESULT hRet;
switch (iMsg)
{
case WM_MOVE:
// Make sure we're not moving to be minimized - because otherwise
// our ratio varialbes (g_dwXRatio and g_dwYRatio) will end up
// being 0, and once we hit CheckBoundries it divides by 0.
if (!IsIconic(hwnd))
{
g_rcSrc.left = 0;
g_rcSrc.right = g_sizex;
g_rcSrc.top = 0;
g_rcSrc.bottom = g_sizey;
GetClientRect(hwnd, &g_rcDst);
g_dwXRatio = (g_rcDst.right - g_rcDst.left) * 1000 /
(g_rcSrc.right - g_rcSrc.left);
g_dwYRatio = (g_rcDst.bottom - g_rcDst.top) * 1000 /
(g_rcSrc.bottom - g_rcSrc.top);
ClientToScreen(hwnd, &p);
g_rcDst.left = p.x;
g_rcDst.top = p.y;
g_rcDst.bottom += p.y;
g_rcDst.right += p.x;
CheckBoundries();
}
else
// Else, hide the overlay... just in case we can't do
// destination color keying, this will pull the overlay
// off of the screen for the user.
if (g_pDDSOverlay && g_pDDSPrimary)
g_pDDSOverlay->UpdateOverlay(NULL, g_pDDSPrimary, NULL, DDOVER_HIDE, NULL);
// Check to make sure our window exists before we tell it to
// repaint. This will fail the first time (while the window is being created).
if (hwnd)
{
InvalidateRect(hwnd, NULL, FALSE);
UpdateWindow(hwnd);
}
return 0L;
case WM_SIZE:
// Another check for the minimization action. This check is
// quicker though...
if (wParam != SIZE_MINIMIZED)
{
GetClientRect(hwnd, &g_rcDst);
ClientToScreen(hwnd, &p);
g_rcDst.left = p.x;
g_rcDst.top = p.y;
g_rcDst.bottom += p.y;
g_rcDst.right += p.x;
g_rcSrc.left = 0;
g_rcSrc.right = g_sizex;
g_rcSrc.top = 0;
g_rcSrc.bottom = g_sizey;
// Here we multiply by 1000 to preserve 3 decimal places in the
// division opperation (we picked 1000 to be on the same order
// of magnitude as the stretch factor for easier comparisons)
g_dwXRatio = (g_rcDst.right - g_rcDst.left) * 1000 /
(g_rcSrc.right - g_rcSrc.left);
g_dwYRatio = (g_rcDst.bottom - g_rcDst.top) * 1000 /
(g_rcSrc.bottom - g_rcSrc.top);
CheckBoundries();
}
return 0L;
case WM_PAINT:
BeginPaint(hwnd, &ps);
// Check the primary surface to see if it's lost - if so you can
// pretty much bet that the other surfaces are also lost - thus
// restore EVERYTHING! If we got our surfaces stolen by a full
// screen app - then we'll destroy our primary - and won't be able
// to initialize it again. When we get our next paint message (the
// full screen app closed for example) we'll want to try to reinit
// the surfaces again - that's why there is a check for
// g_pDDSPrimary == NULL. The other option, is that our program
// went through this process, could init the primary again, but it
// couldn't init the overlay, that's why there's a third check for
// g_pDDSOverlay == NULL. Make sure that the check for
// !g_pDDSPrimary is BEFORE the IsLost call - that way if the
// pointer is NULL (ie. !g_pDDSPrimary is TRUE) - the compiler
// won't try to evaluate the IsLost function (which, since the
// g_pDDSPrimary surface is NULL, would be bad...).
if (!g_pDDSPrimary || (g_pDDSPrimary->IsLost() != DD_OK) ||
(g_pDDSOverlay == NULL))
{
DestroyOverlay();
DestroyPrimary();
if (DDPrimaryInit())
if (DDOverlayInit())
if (!DrawOverlay())
DestroyOverlay();
}
// UpdateOverlay is how we put the overlay on the screen.
if (g_pDDSOverlay && g_pDDSPrimary && g_video->updating)
//.........这里部分代码省略.........