|
Mike Savoie wrote:
PS- CWnd::GetDC(); //error C2660: 'GetDC' : function does not take 1 parameters
are you trying ::GetDC(NULL) ? (ie. don't try CWnd::GetDC(NULL) )
-c
Alcohol is the anesthesia by which we endure the operation of life.
-- George Bernard Shaw
|
|
|
|
|
Dude, if I knew where you were I'd kiss ya!! (umm, well maybe buy ya a beer) haha yeah ::GetDC(NULL); worked. A few more bugs and it'll be finished. Thanks again.
|
|
|
|
|
Hi!
I want to read some information stored in a file.
I mean such as Comment, Title, Author or Keywords.
Are there some APIs that do that ... or must I access the file directly?
Maybe somebody have some code example for me?
Furthermore I want to write (change) this information...
Thanks
Martin
|
|
|
|
|
|
Hi all.
I want to have a CComboBox control that accepts a user's new entry (like a CEdit control) and then adds this entry to the CComboBox.
Here is an example:
Current entries: Cat, Dog, Canary
User types: d-o-l-p-h-i-n (the word dolphin)
Since not in the list, I want my code to add it.
I saw the examples for the IAutoComplete, but I'm not really concerned with that - I just want something simple and that/those examples seem too complex (maybe not? )
Can anyone help me with adding entries to a CComboBox WHILE IN THE CComboBox control?
Thanks so much.
Johnny
|
|
|
|
|
No big magic here - just use CComboBox::FindStringExact to check if user has typed new or existing string, and CComboBox::AddString or CComboBox::InsertString to actually add new entry to dropdown part of the combo.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
hi!
i've encountered serious problem, which couldnt solve for hours.
i've got a couple of views splitted by CSplitterWnd
in one of this views (ParentView) i dynamically create CWnd-derived object (SpinEdit) that holds CEdit and CSpinButtonCtrl (analogously to CInPlaceEdit by Chris Maunder).
the problem is:
i cant handle WM_KILLFOCUS message in SpinEdit window. Spy++ shows that this message isnt sent to SpinEdit window than user clicks mouse button on ParentView.
maybe problem is in ParentView? it is completely owner drawn and has no more child-controls except this dynamically created SpinEdit.
any help will be greatly appreciated
nobody is perfect
|
|
|
|
|
This may be of help http://www.codeproject.com/dialog/killfocus.asp[^]
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Hello,
I have learned a ton in the past few days.. Having never programmed UI Threads (with the help of articles on Code Project and all of you) I have implemented a UI thread that contains a CSocket for file transfer.. The server works perfect except when I close the server I have a memory leak.. This is how I start the UI Thread and how I close the UI thread.. what am I doing wrong??
Here is the creation inside CMainFrame
CFtThread* pThread = (CFtThread*)AfxBeginThread(RUNTIME_CLASS(CFtThread),
THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
pThread->m_nPort = 21;
pThread->ResumeThread();
pThread->OnStartListening();
Here is how I am trying to close the thread.. it's in CMainFrame::OnClose()
void CMainFrame::OnClose()
{
..... code
CFtThread* pThread = (CFtThread*)AfxGetThread();
pThread->ExitInstance();
..... code
CFrameWnd::OnClose();
}
In my int CFtThread::ExitInstance() I try to close the socket and remove any connected sockets...
int CFtThread::ExitInstance()
{
m_sSocket.ShutDown(2);
m_sSocket.Close();
POSITION pos, temp;
pos = m_pEpList.GetHeadPosition();
while(!m_pEpList.IsEmpty())
{
temp = pos;
CFtSocket* pSocket = (CFtSocket*)m_pEpList.GetNext(pos);
pSocket->Close();
m_pEpList.RemoveAt(temp);
}
return CWinThread::ExitInstance();
}
Any ideas on why I still have a memory leak?
Thanks,
Rob Jones
|
|
|
|
|
u are emtying the list, but are u deleting the pointers if any??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
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. ***
|
|
|
|