티스토리 뷰

WINAPI

winapi 기본 구조

쭈니's 2010. 1. 26. 18:04
#include 

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE g_hInst;
LPSTR lpszClass="TextOut";

int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance
		  ,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)WndProc;
	WndClass.lpszClassName=lpszClass;
	WndClass.lpszMenuName=NULL;
	WndClass.style=CS_HREDRAW | CS_VREDRAW;
	RegisterClass(&WndClass);

	hWnd=CreateWindow(lpszClass,"My First Program",WS_OVERLAPPEDWINDOW,
		  CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
		  NULL,(HMENU)NULL,hInstance,NULL);
	ShowWindow(hWnd,nCmdShow);
	
	while(GetMessage(&Message,0,0,0)) {
		TranslateMessage(&Message);
		DispatchMessage(&Message);
	}
	return Message.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
	HDC hdc;
	switch(iMessage) {
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	case WM_LBUTTONDOWN:
		hdc=GetDC(hWnd);
		TextOut(hdc,100,100,"Beautiful Korea",15);
		ReleaseDC(hWnd, hdc);
		return 0;
	}
	return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
원도우 api 기본적인 구조이다.. 문자열을 출력하는^^..

'WINAPI' 카테고리의 다른 글

현재 디렉토리 알아오는 함수  (0) 2010.01.29
INI 파일 제어  (0) 2010.01.27
파일 검색 소스  (1) 2010.01.26
폴더 선택창 뛰우기  (0) 2010.01.26
vs 2008 xp스타일 설정!!  (0) 2010.01.26
winapi 기본 구조  (1) 2010.01.26
댓글
댓글쓰기 폼