Click here to Skip to main content
15,914,481 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralQuestion about how to get the Control's ID in a message handler Pin
Matias13-Oct-02 7:37
Matias13-Oct-02 7:37 
GeneralRe: Question about how to get the Control's ID in a message handler Pin
Joaquín M López Muñoz13-Oct-02 8:32
Joaquín M López Muñoz13-Oct-02 8:32 
GeneralRe: Question about how to get the Control's ID in a message handler Pin
Matias13-Oct-02 11:06
Matias13-Oct-02 11:06 
GeneralGet the Class Name Pin
Gaurika Wijeratne13-Oct-02 7:21
Gaurika Wijeratne13-Oct-02 7:21 
GeneralRe: Get the Class Name Pin
pankajdaga13-Oct-02 10:12
pankajdaga13-Oct-02 10:12 
GeneralRe: Get the Class Name Pin
alex.barylski13-Oct-02 16:30
alex.barylski13-Oct-02 16:30 
GeneralRe: Get the Class Name Pin
alex.barylski13-Oct-02 16:57
alex.barylski13-Oct-02 16:57 
GeneralThreads problem ... Pin
BlackKettle13-Oct-02 5:16
BlackKettle13-Oct-02 5:16 
Hi,

I have a threads problem and here it is:
I am developing a program that will draw the graphic of a mathematical function but I want the draw to be done in other thread because for example if the multiplaier(the for is decreasing 'x' with 1/multiplaier) is too big, the program will draw the graphic slowly, and on every WM_PAINT message to my control the graphic has to be redrawn, and so if the user moves the window or whatever he doest to it, he will have to wait until the graphic is completly drawn, so I wanna make another thread to do this, but I have problem with the ThreadProc function:

I made a struct where all the parameters for the drawing are set:
<br />
typedef struct _DRAWERSUB {<br />
	HDC dc;<br />
	CRichEditCtrl *ctrlResults;<br />
	char * strFormula;<br />
	char * strX;<br />
	float nMultip;<br />
	int cx;<br />
	int cy;<br />
	double dPrecision;<br />
	BOOL bPrecision;<br />
	int nRootsFound;<br />
	double nDivs;<br />
	BOOL bCalc;<br />
} DRAWERSUB, *LPDRAWERSUB;<br />

this is the struct.
I initialize it in a function called by WM_PAINT as:
<br />
	DRAWERSUB dwsub;<br />
	dwsub.strFormula = (LPTSTR)(LPCTSTR)m_strFormula;<br />
	dwsub.strX = (LPTSTR)(LPCTSTR)m_strX;<br />
	dwsub.dc = dc->GetSafeHdc();<br />
	dwsub.nDivs = m_nDivisions;<br />
	dwsub.nMultip = m_nMultip;<br />
	dwsub.cx = cx;dwsub.cy = cy;<br />
	dwsub.bCalc = m_bCalc;<br />
	dwsub.bPrecision = m_bPrecission;<br />
	dwsub.dPrecision = precision;<br />
	m_trGraphicDrawer = AfxBeginThread(GraphicDrawerSub,&dwsub); 

and this is the code for the ThreadProc:
<br />
UINT CGraphicFunc::GraphicDrawerSub(LPVOID pParam)<br />
{<br />
	LPDRAWERSUB dwsub = (LPDRAWERSUB)pParam;<br />
	CString strFormula((LPCTSTR)(LPTSTR)dwsub->strFormula), strX((LPCTSTR)(LPTSTR)dwsub->strX);<br />
	HDC hDC = dwsub->dc;<br />
	double nDivs = dwsub->nDivs;<br />
	float nMultip = dwsub->nMultip;<br />
	int cx = dwsub->cx, cy = dwsub->cy;<br />
	double dPrecision = dwsub->dPrecision;<br />
	BOOL bPrecision = dwsub->bPrecision;<br />
	BOOL bCalc = dwsub->bCalc;<br />
.....<br />
}<br />

but every time the ThreadProc is called, strFormula, strX and every value from it, has different value, sometimes the hDC is valid and sometimes it isn't...strFormula sometimes is "" and strX is something like this:
"U‹ìQƒeü"
What can I do for rapairing this problem???
I am not good at threads and I almost no experience with them Frown | :( ...

Thanks.
GeneralRe: Threads problem ... Pin
Stephane Rodriguez.13-Oct-02 5:36
Stephane Rodriguez.13-Oct-02 5:36 
GeneralRe: Threads problem ... Pin
BlackKettle13-Oct-02 6:43
BlackKettle13-Oct-02 6:43 
GeneralRe: Threads problem ... Pin
Al Giv.13-Oct-02 7:08
sussAl Giv.13-Oct-02 7:08 
GeneralShare variable into DLL Pin
Raphael Kindt13-Oct-02 5:06
Raphael Kindt13-Oct-02 5:06 
GeneralRe: Share variable into DLL Pin
Stephane Rodriguez.13-Oct-02 5:40
Stephane Rodriguez.13-Oct-02 5:40 
GeneralRe: Share variable into DLL Pin
Joaquín M López Muñoz13-Oct-02 8:48
Joaquín M López Muñoz13-Oct-02 8:48 
GeneralDumb question... Copying derived class from base class pointer Pin
work_to_live13-Oct-02 3:44
work_to_live13-Oct-02 3:44 
GeneralRe: Dumb question... Copying derived class from base class pointer Pin
Nish Nishant13-Oct-02 4:18
sitebuilderNish Nishant13-Oct-02 4:18 
GeneralRe: Dumb question... Copying derived class from base class pointer Pin
Nish Nishant13-Oct-02 4:23
sitebuilderNish Nishant13-Oct-02 4:23 
GeneralRe: Dumb question... Copying derived class from base class pointer Pin
Joaquín M López Muñoz13-Oct-02 4:29
Joaquín M López Muñoz13-Oct-02 4:29 
GeneralMySQL Inserting data Pin
Anonymous13-Oct-02 3:20
Anonymous13-Oct-02 3:20 
GeneralRe: MySQL Inserting data Pin
Nish Nishant13-Oct-02 3:31
sitebuilderNish Nishant13-Oct-02 3:31 
GeneralRe: MySQL Inserting data Pin
Anonymous13-Oct-02 10:45
Anonymous13-Oct-02 10:45 
GeneralGetting DNS Server IP Pin
Al Giv.13-Oct-02 0:19
sussAl Giv.13-Oct-02 0:19 
GeneralRe: Getting DNS Server IP Pin
Anders Molin13-Oct-02 0:29
professionalAnders Molin13-Oct-02 0:29 
GeneralQuery about how to pass a control's Identification through its Message parameters Pin
12-Oct-02 22:17
suss12-Oct-02 22:17 
GeneralA beginner's confusion. Pin
zhoujun12-Oct-02 21:33
zhoujun12-Oct-02 21:33 

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.