|
In my experience, this is not true. Typing '=' instead of '==' is as often a real typing error as it is a coding oversight. I even go so far as to always put the constants on the left hand side in all comparisons, so I don't forget to do so on equality operators. I never ever had a '='/'==' error since I started using this practice some time around 1990. (I did fix quite a few such errors caused by others though, and I can tell you that kind of work is not pretty!)
|
|
|
|
|
Yes that's true. I've had some serious problems in algorithms because of this == typo. That killed me for days. I think all these recent compilers take strain to point out this type of typos. But older ones just wait for you to make one and kill you. Eversince I got my fingers burnt on this, I put the constants on the left for ever! unless I'm typing something for fun.
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
_Josh_ wrote: I have a colleague working with me at the moment and he loves to do this (NULL
first) and I hate it.
If I was working somewhere where that was the most significant problem in the code base then I would be ecstatic.
|
|
|
|
|
Over the past 20+ years, yes, this has saved me a couple dozen times. It's so much faster to just quickly fix a compiler error than hunting down some weird bug that can express itself in all kind of ways, but usually nowhere near the context of the actual source of the problem.
And no, there is no other reason that I am aware of. I don't need any.
|
|
|
|
|
Hi,
I did a setup to install my app, but I need add the activeX (msflxgrd) to show a grid.
How can I add the active X to my project??
Thank you.
The project is in Visual C++, mfc.
|
|
|
|
|
Do you want to add the flexgrid to your dialog box??
Every new day is another chance to change your life.
|
|
|
|
|
Nooo, I have added the msflegrid in my dialog, but now, I did a setup to be able to install my app in any pc, and I need add the activeX here.
If I run the setup I get this:
Can not find source file 'C: \ Windows \ System32 \ msflxgrd.ocx' for file 'msflxgrd.ocx' located in '[TARGETDIR]', the file may be missing or blocked.
I followed this page:
http://www.simple-talk.com/dotnet/visual-studio/getting-started-with-setup-projects/[^]
modified 8-Nov-11 4:22am.
|
|
|
|
|
Include the required "MSFlxgrd.OCX" file into your Setup Project. Copy that file to either system folder or to your application folder. Register the ActiveX from the setup project.
|
|
|
|
|
Check Here[^]
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
In my huge, multithreaded codebase, at one place it use setTimer like
in a class's OnStart() function
::SetTimer(this->m_hWnd, 2020, 60000 ,NULL);
in OnStop() function
::KillTimer(this->m_hWnd, 2020);
So right now SetTimer is set for 1 minute but my requirement is that instead of this constant value, i want to change that value based upon clock time. Say it works as it works now for first 15 minute (checking after every minute) then it start checking every 15 minute, if still its unable to service then after 1 hour change it to every 30 minute.
Can somebody please send me sample callback function that implements the logic i mentioned?
|
|
|
|
|
Why not simply kill the old timer and start a new one when you want to change the interval? It seems to me that you are making the determination of the new interval during processing of the old timer going off so it's easy to reset the time to the next timer event.
Now personally, I wouldn't do it this way, especially if the application is already threaded. I use a thread with a sleep interval that takes me to the next event. In fact, I use a "WaitForSingleObject()" on an event flag with the timer interval as the timeout. This allows for another thread to "wake" the timer thread when some extraordinary event takes place, one that could possible affect when the next interval is supposed to fire.
|
|
|
|
|
Nothing wrong with using timer, but for a changing interval, your suggestion is great (specially the part about using the waitforsingleobject over plain sleep). +5
|
|
|
|
|
Firstly thanks a lot for your reply. I finally reached the timeline, did exactly what you mentioned like killing old timer and starting a new one based upon different conditions so the timer keep on changing the interval. Now the requirement got changed so that i need to continue using the old timer to do task A and invoking the second timer (which needs to be updated say every few minutes) but the first timer is getting invoded every 20 seconds and its independent upon the 2nd timer.
So i was wondering like if when the first timer got fired and invoke the OnTimer(), can i create a new timer(timerB) in the OnTimer() event, kill new timerB and reset new timerB all through the OnTimer() Event. It look like a mess right now since after every few seconds the OnTimer() is getting fired & most of the application logic is written itself in OnTimer Event but the same things i need to invoke/update using 2nd timer which has a big time interval. So what you suggest in this case? like do i need to create Ontimer2()Events for the 2nd timer.
Second solution is the ideal one in my particular case but i've few design constraints that prohibit me to create new threads.
|
|
|
|
|
There is no such thing as "Ontime2()" in the framework, there is only "OnTimer(UINT_PTR nIDEvent)".
Nothing prevents you from having two separate timer IDs
m_TimerID1 = SetTimer(1, TimerValue1, NULL);
m_TimerID2 = SetTimer(2, TimerValue2, NULL);
They will both go through the same "OnTimer()" function, you will be passed the event id so you can test which one went off and act appropriately.
There are probably other ways of handling this kind of situation, including having a "lowest common denominator" interval and managing your own countdown for event A or event B. As long as it doesn't get any crazier, two timers should work out ok.
|
|
|
|
|
Hi,
Just to understand the use of cross casting by practice,
Could any person give me a practical example of using a cross casting ?
Thx.
|
|
|
|
|
I notice you have given a practical example of cross-posting; please don't. Select one forum for your question and use that only.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
Sorry, but that was not a good example! The example you are talking about is a acadimical research one. I've said a practical example, used in professionel sosftware development context.
I notice you that we can't evaluate a response if we can't see what the question is about!
Best regards.
|
|
|
|
|
You missed my point, I suggested that you do not post your question in multiple forums. Read the posting guidelines for clarification.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I thought that it would be possible to discuss this subject in a forum.
The Question was just dedicated for answers not discussions.
It's Ok, I'll delete it from here.
|
|
|
|
|
Hi all,
i am working on visual studio 2010 and i am making a dialog based application.
In a function i have made a unsigned char array like this
unsigned char buffer [ 524600 ];
and a small array of unsigned char buffer1 [ 628 ];
now i need a bigger array in the same function to store something else, but when i make a array bigger or equal to buffer it gives me a stack overflow error and taking me to this line
cs20:
sub eax, _PAGESIZE_ ; decrease by PAGESIZE
test dword ptr [eax],eax ; probe page.
jmp short cs10
i am not getting what problem i am facing??
can anybody help me....
|
|
|
|
|
Well, your stack is only so big and if you are declaring stack based (local variable) arrays of that size, it's no wonder you got a stack overflow. And while it is possible to enlarge the stack (Project Properties, Stack Size[^]), I wouldn't recommend that.
Instead, you should use new or malloc to dynamically create the array from the larger "heap" pool. You can look up those functions on MSDN if you are unfamiliar with them.
(PS, if you new something, remember to delete it when you are done with it, otherwize you will have a memory leak and eventually you will not be able to repeat the dynamic allocation. If you use malloc instead, you will need to use free to return the memory to the pool.)
|
|
|
|
|
Chuck O'Toole wrote: it's no wonder you got a stack overflow
Hmm. One could argue that a system with gigabytes of memory, a hardware memory management unit, and an OS that is based on virtual memory, still has a rather artificial limit on stack size; with a couple different implementation choices the stack could have been made to grow automatically as need be, from a default size (say 1MB) to whatever is required by the app.
|
|
|
|
|
Yep, spot on. All arrays should go on the heap. It is FAR FAR safer that way.
==============================
Nothing to say.
|
|
|
|
|
+5, but I wonder why one would need arrays that large...
|
|
|
|