여기서 / 누르면 전체 문자열이 10개씩 개행되개 만들려는대
e x) 1234567890123456789012345678901234567890 -> 1234567890
1234567890
1234567890
1234567890
이렇게 만들려는대 신의 한수좀 알려주세여 형들
#include<windows.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, 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.hIc 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, // 윈도우의 생성위치 좌표 x값
CW_USEDEFAULT, // 윈도우의 생성위치 좌표 y값
970, // 윈도우의 폭 x 픽셀
655, // 윈도우의 높이 y 픽셀
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 char str[10][100]; //문자열 저장 배열[행][열]
static int xPos, yPos, line,tempPos,S_x,S_y; //문자열 인덱스 변수(xPos), 문자행 인덱스 변수(yPos), 문자행 위치 변수(line)
static SIZE size; //문자열의 폭과 높이 저장 변수
static char temp[10][100];
static char comp[10][100];
static char homp[10][100];
static char somp[10][100];
static bool nim=FALSE;
static int k_x,k_y;
int i,j;
switch ( iMsg )
{
case WM_CREATE:
CreateCaret(hwnd, NULL, 5, 15); //폭 5픽셀, 높이 15픽셀
ShowCaret(hwnd);
xPos = 0;
yPos = 0;
k_x=rand()@0;
k_y=rand()00;
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
for(line = 0; line <= yPos; line++)
TextOut(hdc,k_x , k_y+line*20, str[line], strlen(str[line])); //1차원 배열 단위 출력
GetTextExtentPoint(hdc, str[yPos], strlen(str[yPos]), &size);
SetCaretPos(size.cx+k_x, k_y+yPos*20); //커서 위치
EndPaint(hwnd, &ps);
break;
case WM_CHAR:
if(wParam=='/')
{
for(i=0; i<100; i++)
{
if(i>9)
{
str[yPos][i]=str[yPos+1][i];
}
}
}
else if(wParam==VK_BACK)
{
strcpy(comp[yPos],str[yPos]);
for(i=0; i<100; i++)
str[yPos][i]=comp[yPos][i+1];
xPos--;
if(xPos<0)
xPos=0;
}
else if(wParam==VK_RETURN)
{
if(yPos<9)
{
xPos=0;
yPos++;
}
}
else
str[yPos][xPos++]=wParam;
str[yPos][xPos]='\0'; //마지막 문자 값을 NULL 저장
InvalidateRgn(hwnd, NULL, TRUE); //WM_PAINT 호출
break;
case WM_KEYDOWN:
if(wParam==VK_F1)
{
for(i=0; i<10; i++)
{
strcpy(homp[i],str[i]);
}
for(i=1; i<=strlen(str[yPos]); i++)
{
str[yPos][4+7*(i-1)]='0';
str[yPos][5+7*(i-1)]='0';
str[yPos][6+7*(i-1)]='0';
str[yPos][7+7*(i-1)]=homp[yPos][4*i];
str[yPos][8+7*(i-1)]=homp[yPos][5+(4*(i-1))];
str[yPos][9+7*(i-1)]=homp[yPos][6+(4*(i-1))];
str[yPos][10+7*(i-1)]=homp[yPos][7+(4*(i-1))];
}
}
str[yPos][xPos]='\0'; //마지막 문자 값을 NULL 저장
InvalidateRgn(hwnd, NULL, TRUE); //WM_PAINT 호출
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default :
return DefWindowProc( hwnd, iMsg, wParam, lParam);
}
return 0;
}
저는아닙니다그형