...if you set a breakpoint and right click on it (in the editor gutter) to display the context menu you can select "Breakpoint properties..."H
ave you ever tried debugging GUI code where focus changes cause code to execute that you didn't want executed? This is a fairly standard GUI debugging problem and one that Mark Edington (of Delphi
R&D) recently discussed
relating to debugging drag/drop code in the VCL. Having written a custom menuing system (in ActionBands) I've had my fair share of this type of debugging as well. I was helping Mark debug the above drag/drop problem and it occurred to me that it might be useful to mention a few breakpoint debugger features in our IDE that are likely overlooked by a lot of people.
For example, if you set a breakpoint and right click on it (in the editor gutter) to display the context menu you can select "Breakpoint properties..." (where you even aware of this menu item? :) ) that displays a dialog with various properties controlling how the breakpoint will function. There are many useful properties on this dialog which I'm not going to discuss here and you can read about them in the online help however, the ones that I'd like to point out I think are particularly useful for GUI debugging situations:
- The Pass count property allows you to set a value which represents the number of times execution passes this breakpoint before stopping.
- If you click the "Advanced" button you can see a "Break" checkbox that indicates whether or not the debugger will actually break at this breakpoint. Now, you might be asking what good is a breakpoint that does not break? Well, it can be good for lots of things and one of which is outputing useful debugging information. Just below the Break checkbox is a Log Message dropdown which causes whatever you've typed to be sent to the Event Log whenever the breakpoint is hit. One advantage of this is you don't have to litter your code with lots of OutputDebugString calls.
- Another option is Eval Expression dropdown which will cause whatever expression you've entered to be evaluated where the results can also be viewed via the Event Log.
I realize for some people this is probably old news but perhaps there are at least a few people who can benefit.