|
I don't know of a simple test, but you can use floor(), ceil() or fmod() to help. e.g.
if (f == floor(f)) {}<br />
<br />
if (f == ceil(f)) {}<br />
<br />
float intPart;<br />
if (fmod(f,&intPart) == 0) {}
I don't know what is most efficient if speed is important.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Hi,
My project is written in C++ using MFC and VC++ .NET 2005.
My problem is this:
When I run my program on any computer that has .NET 2005, it seems to work fine. However, if I move it over to a computer without any IDE (like a fresh WinXP SP2 install) it crashes whenever I try to call an application-specific dll file.
So it's like this, let's say a part of my application uses a dll file called utils.dll. Utils.dll normally is used to start up a "utility" thread which accesses a database that contains various useful information. Normally the application runs fine, however, if I move it to another computer (along with all of the dlls I can think of that it might possibly need) it will crash as soon as I try to call a function from utils.dll (utils.dll IS in the folder with the program where it should be, and I know it's loading because I can still call static functions from it).
Any idea of what might be happening?
I have all the dlls included that I could think of (mfc80.dll, msvcr80.dll, etc etc) but I feel like maybe I'm missing one somehow and I don't know how to tell what it could be.
Sorry if I made this sound overly complicated, but it's a very irritating problem.
Thanks!
KR
|
|
|
|
|
I am using installsheild dev studio 9. I have a install program that looks for a serial number when you enter it in a blank field. At the time of purchase, our customers receive the serial and need to enter it when they install. The problem is that the serial number has dashes and 25% of our customers cant figure out to use the dashes.
I came up with the Idea of (same as windows vista style) of having the program automatically insert the dash or have 3 boxes that automatically change focus. How is this done??
|
|
|
|
|
Trey5498 wrote: I came up with the Idea of (same as windows vista style) of having the program automatically insert the dash or have 3 boxes that automatically change focus. How is this done??
For the former, check out masked edit controls.
For the latter, handle the EN_CHANGE message for each edit control. Each time that notification is received, check to see how many characters are in the control. If three, send the window a WM_NEXTDLGCTL message.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi, this one is for the MFC aces:
I got a rather complicated CListCtrl (owner draw and owner data) with a 100 entries, though I don't think that should matter for this issue.
Calling SetItemState(...) takes me about 30 ms on my rather new PC (maybe half the time in release mode), when it has to alter an item state. When the item state stays the same, it returns instantly.
Calling SetItemState(-1, ...) takes about the same time as any other SetItemState(...) call, even if it alters all items.
It doesn't really make a difference if the ListCtrl is SW_SHOW or SW_HIDDEN and setting ListCtrl.SetRedraw(false) doesn't help either.
When just a couple of items are changed at the same time, I get a noticeable break. Has anybody experienced something similar or knows a work-around? (I'm just asking before starting to write test cases)
Thanks in advance,
Andy
|
|
|
|
|
Doc Lobster wrote: I got a rather complicated CListCtrl (owner draw and owner data) with a 100 entries, though I don't think that should matter for this issue.
Calling SetItemState(...) takes me about 30 ms on my rather new PC (maybe half the time in release mode), when it has to alter an item state. When the item state stays the same, it returns instantly.
It sounds like the list control is sending messages to announce the state change before it returns. I'm not sure there is any way to disable that.
Nathan
|
|
|
|
|
Doc Lobster wrote: Calling SetItemState(-1, ...) takes about the same time as any other SetItemState(...) call, even if it alters all items.
I think this is a good hint.
(Un)fortunately 'debugging' is your only friend.
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.
|
|
|
|
|
Hi all,
I am trying to display a char string that contains following character: " (one double quote).
If I write:
char * c = " some string " ";
Now you see the problem I encounter, The second quote is taken as end of the string. But I want it to be displayed inside the string. So, how can I manage to display: some string "
Thanks !
|
|
|
|
|
You use the escape character "\":
char* c = " some string \" ";
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
|
Hi!
I run a simulation program as a child from another application. The program is a bit time consuming, so, as a user-feedback, I want the names of the output-files that are generated to be listed in a text-box, as the simulations are carried out. The child-program should in other words just display the dialog with the text-box, perform the simulations, and for each one add a file-name to the text box, and finally close the dialog and terminate after the last one. Whithout the need to click any buttons.
My question is "where do I put the call to the simulation function? Placing it at the end of the OnInitDialog-function makes the dialog show up first at the very end of the last siimulation.
maladuk
|
|
|
|
|
Without using thread you can:
(1) Post a user defined message to your dialog at the end of the InitDialog method and then, in the message handler, call the simulation function (that has also to periodically update your 'status textbox').
(2) Use, for the same purpose, a one-shot timer.
(3) ... (at the moment no further ideas)
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.
|
|
|
|
|
maladuk wrote: I run a simulation program as a child from another application. The program is a bit time consuming, so, as a user-feedback, I want the names of the output-files that are generated to be listed in a text-box, as the simulations are carried out.
If the child process is printing the names of those files, see here and here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I want to write a console application with WinMain, i.e. WIN32 APP but without any windows.
I want it to have a while cycle in the main func doing something and the program to exit gracefully when Windows shuts down. And my problem is I do not know how to get system information - if windows is shutting down or restarting. If I do not exit the cycle the system will hang waiting for my program to finish. And as I do not want to run it as a service there is no way to catch the messages coming from the OS because they are sent either to services or Windows Apps. Can you help me ?
modified 7-Mar-17 16:42pm.
|
|
|
|
|
You could try creating one Window but make it invisible. Not pretty but even Microsoft themselves have been known to resort to this at times. I'm sure WMI could also be used to get you the information you want but I don't knw any more about it than that I'm afraid.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
U could handle WM_ENDSESSION .
Come online at:-
jubinc@skype
|
|
|
|
|
Without a window, how are you going to respond to the WM_QUERYENDSESSION or WM_ENDSESSION message?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You have a hidden window. It's a common technique. If you use Spy you'll find a number of such windows.
Steve
|
|
|
|
|
I know that, but Daniel's requirement was, "without any windows."
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Have your application be a window - hidden and with no size.
This way, you can catch the relevant messages.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hi Experts,
How to get Log of a value with respect base of 2.
Thanx
|
|
|
|
|
log<sub>2</sub>(x)=log<sub>e</sub>(x)/log<sub>e</sub>(2)
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.
|
|
|
|
|
Binary logarithm.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi Experts,
How can I read a byte in unsigned variable. Because this value may be nagetive.
I tried like this
<br />
short signed int m_nOneByte=0;<br />
memcpy(&m_nOneByte,btBuffer+0x40,1);<br />
Hex value is 0xf6 which is -10.But it is dispalying 246.
|
|
|
|
|
pther wrote: How can I read a byte in unsigned variable. Because this value may be nagetive.
Sorry, you seem confused: Bytes *ARE* unsigned types. Range 0-255.
0xf6 is 246. It is NOT negative.
int (the signed is the default) can hold all positive values a byte can have.
Are you perchance missing the char -type?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|