Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Logging starategy

1 view
Skip to first unread message

Kuenga

unread,
Oct 16, 2008, 5:57:52 AM10/16/08
to
Hi,

I am working on an MFC application and want to record all the events
carried out by user. Selecting a object, a menu item, invoking dialog
etc, so that I can replay it later.

What's the strategy to start with ? Which desing pattern suitable for
this ?

By logging the WM_message, is it a good idea and then for replay I use
POSTMessage ?

Stephen Wolstenholme

unread,
Oct 16, 2008, 8:52:51 AM10/16/08
to
On Thu, 16 Oct 2008 02:57:52 -0700 (PDT), Kuenga <sagk...@gmail.com>
wrote:

I needed the same functionally so I produced a macro record and play.
As it had to be flexible I used a string parameter on the record
interface. Anything can be converted into a string and recorded in the
macro file. Playback is a little more complex. The recorded strings
are converted back into functions and parameters and called as needed.

Steve


--
Neural Planner Software Ltd http://www.NPSL1.com
JustNN. Just Neural Networks. http://www.justnn.com
EasyNN-plus. Neural Networks plus. http://www.easynn.com
SwingNN. Forecast with Neural Network. http://www.swingnn.com


Joseph M. Newcomer

unread,
Oct 16, 2008, 2:37:37 PM10/16/08
to
Logging has nothing to do with replaying, and in fact replaying has numerous technical
challenges, which require a lot of work to overcome.

Logging WM_ messages will almost certainly result in failure. Imagine that you log a
message OnRButtonDown which has a particular x,y coordinate. Play it back with the
application a half-inch to the left. What do you think you will get?

One approach is to divide your program into two components: GUI manipulation and object
manipulation. The GUI is just a way to manipulate objects. Record the object
manipulations and ignore the existence of the GUI.

Note that this only works if your initial state on replay is identical to the initial
state during recording.
joe

On Thu, 16 Oct 2008 02:57:52 -0700 (PDT), Kuenga <sagk...@gmail.com> wrote:

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Kuenga

unread,
Nov 7, 2008, 8:11:26 AM11/7/08
to
On Oct 16, 11:37 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
> Logging has nothing to do with replaying, and in fact replaying has numerous technical
> challenges, which require a lot of work to overcome.
>
> Logging WM_ messages will almost certainly result in failure.  Imagine that you log a
> message OnRButtonDown which has a particular x,y coordinate.  Play it back with the
> application a half-inch to the left.  What do you think you will get?
>
> One approach is to divide your program into two components: GUI manipulation and object
> manipulation.  The GUI is just a way to manipulate objects.  Record the object
> manipulations and ignore the existence of the GUI.
>
> Note that this only works if your initial state on replay is identical to the initial
> state during recording.
>                                         joe
>
> On Thu, 16 Oct 2008 02:57:52 -0700 (PDT), Kuenga <sagku...@gmail.com> wrote:
> >Hi,
>
> >I am working on an MFC application and want to record all the events
> >carried out by user. Selecting a object, a menu item, invoking dialog
> >etc, so that I can replay it later.
>
> >What's the strategy to start with ? Which desing pattern suitable for
> >this ?
>
> >By logging the WM_message, is it a good idea and then for replay I use
> >POSTMessage ?
>
> Joseph M. Newcomer [MVP]
> email: newco...@flounder.com

I am working on large code base. So came up with the following logging
strategy. I am just logging the menu commands. Is it correct way of
doing it or there exist better way ?

BOOL CTestApp::PreTranslateMessage( MSG* pMsg )
{
if (pMsg->message == WM_COMMAND)
{
if(gCommandDumpFlag==1){
if(HIWORD(pMsg->wParam)==0)
{
CString str;
CWnd *wnd = CWnd::FromHandle(pMsg->hwnd);
if(wnd) {
wnd->GetWindowText(str);
gCmdDump.WriteToBuffer(str);
CMenu *pCMenu = wnd->GetMenu();
if(pCMenu) {
CString str;
pCMenu->GetMenuString(LOWORD(pMsg->wParam),str,MF_BYCOMMAND);
char buf[255];
sprintf(buf," ID=%d",LOWORD(pMsg->wParam));
str+=" ";
str+=buf;
gCmdDump.WriteToBuffer(str);
}
}
}
}
return CWinApp::PreTranslateMessage(pMsg);
}

Ajay Kalra

unread,
Nov 7, 2008, 8:53:07 AM11/7/08
to
On Nov 7, 8:11 am, Kuenga <sagku...@gmail.com> wrote:
Why in PreTranslateMessage? This is not the way to go at all IMO. One
way would be to override OnCmdMsg of your mainframe and do it there
only for WM_COMMANDs. OnCmdMsg is used to route MFC update_command_ui/
Command messages.

--
Ajay
0 new messages