奶妈50圣物上衣怎么做:vc++文字移动变颜色

来源:百度文库 编辑:偶看新闻 时间:2024/04/28 17:55:20

#include
int static i=0;
int X=0,Y=200;
int x0;
SIZE size;
HINSTANCE hinst;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
HACCEL haccel;

char lClassName[]="窗口";
char lTitle[]="我的窗口";


wndclass.style=0;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lClassName;


    if(!RegisterClass(&wndclass))
{MessageBeep(0);
   return FALSE;
}


hwnd=CreateWindow(lClassName,
                lTitle,
       WS_OVERLAPPEDWINDOW,
       CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        NULL,
        NULL,
        hInstance,
        NULL);

ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
   
hinst=hInstance;

while(GetMessage(&Msg,NULL,0,0))
{
    TranslateMessage(&Msg);
       DispatchMessage(&Msg);

}

return Msg.wParam;
}


LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ HDC hdc;
    HFONT hf;
TEXTMETRIC tm;
PAINTSTRUCT ps;
    char str[]="燕草如碧丝";
char zt[][10]={"宋体","楷体","仿宋","黑体"};
switch (message)
{
     case WM_CREATE:
       SetTimer(hwnd,1,400,NULL);
    break;
    case WM_PAINT:
   hdc=BeginPaint(hwnd,&ps);
   hf=CreateFont(20*(i+1),0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,OUT_DEFAULT_PRECIS,
    CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,zt[i]);
   switch(i)
   {
   case 0:
SetTextColor(hdc,RGB(255,0,0));
break;
   case 1:
SetTextColor(hdc,RGB(0,255,0));
break;
   
   case 2:
   SetTextColor(hdc,RGB(255,255,0));
   break;

   case 3:
    SetTextColor(hdc,RGB(0,0,255));
    break;
   }

    SelectObject(hdc,hf);
GetTextMetrics(hdc,&tm);
TextOut(hdc,X%800,Y,str,strlen(str));
GetTextExtentPoint32(hdc,str,strlen(str),&size);
    x0=X+size.cx ;

DeleteObject(hf);
EndPaint(hwnd,&ps);
break;
case WM_TIMER:
X=X+15;

if(x0>700)
{
   X=0;
     i=(i+1)%4;
}
InvalidateRect(hwnd,NULL,1);
        break;
case WM_DESTROY:
      PostQuitMessage(0);
     default:
   return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}