当前位置: 首页>>代码示例>>C++>>正文


C++ DeleteDC函数代码示例

本文整理汇总了C++中DeleteDC函数的典型用法代码示例。如果您正苦于以下问题:C++ DeleteDC函数的具体用法?C++ DeleteDC怎么用?C++ DeleteDC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DeleteDC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_DIB_PAL_COLORS

static void test_DIB_PAL_COLORS(void) {
    HDC hdc = GetDC( NULL );
    HDC memhdc = CreateCompatibleDC( hdc );
    HBITMAP hbmp, hbmpOld;
    char bmpbuf[sizeof(BITMAPINFO) + 10 * sizeof(WORD)];
    PBITMAPINFO bmp = (PBITMAPINFO)bmpbuf;
    WORD * bmpPalPtr;
    char logpalettebuf[sizeof(LOGPALETTE) + sizeof(logpalettedata)];
    PLOGPALETTE logpalette = (PLOGPALETTE)logpalettebuf;
    HPALETTE hpal, hpalOld;
    COLORREF setColor, chkColor, getColor;
    int i;

    /* Initialize the logical palette with a few colours */
    logpalette->palVersion = 0x300;
    logpalette->palNumEntries = 8;
    memcpy( logpalette->palPalEntry, logpalettedata, sizeof(logpalettedata) );
    hpal = CreatePalette( logpalette ); 
    hpalOld = SelectPalette( memhdc, hpal, FALSE );
    ok( hpalOld != NULL, "error=%d\n", GetLastError() );

    /* Create a DIB BMP which references colours in the logical palette */
    memset( bmp, 0x00, sizeof(BITMAPINFO) );
    bmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmp->bmiHeader.biWidth = 1;
    bmp->bmiHeader.biHeight = 1;
    bmp->bmiHeader.biPlanes = 1;
    bmp->bmiHeader.biBitCount = 8;
    bmp->bmiHeader.biCompression = BI_RGB;
    bmp->bmiHeader.biClrUsed = 10;
    bmp->bmiHeader.biClrImportant = 0;
    bmpPalPtr = (WORD *)&bmp->bmiColors;
    for( i = 0; i < 8; i++ ) {
        *bmpPalPtr++ = i;
    }
    *bmpPalPtr++ = 8; /* Pointer to logical palette index just outside range */
    *bmpPalPtr++ = 19; /* Pointer to bad logical palette index */

    hbmp = CreateDIBSection( memhdc, bmp, DIB_PAL_COLORS, 0, 0, 0 );
    ok( hbmp != NULL, "error=%d\n", GetLastError() );
    hbmpOld = SelectObject( memhdc, hbmp );
    ok( hbmpOld != NULL, "error=%d\n", GetLastError() );

    /* Test with a RGB to DIB_PAL_COLORS */
    setColor = RGB( logpalettedata[1].peRed, logpalettedata[1].peGreen, logpalettedata[1].peBlue );
    SetPixel( memhdc, 0, 0, setColor );
    chkColor = RGB( logpalettedata[1].peRed, logpalettedata[1].peGreen, logpalettedata[1].peBlue );
    getColor = GetPixel( memhdc, 0, 0 );
    ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );

    /* Test with a valid DIBINDEX to DIB_PAL_COLORS */
    setColor = DIBINDEX( 2 );
    SetPixel( memhdc, 0, 0, setColor );
    chkColor = RGB( logpalettedata[2].peRed, logpalettedata[2].peGreen, logpalettedata[2].peBlue );
    getColor = GetPixel( memhdc, 0, 0 );
    ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );

    /* Test with an invalid DIBINDEX to DIB_PAL_COLORS */
    setColor = DIBINDEX( 12 );
    SetPixel( memhdc, 0, 0, setColor );
    chkColor = RGB( 0, 0, 0 );
    getColor = GetPixel( memhdc, 0, 0 );
    ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );

    /* Test for double wraparound on logical palette references from */
    /* DIBINDEX by DIB_PAL_COLORS. */
    setColor = DIBINDEX( 9 );
    SetPixel( memhdc, 0, 0, setColor );
    chkColor = RGB( logpalettedata[3].peRed, logpalettedata[3].peGreen, logpalettedata[3].peBlue );
    getColor = GetPixel( memhdc, 0, 0 );
    ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );

    SelectPalette( memhdc, hpalOld, FALSE );
    DeleteObject( hpal );
    SelectObject( memhdc, hbmpOld );
    DeleteObject( hbmp );
    DeleteDC( memhdc );
    ReleaseDC( NULL, hdc );
}
开发者ID:hoangduit,项目名称:reactos,代码行数:79,代码来源:palette.c

示例2: SplashRedrawWindow

/* The function makes the window visible if it is hidden
 or is not yet shown. */
