#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR 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 msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
static TCHAR str[5][11];
static int line;
static int count;
int i;
switch(iMsg)
{
case WM_CREATE:
line = 0;
count = 0;
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
for ( i = 0; i < 5; i++)
{
TextOut (hdc, 0, i*15, str[i], strlen(str[i]));
}
break;
EndPaint(hwnd, &ps);
case WM_CHAR:
if(wParam == VK_BACK ) {
if (count > 0) count--;
str[line][count] = '\0';
}
else if(wParam == VK_RETURN)
{
if ( count < 5-1 ){
count = 0;
line++;
}
}
else {
if ( count < 10 ) {
str[line][count] = wParam;
count++;
str[line][count] = 0 ;
if( count == 10)
{
count=0;
line++;
}
}
InvalidateRgn(hwnd, NULL, TRUE);
if(line==5&&count++)
{
if(MessageBox(hwnd,"라인이초과되었습니다.\n종료하시겠습니까?", "EXIT", MB_YESNO)==IDYES)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
else
{
}
}
}
InvalidateRgn(hwnd, NULL, TRUE);
}
return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
코드는 저렇게 만들었는데..
대략 내용은 10자 5라인을 받을 수 있는건데..
먼저 5라인 10자째 한글자를 더 입력을 하면 메시지 처리가 되게 만들었는데..
아무리 해도 엔터로만 5라인 다 채우구 한번더 엔터를 쳤을때는 종료 하시겠습니까 하는 메시지가 어떻게 해도 안나오네요..
어디를 수정 해야 될까요??
부탁드립니다.. ㅠㅠ