test various algorithms that we develop. It writes to stdout.
Joseph M. Newcomer wrote:
You already have a timestamp on the message, GetMessageTime, which gives you the timestamp
of the last message. And moving the code to the proper handler will NOT materially affect
the time you record. If they arrive "infrequently", you need to specify the accuracy of
the timestamp (remember that by the time you get to PreTranslateMessage, a lot of water
has flowed under the bridge anyway, and you need to figure out what percentage error a
correct implementation will impose. This is particularly interesting in that the use of
GetCurrentTime is fairly hefty, and has an accuracy of no better than 10 or 15
milliseconds, several orders of magnitude greater than the cost induced by doing the job
right, and in addition you've put this massive, heavy-duty call in the procssing of EVERY
message)
Since this is clearly a Windows program, there is no such thing as a "printf" that can
have meaning, because there is no stdout, or stderr, so a "print statement" doesn't do
anything because it has no place to write. So you won't see any message even if you
execute a printf statement because there isn't any place for it to appear. Consequently,
the inability to see the output indicates nothing interesting.
joe
On 3 Aug 2006 06:56:30 -0700, PloutzMR@Npt.NUWC.Navy.Mil wrote:
These messages are received fairly infrequently, and so an accurate
time reading is necessary for proper display in each listbox.
A print statement would be printf() in C++...maybe that's the incorrect
term, but all my college courses used it.
And remember, I am new to all this...I don't claim to be an expert :-)
Matt
Joseph M. Newcomer wrote:
Do not under any circumstances put this in the PreTranslateMessage handler. This is
wrong, and a misuse of PreTranslateMessage. Just add to the message map
ON_MESSAGE(OECM_MESSAGE, OnOecmMessage)
or
ON_REGISTERED_MESSAGE(OECM_MESSAGE, OnOecnMessage)
where you had defined
LRESULT ViewConnections::OnOecmMessage(WPARAM, LPARAM)
{
...format stuff here
return 0;
}
Note that this code forces you to read the current time EVERY TIME A MESSAGE IS RECEIVED,
which is completely silly.
The UpdateData is pointless and serves absolutely no useful purpose. There is nothing
here that sets any state that UpdateData is concerned with or manipulates. Get rid of it.
And what, exactly, is a "print statement"?
joe
On 2 Aug 2006 07:49:45 -0700, PloutzMR@Npt.NUWC.Navy.Mil wrote:
Another noob question...
I need to pass a message from a main frame window to one of its
children...the child is created with
dlg = new Window();
dlg->Create(IDD_TABHOLDER,this);
dlg->ShowWindow(SW_SHOW);
within the main frame. Then the message is sent:
SendMessageToDescendants(OECM_MESSAGE,0,0,true);
In the child dialog class, I do the following:
BOOL ViewConnections::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
CString msg;
CTime theTime = CTime::GetCurrentTime(); //the current time
switch (pMsg->message)
{
case OECM_MESSAGE:
msg.Format("{%02d:%02d:%02d} SubSkillsNet Connection
Established",theTime.GetHour(),
theTime.GetMinute(),theTime.GetSecond());
listbox.AddString(msg);
UpdateData(false);
break;
default:
break;
}
return CDialog::PreTranslateMessage(pMsg);
}
But the child dialog never receives the message...this was confirmed
with a print statement inside the first case of the switch
statement....Any ideas here?
Thank you!
-Matt
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm