MSHTML Command Identifiers --------------------------------------------------------------------------------The following set of MSHTML command identifiers specify an action to take on the given object. They can be used with the IOleCommandTarget::Exec  and IOleCommandTarget::QueryStatus  methods.Command IdentifiersIDM_1D_ELEMENT Determines if an element is statically positioned. 
IDM_2D_ELEMENT Determines if an element is absolutely positioned. 
IDM_2D_POSITION Allows absolutely positioned elements to be moved by dragging. 
IDM_ABSOLUTE_POSITION Sets an element's position property to "absolute." 
IDM_ADDFAVORITES Prompts the user with a dialog box to add the current document, a hyperlink, or an image to the Favorites list. 
IDM_ADDTOGLYPHTABLE Adds an entry or entries to the glyph table, which specifies images to display for specific tags in design mode. 
IDM_ATOMICSELECTION When this command is issued in design mode, any element that has an ATOMICSELECTION attribute set to TRUE will be selectable only as a unit. 
IDM_AUTOURLDETECT_MODE Turns automatic URL detection on and off. 
IDM_BACKCOLOR Sets or retrieves the background color of the current selection. 
IDM_BLOCKDIRLTR Not currently supported. 
IDM_BLOCKDIRRTL Not currently supported. 
IDM_BLOCKFMT Sets or retrieves the current block format tag. 
IDM_BOLD Toggles the current selection between bold and nonbold. 
IDM_BOOKMARK Creates a book anchor or retrieves the name of a book anchor for the current selection or insertion point. 
IDM_BROWSEMODE Not currently supported. 
IDM_BUTTON Overwrites a button control on the current selection. 
IDM_CHECKBOX Overwrites a check box control on the current selection. 
IDM_CLEARSELECTION Clears the current selection. 
IDM_COMPOSESETTINGS Sets the default composition font settings for the MSHTML Editor. 
IDM_COPY Copies the current selection to the clipboard. 
IDM_CUT Copies the current selection to the clipboard and then deletes it. 
IDM_DELETE Deletes the current selection. 
IDM_DIRLTR Not currently supported. 
IDM_DIRRTL Not currently supported. 
IDM_DROPDOWNBOX Overwrites a drop-down selection control on the current selection. 
IDM_DYNSRCPLAY Not currently supported. 
IDM_DYNSRCSTOP Not currently supported. 
IDM_EDITMODE Not currently supported. 
IDM_EXECPRINT Not currently supported. 
IDM_FONT Opens a font dialog box to enable the user to change the text color, font, and font size of the current selection. 
IDM_FONTNAME Sets or retrieves the font for the current selection. 
IDM_FONTSIZE Sets or retrieves the font size for the current selection. 
IDM_FORECOLOR Sets or retrieves the foreground (text) color of the current selection. 
IDM_GETBLOCKFMTS Retrieves the strings corresponding to the available block format tags. 
IDM_GETFRAMEZONE IDM_GETFRAMEZONE returns the security zone of the current page in the web browser.  
IDM_HORIZONTALLINE Overwrites a horizontal line on the current selection. 
IDM_HTMLEDITMODE Enables the IDM_COMPOSESETTINGS command. 
IDM_HYPERLINK Inserts a hyperlink on the current selection, or displays a dialog box enabling the user to specify a URL to insert as a hyperlink on the current selection. 
IDM_IFRAME Overwrites an inline frame on the current selection. 
IDM_IMAGE Overwrites an image on the current selection. 
IDM_INDENT Increases the indent of the selected text by one indentation increment. 
IDM_INLINEDIRLTR Not currently supported. 
IDM_INLINEDIRRTL Not currently supported. 
IDM_INSFIELDSET Overwrites a box on the current selection. 
IDM_INSINPUTBUTTON Overwrites a button control on the current selection. 
IDM_INSINPUTHIDDEN Inserts a hidden control on the current selection. 
IDM_INSINPUTIMAGE Overwrites an image control on the current selection. 
IDM_INSINPUTPASSWORD Overwrites a password control on the current selection. 
IDM_INSINPUTRESET Overwrites a reset control on the current selection. 
IDM_INSINPUTSUBMIT Overwrites a submit control on the current selection. 
IDM_INSINPUTUPLOAD Overwrites a file upload control on the current selection. 
IDM_ITALIC Toggles the current selection between italic and nonitalic. 
IDM_JUSTIFYCENTER Centers the format block in which the current selection is located. 
IDM_JUSTIFYFULL Not currently supported. 
IDM_JUSTIFYLEFT Left-justifies the format block in which the current selection is located. 
IDM_JUSTIFYNONE Not currently supported. 
IDM_JUSTIFYRIGHT Right-justifies the format block in which the current selection is located. 
IDM_LISTBOX Overwrites a list box selection control on the current selection. 
IDM_LIVERESIZE Causes the MSHTML Editor to update an element's appearance continuously during a resizing or moving operation, rather than updating only at the completion of the move or resize. 
IDM_MARQUEE Overwrites an empty marquee on the current selection. 
IDM_MULTIPLESELECTION Allows for the selection of more than one site selectable element at a time when the user holds down the SHIFT or CTRL keys. 
IDM_OPEN Not currently supported. 
IDM_ORDERLIST Toggles the current selection between an ordered list and a normal format block. 
IDM_OUTDENT Decreases by one increment the indentation of the format block in which the current selection is located. 
IDM_OVERWRITE Toggles the text-entry mode between insert and overwrite. 
IDM_PARAGRAPH Overwrites a line break on the current selection. 
IDM_PASTE Overwrites the contents of the clipboard on the current selection. 
IDM_PRINT Prints the current document using either the default print template or a custom print template. 
IDM_PRINTPREVIEW Opens the Print Preview window for the current document using either the default print preview template or a custom template. 
IDM_RADIOBUTTON Overwrites a radio control on the current selection. 
IDM_REDO Not currently supported. 
IDM_REFRESH Refreshes the current document. 
IDM_REMOVEFORMAT Removes the formatting tags from the current selection. 
IDM_REMOVEPARAFORMAT Not currently supported. 
IDM_SAVEAS Saves the current Web page to a file. 
IDM_SELECTALL Selects the entire document. 
IDM_SIZETOCONTROL Not currently supported. 
IDM_SIZETOCONTROLHEIGHT Not currently supported. 
IDM_SIZETOCONTROLWIDTH Not currently supported. 
IDM_STOP Not currently supported. 
IDM_STRIKETHROUGH Not currently supported. 
IDM_SUBSCRIPT Not currently supported. 
IDM_SUPERSCRIPT Not currently supported. 
IDM_TEXTAREA Overwrites a multiline text input control on the current selection. 
IDM_TEXTBOX Overwrites a text control on the current selection. 
IDM_UNBOOKMARK Removes any book from the current selection. 
IDM_UNDERLINE Toggles the current selection between underlined and not underlined. 
IDM_UNDO Not currently supported. 
IDM_UNLINK Removes any hyperlink from the current selection. 
IDM_UNORDERLIST Toggles the current selection between an ordered list and a normal format block. 
IECMDID_CLEAR_AUTOCOMPLETE_FOR_FORMS Clears data saved in forms. 
--------------------------------------------------------------------------------© 2001 Microsoft Corporation. All rights reserved. Terms of use.

