GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 20-Apr-2005, 03:13
puzz puzz is offline
New Member
 
Join Date: Apr 2005
Posts: 2
puzz is on a distinguished road

Problem with draw lines using MFC


Hi..

I have a problem with line that I draw using mouse click (LButtonDown). I use VC++ and MFC.
The problem is whenever I maximize or minimize the window the lines that I draw dissapear.
Below is my code for LButtonDown :

CPP / C++ / C Code:
struct LINE
{
int xp[2];
int yp[2];
};
LINE L[100];

int Lnum = 0;
int icoord = 0;
int isline =0;
int psize = 1;


if(bLineFlag)
{
CPen penRed(PS_SOLID,1,RGB(250,0,0));
CPen *pOldPen = NULL;
pOldPen = pDC->SelectObject(&penRed);
CRect rcClient;
GetClientRect(&rcClient);
CPoint xpoint,ypoint;

L[Lnum].xp[icoord] = point.x / psize;
L[Lnum].yp[icoord] = point.y / psize;
if(icoord ==0)
{
icoord++; 
isline = 0;
}
else
{
isline =1;
pDC->MoveTo(L[Lnum].xp[0],L[Lnum].yp[0]);
t.x = L[Lnum].xp[0];
t.y = L[Lnum].yp[0];

pDC->LineTo(L[Lnum].xp[1],L[Lnum].yp[1]);
p.x = L[Lnum].xp[1];
p.y = L[Lnum].yp[1];

icoord =0;
}
DrawCross(point,RGB(0,255,0),5,pDC->m_hDC);
}

Could anyone help me with the problem..TQ
Last edited by LuciWiz : 20-Apr-2005 at 04:26. Reason: Please insert your C++ code between [c++] & [/c++] tags
  #2  
Old 26-Apr-2005, 04:59
Janakiraman Janakiraman is offline
Junior Member
 
Join Date: Apr 2005
Location: Chennai - India
Posts: 47
Janakiraman is on a distinguished road

line drawn after minimised and maximized


Hi,

Here i have given three functions u copy and paste it to your corresponding place

1)
CPP / C++ / C Code:
///On button click
void CMyWindow::DrawLineOnClick()
{
	CClientDC dc(this);

             //a function called to draw a line
	DrawLine(dc);
//         Create this variable in public and initialize it to false in constructor
	bClicked=TRUE;
	Invalidate(TRUE);

}


2)
CPP / C++ / C Code:
//this function draws a line when button is clicked
void CMyWindow::DrawLine(CDC& dc)
{
	CRect rect;
	GetClientRect(&rect);
	dc.MoveTo(0,0);
	dc.LineTo(rect.Width(),rect.Height());
	
}

3)
CPP / C++ / C Code:
//this piece of code will satisfy your need... if u r working in SDI u write it in OnDraw() function else if u use Dlg based write in OnPaint()

void CMyWindow::OnPaint()
{
	CPaintDC dc(this);
	if(TRUE==bClicked)
	{
	DrawLine(dc);
	}
}

//sure it works...

Best Regards,
Janakiraman
Last edited by JdS : 27-Apr-2005 at 10:01. Reason: please insert your example C codes between [c] and [/c] bbcode tags
  #3  
Old 26-Apr-2005, 05:32
Janakiraman Janakiraman is offline
Junior Member
 
Join Date: Apr 2005
Location: Chennai - India
Posts: 47
Janakiraman is on a distinguished road

what is Software design..?


Hi,

Can anyone tell me what r the process(atleast technical names) involved in Software design...

Best Regards,
janakiraman
  #4  
Old 26-Apr-2005, 20:15
puzz puzz is offline
New Member
 
Join Date: Apr 2005
Posts: 2
puzz is on a distinguished road
Hi..
thanks for the solution..i will try it immedietly..
about your problem..are you looking for SDLC(software dev. life cycle)?

puzz
 
 

Recent GIDBlogWelcome to Baghdad by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem modifying an array of char in a function ronin C Programming Language 10 28-Mar-2005 18:15
calling abstract base class method calls draw instead achoo FLTK Forum 1 19-Dec-2004 09:38
Major problem with recursive function, help.. kakamuti C Programming Language 4 19-Dec-2004 07:47
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 07:53
read specified range of lines from file etron C Programming Language 8 18-Feb-2004 08:04

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:36.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.