|
Thanks for your comments on the code.
All I am trying to do is have an Edit Box (Multi-line, vertical scroll) display text posted via a call to DLL. The thread handles the Event from the DLL but needed access to the dialogs classes.
I don't like how you pass the pointer of the dlg into the thread; it seems awfully convoluted. Why not just pass the this pointer as the param?
That why I pass in the dialog pointer (this) and the stop flag.
The structure is as follows:-
// For Display Text Thread
typedef struct
{
bool stopFlag; // Set if some error occured during the process or want to terminate
CTestGUI1Dlg* _this;
}DisplayThreadData;
The second potential problem is pxDlg->UpdateOutput(). This is the most likely candidate for a memory overwrite of your m_pMsg pointer.
Whats the alternative, as if I comment this call out, program does not crash (but does not display the text. I think you are right, this is where the problem is!!!
But what to do?
A few other concern: You may be handling CTestGUI1Dlg incorrectly. You should use PostThreadMessage to do more than trivial things in a CWnd derived object from a secondary thread.
Sorry you have passed the limit of my knowledge.
I was using a timer to process the text display, but had to slow things down (on both size) to be sure of not losing data.
Was advised that reacting to events would be better.
But ended up with a different problem.
Have now set Event to Auto reset and sorted out the terminate logic.
Sweep123 working from home.
grahamfff
|
|
|
|
|
Grahamfff wrote:
That why I pass in the dialog pointer (this) and the stop flag.
My mistake; based on past experience I assumed you were passing some convoluted thing.
Grahamfff wrote:
A few other concern: You may be handling CTestGUI1Dlg incorrectly. You should use PostThreadMessage to do more than trivial things in a CWnd derived object from a secondary thread.
Sorry you have passed the limit of my knowledge.
In MFC, you aren't supposed to call any control objects owned by one thread from another. You can do it, but it can cause problems [usually reentrancy problems.] The proscribed solution is to use PostThreadMessage with the handle of the window in question, in this case the dialog box, with a USER message or even a "fake" valid message. (Try creating a fake WM_TIMER message.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
such as tips, compiler setting, shortcut key...
|
|
|
|
|
|
|
Hi, I have a question.
Is there any way to play a MJPEG file with Windows Media Player?
Thanks
|
|
|
|
|
yes. but you'll need an MJPEG codec to do it. there are many commercial codecs available... don't know of any free ones...
Cleek | Jewelry | ClickPic | ThumbNailer
|
|
|
|
|
Dear Expert,
I'm a mschart control newbie. Here are 3 Questions needed your help.
(below is supposing to use this contorl in VB , you can also use it in VC, or other windows program tools capable of using this ActiveX controls, the encountered problem is same)
Q1: When I set *.ChartType=VtChChartType2dXY, How can I set X-asis Label to
my own expected string instead of Xas automatic generated by
itself.(Such as datetime instead of "0 1 2 3 ...")
Q2: Both when *.ChartType=VtChChartType2dXY or VtChChartType2dLine,
and when Xas Lable string is too long , How can I display it in Multi-line
Q3: When *.ChartType=VtChChartType2dLine , and after I set xasis.tick.style=...Inside,
& xasis.tick.length=200, it does not take effect, nothing changes , and what I expected to occur does not occur
In sum, What I want to do is by using mschart (must , cant use any other 3rd party controls),
set xasis infos(such as label , tick style, length) customarily by my expected format
Thanks in advance , Expecting your answer!
Allen, Homer
|
|
|
|
|
Hi!! I need some help here.
How to convert an integer variable to string so that the string and the variable can be concatenated. The string will be displayed in the edit control.
Thanks
jazzlycool
|
|
|
|
|
CString str;
str.Format("%d", intValue);
char acBuffer[16] = {0};
sprintf(acBuffer, "%d", intValue);
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Without using MFC:
int Number = 178;<br />
char szString[50];<br />
<br />
wsprintf(szString,"%d",Number);
or
itoa(Number,szString,10); /*gives the string in decimal : "178"*/
or
itoa(Number,szString,2); /*gives the string in binary : "10110010"*/
~Bikram~
|
|
|
|
|
Thanks for helping me.
jazzlycool
|
|
|
|
|
CString my_string;
int my_int = 54;
my_string.Format("The value is: %d", my_int);
|
|
|
|
|
is there any (system) function can test memory pointer to know combination of bits there is real (double, float) value?
something like this
if(isValidDoubleValue(dptr))
dvalue = 0.0;
else
dvalue = *dptr; //always no exception crash here
what will not crash
(all i found (like _isnan) expect given bit combination represents valid state and crashes getting invalid one)
thanks
|
|
|
|
|
Check IsBadReadPtr to guaranty that you have read access to the memory pointed by dptr
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
yes, but it does not guarantee will not crash next
doublevalue = *ptr;
|
|
|
|
|
If you have read access, it wont crash
will it?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
sometimes will
_FPE_INVALID
|
|
|
|
|
After gaining read access, check for Floating point exceptions
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
it seems it will end with own fn of this kind
just afraid with big data will be exception handling
|
|
|
|
|
Never heard of that, but a look at MSDN with _FPE_INVALID lead me to SIGFPE
and that lead me to signal(), a function you can use to set your own signal handler.
I never tried that but maybe this is worth a try?
Jens
|
|
|
|
|
it seems it will end with own fn of this kind
just afraid with big data will be exception handling slow
|
|
|
|
|
Tibor Blazko wrote:
is there any (system) function can test memory pointer to know combination of bits there is real (double, float) value?
None that I know of. What's stored at a particular memory location is only important to the application that put it there. In other words, if application A wrote 123.45 to some memory location, it's possible (not to be confused with easy or commonplace) for application B to read that memory location, but application B would not know that those particular bytes represented a double or float .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
i know it should represent double
just have data with some uninitialized values (sometimes not valid doubles)
and this (crashing ones) i want set to 0.0 in correction step nr.1
|
|
|
|
|
I'm might be missing something here, but if it just uninitialised variables, the following might help you out.
try
{
dValue = *dPtr;
}
catch( . . . )
{
dValue = 0.0;
}
Chris Meech
We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton
VB is like a toolbox, in the hands of a craftsman, you can end up with some amazing stuff, but without the skills to use it right you end up with Homer Simpson's attempt at building a barbeque or his attempt at a Spice rack. Michael P. Butler
|
|
|
|