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 / August 2005

Tip: Looking for answers? Try searching our database.

Undo/Redo

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Boni - 25 Aug 2005 11:15 GMT
Dear all,
what do I have to implement, in order to standard UnDo/Redo buttons goes
enabled, when my toolwindow is active? I can't find any example.Do I have to
make workaround and place an editor on my toolwindow and disable it's
visibility? Any easier solution?
Thank you,
Boni
Carlos J. Quintero [VB MVP] - 29 Aug 2005 14:52 GMT
When your toolwindow is active, you can manage it with DTE.UndoContext.Open,
performing your action(s) and calling Close. The Undo buttons are enabled
automatically.

Signature

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

> Dear all,
> what do I have to implement, in order to standard UnDo/Redo buttons goes
[quoted text clipped - 3 lines]
> Thank you,
> Boni
Boni - 30 Aug 2005 00:22 GMT
Dear Carlos,
You are saveing my life:). I placed DTE.UndoContext.Open in
GotFocusEventHandler of my window and made sure that it is really called.
Unfortunately the undo button stays disabled. As I understand I have to
place some undo actions into VS undo stack in order button goes enabled? How
would I do that? Is it documented somewhere? So far the only source of
information on UnDo, which I could find, is your great advices.
With big thanks,
Boni

> When your toolwindow is active, you can manage it with
> DTE.UndoContext.Open, performing your action(s) and calling Close. The
[quoted text clipped - 7 lines]
>> Thank you,
>> Boni
Boni - 30 Aug 2005 10:14 GMT
My problem is that my tool window is not related to any document. As far as
I understand the undo/redo actions must be in some relationship with a
document. But it is not my case.
Just an example, to demonstrate the problem (it is not*real* example, just
very demonstrative and  it has analogy to my problem). If you would place a
chess board on a tool windows and undo should undo last move how would you
do that? I don't know how to put "movement" actions in VS undo stack. Would
you somewhere in your program have alternative undo stack, and when undo
button pressed take actions from your stack? It is what I want to do. The
only problem, that the f+++ undo/redo buttons don't go enabled, they are
alwasy disabled when toolwindow active.
My next idea is to put a dummy invisible text buffer on a toolwindow (seems
to be a bit tricky from an addin) and then may be buttons go enabled, when I
change something in this buffer.But I also could not find an example how to
do that so far (seems that I will have to  try/error).
With best wishes,
Boni

Any help is greatly appreciated.
Kindly yours,
> Dear Carlos,
> You are saveing my life:). I placed DTE.UndoContext.Open in
[quoted text clipped - 17 lines]
>>> Thank you,
>>> Boni
Paul Skelton - 30 Aug 2005 14:52 GMT
Also try taking a look at IOleUndoManager.  You may be able to implement
your own undo manager for your tool window.  Using IOleUndoManager from
managed packages (C# or VB) is not that intuitive but it's possible.

> My problem is that my tool window is not related to any document. As far
> as I understand the undo/redo actions must be in some relationship with a
[quoted text clipped - 37 lines]
>>>> Thank you,
>>>> Boni
Boni - 30 Aug 2005 15:52 GMT
Hi Paul,
first of all thanks for the advice.
When I implemented undo manager (seems to be quite easy
http://www.codeproject.com/atl/undomgr.asp) how do I "attach" it to the
toolwindow?
Thank you very much,
Boni

> Also try taking a look at IOleUndoManager.  You may be able to implement
> your own undo manager for your tool window.  Using IOleUndoManager from
[quoted text clipped - 42 lines]
>>>>> Thank you,
>>>>> Boni
Boni - 30 Aug 2005 20:57 GMT
Dear all,
My idea now is to get UndoManager from VS
Dim _sp As Microsoft.VisualStudio.OLE.Interop.IServiceProvider =
VSCDesignerEntryObjects.ApplicationObject

hr = _sp.QueryService(GetType(IOleUndoManager).GUID, GetType(????).GUID,
objPtr)

Debug.Assert(hr = 0, "Failed to get undomgr")

Dim UndMgr As IOleUndoManager =
DirectCast(System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(resptr),
IOleUndoManager)

Then I could implement undounit and put it into undomanager.
Only problem that I need IID and SID of IOleUndoManager.
May be somebody of experts Garry, Carlos??? has an idea where to get it?
Am I on right way?
Thank you very much in advance,
Boni

> Hi Paul,
> first of all thanks for the advice.
[quoted text clipped - 51 lines]
>>>>>> Thank you,
>>>>>> Boni
Paul Skelton - 30 Aug 2005 23:14 GMT
Try this:

Guid undoManagerGuid = typeof(IOleUndoManager).GUID;

Guid undoManagerGuid2 = typeof(IOleUndoManager).GUID;

IntPtr undoManagerPtr = NullIntPtr;

int hr = m_serviceProvider.QueryService(ref undoManagerGuid2, ref
undoManagerGuid, out undoManagerPtr);

if ((hr == VSConstants.S_OK) && (undoManagerPtr != NullIntPtr))

{

m_undoManager =
(IOleUndoManager)Marshal.GetObjectForIUnknown(undoManagerPtr);

Marshal.Release(undoManagerPtr);

}

> Dear all,
> My idea now is to get UndoManager from VS
[quoted text clipped - 73 lines]
>>>>>>> Thank you,
>>>>>>> Boni
Boni - 31 Aug 2005 00:41 GMT
Hi Paul,
I already tried this.
return value of QueryService hr<>S_OK.
It seems, that other SID should be used.
Do you understand the architecture of VS undo? Do I have to implement
IOleUndoManager in my hostcontrol and VS will use it or is it a one global
UndoManager inVS and I have to request it somehow?
The main issue is that there is no docus (not in MSDN not on google)

> Try this:
>
[quoted text clipped - 96 lines]
>>>>>>>> Thank you,
>>>>>>>> Boni
Carlos J. Quintero [VB MVP] - 30 Aug 2005 10:22 GMT
Hi Boni,

Once you open an Undo Context calling DTE.UndoContext("My name"), all
actions in text documents such as EditPoint.Insert(), etc, are placed in a
single group in the undo stack until you call Close. Try first with a simple
add-in without windows, etc. until you get it, and then move back to your
actual scenario.

Signature

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

> Dear Carlos,
> You are saveing my life:). I placed DTE.UndoContext.Open in
[quoted text clipped - 5 lines]
> With big thanks,
> Boni

Rate this thread:







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.