API인데.....계속 막히는 부분이 있습니다...도와주세요 ㅠㅠ

chwealthy의 이미지

아래 처럼 요렇게 짰는데...출력하면 네모박스안에서
글을 입력할 수가 있는데....네모박스안에서 한줄을 입력하면 다음 줄로 넘어가야되는데 이상하게...한줄로만 나오네요 ㅠ
어느 부분을 수정해야되나요?
아무리 해도 ㅠㅠ

#include
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) ;
HINSTANCE g_hInst;
char lpszClass[100]="API Program Ex06";

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
//ZeroMemory(&WndClass,sizeof(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);

RegisterClass(&WndClass);

hWnd=CreateWindow(lpszClass,lpszClass,WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL ,(HMENU)NULL, hInstance, NULL);
ShowWindow(hWnd,nCmdShow);

while(GetMessage(&Message,0,0,0)){
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return (int)Message.wParam;
}

#define LEFT 100
#define TOP 100
#define RIGHT 300
#define BOTTOM 200

LRESULT CALLBACK WndProc (HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
HDC hdc;
PAINTSTRUCT ps;

RECT rect;
static char str[10][50];
static int count,line,yPos;
static SIZE size;
int i;

switch (iMsg)
{
case WM_CREATE:
count=0;
line=0;
yPos=0;
CreateCaret(hWnd,NULL,5,15);
ShowCaret(hWnd);
return 0;

case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
yPos=0;
Rectangle(hdc, LEFT,TOP, RIGHT,BOTTOM);

for(i=0; i
TextOut(hdc,LEFT+0, TOP+i*yPos, str[i],strlen(str[i]));
GetTextExtentPoint(hdc,str[line], strlen(str[i]),&size);
TextOut(hdc,LEFT+0, TOP+i*yPos, str[i],strlen(str[i]));
SetCaretPos(LEFT+size.cx,TOP+line*yPos);
yPos+=20;
EndPaint(hWnd,&ps);
break;

case WM_CHAR:
if(wParam == (VK_BACK))
count--;

else if(wParam == VK_RETURN)
{
count = 0;
line = line + 1;
}
else
str[line][count++]=wParam;

hdc = GetDC(hWnd);
GetTextExtentPoint(hdc, str[line], count, &size);
ReleaseDC(hWnd, hdc);

if(size.cx > RIGHT - LEFT)
{
str[line +1][0] = str[line][count-1];
str[line][count-1]='\0';
line++;
count = 1;
}
str[line][count] = '\0';

if((line+1)*yPos > BOTTOM - TOP)
{
MessageBox(hWnd, "글상자가 가득 찼습니다.","글상자",MB_OK);
break;
}

InvalidateRgn(hWnd, NULL, TRUE);
return 0;

case WM_DESTROY:
HideCaret(hWnd);
DestroyCaret();
PostQuitMessage (0) ;
break;
}
return DefWindowProc (hWnd, iMsg, wParam, lParam);

}

File attachments: 
첨부파일 크기
Plain text icon Test.txt2.76 KB
bacon의 이미지

case WM_PAINT 아래에 yPos = 0해버리면 for룹안의 TextOut에서 TOP+i*yPos는 항상 TOP이 되어 항상 같은 높이에 찍히는듯 하고, 커서위치시키는 부분도 문제가 있어 보입니다.

chwealthy의 이미지

네...감사해요...도움이 되었네요 ^^;

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.