LuvSea

API 기본 출력 소스 본문

sTudy

API 기본 출력 소스

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

#include<windows.h>

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass=TEXT("first");

int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevlnstance, LPSTR lpszCmdParam, int nCmdShow)
{
 HWND hWnd;
 MSG Message;
 WNDCLASS WndClass;
 g_hInst=hInstance;
 
 //윈도우 생성값 등록
 WndClass.cbClsExtra=0;
 WndClass.cbWndExtra=0;
 WndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
 WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
 WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
 WndClass.hInstance=hInstance;
 WndClass.lpfnWndProc=WndProc;
 WndClass.lpszClassName=lpszClass;
 WndClass.lpszMenuName=NULL;
 WndClass.style=CS_HREDRAW|CS_VREDRAW;
 RegisterClass(&WndClass); //주소에 write
 
 //윈도우 생성
 hWnd=CreateWindow(TEXT("first"),TEXT("abc"),WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL |WS_BORDER
  ,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,
  (HMENU)NULL,hInstance,NULL);
 
 //화면에 출력
 ShowWindow(hWnd,nCmdShow);
 
 //메세지 처리 (무한 반복)
 while(GetMessage(&Message,NULL,0,0))
 {
  TranslateMessage(&Message);
  DispatchMessage(&Message);
 }
 return (int)Message.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM WParam,LPARAM IParam)
{
 HDC  hdc;
 PAINTSTRUCT ps;
 switch(iMessage)
 {
 case WM_DESTROY:
  PostQuitMessage(0);
  return 0;
 case WM_RBUTTONDOWN:  //우클릭 시
  hdc = GetDC(hWnd);
  TextOut(hdc,200,200,"beautiful Korea",15);
  ReleaseDC(hWnd,hdc);
  return 0;
 case WM_LBUTTONDOWN:  //좌클릭 시
  hdc = GetDC(hWnd);
  TextOut(hdc,100,200,"beautiful Korea",15);
  ReleaseDC(hWnd,hdc);
  MessageBeep(2);

  return 0;
 case WM_PAINT:
  hdc = BeginPaint(hWnd,&ps);
  SetTextAlign(hdc,TA_UPDATECP);
  TextOut(hdc,100,100,TEXT("geegeegeegeegee"),15);
  TextOut(hdc,100,120,TEXT("geegeegeegee"),12);
  TextOut(hdc,100,140,TEXT("geegeegeegeegeegee"),18);

  EndPaint(hWnd,&ps);
  return 0;
 }
 return(DefWindowProc(hWnd,iMessage,WParam,IParam));
}

Comments