will if (!handle to window1 && !handle to window2) work?

Started by
3 comments, last by PPCThug 22 years, 2 months ago
the idea was to check if both windows where closed and if so PostQuitMessage(0); Please be patient I''m a newbie! the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Bloodshed Dev-C++ 4.9.8.0 Mingw DX 9.0a DX SDK 6.1win2k#define WIN32_LEAN_AND_MEANthe Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.mechwarrior 2 mercenaries, 4 particle projection cannons, thug chassis
Advertisement
Yes.

&& will evaluate to true if all the conditions are met. || will evaluate to true if ANY of the conditions are met. I believe, with &&, you can count on the order of execution being left to right. So, you can do things like:

    char *sptr;...if (sptr != 0 && *sptr == 't')    


If sptr is 0, you certainly don't want to do *sptr. But, checking first for sptr != 0 allows you to safely deference sptr in a single condition like this.

Edited by - OldGuy on January 31, 2002 6:54:45 PM
The operators && || and , are always evaluated left to right, unless you overload them, in which case it is implementation-defined, being directly dependent on the order of evaluation of function parameters.

Note also, that && and || do ''shortcut evaluation''.
That is, once the value of the expression is determined, the remaining terms won''t be evaluated.

So once you have a ''false'' argument to && or a ''true'' argument to ||, the result is decided, and the remaining terms are ignored.

Which enables you to write things like
if (ptr!=NULL && *ptr!=0) 
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
If I understand you, this won''t work to check if the window is still ''alive''. Rather than just check the HWND values, you want to call IsWindow() to check that, although you can still put them into a single if statement:

if( !IsWindow( hwnd1 ) && !IsWindow( hwnd2 ) )
... // Both windows are dead


--
Eric
-- Eric
thanks for all the help!


the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Bloodshed Dev-C++ 4.9.8.0 Mingw DX 9.0a DX SDK 6.1win2k#define WIN32_LEAN_AND_MEANthe Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.mechwarrior 2 mercenaries, 4 particle projection cannons, thug chassis

This topic is closed to new replies.

Advertisement