void
SplashRedrawWindow(Splash * splash)
{
    if (!SplashIsStillLooping(splash)) {
        KillTimer(splash->hWnd, 0);
    }

    if (splash->currentFrame < 0) {
        return;
    }

    SplashUpdateScreenData(splash);
    if (splash->isLayered) {
        BLENDFUNCTION bf;
        POINT ptSrc;
        HDC hdcSrc = CreateCompatibleDC(NULL), hdcDst;
        BITMAPINFOHEADER bmi;
        void *bitmapBits;
        HBITMAP hBitmap, hOldBitmap;
        RECT rect;
        POINT ptDst;
        SIZE size;

        bf.BlendOp = AC_SRC_OVER;
        bf.BlendFlags = 0;
        bf.AlphaFormat = AC_SRC_ALPHA;
        bf.SourceConstantAlpha = 0xFF;
        ptSrc.x = ptSrc.y = 0;

        memset(&bmi, 0, sizeof(bmi));
        bmi.biSize = sizeof(BITMAPINFOHEADER);
        bmi.biWidth = splash->width;
        bmi.biHeight = -splash->height;
        bmi.biPlanes = 1;
        bmi.biBitCount = 32;
        bmi.biCompression = BI_RGB;

        //      FIXME: this is somewhat ineffective
        //      maybe if we allocate memory for all frames as DIBSections,
        //      then we could select the frames into the DC directly

        hBitmap = CreateDIBSection(NULL, (BITMAPINFO *) & bmi, DIB_RGB_COLORS,
                &bitmapBits, NULL, 0);
        memcpy(bitmapBits, splash->screenData,
                splash->screenStride * splash->height);
        hOldBitmap = (HBITMAP) SelectObject(hdcSrc, hBitmap);
        hdcDst = GetDC(splash->hWnd);

        GetWindowRect(splash->hWnd, &rect);

        ptDst.x = rect.left;
        ptDst.y = rect.top;

        size.cx = splash->width;
        size.cy = splash->height;

        UpdateLayeredWindow(splash->hWnd, hdcDst, &ptDst, &size,
                hdcSrc, &ptSrc, 0, &bf, ULW_ALPHA);

        ReleaseDC(splash->hWnd, hdcDst);
        SelectObject(hdcSrc, hOldBitmap);
        DeleteObject(hBitmap);
        DeleteDC(hdcSrc);
    }
    else {
       InvalidateRect(splash->hWnd, NULL, FALSE);
       if (splash->maskRequired) {
            HRGN hRgn = CreateRectRgn(0, 0, 0, 0);

            CombineRgn(hRgn, splash->frames[splash->currentFrame].hRgn,
                    splash->frames[splash->currentFrame].hRgn, RGN_COPY);
            SetWindowRgn(splash->hWnd, hRgn, TRUE);
        } else {
            SetWindowRgn(splash->hWnd, NULL, TRUE);
        }
        UpdateWindow(splash->hWnd);
    }
    if (!IsWindowVisible(splash->hWnd)) {
        POINT cursorPos;
        ShowWindow(splash->hWnd, SW_SHOW);
        // Windows won't update the cursor after the window is shown,
        // if the cursor is already above the window. need to do this manually.
        GetCursorPos(&cursorPos);
        if (WindowFromPoint(cursorPos) == splash->hWnd) {
            // unfortunately Windows fail to understand that the window
            // thread should own the cursor, even though the mouse pointer
            // is over the window, until the mouse has been moved.
            // we're using SetCursorPos here to fake the mouse movement
            // and enable proper update of the cursor.
            SetCursorPos(cursorPos.x, cursorPos.y);
            SetCursor(LoadCursor(NULL, IDC_WAIT));
        }
    }
    if (SplashIsStillLooping(splash)) {
        int time = splash->time +
            splash->frames[splash->currentFrame].delay - SplashTime();

        if (time < 0)
//.........这里部分代码省略.........
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:101,代码来源:splashscreen_sys.c

示例3: MainWindowProcedure

// Handles OS messages, is driven by the 'main loop' above.
LRESULT CALLBACK MainWindowProcedure(HWND windowHandle, UINT messageCode, WPARAM wParam, LPARAM lParam)
{
	switch (messageCode) {
	// On window creation.
	case WM_CREATE:
		DEBUG_OUT(TEXT("WM_CREATE message"));
		// Start game loop timer.
		DEBUG_VAL(TEXT("SetTimer()"), SetTimer(windowHandle, MAIN_CYCLE_TIMER_ID, MAIN_CYCLE_WAIT, NULL));
		break;
	
	// Upon redraw request or something else changing we draw the window.
	case WM_PAINT:
		{
			PAINTSTRUCT paintJobStruct;
			HDC deviceContextHandle = BeginPaint(windowHandle, &paintJobStruct);
			HDC bufferDeviceContextHandle = CreateCompatibleDC(deviceContextHandle);
			HBITMAP bufferBitmapHandle = CreateCompatibleBitmap(deviceContextHandle, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
			HGDIOBJ oldBufferBitmapHandle = SelectObject(bufferDeviceContextHandle, bufferBitmapHandle);
			Gdiplus::Graphics graphics(bufferDeviceContextHandle);
			graphics.SetSmoothingMode(GRAPHICS_SMOOTHING_MODE);
			DrawGame(graphics, *mainGameObject);
			BitBlt(deviceContextHandle, 0, 0, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT, bufferDeviceContextHandle, 0, 0, SRCCOPY);
			SelectObject(bufferDeviceContextHandle, oldBufferBitmapHandle);
			DeleteDC(bufferDeviceContextHandle);
			DeleteObject(bufferBitmapHandle);
			EndPaint(windowHandle, &paintJobStruct);
		}
		break;
	
	// When a user presses a key (can be triggered by auto-repeat).
	case WM_KEYDOWN:
		DEBUG_OUT(TEXT("WM_KEYDOWN message"));
		DEBUG_VAL(TEXT("wParam"), wParam);
		switch(wParam) {
		case VK_LEFT:
		case VK_UP:
		case VK_RIGHT:
		case VK_DOWN:
			DEBUG_OUT(TEXT("Arrow key pressed"));
			mainGameObject->Input(wParam);
		}
		break;
		
	case WM_TIMER:
		if (wParam == MAIN_CYCLE_TIMER_ID) {
			// This is where the 'main game loop' kicks in.  This line should be reached at a frequency of about 60Hz.
			mainGameObject->Step(windowHandle);
			RedrawWindow(windowHandle, NULL, NULL, RDW_INVALIDATE);
			//InvalidateRect(windowHandle, NULL, TRUE);
			//UpdateWindow(windowHandle);
		}
		break;
		
	case WM_CLOSE:
		DEBUG_OUT(TEXT("WM_CLOSE message"));
		// Clean up Windows API objects and etc.
		KillTimer(windowHandle, MAIN_CYCLE_TIMER_ID);
		DestroyWindow(windowHandle);
		break;
		
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
		
	default:
		return DefWindowProc(windowHandle, messageCode, wParam, lParam);
		break;
	}
	return 0;
}
开发者ID:Veltas,项目名称:recursive-maze-game,代码行数:71,代码来源:main.cpp

示例4: Paint

static void Paint(HWND hWnd, LPPAINTSTRUCT lpPS) {

    GetClientRect(hWnd, &rc);

    hdcMem = CreateCompatibleDC(lpPS->hdc);
    hbmMem = CreateCompatibleBitmap(lpPS->hdc, rc.right-rc.left, rc.bottom-rc.top);
    hbmOld = (HBITMAP) SelectObject(hdcMem, hbmMem);
    hbrBkGnd = CreateSolidBrush(GetSysColor(COLOR_WINDOW));

    FillRect(hdcMem, &rc, hbrBkGnd);

    for(int i = 0; i < vectorSize; i++){
        x = vec[i].getX();
        y = vec[i].getY();
        hbrBkGnd = CreateSolidBrush(RGB(vec[i].getR(), vec[i].getG(), vec[i].getB()));
        SelectObject(hdcMem, hbrBkGnd);


        for(int j = 0; j < vectorSize; j++){
            if(j != i){
                if(vec[i].trueCollision(vec[j].getX(), vec[j].getY())){
                    vec[i].setColor(rand()%250, rand()%250, rand()%250);
                    vec[j].setColor(rand()%250, rand()%250, rand()%250);

                }
            }
        }

        vec[i].collision(rect.right, rect.bottom);


        switch(vec[i].getDir()) {
            case 0:
                x += vec[i].getVelocity() + velocity;
                y += vec[i].getVelocity() + velocity;
                break;
            case 1:
                x -= vec[i].getVelocity() + velocity;
                y += vec[i].getVelocity() + velocity;
                break;
            case 2:
                x += vec[i].getVelocity() + velocity;
                y -= vec[i].getVelocity() + velocity;
                break;
            case 3:
                x -= vec[i].getVelocity() + velocity;
                y -= vec[i].getVelocity() + velocity;
                break;
        }

        vec[i].setPosition(x, y);
        if(vec[i].trueCircle()){
            Ellipse(hdcMem, vec[i].getX(), vec[i].getY(), vec[i].getX() + vec[i].getWidth(),
                    vec[i].getY() + vec[i].getHeight());
        }else{
            Rectangle(hdcMem, vec[i].getX(), vec[i].getY(), vec[i].getX() + vec[i].getWidth(),
                      vec[i].getY() + vec[i].getHeight());
        }
    }
    DeleteObject(hbrBkGnd);
    SetBkMode(hdcMem, BACKGROUND_BLUE);
    SetTextColor(hdcMem, GetSysColor(COLOR_WINDOWTEXT));


    if (hfntOld) {
        SelectObject(hdcMem, hfntOld);
    }

    BitBlt(lpPS->hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdcMem, 0, 0, SRCCOPY);

    SelectObject(hdcMem, hbmOld);
    DeleteObject(hbmMem);
    DeleteDC(hdcMem);

}
开发者ID:TUM-FAF,项目名称:FAF-141-Schidu-Vasile,代码行数:75,代码来源:main.cpp

示例5: rgnCreateFromBitmap


//.........这里部分代码省略.........

		//	Look for the beginning of a run

		x = 0;
		xRunStart = -1;
		while (x < bm.bmWidth)
			{
			if (xRunStart == -1)
				{
				//	If we're not in a run and we suddenly find a white pixel
				//	then we know that we begin a run

				if (PixelAt(pLine, x))
					xRunStart = x;
				}
			else
				{
				//	If we're in a run and we suddenly find a black pixel
				//	then we know that we're done

				if (!PixelAt(pLine, x))
					{
					RECT rcRect;

					rcRect.left = xRunStart;
					rcRect.top = y;
					rcRect.right = x;
					rcRect.bottom = y + 1;

					//	Add the rect to the region

					if (error = Output.Write((char *)&rcRect, sizeof(rcRect), NULL))
						goto Fail;

					rdh.nCount++;
					rdh.nRgnSize += sizeof(RECT);

					xRunStart = -1;
					}
				}

			x++;
			}

		//	If we were in a run, then end it

		if (xRunStart != -1)
			{
			RECT rcRect;

			rcRect.left = xRunStart;
			rcRect.top = y;
			rcRect.right = x;
			rcRect.bottom = y + 1;

			//	Add the rect to the region

			if (error = Output.Write((char *)&rcRect, sizeof(rcRect), NULL))
				goto Fail;

			rdh.nCount++;
			rdh.nRgnSize += sizeof(RECT);
			}
		}

	//	Close it out

	MemFree(pLine);
	pLine = NULL;

	DeleteDC(hDC);
	hDC = NULL;

	if (error = Output.Close())
		goto Fail;

	//	Update the header

	*(RGNDATAHEADER *)Output.GetPointer() = rdh;

	//	Create the region

	*rethRgn = ExtCreateRegion(NULL,
			Output.GetLength(),
			(RGNDATA *)Output.GetPointer());

	//	Done

	return NOERROR;

Fail:

	if (pLine)
		MemFree(pLine);

	if (hDC)
		DeleteDC(hDC);

	return error;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:101,代码来源:Regions.cpp

示例6: VERIFY

CMonitorDC::~CMonitorDC()
{
	VERIFY( DeleteDC() );
}
开发者ID:moodboom,项目名称:Reusable,代码行数:4,代码来源:MultiMonitor.cpp

示例7: GetClientRect

void CDrawCheckbox::Draw(HDC hDC)
{
    RECT rcWnd = {};
    GetClientRect(m_hWnd, &rcWnd);
    int nWidth = rcWnd.right - rcWnd.left;
    int nHeight = rcWnd.bottom - rcWnd.top;

    HDC hMemDC = CreateCompatibleDC(hDC);
    HBITMAP hBmpMem = CreateCompatibleBitmap(hDC, nWidth, nHeight);
    HBITMAP hOldBmpMem = (HBITMAP)SelectObject(hMemDC, hBmpMem);

    Image *pDrawImg = NULL;
    if(!m_fLight)
    {
        pDrawImg = m_pNormalStateImg;
    }
    else
    {
        pDrawImg = m_pLightStateImg;
    }

    int nBmpWidth = pDrawImg->GetWidth();
    int nBmpHeight = pDrawImg->GetHeight();

    if (m_bkimState == BKLS_HORIZONTAL)
    {
        nBmpWidth = pDrawImg->GetWidth() / 8;
        nBmpHeight = pDrawImg->GetHeight();
    }
    else
    {
        nBmpWidth = pDrawImg->GetWidth();
        nBmpHeight = pDrawImg->GetHeight() / 8;
    }

    //绘制父窗口背景图
	BitBlt(hMemDC, 0, 0, nWidth, nHeight, m_DrawBackgroundDC.m_hDC, 0, 0, SRCCOPY);

    //绘制背景图,高宽一样大小
    //StretchBlt(hDC, 0, nYPos, nWidth, nHeight - nYPos, hMemDC, nXBmpPos,\
    //    0, nBmpWidth, nBmpHeight, SRCCOPY);
    SetBkMode(hMemDC, TRANSPARENT);
    Graphics graphics(hMemDC); // Create a GDI+ graphics object
    RectF gRect; 
    gRect.X = (REAL)0;
    gRect.Y = (REAL)0; 
    gRect.Width = (REAL)nHeight; 
    gRect.Height = (REAL)nHeight;

    if (m_bkimState == BKLS_HORIZONTAL)
    {
        graphics.DrawImage(pDrawImg, gRect, (REAL)nBmpWidth * m_nCtrlState + m_bCheck * 4 * nBmpWidth, 0, (REAL)nBmpWidth, (REAL)nBmpHeight, UnitPixel);
    }
    else
    {
        graphics.DrawImage(pDrawImg, gRect, 0, (REAL)nBmpHeight * m_nCtrlState + m_bCheck * 4 * nBmpWidth, (REAL)nBmpWidth, (REAL)nBmpHeight, UnitPixel);
    }

    //  绘制文本
    //  当前绘制文本为单行,若绘制多行,可修改一下源码
    TCHAR szCaption[g_nCaptionLen] = {};
    GetWindowText(m_hWnd, szCaption, g_nCaptionLen - 1);
    if(_tcslen(szCaption) > 0)
	{
		HFONT hOldFont = (HFONT)SelectObject(hMemDC, m_hFont);
		rcWnd.left += nHeight + 2;
		rcWnd.top ++;
		SetTextColor(hMemDC, m_colorText);
		DrawText(hMemDC, szCaption, _tcslen(szCaption), &rcWnd, DT_VCENTER|DT_SINGLELINE);
		SelectObject(hMemDC, hOldFont);
	}

	BitBlt(hDC, 0, 0, nWidth, nHeight, hMemDC, 0, 0, SRCCOPY);

	SetBkMode(hMemDC, OPAQUE);
	graphics.ReleaseHDC(hMemDC);
    SelectObject(hMemDC, hOldBmpMem);
    DeleteObject(hBmpMem);
    DeleteDC(hMemDC);
}
开发者ID:haomiao,项目名称:OwnerDrawCtrl,代码行数:80,代码来源:DrawCheckbox.cpp

示例8: test_surface_from_dc3

static void test_surface_from_dc3(void)
{
    IDirectDrawSurface3 *surf3;
    IDirectDrawSurface *surf1;
    IDirectDrawSurface *tmp;
    DDSURFACEDESC ddsd;
    IDirectDraw3 *dd3;
    IDirectDraw *dd1;
    HRESULT hr;
    HDC dc;

    dd1 = createDD();
    hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw3, (void **)&dd3);
    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed, hr %#x.\n", hr);
    IDirectDraw_Release(dd1);

    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
    ddsd.dwWidth = 64;
    ddsd.dwHeight = 64;
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;

    hr = IDirectDraw3_CreateSurface(dd3, &ddsd, &surf1, NULL);
    if (hr == DDERR_UNSUPPORTEDMODE) {
        win_skip("Unsupported mode\n");
        IDirectDraw3_Release(dd3);
        return;
    }
    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#x.\n", hr);

    hr = IDirectDrawSurface3_QueryInterface(surf1, &IID_IDirectDrawSurface, (void **)&surf3);
    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
    IDirectDrawSurface_Release(surf1);

    hr = IDirectDrawSurface3_GetDC(surf3, &dc);
    ok(SUCCEEDED(hr), "GetDC failed, hr %#x.\n", hr);

    hr = IDirectDraw3_GetSurfaceFromDC(dd3, dc, NULL);
    ok(hr == E_POINTER, "Expected E_POINTER, got %#x.\n", hr);

    hr = IDirectDraw3_GetSurfaceFromDC(dd3, dc, &tmp);
    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#x.\n", hr);
    ok((IDirectDrawSurface3 *)tmp == surf3, "Expected surface != %p.\n", surf3);

    IUnknown_Release(tmp);

    hr = IDirectDrawSurface3_ReleaseDC(surf3, dc);
    ok(SUCCEEDED(hr), "ReleaseDC failed, hr %#x.\n", hr);

    dc = CreateCompatibleDC(NULL);
    ok(!!dc, "CreateCompatibleDC failed.\n");

    tmp = (IDirectDrawSurface *)0xdeadbeef;
    hr = IDirectDraw3_GetSurfaceFromDC(dd3, dc, &tmp);
    ok(hr == DDERR_NOTFOUND, "Expected DDERR_NOTFOUND, got %#x.\n", hr);
    ok(!tmp, "Expected surface NULL, got %p.\n", tmp);

    ok(DeleteDC(dc), "DeleteDC failed.\n");

    IDirectDrawSurface3_Release(surf3);
    IDirectDraw3_Release(dd3);
}
开发者ID:YokoZar,项目名称:wine,代码行数:63,代码来源:surface.c

示例9: test_surface_from_dc4

static void test_surface_from_dc4(void)
{
    IDirectDrawSurface4 *surf4;
    IDirectDrawSurface *surf1;
    DDSURFACEDESC2 ddsd2;
    IUnknown *tmp, *tmp2;
    IDirectDraw4 *dd4;
    IDirectDraw *dd1;
    DWORD priv, size;
    HRESULT hr;
    HDC dc;

    dd1 = createDD();
    hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw4, (void **)&dd4);
    if (hr == E_NOINTERFACE) {
        win_skip("DirectDraw4 is not supported\n");
        IDirectDraw_Release(dd1);
        return;
    }
    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed, hr %#x.\n", hr);
    IDirectDraw_Release(dd1);

    memset(&ddsd2, 0, sizeof(ddsd2));
    ddsd2.dwSize = sizeof(ddsd2);
    ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
    ddsd2.dwWidth = 64;
    ddsd2.dwHeight = 64;
    ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;

    hr = IDirectDraw4_CreateSurface(dd4, &ddsd2, &surf4, NULL);
    if (hr == DDERR_UNSUPPORTEDMODE) {
        win_skip("Unsupported mode\n");
        IDirectDraw3_Release(dd4);
        return;
    }
    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#x.\n", hr);

    hr = IDirectDrawSurface4_QueryInterface(surf4, &IID_IDirectDrawSurface, (void **)&surf1);
    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);

    priv = 0xdeadbeef;
    size = sizeof(priv);
    hr = IDirectDrawSurface4_SetPrivateData(surf4, &guid, &priv, size, 0);
    ok(SUCCEEDED(hr), "SetPrivateData failed, hr %#x.\n", hr);

    priv = 0;
    hr = IDirectDrawSurface4_GetPrivateData(surf4, &guid, &priv, &size);
    ok(SUCCEEDED(hr), "GetPrivateData failed, hr %#x.\n", hr);
    ok(priv == 0xdeadbeef, "Expected private data 0xdeadbeef, got %#x.\n", priv);

    hr = IDirectDrawSurface4_GetDC(surf4, &dc);
    ok(SUCCEEDED(hr), "GetDC failed, hr %#x.\n", hr);

    hr = IDirectDraw4_GetSurfaceFromDC(dd4, dc, NULL);
    ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %#x.\n", hr);

    hr = IDirectDraw4_GetSurfaceFromDC(dd4, dc, (IDirectDrawSurface4 **)&tmp);
    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#x.\n", hr);
    ok((IDirectDrawSurface4 *)tmp != surf4, "Expected surface != %p.\n", surf4);

    hr = IUnknown_QueryInterface(tmp, &IID_IDirectDrawSurface, (void **)&tmp2);
    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
    ok(tmp2 == tmp, "Expected %p, got %p.\n", tmp, tmp2);
    ok((IDirectDrawSurface *)tmp2 != surf1, "Expected surface != %p.\n", surf1);
    IUnknown_Release(tmp2);

    hr = IUnknown_QueryInterface(tmp, &IID_IDirectDrawSurface4, (void **)&tmp2);
    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
    ok((IDirectDrawSurface4 *)tmp2 != surf4, "Expected surface != %p.\n", surf4);

    priv = 0;
    hr = IDirectDrawSurface4_GetPrivateData((IDirectDrawSurface4 *)tmp2, &guid, &priv, &size);
    ok(SUCCEEDED(hr), "GetPrivateData failed, hr %#x.\n", hr);
    ok(priv == 0xdeadbeef, "Expected private data 0xdeadbeef, got %#x.\n", priv);
    IUnknown_Release(tmp2);

    IUnknown_Release(tmp);

    hr = IDirectDrawSurface4_ReleaseDC(surf4, dc);
    ok(SUCCEEDED(hr), "ReleaseDC failed, hr %#x.\n", hr);

    dc = CreateCompatibleDC(NULL);
    ok(!!dc, "CreateCompatibleDC failed.\n");

    tmp = (IUnknown *)0xdeadbeef;
    hr = IDirectDraw4_GetSurfaceFromDC(dd4, dc, (IDirectDrawSurface4 **)&tmp);
    ok(hr == DDERR_NOTFOUND, "Expected DDERR_NOTFOUND, got %#x.\n", hr);
    ok(!tmp, "Expected surface NULL, got %p.\n", tmp);

    ok(DeleteDC(dc), "DeleteDC failed.\n");

    tmp = (IUnknown *)0xdeadbeef;
    hr = IDirectDraw4_GetSurfaceFromDC(dd4, NULL, (IDirectDrawSurface4 **)&tmp);
    ok(hr == DDERR_NOTFOUND, "Expected DDERR_NOTFOUND, got %#x.\n", hr);
    ok(!tmp, "Expected surface NULL, got %p.\n", tmp);

    IDirectDrawSurface_Release(surf1);
    IDirectDrawSurface4_Release(surf4);
    IDirectDraw4_Release(dd4);
}
开发者ID:YokoZar,项目名称:wine,代码行数:100,代码来源:surface.c

