回 帖 发 新 帖 刷新版面

主题:[原创]仿骇客帝国数据精流

#include<windows.h>
#include<stdlib.h>
#include<time.h>

#define ID_TIMER1 1
#define ID_TIMER2 2

LRESULT CALLBACK Winproc(HWND,UINT,WPARAM,LPARAM);

int cxChar,cyChar;
COLORREF color[] = {RGB(176,251,255),RGB(147,250,255),RGB(117,249,255),RGB(89,247,255),RGB(47,244,255),RGB(11,243,255),RGB(0,216,227),RGB(0,186,196),RGB(0,153,162),RGB(0,139,147),RGB(0,115,121),RGB(0,95,100)};



int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
    static HWND hwnd;
    TCHAR szAppName[] = TEXT("HK");
    MSG msg;
    WNDCLASS wc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    wc.hCursor = NULL;
    wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
    wc.hInstance = hInstance;
    wc.lpszClassName = szAppName;
    wc.lpfnWndProc = Winproc;
    wc.lpszMenuName = NULL;
    wc.style = CS_VREDRAW | CS_HREDRAW;

    if(!RegisterClass(&wc))
    {
        MessageBox(NULL,TEXT("注册失败"),TEXT("警告框"),MB_OK);
        return 0;
    }

    hwnd = CreateWindow(szAppName,TEXT("矩阵数据流"),
                        WS_OVERLAPPEDWINDOW,
                        CW_USEDEFAULT,CW_USEDEFAULT,
                        CW_USEDEFAULT,CW_USEDEFAULT,
                        NULL,NULL,hInstance,NULL);

    ShowWindow(hwnd,SW_MAXIMIZE);
    UpdateWindow(hwnd);

    while(GetMessage(&msg,NULL,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}

LRESULT CALLBACK Winproc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
{
    int x,y;
    static int *p;
    static int value,i;
    static int cyScreen,cxScreen;
    static int iLine=-1;
    static TCHAR szBuffer[1];
    static HDC hdc;
    static SYSTEMTIME st;

    switch(message)
    {
    case WM_CREATE:
        hdc = GetDC(hwnd);
        cxChar = LOWORD(GetDialogBaseUnits());
        cyChar = HIWORD(GetDialogBaseUnits());
    
        SetTimer(hwnd,ID_TIMER1,50,NULL);
    
        SetTimer(hwnd,ID_TIMER2,60,NULL);
        
        return 0;

    case WM_SIZE:
        
        cyScreen = HIWORD(lparam);
        cxScreen = LOWORD(lparam);
        if(p) delete []p;
        p = new int[(int)(cxScreen/cxChar)];
        for(x=0; x<(int)(cxScreen/cxChar); x++)
            *(p+x) = rand()%100;
        return 0;

    case WM_TIMER:
        switch(wparam)
        {
            case ID_TIMER1:
                if(value>=10) value=0;
                value++;            
             break;

            case ID_TIMER2:
                
                if(iLine>=260)
                { 
                    iLine =0;
                    srand((unsigned)time(0));
                    for(x=0; x<(int)(cxScreen/cxChar); x++)
                        *(p+x) = rand()%100;
                }
                iLine++;
            for(x=0; x<=(int)(cxScreen/cxChar);x++)

                for(y=0; y<=((int)(iLine-*(p+x))); y++)

                {
                 SetBkColor (hdc, 0) ;
                 SetTextColor(hdc,color[(((iLine-*(p+x)-y)>107)?11:(iLine-*(p+x)-y))%12]);
                 TextOut(hdc, x*cxChar, y*cyChar, szBuffer,wsprintf(szBuffer, TEXT("%i"),(rand()+value)%10));
                }

                break;

        }
             return 0;

        case WM_DESTROY:
            delete []p;
            ReleaseDC(hwnd,hdc);
            KillTimer(hwnd,1);
            KillTimer(hwnd,2);
            PostQuitMessage(0);
            return 0;
    }
return DefWindowProc(hwnd,message,wparam,lparam);
}
 

回复列表 (共2个回复)

沙发

我无法编译啊!

板凳

如此大量的循环体计算放置在主线程.吓人.

我来回复

您尚未登录,请登录后再回复。点此登录或注册