解决方案 »

  1.   

    多谢了,不过还是劳烦 jiangsheng 细讲讲,
    在具体实现时使用Postmessage(hwndofMyWindow,WM_COMMAND,IDM_...,0)可否,要不我先试试再说吧? 不行再问!
      

  2.   

    今天晕了,乱发帖子:(
    你这个问题要通过IWebBrowser2调用方法才行看看这个
    HOWTO: Get IHTMLDocument2 from a HWND Q249232
    --------------------------------------------------------------------------------
    The information in this article applies to:Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5, 5.5
      

  3.   

    然后看看这个
    从IHTMLDocument2 获得 IWebBrowser2接口MSDN Magazine
    C++Q&A
    Paul DiLascia 
    Download the code for this article: CQA0106.exe (60KB)
    Browse the code for this article at Code Center: LCTest Update 
     Q 
    I use the Active Accessibility SDK to obtain an IHTMLDoc-ument2 pointer from a window handle (HWND). Is there any way to obtain an IWebBrowser2 pointer from the IHTMLDocument2 pointer? I抳e tried QueryInterface on both the document pointer as well as the IHTMLWindow2 pointer without results. I also tried the IOmNavigator * from get_navigator on the HTMLWindow2 pointer. Any ideas? A 
    This is a common cause for COM consternation. You have the window, document, or browser and you know you should be able to get the others, but everywhere you turn, QueryInterface delivers a big fat NULL. The answer lies in the mysterious IServiceProvider whose job it is, well, to provide services. IServiceProvider is a great interface: it has only one method, QueryService. If you抮e using ATL smart pointers, it looks like this. First, you have to get the IServiceProvider.CComQIPtr<IServiceProvider> isp = pIHTMLDocument2;This does a QueryInterface on the document for IServiceProvider. Once you have it, you can get the browser like so.CComQIPtr<IWebBrowser2> iwb2;
    isp->QueryService(IID_IWebBrowserApp,
        IID_IWebBrowser2, (void**)&iwb2);      If all this seems confusing, there抯 a good reason for it. A cardinal rule of COM is that QueryInterface must always return an interface to the object queried. But the document doesn抰 implement IWebBrowser2; it only knows how to get the object that does. The document, browser, and window are all separate objects. In general, IServiceProvider is used whenever a bunch of separate but related COM objects together implement some kind of service. QueryInterface asks an object, do you implement this interface? QueryService tells a service provider, "get me whatever object implements this interface, please." With QueryService, the interface pointer returned may or may not be the same object as the one queried. Figure 6 illustrates the system. All the objects implement their various interfaces and store internal pointers to one another; IServiceProvider is your way to get whichever object implements a particular interface. IServiceProvider::QueryService chases the internal pointers to retrieve the object that implements the interface you want.
    Figure 6 Many Objects, One IServiceProvider      IServiceProvider is essential for navigating the DHTML object hierarchy. Say you抮e writing an ActiveX&reg; control and you want to navigate the object model. How do you do it? First, query your IOleClientSite for IServiceProvider like so:CComQIPtr<IServiceProvider> isp = pSite;then, once you have IServiceProvider, you can QueryService it for the application object.CComQIPtr<IWebBrowserApp> iwba;
    isp->QueryService(IID_IWebBrowserApp, 
        IID_IWebBrowserApp, (void **)&iwba); Now you can navigate the object hierarchy (the app object is at the top). If you want the Web browser, it抯 the same as before.CComQIPtr<IWebBrowser2> iwb2;
    isp->QueryService(IID_IWebBrowserApp, 
     IID_IWebBrowser2, (void **)&iwb2));       In all these examples, SID_SWebBrowserApp identifies the service, but you抣l often see code that uses IID_IWebBrowserApp as the service ID. Either will work, since <shlguid.h> #defines SID_SWebBrowserApp to IID_IWebBrowserApp, but for programming pedants SID_SWebBrowserApp is technically more correct, and more clear to anyone reading your code.
          By the way, if you抮e brave enough to implement some far-reaching colossal object system such as the DHTML object model (Lord help you!), then you should implement IServiceProvider too.
      

  4.   

    最后调用IWebBrowser的方法
    GoBack Navigates backward one item in the history list. 
    GoForward Navigates forward one item in the history list. 
    Navigate Navigates to a resource identified by a URL or to the file identified by a full path. 
    Navigate2 Navigates the browser to a location that might not be able to be expressed as a URL, such as a pointer to an item identifier list (PIDL) for an entity in the Microsoft&reg; Windows&reg; shell namespace. 
    Refresh Reloads the file that is currently displayed in the object. 
    Refresh2 Reloads the file that is currently displayed in the object. Unlike IWebBrowser2::Refresh, this method contains a parameter that specifies the refresh level. 
      

  5.   

    同意jiangsheng(蒋晟) 
    这个问题需要用COM,不是PostMessage那么简单的
      

  6.   

    多谢各位,我实际是用Delphi在做,所以想通过发送消息解决,这么说只能另谋出路了,好了,结帐!