switch (iMsg) {
case WM_CREATE:
line = 0;
count = 0;
//Process caret
CreateCaret(hwnd, NULL, 5, 15);
ShowCaret(hwnd);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
for(i=0; i<line; i++)
TextOut(hdc, 0, i*20, str[i], lstrlen(str[i]));
//Show caret at the last line
GetTextExtentPoint(hdc, str[line],lstrlen(str[line]), &size);
TextOut(hdc, 0,line*20, str[line],lstrlen(str[line]));
SetCaretPos(size.cx, line*20);
EndPaint(hwnd, &ps);
break;
case WM_CHAR:
switch(wParam){
case VK_BACK:
if(count > 0)
count--;
else if(line > 0){
line--;
count = COL-1;
}
break;
case VK_RETURN:
if(line == LOW-1){
CallMsgBox(hwnd);
}else{
count = 0;
line++;
}
break;
/*
가상키는 WM_KEYDOWN에서 구현 해야함
*/
default: //문자가 입력됨
//문자의 갯수가 10개이면 한줄을 띄움
if(count == COL-1){
if(line == 4){
CallMsgBox(hwnd);
}else{
count = 0;
line++;
}
}else{
str[line][count] = (TCHAR)wParam;
count++;
}
break;
}
str[line][count] = '\0';
InvalidateRgn(hwnd, NULL, TRUE);
return 0;
case WM_KEYDOWN :
{
case VK_UP:
if(line > 0)
{
line++;
hdc = GetDC(hwnd);
GetTextExtentPoint(hdc,str[count],count,&size);
ReleaseDC(hwnd, hdc);
SetCaretPos(count,line);
break;
}
else
break;
case VK_DOWN:
if(line > 5)
{
line--;
hdc = GetDC(hwnd);
GetTextExtentPoint(hdc,str[count],count,&size);
ReleaseDC(hwnd, hdc);
SetCaretPos(count,line);
break;
}
break;
case VK_RIGHT:
if(count < 4 )
{
count ++;
hdc = GetDC(hwnd);
GetTextExtentPoint(hdc,str[count],count,&size);
ReleaseDC(hwnd, hdc);
SetCaretPos(count,line);
break;
}
/*else if(count =4)
{
hdc = GetDC(hwnd);
GetTextExtentPoint(hdc,str[count],count,&size);
ReleaseDC(hwnd, hdc);
SetCaretPos(count,line);
break;
}*/
case VK_LEFT:
if(count > 0)
{
count --;
hdc = GetDC(hwnd);
GetTextExtentPoint(hdc,str[count],count,&size);
ReleaseDC(hwnd, hdc);
SetCaretPos(count,line);
break;
}
/*else if(count = 0)
{
hdc = GetDC(hwnd);
GetTextExtentPoint(hdc,str[count],count,&size);
ReleaseDC(hwnd, hdc);
SetCaretPos(count,line);
break;
}*/
캐럿(커서)의 위치를 칸에 맞게 바꾸고 싶은데 잘 안되네요 ㅜㅜ 힌트나 도움 부탁드립니다.