Thread: trying to make a VS addin

  1. #1
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102

    trying to make a VS addin

    I am trying to learn how to make VStudio addins and am a little new to the COM objects, I'd like to know if I'm doing this at all right, I had to modify the code created by the wizard by adding the typecast (LPVOID*) and (IDispatch**) which I just added by a guess. I created a project using the addin wizard with minimum features to simplify the code. Just to start off if I want to make the cursor backspace 2 spaces. This is the code I've got(in Commands.cpp), followed by the error I get when I build.


    PHP Code:
    STDMETHODIMP CCommands::TestCommandMethod() 
    {
        
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

        
    // TODO: Replace this with the actual code to execute this command
        //  Use m_pApplication to access the Developer Studio Application object,
        //  and VERIFY_OK to see error strings in DEBUG builds of your add-in
        //  (see stdafx.h)



        
    IGenericDocumentpDoc;
    m_pApplication->get_ActiveDocument((IDispatch**)&pDoc);
    BSTR bstrType;
    pDoc->get_Type(&bstrType);
    if (!
    wcscmp(bstrTypeL"Text"))
    {
       
    // It is a text document, 
       // ..so QI for the right interface
       
    ITextSelectionpTextDoc;
       
    pDoc->QueryInterface(IID_ITextSelection, (LPVOID*)&pTextDoc);

       
    pTextDoc->Backspace(2);
       
    // Now, we can use text-specific
       //   members of pTextDoc
       
    pTextDoc->Release();
    }
    SysFreeString(bstrType);
    pDoc->Release();



        return 
    S_OK;



    The error:
    --------------------Configuration: test - Win32 Debug--------------------
    Compiling...
    Commands.cpp
    C:\test\Commands.cpp(62) : error C2664: 'Backspace' : cannot convert parameter 1 from 'const int' to 'struct tagVARIANT'
    No constructor could take the source type, or constructor overload resolution was ambiguous
    Error executing cl.exe.

    test.dll - 1 error(s), 0 warning(s)

    This is the object model thing for the backspace method.
    I don't understand what STDMETHOD, THIS_ VARIANT, or the PURE things do. I'm confused and really would like to learn how to use this stuff.

    STDMETHOD(Backspace)(THIS_ VARIANT Count) PURE;
    WebSnozz-
    Cats have no butt cheeks.
    If one farted, then it would make a flute noise.

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Don't crosspost

  3. #3
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102
    I don't know how to not do something if I don't know what that something is.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Crossposts are posts that are put in more than one forum.......

    Annoying as hell against board rules

  5. #5
    Unregistered
    Guest
    sorry

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 09:51 PM
  2. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  3. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 01:05 PM
  4. Replies: 6
    Last Post: 04-20-2002, 06:35 PM