|
Yes,
It's Visual C++.
Thanks
Discover beauty in whatever you're doing
|
|
|
|
|
I recommend asking in the right forum then
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Yeah,
I created a similar message in the "Visual C++/MFC" forum
Cristi
Discover beauty in whatever you're doing
|
|
|
|
|
Hi,
I am busy searching, but I'm not sure, what I need to "register" all methods of the main program class, build a console host for that app and:
1. make it posible for the console host to autocomplete the method name when the user types the beginning of the method name and presses [tab]?
2. have one invoking point for all methods, passing the method name as a string parameter - something like
RunMethod(System::String methodName) . Should I use attributes? Delegates?
Any hints appreciated.
Thanks,
nj
-- modified at 5:53 Tuesday 17th October, 2006
(added to title)
|
|
|
|
|
I want to convert "abcd" into ASCII code
but I met a strange problem. My code is below.
<br />
char *s="abcd";<br />
int br[100];<br />
for(int i=0;i<4;i++)<br />
{<br />
br[i]=__toascii(s[i]);<br />
cout << br[i] << "\n";<br />
}<br />
string kkb=""; <br />
kkb=kkb.insert(0,br[1].ToString());<br />
cout << kkb;<br />
and there is an error at kkb=kkb.insert(0,br[1].ToString());
error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::insert(__w64 unsigned int,const std::basic_string<_Elem,_Traits,_Ax> &)' : cant convert argument 2 from 'System::String ^' to 'const std::basic_string<_Elem,_Traits,_Ax> &'a
It's very strange that I change the code
kkb=kkb.insert(0,br[1].ToString());
into
kkb=kkb.insert(0,"a string");
then it works.
I dont understand that both them are string.
why as long as I put the string variable int the function, it has an error?
Can somebody help me?
Thanks a lot.
minihotto
|
|
|
|
|
I'd recommend using sprintf or ( better ) ostringstream to do this. That would also make all your code C++, instead of the one reference to the .NET libraries.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hello everybody !!
my new problem is that i have a class that contain a some functions and some variables
i want to execute one of these functions in a separate thread using AfxBeginThread(...);
and FYI this function uses some member variables of the class to do it's work
any idea ???
thnx 4 ur time and concern
a.hemdan
|
|
|
|
|
This is a Visual C++ question, not a managed C++ question. Ask in the right forum, and you'll get lots of help./
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I want to obtain the pixel value of any pixel on the form (dialog) during mouse move.
In MFC, i can get the pixel value using
CDC *pDC = this->GetDC();<br />
COLORREF clr = pDC->GetPixel(x,y);
ReleaseDC(pDC);
How do i do the same using managed C++.
I added an event OnMouseMove, and i can get the pixel coordinate using
e->X and e->Y;
How do i get the pixel value? I tried this
Graphics ^g = this->CreateGraphics();
then i do not know what else to do...
Usman
|
|
|
|
|
You can still use the old code in managed C++, it's still C++.
In GDI+, the graphics object doesn't offer a get pixel method, the Bitmap class does instead. I'm not sure how to get a bitmap that represents the current screen, without doing a screen capture ( by which time, you've had the screen in a DC and could have just called GetPixel )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I need to get the pixel value each time the mouse is moved. Taking a full screen capture will be slow. Thus, as you have suggested, i used the unmanaged C++ code. It works, but what i'm afraid of is that the transition to and from unmanaged code will cause performance degradation. That's why i needed a pure managed solution. Anyway, since there is no managed way of doing it, i'm using the unmanaged way;
Graphics ^g = this->CreateGraphics();<br />
System::IntPtr p = g->GetHdc();<br />
HDC hdc = (HDC) p.ToPointer();<br />
<br />
COLORREF clr = GetPixel(hdc,x,y);
|
|
|
|
|
Oh, thanks by the way
|
|
|
|
|
I have 2 pairs of ODE that resulted from the mathematical modelling of a 2-link robotic system. My problem is in setting the intial conditions and printing to files.
I could have attached the equations but they are not showing when I tried to copy and paste.
Anyone interested in helping me out could send me his/her email and i will send the equation with other information to him/her. I will really appreciate your assistance.
Thank you.
Regards,
Sahoong.
skg
|
|
|
|
|
If you click 'Ignore HTML tags', you can paste equations without any hassles.
But, this looks like it might be a C++ and not managed C++ question.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Dear Chris,
Million thanks for your response.
Unfortunately, I still cannot paste the equation. It was typed with Microsoft equation editor.
The codes that I have written so far is below:
// Simulation of the Dynamics of a 2-Link Pan-Tilt Robotic Manipulator
/* This programme calculates the Velocity, Acceleration and the angles of inclination
of the two links of the Spherical Pointing Motor, which is essentially a Two-Link Robotic
Manipulator*/
//#include <basis.h>
//#include <assert.h>
//#include <string.h>
//#include <iostream.h>
//#include <iomanip.h>
//#include <fstream.h>
// Precompiler Directives
#include <math.h>
#include <stdlib.h>
// Constants Declaration
#define n (int) 2
#define m1 (float) 0.05
#define m2 (float) 0.03
#define r1 (float) 0.04
#define r2 (float) 0.06
#define ra (float) 0.04
#define rb (float) 0.06
#define l (float) 0.05
#define d (float) 0.02
#define acc_due_gravity (float) 9.81
class AngVel1
{
public:
};
class AngAccln1
{
public:
};
class AngVel2
{
public:
};
class AngAccln2
{
public:
}
/*
n = Number of Links = 2
m1 = Mass of the First Link (The Annulus)
m2 = Mass of the Second Link
r1 = Inner Radius of Link 1 (The Annulus)
r2 = Outer Radius of Link 1 (The Annulus)
ra = Outer Radius of the Annulus
rb = Inner Radius of the Annulus
l = Half the Lenght of Link 1
d = Displacement from the Centre of Mass
g = Acceleration due to gravity = 9.81
t = time in seconds
*/
// Declaration of variables (Robot Parameters)
float t;
// Prototypes
float TorqueVal(float t);
double Runge_Kutta ();
double AngVel1 (double om1){
return om1;
}
double AngAccln1 (double t, double om1, double tetha1, double tetha2){
t = 0.1;
return (tau1 - 2*m2(r2*r2/4 -h2*h2/3 -d*d) * om1*om2*sintetha2*costetha2 - m2*g*d*costetha1*costetha2)/
om1*(m1(ra*ra + rb*rb)/4 + m1(h1*h1)/3 + m2((r2*r2)(1+sinsqtetha2)/4 + m2*h2*h2*cossqtetha2/3 + m2*d*d*cossqtetha2);
}
double AngVel2 (double om2){
return om2;
}
double AngAccln2 (double t, double om1, double om2, double tetha1, double tetha2){
t=0.4;
return (tau2 + (m2(r2*r2/4 -h2*h2/3 -d*d)*om1*om1*sintetha2*costetha2) - m2*g*d*sintetha1*sintetha2)/
om2*m2(r2*r2/4 + h2*h2/3 + d*d;
double RK(double y){
double k1,k2,k3,k4;
k1=h*fn(y);
k2=h*fn(y+(k1/2.0));
k3=h*fn(y+(k2/2.0));
k4=h*fn(y+k3);
return y+(k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
}
// The Main Routine
int main()
{
// Torque Function
float TorqueVal1(float t)
{
t = 0.1;
return t;
}
// Runge-Kutta Function
double RK(double y){
double k1,k2,k3,k4;
k1=h*fn(y);
k2=h*fn(y+(k1/2.0));
k3=h*fn(y+(k2/2.0));
k4=h*fn(y+k3);
return y+(k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
}
double RK(double l){
double v1,v2,v3,v4;
v1=h*fn(l);
v2=h*fn(l+(k1/2.0));
v3=h*fn(l+(k2/2.0));
v4=h*fn(l+k3);
return l+(v1/6.0)+(v2/3.0)+(v3/3.0)+(v4/6.0);
}
}
I was not using a class before and I just started packing the four equation into classes.
You could me to olaskg@yahoo.ie.
Thank you.
skg
|
|
|
|
|
I'm trying to develop a WM visualization but i cannot seem to to find any examples or tutorials on the subject. I have the wm sdk and have read the documentation, but the example in it is far from impressive. Any help would be great.
|
|
|
|
|
Hi,
I posted this on MS's "Visual C++ Language" forum a few days ago without getting a useful answer. I'm hoping somebody (Nish??) here can help. I'm pretty desperately needing a solution at this point.
We are doing a transition project where we are wrapping unmanaged C++ code with C++/CLI (VS 2005) managed classes. The various methods and properties on a given managed wrapper class are mostly just pass-through calls to the wrapped C++ class.
Mostly this works fine. Sometimes, however, the call from the managed code ends up in the wrong C++ function. IOW:
void ManagedMethod1( void )
{
m_pUnmanagedObject->Func1();
}
actually calls m_pUnmanagedObject->Func20().
So far, it seems that every time this happens, the called method on the UNmanaged C++ class is declared "virtual"; it also seems that the incorrect method that is actually called is also declared virtual. I have tried in one or two situations to change the legacy class method to non-virtual and it fixed the problem. However, that isn't a very general or useful solution.
The unmanaged code is in a DLL, and the managed wrappers are in an assembly DLL. I've cleaned and rebuilt both multiple times, as well as the C# test driver program.
There is another problem that is probably related that I've found with another virtual function, this one taking a parameter (the first problems above were with virtual functions taking no parameters). Tracing in the managed wrapper code in Disassembly mode, there is what looks like a call to something called MarshalCopy, which calls the copy c'tor for the class of the passed parameter. This call appears to execute without error; however, when execution returns from that function, it returns to a completely different place than it was called from, which needless to say, is fatal pretty quickly.
I'm sure I'm doing something wrong and/or stupid; perhaps I need some kind of explicit marshalling (though I thought you didn't need this with C++ interop), or some compiler switch or something. But I've looked and looked, and can't find anything.
I would GREATLY appreciate any help or suggestions.
Thanks.
Doug
|
|
|
|
|
Well, embarrassingly enough, I was doing something pretty stupid - trusting the compiler to rebuild everything necessary automatically.
Apparently I never first "Cleaned" then "REbuilt" both projects at the same time. When I did that, the problem went away.
So, I was stupid for not doing this right away, but... it seems the compiler is somehow defective, since I did "Build" both projects many times.
I guess this is better than an actual compiler bug that MS wouldn't fix for a year!
Doug
|
|
|
|
|
now i have a CString variable contain an integer value
i wanna convert the CString to int so i used atoi() function
<br />
CString strNumber = "00123"<br />
int nNumber = atoi(strNumber);<br />
then nNumber will contain (123)and it ignore the Zeros
so what if i need these Zeros, what should i do
also if i wrote
int x = 0110;
x will result into (72)
could anybody explain that
thnx 4 ur time and concern
|
|
|
|
|
hello,
In a integer you can't keep the zeros, so if you want the zeros at the left you have to use string and so on,
About the second problem, if you put 0 at the left, you are using octal system so,
0110 = 0*8^3+1*8^2+1*8+0 = 72
Regards
-- modified at 10:03 Wednesday 11th October, 2006
|
|
|
|
|
singersinger wrote: so what if i need these Zeros, what should i do
padding zeros is a display formatting operation and has nothing to do with the value of the intrinsice numeric type (int, long, etc.)
singersinger wrote: x will result into (72)
if you want x = 110 write:
int x = 110;
otherwise the leading zero is interpreted by the compiler to mean "octal" just as leading 0x means hexadecimal.
led mike
|
|
|
|
|
note: int x;
x= 0110; //oct value 0"number", base 8
x= 0x110; //hex value 0x"number", base 16
x= 110; //dec value, base 10
so a 0110(base 8) number is 72(base 10)
* use Windows calculator to check the above values
you can NOT keep the zeros if you use a "int" type
|
|
|
|
|
Hello,
To convert from CStrin to String^ I have done it like this:
CString TextAuxStr;
String^ TextCLR;
TextAuxStr = "Test";
TextCLR = gcnew String(TextAuxStr.GetBuffer());
Is there any other way to do it??
Thank you
Regards
|
|
|
|
|
The method you've used is the best way to do it (though there are other ways too).
|
|
|
|
|
Hello,
I'm using treeview with Windows forms, and I would like to select an ITEM of the tree when and event occurs, How can I do this??? I have been trying to use the TreeView.Select() , but I don't manage to make it work.
Thank you
Regards
|
|
|
|
|