示例10: ComponentFactory_CreateBitmapFromHICON

static HRESULT WINAPI ComponentFactory_CreateBitmapFromHICON(IWICComponentFactory *iface,
    HICON hicon, IWICBitmap **bitmap)
{
    IWICBitmapLock *lock;
    ICONINFO info;
    BITMAP bm;
    int width, height, x, y;
    UINT stride, size;
    BYTE *buffer;
    DWORD *bits;
    BITMAPINFO bi;
    HDC hdc;
    BOOL has_alpha;
    HRESULT hr;

    TRACE("(%p,%p,%p)\n", iface, hicon, bitmap);

    if (!bitmap) return E_INVALIDARG;

    if (!GetIconInfo(hicon, &info))
        return HRESULT_FROM_WIN32(GetLastError());

    GetObjectW(info.hbmColor ? info.hbmColor : info.hbmMask, sizeof(bm), &bm);

    width = bm.bmWidth;
    height = info.hbmColor ? abs(bm.bmHeight) : abs(bm.bmHeight) / 2;
    stride = width * 4;
    size = stride * height;

    hr = BitmapImpl_Create(width, height, stride, size, NULL, 0,
                           &GUID_WICPixelFormat32bppBGRA, WICBitmapCacheOnLoad, bitmap);
    if (hr != S_OK) goto failed;

    hr = IWICBitmap_Lock(*bitmap, NULL, WICBitmapLockWrite, &lock);
    if (hr != S_OK)
    {
        IWICBitmap_Release(*bitmap);
        goto failed;
    }
    IWICBitmapLock_GetDataPointer(lock, &size, &buffer);

    hdc = CreateCompatibleDC(0);

    memset(&bi, 0, sizeof(bi));
    bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
    bi.bmiHeader.biWidth = width;
    bi.bmiHeader.biHeight = info.hbmColor ? -height: -height * 2;
    bi.bmiHeader.biPlanes = 1;
    bi.bmiHeader.biBitCount = 32;
    bi.bmiHeader.biCompression = BI_RGB;

    has_alpha = FALSE;

    if (info.hbmColor)
    {
        GetDIBits(hdc, info.hbmColor, 0, height, buffer, &bi, DIB_RGB_COLORS);

        if (bm.bmBitsPixel == 32)
        {
            /* If any pixel has a non-zero alpha, ignore hbmMask */
            bits = (DWORD *)buffer;
            for (x = 0; x < width && !has_alpha; x++, bits++)
            {
                for (y = 0; y < height; y++)
                {
                    if (*bits & 0xff000000)
                    {
                        has_alpha = TRUE;
                        break;
                    }
                }
            }
        }
    }
    else
        GetDIBits(hdc, info.hbmMask, 0, height, buffer, &bi, DIB_RGB_COLORS);

    if (!has_alpha)
    {
        DWORD *rgba;

        if (info.hbmMask)
        {
            BYTE *mask;

            mask = HeapAlloc(GetProcessHeap(), 0, size);
            if (!mask)
            {
                IWICBitmapLock_Release(lock);
                IWICBitmap_Release(*bitmap);
                DeleteDC(hdc);
                hr = E_OUTOFMEMORY;
                goto failed;
            }

            /* read alpha data from the mask */
            GetDIBits(hdc, info.hbmMask, info.hbmColor ? 0 : height, height, mask, &bi, DIB_RGB_COLORS);

            for (y = 0; y < height; y++)
            {
//.........这里部分代码省略.........
开发者ID:ccpgames,项目名称:wine,代码行数:101,代码来源:imgfactory.c

示例11: OnShowdireNum

UINT OnShowdireNum(LPVOID lParam)
{
  	int x=0;
	int y=0;
	int t=0;
   	double pi=3.1415926535898;
	double r=170;
    int a=0;
    int b=0;
	int m_shownum=0;
 	BITMAP  m_bitmapinfo;                                       //位图信息结构                  
	CBitmap m_bitmap;                                           //位图处理类  
	
	CDC  m_men;
	m_men.CreateCompatibleDC(m_diredashdc);

	CPen m_pen1(NULL,3,RGB(255,0,0));
	CPen m_pen2(NULL,5,RGB(255,0,0));
	
	CRect m_childrect;
	m_childrect.top=0;
	m_childrect.left=0;
    m_childrect.bottom=600;
    m_childrect.right=700;

	
	while(1){
    m_bitmap.LoadBitmapA(MAKEINTRESOURCEA(IDB_YAM));
    m_bitmap.GetBitmap(&m_bitmapinfo);
	m_men.SelectObject(&m_bitmap);
	
	m_shownum=(int)m_flightinfo.m_udirection; 
	
	m_men.SelectObject(&m_pen1);
	m_men.SelectStockObject(NULL_BRUSH);
	m_men.Ellipse(m_direrect.Width()/2-14-15+5+120,m_direrect.Height()/2+6-15-2+110,m_direrect.Width()/2-14+15+5+120,m_direrect.Height()/2+6+15-2+110);
	m_pen1.DeleteObject();
	
	m_men.SelectObject(&m_pen2);   
	m_men.Ellipse(m_direrect.Width()/2-14-5+5+120,m_direrect.Height()/2+6-5-2+110,m_direrect.Width()/2-14+5+5+120,m_direrect.Height()/2+6+5-2+110);
	m_pen2.DeleteObject();
	
	m_men.SelectObject(&m_pen1);
	m_men.MoveTo(m_direrect.Width()/2-14+5+120,m_direrect.Height()/2+6-2+110);
    x=m_direrect.Width()/2-14+5+120;
	y=m_direrect.Height()/2+6-2+110;
	t=(int)((m_shownum-1050)*180/900);
    a=x-(int)(r*cos(t*pi/180));
	b=y-(int)(r*sin(t*pi/180));
	m_men.LineTo(a,b);
	m_pen1.DeleteObject();

	m_diredashdc->SetStretchBltMode(HALFTONE);
    m_diredashdc->StretchBlt(m_direrect.top,m_direrect.left,m_direrect.Width(),m_direrect.Height(),&m_men,0,0,m_bitmapinfo.bmWidth,m_bitmapinfo.bmHeight,SRCCOPY);

	m_bitmap.DeleteObject();


	Sleep(14);
	}
	
	DeleteDC(m_men.m_hDC);
    
	return 1;
}
开发者ID:whitelok,项目名称:SimAirCockpit,代码行数:65,代码来源:DirectionDash.cpp

示例12: ComponentFactory_CreateBitmapFromHBITMAP

static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFactory *iface,
    HBITMAP hbm, HPALETTE hpal, WICBitmapAlphaChannelOption option, IWICBitmap **bitmap)
{
    BITMAP bm;
    HRESULT hr;
    WICPixelFormatGUID format;
    IWICBitmapLock *lock;
    UINT size, num_palette_entries = 0;
    PALETTEENTRY entry[256];

    TRACE("(%p,%p,%p,%u,%p)\n", iface, hbm, hpal, option, bitmap);

    if (!bitmap) return E_INVALIDARG;

    if (GetObjectW(hbm, sizeof(bm), &bm) != sizeof(bm))
        return WINCODEC_ERR_WIN32ERROR;

    if (hpal)
    {
        num_palette_entries = GetPaletteEntries(hpal, 0, 256, entry);
        if (!num_palette_entries)
            return WINCODEC_ERR_WIN32ERROR;
    }

    /* TODO: Figure out the correct format for 16, 32, 64 bpp */
    switch(bm.bmBitsPixel)
    {
    case 1:
        format = GUID_WICPixelFormat1bppIndexed;
        break;
    case 4:
        format = GUID_WICPixelFormat4bppIndexed;
        break;
    case 8:
        format = GUID_WICPixelFormat8bppIndexed;
        break;
    case 16:
        if (!get_16bpp_format(hbm, &format))
            return E_INVALIDARG;
        break;
    case 24:
        format = GUID_WICPixelFormat24bppBGR;
        break;
    case 32:
        switch (option)
        {
        case WICBitmapUseAlpha:
            format = GUID_WICPixelFormat32bppBGRA;
            break;
        case WICBitmapUsePremultipliedAlpha:
            format = GUID_WICPixelFormat32bppPBGRA;
            break;
        case WICBitmapIgnoreAlpha:
            format = GUID_WICPixelFormat32bppBGR;
            break;
        default:
            return E_INVALIDARG;
        }
        break;
    case 48:
        format = GUID_WICPixelFormat48bppRGB;
        break;
    default:
        FIXME("unsupported %d bpp\n", bm.bmBitsPixel);
        return E_INVALIDARG;
    }

    hr = BitmapImpl_Create(bm.bmWidth, bm.bmHeight, bm.bmWidthBytes, 0, NULL, 0, &format,
                           WICBitmapCacheOnLoad, bitmap);
    if (hr != S_OK) return hr;

    hr = IWICBitmap_Lock(*bitmap, NULL, WICBitmapLockWrite, &lock);
    if (hr == S_OK)
    {
        BYTE *buffer;
        HDC hdc;
        char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
        BITMAPINFO *bmi = (BITMAPINFO *)bmibuf;

        IWICBitmapLock_GetDataPointer(lock, &size, &buffer);

        hdc = CreateCompatibleDC(0);

        bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
        bmi->bmiHeader.biBitCount = 0;
        GetDIBits(hdc, hbm, 0, 0, NULL, bmi, DIB_RGB_COLORS);
        bmi->bmiHeader.biHeight = -bm.bmHeight;
        GetDIBits(hdc, hbm, 0, bm.bmHeight, buffer, bmi, DIB_RGB_COLORS);

        DeleteDC(hdc);
        IWICBitmapLock_Release(lock);

        if (num_palette_entries)
        {
            IWICPalette *palette;
            WICColor colors[256];
            UINT i;

            hr = PaletteImpl_Create(&palette);
            if (hr == S_OK)
//.........这里部分代码省略.........
开发者ID:ccpgames,项目名称:wine,代码行数:101,代码来源:imgfactory.c

示例13: ThrowReaderException


//.........这里部分代码省略.........
        }
      else
        {
          *p='\0';
          flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
            &image->rows);
          if (image->x_resolution != 0.0)
            image->columns=(size_t) floor(((image->columns*image->x_resolution)/
              DefaultResolution)+0.5);
          if (image->y_resolution != 0.0)
            image->rows=(size_t) floor(((image->rows*image->y_resolution)/
              DefaultResolution)+0.5);
        }
      geometry=DestroyString(geometry);
    }
  hDC=GetDC(NULL);
  if (hDC == (HDC) NULL)
    {
      DeleteEnhMetaFile(hemf);
      ThrowReaderException(ResourceLimitError,"UnableToCreateADC");
    }
  /*
    Initialize the bitmap header info.
  */
  (void) ResetMagickMemory(&DIBinfo,0,sizeof(BITMAPINFO));
  DIBinfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
  DIBinfo.bmiHeader.biWidth=(LONG) image->columns;
  DIBinfo.bmiHeader.biHeight=(-1)*(LONG) image->rows;
  DIBinfo.bmiHeader.biPlanes=1;
  DIBinfo.bmiHeader.biBitCount=32;
  DIBinfo.bmiHeader.biCompression=BI_RGB;
  hBitmap=CreateDIBSection(hDC,&DIBinfo,DIB_RGB_COLORS,(void **) &ppBits,NULL,
    0);
  ReleaseDC(NULL,hDC);
  if (hBitmap == (HBITMAP) NULL)
    {
      DeleteEnhMetaFile(hemf);
      ThrowReaderException(ResourceLimitError,"UnableToCreateBitmap");
    }
  hDC=CreateCompatibleDC(NULL);
  if (hDC == (HDC) NULL)
    {
      DeleteEnhMetaFile(hemf);
      DeleteObject(hBitmap);
      ThrowReaderException(ResourceLimitError,"UnableToCreateADC");
    }
  hOldBitmap=(HBITMAP) SelectObject(hDC,hBitmap);
  if (hOldBitmap == (HBITMAP) NULL)
    {
      DeleteEnhMetaFile(hemf);
      DeleteDC(hDC);
      DeleteObject(hBitmap);
      ThrowReaderException(ResourceLimitError,"UnableToCreateBitmap");
    }
  /*
    Initialize the bitmap to the image background color.
  */
  pBits=ppBits;
  for (y=0; y < (ssize_t) image->rows; y++)
  {
    for (x=0; x < (ssize_t) image->columns; x++)
    {
      pBits->rgbRed=ScaleQuantumToChar(image->background_color.red);
      pBits->rgbGreen=ScaleQuantumToChar(image->background_color.green);
      pBits->rgbBlue=ScaleQuantumToChar(image->background_color.blue);
      pBits++;
    }
  }
  rect.top=0;
  rect.left=0;
  rect.right=(LONG) image->columns;
  rect.bottom=(LONG) image->rows;
  /*
    Convert metafile pixels.
  */
  PlayEnhMetaFile(hDC,hemf,&rect);
  pBits=ppBits;
  for (y=0; y < (ssize_t) image->rows; y++)
  {
    q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
    if (q == (PixelPacket *) NULL)
      break;
    for (x=0; x < (ssize_t) image->columns; x++)
    {
      SetPixelRed(q,ScaleCharToQuantum(pBits->rgbRed));
      SetPixelGreen(q,ScaleCharToQuantum(pBits->rgbGreen));
      SetPixelBlue(q,ScaleCharToQuantum(pBits->rgbBlue));
      SetPixelOpacity(q,OpaqueOpacity);
      pBits++;
      q++;
    }
    if (SyncAuthenticPixels(image,exception) == MagickFalse)
      break;
  }
  DeleteEnhMetaFile(hemf);
  SelectObject(hDC,hOldBitmap);
  DeleteDC(hDC);
  DeleteObject(hBitmap);
  return(GetFirstImageInList(image));
}
开发者ID:ikbear,项目名称:ImageMagick,代码行数:101,代码来源:emf.c

示例14: GBK_InitVisibleTable

int GBK_InitVisibleTable()
{
    HDC hdc = CreateCompatibleDC( GetWindowDC( GetDesktopWindow() ) );
	HBITMAP hBmp = CreateCompatibleBitmap(hdc, 12, 12);
    RECT rect = {0, 0, 12, 12};

	BITMAPINFO bi;

	ZeroMemory(&bi, sizeof(bi));
	bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bi.bmiHeader.biWidth = 12;
	bi.bmiHeader.biHeight = 12;
	bi.bmiHeader.biPlanes = 1;
	bi.bmiHeader.biBitCount = 16;
	bi.bmiHeader.biCompression = BI_RGB;

    LOGFONT lf;

	lf.lfHeight = 0xfffffff4;
	lf.lfWidth = 0x00000000;
	lf.lfEscapement = 0x00000000;
	lf.lfOrientation = 0x00000000;
	lf.lfWeight = 0x00000190;
	lf.lfItalic = 0;
	lf.lfUnderline = 0;
	lf.lfStrikeOut = 0;
	lf.lfCharSet = 0;
	lf.lfOutPrecision = 0x03;
	lf.lfClipPrecision = 0x02;
	lf.lfQuality = 0x01;
	lf.lfPitchAndFamily = 0x02;
	strcpy(lf.lfFaceName, "宋体");

    HFONT hFont = CreateFontIndirect(&lf);
    if(hFont == 0)
    {
        MessageBox(NULL, "字体创建失败!", "Error", MB_OK | MB_ICONEXCLAMATION);
        return 0;
    }
    
    SelectObject(hdc, hFont);
	SelectObject(hdc, hBmp);

	SetBkColor(hdc, RGB(0, 0, 0));
	SetTextColor(hdc, RGB(255, 255, 255));

    unsigned short TestBuf[12][12];

    for (unsigned short lead=0x81; lead<0xff; lead++)
    for (unsigned short follow=0x40; follow<0xff; follow++)
    {
        bool test = false;

        if (follow != 0x7f)
        {
            unsigned short ucode = MAKEWORD(lead, follow);
		    DrawText(hdc, (char *)&ucode, 2, &rect, 0);
		    GetDIBits(hdc, hBmp, 0, 12, *TestBuf, &bi, 0);

		    for (int nY=0; nY<12; nY++)
		    {
			    for(int nX = 0; nX<12; nX++)
			    {
                    test |= (TestBuf[nY][nX] != 0);
			    }
		    }
        }

        GBK_VisibleTable[lead - 0x81][follow - 0x40] = test;
    }

    DeleteObject(hFont);
    DeleteObject(hBmp);
    DeleteDC(hdc);

    return 1;
}
开发者ID:luw630,项目名称:Server,代码行数:77,代码来源:GBK_VisibleTest.cpp

示例15: MyWindowFunc

/* Функция обработки сообщения окна.
* АРГУМЕНТЫ:
* - дескриптор окна:
* HWND hWnd;
* - номер сообщения (см. WM_***):
* UINT Msg;
* - параметр сообшения ('word parameter'):
* WPARAM wParam;
* - параметр сообшения ('long parameter'):
* LPARAM lParam;
* ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ:
* (LRESULT) - в зависимости от сообщения.
*/
LRESULT CALLBACK MyWindowFunc( HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam )
{
HDC hDC;
static HDC hMemDC;
static INT w, h;
static BITMAP bm;
static HBITMAP hBm;
switch (Msg)
{
case WM_CREATE:
SetTimer(hWnd, 111, 50, NULL);
/* создаем контекст в памяти */
hDC = GetDC(hWnd);
hMemDC = CreateCompatibleDC(hDC);
ReleaseDC(hWnd, hDC);
return 0;
case WM_SIZE:
w = LOWORD(lParam);
h = HIWORD(lParam);
/* создаем картинку размером с окно */
if (hBm != NULL)
DeleteObject(hBm);
hDC = GetDC(hWnd);
hBm = CreateCompatibleBitmap(hDC, w, h);
ReleaseDC(hWnd, hDC);
SelectObject(hMemDC, hBm);
SendMessage(hWnd, WM_TIMER, 111, 0);
return 0;
case WM_TIMER:
/* Clear Background */
SelectObject(hMemDC, GetStockObject(NULL_PEN));
SelectObject(hMemDC, GetStockObject(DC_BRUSH));
SetDCBrushColor(hMemDC, RGB(255, 255, 255));
Rectangle(hMemDC, 0, 0, w + 1, h + 1);
SelectObject(hMemDC, GetStockObject(NULL_PEN));
SelectObject(hMemDC, GetStockObject(DC_BRUSH));
SetDCBrushColor(hMemDC, RGB(255, 0, 0));
GlobeBuild();
GlobeDraw(hMemDC, w, h);
InvalidateRect(hWnd, NULL, TRUE);
return 0;
case WM_KEYDOWN:
if (wParam == 'F')
  FlipFullScreen(hWnd);
if (wParam == 27)
  SendMessage(hWnd, WM_CLOSE, 0, 0);
if (wParam == 'W')
  IsWire = !IsWire;
return 0;

case WM_CLOSE:
if (MessageBox(hWnd, "Are you shure to exit from program?",
"Exit", MB_YESNO | MB_ICONQUESTION) == IDNO)
return 0;
break;
case WM_ERASEBKGND:
BitBlt((HDC)wParam, 0, 0, w, h, hMemDC, 0, 0, SRCCOPY);
return 0;
case WM_DESTROY:
DeleteDC(hMemDC);
DeleteObject(hBm);
KillTimer(hWnd, 111);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
开发者ID:Akrilont,项目名称:SUM2015,代码行数:81,代码来源:t05globe.c


注:本文中的DeleteDC函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。