#include <windows.h>
HINSTANCE g_hInst;
LPCTSTR lpszClass = "window program";
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI 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, lpszClass, WS_OVERLAPPEDWINDOW, 0, 0,
800, 600, NULL, (HMENU)NULL, hInstance, NULL);
// 윈도우 출력
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
// 이벤트 루프 처리
while (GetMessage(&Message, 0, 0, 0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc=GetDC(hWnd);
PAINTSTRUCT ps;
static SIZE size;
static int xPos = 0;
static int yPos = 0;
static char str[10][10];
static char temstr[10][10];
static int count = 0;
static int line = 0;
int i,j,temp;
switch (iMsg)
{
case WM_CREATE:
CreateCaret(hWnd, NULL, 5, 15);
ShowCaret(hWnd);
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
for (i = 0; i < line + 1; i++) {
GetTextExtentPoint(hdc, str[i], strlen(str[i]), &size);
TextOut(hdc, xPos, 20 * i, str[i], strlen(str[i]));
SetCaretPos(size.cx + xPos, 20 * i);
}
EndPaint(hWnd, &ps);
break;
case WM_CHAR:
if (wParam >= '0' && wParam <= '9') {
if (count != 0)
{
line += 1;
count = 0;
}
str[line][count++] = wParam; // 문자 붉게?
count = 0;
line += 1;
}
else if (wParam == 'R' || wParam == 'r')
{
for (i = line - 1; i >= 0; i--)
{
for (j = count - 1; j >= 0; i--)
str[line][count]=str[i][j];
}
}
else if (wParam == 'Q' || wParam == 'q') {
exit(0);
}
else
{
if (count > 8)
{
line += 1;
count = 0;
}
str[line][count++] = wParam;
}
InvalidateRect(hWnd, NULL, TRUE);
break;
case WM_DESTROY:
HideCaret(hWnd);
DestroyCaret();
PostQuitMessage(0);
break;
}
return (DefWindowProc(hWnd, iMsg, wParam, lParam));
}
붉은 부분 왜 컴파일 에러 나나요?? 의도한 부분은 1 abcd
abcd -> 1 입니다
ㄴ 학식충 구제좀 해줘요.. 어제부터 머리 굴리는데 제 빡대가리에서는 처리를 못하네요