본문 바로가기
코스웨어/13년 스마트컨트롤러

API 숙제 -1002 임기준

by 알 수 없는 사용자 2013. 10. 2.
728x90
반응형

소스


#include <windows.h>


LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

HINSTANCE g_hInst;

LPCTSTR lpszClass = TEXT("KIJOON");


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;

WndClass.lpszClassName = lpszClass;

WndClass.lpszMenuName = NULL;

WndClass.style = CS_HREDRAW | CS_VREDRAW;

RegisterClass(&WndClass);


hWnd = CreateWindow(lpszClass,lpszClass,WS_OVERLAPPEDWINDOW,

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 lParam)

{

HDC hdc;

  PAINTSTRUCT ps;

static TCHAR         str[256];

int len;

CONST RECT lpRect = {100, 100, 1300, 120};

switch (iMessage)

{

case WM_DESTROY:

PostQuitMessage(0);

return 0;

case WM_CHAR :

len = lstrlen(str);

str[len] = (TCHAR)wParam;

str[len + 1] = 0;

InvalidateRect(hWnd, &lpRect, TRUE);

return 0;


case WM_PAINT :

hdc = BeginPaint(hWnd, &ps);

TextOut(hdc, 100, 100, str, lstrlen(str));

if(255 == lstrlen(str))

{

str[0] = 0;

}

EndPaint(hWnd, &ps);

return 0;

}

return (DefWindowProc(hWnd, iMessage, wParam, lParam));

}


실행결과







728x90