Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. VC++ ActiveX

VC++ ActiveX

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcsharphtmlcom
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wender Oliveira
    wrote on last edited by
    #1

    I hate to be a newbie but I need this. I made an ActiveX that its only function is return a string with some information of client PC but this doesn't matter ... the problem is... When I invoke my method in my HTML file my method doesn't return any string... I don't know how to make this but I tried by this way: /****** IDL FILE *********/ dispinterface _DMyActiveX { properties: methods: [id(60666)] char* GetString(); }; /******Control CPP File*******/ BEGIN_DISPATCH_MAP(CMyActiveXCtrl, COleControl) DISP_FUNCTION_ID(CMyActiveXCtrl, "GetString", 60666, GetString, VT_EMPTY, VTS_NONE) END_DISPATCH_MAP() char* CMyActiveXCtrl::GetString() { return "TestString\0"; } /******** CONTROL H FILE *****/ // Dispatch maps DECLARE_DISPATCH_MAP() afx_msg char* GetString(); /************************************************************/ This is what I changed on original VC++ files... this method works as well to show an MessageBox or an Dialog but it doesn't to just return a string... I don't know the reason... maybe the afx_msg... Can anyone help me??? Thanks!!!! :confused::confused::confused: Wender Oliveira .NET Programmer

    T 1 Reply Last reply
    0
    • W Wender Oliveira

      I hate to be a newbie but I need this. I made an ActiveX that its only function is return a string with some information of client PC but this doesn't matter ... the problem is... When I invoke my method in my HTML file my method doesn't return any string... I don't know how to make this but I tried by this way: /****** IDL FILE *********/ dispinterface _DMyActiveX { properties: methods: [id(60666)] char* GetString(); }; /******Control CPP File*******/ BEGIN_DISPATCH_MAP(CMyActiveXCtrl, COleControl) DISP_FUNCTION_ID(CMyActiveXCtrl, "GetString", 60666, GetString, VT_EMPTY, VTS_NONE) END_DISPATCH_MAP() char* CMyActiveXCtrl::GetString() { return "TestString\0"; } /******** CONTROL H FILE *****/ // Dispatch maps DECLARE_DISPATCH_MAP() afx_msg char* GetString(); /************************************************************/ This is what I changed on original VC++ files... this method works as well to show an MessageBox or an Dialog but it doesn't to just return a string... I don't know the reason... maybe the afx_msg... Can anyone help me??? Thanks!!!! :confused::confused::confused: Wender Oliveira .NET Programmer

      T Offline
      T Offline
      TimWallace
      wrote on last edited by
      #2

      Maybe since you are not "really" allocating any memory to set the return value, the string value gets cleaned up when the method exits. Try allocating some memory and setting it to the value you want. Do not forget to free the memory when the callee is done using the value.

      W 1 Reply Last reply
      0
      • T TimWallace

        Maybe since you are not "really" allocating any memory to set the return value, the string value gets cleaned up when the method exits. Try allocating some memory and setting it to the value you want. Do not forget to free the memory when the callee is done using the value.

        W Offline
        W Offline
        Wender Oliveira
        wrote on last edited by
        #3

        I didn't understood... I really haven't experience with C++ and this is the reason that I don't know how to make what you said... Can you show me an example? I changed the method to: void CMacAddressCtrl::GetMacAddress() { MessageBox("TestString"); } and it works as well... But when I try to return the char* it returns ... Wender Oliveira .NET Programmer

        N 1 Reply Last reply
        0
        • W Wender Oliveira

          I didn't understood... I really haven't experience with C++ and this is the reason that I don't know how to make what you said... Can you show me an example? I changed the method to: void CMacAddressCtrl::GetMacAddress() { MessageBox("TestString"); } and it works as well... But when I try to return the char* it returns ... Wender Oliveira .NET Programmer

          N Offline
          N Offline
          Nick Parker
          wrote on last edited by
          #4

          Wender Oliveira wrote: I really haven't experience with C++ Starting out in C++ with an ActiveX control probably isn't the best path, IMHO. - Nick Parker
          My Blog | My Articles

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups