LuvSea

타이머를 이용한 애니메이션 본문

sTudy

타이머를 이용한 애니메이션

사랑海 2009. 7. 6. 12:26
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

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


....<중략>....



LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM WParam,LPARAM lParam)
{
 HDC hdc;
 PAINTSTRUCT ps;
 SYSTEMTIME st;
 static TCHAR sTime[128];
 static TCHAR sTime1[128];
 static TCHAR sTime2[128];
 static TCHAR sTime3[128];
 static TCHAR sTime4[128];
 static TCHAR sTime5[128];
 static TCHAR sTime6[128];
 srand((int)time(NULL));
 static int a = 115;
 static int b = 420;
 static int c = 0;

 switch(iMessage)
 {

 case WM_CREATE:
  SetTimer(hWnd,1,70,NULL);
  SetTimer(hWnd,2,70,NULL);
  SendMessage(hWnd,WM_TIMER,1,0);   //WParam 에 70ms 당 한번씩 1을 입력시켜준다.
  SendMessage(hWnd,WM_TIMER,2,0);
  return 0;
  
 case WM_TIMER:  
  switch(WParam){
  case 1:
  GetLocalTime(&st);
  wsprintf(sTime, " o ");  //sTime 배열에 해당 문자열을 입력시키는 기능
  wsprintf(sTime1," *< ");
  wsprintf(sTime2," || ");
  wsprintf(sTime3," =)) ");
  break;
  
  case 2:
  GetLocalTime(&st);
  wsprintf(sTime4," /o/ ");
  wsprintf(sTime5,"  * ");
  wsprintf(sTime6,"/ /  ");
  break;
  }
  if(a<=420)
  a+=8; 
  else
  c=1;
  
  if(c==1)
   b+=8;
  
  
  InvalidateRect(hWnd,NULL,TRUE);
  return 0;
  
 case WM_PAINT:
  hdc=BeginPaint(hWnd,&ps);
  TextOut(hdc,100,100,sTime,lstrlen(sTime));
  TextOut(hdc,100,115,sTime1,lstrlen(sTime1));
  TextOut(hdc,100,130,sTime2,lstrlen(sTime2));
  TextOut(hdc,a,115,sTime3,lstrlen(sTime3));
  TextOut(hdc,b,100,sTime4,lstrlen(sTime4));
  TextOut(hdc,b,115,sTime5,lstrlen(sTime5));
  TextOut(hdc,b,135,sTime6,lstrlen(sTime6));

  
  
  EndPaint(hWnd,&ps);
  return 0;
 
 case WM_DESTROY:
  KillTimer(hWnd,1);
  PostQuitMessage(0);
  return 0;


'sTudy' 카테고리의 다른 글

Gdiobject  (0) 2009.07.06
작업영역  (0) 2009.07.06
타이머를 이용한 시계  (0) 2009.07.06
키 입력과 무효 영역  (0) 2009.07.06
Message Box  (0) 2009.07.06
Comments