|
I am creating activex control in vc++6.0. I need to implement MyRegisterClass in my control class. Can anyone let e know how to implement it.
S.Yamini
|
|
|
|
|
Ok if I have a number (stored in a regular integer) and say that number is 51.... Is there a function to search the Integer and return how many numbers there are in the Integer? e.g. 51 has a 5 and a 1 in it so it should return 2.
I tried -> sprintf(IntLength, "%d", Prime); but I get compilation errors does anyone have any ideas?
Thanks of course in advance
|
|
|
|
|
Here sprintf() will convert your prime integer to the string representation. so it will not give you your answer that how many numbers in integer.
And Regarding to your error , check the type of variable IntLength used in sprintf() function.
|
|
|
|
|
technically you are not 100% correct. the return value of sprintf() is the number of characters stored in buffer so adapting the answer to the previous question Michael asked given by Naveen.R here[^] you could end up with
<br />
int IntLength;<br />
int n = 123456;<br />
char c[33] = {0};<br />
IntLength = sprintf( c, "%d", n ); <br />
|
|
|
|
|
Michael101 wrote: sprintf(IntLength, "%d", Prime);
Whats the error?
any way you can use the following function for it
int n = 12345678;<br />
int nCount = 1;<br />
while( n )<br />
{<br />
n = n/10;<br />
if( n > 0 )<br />
{<br />
nCount++;<br />
}<br />
}
|
|
|
|
|
Naveen.R wrote: nave
you are superfast dude!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
int iCount = 0;
int iurNumber= any number;
while(iurNumber !=0)
{
iurNumber /=10;
iCount++;
}
iCount will contain number of element integer have
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Michael101 wrote: ...but I get compilation errors...
Are we supposed to guess what those are?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I've never seen sprintf with this signature. Have you overloaded it yourself?
I think the error you are getting is because you are passing an integer instead of a char*.
Instead of:
sprintf(IntLength, "%d", Prime);
use:
IntLength = sprintf( someCharBuffer, "%d", Prime );
Or better yet, use one of the other solutions already given.
David
|
|
|
|
|
Hi everyone,
I'm working on a solution and I've come accross a problem which seems to be trickier than I expected! I've got an Integer and I need to put the numbers from that Integer into a character array! This array is used for other operations but I don't know how to extract the numbers in the Integer and place them in their own single element in the array. E.g. 47 needs to be over two diffent elements and so on.
Any ideas?
Thanks in advance, I appreciate the help
Michael
|
|
|
|
|
check the sprintf() function.
eg:
int n = 123456;<br />
char c[33] = {0};<br />
sprintf( c, "%d", n );
|
|
|
|
|
Legend
Worked like a charm! Thanks
|
|
|
|
|
you can also use itoa, _itot function!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You can use
#include <strstream>
const int number = 47;
std::stringstream stream;
stream << number;
std::string numberAsString = stream.str(); This way, you are using the power of the STL for you, and are avoiding literally thousands of error possibilities when fiddeling around with char-pointers and string lenghts.
The std::string would fit in nicely with the std::vector (or any oher standard container), and as a plus you can get the content as a plain old C-String by calling its c_str()-member.
Just to bring regular C++ to the mind, instead of this ugly 30+years old C code floating around here.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Hello,
I'm having a problem with my double precision variables right now, and I'm hoping someone out there will be able to give me a hint as to what's going on. The details are going to be a little sketchy simply because of the size and complexity of the application.
I have a function that tests to see if the double precision code is behaving properly. This function looks something like this.
void TestMath()<br />
{<br />
double kappa = -2.5316332141755993e-008;<br />
double cx;<br />
cx = (double)1.0 / (double)kappa;<br />
<br />
if (cx != -39500192.000000000){<br />
BREAK("MATH IS WORKING");<br />
}<br />
}
When this function is called from the main body of my application, it never hits the break. However, if the function is called from a thread I have spawned using CreateThread(), the break does get hit.
The value for cx should be -39500192.776766039, but it's being set to -39500192.000000000
And if I add the line
double cx2 = 1.0 / -2.5316332141755993e-008;
cx2 always equals -39500192.776766039 regardless of where I'm making the call.
Using the IDE and checking the value for kappa indicates that it's value is correctly being stored.
And again, if the function is called from a spawned thread, cx is evaluated to be
-39500192.776766039
To create the thread, I'm simply calling
handle = CreateThread( NULL, 0,(LPTHREAD_START_ROUTINE)threadProcess, parameter, 0, NULL);<br />
And the function declaration for the thread looks like this.
DWORD WINAPI threadProcess(void *param)
Does anyone have any suggestions as to what could be causing this behavior?
Thanks,
Adam
|
|
|
|
|
Found it!
So, one of the details that I left out was that I am using DirectX for GPGPU math processing as well as for displaying 3d objects.
It turns out that if you create a D3DDevice without the behavior flag D3DCREATE_FPU_PRESERVE, the following happens:
Without this flag, Direct3D defaults to setting the FPU to single-precision round-to-nearest mode. Using this flag with the FPU in double-precision mode will reduce Direct3D performance.
Don't you just love how moments after you post about a problem, your thinking changes just enough to allow you to find the culprit?
Thanks for forum,
Adam
|
|
|
|
|
Nice post. Maybe it'll save someone else the trouble. Thanks for sharing it.
David
|
|
|
|
|
Hello,
when we login to email account(gmail.com) on internet browser, the browser sends data with sockets(packets), in the packet should have the email accounts password.
I am wondering that someone does know hot to retrieve the password from the packet? or somebody has any idea?
this is not hacking or anything else, this is just to better understand how sockets work.
thanks for any help
|
|
|
|
|
Gofur Halmuratov wrote: this is not hacking or anything else, this is just to better understand how sockets work.
Hmm...it has nothing to do with sockets.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Gofur Halmuratov wrote: this is not hacking or anything else, this is just to better understand how sockets work.
That's like trying to learn to read and write English by studying paper and pens.
Steve
|
|
|
|
|
it's not possible; well, nothing is impossible, but so hard you'd better do something else with your time.
the data is encrypted, with RSA.
|
|
|
|
|
I'm not sure if the thread title is really accurate, but it's the best description I can think of.
I'm in the process of creating the GUI part of a software synthesizer (VST). The synthesizer will reside in a dll. An application called the host will load the dll and run the synthesizer. I've chosen MFC for putting together the GUI elements for the synthesizer. My approach has been to test out the GUI elements in an MFC dialog based application. I've reached a point where I now I have most of the GUI work done, and I've been attempting to integrate it with the syth engine. This has meant basically copying relevant MFC files over to my synth dll project. I've made sure that I've set up the project so that it links to MFC in a shared library.
The idea is that when the host asks me for an synth editor, I pass it a class encapsulating an MFC dialog. The dialog displays all of the synth controls.
So for so good, but I've run into a problem in that I get this compile error:
Linking...
mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in vstplugmain.obj
There's a conflict between the main function that is implemented in vstplugmain.cpp and the main function implemented some where in the bowels of the MFC library. I've been googling like crazy, but have not found a solution to resolve the conflict.
vstplugmain.cpp is the file that exports the main function. It's the function that the host interacts with when it loads the dll.
Is there something fundamentally wrong with this approach in that I won't be able to use MFC in a dll that exports its own main function?
[EDIT]
Hmm, the error goes away when I statically link to MFC.
[/EDIT]
-- modified at 16:30 Wednesday 3rd October, 2007
|
|
|
|
|
Leslie Sanford wrote: The idea is that when the host asks me for an synth editor, I pass it a class encapsulating an MFC dialog. The dialog displays all of the synth controls.
My approach would be to create an MFC enabled dll and add both the gui and the classes from the synth dll to it. I would tend to use either an MFC extension dll or an inproc COM server with MFC support, but a normal dll with MFC support should do as well.
Nathan
|
|
|
|
|
In addition to Nathan's reply...
This Link[^] has info on choosing MFC DLL types and for
each type, info on proper initialization.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|