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#
  4. Using Cadlib with C#

Using Cadlib with C#

Scheduled Pinned Locked Moved C#
csharpc++visual-studiocomgraphics
6 Posts 2 Posters 0 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.
  • R Offline
    R Offline
    Reanalyse
    wrote on last edited by
    #1

    I am slowly going nuts trying to make this work. I can compile the CADIO.dll in Visual Studio 2003, and have the exported functions list (from http://www.codeproject.com/library/cadlib.asp). I am trying to call the DLL using the sample code as below ___________________________________________________________________________ namespace BC_Imager { using System; using System.Windows.Forms; using System.Drawing; using System.Runtime.InteropServices; public class FormDXF : System.Windows.Forms.Form { [DllImport("CadIO.dll")] static extern bool drvCreate(string filename,bool overwrite); } } ____________________________________________________________________________ but having problems getting my head around how to use this DLL in C# to carry out the functions demonstrated in the test.cpp code. Can anyone please give me some pointers, especially in the use in C# of window items generated in MFC (i.e the progress and output "drawing" window in this DLL) Many Thanks for your help Regards

    R 1 Reply Last reply
    0
    • R Reanalyse

      I am slowly going nuts trying to make this work. I can compile the CADIO.dll in Visual Studio 2003, and have the exported functions list (from http://www.codeproject.com/library/cadlib.asp). I am trying to call the DLL using the sample code as below ___________________________________________________________________________ namespace BC_Imager { using System; using System.Windows.Forms; using System.Drawing; using System.Runtime.InteropServices; public class FormDXF : System.Windows.Forms.Form { [DllImport("CadIO.dll")] static extern bool drvCreate(string filename,bool overwrite); } } ____________________________________________________________________________ but having problems getting my head around how to use this DLL in C# to carry out the functions demonstrated in the test.cpp code. Can anyone please give me some pointers, especially in the use in C# of window items generated in MFC (i.e the progress and output "drawing" window in this DLL) Many Thanks for your help Regards

      R Offline
      R Offline
      Reanalyse
      wrote on last edited by
      #2

      Specifically I am trying to open a file using a call ________________________________________________________________________ string filetoget="H:\test.dxf"; [DllImport("CadIO.dll")] static extern bool drvLoadDataFromFile(IntPtr boxhandle,IntPtr NULL, IntPtr NULL ,string filetoget); ________________________________________________________________________ But C# complains "The parameter name 'NULL' is a duplicate" the C++ DLL Exported Interface is BOOL drwLoadDataFromFile( HDRAWING hDrawing, // handle to the current DRAWING structure OBJHANDLE BlockObjhandle, // handle of block that entities must be put in it. (NULL = Entity Section) DWORD Reserved, // reserved, must be 0 LPCTSTR strFileName // input file name (Can not be NULL) ); Thanks in advance

      R 1 Reply Last reply
      0
      • R Reanalyse

        Specifically I am trying to open a file using a call ________________________________________________________________________ string filetoget="H:\test.dxf"; [DllImport("CadIO.dll")] static extern bool drvLoadDataFromFile(IntPtr boxhandle,IntPtr NULL, IntPtr NULL ,string filetoget); ________________________________________________________________________ But C# complains "The parameter name 'NULL' is a duplicate" the C++ DLL Exported Interface is BOOL drwLoadDataFromFile( HDRAWING hDrawing, // handle to the current DRAWING structure OBJHANDLE BlockObjhandle, // handle of block that entities must be put in it. (NULL = Entity Section) DWORD Reserved, // reserved, must be 0 LPCTSTR strFileName // input file name (Can not be NULL) ); Thanks in advance

        R Offline
        R Offline
        Reanalyse
        wrote on last edited by
        #3

        Think I have cracked it - I needed to pass variable not constants The code [DllImport("CadIO.dll")] static extern bool drvLoadDataFromFile(IntPtr boxhandle,IntPtr NULL, int nonum ,string filetoget); compiled OK, whether it will work at runtime is another matter :sigh:

        R 1 Reply Last reply
        0
        • R Reanalyse

          Think I have cracked it - I needed to pass variable not constants The code [DllImport("CadIO.dll")] static extern bool drvLoadDataFromFile(IntPtr boxhandle,IntPtr NULL, int nonum ,string filetoget); compiled OK, whether it will work at runtime is another matter :sigh:

          R Offline
          R Offline
          Reanalyse
          wrote on last edited by
          #4

          Well for the calls _______________________________________ [DllImport("CadIO.dll")] static extern bool drwCreate(); [DllImport("CadIO.dll")] static extern bool drwLoadDataFromFile(IntPtr boxhandle,int npoint,int nonum ,string filetoget); [DllImport("CadIO.dll")] static extern bool drwInitView(int top1,int left1, int bottom1, int right1); [DllImport("CadIO.dll")] static extern int drwPaint(IntPtr boxhandle); ___________________________________________________ And calling it with ____________________________________________________ private void button1_Click(object sender, System.EventArgs e) { bool step1=drwCreate(); bool step2=drwLoadDataFromFile(dxfBox.Handle, 0 ,0,"H:\test.dxf"); bool step3=drwInitView(1,1,200,300); } __________________________________________________________ worked OK for step 1 -drwCreate() but returned false (no exceptions though) but returned faklse for steps 2 & 3

          R 1 Reply Last reply
          0
          • R Reanalyse

            Well for the calls _______________________________________ [DllImport("CadIO.dll")] static extern bool drwCreate(); [DllImport("CadIO.dll")] static extern bool drwLoadDataFromFile(IntPtr boxhandle,int npoint,int nonum ,string filetoget); [DllImport("CadIO.dll")] static extern bool drwInitView(int top1,int left1, int bottom1, int right1); [DllImport("CadIO.dll")] static extern int drwPaint(IntPtr boxhandle); ___________________________________________________ And calling it with ____________________________________________________ private void button1_Click(object sender, System.EventArgs e) { bool step1=drwCreate(); bool step2=drwLoadDataFromFile(dxfBox.Handle, 0 ,0,"H:\test.dxf"); bool step3=drwInitView(1,1,200,300); } __________________________________________________________ worked OK for step 1 -drwCreate() but returned false (no exceptions though) but returned faklse for steps 2 & 3

            R Offline
            R Offline
            rrace
            wrote on last edited by
            #5

            This is an old code, but did you get the CadIO.dll to work with C#. I am trying now and any help would be appreciated.

            R 1 Reply Last reply
            0
            • R rrace

              This is an old code, but did you get the CadIO.dll to work with C#. I am trying now and any help would be appreciated.

              R Offline
              R Offline
              Reanalyse
              wrote on last edited by
              #6

              No - sorry :( - was not able to easily do this. As this was for a work initiative I bought Cadlib from Woutware- the cost of my time was worth more that the purchase price. Regards

              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