forked from hiyohiyo/CrystalDiskInfo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFontComboBox.cpp
More file actions
76 lines (60 loc) · 1.86 KB
/
Copy pathFontComboBox.cpp
File metadata and controls
76 lines (60 loc) · 1.86 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*---------------------------------------------------------------------------*/
// Author : hiyohiyo
// Mail : hiyohiyo@crystalmark.info
// Web : https://crystalmark.info/
// License : The MIT License
/*---------------------------------------------------------------------------*/
#include "stdafx.h"
#include "DiskInfo.h"
#include "ComboBoxCx.h"
#include "FontComboBox.h"
// CFontComboBox
IMPLEMENT_DYNAMIC(CFontComboBox, CComboBox)
CFontComboBox::CFontComboBox()
{
m_FontHeight = (LONG)(-1 * 16 * 1.00);
}
CFontComboBox::~CFontComboBox()
{
}
BEGIN_MESSAGE_MAP(CFontComboBox, CComboBoxCx)
END_MESSAGE_MAP()
void CFontComboBox::SetFontHeight(int height, double zoomRatio)
{
m_FontHeight = (LONG)(-1 * height * zoomRatio);
}
void CFontComboBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
lpMeasureItemStruct->itemHeight = abs(m_FontHeight);
}
void CFontComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CString cstr;
if (lpDrawItemStruct->itemID == -1)
return;
GetLBText(lpDrawItemStruct->itemID, cstr);
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CFont font;
LOGFONT logfont;
memset(&logfont, 0, sizeof(logfont));
logfont.lfHeight = m_FontHeight;
logfont.lfWidth = 0;
logfont.lfWeight = 400;
logfont.lfCharSet = DEFAULT_CHARSET;
pDC->SelectObject(&font);
_tcscpy_s(logfont.lfFaceName, 32, (LPCTSTR)cstr);
font.CreateFontIndirect(&logfont);
pDC->SelectObject(&font);
pDC->DrawText(cstr, &lpDrawItemStruct->rcItem, DT_SINGLELINE | DT_VCENTER);
}
int CFontComboBox::CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct)
{
/*
LPCTSTR lpszText1 = (LPCTSTR) lpCompareItemStruct->itemData1;
ASSERT(lpszText1 != NULL);
LPCTSTR lpszText2 = (LPCTSTR) lpCompareItemStruct->itemData2;
ASSERT(lpszText2 != NULL);
return _tcscmp(lpszText2, lpszText1);
*/
return -1;
}