Dear Ash, Thank you for such a detailed answer, at first i thought i can have data set and implement different operations on that data set (Area, Perimeter and some clipping operations) Defining an interface and hide the data in concrete classes and use interface functions to operate on is another perhaps better way. I had already looked into below link. Mature Approach part is similar to yours except virtual destructor is replaced by a Release() method and Smart Pointer calls that function for clean-up. HowTo: Export C++ classes from a DLL[^] Again thank you for the answers. Best Regards.
beko
Posts
-
DLL and STL in function parameters -
DLL and STL in function parametersHi Moak, I was about to write that function and ask :) and saw your message. When I use, then i can safely give the vector's first element as reference to the function and vector's size.
std::vector points;
....if(!points.empty())
calcPerimeter(&points[0], static_cast(points.size());Best Regards. Bekir.
-
DLL and STL in function parametersThank you for the answers. I will look at options to remove that STL vector, any recommendations ? Bekir.
-
DLL and STL in function parametersHello, I wanted to move the implementation of some of my functions to a DLL and update only the DLL and do not touch the GUI.I normally use STL and i learnt that STL and DLLs together can create some problems. Lets say i have such a function below and that Point3D vector will be given from another DLL (which deals IO stuff). 1. DLL
TEST_API double calcPerimeter(const std::vector<Point3D>& pts)
{
double p = 0.0;
for(std::size_t i = 1; i < pts.size(); ++i)
p+= calcDistance(pts[i-1],pts[i], false);p = sqrt(p); return p;
}
2. DLL i want to export a std::vector from a function. Will this work or even if it works under what conditions? By the way, I will use the same compiler for exe and dlls. How will you implement above? (a very simple data holder (Point3D vector) in a DLL and in another DLL just bunch of functions which operates on that data? Best Regards. Bekir.
-
Resolution for Dialog -
truncating floatHello i use the following in order to truncate a double value (found somewhere and modified :) ) However you must be careful in here, because there could be an overflow in double fac = Num/Seed
#include <math.h>
#include <stdio.h>double truncate(double Num, double Seed)
{
// get rational factor
double fac = Num / Seed;// get natural factor fac = (fac < 0) ? (ceil(fac)) : (floor(fac)); // fac = (fac < 0) ? static\_cast<int>(fac-0.5) : static\_cast<int>(fac+0.5); // return multiple return fac \* Seed;
}
int main()
{
double val = 4./3.;printf("%6.4f\\n",truncate(val,1e-04)); return 0;
}
-
Running a windows service in Windows7I do not know if this is the right place to ask this question but, I have written a windows service which polls serial port for serial activity and an input device writes out the port with some time interval. In other words, whenever a write occurs, the service reads and process that and make available to another program. Since it would be a waste of time and resource to poll the port all the time, i was starting the service when the main application is running and stopping it when the program exits. However, this scenario does not work for Windows7 and i could not test it but probably for vista as well. I used OpenSCManager with CONNECT but cannot open the service with SERVICE_START or SERVICE_STOP privilege. any idea, how can this be solved? (I am currently reading some UAC stuff but have not found something yet) Best Regards
-
Render multiple object in single viewHello, you can define a draw function for each object in its class, and make that class inherited from an interface. class Object { ..... virtual void draw() = 0; .... }; class Circle : public Object { virtual void draw() {} }; and call each objects'draw method in the view. you may also want to look at the visitor pattern. Hope this helps. Bekir.
-
version changeHello If you are just using standard features which are also available with VS2005, just change version number to 8.0 and also do relative changes and apply the same for vcproj file (just version number change,etc.). I learnt this in here from someone couple of weeks ago and it is working for me so far. Hope this helps. Bekir.
-
Writing a similar function as ComboBox SelectStringThank you, this is what i was looking for :thumbsup: Bekir.
-
Writing a similar function as ComboBox SelectStringHello, I have a STL map and string values as the key values However recently, i want to search this map as it is like auto-complete ComboBox. For example,I have keys in the map as such Apple, Pearl, Orange. When i enter 'A' i want to return Apple from the map. I know that i can iterate thorough each map object and compare its key, but i think that would inefficient. Any ideas ? Bekir.
-
calculate polygon area and its centre in 3dThank you, i will try that and i think it will solve the problem but it will create a bit of overhead. Bekir.
-
calculate polygon area and its centre in 3dHello, I have some 3d points (not self intersecting). the shape of the points is looking like / (forward slash) from profile, It is actually a slice of a 3d object, cut with a rotated plane. I want to calculate the area of 3d points and its centre. For 2d case, i use the following http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/[^] but, how can i extend the 2d case to 3d for area and its centre? Thanks in advance. Bekir.
-
Regarding application expirationHello, Either limit the number of days also or if you are providing a license, do not proceed if the supplied date is earlier than the start date of the license. You could also use both, if you want it. The only drawback of this approach is that, if the user changes the date to an earlier date for any purpose (reports :)), and mistakenly opened your program also, he/she would be pissed off ;P . Bekir.
-
Regarding application expirationHello, you can save the current date every time the program runs, so you can check against the date for alterations. Hope this helps Bekir.
-
GetProfileString creates a key automaticallyHello, I am using GetProfileString to read from registry, the registry keys are created via setup and i should check if there is an option set, and the program should act accordingly. For example; MyApplication Data Data01 I have to check if Data01 available, if yes then read its setting from the registry, otherwise do the default handling. However when i check if Data01 available, GetProfileString creates that entry for me :), if that entry is there no problem but if it is not, then it automatically creates. You can see how i am trying to check.
CString category(_T("Data\\"));
category+=dataCode; // DataCode could be Data01 or Data02 i dont know this before hand.
path = GetProfileString(category,_T("InitPath"));How should i check if an entry there using GetProfileString or how can i do it? Thanks in advance. Bekir.
-
Placing an image to main window, like IEi found what i want to do in here, lots of digging :). http://www.codeguru.com/cpp/controls/menu/bitmappedmenus/article.php/c3725/[^] Best Regards. Bekir.
-
Placing an image to main window, like IEHello, I want to put an image,like a logo, to the right of the main window of my application, just like Internet Explorer. What is the best way to implement? (Using MFC) Thanks in advance. Bekir
-
creating spline thru n points (c/c++)Natural cubic splines or clamped, check the implementation at http://www.as.ysu.edu/~faires/Numerical-Analysis/DiskMaterial/programs/C/[^] Algo 3.4 and 3.5 any numerical analysis book with interpolation section might help. Of course, due to the nature of the curve, the curve passes directly through the provided points. Bekir.
-
Hide/Remove the Application Icon in the Title bar icon for a dialog with Border - Resizing.Hello, Right click on the dialog, go to Properties then Select Right Align Text in the misc. category It does change where the title bar is located, but not sure that is exactly what you need. Hope this helps. Bekir.