📄 runnodebug.html
字号:
<HTML>
<HEAD><TITLE>Delphi Expert that will allow you to run your project without debug info</TITLE></HEAD>
<BODY>
<font face="Verdana" size="2">
<h1>Delphi Expert - Run your project without debug info</h1><br>
By <a href="mailto:shenoy@agnisoft.com">Deepak Shenoy</a><p>
As a Delphi programmer you might have felt the need, as I did, to run a
program without debug information...just run the program, without Delphi
having to go into Debug mode.
<p>
Going into debug mode has its disadvantages: you can't use the object browser,
your oh-so-useful ctrl+click doesn't work, and code insight is disabled.
But why do you ever need to run a program without going into debug mode? I'll give you my reasoning.
<ul>
<li>Sometimes my program's user interface needs that little bit of tweaking (left align, sizing etc.)
and I just need to see my program running to see it happen. At the same time I need to change some
code here and there, and I need the Ctrl+Click stuff happening.
<li> I need to be able to see what's happening inside of an external trace program
(GExperts' Log Window etc.). Especially when I'm doing some custom painting or OnSetFocus handlers,
in which case any debug time breakpoints would just keep triggering again and again.
<li>I use project groups quite often...in this scenario, I end up having to run one program
while coding another - I end up running it from Windows Explorer and then writing the code.
</ul>
Steve T. came up with an expert that adds an option called "Run without debugging" -
an option that allows you to run without debug info.
You can find the expert at: <a href="http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=16377" >
http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=16377</a>. Unfortunately this doesn't come with
source code since it's compiled using some internal IDE packages we don't have access to. So, as a programmer with
too much time in a stuffy airport, I decided to see if I could write one on my own.
<p>
I found out that a "Run without Debugging" menu option is already there in Delphi!
While running our program (note: shameless plug coming up) Eyespy (<a href="http://www.agnisoft.com/hawkeye/es.asp" target="_new">
http://www.agnisoft.com/hawkeye/es.asp</a>) I noticed a menu item called RunRunNoDebugItem which was not visible (visible=FALSE).
So I thought it might be possible to enable this item by simply setting visible=TRUE ... which turned out to work
perfectly! And it's so easy that I couldn't wait to get this expert done. Here's how you can do it too.
<p>
The Expert is quite simple. Let's create a new package using File | New | Other | Package.
Save it in some directory, and then you can create a new unit (File|New|Unit) and
save it in the same directory. Add a procedure called Register (case sensitive) and then write this code in it.
<pre class="SourceCode">
<font size="2">
<b>procedure</b> Register;
<b>var</b>
RunNoDebugItem : TComponent;
<b>begin</b>
RunNoDebugItem := (BorlandIDEServices <b>as</b> INtaServices).MainMenu.Owner.FindComponent(<font color="#9933CC">'RunRunNoDebugItem'</font>);
<b>if</b> RunNoDebugItem <> <b>nil</b> <b>then</b>
(RunNoDebugItem <b>as</b> TMenuItem).Visible := TRUE;
<b>end</b>;
</font>
</pre>
(Note: you need to add Toolsapi to your uses clause and then add $(DELPHI)\Source\Toolsapi to your package's search directories.
<p>
That's it. Really. All you need to do is install the package (you might get warnings that ask you
to add designide and vcl to the requires clause, just click ok and recompile) and your Run
Menu will now have an item called "Run without debugging". <br>
(Note:Adding a keyboard shortcut to it is quite simple but I'm too lazy to do it right now)
<p>
This is what your Run Menu should now look like :<br>
<img src="Delphimenu.jpg">
<br>
Notice the "Run without Debugging" menu? [duh]
<p>
The code is quite simple to understand. BorlandIDEServices is a global variable that you can use to access
any of the IDE components using the Open Tools API. What we need here is the MainMenu and it's
owner (TAppBuilder) so we'll get the INTAServices interface, get it's main menu, find the sub menu
by using FindComponent and set it's Visible = TRUE.
<p>
(The reason why I needed to use MainMenu.Owner is that the sub item is owned by the MainForm
(A class called TAppBuilder) rather than by the menu itself)
<p>
You can download all the code for this project at <a href="http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=16431">
http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=16431</a>.
<p>
<I><B>Deepak Shenoy</B>(<A href="mailto:shenoy@agnisoft.com">shenoy@agnisoft.com</A>) is a Director at <A
href="http://www.agnisoft.com">Agni Software</A>, a software company in India
that offers consultancy and offshore development solutions. It might be a while before his hair gets pointy
so he's allowed to understand some technology.
</font>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -