|
You are right it does work. I tried in a clean Doc/View program too.
Odd that it doesn't work in the current program I am working on.
I have OnDraw calling a function to draw but CRect and CPoint value just disappear. I even output the value before the function is called but as soon it's called the value is gone.
This is what happen I use Debug to trace into it
CXX0069: Error: variable needs stack frame
|
|
|
|
|
Are you using cout in a GUI application?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Ooops disregard the debug error message. I breakpoint too early.
No cout I am drawing a graph and basically I have it
CPoint pt declare in the View header
int dummy declare in the header also
OnDraw(CDC* pDC){
CRect final;
int x =6, y = 7;
pt = (3, 2);
dummy = 9;
// At this point 3, 2 is still valid
final = function(x, y);
// pt, 3, 2 returns
// Draw final rectangle
}
CRect function{int x, int y){
// pt x = 0, y = 0;
// dummy = 7
CRect temp;
temp = (CPoint(pt.x+x, pt.y+y), CSize(3,3));
return temp;
}
Something like that. I don't understand why my function is having problem accessing pt value but if I declare it as int it would be fine Grrr. pt.x was orignally an int and it worked fine but when I changed it to CPoint pt.x it stopped working.
|
|
|
|
|
Anonymous wrote:
pt = (3, 2);
Are you sure this is right? Set a breakpoint on this statement and notice that the x and y member variables are not what you think they should be. Use an explicit assignment, or use something like:
pt = (2 << 16) + 3; Anonymous wrote:
CRect function{int x, int y){
Is this a member of the view class? In either case, the left curly brace does not match the right parenthesis.
Anonymous wrote:
temp = (CPoint(pt.x+x, pt.y+y), CSize(3,3));
This assignment also looks suspect. I would change it to this instead:
CRect temp(CPoint(pt.x+x, pt.y+y), CSize(3,3));
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I just check the memory address.
When I called rect/pt value in the function it reads a new memory address location?!? And it doesn't do that with int.
The View contructor was only called once.
|
|
|
|
|
Disregard. I figured out why. I feel very stupid right now
When I chaged declaration to header, I forgot to clear the declaration in the function(I thought I did).
I am surprise the compiler didn't raise flag about the overlap. Hmm I remember there was a declaring function to tell the program which overlap variable to use.
|
|
|
|
|
I am getting these linking errors. i would appreciate if someone has already had these errors and let me know how he or she resolved them.
Linking...
LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification
Creating library ..\mmig\m3.lib and object ..\mmig\m3.exp
vld.lib(vld.obj) : error LNK2019: unresolved external symbol __CrtDbgReport referenced in function "public: __thiscall VisualLeakDetector::VisualLeakDetector(void)" (??0VisualLeakDetector@@QAE@XZ)
vld.lib(vld.obj) : error LNK2019: unresolved external symbol __CrtSetAllocHook referenced in function "public: __thiscall VisualLeakDetector::VisualLeakDetector(void)" (??0VisualLeakDetector@@QAE@XZ)
vld.lib(vld.obj) : error LNK2019: unresolved external symbol "void __cdecl std::_Xran(void)" (?_Xran@std@@YAXXZ) referenced in function "private: class std::basic_string,class std::allocator > __thiscall VisualLeakDetector::buildsymbolsearchpath(void)" (?buildsymbolsearchpath@VisualLeakDetector@@AAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
vld.lib(vld.obj) : error LNK2019: unresolved external symbol "void __cdecl std::_Xlen(void)" (?_Xlen@std@@YAXXZ) referenced in function "private: void __thiscall VisualLeakDetector::reportleaks(void)" (?reportleaks@VisualLeakDetector@@AAEXXZ)
..\mmig\m3.dll : fatal error LNK1120: 4 unresolved externals
Jay
|
|
|
|
|
|
How to display ohm sign, 'Ω', on the screen using VC++, VC++ .net and VB.net? if possible?, What is the project setting?
|
|
|
|
|
ds feng wrote:
How to display ohm sign, 'Ω', on the screen...
Is this a console or a GUI application?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
The console does not support it, and a GUI application will need unicode for that sign because the ANSI converts it to 0x4F and that is 'O'.
Don't try it, just do it!
|
|
|
|
|
Why did you delete your answer??
The unicode data for L"Ω" is 0xA9 0x03 0x00 0x00.
=> WORD wOhm = 0x03A9;
Don't try it, just do it!
|
|
|
|
|
Hi ds feng,
#ifndef UNICODE
#define UNICODE
#ifdef UNICODE
//ur code for display ohm goes here
#endif
This might solve your problem.
Cheers,
Vishal
|
|
|
|
|
Hi everybody, i have a problem with CEdit, for example
CString s1="Hello World";
CString s2="This is a Test";
//and we have CEdit variable m_edit
m_edit=s1+"\n"+s2;
as you see i want the result to be
Hello World
This is a Test
but CEdit shows :
Hello World This is a Test
though CEdit is marked in properties as "Multiline"
Can anybody help??
Regards
m0n0
|
|
|
|
|
replace \n with \r\n
it will work... even today (April, 1st)
ps: is your EditBox declared as MultiLine ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
|
Hi gurus
I'd like to know how I can brutally kill a running thread created via AfxBeginThread ?
The core of the function looks like this:
while (!m_dwBytesRead && (nRetries < 2600))<br />
{<br />
m_pReadThread=AfxBeginThread(ReadThread, this, THREAD_PRIORITY_NORMAL);<br />
<br />
nRetries++;<br />
::Sleep(600);<br />
<br />
if (!m_dwBytesRead)<br />
{<br />
}<br />
}
Thanks.
Best regards.
There is no spoon.
|
|
|
|
|
To end the thread, call AfxEndThread from within the thread, or return from the controlling function of the worker thread.
MSDN is your answer.
Don't try it, just do it!
|
|
|
|
|
no, not from inside the thread... The creator of the thread, kills its created thread.
<br />
while (!m_dwBytesRead && (nRetries < 2600))<br />
{<br />
m_pReadThread=AfxBeginThread(ReadThread, this, THREAD_PRIORITY_NORMAL);<br />
<br />
nRetries++;<br />
::Sleep(600);<br />
<br />
if (!m_dwBytesRead)<br />
{<br />
}<br />
}<br />
There is no spoon.
|
|
|
|
|
|
I wish the creator of the thread kill his created thread:
while (!m_dwBytesRead && (nRetries < 2600))<br />
{<br />
m_pReadThread=AfxBeginThread(ReadThread, this, THREAD_PRIORITY_NORMAL);<br />
<br />
nRetries++;<br />
::Sleep(600);<br />
<br />
if (!m_dwBytesRead)<br />
{<br />
}<br />
}
There is no spoon.
|
|
|
|
|
ok, i so repost my question :
don't SendMessge() work with the correct argument ? (i don't remember which, but it might be something like WM_KILL or WM_END)... of course, sent to the correct thread, ie. m_pReadThread
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
no, the owner of the thread is not a window. the owner of the thread is a CObject derived class. There must be a way for the owner of the thread to kill its own created thread without condition.
There is no spoon.
|
|
|
|
|
where did you see that SendMessage() was a member of CWindow or CDialog or i don't even know what else... there's a global one ...
but if you don't want (and you ahve the right to), don't do it ...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|