Hello, I was wondering if there was a way to have a program prompt this before quiting:
1 2
if (MessageBox (hWnd, "You sure you want to quit?", "Message", MB_YESNO) == 6) return 0;
else {do what ever to keep program open}
I tried a few things with the window proc, and after the message loop, nothing worked for alt + f4 or closing the window with the X button, only with the escape key (I added a feature to close the program when I press escape).
It is better to use the ID than the actual value - although IDYES has the value 6, it is possible
for Microsoft to rearrange the values in the future. Ok, it is unlikely to happen, but
if they did change the values your code would be broken if you use the value 6 because that might not be IDYES anymore.
Well spoken Kiana! I hate it when people post the "sum += 13" sure we know what it does but that looks confusing to anyone trying to learn "sum = sum + 13" makes a lot more sense...in C++, just because you can get away with it and it works, it doesn't mean you've made it any easier for you, when you open up that program months later and nothing in it makes sense!
Id be willing to see some tests done firedraco, not trying to be an ass or anything...it is easier because you write less but it ends in rather bizarre looking code sum += 13 llooks confusing because anyone could mistake it for sum + sum = 13; were as sum =+ could be read as sum = sum + 13; how about mov eax, sum | add eax, 13 | mov sum, eax ..... id be curious to know which is faster sum += 13 or adding 13 to the value of sum in assembler...perhaps I should run some experiments :)
I always assumed these two symbol operators were designed they way they are
based on operator precedence - the = operator has lower priority than all the other maths symbol
so the operators are written as:
+=, *=, -= and so forth.
@mrfaosfx: I read sum += 13 the same as sum = sum + 13. If I am reading C++ and there is one way used, and not the other, then I can still understand what it is saying, just like two works in English that mean the same thing.