|
Yes I delete all Socket pointers.. It's in a different function.. 99% of the time the pointers are gone and the pointer list is empty.. I just empty it on close "just incase"..
|
|
|
|
|
AfxGetThread() returns a CWinThread pointer to the thread that makes the call. From your chunks of code it looks like you are trying to close your main thread from the OnClose() event handler for it, and thus not actually closing your CFtThread object.
I don't know what would happen if you cast a CWinThread pointer to CFtThread; I would have thought something more significant than a memory leak would happen when you try to call members of CFtThread.m_sSocket.
You get given a pointer to your CFtThread as a return from AfxBeginThread(). Try using that to close the thread.
Signature space for rent. Apply by email to....
|
|
|
|
|
I set a member pointer to CFtThread (in CMainFrame) and tried to use that pointer (from AfxBeginThread()) to close the thread.. seems that maybe the app closes before the thread does.. is there a way to wait for the thread to close before closing the app?
|
|
|
|
|
Thats cool. Just these two lines in your sample code made me suspicious:-
CFtThread* pThread = (CFtThread*)AfxGetThread();
pThread->ExitInstance();
Anyway. Only your CFtThread thread can terminate itself safely. You need to devise a mechanism for signaling to it that it needs to terminate. For a suitable signalling mechanism, see CWinThread::PostThreadMessage. You could use a custom message for it.
When your thread receives the message, it should call AfxEndThread().
for detailed info, see msdn "multithread programming | with mfc"
Signature space for rent. Apply by email to....
|
|
|
|
|
Dumping objects ->
strcore.cpp(118) : {93} normal block at 0x01222E40, 52 bytes long.
Data: < ' ' C:\C> 01 00 00 00 27 00 00 00 27 00 00 00 43 3A 5C 43
C:\Code\FtServer\FtThread.cpp(17) : {91} client block at 0x01222F40, subtype 0, 168 bytes long.
a CFtThread object at $01222F40, 168 bytes long
Object dump complete.
I'm unsure what strcore.ccp is... not sure if this helps.
Any ideas?
|
|
|
|
|
strcore.cpp needn't concern you:- MFC internals. The useful part of that dump is the line:-
a CFtThread object at $01222F40, 168 bytes long
tells you what it was.
Signature space for rent. Apply by email to....
|
|
|
|
|
strcore.cpp is the guts of CString.
As you can see, the leaked memory even contains fragments of your string.
But this is not CStrings fault, it simply gets no opportunity to clean up.
|
|
|
|
|
The best way to kill a thread is asking it to finish and wait for its end. A way to to this could be to implement a specific message send by the app to the thread.
(m_pMyThread is the pointer you get from AfxBeginThread
WM_STOPTHREAD defined as WM_APP + 1)
In the application:
<code>
// asking the thread to end
m_pMyThread->PostThreadMessage(WM_STOPTHREAD, 0, 0);
MsgWaitForMultipleObjects(1, &(m_pMyThread->m_hThread), TRUE, INFINITE, QS_ALLEVENTS);</code>
In the thread
<code>BEGIN_MESSAGE_MAP(CMyThread, CWinThread)
ON_THREAD_MESSAGE(WM_STOPTHREAD, OnStopThread)
END_MESSAGE_MAP()</code>
<code>LRESULT CMyThread::OnStopThreadClip(WPARAM wParam, LPARAM lParam)
{
// cleaning data here
AfxEndThread(1);
return 0L;
}</code>
HTH,
K.
<font size=0>
Some of those that work forces
Are the same that burn crosses !
Killing In The Name/Rage Against The Machine
</a>
</font>
|
|
|
|
|
How can I find out if I'm in print preview mode in my main frames OnClose()?
I've tried checking the DC IsKindOf for CPreviewDC, but couldn't get a positive result (am I using the DC incorrectly?) like this:
CDC* pDC = GetDC();
if (pDC && pDC->IsKindOf(RUNTIME_CLASS(CPreviewDC)))
if (pDC)
ReleaseDC(pDC); And I've also tried checking for difference's in the hDC's without joy:
CDC* pDC = GetDC();
if (pDC && pDC->m_hDC != pDC->m_hAttribDC)
if (pDC)
ReleaseDC(pDC); Anyone know how I can find out if I'm in print preview in my CMainFrame::OnClose() ??
Dylan Kenneally
London, UK
|
|
|
|
|
From the top of my head: override CFrameWnd::OnSetPreviewMode. Never did that, however
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Works a treat, thanks very much
Dylan Kenneally
London, UK
|
|
|
|
|
I am doing my win32 application.How to dynamically increase scroll bar size
of a window.
|
|
|
|
|
Do you create your scrollbars by adding WS_HSCROLL or WS_VSCROLL window style, or it's a child control?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Hi,
I have 2 Tables on MS-Access and I use 1 class CRecordSet because these tables are joined. I have no problem to read a recordset like this:
rsMsg.m_strFilter.Format("CLE = %d", lCle );
rsMsgExp.Open( CRecordset::snapshot,_T("Proc"));
if(!(rsMsgExp.IsEOF() && rsMsgExp.IsBOF()))
{
rsMsgExp.MoveFirst();
csToto = rsMsgExp.m_TOTO;
But when I don't want to write (Add or Update a record), it's not possible, the Exception is "Record is on Read Only Mode", why ???????
Thanks a lot ....
|
|
|
|
|
Snapshots are not updateable. BTW: why don't you use CDaoRecordset instead of ODBC-based CRecordset if you're using Access?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
|
So use CDaoRecordset and open it as 'dynaset', not 'snapshot' - pass dbOpenDynaset to CDaoRecordset::Open.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Hi,
I have a problem with the COleDateTime class. I have no idea how to do subtraction and addition for two COleDateTime objects. I am used to the VB type of time and date addition and subtraction. Is there a way to do subtraction and addition as in VB date/time?
By the way is there an equalvalent date/time method in VC that is similar to the one in VB?
Your help is greatly appreciated.
leonwoo
|
|
|
|
|
Look at the COleDateTimeSpan class and operators +,-,+= and -= defined in COleDateTime.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Im using dinput.h's GetDeviceState to retrieve the
current mouse cursor position.
Why do I get coordinates returned in the billions???
I get the same result using ints and longs for x&y.
All I want are pixel coordinates within the
range of my window app.
Any help would be much appreciated
Thanks,
Rob
|
|
|
|
|
Says MSDN-
> The mouse is a relative-axis device, so the absolute axis positions for mouse axes are simply accumulated relative motion. Therefore, the value of the absolute axis position is not meaningful except in comparison with other absolute axis positions.
Why don't you just handle WM_MOUSEMOVE events instead? Potentially with a SetCapture() first.
Signature space for rent. Apply by email to....
|
|
|
|
|
As far as I know, GetCursorPos() works very well, this gets your position in screen coordinates, you can use ScreenToClient() after that.
Romeo JUNCU
|
|
|
|
|
hi,
the template was not recognized, in my MFC DLL.
typedef struct
{
CString name;
int age;
}MYSTRUCT;
CList<MYSTRUCT,MYSTRUCT&> myList;
what's wrong then?
Extreme programming. Do the No.1
|
|
|
|
|
I believe you must export your struct from your extension dll. Use AFX_EXT_CLASS macro
Best regards,
Alexandru Savescu
|
|
|
|
|
I've created a dialog based multithreaded application in VC++ 6.0. The problem is that, whenever i close my application in "release" build, the memory error appears. I am unable to discover the problem because this error is not appearing in debug build. Can any one suggest me something ???
The error i am getting in release build while closing application is:
The instruction at "0x004165a3 referenced at 0x00000078. The meemory could not be "read"
|
|
|
|