主题:[原创]一段功能奇妙的代码
[b]下面是一段功能奇妙的代码,大家试试,呵,申明:本代码绝非病毒代码!!!
新建工程Win32 Application
//------------一段功能奇妙的代码----------------
#include <windows.h>
#define CELL 600
#define TIMES 150
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
PSTR szCmdLine,int iCmdShow)
{
HWND hwnd;
HBITMAP hBitmap[2];
HDC hdcScr,hdcTemp[2];
int i,iScrx,iScry;
iScrx=GetSystemMetrics(SM_CXSCREEN);
iScry=GetSystemMetrics(SM_CYSCREEN);
if(LockWindowUpdate(hwnd=GetDesktopWindow()))
{
hdcScr=GetDCEx(hwnd,NULL,DCX_CACHE|DCX_LOCKWINDOWUPDATE);
hdcTemp[0]=CreateCompatibleDC(hdcScr);
hBitmap[0]=CreateCompatibleBitmap(hdcScr,CELL,CELL);
SelectObject(hdcTemp[0],hBitmap[0]);
hdcTemp[1]=CreateCompatibleDC(hdcScr);
hBitmap[1]=CreateCompatibleBitmap(hdcScr,CELL/5,CELL/5);
SelectObject(hdcTemp[1],hBitmap[1]);
BitBlt(hdcTemp[0],0,0,CELL,CELL,hdcScr,(iScrx-CELL)/2,(iScry-CELL)/2,SRCCOPY);
BitBlt(hdcTemp[1],0,0,CELL/5,CELL/5,hdcScr,(iScrx-CELL/5)/2,(iScry-CELL/5)/2,SRCCOPY);
for(i=1;i<TIMES;i+=5)
{
StretchBlt(hdcScr,(iScrx-CELL/5-i*0.8*CELL/TIMES)/2,(iScry-CELL/5-i*0.8*CELL/TIMES)/2,
CELL/5+i*0.8*CELL/TIMES,CELL/5+i*0.8*CELL/TIMES,
hdcTemp[1],0,0,CELL/5,CELL/5,SRCCOPY);
Sleep(1000/TIMES);
}
BitBlt(hdcScr,(iScrx-CELL)/2,(iScry-CELL)/2,CELL,CELL,hdcTemp[0],0,0,SRCCOPY);
ReleaseDC(hwnd,hdcScr);
DeleteDC(hdcTemp[0]);
DeleteDC(hdcTemp[1]);
DeleteObject(hBitmap);
LockWindowUpdate(NULL);
}
return FALSE;
}
[em1]
新建工程Win32 Application
//------------一段功能奇妙的代码----------------
#include <windows.h>
#define CELL 600
#define TIMES 150
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
PSTR szCmdLine,int iCmdShow)
{
HWND hwnd;
HBITMAP hBitmap[2];
HDC hdcScr,hdcTemp[2];
int i,iScrx,iScry;
iScrx=GetSystemMetrics(SM_CXSCREEN);
iScry=GetSystemMetrics(SM_CYSCREEN);
if(LockWindowUpdate(hwnd=GetDesktopWindow()))
{
hdcScr=GetDCEx(hwnd,NULL,DCX_CACHE|DCX_LOCKWINDOWUPDATE);
hdcTemp[0]=CreateCompatibleDC(hdcScr);
hBitmap[0]=CreateCompatibleBitmap(hdcScr,CELL,CELL);
SelectObject(hdcTemp[0],hBitmap[0]);
hdcTemp[1]=CreateCompatibleDC(hdcScr);
hBitmap[1]=CreateCompatibleBitmap(hdcScr,CELL/5,CELL/5);
SelectObject(hdcTemp[1],hBitmap[1]);
BitBlt(hdcTemp[0],0,0,CELL,CELL,hdcScr,(iScrx-CELL)/2,(iScry-CELL)/2,SRCCOPY);
BitBlt(hdcTemp[1],0,0,CELL/5,CELL/5,hdcScr,(iScrx-CELL/5)/2,(iScry-CELL/5)/2,SRCCOPY);
for(i=1;i<TIMES;i+=5)
{
StretchBlt(hdcScr,(iScrx-CELL/5-i*0.8*CELL/TIMES)/2,(iScry-CELL/5-i*0.8*CELL/TIMES)/2,
CELL/5+i*0.8*CELL/TIMES,CELL/5+i*0.8*CELL/TIMES,
hdcTemp[1],0,0,CELL/5,CELL/5,SRCCOPY);
Sleep(1000/TIMES);
}
BitBlt(hdcScr,(iScrx-CELL)/2,(iScry-CELL)/2,CELL,CELL,hdcTemp[0],0,0,SRCCOPY);
ReleaseDC(hwnd,hdcScr);
DeleteDC(hdcTemp[0]);
DeleteDC(hdcTemp[1]);
DeleteObject(hBitmap);
LockWindowUpdate(NULL);
}
return FALSE;
}
[em1]