Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PartBox.cpp « Ext2Mgr - github.com/matt-wu/Ext3Fsd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6a6dc7f5689ff40801bf9a1f79e4e96aea09865c (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// PartBox.cpp : implementation file
//

#include "stdafx.h"
#include "PartBox.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPartBox

CPartBox::CPartBox()
{
    m_nID = IDC_PROPERTY_SDEV;
    m_nLeft = 10;
    m_nSize = 80;
}

CPartBox::~CPartBox()
{
}

BEGIN_MESSAGE_MAP(CPartBox, CButton)
	//{{AFX_MSG_MAP(CPartBox)
	ON_WM_SETFOCUS()
	ON_CBN_SELCHANGE(IDC_PROPERTY_SDEV, OnSelectChanged)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPartBox message handlers

void CPartBox::OnSelectChanged()
{
    GetParent()->SendMessage(WM_GROUP_BOX_UPDATED, 'GB', 'PVLU');
}

void CPartBox::PreSubclassWindow() 
{
    //
	// Make sure that this control has the BS_ICON style set.
	// If not, it behaves very strangely:
	//  It erases itself if the user TABs to controls in the dialog,
	//  unless the user first clicks it.  Very strange!!
    //

	ModifyStyle(0, BS_ICON|WS_TABSTOP|WS_GROUP);

	CString	strTitle;
	GetWindowText(strTitle);

	int nWidth = AssemblingTitle();

	CRect	r;
	GetWindowRect(&r);
	ScreenToClient(r);

	r.OffsetRect(m_nLeft, 0);
	r.bottom = r.top + m_nSize;
	r.right = r.left + m_nSize + nWidth;

    m_ComboBox.Create(WS_CHILD | CBS_DROPDOWN | WS_VSCROLL |
                      CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST,
                      r, this, m_nID);
	m_ComboBox.SetFont(GetFont(), true);
	m_ComboBox.ShowWindow(SW_SHOW);

    SetListboxHeight(m_ComboBox.m_hWnd);
}

int CPartBox::AssemblingTitle()
{
    //
	// The group box title needs to be erased, but I need to keep
    // the border away from the check box text. I create a string
    // of spaces (' ') that is the same length as the title was
    // plus the size of the checkbox. plus a little more.
    //

	CString	strOldTitle, strNewTitle;
	GetWindowText(strOldTitle);

	CClientDC dc(this);
	CFont*	  pOldFont = dc.SelectObject(GetFont());

	CSize	czText	= dc.GetTextExtent(strOldTitle);
	int		nRet	= czText.cx;
	int		nTarget = czText.cx + m_nSize;
	
	while(czText.cx < nTarget)
	{
		strNewTitle.Insert(0, ' ');
		czText = dc.GetTextExtent(strNewTitle);
	}

	dc.SelectObject(pOldFont);

	SetWindowText(strNewTitle);
	return nRet;
}

void CPartBox::OnSetFocus(CWnd* pOldWnd) 
{
	CButton::OnSetFocus(pOldWnd);
	m_ComboBox.SetFocus();
}


void CPartBox::SetListboxHeight(HWND hWnd)
{   
    RECT   rc;   

    ::SendMessage(hWnd, LB_GETITEMRECT, 0, (LPARAM)&rc);   
    ::GetClientRect(hWnd, &rc);   
    int   cyClient= rc.bottom - rc.top;   

    ::GetWindowRect(hWnd, &rc);   
    int   cxListbox = rc.right - rc.left;   
    int   cyListbox = rc.bottom - rc.top;   

    cyListbox = 120;
    ::SetWindowPos(hWnd, NULL, 0, 0,     
                   cxListbox, cyListbox,
                   SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCOPYBITS|
                   SWP_NOOWNERZORDER|SWP_NOZORDER
        );
}