
2个回答
展开全部
用一个SetTimer()的函数定时给窗口发送WM_TIMER信息,然后改变文字位子,不停的输出刷新,改变位子,输出刷新就行了,下面是窗口处理函数:
LRESULT CALLBACK WinProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam )
{
//全局变量
HDC hdc;
PAINTSTRUCT sp;
static WORD xplace=0;
static char *water="蓝蓝的天";
static WORD wordlong=5*strlen(water);
//
switch(uMsg)
{
case WM_CREATE:
SetTimer(hwnd,1,200,NULL);
break;
case WM_TIMER:
InvalidateRect(hwnd,NULL,TRUE);
break;
case WM_PAINT:
//内容
hdc=BeginPaint(hwnd,&sp);
TextOut(hdc,xplace,0,water,strlen(water));
xplace+=5;
EndPaint(hwnd,&sp);
break;
case WM_CLOSE:
if (IDYES==MessageBox(hwnd,"确实要关闭吗?","sb",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
LRESULT CALLBACK WinProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam )
{
//全局变量
HDC hdc;
PAINTSTRUCT sp;
static WORD xplace=0;
static char *water="蓝蓝的天";
static WORD wordlong=5*strlen(water);
//
switch(uMsg)
{
case WM_CREATE:
SetTimer(hwnd,1,200,NULL);
break;
case WM_TIMER:
InvalidateRect(hwnd,NULL,TRUE);
break;
case WM_PAINT:
//内容
hdc=BeginPaint(hwnd,&sp);
TextOut(hdc,xplace,0,water,strlen(water));
xplace+=5;
EndPaint(hwnd,&sp);
break;
case WM_CLOSE:
if (IDYES==MessageBox(hwnd,"确实要关闭吗?","sb",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
展开全部
#include <stdio.h>
#include <string.h>
#include <windows.h>
void main()
{
char *word="蓝蓝的天";
int len=strlen(word);
int scr=79;
printf("\n");
int i=0;
while(1)
{
for(int j=0;j<scr;)
{
if(j==(scr-len-i))
{
printf(word);
j+=len;
}else
{
printf(" ");
j++;
}
}
printf("\r");
Sleep(100);
i++;
if(i==(scr-len))
i=0;
}
printf("\n");
}
#include <string.h>
#include <windows.h>
void main()
{
char *word="蓝蓝的天";
int len=strlen(word);
int scr=79;
printf("\n");
int i=0;
while(1)
{
for(int j=0;j<scr;)
{
if(j==(scr-len-i))
{
printf(word);
j+=len;
}else
{
printf(" ");
j++;
}
}
printf("\r");
Sleep(100);
i++;
if(i==(scr-len))
i=0;
}
printf("\n");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询