|
hi_prk_bably wrote: i want it as soon as possible
And yet, you're asking on a site with no visible Java forum or other Java support, in the forum with the least readers ( C++/CLI ) ????
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hello,
How can I read a Matlab array of integers in C++ using mexfiles. I found it's easy to read array of doubles with mxGetPr, but I could not find how to do it with integers.
Any help would be appreciates.
Oct.
|
|
|
|
|
You're using C++/CLI with Matlab ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
What I have is a Matlab code, and I am writing some of the subrutines in c++ using mexfiles to speed up the computations. Then you can compile this cpp files and use them in Matlab as any other function.
Mexfiles allow you to write a c++ code and through a so called gateway function just translate the input parameters from Matlab to C++, perform the operations you have to do, and then translate back the output from C++ to Matlab.
My problem is that I cannot find a way to translate an array of integers. Using the mxGetPr function you can translate an array of doubles. I am trying to read as input an array of integers and I cannot find the way.
I am not sure what CLI is.
Oct.
|
|
|
|
|
OK, so you're using VS.NET and C++/CLI ( C++ with .NET ), or are you in the wrong forum ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
I think (though I'm not absolutely sure) that mex DLLs always treat matrices as double type.
BTW, please do not use C++/CLI forum for this issue; use Visual C++ forum instead. I attempted to send you an e-mail, but you have not confirmed your address to CP, so I could not send my reply there. Please make this confirmation.
Also, take a look at a brilliant series of MATLAB articles at CodeProject, many of them written by A.Riazi.
|
|
|
|
|
how to write programe " Auto View CD"
|
|
|
|
|
I have been assigned with C++ project; to develop a software application for converting MP3 files to wave and vice-versa. So I need help regarding the same. I have to develop this project in C/C++.
|
|
|
|
|
Do you have to do it in C++/CLI, or ar eyou in the wrong forum ?
There's plenty of source for mp3 converting on the web, none of it C++/CLI, but much of it, C++
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi there,
My problem is I am using visual 2005 C++ express and try to compile the following source code:-
<br />
Byte b[] = * gcnew Byte[Convert::ToInt32((dr->GetBytes(PictureCol, 0, 0,0, Int32::MaxValue)))];<br />
And it prompt me the following error messages:-
<br />
error C2664: '__int64 System::Data::Common::DbDataReader::GetBytes(int,__int64,cli::array<Type,dimension> ^,int,int)' : cannot convert parameter 3 from 'int' to 'cli::array<Type,dimension> ^'<br />
with<br />
[<br />
Type=unsigned char,<br />
dimension=1<br />
]<br />
No standard conversion exists from the boxed form of the arithmetic type to the target type<br />
error C2440: 'initializing' : cannot convert from 'unsigned char' to 'unsigned char []'<br />
Please help to correct some of the error. Thanks you in advance
-- modified at 11:26 Monday 29th January, 2007
|
|
|
|
|
p_c wrote: error C2664: '__int64 System::Data::Common::DbDataReader::GetBytes(int,__int64,cli::array ^,int,int)' : cannot convert parameter 3 from 'int' to 'cli::array ^'
GetBytes require array<unsigned char>^ buffer as third param.
p_c wrote: error C2440: 'initializing' : cannot convert from 'unsigned char' to 'unsigned char []'
change Byte b[] to Byte b .
|
|
|
|
|
Hi,
i have a mixed mode program (C++/CLR with native code), and i am having the following error while running the program in debug mode. The error is displayed in the Output window. (i'm using Visual C++ 2005).
Although the following error is displayed, the program runs fine. The operation, behaviour of the program is fine in debug and release modes.
The program is a little complicated, it has a main C++/CLI thread (with GUI etc) which calls a native thread which performs some processing using DirectX.
The error is:
First-chance exception at 0x7c812a5b in Scene Configurator.exe: 0x000006EF: A null context handle was passed from the client to the host during a remote procedure call.<br />
First-chance exception at 0x7c812a5b in Scene Configurator.exe: 0x000006A6: The binding handle is invalid.
I am not using any sort of Remote Procedure Call. All i want to know why this error is produced, and how to eliminate it. (Or where to start looking for it)
Another part of the program causes another First-Chance exception, the code is
void Draw_Grid(LPDIRECT3DDEVICE9 g_3Ddevice)<br />
{ <br />
tVector3 vertData[2]; <br />
const float fNear = gVar.GridNear;
const float fFar = gVar.GridFar;
const float fStep= gVar.GridStep;<br />
<br />
for(float i = fNear; i <= fFar; i += fStep)<br />
{
vertData[0] = tVector3(fNear, 0, i); <br />
vertData[0].color = 0xFFD9810E;<br />
vertData[1] = tVector3( fFar, 0, i); <br />
vertData[1].color = 0xFFD9810E; <br />
g_3Ddevice->DrawPrimitiveUP(D3DPT_LINELIST , 1, &vertData, sizeof( vertData[0] ) );<br />
<br />
vertData[0] = tVector3(i, 0,fNear); <br />
vertData[0].color = 0xFFD9810E;<br />
vertData[1] = tVector3(i, 0, fFar); <br />
vertData[1].color = 0xFFD9810E; <br />
g_3Ddevice->DrawPrimitiveUP(D3DPT_LINELIST , 1, &vertData, sizeof( vertData[0] ) );<br />
<br />
}<br />
}
It seems DrawPrimitiveUp is producing an error of First-chance exception at 0x7c812a5b in Scene Configurator.exe: Microsoft C++ exception: long at memory location 0x04a4f808.. but the drawing of grid (the purpose of this code) is fine. Output of grid on the screen is as desired and the program runs fine. Commenting the DrawPrimitiveUp lines removes this error message. Any idea why?
Thanks.
|
|
|
|
|
Hi,
Is there any method in C++ to know the type of exception that occured...like e.getMessage() in Java??
Priya.
|
|
|
|
|
This is the C++/CLI forum. For C++/CLI, the answer is yes. For C++, the answer is no.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I am developing this simple arithmetic program and this is my first windows application ever, so I am not so sure at how to program this. In my app the user can set the lower limit and upper limit for the calculations numbers that are about to come up in a test the user want’s to do. You se the upper and lower limit as variables in the code below. The code below generates calculations for addition, subtraction and multiplication. So let us suppose that the user sets the limits to lower = 1 and upper = 100, that will give us 100 x 100 = 10 000 calculations! When I test this on my own computer it takes a while to generate all calculations, and if I change upper limit = 200 the program stops I push (ctrl+alt+del) and it says that the application is not responding.
// Generating all Calculations for addition, subtraction and multiplication
for(int i = lowerLimit; i <= upperLimit; i++)
{
for(int j = lowerLimit; j <= upperLimit; j++)
{
// Reset flag
excludeCalculation = false;
// Create temp Calculation
tempCalculation = gcnew Calculation(i, calculationOperator, j);
// Check if Calculation should be removed
excludeCalculation = this->removeCalculation(tempCalculation);
// Check if to add Calculation
if(excludeCalculation == false) // If NOT to be excluded
{
calculations->Add(tempCalculation);
}
}
}
How do I prevent the application from stopping like this??
I would like to show a progressbar while the application is generating the calculations, but I don’t know how to do this when the application get hung up by it self all the time, I can not figure out how to work around this problem.
Does anybody have any tips???
I am not so familiar with using Threads, but is this one of these occasions when I should be using Threads???
If so, can someone give me an example of how to program with treads?? And how do I pass data between threads?… I have to know how many calculations is generated for my progressbar… or??
I am a complete newbe on this… so all help is appreciated!!
Best regards, Andreas
|
|
|
|
|
AAsterlund wrote: I am a complete newbe
What made you choose C++/CLI ? C# or proper C++ seem like better places to start, to me.
Have you set a breakpoint to step through and work out where your program is getting stuck ? You can also choose "break all" from the debug menu while running in debug mode, and the code will stop where it's stuck.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Christian Graus wrote: What made you choose C++/CLI ? C# or proper C++ seem like better places to start, to me.
Have you set a breakpoint to step through and work out where your program is getting stuck ? You can also choose "break all" from the debug menu while running in debug mode, and the code will stop where it's stuck.
First of all I want to say that I am NOT a professional programer that develops applications on a day to day basis. And I am NOT a master in Visual C++ either (and I am not used to work with the debugger, but I like to learn it some time when I got som time left over for it). Programming is only a hobby of mine that I like to practise only on my spare time. I like the fact that one could develop applications, that can be used to ease the burden in various occasions in life.
In the past I have had 1-2 months of education in native C++ (that is developing in a dos environment and not using any development tool, only notepad). Later I wanted to develop some windows application and I needed a development tool and I chose Microsoft Visual Studio 2005. And it felt natural for me to go from native C++ to C++/CLI. I mean I knew a little C++ and managed C++ seemed to me to be a good technology, so I went with that!
And yes I am a complete newbe on thread-programming... I have never had to use it before.
So instead of moralizing about what is the right place or not for me to start developing my little interest in programming, it would be a lot more helpful and less timeconsuming for both me and you if you just could give me answers to my questions! I am not asking for you or anybody else to write my program for me, that I want to do on my own. I just need help, tips or derections on how to proceed from here.
As you maybe have noticed I am not used to the debugger due to the small complexity of my applications. Maybe it is foolish of me not to use it, but if I got more time left over I would try to learn it. It seems to be a good help in development, but that is not the question here I think.
I put a messagebox before and after this particular code snippet and only the one before showed up before the application got hung up. The one after showed up only after I had removed the the loops from the code. So I think I am fairly sure that this is where my program is getting stuck, don't you think??
I think I must run the code in another thread and I was thinking about showing a dialog with a progressbar on how many calculations is left to generate before the test dialog is shown. Should I run the dialog with the progressbar in the same thread as the one I am generating calculations in??
I am little confused about how to think here...
best regards, Andreas
|
|
|
|
|
AAsterlund wrote: So instead of moralizing about what is the right place or not for me to start developing my little interest in programming, it would be a lot more helpful and less timeconsuming for both me and you if you just could give me answers to my questions!
I'm sorry, I'm just trying to help. C++/CLI is a lot harder than C#, and not widely supported. If you follow this path, you'll find it hard to get much help, which is why I commented.
AAsterlund wrote: Maybe it is foolish of me not to use it, but if I got more time left over I would try to learn it.
Using the debugger is a basic skill, you're not going to get far without it. Just press F9 or right click to set a breakpoint. Then press F5 and the code will stop at the breakpoint, you can then single step through code, and type in variable names and expressions in the Watch window to see what your program is doing. Until you learn that, you're just stabbing in the dark
AAsterlund wrote: I put a messagebox before and after this particular code snippet and only the one before showed up before the application got hung up.
OK, then it's getting stuck in the loop. If you press the break all under the debug menu, you'll see which line it's on, and be able to see the values of your various variables. You can also put console.writeline statements inside the loop and they will appear in the output window.
AAsterlund wrote: don't you think??
I had no doubt, I was advocating you step into the code to work out *why*
AAsterlund wrote: I think I must run the code in another thread
It shouldn't take very long, this code. You don't need another thread every time you write a nested loop
AAsterlund wrote: Should I run the dialog with the progressbar in the same thread as the one I am generating calculations in??
No, all UI must be in the same thread, that's the point. The UI remains responsive while the background thread does the work.
AAsterlund wrote: I am little confused about how to think here...
I'm sure if you step into the code with the debugger, you can solve this in less time than it took you to reply to my post.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Christian Graus wrote: I'm sorry, I'm just trying to help. C++/CLI is a lot harder than C#, and not widely supported. If you follow this path, you'll find it hard to get much help, which is why I commented.
Okey it seems to be a missunderstanding of mine. And I certainly don't want argue with you. Tanks for the help!
best regards, Andreas 000 the computer got hung up. And when I changed the lower and upper values to -10000 and 10000 I got this message:
"An unhandled exception of type 'System.OutOfMemoryException' occurred"
Does this mean that my computer can not generate all calculations between -10000 and 10000 (like: 10000 - 7893, -8512 - 2113, 9875 - 3213 and so on...)??
I would have hoped for my application to being able to generate calculations up to at least 100000 and maybe up to 1000000.
If it is to any help for you, my computer specifications are:
AMD Athlon XP 2200+ 1.80 GHz
512 MB RAM
Under given circumstances; is my computer to slow or is there a bug in my code??
best regards, Andreas
|
|
|
|
|
When the OS says "not responding," that just means that the app has stopped processing window messages. If you watch task manager, you'll see that the thread is still using CPU time.
|
|
|
|
|
Yeah, good point.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello,
One thing I dislike about C++/CLI is that using Designer for forms most often ruins my formatting of the code. C# has a good solution against that, which is the partial keyword, allowing me to write my part of code cleanly while the generated mess resides in another file.
Is partial keyword going to be implemented in any of the upcoming C++/CLI versions?
|
|
|
|
|
Microsoft is attempting to keep C++/CLI close to the standard as possible. Thus, the concept behind the "partial" keyword goes against the current C++ standard, and Microsoft will not make any attempt to support the "partial" class concept. By the way, the upcoming C++ standard will not support this concept also.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
George L. Jackson wrote: Microsoft is attempting to keep C++/CLI close to the standard as possible. Thus, the concept behind the "partial" keyword goes against the current C++ standard
I cannot see how ^ or finalizers are closer to C++ standard than the partial keyword would be. The influence of partial to the compiler is perhaps much smaller than this of already introduced keywords, isn't it?
BTW, you may want to take a look at "C++ divided by CLI"[^] by Dominic Connor.
|
|
|
|
|
The "^" and finalizers have a swallow impact on the overall behavior of C++. However, partial classes impact on how the compiler works and the behavior of OOP in general. The problem is how would you create partial classes following C++ rules. IMHO, combining partial classes is similar to public inheritance without a base or derived class. That concept is very alien to C++.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|