Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / October 2005

Tip: Looking for answers? Try searching our database.

intercepting the F5 key

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kehlar - 28 Oct 2005 19:40 GMT
I would like to be able to intercept the F5 key so I can run some operations
before the debug session starts. Is there a way to do this? I have an addin
that listens for the WM_KEYUP event but it's not catching any.
Dustin Campbell - 29 Oct 2005 12:20 GMT
> I would like to be able to intercept the F5 key so I can run some
> operations before the debug session starts. Is there a way to do
> this? I have an addin that listens for the WM_KEYUP event but it's
> not catching any.

If you are using in add-in, the easiest way is to listen to the
EnvDTE.Commands.BeforeExecute event for the Debug.Start command. Here
is some C# add-in code that will do this:

private DTE dte;
private CommandEvents commandEvents;

public void OnConnection(object application, ext_ConnectMode
connectMode, object addInInst, ref Array custom)
{
 dte = (DTE)application;
 commandEvents =
dte.Events.get_CommandEvents("{5EFC7975-14BC-11CF-9B2B-00AA00573819}",
295); // Debug.Start command...
 commandEvents.BeforeExecute += new
_dispCommandEvents_BeforeExecuteEventHandler(ehBeforeDebugStart);
}
public void OnDisconnection(ext_DisconnectMode disconnectMode, ref
Array custom)
{
 commandEvents.BeforeExecute -= new
_dispCommandEvents_BeforeExecuteEventHandler(ehBeforeDebugStart);
 commandEvents = null;
 dte = null;
}

private void ehBeforeDebugStart(string Guid, int ID, object CustomIn,
object CustomOut, ref bool CancelDefault)
{
 // Do stuff here before Debug.Start executes...
}

Signature

Best Regards,
Dustin Campbell
Developer Express, Inc

kehlar - 31 Oct 2005 16:22 GMT
Thanks! That's exactly what I was looking for.

One more question: where do you find the GUIDs for the command events?
Somehow my event handlers are not been called eventhough the commandEvents
object was created successfully and CommandEvents::DispEventAdvise was called
for it (I'm writing this in C++). I want to make sure that I have the right
GUID.

> > I would like to be able to intercept the F5 key so I can run some
> > operations before the debug session starts. Is there a way to do
[quoted text clipped - 32 lines]
>   // Do stuff here before Debug.Start executes...
> }
Dustin Campbell - 31 Oct 2005 16:45 GMT
> One more question: where do you find the GUIDs for the command
> events?  Somehow my event handlers are not been called eventhough the
> commandEvents object was created successfully and
> CommandEvents::DispEventAdvise was called for it (I'm writing this in
> C++). I want to make sure that I have the right GUID.

The easy way is to simply set up your CommandEvents handlers to watch
for *all* commands and then check the Guid parameter when the event
fires. You can do this by passing null and 0 when calling
"get_CommandEvents":

dte.Events.get_CommandEvents(null, 0);

Then, just fire the command you're trying to find the command group
(guid) and id for and watch the parameters.

The comprehensive way is to look in the "stdidcmd.h" file that installs
with the Visual Studio SDK (formerly known as the VSIP SDK). If you
look in this file, you'll see that there are really only two GUIDs that
are used for standard Visual Studio shell commands:
CLSID_StandardCommandSet97 (5efc7975-14bc-11cf-9b2b-00aa00573819) and
CMDSETID_StandardCommandSet2K (1496A755-94DE-11D0-8C3F-00C04FC2AAE2).
The comments and this file can show you what commands belong to which
command group.

Signature

Best Regards,
Dustin Campbell
Developer Express, Inc

kehlar - 31 Oct 2005 18:11 GMT
Thanks, that worked perfectly!

> > One more question: where do you find the GUIDs for the command
> > events?  Somehow my event handlers are not been called eventhough the
[quoted text clipped - 20 lines]
> The comments and this file can show you what commands belong to which
> command group.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.