⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 z.cpp

📁 在窗口中依次显示一行字,字体逐渐变大, 字体的色彩也发生相应的变化
💻 CPP
字号:
#include <windows.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include<stdio.h>




LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);		
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine, int nCmdShow)
{
     HWND       	hwnd ;		
     MSG        	msg ;		
     WNDCLASS		wndclass ;	
     wndclass.style  			= CS_HREDRAW | CS_VREDRAW ;	
     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 	= "Good";	
     if (!RegisterClass (&wndclass))				
     {
          MessageBox (NULL, "failure!", "Good", 0) ;
          return 0 ;
     }
    
     hwnd = CreateWindow ("Good",                
                          "xiezi ",				
                          WS_OVERLAPPEDWINDOW,    	
                          CW_USEDEFAULT,            	
                          0,             
                          CW_USEDEFAULT,             	
                          0,             
                          NULL,                       	
                          NULL,                       	
                          hInstance,                  	
                          NULL) ;                     		
     ShowWindow (hwnd, nCmdShow) ;					
     UpdateWindow (hwnd) ;	 
	 
	 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;
	 PAINTSTRUCT	ps;
     HFONT      hf1;
	 TEXTMETRIC   tm;
	 char lpsz[]={"模式也称逻辑模式是数据库中全体数据的逻辑结构和特征的描述!"};
	 
int i=0,j=0,k=strlen(lpsz),x=0,y=0;


 switch (message)  {
		 
		 case WM_PAINT:
			  	hdc = BeginPaint(hwnd, &ps);
				
		
				for(i=0;i<k;i+=2)
            // if(j<21)
			 {
				 	hf1=CreateFont((long)8+32/30*i,
					            0,
                                0,
								0,
								FW_NORMAL,
								0,
								0,
								0,
								ANSI_CHARSET,
								OUT_DEFAULT_PRECIS,
								CLIP_DEFAULT_PRECIS,
								DEFAULT_QUALITY,
								DEFAULT_PITCH|FF_DONTCARE,
								"大号字");
				 SetTextColor(hdc,RGB((long)255/20*i,(long)255/30*i,(long)255/15*i));
			     SelectObject(hdc,hf1);
				 GetTextMetrics(hdc,&tm);
		        
				TextOut(hdc,x,y,&lpsz[i],2);
			      x=x+tm.tmAveCharWidth*2;
				  y=y+tm.tmExternalLeading; 
				   
				 Sleep(150);
                 DeleteObject(hf1);}
				 
			 InvalidateRect(hwnd,NULL,1);
				
				EndPaint(hwnd,&ps);
				return 0;
          case WM_DESTROY:	
			   {	PostQuitMessage (0) ;
			 return 0 ;}
		 default:
			 {return DefWindowProc (hwnd, message, wParam, lParam) ; }
	 }
	}    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -