SetFont Sets the font to use when new lines are added to the history list Params hont - handle to a font Return 0 - (UH_SUCCESS) 1 - (UH_ERROR) ***********************************/
| 649 | 1 - (UH_ERROR) |
| 650 | ***********************************/ |
| 651 | int CUH_Control::SetFont(HFONT font){ |
| 652 | |
| 653 | SIZE size; |
| 654 | HFONT oldFont = NULL; |
| 655 | |
| 656 | if(m_font != NULL && font != NULL) |
| 657 | DeleteObject(m_font); |
| 658 | |
| 659 | m_font = font; |
| 660 | |
| 661 | //get the font height |
| 662 | if(m_hWnd != NULL){ |
| 663 | HDC dc = GetDC(m_hWnd); |
| 664 | if(m_font != NULL) |
| 665 | oldFont = (HFONT)SelectObject(dc,m_font); |
| 666 | GetTextExtentPoint(dc,_T("X"),1,&size); |
| 667 | if(m_font != NULL) |
| 668 | SelectObject(dc,oldFont); |
| 669 | ReleaseDC(m_hWnd,dc); |
| 670 | } |
| 671 | else{ |
| 672 | HDC dc = GetDC(NULL); |
| 673 | if(m_font != NULL) |
| 674 | oldFont = (HFONT)SelectObject(dc,m_font); |
| 675 | GetTextExtentPoint(dc,_T("X"),1,&size); |
| 676 | if(m_font != NULL) |
| 677 | SelectObject(dc,oldFont); |
| 678 | ReleaseDC(NULL,dc); |
| 679 | } |
| 680 | |
| 681 | //store the font height |
| 682 | m_fontHeight = size.cy; |
| 683 | m_fontWidth = size.cx; |
| 684 | |
| 685 | //get the number of screen lines |
| 686 | if(m_hWnd != NULL){ |
| 687 | RECT rect; |
| 688 | GetClientRect(m_hWnd,&rect); |
| 689 | m_vScrollPageSize = (rect.bottom / m_fontHeight); |
| 690 | m_hScrollPageSize = (rect.right / m_fontWidth); |
| 691 | SetHistoryLength(m_historyListMaxLen); |
| 692 | } |
| 693 | |
| 694 | return UH_SUCCESS; |
| 695 | } |
| 696 | |
| 697 | /********************************** |
| 698 | SetCurrentPosPtr |
nothing calls this directly
no outgoing calls
no test coverage detected