473,586 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Undo on InternetExplore r

I am still trying to get the Undo function work on Internet Explorer editor
hosted as activex in my c# application.

Some time ago I've found a note at msdn that says "undo is not supported". I
gave up.

But lately I've downloaded LutzRoeder Writer that makes use of undo
function. I've looked at the code and it turns out that it uses
IOleCommandTarg et interface to invoke this command.

Because I cannot get it to work, I have questions:

1. is it a good way to follow? the undo does not work when invoked by
execCommand on IHtmlDocument. is there a chance that it will work with
IOleCommandTarg et then?

2. after few days of fighting, digging through msdn and the groups archive,
I've came up with following code but it still does not work. when asking for
CanUndo I always get 0.

could anyone share his/her experiences with me and tell me where the problem
could be? I can send the full source code of my webbrowser control if
needed.
thanks in advance,

Wiktor Zychla

----------------------------------------------------------------------------
---

public class MyWebBrowser
{
// the rest of the code is not here
public enum MiscCommandTarg et

{

Find = 1, ViewSource = 2, Options = 3, Undo = 43

}

internal int GetCommandInfo( MiscCommandTarg et commandId )

{

OLECMD[] ole = new OLECMD[1];

ole[0] = new OLECMD();

ole[0].cmdID = (int)commandId;

OLECMDTEXT ret = new OLECMDTEXT();

((IOleCommandTa rget)Document). QueryStatus( ref cmdGuid, 1, ole, ret );

return ( (int)ole[0].cmdf >> 1 );

}

internal bool IsEnabled( MiscCommandTarg et commandId )

{

return ( (this.GetComman dInfo( commandId ) & 1) != 0);

}

internal object Execute( MiscCommandTarg et command )

{

return this.Execute( command, null );

}

internal object Execute( MiscCommandTarg et command, object[] arguments )

{

object[] array = new object[1];

int n = ((IOleCommandTa rget)Document). Exec( ref cmdGuid, (int)command,
2, ref arguments, ref array );

if ( n != 0 )

{

MessageBox.Show ( string.Concat( "Execution of MSHTML command ID '",
command, "' failed.") );

}

return array[0];

}

public bool CanUndo

{

get

{

return this.IsEnabled( MiscCommandTarg et.Undo);

}

}

public void Undo()

{

if ( this.CanUndo ) this.Execute( MiscCommandTarg et.Undo );

}

}

[StructLayout(La youtKind.Sequen tial)]

public struct OLECMD

{

public int cmdID;

public int cmdf;

}

[StructLayout(La youtKind.Sequen tial, CharSet=CharSet .Unicode)]

public struct OLECMDTEXT

{

public int cmdtextf;

public int cwActual;

private int cwBuf;

[MarshalAs(Unman agedType.ByValT Str, SizeConst=256)]

public string text;

}

[ComImport, Guid("b722bccb-4e68-101b-a2bc-00aa00404770"),
InterfaceType(C omInterfaceType .InterfaceIsIUn known)]

public interface IOleCommandTarg et

{

[PreserveSig()]

int QueryStatus(ref Guid pguidCmdGroup,

int cCmds,

[In(), Out()]

OLECMD[] prgCmds,

[In(), Out()]

OLECMDTEXT cmdText );

[PreserveSig()]

int Exec(ref Guid pguidCmdGroup, int nCmdId, int nCmdExecOpt, ref object[]
pvaIn, ref object[] pvaOut);

}

Nov 15 '05 #1
0 1262

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2666
by: Lyn | last post by:
Hi, I have a text control on a form which is bound to table field StartDate which is in Date format. When updating the table record via the form, any data entered into the StartDate control is immediately validated. If the data entered is considered valid, focus moves to the next control in the tab sequence. So far, so good. If the data...
3
8046
by: Tom | last post by:
Hi, I wrote the following code in a c# winform. InternetExplorer ie = new InternetExplorer(); ie.Navigate(url, ref o, ref o, ref o, ref o); The url can be passed to the IE. However, how can I know that the url can be successfully
0
1014
by: Afigels | last post by:
I have an asp.net application that has references to MSHTML and SHDocVw to automate InternetExplorer from asp.net page. It works fine at the originating PC where the page was coded and compiled. But when i copy the application files to another PC -- application fails at the following line > SHDocVw.InternetExplorer wb = new...
4
3287
by: Lars-Erik Aabech | last post by:
Hi! I've been walking in extacy since reading the article about test automation with IE in the latest MSDN mag. (http://msdn.microsoft.com/msdnmag/issues/05/10/TestRun/default.aspx) After a while, I had to find an issue I couldn't solve. (Of course) If an ASP.NET page uses the smartnav option, the document you get from IE only contains...
0
10135
by: mammucion | last post by:
Trying to automate processing 80,000 data sets through 15 web pages. Application URL creates a new IE instance in which runs first a login form and then runs the rest of the pages in the new window. I can connect to a running Excel instance and obtain information from the Excel DOM. I cannot do the same with Internet Explorer. However, I can...
4
3401
by: Dick Sutton | last post by:
I am so close, yet oh so far! Here's the problem: I want to load a string variable that contains HTML into an instance of SHDocVw.InternetExplorer. Here's what I have so far: Function ShowMonTaxes(ByVal bTax As Boolean) As Integer Dim oIE As New SHDocVw.InternetExplorer ' set Internet Explorer properties... oIE.Left = 225 oIE.Top = 75
8
3756
by: Ludwig Wittgenstein | last post by:
Hi, all. How can i hook up an InternetExplorer object to a WebBrowser control that I have in my windows form. Basically what I want to do is automate the WebBrowser control via the InternetExplorer object (instead of loading iexplorer.exe externally...). Thanks,
4
1583
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, Does vb2005 have a built-in UnDo feature / object for applications so that I can undo actions like other windows apps? Or do I have to write my own UnDo routine? If vb2005 does have a builtin Undo feature / object / command -- how to implement it? invoke it? If there is no builtin undo feature - is there a recommended way to...
1
1634
by: Jeremy | last post by:
I'm working on an application that does some DOM manipulation. I want to add a mechanism for "Undo" so that the user can revert to the previous state after performing a mistaken action. Simple idea, not necessarily simple to implement. My first idea for this is to use closures and an array that tracks the inverse of the user's actions. ...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.