Click here to Skip to main content
16,004,924 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: EnumWindows Pin
Archer2825-Jun-04 11:44
Archer2825-Jun-04 11:44 
GeneralRe: EnumWindows Pin
User 66585-Jun-04 14:05
User 66585-Jun-04 14:05 
GeneralRe: EnumWindows Pin
David Crow7-Jun-04 2:56
David Crow7-Jun-04 2:56 
GeneralIntegrating the MS VC Toolkit 2003 into VC6.0 Pin
steven115-Jun-04 9:49
steven115-Jun-04 9:49 
GeneralRe: Integrating the MS VC Toolkit 2003 into VC6.0 Pin
bneacetp5-Jun-04 14:39
bneacetp5-Jun-04 14:39 
GeneralPainting in dialogs: WM_PAINT Pin
kfaday5-Jun-04 9:43
kfaday5-Jun-04 9:43 
GeneralRe: Painting in dialogs: WM_PAINT Pin
bneacetp5-Jun-04 13:05
bneacetp5-Jun-04 13:05 
GeneralRe: Painting in dialogs: WM_PAINT Pin
kfaday5-Jun-04 13:18
kfaday5-Jun-04 13:18 
i'm trying to store points, and then redraw in the OnDraw function, but i'm not successful.

I've declared in the header file
typedef std::list<CPoint> CListaPuntos; 
inside the class there's:
CListaPuntos ListaPuntos; 


In the constructor of the class, i've written:
m_PosMouse.x=-1;
m_PosMouse.y=-1;
this->ListaPuntos.push_back(m_PosMouse);

In the list, i store a Cpoint variable with (-1,-1)

Then, this is the function which draws and stores points in the list
void CVentanaPizarra::OnMouseMove(UINT nFlags, CPoint point) 
{
	if (m_DibLapiz)
	{
		CRect rect;
		GetClientRect(rect);

		if ((nFlags == MK_LBUTTON) && ((m_PosMouse.x>rect.left+90) || (m_PosMouse.x==-1)))
		{
			CClientDC dc(this);
			CPen Lapiz; 

			Lapiz.CreatePen (PS_SOLID,1,RGB(0,0,0));   
			dc.SelectObject(Lapiz);               
			
			if (point.x>rect.left+90)
			{
				CPoint punto;
				if ((m_PosMouse.x!=-1)&&(m_PosMouse.y!=-1))
				{
					this->ListaPuntos.push_back(point);
					dc.MoveTo(point.x, point.y);
					dc.LineTo(m_PosMouse.x,m_PosMouse.y);
				}
				dc.MoveTo(point.x, point.y);
				this->ListaPuntos.push_back(point);
				punto.x=point.x+(int).5;
				punto.y=point.y+(int).5;
				dc.LineTo(punto.x, punto.y);
				this->ListaPuntos.push_back(punto);
			}
			m_PosMouse=dc.GetCurrentPosition();	
		}
	}
	CDialog::OnMouseMove(nFlags, point);
}


this function compliments the abovementioned one:
void CVentanaPizarra::OnLButtonUp(UINT nFlags, CPoint point) 
{
	m_PosMouse.x=-1;
	m_PosMouse.y=-1;
	this->ListaPuntos.push_back(m_PosMouse);
	CDialog::OnLButtonUp(nFlags, point);
}


and this is the onpaint function:

void CVentanaPizarra::OnPaint() 
{
	CPaintDC dlgDC(this); // device context for painting
	PintarBlanco(dlgDC);
	
	if (ListaPuntos.size()>1)
	{
		CPoint punto1, punto2;
		for (CListaPuntos::iterator i = ListaPuntos.begin(); i != ListaPuntos.end(); i++)
		{
			punto1= *i;
			if (i==ListaPuntos.end())
				break;
			if (punto1.x!=-1)
			{
				dlgDC.LineTo(punto1.x,punto1.x);
				dlgDC.MoveTo(punto1.x,punto1.y);
			}
			i++;
			if (i==ListaPuntos.end())
				break;
			punto2= *i;
			if (punto1.x!=-1)
				dlgDC.LineTo(punto2.x,punto2.x);
			dlgDC.MoveTo(punto2.x,punto2.y);
		}
	}
} 


something is drawn, but not what i want, or what i've drawn with the mouse.
any ideas?
thanks!
GeneralRe: Painting in dialogs: WM_PAINT Pin
Johan Rosengren5-Jun-04 22:15
Johan Rosengren5-Jun-04 22:15 
GeneralRe: Painting in dialogs: WM_PAINT Pin
kfaday6-Jun-04 14:48
kfaday6-Jun-04 14:48 
GeneralSOAP With Attachments over MQ/MSMQ Pin
krisko5-Jun-04 9:11
krisko5-Jun-04 9:11 
GeneralRe: SOAP With Attachments over MQ/MSMQ Pin
Navin5-Jun-04 9:33
Navin5-Jun-04 9:33 
GeneralRe: SOAP With Attachments over MQ/MSMQ Pin
krisko5-Jun-04 12:02
krisko5-Jun-04 12:02 
GeneralRe: SOAP With Attachments over MQ/MSMQ Pin
palbano5-Jun-04 16:30
palbano5-Jun-04 16:30 
GeneralIcons Pin
Archer2825-Jun-04 9:09
Archer2825-Jun-04 9:09 
GeneralRe: Icons Pin
wb5-Jun-04 21:06
wb5-Jun-04 21:06 
Questionhow to build codec in visual c++/MFC Pin
Member 11334805-Jun-04 8:52
Member 11334805-Jun-04 8:52 
AnswerRe: how to build codec in visual c++/MFC Pin
Andrew Walker5-Jun-04 14:07
Andrew Walker5-Jun-04 14:07 
GeneralMDI vs SDI vs Dialog based applications Pin
Anonymous5-Jun-04 7:19
Anonymous5-Jun-04 7:19 
GeneralRe: MDI vs SDI vs Dialog based applications Pin
bneacetp5-Jun-04 13:16
bneacetp5-Jun-04 13:16 
GeneralRe: MDI vs SDI vs Dialog based applications Pin
ThePilgrim5-Jun-04 19:09
ThePilgrim5-Jun-04 19:09 
GeneralDialog Always On Top Pin
Grahamfff5-Jun-04 6:43
Grahamfff5-Jun-04 6:43 
GeneralRe: Dialog Always On Top Pin
Deian5-Jun-04 7:13
Deian5-Jun-04 7:13 
QuestionHow to get Data from a Dialog Pin
Larry A Mills5-Jun-04 4:44
Larry A Mills5-Jun-04 4:44 
AnswerRe: How to get Data from a Dialog Pin
Alton Williams6-Jun-04 6:36
Alton Williams6-Jun-04 6:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.