Click here to Skip to main content
15,886,584 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how can i functional m_my combo box?


What I have tried:

void CnewprojectmengaeView::OnInitialUpdate()
{
	CView::OnInitialUpdate();

	// TODO: Add your specialized code here and/or call the base class
m_myCombo.Create(WS_CHILD | WS_VISIBLE | CBS_SIMPLE | WS_VSCROLL,
		CRect(1200, 600, 1300, 750), this, 7);
	m_myCombo.InsertString(0, _T("View"));
	m_myCombo.InsertString(1, _T("Move"));
	m_myCombo.InsertString(2, _T("Stop"));
	m_myCombo.InsertString(3, _T("Exit"));
void CnewprojectmengaeView::Onm_myCombo()
{
	// TODO: Add your implementation code here.
	if (m_myCombo.GetCurSel() == 0)
	{
		CClientDC dc(this);
		CBrush brush_black(RGB(0, 0, 0)); //Brush black the new train
		dc.FillRect(CRect(130, 171, 170, 180),
			&brush_black); //Draw train
		SetTimer(1, 30, NULL);
	}
	if (m_myCombo.GetCurSel() == 1)
	{
		CClientDC dc(this);
		CBrush brush_black(RGB(0, 0, 0)); //Brush black the new train
		CBrush brush_white(RGB(255, 255, 255)); //Brush white the old train
		dc.FillRect(CRect(X1, 171, X1 - 20, 180), &brush_black); //Draw new train
		dc.FillRect(CRect(X1 - 40, 171, X1 - 20, 180), &brush_white); //Draw the old train
		X1++; // Run the train 
		SetTimer(1, 30, NULL);
	}
	if (m_myCombo.GetCurSel() == 2)
	{
		X1--;
	}
	if (m_myCombo.GetCurSel() == 3)
	{
		exit(0);
	}
	SetTimer(1, 30, NULL);
}
Posted
Updated 16-Jan-20 3:44am
v2
Comments
OriginalGriff 16-Jan-20 8:24am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. And we don't have any idea what your combobox is intended to do, much less what it does or doesn't do at the moment.

Use the "Improve question" widget to edit your question and provide better information.

1 solution

Quote:
if (m_myCombo.GetCurSel() == 1)
{
CClientDC dc(this);
CBrush brush_black(RGB(0, 0, 0)); //Brush black the new train
CBrush brush_white(RGB(255, 255, 255)); //Brush white the old train
dc.FillRect(CRect(X1, 171, X1 - 20, 180), &brush_black); //Draw new train
dc.FillRect(CRect(X1 - 40, 171, X1 - 20, 180), &brush_white); //Draw the old train
X1++; // Run the train
SetTimer(1, 30, NULL);
}


Painting should happen only in the OnDraw method of the CView, see Drawing in a View | Microsoft Docs[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900