A Journey 2 Eternity

Removing the Button of a CComboBox

Posted on: December 18, 2008

int CMyComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	int nRet = rtn = CComboBox::OnCreate(lpCreateStruct);
	
	COMBOBOXINFO pcb;
	pcb.cbSize = sizeof(COMBOBOXINFO);
	if(GetComboBoxInfo(&pcb)) {
		CEdit* pEdit = (CEdit*)FromHandle(pcb.hwndItem);
		if(pEdit != NULL) {
			m_rcComboEdit = pcb.rcItem;
			m_rcComboEditUnionBtn.UnionRect(ceRect,&pcb.rcButton);
		}
	}

	return nRet;
}

void CMyComboBox::HideButton(BOOL bHide)
{
	COMBOBOXINFO pcb;
	pcb.cbSize = sizeof(COMBOBOXINFO);

	if(GetComboBoxInfo(&pcb)) {
		CEdit* pEdit = (CEdit*)FromHandle(pcb.hwndItem);
		if(pEdit != NULL) {
			if(bHide) {
				pEdit->MoveWindow(m_rcComboEdit.left, 	m_rcComboEdit.top, m_rcComboEditUnionBtn.Width(), m_rcComboEdit.Height());
			} else {
				pEdit->MoveWindow(m_rcComboEdit.left, m_rcComboEdit.top, m_rcComboEdit.Width(), m_rcComboEdit.Height());
			}
		}
	}

	RedrawWindow();
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Pages

Categories

December 2008
M T W T F S S
« Sep   Apr »
1234567
891011121314
15161718192021
22232425262728
293031  

Blog Stats

  • 26,968 hits
%d bloggers like this: