|
Thanks Andrew - works a treat
|
|
|
|
|
hi i need source genetic algorithm function sphere,schwefel, rosenberg, Ackley, Giewank with languages c++
|
|
|
|
|
I would suggest a Google search, this forum does not provide code on demand.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Do your own homework.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Hi,
I created the CFromView dynamically, Form is having CListCtrl where should set the style for CListCtrl?
the below code is giving error as m_ListDriveis is NULL .
bool CRecoverDriveDlg::CreateView(UINT Style, CRect rect,CWnd *Parent)
{
Create(NULL,NULL,Style,rect,Parent,0x10,NULL);
m_ListDrive.SetExtendedStyle(LVS_EX_FULLROWSELECT);
return 1;
}
|
|
|
|
|
What is m_ListDrive supposed to be and where is it initialised?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I'm guessing what you mean is m_ListDrivis.m_hwnd is null. The variable somehow needs to be attached to the dialog control.
This can be done with Dynamic Data eXchange (DDX) or the SubclassDlgItem[^] function, which must be called before m_ListDrive.SetExtendedStyle(LVS_EX_FULLROWSELECT); .
You could also make it into a pointer in the class definition, and then use
m_ListDrive = (CListCtrl *)GetDlgItem(IDC_MY_LIST); m_ListDrive->SetExtendedStyle(LVS_EX_FULLROWSELECT);
|
|
|
|
|
Where did you get all this about a dialog? The OP's question is about creating a window.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I have not used MFC for about a year now, so my memory could be a bit flaky, but:
"These controls are laid out based on a dialog-template resource."
- CFormView Class[^].
The form view is a pretty way of embedding a dialog into a MFC view. All of the controls on it have a dialog ID associated with them.
|
|
|
|
|
That may well be true but it does not seem to be the way OP is implementing it. I'm ready to stand corrected, however.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I could be completely wrong on this, but to me, it appears that he has defined a variable, something like CListCtrl m_ListDrive in the CRecoverDriveDlg class.
He is expecting this variable to automatically attach to some list control he has in the dialog template (I dont see a call to m_ListDrive.Create() ).
My suggestion was to manually attach m_ListDrive to this control somehow.
It is possible that he has called m_ListDrive.Create() elsewhere in his code and simply hasn't shown it and hence I am completely wrong. Since the original issue is m_ListDrive is NULL, then this call has failed, and that code would be relevant to helping him find a solution.
|
|
|
|
|
I agree, which is why my question to him was "what is this variable and where is it initialised?". We will see; or not!
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Why shouldn't it be NULL ?
I mean, you didn't show us the code initializing it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
As I know IOCP which is called one powerful model to meet socket program in scalable case, from then on I have a question on IOCP.Today, still puzzle me.
The question is What will happen if you post more than one WSASend() request in one client socket which has been associated with the existing completion port. The scenario is as follows:
IO Request:
WSASend(...,wsaBuff1,1,...); WSASend(...,wsaBuff2,1,...); WSASend(...,wsaBuff3,1,...);
What will happen in the completion port?
1/ How many completion packet will be received?
2/ What is the order of the completion packet?
3/ Is it possbile to require more than one send request for each buffer? It means one time send request can't finish the data transmission. The user need to post another or more WSASend request for the rest data.
|
|
|
|
|
SAMZCN wrote: How many completion packet will be received?
One for each WSASend call. Always one for each completion packet queued.
SAMZCN wrote: What is the order of the completion packet?
If you only have one completion handler thread then they'll be in order queued. Multiple completion handler threads could execute in any order as always.
SAMZCN wrote: Is it possbile to require more than one send request for each buffer?
Yes it's possible, so you need to check if the entire buffer of data was sent for each call, same as always with sockets.
Note: If you make multiple asynchronous WSASend calls using an I/O completion port then make sure all calls are made on the same thread.
For TCP/IP, I personally much prefer only one outstanding read and/or one outstanding write per socket given the above information
Mark Salsbery
|
|
|
|
|
Hello Mark,
Much appreciated for your input. I think it is very helpful to me.
Mark Salsbery wrote: SAMZCN wrote: Is it possbile to require more than one send request for each buffer?
Yes it's possible, so you need to check if the entire buffer of data was sent for each call, same as always with sockets.
Note: If you make multiple asynchronous WSASend calls using an I/O completion port then make sure all calls are made on the same thread.
For TCP/IP, I personally much prefer only one outstanding read and/or one outstanding write per socket given the above information
At this point, it is the biggest puzzling thing to me. I read many articles on this issue about IOCP. But don't find any conclusion to make me convienced. By your saying, it seems really I need to check the whether the entire buffer in one request was sent out completely. If not, I need to post another send request for the rest data.
Yes. Really I want to make multiple asynchronous WSASend calls using an I/O completion port to get performance improvement. But I can't make sure the calls are received by same thread. It is my problem. I do many trials on this. It seems meaningless.
I agree that one outstanding IO operation per socket in a given time is a good way to get stable running. Thanks.
|
|
|
|
|
SAMZCN wrote: it seems really I need to check the whether the entire buffer in one request was sent out completely. If not, I need to post another send request for the rest data.
With TCP/IP protocol, YES - always with sockets! (I say with TCP/IP since for example, UDP datagrams always go all at once).
SAMZCN wrote: I want to make multiple asynchronous WSASend calls using an I/O completion port to get performance improvement. But I can't make sure the calls are received by same thread.
Won't really be any performance increase.. The network stack (including the socket and the network adapter(s)) is a huge bottleneck and generally magnitudes slower than your running code.
*edit* Plus you really can't since you need the result of the previous sends. Any thread synchronization you could maybe add to "solve" this would probably just slow down the IOCP since you'd have IOCP completion handler threads waiting on synch objects instead of waiting for completion packets so overall performance could suffer when many sockets are involved (which is where IOCPs really shine).
Mark Salsbery
modified 26-Oct-11 14:26pm.
|
|
|
|
|
Hi Mark. Thanks.
Appreciated for your share. It really helps me understand IOCP and other asnc IO operation.
|
|
|
|
|
I have an SDI app, where I want to serialize an versionable object, of CData class :
class CData : public CObject
{
DECLARE_SERIAL(CData)
public:
CData();
virtual ~CData();
virtual void Serialize(CArchive& ar);
BOOL ReadDocumentFromDisk();
BOOL WriteDocumentToDisk();
};
and here is implementation code :
IMPLEMENT_SERIAL(CData, CObject, VERSIONABLE_SCHEMA | 1)
CData::CData()
{
}
CData::~CData()
{
}
void CData::Serialize(CArchive& ar)
{
CObject::Serialize(ar);
try
{
if(ar.IsLoading())
{
TRACE("Loading : objectschema - %d\n",ar.GetObjectSchema());
int n = 0;
ar >> n;
TRACE("n is %d\n",n);
}
else {
int x = 456;
ar << x;
}
}
catch(CFileException* pFileException)
{
pFileException->ReportError();
pFileException->Delete();
}
}
BOOL CData::ReadDocumentFromDisk()
{
CFile file;
CString sFile;
CFileException FileException;
::GetModuleFileName(NULL,sFile.GetBuffer(255),255);
sFile.ReleaseBuffer();
sFile = sFile.Left(sFile.ReverseFind('\\') + 1);
sFile += _T("Default.tse");
if(! file.Open(sFile,CFile::modeRead,&FileException))
{
return FALSE;
}
CArchive ar(&file,CArchive::load);
Serialize(ar);
return TRUE;
}
BOOL CData::WriteDocumentToDisk()
{
CFile file;
CString sFile;
CFileException* pFileException = NULL;
::GetModuleFileName(NULL,sFile.GetBuffer(255),255);
sFile.ReleaseBuffer();
sFile = sFile.Left(sFile.ReverseFind('\\') + 1);
sFile += _T("Default.tse");
if(! file.Open(sFile,CFile::modeCreate | CFile::modeWrite,pFileException))
{
return FALSE;
}
CArchive ar(&file,CArchive::store);
Serialize(ar);
return TRUE;
}
and from somewhere in CMyView class, I call :
void CTestSerializeView::OnHelpLoad()
{
CData data;
data.ReadDocumentFromDisk();
}
void CTestSerializeView::OnHelpStore()
{
CData data;
data.WriteDocumentToDisk();
}
although serialization of integer variable is good, I always get version -1 of CData object :
<br />
TRACE("Loading : objectschema - %d\n",ar.GetObjectSchema()); <br />
what I'm doing wrong ?
|
|
|
|
|
Debug each step and see where the value is coming from.
==============================
Nothing to say.
|
|
|
|
|
Hello,
I have a class that doesn't connect to a dialog or window
and I need to do some operations on timer but the timers works only with dialogs ,
does anyone know another way I do it?
thank
|
|
|
|
|
You can have a thread running the Sleep API. After a specified interval of time it becomes active, performs it's task and sleep's again for the specified duration.
That is somewhat similar to what a timer does.
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
Thanks for the answer,
But the operations that I need to perform on the timer
shuld have an approach to the data members and member Functions of the class ,
can I do it with threads?
|
|
|
|
|
No, not thread safe at all.
|
|
|
|
|
Could make it threadsafe with Mutexes[^]
|
|
|
|