학교 첫주인데 과제가 나왔는데..
아무리 생각해봐도 답이 해결이 안되네요..
대략 과제 내용은
한라인에는 10글자 즉 영어 10자 한글 5자로 하고
5라인까지 입력 가능하게 하고, 10글자가 넘으면 자동 개행이 되고, 5라인이 넘게되면 메시지 박스를 통해서 끝낼건지 계속 할건지
묻는 메시지 박스가 나오면서 예를 누르면 다시 그창으로 아니오를 누르면 꺼지는 걸 만들라는데..
아무리 생각해봐도 안되네요.. ㅠㅠ
api 첫주 수업인데..
코드는
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg,
WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS WndClass;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
WndClass.lpfnWndProc = WndProc;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hInstance = hInstance;
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.lpszMenuName = NULL;
WndClass.lpszClassName = "Window Class Name";
RegisterClass(&WndClass);
hwnd = CreateWindow("Window Class Name",
"Window Title Name",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
static char str[100];
static int count, yPos;
switch (iMsg)
{
case WM_CREATE:
count = 0;
yPos = 0;
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc, 0, yPos, str, strlen(str));
EndPaint(hwnd, &ps);
break;
case WM_CHAR:
if (wParam == VK_BACK) count--;
else if (wParam == VK_RETURN)
{
count = 0;
yPos = yPos + 20;
}
else str[count++] = wParam;
str[count] = '';
InvalidateRgn(hwnd, NULL, TRUE);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return(DefWindowProc(hwnd, iMsg, wParam, lParam));
}
여기서 수정 하면 된다고 하는데..
어떻게 해야 될지 막막하네요.. ㅠㅠ
어제 밤새도록 했는데도, 여러군데 뒤져봐도 api자료 찾기가 힘드네요..
배열 선언해주고, 어떻게 하면 될것 같기도 한데..
코드 수정 해봤지만.. 어떻게 해도 안되네요..
도와주세요..!!