Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hallo

 

I am working in VB.NET, and I want to write a DLL for Visual C++. It works in VB.net (Create a DLL and use it in VB.NET) but in Visual C++, It does not recognize a function.

 

This is a code.

 


Imports System.Drawing

Public Class clsMyClass
       Private mMyName As String

       Property MyName() As String
               Get
                       MyName = mMyName
               End Get
               Set(ByVal Value As String)
                       mMyName = Value
               End Set
       End Property

       Public Function GetDate() As String
               ' Return today's date
               Return "Today is " & Today
       End Function

       Public Sub DrawResult(ByRef Obj As Windows.Forms.Panel, _
                ByRef TotalHit As Integer, _
                ByRef RightHit As Integer, _
                ByRef FormObj As Windows.Forms.TabPage)

               Obj.Visible = False

               ' Get a Graphics object from the current form and clear its background.

               Dim gr As Graphics = FormObj.CreateGraphics

               Dim mPen As New Pen(Color.White, 2)
               Dim mPen2 As New Pen(Color.RoyalBlue.Black, 1)

               Dim TotalProzent, Total2 As Integer


               Dim rr As New Rectangle(Obj.Left, Obj.Top, Obj.Width, Obj.Height)
               gr.FillRectangle(Brushes.White, rr)
              
               TotalProzent = Int(RightHit / TotalHit * 360)

               ' Draw a green filled rectangle.

               Dim x, y, mWidth, mHeight, StartAngle, SweepAngle As Integer

               x = Obj.Left + 10
               y = Obj.Top + 10
               mHeight = Obj.Height - 20
               mWidth = Obj.Width - 20

               ' Draw a red pie (portion of an ellipse).
               Dim i, j As Integer
               For i = 0 To TotalProzent
                       gr.FillPie(Brushes.Blue, x, y, mWidth, mHeight, 0, i)
               Next


               gr.DrawPie(mPen2, x, y, mWidth, mHeight, 0, TotalProzent)

               Total2 = 360 - TotalProzent

               For i = 0 To Total2
                       gr.FillPie(Brushes.Red, x, y, mWidth, mHeight, TotalProzent, i)
               Next

               gr.DrawPie(mPen2, x, y, mWidth, mHeight, TotalProzent, Total2)
               gr.Dispose()
               
       End Sub


End Class

 

Please help me.

  • *Experts*
Posted

If this is for a managed C++ project, you're in luck! Just add a reference to the VB.NET DLL (or project, if both projects are in the same solution)!

 

If this is for unmanaged C++, you're outta luck, mostly. You can probably wrap the VB.NET code as a COM object and create/use the object from unmanged C++, but that's a LOT of work.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
If this is for a managed C++ project, you're in luck! Just add a reference to the VB.NET DLL (or project, if both projects are in the same solution)!

 

If this is for unmanaged C++, you're outta luck, mostly. You can probably wrap the VB.NET code as a COM object and create/use the object from unmanged C++, but that's a LOT of work.

 

-ner

 

You have a bit more options. Some of the things that come to mind is creating a mixed mode c++ dll, or using the gcroot template

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...