|
There's also the ceil() and floor() functions. It's really just a matter of trying each suggestion until you find the one that does just what you need.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Strings:
CString str;<br />
float f = 0.306;<br />
str.Format(_T("%.2g"), f);<br />
TRACE(_T("%s\n"), str);
Because I've used %g (instead of %f), 12.0 will be 12.
Numerics:
Take a look at this: http://www.codeproject.com/cpp/floatutils.asp[^]
- Dy
|
|
|
|
|
Well, that's not very "generic" (what happens when you need to round at a higher precision?).
double Rounder(double fVal, int nPrecision)
{
nPrecision = __max(__min(16, nPrecision), 1);
double fEpsilon = pow(10, nPrecision);
double fResult = ( floor(fVal * fEpsilon + 0.5) / fEpsilon);
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Now, that seems good, but it does lots of weird things that i dont want, try setting f to, 299.99 or 31.2699
thanks!!
/Johannes
|
|
|
|
|
that's normal floating point behavior...
know that their height storage capability is at the cost of the precision
|
|
|
|
|
hu?
im like a total beginner at c++
/Johannes
|
|
|
|
|
I have an SDI style (no doc/view) MFC application that has several windows. These the content of these windows take a while to initialise and the net result is that from double clicking the icon to the application apearing takes a long time and makes it apear that it has not been started.
I would like the main ui of this application to appear asap and then initialise the processes that take time to get going.
Anyone have suggestions how I might be able to achieve this?
Robin
|
|
|
|
|
You can start the task once the dialog is showing. You can use a thread that would keep on downloading and updating the controls and the data that you need to show in your application, also you can show a progress bar somewhere on the screen of your application that some work is in progress and the user needs to wait until he can work on the application.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
My app isn't dialog based! But I assume the technique would be the same for a dialog app and Windowed app. Would I start off my thread from OnShowWindow or OnActivate? (with traps to ensure it dosent get fired more than once)
|
|
|
|
|
Robin Imrie wrote: ...from double clicking the icon to the application apearing takes a long time...
So what are you having the application do?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I havent got to the point of working out what is taking up the time but I thint it might have somting to do with the 2 http (aspx) server (one used by the application only and the other for external access only) and displaying of a video file.
These are things I want to delay the start up/initialization of.
|
|
|
|
|
Robin Imrie wrote: ...I thint it might have somting to do with the 2 http (aspx) server (one used by the application only and the other for external access only) and displaying of a video file.
So don't start these things until after the application has fully shown itself.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
This is exactly what I want to do hence the original post...
When do I know when the application has fully shown itself?
|
|
|
|
|
Robin Imrie wrote: When do I know when the application has fully shown itself?
That's hard to say since you've removed the doc/view support from it. Do you still have a "main" frame? Has anything replaced the view?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I do still have a Main frame. The main frame contains a CChildView and this is where all the other visible elements are contained. CChildView inherits CWnd.
|
|
|
|
|
My first guess would be to post a message from CChildView::OnCreate() . In the handler for that message, start your other processing. This is likely to not work, however, if the "other processing" ties up the main thread enough such that it cannot finish rendering the UI.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
After adding various handlers (WM_ACTIVATE & WM_SHOWWINDOW) which just produce trace statments so I can see the order of events. I have come to the conclussion there there are two ways of tackling this... (could be more!)
1) Start a thread in response to a WM_ACTIVATE (with mechanizm to prevent it from being run a 2nd time).
2) Finish off the initialization from the InitInstance() function in the CWinApp derived class.
Do these seem good options?
Out of curiosity how could it be done if was using doc/view?
|
|
|
|
|
Robin Imrie wrote:
Out of curiosity how could it be done if was using doc/view?
Probably in the CView::OnUpdate() method.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How to delete a directory ?
Thanks...
|
|
|
|
|
you can use SHFileOperation() function to delete a directory
nave
|
|
|
|
|
_rmdir(),RemoveDirectory()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi
i want to send a message to multiple windows,those window have same caption name. is there any way to send a perticular message to those windows only.firstly i wanted to use FindWindow then using their handle i will send message, but all those window have same caption. Can any one help me please.
tunu
|
|
|
|
|
aaaan wrote: I want to send a message to multiple windows,those window have same caption name. is there any way to send a perticular message to those windows only.firstly i wanted to use FindWindow then using their handle i will send message, but all those window have same caption. Can any one help me please.
First register a window message for your application using RegisterWindowMessage and provide a handler for this message, then broadcast this message.
This message will only be processed by your application since the Message id will be unique for your application.
|
|
|
|
|
i'm not sure at all the OP wants to send a own defined message.
it seems more that he is trying to send an already defined message to some windows the OP don't own at all
|
|
|
|
|
toxcct wrote: i'm not sure at all the OP wants to send a own defined message.
My bad.
|
|
|
|