《Windows程序设计》之位块传输

来源:互联网 发布:正规淘宝代刷兼职 编辑:程序博客网 时间:2024/06/07 02:23
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){static HBITMAP hBitmap;static int cxClient,cyClient,cxSource,cySource;BITMAP bitmap;HDC hdc,hdcMem;HINSTANCE hInstance;int x,y;PAINTSTRUCT ps;switch(message){case WM_CREATE://实例句柄hInstance=((LPCREATESTRUCT)lParam)->hInstance;//载入图片hBitmap=LoadBitmap(hInstance,TEXT("Bricks"));//该函数得到指定图形对象的信息GetObject(hBitmap,sizeof(BITMAP),&bitmap);cxSource=bitmap.bmWidth;cySource=bitmap.bmHeight;return 0;case WM_SIZE:cxClient=LOWORD(lParam);cyClient=HIWORD(lParam);return 0;case WM_PAINT:hdc=BeginPaint(hwnd,&ps);//创建设备上下文hdcMem=CreateCompatibleDC(hdc);//把hBitmap选入设备SelectObject(hdcMem,hBitmap);for(y=0;y<cyClient;y+=cySource)for(x=0;x<cxClient;x+=cxSource)//把设备环境中的图像进行块转换,放入目标设备中BitBlt(hdc,x,y,cxSource,cySource,hdcMem,0,0,SRCCOPY);//删除设备环境DeleteDC(hdcMem);EndPaint(hwnd,&ps);return 0;case WM_DESTROY://删除hBitmapDeleteObject(hBitmap);PostQuitMessage(0);return 0;}return DefWindowProc(hwnd,message,wParam,lParam);}


原创粉丝点击