|
m.dietz wrote: To solve that problem mathematically: take the logarithm to base 10 (double log10(double))and add 1.
First make sure the value is greater than zero.
m.dietz wrote: Else you can format it into a CString and check that length.
the above works anyway.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
. I leave you as an exercise the extension to n<=0 .
int howmanychars(int n)
{
return (int)log10(n) + 1;
}
BTW of course you don't need it
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thank you
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Please note: I gave you the function only for informative pourposes (an academic exercise): you really don't need it. Moreover it will slow down your code.
BTW: Think a bit before giving judge on programmers slowness, with David Crow you surely miss the target.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Yeah I know.. I'm not even a professional programmer :p but I really hate Windows programs which are really slow and clunky and don't manage resources well.. I'm not having a go at him, I'm grateful for the advice from him and everyone.. I'm just sure that there must be an efficient way of doing this and throwing memory away unnecessarily is a bit of a waste.. Don't you agree?
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Perspx wrote: ...don't manage resources well
Don't forget, memory is not the only resource a computer has. Sounds to me like you're wasting the CPU time (another resource) in order to save a few bytes of memory. It's hard to imagine a case where those few bytes would ever matter. There's also the factor of code complexity -- sounds like you're making your code more complex than it needs to be.
Since you're calculating size, I'd guess you're going to be allocating memory dynamically through malloc or new[] etc. Those schemes will add their own overhead which will swamp the few bytes you're aiming to save.
Perspx wrote: Don't you agree?
In principal, yes, don't waste resources. However, I think you're going overboard in this case (the other posts seem to agree).
|
|
|
|
|
Ok yes I see what you are all saying..
Thanks everyone
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
CPallini wrote: hink a bit before giving judge on programmers slowness, with David Crow you surely miss the target.
Yep, that's the least we can say.
|
|
|
|
|
Hi chaps,
Does anyone know of a hack I can use to prevent a modal dialog from closing when I call EndDialog()?
What I want is for my dialog to behave just like a normal modal dialog in all aspects except that when it reaches the end of it's modal loop it exits as normal, DoModal returns a value, but the dialog doesn't actually close. So that I can call DoModal() on it once again without the dialog disappearing and re-appearing. It only closes when I explicitly kill it (or when the object goes out of scope).
Anyone know if this is do-able?
Thanks,
Jim
|
|
|
|
|
I'd rather replace the OK button with a button of your own, and hide the dialog instead. You can start to destroy a dialog and then force it to stay alive. You need to use a modeless dialog, emulate the modal dialog, and hide/show it when you need, and destroy it once at the end.
|
|
|
|
|
Yeah, I'm pretty much resigned to that. Dagnabbit.
Thing is, it's a progress dialog that keeps the user informed of the progress of a worker thread, which means we have to allow Windows to run it's message pump to update the dialog. If it's modal this isn't a problem. What is the problem is that now we want to change it such that the worker thread may now run more than once. This again works OK except that the dialog pops down when the thread has finished only to pop up again moments later when the thread runs again.
It's not so much changing the dialog to be modeless it's more that I will have to change all the calling code to have to return to Windows to allow the message pump to run and then have a handler to pick up when the thread has finished. It means changing a lot of working code to fix a minor UI irritation. Damn. If a hack like I described were possible it save a lot of work.
Still, since posting it has occurred that I might be able to fix it by moving the loop to be inside the dialog.
Jim
|
|
|
|
|
Hello!
I have a digitals that contain a local time (1387475976). How I can recieve the correctly filled SYSTEMTIME struct? I try to use next code, but it is wrong:
__int64 ull(1387475976);
FILETIME lpFileTime;
SYSTEMTIME SystemTime;
memcpy(&lpFileTime, &ull, sizeof(__int64));
FileTimeToSystemTime(&lpFileTime, &SystemTime);
cout << SystemTime.wYear << endl;
In out SystemTime.wYear = 1601
Thanks,
Andrey
|
|
|
|
|
myshketer wrote: I have a digitals that contain a local time (1387475976).
Does this represent the number of 100-nanosecond intervals since 1-January-1601?
"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 thinked it is... but investigation show that it number too small
|
|
|
|
|
That all depends on what you mean by "too small." Since there are 36,000,000,000 100-nanosecond intervals per hour, the value 1,387,475,976 is still within January 1st, 1601. Make sense?
"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
|
|
|
|
|
myshketer wrote: 1387475976
This is far too small. Where did you get that number ?
|
|
|
|
|
Is it possible in MFC to create an EXE file programmatically?
I hope you guys can help me on this. My application is gonna upload an image to a device. When it is uploaded it also contains meta information appended on the image data because my application has also settings. I want a way that i can preserve the image data and all its settings on the absence of the device. I want to generate an executable file and when i execute the file it can automatically upload the image and all the necessary information to the device.
With presence of the device:
image -----> application ------> image + meta information -----> device
Absence of the device:
(generate an exe file if the device is unavailable)
image ------> application -------> image + meta information -----> exe file
If exe file is executed:
(it will automatically do the same function as with the presence of the device
exe file -------->device
positive vibes
|
|
|
|
|
dacky wrote: Is it possible in MFC to create an EXE file programmatically?
Yes, assuming you knew the PE file format intimately.
"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
|
|
|
|
|
Yes,and for more information about exe files I saw a good article on the www.codeguru.com about exe files header of exe and PE and... if you see that article it will be helpful for you.
|
|
|
|
|
Thank you so much for the information
positive vibes
|
|
|
|
|
Thanks for the information. im gonna check that out
positive vibes
|
|
|
|
|
You're welcome I saw that article some times ago I dont remember its address but its a realy good article.
Good luck.;)
|
|
|
|
|
You could make the application yourself, and store a small image in its resources. Also, a string saying "<none>" in the string table.
Then, your main app can either put the image straight to the device, or make a copy of mystubapp.exe, and change the image resource to be the one to upload later, and the string to be the name of the resource?
That's all very handwavy stuff, but have a look at ::UpdateResource[^] for more information on my Cunning Plan (tm)
Iain.
|
|
|
|
|
Thank you so much for your ideas..i will try to investigate them and gonna post some comments soon
positive vibes
|
|
|
|
|
Hello,
I'm creating a Wizard generated MFC application. The right pane displays a CFrameWnd, which in turn displays various views at different times. Whenever it displays a CFormView, there is an unsightly sunken border around its perimetre. This sunken border does not appear if I display a CListView, for example.
How can I remove this sunken border?
Regards,
Sternoceral
|
|
|
|