TODAY : / TOTAL :

120705_API :: ScrollBar 를 이용한 폰트크기 조절

  • Share this:
반응형

 #define ID_FNTSZSCR 100

HWND hFontSize;
int iFontSize;
int iScrSelSize;


LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
 HDC hdc;
 PAINTSTRUCT ps;
 HFONT hFont, OldFont;
 TCHAR *str=TEXT("폰트 Test 1234");
 
 
 switch (iMessage)
 {
  case WM_CREATE :
   hFontSize = CreateWindow(TEXT("scrollbar"),
    NULL,
    WS_CHILD | WS_VISIBLE | SBS_HORZ,
    10,
    10,
    400,
    20,
    hWnd,
    (HMENU)ID_FNTSZSCR,
    g_hInst,
    NULL);

   SetScrollRange(hFontSize,SB_CTL,10,50,TRUE);
   SetScrollPos(hFontSize,SB_CTL,10,TRUE);

   return 0;

  case WM_HSCROLL :
   switch(LOWORD(wParam))
   {
   case SB_LINELEFT :
    iFontSize = max(0,iFontSize-1);
    break;

   case SB_LINERIGHT :
    iFontSize = min(255,iFontSize+1);
    break;

   case SB_PAGELEFT :
    iFontSize = max(0,iFontSize-10);
    break;

   case SB_PAGERIGHT :
    iFontSize = min(255,iFontSize+10);
    break;

   case SB_THUMBTRACK :
    iFontSize = HIWORD(wParam);
    break;
   }

   SetScrollPos((HWND)lParam,SB_CTL,iFontSize,TRUE);
   InvalidateRect(hWnd,NULL,FALSE);


  case WM_PAINT:
   hdc=BeginPaint(hWnd, &ps);
   hFont=CreateFont(iFontSize,0,0,0,0,0,0,0,HANGEUL_CHARSET,0,0,0,
    VARIABLE_PITCH | FF_ROMAN,TEXT("궁서"));
   OldFont=(HFONT)SelectObject(hdc,hFont);
   TextOut(hdc, 100,100,str,lstrlen(str));
   SelectObject(hdc,OldFont);
   DeleteObject(hFont);
   EndPaint(hWnd, &ps);
   return 0;
  case WM_DESTROY:
   PostQuitMessage(0);
   return 0;
 }
 return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}



- p.s -
확인 버튼 누른 뒤
GetWindowText(폰트콤보핸들, 폰트저장배열 , 배열크기);   를 이용하여 폰트정보 전송 ㅇ

반응형

SEARCH

태그로 찾아보기