|
Could you please post code from your header definition and source file, only relevant parts please.
At a guess tho, I would say it is because you didn't declare it as a virtual function.
In the header file it should be declared as virtual void OnInitialUpdate();
|
|
|
|
|
Andrew Brock wrote: At a guess tho, I would say it is because you didn't declare it as a virtual function.
In the header file it should be declared as virtual void OnInitialUpdate();
Not likely since once virtual, always virtual. You don't need to declare an overridden virtual function virtual. However good it might be for readability, it's not necessary.
|
|
|
|
|
Hi,
I have changed the background colour of one of my dialogs by handling the WM_CTLCOLOR message. This works OK but the child controls are still painted using the original dialog background colour. I have set the transparent property of the child controls but this makes no difference.
Is there something else I need to do?
Thanks
Tony
|
|
|
|
|
What are your child controls? Static text?
Typically you would need to override the WM_ERASEBKGND (OnEraseBkgnd in MFC) in the child controls to stop it painting the background or to copy the parent background (depending on what you are doing). Check out some of the transparent controls[^] in the articles section.
|
|
|
|
|
My dialog contains a mixture of control types, including CStatic, CEdit etc. I have discovered that if I call pDC->SetBkMode(TRANSPARENT) in my dialog's OnCtlColor() handler then all of the child static controls have a transparent background - GREAT! - but unfortunately, so do my edit controls.
So close but yet so far
I was hoping that I would be able to create a generic dialog class which would allow me to set the background colour without me having to fiddle with the child controls on an individual basis.
|
|
|
|
|
Ok, great start. Check out the MSDN page[^] for OnCtlColor().
Notice the nCtlColor parameter? Only do pDC->SetBkMode(TRANSPARENT) if it is equal to CTLCOLOR_STATIC and you should be set.
EDIT:
If you only want to set specific controls as transperent, rather than all controls of a type, check if pWnd is the instance you want to set instead.
|
|
|
|
|
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 ?
|
|
|
|