Hi,
I want to create a logfile with every menu-option or button that is clicked in my MAIN application.
Anyone who has something for this? I want to add some code to the handler and to save the date, time, caption of clicked option, username, ... in a file. To prevent that this file is getting too big, I would recycle after three months.
If someone has something to share?
Creating logfile
Re: Creating logfile
At the risk of being branded a heretic, Clayton Jones' "Top Down" demo has a very clever method of keeping track of a user's activity in a program.
Re: Creating logfile
what about :skiman wrote:I want to create a logfile with every menu-option or button that is clicked in my MAIN application.
Anyone who has something for this? I want to add some code to the handler and to save the date, time, caption of clicked option, username, ... in a file. To prevent that this file is getting too big, I would recycle after three months.
If someone has something to share?
Code: Select all
PROCEDURE MAIN
SET ALTER TO myLog.TXT
...
Userlog("blabla")
...
SET ALTER TO
RETURN
PROCEDURE Userlog(cText)
DEFAULT cText TO ""
SET CONSOLE OFF // need for GUI
SET ALTER ON
? ID_USER,DATE(),TIME(), cText
SET ALTER OFF
SET CONSOLE ON // need for GUI
RETURN
... shure you can make same with a DBF

greetings by OHR
Jimmy
Jimmy
Re: Creating logfile
Hi Jimmy,
This is not what I'm looking for. I want to add the logsystem to the handler of my main application. This way I can log all the actions a user can click in my application.
This is not what I'm looking for. I want to add the logsystem to the handler of my main application. This way I can log all the actions a user can click in my application.
Re: Creating logfile
aha ... so you looking for EventSpy !?skiman wrote:I want to add the logsystem to the handler of my main application. This way I can log all the actions a user can click in my application.
// DESCRIPTION
//
// This file implements an Event Spy that can display all events,
// message parameters and message receivers in an Xbase++ program.
//
// It is great for the Xbase++ novice who wants to see what happens
// in the event loop, and it is a great tool for advanced programmers
// who need to trace single events.
//
// FYI: I have found this tool to be invaluable for "hard core" event
// programming. That is: a single Xbase Part captures all mouse
// messages. In this scenario, it is pretty hard to find a paint event
// that causes wrong display unless you have a complete history of
// events and their receivers.
//
// USAGE
//
// Copy EVENTSPY.DLL and EVENTSPY.LIB to a directory of the LIB path.
// (e.g: \ALASKA\XPPW32\LIB). And link EVENTSPY.LIB to your application
greetings by OHR
Jimmy
Jimmy
Re: Creating logfile
Chris -
This is what DC_ReadGuiHandler() is for.
Below is some code from \exp19\samples\xdemo\xdemo.prg.
A global handler works in all threads, so it is the first thing called whenever any event occurs.
In the below sample, it is used to invoke the context help system and also to provide print screen routines.
You can add code to log menu or button activations like so:
If this is what you are looking for and you decide to go with this solution, I will give you the code to get a pointer to the GetList item for the object causing the event.
This is what DC_ReadGuiHandler() is for.
Below is some code from \exp19\samples\xdemo\xdemo.prg.
A global handler works in all threads, so it is the first thing called whenever any event occurs.
In the below sample, it is used to invoke the context help system and also to provide print screen routines.
You can add code to log menu or button activations like so:
Code: Select all
IF nEvent == xbeP_Activate
LogEvent( 'Button Activated', oXbp:caption )
ELSEIF nEvent == xbeP_ItemSelected
LogEvent( 'Menu Activated', GetCaption(oXbp,mp1,mp2)
Code: Select all
// Install global handler.
DC_ReadGuiHandler({|a,b,c,d,e,f|Xdemo_Handler(a,b,c,d,e,f)})
STATIC FUNCTION Xdemo_Handler( nEvent, mp1, mp2, oXbp, oDlg, aGetList )
LOCAL oPrintMenu, GetList[0]
IF nEvent == xbeP_Keyboard .AND. mp1 == xbeK_CTRL_P
IF Empty(oDlg)
oDlg := oXbp
DO WHILE !oDlg:isDerivedFrom('XbpDialog')
oDlg := oDlg:setParent()
ENDDO
ENDIF
DCSUBMENU oPrintMenu PARENT oXbp
DCMENUITEM 'Display Image in another Window' ;
ACTION {||DisplayImage(oDlg)} PARENT oPrintMenu
DCMENUITEM 'Print WYSIWYG (Current Object)' PARENT oPrintMenu ;
ACTION {||DC_PrintImage(oDlg,1)} ;
WHEN {||!oXbp:isDerivedFrom('XbpDialog')}
DCMENUITEM 'Print WYSIWYG (All TabPages)' PARENT oPrintMenu ;
ACTION {||DC_PrintImage(oDlg,2)} ;
WHEN {||oXbp:isDerivedFrom('XbpDialog')}
DCMENUITEM SEPARATOR PARENT oPrintMenu ;
DCMENUITEM 'Show Source Code for this Object' ;
ACTION {||DC_ShowSourceCode(oDlg)} ;
PARENT oPrintMenu
DCREAD GUI PARENT AppDeskTop() EXIT
oPrintMenu:popup( oDlg, {0,0}, 1 , XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN )
RETURN DCGUI_IGNORE
ENDIF
RETURN DC_HelpHandler( nEvent, mp1, mp2, oXbp, oDlg, GetList )
The eXpress train is coming - and it has more cars.
Re: Creating logfile
Roger,
Yes, this is what I'm looking for. I didn't knew that there was a possibility to have a global handler which is working in all threats.
Yes, this is what I'm looking for. I didn't knew that there was a possibility to have a global handler which is working in all threats.
Re: Creating logfile
I modified one of my sample programs to also write out Menu and Button activations to a log file.
Unzip the following file to your \exp19\samples\menu directory.
Pbuild MSGBOX.XPJ
Run MSGBOX.EXE and select the File -> Open Test Window.
A file name EVENTS.LOG will be created and any button pushed or menu item selected will be logged.
http://donnay-software.com:8080/support ... agebox.zip
Unzip the following file to your \exp19\samples\menu directory.
Pbuild MSGBOX.XPJ
Run MSGBOX.EXE and select the File -> Open Test Window.
A file name EVENTS.LOG will be created and any button pushed or menu item selected will be logged.
http://donnay-software.com:8080/support ... agebox.zip
The eXpress train is coming - and it has more cars.
Re: Creating logfile
Hi Roger,
Thanks for the sample. I will add it to my application.
Thanks for the sample. I will add it to my application.