Thread: Some questions regarding DLL's

  1. #1
    Registered User
    Join Date
    Dec 2005

    Some questions regarding DLL's

    Basically, I have to make a GUI that interacts with the user and based on things like the coordinates of the points where the user clicks, stores certain values in a set of data types defined by me. The datatypes have been defined in a seperate file in c++ style, ie, using classes. However I really dont want to implement the GUI using C++. Agree or not, C++ sucks at making GUI's. I prefer using VB. So what I thought was, to make a DLL of the user defined data types and then use the dll in VB. Unfortunately I am a novice at making dll's too. I did some research on the net. But I still dont have a clue about what to do when the dll contains things like classes. So please tell me some place where I can read about dll's.
    I am posting my code where I have defined the data types. Someone please tell me what differences will I have to make in the code to make it build-able as a dll...
    #ifndef _GRAPH_H
    #define _GRAPH_H
    #define INFINITE -1
    class Point
    	float _x, _y, _cost1, _cost2;
    	Point(float x, float y, float cost1 = 0, float cost2 = 0);
    class Graph
    	Point **points;
    	float **adj;
    	int capacity;
    	int *free;
    	int freeIndex;
    	int _size;
    	int size();
    	int insertPoint(Point *point);   //returns a pointHandle
    	bool deletePoint(int pointHandle);   //returns 0 if the pointHandle does not exist
    	bool editAdj(int pointHandle1, int pointHandle2, float weight);   //returns INFINITE if either of pointHandle1 and pointHandle2 doesnt exist or if weight is negative
    	Point point(int pointHandle);   //Blee
    	float showAdj(int pointHandle1, int pointHandle2);
    	bool editCost(int pointHandle, float cost1, float cost2);
    	Graph(int maxSize);
    Point :: Point(float x, float y, float cost1, float cost2)
    	_x = x;
    	_y = y;
    	_cost1 = cost1;
    	_cost2 = cost2;
    Graph :: Graph(int maxSize)
    	points = new Point *[maxSize];
    	free = new int[maxSize];
    	freeIndex = maxSize - 1;
    	adj = new float *[maxSize];
    	for (int i = 0; i < maxSize; i++)
    		adj[i] = new float[maxSize];
    		points[i] = NULL;
    		free[i] = maxSize - 1 - i;
    	_size = 0;
    	for (i = 0; i < maxSize; i++)
    		for (int j = 0; j < maxSize; j++)
    			adj[i][j] = INFINITE;
    	capacity = maxSize;
    int Graph :: insertPoint(Point *point)
    	if (freeIndex < 0) return INFINITE;
    	int i = free[freeIndex];
    	points[i] = point;
    	return i;
    bool Graph :: deletePoint(int pointHandle)
    	if (points[pointHandle] == NULL) return 0;
    	points[pointHandle] = NULL;
    	free[freeIndex] = pointHandle;
    	return 1;
    bool Graph :: editAdj(int pointHandle1, int pointHandle2, float weight)
    	if (points[pointHandle1] == NULL || points[pointHandle2] == NULL || weight < 0) return 0;
    	adj[pointHandle1][pointHandle2] = weight;
    	return 1;
    Point Graph :: point(int pointHandle)
    	Point p(0,0);
    	p = *points[pointHandle];
    	return p;
    float Graph :: showAdj(int pointHandle1, int pointHandle2)
    	return adj[pointHandle1][pointHandle2];
    bool Graph :: editCost(int pointHandle, float cost1, float cost2)
    	if (points[pointHandle] == NULL) return 0;
    	points[pointHandle] -> _cost1 = cost1;
    	points[pointHandle] -> _cost2 = cost2;
    	return 1;
    int Graph :: size()
    	return _size;

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Say what you want about making GUIs in C++, but making C++ and VB interoperate sucks infinitely more.

    You have two choices:
    1) Strict, simple procedural API using only POD structs and free functions.
    2) ActiveX.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Join Date
    Jan 2002
    >>So please tell me some place where I can read about dll's.<<

    Dynamic Link libraries
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Linking Library questions
    By Blackroot in forum C++ Programming
    Replies: 4
    Last Post: 10-11-2007, 03:04 AM
  2. Some doubts on DLLs
    By BrownB in forum Windows Programming
    Replies: 1
    Last Post: 05-30-2007, 02:25 AM
  3. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  4. standart dlls
    By keeper in forum C++ Programming
    Replies: 3
    Last Post: 07-05-2006, 07:32 PM
  5. Trivial questions - what to do?
    By Aerie in forum A Brief History of
    Replies: 23
    Last Post: 12-26-2004, 08:44 AM