티스토리 뷰

프로그래밍/API

캐럿 Caret

에어버스 2016. 4. 24. 12:29

BOOL CreateCaret(HWND hWnd, HBITMAP hBitmap, int nWidth, int nHieght)
BOOL ShowCaret(HWND hWnd)
BOOL HideCaret(HWND hWnd)
BOOL SetCaretPos(intX, int Y)
BOOL DestroyCaret(VOID)

BOOL GetTextExtentPoint(HDC hdc,
LPCTSTR 입력중인 문자열 포인터,
int 문자열수,
LPSIZE 얻어올문자열정보)

static int pos = 0;
SIZE size;
static char strChar[MAX_PATH];

case WM_SETFOCUS:
  CreateCaret(hWnd, NULL, 2, 14);
  ShowCaret(hWnd);
  SetCaretPos(100, 100);
  break;
case WM_KILLFOCUS:
  HideCaret(hWnd);
  DestroyCaret();
  break;
case WM_CHAR:
  int nlen = strlen(strChar);
  strChar[nLen] = (char)wparam;
  strChar[nLen+1] = 0;
  pos++;
  HDC hdc = GetDC(hWnd);
  GetTextExtentPoint(hdc, strChar, pos, &size); // 문자열 넓이와 높이얻어 szie에 저장
  ReleaseDC(hWnd, hdc);
  SetCaretPos(szie.cx + 100, 100); // 캐럿 위치를 문자열 끝으로 이동
  InvalidateRect(hWnd, NULL, FALSE);
  break;
case WM_PAINT:
  HDC hdc = BeginPaint(hWnd, &ps);
  TextOut(hdc, 100, 100, strChar, strlen(strChar));
  EndPaint(hWnd, &ps);
  break;

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31