|
Why have you put the code in the update handler for FileExit?
You need to put it into the update handler for the menu item Start in the options menu.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I know that, i was testing if my Exit menu item will change it's caption. It was a test app, which does nothing. Just a menu with File>Exit. Clicking the Exit does not execute any function. So i just wanted to test if the caption changes, but it doesnt! Why?
|
|
|
|
|
I tried the samething with SDI app. And it works. But it doesnt in my dialog based app. Anyone?
|
|
|
|
|
I have a wizard97 application i want to make the next back etc. buttons more jazzy how can i subclass them or is there another way
thanks a bunch already
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
http://www.mastishk.com
|
|
|
|
|
|
Hi All,
I have Win 2000 and VS 6.
We have developed an application which is suppose to run on all Windows OS. Application is devided in two parts mainly and those two parts communicate with each other over the network.
But when it comes to WinXP SP2 it fails because of the Firewall.
So we decided to change the firewall settings programmatically.
I cut the CD from image version of WinXP SP2 Platform SDK available at
http://www.microsoft.com/downloads/...&displaylang=en
After installing the above Platform SDK I also registred the PSDK Directories with VS by clicking on Start-->Programmes-->Microsoft Platform SDK for Windows XP SP2-->Visual Studio Registration-->Register PSDK directories with Visual Studio.
After that when I am trying to rebuild my VC++ apllication it gives me following two compilation errors.
1. C:\Program Files\Microsoft Platform SDK for Windows XP SP2\include\objidl.idl(2554) : error MIDL2025 : syntax error : expecting a type specification near "ULONG_PTR"
2. C:\Program Files\Microsoft Platform SDK for Windows XP SP2\include\objidl.idl(2554) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
What are the settings which I should take care? I even read 'Read Me' and Getting Started documents coming with the PSDK. But I could not solve it. These documents basically suggest everythign for compiling using .mak files. I am not using .mak.
I have also made it sure that SDK include, lib and bin directories are list before Visual C++ include, lib and bin directories (from toos->options->directories in the IDE).
How to solve this? Any idea?
I will appreciate your help in this regard.
--------------
Vaibhav...
|
|
|
|
|
Hi
I have one question regarding on how to make my program run faster.
I use std::vector in my app, and I often do something like:
for(int ii = 0; ii < a_vector.size(); ++ii)
{
... codes here
}
I am wondering, will storing the a_vector's size before the loop and using it instead of calling a_vector.size() method on each iteration provide better performance?
Thanks!
|
|
|
|
|
I assume it will, since you don't have to make a function call. I also assume you're not changing the size of a_vector within the loop.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I would use a variable.
For further reading:
http://www.codeproject.com/tips/optimizationenemy.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Possibly, but probably not. The size() method is an inline method that simply returns the value of a member variable, so if your compiler optimises correctly it should boil down to a simple comparison with a indirect-indexed value, just the same as if it was a local variable you were comparing against. However, it's probably a good idea to store the size locally anyway, just in case the compiler doesn't optimise it for some reason, and to make it more obvious to humans that you want the code to run as fast as possible.
Obviously, if the size of the vector changes inside the loop, then you'll have to either call size() each time or update your local variable every time you do something that changes the size of the vector (add, delete etc...)
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Why not create two small functions and test it? Remember to run in release-mode.
|
|
|
|
|
I would compare the assembly when compiled in release mode.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I would just time the results - if the differences were not big enough to make a mark in - say - 10 000 iterations, I wouldn't even bother optimize it
|
|
|
|
|
Fair point. Most times optimization of such loops is wasted effort IMO.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Your question implies that you are doing,
for (int ii = 0; ii < a_vector.size (); ++ii )
{
a_vector [ ii ].DoSomething () ;
}
You may find that operator [] on vector is more expensive than size. Especially given that in many cases an interator resolves to a plain old pointer, so both the dereference and the increment are cheap.
Perhaps you could measure your way and also,
A_VECTOR::iterator it ;
A_VECTOR::iterator itE = a_vector.end () ;
for ( it = a_vector.begin () ; it != itE; ++it )
{
(*it).DoSomething () ;
}
But it's cleanest by far to write,
class A_TYPE { ... } ;
vector<A_TYPE> a_vector ;
for_each ( a_vector.begin (), a_vector.end (), mem_fun_ref ( &A_TYPE::DoSomething )) ;
or some variant of function, functor etc that suits your code. I think this is probably potentially the fastest since the compiler has all the information to inline everything.
Paul
|
|
|
|
|
C++ in "Hardware structures" stand point question: Does the ALU handle any floading points operations? or will the processor let the FPU handles them?
I mean, any floading point operation, both simple and complex ones.
Thanks.
|
|
|
|
|
If the CPU has an FPU, then the FPU will handle all floating-point operations, as long as the compiler uses the correct instructions. If it emulates floating point in software, then the FPU will not be used. Also, if the FPU doesn't support a certain operation, it will have to be emulated in software (which, incidentally, will probably use other FPU instructions).
There are very few cases when a CPU's main ALU actually handles floating-point operations - floating-point DSP processors are the only ones I can think of.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I have a property page that is used multiple times in a wizard with slight variations each time. Therefore for each instance of the page I want to show/not show various controls. How do I do that? I thought I could just make a control variable and then do something like m_nListBox1.SetVisible or something or other. How do I dynamically make controls visible and invisible? I am missing something obvious and it must be because I got up far too early this morning.
|
|
|
|
|
use CWnd::ShowWindow function to show or hide them.
|
|
|
|
|
Tried this in OnInitDialog and OnSetActive. Causes and assertion both times.
|
|
|
|
|
ShowWindow is THE API to use to show and hide windows, if your window does not exist yet, the function will assert.
Try making sure that the window you are calling this function on is valid before you call this function.
an exmaple of this would be
Page::OnInitDialog();
{
BOOL ret = CPropertyPage::OnInitDialog();
CWnd *pWnd = GetDlgItem(IDC_MY_WINDOW);
if (!pWnd || !::IsWindow(pWnd->GetSafeHwnd())
{
ASSERT(FALSE);
}
else
pWnd->ShowWindow(SW_HIDE); // or whatever you want to do with it.
}
Did you use classwizard to generate control variables for your window objects?
/yawar
|
|
|
|
|
Hi,
I have an over-ridden handler CMyDialog::OnNcLButtonDown() which detects if the user selects the title bar of my dialog. The user then drags the dialog and releases the mouse button. How can my program know when the mouse button has been released? I have tried over-riding the CMyDialog::OnNcLButtonDown() function but it does not work.
|
|
|
|
|
Anonymous wrote:
I have tried over-riding the CMyDialog::OnNcLButtonDown() function but it does not work.
Sorry. I mean to say the CMyDialog::OnNcLButtonUp() function
|
|
|
|
|
try overloading WM_NCHITTEST message, the code will look something like this
UINT YourClass::OnNcHitTest(CPoint point) <br />
{ <br />
int ret = YourParentCwndBasedClass::OnNcHitTest(point);<br />
if (ret == HTCAPTION)<br />
{<br />
if (GetAsyncKeyState(VK_LBUTTON) < 0)<br />
{<br />
if (!mbLButtonDown)<br />
{<br />
TRACE("\nDown");<br />
mbLButtonDown = true;<br />
}<br />
}<br />
else<br />
{<br />
if (mbLButtonDown)<br />
{<br />
TRACE("\nUp");<br />
mbLButtonDown = false;<br />
}<br />
}<br />
}<br />
return ret;<br />
}
where mbLButtonDown would be a bool member of your class and would need to be initialized as false when constructing your window.
There might be some other way to do this too, this was just a quick thing that came to my mind.
HTH,
/yawar
|
|
|
|
|
I said "try overloading".. that was not right, I meant "try writing message handler for"...
|
|
|
|